mobx-state-tree
Advanced tools
Comparing version 2.2.0 to 3.0.0-beta.2
@@ -7,5 +7,5 @@ import { IObservableArray, ObservableMap } from "mobx"; | ||
* @param {IStateTreeNode} object | ||
* @returns {IType<S, T>} | ||
* @returns {IAnyType} | ||
*/ | ||
export declare function getType<S, T>(object: IStateTreeNode): IType<S, T>; | ||
export declare function getType<C, S, T>(object: IStateTreeNode): IType<C, S, T>; | ||
/** | ||
@@ -23,5 +23,5 @@ * Returns the _declared_ type of the given sub property of an object, array or map. | ||
* @param {string} child | ||
* @returns {IType<any, any>} | ||
* @returns {IAnyType} | ||
*/ | ||
export declare function getChildType(object: IStateTreeNode, child: string): IType<any, any>; | ||
export declare function getChildType(object: IStateTreeNode, child: string): IAnyType; | ||
/** | ||
@@ -35,3 +35,2 @@ * Registers a function that will be invoked for each mutation that is applied to the provided model instance, or to any of its children. | ||
* @param {(patch: IJsonPatch, reversePatch) => void} callback the callback that is invoked for each patch. The reversePatch is a patch that would actually undo the emitted patch | ||
* @param {includeOldValue} boolean if oldValue is included in the patches, they can be inverted. However patches will become much bigger and might not be suitable for efficient transport | ||
* @returns {IDisposer} function to remove the listener | ||
@@ -56,3 +55,3 @@ */ | ||
*/ | ||
export declare function applyPatch(target: IStateTreeNode, patch: IJsonPatch | IJsonPatch[]): void; | ||
export declare function applyPatch(target: IStateTreeNode, patch: IJsonPatch | ReadonlyArray<IJsonPatch>): void; | ||
export interface IPatchRecorder { | ||
@@ -156,8 +155,8 @@ patches: ReadonlyArray<IJsonPatch>; | ||
* @param {Object} target | ||
* @param {IType<any, any>} type | ||
* @param {IAnyType} type | ||
* @returns {boolean} | ||
*/ | ||
export declare function hasParentOfType(target: IStateTreeNode, type: IType<any, any>): boolean; | ||
export declare function getParentOfType(target: IStateTreeNode, type: IType<any, any>): any & IStateTreeNode; | ||
export declare function getParentOfType<S, T>(target: IStateTreeNode, type: IType<S, T>): T & IStateTreeNode; | ||
export declare function hasParentOfType(target: IStateTreeNode, type: IAnyType): boolean; | ||
export declare function getParentOfType(target: IStateTreeNode, type: IAnyType): any & IStateTreeNode; | ||
export declare function getParentOfType<S, T>(target: IStateTreeNode, type: IAnyType): T & IStateTreeNode; | ||
export declare function getRoot(target: IStateTreeNode): any & IStateTreeNode; | ||
@@ -204,3 +203,3 @@ export declare function getRoot<T>(target: IStateTreeNode): T & IStateTreeNode; | ||
* @export | ||
* @param {IType<any, any>} type | ||
* @param {IAnyType} type | ||
* @param {IStateTreeNode} target | ||
@@ -210,5 +209,6 @@ * @param {(string | number)} identifier | ||
*/ | ||
export declare function resolveIdentifier(type: IType<any, any>, target: IStateTreeNode, identifier: string | number): any; | ||
export declare function resolveIdentifier(type: IAnyType, target: IStateTreeNode, identifier: string | number): any; | ||
/** | ||
* Returns the identifier of the target node. | ||
* This is the *string normalized* identifier, which might not match the type of the identifier attribute | ||
* | ||
@@ -300,2 +300,5 @@ * @export | ||
* | ||
* Please note that in child nodes access to the root is only possible | ||
* once the `afterAttach` hook has fired | ||
* | ||
* Returns an empty environment if the tree wasn't initialized with an environment | ||
@@ -315,3 +318,3 @@ * | ||
properties: { | ||
[K: string]: IType<any, any>; | ||
[K: string]: IAnyType; | ||
}; | ||
@@ -330,2 +333,2 @@ actions: string[]; | ||
export declare function getMembers(target: IStateTreeNode): IModelReflectionData; | ||
import { IStateTreeNode, IJsonPatch, IDisposer, ISnapshottable, IType } from "../internal"; | ||
import { IStateTreeNode, IJsonPatch, IDisposer, ISnapshottable, IType, IAnyType } from "../internal"; |
import { INode, ObjectNode, ScalarNode, IType } from "../../internal"; | ||
export declare function createNode<S, T>(type: IType<S, T>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, createNewInstance?: (initialValue: any) => T, finalizeNewInstance?: (node: INode, initialValue: any) => void): ObjectNode | ScalarNode; | ||
export declare function createNode<C, S, T>(type: IType<C, S, T>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, createNewInstance?: (initialValue: any) => T, finalizeNewInstance?: (node: INode, childNodes?: any) => void): ObjectNode | ScalarNode; | ||
export declare function isNode(value: any): value is INode; |
@@ -1,2 +0,2 @@ | ||
import { IType, ObjectNode } from "../../internal"; | ||
import { ObjectNode, IAnyType } from "../../internal"; | ||
export declare class IdentifierCache { | ||
@@ -9,3 +9,3 @@ private cache; | ||
splitCache(node: ObjectNode): IdentifierCache; | ||
resolve(type: IType<any, any>, identifier: string): ObjectNode | null; | ||
resolve(type: IAnyType, identifier: string): ObjectNode | null; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IType, ObjectNode } from "../../internal"; | ||
import { ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; | ||
export declare enum NodeLifeCycle { | ||
@@ -10,3 +10,3 @@ INITIALIZING = 0, | ||
export interface INode { | ||
readonly type: IType<any, any>; | ||
readonly type: IAnyType; | ||
readonly storedValue: any; | ||
@@ -30,3 +30,3 @@ readonly path: string; | ||
properties: { | ||
[name: string]: IType<any, any>; | ||
[name: string]: IAnyType; | ||
}; | ||
@@ -55,1 +55,2 @@ actions: Object; | ||
export declare function resolveNodeByPathParts(base: ObjectNode, pathParts: string[], failIfResolveFails: boolean): INode | undefined; | ||
export declare function convertChildNodesToArray(childNodes: IChildNodesMap | null): INode[]; |
@@ -1,32 +0,59 @@ | ||
import { INode, IJsonPatch, IReversibleJsonPatch, IType, IDisposer, IMiddleware, IMiddlewareHandler, NodeLifeCycle, IdentifierCache } from "../../internal"; | ||
import { IAtom } from "mobx"; | ||
import { INode, IJsonPatch, IReversibleJsonPatch, IDisposer, IMiddleware, IMiddlewareHandler, NodeLifeCycle, IdentifierCache, IAnyType } from "../../internal"; | ||
export declare type LivelynessMode = "warn" | "error" | "ignore"; | ||
/** | ||
* Defines what MST should do when running into reads / writes to objects that have died. | ||
* By default it will print a warning. | ||
* Use te `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place | ||
* | ||
* Possible values: `"warn"`, `"error"` and `"ignore"` | ||
* | ||
* @export | ||
* @param {LivelynessMode} mode | ||
*/ | ||
export declare function setLivelynessChecking(mode: LivelynessMode): void; | ||
export interface IChildNodesMap { | ||
[key: string]: INode; | ||
} | ||
export declare class ObjectNode implements INode { | ||
nodeId: number; | ||
readonly type: IType<any, any>; | ||
readonly storedValue: any; | ||
readonly type: IAnyType; | ||
readonly identifierAttribute: string | undefined; | ||
readonly identifier: string | null; | ||
subpathAtom: IAtom; | ||
subpath: string; | ||
protected _parent: ObjectNode | null; | ||
_isRunningAction: boolean; | ||
escapedSubpath: string; | ||
parent: ObjectNode | null; | ||
state: NodeLifeCycle; | ||
storedValue: any; | ||
identifierCache: IdentifierCache | undefined; | ||
isProtectionEnabled: boolean; | ||
identifierAttribute: string | undefined; | ||
middlewares: IMiddleware[] | null; | ||
applyPatches(patches: IJsonPatch[]): void; | ||
applySnapshot(snapshot: any): void; | ||
_autoUnbox: boolean; | ||
_environment: any; | ||
protected _autoUnbox: boolean; | ||
state: NodeLifeCycle; | ||
middlewares: IMiddleware[] | null; | ||
private snapshotSubscribers; | ||
private patchSubscribers; | ||
private disposers; | ||
applyPatches: (patches: IJsonPatch[]) => void; | ||
applySnapshot: (snapshot: any) => void; | ||
constructor(type: IType<any, any>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, storedValue: any, canAttachTreeNode: boolean, finalizeNewInstance?: (node: INode, initialValue: any) => void); | ||
_isRunningAction: boolean; | ||
_hasSnapshotReaction: boolean; | ||
private _disposers; | ||
private _patchSubscribers; | ||
private _snapshotSubscribers; | ||
private _observableInstanceCreated; | ||
private _childNodes; | ||
private _initialSnapshot; | ||
private _createNewInstance; | ||
private _finalizeNewInstance; | ||
constructor(type: IAnyType, parent: ObjectNode | null, subpath: string, environment: any, initialSnapshot: any, createNewInstance: (initialValue: any) => any, finalizeNewInstance: (node: INode, initialValue: any) => void); | ||
private _createObservableInstance(); | ||
readonly path: string; | ||
readonly root: ObjectNode; | ||
readonly isRoot: boolean; | ||
readonly parent: ObjectNode | null; | ||
readonly root: ObjectNode; | ||
setParent(newParent: ObjectNode | null, subpath?: string | null): void; | ||
fireHook(name: string): void; | ||
readonly value: any; | ||
private readonly _value; | ||
readonly snapshot: any; | ||
private _getActualSnapshot(); | ||
private _getInitialSnapshot(); | ||
isRunningAction(): boolean; | ||
readonly identifier: string | null; | ||
readonly isAlive: boolean; | ||
@@ -36,3 +63,3 @@ assertAlive(): void; | ||
getChildren(): ReadonlyArray<INode>; | ||
getChildType(key: string): IType<any, any>; | ||
getChildType(key: string): IAnyType; | ||
readonly isProtected: boolean; | ||
@@ -57,3 +84,3 @@ assertWritable(): void; | ||
applyPatchLocally(subpath: string, patch: IJsonPatch): void; | ||
private _invalidateComputed(prop); | ||
private _addSnapshotReaction(); | ||
} |
@@ -1,13 +0,12 @@ | ||
import { INode, IType, ObjectNode } from "../../internal"; | ||
import { INode, ObjectNode, IAnyType } from "../../internal"; | ||
export declare class ScalarNode implements INode { | ||
readonly type: IType<any, any>; | ||
readonly type: IAnyType; | ||
readonly storedValue: any; | ||
subpath: string; | ||
private readonly _parent; | ||
readonly _environment: any; | ||
readonly parent: ObjectNode | null; | ||
readonly subpath: string; | ||
private state; | ||
constructor(type: IType<any, any>, parent: ObjectNode | null, subpath: string, environment: any, initialValue: any, storedValue: any, canAttachTreeNode: boolean, finalizeNewInstance?: (node: INode, initialValue: any) => void); | ||
_environment: any; | ||
constructor(type: IAnyType, parent: ObjectNode | null, subpath: string, environment: any, initialSnapshot: any, createNewInstance: (initialValue: any) => any, finalizeNewInstance?: (node: INode, initialValue: any) => void); | ||
readonly path: string; | ||
readonly isRoot: boolean; | ||
readonly parent: ObjectNode | null; | ||
readonly root: ObjectNode; | ||
@@ -20,3 +19,2 @@ setParent(newParent: INode | null, subpath?: string | null): void; | ||
die(): void; | ||
private _invalidateComputed(prop); | ||
} |
@@ -1,5 +0,5 @@ | ||
import { IType } from "../../internal"; | ||
import { IAnyType } from "../../internal"; | ||
export interface IContextEntry { | ||
path: string; | ||
type?: IType<any, any>; | ||
type?: IAnyType; | ||
} | ||
@@ -14,8 +14,8 @@ export declare type IContext = IContextEntry[]; | ||
export declare function prettyPrintValue(value: any): string; | ||
export declare function getDefaultContext(type: IType<any, any>): IContext; | ||
export declare function getContextForPath(context: IContext, path: string, type?: IType<any, any>): IContext; | ||
export declare function getDefaultContext(type: IAnyType): IContext; | ||
export declare function getContextForPath(context: IContext, path: string, type?: IAnyType): IContext; | ||
export declare function typeCheckSuccess(): IValidationResult; | ||
export declare function typeCheckFailure(context: IContext, value: any, message?: string): IValidationResult; | ||
export declare function flattenTypeErrors(errors: IValidationResult[]): IValidationResult; | ||
export declare function typecheck(type: IType<any, any>, value: any): void; | ||
export declare function typecheck(type: IAnyType, value: any): void; | ||
/** | ||
@@ -28,5 +28,5 @@ * Run's the typechecker on the given type. | ||
* @export | ||
* @param {IType<any, any>} type | ||
* @param {IAnyType} type | ||
* @param {*} value | ||
*/ | ||
export declare function typecheckPublic(type: IType<any, any>, value: any): void; | ||
export declare function typecheckPublic(type: IAnyType, value: any): void; |
@@ -1,2 +0,2 @@ | ||
import { IContext, IValidationResult, INode, IStateTreeNode, IJsonPatch, ObjectNode } from "../../internal"; | ||
import { IContext, IValidationResult, INode, IStateTreeNode, IJsonPatch, ObjectNode, IChildNodesMap } from "../../internal"; | ||
export declare enum TypeFlags { | ||
@@ -23,8 +23,8 @@ String = 1, | ||
} | ||
export interface IType<S, T> { | ||
export interface IType<C, S, T> { | ||
name: string; | ||
flags: TypeFlags; | ||
is(thing: any): thing is S | T; | ||
is(thing: any): thing is C | S | T; | ||
validate(thing: any, context: IContext): IValidationResult; | ||
create(snapshot?: S, environment?: any): T; | ||
create(snapshot?: C, environment?: any): T; | ||
isType: boolean; | ||
@@ -34,27 +34,31 @@ describe(): string; | ||
SnapshotType: S; | ||
CreationType: C; | ||
instantiate(parent: INode | null, subpath: string, environment: any, initialValue?: any): INode; | ||
initializeChildNodes(node: INode, snapshot: any): IChildNodesMap | null; | ||
reconcile(current: INode, newValue: any): INode; | ||
getValue(node: INode): T; | ||
getSnapshot(node: INode, applyPostProcess?: boolean): S; | ||
applySnapshot(node: INode, snapshot: S): void; | ||
applySnapshot(node: INode, snapshot: C): void; | ||
applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void; | ||
getChildren(node: INode): ReadonlyArray<INode>; | ||
getChildNode(node: INode, key: string): INode; | ||
getChildType(key: string): IType<any, any>; | ||
getChildType(key: string): IAnyType; | ||
removeChild(node: INode, subpath: string): void; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
shouldAttachNode: boolean; | ||
} | ||
export interface ISimpleType<T> extends IType<T, T> { | ||
export declare type IAnyType = IType<any, any, any>; | ||
export interface ISimpleType<T> extends IType<T, T, T> { | ||
} | ||
export interface IComplexType<S, T> extends IType<S, T & IStateTreeNode> { | ||
create(snapshot?: S, environment?: any): T & { | ||
export interface IComplexType<C, S, T> extends IType<C, S, T & IStateTreeNode> { | ||
create(snapshot?: C, environment?: any): T & { | ||
toJSON?(): S; | ||
} & ISnapshottable<S>; | ||
} | ||
export declare abstract class ComplexType<S, T> implements IType<S, T> { | ||
export declare abstract class ComplexType<C, S, T> implements IType<C, S, T> { | ||
readonly isType: boolean; | ||
readonly name: string; | ||
constructor(name: string); | ||
create(snapshot?: S, environment?: any): any; | ||
create(snapshot?: C, environment?: any): any; | ||
initializeChildNodes(node: INode, snapshot: any): IChildNodesMap | null; | ||
abstract instantiate(parent: INode | null, subpath: string, environment: any, initialValue: any): INode; | ||
@@ -70,7 +74,7 @@ abstract flags: TypeFlags; | ||
abstract applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void; | ||
abstract getChildType(key: string): IType<any, any>; | ||
abstract getChildType(key: string): IAnyType; | ||
abstract removeChild(node: INode, subpath: string): void; | ||
abstract isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
abstract shouldAttachNode: boolean; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
validate(value: any, context: IContext): IValidationResult; | ||
@@ -81,4 +85,5 @@ is(value: any): value is S | T; | ||
readonly SnapshotType: S; | ||
readonly CreationType: C; | ||
} | ||
export declare abstract class Type<S, T> extends ComplexType<S, T> implements IType<S, T> { | ||
export declare abstract class Type<C, S, T> extends ComplexType<C, S, T> implements IType<C, S, T> { | ||
constructor(name: string); | ||
@@ -89,10 +94,10 @@ abstract instantiate(parent: INode | null, subpath: string, environment: any, initialValue: any): INode; | ||
getDefaultSnapshot(): undefined; | ||
applySnapshot(node: INode, snapshot: S): void; | ||
applySnapshot(node: INode, snapshot: C): void; | ||
applyPatchLocally(node: INode, subpath: string, patch: IJsonPatch): void; | ||
getChildren(node: INode): INode[]; | ||
getChildNode(node: INode, key: string): INode; | ||
getChildType(key: string): IType<any, any>; | ||
getChildType(key: string): IAnyType; | ||
reconcile(current: INode, newValue: any): INode; | ||
removeChild(node: INode, subpath: string): void; | ||
} | ||
export declare function isType(value: any): value is IType<any, any>; | ||
export declare function isType(value: any): value is IAnyType; |
import "./internal"; | ||
import { ISimpleType, IType, map, array, identifier, model, compose, reference, union, optional, literal, maybe, refinement, late, enumeration, custom } from "./internal"; | ||
import { ISimpleType, IType, map, array, model, compose, reference, union, optional, literal, maybe, refinement, frozen, late, enumeration, custom, maybeNull } from "./internal"; | ||
export declare const types: { | ||
@@ -13,2 +13,3 @@ enumeration: typeof enumeration; | ||
maybe: typeof maybe; | ||
maybeNull: typeof maybeNull; | ||
refinement: typeof refinement; | ||
@@ -18,7 +19,8 @@ string: ISimpleType<string>; | ||
number: ISimpleType<number>; | ||
Date: IType<number, Date>; | ||
Date: IType<number, number, Date>; | ||
map: typeof map; | ||
array: typeof array; | ||
frozen: ISimpleType<any>; | ||
identifier: typeof identifier; | ||
frozen: typeof frozen; | ||
identifier: IType<string, string, string>; | ||
identifierNumber: IType<number, number, number>; | ||
late: typeof late; | ||
@@ -28,3 +30,3 @@ undefined: ISimpleType<undefined>; | ||
}; | ||
export { IModelType, IExtendedObservableMap, IType, ISimpleType, IComplexType, ISnapshottable, Snapshot, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware } from "./internal"; | ||
export { IAnyType, IModelType, IMSTMap, IType, ISimpleType, IComplexType, ISnapshottable, typecheckPublic as typecheck, escapeJsonPath, unescapeJsonPath, joinJsonPath, splitJsonPath, IJsonPatch, decorate, addMiddleware, IMiddlewareEvent, IMiddlewareHandler, IMiddlewareEventType, process, isStateTreeNode, IStateTreeNode, flow, applyAction, onAction, IActionRecorder, ISerializedActionCall, recordActions, createActionTrackingMiddleware, setLivelynessChecking, LivelynessMode } from "./internal"; | ||
export * from "./core/mst-operations"; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],e):e(t.mobxStateTree=t.mobxStateTree||{},t.mobx)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}Ot(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]]);return n}function i(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function o(t){return F(t).type}function a(t,e){return F(t).onPatch(e)}function s(t,e){F(t).applyPatches(G(e))}function u(t,e){return F(t).applySnapshot(e)}function p(t){return F(t).root.storedValue}function c(t,e){var n=U(F(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=F(t);n.getChildren().forEach(function(t){M(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function f(t){return"object"==typeof t&&t&&!0===t.isType}function h(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(Q(r))return r;if(M(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!K(r)&&!Z(r))return y("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return y(""+t)}}function d(t,e){return e&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e}function y(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function v(t,n){e.runInAction(function(){G(n).forEach(function(e){return b(t,e)})})}function b(t,e){var n=c(t,e.path||"");if(!n)return J("Invalid action path: "+(e.path||""));var r=F(n);return"@APPLY_PATCHES"===e.name?s.call(null,n,e.args[0]):"@APPLY_SNAPSHOT"===e.name?u.call(null,n,e.args[0]):("function"!=typeof n[e.name]&&J("Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return d(r,t)}):[]))}function m(t,e,n){function r(n){if("action"===n.type&&n.id===n.rootId){var r=F(n.context);e({name:n.name,path:H(F(t),r),args:n.args.map(function(t,e){return h(r,n.name,e,t)})})}}return void 0===n&&(n=!1),P(t,n?function(t,e){var n=e(t);return r(t),n}:function(t,e){return r(t),e(t)})}function g(){return Mt++}function A(t,e){var n=F(t.context),r=n._isRunningAction,i=Ft;"action"===t.type&&n.assertAlive(),n._isRunningAction=!0,Ft=t;try{return j(n,t,e)}finally{Ft=i,n._isRunningAction=r}}function w(){return Ft||J("Not running an action!")}function V(t,e,n){var r=function(){var r=g();return A({type:"action",name:e,id:r,args:at(arguments),context:t,tree:p(t),rootId:Ft?Ft.rootId:r,parentId:Ft?Ft.id:0},n)};return r._isMSTAction=!0,r}function P(t,e,n){return void 0===n&&(n=!0),F(t).addMiddleWare(e,n)}function S(t,e,n){for(var r=n.$mst_middleware||$t,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function j(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){f=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,f=!1,h=function(){return c(t,n,u),s};return c&&p.includeHooks?h():c&&!p.includeHooks?Bt[t.name]?i(t):h():e.action(r).apply(null,t.args)}var o=S(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function T(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function N(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":M(t)?"<"+t+">":"`"+T(t)+"`"}function C(t){return t.length<280?t:t.substring(0,272)+"......"+t.substring(t.length-8)}function O(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map(function(t){return t.path}).filter(function(t){return t.length>0}).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=M(e)?"value of type "+F(e).type.name+":":Q(e)?"value":"snapshot",a=n&&M(e)&&n.is(F(e).snapshot);return""+i+o+" "+N(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?St(n)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function _(t,e,n){return t.concat([{path:e,type:n}])}function I(){return $t}function D(t,e,n){return[{context:t,value:e,message:n}]}function E(t){return t.reduce(function(t,e){return t.concat(e)},[])}function x(t,e){}function R(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&J("Error while converting "+C(N(e))+" to `"+t.name+"`:\n\n "+n.map(O).join("\n "))}function z(t,e,n,r,i,o,a){if(void 0===o&&(o=W),void 0===a&&(a=Y),M(i)){var s=i.$treenode;return s.isRoot||J("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+s.path+"'"),s.setParent(e,n),s}var u=o(i);if(t.shouldAttachNode){var p=new Et(t,e,n,r,i,u,t.shouldAttachNode,a);return p.finalizeCreation(),p}return new It(t,e,n,r,i,u,t.shouldAttachNode,a)}function k(t){return t instanceof It||t instanceof Et}function M(t){return!(!t||!t.$treenode)}function F(t){return M(t)?t.$treenode:J("Value "+t+" is no MST Node")}function L(){return F(this).snapshot}function H(t,e){t.root!==e.root&&J("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=vt(t.path),r=vt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Ht).join("/")+yt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),$(t,vt(e),n)}function $(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];{if(""!==o){if(".."===o){if(r=r.parent)continue}else{if("."===o||""===o)continue;if(r){if(r instanceof It)try{var a=r.value;M(a)&&(r=F(a))}catch(t){if(!n)return;throw t}if(r instanceof Et&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?J("Could not resolve '"+o+"' in path '"+(yt(e.slice(0,i))||"/")+"' while resolving '"+yt(e)+"'"):void 0}r=r.root}}return r}function J(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function W(t){return t}function Y(){}function Z(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function G(t){return t?Z(t)?t:[t]:$t}function B(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}function K(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function q(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function Q(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function X(t){return t}function tt(t){return t}function et(t){return"function"!=typeof t}function nt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function it(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function ot(t,e){return t.push(e),function(){it(t,e)}}function at(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function st(t){return ut(t.name,t)}function ut(t,e){var n=function(){function r(e,r,a){e.$mst_middleware=n.$mst_middleware,A({name:t,type:r,id:i,args:[a],tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},e)}var i=g(),o=w(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=f.next(t)},"flow_resume",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function c(t){var e;try{r(function(t){e=f.throw(t)},"flow_resume_error",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function l(t){if(!t.done)return t.value&&"function"==typeof t.value.then||J("Only promises can be yielded to `async`, got: "+t),t.value.then(p,c);setImmediate(function(){r(function(t){s(t)},"flow_return",t.value)})}var f,h=function(){f=e.apply(null,arguments),p(void 0)};h.$mst_middleware=n.$mst_middleware,A({name:t,type:"flow_spawn",id:i,args:at(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},h)})};return n}function pt(t){return"oldValue"in t||J("Patches without `oldValue` field cannot be inversed"),[ct(t),lt(t)]}function ct(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function lt(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function ft(t){return"number"==typeof t}function ht(t){return!0===ft(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function dt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function yt(t){return 0===t.length?"":"/"+t.map(ht).join("/")}function vt(t){var e=t.split("/").map(dt);return""===e[0]?e.slice(1):e}function bt(t){if(t||J("Map.put cannot be used to set empty values"),M(t)){var e=F(t);return this.set(""+e.identifier,e.value),this}if(q(t)){var n=F(this).type;return n.identifierMode===Zt.NO?J(Gt):n.identifierMode===Zt.YES?(this.set(""+t[n.identifierAttribute],t),this):(e=F(n.subType.create(t))).identifierAttribute?(this.set(""+e.value[e.identifierAttribute],e.value),this):J(Gt)}return J("Map.put can only be used to store complex values")}function mt(t,e,n,r,i){for(var o,a,s=!1,u=void 0,p=0;s=p<=r.length-1,o=n[p],a=s?r[p]:void 0,k(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(At(o,a))n[p]=gt(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(At(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,gt(e,t,""+i[p],a,u))}else M(a)&&F(a).parent===t&&J("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+t.path+"/"+i[p]+"', but it lives already at '"+F(a).path+"'"),n.splice(p,0,gt(e,t,""+i[p],a));else o.die(),n.splice(p,1),p--;return n}function gt(t,e,n,r,i){if(x(t,r),M(r)){var o=F(r);if(o.assertAlive(),null!==o.parent&&o.parent===e)return o.setParent(e,n),i&&i!==o&&i.die(),o}if(i){var a=t.reconcile(i,r);return a.setParent(e,n),a}return t.instantiate(e,n,e._environment,r)}function At(t,e){return M(e)?F(e)===t:!(!q(e)||t.snapshot!==e)||!!(t instanceof Et&&null!==t.identifier&&t.identifierAttribute&&K(e)&&e[t.identifierAttribute]===t.identifier)}function wt(){return F(this).toString()}function Vt(t){return Object.keys(t).reduce(function(t,e){if(e in Bt)return J("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var n=Object.getOwnPropertyDescriptor(t,e);"get"in n&&J("Getters are not supported as properties. Please use views instead");var r=n.value;if(null===r||void 0===r)J("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else{if(Q(r))return Object.assign({},t,(i={},i[e]=Nt(Pt(r),r),i));if(f(r))return t;J("function"==typeof r?"Functions are not supported as properties, use views instead":"object"==typeof r?"In property '"+e+"': base models should not contain complex values: '"+r+"'":"Unexpected value for property '"+e+"'")}var i},t)}function Pt(t){switch(typeof t){case"string":return ee;case"number":return ne;case"boolean":return re;case"object":if(t instanceof Date)return ae}return J("Cannot determine primitive type from value "+t)}function St(t){return f(t)&&(t.flags&(Ct.String|Ct.Number|Ct.Boolean|Ct.Date))>0}function jt(t){return new se(t)}function Tt(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=f(t)?null:t,i=f(t)?e.concat(t):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new pe(o,i,r)}function Nt(t,e){return new ce(t,e)}var Ct,Ot=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},_t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},It=function(){function t(t,e,n,r,i,o,a,s){void 0===s&&(s=Y),this.subpath="",this._environment=void 0,this.state=xt.INITIALIZING,this.type=t,this.storedValue=o,this._parent=e,this.subpath=n,this.storedValue=o,this._environment=r,a&&nt(this.storedValue,"$treenode",this);var u=!0;try{a&&nt(this.storedValue,"toJSON",L),s(this,i),this.state=xt.CREATED,u=!1}finally{u&&(this.state=xt.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+ht(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this._parent?this._parent.root:J("This scalar node is not part of a tree")},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent!==t&&J("Cannot change parent of immutable node"),this.subpath!==e&&(this.subpath=e||"",this._invalidateComputed("path"))},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return X(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==xt.DEAD},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=xt.DEAD},t.prototype._invalidateComputed=function(t){e.getAtom(this,t).trackAndCompute()},i([e.computed],t.prototype,"path",null),t}(),Dt=1,Et=function(){function t(t,n,r,i,o,a,s,u){void 0===u&&(u=Y);var p=this;this.nodeId=++Dt,this.subpath="",this._parent=null,this._isRunningAction=!1,this.isProtectionEnabled=!0,this.identifierAttribute=void 0,this._environment=void 0,this._autoUnbox=!0,this.state=xt.INITIALIZING,this.middlewares=null,this.snapshotSubscribers=null,this.patchSubscribers=null,this.disposers=null,this.type=t,this.storedValue=a,this._parent=n,this.subpath=r,this._environment=i,this.preboot(),n||(this.identifierCache=new Lt),s&&nt(this.storedValue,"$treenode",this);var c=!0;try{s&&nt(this.storedValue,"toJSON",L),this._isRunningAction=!0,u(this,o),this._isRunningAction=!1,n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this),this.fireHook("afterCreate"),this.state=xt.CREATED,c=!1}finally{c&&(this.state=xt.DEAD)}var l=e.reaction(function(){return p.snapshot},function(t){p.emitSnapshot(t)},{onError:function(t){throw t}});this.addDisposer(l)}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+ht(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var t,e=this;t=e.parent;)e=t;return e},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent===t&&this.subpath===e||(t&&(this._parent&&t!==this._parent&&J("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+t.path+"/"+e+"'."),this._parent||t.root!==this||J("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+t.path+"/"+e+"'"),!this._parent&&this.root._environment&&this.root._environment!==t.root._environment&&J("A state tree cannot be made part of another state tree as long as their environments are different.")),this.parent&&!t?this.die():(this.subpath=e||"",t&&t!==this._parent&&(t.root.identifierCache.mergeCache(this),this._parent=t,this.fireHook("afterAttach")),this._invalidateComputed("path")))},t.prototype.fireHook=function(t){var e=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof e&&e.apply(this.storedValue)},Object.defineProperty(t.prototype,"value",{get:function(){if(this.isAlive)return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this.isAlive)return X(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"identifier",{get:function(){return this.identifierAttribute?this.storedValue[this.identifierAttribute]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==xt.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){this.isAlive||J("You are trying to read or write to an object that is no longer part of a state tree. (Object type was '"+this.type.name+"').")},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this.type.getChildNode(this,t)}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this.type.getChildren(this)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&J("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.unbox=function(t){return t&&t.parent&&t.parent.assertAlive(),t&&t.parent&&t.parent._autoUnbox?t.value:t},t.prototype.toString=function(){var t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+t+(this.isAlive?"":"[dead]")},t.prototype.finalizeCreation=function(){if(this.state===xt.CREATED){if(this.parent){if(this.parent.state!==xt.FINALIZED)return;this.fireHook("afterAttach")}this.state=xt.FINALIZED;for(var e=0,n=this.getChildren();e<n.length;e++){var r=n[e];r instanceof t&&r.finalizeCreation()}}},t.prototype.detach=function(){this.isAlive||J("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this.state=xt.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this.state=xt.FINALIZED,this._invalidateComputed("path"))},t.prototype.preboot=function(){var t=this;this.applyPatches=V(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=vt(e.path);$(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this.applySnapshot=V(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})},t.prototype.die=function(){this.state!==xt.DETACHING&&M(this.storedValue)&&(l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this.disposers&&this.disposers.splice(0).forEach(function(t){return t()}),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this);this.path;rt(this,"snapshot",this.snapshot),this.patchSubscribers&&this.patchSubscribers.splice(0),this.snapshotSubscribers&&this.snapshotSubscribers.splice(0),this.state=xt.DEAD,this._parent=null,this.subpath="",this._invalidateComputed("path")},t.prototype.onSnapshot=function(t){return this.snapshotSubscribers||(this.snapshotSubscribers=[]),ot(this.snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this.snapshotSubscribers&&this.snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return this.patchSubscribers||(this.patchSubscribers=[]),ot(this.patchSubscribers,t)},t.prototype.emitPatch=function(t,e){if(this.patchSubscribers&&this.patchSubscribers.length){var n=pt(B({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),r=n[0],i=n[1];this.patchSubscribers.forEach(function(t){return t(r,i)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this.disposers||(this.disposers=[]),this.disposers.unshift(t)},t.prototype.removeMiddleware=function(t){this.middlewares&&(this.middlewares=this.middlewares.filter(function(e){return e.handler!==t}))},t.prototype.addMiddleWare=function(t,e){var n=this;return void 0===e&&(e=!0),this.middlewares||(this.middlewares=[]),this.middlewares.push({handler:t,includeHooks:e}),function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this.type.applyPatchLocally(this,t,e)},t.prototype._invalidateComputed=function(t){e.getAtom(this,t).trackAndCompute()},i([e.computed],t.prototype,"path",null),i([e.computed],t.prototype,"value",null),i([e.computed],t.prototype,"snapshot",null),t}();!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined"}(Ct||(Ct={}));var xt,Rt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),x(this,t),this.instantiate(null,"",e,t).value},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return M(t)?o(t)===this||this.isAssignableFrom(o(t))?I():D(e,t):this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},t.prototype.reconcile=function(t,e){if(t.snapshot===e)return t;if(M(e)&&F(e)===t)return t;if(t.type===this&&q(e)&&!M(e)&&(!t.identifierAttribute||t.identifier===e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),M(e)&&this.isAssignableFrom(o(e))){var i=F(e);return i.setParent(n,r),i}return this.instantiate(n,r,t._environment,e)},Object.defineProperty(t.prototype,"Type",{get:function(){return J("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){return J("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),zt=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.getDefaultSnapshot=function(){},e.prototype.applySnapshot=function(t,e){J("Immutable types do not support applying snapshots")},e.prototype.applyPatchLocally=function(t,e,n){J("Immutable types do not support applying patches")},e.prototype.getChildren=function(t){return $t},e.prototype.getChildNode=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e.prototype.getChildType=function(t){return J("No child '"+t+"' available in type: "+this.name)},e.prototype.reconcile=function(t,e){if(t.type===this&&t.storedValue===e)return t;var n=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),n},e.prototype.removeChild=function(t,e){return J("No child '"+e+"' available in type: "+this.name)},e}(Rt),kt=new Map,Mt=1,Ft=null,Lt=function(){function t(){this.cache=e.observable.map()}return t.prototype.addNodeToCache=function(t){if(t.identifierAttribute){var n=""+t.identifier;this.cache.has(n)||this.cache.set(n,e.observable.array([],Wt));var r=this.cache.get(n);-1!==r.indexOf(t)&&J("Already registered"),r.push(t)}return this},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach(function(t){return t.forEach(function(t){n.addNodeToCache(t)})})},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=this.cache.get(""+t.identifier);e&&e.remove(t)}},t.prototype.splitCache=function(n){var r=new t,i=n.path;return e.values(this.cache).forEach(function(t){for(var e=t.length-1;e>=0;e--)0===t[e].path.indexOf(i)&&(r.addNodeToCache(t[e]),t.splice(e,1))}),r},t.prototype.resolve=function(t,e){var n=this.cache.get(""+e);if(!n)return null;var r=n.filter(function(e){return t.isAssignableFrom(e.type)});switch(r.length){case 0:return null;case 1:return r[0];default:return J("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map(function(t){return t.path}).join(", "))}},t}();!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(xt||(xt={}));var Ht=function(t){return".."},Ut="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.",$t=Object.freeze([]),Jt=Object.freeze({}),Wt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Wt);var Yt=function(){};(Yt=function(t,e){}).ids={};var Zt,Gt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(Zt||(Zt={}));var Bt,Kt=function(t){function r(n,r){var i=t.call(this,n)||this;return i.shouldAttachNode=!0,i.identifierMode=Zt.UNKNOWN,i.identifierAttribute=void 0,i.flags=Ct.Map,i.createNewInstance=function(){var t=e.observable.map({},Wt);return nt(t,"put",bt),t},i.finalizeNewInstance=function(t,n){var r=t,o=r.storedValue;e._interceptReads(o,r.unbox),e.intercept(o,function(t){return i.willChange(t)}),r.applySnapshot(n),e.observe(o,i.didChange)},i.subType=r,i}return n(r,t),r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},r.prototype.getChildren=function(t){return e.values(t.storedValue)},r.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||J("Not a child "+e),n},r.prototype.willChange=function(t){var e=F(t.object),n=""+t.name;switch(e.assertWritable(),t.type){case"update":var r=t.newValue;if(r===t.object.get(n))return null;x(this.subType,r),t.newValue=this.subType.reconcile(e.getChildNode(n),t.newValue),this.processIdentifier(n,t.newValue);break;case"add":x(this.subType,t.newValue),t.newValue=this.subType.instantiate(e,n,void 0,t.newValue),this.processIdentifier(n,t.newValue)}return t},r.prototype.processIdentifier=function(t,e){if(e instanceof Et&&(this.identifierMode===Zt.UNKNOWN&&(this.identifierMode=void 0!==e.identifierAttribute?Zt.YES:Zt.NO,this.identifierAttribute=e.identifierAttribute),e.identifierAttribute!==this.identifierAttribute&&J("The objects in a map should all have the same identifier attribute, expected '"+this.identifierAttribute+"', but child of type '"+e.type.name+"' declared attribute '"+e.identifierAttribute+"' as identifier"),this.identifierMode===Zt.YES)){var n=""+e.identifier;n!==t&&J("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},r.prototype.didChange=function(t){var e=F(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:ht(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:ht(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:ht(t.name),oldValue:n},e)}},r.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},r.prototype.applySnapshot=function(t,e){x(this,e);var n=t.storedValue,r={};Array.from(n.keys()).forEach(function(t){r[t]=!1});for(var i in e)n.set(""+i,e[i]),r[""+i]=!0;Object.keys(r).forEach(function(t){!1===r[t]&&n.delete(t)})},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return K(t)?E(Object.keys(t).map(function(r){return n.subType.validate(t[r],_(e,r,n.subType))})):D(e,t,"Value is not a plain object")},r.prototype.getDefaultSnapshot=function(){return{}},r.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],r.prototype,"applySnapshot",null),r}(Rt),qt=function(t){function r(n,r){var i=t.call(this,n)||this;return i.shouldAttachNode=!0,i.flags=Ct.Array,i.createNewInstance=function(){return e.observable.array([],Wt)},i.finalizeNewInstance=function(t,n){var r=t,o=r.storedValue;e._getAdministration(o).dehancer=r.unbox,e.intercept(o,function(t){return i.willChange(t)}),r.applySnapshot(n),e.observe(o,i.didChange)},i.subType=r,i}return n(r,t),r.prototype.describe=function(){return this.subType.describe()+"[]"},r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.getChildren=function(t){return t.storedValue.slice()},r.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:J("Not a child: "+e)},r.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=mt(e,this.subType,[n[t.index]],[t.newValue],[t.index])[0];break;case"splice":var r=t.index,i=t.removedCount,o=t.added;t.added=mt(e,this.subType,n.slice(r,r+i),o,o.map(function(t,e){return r+e}));for(var a=r+i;a<n.length;a++)n[a].setParent(e,""+(a+o.length-i))}return t},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},r.prototype.didChange=function(t){var e=F(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(var n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},r.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:parseInt(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},r.prototype.applySnapshot=function(t,e){x(this,e),t.storedValue.replace(e)},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return Z(t)?E(t.map(function(t,r){return n.subType.validate(t,_(e,""+r,n.subType))})):D(e,t,"Value is not an array")},r.prototype.getDefaultSnapshot=function(){return[]},r.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],r.prototype,"applySnapshot",null),r}(Rt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.postProcessSnapshot="postProcessSnapshot",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(Bt||(Bt={}));var Qt={name:"AnonymousModel",properties:{},initializers:$t},Xt=function(t){function o(n){var r=t.call(this,n.name||Qt.name)||this;r.flags=Ct.Object,r.shouldAttachNode=!0,r.properties={},r.createNewInstance=function(){var t=e.observable.object(Jt,Jt,Wt);return nt(t,"toString",wt),t},r.finalizeNewInstance=function(t,n){var i=t,o=i.storedValue;r.forAllProps(function(t,r){e.extendObservable(o,(a={},a[t]=r.instantiate(i,t,i._environment,n[t]),a),Jt,Wt),e._interceptReads(o,t,i.unbox);var a}),r.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,function(t){return r.willChange(t)}),e.observe(o,r.didChange)},r.didChange=function(t){if(r.properties[t.name]){var e=F(t.object),n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:ht(t.name),value:t.newValue.snapshot,oldValue:n},e)}};var i=n.name||Qt.name;return/^\w[\w\d_]*$/.test(i)||J("Typename should be a valid identifier: "+i),Object.assign(r,Qt,n),r.properties=Vt(r.properties),X(r.properties),r}return n(o,t),Object.defineProperty(o.prototype,"propertyNames",{get:function(){return Object.keys(this.properties)},enumerable:!0,configurable:!0}),o.prototype.cloneAndEnhance=function(t){return new o({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor})},o.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},o.prototype.instantiateActions=function(t,e){K(e)||J("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){if("preProcessSnapshot"===n)return J("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in Bt&&i){var o=r;r=n===Bt.postProcessSnapshot?function(t){return o(i(t))}:function(){i.apply(null,arguments),o.apply(null,arguments)}}nt(t,n,V(t,n,r))})},o.prototype.named=function(t){return this.cloneAndEnhance({name:t})},o.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},o.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},o.prototype.instantiateVolatileState=function(t,n){K(n)||J("volatile state initializer should return a plain object containing state"),e.extendObservable(t,n,Jt,Wt)},o.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var i=t(n),o=i.actions,a=i.views,s=i.state,u=r(i,["actions","views","state"]);for(var p in u)J("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return s&&e.instantiateVolatileState(n,s),a&&e.instantiateViews(n,a),o&&e.instantiateActions(n,o),n}]})},o.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},o.prototype.instantiateViews=function(t,n){K(n)||J("views initializer should return a plain object containing views"),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r),o=i.value;if("get"in i)if(e.isComputedProp(t,r)){var a=e._getAdministration(t,r);a.derivation=i.get,a.scope=t,i.set&&(a.setter=e.action(a.name+"-setter",i.set))}else{var s={};Object.defineProperty(s,r,{get:i.get,set:i.set,enumerable:!0}),e.extendObservable(t,s,Jt,Wt)}else"function"==typeof o?nt(t,r,o):J("A view member should either be a function or getter based property")})},o.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},o.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},o.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=this.properties[t.name];return n&&(x(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},o.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},o.prototype.getChildNode=function(t,n){if(!(n in this.properties))return J("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;return r||J("Node not available for property "+n)},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps(function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot}),"function"==typeof t.storedValue.postProcessSnapshot&&n?t.storedValue.postProcessSnapshot.call(null,i):i},o.prototype.applyPatchLocally=function(t,e,n){"replace"!==n.op&&"add"!==n.op&&J("object does not support operation "+n.op),t.storedValue[e]=n.value},o.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);x(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},o.prototype.applySnapshotPreProcessor=function(t){return this.preProcessor?this.preProcessor.call(null,t):t},o.prototype.getChildType=function(t){return this.properties[t]},o.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return K(r)?E(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],_(e,t,n.properties[t]))})):D(e,r,"Value is not a plain object")},o.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},o.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],o.prototype,"applySnapshot",null),o}(Rt),te=function(t){function e(e,n,r,i){void 0===i&&(i=W);var o=t.call(this,e)||this;return o.shouldAttachNode=!1,o.flags=n,o.checker=r,o.initializer=i,o}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return Q(t)&&this.checker(t)?I():D(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(zt),ee=new te("string",Ct.String,function(t){return"string"==typeof t}),ne=new te("number",Ct.Number,function(t){return"number"==typeof t}),re=new te("boolean",Ct.Boolean,function(t){return"boolean"==typeof t}),ie=new te("null",Ct.Null,function(t){return null===t}),oe=new te("undefined",Ct.Undefined,function(t){return void 0===t}),ae=new te("Date",Ct.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});ae.getSnapshot=function(t){return t.storedValue.getTime()};var se=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.shouldAttachNode=!1,n.flags=Ct.Literal,n.value=e,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return Q(t)&&t===this.value?I():D(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(zt),ue=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|Ct.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=M(t)?F(t).snapshot:t;return this.predicate(r)?I():D(e,t,this.message(t))},e}(zt),pe=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dispatcher=null,i.dispatcher=r,i.types=n,i}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=Ct.Union;return this.types.forEach(function(e){t|=e.flags}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this.types.some(function(e){return e.isAssignableFrom(t)})},e.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){return this.determineType(r).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.determineType(e).reconcile(t,e)},e.prototype.determineType=function(t){if(null!==this.dispatcher)return this.dispatcher(t);var e=this.types.filter(function(e){return e.is(t)});return e.length>1?J("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):e[0]},e.prototype.isValidSnapshot=function(t,e){if(null!==this.dispatcher)return this.dispatcher(t).validate(t,e);var n=this.types.map(function(n){return n.validate(t,e)}),r=n.filter(function(t){return 0===t.length});return r.length>1?D(e,t,"Multiple types are applicable for the union (hint: provide a dispatch function)"):0===r.length?D(e,t,"No type is applicable for the union").concat(E(n)):I()},e}(zt),ce=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|Ct.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValue(),o=M(i)?F(i).snapshot:i;return this.type.instantiate(t,e,n,o)}return this.type.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)&&void 0!==e?e:this.getDefaultValue())},e.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&x(this,t),t},e.prototype.isValidSnapshot=function(t,e){return void 0===t?I():this.type.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e}(zt),le=Nt(ie,null),fe=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=null,r.definition=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.subType.flags|Ct.Late},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.subType.shouldAttachNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),e.prototype.instantiate=function(t,e,n,r){return this.subType.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.subType.reconcile(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.isValidSnapshot=function(t,e){return this.subType.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.subType.isAssignableFrom(t)},e}(zt),he=new(function(t){function e(){var e=t.call(this,"frozen")||this;return e.shouldAttachNode=!1,e.flags=Ct.Frozen,e}return n(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,tt(r))},e.prototype.isValidSnapshot=function(t,e){return et(t)?I():D(e,t,"Value is not serializable and cannot be frozen")},e}(zt)),de=function(){return function(t,e){if(this.mode=t,this.value=e,"object"===t){if(!M(e))return J("Can only store references to tree nodes, got: '"+e+"'");if(!F(e).identifierAttribute)return J("Can only store references with a defined identifier attribute.")}}}(),ye=function(t){function e(e){var n=t.call(this,"reference("+e.name+")")||this;return n.targetType=e,n.shouldAttachNode=!1,n.flags=Ct.Reference,n}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){return"string"==typeof t||"number"==typeof t?I():D(e,t,"Value is not a valid identifier, which is a string or a number")},e}(zt),ve=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive){var e=t.storedValue;if("object"===e.mode)return e.value;var n=t.root.identifierCache.resolve(this.targetType,e.value);return n?n.value:J("Failed to resolve reference '"+e.value+"' to type '"+this.targetType.name+"' (from node: "+t.path+")")}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return F(e.value).identifier}},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,new de(M(r)?"object":"identifier",r))},e.prototype.reconcile=function(t,e){if(t.type===this){var n=M(e)?"object":"identifier",r=t.storedValue;if(n===r.mode&&r.value===e)return t}var i=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),i},e}(ye),be=function(t){function e(e,n){var r=t.call(this,e)||this;return r.options=n,r}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,M(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=M(e)?this.options.set(e,t?t.storedValue:null):e;if(t.type===this&&t.storedValue===n)return t;var r=this.instantiate(t.parent,t.subpath,t._environment,n);return t.die(),r},e}(ye),me=function(t){function e(e){var n=t.call(this,"identifier("+e.name+")")||this;return n.identifierType=e,n.shouldAttachNode=!1,n.flags=Ct.Identifier,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return t&&M(t.storedValue)?(t.identifierAttribute&&J("Cannot define property '"+e+"' as object identifier, property '"+t.identifierAttribute+"' is already defined as identifier property"),t.identifierAttribute=e,z(this,t,e,n,r)):J("Identifier types can only be instantiated as direct child of a model type")},e.prototype.reconcile=function(t,e){return t.storedValue!==e?J("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed."):t},e.prototype.describe=function(){return"identifier("+this.identifierType.describe()+")"},e.prototype.isValidSnapshot=function(t,e){return void 0===t||null===t||"string"==typeof t||"number"==typeof t?this.identifierType.validate(t,e):D(e,t,"Value is not a valid identifier, which is a string or a number")},e}(zt),ge=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=Ct.Reference,n.shouldAttachNode=!1,n}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return t===this},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return I();var n=this.options.getValidationMessage(t);return n?D(e,t,"Invalid value for type '"+this.name+"': "+n):I()},e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},e.prototype.reconcile=function(t,e){var n=!this.options.isTargetType(e);if(t.type===this&&(n?e===t.snapshot:e===t.storedValue))return t;var r=n?this.options.fromSnapshot(e):e,i=this.instantiate(t.parent,t.subpath,t._environment,r);return t.die(),i},e}(zt),Ae={enumeration:function(t,e){var n="string"==typeof t?e:t,r=Tt.apply(void 0,n.map(function(t){return jt(""+t)}));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new Xt({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel";return t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers})}).named(n)},custom:function(t){return new ge(t)},reference:function(t,e){return e?new be(t,e):new ve(t)},union:Tt,optional:Nt,literal:jt,maybe:function(t){return Tt(le,t)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():f(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new ue(n,r,i,o)},string:ee,boolean:re,number:ne,Date:ae,map:function(t){return new Kt("map<string, "+t.name+">",t)},array:function(t){return new qt(t.name+"[]",t)},frozen:he,identifier:function(t){return void 0===t&&(t=ee),new me(t)},late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new fe(n,"string"==typeof t?e:t)},undefined:oe,null:ie};t.types=Ae,t.typecheck=R,t.escapeJsonPath=ht,t.unescapeJsonPath=dt,t.joinJsonPath=yt,t.splitJsonPath=vt,t.decorate=function(t,e){var n={handler:t,includeHooks:!0};return e.$mst_middleware?e.$mst_middleware.push(n):e.$mst_middleware=[n],e},t.addMiddleware=P,t.process=function(t){return Yt("process","`process()` has been renamed to `flow()`. "+Ut),st(t)},t.isStateTreeNode=M,t.flow=st,t.applyAction=v,t.onAction=m,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){v(t,e.actions)}},n=m(t,e.actions.push.bind(e.actions));return e},t.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),kt.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===kt.get(e.id).async&&(kt.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw kt.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=kt.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=kt.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=kt.get(e.rootId),kt.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=kt.get(e.rootId);return kt.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.getType=o,t.getChildType=function(t,e){return F(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return F(t).onSnapshot(e)},t.applyPatch=s,t.recordPatches=function(t){function e(){n||(n=a(t,function(t,e){r.rawPatches.push([t,e])}))}var n=null,r={rawPatches:[],get patches(){return this.rawPatches.map(function(t){return t[0]})},get inversePatches(){return this.rawPatches.map(function(t){return t[0],t[1]})},stop:function(){n&&n(),n=null},resume:e,replay:function(e){s(e||t,r.patches)},undo:function(e){s(e||t,r.inversePatches.slice().reverse())}};return e(),r},t.protect=function(t){var e=F(t);e.isRoot||J("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=F(t);e.isRoot||J("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return F(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=F(t);return e?n.snapshot:X(n.type.getSnapshot(n,!1))},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=F(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=F(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return J("Failed to find the parent of "+F(t)+" at depth "+e)},t.hasParentOfType=function(t,e){for(var n=F(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.getParentOfType=function(t,e){for(var n=F(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}return J("Failed to find the parent of "+F(t)+" of a given type")},t.getRoot=p,t.getPath=function(t){return F(t).path},t.getPathParts=function(t){return vt(F(t).path)},t.isRoot=function(t){return F(t).isRoot},t.resolvePath=function(t,e){var n=U(F(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=F(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return F(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return H(F(t),F(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=F(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return F(t).detach(),t},t.destroy=function(t){var e=F(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return F(t).isAlive},t.addDisposer=function(t,e){F(t).addDisposer(e)},t.getEnv=function(t){var e=F(t).root._environment;return e||Jt},t.walk=l,t.getMembers=function(t){var n=F(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:_t({},n.properties),actions:[],volatile:[],views:[]};return r.forEach(function(n){if(!(n in i.properties)){var r=Object.getOwnPropertyDescriptor(t,n);r.get?e.isComputedProp(t,n)?i.views.push(n):i.volatile.push(n):!0===r.value._isMSTAction?i.actions.push(n):e.isObservableProp(t,n)?i.volatile.push(n):i.views.push(n)}}),i},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],e):e(t.mobxStateTree=t.mobxStateTree||{},t.mobx)}(this,function(t,e){"use strict";function n(t,e){function n(){this.constructor=t}Et(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]]);return n}function i(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function o(t){return F(t).type}function a(t,e){return F(t).onPatch(e)}function s(t,e){F(t).applyPatches(B(e))}function u(t,e){return F(t).applySnapshot(e)}function p(t){return F(t).root.storedValue}function c(t,e){var n=U(F(t),e,!1);if(void 0!==n)try{return n.value}catch(t){return}}function l(t,e){var n=F(t);n.getChildren().forEach(function(t){M(t.storedValue)&&l(t.storedValue,e)}),e(n.storedValue)}function h(t){return"object"==typeof t&&t&&!0===t.isType}function f(t,e,n,r){if(r instanceof Date)return{$MST_DATE:r.getTime()};if(X(r))return r;if(M(r))return y("[MSTNode: "+o(r).name+"]");if("function"==typeof r)return y("[function]");if("object"==typeof r&&!q(r)&&!G(r))return y("[object "+(r&&r.constructor&&r.constructor.name||"Complex Object")+"]");try{return JSON.stringify(r),r}catch(t){return y(""+t)}}function d(t,e){return e&&"object"==typeof e&&"$MST_DATE"in e?new Date(e.$MST_DATE):e}function y(t){return{$MST_UNSERIALIZABLE:!0,type:t}}function b(t,n){e.runInAction(function(){B(n).forEach(function(e){return v(t,e)})})}function v(t,e){var n=c(t,e.path||"");if(!n)return W("Invalid action path: "+(e.path||""));var r=F(n);return"@APPLY_PATCHES"===e.name?s.call(null,n,e.args[0]):"@APPLY_SNAPSHOT"===e.name?u.call(null,n,e.args[0]):("function"!=typeof n[e.name]&&W("Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return d(r,t)}):[]))}function g(t,e,n){function r(n){if("action"===n.type&&n.id===n.rootId){var r=F(n.context);e({name:n.name,path:H(F(t),r),args:n.args.map(function(t,e){return f(r,n.name,e,t)})})}}return void 0===n&&(n=!1),S(t,n?function(t,e){var n=e(t);return r(t),n}:function(t,e){return r(t),e(t)})}function m(){return $t++}function w(t,e){var n=F(t.context),r=n._isRunningAction,i=Jt;"action"===t.type&&n.assertAlive(),n._isRunningAction=!0,Jt=t;try{return _(n,t,e)}finally{Jt=i,n._isRunningAction=r}}function A(){return Jt||W("Not running an action!")}function P(t,e,n){var r=function(){var r=m();return w({type:"action",name:e,id:r,args:st(arguments),context:t,tree:p(t),rootId:Jt?Jt.rootId:r,parentId:Jt?Jt.id:0},n)};return r._isMSTAction=!0,r}function S(t,e,n){return void 0===n&&(n=!0),F(t).addMiddleWare(e,n)}function V(t,e,n){for(var r=n.$mst_middleware||Gt,i=t;i;)i.middlewares&&(r=r.concat(i.middlewares)),i=i.parent;return r}function _(t,n,r){function i(t){function n(t,e){l=!0,s=e?e(i(t)||s):i(t)}function u(t){h=!0,s=t}var p=o[a++],c=p&&p.handler,l=!1,h=!1,f=function(){return c(t,n,u),s};return c&&p.includeHooks?f():c&&!p.includeHooks?te[t.name]?i(t):f():e.action(r).apply(null,t.args)}var o=V(t,n,r);if(!o.length)return e.action(r).apply(null,n.args);var a=0,s=null;return i(n)}function N(t){try{return JSON.stringify(t)}catch(t){return"<Unserializable: "+t+">"}}function C(t){return"function"==typeof t?"<function"+(t.name?" "+t.name:"")+">":M(t)?"<"+t+">":"`"+N(t)+"`"}function T(t){return t.length<280?t:t.substring(0,272)+"......"+t.substring(t.length-8)}function j(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map(function(t){return t.path}).filter(function(t){return t.length>0}).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=M(e)?"value of type "+F(e).type.name+":":X(e)?"value":"snapshot",a=n&&M(e)&&n.is(F(e).snapshot);return""+i+o+" "+C(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?Ct(n)||X(e)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function O(t,e,n){return t.concat([{path:e,type:n}])}function I(){return Gt}function E(t,e,n){return[{context:t,value:e,message:n}]}function D(t){return t.reduce(function(t,e){return t.concat(e)},[])}function x(t,e){}function R(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&W("Error while converting "+T(C(e))+" to `"+t.name+"`:\n\n "+n.map(j).join("\n "))}function z(t,e,n,r,i,o,a){if(void 0===o&&(o=Y),void 0===a&&(a=Z),M(i)){var s=i.$treenode;return s.isRoot||W("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(e?e.path:"")+"/"+n+"', but it lives already at '"+s.path+"'"),s.setParent(e,n),s}return t.shouldAttachNode?new Mt(t,e,n,r,i,o,a):new xt(t,e,n,r,i,o,a)}function k(t){return t instanceof xt||t instanceof Mt}function M(t){return!(!t||!t.$treenode)}function F(t){return M(t)?t.$treenode:W("Value "+t+" is no MST Node")}function L(){return F(this).snapshot}function H(t,e){t.root!==e.root&&W("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=gt(t.path),r=gt(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(Yt).join("/")+vt(r.slice(i))}function U(t,e,n){return void 0===n&&(n=!0),$(t,gt(e),n)}function $(t,e,n){void 0===n&&(n=!0);for(var r=t,i=0;i<e.length;i++){var o=e[i];{if(""!==o){if(".."===o){if(r=r.parent)continue}else{if("."===o||""===o)continue;if(r){if(r instanceof xt)try{var a=r.value;M(a)&&(r=F(a))}catch(t){if(!n)return;throw t}if(r instanceof Mt&&r.getChildType(o)&&(r=r.getChildNode(o)))continue}}return n?W("Could not resolve '"+o+"' in path '"+(vt(e.slice(0,i))||"/")+"' while resolving '"+vt(e)+"'"):void 0}r=r.root}}return r}function J(t){if(!t)return Gt;var e=Object.keys(t);if(!e.length)return Gt;var n=new Array(e.length);return e.forEach(function(e,r){n[r]=t[e]}),n}function W(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function Y(t){return t}function Z(){}function G(t){return!(!Array.isArray(t)&&!e.isObservableArray(t))}function B(t){return t?G(t)?t:[t]:Gt}function K(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}function q(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Q(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function X(t){return null===t||void 0===t||("string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date)}function tt(t){return t}function et(t){return t}function nt(t){return"function"!=typeof t}function rt(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function it(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function ot(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}function at(t,e){return t.push(e),function(){ot(t,e)}}function st(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function ut(t,n){e.getAtom(t,n).trackAndCompute()}function pt(t){return ct(t.name,t)}function ct(t,e){var n=function(){function r(e,r,a){e.$mst_middleware=n.$mst_middleware,w({name:t,type:r,id:i,args:[a],tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},e)}var i=m(),o=A(),a=arguments;return new Promise(function(s,u){function p(t){var e;try{r(function(t){e=h.next(t)},"flow_resume",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function c(t){var e;try{r(function(t){e=h.throw(t)},"flow_resume_error",t)}catch(t){return void setImmediate(function(){r(function(e){u(t)},"flow_throw",t)})}l(e)}function l(t){if(!t.done)return t.value&&"function"==typeof t.value.then||W("Only promises can be yielded to `async`, got: "+t),t.value.then(p,c);setImmediate(function(){r(function(t){s(t)},"flow_return",t.value)})}var h,f=function(){h=e.apply(null,arguments),p(void 0)};f.$mst_middleware=n.$mst_middleware,w({name:t,type:"flow_spawn",id:i,args:st(a),tree:o.tree,context:o.context,parentId:o.id,rootId:o.rootId},f)})};return n}function lt(t){return"oldValue"in t||W("Patches without `oldValue` field cannot be inversed"),[ht(t),ft(t)]}function ht(t){switch(t.op){case"add":return{op:"add",path:t.path,value:t.value};case"remove":return{op:"remove",path:t.path};case"replace":return{op:"replace",path:t.path,value:t.value}}}function ft(t){switch(t.op){case"add":return{op:"remove",path:t.path};case"remove":return{op:"add",path:t.path,value:t.oldValue};case"replace":return{op:"replace",path:t.path,value:t.oldValue}}}function dt(t){return"number"==typeof t}function yt(t){return!0===dt(t)?""+t:t.replace(/~/g,"~1").replace(/\//g,"~0")}function bt(t){return t.replace(/~0/g,"/").replace(/~1/g,"~")}function vt(t){return 0===t.length?"":"/"+t.map(yt).join("/")}function gt(t){var e=t.split("/").map(bt);return""===e[0]?e.slice(1):e}function mt(t,e){if(t instanceof oe)e.push(t);else if(t instanceof be){if(!mt(t.type,e))return!1}else if(t instanceof ye){for(var n=0;n<t.types.length;n++)if(!mt(t.types[n],e))return!1}else if(t instanceof me)try{mt(t.subType,e)}catch(t){return!1}return!0}function wt(t,e,n,r,i){for(var o,a,s=!1,u=void 0,p=0;s=p<=r.length-1,o=n[p],a=s?r[p]:void 0,k(a)&&(a=a.storedValue),o||s;p++)if(s)if(o)if(Pt(o,a))n[p]=At(e,t,""+i[p],a,o);else{u=void 0;for(var c=p;c<n.length;c++)if(Pt(n[c],a)){u=n.splice(c,1)[0];break}n.splice(p,0,At(e,t,""+i[p],a,u))}else M(a)&&F(a).parent===t&&W("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+t.path+"/"+i[p]+"', but it lives already at '"+F(a).path+"'"),n.splice(p,0,At(e,t,""+i[p],a));else o.die(),n.splice(p,1),p--;return n}function At(t,e,n,r,i){if(x(t,r),M(r)&&((o=F(r)).assertAlive(),null!==o.parent&&o.parent===e))return o.setParent(e,n),i&&i!==o&&i.die(),o;if(i){var o=t.reconcile(i,r);return o.setParent(e,n),o}return t.instantiate(e,n,e._environment,r)}function Pt(t,e){return M(e)?F(e)===t:!(!Q(e)||t.snapshot!==e)||!!(t instanceof Mt&&null!==t.identifier&&t.identifierAttribute&&q(e)&&t.identifier===""+e[t.identifierAttribute])}function St(){return F(this).toString()}function Vt(t){return Object.keys(t).reduce(function(t,e){if(e in te)return W("Hook '"+e+"' was defined as property. Hooks should be defined as part of the actions");var n=Object.getOwnPropertyDescriptor(t,e);"get"in n&&W("Getters are not supported as properties. Please use views instead");var r=n.value;if(null===r||void 0===r)W("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else{if(X(r))return Object.assign({},t,(i={},i[e]=Ot(Nt(r),r),i));if(r instanceof ne)return Object.assign({},t,(o={},o[e]=Ot(r,{}),o));if(r instanceof re)return Object.assign({},t,(a={},a[e]=Ot(r,[]),a));if(h(r))return t;W("Invalid type definition for property '"+e+"', cannot infer a type from a value like '"+r+"' ("+typeof r+")")}var i,o,a},t)}function _t(t){if(t)return t.flags&It.Union?t.types.find(_t):t.flags&It.Late?_t(t.subType):t.flags&It.Optional?t:void 0}function Nt(t){switch(typeof t){case"string":return se;case"number":return ue;case"boolean":return pe;case"object":if(t instanceof Date)return he}return W("Cannot determine primitive type from value "+t)}function Ct(t){return h(t)&&(t.flags&(It.String|It.Number|It.Boolean|It.Date))>0}function Tt(t){return new fe(t)}function jt(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=h(t)?void 0:t,i=h(t)?[t].concat(e):e,o="("+i.map(function(t){return t.name}).join(" | ")+")";return new ye(o,i,r)}function Ot(t,e){return new be(t,e)}var It,Et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},Dt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},xt=function(){function t(t,e,n,r,i,o,a){void 0===a&&(a=Z),this.subpath="",this.state=Ft.INITIALIZING,this._environment=void 0,this.type=t,this.parent=e,this.subpath=n,this.storedValue=o(i);var s=!0;try{a(this,i),this.state=Ft.CREATED,s=!1}finally{s&&(this.state=Ft.DEAD)}}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+yt(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return this.parent?this.parent.root:W("This scalar node is not part of a tree")},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){void 0===e&&(e=null),W("setParent is not supposed to be called on scalar nodes")},Object.defineProperty(t.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return tt(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==Ft.DEAD},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.type.name+"@"+(this.path||"<root>")+(this.isAlive?"":"[dead]")},t.prototype.die=function(){this.state=Ft.DEAD},t}(),Rt=1,zt="warn",kt={onError:function(t){throw t}},Mt=function(){function t(t,n,r,i,o,a,s){this.nodeId=++Rt,this.subpathAtom=e.createAtom("path"),this.subpath="",this.parent=null,this.state=Ft.INITIALIZING,this.isProtectionEnabled=!0,this.middlewares=null,this._autoUnbox=!0,this._environment=void 0,this._isRunningAction=!1,this._hasSnapshotReaction=!1,this._disposers=null,this._patchSubscribers=null,this._snapshotSubscribers=null,this._observableInstanceCreated=!1,this._environment=i,this._initialSnapshot=o,this._createNewInstance=a,this._finalizeNewInstance=s,this.type=t,this.parent=n,this.subpath=r,this.escapedSubpath=yt(this.subpath),this.identifierAttribute=t instanceof oe?t.identifierAttribute:void 0,this.identifier=this.identifierAttribute&&this._initialSnapshot?""+this._initialSnapshot[this.identifierAttribute]:null,n||(this.identifierCache=new Wt),this._childNodes=t.initializeChildNodes(this,this._initialSnapshot),n?n.root.identifierCache.addNodeToCache(this):this.identifierCache.addNodeToCache(this)}return t.prototype.applyPatches=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applyPatches(t)},t.prototype.applySnapshot=function(t){this._observableInstanceCreated||this._createObservableInstance(),this.applySnapshot(t)},t.prototype._createObservableInstance=function(){this.storedValue=this._createNewInstance(this._childNodes),this.preboot(),rt(this.storedValue,"$treenode",this),rt(this.storedValue,"toJSON",L),this._observableInstanceCreated=!0;var t=!0;try{this._isRunningAction=!0,this._finalizeNewInstance(this,this._childNodes),this._isRunningAction=!1,this.fireHook("afterCreate"),this.state=Ft.CREATED,t=!1}finally{t&&(this.state=Ft.DEAD)}ut(this,"snapshot"),this.isRoot&&this._addSnapshotReaction(),this.finalizeCreation(),this._childNodes=null,this._initialSnapshot=null,this._createNewInstance=null,this._finalizeNewInstance=null},Object.defineProperty(t.prototype,"path",{get:function(){return this.subpathAtom.reportObserved(),this.parent?this.parent.path+"/"+this.escapedSubpath:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t,e){if(void 0===e&&(e=null),this.parent!==t||this.subpath!==e)if(this.parent&&!t)this.die();else{var n=null===e?"":e;this.subpath!==n&&(this.subpath=n,this.escapedSubpath=yt(this.subpath),this.subpathAtom.reportChanged()),t&&t!==this.parent&&(t.root.identifierCache.mergeCache(this),this.parent=t,this.subpathAtom.reportChanged(),this.fireHook("afterAttach"))}},t.prototype.fireHook=function(t){var e=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[t];"function"==typeof e&&e.apply(this.storedValue)},Object.defineProperty(t.prototype,"value",{get:function(){return this._observableInstanceCreated||this._createObservableInstance(),this._value},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_value",{get:function(){if(this.isAlive)return this.type.getValue(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this.isAlive)return tt(this._observableInstanceCreated?this._getActualSnapshot():this._getInitialSnapshot())},enumerable:!0,configurable:!0}),t.prototype._getActualSnapshot=function(){return this.type.getSnapshot(this)},t.prototype._getInitialSnapshot=function(){var t=this._initialSnapshot;return this.type instanceof oe?this.type.applySnapshotPostProcessor(t):t},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},Object.defineProperty(t.prototype,"isAlive",{get:function(){return this.state!==Ft.DEAD},enumerable:!0,configurable:!0}),t.prototype.assertAlive=function(){if(!this.isAlive){var t="[mobx-state-tree][error] You are trying to read or write to an object that is no longer part of a state tree. (Object type was '"+this.type.name+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.";switch(zt){case"error":throw new Error(t);case"warn":console.warn(t+' Use setLivelynessCheck("error") to simplify debugging this error.')}}},t.prototype.getChildNode=function(t){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}},t.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;try{return this._observableInstanceCreated?this.type.getChildren(this):J(this._childNodes)}finally{this._autoUnbox=!0}},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!0,configurable:!0}),t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&W("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.unbox=function(t){return t&&t.parent&&t.parent.assertAlive(),t&&t.parent&&t.parent._autoUnbox?t.value:t},t.prototype.toString=function(){var t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+t+(this.isAlive?"":"[dead]")},t.prototype.finalizeCreation=function(){if(this.state===Ft.CREATED){if(this.parent){if(this.parent.state!==Ft.FINALIZED)return;this.fireHook("afterAttach")}this.state=Ft.FINALIZED;for(var e=0,n=this.getChildren();e<n.length;e++){var r=n[e];r instanceof t&&r.finalizeCreation()}}},t.prototype.detach=function(){this.isAlive||W("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this.state=Ft.DETACHING,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this.parent=null,this.subpath=this.escapedSubpath="",this.subpathAtom.reportChanged(),this.state=Ft.FINALIZED)},t.prototype.preboot=function(){var t=this;this.applyPatches=P(this.storedValue,"@APPLY_PATCHES",function(e){e.forEach(function(e){var n=gt(e.path);$(t,n.slice(0,-1)).applyPatchLocally(n[n.length-1],e)})}),this.applySnapshot=P(this.storedValue,"@APPLY_SNAPSHOT",function(e){if(e!==t.snapshot)return t.type.applySnapshot(t,e)})},t.prototype.die=function(){this.state!==Ft.DETACHING&&M(this.storedValue)&&(l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.aboutToDie()}),l(this.storedValue,function(e){var n=F(e);n instanceof t&&n.finalizeDeath()}))},t.prototype.aboutToDie=function(){this._disposers&&(this._disposers.forEach(function(t){return t()}),this._disposers=null),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this),it(this,"snapshot",this.snapshot),this._patchSubscribers&&(this._patchSubscribers=null),this._snapshotSubscribers&&(this._snapshotSubscribers=null),this.state=Ft.DEAD,this.subpath=this.escapedSubpath="",this.parent=null,this.subpathAtom.reportChanged()},t.prototype.onSnapshot=function(t){return this._addSnapshotReaction(),this._snapshotSubscribers||(this._snapshotSubscribers=[]),at(this._snapshotSubscribers,t)},t.prototype.emitSnapshot=function(t){this._snapshotSubscribers&&this._snapshotSubscribers.forEach(function(e){return e(t)})},t.prototype.onPatch=function(t){return this._patchSubscribers||(this._patchSubscribers=[]),at(this._patchSubscribers,t)},t.prototype.emitPatch=function(t,e){var n=this._patchSubscribers;if(n&&n.length){var r=lt(K({},t,{path:e.path.substr(this.path.length)+"/"+t.path})),i=r[0],o=r[1];n.forEach(function(t){return t(i,o)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.addDisposer=function(t){this._disposers?this._disposers.unshift(t):this._disposers=[t]},t.prototype.removeMiddleware=function(t){this.middlewares&&(this.middlewares=this.middlewares.filter(function(e){return e.handler!==t}))},t.prototype.addMiddleWare=function(t,e){var n=this;return void 0===e&&(e=!0),this.middlewares?this.middlewares.push({handler:t,includeHooks:e}):this.middlewares=[{handler:t,includeHooks:e}],function(){n.removeMiddleware(t)}},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this._observableInstanceCreated||this._createObservableInstance(),this.type.applyPatchLocally(this,t,e)},t.prototype._addSnapshotReaction=function(){var t=this;if(!this._hasSnapshotReaction){var n=e.reaction(function(){return t.snapshot},function(e){return t.emitSnapshot(e)},kt);this.addDisposer(n),this._hasSnapshotReaction=!0}},i([e.action],t.prototype,"_createObservableInstance",null),i([e.computed],t.prototype,"snapshot",null),i([e.action],t.prototype,"detach",null),i([e.action],t.prototype,"die",null),t}();!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional",t[t.Reference=1024]="Reference",t[t.Identifier=2048]="Identifier",t[t.Late=4096]="Late",t[t.Refinement=8192]="Refinement",t[t.Union=16384]="Union",t[t.Null=32768]="Null",t[t.Undefined=65536]="Undefined"}(It||(It={}));var Ft,Lt=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.create=function(t,e){return void 0===t&&(t=this.getDefaultSnapshot()),x(this,t),this.instantiate(null,"",e,t).value},t.prototype.initializeChildNodes=function(t,e){return null},t.prototype.isAssignableFrom=function(t){return t===this},t.prototype.validate=function(t,e){return M(t)?o(t)===this||this.isAssignableFrom(o(t))?I():E(e,t):this.isValidSnapshot(t,e)},t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},t.prototype.reconcile=function(t,e){if(t.snapshot===e)return t;if(M(e)&&F(e)===t)return t;if(t.type===this&&Q(e)&&!M(e)&&(!t.identifierAttribute||t.identifier===""+e[t.identifierAttribute]))return t.applySnapshot(e),t;var n=t.parent,r=t.subpath;if(t.die(),M(e)&&this.isAssignableFrom(o(e))){var i=F(e);return i.setParent(n,r),i}return this.instantiate(n,r,t._environment,e)},Object.defineProperty(t.prototype,"Type",{get:function(){return W("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){return W("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"CreationType",{get:function(){return W("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!0,configurable:!0}),i([e.action],t.prototype,"create",null),t}(),Ht=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){return t.storedValue},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.getDefaultSnapshot=function(){},e.prototype.applySnapshot=function(t,e){W("Immutable types do not support applying snapshots")},e.prototype.applyPatchLocally=function(t,e,n){W("Immutable types do not support applying patches")},e.prototype.getChildren=function(t){return Gt},e.prototype.getChildNode=function(t,e){return W("No child '"+e+"' available in type: "+this.name)},e.prototype.getChildType=function(t){return W("No child '"+t+"' available in type: "+this.name)},e.prototype.reconcile=function(t,e){if(t.type===this&&t.storedValue===e)return t;var n=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),n},e.prototype.removeChild=function(t,e){return W("No child '"+e+"' available in type: "+this.name)},e}(Lt),Ut=new Map,$t=1,Jt=null,Wt=function(){function t(){this.cache=e.observable.map()}return t.prototype.addNodeToCache=function(t){if(t.identifierAttribute){var n=t.identifier;this.cache.has(n)||this.cache.set(n,e.observable.array([],Kt));var r=this.cache.get(n);-1!==r.indexOf(t)&&W("Already registered"),r.push(t)}return this},t.prototype.mergeCache=function(t){var n=this;e.values(t.identifierCache.cache).forEach(function(t){return t.forEach(function(t){n.addNodeToCache(t)})})},t.prototype.notifyDied=function(t){if(t.identifierAttribute){var e=this.cache.get(t.identifier);e&&e.remove(t)}},t.prototype.splitCache=function(n){var r=new t,i=n.path;return e.values(this.cache).forEach(function(t){for(var e=t.length-1;e>=0;e--)0===t[e].path.indexOf(i)&&(r.addNodeToCache(t[e]),t.splice(e,1))}),r},t.prototype.resolve=function(t,e){var n=this.cache.get(""+e);if(!n)return null;var r=n.filter(function(e){return t.isAssignableFrom(e.type)});switch(r.length){case 0:return null;case 1:return r[0];default:return W("Cannot resolve a reference to type '"+t.name+"' with id: '"+e+"' unambigously, there are multiple candidates: "+r.map(function(t){return t.path}).join(", "))}},t}();!function(t){t[t.INITIALIZING=0]="INITIALIZING",t[t.CREATED=1]="CREATED",t[t.FINALIZED=2]="FINALIZED",t[t.DETACHING=3]="DETACHING",t[t.DEAD=4]="DEAD"}(Ft||(Ft={}));var Yt=function(t){return".."},Zt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.",Gt=Object.freeze([]),Bt=Object.freeze({}),Kt="string"==typeof e.$mobx?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Kt);var qt=function(){};(qt=function(t,e){}).ids={};var Qt,Xt="Map.put can only be used to store complex values that have an identifier type attribute";!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.YES=1]="YES",t[t.NO=2]="NO"}(Qt||(Qt={}));var te,ee=function(t){function r(n){return t.call(this,n,e.observable.ref.enhancer)||this}return n(r,t),r.prototype.get=function(e){return t.prototype.get.call(this,""+e)},r.prototype.has=function(e){return t.prototype.has.call(this,""+e)},r.prototype.delete=function(e){return t.prototype.delete.call(this,""+e)},r.prototype.set=function(e,n){return t.prototype.set.call(this,""+e,n)},r.prototype.put=function(t){if(t||W("Map.put cannot be used to set empty values"),M(t)){var e=F(t),n=e.identifier;return this.set(n,e.value),e.value}if(Q(t)){var n=void 0,r=F(this).type;return r.identifierMode===Qt.NO?W(Xt):r.identifierMode===Qt.YES?(n=""+t[r.identifierAttribute],this.set(n,t),this.get(n)):W(Xt)}return W("Map.put can only be used to store complex values")},r}(e.ObservableMap),ne=function(t){function r(e,n){var r=t.call(this,e)||this;return r.shouldAttachNode=!0,r.identifierMode=Qt.UNKNOWN,r.identifierAttribute=void 0,r.flags=It.Map,r.subType=n,r._determineIdentifierMode(),r}return n(r,t),r.prototype.instantiate=function(t,e,n,r){return this.identifierMode===Qt.UNKNOWN&&this._determineIdentifierMode(),z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype._determineIdentifierMode=function(){var t=[];if(mt(this.subType,t)){var e=void 0;t.forEach(function(t){t.identifierAttribute&&(e&&e!==t.identifierAttribute&&W("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier"),e=t.identifierAttribute)}),e?(this.identifierMode=Qt.YES,this.identifierAttribute=e):this.identifierMode=Qt.NO}},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n=t.type.subType,r=t._environment,i={};return Object.keys(e).forEach(function(o){i[o]=n.instantiate(t,o,r,e[o])}),i},r.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},r.prototype.createNewInstance=function(t){return new ee(t)},r.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._interceptReads(i,n.unbox),e.intercept(i,r.willChange),e.observe(i,r.didChange)},r.prototype.getChildren=function(t){return e.values(t.storedValue)},r.prototype.getChildNode=function(t,e){var n=t.storedValue.get(""+e);return n||W("Not a child "+e),n},r.prototype.willChange=function(t){var e=F(t.object),n=t.name;e.assertWritable();var r=e.type,i=r.subType;switch(t.type){case"update":var o=t.newValue;if(o===t.object.get(n))return null;x(i,o),t.newValue=i.reconcile(e.getChildNode(n),t.newValue),r.processIdentifier(n,t.newValue);break;case"add":x(i,t.newValue),t.newValue=i.instantiate(e,n,void 0,t.newValue),r.processIdentifier(n,t.newValue)}return t},r.prototype.processIdentifier=function(t,e){if(this.identifierMode===Qt.YES&&e instanceof Mt){var n=e.identifier;n!==t&&W("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+t+"'")}},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){var e={};return t.getChildren().forEach(function(t){e[t.subpath]=t.snapshot}),e},r.prototype.didChange=function(t){var e=F(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"add":return void e.emitPatch({op:"add",path:yt(t.name),value:t.newValue.snapshot,oldValue:void 0},e);case"delete":var n=t.oldValue.snapshot;return t.oldValue.die(),void e.emitPatch({op:"remove",path:yt(t.name),oldValue:n},e)}},r.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},r.prototype.applySnapshot=function(t,e){x(this,e);var n=t.storedValue,r={};Array.from(n.keys()).forEach(function(t){r[t]=!1});for(var i in e)n.set(i,e[i]),r[""+i]=!0;Object.keys(r).forEach(function(t){!1===r[t]&&n.delete(t)})},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return q(t)?D(Object.keys(t).map(function(r){return n.subType.validate(t[r],O(e,r,n.subType))})):E(e,t,"Value is not a plain object")},r.prototype.getDefaultSnapshot=function(){return{}},r.prototype.removeChild=function(t,e){t.storedValue.delete(e)},i([e.action],r.prototype,"applySnapshot",null),r}(Lt),re=function(t){function r(e,n){var r=t.call(this,e)||this;return r.shouldAttachNode=!0,r.flags=It.Array,r.subType=n,r}return n(r,t),r.prototype.describe=function(){return this.subType.describe()+"[]"},r.prototype.createNewInstance=function(t){return e.observable.array(J(t),Kt)},r.prototype.finalizeNewInstance=function(t){var n=t,r=n.type,i=n.storedValue;e._getAdministration(i).dehancer=n.unbox,e.intercept(i,r.willChange),e.observe(i,r.didChange)},r.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.createNewInstance,this.finalizeNewInstance)},r.prototype.initializeChildNodes=function(t,e){void 0===e&&(e=[]);var n=t.type.subType,r=t._environment,i={};return e.forEach(function(e,o){var a=""+o;i[a]=n.instantiate(t,a,r,e)}),i},r.prototype.getChildren=function(t){return t.storedValue.slice()},r.prototype.getChildNode=function(t,e){var n=parseInt(e,10);return n<t.storedValue.length?t.storedValue[n]:W("Not a child: "+e)},r.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=e.type.subType,r=e.getChildren();switch(t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=wt(e,n,[r[t.index]],[t.newValue],[t.index])[0];break;case"splice":var i=t.index,o=t.removedCount,a=t.added;t.added=wt(e,n,r.slice(i,i+o),a,a.map(function(t,e){return i+e}));for(var s=i+o;s<r.length;s++)r[s].setParent(e,""+(s+a.length-o))}return t},r.prototype.getValue=function(t){return t.storedValue},r.prototype.getSnapshot=function(t){return t.getChildren().map(function(t){return t.snapshot})},r.prototype.didChange=function(t){var e=F(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},e);case"splice":for(n=t.removedCount-1;n>=0;n--)e.emitPatch({op:"remove",path:""+(t.index+n),oldValue:t.removed[n].snapshot},e);for(var n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:e.getChildNode(""+(t.index+n)).snapshot,oldValue:void 0},e);return}},r.prototype.applyPatchLocally=function(t,e,n){var r=t.storedValue,i="-"===e?r.length:parseInt(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},r.prototype.applySnapshot=function(t,e){x(this,e),t.storedValue.replace(e)},r.prototype.getChildType=function(t){return this.subType},r.prototype.isValidSnapshot=function(t,e){var n=this;return G(t)?D(t.map(function(t,r){return n.subType.validate(t,O(e,""+r,n.subType))})):E(e,t,"Value is not an array")},r.prototype.getDefaultSnapshot=function(){return Gt},r.prototype.removeChild=function(t,e){t.storedValue.splice(parseInt(e,10),1)},i([e.action],r.prototype,"applySnapshot",null),r}(Lt);!function(t){t.afterCreate="afterCreate",t.afterAttach="afterAttach",t.beforeDetach="beforeDetach",t.beforeDestroy="beforeDestroy"}(te||(te={}));var ie={name:"AnonymousModel",properties:{},initializers:Gt},oe=function(t){function o(e){var n=t.call(this,e.name||ie.name)||this;n.flags=It.Object,n.shouldAttachNode=!0;var r=e.name||ie.name;return/^\w[\w\d_]*$/.test(r)||W("Typename should be a valid identifier: "+r),Object.assign(n,ie,e),n.properties=Vt(n.properties),tt(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return n(o,t),o.prototype._getIdentifierAttribute=function(){var t=void 0;return this.forAllProps(function(e,n){n.flags&It.Identifier&&(t&&W("Cannot define property '"+e+"' as object identifier, property '"+t+"' is already defined as identifier property"),t=e)}),t},o.prototype.cloneAndEnhance=function(t){return new o({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})},o.prototype.actions=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateActions(n,t(n)),n}]})},o.prototype.instantiateActions=function(t,e){q(e)||W("actions initializer should return a plain object containing actions"),Object.keys(e).forEach(function(n){"preProcessSnapshot"===n&&W("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead"),"postProcessSnapshot"===n&&W("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var r=e[n],i=t[n];if(n in te&&i){var o=r;r=function(){i.apply(null,arguments),o.apply(null,arguments)}}rt(t,n,P(t,n,r))})},o.prototype.named=function(t){return this.cloneAndEnhance({name:t})},o.prototype.props=function(t){return this.cloneAndEnhance({properties:t})},o.prototype.volatile=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateVolatileState(n,t(n)),n}]})},o.prototype.instantiateVolatileState=function(t,n){q(n)||W("volatile state initializer should return a plain object containing state"),e.set(t,n)},o.prototype.extend=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){var i=t(n),o=i.actions,a=i.views,s=i.state,u=r(i,["actions","views","state"]);for(var p in u)W("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return s&&e.instantiateVolatileState(n,s),a&&e.instantiateViews(n,a),o&&e.instantiateActions(n,o),n}]})},o.prototype.views=function(t){var e=this;return this.cloneAndEnhance({initializers:[function(n){return e.instantiateViews(n,t(n)),n}]})},o.prototype.instantiateViews=function(t,n){q(n)||W("views initializer should return a plain object containing views"),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r),o=i.value;if("get"in i)if(e.isComputedProp(t,r)){var a=e._getAdministration(t,r);a.derivation=i.get,a.scope=t,i.set&&(a.setter=e.action(a.name+"-setter",i.set))}else e.computed(t,r,i,!0);else"function"==typeof o?rt(t,r,o):W("A view member should either be a function or getter based property")})},o.prototype.preProcessSnapshot=function(t){var e=this.preProcessor;return e?this.cloneAndEnhance({preProcessor:function(n){return e(t(n))}}):this.cloneAndEnhance({preProcessor:t})},o.prototype.postProcessSnapshot=function(t){var e=this.postProcessor;return e?this.cloneAndEnhance({postProcessor:function(n){return t(e(n))}}):this.cloneAndEnhance({postProcessor:t})},o.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,M(r)?r:this.applySnapshotPreProcessor(r),this.createNewInstance,this.finalizeNewInstance)},o.prototype.initializeChildNodes=function(t,e){void 0===e&&(e={});var n={};return t.type.forAllProps(function(r,i){n[r]=i.instantiate(t,r,t._environment,e[r])}),n},o.prototype.createNewInstance=function(){var t=e.observable.object(Bt,Bt,Kt);return rt(t,"toString",St),t},o.prototype.finalizeNewInstance=function(t,n){var r=t,i=r.type,o=r.storedValue;e.extendObservable(o,n,Bt,Kt),i.forAllProps(function(t){e._interceptReads(o,t,r.unbox)}),i.initializers.reduce(function(t,e){return e(t)},o),e.intercept(o,i.willChange),e.observe(o,i.didChange)},o.prototype.willChange=function(t){var e=F(t.object);e.assertWritable();var n=e.type.properties[t.name];return n&&(x(n,t.newValue),t.newValue=n.reconcile(e.getChildNode(t.name),t.newValue)),t},o.prototype.didChange=function(t){var e=F(t.object);if(e.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;e.emitPatch({op:"replace",path:yt(t.name),value:t.newValue.snapshot,oldValue:n},e)}},o.prototype.getChildren=function(t){var e=this,n=[];return this.forAllProps(function(r,i){n.push(e.getChildNode(t,r))}),n},o.prototype.getChildNode=function(t,n){if(!(n in this.properties))return W("Not a value property: "+n);var r=e._getAdministration(t.storedValue,n).value;return r||W("Node not available for property "+n)},o.prototype.getValue=function(t){return t.storedValue},o.prototype.getSnapshot=function(t,n){var r=this;void 0===n&&(n=!0);var i={};return this.forAllProps(function(n,o){e.getAtom(t.storedValue,n).reportObserved(),i[n]=r.getChildNode(t,n).snapshot}),n?this.applySnapshotPostProcessor(i):i},o.prototype.applyPatchLocally=function(t,e,n){"replace"!==n.op&&"add"!==n.op&&W("object does not support operation "+n.op),t.storedValue[e]=n.value},o.prototype.applySnapshot=function(t,e){var n=this.applySnapshotPreProcessor(e);x(this,n),this.forAllProps(function(e,r){t.storedValue[e]=n[e]})},o.prototype.applySnapshotPreProcessor=function(t){var e=this.preProcessor,n=e?e.call(null,t):t;return n&&this.forAllProps(function(t,e){if(!(t in n)){var r=_t(e);r&&(n[t]=r.getDefaultValueSnapshot())}}),n},o.prototype.applySnapshotPostProcessor=function(t){var e=this.postProcessor;return e?e.call(null,t):t},o.prototype.getChildType=function(t){return this.properties[t]},o.prototype.isValidSnapshot=function(t,e){var n=this,r=this.applySnapshotPreProcessor(t);return q(r)?D(this.propertyNames.map(function(t){return n.properties[t].validate(r[t],O(e,t,n.properties[t]))})):E(e,r,"Value is not a plain object")},o.prototype.forAllProps=function(t){var e=this;this.propertyNames.forEach(function(n){return t(n,e.properties[n])})},o.prototype.describe=function(){var t=this;return"{ "+this.propertyNames.map(function(e){return e+": "+t.properties[e].describe()}).join("; ")+" }"},o.prototype.getDefaultSnapshot=function(){return{}},o.prototype.removeChild=function(t,e){t.storedValue[e]=null},i([e.action],o.prototype,"applySnapshot",null),o}(Lt),ae=function(t){function e(e,n,r,i){void 0===i&&(i=Y);var o=t.call(this,e)||this;return o.shouldAttachNode=!1,o.flags=n,o.checker=r,o.initializer=i,o}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r,this.initializer)},e.prototype.isValidSnapshot=function(t,e){return X(t)&&this.checker(t)?I():E(e,t,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))},e}(Ht),se=new ae("string",It.String,function(t){return"string"==typeof t}),ue=new ae("number",It.Number,function(t){return"number"==typeof t}),pe=new ae("boolean",It.Boolean,function(t){return"boolean"==typeof t}),ce=new ae("null",It.Null,function(t){return null===t}),le=new ae("undefined",It.Undefined,function(t){return void 0===t}),he=new ae("Date",It.Date,function(t){return"number"==typeof t||t instanceof Date},function(t){return t instanceof Date?t:new Date(t)});he.getSnapshot=function(t){return t.storedValue.getTime()};var fe=function(t){function e(e){var n=t.call(this,JSON.stringify(e))||this;return n.shouldAttachNode=!1,n.flags=It.Literal,n.value=e,n}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,r)},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.isValidSnapshot=function(t,e){return X(t)&&t===this.value?I():E(e,t,"Value is not a literal "+JSON.stringify(this.value))},e}(Ht),de=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.type=n,o.predicate=r,o.message=i,o}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|It.Refinement},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.instantiate=function(t,e,n,r){return this.type.instantiate(t,e,n,r)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){var n=this.type.validate(t,e);if(n.length>0)return n;var r=M(t)?F(t).snapshot:t;return this.predicate(r)?I():E(e,t,this.message(t))},e}(Ht),ye=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.eager=!0,i.dispatcher=r&&r.dispatcher,r&&!r.eager&&(i.eager=!1),i.types=n,i}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=It.Union;return this.types.forEach(function(e){t|=e.flags}),t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.types.some(function(t){return t.shouldAttachNode})},enumerable:!0,configurable:!0}),e.prototype.isAssignableFrom=function(t){return this.types.some(function(e){return e.isAssignableFrom(t)})},e.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},e.prototype.instantiate=function(t,e,n,r){return this.determineType(r).instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.determineType(e).reconcile(t,e)},e.prototype.determineType=function(t){if(this.dispatcher)return this.dispatcher(t);var e=this.types.filter(function(e){return e.is(t)});return!this.eager&&e.length>1?W("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):e[0]},e.prototype.isValidSnapshot=function(t,e){if(this.dispatcher)return this.dispatcher(t).validate(t,e);var n=this.types.map(function(n){return n.validate(t,e)}),r=n.filter(function(t){return 0===t.length});return!this.eager&&r.length>1?E(e,t,"Multiple types are applicable for the union (hint: provide a dispatch function)"):0===r.length?E(e,t,"No type is applicable for the union").concat(D(n)):I()},e}(Ht),be=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|It.Optional},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.type.shouldAttachNode},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.instantiate=function(t,e,n,r){if(void 0===r){var i=this.getDefaultValueSnapshot();return this.type.instantiate(t,e,n,i)}return this.type.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.type.reconcile(t,this.type.is(e)&&void 0!==e?e:this.getDefaultValue())},e.prototype.getDefaultValue=function(){var t="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&x(this,t),t},e.prototype.getDefaultValueSnapshot=function(){var t=this.getDefaultValue();return M(t)?F(t).snapshot:t},e.prototype.isValidSnapshot=function(t,e){return void 0===t?I():this.type.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.type.isAssignableFrom(t)},e}(Ht),ve=Ot(le,void 0),ge=Ot(ce,null),me=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=null,r.definition=n,r}return n(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|It.Late},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shouldAttachNode",{get:function(){return this.subType.shouldAttachNode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subType",{get:function(){if(null===this._subType){var t=this.definition();"object"!=typeof t&&W("Failed to determine subtype, make sure types.late returns a type definition."),this._subType=t}return this._subType},enumerable:!0,configurable:!0}),e.prototype.instantiate=function(t,e,n,r){return this.subType.instantiate(t,e,n,r)},e.prototype.reconcile=function(t,e){return this.subType.reconcile(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.isValidSnapshot=function(t,e){return this.subType.validate(t,e)},e.prototype.isAssignableFrom=function(t){return this.subType.isAssignableFrom(t)},e}(Ht),we=function(t){function e(e){var n=t.call(this,e?"frozen("+e.name+")":"frozen")||this;return n.subType=e,n.shouldAttachNode=!1,n.flags=It.Frozen,n}return n(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,et(r))},e.prototype.isValidSnapshot=function(t,e){return nt(t)?this.subType?this.subType.validate(t,e):I():E(e,t,"Value is not serializable and cannot be frozen")},e}(Ht),Ae=new we,Pe=function(){function t(t,e,n){if(this.mode=t,this.value=e,this.targetType=n,"object"===t){if(!M(e))return W("Can only store references to tree nodes, got: '"+e+"'");if(!F(e).identifierAttribute)return W("Can only store references with a defined identifier attribute.")}}return Object.defineProperty(t.prototype,"resolvedValue",{get:function(){var t=this,e=t.node,n=t.targetType,r=e.root.identifierCache.resolve(n,this.value);return r?r.value:W("Failed to resolve reference '"+this.value+"' to type '"+this.targetType.name+"' (from node: "+e.path+")")},enumerable:!0,configurable:!0}),i([e.computed],t.prototype,"resolvedValue",null),t}(),Se=function(t){function e(e){var n=t.call(this,"reference("+e.name+")")||this;return n.targetType=e,n.shouldAttachNode=!1,n.flags=It.Reference,n}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return this.targetType.isAssignableFrom(t)},e.prototype.isValidSnapshot=function(t,e){return"string"==typeof t||"number"==typeof t?I():E(e,t,"Value is not a valid identifier, which is a string or a number")},e}(Ht),Ve=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive){var e=t.storedValue;return"object"===e.mode?e.value:e.resolvedValue}},e.prototype.getSnapshot=function(t){var e=t.storedValue;switch(e.mode){case"identifier":return e.value;case"object":return e.value[F(e.value).identifierAttribute]}},e.prototype.instantiate=function(t,e,n,r){var i,o=M(r)?"object":"identifier",a=z(this,t,e,n,i=new Pe(o,r,this.targetType));return i.node=a,a},e.prototype.reconcile=function(t,e){if(t.type===this){var n=M(e)?"object":"identifier",r=t.storedValue;if(n===r.mode&&r.value===e)return t}var i=this.instantiate(t.parent,t.subpath,t._environment,e);return t.die(),i},e}(Se),_e=function(t){function e(e,n){var r=t.call(this,e)||this;return r.options=n,r}return n(e,t),e.prototype.getValue=function(t){if(t.isAlive)return this.options.get(t.storedValue,t.parent?t.parent.storedValue:null)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,M(r)?this.options.set(r,t?t.storedValue:null):r)},e.prototype.reconcile=function(t,e){var n=M(e)?this.options.set(e,t?t.storedValue:null):e;if(t.type===this&&t.storedValue===n)return t;var r=this.instantiate(t.parent,t.subpath,t._environment,n);return t.die(),r},e}(Se),Ne=function(t){function e(){var e=t.call(this,"identifier")||this;return e.shouldAttachNode=!1,e.flags=It.Identifier,e}return n(e,t),e.prototype.instantiate=function(t,e,n,r){return t&&t.type instanceof oe||W("Identifier types can only be instantiated as direct child of a model type"),z(this,t,e,n,r)},e.prototype.reconcile=function(t,e){return t.storedValue!==e?W("Tried to change identifier from '"+t.storedValue+"' to '"+e+"'. Changing identifiers is not allowed."):t},e.prototype.describe=function(){return"identifier"},e.prototype.isValidSnapshot=function(t,e){return"string"!=typeof t?E(e,t,"Value is not a valid identifier, expected a string"):I()},e}(Ht),Ce=function(t){function e(){var e=t.call(this)||this;return e.name="identifierNumber",e}return n(e,t),e.prototype.instantiate=function(e,n,r,i){return t.prototype.instantiate.call(this,e,n,r,i)},e.prototype.isValidSnapshot=function(t,e){return"number"==typeof t?I():E(e,t,"Value is not a valid identifierNumber, expected a number")},e.prototype.reconcile=function(e,n){return t.prototype.reconcile.call(this,e,n)},e.prototype.getSnapshot=function(t){return t.storedValue},e.prototype.describe=function(){return"identifierNumber"},e}(Ne),Te=new Ne,je=new Ce,Oe=function(t){function e(e){var n=t.call(this,e.name)||this;return n.options=e,n.flags=It.Reference,n.shouldAttachNode=!1,n}return n(e,t),e.prototype.describe=function(){return this.name},e.prototype.isAssignableFrom=function(t){return t===this},e.prototype.isValidSnapshot=function(t,e){if(this.options.isTargetType(t))return I();var n=this.options.getValidationMessage(t);return n?E(e,t,"Invalid value for type '"+this.name+"': "+n):I()},e.prototype.getValue=function(t){if(t.isAlive)return t.storedValue},e.prototype.getSnapshot=function(t){return this.options.toSnapshot(t.storedValue)},e.prototype.instantiate=function(t,e,n,r){return z(this,t,e,n,this.options.isTargetType(r)?r:this.options.fromSnapshot(r))},e.prototype.reconcile=function(t,e){var n=!this.options.isTargetType(e);if(t.type===this&&(n?e===t.snapshot:e===t.storedValue))return t;var r=n?this.options.fromSnapshot(e):e,i=this.instantiate(t.parent,t.subpath,t._environment,r);return t.die(),i},e}(Ht),Ie={enumeration:function(t,e){var n="string"==typeof t?e:t,r=jt.apply(void 0,n.map(function(t){return Tt(""+t)}));return"string"==typeof t&&(r.name=t),r},model:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel",r=t.shift()||{};return new oe({name:n,properties:r})},compose:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():"AnonymousModel";return t.reduce(function(t,e){return t.cloneAndEnhance({name:t.name+"_"+e.name,properties:e.properties,initializers:e.initializers})}).named(n)},custom:function(t){return new Oe(t)},reference:function(t,e){return e?new _e(t,e):new Ve(t)},union:jt,optional:Ot,literal:Tt,maybe:function(t){return jt(t,ve)},maybeNull:function(t){return jt(t,ge)},refinement:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="string"==typeof t[0]?t.shift():h(t[0])?t[0].name:null,r=t[0],i=t[1],o=t[2]?t[2]:function(t){return"Value does not respect the refinement predicate"};return new de(n,r,i,o)},string:se,boolean:pe,number:ue,Date:he,map:function(t){return new ne("map<string, "+t.name+">",t)},array:function(t){return new re(t.name+"[]",t)},frozen:function(t){return 0===arguments.length?Ae:h(t)?new we(t):Ot(Ae,t)},identifier:Te,identifierNumber:je,late:function(t,e){var n="string"==typeof t?t:"late("+t.toString()+")";return new me(n,"string"==typeof t?e:t)},undefined:le,null:ce};t.types=Ie,t.typecheck=R,t.escapeJsonPath=yt,t.unescapeJsonPath=bt,t.joinJsonPath=vt,t.splitJsonPath=gt,t.decorate=function(t,e){var n={handler:t,includeHooks:!0};return e.$mst_middleware?e.$mst_middleware.push(n):e.$mst_middleware=[n],e},t.addMiddleware=S,t.process=function(t){return qt("process","`process()` has been renamed to `flow()`. "+Zt),pt(t)},t.isStateTreeNode=M,t.flow=pt,t.applyAction=b,t.onAction=g,t.recordActions=function(t){var e={actions:[],stop:function(){return n()},replay:function(t){b(t,e.actions)}},n=g(t,e.actions.push.bind(e.actions));return e},t.createActionTrackingMiddleware=function(t){return function(e,n,r){switch(e.type){case"action":if(t.filter&&!0!==t.filter(e))return n(e);var i=t.onStart(e);t.onResume(e,i),Ut.set(e.id,{call:e,context:i,async:!1});try{var o=n(e);return t.onSuspend(e,i),!1===Ut.get(e.id).async&&(Ut.delete(e.id),t.onSuccess(e,i,o)),o}catch(n){throw Ut.delete(e.id),t.onFail(e,i,n),n}case"flow_spawn":return(a=Ut.get(e.rootId)).async=!0,n(e);case"flow_resume":case"flow_resume_error":a=Ut.get(e.rootId),t.onResume(e,a.context);try{return n(e)}finally{t.onSuspend(e,a.context)}case"flow_throw":return a=Ut.get(e.rootId),Ut.delete(e.id),t.onFail(e,a.context,e.args[0]),n(e);case"flow_return":var a=Ut.get(e.rootId);return Ut.delete(e.id),t.onSuccess(e,a.context,e.args[0]),n(e)}}},t.setLivelynessChecking=function(t){zt=t},t.getType=o,t.getChildType=function(t,e){return F(t).getChildType(e)},t.onPatch=a,t.onSnapshot=function(t,e){return F(t).onSnapshot(e)},t.applyPatch=s,t.recordPatches=function(t){function e(){n||(n=a(t,function(t,e){r.rawPatches.push([t,e])}))}var n=null,r={rawPatches:[],get patches(){return this.rawPatches.map(function(t){return t[0]})},get inversePatches(){return this.rawPatches.map(function(t){return t[0],t[1]})},stop:function(){n&&n(),n=null},resume:e,replay:function(e){s(e||t,r.patches)},undo:function(e){s(e||t,r.inversePatches.slice().reverse())}};return e(),r},t.protect=function(t){var e=F(t);e.isRoot||W("`protect` can only be invoked on root nodes"),e.isProtectionEnabled=!0},t.unprotect=function(t){var e=F(t);e.isRoot||W("`unprotect` can only be invoked on root nodes"),e.isProtectionEnabled=!1},t.isProtected=function(t){return F(t).isProtected},t.applySnapshot=u,t.getSnapshot=function(t,e){void 0===e&&(e=!0);var n=F(t);return e?n.snapshot:tt(n.type.getSnapshot(n,!1))},t.hasParent=function(t,e){void 0===e&&(e=1);for(var n=F(t).parent;n;){if(0==--e)return!0;n=n.parent}return!1},t.getParent=function(t,e){void 0===e&&(e=1);for(var n=e,r=F(t).parent;r;){if(0==--n)return r.storedValue;r=r.parent}return W("Failed to find the parent of "+F(t)+" at depth "+e)},t.hasParentOfType=function(t,e){for(var n=F(t).parent;n;){if(e.is(n.storedValue))return!0;n=n.parent}return!1},t.getParentOfType=function(t,e){for(var n=F(t).parent;n;){if(e.is(n.storedValue))return n.storedValue;n=n.parent}return W("Failed to find the parent of "+F(t)+" of a given type")},t.getRoot=p,t.getPath=function(t){return F(t).path},t.getPathParts=function(t){return gt(F(t).path)},t.isRoot=function(t){return F(t).isRoot},t.resolvePath=function(t,e){var n=U(F(t),e);return n?n.value:void 0},t.resolveIdentifier=function(t,e,n){var r=F(e).root.identifierCache.resolve(t,""+n);return r?r.value:void 0},t.getIdentifier=function(t){return F(t).identifier},t.tryResolve=c,t.getRelativePath=function(t,e){return H(F(t),F(e))},t.clone=function(t,e){void 0===e&&(e=!0);var n=F(t);return n.type.create(n.snapshot,!0===e?n.root._environment:!1===e?void 0:e)},t.detach=function(t){return F(t).detach(),t},t.destroy=function(t){var e=F(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)},t.isAlive=function(t){return F(t).isAlive},t.addDisposer=function(t,e){F(t).addDisposer(e)},t.getEnv=function(t){var e=F(t).root._environment;return e||Bt},t.walk=l,t.getMembers=function(t){var n=F(t).type,r=Object.getOwnPropertyNames(t),i={name:n.name,properties:Dt({},n.properties),actions:[],volatile:[],views:[]};return r.forEach(function(n){if(!(n in i.properties)){var r=Object.getOwnPropertyDescriptor(t,n);r.get?e.isComputedProp(t,n)?i.views.push(n):i.volatile.push(n):!0===r.value._isMSTAction?i.actions.push(n):e.isObservableProp(t,n)?i.volatile.push(n):i.views.push(n)}}),i},Object.defineProperty(t,"__esModule",{value:!0})}); |
import { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "mobx"; | ||
import { IJsonPatch, INode, IContext, IValidationResult, ComplexType, IComplexType, IType, TypeFlags, ObjectNode } from "../../internal"; | ||
export declare class ArrayType<S, T> extends ComplexType<S[], IObservableArray<T>> { | ||
import { IJsonPatch, INode, IContext, IValidationResult, ComplexType, IComplexType, IType, TypeFlags, ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; | ||
export declare class ArrayType<C, S, T> extends ComplexType<C[], S[], IObservableArray<T>> { | ||
shouldAttachNode: boolean; | ||
subType: IType<any, any>; | ||
subType: IAnyType; | ||
readonly flags: TypeFlags; | ||
constructor(name: string, subType: IType<any, any>); | ||
constructor(name: string, subType: IAnyType); | ||
describe(): string; | ||
createNewInstance: () => IObservableArray<never>; | ||
finalizeNewInstance: (node: INode, snapshot: any) => void; | ||
createNewInstance(childNodes: IChildNodesMap): IObservableArray<INode>; | ||
finalizeNewInstance(node: INode): void; | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: S): INode; | ||
initializeChildNodes(objNode: ObjectNode, snapshot?: S[]): IChildNodesMap; | ||
getChildren(node: ObjectNode): INode[]; | ||
@@ -20,5 +21,5 @@ getChildNode(node: ObjectNode, key: string): INode; | ||
applySnapshot(node: ObjectNode, snapshot: any[]): void; | ||
getChildType(key: string): IType<any, any>; | ||
getChildType(key: string): IAnyType; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
getDefaultSnapshot(): never[]; | ||
getDefaultSnapshot(): ReadonlyArray<any>; | ||
removeChild(node: ObjectNode, subpath: string): void; | ||
@@ -50,3 +51,3 @@ } | ||
*/ | ||
export declare function array<S, T>(subtype: IType<S, T>): IComplexType<S[], IObservableArray<T>>; | ||
export declare function isArrayType<S, T>(type: any): type is IComplexType<S[], IObservableArray<T>>; | ||
export declare function array<C, S, T>(subtype: IType<C, S, T>): IComplexType<ReadonlyArray<C>, ReadonlyArray<S>, IObservableArray<T>>; | ||
export declare function isArrayType<C, S, T>(type: any): type is IComplexType<C[], S[], IObservableArray<T>>; |
@@ -1,5 +0,41 @@ | ||
import { ObservableMap, IMapWillChange, IMapDidChange } from "mobx"; | ||
import { IJsonPatch, INode, IType, IComplexType, ComplexType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
export interface IExtendedObservableMap<T> extends ObservableMap<string, T> { | ||
put(value: T | any): this; | ||
import { IMapWillChange, IMapDidChange, IKeyValueMap, Lambda, IInterceptor } from "mobx"; | ||
import { IJsonPatch, INode, IType, IComplexType, ComplexType, TypeFlags, IContext, IValidationResult, ObjectNode, IChildNodesMap, IAnyType } from "../../internal"; | ||
export interface IMSTMap<C, S, T> { | ||
clear(): void; | ||
delete(key: string): boolean; | ||
forEach(callbackfn: (value: T, key: string, map: IMSTMap<C, S, T>) => void, thisArg?: any): void; | ||
get(key: string): T | undefined; | ||
has(key: string): boolean; | ||
set(key: string, value: C | S | T): this; | ||
readonly size: number; | ||
put(value: C | S | T): T; | ||
keys(): IterableIterator<string>; | ||
values(): IterableIterator<T>; | ||
entries(): IterableIterator<[string, T]>; | ||
[Symbol.iterator](): IterableIterator<[string, T]>; | ||
/** Merge another object into this map, returns self. */ | ||
merge(other: IMSTMap<any, any, T> | IKeyValueMap<C | S | T> | any): this; | ||
clear(): void; | ||
replace(values: IMSTMap<any, any, T> | IKeyValueMap<T>): this; | ||
/** | ||
* Returns a plain object that represents this map. | ||
* Note that all the keys being stringified. | ||
* If there are duplicating keys after converting them to strings, behaviour is undetermined. | ||
*/ | ||
toPOJO(): IKeyValueMap<T>; | ||
/** | ||
* Returns a shallow non observable object clone of this map. | ||
* Note that the values migth still be observable. For a deep clone use mobx.toJS. | ||
*/ | ||
toJS(): Map<string, T>; | ||
toJSON(): IKeyValueMap<T>; | ||
toString(): string; | ||
[Symbol.toStringTag]: "Map"; | ||
/** | ||
* Observes this object. Triggers for the events 'add', 'update' and 'delete'. | ||
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe | ||
* for callback details | ||
*/ | ||
observe(listener: (changes: IMapDidChange<string, T>) => void, fireImmediately?: boolean): Lambda; | ||
intercept(handler: IInterceptor<IMapWillChange<string, T>>): Lambda; | ||
} | ||
@@ -11,15 +47,15 @@ export declare enum MapIdentifierMode { | ||
} | ||
export declare class MapType<S, T> extends ComplexType<{ | ||
[key: string]: S; | ||
}, IExtendedObservableMap<T>> { | ||
export declare class MapType<C, S, T> extends ComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IMSTMap<C, S, T>> { | ||
shouldAttachNode: boolean; | ||
subType: IType<any, any>; | ||
subType: IAnyType; | ||
identifierMode: MapIdentifierMode; | ||
identifierAttribute: string | undefined; | ||
readonly flags: TypeFlags; | ||
constructor(name: string, subType: IType<any, any>); | ||
constructor(name: string, subType: IAnyType); | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: S): INode; | ||
private _determineIdentifierMode(); | ||
initializeChildNodes(objNode: ObjectNode, initialSnapshot?: any): IChildNodesMap; | ||
describe(): string; | ||
createNewInstance: () => ObservableMap<any, any>; | ||
finalizeNewInstance: (node: INode, snapshot: any) => void; | ||
createNewInstance(childNodes: IChildNodesMap): IMSTMap<any, any, any>; | ||
finalizeNewInstance(node: INode): void; | ||
getChildren(node: ObjectNode): ReadonlyArray<INode>; | ||
@@ -30,9 +66,7 @@ getChildNode(node: ObjectNode, key: string): INode; | ||
getValue(node: ObjectNode): any; | ||
getSnapshot(node: ObjectNode): { | ||
[key: string]: any; | ||
}; | ||
getSnapshot(node: ObjectNode): IKeyValueMap<S>; | ||
didChange(change: IMapDidChange<any, any>): void; | ||
applyPatchLocally(node: ObjectNode, subpath: string, patch: IJsonPatch): void; | ||
applySnapshot(node: ObjectNode, snapshot: any): void; | ||
getChildType(key: string): IType<any, any>; | ||
getChildType(key: string): IAnyType; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
@@ -42,7 +76,3 @@ getDefaultSnapshot(): {}; | ||
} | ||
export declare function map<S, T>(subtype: IComplexType<S, T>): IComplexType<{ | ||
[key: string]: S; | ||
}, IExtendedObservableMap<T>>; | ||
export declare function isMapType<S, T>(type: any): type is IComplexType<{ | ||
[key: string]: S; | ||
}, IExtendedObservableMap<T>>; | ||
export declare function map<C, S, T>(subtype: IType<C, S, T>): IComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IMSTMap<C, S, T>>; | ||
export declare function isMapType<C, S, T>(type: any): type is IComplexType<IKeyValueMap<C>, IKeyValueMap<S>, IMSTMap<C, S, T>>; |
@@ -1,58 +0,119 @@ | ||
import { IObjectWillChange } from "mobx"; | ||
import { IStateTreeNode, IJsonPatch, INode, ComplexType, IComplexType, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
import { IObjectWillChange, IObservableArray } from "mobx"; | ||
import { IStateTreeNode, IJsonPatch, INode, ComplexType, IComplexType, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IChildNodesMap, IAnyType, IMSTMap } from "../../internal"; | ||
export declare enum HookNames { | ||
afterCreate = "afterCreate", | ||
afterAttach = "afterAttach", | ||
postProcessSnapshot = "postProcessSnapshot", | ||
beforeDetach = "beforeDetach", | ||
beforeDestroy = "beforeDestroy", | ||
} | ||
export declare type ModelProperties = { | ||
[key: string]: IAnyType; | ||
}; | ||
export declare type ModelPrimitive = string | number | boolean | Date; | ||
export declare type ModelPropertiesDeclaration = { | ||
[key: string]: ModelPrimitive | IAnyType; | ||
}; | ||
/** | ||
* Unmaps syntax property declarations to a map of { propName: IType } | ||
*/ | ||
export declare type ModelPropertiesDeclarationToProperties<T extends ModelPropertiesDeclaration> = { | ||
[K in keyof T]: T[K] extends string ? IType<string | undefined, string, string> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends number ? IType<number | undefined, number, number> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends boolean ? IType<boolean | undefined, boolean, boolean> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends Date ? IType<number | undefined, number, Date> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends (IComplexType<infer C, infer S, IObservableArray<infer A>>) ? IComplexType<C, S, IObservableArray<A>> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends (IComplexType<infer C, infer S, IMSTMap<infer X, infer Y, infer Z>>) ? IComplexType<C, S, IMSTMap<X, Y, Z>> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends IType<infer C, infer S, infer A> & { | ||
flags: TypeFlags.Optional; | ||
} ? IType<C, S, A> & { | ||
flags: TypeFlags.Optional; | ||
} : T[K] extends IType<infer C, infer S, infer A> ? IType<C, S, A> : never; | ||
}; | ||
export declare type OptionalPropertyTypes = ModelPrimitive | { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare type RequiredPropNames<T> = { | ||
[K in keyof T]: T[K] extends OptionalPropertyTypes ? never : undefined extends T[K] ? never : K; | ||
}[keyof T]; | ||
export declare type RequiredProps<T> = Pick<T, RequiredPropNames<T>>; | ||
export declare type OptionalPropNames<T> = { | ||
[K in keyof T]: T[K] extends OptionalPropertyTypes ? K : never; | ||
}[keyof T]; | ||
export declare type OptionalProps<T> = Pick<T, OptionalPropNames<T>>; | ||
/** | ||
* Maps property types to the snapshot, including omitted optional attributes | ||
*/ | ||
export declare type ModelCreationType<T extends ModelProperties> = { | ||
readonly [K in keyof RequiredProps<T>]: T[K] extends IType<infer X, any, infer Y> ? X | Y : never; | ||
} & { | ||
readonly [K in keyof OptionalProps<T>]?: T[K] extends IType<infer X, any, infer Y> ? X | Y : never; | ||
}; | ||
export declare type ModelSnapshotType<T extends ModelProperties> = { | ||
readonly [K in keyof RequiredProps<T>]: T[K] extends IType<any, infer X, any> ? X : never; | ||
} & { | ||
readonly [K in keyof OptionalProps<T>]: T[K] extends IType<any, infer X, any> ? X : never; | ||
}; | ||
export declare type ModelInstanceType<T extends ModelProperties, O> = { | ||
[K in keyof T]: T[K] extends IType<any, any, infer X> ? X : never; | ||
} & O & IStateTreeNode; | ||
export declare type ModelActions = { | ||
[key: string]: Function; | ||
}; | ||
export interface IModelType<PROPS extends ModelProperties, OTHERS, C = ModelCreationType<PROPS>, S = ModelSnapshotType<PROPS>, T = ModelInstanceType<PROPS, OTHERS>> extends IComplexType<C, S, T> { | ||
readonly properties: PROPS; | ||
named(newName: string): this; | ||
props<PROPS2 extends ModelPropertiesDeclaration>(props: PROPS2): IModelType<PROPS & ModelPropertiesDeclarationToProperties<PROPS2>, OTHERS>; | ||
views<V extends Object>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => V): IModelType<PROPS, OTHERS & V>; | ||
actions<A extends ModelActions>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => A): IModelType<PROPS, OTHERS & A>; | ||
volatile<TP extends object>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => TP): IModelType<PROPS, OTHERS & TP>; | ||
extend<A extends ModelActions = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: ModelInstanceType<PROPS, OTHERS>) => { | ||
actions?: A; | ||
views?: V; | ||
state?: VS; | ||
}): IModelType<PROPS, OTHERS & A & V & VS>; | ||
preProcessSnapshot<S0 = ModelCreationType<PROPS>>(fn: (snapshot: S0) => ModelCreationType<PROPS>): IModelType<PROPS, OTHERS, S0>; | ||
postProcessSnapshot<S1 = ModelCreationType<PROPS>>(fn: (snapshot: ModelSnapshotType<PROPS>) => S1): IModelType<PROPS, OTHERS, S1>; | ||
} | ||
export declare type ModelTypeConfig = { | ||
name?: string; | ||
properties?: { | ||
[K: string]: IType<any, any>; | ||
}; | ||
properties?: ModelProperties; | ||
initializers?: ReadonlyArray<((instance: any) => any)>; | ||
preProcessor?: (snapshot: any) => any; | ||
postProcessor?: (snapshot: any) => any; | ||
}; | ||
export declare class ModelType<S, T> extends ComplexType<S, T> implements IModelType<S, T> { | ||
export declare class ModelType<S extends ModelProperties, T> extends ComplexType<any, any, any> implements IModelType<S, T> { | ||
readonly flags: TypeFlags; | ||
shouldAttachNode: boolean; | ||
readonly identifierAttribute: string | undefined; | ||
readonly initializers: ((instance: any) => any)[]; | ||
readonly properties: { | ||
[K: string]: IType<any, any>; | ||
}; | ||
readonly properties: any; | ||
private preProcessor; | ||
private postProcessor; | ||
private readonly propertyNames; | ||
constructor(opts: ModelTypeConfig); | ||
readonly propertyNames: string[]; | ||
private _getIdentifierAttribute(); | ||
cloneAndEnhance(opts: ModelTypeConfig): ModelType<any, any>; | ||
actions<A extends { | ||
[name: string]: Function; | ||
}>(fn: (self: T) => A): IModelType<S, T & A>; | ||
instantiateActions(self: T, actions: { | ||
[name: string]: Function; | ||
}): void; | ||
named(name: string): IModelType<S, T>; | ||
props<SP, TP>(properties: { | ||
[K in keyof TP]: IType<any, TP[K]> | TP[K]; | ||
} & { | ||
[K in keyof SP]: IType<SP[K], any> | SP[K]; | ||
}): IModelType<S & SP, T & TP>; | ||
volatile<TP>(fn: (self: T) => TP): IModelType<S, T & TP>; | ||
actions(fn: (self: any) => any): any; | ||
instantiateActions(self: T, actions: any): void; | ||
named(name: string): this; | ||
props(properties: ModelPropertiesDeclaration): any; | ||
volatile(fn: (self: any) => any): any; | ||
instantiateVolatileState(self: T, state: Object): void; | ||
extend<A extends { | ||
[name: string]: Function; | ||
} = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: T & IStateTreeNode) => { | ||
actions?: A; | ||
views?: V; | ||
state?: VS; | ||
}): IModelType<S, T & A & V & VS>; | ||
views<V extends Object>(fn: (self: T) => V): IModelType<S, T & V>; | ||
extend(fn: (self: any) => any): any; | ||
views(fn: (self: any) => any): any; | ||
instantiateViews(self: T, views: Object): void; | ||
preProcessSnapshot(preProcessor: (snapshot: any) => S): IModelType<S, T>; | ||
preProcessSnapshot(preProcessor: (snapshot: any) => any): any; | ||
postProcessSnapshot(postProcessor: (snapshot: any) => any): any; | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: any): INode; | ||
createNewInstance: () => Object; | ||
finalizeNewInstance: (node: INode, snapshot: any) => void; | ||
initializeChildNodes(objNode: ObjectNode, initialSnapshot?: any): IChildNodesMap; | ||
createNewInstance(): Object; | ||
finalizeNewInstance(node: INode, childNodes: IChildNodesMap): void; | ||
willChange(change: any): IObjectWillChange | null; | ||
didChange: (change: any) => void; | ||
didChange(change: any): void; | ||
getChildren(node: ObjectNode): INode[]; | ||
@@ -65,3 +126,4 @@ getChildNode(node: ObjectNode, key: string): INode; | ||
applySnapshotPreProcessor(snapshot: any): any; | ||
getChildType(key: string): IType<any, any>; | ||
applySnapshotPostProcessor(snapshot: any): any; | ||
getChildType(key: string): IAnyType; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
@@ -73,39 +135,12 @@ private forAllProps(fn); | ||
} | ||
export interface IModelType<S, T> extends IComplexType<S, T & IStateTreeNode> { | ||
readonly properties: { | ||
readonly [K: string]: IType<any, any>; | ||
}; | ||
named(newName: string): IModelType<S, T>; | ||
props<SP, TP>(props: { | ||
[K in keyof TP]: IType<any, TP[K]> | TP[K]; | ||
} & { | ||
[K in keyof SP]: IType<SP[K], any> | SP[K]; | ||
}): IModelType<S & Snapshot<SP>, T & TP>; | ||
views<V extends Object>(fn: (self: T & IStateTreeNode) => V): IModelType<S, T & V>; | ||
actions<A extends { | ||
[name: string]: Function; | ||
}>(fn: (self: T & IStateTreeNode) => A): IModelType<S, T & A>; | ||
volatile<TP>(fn: (self: T) => TP): IModelType<S, T & TP>; | ||
extend<A extends { | ||
[name: string]: Function; | ||
} = {}, V extends Object = {}, VS extends Object = {}>(fn: (self: T & IStateTreeNode) => { | ||
actions?: A; | ||
views?: V; | ||
state?: VS; | ||
}): IModelType<S, T & A & V & VS>; | ||
preProcessSnapshot(fn: (snapshot: any) => S): IModelType<S, T>; | ||
} | ||
export declare type IModelProperties<T> = { | ||
[K in keyof T]: IType<any, T[K]> | T[K]; | ||
}; | ||
export declare type IModelVolatileState<T> = { | ||
[K in keyof T]: ((self?: any) => T[K]) | T[K]; | ||
}; | ||
export declare type Snapshot<T> = { | ||
[K in keyof T]?: Snapshot<T[K]> | any; | ||
}; | ||
export declare function model<T = {}>(name: string, properties?: IModelProperties<T>): IModelType<Snapshot<T>, T>; | ||
export declare function model<T = {}>(properties?: IModelProperties<T>): IModelType<Snapshot<T>, T>; | ||
export declare function compose<T1, S1, T2, S2, T3, S3>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3?: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>; | ||
export declare function compose<T1, S1, A1, T2, S2, A2, T3, S3, A3>(name: string, t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3?: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>; | ||
export declare function isObjectType(type: any): type is ModelType<any, any>; | ||
export declare function model<T extends ModelPropertiesDeclaration = {}>(name: string, properties?: T): IModelType<ModelPropertiesDeclarationToProperties<T>, {}>; | ||
export declare function model<T extends ModelPropertiesDeclaration = {}>(properties?: T): IModelType<ModelPropertiesDeclarationToProperties<T>, {}>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>): IModelType<T1 & T2, S1 & S2>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>): IModelType<T1 & T2 & T3, S1 & S2 & S3>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>): IModelType<T1 & T2 & T3 & T4, S1 & S2 & S3 & S4>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>): IModelType<T1 & T2 & T3 & T4 & T5, S1 & S2 & S3 & S4 & S5>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>): IModelType<T1 & T2 & T3 & T4 & T5 & T6, S1 & S2 & S3 & S4 & S5 & S6>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7, S1 & S2 & S3 & S4 & S5 & S6 & S7>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7, T8 extends ModelProperties, S8>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>, t8: IModelType<T8, S8>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8>; | ||
export declare function compose<T1 extends ModelProperties, S1, T2 extends ModelProperties, S2, T3 extends ModelProperties, S3, T4 extends ModelProperties, S4, T5 extends ModelProperties, S5, T6 extends ModelProperties, S6, T7 extends ModelProperties, S7, T8 extends ModelProperties, S8, T9 extends ModelProperties, S9>(t1: IModelType<T1, S1>, t2: IModelType<T2, S2>, t3: IModelType<T3, S3>, t4: IModelType<T4, S4>, t5: IModelType<T5, S5>, t6: IModelType<T6, S6>, t7: IModelType<T7, S7>, t8: IModelType<T8, S8>, t9: IModelType<T9, S9>): IModelType<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9>; | ||
export declare function isModelType(type: any): type is ModelType<any, any>; |
import { Type, INode, ISimpleType, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../internal"; | ||
export declare class CoreType<S, T> extends Type<S, T> { | ||
export declare class CoreType<S, T> extends Type<S, S, T> { | ||
readonly shouldAttachNode: boolean; | ||
@@ -77,4 +77,4 @@ readonly checker: (value: any) => boolean; | ||
*/ | ||
export declare const DatePrimitive: IType<number, Date>; | ||
export declare const DatePrimitive: IType<number, number, Date>; | ||
export declare function getPrimitiveFactoryFromValue(value: any): ISimpleType<any>; | ||
export declare function isPrimitiveType(type: any): type is CoreType<any, any>; |
@@ -1,2 +0,2 @@ | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IAnyType } from "../../internal"; | ||
export declare type CustomTypeOptions<S, T> = { | ||
@@ -54,4 +54,4 @@ name: string; | ||
*/ | ||
export declare function custom<S, T>(options: CustomTypeOptions<S, T>): IType<S, T>; | ||
export declare class CustomType<S, T> extends Type<S, T> { | ||
export declare function custom<S, T>(options: CustomTypeOptions<S, T>): IType<S | T, S, T>; | ||
export declare class CustomType<S, T> extends Type<S, S, T> { | ||
protected readonly options: CustomTypeOptions<S, T>; | ||
@@ -62,3 +62,3 @@ readonly flags: TypeFlags; | ||
describe(): string; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
@@ -65,0 +65,0 @@ getValue(node: INode): any; |
@@ -1,6 +0,7 @@ | ||
import { INode, ISimpleType, Type, IContext, IValidationResult, TypeFlags, ObjectNode } from "../../internal"; | ||
export declare class Frozen<T> extends Type<T, T> { | ||
import { INode, Type, IContext, IValidationResult, TypeFlags, ObjectNode, IType, ISimpleType } from "../../internal"; | ||
export declare class Frozen<T> extends Type<T, T, T> { | ||
private subType; | ||
readonly shouldAttachNode: boolean; | ||
flags: TypeFlags; | ||
constructor(); | ||
constructor(subType?: IType<any, any, any> | undefined); | ||
describe(): string; | ||
@@ -10,28 +11,6 @@ instantiate(parent: ObjectNode | null, subpath: string, environment: any, value: any): INode; | ||
} | ||
/** | ||
* Frozen can be used to story any value that is serializable in itself (that is valid JSON). | ||
* Frozen values need to be immutable or treated as if immutable. They need be serializable as well. | ||
* Values stored in frozen will snapshotted as-is by MST, and internal changes will not be tracked. | ||
* | ||
* This is useful to store complex, but immutable values like vectors etc. It can form a powerful bridge to parts of your application that should be immutable, or that assume data to be immutable. | ||
* | ||
* Note: if you want to store free-form state that is mutable, or not serializeable, consider using volatile state instead. | ||
* | ||
* @example | ||
* const GameCharacter = types.model({ | ||
* name: string, | ||
* location: types.frozen | ||
* }) | ||
* | ||
* const hero = GameCharacter.create({ | ||
* name: "Mario", | ||
* location: { x: 7, y: 4 } | ||
* }) | ||
* | ||
* hero.location = { x: 10, y: 2 } // OK | ||
* hero.location.x = 7 // Not ok! | ||
* | ||
* @alias types.frozen | ||
*/ | ||
export declare const frozen: ISimpleType<any>; | ||
export declare type CreationTypeOf<T extends IType<any, any, any>> = T extends IType<infer C, any, any> ? C : never; | ||
export declare function frozen<T extends IType<any, any, any>>(subType: T): ISimpleType<CreationTypeOf<T>>; | ||
export declare function frozen<T>(defaultValue: T): IType<T | undefined, T, Readonly<T>>; | ||
export declare function frozen<T = any>(): IType<T | undefined, T | undefined, Readonly<T> | undefined>; | ||
export declare function isFrozenType(type: any): type is Frozen<any>; |
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
export declare class IdentifierType<T> extends Type<T, T> { | ||
readonly identifierType: IType<T, T>; | ||
export declare class IdentifierType extends Type<string, string, string> { | ||
readonly shouldAttachNode: boolean; | ||
readonly flags: TypeFlags; | ||
constructor(identifierType: IType<T, T>); | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: T): INode; | ||
reconcile(current: INode, newValue: any): INode; | ||
constructor(); | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: string): INode; | ||
reconcile(current: INode, newValue: string): INode; | ||
describe(): string; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
} | ||
export declare function identifier<T>(baseType: IType<T, T>): IType<T, T>; | ||
export declare function identifier<T>(): T; | ||
export declare function isIdentifierType(type: any): type is IdentifierType<any>; | ||
export declare class IdentifierNumberType extends IdentifierType { | ||
constructor(); | ||
instantiate(parent: ObjectNode | null, subpath: string, environment: any, snapshot: any): INode; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
reconcile(current: INode, newValue: any): INode; | ||
getSnapshot(node: INode): any; | ||
describe(): string; | ||
} | ||
/** | ||
* Identifiers are used to make references, lifecycle events and reconciling works. | ||
* Inside a state tree, for each type can exist only one instance for each given identifier. | ||
* For example there couldn't be 2 instances of user with id 1. If you need more, consider using references. | ||
* Identifier can be used only as type property of a model. | ||
* This type accepts as parameter the value type of the identifier field that can be either string or number. | ||
* | ||
* @example | ||
* const Todo = types.model("Todo", { | ||
* id: types.identifier, | ||
* title: types.string | ||
* }) | ||
* | ||
* @export | ||
* @alias types.identifier | ||
* @template T | ||
* @returns {IType<T, T>} | ||
*/ | ||
export declare const identifier: IType<string, string, string>; | ||
/** | ||
* Similar to `types.identifier`, but `identifierNumber` will serialize from / to a number when applying snapshots | ||
* | ||
* @example | ||
* const Todo = types.model("Todo", { | ||
* id: types.identifierNumber, | ||
* title: types.string | ||
* }) | ||
* | ||
* @export | ||
* @alias types.identifierNumber | ||
* @template T | ||
* @returns {IType<T, T>} | ||
*/ | ||
export declare const identifierNumber: IType<number, number, number>; | ||
export declare function isIdentifierType(type: any): type is IdentifierType | IdentifierNumberType; |
@@ -1,9 +0,9 @@ | ||
import { INode, Type, IType, IContext, IValidationResult } from "../../internal"; | ||
export declare class Late<S, T> extends Type<S, T> { | ||
readonly definition: () => IType<S, T>; | ||
import { INode, Type, IType, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
export declare class Late<C, S, T> extends Type<C, S, T> { | ||
readonly definition: () => IAnyType; | ||
private _subType; | ||
readonly flags: number; | ||
readonly shouldAttachNode: boolean; | ||
readonly subType: IType<S, T>; | ||
constructor(name: string, definition: () => IType<S, T>); | ||
readonly subType: IAnyType; | ||
constructor(name: string, definition: () => IAnyType); | ||
instantiate(parent: INode | null, subpath: string, environment: any, snapshot: any): INode; | ||
@@ -13,7 +13,6 @@ reconcile(current: INode, newValue: any): INode; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
} | ||
export declare type ILateType<S, T> = () => IType<S, T>; | ||
export declare function late<S = any, T = any>(type: ILateType<S, T>): IType<S, T>; | ||
export declare function late<S = any, T = any>(name: string, type: ILateType<S, T>): IType<S, T>; | ||
export declare function isLateType(type: any): type is Late<any, any>; | ||
export declare function late<C, S, T>(type: () => IType<C, S, T>): IType<C, S, T>; | ||
export declare function late<C, S, T>(name: string, type: () => IType<C, S, T>): IType<C, S, T>; | ||
export declare function isLateType(type: any): type is Late<any, any, any>; |
import { INode, ISimpleType, Type, TypeFlags, IContext, IValidationResult, ObjectNode } from "../../internal"; | ||
export declare class Literal<T> extends Type<T, T> { | ||
export declare class Literal<T> extends Type<T, T, T> { | ||
readonly shouldAttachNode: boolean; | ||
@@ -4,0 +4,0 @@ readonly value: any; |
@@ -1,4 +0,5 @@ | ||
import { IType } from "../../internal"; | ||
import { IType, TypeFlags } from "../../internal"; | ||
/** | ||
* Maybe will make a type nullable, and also null by default. | ||
* Maybe will make a type nullable, and also optional. | ||
* The value `undefined` will be used to represent nullability. | ||
* | ||
@@ -10,4 +11,20 @@ * @export | ||
* @param {IType<S, T>} type The type to make nullable | ||
* @returns {(IType<S | null | undefined, T | null>)} | ||
* @returns {(IType<S | undefined, T | undefined>)} | ||
*/ | ||
export declare function maybe<S, T>(type: IType<S, T>): IType<S | null | undefined, T | null>; | ||
export declare function maybe<C, S, T>(type: IType<C, S, T>): IType<S | undefined, S | undefined, T | undefined> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
/** | ||
* Maybe will make a type nullable, and also optional. | ||
* The value `null` will be used to represent no value. | ||
* | ||
* @export | ||
* @alias types.maybeNull | ||
* @template S | ||
* @template T | ||
* @param {IType<S, T>} type The type to make nullable | ||
* @returns {(IType<S | null, T | null>)} | ||
*/ | ||
export declare function maybeNull<C, S, T>(type: IType<C, S, T>): IType<S | null | undefined, S | null, T | null> & { | ||
flags: TypeFlags.Optional; | ||
}; |
@@ -1,10 +0,10 @@ | ||
import { INode, Type, IType, IContext, IValidationResult } from "../../internal"; | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
export declare type IFunctionReturn<T> = () => T; | ||
export declare type IOptionalValue<S, T> = S | T | IFunctionReturn<S> | IFunctionReturn<T>; | ||
export declare class OptionalValue<S, T> extends Type<S, T> { | ||
readonly type: IType<S, T>; | ||
readonly defaultValue: IOptionalValue<S, T>; | ||
export declare type IOptionalValue<C, S, T> = C | S | T | IFunctionReturn<C | S | T>; | ||
export declare class OptionalValue<C, S, T> extends Type<C, S, T> { | ||
readonly type: IType<C, S, T>; | ||
readonly defaultValue: IOptionalValue<C, S, T>; | ||
readonly flags: number; | ||
readonly shouldAttachNode: boolean; | ||
constructor(type: IType<S, T>, defaultValue: IOptionalValue<S, T>); | ||
constructor(type: IType<C, S, T>, defaultValue: IOptionalValue<C, S, T>); | ||
describe(): string; | ||
@@ -14,9 +14,12 @@ instantiate(parent: INode, subpath: string, environment: any, value: S): INode; | ||
private getDefaultValue(); | ||
getDefaultValueSnapshot(): any; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
} | ||
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: S): IType<S, T>; | ||
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: T): IType<S, T>; | ||
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: () => S): IType<S, T>; | ||
export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: () => T): IType<S, T>; | ||
export declare function isOptionalType(type: any): type is OptionalValue<any, any>; | ||
export declare function optional<C, S, T>(type: IType<C, S, T>, defaultValueOrFunction: C | S | T): IType<C | undefined, S, T> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare function optional<C, S, T>(type: IType<C, S, T>, defaultValueOrFunction: () => C | S | T): IType<C, S, T> & { | ||
flags: TypeFlags.Optional; | ||
}; | ||
export declare function isOptionalType(type: any): type is OptionalValue<any, any, any>; |
@@ -1,13 +0,13 @@ | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IStateTreeNode } from "../../internal"; | ||
export declare abstract class BaseReferenceType<T> extends Type<string | number, T> { | ||
protected readonly targetType: IType<any, T>; | ||
import { INode, Type, IType, TypeFlags, IContext, IValidationResult, ObjectNode, IStateTreeNode, IAnyType } from "../../internal"; | ||
export declare abstract class BaseReferenceType<T> extends Type<string | number | T, string | number, T> { | ||
protected readonly targetType: IType<any, any, T>; | ||
readonly shouldAttachNode: boolean; | ||
readonly flags: TypeFlags; | ||
constructor(targetType: IType<any, T>); | ||
constructor(targetType: IType<any, any, T>); | ||
describe(): string; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
} | ||
export declare class IdentifierReferenceType<T> extends BaseReferenceType<T> { | ||
constructor(targetType: IType<any, T>); | ||
constructor(targetType: IType<any, any, T>); | ||
getValue(node: INode): any; | ||
@@ -20,3 +20,3 @@ getSnapshot(node: INode): any; | ||
private readonly options; | ||
constructor(targetType: IType<any, T>, options: ReferenceOptions<T>); | ||
constructor(targetType: IType<any, any, T>, options: ReferenceOptions<T>); | ||
getValue(node: INode): T | undefined; | ||
@@ -31,3 +31,3 @@ getSnapshot(node: INode): any; | ||
}; | ||
export declare function reference<T>(factory: IType<any, T>, options?: ReferenceOptions<T>): IType<string | number, T>; | ||
export declare function reference<T>(factory: IType<any, any, T>, options?: ReferenceOptions<T>): IType<string | number | T, string | number, T>; | ||
export declare function isReferenceType(type: any): type is BaseReferenceType<any>; |
@@ -1,4 +0,4 @@ | ||
import { INode, IType, Type, IContext, IValidationResult } from "../../internal"; | ||
export declare class Refinement<S, T> extends Type<S, T> { | ||
readonly type: IType<any, any>; | ||
import { INode, IType, Type, IContext, IValidationResult, IAnyType } from "../../internal"; | ||
export declare class Refinement<C, S, T> extends Type<C, S, T> { | ||
readonly type: IAnyType; | ||
readonly predicate: (v: any) => boolean; | ||
@@ -8,12 +8,10 @@ readonly message: (v: any) => string; | ||
readonly shouldAttachNode: boolean; | ||
constructor(name: string, type: IType<any, any>, predicate: (v: any) => boolean, message: (v: any) => string); | ||
constructor(name: string, type: IAnyType, predicate: (v: any) => boolean, message: (v: any) => string); | ||
describe(): string; | ||
instantiate(parent: INode, subpath: string, environment: any, value: any): INode; | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
isAssignableFrom(type: IAnyType): boolean; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
} | ||
export declare function refinement<T>(name: string, type: IType<T, T>, predicate: (snapshot: T) => boolean, message?: string | ((v: any) => string)): IType<T, T>; | ||
export declare function refinement<S, T extends S, U extends S>(name: string, type: IType<S, T>, predicate: (snapshot: S) => snapshot is U, message?: string | ((v: any) => string)): IType<S, U>; | ||
export declare function refinement<S, T extends S, U extends S>(type: IType<S, T>, predicate: (snapshot: S) => snapshot is U, message?: string | ((v: any) => string)): IType<S, U>; | ||
export declare function refinement<T>(type: IType<T, T>, predicate: (snapshot: T) => boolean, message?: string | ((v: any) => string)): IType<T, T>; | ||
export declare function isRefinementType(type: any): type is Refinement<any, any>; | ||
export declare function refinement<C, S, T>(name: string, type: IType<C, S, T>, predicate: (snapshot: C) => boolean, message?: string | ((v: any) => string)): IType<C, S, T>; | ||
export declare function refinement<C, S, T>(type: IType<C, S, T>, predicate: (snapshot: C) => boolean, message?: string | ((v: any) => string)): IType<C, S, T>; | ||
export declare function isRefinementType(type: any): type is Refinement<any, any, any>; |
@@ -1,36 +0,39 @@ | ||
import { IContext, IValidationResult, TypeFlags, IType, Type, INode } from "../../internal"; | ||
export declare type ITypeDispatcher = (snapshot: any) => IType<any, any>; | ||
export declare class Union extends Type<any, any> { | ||
readonly dispatcher: ITypeDispatcher | null; | ||
readonly types: IType<any, any>[]; | ||
import { IContext, IValidationResult, TypeFlags, IType, Type, INode, IAnyType } from "../../internal"; | ||
export declare type ITypeDispatcher = (snapshot: any) => IAnyType; | ||
export declare type UnionOptions = { | ||
eager?: boolean; | ||
dispatcher?: ITypeDispatcher; | ||
}; | ||
export declare class Union extends Type<any, any, any> { | ||
readonly dispatcher?: ITypeDispatcher; | ||
readonly eager: boolean; | ||
readonly types: IAnyType[]; | ||
readonly flags: TypeFlags; | ||
readonly shouldAttachNode: boolean; | ||
constructor(name: string, types: IType<any, any>[], dispatcher: ITypeDispatcher | null); | ||
isAssignableFrom(type: IType<any, any>): boolean; | ||
constructor(name: string, types: IAnyType[], options?: UnionOptions); | ||
isAssignableFrom(type: IAnyType): boolean; | ||
describe(): string; | ||
instantiate(parent: INode, subpath: string, environment: any, value: any): INode; | ||
reconcile(current: INode, newValue: any): INode; | ||
determineType(value: any): IType<any, any>; | ||
determineType(value: any): IAnyType; | ||
isValidSnapshot(value: any, context: IContext): IValidationResult; | ||
} | ||
export declare function union<SA, SB, TA, TB>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>): IType<SA | SB, TA | TB>; | ||
export declare function union<SA, SB, TA, TB>(A: IType<SA, TA>, B: IType<SB, TB>): IType<SA | SB, TA | TB>; | ||
export declare function union<SA, SB, SC, TA, TB, TC>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>): IType<SA | SB | SC, TA | TB | TC>; | ||
export declare function union<SA, SB, SC, TA, TB, TC>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>): IType<SA | SB | SC, TA | TB | TC>; | ||
export declare function union<SA, SB, SC, SD, TA, TB, TC, TD>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>): IType<SA | SB | SC | SD, TA | TB | TC | TD>; | ||
export declare function union<SA, SB, SC, SD, TA, TB, TC, TD>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>): IType<SA | SB | SC | SD, TA | TB | TC | TD>; | ||
export declare function union<SA, SB, SC, SD, SE, TA, TB, TC, TD, TE>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>): IType<SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>; | ||
export declare function union<SA, SB, SC, SD, SE, TA, TB, TC, TD, TE>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>): IType<SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, TA, TB, TC, TD, TE, TF>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>): IType<SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, TA, TB, TC, TD, TE, TF>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>): IType<SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, TA, TB, TC, TD, TE, TF, TG>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>): IType<SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, TA, TB, TC, TD, TE, TF, TG>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>): IType<SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, TA, TB, TC, TD, TE, TF, TG, TH>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>): IType<SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, TA, TB, TC, TD, TE, TF, TG, TH>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>): IType<SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, TA, TB, TC, TD, TE, TF, TG, TH, TI>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, TA, TB, TC, TD, TE, TF, TG, TH, TI>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, SJ, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>, J: IType<SJ, TJ>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI | SJ, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ>; | ||
export declare function union<SA, SB, SC, SD, SE, SF, SG, SH, SI, SJ, TA, TB, TC, TD, TE, TF, TG, TH, TI, TJ>(A: IType<SA, TA>, B: IType<SB, TB>, C: IType<SC, TC>, D: IType<SD, TD>, E: IType<SE, TE>, F: IType<SF, TF>, G: IType<SG, TG>, H: IType<SH, TH>, I: IType<SI, TI>, J: IType<SJ, TJ>): IType<SA | SB | SC | SD | SE | SF | SG | SH | SI | SJ, TA | TB | TC | TD | TE | TF | TG | TH | TI | TJ>; | ||
export declare function union(...types: IType<any, any>[]): IType<any, any>; | ||
export declare function union(dispatchOrType: ITypeDispatcher | IType<any, any>, ...otherTypes: IType<any, any>[]): IType<any, any>; | ||
export declare function union<CA, SA, TA, CB, SB, TB>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): IType<CA | CB, SA | SB, TA | TB>; | ||
export declare function union<CA, SA, TA, CB, SB, TB>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>): IType<CA | CB, SA | SB, TA | TB>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>): IType<CA | CB | CC, SA | SB | SC, TA | TB | TC>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>): IType<CA | CB | CC, SA | SB | SC, TA | TB | TC>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>): IType<CA | CB | CC | CD, SA | SB | SC | SD, TA | TB | TC | TD>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>): IType<CA | CB | CC | CD, SA | SB | SC | SD, TA | TB | TC | TD>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>): IType<CA | CB | CC | CD | CE, SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>): IType<CA | CB | CC | CD | CE, SA | SB | SC | SD | SE, TA | TB | TC | TD | TE>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>): IType<CA | CB | CC | CD | CE | CF, SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>): IType<CA | CB | CC | CD | CE | CF, SA | SB | SC | SD | SE | SF, TA | TB | TC | TD | TE | TF>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>): IType<CA | CB | CC | CD | CE | CF | CG, SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>): IType<CA | CB | CC | CD | CE | CF | CG, SA | SB | SC | SD | SE | SF | SG, TA | TB | TC | TD | TE | TF | TG>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>): IType<CA | CB | CC | CD | CE | CF | CG | CH, SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>): IType<CA | CB | CC | CD | CE | CF | CG | CH, SA | SB | SC | SD | SE | SF | SG | SH, TA | TB | TC | TD | TE | TF | TG | TH>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH, CI, SI, TI>(options: UnionOptions, A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>, I: IType<CI, SI, TI>): IType<CA | CB | CC | CD | CE | CF | CG | CH | CI, SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>; | ||
export declare function union<CA, SA, TA, CB, SB, TB, CC, SC, TC, CD, SD, TD, CE, SE, TE, CF, SF, TF, CG, SG, TG, CH, SH, TH, CI, SI, TI>(A: IType<CA, SA, TA>, B: IType<CB, SB, TB>, C: IType<CC, SC, TC>, D: IType<CD, SD, TD>, E: IType<CE, SE, TE>, F: IType<CF, SF, TF>, G: IType<CG, SG, TG>, H: IType<CH, SH, TH>, I: IType<CI, SI, TI>): IType<CA | CB | CC | CD | CE | CF | CG | CH | CI, SA | SB | SC | SD | SE | SF | SG | SH | SI, TA | TB | TC | TD | TE | TF | TG | TH | TI>; | ||
export declare function union(...types: IAnyType[]): IAnyType; | ||
export declare function union(dispatchOrType: UnionOptions | IAnyType, ...otherTypes: IAnyType[]): IAnyType; | ||
export declare function isUnionType(type: any): type is Union; |
@@ -16,3 +16,3 @@ export declare const EMPTY_ARRAY: ReadonlyArray<any>; | ||
export declare function isArray(val: any): boolean; | ||
export declare function asArray<T>(val: undefined | null | T | T[]): T[]; | ||
export declare function asArray<T>(val: undefined | null | T | T[] | ReadonlyArray<T>): T[]; | ||
export declare function extend<A, B>(a: A, b: B): A & B; | ||
@@ -39,2 +39,3 @@ export declare function extend<A, B, C>(a: A, b: B, c: C): A & B & C; | ||
export declare function argsToArray(args: IArguments): any[]; | ||
export declare function invalidateComputed(target: any, propName: string): void; | ||
export declare type DeprecatedFunction = Function & { | ||
@@ -41,0 +42,0 @@ ids?: { |
{ | ||
"name": "mobx-state-tree", | ||
"version": "2.2.0", | ||
"version": "3.0.0-beta.2", | ||
"description": "Opinionated, transactional, MobX powered state container", | ||
@@ -12,8 +12,8 @@ "main": "dist/mobx-state-tree.js", | ||
"rollup": "rollup -c", | ||
"test": "cross-env NODE_ENV=development jest --ci && cross-env NODE_ENV=production jest --ci && npm run test-cyclic && npm run speedtest && npm run test-mobx4", | ||
"speedtest": "node --expose-gc test/perf/report.js", | ||
"test-cyclic": "npm run build && node -e \"require('.')\"", | ||
"test": "cross-env NODE_ENV=development jest --ci && cross-env NODE_ENV=production jest --ci && yarn run test-cyclic && yarn run test-mobx4", | ||
"speedtest": "yarn build && /usr/bin/time node --expose-gc test/perf/report.js", | ||
"test-cyclic": "yarn run build && node -e \"require('.')\"", | ||
"test-mobx4": "yarn add -D mobx@4.3.1 && yarn build && jest --ci && git checkout package.json ../../yarn.lock && yarn install", | ||
"watch": "jest --watch", | ||
"_prepublish": "npm run build && npm run build-docs", | ||
"_prepublish": "yarn run build && yarn run build-docs", | ||
"coverage": "jest --coverage", | ||
@@ -44,3 +44,3 @@ "build-docs": "tsc && documentation build lib/index.js --sort-order alpha -f md -o ../../API.md.tmp && concat -o ../../API.md ../../docs/API_header.md ../../API.md.tmp && rm ../../API.md.tmp", | ||
"documentation": "^5.2.2", | ||
"jest": "^22.4.2", | ||
"jest": "^23.2.0", | ||
"mobx": "5.0.3", | ||
@@ -91,7 +91,4 @@ "rollup": "^0.43.0", | ||
"/\\./" | ||
], | ||
"watchPathIgnorePatterns": [ | ||
"<rootDir>/node_modules/" | ||
] | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
592992
11391
3
110