mobx-keystone
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("mobx"),t=require("tslib");function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function o(e,t){for(var n in t)(a=t[n]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,n,a);if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(t),o=0;o<r.length;o++){var a,i=r[o];(a=t[i]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,i,a)}return e}function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e,t,n){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return s(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var l=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(f(r),t.prototype),r}return i(t,e),t}(p(Error));function d(e){return new l(e)}function h(e){if(!v(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function v(e){return null!==e&&"object"==typeof e}function y(e){switch(typeof e){case"object":return null===e;case"function":case"symbol":return!1;default:return!0}}function b(e,t){var n=e.indexOf(t);return n>=0&&(e.splice(n,1),!0)}function m(t){return t instanceof Map||e.isObservableMap(t)}function g(t){return t instanceof Set||e.isObservableSet(t)}function x(t){return Array.isArray(t)||e.isObservableArray(t)}function w(e,t){if(!v(e))throw d(t+" must be an object")}function A(e,t){if("function"!=typeof e)throw d(t+" must be a function")}function S(e,t){var n=e.target,r=e.propertyKey,o=e.baseDescriptor;if(o)return{enumerable:!1,writable:!0,configurable:!0,value:t(e,o.value)};Object.defineProperty(n,r,{configurable:!0,enumerable:!1,get:function(){},set:function(n){var o,i,u;o=r,i=t(a({},e,{target:this}),n),void 0===u&&(u=!0),Object.defineProperty(this,o,{enumerable:!1,writable:u,configurable:!0,value:i})}})}var k=Symbol("modelProperties"),C=Symbol("modelDataTypeChecker"),O=Symbol("modelInitializers");function T(e){if(me(e)||xe(e))return e[C];throw d("modelClassOrInstance must be a model class or instance")}var j="$modelType";function R(e){return e===j}var M={},_=new Map;function P(e){return M[e]}var N,E,$,I=Symbol("modelConstructor");function F(){return $}function D(e){$=e}(N=exports.ActionContextActionType||(exports.ActionContextActionType={})).Sync="sync",N.Async="async",(E=exports.ActionContextAsyncStepType||(exports.ActionContextAsyncStepType={})).Spawn="spawn",E.Return="return",E.Resume="resume",E.ResumeError="resumeError",E.Throw="throw";var z=!0,U=new WeakSet;function W(e){return!y(e)&&U.has(e)}function V(e){return W(e)}function B(e,t){if(!W(e))throw d(t+" must be a tree node (usually a model or a shallow / deep child part of a model 'data' object)");return!0}function L(){if(z&&!F())throw d("data changes must be performed inside model actions")}var Q=!1,K=new WeakMap,H=new WeakMap,J=new WeakMap;function G(t){var n=H.get(t);return n||(n=e.createAtom("parentAtom"),H.set(t,n)),n}function q(e){G(e).reportChanged()}function X(e){return B(e,"value"),G(e).reportObserved(),K.get(e)}function Y(e,t){void 0===t&&(t=!1),B(e,"value");var n=X(e);return n&&t&&Z(n.parent)?Y(n.parent,!1):n?n.parent:void 0}function Z(e){if(B(e,"value"),!v(e))return!1;var t=X(e);return!!t&&"$"===t.path&&t.parent instanceof ye}function ee(e){B(e,"value");for(var t,n={root:e,path:[]};t=X(n.root);)n.root=t.parent,n.path.unshift(t.path);return n}function te(e){return B(e,"value"),ee(e).root}function ne(e){return B(e,"value"),!Y(e)}function re(e,t){B(e,"child"),B(t,"parent");for(var n,r=e;n=X(r);)if((r=n.parent)===t)return!0;return!1}function oe(e,t){for(var n=e,r=t.length,o=0;o<r;o++){if(!v(n))return{resolved:!1};n=n[t[o]]}return{resolved:!0,value:n}}var ae=function(){function e(e,t,n){this.path=e,this.expectedTypeName=t,this.actualValue=n}return e.prototype.throw=function(e){var t="TypeCheckError: ",n=[];throw e&&W(e)&&(n=ee(e).path),t+="["+[].concat(n,this.path).join("/")+"] ",d(t+="Expected: "+this.expectedTypeName)},e}(),ie=[],ue=new WeakMap,ce=function(){function e(e,t){this._check=e,this.getTypeName=t,this.unchecked=!e}var t=e.prototype;return t.createCacheIfNeeded=function(){return this.checkResultCache||(this.checkResultCache=new WeakMap),this.checkResultCache},t.setCachedResult=function(e,t){this.createCacheIfNeeded().set(e,t);var n=ue.get(e);n||(n=new Set,ue.set(e,n)),n.add(this)},t.invalidateCachedResult=function(e){this.checkResultCache&&this.checkResultCache.delete(e)},t.getCachedResult=function(e){return this.checkResultCache?this.checkResultCache.get(e):void 0},t.check=function(e,t){if(this.unchecked)return null;if(!W(e))return this._check(e,t);var n=this.getCachedResult(e);return void 0===n&&(n=this._check(e,ie),this.setCachedResult(e,n)),n?new ae([].concat(t,n.path),n.expectedTypeName,n.actualValue):null},e}();function se(e){for(var t,n=e;;){if(n instanceof ce)return n;if("function"!=typeof(t=n)||!t[pe])throw d("type checker could not be resolved");n=n()}}var pe=Symbol("lateTypeCheker");function fe(e){var t,n=function(){return t||(t=e())};return n[pe]=!0,n}var le=new WeakMap;function de(e){if(!xe(e)&&"function"==typeof e)return fe(function(){return de(e())});var t=e;we(t,"modelClass");var n=le.get(t);if(n)return n;var r=fe(function(){var e=_.get(t),n="Model("+e.name+")";return new ce(function(r,o){if(!(r instanceof t))return new ae(o,n,r);var a=T(r);if(!a)throw d("type checking cannot be performed over model of type '"+e.name+"' at path "+o.join("/")+" since that model type has no data type declared, consider adding a data type or using types.unchecked() instead");var i=se(a);return i.unchecked?null:i.check(r.$,[].concat(o,["$"]))},function(){return n})});return le.set(t,r),r}function he(e,t){if(!e)throw d("a type must be passed");var n=se(e);return n.unchecked?null:n.check(t,[])}var ve,ye=function(){function e(e){if(e!==I)throw d("did you forget to add the @model decorator?")}return e.prototype.typeCheck=function(){return he(de(this.constructor),this)},e}(),be=new Set([j,"onInit","$","onAttachedToRootStore","fromSnapshot","typeCheck"]);function me(e){return e instanceof ye}function ge(e,t,n){if(void 0===n&&(n="must be a model instance"),!me(e))throw d(t+" "+n)}function xe(e){return"function"==typeof e&&(e===ye||e.prototype instanceof ye)}function we(e,t){if("function"!=typeof e)throw d(t+" must be a class");if(e!==ye&&!(e.prototype instanceof ye))throw d(t+" must extend Model")}function Ae(e){return h(e)&&!!e[j]}function Se(e,t,n){if("string"!=typeof n)throw d(e+" cannot be used over symbol properties");var r=e+" must be used over model classes or instances";if(!t)throw d(r);if(!(t instanceof ye||t===ye||t.prototype instanceof ye))throw d(r)}(ve=exports.BuiltInAction||(exports.BuiltInAction={})).ApplyPatches="$$applyPatches",ve.ApplySnapshot="$$applySnapshot",ve.Detach="$$detach";var ke=new Set(Object.values(exports.BuiltInAction));function Ce(e){return ke.has(e)}var Oe=new WeakMap,Te=new WeakMap;function je(t){w(t,"middleware");var n=t.middleware,r=t.filter,o=t.subtreeRoot;if(B(o,"middleware.subtreeRoot"),A(n,"middleware.middleware"),r&&"function"!=typeof r)throw d("middleware.filter must be a function or undefined");if(e.isAction(n)||(n=e.action(n.name||"actionMiddleware",n)),o){var a=function(e){return e.target===o||re(e.target,o)};if(r){var i=r;r=function(e){return a(e)&&i(e)}}else r=a}var u={middleware:n,filter:r},c=Oe.get(o);return c?c.push(u):Oe.set(o,c=[u]),function(){b(c,u)}}function Re(e){return"function"==typeof e&&e[_e]}function Me(e,t,n){return S({target:e,propertyKey:t,baseDescriptor:n},function(e,t){return Re(t)?t:(function(e,n,r){if("function"!=typeof t)throw d("modelAction has to be used over functions");Se("modelAction",e,n)}(e.target,e.propertyKey),Pe(e.propertyKey,t,exports.ActionContextActionType.Sync))})}var _e=Symbol("modelAction");function Pe(t,n,r,o,a){function i(){var e,i=F(),u={actionName:t,type:r,target:this,args:Array.from(arguments),parentContext:i,data:{},rootContext:void 0};o&&o(u),u.rootContext||(u.rootContext=u.previousAsyncStepContext?u.previousAsyncStepContext.rootContext:u.parentContext?u.parentContext.rootContext:u),D(u);var c,s,p,f=(e=n).bind.apply(e,[this].concat(Array.prototype.slice.call(arguments))),l=((p=Te.get(c=this))||((s={})[Symbol.iterator]=function(){var e=c;function t(){var t=e?Oe.get(e):void 0;if(t&&!(t.length<=0))return t[Symbol.iterator]()}function n(){for(var n;e&&!n;)e=Y(e),n=t();return n}var r=t();return r||(r=n()),{next:function(){if(!r)return{value:void 0,done:!0};var e=r.next();return e.done?(r=n(),this.next()):e}}},Te.set(c,p=s)),p),d=Array.isArray(l),h=0;for(l=d?l:l[Symbol.iterator]();;){var v;if(d){if(h>=l.length)break;v=l[h++]}else{if((h=l.next()).done)break;v=h.value}var y=v;(!y.filter||y.filter(u))&&(f=y.middleware.bind(void 0,u,f))}try{var b=f();if(a){var m=b,g=m.value;return"accept"===m.resolution?m.accepter(g):m.rejecter(g),g}return b}finally{D(u.parentContext)}}return void 0===a&&(a=!1),e.isAction(n)||(n=e.action(t,n)),i[_e]=!0,i}function Ne(e,t,n){var r=e[t];if(!Re(r)){var o=Pe(n,r,exports.ActionContextActionType.Sync),a=Object.getPrototypeOf(e);a[t]===r?a[t]=o:e[t]=o}}function Ee(e){B(e,"node"),Ie.call(e)}var $e,Ie=Pe(exports.BuiltInAction.Detach,Fe,exports.ActionContextActionType.Sync);function Fe(){var t=X(this);if(t){var n=t.parent,r=t.path;if(e.isObservableArray(n))n.splice(+r,1);else{if(!e.isObservableObject(n))throw d("parent must be an observable object or an observable array");delete n[r]}}}($e=exports.HookAction||(exports.HookAction={})).OnInit="$$onInit",$e.OnAttachedToRootStore="$$onAttachedToRootStore",$e.OnAttachedToRootStoreDisposer="$$onAttachedToRootStoreDisposer";var De,ze=new Set(Object.values(exports.HookAction));function Ue(e){return ze.has(e)}function We(e){return B(e,"node"),J.get(e)}function Ve(e,t,n){if(B(e,"target"),n===exports.WalkTreeMode.ParentFirst){var r=t(e);if(void 0!==r)return r}var o=We(e),a=Array.isArray(o),i=0;for(o=a?o:o[Symbol.iterator]();;){var u;if(a){if(i>=o.length)break;u=o[i++]}else{if((i=o.next()).done)break;u=i.value}var c=Ve(u,t,n);if(void 0!==c)return c}if(n===exports.WalkTreeMode.ChildrenFirst){var s=t(e);if(void 0!==s)return s}}(De=exports.WalkTreeMode||(exports.WalkTreeMode={})).ParentFirst="parentFirst",De.ChildrenFirst="childrenFirst";var Be=new WeakMap;function Le(e,t){Ve(t,function(t){if(t instanceof ye&&t.onAttachedToRootStore){Ne(t,"onAttachedToRootStore",exports.HookAction.OnAttachedToRootStore);var n=t.onAttachedToRootStore(e);if(n){var r=Pe(exports.HookAction.OnAttachedToRootStoreDisposer,n,exports.ActionContextActionType.Sync);Be.set(t,r)}}},exports.WalkTreeMode.ParentFirst)}function Qe(e){Ve(e,function(e){var t=Be.get(e);t&&(Be.delete(e),t.call(e))},exports.WalkTreeMode.ChildrenFirst)}var Ke=new WeakSet,He=e.action("registerRootStore",function(e){if(B(e,"node"),Ke.has(e))throw d("object already marked as root store");if(!ne(e))throw d("a root store must not have a parent");return Ke.add(e),Le(e,e),e}),Je=e.action("unregisterRootStore",function(e){if(!Ge(e))throw d("not a root store");Ke.delete(e),Qe(e)});function Ge(e){return Ke.has(e)}var qe=e.action("setParent",function(t,n,r){if(void 0===r&&(r=!1),!y(t)){J.has(t)||J.set(t,e.observable.set());var o=X(t);if(i=n,void 0===u&&(u=!0),((a=o)||i)&&(!a||!i||a.parent!==i.parent||u&&a.path!==i.path)){var a,i,u;if(Ge(t))throw d("root stores cannot be attached to any parents");if(o&&n){if(o.parent===n.parent&&r)return K.set(t,n),void q(t);throw d("an object cannot be assigned a new parent when it already has one")}var c=function(){o&&o.parent&&J.get(o.parent).delete(t)},s=function(){n&&n.parent&&J.get(n.parent).add(t),K.set(t,n)};if(t instanceof ye){var p=te(t),f=Ge(p)?p:void 0;c(),s();var l=te(t),h=Ge(l)?l:void 0;f!==h&&(f&&Qe(t),h&&Le(h,t))}else c(),s();q(t)}}}),Xe=function(){function e(){this.record=this.record.bind(this)}var t=e.prototype;return t.record=function(e,t){this.patches=e,this.invPatches=t},t.emit=function(e){!function e(t,n,r,o){if(!(n.length<=0&&r.length<=0)){if(o)for(var a=0;a<Ze.length;a++)(0,Ze[a])(t,n,r);var i=Ye.get(t);if(i)for(var u=0;u<i.length;u++)(0,i[u])(n,r);var c=X(t);if(c){var s=c.path,p=c.parent instanceof ye,f=p?n:n.map(function(e){return nt(e,s)}),l=p?r:r.map(function(e){return nt(e,s)});e(c.parent,f,l,!1)}}}(e,this.patches,this.invPatches,!0)},e}(),Ye=new WeakMap,Ze=[];function et(t,n){B(t,"subtreeRoot"),A(n,"listener"),e.isAction(n)||(n=e.action(n.name||"onPatchesListener",n));var r=Ye.get(t);return r||Ye.set(t,r=[]),r.push(n),function(){b(r,n)}}function tt(t){return A(t,"listener"),e.isAction(t)||(t=e.action(t.name||"onGlobalPatchesListener",t)),Ze.push(t),function(){b(Ze,t)}}function nt(e,t){return a({},e,{path:[t].concat(e.path)})}var rt=new WeakMap;function ot(e){return rt.get(e)}var at,it=e.action("setInternalSnapshot",function(t,n){var r=ot(t);if(!r||r.standard!==n){var o;r?(o=r).standard=n:(o={standard:n,atom:e.createAtom("snapshot")},rt.set(t,o)),o.atom.reportChanged();var a=function t(n,r){return e.untracked(function(){if(r){var e=ot(r.parent);if(e)return n===e?t(e,X(r.parent)):n?{parentSnapshot:e,parentPath:r}:void 0}})}(r,X(t));if(a){var i=a.parentSnapshot,u=a.parentPath;if(i){var c=u.path,s=i.standard;s[c]!==o.standard&&((s=Array.isArray(s)?s.slice():Object.assign({},s))[c]=o.standard,it(u.parent,s))}}}});(at=exports.ModelAutoTypeCheckingMode||(exports.ModelAutoTypeCheckingMode={})).DevModeOnly="devModeOnly",at.AlwaysOn="alwaysOn",at.AlwaysOff="alwaysOff";var ut={modelAutoTypeChecking:exports.ModelAutoTypeCheckingMode.DevModeOnly};function ct(){return ut}function st(){switch(ct().modelAutoTypeChecking){case exports.ModelAutoTypeCheckingMode.DevModeOnly:case exports.ModelAutoTypeCheckingMode.AlwaysOff:return!1;case exports.ModelAutoTypeCheckingMode.AlwaysOn:return!0;default:throw d("invalid 'modelAutoTypeChecking' config value - "+ut.modelAutoTypeChecking)}}function pt(e,t,n){void 0===n&&(n=0),B(e,"child");for(var r,o=e,a=0;r=X(o);){if(a++,t(o=r.parent))return o;if(n>0&&a===n)break}}function ft(t,n){if(function(e){for(var t=e;t;){var n=ue.get(t);if(n){var r=n,o=Array.isArray(r),a=0;for(r=o?r:r[Symbol.iterator]();;){var i;if(o){if(a>=r.length)break;i=r[a++]}else{if((a=r.next()).done)break;i=a.value}i.invalidateCachedResult(t)}ue.delete(t)}t=Y(t)}}(t),st()){var r=pt(t,function(e){return me(e)&&!!T(e)});if(r){var o=r.typeCheck();o&&(function(r){var o=Q;Q=!0;try{e.runInAction(function(){Pt.call(t,n.invPatches)})}finally{Q=o}}(),o.throw(r))}}}function lt(t,n,r){var o=t,a=o.length,i=e.isObservableArray(o)?o:e.observable.array([],ht);i!==o&&(i.length=o.length),U.add(i),qe(i,n);var u=[];u.length=a;for(var c=0;c<a;c++){var s=o[c];if(y(s))r||e.set(i,c,s),u[c]=s;else{var p={parent:i,path:c},f=void 0;r?qe(f=s,p):(f=At(s,p),e.set(i,c,f));var l=ot(f);u[c]=l.standard}}return it(i,u),e.intercept(i,function(e,t){switch(L(),t.type){case"splice":for(var n=0;n<t.removedCount;n++)At(t.object[t.index+n],void 0);for(var r=0;r<t.added.length;r++)t.added[r]=At(t.added[r],{parent:t.object,path:t.index+r});var o=t.index+t.removedCount,a=t.index+t.added.length;if(o!==a)for(var i=o,u=a;i<t.object.length;i++,u++)qe(t.object[i],{parent:t.object,path:u},!0);break;case"update":At(e[t.index],void 0),t.newValue=At(t.newValue,{parent:e,path:t.index})}return t}.bind(void 0,i)),e.observe(i,dt),i}function dt(e){var t=e.object,n=ot(t).standard,r=new Xe;switch(n=n.slice(),e.type){case"splice":var o,a=[],i=e.addedCount;a.length=i;for(var u=0;u<i;u++){var c=e.added[u];a[u]=y(c)?c:ot(c).standard}for(var s=n.length,p=e.removedCount,f=(o=n).splice.apply(o,[e.index,p].concat(a)),l=[],d=[],h=Math.min(p,i),v=0;v<h;v++){var b=f[v],m=a[v];if(b!==m){var g=[e.index+v];l.push({op:"replace",path:g,value:m}),d.push({op:"replace",path:g,value:b})}}if(p>i){l.push({op:"replace",path:["length"],value:n.length});for(var x=h;x<p;x++)d.push({op:"add",path:[e.index+x],value:f[x]})}else if(i>p){for(var w=h;w<i;w++)l.push({op:"add",path:[e.index+w],value:a[w]});d.push({op:"replace",path:["length"],value:s})}r.record(l,d);break;case"update":var A=e.index,S=e.newValue,k=n[A];if(y(S))n[A]=S;else{var C=ot(S);n[A]=C.standard}var O=[A];r.record([{op:"replace",path:O,value:n[A]}],[{op:"replace",path:O,value:k}])}ft(t,r),Q||(it(t,n),r.emit(t))}var ht={deep:!1};function vt(e,t){return U.add(e),qe(e,t),e}function yt(t,n,r,o){var a=t,i=e.isObservableObject(a)?a:e.observable.object({},void 0,bt);U.add(i),qe(i,n);for(var u={},c=Object.keys(a),s=c.length,p=0;p<s;p++){var f=c[p],l=a[f];if(y(l))o||e.set(i,f,l),u[f]=l;else{var d={parent:i,path:f},h=void 0;o?qe(h=l,d):(h=At(l,d),e.set(i,f,h));var v=ot(h);u[f]=v.standard}}return r&&(u[j]=r),it(i,u),e.intercept(i,gt),e.observe(i,mt),i}var bt={deep:!1};function mt(e){var t=e.object,n=ot(t).standard,r=new Xe;switch(n=Object.assign({},n),e.type){case"add":case"update":var o=e.name,a=e.newValue,i=n[o];if(y(a))n[o]=a;else{var u=ot(a);n[o]=u.standard}var c=[o];"add"===e.type?r.record([{op:"add",path:c,value:n[o]}],[{op:"remove",path:c}]):r.record([{op:"replace",path:c,value:n[o]}],[{op:"replace",path:c,value:i}]);break;case"remove":var s=e.name,p=n[s];delete n[s];var f=[s];r.record([{op:"remove",path:f}],[{op:"add",path:f,value:p}])}ft(t,r),Q||(it(t,n),r.emit(t))}function gt(e){if(L(),"symbol"==typeof e.name)throw d("symbol properties are not supported.");switch(e.type){case"add":e.newValue=At(e.newValue,{parent:e.object,path:""+e.name});break;case"remove":At(e.object[e.name],void 0);break;case"update":At(e.object[e.name],void 0),e.newValue=At(e.newValue,{parent:e.object,path:""+e.name})}return e}function xt(t,n){if(y(t))return t;if(W(t))return qe(t,n),t;if(t instanceof kt)return function(e,t){var n;return U.add(e),qe(e,t),it(e,((n={})[St]=!0,n.data=e.data,n)),e}(t,n);if(function(e){if(v(e)&&e[j])return P(e[j])}(t))return vt(t,n);if(Array.isArray(t)||e.isObservableArray(t))return lt(t,n,!1);if(e.isObservableObject(t)||h(t))return yt(t,n,void 0,!1);if(m(t))throw d("maps are not supported");if(g(t))throw d("sets are not supported");throw d("tweak can only work over models, observable objects/arrays, or primitives, but got "+t+" instead")}var wt,At=e.action("tweak",xt);(wt=exports.FrozenCheckMode||(exports.FrozenCheckMode={})).DevModeOnly="devModeOnly",wt.On="on",wt.Off="off";var St="$frozen",kt=function(e,t){void 0===t&&(t=exports.FrozenCheckMode.DevModeOnly);var n=t===exports.FrozenCheckMode.On||t===exports.FrozenCheckMode.DevModeOnly&&!1;n&&function e(t){if(!y(t))if(Array.isArray(t)){for(var n=t.length,r=0;r<n;r++){var o=t[r];if(void 0===o)throw d("undefined is not supported inside arrays since it is not serializable in JSON, consider using null instead");e(o)}Object.freeze(t)}else{if(!h(t))throw d("frozen data must be plainly serializable to JSON, but "+t+" is not");for(var a=Object.keys(t),i=a.length,u=0;u<i;u++){var c=a[u],s=t[c];e(c),e(s)}Object.freeze(t)}}(e),this.data=e,n&&Object.freeze(this.data),At(this,void 0)};function Ct(e,t){return void 0===t&&(t=exports.FrozenCheckMode.DevModeOnly),new kt(e,t)}function Ot(e){return h(e)&&!!e[St]}function Tt(t){if(y(t))return t;if(m(t))throw d("a snapshot might not contain maps");if(g(t))throw d("a snapshot might not contain sets");if(x(t))return function(t){for(var n=e.observable.array([],Rt),r=t.length,o=0;o<r;o++)n.push(Tt(t[o]));return lt(n,void 0,!0)}(t);if(Ot(t))return Ct(t.data);if(Ae(t))return function(e){var t=e[j];if(!t)throw d("a model a snapshot must contain a type key ("+j+"), but none was found");var n=P(t);if(!n)throw d('model with name "'+t+'" not found in the registry');return new n.class(void 0,{unprocessedSnapshot:e,snapshotToInitialData:jt})}(t);if(h(t))return function(t){for(var n=e.observable.object({},void 0,Rt),r=Object.keys(t),o=r.length,a=0;a<o;a++){var i=r[a];n[i]=Tt(t[i])}return yt(n,void 0,void 0,!0)}(t);throw d("unsupported snapshot - "+t)}function jt(t){for(var n=e.observable.object({},void 0,Rt),r=Object.keys(t),o=r.length,a=0;a<o;a++){var i=r[a];R(i)||(n[i]=Tt(t[i]))}return n}exports.fromSnapshot=function(e){return Tt(e)},exports.fromSnapshot=e.action("fromSnapshot",exports.fromSnapshot);var Rt={deep:!1};function Mt(t,n){if(y(n))return n;if(m(n))throw d("a snapshot might not contain maps");if(g(n))throw d("a snapshot might not contain sets");if(x(n))return function(e,t){if(!x(e))return exports.fromSnapshot(t);e.length>t.length&&e.splice(t.length,e.length-t.length);for(var n=0;n<e.length;n++)e[n]=Mt(e[n],t[n]);for(var r=e.length;r<t.length;r++)e.push(exports.fromSnapshot(t[r]));return e}(t,n);if(Ot(n))return function(e,t){return e instanceof kt&&e.data===t.data?e:Ct(t.data)}(t,n);if(Ae(n))return function(e,t){var n=t[j],r=P(n);if(!r)throw d('model with name "'+n+'" not found in the registry');if(!(e instanceof r.class)||e.$modelType!==n)return exports.fromSnapshot(t);var o=e,a=t;o.fromSnapshot&&(a=o.fromSnapshot(t));for(var i=o.$,u=Object.keys(i),c=u.length,s=0;s<c;s++){var p=u[s];p in a||delete i[p]}for(var f=Object.keys(a),l=f.length,h=0;h<l;h++){var v=f[h];R(v)||(i[v]=Mt(i[v],a[v]))}return o}(t,n);if(h(n))return function(t,n){if(!h(t)&&!e.isObservableObject(t))return exports.fromSnapshot(n);for(var r=t,o=Object.keys(r),a=o.length,i=0;i<a;i++){var u=o[i];u in n||delete r[u]}for(var c=Object.keys(n),s=c.length,p=0;p<s;p++){var f=c[p];r[f]=Mt(r[f],n[f])}return r}(t,n);throw d("unsupported snapshot - "+n)}function _t(e,t){B(e,"node"),Nt.call(e,t)}function Pt(e){var t=this;e.forEach(function(e){return function(e,t){var n=function(e,t){if(0===t.length)return{target:e};var n=e;n instanceof ye&&(n=n.$);for(var r=0;r<=t.length-2;r++)(n=n[t[r]])instanceof ye&&(n=n.$);return{target:n,prop:t[t.length-1]}}(e,t.path),r=n.target,o=n.prop;if(x(r))switch(t.op){case"add":r.splice(+o,0,exports.fromSnapshot(t.value));break;case"remove":r.splice(+o,1);break;case"replace":if("length"===o)r.length=t.value;else{var a=+o;r[a]=Mt(r[a],t.value)}break;default:throw d("unsupported patch operation: "+t.op)}else switch(t.op){case"add":r[o]=exports.fromSnapshot(t.value);break;case"remove":delete r[o];break;case"replace":r[o]=Mt(r[o],t.value);break;default:throw d("unsupported patch operation: "+t.op)}}(t,e)})}var Nt=Pe(exports.BuiltInAction.ApplyPatches,Pt,exports.ActionContextActionType.Sync);function Et(e,t){B(e,"node"),w(t,"snapshot"),It.call(e,t)}function $t(t){var n=this,r=function(){Mt(n,t)};if(x(t)){if(!x(n))throw d("if the snapshot is an array the target must be an array too");return r()}if(Ot(t))throw d("applySnapshot can not be used over frozen objects");if(Ae(t)){var o=t[j],a=P(o);if(!a)throw d('model with name "'+o+'" not found in the registry');if(!(n instanceof a.class)||n.$modelType!==o)throw d("snapshot model type does not match target model type");return r()}if(h(t)){if(!h(n)&&!e.isObservableObject(n))throw d("if the snapshot is an object the target must be an object too");return r()}throw d("unsupported snapshot - "+t)}var It=Pe(exports.BuiltInAction.ApplySnapshot,$t,exports.ActionContextActionType.Sync);function Ft(e,t){B(e,"subtreeRoot");var n=oe(e,t.targetPath),r=n.value;if(!n.resolved)throw d("object at path "+t.targetPath+" could not be resolved");if(ge(r,"resolved "+t.targetPath),!Ce(t.actionName)){if(Ue(t.actionName))throw d("calls to hooks ("+t.actionName+") cannot be applied");return r[t.actionName].apply(r,t.args)}switch(t.actionName){case exports.BuiltInAction.ApplySnapshot:return Et.apply(r,[r].concat(t.args));case exports.BuiltInAction.ApplyPatches:return _t.apply(r,[r].concat(t.args));case exports.BuiltInAction.Detach:return Ee.apply(r,[r].concat(t.args));default:throw d("assertion error: unknown built-in action - "+t.actionName)}}var Dt,zt=Symbol("modelFlow");function Ut(e){return"function"==typeof e&&e[zt]}function Wt(e,t){B(e,"subtreeRoot");var n=Symbol("actionTrackingMiddlewareData");function r(e){return e.data[n]}function o(e,t){var r=e.data[n];r?Object.assign(r,t):e.data[n]=t}var a=function(e){return!t.filter||t.filter(Lt(e))},i=!!t.onResume||!!t.onSuspend,u=function(e){if(o(e,{state:"started"}),t.onStart)return t.onStart(e)||void 0},c=function(e,n){var a=e.parentContext,i=!1;if(a){var u=r(a);u&&u.startAccepted&&"suspended"===u.state&&(i=!0,s(a,!1))}return o(e,{state:"finished"}),t.onFinish&&(n=t.onFinish(e,n)||n),i&&p(a),n},s=function e(n,a){var i=n.parentContext;if(i){var u=r(i);u&&u.startAccepted&&"suspended"===u.state&&e(i,!1)}o(n,{state:a?"realResumed":"fakeResumed"}),t.onResume&&t.onResume(n)},p=function e(n){o(n,{state:"suspended"}),t.onSuspend&&t.onSuspend(n);var a=n.parentContext;if(a){var i=r(a);i&&i.startAccepted&&"fakeResumed"===i.state&&e(a)}};return je({middleware:function(e,t){var n=Lt(e),r=t;if(t=function(){s(n,!0);try{return r()}finally{p(n)}},e.type===exports.ActionContextActionType.Sync){var o=u(n);if(o)s(n,!0),p(n),o=c(n,o);else try{o=c(n,{result:exports.ActionTrackingResult.Return,value:t()})}catch(e){o=c(n,{result:exports.ActionTrackingResult.Throw,value:e})}return Vt(o)}switch(e.asyncStepType){case exports.ActionContextAsyncStepType.Spawn:var a=u(n);return a?(s(n,!0),p(n),Vt(a=c(n,a))):t();case exports.ActionContextAsyncStepType.Return:var f=t(),l=c(n,{result:exports.ActionTrackingResult.Return,value:f.value});return f.resolution=l.result===exports.ActionTrackingResult.Return?"accept":"reject",f.value=l.value,f;case exports.ActionContextAsyncStepType.Throw:var h=t(),v=c(n,{result:exports.ActionTrackingResult.Throw,value:h.value});return h.resolution=v.result===exports.ActionTrackingResult.Return?"accept":"reject",h.value=v.value,h;case exports.ActionContextAsyncStepType.Resume:case exports.ActionContextAsyncStepType.ResumeError:if(i)return t();throw d("asssertion error: async step should have been filtered out - "+e.asyncStepType);default:throw d("asssertion error: async step should have been filtered out - "+e.asyncStepType)}},filter:function(e){if(e.type===exports.ActionContextActionType.Sync){var t=a(e);return t&&o(e,{startAccepted:!0,state:"idle"}),t}switch(e.asyncStepType){case exports.ActionContextAsyncStepType.Spawn:var n=a(e);return n&&o(e,{startAccepted:!0,state:"idle"}),n;case exports.ActionContextAsyncStepType.Return:case exports.ActionContextAsyncStepType.Throw:var u=r(e.spawnAsyncStepContext);return!!u&&u.startAccepted;case exports.ActionContextAsyncStepType.Resume:case exports.ActionContextAsyncStepType.ResumeError:if(i){var c=r(e.spawnAsyncStepContext);return!!c&&c.startAccepted}return!1;default:return!1}},subtreeRoot:e})}function Vt(e){if(e.result===exports.ActionTrackingResult.Return)return e.value;throw e.value}(Dt=exports.ActionTrackingResult||(exports.ActionTrackingResult={})).Return="return",Dt.Throw="throw";var Bt=Symbol("simpleDataContext");function Lt(e){for(;e.previousAsyncStepContext;)e=e.previousAsyncStepContext;var t=e.data[Bt];if(!t){var n=e.parentContext?Lt(e.parentContext):void 0;(t={actionName:e.actionName,type:e.type,target:e.target,args:e.args,data:e.data,parentContext:n}).rootContext=n?n.rootContext:t,e.data[Bt]=t}return t}function Qt(e){if(y(e))return e;B(e,"nodeOrPrimitive");var t=ot(e);if(!t)throw d("getSnapshot is not supported for this kind of object");return t.atom.reportObserved(),t.standard}function Kt(e){var t=ee(e.target);return{actionName:e.actionName,args:e.args,targetPath:t.path}}function Ht(t){if(y(t))return t;if(W(t))return Qt(t);var n=t;if(e.isObservable(t)&&(t=e.toJS(t,{exportMapsAsObjects:!1,detectCycles:!1})),h(t)||Array.isArray(t))return t;throw d("serializeActionCallArgument could not serialize the given value: "+n)}function Jt(e){return Ae(e)?exports.fromSnapshot(e):e}var Gt=e.action("newModel",function(e,t,n,r){we(t,"modelClass");var o=e,a=_.get(t);if(!a)throw d("no model info for class "+t.name+" could be found - did you forget to add the @model decorator?");if(r){var i=r.unprocessedSnapshot;o.fromSnapshot&&(i=o.fromSnapshot(i)),n=r.snapshotToInitialData(i)}o[j]=a.name;for(var u=o[k],c=Object.keys(u),s=0;s<c.length;s++){var p=c[s];if(void 0===n[p]){var f=void 0,l=u[p];void 0!==l.defaultFn?f=l.defaultFn():void 0!==l.defaultValue&&(f=l.defaultValue),n[p]=f}}vt(o,void 0);var h,v,y=yt(n,{parent:o,path:"$"},o[j],!1),b=ot(y);if(rt.set(o,b),o.$=y,h=o,(v=Object.getOwnPropertyDescriptor(h,"$"))&&(v.enumerable=!0,v.get?delete v.set:v.writable=!1,Object.defineProperty(h,"$",v)),st()&&T(t)){var m=o.typeCheck();m&&m.throw(o)}var g=function(e){return e[O]}(t);return g&&g.forEach(function(e){return e(o)}),o});function qt(e,t){return Xt(e,t)}function Xt(e,t){var n,r=a({recording:!0,filter:Yt},t),o=r.recording,i=r.filter,u=[];return n=e?et(e,function(t,n){o&&i(t,n)&&u.push({target:e,patches:t,inversePatches:n})}):tt(function(e,t,n){o&&i(t,n)&&u.push({target:e,patches:t,inversePatches:n})}),{get recording(){return o},set recording(e){o=e},get events(){return u},dispose:function(){n()}}}var Yt=function(){return!0};function Zt(e){w(e,"target");var t=e.model,n=e.actionName;if(ge(t,"target.model"),"string"!=typeof n)throw d("target.actionName must be a string");var r=Symbol("patchRecorder");function o(e){return e.rootContext.data[r]}return Wt(t,{filter:function(e){var r=e.rootContext;return r.target===t&&r.actionName===n},onStart:function(e){e===e.rootContext&&function(e){e.rootContext.data[r]=Xt(void 0,{recording:!1})}(e)},onResume:function(e){o(e).recording=!0},onSuspend:function(e){o(e).recording=!1},onFinish:function(e,t){if(e===e.rootContext){var n=o(e);try{if(t.result===exports.ActionTrackingResult.Throw)for(var r=n.events,a=r.length-1;a>=0;a--){var i=r[a];_t(i.target,i.inversePatches)}}finally{n.dispose()}}}})}function en(e,t){return A(e,"objFn"),fe(function(){var n=e();w(n,"objectSchema");var r=Object.entries(n),o=function(){for(var e=[],t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];for(var a=0,i=r;a<i.length;a++){var u=i[a],c=u[0],s=se(u[1]),p="...";n.includes(s)||(p=s.getTypeName.apply(s,n.concat([s]))),e.push(c+": "+p+";")}return"{ "+e.join(" ")+" }"},a=new ce(function(e,n){if(!v(e)||t&&!(e instanceof kt))return new ae(n,o(a),e);for(var i=new Set(Object.keys(e)),u=0,c=r;u<c.length;u++){var s=c[u],p=s[0],f=se(s[1]),l=f.unchecked?null:f.check(e[p],[].concat(n,[p]));if(l)return l;i.delete(p)}return i.size>0?new ae(n,o(a),e):null},o);return a})}function tn(e){return en(e,!1)}var nn=new ce(null,function(){return"any"});function rn(){return nn}function on(t){var n;if(w(t,"modelProps"),Object.values(t).some(function(e){return e.typeChecker})){for(var r={},o=0,a=Object.entries(t);o<a.length;o++){var u=a[o];r[u[0]]=u[1].typeChecker||rn()}n=tn(function(){return r})}var c={enumerable:!1,writable:!1,configurable:!0,value:t},s={enumerable:!1,writable:!1,configurable:!0,value:n},p={},l=function(){if(h){if(v>=d.length)return"break";y=d[v++]}else{if((v=d.next()).done)return"break";y=v.value}var e=y;p[e]={enumerable:!1,configurable:!0,get:function(){return this.$[e]},set:function(t){this.$[e]=t}}},d=Object.keys(t).filter(function(e){return!be.has(e)}),h=Array.isArray(d),v=0;for(d=h?d:d[Symbol.iterator]();;){var y;if("break"===l())break}var b=function(t){function n(n,r){var o,a=f(o=t.call(this,I)||this);Object.defineProperty(a,k,c),Object.defineProperty(a,C,s),Object.defineProperties(a,p);var i=o.constructor;return r?Gt(f(o),i,void 0,r):(w(n,"initialData"),Gt(f(o),i,e.observable.object(n,void 0,{deep:!1}),void 0)),o}return i(n,t),n}(ye);return b[C]=n,b}var an=function(e){return function(t){var n,r;we(t,"a model class"),M[e]&&(r="[mobx-keystone] "+(r='a model with name "'+e+'" already exists (if you are using hot-reloading this might be the cause)'),console.error(r));var o=((n={})[t.name]=function(e,n){var r=new t(e,n);return r.onInit&&(Ne(r,"onInit",exports.HookAction.OnInit),r.onInit()),r},n)[t.name];o.prototype=t.prototype,o[O]=t[O];var a={name:e,class:o};return M[e]=a,_.set(o,a),_.set(t,a),o}};function un(e){return fe(function(){var t=se(e),n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return"Array<"+t.getTypeName.apply(t,n.concat([t]))+">"},r=new ce(function(e,o){if(!x(e))return new ae(o,n(r),e);if(!t.unchecked)for(var a=0;a<e.length;a++){var i=t.check(e[a],[].concat(o,[a]));if(i)return i}return null},n);return r})}function cn(e,t){var n="function"==typeof t;return{$valueType:null,$hasDefault:null,defaultFn:n?t:void 0,defaultValue:n?void 0:t,typeChecker:e}}exports.UndoStore=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n._clearUndo=function(){var e=this;ln(function(){e.undoEvents.length=0})},n._clearRedo=function(){var e=this;ln(function(){e.redoEvents.length=0})},n._undo=function(){var e=this;ln(function(){var t=e.undoEvents.pop();e.redoEvents.push(t)})},n._redo=function(){var e=this;ln(function(){var t=e.redoEvents.pop();e.undoEvents.push(t)})},n._addUndo=function(e){var t=this;ln(function(){t.undoEvents.push(e),t.redoEvents.length=0})},t}(on({undoEvents:cn(un(rn()),function(){return[]}),redoEvents:cn(un(rn()),function(){return[]})})),t.__decorate([Me],exports.UndoStore.prototype,"_clearUndo",null),t.__decorate([Me],exports.UndoStore.prototype,"_clearRedo",null),t.__decorate([Me],exports.UndoStore.prototype,"_undo",null),t.__decorate([Me],exports.UndoStore.prototype,"_redo",null),t.__decorate([Me],exports.UndoStore.prototype,"_addUndo",null),exports.UndoStore=t.__decorate([an("mobx-keystone/UndoStore")],exports.UndoStore);var sn=function(){function e(e,t,n){this.disposer=e,this.subtreeRoot=t,this.store=n||new exports.UndoStore({})}var t=e.prototype;return t.clearUndo=function(){this.store._clearUndo()},t.clearRedo=function(){this.store._clearRedo()},t.undo=function(){var e=this;if(!this.canUndo)throw d("nothing to undo");var t=this.undoQueue[this.undoQueue.length-1];ln(function(){_t(e.subtreeRoot,t.inversePatches)}),this.store._undo()},t.redo=function(){var e=this;if(!this.canRedo)throw d("nothing to redo");var t=this.redoQueue[this.redoQueue.length-1];ln(function(){_t(e.subtreeRoot,t.patches)}),this.store._redo()},t.dispose=function(){this.disposer()},r(e,[{key:"undoQueue",get:function(){return this.store.undoEvents}},{key:"redoQueue",get:function(){return this.store.redoEvents}},{key:"undoLevels",get:function(){return this.undoQueue.length}},{key:"canUndo",get:function(){return this.undoLevels>0}},{key:"redoLevels",get:function(){return this.redoQueue.length}},{key:"canRedo",get:function(){return this.redoLevels>0}}]),e}();t.__decorate([e.computed],sn.prototype,"undoQueue",null),t.__decorate([e.computed],sn.prototype,"redoQueue",null),t.__decorate([e.computed],sn.prototype,"undoLevels",null),t.__decorate([e.computed],sn.prototype,"canUndo",null),t.__decorate([e.action],sn.prototype,"clearUndo",null),t.__decorate([e.computed],sn.prototype,"redoLevels",null),t.__decorate([e.computed],sn.prototype,"canRedo",null),t.__decorate([e.action],sn.prototype,"clearRedo",null),t.__decorate([e.action],sn.prototype,"undo",null),t.__decorate([e.action],sn.prototype,"redo",null);var pn=!1,fn=function(){return!pn};function ln(e){var t=pn;pn=!0;try{return e()}finally{pn=t}}function dn(t,n){B(t,"node");var r=Qt(t);return e.reaction(function(){return Qt(t)},function(e){var t=r;r=e,n(e,t)})}function hn(e,t,n){return fe(function(){var r=se(e),o=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var a=r.getTypeName.apply(r,t.concat([r]));return(n||"refinementOf")+"<"+a+">"},a=new ce(function(e,n){var i=r.check(e,n);if(i)return i;var u=t(e);return!0===u?null:!1===u?new ae([],o(a),e):u||null},o);return a})}function vn(e){var t;switch(function(t,n){if(!y(e))throw d("literal must be a primitive")}(),e){case void 0:t="undefined";break;case null:t="null";break;default:t=JSON.stringify(e)}return new ce(function(n,r){return n===e?null:new ae(r,t,n)},function(){return t})}var yn=vn(void 0),bn=vn(null),mn=new ce(function(e,t){return"boolean"==typeof e?null:new ae(t,"boolean",e)},function(){return"boolean"}),gn=new ce(function(e,t){return"number"==typeof e?null:new ae(t,"number",e)},function(){return"number"}),xn=new ce(function(e,t){return"string"==typeof e?null:new ae(t,"string",e)},function(){return"string"}),wn=hn(gn,function(e){return Number.isInteger(e)},"integer"),An=hn(xn,function(e){return""!==e},"nonEmpty"),Sn=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),r(t,[{key:"maybeCurrent",get:function(){return this.resolve()}},{key:"isValid",get:function(){return!!this.maybeCurrent}},{key:"current",get:function(){var e=this.maybeCurrent;if(!e)throw d("a reference of type '"+this.$modelType+"' could not resolve an object with id '"+this.id+"'");return e}}]),t}(on({id:cn(xn)}));function kn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return fe(function(){var e=t.map(se);if(e.some(function(e){return e.unchecked}))return rn();var n=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.map(function(e){return n.includes(e)?"...":e.getTypeName.apply(e,n.concat([e]))}).join(" | ")},r=new ce(function(t,o){return e.every(function(e){return!!e.check(t,o)})?new ae(o,n(r),t):null},n);return r})}function Cn(e){return fe(function(){var t=se(e),n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return"Record<"+t.getTypeName.apply(t,n.concat([t]))+">"},r=new ce(function(e,o){if(!v(e))return new ae(o,n(r),e);if(!t.unchecked)for(var a=Object.keys(e),i=0;i<a.length;i++){var u=a[i],c=t.check(e[u],[].concat(o,[u]));if(c)return c}return null},n);return r})}t.__decorate([e.computed],Sn.prototype,"maybeCurrent",null),t.__decorate([e.computed],Sn.prototype,"isValid",null),t.__decorate([e.computed],Sn.prototype,"current",null),exports.ArraySet=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.add=function(e){var t=this.items;return t.includes(e)||t.push(e),this},n.clear=function(){this.items.length=0},n.delete=function(e){var t=this.items,n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,1),!0)},n.forEach=function(e,t){var n=this;this.items.forEach(function(r){e.call(t,r,r,n)})},n.has=function(e){return this.items.includes(e)},n.keys=function(){return this.values()},n.values=function(){return this.items.values()},n.entries=function(){return this.items.map(function(e){return[e,e]}).values()},n[Symbol.iterator]=function(){return this.values()},r(t,[{key:"size",get:function(){return this.items.length}},{key:Symbol.toStringTag,get:function(){return"ArraySet"}}]),t}(on({items:cn(un(rn()),function(){return[]})})),t.__decorate([Me],exports.ArraySet.prototype,"add",null),t.__decorate([Me],exports.ArraySet.prototype,"clear",null),t.__decorate([Me],exports.ArraySet.prototype,"delete",null),exports.ArraySet=t.__decorate([an("mobx-keystone/ArraySet")],exports.ArraySet),exports.ObjectMap=function(e){function t(){return e.apply(this,arguments)||this}i(t,e);var n=t.prototype;return n.clear=function(){var e=this.items;Object.keys(e).forEach(function(t){delete e[t]})},n.delete=function(e){return!!this.has(e)&&(delete this.items[e],!0)},n.forEach=function(e,t){var n=this,r=this.items;Object.keys(r).forEach(function(o){e.call(t,r[o],o,n)})},n.get=function(e){return this.items[e]},n.has=function(e){return e in this.items},n.set=function(e,t){return this.items[e]=t,this},n.keys=function(){return Object.keys(this.items)[Symbol.iterator]()},n.values=function(){return Object.values(this.items)[Symbol.iterator]()},n.entries=function(){return Object.entries(this.items)[Symbol.iterator]()},n[Symbol.iterator]=function(){return this.entries()},r(t,[{key:"size",get:function(){return Object.keys(this.items).length}},{key:Symbol.toStringTag,get:function(){return"ObjectMap"}}]),t}(on({items:cn(Cn(rn()),function(){return{}})})),t.__decorate([Me],exports.ObjectMap.prototype,"clear",null),t.__decorate([Me],exports.ObjectMap.prototype,"delete",null),t.__decorate([Me],exports.ObjectMap.prototype,"set",null),exports.ObjectMap=t.__decorate([an("mobx-keystone/ObjectMap")],exports.ObjectMap);var On=tn(function(){return{id:xn}}),Tn=new ce(function(e,t){return e instanceof Sn?se(On).check(e.$,[].concat(t,["$"])):new ae(t,"Ref",e)},function(){return"Ref"}),jn={literal:vn,undefined:yn,null:bn,boolean:mn,number:gn,string:xn,or:kn,maybe:function(e){return kn(e,yn)},maybeNull:function(e){return kn(e,bn)},array:un,record:Cn,unchecked:rn,model:de,object:tn,ref:function(){return Tn},frozen:function(e){return en(function(){return{data:e}},!0)},enum:function(e){w(e,"enumObject");var t=function(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var o=r[n],a=e[o];"string"==typeof a&&e[a]===+o||t.push(a)}return t}(e).map(function(e){return vn(e)});return kn.apply(void 0,t)},refinement:hn,integer:wn,nonEmptyString:An,objectMap:function(e){return fe(function(){var t=se(e),n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return"ObjectMap<"+t.getTypeName.apply(t,n.concat([t]))+">"},r=new ce(function(e,o){return e instanceof exports.ObjectMap?se(tn(function(){return{items:Cn(t)}})).check(e.$,[].concat(o,["$"])):new ae(o,n(r),e)},n);return r})},arraySet:function(e){return fe(function(){var t=se(e),n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return"ArraySet<"+t.getTypeName.apply(t,n.concat([t]))+">"},r=new ce(function(e,o){return e instanceof exports.ArraySet?se(tn(function(){return{items:un(t)}})).check(e.$,[].concat(o,["$"])):new ae(o,n(r),e)},n);return r})}};exports.BaseModel=ye,exports.Frozen=kt,exports.MobxDataModelError=l,exports.Model=on,exports.Ref=Sn,exports.TypeCheckError=ae,exports.UndoManager=sn,exports.actionCallToReduxAction=function(e){return{type:"applyAction",payload:e}},exports.actionTrackingMiddleware=Wt,exports.addActionMiddleware=je,exports.applyAction=Ft,exports.applyPatches=_t,exports.applySnapshot=Et,exports.arrayAsMap=function(e){var t,n,r,a=((n={clear:function(){e().length=0},delete:function(t){var n=e(),r=n.findIndex(function(e){return e[0]===t});return r>=0&&(n.splice(r,1),!0)},forEach:function(t,n){e().forEach(function(e){t.call(n,e[1],e[0],a)})},get:function(t){var n=e().find(function(e){return e[0]===t});return n?n[1]:void 0},has:function(t){return e().some(function(e){return e[0]===t})},set:function(t,n){var r=e(),o=r.find(function(e){return e[0]===t});return o?o[1]=n:r.push([t,n]),a},get size(){return e().length},keys:function(){return e().map(function(e){return e[0]})[Symbol.iterator]()},values:function(){return e().map(function(e){return e[1]})[Symbol.iterator]()},entries:function(){return e().map(function(e){return[e[0],e[1]]})[Symbol.iterator]()}})[Symbol.iterator]=function(){return a.entries()},(r={})[t=Symbol.toStringTag]=r[t]||{},r[t].get=function(){return"Map"},o(n,r),n);return a},exports.arrayAsSet=function(e){var t,n,r,a=((n={add:function(t){var n=e();return n.includes(t)||n.push(t),a},clear:function(){e().length=0},delete:function(t){var n=e(),r=n.findIndex(function(e){return e===t});return r>=0&&(n.splice(r,1),!0)},forEach:function(t,n){e().forEach(function(e){t.call(n,e,e,a)})},has:function(t){return e().includes(t)},get size(){return e().length},keys:function(){return a.values()},values:function(){return e().values()},entries:function(){return e().map(function(e){return[e,e]}).values()}})[Symbol.iterator]=function(){return a.values()},(r={})[t=Symbol.toStringTag]=r[t]||{},r[t].get=function(){return"Set"},o(n,r),n);return a},exports.arraySet=function(e){var t=e?e.slice():[];return new exports.ArraySet({items:t})},exports.asReduxStore=function(e){B(e,"target");for(var t=function(t){if("applyAction"!==t.type)throw d("action type was expected to be 'applyAction', but it was '"+t.type+"'");return Ft(e,t.payload),t},n={getState:function(){return Qt(e)},dispatch:function(e){return function(t,n,r){var o=0;return function e(t){var a=n[o];return o++,a?a(e)(t):r(t)}(e)}(0,i,t)},subscribe:function(t){return dn(e,t)}},r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var i=o.map(function(e){return e(n)});return n},exports.clone=function(e){B(e,"node");var t=Qt(e);return exports.fromSnapshot(t)},exports.connectReduxDevTools=function(e,t,n,r){var o=a({logArgsNearName:!0},r),i=0;t.subscribe(function(r){"DISPATCH"===r.type&&function(t,n,r){try{switch(i++,r.payload.type){case"RESET":return Et(n,u),t.init(u);case"COMMIT":return t.init(Qt(n));case"ROLLBACK":return t.init(e.extractState(r));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return void Et(n,e.extractState(r));case"IMPORT_STATE":var o=r.payload.nextLiftedState,a=o.computedStates;Et(n,a[a.length-1].state),t.send(null,o)}}finally{i--}}(t,n,r)});var u=Qt(n);t.init(u);var c=0,s=Symbol("actionId");Wt(n,{onStart:function(e){e.data[s]=c++},onResume:function(e){e.parentContext&&f(e.parentContext,void 0),f(e,void 0)},onSuspend:function(e){f(e,void 0)},onFinish:function(e,t){f(e,t.result)}});var p=u;function f(e,r){if(!i){var a=Qt(n);if(a!==p||r===exports.ActionTrackingResult.Throw){p=a;var u=ee(e.target),c=function e(t,n,r){var a="[/"+n.path.join("/")+"] "+t.actionName;if(o.logArgsNearName){var i=t.args.map(function(e){try{return JSON.stringify(e)}catch(e){return"**unserializable**"}}).join(", ");i.length>64&&(i=i.slice(0,64)+"..."),a+="("+i+")"}var u=t.data[s];if(a+=" (id "+(void 0!==u?u:"?"),t.type===exports.ActionContextActionType.Async&&(a+=", async"),a+=")",r===exports.ActionTrackingResult.Throw&&(a+=" -error thrown-"),t.parentContext){var c=e(t.parentContext,ee(t.parentContext.target),void 0);c&&(a=c+" >>> "+a)}return a}(e,u,r);t.send({type:c,path:u.path,args:e.args},a)}}}},exports.customRef=function(n,r){var o=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t.prototype.resolve=function(){return r.resolve(this)},t}(Sn);o=t.__decorate([an(n)],o);var a=function(t){var n;"string"==typeof t?n=t:(w(t,"target"),n=r.getId(t));var a=new o({id:n});if(r.onResolvedValueChange){var i=a.maybeCurrent;e.reaction(function(){return a.maybeCurrent},function(e){if(e!==i){var t=i;i=e,r.onResolvedValueChange(a,e,t)}},{fireImmediately:!0})}return a};return a.refClass=o,a},exports.deserializeActionCall=function(e){return a({},e,{args:e.args.map(Jt)})},exports.deserializeActionCallArgument=Jt,exports.detach=Ee,exports.findParent=pt,exports.frozen=Ct,exports.getChildrenObjects=We,exports.getCurrentActionContext=F,exports.getGlobalConfig=ct,exports.getModelDataType=T,exports.getParent=Y,exports.getParentPath=X,exports.getRoot=te,exports.getRootPath=ee,exports.getRootStore=function(e){B(e,"node");var t=te(e);return Ge(t)?t:void 0},exports.getSnapshot=Qt,exports.isBuiltInAction=Ce,exports.isChildOfParent=re,exports.isHookAction=Ue,exports.isModel=me,exports.isModelAction=Re,exports.isModelDataObject=Z,exports.isModelFlow=Ut,exports.isParentOfChild=function(e,t){return B(e,"parent"),B(t,"child"),re(t,e)},exports.isRoot=ne,exports.isRootStore=Ge,exports.isTreeNode=V,exports.model=an,exports.modelAction=Me,exports.modelFlow=function(e,t,n){return S({target:e,propertyKey:t,baseDescriptor:n},function(e,t){return Ut(t)?t:(function(e,n,r){if("function"!=typeof t)throw d("modelFlow has to be used over functions");Se("modelFlow",e,n)}(e.target,e.propertyKey),n=e.propertyKey,r=t,(o=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var a,i=this,u=function(e){return function(n){n.previousAsyncStepContext=a,n.spawnAsyncStepContext=a?a.spawnAsyncStepContext:n,n.asyncStepType=e,n.args=t,a=n}},c=!1,s=Pe(n,function(){return c=!0,r.apply(i,t)},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Spawn)).apply(i);if(!c)return s instanceof Promise?s:Promise.resolve(s);var p=s.next.bind(s),f=s.throw.bind(s);return new Promise(function(e,t){function r(r){var o;try{o=Pe(n,p,exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Resume)).call(i,r)}catch(r){return void Pe(n,function(n){return{value:n,resolution:"reject",accepter:e,rejecter:t}},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Throw),!0).call(i,r)}a(o)}function o(r){var o;try{o=Pe(n,f,exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.ResumeError)).call(i,r)}catch(r){return void Pe(n,function(n){return{value:n,resolution:"reject",accepter:e,rejecter:t}},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Throw),!0).call(i,r)}a(o)}function a(c){c&&"function"==typeof c.then?c.then(a,t):c.done?Pe(n,function(n){return{value:n,resolution:"accept",accepter:e,rejecter:t}},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Return),!0).call(i,c.value):Promise.resolve(c.value).then(r,o)}r(void 0)})})[zt]=!0,o);var n,r,o})},exports.modelSnapshotInWithMetadata=function(e,t){var n;we(e,"modelClass"),w(t,"initialData");var r=_.get(e);return a({},t,((n={})[j]=r.name,n))},exports.modelSnapshotOutWithMetadata=function(e,t){var n;we(e,"modelClass"),w(t,"initialData");var r=_.get(e);return a({},t,((n={})[j]=r.name,n))},exports.modelTypeKey=j,exports.objectAsMap=function(e){var t,n,r,a=((n={clear:function(){var t=e();Object.keys(t).forEach(function(e){delete t[e]})},delete:function(t){var n=e();return!!a.has(t)&&(delete n[t],!0)},forEach:function(t,n){var r=e();Object.keys(r).forEach(function(e){t.call(n,r[e],e,a)})},get:function(t){return e()[t]},has:function(t){return t in e()},set:function(t,n){return e()[t]=n,a},get size(){var t=e();return Object.keys(t).length},keys:function(){var t=e();return Object.keys(t)[Symbol.iterator]()},values:function(){var t=e();return Object.values(t)[Symbol.iterator]()},entries:function(){var t=e();return Object.entries(t)[Symbol.iterator]()}})[Symbol.iterator]=function(){return a.entries()},(r={})[t=Symbol.toStringTag]=r[t]||{},r[t].get=function(){return"Map"},o(n,r),n);return a},exports.objectMap=function(e){var t={};if(e)for(var n=e.length,r=0;r<n;r++){var o=e[r];t[o[0]]=o[1]}return new exports.ObjectMap({items:t})},exports.onActionMiddleware=function(e,t){return B(e,"subtreeRoot"),w(t,"listeners"),Wt(e,{filter:function(e){return!e.parentContext&&!Ue(e.actionName)},onStart:function(e){if(t.onStart){var n=Kt(e);return t.onStart(n,e)}},onFinish:function(e,n){if(t.onFinish){var r=Kt(e);return t.onFinish(r,e,n)}}})},exports.onGlobalPatches=tt,exports.onPatches=et,exports.onSnapshot=dn,exports.patchRecorder=qt,exports.prop=function(e){var t="function"==typeof e;return{$valueType:null,$hasDefault:null,defaultFn:t?e:void 0,defaultValue:t?void 0:e,typeChecker:null}},exports.readonlyMiddleware=function(e){B(e,"subtreeRoot");var t=!1;return{dispose:Wt(e,{filter:function(e){return!e.parentContext&&!Ue(e.actionName)},onStart:function(e){return t?void 0:{result:exports.ActionTrackingResult.Throw,value:d("tried to invoke action '"+e.actionName+"' over a readonly node")}}}),allowWrite:function(e){var n=t;t=!0;try{return e()}finally{t=n}}}},exports.reduxActionType="applyAction",exports.registerRootStore=He,exports.resolvePath=oe,exports.runUnprotected=function(t,n){var r="string"==typeof t?t:void 0,o="string"==typeof t?n:t,a=z;z=!1;try{return r?e.runInAction(r,o):e.runInAction(o)}finally{z=a}},exports.serializeActionCall=function(e){return a({},e,{args:e.args.map(Ht)})},exports.serializeActionCallArgument=Ht,exports.setGlobalConfig=function(e){ut=Object.freeze(a({},ut,{},e))},exports.simplifyActionContext=Lt,exports.tProp=cn,exports.toTreeNode=function(e){if(!v(e))throw d("only objects can be turned into tree nodes");return V(e)?e:At(e,void 0)},exports.transaction=function(e,t){var n,r,o;Se("transaction",e,t),r=function(e){Zt({model:e,actionName:t})},(o=(n=e.constructor)[O])||(n[O]=o=[]),o.push(r)},exports.transactionMiddleware=Zt,exports.typeCheck=he,exports.types=jn,exports.undoMiddleware=function(e,t){B(e,"subtreeRoot");var n,r=Symbol("patchRecorder");function o(e){return e.rootContext.data[r]}var a=Wt(e,{onStart:function(t){t===t.rootContext&&function(t){t.rootContext.data[r]=qt(e,{recording:!1,filter:fn})}(t)},onResume:function(e){o(e).recording=!0},onSuspend:function(e){o(e).recording=!1},onFinish:function(e){if(e===e.rootContext){var t=o(e);if(t.events.length>0){var r=[],a=[],i=t.events,u=Array.isArray(i),c=0;for(i=u?i:i[Symbol.iterator]();;){var s;if(u){if(c>=i.length)break;s=i[c++]}else{if((c=i.next()).done)break;s=c.value}var p=s;r.push.apply(r,p.patches),a.unshift.apply(a,p.inversePatches)}n.store._addUndo({targetPath:ee(e.target).path,actionName:e.actionName,patches:r,inversePatches:a})}t.dispose()}}});return n=new sn(a,e,t)},exports.unregisterRootStore=Je,exports.walkTree=Ve,exports.withoutUndo=ln; | ||
"use strict";var t=require("mobx"),e=require("tslib");function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function o(t,e){for(var n in e)(a=e[n]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,n,a);if(Object.getOwnPropertySymbols)for(var r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++){var a,i=r[o];(a=e[i]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,i,a)}return t}function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t,e,n){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return(p=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return s(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)})(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var l=function(t){function e(n){var r;return r=t.call(this,n)||this,Object.setPrototypeOf(f(r),e.prototype),r}return i(e,t),e}(p(Error));function d(t){return new l(t)}function h(t){if(!v(t))return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function v(t){return null!==t&&"object"==typeof t}function y(t){switch(typeof t){case"object":return null===t;case"function":case"symbol":return!1;default:return!0}}function m(t,e){var n=t.indexOf(e);return n>=0&&(t.splice(n,1),!0)}function b(e){return e instanceof Map||t.isObservableMap(e)}function g(e){return e instanceof Set||t.isObservableSet(e)}function x(e){return Array.isArray(e)||t.isObservableArray(e)}function w(t,e){if(!v(t))throw d(e+" must be an object")}function A(t,e){if("function"!=typeof t)throw d(e+" must be a function")}function S(t,e){var n=t.target,r=t.propertyKey,o=t.baseDescriptor;if(o)return{enumerable:!1,writable:!0,configurable:!0,value:e(t,o.value)};Object.defineProperty(n,r,{configurable:!0,enumerable:!1,get:function(){},set:function(n){var o,i,u;o=r,i=e(a({},t,{target:this}),n),void 0===u&&(u=!0),Object.defineProperty(this,o,{enumerable:!1,writable:u,configurable:!0,value:i})}})}var k=Symbol("modelProperties"),C=Symbol("modelDataTypeChecker"),T=Symbol("modelInitializers");function O(t){if(bt(t)||xt(t))return t[C];throw d("modelClassOrInstance must be a model class or instance")}var j="$modelType";function R(t){return t===j}var M={},_=new Map;function P(t){return M[t]}var N,E,$,I=Symbol("modelConstructor");function F(){return $}function D(t){$=t}(N=exports.ActionContextActionType||(exports.ActionContextActionType={})).Sync="sync",N.Async="async",(E=exports.ActionContextAsyncStepType||(exports.ActionContextAsyncStepType={})).Spawn="spawn",E.Return="return",E.Resume="resume",E.ResumeError="resumeError",E.Throw="throw";var z=!0,U=new WeakSet;function W(t){return!y(t)&&U.has(t)}function V(t){return W(t)}function B(t,e){if(!W(t))throw d(e+" must be a tree node (usually a model or a shallow / deep child part of a model 'data' object)");return!0}function L(){if(z&&!F())throw d("data changes must be performed inside model actions")}var Q=!1,K=new WeakMap,H=new WeakMap,J=new WeakMap;function G(e){var n=H.get(e);return n||(n=t.createAtom("parentAtom"),H.set(e,n)),n}function q(t){G(t).reportChanged()}function X(t){return B(t,"value"),G(t).reportObserved(),K.get(t)}function Y(t,e){void 0===e&&(e=!1),B(t,"value");var n=X(t);return n&&e&&Z(n.parent)?Y(n.parent,!1):n?n.parent:void 0}function Z(t){if(B(t,"value"),!v(t))return!1;var e=X(t);return!!e&&"$"===e.path&&e.parent instanceof yt}function tt(t){B(t,"value");for(var e,n={root:t,path:[]};e=X(n.root);)n.root=e.parent,n.path.unshift(e.path);return n}function et(t){return B(t,"value"),tt(t).root}function nt(t){return B(t,"value"),!Y(t)}function rt(t,e){B(t,"child"),B(e,"parent");for(var n,r=t;n=X(r);)if((r=n.parent)===e)return!0;return!1}function ot(t,e){for(var n=t,r=e.length,o=0;o<r;o++){if(!v(n))return{resolved:!1};n=n[e[o]]}return{resolved:!0,value:n}}var at=function(){function t(t,e,n){this.path=t,this.expectedTypeName=e,this.actualValue=n}return t.prototype.throw=function(t){var e="TypeCheckError: ",n=[];throw t&&W(t)&&(n=tt(t).path),e+="["+[].concat(n,this.path).join("/")+"] ",d(e+="Expected: "+this.expectedTypeName)},t}(),it=[],ut=new WeakMap,ct=function(){function t(t,e){this._check=t,this.getTypeName=e,this.unchecked=!t}var e=t.prototype;return e.createCacheIfNeeded=function(){return this.checkResultCache||(this.checkResultCache=new WeakMap),this.checkResultCache},e.setCachedResult=function(t,e){this.createCacheIfNeeded().set(t,e);var n=ut.get(t);n||(n=new Set,ut.set(t,n)),n.add(this)},e.invalidateCachedResult=function(t){this.checkResultCache&&this.checkResultCache.delete(t)},e.getCachedResult=function(t){return this.checkResultCache?this.checkResultCache.get(t):void 0},e.check=function(t,e){if(this.unchecked)return null;if(!W(t))return this._check(t,e);var n=this.getCachedResult(t);return void 0===n&&(n=this._check(t,it),this.setCachedResult(t,n)),n?new at([].concat(e,n.path),n.expectedTypeName,n.actualValue):null},t}();function st(t){for(var e,n=t;;){if(n instanceof ct)return n;if("function"!=typeof(e=n)||!e[pt])throw d("type checker could not be resolved");n=n()}}var pt=Symbol("lateTypeCheker");function ft(t){var e,n=function(){return e||(e=t())};return n[pt]=!0,n}var lt=new WeakMap;function dt(t){if(!xt(t)&&"function"==typeof t)return ft(function(){return dt(t())});var e=t;wt(e,"modelClass");var n=lt.get(e);if(n)return n;var r=ft(function(){var t=_.get(e),n="Model("+t.name+")";return new ct(function(r,o){if(!(r instanceof e))return new at(o,n,r);var a=O(r);if(!a)throw d("type checking cannot be performed over model of type '"+t.name+"' at path "+o.join("/")+" since that model type has no data type declared, consider adding a data type or using types.unchecked() instead");var i=st(a);return i.unchecked?null:i.check(r.$,[].concat(o,["$"]))},function(){return n})});return lt.set(e,r),r}function ht(t,e){if(!t)throw d("a type must be passed");var n=st(t);return n.unchecked?null:n.check(e,[])}var vt,yt=function(){function t(t){if(t!==I)throw d("did you forget to add the @model decorator?")}return t.prototype.typeCheck=function(){return ht(dt(this.constructor),this)},t}(),mt=new Set([j,"onInit","$","onAttachedToRootStore","fromSnapshot","typeCheck"]);function bt(t){return t instanceof yt}function gt(t,e,n){if(void 0===n&&(n="must be a model instance"),!bt(t))throw d(e+" "+n)}function xt(t){return"function"==typeof t&&(t===yt||t.prototype instanceof yt)}function wt(t,e){if("function"!=typeof t)throw d(e+" must be a class");if(t!==yt&&!(t.prototype instanceof yt))throw d(e+" must extend Model")}function At(t){return h(t)&&!!t[j]}function St(t,e,n){if("string"!=typeof n)throw d(t+" cannot be used over symbol properties");var r=t+" must be used over model classes or instances";if(!e)throw d(r);if(!(e instanceof yt||e===yt||e.prototype instanceof yt))throw d(r)}(vt=exports.BuiltInAction||(exports.BuiltInAction={})).ApplyPatches="$$applyPatches",vt.ApplySnapshot="$$applySnapshot",vt.Detach="$$detach";var kt=new Set(Object.values(exports.BuiltInAction));function Ct(t){return kt.has(t)}var Tt=new WeakMap,Ot=new WeakMap;function jt(e){w(e,"middleware");var n=e.middleware,r=e.filter,o=e.subtreeRoot;if(B(o,"middleware.subtreeRoot"),A(n,"middleware.middleware"),r&&"function"!=typeof r)throw d("middleware.filter must be a function or undefined");if(t.isAction(n)||(n=t.action(n.name||"actionMiddleware",n)),o){var a=function(t){return t.target===o||rt(t.target,o)};if(r){var i=r;r=function(t){return a(t)&&i(t)}}else r=a}var u={middleware:n,filter:r},c=Tt.get(o);return c?c.push(u):Tt.set(o,c=[u]),function(){m(c,u)}}function Rt(t){return"function"==typeof t&&t[_t]}function Mt(t,e,n){return S({target:t,propertyKey:e,baseDescriptor:n},function(t,e){return Rt(e)?e:(function(t,n,r){if("function"!=typeof e)throw d("modelAction has to be used over functions");St("modelAction",t,n)}(t.target,t.propertyKey),Pt(t.propertyKey,e,exports.ActionContextActionType.Sync))})}var _t=Symbol("modelAction");function Pt(e,n,r,o,a){function i(){var t,i=F(),u={actionName:e,type:r,target:this,args:Array.from(arguments),parentContext:i,data:{},rootContext:void 0};o&&o(u),u.rootContext||(u.rootContext=u.previousAsyncStepContext?u.previousAsyncStepContext.rootContext:u.parentContext?u.parentContext.rootContext:u),D(u);var c,s,p,f=(t=n).bind.apply(t,[this].concat(Array.prototype.slice.call(arguments))),l=((p=Ot.get(c=this))||((s={})[Symbol.iterator]=function(){var t=c;function e(){var e=t?Tt.get(t):void 0;if(e&&!(e.length<=0))return e[Symbol.iterator]()}function n(){for(var n;t&&!n;)t=Y(t),n=e();return n}var r=e();return r||(r=n()),{next:function(){if(!r)return{value:void 0,done:!0};var t=r.next();return t.done?(r=n(),this.next()):t}}},Ot.set(c,p=s)),p),d=Array.isArray(l),h=0;for(l=d?l:l[Symbol.iterator]();;){var v;if(d){if(h>=l.length)break;v=l[h++]}else{if((h=l.next()).done)break;v=h.value}var y=v;(!y.filter||y.filter(u))&&(f=y.middleware.bind(void 0,u,f))}try{var m=f();if(a){var b=m,g=b.value;return"accept"===b.resolution?b.accepter(g):b.rejecter(g),g}return m}finally{D(u.parentContext)}}return void 0===a&&(a=!1),t.isAction(n)||(n=t.action(e,n)),i[_t]=!0,i}function Nt(t,e,n){var r=t[e];if(!Rt(r)){var o=Pt(n,r,exports.ActionContextActionType.Sync),a=Object.getPrototypeOf(t);a[e]===r?a[e]=o:t[e]=o}}function Et(t){B(t,"node"),It.call(t)}var $t,It=Pt(exports.BuiltInAction.Detach,Ft,exports.ActionContextActionType.Sync);function Ft(){var e=X(this);if(e){var n=e.parent,r=e.path;if(t.isObservableArray(n))n.splice(+r,1);else{if(!t.isObservableObject(n))throw d("parent must be an observable object or an observable array");t.remove(n,""+r)}}}($t=exports.HookAction||(exports.HookAction={})).OnInit="$$onInit",$t.OnAttachedToRootStore="$$onAttachedToRootStore",$t.OnAttachedToRootStoreDisposer="$$onAttachedToRootStoreDisposer";var Dt,zt=new Set(Object.values(exports.HookAction));function Ut(t){return zt.has(t)}function Wt(t){return B(t,"node"),J.get(t)}function Vt(t,e,n){if(B(t,"target"),n===exports.WalkTreeMode.ParentFirst){var r=e(t);if(void 0!==r)return r}var o=Wt(t),a=Array.isArray(o),i=0;for(o=a?o:o[Symbol.iterator]();;){var u;if(a){if(i>=o.length)break;u=o[i++]}else{if((i=o.next()).done)break;u=i.value}var c=Vt(u,e,n);if(void 0!==c)return c}if(n===exports.WalkTreeMode.ChildrenFirst){var s=e(t);if(void 0!==s)return s}}(Dt=exports.WalkTreeMode||(exports.WalkTreeMode={})).ParentFirst="parentFirst",Dt.ChildrenFirst="childrenFirst";var Bt=new WeakMap;function Lt(t,e){Vt(e,function(e){if(e instanceof yt&&e.onAttachedToRootStore){Nt(e,"onAttachedToRootStore",exports.HookAction.OnAttachedToRootStore);var n=e.onAttachedToRootStore(t);if(n){var r=Pt(exports.HookAction.OnAttachedToRootStoreDisposer,n,exports.ActionContextActionType.Sync);Bt.set(e,r)}}},exports.WalkTreeMode.ParentFirst)}function Qt(t){Vt(t,function(t){var e=Bt.get(t);e&&(Bt.delete(t),e.call(t))},exports.WalkTreeMode.ChildrenFirst)}var Kt=new WeakSet,Ht=t.action("registerRootStore",function(t){if(B(t,"node"),Kt.has(t))throw d("object already marked as root store");if(!nt(t))throw d("a root store must not have a parent");return Kt.add(t),Lt(t,t),t}),Jt=t.action("unregisterRootStore",function(t){if(!Gt(t))throw d("not a root store");Kt.delete(t),Qt(t)});function Gt(t){return Kt.has(t)}var qt=t.action("setParent",function(e,n,r){if(void 0===r&&(r=!1),!y(e)){J.has(e)||J.set(e,t.observable.set());var o=X(e);if(i=n,void 0===u&&(u=!0),((a=o)||i)&&(!a||!i||a.parent!==i.parent||u&&a.path!==i.path)){var a,i,u;if(Gt(e))throw d("root stores cannot be attached to any parents");if(o&&n){if(o.parent===n.parent&&r)return K.set(e,n),void q(e);throw d("an object cannot be assigned a new parent when it already has one")}var c=function(){o&&o.parent&&J.get(o.parent).delete(e)},s=function(){n&&n.parent&&J.get(n.parent).add(e),K.set(e,n)};if(e instanceof yt){var p=et(e),f=Gt(p)?p:void 0;c(),s();var l=et(e),h=Gt(l)?l:void 0;f!==h&&(f&&Qt(e),h&&Lt(h,e))}else c(),s();q(e)}}}),Xt=function(){function t(){this.record=this.record.bind(this)}var e=t.prototype;return e.record=function(t,e){this.patches=t,this.invPatches=e},e.emit=function(t){!function t(e,n,r,o){if(!(n.length<=0&&r.length<=0)){if(o)for(var a=0;a<Zt.length;a++)(0,Zt[a])(e,n,r);var i=Yt.get(e);if(i)for(var u=0;u<i.length;u++)(0,i[u])(n,r);var c=X(e);if(c){var s=c.path,p=c.parent instanceof yt,f=p?n:n.map(function(t){return ne(t,s)}),l=p?r:r.map(function(t){return ne(t,s)});t(c.parent,f,l,!1)}}}(t,this.patches,this.invPatches,!0)},t}(),Yt=new WeakMap,Zt=[];function te(e,n){B(e,"subtreeRoot"),A(n,"listener"),t.isAction(n)||(n=t.action(n.name||"onPatchesListener",n));var r=Yt.get(e);return r||Yt.set(e,r=[]),r.push(n),function(){m(r,n)}}function ee(e){return A(e,"listener"),t.isAction(e)||(e=t.action(e.name||"onGlobalPatchesListener",e)),Zt.push(e),function(){m(Zt,e)}}function ne(t,e){return a({},t,{path:[e].concat(t.path)})}var re=new WeakMap;function oe(t){return re.get(t)}var ae,ie=t.action("setInternalSnapshot",function(e,n){var r=oe(e);if(!r||r.standard!==n){var o;r?(o=r).standard=n:(o={standard:n,atom:t.createAtom("snapshot")},re.set(e,o)),o.atom.reportChanged();var a=function e(n,r){return t.untracked(function(){if(r){var t=oe(r.parent);if(t)return n===t?e(t,X(r.parent)):n?{parentSnapshot:t,parentPath:r}:void 0}})}(r,X(e));if(a){var i=a.parentSnapshot,u=a.parentPath;if(i){var c=u.path,s=i.standard;s[c]!==o.standard&&((s=Array.isArray(s)?s.slice():Object.assign({},s))[c]=o.standard,ie(u.parent,s))}}}});(ae=exports.ModelAutoTypeCheckingMode||(exports.ModelAutoTypeCheckingMode={})).DevModeOnly="devModeOnly",ae.AlwaysOn="alwaysOn",ae.AlwaysOff="alwaysOff";var ue={modelAutoTypeChecking:exports.ModelAutoTypeCheckingMode.DevModeOnly};function ce(){return ue}function se(){switch(ce().modelAutoTypeChecking){case exports.ModelAutoTypeCheckingMode.DevModeOnly:case exports.ModelAutoTypeCheckingMode.AlwaysOff:return!1;case exports.ModelAutoTypeCheckingMode.AlwaysOn:return!0;default:throw d("invalid 'modelAutoTypeChecking' config value - "+ue.modelAutoTypeChecking)}}function pe(t,e,n){void 0===n&&(n=0),B(t,"child");for(var r,o=t,a=0;r=X(o);){if(a++,e(o=r.parent))return o;if(n>0&&a===n)break}}function fe(e,n){if(function(t){for(var e=t;e;){var n=ut.get(e);if(n){var r=n,o=Array.isArray(r),a=0;for(r=o?r:r[Symbol.iterator]();;){var i;if(o){if(a>=r.length)break;i=r[a++]}else{if((a=r.next()).done)break;i=a.value}i.invalidateCachedResult(e)}ut.delete(e)}e=Y(e)}}(e),se()){var r=pe(e,function(t){return bt(t)&&!!O(t)});if(r){var o=r.typeCheck();o&&(function(r){var o=Q;Q=!0;try{t.runInAction(function(){Pe.call(e,n.invPatches)})}finally{Q=o}}(),o.throw(r))}}}function le(e,n,r){var o=e,a=o.length,i=t.isObservableArray(o)?o:t.observable.array([],he);i!==o&&(i.length=o.length),U.add(i),qt(i,n);var u=[];u.length=a;for(var c=0;c<a;c++){var s=o[c];if(y(s))r||t.set(i,c,s),u[c]=s;else{var p={parent:i,path:c},f=void 0;r?qt(f=s,p):(f=Ae(s,p),t.set(i,c,f));var l=oe(f);u[c]=l.standard}}return ie(i,u),t.intercept(i,function(t,e){switch(L(),e.type){case"splice":for(var n=0;n<e.removedCount;n++)Ae(e.object[e.index+n],void 0);for(var r=0;r<e.added.length;r++)e.added[r]=Ae(e.added[r],{parent:e.object,path:e.index+r});var o=e.index+e.removedCount,a=e.index+e.added.length;if(o!==a)for(var i=o,u=a;i<e.object.length;i++,u++)qt(e.object[i],{parent:e.object,path:u},!0);break;case"update":Ae(t[e.index],void 0),e.newValue=Ae(e.newValue,{parent:t,path:e.index})}return e}.bind(void 0,i)),t.observe(i,de),i}function de(t){var e=t.object,n=oe(e).standard,r=new Xt;switch(n=n.slice(),t.type){case"splice":var o,a=[],i=t.addedCount;a.length=i;for(var u=0;u<i;u++){var c=t.added[u];a[u]=y(c)?c:oe(c).standard}for(var s=n.length,p=t.removedCount,f=(o=n).splice.apply(o,[t.index,p].concat(a)),l=[],d=[],h=Math.min(p,i),v=0;v<h;v++){var m=f[v],b=a[v];if(m!==b){var g=[t.index+v];l.push({op:"replace",path:g,value:b}),d.push({op:"replace",path:g,value:m})}}if(p>i){l.push({op:"replace",path:["length"],value:n.length});for(var x=h;x<p;x++)d.push({op:"add",path:[t.index+x],value:f[x]})}else if(i>p){for(var w=h;w<i;w++)l.push({op:"add",path:[t.index+w],value:a[w]});d.push({op:"replace",path:["length"],value:s})}r.record(l,d);break;case"update":var A=t.index,S=t.newValue,k=n[A];if(y(S))n[A]=S;else{var C=oe(S);n[A]=C.standard}var T=[A];r.record([{op:"replace",path:T,value:n[A]}],[{op:"replace",path:T,value:k}])}fe(e,r),Q||(ie(e,n),r.emit(e))}var he={deep:!1};function ve(t,e){return U.add(t),qt(t,e),t}function ye(e,n,r,o){var a=e,i=t.isObservableObject(a)?a:t.observable.object({},void 0,me);U.add(i),qt(i,n);for(var u={},c=Object.keys(a),s=c.length,p=0;p<s;p++){var f=c[p],l=a[f];if(y(l))o||t.set(i,f,l),u[f]=l;else{var d={parent:i,path:f},h=void 0;o?qt(h=l,d):(h=Ae(l,d),t.set(i,f,h));var v=oe(h);u[f]=v.standard}}return r&&(u[j]=r),ie(i,u),t.intercept(i,ge),t.observe(i,be),i}var me={deep:!1};function be(t){var e=t.object,n=oe(e).standard,r=new Xt;switch(n=Object.assign({},n),t.type){case"add":case"update":var o=t.name,a=t.newValue,i=n[o];if(y(a))n[o]=a;else{var u=oe(a);n[o]=u.standard}var c=[o];"add"===t.type?r.record([{op:"add",path:c,value:n[o]}],[{op:"remove",path:c}]):r.record([{op:"replace",path:c,value:n[o]}],[{op:"replace",path:c,value:i}]);break;case"remove":var s=t.name,p=n[s];delete n[s];var f=[s];r.record([{op:"remove",path:f}],[{op:"add",path:f,value:p}])}fe(e,r),Q||(ie(e,n),r.emit(e))}function ge(t){if(L(),"symbol"==typeof t.name)throw d("symbol properties are not supported.");switch(t.type){case"add":t.newValue=Ae(t.newValue,{parent:t.object,path:""+t.name});break;case"remove":Ae(t.object[t.name],void 0);break;case"update":Ae(t.object[t.name],void 0),t.newValue=Ae(t.newValue,{parent:t.object,path:""+t.name})}return t}function xe(e,n){if(y(e))return e;if(W(e))return qt(e,n),e;if(e instanceof ke)return function(t,e){var n;return U.add(t),qt(t,e),ie(t,((n={})[Se]=!0,n.data=t.data,n)),t}(e,n);if(function(t){if(v(t)&&t[j])return P(t[j])}(e))return ve(e,n);if(Array.isArray(e)||t.isObservableArray(e))return le(e,n,!1);if(t.isObservableObject(e)||h(e))return ye(e,n,void 0,!1);if(b(e))throw d("maps are not supported");if(g(e))throw d("sets are not supported");throw d("tweak can only work over models, observable objects/arrays, or primitives, but got "+e+" instead")}var we,Ae=t.action("tweak",xe);(we=exports.FrozenCheckMode||(exports.FrozenCheckMode={})).DevModeOnly="devModeOnly",we.On="on",we.Off="off";var Se="$frozen",ke=function(t,e){void 0===e&&(e=exports.FrozenCheckMode.DevModeOnly);var n=e===exports.FrozenCheckMode.On||e===exports.FrozenCheckMode.DevModeOnly&&!1;n&&function t(e){if(!y(e))if(Array.isArray(e)){for(var n=e.length,r=0;r<n;r++){var o=e[r];if(void 0===o)throw d("undefined is not supported inside arrays since it is not serializable in JSON, consider using null instead");t(o)}Object.freeze(e)}else{if(!h(e))throw d("frozen data must be plainly serializable to JSON, but "+e+" is not");for(var a=Object.keys(e),i=a.length,u=0;u<i;u++){var c=a[u],s=e[c];t(c),t(s)}Object.freeze(e)}}(t),this.data=t,n&&Object.freeze(this.data),Ae(this,void 0)};function Ce(t,e){return void 0===e&&(e=exports.FrozenCheckMode.DevModeOnly),new ke(t,e)}function Te(t){return h(t)&&!!t[Se]}function Oe(e){if(y(e))return e;if(b(e))throw d("a snapshot might not contain maps");if(g(e))throw d("a snapshot might not contain sets");if(x(e))return function(e){for(var n=t.observable.array([],Re),r=e.length,o=0;o<r;o++)n.push(Oe(e[o]));return le(n,void 0,!0)}(e);if(Te(e))return Ce(e.data);if(At(e))return function(t){var e=t[j];if(!e)throw d("a model a snapshot must contain a type key ("+j+"), but none was found");var n=P(e);if(!n)throw d('model with name "'+e+'" not found in the registry');return new n.class(void 0,{unprocessedSnapshot:t,snapshotToInitialData:je})}(e);if(h(e))return function(e){for(var n=t.observable.object({},void 0,Re),r=Object.keys(e),o=r.length,a=0;a<o;a++){var i=r[a];t.set(n,i,Oe(e[i]))}return ye(n,void 0,void 0,!0)}(e);throw d("unsupported snapshot - "+e)}function je(e){for(var n=t.observable.object({},void 0,Re),r=Object.keys(e),o=r.length,a=0;a<o;a++){var i=r[a];R(i)||t.set(n,i,Oe(e[i]))}return n}exports.fromSnapshot=function(t){return Oe(t)},exports.fromSnapshot=t.action("fromSnapshot",exports.fromSnapshot);var Re={deep:!1};function Me(e,n){if(y(n))return n;if(b(n))throw d("a snapshot might not contain maps");if(g(n))throw d("a snapshot might not contain sets");if(x(n))return function(e,n){if(!x(e))return exports.fromSnapshot(n);e.length>n.length&&e.splice(n.length,e.length-n.length);for(var r=0;r<e.length;r++)t.set(e,r,Me(e[r],n[r]));for(var o=e.length;o<n.length;o++)e.push(exports.fromSnapshot(n[o]));return e}(e,n);if(Te(n))return function(t,e){return t instanceof ke&&t.data===e.data?t:Ce(e.data)}(e,n);if(At(n))return function(e,n){var r=n[j],o=P(r);if(!o)throw d('model with name "'+r+'" not found in the registry');if(!(e instanceof o.class)||e.$modelType!==r)return exports.fromSnapshot(n);var a=e,i=n;a.fromSnapshot&&(i=a.fromSnapshot(n));for(var u=a.$,c=Object.keys(u),s=c.length,p=0;p<s;p++){var f=c[p];f in i||t.remove(u,f)}for(var l=Object.keys(i),h=l.length,v=0;v<h;v++){var y=l[v];R(y)||t.set(u,y,Me(u[y],i[y]))}return a}(e,n);if(h(n))return function(e,n){if(!h(e)&&!t.isObservableObject(e))return exports.fromSnapshot(n);for(var r=e,o=Object.keys(r),a=o.length,i=0;i<a;i++){var u=o[i];u in n||t.remove(r,u)}for(var c=Object.keys(n),s=c.length,p=0;p<s;p++){var f=c[p];t.set(r,f,Me(r[f],n[f]))}return r}(e,n);throw d("unsupported snapshot - "+n)}function _e(t,e){B(t,"node"),Ne.call(t,e)}function Pe(e){var n=this;e.forEach(function(e){return function(e,n){var r=function(t,e){if(0===e.length)return{target:t};var n=t;n instanceof yt&&(n=n.$);for(var r=0;r<=e.length-2;r++)(n=n[e[r]])instanceof yt&&(n=n.$);return{target:n,prop:e[e.length-1]}}(e,n.path),o=r.target,a=r.prop;if(x(o))switch(n.op){case"add":o.splice(+a,0,exports.fromSnapshot(n.value));break;case"remove":o.splice(+a,1);break;case"replace":if("length"===a)o.length=n.value;else{var i=+a;t.set(o,i,Me(o[i],n.value))}break;default:throw d("unsupported patch operation: "+n.op)}else switch(n.op){case"add":t.set(o,a,exports.fromSnapshot(n.value));break;case"remove":t.remove(o,a);break;case"replace":t.set(o,a,Me(o[a],n.value));break;default:throw d("unsupported patch operation: "+n.op)}}(n,e)})}var Ne=Pt(exports.BuiltInAction.ApplyPatches,Pe,exports.ActionContextActionType.Sync);function Ee(t,e){B(t,"node"),w(e,"snapshot"),Ie.call(t,e)}function $e(e){var n=this,r=function(){Me(n,e)};if(x(e)){if(!x(n))throw d("if the snapshot is an array the target must be an array too");return r()}if(Te(e))throw d("applySnapshot can not be used over frozen objects");if(At(e)){var o=e[j],a=P(o);if(!a)throw d('model with name "'+o+'" not found in the registry');if(!(n instanceof a.class)||n.$modelType!==o)throw d("snapshot model type does not match target model type");return r()}if(h(e)){if(!h(n)&&!t.isObservableObject(n))throw d("if the snapshot is an object the target must be an object too");return r()}throw d("unsupported snapshot - "+e)}var Ie=Pt(exports.BuiltInAction.ApplySnapshot,$e,exports.ActionContextActionType.Sync);function Fe(t,e){B(t,"subtreeRoot");var n=ot(t,e.targetPath),r=n.value;if(!n.resolved)throw d("object at path "+e.targetPath+" could not be resolved");if(gt(r,"resolved "+e.targetPath),!Ct(e.actionName)){if(Ut(e.actionName))throw d("calls to hooks ("+e.actionName+") cannot be applied");return r[e.actionName].apply(r,e.args)}switch(e.actionName){case exports.BuiltInAction.ApplySnapshot:return Ee.apply(r,[r].concat(e.args));case exports.BuiltInAction.ApplyPatches:return _e.apply(r,[r].concat(e.args));case exports.BuiltInAction.Detach:return Et.apply(r,[r].concat(e.args));default:throw d("assertion error: unknown built-in action - "+e.actionName)}}var De,ze=Symbol("modelFlow");function Ue(t){return"function"==typeof t&&t[ze]}function We(t,e){B(t,"subtreeRoot");var n=Symbol("actionTrackingMiddlewareData");function r(t){return t.data[n]}function o(t,e){var r=t.data[n];r?Object.assign(r,e):t.data[n]=e}var a=function(t){return!e.filter||e.filter(Le(t))},i=!!e.onResume||!!e.onSuspend,u=function(t){if(o(t,{state:"started"}),e.onStart)return e.onStart(t)||void 0},c=function(t,n){var a=t.parentContext,i=!1;if(a){var u=r(a);u&&u.startAccepted&&"suspended"===u.state&&(i=!0,s(a,!1))}return o(t,{state:"finished"}),e.onFinish&&(n=e.onFinish(t,n)||n),i&&p(a),n},s=function t(n,a){var i=n.parentContext;if(i){var u=r(i);u&&u.startAccepted&&"suspended"===u.state&&t(i,!1)}o(n,{state:a?"realResumed":"fakeResumed"}),e.onResume&&e.onResume(n)},p=function t(n){o(n,{state:"suspended"}),e.onSuspend&&e.onSuspend(n);var a=n.parentContext;if(a){var i=r(a);i&&i.startAccepted&&"fakeResumed"===i.state&&t(a)}};return jt({middleware:function(t,e){var n=Le(t),r=e;if(e=function(){s(n,!0);try{return r()}finally{p(n)}},t.type===exports.ActionContextActionType.Sync){var o=u(n);if(o)s(n,!0),p(n),o=c(n,o);else try{o=c(n,{result:exports.ActionTrackingResult.Return,value:e()})}catch(t){o=c(n,{result:exports.ActionTrackingResult.Throw,value:t})}return Ve(o)}switch(t.asyncStepType){case exports.ActionContextAsyncStepType.Spawn:var a=u(n);return a?(s(n,!0),p(n),Ve(a=c(n,a))):e();case exports.ActionContextAsyncStepType.Return:var f=e(),l=c(n,{result:exports.ActionTrackingResult.Return,value:f.value});return f.resolution=l.result===exports.ActionTrackingResult.Return?"accept":"reject",f.value=l.value,f;case exports.ActionContextAsyncStepType.Throw:var h=e(),v=c(n,{result:exports.ActionTrackingResult.Throw,value:h.value});return h.resolution=v.result===exports.ActionTrackingResult.Return?"accept":"reject",h.value=v.value,h;case exports.ActionContextAsyncStepType.Resume:case exports.ActionContextAsyncStepType.ResumeError:if(i)return e();throw d("asssertion error: async step should have been filtered out - "+t.asyncStepType);default:throw d("asssertion error: async step should have been filtered out - "+t.asyncStepType)}},filter:function(t){if(t.type===exports.ActionContextActionType.Sync){var e=a(t);return e&&o(t,{startAccepted:!0,state:"idle"}),e}switch(t.asyncStepType){case exports.ActionContextAsyncStepType.Spawn:var n=a(t);return n&&o(t,{startAccepted:!0,state:"idle"}),n;case exports.ActionContextAsyncStepType.Return:case exports.ActionContextAsyncStepType.Throw:var u=r(t.spawnAsyncStepContext);return!!u&&u.startAccepted;case exports.ActionContextAsyncStepType.Resume:case exports.ActionContextAsyncStepType.ResumeError:if(i){var c=r(t.spawnAsyncStepContext);return!!c&&c.startAccepted}return!1;default:return!1}},subtreeRoot:t})}function Ve(t){if(t.result===exports.ActionTrackingResult.Return)return t.value;throw t.value}(De=exports.ActionTrackingResult||(exports.ActionTrackingResult={})).Return="return",De.Throw="throw";var Be=Symbol("simpleDataContext");function Le(t){for(;t.previousAsyncStepContext;)t=t.previousAsyncStepContext;var e=t.data[Be];if(!e){var n=t.parentContext?Le(t.parentContext):void 0;(e={actionName:t.actionName,type:t.type,target:t.target,args:t.args,data:t.data,parentContext:n}).rootContext=n?n.rootContext:e,t.data[Be]=e}return e}function Qe(t){if(y(t))return t;B(t,"nodeOrPrimitive");var e=oe(t);if(!e)throw d("getSnapshot is not supported for this kind of object");return e.atom.reportObserved(),e.standard}function Ke(t){var e=tt(t.target);return{actionName:t.actionName,args:t.args,targetPath:e.path}}function He(e){if(y(e))return e;if(W(e))return Qe(e);var n=e;if(t.isObservable(e)&&(e=t.toJS(e,{exportMapsAsObjects:!1,detectCycles:!1})),h(e)||Array.isArray(e))return e;throw d("serializeActionCallArgument could not serialize the given value: "+n)}function Je(t){return At(t)?exports.fromSnapshot(t):t}var Ge=t.action("newModel",function(e,n,r,o){wt(n,"modelClass");var a=e,i=_.get(n);if(!i)throw d("no model info for class "+n.name+" could be found - did you forget to add the @model decorator?");if(o){var u=o.unprocessedSnapshot;a.fromSnapshot&&(u=a.fromSnapshot(u)),r=o.snapshotToInitialData(u)}a[j]=i.name;for(var c=a[k],s=Object.keys(c),p=0;p<s.length;p++){var f=s[p];if(void 0===r[f]){var l=void 0,h=c[f];void 0!==h.defaultFn?l=h.defaultFn():void 0!==h.defaultValue&&(l=h.defaultValue),t.set(r,f,l)}}ve(a,void 0);var v,y,m=ye(r,{parent:a,path:"$"},a[j],!1),b=oe(m);if(re.set(a,b),a.$=m,v=a,(y=Object.getOwnPropertyDescriptor(v,"$"))&&(y.enumerable=!0,y.get?delete y.set:y.writable=!1,Object.defineProperty(v,"$",y)),se()&&O(n)){var g=a.typeCheck();g&&g.throw(a)}var x=function(t){return t[T]}(n);return x&&x.forEach(function(t){return t(a)}),a});function qe(t,e){return Xe(t,e)}function Xe(t,e){var n,r=a({recording:!0,filter:Ye},e),o=r.recording,i=r.filter,u=[];return n=t?te(t,function(e,n){o&&i(e,n)&&u.push({target:t,patches:e,inversePatches:n})}):ee(function(t,e,n){o&&i(e,n)&&u.push({target:t,patches:e,inversePatches:n})}),{get recording(){return o},set recording(t){o=t},get events(){return u},dispose:function(){n()}}}var Ye=function(){return!0};function Ze(t){w(t,"target");var e=t.model,n=t.actionName;if(gt(e,"target.model"),"string"!=typeof n)throw d("target.actionName must be a string");var r=Symbol("patchRecorder");function o(t){return t.rootContext.data[r]}return We(e,{filter:function(t){var r=t.rootContext;return r.target===e&&r.actionName===n},onStart:function(t){t===t.rootContext&&function(t){t.rootContext.data[r]=Xe(void 0,{recording:!1})}(t)},onResume:function(t){o(t).recording=!0},onSuspend:function(t){o(t).recording=!1},onFinish:function(t,e){if(t===t.rootContext){var n=o(t);try{if(e.result===exports.ActionTrackingResult.Throw)for(var r=n.events,a=r.length-1;a>=0;a--){var i=r[a];_e(i.target,i.inversePatches)}}finally{n.dispose()}}}})}function tn(t,e){return A(t,"objFn"),ft(function(){var n=t();w(n,"objectSchema");var r=Object.entries(n),o=function(){for(var t=[],e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];for(var a=0,i=r;a<i.length;a++){var u=i[a],c=u[0],s=st(u[1]),p="...";n.includes(s)||(p=s.getTypeName.apply(s,n.concat([s]))),t.push(c+": "+p+";")}return"{ "+t.join(" ")+" }"},a=new ct(function(t,n){if(!v(t)||e&&!(t instanceof ke))return new at(n,o(a),t);for(var i=new Set(Object.keys(t)),u=0,c=r;u<c.length;u++){var s=c[u],p=s[0],f=st(s[1]),l=f.unchecked?null:f.check(t[p],[].concat(n,[p]));if(l)return l;i.delete(p)}return i.size>0?new at(n,o(a),t):null},o);return a})}function en(t){return tn(t,!1)}var nn=new ct(null,function(){return"any"});function rn(){return nn}function on(e){var n;if(w(e,"modelProps"),Object.values(e).some(function(t){return t.typeChecker})){for(var r={},o=0,a=Object.entries(e);o<a.length;o++){var u=a[o];r[u[0]]=u[1].typeChecker||rn()}n=en(function(){return r})}var c={enumerable:!1,writable:!1,configurable:!0,value:e},s={enumerable:!1,writable:!1,configurable:!0,value:n},p={},l=function(){if(h){if(v>=d.length)return"break";y=d[v++]}else{if((v=d.next()).done)return"break";y=v.value}var e=y;p[e]={enumerable:!1,configurable:!0,get:function(){return t.get(this.$,e)},set:function(n){t.set(this.$,e,n)}}},d=Object.keys(e).filter(function(t){return!mt.has(t)}),h=Array.isArray(d),v=0;for(d=h?d:d[Symbol.iterator]();;){var y;if("break"===l())break}var m=function(e){function n(n,r){var o,a=f(o=e.call(this,I)||this);Object.defineProperty(a,k,c),Object.defineProperty(a,C,s),Object.defineProperties(a,p);var i=o.constructor;return r?Ge(f(o),i,void 0,r):(w(n,"initialData"),Ge(f(o),i,t.observable.object(n,void 0,{deep:!1}),void 0)),o}return i(n,e),n}(yt);return m[C]=n,m}var an=function(t){return function(e){var n,r;wt(e,"a model class"),M[t]&&(r="[mobx-keystone] "+(r='a model with name "'+t+'" already exists (if you are using hot-reloading this might be the cause)'),console.error(r));var o=((n={})[e.name]=function(t,n){var r=new e(t,n);return r.onInit&&(Nt(r,"onInit",exports.HookAction.OnInit),r.onInit()),r},n)[e.name];o.prototype=e.prototype,o[T]=e[T];var a={name:t,class:o};return M[t]=a,_.set(o,a),_.set(e,a),o}};function un(t){return ft(function(){var e=st(t),n=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return"Array<"+e.getTypeName.apply(e,n.concat([e]))+">"},r=new ct(function(t,o){if(!x(t))return new at(o,n(r),t);if(!e.unchecked)for(var a=0;a<t.length;a++){var i=e.check(t[a],[].concat(o,[a]));if(i)return i}return null},n);return r})}function cn(t,e){var n="function"==typeof e;return{$valueType:null,$hasDefault:null,defaultFn:n?e:void 0,defaultValue:n?void 0:e,typeChecker:t}}exports.UndoStore=function(t){function e(){return t.apply(this,arguments)||this}i(e,t);var n=e.prototype;return n._clearUndo=function(){var t=this;ln(function(){t.undoEvents.length=0})},n._clearRedo=function(){var t=this;ln(function(){t.redoEvents.length=0})},n._undo=function(){var t=this;ln(function(){var e=t.undoEvents.pop();t.redoEvents.push(e)})},n._redo=function(){var t=this;ln(function(){var e=t.redoEvents.pop();t.undoEvents.push(e)})},n._addUndo=function(t){var e=this;ln(function(){e.undoEvents.push(t),e.redoEvents.length=0})},e}(on({undoEvents:cn(un(rn()),function(){return[]}),redoEvents:cn(un(rn()),function(){return[]})})),e.__decorate([Mt],exports.UndoStore.prototype,"_clearUndo",null),e.__decorate([Mt],exports.UndoStore.prototype,"_clearRedo",null),e.__decorate([Mt],exports.UndoStore.prototype,"_undo",null),e.__decorate([Mt],exports.UndoStore.prototype,"_redo",null),e.__decorate([Mt],exports.UndoStore.prototype,"_addUndo",null),exports.UndoStore=e.__decorate([an("mobx-keystone/UndoStore")],exports.UndoStore);var sn=function(){function t(t,e,n){this.disposer=t,this.subtreeRoot=e,this.store=n||new exports.UndoStore({})}var e=t.prototype;return e.clearUndo=function(){this.store._clearUndo()},e.clearRedo=function(){this.store._clearRedo()},e.undo=function(){var t=this;if(!this.canUndo)throw d("nothing to undo");var e=this.undoQueue[this.undoQueue.length-1];ln(function(){_e(t.subtreeRoot,e.inversePatches)}),this.store._undo()},e.redo=function(){var t=this;if(!this.canRedo)throw d("nothing to redo");var e=this.redoQueue[this.redoQueue.length-1];ln(function(){_e(t.subtreeRoot,e.patches)}),this.store._redo()},e.dispose=function(){this.disposer()},r(t,[{key:"undoQueue",get:function(){return this.store.undoEvents}},{key:"redoQueue",get:function(){return this.store.redoEvents}},{key:"undoLevels",get:function(){return this.undoQueue.length}},{key:"canUndo",get:function(){return this.undoLevels>0}},{key:"redoLevels",get:function(){return this.redoQueue.length}},{key:"canRedo",get:function(){return this.redoLevels>0}}]),t}();e.__decorate([t.computed],sn.prototype,"undoQueue",null),e.__decorate([t.computed],sn.prototype,"redoQueue",null),e.__decorate([t.computed],sn.prototype,"undoLevels",null),e.__decorate([t.computed],sn.prototype,"canUndo",null),e.__decorate([t.action],sn.prototype,"clearUndo",null),e.__decorate([t.computed],sn.prototype,"redoLevels",null),e.__decorate([t.computed],sn.prototype,"canRedo",null),e.__decorate([t.action],sn.prototype,"clearRedo",null),e.__decorate([t.action],sn.prototype,"undo",null),e.__decorate([t.action],sn.prototype,"redo",null);var pn=!1,fn=function(){return!pn};function ln(t){var e=pn;pn=!0;try{return t()}finally{pn=e}}function dn(e,n){B(e,"node");var r=Qe(e);return t.reaction(function(){return Qe(e)},function(t){var e=r;r=t,n(t,e)})}function hn(t,e,n){return ft(function(){var r=st(t),o=function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];var a=r.getTypeName.apply(r,e.concat([r]));return(n||"refinementOf")+"<"+a+">"},a=new ct(function(t,n){var i=r.check(t,n);if(i)return i;var u=e(t);return!0===u?null:!1===u?new at([],o(a),t):u||null},o);return a})}function vn(t){var e;switch(function(e,n){if(!y(t))throw d("literal must be a primitive")}(),t){case void 0:e="undefined";break;case null:e="null";break;default:e=JSON.stringify(t)}return new ct(function(n,r){return n===t?null:new at(r,e,n)},function(){return e})}var yn=vn(void 0),mn=vn(null),bn=new ct(function(t,e){return"boolean"==typeof t?null:new at(e,"boolean",t)},function(){return"boolean"}),gn=new ct(function(t,e){return"number"==typeof t?null:new at(e,"number",t)},function(){return"number"}),xn=new ct(function(t,e){return"string"==typeof t?null:new at(e,"string",t)},function(){return"string"}),wn=hn(gn,function(t){return Number.isInteger(t)},"integer"),An=hn(xn,function(t){return""!==t},"nonEmpty"),Sn=function(t){function e(){return t.apply(this,arguments)||this}return i(e,t),r(e,[{key:"maybeCurrent",get:function(){return this.resolve()}},{key:"isValid",get:function(){return!!this.maybeCurrent}},{key:"current",get:function(){var t=this.maybeCurrent;if(!t)throw d("a reference of type '"+this.$modelType+"' could not resolve an object with id '"+this.id+"'");return t}}]),e}(on({id:cn(xn)}));function kn(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ft(function(){var t=e.map(st);if(t.some(function(t){return t.unchecked}))return rn();var n=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.map(function(t){return n.includes(t)?"...":t.getTypeName.apply(t,n.concat([t]))}).join(" | ")},r=new ct(function(e,o){return t.every(function(t){return!!t.check(e,o)})?new at(o,n(r),e):null},n);return r})}function Cn(t){return ft(function(){var e=st(t),n=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return"Record<"+e.getTypeName.apply(e,n.concat([e]))+">"},r=new ct(function(t,o){if(!v(t))return new at(o,n(r),t);if(!e.unchecked)for(var a=Object.keys(t),i=0;i<a.length;i++){var u=a[i],c=e.check(t[u],[].concat(o,[u]));if(c)return c}return null},n);return r})}e.__decorate([t.computed],Sn.prototype,"maybeCurrent",null),e.__decorate([t.computed],Sn.prototype,"isValid",null),e.__decorate([t.computed],Sn.prototype,"current",null),exports.ArraySet=function(e){function n(){return e.apply(this,arguments)||this}i(n,e);var o=n.prototype;return o.add=function(t){var e=this.items;return e.includes(t)||e.push(t),this},o.clear=function(){this.items.length=0},o.delete=function(t){var e=this.items,n=e.findIndex(function(e){return e===t});return n>=0&&(e.splice(n,1),!0)},o.forEach=function(t,e){var n=this;this.items.forEach(function(r){t.call(e,r,r,n)})},o.has=function(t){return this.items.includes(t)},o.keys=function(){return this.values()},o.values=function(){return t.values(this.items)[Symbol.iterator]()},o.entries=function(){return this.items.map(function(t){return[t,t]}).values()},o[Symbol.iterator]=function(){return this.values()},r(n,[{key:"size",get:function(){return this.items.length}},{key:Symbol.toStringTag,get:function(){return"ArraySet"}}]),n}(on({items:cn(un(rn()),function(){return[]})})),e.__decorate([Mt],exports.ArraySet.prototype,"add",null),e.__decorate([Mt],exports.ArraySet.prototype,"clear",null),e.__decorate([Mt],exports.ArraySet.prototype,"delete",null),exports.ArraySet=e.__decorate([an("mobx-keystone/ArraySet")],exports.ArraySet),exports.ObjectMap=function(e){function n(){return e.apply(this,arguments)||this}i(n,e);var o=n.prototype;return o.clear=function(){var e=this.items;Object.keys(e).forEach(function(n){t.remove(e,n)})},o.delete=function(e){return!!this.has(e)&&(t.remove(this.items,e),!0)},o.forEach=function(t,e){var n=this,r=this.items;Object.keys(r).forEach(function(o){t.call(e,r[o],o,n)})},o.get=function(e){return t.get(this.items,e)},o.has=function(e){return t.has(this.items,e)},o.set=function(e,n){return t.set(this.items,e,n),this},o.keys=function(){return t.keys(this.items)[Symbol.iterator]()},o.values=function(){return t.values(this.items)[Symbol.iterator]()},o.entries=function(){return t.entries(this.items)[Symbol.iterator]()},o[Symbol.iterator]=function(){return this.entries()},r(n,[{key:"size",get:function(){return t.keys(this.items).length}},{key:Symbol.toStringTag,get:function(){return"ObjectMap"}}]),n}(on({items:cn(Cn(rn()),function(){return{}})})),e.__decorate([Mt],exports.ObjectMap.prototype,"clear",null),e.__decorate([Mt],exports.ObjectMap.prototype,"delete",null),e.__decorate([Mt],exports.ObjectMap.prototype,"set",null),exports.ObjectMap=e.__decorate([an("mobx-keystone/ObjectMap")],exports.ObjectMap);var Tn=en(function(){return{id:xn}}),On=new ct(function(t,e){return t instanceof Sn?st(Tn).check(t.$,[].concat(e,["$"])):new at(e,"Ref",t)},function(){return"Ref"}),jn={literal:vn,undefined:yn,null:mn,boolean:bn,number:gn,string:xn,or:kn,maybe:function(t){return kn(t,yn)},maybeNull:function(t){return kn(t,mn)},array:un,record:Cn,unchecked:rn,model:dt,object:en,ref:function(){return On},frozen:function(t){return tn(function(){return{data:t}},!0)},enum:function(t){w(t,"enumObject");var e=function(t){for(var e=[],n=0,r=Object.keys(t);n<r.length;n++){var o=r[n],a=t[o];"string"==typeof a&&t[a]===+o||e.push(a)}return e}(t).map(function(t){return vn(t)});return kn.apply(void 0,e)},refinement:hn,integer:wn,nonEmptyString:An,objectMap:function(t){return ft(function(){var e=st(t),n=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return"ObjectMap<"+e.getTypeName.apply(e,n.concat([e]))+">"},r=new ct(function(t,o){return t instanceof exports.ObjectMap?st(en(function(){return{items:Cn(e)}})).check(t.$,[].concat(o,["$"])):new at(o,n(r),t)},n);return r})},arraySet:function(t){return ft(function(){var e=st(t),n=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return"ArraySet<"+e.getTypeName.apply(e,n.concat([e]))+">"},r=new ct(function(t,o){return t instanceof exports.ArraySet?st(en(function(){return{items:un(e)}})).check(t.$,[].concat(o,["$"])):new at(o,n(r),t)},n);return r})}};exports.BaseModel=yt,exports.Frozen=ke,exports.MobxDataModelError=l,exports.Model=on,exports.Ref=Sn,exports.TypeCheckError=at,exports.UndoManager=sn,exports.actionCallToReduxAction=function(t){return{type:"applyAction",payload:t}},exports.actionTrackingMiddleware=We,exports.addActionMiddleware=jt,exports.applyAction=Fe,exports.applyPatches=_e,exports.applySnapshot=Ee,exports.arrayAsMap=function(t){var e,n,r,a=((n={clear:function(){t().length=0},delete:function(e){var n=t(),r=n.findIndex(function(t){return t[0]===e});return r>=0&&(n.splice(r,1),!0)},forEach:function(e,n){t().forEach(function(t){e.call(n,t[1],t[0],a)})},get:function(e){var n=t().find(function(t){return t[0]===e});return n?n[1]:void 0},has:function(e){return t().some(function(t){return t[0]===e})},set:function(e,n){var r=t(),o=r.find(function(t){return t[0]===e});return o?o[1]=n:r.push([e,n]),a},get size(){return t().length},keys:function(){return t().map(function(t){return t[0]})[Symbol.iterator]()},values:function(){return t().map(function(t){return t[1]})[Symbol.iterator]()},entries:function(){return t().map(function(t){return[t[0],t[1]]})[Symbol.iterator]()}})[Symbol.iterator]=function(){return a.entries()},(r={})[e=Symbol.toStringTag]=r[e]||{},r[e].get=function(){return"Map"},o(n,r),n);return a},exports.arrayAsSet=function(e){var n,r,a,i=((r={add:function(t){var n=e();return n.includes(t)||n.push(t),i},clear:function(){e().length=0},delete:function(t){var n=e(),r=n.findIndex(function(e){return e===t});return r>=0&&(n.splice(r,1),!0)},forEach:function(t,n){e().forEach(function(e){t.call(n,e,e,i)})},has:function(t){return e().includes(t)},get size(){return e().length},keys:function(){return i.values()},values:function(){var n=e();return t.values(n)[Symbol.iterator]()},entries:function(){return e().map(function(t){return[t,t]}).values()}})[Symbol.iterator]=function(){return i.values()},(a={})[n=Symbol.toStringTag]=a[n]||{},a[n].get=function(){return"Set"},o(r,a),r);return i},exports.arraySet=function(t){var e=t?t.slice():[];return new exports.ArraySet({items:e})},exports.asReduxStore=function(t){B(t,"target");for(var e=function(e){if("applyAction"!==e.type)throw d("action type was expected to be 'applyAction', but it was '"+e.type+"'");return Fe(t,e.payload),e},n={getState:function(){return Qe(t)},dispatch:function(t){return function(e,n,r){var o=0;return function t(e){var a=n[o];return o++,a?a(t)(e):r(e)}(t)}(0,i,e)},subscribe:function(e){return dn(t,e)}},r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var i=o.map(function(t){return t(n)});return n},exports.clone=function(t){B(t,"node");var e=Qe(t);return exports.fromSnapshot(e)},exports.connectReduxDevTools=function(t,e,n,r){var o=a({logArgsNearName:!0},r),i=0;e.subscribe(function(r){"DISPATCH"===r.type&&function(e,n,r){try{switch(i++,r.payload.type){case"RESET":return Ee(n,u),e.init(u);case"COMMIT":return e.init(Qe(n));case"ROLLBACK":return e.init(t.extractState(r));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return void Ee(n,t.extractState(r));case"IMPORT_STATE":var o=r.payload.nextLiftedState,a=o.computedStates;Ee(n,a[a.length-1].state),e.send(null,o)}}finally{i--}}(e,n,r)});var u=Qe(n);e.init(u);var c=0,s=Symbol("actionId");We(n,{onStart:function(t){t.data[s]=c++},onResume:function(t){t.parentContext&&f(t.parentContext,void 0),f(t,void 0)},onSuspend:function(t){f(t,void 0)},onFinish:function(t,e){f(t,e.result)}});var p=u;function f(t,r){if(!i){var a=Qe(n);if(a!==p||r===exports.ActionTrackingResult.Throw){p=a;var u=tt(t.target),c=function t(e,n,r){var a="[/"+n.path.join("/")+"] "+e.actionName;if(o.logArgsNearName){var i=e.args.map(function(t){try{return JSON.stringify(t)}catch(t){return"**unserializable**"}}).join(", ");i.length>64&&(i=i.slice(0,64)+"..."),a+="("+i+")"}var u=e.data[s];if(a+=" (id "+(void 0!==u?u:"?"),e.type===exports.ActionContextActionType.Async&&(a+=", async"),a+=")",r===exports.ActionTrackingResult.Throw&&(a+=" -error thrown-"),e.parentContext){var c=t(e.parentContext,tt(e.parentContext.target),void 0);c&&(a=c+" >>> "+a)}return a}(t,u,r);e.send({type:c,path:u.path,args:t.args},a)}}}},exports.customRef=function(n,r){var o=function(t){function e(){return t.apply(this,arguments)||this}return i(e,t),e.prototype.resolve=function(){return r.resolve(this)},e}(Sn);o=e.__decorate([an(n)],o);var a=function(e){var n;"string"==typeof e?n=e:(w(e,"target"),n=r.getId(e));var a=new o({id:n});if(r.onResolvedValueChange){var i=a.maybeCurrent;t.reaction(function(){return a.maybeCurrent},function(t){if(t!==i){var e=i;i=t,r.onResolvedValueChange(a,t,e)}},{fireImmediately:!0})}return a};return a.refClass=o,a},exports.deserializeActionCall=function(t){return a({},t,{args:t.args.map(Je)})},exports.deserializeActionCallArgument=Je,exports.detach=Et,exports.findParent=pe,exports.frozen=Ce,exports.getChildrenObjects=Wt,exports.getCurrentActionContext=F,exports.getGlobalConfig=ce,exports.getModelDataType=O,exports.getParent=Y,exports.getParentPath=X,exports.getRoot=et,exports.getRootPath=tt,exports.getRootStore=function(t){B(t,"node");var e=et(t);return Gt(e)?e:void 0},exports.getSnapshot=Qe,exports.isBuiltInAction=Ct,exports.isChildOfParent=rt,exports.isHookAction=Ut,exports.isModel=bt,exports.isModelAction=Rt,exports.isModelDataObject=Z,exports.isModelFlow=Ue,exports.isParentOfChild=function(t,e){return B(t,"parent"),B(e,"child"),rt(e,t)},exports.isRoot=nt,exports.isRootStore=Gt,exports.isTreeNode=V,exports.model=an,exports.modelAction=Mt,exports.modelFlow=function(t,e,n){return S({target:t,propertyKey:e,baseDescriptor:n},function(t,e){return Ue(e)?e:(function(t,n,r){if("function"!=typeof e)throw d("modelFlow has to be used over functions");St("modelFlow",t,n)}(t.target,t.propertyKey),n=t.propertyKey,r=e,(o=function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];var a,i=this,u=function(t){return function(n){n.previousAsyncStepContext=a,n.spawnAsyncStepContext=a?a.spawnAsyncStepContext:n,n.asyncStepType=t,n.args=e,a=n}},c=!1,s=Pt(n,function(){return c=!0,r.apply(i,e)},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Spawn)).apply(i);if(!c)return s instanceof Promise?s:Promise.resolve(s);var p=s.next.bind(s),f=s.throw.bind(s);return new Promise(function(t,e){function r(r){var o;try{o=Pt(n,p,exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Resume)).call(i,r)}catch(r){return void Pt(n,function(n){return{value:n,resolution:"reject",accepter:t,rejecter:e}},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Throw),!0).call(i,r)}a(o)}function o(r){var o;try{o=Pt(n,f,exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.ResumeError)).call(i,r)}catch(r){return void Pt(n,function(n){return{value:n,resolution:"reject",accepter:t,rejecter:e}},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Throw),!0).call(i,r)}a(o)}function a(c){c&&"function"==typeof c.then?c.then(a,e):c.done?Pt(n,function(n){return{value:n,resolution:"accept",accepter:t,rejecter:e}},exports.ActionContextActionType.Async,u(exports.ActionContextAsyncStepType.Return),!0).call(i,c.value):Promise.resolve(c.value).then(r,o)}r(void 0)})})[ze]=!0,o);var n,r,o})},exports.modelSnapshotInWithMetadata=function(t,e){var n;wt(t,"modelClass"),w(e,"initialData");var r=_.get(t);return a({},e,((n={})[j]=r.name,n))},exports.modelSnapshotOutWithMetadata=function(t,e){var n;wt(t,"modelClass"),w(e,"initialData");var r=_.get(t);return a({},e,((n={})[j]=r.name,n))},exports.modelTypeKey=j,exports.objectAsMap=function(e){var n,r,a,i=((r={clear:function(){var n=e();Object.keys(n).forEach(function(e){t.remove(n,e)})},delete:function(n){var r=e();return!!i.has(n)&&(t.remove(r,n),!0)},forEach:function(t,n){var r=e();Object.keys(r).forEach(function(e){t.call(n,r[e],e,i)})},get:function(n){var r=e();return t.get(r,n)},has:function(n){var r=e();return t.has(r,n)},set:function(n,r){var o=e();return t.set(o,n,r),i},get size(){var n=e();return t.keys(n).length},keys:function(){var n=e();return t.keys(n)[Symbol.iterator]()},values:function(){var n=e();return t.values(n)[Symbol.iterator]()},entries:function(){var n=e();return t.entries(n)[Symbol.iterator]()}})[Symbol.iterator]=function(){return i.entries()},(a={})[n=Symbol.toStringTag]=a[n]||{},a[n].get=function(){return"Map"},o(r,a),r);return i},exports.objectMap=function(t){var e={};if(t)for(var n=t.length,r=0;r<n;r++){var o=t[r];e[o[0]]=o[1]}return new exports.ObjectMap({items:e})},exports.onActionMiddleware=function(t,e){return B(t,"subtreeRoot"),w(e,"listeners"),We(t,{filter:function(t){return!t.parentContext&&!Ut(t.actionName)},onStart:function(t){if(e.onStart){var n=Ke(t);return e.onStart(n,t)}},onFinish:function(t,n){if(e.onFinish){var r=Ke(t);return e.onFinish(r,t,n)}}})},exports.onGlobalPatches=ee,exports.onPatches=te,exports.onSnapshot=dn,exports.patchRecorder=qe,exports.prop=function(t){var e="function"==typeof t;return{$valueType:null,$hasDefault:null,defaultFn:e?t:void 0,defaultValue:e?void 0:t,typeChecker:null}},exports.readonlyMiddleware=function(t){B(t,"subtreeRoot");var e=!1;return{dispose:We(t,{filter:function(t){return!t.parentContext&&!Ut(t.actionName)},onStart:function(t){return e?void 0:{result:exports.ActionTrackingResult.Throw,value:d("tried to invoke action '"+t.actionName+"' over a readonly node")}}}),allowWrite:function(t){var n=e;e=!0;try{return t()}finally{e=n}}}},exports.reduxActionType="applyAction",exports.registerRootStore=Ht,exports.resolvePath=ot,exports.runUnprotected=function(e,n){var r="string"==typeof e?e:void 0,o="string"==typeof e?n:e,a=z;z=!1;try{return r?t.runInAction(r,o):t.runInAction(o)}finally{z=a}},exports.serializeActionCall=function(t){return a({},t,{args:t.args.map(He)})},exports.serializeActionCallArgument=He,exports.setGlobalConfig=function(t){ue=Object.freeze(a({},ue,{},t))},exports.simplifyActionContext=Le,exports.tProp=cn,exports.toTreeNode=function(t){if(!v(t))throw d("only objects can be turned into tree nodes");return V(t)?t:Ae(t,void 0)},exports.transaction=function(t,e){var n,r,o;St("transaction",t,e),r=function(t){Ze({model:t,actionName:e})},(o=(n=t.constructor)[T])||(n[T]=o=[]),o.push(r)},exports.transactionMiddleware=Ze,exports.typeCheck=ht,exports.types=jn,exports.undoMiddleware=function(t,e){B(t,"subtreeRoot");var n,r=Symbol("patchRecorder");function o(t){return t.rootContext.data[r]}var a=We(t,{onStart:function(e){e===e.rootContext&&function(e){e.rootContext.data[r]=qe(t,{recording:!1,filter:fn})}(e)},onResume:function(t){o(t).recording=!0},onSuspend:function(t){o(t).recording=!1},onFinish:function(t){if(t===t.rootContext){var e=o(t);if(e.events.length>0){var r=[],a=[],i=e.events,u=Array.isArray(i),c=0;for(i=u?i:i[Symbol.iterator]();;){var s;if(u){if(c>=i.length)break;s=i[c++]}else{if((c=i.next()).done)break;s=c.value}var p=s;r.push.apply(r,p.patches),a.unshift.apply(a,p.inversePatches)}n.store._addUndo({targetPath:tt(t.target).path,actionName:t.actionName,patches:r,inversePatches:a})}e.dispose()}}});return n=new sn(a,t,e)},exports.unregisterRootStore=Jt,exports.walkTree=Vt,exports.withoutUndo=ln; | ||
//# sourceMappingURL=mobx-keystone.cjs.production.min.js.map |
{ | ||
"name": "mobx-keystone", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more", | ||
@@ -41,7 +41,7 @@ "keywords": [ | ||
"peerDependencies": { | ||
"mobx": "^5.9.4" | ||
"mobx": "^5.0.0 || ^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.12", | ||
"mobx": "^5.9.4", | ||
"mobx": "^5.0.0", | ||
"shx": "^0.3.2", | ||
@@ -48,0 +48,0 @@ "spec.ts": "^1.1.3", |
@@ -51,3 +51,4 @@ # mobx-keystone | ||
- Proxies | ||
- Mobx 4 (with its gotchas) or 5 (recommended) | ||
- Proxies (when using mobx 5+) | ||
- Symbols | ||
@@ -54,0 +55,0 @@ - WeakMap/WeakSet |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1440803
69
13992