UNPKG

106 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mobx")):"function"==typeof define&&define.amd?define(["exports","mobx"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mobxStateTree={},e.mobx)}(this,(function(e,t){"use strict";var r,n="warn";function i(e){n=e}function a(){return n}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(r||(r={}));
2/*! *****************************************************************************
3 Copyright (c) Microsoft Corporation.
4
5 Permission to use, copy, modify, and/or distribute this software for any
6 purpose with or without fee is hereby granted.
7
8 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 PERFORMANCE OF THIS SOFTWARE.
15 ***************************************************************************** */
16var o=function(e,t){return(o=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 u(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}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var l=function(){return(l=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 s(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(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}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 p(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 f(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}function b(e){return fe(e).type}function h(e,t){return fe(e).onPatch(t)}function d(e,t){fe(e).applyPatches(Te(t))}function y(e,t){return fe(e).applySnapshot(t)}function v(e,t){void 0===t&&(t=!0);var r=fe(e);return t?r.snapshot:r.type.getSnapshot(r,!1)}function g(e){return fe(e).root.storedValue}function m(e){return fe(e).path}function w(e){return fe(e).identifier}function P(e,t){var r=ve(fe(e),t,!1);if(void 0!==r)try{return r.value}catch(e){return}}function O(e){return fe(e).observableIsAlive}function j(e){var t;return{name:(t=pe(e)?b(e):e).name,properties:l({},t.properties)}}var _=function(){function e(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:oe.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(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.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(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new xe),this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.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(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.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?Ue(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==oe.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===oe.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=t.createAtom("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.state===oe.CREATED){if(this.parent){if(this.parent.state!==oe.FINALIZED)return;this.fireHook(r.afterAttach)}this.state=oe.FINALIZED,e&&e()}}}),Object.defineProperty(e.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=oe.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(r.beforeDestroy)}}),e}(),S=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=oe.DEAD,e}return o.state=oe.CREATED,o.finalizeCreation(),o}return u(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw _e("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 this.type.name+"@"+e+(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==oe.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}(_);S.prototype.die=t.action(S.prototype.die);var A,I,T=1,C={onError:function(e){throw e}},E=function(e){function n(r,n,i,a,o){var u=e.call(this,r,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++T}),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,"_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:0}),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=r.identifierAttribute,n||(u.identifierCache=new le),u._childNodes=r.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 s=u._childNodes[u.identifierAttribute];s&&(l=s.value)}if("string"!=typeof l&&"number"!=typeof l)throw _e("Instance identifier '"+u.identifierAttribute+"' for type '"+u.type.name+"' must be a string or a number");u.identifier=Lt(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return u(n,e),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(){0===this._observableInstanceState&&this.createObservableInstance()}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t;this._observableInstanceState=1;for(var n=[],i=this.parent;i&&0===i._observableInstanceState;)n.unshift(i),i=i.parent;try{for(var a=c(n),o=a.next();!o.done;o=a.next()){o.value.createObservableInstanceIfNeeded()}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}var u=this.type;try{this.storedValue=u.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,u.finalizeNewInstance(this,this.storedValue)}catch(e){throw this.state=oe.DEAD,e}finally{this._isRunningAction=!1}this._observableInstanceState=2,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=Oe,this.state=oe.CREATED,this.fireHook(r.afterCreate),this.finalizeCreation()}}),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(r.beforeDetach);var e=this.state;this.state=oe.DETACHING;var t=this.root,n=t.environment,i=t.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=e}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=e!==this.parent,i=t!==this.subpath;(n||i)&&(n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,t),this.fireHook(r.afterAttach)):i&&this.baseSetParent(this.parent,t))}}),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._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?2===this._observableInstanceState?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=a();if(!this.isAlive&&"ignore"!==r){var n=this._getAssertAliveError(e);switch(r){case"error":throw _e(n);case"warn":t=n,console.warn(new Error("[mobx-state-tree] "+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&&Ue(e.subpath)||"",n=e.actionContext||$();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";n&&null!=n.name&&(i=(n&&n.context&&m(n.context)||t)+"."+n.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+t+"', Subpath: '"+r+"', Action: '"+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 2===this._observableInstanceState?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(Oe),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):me(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 _e("Cannot modify '"+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: "+this.identifier+")":"";return this.type.name+"@"+e+t+(this.isAlive?"":" [dead]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation((function(){var t,n;try{for(var i=c(e.getChildren()),a=i.next();!a.done;a=i.next()){a.value.finalizeCreation()}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.fireInternalHook(r.afterCreationFinalization)}))}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw _e("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=Ge(t.path);ge(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)})),Ne(this.storedValue,"$treenode",this),Ne(this.storedValue,"toJSON",he)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==oe.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){0!==this._observableInstanceState&&(this.getChildren().forEach((function(e){e.aboutToDie()})),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("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("snapshot",e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit("snapshot",e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister("patch",e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers("patch")){var r=p(function(e){if(!("oldValue"in e))throw _e("Patches without `oldValue` field cannot be inversed");return[He(e),Le(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})),2),n=r[0],i=r[1];this._internalEventsEmit("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("dispose",e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw _e("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas("dispose",e))throw _e("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("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)}),C);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 xe),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,f([e],r))}}),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}(_);E.prototype.createObservableInstance=t.action(E.prototype.createObservableInstance),E.prototype.detach=t.action(E.prototype.detach),E.prototype.die=t.action(E.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"}(I||(I={}));var V=Symbol("$type"),N=function(){function e(e){Object.defineProperty(this,A,{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 ie(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw _e("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(be(e)){var r=b(e);return this.isAssignableFrom(r)?te():re(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 _e("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 _e("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 _e("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 _e("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}();A=V,N.prototype.create=t.action(N.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 u(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===Lt(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!pe(t)||fe(t)!==e)||!(e.type!==this||!Ee(t)||pe(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(),pe(t)&&this.isAssignableFrom(b(t))){var i=fe(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}(N);D.prototype.create=t.action(D.prototype.create);var x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(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}(N);function k(e){return"object"==typeof e&&e&&!0===e.isType}var R=new Map;var z=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 F(e,r){t.runInAction((function(){Te(r).forEach((function(t){return function(e,t){var r=P(e,t.path||"");if(!r)throw _e("Invalid action path: "+(t.path||""));var n=fe(r);if("@APPLY_PATCHES"===t.name)return d.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return y.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw _e("Action '"+t.name+"' does not exist in '"+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),Z(e,(function(n,i){if("action"===n.type&&n.id===n.rootId){var a=fe(n.context),o={name:n.name,path:ye(fe(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(Ve(n))return n;if(pe(n))return M("[MSTNode: "+b(n).name+"]");if("function"==typeof n)return M("[function]");if("object"==typeof n&&!Ce(n)&&!Ie(n))return M("[object "+(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 L,U=1;function $(){return L}function W(){return U++}function G(e,n){var i=fe(e.context);"action"===e.type&&i.assertAlive({actionContext:e});var a=i._isRunningAction;i._isRunningAction=!0;var o=L;L=e;try{return function(e,n,i){var a=new B(e,i);if(a.isEmpty)return t.action(i).apply(null,n.args);var o=null;return function e(n){var u=a.getNextMiddleware(),l=u&&u.handler;return l?!u.includeHooks&&r[n.name]?e(n):(l(n,(function(t,r){o=e(t),r&&(o=r(o))}),(function(e){o=e})),o):t.action(i).apply(null,n.args)}(n)}(i,e,n)}finally{L=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=L,a=Y(i);return G({type:"action",name:t,id:n,args:ke(arguments),context:e,tree:g(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?f(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:a},r)};return n._isMSTAction=!0,n}function Z(e,t,r){return void 0===r&&(r=!0),fe(e).addMiddleWare(t,r)}var B=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 K(){for(var e=$();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 Q(e){return"function"==typeof e?"<function"+(e.name?" "+e.name:"")+">":pe(e)?"<"+e+">":"`"+function(e){try{return JSON.stringify(e)}catch(e){return"<Unserializable: "+e+">"}}(e)+"`"}function X(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 "/'+n+'" ':"",a=pe(t)?"value of type "+fe(t).type.name+":":Ve(t)?"value":"snapshot",o=r&&pe(t)&&r.is(fe(t).snapshot);return""+i+a+" "+Q(t)+" is not assignable "+(r?"to type: `"+r.name+"`":"")+(e.message?" ("+e.message+")":"")+(r?dt(r)||Ve(t)?".":", expected an instance of `"+r.name+"` or a snapshot like `"+r.describe()+"` instead."+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function ee(e,t,r){return e.concat([{path:t,type:r}])}function te(){return Pe}function re(e,t,r){return[{context:e,value:t,message:r}]}function ne(e){return e.reduce((function(e,t){return e.concat(t)}),[])}function ie(e,t){"undefined"!=typeof process&&process.env&&"true"===process.env.ENABLE_TYPE_CHECK&&ae(e,t)}function ae(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw _e(function(e,t,r){if(0===r.length)return;return"Error while converting "+(n=Q(t),(n.length<280?n:n.substring(0,272)+"......"+n.substring(n.length-8))+" to `")+e.name+"`:\n\n "+r.map(X).join("\n ");var n}(e,t,r))}var oe,ue=0,le=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:ue++}),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 this.cacheId+"-"+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([],je));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw _e("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=p(e,2),r=t[0],o=t[1],u=!1,l=o.length-1;l>=0;l--)0===o[l].path.indexOf(a)&&(i.addNodeToCache(o[l],!1),o.splice(l,1),u=!0);u&&n.updateLastCacheModificationPerId(r)})),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 _e("Cannot resolve a reference to type '"+e.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+n.map((function(e){return e.path})).join(", "))}}}),e}();function se(e,t,r,n,i){var a=be(i);if(a){if(a.parent)throw _e("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(t?t.path:"")+"/"+r+"', but it lives already at '"+a.path+"'");return t&&a.setParent(t,r),a}return new E(e,t,r,n,i)}function ce(e,t,r,n,i){return new S(e,t,r,n,i)}function pe(e){return!(!e||!e.$treenode)}function fe(e){if(!pe(e))throw _e("Value "+e+" is no MST Node");return e.$treenode}function be(e){return e&&e.$treenode||null}function he(){return fe(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"}(oe||(oe={}));var de=function(e){return".."};function ye(e,t){if(e.root!==t.root)throw _e("Cannot calculate relative path: objects '"+e+"' and '"+t+"' are not part of the same object tree");for(var r=Ge(e.path),n=Ge(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(de).join("/")+We(n.slice(i))}function ve(e,t,r){return void 0===r&&(r=!0),ge(e,Ge(t),r)}function ge(e,t,r){void 0===r&&(r=!0);for(var n=e,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 S)try{var o=n.value;pe(o)&&(n=fe(o))}catch(e){if(!r)return;throw e}if(n instanceof E)if(n.getChildType(a)&&(n=n.getChildNode(a)))continue}}if(r)throw _e("Could not resolve '"+a+"' in path '"+(We(t.slice(0,i))||"/")+"' while resolving '"+We(t)+"'");return}return n}function me(e){if(!e)return Pe;var t=Object.keys(e);if(!t.length)return Pe;var r=new Array(t.length);return t.forEach((function(t,n){r[n]=e[t]})),r}var we=Object.toString(),Pe=Object.freeze([]),Oe=Object.freeze({}),je=t._getGlobalState().useProxies?{deep:!1}:{deep:!1,proxy:!1};function _e(e){return void 0===e&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function Se(e){return e}Object.freeze(je);var Ae=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function Ie(e){return Array.isArray(e)||t.isObservableArray(e)}function Te(e){return e?Ie(e)?e:[e]:Pe}function Ce(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())===we}function Ee(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function Ve(e,t){return void 0===t&&(t=!0),null==e||!!("string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date)}function Ne(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 De=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,f(e))}))}}),e}(),xe=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 De),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,f(r))}}),e}();function ke(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function Re(e,t){return 0===e.indexOf(t)}var ze=function(e,t){};function Me(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function Fe(e){return function(e,t){var r=function(){var n=W(),i=$();if(!i)throw _e("a mst flow must always have a parent context");var a=Y(i);if(!a)throw _e("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:f(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:a},u=arguments;function s(e,t,n){e.$mst_middleware=r.$mst_middleware,G(l(l({},o),{type:t,args:[n]}),e)}return new Promise((function(e,n){var i,a=function(){i=t.apply(null,arguments),c(void 0)};function c(e){var t;try{s((function(e){t=i.next(e)}),"flow_resume",e)}catch(e){return void Me((function(){s((function(t){n(e)}),"flow_throw",e)}))}f(t)}function p(e){var t;try{s((function(e){t=i.throw(e)}),"flow_resume_error",e)}catch(e){return void Me((function(){s((function(t){n(e)}),"flow_throw",e)}))}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw _e("Only promises can be yielded to `async`, got: "+t);return t.value.then(c,p)}Me((function(){s((function(t){e(t)}),"flow_return",t.value)}))}a.$mst_middleware=r.$mst_middleware,G(l(l({},o),{type:"flow_spawn",args:ke(u)}),a)}))};return r}(e.name,e)}function He(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 Le(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 Ue(e){return!0==("number"==typeof e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function $e(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function We(e){if(0===e.length)return"";var t=function(e){return e.map(Ue).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function Ge(e){var t=e.split("/").map($e);if(!(""===e||"."===e||".."===e||Re(e,"/")||Re(e,"./")||Re(e,"../")))throw _e("a json path must be either rooted, empty or relative, but got '"+e+"'");return""===t[0]&&t.shift(),t}ze.ids={};var Ye=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 u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|I.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor("+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,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.postProcessor?this._processors.postProcessor.call(null,e):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","is","isMatchingSnapshotId");var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e))}}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=pe(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,pe(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):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshot(e);return 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=k(e)?this._subtype:pe(e)?v(e,!1):this.preProcessSnapshot(e);return 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 D.prototype.isMatchingSnapshotId.call(this._subtype,e,r)}}),t}(N);var Je,Ze="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"}(Je||(Je={}));var Be=function(e){function r(r){return e.call(this,r,t.observable.ref.enhancer)||this}return u(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 _e("Map.put cannot be used to set empty values");if(pe(e)){var t=fe(e);if(null===t.identifier)throw _e(Ze);return this.set(t.identifier,e),e}if(Ee(e)){var r=fe(this),n=r.type;if(n.identifierMode!==Je.YES)throw _e(Ze);var i=e[n.mapIdentifierAttribute];if(!Ut(i)){var a=this.put(n.getChildType().create(e,r.environment));return this.put(v(a))}var o=Lt(i);return this.set(o,e),this.get(o)}throw _e("Map.put can only be used to store complex values")}}),r}(t.ObservableMap),Ke=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:Je.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:I.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return u(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===Je.UNKNOWN){var e=[];if(function e(t,r){var n,i,a=t.getSubTypes();if("cannotDetermine"===a)return!1;if(a){var o=Te(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 it&&r.push(t),!0}(this._subType,e)){var t=void 0;e.forEach((function(e){if(e.identifierAttribute){if(t&&t!==e.identifierAttribute)throw _e("The objects in a map should all have the same identifier attribute, expected '"+t+"', but child of type '"+e.name+"' declared attribute '"+e.identifierAttribute+"' as identifier");t=e.identifierAttribute}})),t?(this.identifierMode=Je.YES,this.mapIdentifierAttribute=t):this.identifierMode=Je.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 Be(e)}}),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);Ne(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"Map<string, "+this._subType.describe()+">"}}),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 _e("Not a child "+t);return r}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=fe(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;ie(i,a),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":ie(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===Je.YES&&t instanceof E){var r=t.identifier;if(r!==e)throw _e("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+r+"', but expected: '"+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=fe(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:Ue(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:Ue(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:Ue(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){ie(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 Ce(e)?ne(Object.keys(e).map((function(n){return r._subType.validate(e[n],ee(t,n,r._subType))}))):re(t,e,"Value is not a plain object")}}),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.delete(t)}}),r}(D);Ke.prototype.applySnapshot=t.action(Ke.prototype.applySnapshot);var qe=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:I.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return u(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){return t.observable.array(me(e),je)}}),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);Ne(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._subType.describe()+"[]"}}),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 _e("Not a child: "+t)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=fe(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=Qe(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=Qe(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 s=a+o;s<n.length;s++)n[s].setParent(t,""+(s+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=fe(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":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:t.getChildNode(""+(e.index+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){ie(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 Ie(e)?ne(e.map((function(e,n){return r._subType.validate(e,ee(t,""+n,r._subType))}))):re(t,e,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Pe}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),r}(D);function Qe(e,t,r,n,i){for(var a,o=!0,u=0;;u++){var l=u<=n.length-1,s=r[u],c=l?n[u]:void 0,p=""+i[u];if(((a=c)instanceof S||a instanceof E)&&(c=c.storedValue),!s&&!l)break;if(l)if(s)if(et(s,c))r[u]=Xe(t,e,p,c,s);else{for(var f=void 0,b=u;b<r.length;b++)if(et(r[b],c)){f=r.splice(b,1)[0];break}o=!1;h=Xe(t,e,p,c,f);r.splice(u,0,h)}else{if(pe(c)&&fe(c).parent===e)throw _e("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+e.path+"/"+p+"', but it lives already at '"+fe(c).path+"'");o=!1;var h=Xe(t,e,p,c);r.splice(u,0,h)}else o=!1,r.splice(u,1),s instanceof E&&s.createObservableInstanceIfNeeded(),s.die(),u--}return o?null:r}function Xe(e,t,r,n,i){ie(e,n);var a=function(){if(pe(n)){var a=fe(n);if(a.assertAlive(Oe),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 E&&i.createObservableInstanceIfNeeded(),i.die()),a}function et(e,t){if(!e.isAlive)return!1;if(pe(t)){var r=fe(t);return r.isAlive&&r===e}return e.snapshot===t||e instanceof E&&null!==e.identifier&&e.identifierAttribute&&Ce(t)&&e.type.isMatchingSnapshotId(e,t)&&e.type.is(t)}qe.prototype.applySnapshot=t.action(qe.prototype.applySnapshot);function tt(){return fe(this).toString()}var rt={name:"AnonymousModel",properties:{},initializers:Pe};function nt(e){return Object.keys(e).reduce((function(e,t){var n,i,a;if(t in r)throw _e("Hook '"+t+"' was defined as property. Hooks should be defined as part of the actions");var o=Object.getOwnPropertyDescriptor(e,t);if("get"in o)throw _e("Getters are not supported as properties. Please use views instead");var u=o.value;if(null==u)throw _e("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(Ve(u))return Object.assign({},e,((n={})[t]=Ot(function(e){switch(typeof e){case"string":return ut;case"number":return lt;case"boolean":return ct;case"object":if(e instanceof Date)return ht}throw _e("Cannot determine primitive type from value "+e)}(u),u),n));if(u instanceof Ke)return Object.assign({},e,((i={})[t]=Ot(u,{}),i));if(u instanceof qe)return Object.assign({},e,((a={})[t]=Ot(u,[]),a));if(k(u))return e;throw _e("Invalid type definition for property '"+t+"', cannot infer a type from a value like '"+u+"' ("+typeof u+")")}),e)}var it=function(e){function n(t){var r=e.call(this,t.name||rt.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:I.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({name:e})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({properties:e})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.preProcessor;return t?r.cloneAndEnhance({preProcessor:function(r){return t(e(r))}}):r.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.postProcessor;return t?r.cloneAndEnhance({postProcessor:function(r){return e(t(r))}}):r.cloneAndEnhance({postProcessor:e})}}),Object.assign(r,rt,t),r.properties=nt(r.properties),r.properties,r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return u(n,e),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&I.Identifier){if(e)throw _e("Cannot define property '"+t+"' as object identifier, property '"+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(e,t){if(!Ce(t))throw _e("actions initializer should return a plain object containing actions");Object.keys(t).forEach((function(n){if("preProcessSnapshot"===n)throw _e("Cannot define action 'preProcessSnapshot', it should be defined using 'type.preProcessSnapshot(fn)' instead");if("postProcessSnapshot"===n)throw _e("Cannot define action 'postProcessSnapshot', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=t[n],a=e[n];if(n in r&&a){var o=i;i=function(){a.apply(null,arguments),o.apply(null,arguments)}}var u=i.$mst_middleware,l=i.bind(t);l.$mst_middleware=u;var s=J(e,n,l);t[n]=s,Ne(e,n,s)}))}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw _e("You passed an "+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(!Ce(r))throw _e("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 _e("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+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(!Ce(r))throw _e("views initializer should return a plain object containing views");Object.keys(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 _e("A view member should either be a function or getter based property");Ne(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,pe(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){return t.observable.object(e,Oe,je)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){Ne(r,"toString",tt),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=fe(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(ie(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=fe(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:Ue(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){if(!(r in this.properties))throw _e("Not a value property: "+r);var n=t._getAdministration(e.storedValue,r).raw();if(!n)throw _e("Node not available for property "+r);return n}}),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){t.getAtom(e.storedValue,r).reportObserved(),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 _e("object does not support operation "+r.op);e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.applySnapshotPreProcessor(t);ie(this,r),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 Ce(n)?ne(this.propertyNames.map((function(e){return r.properties[e].validate(n[e],ee(t,e,r.properties[e]))}))):re(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 Oe}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(D);function at(e){return k(e)&&(e.flags&I.Object)>0}it.prototype.applySnapshot=t.action(it.prototype.applySnapshot);var ot=function(e){function t(t,r,n,i){void 0===i&&(i=Se);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 u(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 ce(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){return Ve(e)&&this.checker(e)?te():re(t,e,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))}}),t}(x),ut=new ot("string",I.String,(function(e){return"string"==typeof e})),lt=new ot("number",I.Number,(function(e){return"number"==typeof e})),st=new ot("integer",I.Integer,(function(e){return Ae(e)})),ct=new ot("boolean",I.Boolean,(function(e){return"boolean"==typeof e})),pt=new ot("null",I.Null,(function(e){return null===e})),ft=new ot("undefined",I.Undefined,(function(e){return void 0===e})),bt=new ot("Date",I.Date,(function(e){return"number"==typeof e||e instanceof Date}),(function(e){return e instanceof Date?e:new Date(e)}));bt.getSnapshot=function(e){return e.storedValue.getTime()};var ht=bt;function dt(e){return k(e)&&(e.flags&(I.String|I.Number|I.Integer|I.Boolean|I.Date))>0}var yt=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:I.Literal}),r.value=t,r}return u(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return ce(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 Ve(e)&&e===this.value?te():re(t,e,"Value is not a literal "+JSON.stringify(this.value))}}),t}(x);function vt(e){return new yt(e)}var gt=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 u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|I.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=pe(e)?fe(e).snapshot:e;return this._predicate(n)?te():re(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}(N);var mt=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=l({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=I.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 _e("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.type);if(!i)throw _e("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 te();n++}else r.push(a)}return 1===n?te():re(t,e,"No type is applicable for the union").concat(ne(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(N);function wt(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=k(e)?void 0:e,i=k(e)?f([e],t):t,a="("+i.map((function(e){return e.name})).join(" | ")+")";return new mt(a,i,n)}var Pt=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 u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|I.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&&ie(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?te():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}(N);function Ot(e,t,r){return function(e,t){if("function"!=typeof t&&pe(t))throw _e("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}(0,t),new Pt(e,t,r||jt)}var jt=[void 0];var _t=Ot(ft,void 0),St=Ot(pt,null);function At(e){return wt(e,_t)}var It=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 u(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|I.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 _e("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):te()}}),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}(N);var Tt=function(e){function t(t){var r=e.call(this,t?"frozen("+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:I.Frozen}),r}return u(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 ce(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return function(e){return"function"!=typeof e}(e)?this.subType?this.subType.validate(e,t):te():re(t,e,"Value is not serializable and cannot be frozen")}}),t}(x),Ct=new Tt;var Et=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}),Ut(e))this.identifier=e;else{if(!pe(e))throw _e("Can only store references to tree nodes or identifiers, got: '"+e+"'");var r=fe(e);if(!r.identifierAttribute)throw _e("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw _e("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=Lt(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 Vt("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+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}(),Vt=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return u(t,e),t}(Error),Nt=function(e){function t(t,r){var n=e.call(this,"reference("+t.name+")")||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:I.Reference}),n}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ut(e)?te():re(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(t.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(){at(i.type)?this.replaceRef(void 0):d(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(t.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,i=this.getValue(e);if(i){var a=fe(i),o=function(i,o){var u=function(e){switch(e){case r.beforeDestroy:return"destroy";case r.beforeDetach:return"detach";default:return}}(o);u&&n.fireInvalidated(u,e,t,a)},u=a.registerHook(r.beforeDetach,o),l=a.registerHook(r.beforeDestroy,o);return function(){u(),l()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var i=this;if(this.onInvalidated){var a;e.registerHook(r.beforeDestroy,(function(){a&&a()}));var o=function(r){a&&a();var o=e.parent,u=o&&o.storedValue;if(o&&o.isAlive&&u){(n?!!n.get(t,u):e.root.identifierCache.has(i.targetType,Lt(t)))?a=i.addTargetNodeWatcher(e,t):r||i.fireInvalidated("invalidSnapshotReference",e,t,null)}};e.state===oe.FINALIZED?o(!0):(e.isRoot||e.root.registerHook(r.afterCreationFinalization,(function(){e.parent&&e.parent.createObservableInstanceIfNeeded()})),e.registerHook(r.afterAttach,(function(){o(!1)})))}}}),t}(x),Dt=function(e){function t(t,r){return e.call(this,t,r)||this}return u(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=pe(n)?w(n):n,a=new Et(n,this.targetType),o=ce(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=pe(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}(Nt),xt=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 u(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=pe(n)?this.options.set(n,e?e.storedValue:null):n,a=ce(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=pe(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}(Nt);function kt(e,t){var r=t||void 0,n=t?t.onInvalidated:void 0;return r&&(r.get||r.set)?new xt(e,{get:r.get,set:r.set},n):new Dt(e,n)}var Rt=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:I.Identifier}),n}return u(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof it))throw _e("Identifier types can only be instantiated as direct child of a model type");return ce(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 _e("Tried to change identifier from '"+e.storedValue+"' to '"+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?re(t,e,"Value is not a valid "+this.describe()+", expected a "+this.validType):te()}}),t}(x),zt=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:I.Identifier}),t}return u(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}(Rt),Mt=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return u(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}(Rt),Ft=new zt,Ht=new Mt;function Lt(e){return""+e}function Ut(e){return"string"==typeof e||"number"==typeof e}var $t=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:I.Custom}),r}return u(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 te();var r=this.options.getValidationMessage(e);return r?re(t,e,"Invalid value for type '"+this.name+"': "+r):te()}}),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 ce(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}(x),Wt={enumeration:function(e,t){var r="string"==typeof e?t:e,n=wt.apply(void 0,f(r.map((function(e){return vt(""+e)}))));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 it({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 $t(e)},reference:kt,safeReference:function(e,t){var r=kt(e,l(l({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:At(r)},union:wt,optional:Ot,literal:vt,maybe:At,maybeNull:function(e){return wt(e,St)},refinement:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():k(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 gt(r,n,i,a)},string:ut,boolean:ct,number:lt,integer:st,Date:ht,map:function(e){return new Ke("map<string, "+e.name+">",e)},array:function(e){return new qe(e.name+"[]",e)},frozen:function(e){return 0===arguments.length?Ct:k(e)?new Tt(e):Ot(Ct,e)},identifier:Ft,identifierNumber:Ht,late:function(e,t){var r="string"==typeof e?e:"late("+e.toString()+")";return new It(r,"string"==typeof e?t:e)},undefined:ft,null:pt,snapshotProcessor:function(e,t,r){return new Ye(e,t,r)}};e.addDisposer=function(e,t){return fe(e).addDisposer(t),t},e.addMiddleware=Z,e.applyAction=F,e.applyPatch=d,e.applySnapshot=y,e.cast=function(e){return e},e.castFlowReturn=function(e){return e},e.castToReferenceSnapshot=function(e){return e},e.castToSnapshot=function(e){return e},e.clone=function(e,t){void 0===t&&(t=!0);var r=fe(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)},e.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),R.set(t.id,{call:t,context:i,async:!1});try{var a=r(t);return e.onSuspend(t,i),!1===R.get(t.id).async&&(R.delete(t.id),e.onSuccess(t,i,a)),a}catch(r){throw R.delete(t.id),e.onFail(t,i,r),r}case"flow_spawn":return(o=R.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var o=R.get(t.rootId);e.onResume(t,o.context);try{return r(t)}finally{e.onSuspend(t,o.context)}case"flow_throw":o=R.get(t.rootId);return R.delete(t.rootId),e.onFail(t,o.context,t.args[0]),r(t);case"flow_return":o=R.get(t.rootId);return R.delete(t.rootId),e.onSuccess(t,o.context,t.args[0]),r(t)}}},e.createActionTrackingMiddleware2=function(e){var t=new WeakMap;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent):void 0;if("action"===r.type){var a=l(l({},r),{env:i&&i.call.env,parentCall:i&&i.call}),o=!e.filter||e.filter(a),u=new z(o?e:void 0,a);t.set(r,u);var s=void 0;try{s=n(r)}catch(e){throw u.finish(e),e}return u.hasFlowsPending||u.finish(),s}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 c=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(c)}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}},e.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},e.destroy=function(e){var t=fe(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)},e.detach=function(e){return fe(e).detach(),e},e.escapeJsonPath=Ue,e.flow=Fe,e.getChildType=function(e,t){return fe(e).getChildType(t)},e.getEnv=function(e){var t=fe(e).root.environment;return t||Oe},e.getIdentifier=w,e.getLivelinessChecking=a,e.getMembers=function(e){var r=fe(e).type,n=l(l({},j(r)),{actions:[],volatile:[],views:[]});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._isMSTAction?n.actions.push(r):t.isObservableProp(e,r)?n.volatile.push(r):n.views.push(r)}})),n},e.getNodeId=function(e){return fe(e).nodeId},e.getParent=function(e,t){void 0===t&&(t=1);for(var r=t,n=fe(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw _e("Failed to find the parent of "+fe(e)+" at depth "+t)},e.getParentOfType=function(e,t){for(var r=fe(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw _e("Failed to find the parent of "+fe(e)+" of a given type")},e.getPath=m,e.getPathParts=function(e){return Ge(fe(e).path)},e.getPropertyMembers=j,e.getRelativePath=function(e,t){return ye(fe(e),fe(t))},e.getRoot=g,e.getRunningActionContext=K,e.getSnapshot=v,e.getType=b,e.hasParent=function(e,t){void 0===t&&(t=1);for(var r=fe(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1},e.hasParentOfType=function(e,t){for(var r=fe(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1},e.isActionContextChildOf=function(e,t){return q(e,t,!1)},e.isActionContextThisOrChildOf=function(e,t){return q(e,t,!0)},e.isAlive=O,e.isArrayType=function(e){return k(e)&&(e.flags&I.Array)>0},e.isFrozenType=function(e){return k(e)&&(e.flags&I.Frozen)>0},e.isIdentifierType=function(e){return k(e)&&(e.flags&I.Identifier)>0},e.isLateType=function(e){return k(e)&&(e.flags&I.Late)>0},e.isLiteralType=function(e){return k(e)&&(e.flags&I.Literal)>0},e.isMapType=function(e){return k(e)&&(e.flags&I.Map)>0},e.isModelType=at,e.isOptionalType=function(e){return k(e)&&(e.flags&I.Optional)>0},e.isPrimitiveType=dt,e.isProtected=function(e){return fe(e).isProtected},e.isReferenceType=function(e){return(e.flags&I.Reference)>0},e.isRefinementType=function(e){return(e.flags&I.Refinement)>0},e.isRoot=function(e){return fe(e).isRoot},e.isStateTreeNode=pe,e.isType=k,e.isUnionType=function(e){return(e.flags&I.Union)>0},e.isValidReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(pe(r))return!t||O(r);throw _e("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Vt)return!1;throw e}},e.joinJsonPath=We,e.onAction=H,e.onPatch=h,e.onSnapshot=function(e,t){return fe(e).onSnapshot(t)},e.process=function(e){return ze("process","`process()` has been renamed to `flow()`. See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`."),Fe(e)},e.protect=function(e){var t=fe(e);if(!t.isRoot)throw _e("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0},e.recordActions=function(e,t){var r,n=[],i=function(e){(!t||t(e,K()))&&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){F(e,n)}};return a.resume(),a},e.recordPatches=function(e,t){var r,n={patches:[],reversedInversePatches:[]},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.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=h(e,(function(e,r){t&&!t(e,r,K())||(n.patches.push(e),n.reversedInversePatches.unshift(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.reversedInversePatches)}};return a.resume(),a},e.resolveIdentifier=function(e,t,r){var n=fe(t).root.identifierCache.resolve(e,Lt(r));return n?n.value:void 0},e.resolvePath=function(e,t){var r=ve(fe(e),t);return r?r.value:void 0},e.setLivelinessChecking=i,e.setLivelynessChecking=function(e){i(e)},e.splitJsonPath=Ge,e.toGenerator=function(e){return s(this,(function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}}))},e.toGeneratorFunction=function(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return s(this,(function(t){switch(t.label){case 0:return[4,e.apply(void 0,f(r))];case 1:return[2,t.sent()]}}))}},e.tryReference=function(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(pe(r))return t?O(r)?r:void 0:r;throw _e("The reference to be checked is not one of node, null or undefined")}catch(e){if(e instanceof Vt)return;throw e}},e.tryResolve=P,e.typecheck=ae,e.types=Wt,e.unescapeJsonPath=$e,e.unprotect=function(e){var t=fe(e);if(!t.isRoot)throw _e("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1},e.walk=function e(t,r){var n=fe(t);n.getChildren().forEach((function(t){pe(t.storedValue)&&e(t.storedValue,r)})),r(n.storedValue)},Object.defineProperty(e,"__esModule",{value:!0})}));