mobx-state-tree 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mobx-state-tree.js +3 -3
- package/dist/mobx-state-tree.min.js +1 -1
- package/dist/mobx-state-tree.module.js +3 -3
- package/dist/mobx-state-tree.umd.js +3 -3
- package/dist/mobx-state-tree.umd.min.js +1 -1
- package/dist/types/complex-types/array.d.ts +1 -1
- package/dist/types/complex-types/map.d.ts +1 -1
- package/dist/types/complex-types/model.d.ts +14 -8
- package/dist/types/primitives.d.ts +1 -1
- package/dist/types/utility-types/frozen.d.ts +2 -2
- package/dist/types/utility-types/identifier.d.ts +1 -1
- package/dist/types/utility-types/late.d.ts +1 -1
- package/dist/types/utility-types/literal.d.ts +1 -1
- package/dist/types/utility-types/optional.d.ts +1 -1
- package/dist/types/utility-types/reference.d.ts +1 -1
- package/dist/types/utility-types/refinement.d.ts +1 -1
- package/dist/types/utility-types/union.d.ts +2 -3
- package/package.json +1 -1
package/dist/mobx-state-tree.js
CHANGED
|
@@ -6974,7 +6974,7 @@ function refinement() {
|
|
|
6974
6974
|
* @returns
|
|
6975
6975
|
*/
|
|
6976
6976
|
function isRefinementType(type) {
|
|
6977
|
-
return (type.flags & TypeFlags.Refinement) > 0;
|
|
6977
|
+
return isType(type) && (type.flags & TypeFlags.Refinement) > 0;
|
|
6978
6978
|
}
|
|
6979
6979
|
|
|
6980
6980
|
/**
|
|
@@ -7180,7 +7180,7 @@ function union(optionsOrType) {
|
|
|
7180
7180
|
* @returns
|
|
7181
7181
|
*/
|
|
7182
7182
|
function isUnionType(type) {
|
|
7183
|
-
return (type.flags & TypeFlags.Union) > 0;
|
|
7183
|
+
return isType(type) && (type.flags & TypeFlags.Union) > 0;
|
|
7184
7184
|
}
|
|
7185
7185
|
|
|
7186
7186
|
/**
|
|
@@ -8229,7 +8229,7 @@ function reference(subType, options) {
|
|
|
8229
8229
|
* @returns
|
|
8230
8230
|
*/
|
|
8231
8231
|
function isReferenceType(type) {
|
|
8232
|
-
return (type.flags & TypeFlags.Reference) > 0;
|
|
8232
|
+
return isType(type) && (type.flags & TypeFlags.Reference) > 0;
|
|
8233
8233
|
}
|
|
8234
8234
|
/**
|
|
8235
8235
|
* `types.safeReference` - A safe reference is like a standard reference, except that it accepts the undefined value by default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("mobx"),r="warn";function n(e){r=e}function i(){return r}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(e||(e={}));var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var u=function(){return(u=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function l(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function c(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function p(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function f(e){return be(e).type}function b(e,t){return be(e).onPatch(t)}function d(e,t){be(e).applyPatches(Ce(t))}function h(e,t){return be(e).applySnapshot(t)}function y(e,t){void 0===t&&(t=!0);var r=be(e);return t?r.snapshot:r.type.getSnapshot(r,!1)}function v(e){return be(e).root.storedValue}function g(e){return be(e).path}function m(e){return be(e).identifier}function w(e,t){var r=ge(be(e),t,!1);if(void 0!==r)try{return r.value}catch(e){return}}function P(e){return be(e).observableIsAlive}function O(e){var t;return{name:(t=fe(e)?f(e):e).name,properties:u({},t.properties)}}"function"==typeof SuppressedError&&SuppressedError;var j=function(){function r(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:ue.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(r.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(r.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new Re),this._hookSubscribers.register(e,t)}}),Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(r.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(r.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=t.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Ge(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(r.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAlive",{get:function(){return this.state!==ue.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDetaching",{get:function(){return this.state===ue.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=t.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.state===ue.CREATED){if(this.parent){if(this.parent.state!==ue.FINALIZED)return;this.fireHook(e.afterAttach)}this.state=ue.FINALIZED,t&&t()}}}),Object.defineProperty(r.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=ue.DEAD}}),Object.defineProperty(r.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(e.beforeDestroy)}}),r}(),_=function(e){function t(t,r,n,i,a){var o=e.call(this,t,r,n,i)||this;try{o.storedValue=t.createNewInstance(a)}catch(e){throw o.state=ue.DEAD,e}return o.state=ue.CREATED,o.finalizeCreation(),o}return o(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw new Se("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;(r||n)&&(this.environment=void 0,this.baseSetParent(this.parent,t))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return"".concat(this.type.name,"@").concat(e).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==ue.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(j);_.prototype.die=t.action(_.prototype.die);var S,A,I=1;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.CREATING=1]="CREATING",e[e.CREATED=2]="CREATED"}(S||(S={})),function(e){e.Dispose="dispose",e.Patch="patch",e.Snapshot="snapshot"}(A||(A={}));var T,C,E={onError:function(e){throw e}},x=function(r){function n(e,n,i,a,o){var u=r.call(this,e,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++I}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"hasSnapshotPostProcessor",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:S.UNINITIALIZED}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=t.computed((function(){return u.getSnapshot()})),u.unbox=u.unbox.bind(u),u._initialSnapshot=o,u.identifierAttribute=e.identifierAttribute,n||(u.identifierCache=new ce),u._childNodes=e.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var c=u._childNodes[u.identifierAttribute];c&&(l=c.value)}if("string"!=typeof l&&"number"!=typeof l)throw new Se("Instance identifier '".concat(u.identifierAttribute,"' for type '").concat(u.type.name,"' must be a string or a number"));u.identifier=Jt(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return o(n,r),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=!0),this._observableInstanceState===S.UNINITIALIZED&&this.createObservableInstance(e)}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,n,i,a;void 0===t&&(t=!0),this._observableInstanceState=S.CREATING;for(var o=[],u=this.parent;u&&u._observableInstanceState===S.UNINITIALIZED;)o.unshift(u),u=u.parent;try{for(var l=c(o),s=l.next();!s.done;s=l.next()){(d=s.value).createObservableInstanceIfNeeded(!1)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}var p=this.type;try{this.storedValue=p.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,p.finalizeNewInstance(this,this.storedValue)}catch(e){throw this.state=ue.DEAD,e}finally{this._isRunningAction=!1}if(this._observableInstanceState=S.CREATED,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=je,this.state=ue.CREATED,t){this.fireHook(e.afterCreate),this.finalizeCreation();try{for(var f=c(o.reverse()),b=f.next();!b.done;b=f.next()){var d;(d=b.value).fireHook(e.afterCreate),d.finalizeCreation()}}catch(e){i={error:e}}finally{try{b&&!b.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}}}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(e.beforeDetach);var t=this.state;this.state=ue.DETACHING;var r=this.root,n=r.environment,i=r.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=t}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){var n=t!==this.parent,i=r!==this.subpath;(n||i)&&(n?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,r),this.fireHook(e.afterAttach)):i&&this.baseSetParent(this.parent,r))}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(t._allowStateChangesInsideComputed?t._allowStateChangesInsideComputed((function(){n.apply(r.storedValue)})):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.hasSnapshotPostProcessor&&this.createObservableInstanceIfNeeded(),this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===S.CREATED?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=i();if(!this.isAlive&&"ignore"!==r){var n=this._getAssertAliveError(e);switch(r){case"error":throw new Se(n);case"warn":t=n,console.warn(new Error("[mobx-state-tree] ".concat(t)))}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&Ge(e.subpath)||"",n=e.actionContext||G();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";if(n&&null!=n.name){var a=n&&n.context&&g(n.context)||t;i="".concat(a,".").concat(n.name,"()")}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name,"', Path upon death: '").concat(t,"', Subpath: '").concat(r,"', Action: '").concat(i,"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.")}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return this._observableInstanceState===S.CREATED?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(je),this._autoUnbox=!1;try{return this._observableInstanceState===S.CREATED?this.type.getChildren(this):we(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw new Se("Cannot modify '".concat(this,"', the object is protected and can only be modified by using an action."))}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>",t=this.identifier?"(id: ".concat(this.identifier,")"):"";return"".concat(this.type.name,"@").concat(e).concat(t).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.baseFinalizeCreation((function(){var r,n;try{for(var i=c(t.getChildren()),a=i.next();!a.done;a=i.next()){a.value.finalizeCreation()}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.fireInternalHook(e.afterCreationFinalization)}))}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw new Se("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=J(this.storedValue,"@APPLY_PATCHES",(function(t){t.forEach((function(t){if(t.path){var r=Ye(t.path);me(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)}))})),this._applySnapshot=J(this.storedValue,"@APPLY_SNAPSHOT",(function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)})),De(this.storedValue,"$treenode",this),De(this.storedValue,"toJSON",he)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==ue.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==S.UNINITIALIZED&&(this.getChildren().forEach((function(e){e.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit(A.Dispose),this._internalEventsClear(A.Dispose))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach((function(e){e.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister(A.Snapshot,e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit(A.Snapshot,e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister(A.Patch,e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers(A.Patch)){var r=s(function(e){if(!("oldValue"in e))throw new Se("Patches without `oldValue` field cannot be inversed");return[Ue(e),$e(e)]}(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var a in i)e[a]=i[a]}return e}({},e,{path:t.path.substr(this.path.length)+(e.path?"/"+e.path:"")})),2),n=r[0],i=r[1];this._internalEventsEmit(A.Patch,n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas(A.Dispose,e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw new Se("cannot add a disposer when it is already registered for execution");this._internalEventsRegister(A.Dispose,e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas(A.Dispose,e))throw new Se("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister(A.Dispose,e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var r=t.reaction((function(){return e.snapshot}),(function(t){return e.emitSnapshot(t)}),E);this.addDisposer(r),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new Re),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,p([e],s(r),!1))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(j);x.prototype.createObservableInstance=t.action(x.prototype.createObservableInstance),x.prototype.detach=t.action(x.prototype.detach),x.prototype.die=t.action(x.prototype.die),function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor",e[e.Lazy=1048576]="Lazy",e[e.Finite=2097152]="Finite",e[e.Float=4194304]="Float"}(C||(C={}));var N=Symbol("$type"),V=function(){function e(e){Object.defineProperty(this,T,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return ae(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw new Se("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(de(e)){var r=f(e);return this.isAssignableFrom(r)?re():ne(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw new Se("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw new Se("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw new Se("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw new Se("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:!1,configurable:!0}),e}();T=N,V.prototype.create=t.action(V.prototype.create);var D=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return o(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===Jt(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!fe(t)||be(t)!==e)||!(e.type!==this||!xe(t)||fe(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),fe(t)&&this.isAssignableFrom(f(t))){var i=be(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(V);D.prototype.create=t.action(D.prototype.create);var k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(V);function R(e){return"object"==typeof e&&e&&!0===e.isType}var z=new Map;var F=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function M(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function L(e,r){t.runInAction((function(){Ce(r).forEach((function(t){return function(e,t){var r=w(e,t.path||"");if(!r)throw new Se("Invalid action path: ".concat(t.path||""));var n=be(r);if("@APPLY_PATCHES"===t.name)return d.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return h.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw new Se("Action '".concat(t.name,"' does not exist in '").concat(n.path,"'"));return r[t.name].apply(r,t.args?t.args.map((function(e){return(t=e)&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t;var t})):[])}(e,t)}))}))}function H(e,t,r){return void 0===r&&(r=!1),B(e,(function(n,i){if("action"===n.type&&n.id===n.rootId){var a=be(n.context),o={name:n.name,path:ve(be(e),a),args:n.args.map((function(e,t){return function(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(Ne(n))return n;if(fe(n))return M("[MSTNode: ".concat(f(n).name,"]"));if("function"==typeof n)return M("[function]");if("object"==typeof n&&!Ee(n)&&!Te(n))return M("[object ".concat(n&&n.constructor&&n.constructor.name||"Complex Object","]"));try{return JSON.stringify(n),n}catch(e){return M(""+e)}}(0,n.name,0,e)}))};if(r){var u=i(n);return t(o),u}return t(o),i(n)}return i(n)}))}var U,$=1;function G(){return U}function W(){return $++}function Z(r,n){var i=be(r.context);"action"===r.type&&i.assertAlive({actionContext:r});var a=i._isRunningAction;i._isRunningAction=!0;var o=U;U=r;try{return function(r,n,i){var a=new K(r,i);if(a.isEmpty)return t.action(i).apply(null,n.args);var o=null;return function r(n){var u=a.getNextMiddleware(),l=u&&u.handler;return l?!u.includeHooks&&e[n.name]?r(n):(l(n,(function(e,t){o=r(e),t&&(o=t(o))}),(function(e){o=e})),o):t.action(i).apply(null,n.args)}(n)}(i,r,n)}finally{U=o,i._isRunningAction=a}}function Y(e){if(e)return"action"===e.type?e:e.parentActionEvent}function J(e,t,r){var n=function(){var n=W(),i=U,a=Y(i);return Z({type:"action",name:t,id:n,args:ze(arguments),context:e,tree:v(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?p(p([],s(i.allParentIds),!1),[i.id],!1):[],parentEvent:i,parentActionEvent:a},r)};return n._isMSTAction=!0,n._isFlowAction=r._isFlowAction,n}function B(e,t,r){return void 0===r&&(r=!0),be(e).addMiddleWare(t,r)}var K=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.middlewares[this.arrayIndex];if(e){var t=e[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function q(){for(var e=G();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function Q(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function X(e){return"function"==typeof e?"<function".concat(e.name?" "+e.name:"",">"):fe(e)?"<".concat(e,">"):"`".concat(function(e){try{return JSON.stringify(e)}catch(e){return"<Unserializable: ".concat(e,">")}}(e),"`")}function ee(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map((function(e){return e.path})).filter((function(e){return e.length>0})).join("/"),i=n.length>0?'at path "/'.concat(n,'" '):"",a=fe(t)?"value of type ".concat(be(t).type.name,":"):Ne(t)?"value":"snapshot",o=r&&fe(t)&&r.is(be(t).snapshot);return"".concat(i).concat(a," ").concat(X(t)," is not assignable ").concat(r?"to type: `".concat(r.name,"`"):"")+(e.message?" (".concat(e.message,")"):"")+(r?wt(r)||Ne(t)?".":", expected an instance of `".concat(r.name,"` or a snapshot like `").concat(r.describe(),"` instead.")+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function te(e,t,r){return e.concat([{path:t,type:r}])}function re(){return Oe}function ne(e,t,r){return[{context:e,value:t,message:r}]}function ie(e){return e.reduce((function(e,t){return e.concat(t)}),[])}function ae(e,t){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&oe(e,t)}function oe(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw new Se(function(e,t,r){if(0===r.length)return;return"Error while converting ".concat((n=X(t),n.length<280?n:"".concat(n.substring(0,272),"......").concat(n.substring(n.length-8)))," to `").concat(e.name,"`:\n\n ")+r.map(ee).join("\n ");var n}(e,t,r))}var ue,le=0,ce=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:le++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return"".concat(this.cacheId,"-").concat(t)}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(void 0===r&&(r=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,t.observable.array([],_e));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw new Se("Already registered");i.push(e),r&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;t.values(e.identifierCache.cache).forEach((function(e){return e.forEach((function(e){r.addNodeToCache(e)}))}))}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var n=this,i=new e,a=r.path+"/";return t.entries(this.cache).forEach((function(e){for(var t=s(e,2),o=t[0],u=t[1],l=!1,c=u.length-1;c>=0;c--){var p=u[c];p!==r&&0!==p.path.indexOf(a)||(i.addNodeToCache(p,!1),u.splice(c,1),u.length||n.cache.delete(o),l=!0)}l&&n.updateLastCacheModificationPerId(o)})),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some((function(t){return e.isAssignableFrom(t.type)}))}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter((function(t){return e.isAssignableFrom(t.type)}));switch(n.length){case 0:return null;case 1:return n[0];default:throw new Se("Cannot resolve a reference to type '".concat(e.name,"' with id: '").concat(t,"' unambigously, there are multiple candidates: ").concat(n.map((function(e){return e.path})).join(", ")))}}}),e}();function se(e,t,r,n,i){var a=de(i);if(a){if(a.parent)throw new Se("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 '".concat(t?t.path:"","/").concat(r,"', but it lives already at '").concat(a.path,"'"));return t&&a.setParent(t,r),a}return new x(e,t,r,n,i)}function pe(e,t,r,n,i){return new _(e,t,r,n,i)}function fe(e){return!(!e||!e.$treenode)}function be(e){if(!fe(e))throw new Se("Value ".concat(e," is no MST Node"));return e.$treenode}function de(e){return e&&e.$treenode||null}function he(){return be(this).snapshot}!function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"}(ue||(ue={}));var ye=function(e){return".."};function ve(e,t){if(e.root!==t.root)throw new Se("Cannot calculate relative path: objects '".concat(e,"' and '").concat(t,"' are not part of the same object tree"));for(var r=Ye(e.path),n=Ye(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(ye).join("/")+Ze(n.slice(i))}function ge(e,t,r){return void 0===r&&(r=!0),me(e,Ye(t),r)}function me(e,t,r){void 0===r&&(r=!0);var n=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(".."===a){if(n=n.parent)continue}else{if("."===a)continue;if(n){if(n instanceof _){var o=n.value;fe(o)&&(n=be(o))}if(n instanceof x)if(n.getChildType(a)&&(n=n.getChildNode(a)))continue}}throw new Se("Could not resolve '".concat(a,"' in path '").concat(Ze(t.slice(0,i))||"/","' while resolving '").concat(Ze(t),"'"))}}catch(e){if(!r)return;throw e}return n}function we(e){if(!e)return Oe;var t=Object.keys(e);if(!t.length)return Oe;var r=new Array(t.length);return t.forEach((function(t,n){r[n]=e[t]})),r}var Pe=Object.toString(),Oe=Object.freeze([]),je=Object.freeze({}),_e=t._getGlobalState().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(_e);var Se=function(e){function t(t){return void 0===t&&(t="Illegal state"),e.call(this,"[mobx-state-tree] ".concat(t))||this}return o(t,e),t}(Error);function Ae(e){return e}var Ie=Number.isInteger;function Te(e){return Array.isArray(e)||t.isObservableArray(e)}function Ce(e){return e?Te(e)?e:[e]:Oe}function Ee(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===Pe}function xe(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function Ne(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date}function Ve(e){return"function"!=typeof e}function De(e,r,n){!function(e,r,n){t.isObservableObject(e)?t.defineProperty(e,r,n):Object.defineProperty(e,r,n)}(e,r,{enumerable:!1,writable:!1,configurable:!0,value:n})}var ke=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this.handlers.slice();r.forEach((function(t){return t.apply(void 0,p([],s(e),!1))}))}}),e}(),Re=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new ke),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,p([],s(r),!1))}}),e}();function ze(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function Fe(e,t){return 0===e.indexOf(t)}var Me=function(e,t){};function Le(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function He(e){return function(e,t){var r=function(){var n=W(),i=G();if(!i)throw new Se("a mst flow must always have a parent context");var a=Y(i);if(!a)throw new Se("a mst flow must always have a parent action context");var o={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:p(p([],s(i.allParentIds),!1),[i.id],!1),rootId:i.rootId,parentEvent:i,parentActionEvent:a},l=arguments;function c(e,t,n){return e.$mst_middleware=r.$mst_middleware,Z(u(u({},o),{type:t,args:[n]}),e)}return new Promise((function(e,n){var i,a=function(){i=t.apply(null,arguments),s(void 0)};function s(e){var t;try{var r=c((function(e){t=i.next(e)}),"flow_resume",e);r instanceof Error&&(t=i.throw(r))}catch(e){return void Le((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function p(e){var t;try{c((function(e){t=i.throw(e)}),"flow_resume_error",e)}catch(e){return void Le((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw new Se("Only promises can be yielded to `async`, got: "+t);return t.value.then(s,p)}Le((function(){c((function(t){e(t)}),"flow_return",t.value)}))}a.$mst_middleware=r.$mst_middleware,Z(u(u({},o),{type:"flow_spawn",args:ze(l)}),a)}))};return r._isFlowAction=!0,r}(e.name,e)}function Ue(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function $e(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function Ge(e){return!0==("number"==typeof e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function We(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ze(e){if(0===e.length)return"";var t=function(e){return e.map(Ge).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function Ye(e){var t=e.split("/").map(We);if(!(""===e||"."===e||".."===e||Fe(e,"/")||Fe(e,"./")||Fe(e,"../")))throw new Se("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return""===t[0]&&t.shift(),t}Me.ids={};var Je=Symbol("$preProcessorFailed"),Be=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor(".concat(this._subtype.describe(),")")}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(e){return Je}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._processors.postProcessor?this._processors.postProcessor.call(null,e,t.storedValue):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;!function(e,t){for(var r,n,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=c(i),u=o.next();!u.done;u=o.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}(e.type,this,"create"),e instanceof x&&(e.hasSnapshotPostProcessor=!!this._processors.postProcessor);var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e),e)},At(this._subtype)||(e.getReconciliationType=function(){return t})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(n)?n:this.preProcessSnapshot(n),a=this._subtype.instantiate(e,t,r,i);return this._fixNode(a),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,fe(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r,e):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===Je?ne(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=R(e)?this._subtype:fe(e)?y(e,!1):this.preProcessSnapshotSafe(e);return t!==Je&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof D))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(V);var Ke,qe="Map.put can only be used to store complex values that have an identifier type attribute";!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(Ke||(Ke={}));var Qe=function(e){function r(r,n){return e.call(this,r,t.observable.ref.enhancer,n)||this}return o(r,e),Object.defineProperty(r.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(r.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(r.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(r.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(r.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw new Se("Map.put cannot be used to set empty values");if(fe(e)){var t=be(e);if(null===t.identifier)throw new Se(qe);return this.set(t.identifier,e),e}if(xe(e)){var r=be(this),n=r.type;if(n.identifierMode!==Ke.YES)throw new Se(qe);var i=e[n.mapIdentifierAttribute];if(!Bt(i)){var a=this.put(n.getChildType().create(e,r.environment));return this.put(y(a))}var o=Jt(i);return this.set(o,e),this.get(o)}throw new Se("Map.put can only be used to store complex values")}}),r}(t.ObservableMap),Xe=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Ke.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return o(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),se(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Ke.UNKNOWN){var e=[];if(function e(t,r){var n,i,a=t.getSubTypes();if("cannotDetermine"===a)return!1;if(a){var o=Ce(a);try{for(var u=c(o),l=u.next();!l.done;l=u.next()){if(!e(l.value,r))return!1}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return t instanceof ut&&r.push(t),!0}(this._subType,e)){var t=e.reduce((function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw new Se("The objects in a map should all have the same identifier attribute, expected '".concat(e,"', but child of type '").concat(t.name,"' declared attribute '").concat(t.identifierAttribute,"' as identifier"));return t.identifierAttribute}),void 0);t?(this.identifierMode=Ke.YES,this.mapIdentifierAttribute=t):this.identifierMode=Ke.NO}}}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach((function(i){n[i]=r.instantiate(e,i,void 0,t[i])})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new Qe(e,this.name)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._interceptReads(r,e.unbox),e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=J(r,e,n);De(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return t.values(e.storedValue)}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw new Se("Not a child "+t);return r}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var a=e.newValue;if(a===e.object.get(r))return null;ae(i,a),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":ae(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(r.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===Ke.YES&&t instanceof x){var r=t.identifier;if(r!==e)throw new Se("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(r,"', but expected: '").concat(e,"'"))}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach((function(e){t[e.subpath]=e.snapshot})),t}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:Ge(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:Ge(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:Ge(e.name),oldValue:r},t)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){ae(this,t);var r=e.storedValue,n={};if(Array.from(r.keys()).forEach((function(e){n[e]=!1})),t)for(var i in t)r.set(i,t[i]),n[""+i]=!0;Object.keys(n).forEach((function(e){!1===n[e]&&r.delete(e)}))}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ee(e)?ie(Object.keys(e).map((function(n){return r._subType.validate(e[n],te(t,n,r._subType))}))):ne(t,e,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return je}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),r}(D);Xe.prototype.applySnapshot=t.action(Xe.prototype.applySnapshot);var et=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return o(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return se(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach((function(t,i){var a=""+i;n[a]=r.instantiate(e,a,void 0,t)})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=u(u({},_e),{name:this.name});return t.observable.array(we(e),r)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._getAdministration(r).dehancer=e.unbox,e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=J(r,e,n);De(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw new Se("Not a child: "+t)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=tt(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var a=e.index,o=e.removedCount,u=e.added,l=tt(t,r,n.slice(a,a+o),u,u.map((function(e,t){return a+t})));if(!l)return null;e.added=l;for(var c=a+o;c<n.length;c++)n[c].setParent(t,""+(c+u.length-o))}return e}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map((function(e){return e.snapshot}))}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach((function(r){t.push(e[r].getSnapshot())})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"splice":if(e.removedCount&&e.addedCount===e.object.length)return void t.emitPatch({op:"replace",path:"",value:t.snapshot,oldValue:e.removed.map((function(e){return e.snapshot}))},t);for(var r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:e.added[r].snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){ae(this,t),e.storedValue.replace(t)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Te(e)?ie(e.map((function(e,n){return r._subType.validate(e,te(t,""+n,r._subType))}))):ne(t,e,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Oe}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),r}(D);function tt(e,t,r,n,i){for(var a,o=!0,u=0;;u++){var l=u<=n.length-1,c=r[u],s=l?n[u]:void 0,p=""+i[u];if(((a=s)instanceof _||a instanceof x)&&(s=s.storedValue),!c&&!l)break;if(l)if(c)if(nt(c,s))r[u]=rt(t,e,p,s,c);else{for(var f=void 0,b=u;b<r.length;b++)if(nt(r[b],s)){f=r.splice(b,1)[0];break}o=!1;d=rt(t,e,p,s,f);r.splice(u,0,d)}else{if(fe(s)&&be(s).parent===e)throw new Se("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 '".concat(e.path,"/").concat(p,"', but it lives already at '").concat(be(s).path,"'"));o=!1;var d=rt(t,e,p,s);r.splice(u,0,d)}else o=!1,r.splice(u,1),c instanceof x&&c.createObservableInstanceIfNeeded(),c.die(),u--}return o?null:r}function rt(e,t,r,n,i){ae(e,n);var a=function(){if(fe(n)){var a=be(n);if(a.assertAlive(je),null!==a.parent&&a.parent===t)return a.setParent(t,r),a}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==a&&(i instanceof x&&i.createObservableInstanceIfNeeded(),i.die()),a}function nt(e,t){if(!e.isAlive)return!1;if(fe(t)){var r=be(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof x))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&Ee(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}et.prototype.applySnapshot=t.action(et.prototype.applySnapshot);function it(){return be(this).toString()}var at={name:"AnonymousModel",properties:{},initializers:Oe};function ot(t){var r=Object.keys(t),n=new Set;return r.forEach((function(e){if(n.has(e))throw new Se("".concat(e," is declared twice in the model. Model should not contain the same keys"));n.add(e)})),r.reduce((function(r,n){if(n in e)throw new Se("Hook '".concat(n,"' was defined as property. Hooks should be defined as part of the actions"));var i=Object.getOwnPropertyDescriptor(t,n);if("get"in i)throw new Se("Getters are not supported as properties. Please use views instead");var a=i.value;if(null==a)throw new Se("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ne(a))r[n]=Tt(function(e){switch(typeof e){case"string":return st;case"number":return pt;case"boolean":return ht;case"object":if(e instanceof Date)return mt}throw new Se("Cannot determine primitive type from value "+e)}(a),a);else if(a instanceof Xe)r[n]=Tt(a,{});else if(a instanceof et)r[n]=Tt(a,[]);else if(!R(a))throw new Se("Invalid type definition for property '".concat(n,"', cannot infer a type from a value like '").concat(a,"' (").concat(typeof a,")"));return r}),u({},t))}var ut=function(r){function n(e){var t=r.call(this,e.name||at.name)||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Object}),Object.defineProperty(t,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.cloneAndEnhance({name:e})}}),Object.defineProperty(t,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.cloneAndEnhance({properties:e})}}),Object.defineProperty(t,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r=t.preProcessor;return r?t.cloneAndEnhance({preProcessor:function(t){return r(e(t))}}):t.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(t,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r=t.postProcessor;return r?t.cloneAndEnhance({postProcessor:function(t){return e(r(t))}}):t.cloneAndEnhance({postProcessor:e})}}),Object.assign(t,at,e),t.properties=ot(t.properties),t.properties,t.propertyNames=Object.keys(t.properties),t.identifierAttribute=t._getIdentifierAttribute(),t}return o(n,r),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps((function(t,r){if(r.flags&C.Identifier){if(e)throw new Se("Cannot define property '".concat(t,"' as object identifier, property '").concat(e,"' is already defined as identifier property"));e=t}})),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(!Ee(r))throw new Se("actions initializer should return a plain object containing actions");Object.keys(r).forEach((function(n){if("preProcessSnapshot"===n)throw new Se("Cannot define action '".concat("preProcessSnapshot","', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if("postProcessSnapshot"===n)throw new Se("Cannot define action '".concat("postProcessSnapshot","', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var i=r[n],a=t[n];if(n in e&&a){var o=i;i=function(){a.apply(null,arguments),o.apply(null,arguments)}}var u=i.$mst_middleware,l=i.bind(r);l._isFlowAction=i._isFlowAction||!1,l.$mst_middleware=u;var c=J(t,n,l);r[n]=c,De(t,n,c)}))}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw new Se("You passed an ".concat(typeof e," to volatile state as an argument, when function is expected"));return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!Ee(r))throw new Se("volatile state initializer should return a plain object containing state");t.set(e,r)}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,a=n.views,o=n.state,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(n,["actions","views","state"]);for(var l in u)throw new Se("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(l,"'"));return o&&t.instantiateVolatileState(r,o),a&&t.instantiateViews(r,a),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!Ee(r))throw new Se("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach((function(n){var i,a=Object.getOwnPropertyDescriptor(r,n);if("get"in a)t.defineProperty(e,n,a),t.makeObservable(e,((i={})[n]=t.computed,i));else{if("function"!=typeof a.value)throw new Se("A view member should either be a function or getter based property");De(e,n,a.value)}}))}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return se(this,e,t,r,fe(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps((function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])})),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=u(u({},_e),{name:this.name});return t.observable.object(e,je,r)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){De(r,"toString",it),this.forAllProps((function(n){t._interceptReads(r,n,e.unbox)})),this.initializers.reduce((function(e,t){return t(e)}),r),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=be(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(ae(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=be(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:Ge(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps((function(n){r.push(t.getChildNode(e,n))})),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n;if(!(r in this.properties))throw new Se("Not a value property: "+r);var i=t._getAdministration(e.storedValue,r),a=null===(n=i.raw)||void 0===n?void 0:n.call(i);if(!a)throw new Se("Node not available for property "+r);return a}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;void 0===r&&(r=!0);var i={};return this.forAllProps((function(r,a){try{t.getAtom(e.storedValue,r).reportObserved()}catch(e){throw new Se("".concat(r," property is declared twice"))}i[r]=n.getChildNode(e,r).snapshot})),r?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw new Se("object does not support operation ".concat(r.op));e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){ae(this,t);var r=this.applySnapshotPreProcessor(t);this.forAllProps((function(t){e.storedValue[t]=r[t]}))}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return Ee(n)?ie(this.propertyNames.map((function(e){return r.properties[e].validate(n[e],te(t,e,r.properties[e]))}))):ne(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach((function(r){return e(r,t.properties[r])}))}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map((function(t){return t+": "+e.properties[t].describe()})).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return je}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(D);function lt(e){return R(e)&&(e.flags&C.Object)>0}ut.prototype.applySnapshot=t.action(ut.prototype.applySnapshot);var ct=function(e){function t(t,r,n,i){void 0===i&&(i=Ae);var a=e.call(this,t)||this;return Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),a.flags=r,a}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(Ne(e)&&this.checker(e))return re();var r="Date"===this.name?"Date or a unix milliseconds timestamp":this.name;return ne(t,e,"Value is not a ".concat(r))}}),t}(k),st=new ct("string",C.String,(function(e){return"string"==typeof e})),pt=new ct("number",C.Number,(function(e){return"number"==typeof e})),ft=new ct("integer",C.Integer,(function(e){return Ie(e)})),bt=new ct("float",C.Float,(function(e){return t=e,Number(t)===t&&t%1!=0;var t})),dt=new ct("finite",C.Finite,(function(e){return t=e,Number.isFinite(t);var t})),ht=new ct("boolean",C.Boolean,(function(e){return"boolean"==typeof e})),yt=new ct("null",C.Null,(function(e){return null===e})),vt=new ct("undefined",C.Undefined,(function(e){return void 0===e})),gt=new ct("Date",C.Date,(function(e){return"number"==typeof e||e instanceof Date}),(function(e){return e instanceof Date?e:new Date(e)}));gt.getSnapshot=function(e){return e.storedValue.getTime()};var mt=gt;function wt(e){return R(e)&&(e.flags&(C.String|C.Number|C.Integer|C.Boolean|C.Date))>0}var Pt=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Literal}),r.value=t,r}return o(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ne(e)&&e===this.value?re():ne(t,e,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t}(k);function Ot(e){return new Pt(e)}var jt=function(e){function t(t,r,n,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=fe(e)?be(e).snapshot:e;return this._predicate(n)?re():ne(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(V);var _t=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=u({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=C.Union;return this._types.forEach((function(t){e|=t.flags})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some((function(t){return t.isAssignableFrom(e)}))}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map((function(e){return e.describe()})).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw new Se("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw new Se("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter((function(e){return e!==t})).find((function(t){return t.is(e)})):this._types.find((function(t){return t.is(e)}))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var a=this._types[i].validate(e,t);if(0===a.length){if(this._eager)return re();n++}else r.push(a)}return 1===n?re():ne(t,e,"No type is applicable for the union").concat(ie(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(V);function St(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=R(e)?void 0:e,i=R(e)?p([e],s(t),!1):t,a="("+i.map((function(e){return e.name})).join(" | ")+")";return new _t(a,i,n)}function At(e){return(e.flags&C.Union)>0}var It=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&ae(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?re():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(V);function Tt(e,t,r){return function(e,t){if("function"!=typeof t&&fe(t))throw new Se("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,t),new It(e,t,r||Ct)}var Ct=[void 0];var Et=Tt(vt,void 0),xt=Tt(yt,null);function Nt(e){return St(e,Et)}var Vt=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|C.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(e){if(!(e instanceof ReferenceError))throw e;t=void 0}if(e&&void 0===t)throw new Se("Late type seems to be used too early, the definition (still) returns undefined");t&&(this._subType=t)}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):re()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||"cannotDetermine"}}),t}(V);var Dt=function(e){function r(r,n){var i=e.call(this,r)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.array()}),t.when((function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some((function(e){return e.isAlive&&i.options.shouldLoadPredicate(e.parent?e.parent.value:null)}))}),(function(){i.options.loadType().then(t.action((function(e){i.loadedType=e,i.pendingNodeList.forEach((function(e){e.parent&&i.loadedType&&e.parent.applyPatches([{op:"replace",path:"/".concat(e.subpath),value:e.snapshot}])}))})))})),i}return o(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<lazy ".concat(this.name,">")}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n,i){var a=this;if(this.loadedType)return this.loadedType.instantiate(e,r,n,i);var o=pe(this,e,r,n,i);return this.pendingNodeList.push(o),t.when((function(){return!o.isAlive}),(function(){return a.pendingNodeList.splice(a.pendingNodeList.indexOf(o),1)})),o}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.loadedType?this.loadedType.validate(e,t):Ve(e)?re():ne(t,e,"Value is not serializable and cannot be lazy")}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i){return this.loadedType?(t.die(),this.loadedType.instantiate(n,i,n.environment,r)):e.prototype.reconcile.call(this,t,r,n,i)}}),r}(k),kt=function(e){function t(t){var r=e.call(this,t?"frozen(".concat(t.name,")"):"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Frozen}),r}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ve(e)?this.subType?this.subType.validate(e,t):re():ne(t,e,"Value is not serializable and cannot be frozen")}}),t}(k),Rt=new kt;var zt=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Bt(e))this.identifier=e;else{if(!fe(e))throw new Se("Can only store references to tree nodes or identifiers, got: '".concat(e,"'"));var r=be(e);if(!r.identifierAttribute)throw new Se("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw new Se("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Jt(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,a=r.identifierCache.resolve(i,t);if(!a)throw new Ft("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(e.path,")"));this.resolvedReference={node:a,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Ft=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return o(t,e),t}(Error),Mt=function(t){function r(e,r){var n=t.call(this,"reference(".concat(e.name,")"))||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Reference}),n}return o(r,t),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Bt(e)?re():ne(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var a=i.storedValue;a&&this.onInvalidated({cause:e,parent:a,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){d(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){lt(i.type)?this.replaceRef(void 0):d(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){var n=this,i=this.getValue(t);if(i){var a=be(i),o=function(i,o){var u=function(t){switch(t){case e.beforeDestroy:return"destroy";case e.beforeDetach:return"detach";default:return}}(o);u&&n.fireInvalidated(u,t,r,a)},u=a.registerHook(e.beforeDetach,o),l=a.registerHook(e.beforeDestroy,o);return function(){u(),l()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n){var i=this;if(this.onInvalidated){var a;t.registerHook(e.beforeDestroy,(function(){a&&a()}));var o=function(e){a&&a();var o=t.parent,u=o&&o.storedValue;if(o&&o.isAlive&&u){(n?!!n.get(r,u):t.root.identifierCache.has(i.targetType,Jt(r)))?a=i.addTargetNodeWatcher(t,r):e||i.fireInvalidated("invalidSnapshotReference",t,r,null)}};t.state===ue.FINALIZED?o(!0):(t.isRoot||t.root.registerHook(e.afterCreationFinalization,(function(){t.parent&&t.parent.createObservableInstanceIfNeeded()})),t.registerHook(e.afterAttach,(function(){o(!1)})))}}}),r}(k),Lt=function(e){function t(t,r){return e.call(this,t,r)||this}return o(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(n)?m(n):n,a=new zt(n,this.targetType),o=pe(this,e,t,r,a);return a.node=o,this.watchTargetNodeForInvalidations(o,i,void 0),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=fe(t),a=e.storedValue;if(!i&&a.identifier===t||i&&a.resolvedValue===t)return e.setParent(r,n),e}var o=this.instantiate(r,n,void 0,t);return e.die(),o}}),t}(Mt),Ht=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return o(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(n)?this.options.set(n,e?e.storedValue:null):n,a=pe(this,e,t,r,i);return this.watchTargetNodeForInvalidations(a,i,this.options),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var a=this.instantiate(r,n,void 0,i);return e.die(),a}}),t}(Mt);function Ut(e,t){var r=t||void 0,n=t?t.onInvalidated:void 0;return r&&(r.get||r.set)?new Ht(e,{get:r.get,set:r.set},n):new Lt(e,n)}var $t=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Identifier}),n}return o(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof ut))throw new Se("Identifier types can only be instantiated as direct child of a model type");return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw new Se("Tried to change identifier from '".concat(e.storedValue,"' to '").concat(t,"'. Changing identifiers is not allowed."));return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?ne(t,e,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):re()}}),t}(k),Gt=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Identifier}),t}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}($t),Wt=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return o(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}($t),Zt=new Gt,Yt=new Wt;function Jt(e){return""+e}function Bt(e){return"string"==typeof e||"number"==typeof e}var Kt=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Custom}),r}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return re();var r=this.options.getValidationMessage(e);return r?ne(t,e,"Invalid value for type '".concat(this.name,"': ").concat(r)):re()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var a=i?this.options.fromSnapshot(t,r.root.environment):t,o=this.instantiate(r,n,void 0,a);return e.die(),o}}),t}(k),qt={enumeration:function(e,t){var r="string"==typeof e?t:e,n=St.apply(void 0,p([],s(r.map((function(e){return Ot(""+e)}))),!1));return"string"==typeof e&&(n.name=e),n},model:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new ut({name:r,properties:n})},compose:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),e.reduce((function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})})).named(n)},custom:function(e){return new Kt(e)},reference:Ut,safeReference:function(e,t){var r=Ut(e,u(u({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:Nt(r)},union:St,optional:Tt,literal:Ot,maybe:Nt,maybeNull:function(e){return St(e,xt)},refinement:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():R(e[0])?e[0].name:null,n=e[0],i=e[1],a=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return new jt(r,n,i,a)},string:st,boolean:ht,number:pt,integer:ft,float:bt,finite:dt,Date:mt,map:function(e){return new Xe("Map<string, ".concat(e.name,">"),e)},array:function(e){return new et("".concat(e.name,"[]"),e)},frozen:function(e){return 0===arguments.length?Rt:R(e)?new kt(e):Tt(Rt,e)},identifier:Zt,identifierNumber:Yt,late:function(e,t){var r="string"==typeof e?e:"late(".concat(e.toString(),")");return new Vt(r,"string"==typeof e?t:e)},lazy:function(e,t){return new Dt(e,t)},undefined:vt,null:yt,snapshotProcessor:function(e,t,r){return new Be(e,t,r)}};exports.addDisposer=function(e,t){return be(e).addDisposer(t),t},exports.addMiddleware=B,exports.applyAction=L,exports.applyPatch=d,exports.applySnapshot=h,exports.cast=function(e){return e},exports.castFlowReturn=function(e){return e},exports.castToReferenceSnapshot=function(e){return e},exports.castToSnapshot=function(e){return e},exports.clone=function(e,t){void 0===t&&(t=!0);var r=be(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)},exports.createActionTrackingMiddleware=function(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),z.set(t.id,{call:t,context:i,async:!1});try{var a=r(t);return e.onSuspend(t,i),!1===z.get(t.id).async&&(z.delete(t.id),e.onSuccess(t,i,a)),a}catch(r){throw z.delete(t.id),e.onFail(t,i,r),r}case"flow_spawn":return(o=z.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var o=z.get(t.rootId);e.onResume(t,o.context);try{return r(t)}finally{e.onSuspend(t,o.context)}case"flow_throw":o=z.get(t.rootId);return z.delete(t.rootId),e.onFail(t,o.context,t.args[0]),r(t);case"flow_return":o=z.get(t.rootId);return z.delete(t.rootId),e.onSuccess(t,o.context,t.args[0]),r(t)}}},exports.createActionTrackingMiddleware2=function(e){var t=new Map;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent.id):void 0;if("action"===r.type){var a=u(u({},r),{env:i&&i.call.env,parentCall:i&&i.call}),o=!e.filter||e.filter(a),l=new F(o?e:void 0,a);t.set(r.id,l);var c=void 0;try{c=n(r)}catch(e){throw t.delete(r.id),l.finish(e),e}return l.hasFlowsPending||(t.delete(r.id),l.finish()),c}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var s=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish(s))}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish())}}}},exports.decorate=function(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t},exports.destroy=function(e){var t=be(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)},exports.detach=function(e){return be(e).detach(),e},exports.escapeJsonPath=Ge,exports.flow=He,exports.getChildType=function(e,t){return be(e).getChildType(t)},exports.getEnv=function(e){var t=be(e),r=t.root.environment;if(!r)throw new Se("Failed to find the environment of ".concat(t," ").concat(t.path));return r},exports.getIdentifier=m,exports.getLivelinessChecking=i,exports.getMembers=function(e){var r=be(e).type,n=u(u({},O(r)),{actions:[],volatile:[],views:[],flowActions:[]});return Object.getOwnPropertyNames(e).forEach((function(r){if(!(r in n.properties)){var i=Object.getOwnPropertyDescriptor(e,r);i.get?t.isComputedProp(e,r)?n.views.push(r):n.volatile.push(r):(!0===i.value._isFlowAction&&n.flowActions.push(r),!0===i.value._isMSTAction?n.actions.push(r):t.isObservableProp(e,r)?n.volatile.push(r):n.views.push(r))}})),n},exports.getNodeId=function(e){return be(e).nodeId},exports.getParent=function(e,t){void 0===t&&(t=1);for(var r=t,n=be(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw new Se("Failed to find the parent of ".concat(be(e)," at depth ").concat(t))},exports.getParentOfType=function(e,t){for(var r=be(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw new Se("Failed to find the parent of ".concat(be(e)," of a given type"))},exports.getPath=g,exports.getPathParts=function(e){return Ye(be(e).path)},exports.getPropertyMembers=O,exports.getRelativePath=function(e,t){return ve(be(e),be(t))},exports.getRoot=v,exports.getRunningActionContext=q,exports.getSnapshot=y,exports.getType=f,exports.hasEnv=function(e){return!!be(e).root.environment},exports.hasParent=function(e,t){void 0===t&&(t=1);for(var r=be(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1},exports.hasParentOfType=function(e,t){for(var r=be(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1},exports.isActionContextChildOf=function(e,t){return Q(e,t,!1)},exports.isActionContextThisOrChildOf=function(e,t){return Q(e,t,!0)},exports.isAlive=P,exports.isArrayType=function(e){return R(e)&&(e.flags&C.Array)>0},exports.isFrozenType=function(e){return R(e)&&(e.flags&C.Frozen)>0},exports.isIdentifierType=function(e){return R(e)&&(e.flags&C.Identifier)>0},exports.isLateType=function(e){return R(e)&&(e.flags&C.Late)>0},exports.isLiteralType=function(e){return R(e)&&(e.flags&C.Literal)>0},exports.isMapType=function(e){return R(e)&&(e.flags&C.Map)>0},exports.isModelType=lt,exports.isOptionalType=function(e){return R(e)&&(e.flags&C.Optional)>0},exports.isPrimitiveType=wt,exports.isProtected=function(e){return be(e).isProtected},exports.isReferenceType=function(e){return(e.flags&C.Reference)>0},exports.isRefinementType=function(e){return(e.flags&C.Refinement)>0},exports.isRoot=function(e){return be(e).isRoot},exports.isStateTreeNode=fe,exports.isType=R,exports.isUnionType=At,exports.isValidReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(fe(r))return!t||P(r);throw new Se("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Ft)return!1;throw e}},exports.joinJsonPath=Ze,exports.onAction=H,exports.onPatch=b,exports.onSnapshot=function(e,t){return be(e).onSnapshot(t)},exports.process=function(e){return Me(),He(e)},exports.protect=function(e){var t=be(e);if(!t.isRoot)throw new Se("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0},exports.recordActions=function(e,t){var r,n=[],i=function(e){(!t||t(e,q()))&&n.push(e)},a={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=H(e,i))},replay:function(e){L(e,n)}};return a.resume(),a},exports.recordPatches=function(e,t){var r,n={patches:[],inversePatches:[]},i={},a={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.inversePatches.slice().reverse()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.inversePatches.slice()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=b(e,(function(e,r){t&&!t(e,r,q())||(n.patches.push(e),n.inversePatches.push(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(t){d(t||e,n.patches)},undo:function(t){d(t||e,n.inversePatches.slice().reverse())}};return a.resume(),a},exports.resolveIdentifier=function(e,t,r){var n=be(t).root.identifierCache.resolve(e,Jt(r));return null==n?void 0:n.value},exports.resolvePath=function(e,t){var r=ge(be(e),t);return r?r.value:void 0},exports.setLivelinessChecking=n,exports.setLivelynessChecking=function(e){n(e)},exports.splitJsonPath=Ye,exports.t=qt,exports.toGenerator=function(e){return l(this,(function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}}))},exports.toGeneratorFunction=function(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return l(this,(function(t){switch(t.label){case 0:return[4,e.apply(void 0,p([],s(r),!1))];case 1:return[2,t.sent()]}}))}},exports.tryReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(fe(r))return t?P(r)?r:void 0:r;throw new Se("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Ft)return;throw e}},exports.tryResolve=w,exports.typecheck=oe,exports.types=qt,exports.unescapeJsonPath=We,exports.unprotect=function(e){var t=be(e);if(!t.isRoot)throw new Se("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1},exports.walk=function e(t,r){var n=be(t);n.getChildren().forEach((function(t){fe(t.storedValue)&&e(t.storedValue,r)})),r(n.storedValue)};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("mobx"),r="warn";function n(e){r=e}function i(){return r}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(e||(e={}));var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var u=function(){return(u=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function l(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function c(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function p(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function f(e){return be(e).type}function b(e,t){return be(e).onPatch(t)}function d(e,t){be(e).applyPatches(Ce(t))}function h(e,t){return be(e).applySnapshot(t)}function y(e,t){void 0===t&&(t=!0);var r=be(e);return t?r.snapshot:r.type.getSnapshot(r,!1)}function v(e){return be(e).root.storedValue}function g(e){return be(e).path}function m(e){return be(e).identifier}function w(e,t){var r=ge(be(e),t,!1);if(void 0!==r)try{return r.value}catch(e){return}}function P(e){return be(e).observableIsAlive}function O(e){var t;return{name:(t=fe(e)?f(e):e).name,properties:u({},t.properties)}}"function"==typeof SuppressedError&&SuppressedError;var j=function(){function r(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:ue.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(r.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(r.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new Re),this._hookSubscribers.register(e,t)}}),Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(r.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(r.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=t.createAtom("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?Ge(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(r.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAlive",{get:function(){return this.state!==ue.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDetaching",{get:function(){return this.state===ue.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=t.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.state===ue.CREATED){if(this.parent){if(this.parent.state!==ue.FINALIZED)return;this.fireHook(e.afterAttach)}this.state=ue.FINALIZED,t&&t()}}}),Object.defineProperty(r.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=ue.DEAD}}),Object.defineProperty(r.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(e.beforeDestroy)}}),r}(),_=function(e){function t(t,r,n,i,a){var o=e.call(this,t,r,n,i)||this;try{o.storedValue=t.createNewInstance(a)}catch(e){throw o.state=ue.DEAD,e}return o.state=ue.CREATED,o.finalizeCreation(),o}return o(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw new Se("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;(r||n)&&(this.environment=void 0,this.baseSetParent(this.parent,t))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return"".concat(this.type.name,"@").concat(e).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==ue.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(j);_.prototype.die=t.action(_.prototype.die);var S,A,I=1;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.CREATING=1]="CREATING",e[e.CREATED=2]="CREATED"}(S||(S={})),function(e){e.Dispose="dispose",e.Patch="patch",e.Snapshot="snapshot"}(A||(A={}));var T,C,E={onError:function(e){throw e}},x=function(r){function n(e,n,i,a,o){var u=r.call(this,e,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++I}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"hasSnapshotPostProcessor",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:S.UNINITIALIZED}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=t.computed((function(){return u.getSnapshot()})),u.unbox=u.unbox.bind(u),u._initialSnapshot=o,u.identifierAttribute=e.identifierAttribute,n||(u.identifierCache=new ce),u._childNodes=e.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var c=u._childNodes[u.identifierAttribute];c&&(l=c.value)}if("string"!=typeof l&&"number"!=typeof l)throw new Se("Instance identifier '".concat(u.identifierAttribute,"' for type '").concat(u.type.name,"' must be a string or a number"));u.identifier=Jt(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return o(n,r),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=!0),this._observableInstanceState===S.UNINITIALIZED&&this.createObservableInstance(e)}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,n,i,a;void 0===t&&(t=!0),this._observableInstanceState=S.CREATING;for(var o=[],u=this.parent;u&&u._observableInstanceState===S.UNINITIALIZED;)o.unshift(u),u=u.parent;try{for(var l=c(o),s=l.next();!s.done;s=l.next()){(d=s.value).createObservableInstanceIfNeeded(!1)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}var p=this.type;try{this.storedValue=p.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,p.finalizeNewInstance(this,this.storedValue)}catch(e){throw this.state=ue.DEAD,e}finally{this._isRunningAction=!1}if(this._observableInstanceState=S.CREATED,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=je,this.state=ue.CREATED,t){this.fireHook(e.afterCreate),this.finalizeCreation();try{for(var f=c(o.reverse()),b=f.next();!b.done;b=f.next()){var d;(d=b.value).fireHook(e.afterCreate),d.finalizeCreation()}}catch(e){i={error:e}}finally{try{b&&!b.done&&(a=f.return)&&a.call(f)}finally{if(i)throw i.error}}}}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(e.beforeDetach);var t=this.state;this.state=ue.DETACHING;var r=this.root,n=r.environment,i=r.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=t}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){var n=t!==this.parent,i=r!==this.subpath;(n||i)&&(n?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,r),this.fireHook(e.afterAttach)):i&&this.baseSetParent(this.parent,r))}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(t._allowStateChangesInsideComputed?t._allowStateChangesInsideComputed((function(){n.apply(r.storedValue)})):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this.hasSnapshotPostProcessor&&this.createObservableInstanceIfNeeded(),this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===S.CREATED?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=i();if(!this.isAlive&&"ignore"!==r){var n=this._getAssertAliveError(e);switch(r){case"error":throw new Se(n);case"warn":t=n,console.warn(new Error("[mobx-state-tree] ".concat(t)))}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&Ge(e.subpath)||"",n=e.actionContext||G();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";if(n&&null!=n.name){var a=n&&n.context&&g(n.context)||t;i="".concat(a,".").concat(n.name,"()")}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '".concat(this.type.name,"', Path upon death: '").concat(t,"', Subpath: '").concat(r,"', Action: '").concat(i,"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.")}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return this._observableInstanceState===S.CREATED?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(je),this._autoUnbox=!1;try{return this._observableInstanceState===S.CREATED?this.type.getChildren(this):we(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw new Se("Cannot modify '".concat(this,"', the object is protected and can only be modified by using an action."))}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>",t=this.identifier?"(id: ".concat(this.identifier,")"):"";return"".concat(this.type.name,"@").concat(e).concat(t).concat(this.isAlive?"":" [dead]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.baseFinalizeCreation((function(){var r,n;try{for(var i=c(t.getChildren()),a=i.next();!a.done;a=i.next()){a.value.finalizeCreation()}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.fireInternalHook(e.afterCreationFinalization)}))}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw new Se("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=J(this.storedValue,"@APPLY_PATCHES",(function(t){t.forEach((function(t){if(t.path){var r=Ye(t.path);me(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)}))})),this._applySnapshot=J(this.storedValue,"@APPLY_SNAPSHOT",(function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)})),De(this.storedValue,"$treenode",this),De(this.storedValue,"toJSON",he)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==ue.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==S.UNINITIALIZED&&(this.getChildren().forEach((function(e){e.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit(A.Dispose),this._internalEventsClear(A.Dispose))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach((function(e){e.finalizeDeath()})),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister(A.Snapshot,e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit(A.Snapshot,e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister(A.Patch,e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers(A.Patch)){var r=s(function(e){if(!("oldValue"in e))throw new Se("Patches without `oldValue` field cannot be inversed");return[Ue(e),$e(e)]}(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var a in i)e[a]=i[a]}return e}({},e,{path:t.path.substr(this.path.length)+(e.path?"/"+e.path:"")})),2),n=r[0],i=r[1];this._internalEventsEmit(A.Patch,n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas(A.Dispose,e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw new Se("cannot add a disposer when it is already registered for execution");this._internalEventsRegister(A.Dispose,e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas(A.Dispose,e))throw new Se("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister(A.Dispose,e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var r=t.reaction((function(){return e.snapshot}),(function(t){return e.emitSnapshot(t)}),E);this.addDisposer(r),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new Re),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,p([e],s(r),!1))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(j);x.prototype.createObservableInstance=t.action(x.prototype.createObservableInstance),x.prototype.detach=t.action(x.prototype.detach),x.prototype.die=t.action(x.prototype.die),function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor",e[e.Lazy=1048576]="Lazy",e[e.Finite=2097152]="Finite",e[e.Float=4194304]="Float"}(C||(C={}));var N=Symbol("$type"),V=function(){function e(e){Object.defineProperty(this,T,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return ae(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw new Se("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(de(e)){var r=f(e);return this.isAssignableFrom(r)?re():ne(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw new Se("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw new Se("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw new Se("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:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw new Se("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:!1,configurable:!0}),e}();T=N,V.prototype.create=t.action(V.prototype.create);var D=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return o(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===Jt(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!fe(t)||be(t)!==e)||!(e.type!==this||!xe(t)||fe(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),fe(t)&&this.isAssignableFrom(f(t))){var i=be(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(V);D.prototype.create=t.action(D.prototype.create);var k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(V);function R(e){return"object"==typeof e&&e&&!0===e.isType}var z=new Map;var F=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function M(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function L(e,r){t.runInAction((function(){Ce(r).forEach((function(t){return function(e,t){var r=w(e,t.path||"");if(!r)throw new Se("Invalid action path: ".concat(t.path||""));var n=be(r);if("@APPLY_PATCHES"===t.name)return d.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return h.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw new Se("Action '".concat(t.name,"' does not exist in '").concat(n.path,"'"));return r[t.name].apply(r,t.args?t.args.map((function(e){return(t=e)&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t;var t})):[])}(e,t)}))}))}function H(e,t,r){return void 0===r&&(r=!1),B(e,(function(n,i){if("action"===n.type&&n.id===n.rootId){var a=be(n.context),o={name:n.name,path:ve(be(e),a),args:n.args.map((function(e,t){return function(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(Ne(n))return n;if(fe(n))return M("[MSTNode: ".concat(f(n).name,"]"));if("function"==typeof n)return M("[function]");if("object"==typeof n&&!Ee(n)&&!Te(n))return M("[object ".concat(n&&n.constructor&&n.constructor.name||"Complex Object","]"));try{return JSON.stringify(n),n}catch(e){return M(""+e)}}(0,n.name,0,e)}))};if(r){var u=i(n);return t(o),u}return t(o),i(n)}return i(n)}))}var U,$=1;function G(){return U}function W(){return $++}function Z(r,n){var i=be(r.context);"action"===r.type&&i.assertAlive({actionContext:r});var a=i._isRunningAction;i._isRunningAction=!0;var o=U;U=r;try{return function(r,n,i){var a=new K(r,i);if(a.isEmpty)return t.action(i).apply(null,n.args);var o=null;return function r(n){var u=a.getNextMiddleware(),l=u&&u.handler;return l?!u.includeHooks&&e[n.name]?r(n):(l(n,(function(e,t){o=r(e),t&&(o=t(o))}),(function(e){o=e})),o):t.action(i).apply(null,n.args)}(n)}(i,r,n)}finally{U=o,i._isRunningAction=a}}function Y(e){if(e)return"action"===e.type?e:e.parentActionEvent}function J(e,t,r){var n=function(){var n=W(),i=U,a=Y(i);return Z({type:"action",name:t,id:n,args:ze(arguments),context:e,tree:v(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?p(p([],s(i.allParentIds),!1),[i.id],!1):[],parentEvent:i,parentActionEvent:a},r)};return n._isMSTAction=!0,n._isFlowAction=r._isFlowAction,n}function B(e,t,r){return void 0===r&&(r=!0),be(e).addMiddleWare(t,r)}var K=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.middlewares[this.arrayIndex];if(e){var t=e[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function q(){for(var e=G();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function Q(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function X(e){return"function"==typeof e?"<function".concat(e.name?" "+e.name:"",">"):fe(e)?"<".concat(e,">"):"`".concat(function(e){try{return JSON.stringify(e)}catch(e){return"<Unserializable: ".concat(e,">")}}(e),"`")}function ee(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map((function(e){return e.path})).filter((function(e){return e.length>0})).join("/"),i=n.length>0?'at path "/'.concat(n,'" '):"",a=fe(t)?"value of type ".concat(be(t).type.name,":"):Ne(t)?"value":"snapshot",o=r&&fe(t)&&r.is(be(t).snapshot);return"".concat(i).concat(a," ").concat(X(t)," is not assignable ").concat(r?"to type: `".concat(r.name,"`"):"")+(e.message?" (".concat(e.message,")"):"")+(r?wt(r)||Ne(t)?".":", expected an instance of `".concat(r.name,"` or a snapshot like `").concat(r.describe(),"` instead.")+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function te(e,t,r){return e.concat([{path:t,type:r}])}function re(){return Oe}function ne(e,t,r){return[{context:e,value:t,message:r}]}function ie(e){return e.reduce((function(e,t){return e.concat(t)}),[])}function ae(e,t){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&oe(e,t)}function oe(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw new Se(function(e,t,r){if(0===r.length)return;return"Error while converting ".concat((n=X(t),n.length<280?n:"".concat(n.substring(0,272),"......").concat(n.substring(n.length-8)))," to `").concat(e.name,"`:\n\n ")+r.map(ee).join("\n ");var n}(e,t,r))}var ue,le=0,ce=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:le++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return"".concat(this.cacheId,"-").concat(t)}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(void 0===r&&(r=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,t.observable.array([],_e));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw new Se("Already registered");i.push(e),r&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;t.values(e.identifierCache.cache).forEach((function(e){return e.forEach((function(e){r.addNodeToCache(e)}))}))}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var n=this,i=new e,a=r.path+"/";return t.entries(this.cache).forEach((function(e){for(var t=s(e,2),o=t[0],u=t[1],l=!1,c=u.length-1;c>=0;c--){var p=u[c];p!==r&&0!==p.path.indexOf(a)||(i.addNodeToCache(p,!1),u.splice(c,1),u.length||n.cache.delete(o),l=!0)}l&&n.updateLastCacheModificationPerId(o)})),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some((function(t){return e.isAssignableFrom(t.type)}))}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter((function(t){return e.isAssignableFrom(t.type)}));switch(n.length){case 0:return null;case 1:return n[0];default:throw new Se("Cannot resolve a reference to type '".concat(e.name,"' with id: '").concat(t,"' unambigously, there are multiple candidates: ").concat(n.map((function(e){return e.path})).join(", ")))}}}),e}();function se(e,t,r,n,i){var a=de(i);if(a){if(a.parent)throw new Se("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 '".concat(t?t.path:"","/").concat(r,"', but it lives already at '").concat(a.path,"'"));return t&&a.setParent(t,r),a}return new x(e,t,r,n,i)}function pe(e,t,r,n,i){return new _(e,t,r,n,i)}function fe(e){return!(!e||!e.$treenode)}function be(e){if(!fe(e))throw new Se("Value ".concat(e," is no MST Node"));return e.$treenode}function de(e){return e&&e.$treenode||null}function he(){return be(this).snapshot}!function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"}(ue||(ue={}));var ye=function(e){return".."};function ve(e,t){if(e.root!==t.root)throw new Se("Cannot calculate relative path: objects '".concat(e,"' and '").concat(t,"' are not part of the same object tree"));for(var r=Ye(e.path),n=Ye(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(ye).join("/")+Ze(n.slice(i))}function ge(e,t,r){return void 0===r&&(r=!0),me(e,Ye(t),r)}function me(e,t,r){void 0===r&&(r=!0);var n=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(".."===a){if(n=n.parent)continue}else{if("."===a)continue;if(n){if(n instanceof _){var o=n.value;fe(o)&&(n=be(o))}if(n instanceof x)if(n.getChildType(a)&&(n=n.getChildNode(a)))continue}}throw new Se("Could not resolve '".concat(a,"' in path '").concat(Ze(t.slice(0,i))||"/","' while resolving '").concat(Ze(t),"'"))}}catch(e){if(!r)return;throw e}return n}function we(e){if(!e)return Oe;var t=Object.keys(e);if(!t.length)return Oe;var r=new Array(t.length);return t.forEach((function(t,n){r[n]=e[t]})),r}var Pe=Object.toString(),Oe=Object.freeze([]),je=Object.freeze({}),_e=t._getGlobalState().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(_e);var Se=function(e){function t(t){return void 0===t&&(t="Illegal state"),e.call(this,"[mobx-state-tree] ".concat(t))||this}return o(t,e),t}(Error);function Ae(e){return e}var Ie=Number.isInteger;function Te(e){return Array.isArray(e)||t.isObservableArray(e)}function Ce(e){return e?Te(e)?e:[e]:Oe}function Ee(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===Pe}function xe(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function Ne(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date}function Ve(e){return"function"!=typeof e}function De(e,r,n){!function(e,r,n){t.isObservableObject(e)?t.defineProperty(e,r,n):Object.defineProperty(e,r,n)}(e,r,{enumerable:!1,writable:!1,configurable:!0,value:n})}var ke=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this.handlers.slice();r.forEach((function(t){return t.apply(void 0,p([],s(e),!1))}))}}),e}(),Re=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new ke),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,p([],s(r),!1))}}),e}();function ze(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function Fe(e,t){return 0===e.indexOf(t)}var Me=function(e,t){};function Le(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function He(e){return function(e,t){var r=function(){var n=W(),i=G();if(!i)throw new Se("a mst flow must always have a parent context");var a=Y(i);if(!a)throw new Se("a mst flow must always have a parent action context");var o={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:p(p([],s(i.allParentIds),!1),[i.id],!1),rootId:i.rootId,parentEvent:i,parentActionEvent:a},l=arguments;function c(e,t,n){return e.$mst_middleware=r.$mst_middleware,Z(u(u({},o),{type:t,args:[n]}),e)}return new Promise((function(e,n){var i,a=function(){i=t.apply(null,arguments),s(void 0)};function s(e){var t;try{var r=c((function(e){t=i.next(e)}),"flow_resume",e);r instanceof Error&&(t=i.throw(r))}catch(e){return void Le((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function p(e){var t;try{c((function(e){t=i.throw(e)}),"flow_resume_error",e)}catch(e){return void Le((function(){c((function(t){n(e)}),"flow_throw",e)}))}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw new Se("Only promises can be yielded to `async`, got: "+t);return t.value.then(s,p)}Le((function(){c((function(t){e(t)}),"flow_return",t.value)}))}a.$mst_middleware=r.$mst_middleware,Z(u(u({},o),{type:"flow_spawn",args:ze(l)}),a)}))};return r._isFlowAction=!0,r}(e.name,e)}function Ue(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function $e(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function Ge(e){return!0==("number"==typeof e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function We(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Ze(e){if(0===e.length)return"";var t=function(e){return e.map(Ge).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function Ye(e){var t=e.split("/").map(We);if(!(""===e||"."===e||".."===e||Fe(e,"/")||Fe(e,"./")||Fe(e,"../")))throw new Se("a json path must be either rooted, empty or relative, but got '".concat(e,"'"));return""===t[0]&&t.shift(),t}Me.ids={};var Je=Symbol("$preProcessorFailed"),Be=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor(".concat(this._subtype.describe(),")")}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(e){return Je}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._processors.postProcessor?this._processors.postProcessor.call(null,e,t.storedValue):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;!function(e,t){for(var r,n,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=c(i),u=o.next();!u.done;u=o.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}(e.type,this,"create"),e instanceof x&&(e.hasSnapshotPostProcessor=!!this._processors.postProcessor);var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e),e)},At(this._subtype)||(e.getReconciliationType=function(){return t})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(n)?n:this.preProcessSnapshot(n),a=this._subtype.instantiate(e,t,r,i);return this._fixNode(a),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,fe(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r,e):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===Je?ne(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=R(e)?this._subtype:fe(e)?y(e,!1):this.preProcessSnapshotSafe(e);return t!==Je&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof D))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(V);var Ke,qe="Map.put can only be used to store complex values that have an identifier type attribute";!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(Ke||(Ke={}));var Qe=function(e){function r(r,n){return e.call(this,r,t.observable.ref.enhancer,n)||this}return o(r,e),Object.defineProperty(r.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(r.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(r.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(r.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(r.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw new Se("Map.put cannot be used to set empty values");if(fe(e)){var t=be(e);if(null===t.identifier)throw new Se(qe);return this.set(t.identifier,e),e}if(xe(e)){var r=be(this),n=r.type;if(n.identifierMode!==Ke.YES)throw new Se(qe);var i=e[n.mapIdentifierAttribute];if(!Bt(i)){var a=this.put(n.getChildType().create(e,r.environment));return this.put(y(a))}var o=Jt(i);return this.set(o,e),this.get(o)}throw new Se("Map.put can only be used to store complex values")}}),r}(t.ObservableMap),Xe=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Ke.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return o(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),se(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Ke.UNKNOWN){var e=[];if(function e(t,r){var n,i,a=t.getSubTypes();if("cannotDetermine"===a)return!1;if(a){var o=Ce(a);try{for(var u=c(o),l=u.next();!l.done;l=u.next()){if(!e(l.value,r))return!1}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return t instanceof ut&&r.push(t),!0}(this._subType,e)){var t=e.reduce((function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw new Se("The objects in a map should all have the same identifier attribute, expected '".concat(e,"', but child of type '").concat(t.name,"' declared attribute '").concat(t.identifierAttribute,"' as identifier"));return t.identifierAttribute}),void 0);t?(this.identifierMode=Ke.YES,this.mapIdentifierAttribute=t):this.identifierMode=Ke.NO}}}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach((function(i){n[i]=r.instantiate(e,i,void 0,t[i])})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new Qe(e,this.name)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._interceptReads(r,e.unbox),e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=J(r,e,n);De(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return t.values(e.storedValue)}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw new Se("Not a child "+t);return r}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var a=e.newValue;if(a===e.object.get(r))return null;ae(i,a),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":ae(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(r.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===Ke.YES&&t instanceof x){var r=t.identifier;if(r!==e)throw new Se("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '".concat(r,"', but expected: '").concat(e,"'"))}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach((function(e){t[e.subpath]=e.snapshot})),t}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:Ge(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:Ge(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:Ge(e.name),oldValue:r},t)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){ae(this,t);var r=e.storedValue,n={};if(Array.from(r.keys()).forEach((function(e){n[e]=!1})),t)for(var i in t)r.set(i,t[i]),n[""+i]=!0;Object.keys(n).forEach((function(e){!1===n[e]&&r.delete(e)}))}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ee(e)?ie(Object.keys(e).map((function(n){return r._subType.validate(e[n],te(t,n,r._subType))}))):ne(t,e,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return je}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),r}(D);Xe.prototype.applySnapshot=t.action(Xe.prototype.applySnapshot);var et=function(e){function r(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return o(r,e),Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new r(this.name,this._subType,t)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return se(this,e,t,r,n)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach((function(t,i){var a=""+i;n[a]=r.instantiate(e,a,void 0,t)})),n}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=u(u({},_e),{name:this.name});return t.observable.array(we(e),r)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){t._getAdministration(r).dehancer=e.unbox,e.type.hookInitializers.forEach((function(e){var t=e(r);Object.keys(t).forEach((function(e){var n=t[e],i=J(r,e,n);De(r,e,i)}))})),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw new Se("Not a child: "+t)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=tt(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var a=e.index,o=e.removedCount,u=e.added,l=tt(t,r,n.slice(a,a+o),u,u.map((function(e,t){return a+t})));if(!l)return null;e.added=l;for(var c=a+o;c<n.length;c++)n[c].setParent(t,""+(c+u.length-o))}return e}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map((function(e){return e.snapshot}))}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach((function(r){t.push(e[r].getSnapshot())})),t}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=be(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"splice":if(e.removedCount&&e.addedCount===e.object.length)return void t.emitPatch({op:"replace",path:"",value:t.snapshot,oldValue:e.removed.map((function(e){return e.snapshot}))},t);for(var r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:e.added[r].snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){ae(this,t),e.storedValue.replace(t)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Te(e)?ie(e.map((function(e,n){return r._subType.validate(e,te(t,""+n,r._subType))}))):ne(t,e,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Oe}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),r}(D);function tt(e,t,r,n,i){for(var a,o=!0,u=0;;u++){var l=u<=n.length-1,c=r[u],s=l?n[u]:void 0,p=""+i[u];if(((a=s)instanceof _||a instanceof x)&&(s=s.storedValue),!c&&!l)break;if(l)if(c)if(nt(c,s))r[u]=rt(t,e,p,s,c);else{for(var f=void 0,b=u;b<r.length;b++)if(nt(r[b],s)){f=r.splice(b,1)[0];break}o=!1;d=rt(t,e,p,s,f);r.splice(u,0,d)}else{if(fe(s)&&be(s).parent===e)throw new Se("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 '".concat(e.path,"/").concat(p,"', but it lives already at '").concat(be(s).path,"'"));o=!1;var d=rt(t,e,p,s);r.splice(u,0,d)}else o=!1,r.splice(u,1),c instanceof x&&c.createObservableInstanceIfNeeded(),c.die(),u--}return o?null:r}function rt(e,t,r,n,i){ae(e,n);var a=function(){if(fe(n)){var a=be(n);if(a.assertAlive(je),null!==a.parent&&a.parent===t)return a.setParent(t,r),a}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==a&&(i instanceof x&&i.createObservableInstanceIfNeeded(),i.die()),a}function nt(e,t){if(!e.isAlive)return!1;if(fe(t)){var r=be(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof x))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&Ee(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}et.prototype.applySnapshot=t.action(et.prototype.applySnapshot);function it(){return be(this).toString()}var at={name:"AnonymousModel",properties:{},initializers:Oe};function ot(t){var r=Object.keys(t),n=new Set;return r.forEach((function(e){if(n.has(e))throw new Se("".concat(e," is declared twice in the model. Model should not contain the same keys"));n.add(e)})),r.reduce((function(r,n){if(n in e)throw new Se("Hook '".concat(n,"' was defined as property. Hooks should be defined as part of the actions"));var i=Object.getOwnPropertyDescriptor(t,n);if("get"in i)throw new Se("Getters are not supported as properties. Please use views instead");var a=i.value;if(null==a)throw new Se("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ne(a))r[n]=Tt(function(e){switch(typeof e){case"string":return st;case"number":return pt;case"boolean":return ht;case"object":if(e instanceof Date)return mt}throw new Se("Cannot determine primitive type from value "+e)}(a),a);else if(a instanceof Xe)r[n]=Tt(a,{});else if(a instanceof et)r[n]=Tt(a,[]);else if(!R(a))throw new Se("Invalid type definition for property '".concat(n,"', cannot infer a type from a value like '").concat(a,"' (").concat(typeof a,")"));return r}),u({},t))}var ut=function(r){function n(e){var t=r.call(this,e.name||at.name)||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Object}),Object.defineProperty(t,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.cloneAndEnhance({name:e})}}),Object.defineProperty(t,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return t.cloneAndEnhance({properties:e})}}),Object.defineProperty(t,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r=t.preProcessor;return r?t.cloneAndEnhance({preProcessor:function(t){return r(e(t))}}):t.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(t,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r=t.postProcessor;return r?t.cloneAndEnhance({postProcessor:function(t){return e(r(t))}}):t.cloneAndEnhance({postProcessor:e})}}),Object.assign(t,at,e),t.properties=ot(t.properties),t.properties,t.propertyNames=Object.keys(t.properties),t.identifierAttribute=t._getIdentifierAttribute(),t}return o(n,r),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps((function(t,r){if(r.flags&C.Identifier){if(e)throw new Se("Cannot define property '".concat(t,"' as object identifier, property '").concat(e,"' is already defined as identifier property"));e=t}})),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(!Ee(r))throw new Se("actions initializer should return a plain object containing actions");Object.keys(r).forEach((function(n){if("preProcessSnapshot"===n)throw new Se("Cannot define action '".concat("preProcessSnapshot","', it should be defined using 'type.preProcessSnapshot(fn)' instead"));if("postProcessSnapshot"===n)throw new Se("Cannot define action '".concat("postProcessSnapshot","', it should be defined using 'type.postProcessSnapshot(fn)' instead"));var i=r[n],a=t[n];if(n in e&&a){var o=i;i=function(){a.apply(null,arguments),o.apply(null,arguments)}}var u=i.$mst_middleware,l=i.bind(r);l._isFlowAction=i._isFlowAction||!1,l.$mst_middleware=u;var c=J(t,n,l);r[n]=c,De(t,n,c)}))}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw new Se("You passed an ".concat(typeof e," to volatile state as an argument, when function is expected"));return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!Ee(r))throw new Se("volatile state initializer should return a plain object containing state");t.set(e,r)}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,a=n.views,o=n.state,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(n,["actions","views","state"]);for(var l in u)throw new Se("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '".concat(l,"'"));return o&&t.instantiateVolatileState(r,o),a&&t.instantiateViews(r,a),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!Ee(r))throw new Se("views initializer should return a plain object containing views");Object.getOwnPropertyNames(r).forEach((function(n){var i,a=Object.getOwnPropertyDescriptor(r,n);if("get"in a)t.defineProperty(e,n,a),t.makeObservable(e,((i={})[n]=t.computed,i));else{if("function"!=typeof a.value)throw new Se("A view member should either be a function or getter based property");De(e,n,a.value)}}))}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return se(this,e,t,r,fe(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps((function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])})),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=u(u({},_e),{name:this.name});return t.observable.object(e,je,r)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){De(r,"toString",it),this.forAllProps((function(n){t._interceptReads(r,n,e.unbox)})),this.initializers.reduce((function(e,t){return t(e)}),r),t.intercept(r,this.willChange),t.observe(r,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=be(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(ae(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=be(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:Ge(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps((function(n){r.push(t.getChildNode(e,n))})),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n;if(!(r in this.properties))throw new Se("Not a value property: "+r);var i=t._getAdministration(e.storedValue,r),a=null===(n=i.raw)||void 0===n?void 0:n.call(i);if(!a)throw new Se("Node not available for property "+r);return a}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this;void 0===r&&(r=!0);var i={};return this.forAllProps((function(r,a){try{t.getAtom(e.storedValue,r).reportObserved()}catch(e){throw new Se("".concat(r," property is declared twice"))}i[r]=n.getChildNode(e,r).snapshot})),r?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].getSnapshot()})),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw new Se("object does not support operation ".concat(r.op));e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){ae(this,t);var r=this.applySnapshotPreProcessor(t);this.forAllProps((function(t){e.storedValue[t]=r[t]}))}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return Ee(n)?ie(this.propertyNames.map((function(e){return r.properties[e].validate(n[e],te(t,e,r.properties[e]))}))):ne(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach((function(r){return e(r,t.properties[r])}))}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map((function(t){return t+": "+e.properties[t].describe()})).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return je}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(D);function lt(e){return R(e)&&(e.flags&C.Object)>0}ut.prototype.applySnapshot=t.action(ut.prototype.applySnapshot);var ct=function(e){function t(t,r,n,i){void 0===i&&(i=Ae);var a=e.call(this,t)||this;return Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),a.flags=r,a}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(Ne(e)&&this.checker(e))return re();var r="Date"===this.name?"Date or a unix milliseconds timestamp":this.name;return ne(t,e,"Value is not a ".concat(r))}}),t}(k),st=new ct("string",C.String,(function(e){return"string"==typeof e})),pt=new ct("number",C.Number,(function(e){return"number"==typeof e})),ft=new ct("integer",C.Integer,(function(e){return Ie(e)})),bt=new ct("float",C.Float,(function(e){return t=e,Number(t)===t&&t%1!=0;var t})),dt=new ct("finite",C.Finite,(function(e){return t=e,Number.isFinite(t);var t})),ht=new ct("boolean",C.Boolean,(function(e){return"boolean"==typeof e})),yt=new ct("null",C.Null,(function(e){return null===e})),vt=new ct("undefined",C.Undefined,(function(e){return void 0===e})),gt=new ct("Date",C.Date,(function(e){return"number"==typeof e||e instanceof Date}),(function(e){return e instanceof Date?e:new Date(e)}));gt.getSnapshot=function(e){return e.storedValue.getTime()};var mt=gt;function wt(e){return R(e)&&(e.flags&(C.String|C.Number|C.Integer|C.Boolean|C.Date))>0}var Pt=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Literal}),r.value=t,r}return o(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ne(e)&&e===this.value?re():ne(t,e,"Value is not a literal ".concat(JSON.stringify(this.value)))}}),t}(k);function Ot(e){return new Pt(e)}var jt=function(e){function t(t,r,n,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=fe(e)?be(e).snapshot:e;return this._predicate(n)?re():ne(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(V);var _t=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=u({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=C.Union;return this._types.forEach((function(t){e|=t.flags})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some((function(t){return t.isAssignableFrom(e)}))}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map((function(e){return e.describe()})).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw new Se("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw new Se("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter((function(e){return e!==t})).find((function(t){return t.is(e)})):this._types.find((function(t){return t.is(e)}))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var a=this._types[i].validate(e,t);if(0===a.length){if(this._eager)return re();n++}else r.push(a)}return 1===n?re():ne(t,e,"No type is applicable for the union").concat(ie(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(V);function St(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=R(e)?void 0:e,i=R(e)?p([e],s(t),!1):t,a="("+i.map((function(e){return e.name})).join(" | ")+")";return new _t(a,i,n)}function At(e){return R(e)&&(e.flags&C.Union)>0}var It=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|C.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&ae(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?re():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(V);function Tt(e,t,r){return function(e,t){if("function"!=typeof t&&fe(t))throw new Se("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,t),new It(e,t,r||Ct)}var Ct=[void 0];var Et=Tt(vt,void 0),xt=Tt(yt,null);function Nt(e){return St(e,Et)}var Vt=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|C.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(e){if(!(e instanceof ReferenceError))throw e;t=void 0}if(e&&void 0===t)throw new Se("Late type seems to be used too early, the definition (still) returns undefined");t&&(this._subType=t)}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):re()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||"cannotDetermine"}}),t}(V);var Dt=function(e){function r(r,n){var i=e.call(this,r)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Lazy}),Object.defineProperty(i,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:t.observable.array()}),t.when((function(){return i.pendingNodeList.length>0&&i.pendingNodeList.some((function(e){return e.isAlive&&i.options.shouldLoadPredicate(e.parent?e.parent.value:null)}))}),(function(){i.options.loadType().then(t.action((function(e){i.loadedType=e,i.pendingNodeList.forEach((function(e){e.parent&&i.loadedType&&e.parent.applyPatches([{op:"replace",path:"/".concat(e.subpath),value:e.snapshot}])}))})))})),i}return o(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<lazy ".concat(this.name,">")}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n,i){var a=this;if(this.loadedType)return this.loadedType.instantiate(e,r,n,i);var o=pe(this,e,r,n,i);return this.pendingNodeList.push(o),t.when((function(){return!o.isAlive}),(function(){return a.pendingNodeList.splice(a.pendingNodeList.indexOf(o),1)})),o}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.loadedType?this.loadedType.validate(e,t):Ve(e)?re():ne(t,e,"Value is not serializable and cannot be lazy")}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i){return this.loadedType?(t.die(),this.loadedType.instantiate(n,i,n.environment,r)):e.prototype.reconcile.call(this,t,r,n,i)}}),r}(k),kt=function(e){function t(t){var r=e.call(this,t?"frozen(".concat(t.name,")"):"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Frozen}),r}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ve(e)?this.subType?this.subType.validate(e,t):re():ne(t,e,"Value is not serializable and cannot be frozen")}}),t}(k),Rt=new kt;var zt=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Bt(e))this.identifier=e;else{if(!fe(e))throw new Se("Can only store references to tree nodes or identifiers, got: '".concat(e,"'"));var r=be(e);if(!r.identifierAttribute)throw new Se("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw new Se("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Jt(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,a=r.identifierCache.resolve(i,t);if(!a)throw new Ft("[mobx-state-tree] Failed to resolve reference '".concat(this.identifier,"' to type '").concat(this.targetType.name,"' (from node: ").concat(e.path,")"));this.resolvedReference={node:a,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Ft=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return o(t,e),t}(Error),Mt=function(t){function r(e,r){var n=t.call(this,"reference(".concat(e.name,")"))||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Reference}),n}return o(r,t),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Bt(e)?re():ne(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var a=i.storedValue;a&&this.onInvalidated({cause:e,parent:a,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){d(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){lt(i.type)?this.replaceRef(void 0):d(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){var n=this,i=this.getValue(t);if(i){var a=be(i),o=function(i,o){var u=function(t){switch(t){case e.beforeDestroy:return"destroy";case e.beforeDetach:return"detach";default:return}}(o);u&&n.fireInvalidated(u,t,r,a)},u=a.registerHook(e.beforeDetach,o),l=a.registerHook(e.beforeDestroy,o);return function(){u(),l()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n){var i=this;if(this.onInvalidated){var a;t.registerHook(e.beforeDestroy,(function(){a&&a()}));var o=function(e){a&&a();var o=t.parent,u=o&&o.storedValue;if(o&&o.isAlive&&u){(n?!!n.get(r,u):t.root.identifierCache.has(i.targetType,Jt(r)))?a=i.addTargetNodeWatcher(t,r):e||i.fireInvalidated("invalidSnapshotReference",t,r,null)}};t.state===ue.FINALIZED?o(!0):(t.isRoot||t.root.registerHook(e.afterCreationFinalization,(function(){t.parent&&t.parent.createObservableInstanceIfNeeded()})),t.registerHook(e.afterAttach,(function(){o(!1)})))}}}),r}(k),Lt=function(e){function t(t,r){return e.call(this,t,r)||this}return o(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(n)?m(n):n,a=new zt(n,this.targetType),o=pe(this,e,t,r,a);return a.node=o,this.watchTargetNodeForInvalidations(o,i,void 0),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=fe(t),a=e.storedValue;if(!i&&a.identifier===t||i&&a.resolvedValue===t)return e.setParent(r,n),e}var o=this.instantiate(r,n,void 0,t);return e.die(),o}}),t}(Mt),Ht=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return o(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(n)?this.options.set(n,e?e.storedValue:null):n,a=pe(this,e,t,r,i);return this.watchTargetNodeForInvalidations(a,i,this.options),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=fe(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var a=this.instantiate(r,n,void 0,i);return e.die(),a}}),t}(Mt);function Ut(e,t){var r=t||void 0,n=t?t.onInvalidated:void 0;return r&&(r.get||r.set)?new Ht(e,{get:r.get,set:r.set},n):new Lt(e,n)}var $t=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Identifier}),n}return o(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof ut))throw new Se("Identifier types can only be instantiated as direct child of a model type");return pe(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw new Se("Tried to change identifier from '".concat(e.storedValue,"' to '").concat(t,"'. Changing identifiers is not allowed."));return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?ne(t,e,"Value is not a valid ".concat(this.describe(),", expected a ").concat(this.validType)):re()}}),t}(k),Gt=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Identifier}),t}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}($t),Wt=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return o(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}($t),Zt=new Gt,Yt=new Wt;function Jt(e){return""+e}function Bt(e){return"string"==typeof e||"number"==typeof e}var Kt=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:C.Custom}),r}return o(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return re();var r=this.options.getValidationMessage(e);return r?ne(t,e,"Invalid value for type '".concat(this.name,"': ").concat(r)):re()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return pe(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var a=i?this.options.fromSnapshot(t,r.root.environment):t,o=this.instantiate(r,n,void 0,a);return e.die(),o}}),t}(k),qt={enumeration:function(e,t){var r="string"==typeof e?t:e,n=St.apply(void 0,p([],s(r.map((function(e){return Ot(""+e)}))),!1));return"string"==typeof e&&(n.name=e),n},model:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new ut({name:r,properties:n})},compose:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),e.reduce((function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})})).named(n)},custom:function(e){return new Kt(e)},reference:Ut,safeReference:function(e,t){var r=Ut(e,u(u({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:Nt(r)},union:St,optional:Tt,literal:Ot,maybe:Nt,maybeNull:function(e){return St(e,xt)},refinement:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():R(e[0])?e[0].name:null,n=e[0],i=e[1],a=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return new jt(r,n,i,a)},string:st,boolean:ht,number:pt,integer:ft,float:bt,finite:dt,Date:mt,map:function(e){return new Xe("Map<string, ".concat(e.name,">"),e)},array:function(e){return new et("".concat(e.name,"[]"),e)},frozen:function(e){return 0===arguments.length?Rt:R(e)?new kt(e):Tt(Rt,e)},identifier:Zt,identifierNumber:Yt,late:function(e,t){var r="string"==typeof e?e:"late(".concat(e.toString(),")");return new Vt(r,"string"==typeof e?t:e)},lazy:function(e,t){return new Dt(e,t)},undefined:vt,null:yt,snapshotProcessor:function(e,t,r){return new Be(e,t,r)}};exports.addDisposer=function(e,t){return be(e).addDisposer(t),t},exports.addMiddleware=B,exports.applyAction=L,exports.applyPatch=d,exports.applySnapshot=h,exports.cast=function(e){return e},exports.castFlowReturn=function(e){return e},exports.castToReferenceSnapshot=function(e){return e},exports.castToSnapshot=function(e){return e},exports.clone=function(e,t){void 0===t&&(t=!0);var r=be(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)},exports.createActionTrackingMiddleware=function(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),z.set(t.id,{call:t,context:i,async:!1});try{var a=r(t);return e.onSuspend(t,i),!1===z.get(t.id).async&&(z.delete(t.id),e.onSuccess(t,i,a)),a}catch(r){throw z.delete(t.id),e.onFail(t,i,r),r}case"flow_spawn":return(o=z.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var o=z.get(t.rootId);e.onResume(t,o.context);try{return r(t)}finally{e.onSuspend(t,o.context)}case"flow_throw":o=z.get(t.rootId);return z.delete(t.rootId),e.onFail(t,o.context,t.args[0]),r(t);case"flow_return":o=z.get(t.rootId);return z.delete(t.rootId),e.onSuccess(t,o.context,t.args[0]),r(t)}}},exports.createActionTrackingMiddleware2=function(e){var t=new Map;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent.id):void 0;if("action"===r.type){var a=u(u({},r),{env:i&&i.call.env,parentCall:i&&i.call}),o=!e.filter||e.filter(a),l=new F(o?e:void 0,a);t.set(r.id,l);var c=void 0;try{c=n(r)}catch(e){throw t.delete(r.id),l.finish(e),e}return l.hasFlowsPending||(t.delete(r.id),l.finish()),c}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var s=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish(s))}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||(t.delete(r.parentActionEvent.id),i.finish())}}}},exports.decorate=function(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t},exports.destroy=function(e){var t=be(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)},exports.detach=function(e){return be(e).detach(),e},exports.escapeJsonPath=Ge,exports.flow=He,exports.getChildType=function(e,t){return be(e).getChildType(t)},exports.getEnv=function(e){var t=be(e),r=t.root.environment;if(!r)throw new Se("Failed to find the environment of ".concat(t," ").concat(t.path));return r},exports.getIdentifier=m,exports.getLivelinessChecking=i,exports.getMembers=function(e){var r=be(e).type,n=u(u({},O(r)),{actions:[],volatile:[],views:[],flowActions:[]});return Object.getOwnPropertyNames(e).forEach((function(r){if(!(r in n.properties)){var i=Object.getOwnPropertyDescriptor(e,r);i.get?t.isComputedProp(e,r)?n.views.push(r):n.volatile.push(r):(!0===i.value._isFlowAction&&n.flowActions.push(r),!0===i.value._isMSTAction?n.actions.push(r):t.isObservableProp(e,r)?n.volatile.push(r):n.views.push(r))}})),n},exports.getNodeId=function(e){return be(e).nodeId},exports.getParent=function(e,t){void 0===t&&(t=1);for(var r=t,n=be(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw new Se("Failed to find the parent of ".concat(be(e)," at depth ").concat(t))},exports.getParentOfType=function(e,t){for(var r=be(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw new Se("Failed to find the parent of ".concat(be(e)," of a given type"))},exports.getPath=g,exports.getPathParts=function(e){return Ye(be(e).path)},exports.getPropertyMembers=O,exports.getRelativePath=function(e,t){return ve(be(e),be(t))},exports.getRoot=v,exports.getRunningActionContext=q,exports.getSnapshot=y,exports.getType=f,exports.hasEnv=function(e){return!!be(e).root.environment},exports.hasParent=function(e,t){void 0===t&&(t=1);for(var r=be(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1},exports.hasParentOfType=function(e,t){for(var r=be(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1},exports.isActionContextChildOf=function(e,t){return Q(e,t,!1)},exports.isActionContextThisOrChildOf=function(e,t){return Q(e,t,!0)},exports.isAlive=P,exports.isArrayType=function(e){return R(e)&&(e.flags&C.Array)>0},exports.isFrozenType=function(e){return R(e)&&(e.flags&C.Frozen)>0},exports.isIdentifierType=function(e){return R(e)&&(e.flags&C.Identifier)>0},exports.isLateType=function(e){return R(e)&&(e.flags&C.Late)>0},exports.isLiteralType=function(e){return R(e)&&(e.flags&C.Literal)>0},exports.isMapType=function(e){return R(e)&&(e.flags&C.Map)>0},exports.isModelType=lt,exports.isOptionalType=function(e){return R(e)&&(e.flags&C.Optional)>0},exports.isPrimitiveType=wt,exports.isProtected=function(e){return be(e).isProtected},exports.isReferenceType=function(e){return R(e)&&(e.flags&C.Reference)>0},exports.isRefinementType=function(e){return R(e)&&(e.flags&C.Refinement)>0},exports.isRoot=function(e){return be(e).isRoot},exports.isStateTreeNode=fe,exports.isType=R,exports.isUnionType=At,exports.isValidReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(fe(r))return!t||P(r);throw new Se("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Ft)return!1;throw e}},exports.joinJsonPath=Ze,exports.onAction=H,exports.onPatch=b,exports.onSnapshot=function(e,t){return be(e).onSnapshot(t)},exports.process=function(e){return Me(),He(e)},exports.protect=function(e){var t=be(e);if(!t.isRoot)throw new Se("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0},exports.recordActions=function(e,t){var r,n=[],i=function(e){(!t||t(e,q()))&&n.push(e)},a={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=H(e,i))},replay:function(e){L(e,n)}};return a.resume(),a},exports.recordPatches=function(e,t){var r,n={patches:[],inversePatches:[]},i={},a={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.inversePatches.slice().reverse()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.inversePatches.slice()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=b(e,(function(e,r){t&&!t(e,r,q())||(n.patches.push(e),n.inversePatches.push(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)})))},replay:function(t){d(t||e,n.patches)},undo:function(t){d(t||e,n.inversePatches.slice().reverse())}};return a.resume(),a},exports.resolveIdentifier=function(e,t,r){var n=be(t).root.identifierCache.resolve(e,Jt(r));return null==n?void 0:n.value},exports.resolvePath=function(e,t){var r=ge(be(e),t);return r?r.value:void 0},exports.setLivelinessChecking=n,exports.setLivelynessChecking=function(e){n(e)},exports.splitJsonPath=Ye,exports.t=qt,exports.toGenerator=function(e){return l(this,(function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}}))},exports.toGeneratorFunction=function(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return l(this,(function(t){switch(t.label){case 0:return[4,e.apply(void 0,p([],s(r),!1))];case 1:return[2,t.sent()]}}))}},exports.tryReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(fe(r))return t?P(r)?r:void 0:r;throw new Se("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Ft)return;throw e}},exports.tryResolve=w,exports.typecheck=oe,exports.types=qt,exports.unescapeJsonPath=We,exports.unprotect=function(e){var t=be(e);if(!t.isRoot)throw new Se("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1},exports.walk=function e(t,r){var n=be(t);n.getChildren().forEach((function(t){fe(t.storedValue)&&e(t.storedValue,r)})),r(n.storedValue)};
|