Comparing version 23.0.0-rc.3 to 23.0.0-rc.4
@@ -7,2 +7,4 @@ const defaultFactories = [ | ||
'atomic-router', | ||
'@withease/factories', | ||
'patronum' // there is also custom handling for patronum/{method} imports | ||
] | ||
@@ -333,3 +335,7 @@ | ||
normalizedSource = stripExtension(normalizedSource) | ||
if (this.effector_factoryPaths.includes(normalizedSource)) { | ||
if ( | ||
this.effector_factoryPaths.includes(normalizedSource) | ||
// custom handling for patronum/{method} imports | ||
|| normalizedSource.startsWith('patronum/') | ||
) { | ||
this.effector_needFactoryImport = true | ||
@@ -336,0 +342,0 @@ createFactoryTemplate() |
@@ -1,2 +0,2 @@ | ||
'use strict';function e(e,r){for(var n in e)r(e[n],n)}function r(e,r){e.forEach(r)}function n(e,r){if(!e)throw Error(r)}function t(e,r){var n=O(e).meta||{};ne={id:O(e).id,parent:ne,value:e,template:n.template||ae(),sidRoot:n.sidRoot||ne&&ne.sidRoot,meta:n};try{return r()}finally{te('region'),ne=q(ne)}}function a(e){var n=void 0===e?{}:e,t=n.node,a=void 0===t?[]:t,i=n.parent,o=n.child,u=void 0===o?n.to||n.target:o,s=n.scope,f=void 0===s?{}:s,c=n.meta,d=void 0===c?{}:c,l=n.family,p=void 0===l?{type:'regular'}:l,v=n.regional,m=ue(void 0===i?n.from||n.source:i),g=ue(p.links),h=ue(p.owners),y=[];r(a,(function(e){return e&&K(y,e)}));var b={id:ee(),seq:y,next:ue(u),meta:d,scope:f,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return K(z(e),b)})),r(h,(function(e){return K(C(e),b)})),r(m,(function(e){return K(e.next,b)})),v&&ne&&oe(I(ne),[b]),b}function i(e,n,t){var a,i=Ge,o=null,u=De;if(e.target&&(n=e.params,t=e.defer,a=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),u=D(e)||u,e=e.target),u&&De&&u!==De&&(De=null),Array.isArray(e))for(var s=0;s<e.length;s++)Ee('pure',i,O(e[s]),o,n[s],u,a);else Ee('pure',i,O(e),o,n,u,a);if(!t||Le){var f,c,d,l,p,v,m={isRoot:Le,currentPage:Ge,scope:De,isWatch:Be,isPure:We};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,Ge=p=n.page,De=D(n),p?v=p.reg:De&&(v=De.reg);var a=!!p,i=!!De,o={fail:0,scope:d.scope};f=c=0;for(var u=e;u<d.seq.length&&!f;u++){var s=d.seq[u];if(s.order){var g=s.order,h=g.priority,y=g.barrierID,b=y?p?p.fullID+"_"+y:y:0;if(u!==e||t!==h)return y?Ve.has(b)||(Ve.add(b),Pe(u,n,h,y)):Pe(u,n,h),"continue|kernelLoop";y&&Ve.delete(b)}switch(s.type){case'mov':var k=s.data,w=void 0;switch(k.from){case j:w=I(n);break;case"a":case'b':w=n[k.from];break;case"value":w=k.store;break;case"store":if(v&&!v[k.store.id])if(a){var x=$e(p,k.store.id);n.page=p=x,x?v=x.reg:i?(Qe(De,k.store,0,1,k.softRead),v=De.reg):v=void 0}else i&&Qe(De,k.store,0,1,k.softRead);w=ze(v&&v[k.store.id]||k.store)}switch(k.to){case j:n.value=w;break;case"a":case'b':n[k.to]=w;break;case"store":Je(p,De,d,k.target).current=w}break;case'compute':var S=s.data;if(S.fn){Be='watch'===F(d,'op'),We=S.pure;var M=S.safe?(0,S.fn)(I(n),o.scope,n):Xe(o,S.fn,n);S.filter?c=!M:n.value=M,Be=m.isWatch,We=m.isPure}}f=o.fail||c}if(Fe&&Fe(n,o),!f){var A=I(n),O=D(n);if(r(d.next,(function(e){Ee('child',p,e,n,A,O)})),O){F(d,'needFxCounter')&&Ee('child',p,O.fxCount,n,A,O),F(d,'storeChange')&&Ee('child',p,O.storeChange,n,A,O),F(d,'warnSerialize')&&Ee('child',p,O.warnSerializeNode,n,A,O);var z=O.additionalLinks[d.id];z&&r(z,(function(e){Ee('child',p,e,n,A,O)}))}}};l=_e();)g();Le=m.isRoot,Ge=m.currentPage,De=D(m)}}function o(r,n){void 0===n&&(n='combine');var t=n+'(',a='',i=0;return e(r,(function(e){i<25&&(null!=e&&(t+=a,t+=P(e)?E(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=E(r);0===e.length?(n=i.path,t=i.fullName):(n=i.path.concat([e]),t=0===i.fullName.length?e:i.fullName+'/'+e)}else n=0===e.length?[]:[e],t=e;return{shortName:a,fullName:t,path:n}}function s(e,r){var n=r?e:e[0];de(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(se(i)&&'and'in i){var o=s(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function f(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}function c(e){var r=ae();if(r){for(var n=r.handlers[e],t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];if(n)return n.apply(void 0,[r].concat(a))}}function d(e,r,n,t){var a=Ge,i=null;if(r)for(i=Ge;i&&i.template!==r;)i=q(i);Ue(i);var o=e.create(n,t);return Ue(a),o}function l(e,r){var t=Ye({or:r,and:'string'==typeof e?{name:e}:e}),o=function e(r){n(!F(e,'derived'),'call of derived event is not supported, use createEvent instead'),n(!We,'unit call from pure function is not supported, use operators like sample instead');for(var t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];return Ge?d(e,u,r,a):e.create(r,a)},u=ae(),s=Object.assign(o,{graphite:a({meta:ur(t.actualOp||"event",o,t),regional:1}),create:function(e){return i({target:o,params:e,scope:De}),e},watch:function(e){return ir(o,e)},map:function(e){return sr(o,A,e,[Ae()])},filter:function(e){return sr(o,"filter",e.fn?e:e.fn,[Ae(he,1)])},filterMap:function(e){return sr(o,'filterMap',e,[Ae(),Se((function(e){return!ce(e)}),1)])},prepend:function(e){n(o.targetable,'.prepend of derived event is not supported, call source event instead');var r=l('* \u2192 '+o.shortName,{parent:q(o)});return c('eventPrepend',O(r)),ar(r,o,[Ae()],'prepend',e),or(o,r),r}});return null!=t&&t.domain&&t.domain.hooks.event(s),_(s,'id',s.graphite.id),te(s.graphite),s}function p(e,t,a,i){return pe(a,t,'first argument'),n(fe(i),'second argument should be a function'),Q(!F(e,'derived'),t+" in derived store",t+" in store created via createStore"),r(Array.isArray(a)?a:[a],(function(r){e.off(r),R(e).set(r,tr(cr(r,e,'on',ge,i)))})),e}function v(e,t){var o=Ye(t),u=Oe(e),s=l({named:'updates',derived:1});c('storeBase',u);var f=u.id,d='skipVoid'in o,m=d&&!o.skipVoid;Q(!(d&&o.skipVoid),'{skipVoid: true}','updateFilter');var g={subscribers:new Map,updates:s,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(Ge){for(var n=Ge;n&&!n.reg[f];)n=q(n);n&&(e=n)}return!e&&De&&(Qe(De,u,1),e=De),e&&(r=e.reg[f]),ze(r)},setState:function(e){return i({target:g,params:e,defer:1,scope:De})},reset:function(){n(g.targetable,'.reset of derived store is not supported');for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r(t,(function(e){return p(g,'.reset',e,(function(){return g.defaultState}))})),g},on:function(e,r){return n(g.targetable,'.on of derived store is not supported'),p(g,'.on',e,r)},off:function(e){var r=R(g).get(e);return r&&(r(),R(g).delete(e)),g},map:function(e,r){var n,t;se(e)&&(n=e,e=e.fn);var a=g.getState(),i=ce(a);ae()?t=null:(!i||i&&m)&&(t=e(a));var o=v(t,Object.assign({name:g.shortName+" \u2192 *",derived:1},r,{and:n})),s=cr(g,o,A,he,e);return Ce(N(o),{type:A,fn:e,from:u}),N(o).noInit=1,c('storeMap',u,s),o},watch:function(e,r){if(Q(!r,'watch second argument','sample'),!r||!P(e)){var t=ir(g,e);return c('storeWatch',u,e)||e(g.getState()),t}return n(fe(r),'second argument should be a function'),e.watch((function(e){return r(g.getState(),e)}))}},h=ur("store",g,o),y=g.defaultConfig.updateFilter;g.graphite=a({scope:{state:u,fn:y},node:[Se((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),Me(u),Se((function(e,r,n){var t=n.a,a=n.b,i=ce(e);return i&&!d&&console.error(fr),(i&&m||!i)&&(e!==t||a)}),1),y&&Ae(me,1),ke({from:j,target:u})],child:s,meta:Object.assign({},h,{defaultState:e}),regional:1}),_(g,'id',g.graphite.id),_(g,'rootStateRefId',f);var b=F(g,'serialize'),k=F(g,'derived'),w='ignore'===b,x=F(g,'sid');x&&(_(g,'storeChange',1),u.sid=x),x||w||k||_(g,'warnSerialize',1);var S=ce(e);return n(k||!S||S&&m,fr),k&&S&&!d&&console.error(fr),oe(g,[s]),null!=o&&o.domain&&o.domain.hooks.store(g),k||(g.reinit=l({named:'reinit'}),g.reset(g.reinit)),u.meta=g.graphite.meta,te(g.graphite),g}function m(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=s(r);o=u[1];var f,c,d,l=(r=u[0])[r.length-1],p=!V(l)&&se(l),v=p&&l,m=p?r[r.length-2]:l;if(fe(m)?(i=r.slice(0,p?-2:-1),a=m):i=r,1===i.length){var g=i[0];V(g)||(f=g,c=1)}if(!c&&(f=i,a)){d=1;var h=a;a=function(e){return h.apply(void 0,e)}}return n(se(f),'shape should be an object'),dr(Array.isArray(f),!d,f,o,a,v)}function g(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function h(e,r){void 0===r&&(r={});var t=Ye(fe(e)?{handler:e}:e,r),o=l(fe(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),u=O(o);_(u,'op',o.kind="effect"),o.use=function(e){return n(fe(e),'.use argument should be a function'),m.scope.handler=e,o},o.use.getCurrent=function(){return m.scope.handler};var s=o.finally=l({named:'finally',derived:1}),f=o.done=s.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),c=o.fail=s.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),d=o.doneData=f.map({named:'doneData',fn:function(e){return e.result}}),p=o.failData=c.map({named:'failData',fn:function(e){return e.error}}),m=a({scope:{handler:o.defaultConfig.handler||function(){return n(0,"no handler used in "+o.getType())}},node:[Se((function(e,r,n){var t=r.handler,a=D(n);if(a){var i=a.handlers.unitMap.get(o)||a.handlers.sidMap[o.sid];i&&(t=i)}return e.handler=t,e}),0,1),Se((function(e,r,n){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,f=pr(t,a,1,s,n),c=pr(t,a,0,s,n),d=lr(i,c,u),l=d[1];d[0]&&(se(l)&&fe(l.then)?l.then(f,c):f(l))}),0,1)],meta:{op:'fx',fx:'runner'}});u.scope.runner=m,K(u.seq,Se((function(e,r,n){var t=r.runner,a=q(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:re()}),i({target:t,params:a,defer:1,scope:D(n),meta:n.meta}),a.params}))),o.create=function(e){var r=g(),n={params:e,req:r};if(De&&!Be){var t=De;r.req.finally((function(){He(t)})).catch((function(){}))}return i({target:o,params:n,scope:De}),r.req};var h=o.inFlight=v(0,{serialize:'ignore',named:(F(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(function(e){return e+1})).on(s,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});_(s,'needFxCounter','dec'),_(o,'needFxCounter',1);var y=o.pending=h.map({fn:function(e){return e>0},named:'pending'});return oe(o,[s,f,c,d,p,y,h]),null!=t&&t.domain&&t.domain.hooks.effect(o),o}function y(e,r){pe(e,'merge','first argument');var n=l({name:o(e,'merge'),derived:1,and:r});return ar(e,n,[],'merge'),n}function b(e,t){var a=0;return r(mr,(function(r){r in e&&(n(null!=e[r],gr(t,r)),a=1)})),a}function k(e,n,t){var a=[];(function e(i){$(a,i)||(K(a,i),"store"===F(i,'op')&&(t||F(i,'sid'))&&n(i,F(i,'sid')),r(i.next,e),r(z(i),e),r(C(i),e))})(e)}function w(e,t){var a=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(a instanceof Map){var u={};return r(a,(function(e,r){n(P(r),'Map key should be a unit'),t&&t(r,e),r.sid&&(r.sid in u&&(o=1),u[r.sid]=e),i.set(r,e)})),{sidMap:u,unitMap:i,hasSidDoubles:o}}return{sidMap:a,unitMap:i}}function x(e,r){return V(r)?[je.mov({store:r.stateRef,to:'stack'})].concat(e):e}Object.defineProperty(exports,'__esModule',{value:1});for(var S,M='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',A='map',j='stack',O=function(e){return e.graphite||e},z=function(e){return e.family.owners},C=function(e){return e.family.links},N=function(e){return e.stateRef},I=function(e){return e.value},R=function(e){return e.subscribers},q=function(e){return e.parent},D=function(e){return e.scope},F=function(e,r){return O(e).meta[r]},_=function(e,r,n){return O(e).meta[r]=n},E=function(e){return e.compositeName},P=function(e){return(fe(e)||se(e))&&'kind'in e},T=function(e){return function(r){return P(r)&&r.kind===e}},V=T("store"),L=T("event"),B=T("effect"),W=function(e){return P(e)&&!!e.targetable},G=T("domain"),H=T("scope"),U={__proto__:null,unit:P,store:V,event:L,effect:B,targetable:W,domain:G,scope:H,attached:function(e){return B(e)&&1==F(e,'attached')}},$=function(e,r){return e.includes(r)},J=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},K=function(e,r){return e.push(r)},Q=function(e,r,n){return!e&&console.error(r+" is deprecated"+(n?", use "+n+" instead":''))},X=function(){var e=0;return function(){return""+ ++e}},Y=X(),Z=X(),ee=X(),re=X(),ne=null,te=function(e){S&&S(e,ne)},ae=function(){return ne&&ne.template},ie=function(e){return e&&ne&&ne.sidRoot&&(e=ne.sidRoot+"|"+e),e},oe=function(e,n){var t=O(e);r(n,(function(e){var r=O(e);"domain"!==t.family.type&&(r.family.type="crosslink"),K(z(r),t),K(C(t),r)}))},ue=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(O)},se=function(e){return'object'==typeof e&&null!==e},fe=function(e){return'function'==typeof e},ce=function(e){return void 0===e},de=function(e){return n(se(e)||fe(e),'expect first argument be an object')},le=function(e,r,t,a){return n(!(!se(e)&&!fe(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},pe=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return le(e,n,r+" item of "+t,'')})):le(e,n,t,' or array of units')},ve=function(e,t,a){return void 0===a&&(a='target'),r(ue(t),(function(r){return n(!F(r,'derived'),e+": derived unit in \""+a+"\" is not supported, use createStore/createEvent instead\"")}))},me=function(e,r,n){return(0,r.fn)(e,n.a)},ge=function(e,r,n){return(0,r.fn)(n.a,e)},he=function(e,r){return(0,r.fn)(e)},ye=function(e,r,n,t){var a={id:Z(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++be)),a},be=0,ke=function(e){var r=e.from,n=e.target,t=e.to;return ye('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":j:t,target:n},e.priority,e.batch)},we=function(e){var r=e.safe,n=e.filter,t=e.pure;return ye('compute',{fn:e.fn,safe:void 0===r?0:r,filter:void 0===n?0:n,pure:void 0===t?0:t},e.priority,e.batch)},xe=function(e){return we({fn:e.fn,priority:"effect"})},Se=function(e,r,n){return we({fn:e,safe:1,filter:r,priority:n&&"effect"})},Me=function(e,r,n){return ke({store:e,to:r?j:"a",priority:n&&"sampler",batch:1})},Ae=function(e,r){return void 0===e&&(e=he),we({fn:e,pure:1,filter:r})},je={mov:ke,compute:we,filter:function(e){return we({fn:e.fn,filter:1,pure:e.pure})},run:xe},Oe=function(e){return{id:Z(),current:e,initial:e}},ze=function(e){return e.current},Ce=function(e,r){e.before||(e.before=[]),K(e.before,r)},Ne=null,Ie=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||Te(r.v.type)>Te(n.v.type))&&(t=r,r=n,n=t),t=e(r.r,n),r.r=r.l,r.l=t,r):r:n;var t},Re=[],qe=0;qe<6;)K(Re,{first:null,last:null,size:0}),qe+=1;var De,Fe,_e=function(){for(var e=0;e<6;e++){var r=Re[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=Ne.v;return Ne=Ie(Ne.l,Ne.r),n}1===r.size&&(r.last=null);var t=r.first;return r.first=t.r,r.size-=1,t.v}}},Ee=function(e,r,n,t,a,i,o){return Pe(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e)},Pe=function(e,r,n,t){void 0===t&&(t=0);var a=Te(n),i=Re[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?Ne=Ie(Ne,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Te=function(e){switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},Ve=new Set,Le=1,Be=0,We=0,Ge=null,He=function(e){De=e},Ue=function(e){Ge=e},$e=function(e,r){if(e){for(;e&&!e.reg[r];)e=q(e);if(e)return e}return null},Je=function(e,r,n,t,a){var i=$e(e,t.id);return i?i.reg[t.id]:r?(Qe(r,t,a),r.reg[t.id]):t},Ke=function(e){return e},Qe=function e(n,t,a,i,o){var u,s=n.reg;if(!s[t.id]){var f=t.sid,c=null==t||null===(u=t.meta)||void 0===u?void 0:u.serialize,d=n.fromSerialize&&'ignore'!==c&&(null==c?void 0:c.read)||Ke,l={id:t.id,current:t.initial,meta:t.meta};if(l.id in n.values.idMap)l.current=n.values.idMap[l.id];else if(f&&f in n.values.sidMap&&!(f in n.sidIdMap))l.current=d(n.values.sidMap[f]);else if(t.before&&!o){var p=0,v=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case A:var t=r.from;if(t||r.fn){t&&e(n,t,a,i);var o=t&&s[t.id].current;v&&(l.current=r.fn?r.fn(o):o)}break;case'field':p||(p=1,l.current=Array.isArray(l.current)?[].concat(l.current):Object.assign({},l.current)),e(n,r.from,a,i),v&&(l.current[r.field]=s[s[r.from.id].id].current)}}))}f&&(n.sidIdMap[f]=t.id),s[t.id]=l}},Xe=function(e,r,n){try{return r(I(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Ye=function r(n,t){return void 0===t&&(t={}),se(n)&&(r(n.or,t),e(n,(function(e,r){ce(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Ze=function(e,r){J(e.next,r),J(z(e),r),J(C(e),r)},er=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=C(r);a=i.pop();)Ze(a,r),(n||t&&'sample'!==F(r,'op')||"crosslink"===a.family.type)&&e(a,n,'on'!==F(a,'op')&&t);for(i=z(r);a=i.pop();)Ze(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==F(a,'op')&&t)},rr=function(e){return e.clear()},nr=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),V(e))rr(R(e));else if(G(e)){t=1;var a=e.history;rr(a.events),rr(a.effects),rr(a.stores),rr(a.domains)}er(O(e),!!n,t)},tr=function(e){return f((function(){return nr(e)}))},ar=function(e,r,n,t,i){return a({node:n,parent:e,child:r,scope:{fn:i},meta:{op:t},family:{owners:[e,r],links:r},regional:1})},ir=function(e,r){return n(fe(r),'.watch argument should be a function'),tr(a({scope:{fn:r},node:[xe({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},or=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},ur=function(e,r,n){var t=Ye(n),a="domain"===e,i=Y(),o=t.sid,s=void 0===o?null:o,f=t.named,c=void 0===f?null:f,d=t.domain,l=t.parent,p=void 0===l?void 0===d?null:d:l,v=c||t.name||(a?'':i),m=u(v,p),g={op:r.kind=e,name:r.shortName=v,sid:r.sid=ie(s),named:c,unitId:r.id=i,serialize:t.serialize,derived:t.derived,config:t};if(r.targetable=!t.derived,r.parent=p,r.compositeName=m,r.defaultConfig=t,r.getType=function(){return Q(0,'getType','compositeName.fullName'),m.fullName},!a){r.subscribe=function(e){return de(e),r.watch(fe(e)?e:function(r){return e.next&&e.next(r)})},r[M]=function(){return r};var h=ae();h&&(g.nativeTemplate=h)}return g},sr=function(e,r,n,t){var a;se(n)&&(a=n,n=n.fn);var i=l({name:e.shortName+" \u2192 *",derived:1,and:a});return ar(e,i,t,r,n),i},fr='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',cr=function(e,r,n,t,a){var i=N(r),o=ke({store:i,to:"a",priority:'read'});n===A&&(o.data.softRead=1);var u=[o,Ae(t)];return c('storeOnMap',i,u,V(e)&&N(e)),ar(e,r,u,n,a)},dr=function(r,t,a,i,u,s){var f=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},d=r?[]:{},l=f(d),p=Oe(l),m=Oe(1);p.type=r?'list':'shape',p.noInit=1,c('combineBase',p,m);var g=v(l,Object.assign({name:o(a),derived:1},s,{and:i})),h=N(g);h.noInit=1,_(g,'isCombine',1);var y=Me(p);y.order={priority:'barrier'};var b=ke({store:h,to:'b',priority:'read'});b.data.softRead=1;var k=[Se((function(e,r,n){return n.scope&&!n.scope.reg[p.id]&&(n.c=1),e})),y,ke({store:m,to:'b'}),Se((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=f(n.a)),n.a[a]=e,1}),1),ke({from:"a",target:p}),ke({from:"value",store:0,target:m}),ke({from:"value",store:1,target:m,priority:"barrier",batch:1}),Me(p,1,1),u&&Ae(),b];if(e(a,(function(e,r){if(!V(e))return n(!P(e)&&!ce(e),"combine expects a store in a field "+r),void(l[r]=d[r]=e);d[r]=e.defaultState,l[r]=e.getState();var t=ar(e,g,k,'combine',u);t.scope.key=r;var a=N(e);Ce(p,{type:'field',field:r,from:a}),c('combineField',a,t)})),g.defaultShape=a,Ce(h,{type:A,from:p,fn:u}),!ae())if(u){var w=u(l);!ce(w)||s&&"skipVoid"in s||console.error(fr),h.current=w,h.initial=w,g.defaultState=w}else g.defaultState=d;return g},lr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},pr=function(e,r,n,t,a){return function(o){i({target:[t,vr],params:[n?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:n?r.rs:r.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})}},vr=a({node:[xe({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),mr=['source','clock','target'],gr=function(e,r){return e+": "+r+" should be defined"},hr=function(e,r,t,a,i,o,u,s,f,d,p,g){var h=!!i;n(!ce(t)||!ce(r),gr(e,'either source or clock'));var b=0;ce(t)?b=1:P(t)||(t=m(t)),ce(r)?r=t:(pe(r,e,'clock'),Array.isArray(r)&&(r=y(r))),b&&(t=r),s||u||(u=t.shortName);var k='none';(p||a)&&(P(a)?k='unit':(n(fe(a),'`filter` should be function or unit'),k='fn')),i?(pe(i,e,'target'),ve(e,i)):'none'===k&&d&&V(t)&&V(r)?i=v(o?o(ze(N(t)),ze(N(r))):ze(N(t)),{name:u,sid:g,or:s}):(i=l({name:u,derived:1,or:s}),c('sampleTarget',O(i)));var w=Oe(),x=[];if('unit'===k){var S=br(a,i,r,w,e),M=S[0];x=[].concat(yr(S[1]),yr(M))}var A=br(t,i,r,w,e),z=A[0],C=A[1],I=ar(r,i,[c('sampleSourceLoader'),ke({from:j,target:w})].concat(yr(C),[Me(z,1,f)],x,[Me(w),'fn'===k&&Ae((function(e,r,n){return a(e,n.a)}),1),o&&Ae(me),c('sampleSourceUpward',h)]),e,o);return oe(t,[I]),Object.assign(I.meta,s,{joint:1}),i},yr=function(e){return[Me(e),Se((function(e,r,n){return n.a}),1)]},br=function(e,r,n,t,i){var o=V(e),u=o?N(e):Oe(),s=Oe(o);return o||a({parent:e,node:[ke({from:j,target:u}),ke({from:"value",store:1,target:s})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),c('sampleSource',s,u,t),[u,s]},kr=function(e,r,n,t){var a=e[r];a&&i({target:a,params:Array.isArray(a)?a.map((function(){return n})):n,defer:1,stack:t})},wr=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!P(e))return Promise.reject(new Error('first argument should be unit'));if(!(B(e)||L(e)||V(e)||H(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));H(e)&&(t=e);var o=g();o.parentFork=De;var u=t.fxCount;K(u.scope.defers,o);var s=[],f=[];return H(e)||(K(s,e),K(f,B(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),K(s,u),K(f,null),i({target:s,params:f,scope:t}),o.req},exports.attach=function(e){var r,t,a=s(e,1);t=a[1];var o=(e=a[0]).source,f=e.effect,c=e.mapParams,d=e.domain;B(f)&&n(ce(d),'`domain` can only be used with a plain function');var l=h(e,t);_(l,'attached',1);var p,v,g=O(l).scope.runner,y=Se((function(e,r,n){var t,a=e.params,u=e.req,s=e.handler,f=l.finally,d=pr(a,u,0,f,n),p=n.a,v=B(s),m=1;if(c){var g=lr(c,d,[a,p]);m=g[0],t=g[1]}else t=o&&v?p:a;if(m){if(!v)return e.args=[p,t],1;i({target:s,params:{params:t,req:{rs:pr(a,u,1,f,n),rj:d}},page:n.page,defer:1,meta:n.meta})}}),1,1);o?(V(o)?oe(v=o,[l]):(v=m(o),oe(l,[v])),p=[Me(N(v)),y]):p=[y],(r=g.seq).splice.apply(r,[1,0].concat(p)),l.use(f);var b=q(f);return b&&(Object.assign(E(l),u(l.shortName,b)),l.defaultConfig.parent=b),or(f,l,"effect"),l},exports.clearNode=nr,exports.combine=m,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=s(n),i=a[0],o=i[0],u=i[1],f=a[1],c={};return e(u,(function(e,r){var n=c[r]=l(r,{parent:q(o),config:f});o.on(n,e),or(o,n)})),c},exports.createDomain=function n(t,o){var u=Ye({or:o,and:'string'==typeof t?{name:t}:t}),s=a({family:{type:"domain"},regional:1,parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent)}),f={history:{},graphite:s,hooks:{}};s.meta=ur("domain",f,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:Object.assign({},u,{derived:1})}),e({Event:l,Effect:h,Store:v,Domain:n},(function(e,n){var t=n.toLowerCase(),a=l({named:"on"+n});f.hooks[t]=a;var o=new Set;f.history[t+"s"]=o,a.create=function(e){return i(a,e),e},K(O(a).seq,Se((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){oe(f,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=f)})),oe(f,[a]),f["onCreate"+n]=function(e){return r(o,e),a.watch(e)},f["create"+n]=f[t]=function(r,n){var t=Ye({and:n,or:r});return null!=t&&t.domain?e(r,n):a(e(r,{parent:f,or:t}))}}));var c=q(f);return c&&e(f.hooks,(function(e,r){return ar(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(f),f},exports.createEffect=h,exports.createEvent=l,exports.createNode=a,exports.createStore=v,exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=e.batch,o=[je.run({fn:function(e){return n(e)}})];i&&o.unshift(je.compute({priority:'sampler',batch:1})),V(r)&&o.unshift(je.mov({store:r.stateRef,to:'stack'}));var u=Array.isArray(r)?r:[r];if(t){var s=[],c=t.additionalLinks;return u.forEach((function(e){var r=c[e.graphite.id]||[];c[e.graphite.id]=r;var n=a({node:x(o,e),meta:{watchOp:e.kind}});r.push(n),s.push((function(){var e=r.indexOf(n);-1!==e&&r.splice(e,1),nr(n)}))})),f((function(){s.forEach((function(e){return e()}))}))}var d=a({node:o,parent:u,family:{owners:u}});return f((function(){nr(d)}))},exports.fork=function(e,t){var i,o=e;G(e)&&(Q(0,'fork(domain)','fork()'),i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[Se((function(e,r,n){q(n)?'dec'===F(q(n).node,'needFxCounter')?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),we({priority:"sampler",batch:1}),Se((function(e,n){var t=n.defers,a=n.fxID;n.inFlight>0||0===t.length||Promise.resolve().then((function(){n.fxID===a&&r(t.splice(0,t.length),(function(e){He(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[Se((function(e,r,n){var t=q(n);if(t){var a=t.node;if(!F(a,'isCombine')||q(t)&&'combine'!==F(q(t).node,'op')){var i=D(n),o=a.scope.state.id,u=F(a,'sid');i.sidIdMap[u]=o,i.values.sidMap[u]=e;var s=F(a,'serialize');s&&i.sidSerializeSettings.set(u,'ignore'===s?{ignore:1}:{ignore:0,write:s.write})}}}))]}),i=a({node:[Se((function(e,r,n){var t=D(n);if(t){var a=q(n);a&&(!F(a.node,'isCombine')||q(a)&&'combine'!==F(q(a).node,'op'))&&(t.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return Je(Ge,o,null,e).current;var r=O(e);return Je(Ge,o,r,r.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[n,t,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:n}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:n,storeChange:t,warnSerializeNode:i};return o}(i);if(o){if(o.values){var s=w(o.values,(function(e){return n(V(e)&&W(e),'Values map can contain only writable stores as keys')})),f=s.unitMap,c=s.hasSidDoubles;Object.assign(u.values.sidMap,s.sidMap),r(f,(function(e,r){u.values.idMap[r.stateRef.id]=e;var n=F(r,'serialize'),t=F(r,'sid');'ignore'===n&&u.sidSerializeSettings.set(t,{ignore:1})})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),u.hasSidDoubles=c}o.handlers&&(Q(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),u.handlers=w(o.handlers,(function(e){return n(B(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){Q(0,'forward','sample');var r='forward',n=s(e,1),t=n[0],i=t.from,o=t.to,u=n[1];return pe(i,r,'"from"'),pe(o,r,'"to"'),ve(r,o,'to'),tr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){de(e);var r=M in e?e[M]():e;n(r.subscribe,'expect observable to have .subscribe');var t=l(),a=tr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){Q(0,'guard','sample');for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=s(r),a=t[0],i=a[0],o=a[1],u=t[1];return o||(i=(o=i).source),b(o,'guard'),hr('guard',o.clock,i,o.filter,o.target,null,o.name,u,!o.greedy,0,1)},exports.hydrate=function(e,t){var a=t.values;n(se(a),'values property should be an object');var o=w(a),u=o.sidMap,s=o.unitMap,f=Object.getOwnPropertyNames(u),c={};r(s,(function(e,r){c[r.stateRef.id]=r}));var d,l,p,v=[],m=[];H(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),Q(0,'hydrate(fork(domain), { values })','fork({ values })'),l=O(d.cloneOf)):G(e)?(Q(0,'hydrate(domain, { values })','fork({ values })'),l=O(e)):n(0,'first argument of hydrate should be domain or scope'),k(l,(function(e,r){if(r&&$(f,r)){K(v,e);var n=F(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),K(m,u[r])}else e.scope.state.id in c&&(K(v,e),K(m,s.get(c[e.scope.state.id])))}),1),i({target:v,params:m,scope:d}),p&&Object.assign(d.values.sidMap,u)},exports.is=U,exports.launch=i,exports.merge=y,exports.restore=function(r,n,t){if(V(r))return Q(0,'restore($store)'),r;if(L(r)||B(r)){var a=q(r),i=v(n,{parent:a,name:r.shortName,and:t});return ar(B(r)?r.doneData:r,i),a&&a.hooks.store(i),i}var o=Array.isArray(r)?[]:{};return e(r,(function(e,r){return o[r]=V(e)?e:v(e,{name:r})})),o},exports.sample=function(){for(var e,r,n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];var i,o,u=s(t),f=u[0],c=f[0],d=f[1],l=f[2],p=u[1],v=1;return ce(d)&&se(c)&&b(c,"sample")&&(d=c.clock,l=c.fn,'batch'in c?v=c.batch:(Q(!('greedy'in c),'greedy in sample','batch'),v=!c.greedy),o=c.filter,e=c.target,r=c.name,i=c.sid,c=c.source),hr("sample",d,c,o,e,l,r,p,v,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||De||t.safe,'scopeBind: scope not found');var o=a||De;return B(e)?function(r){var n=g();return i({target:e,params:{params:r,req:n},scope:o}),n.req}:function(r){return i({target:e,params:r,scope:o}),r}},exports.serialize=function(r,t){void 0===t&&(t={}),r.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!r.hasSidDoubles,'duplicate sid found in this scope');var a=t.ignore?t.ignore.map((function(e){return e.sid})):[],i={};return e(r.values.sidMap,(function(e,n){var t;if(!$(a,n)){var o=r.sidIdMap[n],u=null!==(t=r.sidSerializeSettings.get(n))&&void 0!==t?t:{ignore:0,write:wr};u.ignore||(i[n]=(0,u.write)(o&&o in r.reg?r.reg[o].current:e))}})),'onlyChanges'in t&&(Q(0,'onlyChanges'),t.onlyChanges||(n(r.cloneOf,'scope should be created from domain'),k(O(r.cloneOf),(function(e,n){n in i||$(a,n)||F(e,'isCombine')||'ignore'===F(e,'serialize')||(i[n]=r.getState(e))})))),i},exports.setGraphInspector=function(e){S=e},exports.setInspector=function(e){Fe=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(E(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),f=0;f<o;f++)u[f]=arguments[f];var d=s(u),p=d[0],v=p[0],m=p[1],g=d[1],h=!m;h&&(r=v.cases,m=v.match,t=v.clock,v=v.source);var y=V(m),b=!P(m)&&fe(m),k=!y&&!b&&se(m);n(P(v),'source must be a unit'),r||(r={}),h?e(r,(function(e,r){return ve(i,e,"cases."+r)})):(n(k,'match should be an object'),e(m,(function(e,n){return r[n]=l({derived:1,named:"cases."+n,and:g})})),r.__=l({derived:1,named:'cases.__',and:g}));var w,x=new Set([].concat(v,t||[],Object.values(r))),S=Object.keys(y||b?r:m);if(y||b)y&&x.add(m),w=[y&&Me(N(m),0,1),we({safe:y,filter:1,pure:!y,fn:function(e,r,n){var t=String(y?n.a:m(e));kr(r,$(S,t)?t:'__',e,n)}})];else if(k){var M=Oe({});M.type='shape';var A,j=[];e(m,(function(e,r){if(P(e)){A=1,K(j,r),x.add(e);var n=ar(e,[],[Me(M),Se((function(e,n,t){return t.a[r]=e}))]);if(V(e)){M.current[r]=e.getState();var t=N(e);Ce(M,{from:t,field:r,type:'field'}),c('splitMatchStore',t,n)}}})),A&&c('splitBase',M),w=[A&&Me(M,0,1),Ae((function(e,r,n){for(var t=0;t<S.length;t++){var a=S[t];if($(j,a)?n.a[a]:m[a](e))return void kr(r,a,e,n)}kr(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var O=a({meta:{op:i},parent:t?[]:v,scope:r,node:w,family:{owners:Array.from(x)},regional:1});if(t&&hr(i,t,v,null,O,null,i,g,0,0,0),!h)return r},exports.step=je,exports.version="23.0.0-rc.3",exports.withFactory=function(e){var r=e.sid,n=e.name,i=e.loc,o=e.method,u=e.fn;return t(a({meta:{sidRoot:ie(r),sid:r,name:n,loc:i,method:o,type:'factory'}}),u)},exports.withRegion=t; | ||
'use strict';function e(e,r){for(var n in e)r(e[n],n)}function r(e,r){e.forEach(r)}function n(e,r){if(!e)throw Error(r)}function t(e,r){var n=O(e).meta||{};ne={id:O(e).id,parent:ne,value:e,template:n.template||ae(),sidRoot:n.sidRoot||ne&&ne.sidRoot,meta:n};try{return r()}finally{te('region'),ne=q(ne)}}function a(e){var n=void 0===e?{}:e,t=n.node,a=void 0===t?[]:t,i=n.parent,o=n.child,u=void 0===o?n.to||n.target:o,s=n.scope,f=void 0===s?{}:s,c=n.meta,d=void 0===c?{}:c,l=n.family,p=void 0===l?{type:'regular'}:l,v=n.regional,m=ue(void 0===i?n.from||n.source:i),g=ue(p.links),h=ue(p.owners),y=[];r(a,(function(e){return e&&K(y,e)}));var b={id:ee(),seq:y,next:ue(u),meta:d,scope:f,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return K(z(e),b)})),r(h,(function(e){return K(C(e),b)})),r(m,(function(e){return K(e.next,b)})),v&&ne&&oe(I(ne),[b]),b}function i(e,n,t){var a,i=Ge,o=null,u=De;if(e.target&&(n=e.params,t=e.defer,a=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),u=D(e)||u,e=e.target),u&&De&&u!==De&&(De=null),Array.isArray(e))for(var s=0;s<e.length;s++)Ee('pure',i,O(e[s]),o,n[s],u,a);else Ee('pure',i,O(e),o,n,u,a);if(!t||Le){var f,c,d,l,p,v,m={isRoot:Le,currentPage:Ge,scope:De,isWatch:Be,isPure:We};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,Ge=p=n.page,De=D(n),p?v=p.reg:De&&(v=De.reg);var a=!!p,i=!!De,o={fail:0,scope:d.scope};f=c=0;for(var u=e;u<d.seq.length&&!f;u++){var s=d.seq[u];if(s.order){var g=s.order,h=g.priority,y=g.barrierID,b=y?p?p.fullID+"_"+y:y:0;if(u!==e||t!==h)return y?Ve.has(b)||(Ve.add(b),Pe(u,n,h,y)):Pe(u,n,h),"continue|kernelLoop";y&&Ve.delete(b)}switch(s.type){case'mov':var k=s.data,w=void 0;switch(k.from){case j:w=I(n);break;case"a":case'b':w=n[k.from];break;case"value":w=k.store;break;case"store":if(v&&!v[k.store.id])if(a){var x=$e(p,k.store.id);n.page=p=x,x?v=x.reg:i?(Qe(De,k.store,0,1,k.softRead),v=De.reg):v=void 0}else i&&Qe(De,k.store,0,1,k.softRead);w=ze(v&&v[k.store.id]||k.store)}switch(k.to){case j:n.value=w;break;case"a":case'b':n[k.to]=w;break;case"store":Je(p,De,d,k.target).current=w}break;case'compute':var S=s.data;if(S.fn){Be='watch'===F(d,'op'),We=S.pure;var M=S.safe?(0,S.fn)(I(n),o.scope,n):Xe(o,S.fn,n);S.filter?c=!M:n.value=M,Be=m.isWatch,We=m.isPure}}f=o.fail||c}if(Fe&&Fe(n,o),!f){var A=I(n),O=D(n);if(r(d.next,(function(e){Ee('child',p,e,n,A,O)})),O){F(d,'needFxCounter')&&Ee('child',p,O.fxCount,n,A,O),F(d,'storeChange')&&Ee('child',p,O.storeChange,n,A,O),F(d,'warnSerialize')&&Ee('child',p,O.warnSerializeNode,n,A,O);var z=O.additionalLinks[d.id];z&&r(z,(function(e){Ee('child',p,e,n,A,O)}))}}};l=_e();)g();Le=m.isRoot,Ge=m.currentPage,De=D(m)}}function o(r,n){void 0===n&&(n='combine');var t=n+'(',a='',i=0;return e(r,(function(e){i<25&&(null!=e&&(t+=a,t+=P(e)?E(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=E(r);0===e.length?(n=i.path,t=i.fullName):(n=i.path.concat([e]),t=0===i.fullName.length?e:i.fullName+'/'+e)}else n=0===e.length?[]:[e],t=e;return{shortName:a,fullName:t,path:n}}function s(e,r){var n=r?e:e[0];de(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(se(i)&&'and'in i){var o=s(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function f(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}function c(e){var r=ae();if(r){for(var n=r.handlers[e],t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];if(n)return n.apply(void 0,[r].concat(a))}}function d(e,r,n,t){var a=Ge,i=null;if(r)for(i=Ge;i&&i.template!==r;)i=q(i);Ue(i);var o=e.create(n,t);return Ue(a),o}function l(e,r){var t=Ye({or:r,and:'string'==typeof e?{name:e}:e}),o=function e(r){n(!F(e,'derived'),'call of derived event is not supported, use createEvent instead'),n(!We,'unit call from pure function is not supported, use operators like sample instead');for(var t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];return Ge?d(e,u,r,a):e.create(r,a)},u=ae(),s=Object.assign(o,{graphite:a({meta:ur(t.actualOp||"event",o,t),regional:1}),create:function(e){return i({target:o,params:e,scope:De}),e},watch:function(e){return ir(o,e)},map:function(e){return sr(o,A,e,[Ae()])},filter:function(e){return sr(o,"filter",e.fn?e:e.fn,[Ae(he,1)])},filterMap:function(e){return sr(o,'filterMap',e,[Ae(),Se((function(e){return!ce(e)}),1)])},prepend:function(e){n(o.targetable,'.prepend of derived event is not supported, call source event instead');var r=l('* \u2192 '+o.shortName,{parent:q(o)});return c('eventPrepend',O(r)),ar(r,o,[Ae()],'prepend',e),or(o,r),r}});return null!=t&&t.domain&&t.domain.hooks.event(s),_(s,'id',s.graphite.id),te(s.graphite),s}function p(e,t,a,i){return pe(a,t,'first argument'),n(fe(i),'second argument should be a function'),Q(!F(e,'derived'),t+" in derived store",t+" in store created via createStore"),r(Array.isArray(a)?a:[a],(function(r){e.off(r),R(e).set(r,tr(cr(r,e,'on',ge,i)))})),e}function v(e,t){var o=Ye(t),u=Oe(e),s=l({named:'updates',derived:1});c('storeBase',u);var f=u.id,d='skipVoid'in o,m=d&&!o.skipVoid;Q(!(d&&o.skipVoid),'{skipVoid: true}','updateFilter');var g={subscribers:new Map,updates:s,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(Ge){for(var n=Ge;n&&!n.reg[f];)n=q(n);n&&(e=n)}return!e&&De&&(Qe(De,u,1),e=De),e&&(r=e.reg[f]),ze(r)},setState:function(e){return i({target:g,params:e,defer:1,scope:De})},reset:function(){n(g.targetable,'.reset of derived store is not supported');for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r(t,(function(e){return p(g,'.reset',e,(function(){return g.defaultState}))})),g},on:function(e,r){return n(g.targetable,'.on of derived store is not supported'),p(g,'.on',e,r)},off:function(e){var r=R(g).get(e);return r&&(r(),R(g).delete(e)),g},map:function(e,r){var n,t;se(e)&&(n=e,e=e.fn);var a=g.getState(),i=ce(a);ae()?t=null:(!i||i&&m)&&(t=e(a));var o=v(t,Object.assign({name:g.shortName+" \u2192 *",derived:1},r,{and:n})),s=cr(g,o,A,he,e);return Ce(N(o),{type:A,fn:e,from:u}),N(o).noInit=1,c('storeMap',u,s),o},watch:function(e,r){if(Q(!r,'watch second argument','sample'),!r||!P(e)){var t=ir(g,e);return c('storeWatch',u,e)||e(g.getState()),t}return n(fe(r),'second argument should be a function'),e.watch((function(e){return r(g.getState(),e)}))}},h=ur("store",g,o),y=g.defaultConfig.updateFilter;g.graphite=a({scope:{state:u,fn:y},node:[Se((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),Me(u),Se((function(e,r,n){var t=n.a,a=n.b,i=ce(e);return i&&!d&&console.error(fr),(i&&m||!i)&&(e!==t||a)}),1),y&&Ae(me,1),ke({from:j,target:u})],child:s,meta:Object.assign({},h,{defaultState:e}),regional:1}),_(g,'id',g.graphite.id),_(g,'rootStateRefId',f);var b=F(g,'serialize'),k=F(g,'derived'),w='ignore'===b,x=F(g,'sid');x&&(_(g,'storeChange',1),u.sid=x),x||w||k||_(g,'warnSerialize',1);var S=ce(e);return n(k||!S||S&&m,fr),k&&S&&!d&&console.error(fr),oe(g,[s]),null!=o&&o.domain&&o.domain.hooks.store(g),k||(g.reinit=l({named:'reinit'}),g.reset(g.reinit)),u.meta=g.graphite.meta,te(g.graphite),g}function m(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=s(r);o=u[1];var f,c,d,l=(r=u[0])[r.length-1],p=!V(l)&&se(l),v=p&&l,m=p?r[r.length-2]:l;if(fe(m)?(i=r.slice(0,p?-2:-1),a=m):i=r,1===i.length){var g=i[0];V(g)||(f=g,c=1)}if(!c&&(f=i,a)){d=1;var h=a;a=function(e){return h.apply(void 0,e)}}return n(se(f),'shape should be an object'),dr(Array.isArray(f),!d,f,o,a,v)}function g(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function h(e,r){void 0===r&&(r={});var t=Ye(fe(e)?{handler:e}:e,r),o=l(fe(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),u=O(o);_(u,'op',o.kind="effect"),o.use=function(e){return n(fe(e),'.use argument should be a function'),m.scope.handler=e,o},o.use.getCurrent=function(){return m.scope.handler};var s=o.finally=l({named:'finally',derived:1}),f=o.done=s.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),c=o.fail=s.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),d=o.doneData=f.map({named:'doneData',fn:function(e){return e.result}}),p=o.failData=c.map({named:'failData',fn:function(e){return e.error}}),m=a({scope:{handler:o.defaultConfig.handler||function(){return n(0,"no handler used in "+o.getType())}},node:[Se((function(e,r,n){var t=r.handler,a=D(n);if(a){var i=a.handlers.unitMap.get(o)||a.handlers.sidMap[o.sid];i&&(t=i)}return e.handler=t,e}),0,1),Se((function(e,r,n){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,f=pr(t,a,1,s,n),c=pr(t,a,0,s,n),d=lr(i,c,u),l=d[1];d[0]&&(se(l)&&fe(l.then)?l.then(f,c):f(l))}),0,1)],meta:{op:'fx',fx:'runner'}});u.scope.runner=m,K(u.seq,Se((function(e,r,n){var t=r.runner,a=q(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:re()}),i({target:t,params:a,defer:1,scope:D(n),meta:n.meta}),a.params}))),o.create=function(e){var r=g(),n={params:e,req:r};if(De&&!Be){var t=De;r.req.finally((function(){He(t)})).catch((function(){}))}return i({target:o,params:n,scope:De}),r.req};var h=o.inFlight=v(0,{serialize:'ignore',named:(F(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(function(e){return e+1})).on(s,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});_(s,'needFxCounter','dec'),_(o,'needFxCounter',1);var y=o.pending=h.map({fn:function(e){return e>0},named:'pending'});return oe(o,[s,f,c,d,p,y,h]),null!=t&&t.domain&&t.domain.hooks.effect(o),o}function y(e,r){pe(e,'merge','first argument');var n=l({name:o(e,'merge'),derived:1,and:r});return ar(e,n,[],'merge'),n}function b(e,t){var a=0;return r(mr,(function(r){r in e&&(n(null!=e[r],gr(t,r)),a=1)})),a}function k(e,n,t){var a=[];(function e(i){$(a,i)||(K(a,i),"store"===F(i,'op')&&(t||F(i,'sid'))&&n(i,F(i,'sid')),r(i.next,e),r(z(i),e),r(C(i),e))})(e)}function w(e,t){var a=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(a instanceof Map){var u={};return r(a,(function(e,r){n(P(r),'Map key should be a unit'),t&&t(r,e),r.sid&&(r.sid in u&&(o=1),u[r.sid]=e),i.set(r,e)})),{sidMap:u,unitMap:i,hasSidDoubles:o}}return{sidMap:a,unitMap:i}}function x(e,r){return V(r)?[je.mov({store:r.stateRef,to:'stack'})].concat(e):e}Object.defineProperty(exports,'__esModule',{value:1});for(var S,M='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',A='map',j='stack',O=function(e){return e.graphite||e},z=function(e){return e.family.owners},C=function(e){return e.family.links},N=function(e){return e.stateRef},I=function(e){return e.value},R=function(e){return e.subscribers},q=function(e){return e.parent},D=function(e){return e.scope},F=function(e,r){return O(e).meta[r]},_=function(e,r,n){return O(e).meta[r]=n},E=function(e){return e.compositeName},P=function(e){return(fe(e)||se(e))&&'kind'in e},T=function(e){return function(r){return P(r)&&r.kind===e}},V=T("store"),L=T("event"),B=T("effect"),W=function(e){return P(e)&&!!e.targetable},G=T("domain"),H=T("scope"),U={__proto__:null,unit:P,store:V,event:L,effect:B,targetable:W,domain:G,scope:H,attached:function(e){return B(e)&&1==F(e,'attached')}},$=function(e,r){return e.includes(r)},J=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},K=function(e,r){return e.push(r)},Q=function(e,r,n){return!e&&console.error(r+" is deprecated"+(n?", use "+n+" instead":''))},X=function(){var e=0;return function(){return""+ ++e}},Y=X(),Z=X(),ee=X(),re=X(),ne=null,te=function(e){S&&S(e,ne)},ae=function(){return ne&&ne.template},ie=function(e){return e&&ne&&ne.sidRoot&&(e=ne.sidRoot+"|"+e),e},oe=function(e,n){var t=O(e);r(n,(function(e){var r=O(e);"domain"!==t.family.type&&(r.family.type="crosslink"),K(z(r),t),K(C(t),r)}))},ue=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(O)},se=function(e){return'object'==typeof e&&null!==e},fe=function(e){return'function'==typeof e},ce=function(e){return void 0===e},de=function(e){return n(se(e)||fe(e),'expect first argument be an object')},le=function(e,r,t,a){return n(!(!se(e)&&!fe(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},pe=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return le(e,n,r+" item of "+t,'')})):le(e,n,t,' or array of units')},ve=function(e,t,a){return void 0===a&&(a='target'),r(ue(t),(function(r){return n(!F(r,'derived'),e+": derived unit in \""+a+"\" is not supported, use createStore/createEvent instead\"")}))},me=function(e,r,n){return(0,r.fn)(e,n.a)},ge=function(e,r,n){return(0,r.fn)(n.a,e)},he=function(e,r){return(0,r.fn)(e)},ye=function(e,r,n,t){var a={id:Z(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++be)),a},be=0,ke=function(e){var r=e.from,n=e.target,t=e.to;return ye('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":j:t,target:n},e.priority,e.batch)},we=function(e){var r=e.safe,n=e.filter,t=e.pure;return ye('compute',{fn:e.fn,safe:void 0===r?0:r,filter:void 0===n?0:n,pure:void 0===t?0:t},e.priority,e.batch)},xe=function(e){return we({fn:e.fn,priority:"effect"})},Se=function(e,r,n){return we({fn:e,safe:1,filter:r,priority:n&&"effect"})},Me=function(e,r,n){return ke({store:e,to:r?j:"a",priority:n&&"sampler",batch:1})},Ae=function(e,r){return void 0===e&&(e=he),we({fn:e,pure:1,filter:r})},je={mov:ke,compute:we,filter:function(e){return we({fn:e.fn,filter:1,pure:e.pure})},run:xe},Oe=function(e){return{id:Z(),current:e,initial:e}},ze=function(e){return e.current},Ce=function(e,r){e.before||(e.before=[]),K(e.before,r)},Ne=null,Ie=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||Te(r.v.type)>Te(n.v.type))&&(t=r,r=n,n=t),t=e(r.r,n),r.r=r.l,r.l=t,r):r:n;var t},Re=[],qe=0;qe<6;)K(Re,{first:null,last:null,size:0}),qe+=1;var De,Fe,_e=function(){for(var e=0;e<6;e++){var r=Re[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=Ne.v;return Ne=Ie(Ne.l,Ne.r),n}1===r.size&&(r.last=null);var t=r.first;return r.first=t.r,r.size-=1,t.v}}},Ee=function(e,r,n,t,a,i,o){return Pe(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e)},Pe=function(e,r,n,t){void 0===t&&(t=0);var a=Te(n),i=Re[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?Ne=Ie(Ne,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Te=function(e){switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},Ve=new Set,Le=1,Be=0,We=0,Ge=null,He=function(e){De=e},Ue=function(e){Ge=e},$e=function(e,r){if(e){for(;e&&!e.reg[r];)e=q(e);if(e)return e}return null},Je=function(e,r,n,t,a){var i=$e(e,t.id);return i?i.reg[t.id]:r?(Qe(r,t,a),r.reg[t.id]):t},Ke=function(e){return e},Qe=function e(n,t,a,i,o){var u,s=n.reg;if(!s[t.id]){var f=t.sid,c=null==t||null===(u=t.meta)||void 0===u?void 0:u.serialize,d=n.fromSerialize&&'ignore'!==c&&(null==c?void 0:c.read)||Ke,l={id:t.id,current:t.initial,meta:t.meta};if(l.id in n.values.idMap)l.current=n.values.idMap[l.id];else if(f&&f in n.values.sidMap&&!(f in n.sidIdMap))l.current=d(n.values.sidMap[f]);else if(t.before&&!o){var p=0,v=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case A:var t=r.from;if(t||r.fn){t&&e(n,t,a,i);var o=t&&s[t.id].current;v&&(l.current=r.fn?r.fn(o):o)}break;case'field':p||(p=1,l.current=Array.isArray(l.current)?[].concat(l.current):Object.assign({},l.current)),e(n,r.from,a,i),v&&(l.current[r.field]=s[s[r.from.id].id].current)}}))}f&&(n.sidIdMap[f]=t.id),s[t.id]=l}},Xe=function(e,r,n){try{return r(I(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Ye=function r(n,t){return void 0===t&&(t={}),se(n)&&(r(n.or,t),e(n,(function(e,r){ce(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Ze=function(e,r){J(e.next,r),J(z(e),r),J(C(e),r)},er=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=C(r);a=i.pop();)Ze(a,r),(n||t&&'sample'!==F(r,'op')||"crosslink"===a.family.type)&&e(a,n,'on'!==F(a,'op')&&t);for(i=z(r);a=i.pop();)Ze(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==F(a,'op')&&t)},rr=function(e){return e.clear()},nr=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),V(e))rr(R(e));else if(G(e)){t=1;var a=e.history;rr(a.events),rr(a.effects),rr(a.stores),rr(a.domains)}er(O(e),!!n,t)},tr=function(e){return f((function(){return nr(e)}))},ar=function(e,r,n,t,i){return a({node:n,parent:e,child:r,scope:{fn:i},meta:{op:t},family:{owners:[e,r],links:r},regional:1})},ir=function(e,r){return n(fe(r),'.watch argument should be a function'),tr(a({scope:{fn:r},node:[xe({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},or=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},ur=function(e,r,n){var t=Ye(n),a="domain"===e,i=Y(),o=t.sid,s=void 0===o?null:o,f=t.named,c=void 0===f?null:f,d=t.domain,l=t.parent,p=void 0===l?void 0===d?null:d:l,v=c||t.name||(a?'':i),m=u(v,p),g={op:r.kind=e,name:r.shortName=v,sid:r.sid=ie(s),named:c,unitId:r.id=i,serialize:t.serialize,derived:t.derived,config:t};if(r.targetable=!t.derived,r.parent=p,r.compositeName=m,r.defaultConfig=t,r.getType=function(){return Q(0,'getType','compositeName.fullName'),m.fullName},!a){r.subscribe=function(e){return de(e),r.watch(fe(e)?e:function(r){return e.next&&e.next(r)})},r[M]=function(){return r};var h=ae();h&&(g.nativeTemplate=h)}return g},sr=function(e,r,n,t){var a;se(n)&&(a=n,n=n.fn);var i=l({name:e.shortName+" \u2192 *",derived:1,and:a});return ar(e,i,t,r,n),i},fr='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',cr=function(e,r,n,t,a){var i=N(r),o=ke({store:i,to:"a",priority:'read'});n===A&&(o.data.softRead=1);var u=[o,Ae(t)];return c('storeOnMap',i,u,V(e)&&N(e)),ar(e,r,u,n,a)},dr=function(r,t,a,i,u,s){var f=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},d=r?[]:{},l=f(d),p=Oe(l),m=Oe(1);p.type=r?'list':'shape',p.noInit=1,c('combineBase',p,m);var g=v(l,Object.assign({name:o(a),derived:1},s,{and:i})),h=N(g);h.noInit=1,_(g,'isCombine',1);var y=Me(p);y.order={priority:'barrier'};var b=ke({store:h,to:'b',priority:'read'});b.data.softRead=1;var k=[Se((function(e,r,n){return n.scope&&!n.scope.reg[p.id]&&(n.c=1),e})),y,ke({store:m,to:'b'}),Se((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=f(n.a)),n.a[a]=e,1}),1),ke({from:"a",target:p}),ke({from:"value",store:0,target:m}),ke({from:"value",store:1,target:m,priority:"barrier",batch:1}),Me(p,1,1),u&&Ae(),b];if(e(a,(function(e,r){if(!V(e))return n(!P(e)&&!ce(e),"combine expects a store in a field "+r),void(l[r]=d[r]=e);d[r]=e.defaultState,l[r]=e.getState();var t=ar(e,g,k,'combine',u);t.scope.key=r;var a=N(e);Ce(p,{type:'field',field:r,from:a}),c('combineField',a,t)})),g.defaultShape=a,Ce(h,{type:A,from:p,fn:u}),!ae())if(u){var w=u(l);!ce(w)||s&&"skipVoid"in s||console.error(fr),h.current=w,h.initial=w,g.defaultState=w}else g.defaultState=d;return g},lr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},pr=function(e,r,n,t,a){return function(o){i({target:[t,vr],params:[n?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:n?r.rs:r.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})}},vr=a({node:[xe({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),mr=['source','clock','target'],gr=function(e,r){return e+": "+r+" should be defined"},hr=function(e,r,t,a,i,o,u,s,f,d,p,g){var h=!!i;n(!ce(t)||!ce(r),gr(e,'either source or clock'));var b=0;ce(t)?b=1:P(t)||(t=m(t)),ce(r)?r=t:(pe(r,e,'clock'),Array.isArray(r)&&(r=y(r))),b&&(t=r),s||u||(u=t.shortName);var k='none';(p||a)&&(P(a)?k='unit':(n(fe(a),'`filter` should be function or unit'),k='fn')),i?(pe(i,e,'target'),ve(e,i)):'none'===k&&d&&V(t)&&V(r)?i=v(o?o(ze(N(t)),ze(N(r))):ze(N(t)),{name:u,sid:g,or:s}):(i=l({name:u,derived:1,or:s}),c('sampleTarget',O(i)));var w=Oe(),x=[];if('unit'===k){var S=br(a,i,r,w,e),M=S[0];x=[].concat(yr(S[1]),yr(M))}var A=br(t,i,r,w,e),z=A[0],C=A[1],I=ar(r,i,[c('sampleSourceLoader'),ke({from:j,target:w})].concat(yr(C),[Me(z,1,f)],x,[Me(w),'fn'===k&&Ae((function(e,r,n){return a(e,n.a)}),1),o&&Ae(me),c('sampleSourceUpward',h)]),e,o);return oe(t,[I]),Object.assign(I.meta,s,{joint:1}),i},yr=function(e){return[Me(e),Se((function(e,r,n){return n.a}),1)]},br=function(e,r,n,t,i){var o=V(e),u=o?N(e):Oe(),s=Oe(o);return o||a({parent:e,node:[ke({from:j,target:u}),ke({from:"value",store:1,target:s})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),c('sampleSource',s,u,t),[u,s]},kr=function(e,r,n,t){var a=e[r];a&&i({target:a,params:Array.isArray(a)?a.map((function(){return n})):n,defer:1,stack:t})},wr=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!P(e))return Promise.reject(new Error('first argument should be unit'));if(!(B(e)||L(e)||V(e)||H(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));H(e)&&(t=e);var o=g();o.parentFork=De;var u=t.fxCount;K(u.scope.defers,o);var s=[],f=[];return H(e)||(K(s,e),K(f,B(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),K(s,u),K(f,null),i({target:s,params:f,scope:t}),o.req},exports.attach=function(e){var r,t,a=s(e,1);t=a[1];var o=(e=a[0]).source,f=e.effect,c=e.mapParams,d=e.domain;B(f)&&n(ce(d),'`domain` can only be used with a plain function');var l=h(e,t);_(l,'attached',1);var p,v,g=O(l).scope.runner,y=Se((function(e,r,n){var t,a=e.params,u=e.req,s=e.handler,f=l.finally,d=pr(a,u,0,f,n),p=n.a,v=B(s),m=1;if(c){var g=lr(c,d,[a,p]);m=g[0],t=g[1]}else t=o&&v?p:a;if(m){if(!v)return e.args=[p,t],1;i({target:s,params:{params:t,req:{rs:pr(a,u,1,f,n),rj:d}},page:n.page,defer:1,meta:n.meta})}}),1,1);o?(V(o)?oe(v=o,[l]):(v=m(o),oe(l,[v])),p=[Me(N(v)),y]):p=[y],(r=g.seq).splice.apply(r,[1,0].concat(p)),l.use(f);var b=q(f);return b&&(Object.assign(E(l),u(l.shortName,b)),l.defaultConfig.parent=b),or(f,l,"effect"),l},exports.clearNode=nr,exports.combine=m,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=s(n),i=a[0],o=i[0],u=i[1],f=a[1],c={};return e(u,(function(e,r){var n=c[r]=l(r,{parent:q(o),config:f});o.on(n,e),or(o,n)})),c},exports.createDomain=function n(t,o){var u=Ye({or:o,and:'string'==typeof t?{name:t}:t}),s=a({family:{type:"domain"},regional:1,parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent)}),f={history:{},graphite:s,hooks:{}};s.meta=ur("domain",f,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:Object.assign({},u,{derived:1})}),e({Event:l,Effect:h,Store:v,Domain:n},(function(e,n){var t=n.toLowerCase(),a=l({named:"on"+n});f.hooks[t]=a;var o=new Set;f.history[t+"s"]=o,a.create=function(e){return i(a,e),e},K(O(a).seq,Se((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){oe(f,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=f)})),oe(f,[a]),f["onCreate"+n]=function(e){return r(o,e),a.watch(e)},f["create"+n]=f[t]=function(r,n){var t=Ye({and:n,or:r});return null!=t&&t.domain?e(r,n):a(e(r,{parent:f,or:t}))}}));var c=q(f);return c&&e(f.hooks,(function(e,r){return ar(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(f),f},exports.createEffect=h,exports.createEvent=l,exports.createNode=a,exports.createStore=v,exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=e.batch,o=[je.run({fn:function(e){return n(e)}})];i&&o.unshift(je.compute({priority:'sampler',batch:1})),V(r)&&o.unshift(je.mov({store:r.stateRef,to:'stack'}));var u=Array.isArray(r)?r:[r];if(t){var s=[],c=t.additionalLinks;return u.forEach((function(e){var r=c[e.graphite.id]||[];c[e.graphite.id]=r;var n=a({node:x(o,e),meta:{watchOp:e.kind}});r.push(n),s.push((function(){var e=r.indexOf(n);-1!==e&&r.splice(e,1),nr(n)}))})),f((function(){s.forEach((function(e){return e()}))}))}var d=a({node:o,parent:u,family:{owners:u}});return f((function(){nr(d)}))},exports.fork=function(e,t){var i,o=e;G(e)&&(Q(0,'fork(domain)','fork()'),i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[Se((function(e,r,n){q(n)?'dec'===F(q(n).node,'needFxCounter')?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),we({priority:"sampler",batch:1}),Se((function(e,n){var t=n.defers,a=n.fxID;n.inFlight>0||0===t.length||Promise.resolve().then((function(){n.fxID===a&&r(t.splice(0,t.length),(function(e){He(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[Se((function(e,r,n){var t=q(n);if(t){var a=t.node;if(!F(a,'isCombine')||q(t)&&'combine'!==F(q(t).node,'op')){var i=D(n),o=a.scope.state.id,u=F(a,'sid');i.sidIdMap[u]=o,i.values.sidMap[u]=e;var s=F(a,'serialize');s&&i.sidSerializeSettings.set(u,'ignore'===s?{ignore:1}:{ignore:0,write:s.write})}}}))]}),i=a({node:[Se((function(e,r,n){var t=D(n);if(t){var a=q(n);a&&(!F(a.node,'isCombine')||q(a)&&'combine'!==F(q(a).node,'op'))&&(t.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return Je(Ge,o,null,e).current;var r=O(e);return Je(Ge,o,r,r.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[n,t,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:n}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:n,storeChange:t,warnSerializeNode:i};return o}(i);if(o){if(o.values){var s=w(o.values,(function(e){return n(V(e)&&W(e),'Values map can contain only writable stores as keys')})),f=s.unitMap,c=s.hasSidDoubles;Object.assign(u.values.sidMap,s.sidMap),r(f,(function(e,r){u.values.idMap[r.stateRef.id]=e;var n=F(r,'serialize'),t=F(r,'sid');'ignore'===n&&u.sidSerializeSettings.set(t,{ignore:1})})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),u.hasSidDoubles=c}o.handlers&&(Q(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),u.handlers=w(o.handlers,(function(e){return n(B(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){Q(0,'forward','sample');var r='forward',n=s(e,1),t=n[0],i=t.from,o=t.to,u=n[1];return pe(i,r,'"from"'),pe(o,r,'"to"'),ve(r,o,'to'),tr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){de(e);var r=M in e?e[M]():e;n(r.subscribe,'expect observable to have .subscribe');var t=l(),a=tr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){Q(0,'guard','sample');for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=s(r),a=t[0],i=a[0],o=a[1],u=t[1];return o||(i=(o=i).source),b(o,'guard'),hr('guard',o.clock,i,o.filter,o.target,null,o.name,u,!o.greedy,0,1)},exports.hydrate=function(e,t){var a=t.values;n(se(a),'values property should be an object');var o=w(a),u=o.sidMap,s=o.unitMap,f=Object.getOwnPropertyNames(u),c={};r(s,(function(e,r){c[r.stateRef.id]=r}));var d,l,p,v=[],m=[];H(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),Q(0,'hydrate(fork(domain), { values })','fork({ values })'),l=O(d.cloneOf)):G(e)?(Q(0,'hydrate(domain, { values })','fork({ values })'),l=O(e)):n(0,'first argument of hydrate should be domain or scope'),k(l,(function(e,r){if(r&&$(f,r)){K(v,e);var n=F(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),K(m,u[r])}else e.scope.state.id in c&&(K(v,e),K(m,s.get(c[e.scope.state.id])))}),1),i({target:v,params:m,scope:d}),p&&Object.assign(d.values.sidMap,u)},exports.is=U,exports.launch=i,exports.merge=y,exports.restore=function(r,n,t){if(V(r))return Q(0,'restore($store)'),r;if(L(r)||B(r)){var a=q(r),i=v(n,{parent:a,name:r.shortName,and:t});return ar(B(r)?r.doneData:r,i),a&&a.hooks.store(i),i}var o=Array.isArray(r)?[]:{};return e(r,(function(e,r){return o[r]=V(e)?e:v(e,{name:r})})),o},exports.sample=function(){for(var e,r,n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];var i,o,u=s(t),f=u[0],c=f[0],d=f[1],l=f[2],p=u[1],v=1;return ce(d)&&se(c)&&b(c,"sample")&&(d=c.clock,l=c.fn,'batch'in c?v=c.batch:(Q(!('greedy'in c),'greedy in sample','batch'),v=!c.greedy),o=c.filter,e=c.target,r=c.name,i=c.sid,c=c.source),hr("sample",d,c,o,e,l,r,p,v,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||De||t.safe,'scopeBind: scope not found');var o=a||De;return B(e)?function(r){var n=g();return i({target:e,params:{params:r,req:n},scope:o}),n.req}:function(r){return i({target:e,params:r,scope:o}),r}},exports.serialize=function(r,t){void 0===t&&(t={}),r.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!r.hasSidDoubles,'duplicate sid found in this scope');var a=t.ignore?t.ignore.map((function(e){return e.sid})):[],i={};return e(r.values.sidMap,(function(e,n){var t;if(!$(a,n)){var o=r.sidIdMap[n],u=null!==(t=r.sidSerializeSettings.get(n))&&void 0!==t?t:{ignore:0,write:wr};u.ignore||(i[n]=(0,u.write)(o&&o in r.reg?r.reg[o].current:e))}})),'onlyChanges'in t&&(Q(0,'onlyChanges'),t.onlyChanges||(n(r.cloneOf,'scope should be created from domain'),k(O(r.cloneOf),(function(e,n){n in i||$(a,n)||F(e,'isCombine')||'ignore'===F(e,'serialize')||(i[n]=r.getState(e))})))),i},exports.setGraphInspector=function(e){S=e},exports.setInspector=function(e){Fe=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(E(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),f=0;f<o;f++)u[f]=arguments[f];var d=s(u),p=d[0],v=p[0],m=p[1],g=d[1],h=!m;h&&(r=v.cases,m=v.match,t=v.clock,v=v.source);var y=V(m),b=!P(m)&&fe(m),k=!y&&!b&&se(m);n(P(v),'source must be a unit'),r||(r={}),h?e(r,(function(e,r){return ve(i,e,"cases."+r)})):(n(k,'match should be an object'),e(m,(function(e,n){return r[n]=l({derived:1,named:"cases."+n,and:g})})),r.__=l({derived:1,named:'cases.__',and:g}));var w,x=new Set([].concat(v,t||[],Object.values(r))),S=Object.keys(y||b?r:m);if(y||b)y&&x.add(m),w=[y&&Me(N(m),0,1),we({safe:y,filter:1,pure:!y,fn:function(e,r,n){var t=String(y?n.a:m(e));kr(r,$(S,t)?t:'__',e,n)}})];else if(k){var M=Oe({});M.type='shape';var A,j=[];e(m,(function(e,r){if(P(e)){A=1,K(j,r),x.add(e);var n=ar(e,[],[Me(M),Se((function(e,n,t){return t.a[r]=e}))]);if(V(e)){M.current[r]=e.getState();var t=N(e);Ce(M,{from:t,field:r,type:'field'}),c('splitMatchStore',t,n)}}})),A&&c('splitBase',M),w=[A&&Me(M,0,1),Ae((function(e,r,n){for(var t=0;t<S.length;t++){var a=S[t];if($(j,a)?n.a[a]:m[a](e))return void kr(r,a,e,n)}kr(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var O=a({meta:{op:i},parent:t?[]:v,scope:r,node:w,family:{owners:Array.from(x)},regional:1});if(t&&hr(i,t,v,null,O,null,i,g,0,0,0),!h)return r},exports.step=je,exports.version="23.0.0-rc.4",exports.withFactory=function(e){var r=e.sid,n=e.name,i=e.loc,o=e.method,u=e.fn;return t(a({meta:{sidRoot:ie(r),sid:r,name:n,loc:i,method:o,type:'factory'}}),u)},exports.withRegion=t; | ||
//# sourceMappingURL=compat.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e,t){for(let r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t){if(!e)throw Error(t)}function a(e,t){let r=z(e).meta||{};te={id:z(e).id,parent:te,value:e,template:r.template||ae(),sidRoot:r.sidRoot||te&&te.sidRoot,meta:r};try{return t()}finally{re('region'),te=I(te)}}function n({node:e=[],from:r,source:a,parent:n=r||a,to:i,target:o,child:s=i||o,scope:l={},meta:d={},family:u={type:'regular'},regional:p}={}){let f=oe(n),c=oe(u.links),m=oe(u.owners),g=[];t(e,(e=>e&&U(g,e)));let h={id:Z(),seq:g,next:oe(s),meta:d,scope:l,family:{type:u.type||"crosslink",links:c,owners:m}};return t(c,(e=>U(A(e),h))),t(m,(e=>U($(e),h))),t(f,(e=>U(e.next,h))),p&&te&&ie(j(te),[h]),h}function i(e,r,a){let n,i=Be,o=null,s=Ee;if(e.target&&(r=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),s=O(e)||s,e=e.target),s&&Ee&&s!==Ee&&(Ee=null),Array.isArray(e))for(let t=0;t<e.length;t++)qe('pure',i,z(e[t]),o,r[t],s,n);else qe('pure',i,z(e),o,r,s,n);if(a&&!Pe)return;let l,d,u,p,f,c,m={isRoot:Pe,currentPage:Be,scope:Ee,isWatch:Te,isPure:Ve};Pe=0;e:for(;p=Re();){let{idx:e,stack:r,type:a}=p;u=r.node,Be=f=r.page,Ee=O(r),f?c=f.reg:Ee&&(c=Ee.reg);let n=!!f,i=!!Ee,o={fail:0,scope:u.scope};l=d=0;for(let t=e;t<u.seq.length&&!l;t++){let s=u.seq[t];if(s.order){let{priority:n,barrierID:i}=s.order,o=i?f?`${f.fullID}_${i}`:i:0;if(t!==e||a!==n){i?_e.has(o)||(_e.add(o),De(t,r,n,i)):De(t,r,n);continue e}i&&_e.delete(o)}switch(s.type){case'mov':{let e,t=s.data;switch(t.from){case M:e=j(r);break;case"a":case'b':e=r[t.from];break;case"value":e=t.store;break;case"store":if(c&&!c[t.store.id])if(n){let e=Ge(f,t.store.id);r.page=f=e,e?c=e.reg:i?(Ke(Ee,t.store,0,1,t.softRead),c=Ee.reg):c=void 0}else i&&Ke(Ee,t.store,0,1,t.softRead);e=$e(c&&c[t.store.id]||t.store)}switch(t.to){case M:r.value=e;break;case"a":case'b':r[t.to]=e;break;case"store":Ue(f,Ee,u,t.target).current=e}break}case'compute':let e=s.data;if(e.fn){Te='watch'===R(u,'op'),Ve=e.pure;let t=e.safe?(0,e.fn)(j(r),o.scope,r):Qe(o,e.fn,r);e.filter?d=!t:r.value=t,Te=m.isWatch,Ve=m.isPure}}l=o.fail||d}if(He&&He(r,o),!l){let e=j(r),a=O(r);if(t(u.next,(t=>{qe('child',f,t,r,e,a)})),a){R(u,'needFxCounter')&&qe('child',f,a.fxCount,r,e,a),R(u,'storeChange')&&qe('child',f,a.storeChange,r,e,a),R(u,'warnSerialize')&&qe('child',f,a.warnSerializeNode,r,e,a);let n=a.additionalLinks[u.id];n&&t(n,(t=>{qe('child',f,t,r,e,a)}))}}}Pe=m.isRoot,Be=m.currentPage,Ee=O(m)}function o(t,r="combine"){let a=r+'(',n='',i=0;return e(t,(e=>{i<25&&(null!=e&&(a+=n,a+=F(e)?D(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=D(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function l(e,t){let r=t?e:e[0];ue(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(se(r)&&'and'in r){let r=l(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function d(e){let t=()=>e();return t.unsubscribe=()=>e(),t}function u(e,...t){let r=ae();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function p(e,t){let a=Xe({or:t,and:'string'==typeof e?{name:e}:e}),o=(e,...t)=>(r(!R(o,'derived'),'call of derived event is not supported, use createEvent instead'),r(!Ve,'unit call from pure function is not supported, use operators like sample instead'),Be?((e,t,r,a)=>{let n=Be,i=null;if(t)for(i=Be;i&&i.template!==t;)i=I(i);We(i);let o=e.create(r,a);return We(n),o})(o,s,e,t):o.create(e,t)),s=ae(),l=Object.assign(o,{graphite:n({meta:st(a.actualOp||"event",o,a),regional:1}),create:e=>(i({target:o,params:e,scope:Ee}),e),watch:e=>nt(o,e),map:e=>lt(o,S,e,[Me()]),filter:e=>lt(o,"filter",e.fn?e:e.fn,[Me(he,1)]),filterMap:e=>lt(o,'filterMap',e,[Me(),we((e=>!de(e)),1)]),prepend(e){r(o.targetable,'.prepend of derived event is not supported, call source event instead');let t=p('* \u2192 '+o.shortName,{parent:I(o)});return u('eventPrepend',z(t)),at(t,o,[Me()],'prepend',e),ot(o,t),t}});return null!=a&&a.domain&&a.domain.hooks.event(l),q(l,'id',l.graphite.id),re(l.graphite),l}function f(e,a,n,i){return fe(n,a,'first argument'),r(le(i),'second argument should be a function'),J(!R(e,'derived'),`${a} in derived store`,`${a} in store created via createStore`),t(Array.isArray(n)?n:[n],(t=>{e.off(t),N(e).set(t,rt(ut(t,e,'on',ge,i)))})),e}function c(e,a){let o=Xe(a),s=Ae(e),l=p({named:'updates',derived:1});u('storeBase',s);let d=s.id,m='skipVoid'in o,g=m&&!o.skipVoid;J(!(m&&o.skipVoid),'{skipVoid: true}','updateFilter');let h={subscribers:new Map,updates:l,defaultState:e,stateRef:s,getState(){let e,t=s;if(Be){let t=Be;for(;t&&!t.reg[d];)t=I(t);t&&(e=t)}return!e&&Ee&&(Ke(Ee,s,1),e=Ee),e&&(t=e.reg[d]),$e(t)},setState:e=>i({target:h,params:e,defer:1,scope:Ee}),reset:(...e)=>(r(h.targetable,'.reset of derived store is not supported'),t(e,(e=>f(h,'.reset',e,(()=>h.defaultState)))),h),on:(e,t)=>(r(h.targetable,'.on of derived store is not supported'),f(h,'.on',e,t)),off(e){let t=N(h).get(e);return t&&(t(),N(h).delete(e)),h},map(e,t){let r,a;se(e)&&(r=e,e=e.fn);let n=h.getState(),i=de(n);ae()?a=null:(!i||i&&g)&&(a=e(n));let o=c(a,{name:`${h.shortName} \u2192 *`,derived:1,...t,and:r}),l=ut(h,o,S,he,e);return Ce(C(o),{type:S,fn:e,from:s}),C(o).noInit=1,u('storeMap',s,l),o},watch(e,t){if(J(!t,'watch second argument','sample'),!t||!F(e)){let t=nt(h,e);return u('storeWatch',s,e)||e(h.getState()),t}return r(le(t),'second argument should be a function'),e.watch((e=>t(h.getState(),e)))}},y=st("store",h,o),b=h.defaultConfig.updateFilter;h.graphite=n({scope:{state:s,fn:b},node:[we(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),Se(s),we(((e,t,{a:r,b:a})=>{let n=de(e);return n&&!m&&console.error(dt),(n&&g||!n)&&(e!==r||a)}),1),b&&Me(me,1),ve({from:M,target:s})],child:l,meta:{...y,defaultState:e},regional:1}),q(h,'id',h.graphite.id),q(h,'rootStateRefId',d);let v=R(h,'serialize'),k=R(h,'derived'),x='ignore'===v,w=R(h,'sid');w&&(q(h,'storeChange',1),s.sid=w),w||x||k||q(h,'warnSerialize',1);let z=de(e);return r(k||!z||z&&g,dt),k&&z&&!m&&console.error(dt),ie(h,[l]),null!=o&&o.domain&&o.domain.hooks.store(h),k||(h.reinit=p({named:'reinit'}),h.reset(h.reinit)),s.meta=h.graphite.meta,re(h.graphite),h}function m(...e){let t,a,n;[e,n]=l(e);let i,o,s,d=e[e.length-1],u=!E(d)&&se(d),p=u&&d,f=u?e[e.length-2]:d;if(le(f)?(a=e.slice(0,u?-2:-1),t=f):a=e,1===a.length){let e=a[0];E(e)||(i=e,o=1)}if(!o&&(i=a,t)){s=1;let e=t;t=t=>e(...t)}return r(se(i),'shape should be an object'),pt(Array.isArray(i),!s,i,n,t,p)}function g(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function h(e,t={}){let a=Xe(le(e)?{handler:e}:e,t),o=p(le(e)?{handler:e}:e,{...t,actualOp:"effect"}),s=z(o);q(s,'op',o.kind="effect"),o.use=e=>(r(le(e),'.use argument should be a function'),h.scope.handler=e,o),o.use.getCurrent=()=>h.scope.handler;let l=o.finally=p({named:'finally',derived:1}),d=o.done=l.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),u=o.fail=l.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),f=o.doneData=d.map({named:'doneData',fn:({result:e})=>e}),m=o.failData=u.map({named:'failData',fn:({error:e})=>e}),h=n({scope:{handler:o.defaultConfig.handler||(()=>r(0,`no handler used in ${o.getType()}`))},node:[we(((e,t,r)=>{let a=t.handler,n=O(r);if(n){let e=n.handlers.unitMap.get(o)||n.handlers.sidMap[o.sid];e&&(a=e)}return e.handler=a,e}),0,1),we((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=ct(e,t,1,l,i),s=ct(e,t,0,l,i),[d,u]=ft(r,s,a);d&&(se(u)&&le(u.then)?u.then(o,s):o(u))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=h,U(s.seq,we(((e,{runner:t},r)=>{let a=I(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:ee()}),i({target:t,params:a,defer:1,scope:O(r),meta:r.meta}),a.params}))),o.create=e=>{let t=g(),r={params:e,req:t};if(Ee&&!Te){let e=Ee;t.req.finally((()=>{Le(e)})).catch((()=>{}))}return i({target:o,params:r,scope:Ee}),t.req};let y=o.inFlight=c(0,{serialize:'ignore',named:(R(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(l,'needFxCounter','dec'),q(o,'needFxCounter',1);let b=o.pending=y.map({fn:e=>e>0,named:'pending'});return ie(o,[l,d,u,f,m,b,y]),null!=a&&a.domain&&a.domain.hooks.effect(o),o}function y(e,t){fe(e,'merge','first argument');let r=p({name:o(e,'merge'),derived:1,and:t});return at(e,r,[],'merge'),r}function b(e,a){let n=0;return t(gt,(t=>{t in e&&(r(null!=e[t],ht(a,t)),n=1)})),n}function v(e,r,a){let n=[];(function e(i){G(n,i)||(U(n,i),"store"===R(i,'op')&&(a||R(i,'sid'))&&r(i,R(i,'sid')),t(i.next,e),t(A(i),e),t($(i),e))})(e)}function k(e,a){let n=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(n instanceof Map){let e={};return t(n,((t,n)=>{r(F(n),'Map key should be a unit'),a&&a(n,t),n.sid&&(n.sid in e&&(o=1),e[n.sid]=t),i.set(n,t)})),{sidMap:e,unitMap:i,hasSidDoubles:o}}return{sidMap:n,unitMap:i}}function x(e,t){return E(t)?[ze.mov({store:t.stateRef,to:'stack'}),...e]:e}Object.defineProperty(exports,'__esModule',{value:1});let w='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',S='map',M='stack',z=e=>e.graphite||e,A=e=>e.family.owners,$=e=>e.family.links,C=e=>e.stateRef,j=e=>e.value,N=e=>e.subscribers,I=e=>e.parent,O=e=>e.scope,R=(e,t)=>z(e).meta[t],q=(e,t,r)=>z(e).meta[t]=r,D=e=>e.compositeName,F=e=>(le(e)||se(e))&&'kind'in e;const _=e=>t=>F(t)&&t.kind===e;let E=_("store"),P=_("event"),T=_("effect"),V=e=>F(e)&&!!e.targetable,B=_("domain"),L=_("scope");var W={__proto__:null,unit:F,store:E,event:P,effect:T,targetable:V,domain:B,scope:L,attached:e=>T(e)&&1==R(e,'attached')};let G=(e,t)=>e.includes(t),H=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},U=(e,t)=>e.push(t),J=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const K=()=>{let e=0;return()=>""+ ++e};let Q,X=K(),Y=K(),Z=K(),ee=K(),te=null,re=e=>{Q&&Q(e,te)},ae=()=>te&&te.template,ne=e=>(e&&te&&te.sidRoot&&(e=`${te.sidRoot}|${e}`),e),ie=(e,r)=>{let a=z(e);t(r,(e=>{let t=z(e);"domain"!==a.family.type&&(t.family.type="crosslink"),U(A(t),a),U($(a),t)}))},oe=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(z),se=e=>'object'==typeof e&&null!==e,le=e=>'function'==typeof e,de=e=>void 0===e,ue=e=>r(se(e)||le(e),'expect first argument be an object');const pe=(e,t,a,n)=>r(!(!se(e)&&!le(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${a} to be a unit (store, event or effect)${n}`);let fe=(e,r,a)=>{Array.isArray(e)?t(e,((e,t)=>pe(e,r,`${t} item of ${a}`,''))):pe(e,r,a,' or array of units')},ce=(e,a,n="target")=>t(oe(a),(t=>r(!R(t,'derived'),`${e}: derived unit in "${n}" is not supported, use createStore/createEvent instead"`))),me=(e,{fn:t},{a:r})=>t(e,r),ge=(e,{fn:t},{a:r})=>t(r,e),he=(e,{fn:t})=>t(e);const ye=(e,t,r,a)=>{let n={id:Y(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++be)),n};let be=0,ve=({from:e="store",store:t,target:r,to:a=(r?"store":M),batch:n,priority:i})=>ye('mov',{from:e,store:t,to:a,target:r},i,n),ke=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>ye('compute',{fn:e,safe:a,filter:n,pure:i},r,t),xe=({fn:e})=>ke({fn:e,priority:"effect"}),we=(e,t,r)=>ke({fn:e,safe:1,filter:t,priority:r&&"effect"}),Se=(e,t,r)=>ve({store:e,to:t?M:"a",priority:r&&"sampler",batch:1}),Me=(e=he,t)=>ke({fn:e,pure:1,filter:t}),ze={mov:ve,compute:ke,filter:({fn:e,pure:t})=>ke({fn:e,filter:1,pure:t}),run:xe},Ae=e=>({id:Y(),current:e,initial:e}),$e=({current:e})=>e,Ce=(e,t)=>{e.before||(e.before=[]),U(e.before,t)},je=null;const Ne=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Fe(e.v.type)>Fe(t.v.type))&&(r=e,e=t,t=r),r=Ne(e.r,t),e.r=e.l,e.l=r,e},Ie=[];let Oe=0;for(;Oe<6;)U(Ie,{first:null,last:null,size:0}),Oe+=1;const Re=()=>{for(let e=0;e<6;e++){let t=Ie[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=je.v;return je=Ne(je.l,je.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},qe=(e,t,r,a,n,i,o)=>De(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),De=(e,t,r,a=0)=>{let n=Fe(r),i=Ie[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?je=Ne(je,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Fe=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},_e=new Set;let Ee,Pe=1,Te=0,Ve=0,Be=null,Le=e=>{Ee=e},We=e=>{Be=e};const Ge=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=I(e);if(e)return e}return null};let He,Ue=(e,t,r,a,n)=>{let i=Ge(e,a.id);return i?i.reg[a.id]:t?(Ke(t,a,n),t.reg[a.id]):a};const Je=e=>e;let Ke=(e,r,a,n,i)=>{var o;let s=e.reg;if(s[r.id])return;let l=r.sid,d=null==r||null===(o=r.meta)||void 0===o?void 0:o.serialize,u=e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Je,p={id:r.id,current:r.initial,meta:r.meta};if(p.id in e.values.idMap)p.current=e.values.idMap[p.id];else if(l&&l in e.values.sidMap&&!(l in e.sidIdMap))p.current=u(e.values.sidMap[l]);else if(r.before&&!i){let i=0,o=a||!r.noInit||n;t(r.before,(t=>{switch(t.type){case S:{let r=t.from;if(r||t.fn){r&&Ke(e,r,a,n);let i=r&&s[r.id].current;o&&(p.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,p.current=Array.isArray(p.current)?[...p.current]:{...p.current}),Ke(e,t.from,a,n),o&&(p.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=r.id),s[r.id]=p};const Qe=(e,t,r)=>{try{return t(j(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let Xe=(t,r={})=>(se(t)&&(Xe(t.or,r),e(t,((e,t)=>{de(e)||'or'===t||'and'===t||(r[t]=e)})),Xe(t.and,r)),r);const Ye=(e,t)=>{H(e.next,t),H(A(e),t),H($(e),t)},Ze=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=$(e);for(;a=n.pop();)Ye(a,e),(t||r&&'sample'!==R(e,'op')||"crosslink"===a.family.type)&&Ze(a,t,'on'!==R(a,'op')&&r);for(n=A(e);a=n.pop();)Ye(a,e),r&&"crosslink"===a.family.type&&Ze(a,t,'on'!==R(a,'op')&&r)},et=e=>e.clear();let tt=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),E(e))et(N(e));else if(B(e)){r=1;let t=e.history;et(t.events),et(t.effects),et(t.stores),et(t.domains)}Ze(z(e),!!t,r)},rt=e=>d((()=>tt(e))),at=(e,t,r,a,i)=>n({node:r,parent:e,child:t,scope:{fn:i},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),nt=(e,t)=>(r(le(t),'.watch argument should be a function'),rt(n({scope:{fn:t},node:[xe({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),ot=(e,t,r="event")=>{I(e)&&I(e).hooks[r](t)},st=(e,t,r)=>{let a=Xe(r),n="domain"===e,i=X(),{sid:o=null,named:l=null,domain:d=null,parent:u=d}=a,p=l||a.name||(n?'':i),f=s(p,u),c={op:t.kind=e,name:t.shortName=p,sid:t.sid=ne(o),named:l,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.targetable=!a.derived,t.parent=u,t.compositeName=f,t.defaultConfig=a,t.getType=()=>(J(0,'getType','compositeName.fullName'),f.fullName),!n){t.subscribe=e=>(ue(e),t.watch(le(e)?e:t=>e.next&&e.next(t))),t[w]=()=>t;let e=ae();e&&(c.nativeTemplate=e)}return c};const lt=(e,t,r,a)=>{let n;se(r)&&(n=r,r=r.fn);let i=p({name:`${e.shortName} \u2192 *`,derived:1,and:n});return at(e,i,a,t,r),i};let dt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option';const ut=(e,t,r,a,n)=>{let i=C(t),o=ve({store:i,to:"a",priority:'read'});r===S&&(o.data.softRead=1);let s=[o,Me(a)];return u('storeOnMap',i,s,E(e)&&C(e)),at(e,t,s,r,n)},pt=(t,a,n,i,s,l)=>{let d=t?e=>[...e]:e=>({...e}),p=t?[]:{},f=d(p),m=Ae(f),g=Ae(1);m.type=t?'list':'shape',m.noInit=1,u('combineBase',m,g);let h=c(f,{name:o(n),derived:1,...l,and:i}),y=C(h);y.noInit=1,q(h,'isCombine',1);let b=Se(m);b.order={priority:'barrier'};let v=ve({store:y,to:'b',priority:'read'});v.data.softRead=1;let k=[we(((e,t,r)=>(r.scope&&!r.scope.reg[m.id]&&(r.c=1),e))),b,ve({store:g,to:'b'}),we(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return a&&r.b&&(r.a=d(r.a)),r.a[t]=e,1}),1),ve({from:"a",target:m}),ve({from:"value",store:0,target:g}),ve({from:"value",store:1,target:g,priority:"barrier",batch:1}),Se(m,1,1),s&&Me(),v];if(e(n,((e,t)=>{if(!E(e))return r(!F(e)&&!de(e),`combine expects a store in a field ${t}`),void(f[t]=p[t]=e);p[t]=e.defaultState,f[t]=e.getState();let a=at(e,h,k,'combine',s);a.scope.key=t;let n=C(e);Ce(m,{type:'field',field:t,from:n}),u('combineField',n,a)})),h.defaultShape=n,Ce(y,{type:S,from:m,fn:s}),!ae())if(s){let e=s(f);!de(e)||l&&"skipVoid"in l||console.error(dt),y.current=e,y.initial=e,h.defaultState=e}else h.defaultState=p;return h};let ft=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ct=(e,t,r,a,n)=>o=>{i({target:[a,mt],params:[r?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:n.scope,meta:n.meta})};const mt=n({node:[xe({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),gt=['source','clock','target'],ht=(e,t)=>e+`: ${t} should be defined`;let yt=(e,t,a,n,i,o,s,l,d,f,g,h)=>{let b=!!i;r(!de(a)||!de(t),ht(e,'either source or clock'));let v=0;de(a)?v=1:F(a)||(a=m(a)),de(t)?t=a:(fe(t,e,'clock'),Array.isArray(t)&&(t=y(t))),v&&(a=t),l||s||(s=a.shortName);let k='none';(g||n)&&(F(n)?k='unit':(r(le(n),'`filter` should be function or unit'),k='fn')),i?(fe(i,e,'target'),ce(e,i)):'none'===k&&f&&E(a)&&E(t)?i=c(o?o($e(C(a)),$e(C(t))):$e(C(a)),{name:s,sid:h,or:l}):(i=p({name:s,derived:1,or:l}),u('sampleTarget',z(i)));let x=Ae(),w=[];if('unit'===k){let[r,a]=vt(n,i,t,x,e);w=[...bt(a),...bt(r)]}let[S,A]=vt(a,i,t,x,e),$=at(t,i,[u('sampleSourceLoader'),ve({from:M,target:x}),...bt(A),Se(S,1,d),...w,Se(x),'fn'===k&&Me(((e,t,{a:r})=>n(e,r)),1),o&&Me(me),u('sampleSourceUpward',b)],e,o);return ie(a,[$]),Object.assign($.meta,l,{joint:1}),i};const bt=e=>[Se(e),we(((e,t,{a:r})=>r),1)],vt=(e,t,r,a,i)=>{let o=E(e),s=o?C(e):Ae(),l=Ae(o);return o||n({parent:e,node:[ve({from:M,target:s}),ve({from:"value",store:1,target:l})],family:{owners:[e,t,r],links:t},meta:{op:i},regional:1}),u('sampleSource',l,s,a),[s,l]},kt=(e,t,r,a)=>{let n=e[t];n&&i({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},xt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!F(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||P(e)||E(e)||L(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));L(e)&&(t=e);let a=g();a.parentFork=Ee;let{fxCount:n}=t;U(n.scope.defers,a);let o=[],s=[];return L(e)||(U(o,e),U(s,T(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),U(o,n),U(s,null),i({target:o,params:s,scope:t}),a.req},exports.attach=e=>{let t;[e,t]=l(e,1);let{source:a,effect:n,mapParams:o,domain:d}=e;T(n)&&r(de(d),'`domain` can only be used with a plain function');let u=h(e,t);q(u,'attached',1);let p,{runner:f}=z(u).scope,c=we(((e,t,r)=>{let n,{params:s,req:l,handler:d}=e,p=u.finally,f=ct(s,l,0,p,r),c=r.a,m=T(d),g=1;if(o?[g,n]=ft(o,f,[s,c]):n=a&&m?c:s,g){if(!m)return e.args=[c,n],1;i({target:d,params:{params:n,req:{rs:ct(s,l,1,p,r),rj:f}},page:r.page,defer:1,meta:r.meta})}}),1,1);if(a){let e;E(a)?(e=a,ie(e,[u])):(e=m(a),ie(u,[e])),p=[Se(C(e)),c]}else p=[c];f.seq.splice(1,0,...p),u.use(n);let g=I(n);return g&&(Object.assign(D(u),s(u.shortName,g)),u.defaultConfig.parent=g),ot(n,u,"effect"),u},exports.clearNode=tt,exports.combine=m,exports.createApi=(...t)=>{let[[r,a],n]=l(t),i={};return e(a,((e,t)=>{let a=i[t]=p(t,{parent:I(r),config:n});r.on(a,e),ot(r,a)})),i},exports.createDomain=function r(a,o){let s=Xe({or:o,and:'string'==typeof a?{name:a}:a}),l=n({family:{type:"domain"},regional:1,parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent)}),d={history:{},graphite:l,hooks:{}};l.meta=st("domain",d,{parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent),or:{...s,derived:1}}),e({Event:p,Effect:h,Store:c,Domain:r},((e,r)=>{let a=r.toLowerCase(),n=p({named:`on${r}`});d.hooks[a]=n;let o=new Set;d.history[`${a}s`]=o,n.create=e=>(i(n,e),e),U(z(n).seq,we(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ie(d,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),I(e)||(e.parent=d)})),ie(d,[n]),d[`onCreate${r}`]=e=>(t(o,e),n.watch(e)),d[`create${r}`]=d[a]=(t,r)=>{let a=Xe({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let u=I(d);return u&&e(d.hooks,((e,t)=>at(e,u.hooks[t]))),null!=s&&s.domain&&s.domain.hooks.domain(d),d},exports.createEffect=h,exports.createEvent=p,exports.createNode=n,exports.createStore=c,exports.createWatch=({unit:e,fn:t,scope:r,batch:a})=>{let i=[ze.run({fn:e=>t(e)})];a&&i.unshift(ze.compute({priority:'sampler',batch:1})),E(e)&&i.unshift(ze.mov({store:e.stateRef,to:'stack'}));let o=Array.isArray(e)?e:[e];if(r){let e=[],t=r.additionalLinks;return o.forEach((r=>{let a=t[r.graphite.id]||[];t[r.graphite.id]=a;let o=n({node:x(i,r),meta:{watchOp:r.kind}});a.push(o),e.push((()=>{let e=a.indexOf(o);-1!==e&&a.splice(e,1),tt(o)}))})),d((()=>{e.forEach((e=>e()))}))}{let e=n({node:i,parent:o,family:{owners:o}});return d((()=>{tt(e)}))}},exports.fork=(e,a)=>{let i,o=e;B(e)&&(J(0,'fork(domain)','fork()'),i=e,o=a);let s=(e=>{let r=n({scope:{defers:[],inFlight:0,fxID:0},node:[we(((e,t,r)=>{I(r)?'dec'===R(I(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),ke({priority:"sampler",batch:1}),we(((e,r)=>{let{defers:a,fxID:n}=r;r.inFlight>0||0===a.length||Promise.resolve().then((()=>{r.fxID===n&&t(a.splice(0,a.length),(e=>{Le(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=n({node:[we(((e,t,r)=>{let a=I(r);if(a){let t=a.node;if(!R(t,'isCombine')||I(a)&&'combine'!==R(I(a).node,'op')){let a=O(r),n=t.scope.state.id,i=R(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=R(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),i=n({node:[we(((e,t,r)=>{let a=O(r);if(a){let e=I(r);e&&(!R(e.node,'isCombine')||I(e)&&'combine'!==R(I(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return Ue(Be,o,null,e).current;let t=z(e);return Ue(Be,o,t,t.scope.state,1).current},kind:"scope",graphite:n({family:{type:"domain",links:[r,a,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:a,warnSerializeNode:i};return o})(i);if(o){if(o.values){let{sidMap:e,unitMap:a,hasSidDoubles:n}=k(o.values,(e=>r(E(e)&&V(e),'Values map can contain only writable stores as keys')));Object.assign(s.values.sidMap,e),t(a,((e,t)=>{s.values.idMap[t.stateRef.id]=e;let r=R(t,'serialize'),a=R(t,'sid');'ignore'===r&&s.sidSerializeSettings.set(a,{ignore:1})})),s.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),s.hasSidDoubles=n}o.handlers&&(J(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),s.handlers=k(o.handlers,(e=>r(T(e),"Handlers map can contain only effects as keys"))))}return s},exports.forward=e=>{J(0,'forward','sample');let t='forward',[{from:r,to:a},i]=l(e,1);return fe(r,t,'"from"'),fe(a,t,'"to"'),ce(t,a,'to'),rt(n({parent:r,child:a,meta:{op:t,config:i},family:{},regional:1}))},exports.fromObservable=e=>{ue(e);let t=w in e?e[w]():e;r(t.subscribe,'expect observable to have .subscribe');let a=p(),n=rt(a);return t.subscribe({next:a,error:n,complete:n}),a},exports.guard=(...e)=>{J(0,'guard','sample');let[[t,r],a]=l(e);return r||(r=t,t=r.source),b(r,'guard'),yt('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},exports.hydrate=(e,{values:a})=>{r(se(a),'values property should be an object');let{sidMap:n,unitMap:o}=k(a),s=Object.getOwnPropertyNames(n),l={};t(o,((e,t)=>{l[t.stateRef.id]=t}));let d,u,p,f=[],c=[];L(e)?(d=e,p=1,r(d.cloneOf,'scope should be created from domain'),J(0,'hydrate(fork(domain), { values })','fork({ values })'),u=z(d.cloneOf)):B(e)?(J(0,'hydrate(domain, { values })','fork({ values })'),u=z(e)):r(0,'first argument of hydrate should be domain or scope'),v(u,((e,t)=>{if(t&&G(s,t)){U(f,e);let r=R(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),U(c,n[t])}else e.scope.state.id in l&&(U(f,e),U(c,o.get(l[e.scope.state.id])))}),1),i({target:f,params:c,scope:d}),p&&Object.assign(d.values.sidMap,n)},exports.is=W,exports.launch=i,exports.merge=y,exports.restore=(t,r,a)=>{if(E(t))return J(0,'restore($store)'),t;if(P(t)||T(t)){let e=I(t),n=c(r,{parent:e,name:t.shortName,and:a});return at(T(t)?t.doneData:t,n),e&&e.hooks.store(n),n}let n=Array.isArray(t)?[]:{};return e(t,((e,t)=>n[t]=E(e)?e:c(e,{name:t}))),n},exports.sample=(...e)=>{let t,r,a,n,[[i,o,s],d]=l(e),u=1;return de(o)&&se(i)&&b(i,"sample")&&(o=i.clock,s=i.fn,'batch'in i?u=i.batch:(J(!('greedy'in i),'greedy in sample','batch'),u=!i.greedy),n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),yt("sample",o,i,n,t,s,r,d,u,1,0,a)},exports.scopeBind=(e,{scope:t,safe:a}={})=>{r(t||Ee||a,'scopeBind: scope not found');let n=t||Ee;return T(e)?t=>{let r=g();return i({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(i({target:e,params:t,scope:n}),t)},exports.serialize=(t,a={})=>{t.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),r(!t.hasSidDoubles,'duplicate sid found in this scope');let n=a.ignore?a.ignore.map((({sid:e})=>e)):[],i={};return e(t.values.sidMap,((e,r)=>{var a;if(G(n,r))return;let o=t.sidIdMap[r],s=null!==(a=t.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:xt};s.ignore||(i[r]=(0,s.write)(o&&o in t.reg?t.reg[o].current:e))})),'onlyChanges'in a&&(J(0,'onlyChanges'),a.onlyChanges||(r(t.cloneOf,'scope should be created from domain'),v(z(t.cloneOf),((e,r)=>{r in i||G(n,r)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[r]=t.getState(e))})))),i},exports.setGraphInspector=e=>{Q=e},exports.setInspector=e=>{He=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(D(e),s(t,I(e)))},exports.split=(...t)=>{let a,i,o='split',[[s,d],f]=l(t),c=!d;c&&(a=s.cases,d=s.match,i=s.clock,s=s.source);let m=E(d),g=!F(d)&&le(d),h=!m&&!g&&se(d);r(F(s),'source must be a unit'),a||(a={}),c?e(a,((e,t)=>ce(o,e,`cases.${t}`))):(r(h,'match should be an object'),e(d,((e,t)=>a[t]=p({derived:1,named:`cases.${t}`,and:f}))),a.__=p({derived:1,named:'cases.__',and:f}));let y,b=new Set([].concat(s,i||[],Object.values(a))),v=Object.keys(m||g?a:d);if(m||g)m&&b.add(d),y=[m&&Se(C(d),0,1),ke({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:d(e));kt(t,G(v,a)?a:'__',e,r)}})];else if(h){let t=Ae({});t.type='shape';let r,a=[];e(d,((e,n)=>{if(F(e)){r=1,U(a,n),b.add(e);let i=at(e,[],[Se(t),we(((e,t,{a:r})=>r[n]=e))]);if(E(e)){t.current[n]=e.getState();let r=C(e);Ce(t,{from:r,field:n,type:'field'}),u('splitMatchStore',r,i)}}})),r&&u('splitBase',t),y=[r&&Se(t,0,1),Me(((e,t,r)=>{for(let n=0;n<v.length;n++){let i=v[n];if(G(a,i)?r.a[i]:d[i](e))return void kt(t,i,e,r)}kt(t,'__',e,r)}),1)]}else r(0,'expect match to be unit, function or object');let k=n({meta:{op:o},parent:i?[]:s,scope:a,node:y,family:{owners:Array.from(b)},regional:1});if(i&&yt(o,i,s,null,k,null,o,f,0,0,0),!c)return a},exports.step=ze,exports.version="23.0.0-rc.3",exports.withFactory=({sid:e,name:t,loc:r,method:i,fn:o})=>a(n({meta:{sidRoot:ne(e),sid:e,name:t,loc:r,method:i,type:'factory'}}),o),exports.withRegion=a; | ||
function e(e,t){for(let r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t){if(!e)throw Error(t)}function a(e,t){let r=z(e).meta||{};te={id:z(e).id,parent:te,value:e,template:r.template||ae(),sidRoot:r.sidRoot||te&&te.sidRoot,meta:r};try{return t()}finally{re('region'),te=I(te)}}function n({node:e=[],from:r,source:a,parent:n=r||a,to:i,target:o,child:s=i||o,scope:l={},meta:d={},family:u={type:'regular'},regional:p}={}){let f=oe(n),c=oe(u.links),m=oe(u.owners),g=[];t(e,(e=>e&&U(g,e)));let h={id:Z(),seq:g,next:oe(s),meta:d,scope:l,family:{type:u.type||"crosslink",links:c,owners:m}};return t(c,(e=>U(A(e),h))),t(m,(e=>U($(e),h))),t(f,(e=>U(e.next,h))),p&&te&&ie(j(te),[h]),h}function i(e,r,a){let n,i=Be,o=null,s=Ee;if(e.target&&(r=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),s=O(e)||s,e=e.target),s&&Ee&&s!==Ee&&(Ee=null),Array.isArray(e))for(let t=0;t<e.length;t++)qe('pure',i,z(e[t]),o,r[t],s,n);else qe('pure',i,z(e),o,r,s,n);if(a&&!Pe)return;let l,d,u,p,f,c,m={isRoot:Pe,currentPage:Be,scope:Ee,isWatch:Te,isPure:Ve};Pe=0;e:for(;p=Re();){let{idx:e,stack:r,type:a}=p;u=r.node,Be=f=r.page,Ee=O(r),f?c=f.reg:Ee&&(c=Ee.reg);let n=!!f,i=!!Ee,o={fail:0,scope:u.scope};l=d=0;for(let t=e;t<u.seq.length&&!l;t++){let s=u.seq[t];if(s.order){let{priority:n,barrierID:i}=s.order,o=i?f?`${f.fullID}_${i}`:i:0;if(t!==e||a!==n){i?_e.has(o)||(_e.add(o),De(t,r,n,i)):De(t,r,n);continue e}i&&_e.delete(o)}switch(s.type){case'mov':{let e,t=s.data;switch(t.from){case M:e=j(r);break;case"a":case'b':e=r[t.from];break;case"value":e=t.store;break;case"store":if(c&&!c[t.store.id])if(n){let e=Ge(f,t.store.id);r.page=f=e,e?c=e.reg:i?(Ke(Ee,t.store,0,1,t.softRead),c=Ee.reg):c=void 0}else i&&Ke(Ee,t.store,0,1,t.softRead);e=$e(c&&c[t.store.id]||t.store)}switch(t.to){case M:r.value=e;break;case"a":case'b':r[t.to]=e;break;case"store":Ue(f,Ee,u,t.target).current=e}break}case'compute':let e=s.data;if(e.fn){Te='watch'===R(u,'op'),Ve=e.pure;let t=e.safe?(0,e.fn)(j(r),o.scope,r):Qe(o,e.fn,r);e.filter?d=!t:r.value=t,Te=m.isWatch,Ve=m.isPure}}l=o.fail||d}if(He&&He(r,o),!l){let e=j(r),a=O(r);if(t(u.next,(t=>{qe('child',f,t,r,e,a)})),a){R(u,'needFxCounter')&&qe('child',f,a.fxCount,r,e,a),R(u,'storeChange')&&qe('child',f,a.storeChange,r,e,a),R(u,'warnSerialize')&&qe('child',f,a.warnSerializeNode,r,e,a);let n=a.additionalLinks[u.id];n&&t(n,(t=>{qe('child',f,t,r,e,a)}))}}}Pe=m.isRoot,Be=m.currentPage,Ee=O(m)}function o(t,r="combine"){let a=r+'(',n='',i=0;return e(t,(e=>{i<25&&(null!=e&&(a+=n,a+=F(e)?D(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=D(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function l(e,t){let r=t?e:e[0];ue(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(se(r)&&'and'in r){let r=l(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function d(e){let t=()=>e();return t.unsubscribe=()=>e(),t}function u(e,...t){let r=ae();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function p(e,t){let a=Xe({or:t,and:'string'==typeof e?{name:e}:e}),o=(e,...t)=>(r(!R(o,'derived'),'call of derived event is not supported, use createEvent instead'),r(!Ve,'unit call from pure function is not supported, use operators like sample instead'),Be?((e,t,r,a)=>{let n=Be,i=null;if(t)for(i=Be;i&&i.template!==t;)i=I(i);We(i);let o=e.create(r,a);return We(n),o})(o,s,e,t):o.create(e,t)),s=ae(),l=Object.assign(o,{graphite:n({meta:st(a.actualOp||"event",o,a),regional:1}),create:e=>(i({target:o,params:e,scope:Ee}),e),watch:e=>nt(o,e),map:e=>lt(o,S,e,[Me()]),filter:e=>lt(o,"filter",e.fn?e:e.fn,[Me(he,1)]),filterMap:e=>lt(o,'filterMap',e,[Me(),we((e=>!de(e)),1)]),prepend(e){r(o.targetable,'.prepend of derived event is not supported, call source event instead');let t=p('* \u2192 '+o.shortName,{parent:I(o)});return u('eventPrepend',z(t)),at(t,o,[Me()],'prepend',e),ot(o,t),t}});return null!=a&&a.domain&&a.domain.hooks.event(l),q(l,'id',l.graphite.id),re(l.graphite),l}function f(e,a,n,i){return fe(n,a,'first argument'),r(le(i),'second argument should be a function'),J(!R(e,'derived'),`${a} in derived store`,`${a} in store created via createStore`),t(Array.isArray(n)?n:[n],(t=>{e.off(t),N(e).set(t,rt(ut(t,e,'on',ge,i)))})),e}function c(e,a){let o=Xe(a),s=Ae(e),l=p({named:'updates',derived:1});u('storeBase',s);let d=s.id,m='skipVoid'in o,g=m&&!o.skipVoid;J(!(m&&o.skipVoid),'{skipVoid: true}','updateFilter');let h={subscribers:new Map,updates:l,defaultState:e,stateRef:s,getState(){let e,t=s;if(Be){let t=Be;for(;t&&!t.reg[d];)t=I(t);t&&(e=t)}return!e&&Ee&&(Ke(Ee,s,1),e=Ee),e&&(t=e.reg[d]),$e(t)},setState:e=>i({target:h,params:e,defer:1,scope:Ee}),reset:(...e)=>(r(h.targetable,'.reset of derived store is not supported'),t(e,(e=>f(h,'.reset',e,(()=>h.defaultState)))),h),on:(e,t)=>(r(h.targetable,'.on of derived store is not supported'),f(h,'.on',e,t)),off(e){let t=N(h).get(e);return t&&(t(),N(h).delete(e)),h},map(e,t){let r,a;se(e)&&(r=e,e=e.fn);let n=h.getState(),i=de(n);ae()?a=null:(!i||i&&g)&&(a=e(n));let o=c(a,{name:`${h.shortName} \u2192 *`,derived:1,...t,and:r}),l=ut(h,o,S,he,e);return Ce(C(o),{type:S,fn:e,from:s}),C(o).noInit=1,u('storeMap',s,l),o},watch(e,t){if(J(!t,'watch second argument','sample'),!t||!F(e)){let t=nt(h,e);return u('storeWatch',s,e)||e(h.getState()),t}return r(le(t),'second argument should be a function'),e.watch((e=>t(h.getState(),e)))}},y=st("store",h,o),b=h.defaultConfig.updateFilter;h.graphite=n({scope:{state:s,fn:b},node:[we(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),Se(s),we(((e,t,{a:r,b:a})=>{let n=de(e);return n&&!m&&console.error(dt),(n&&g||!n)&&(e!==r||a)}),1),b&&Me(me,1),ve({from:M,target:s})],child:l,meta:{...y,defaultState:e},regional:1}),q(h,'id',h.graphite.id),q(h,'rootStateRefId',d);let v=R(h,'serialize'),k=R(h,'derived'),x='ignore'===v,w=R(h,'sid');w&&(q(h,'storeChange',1),s.sid=w),w||x||k||q(h,'warnSerialize',1);let z=de(e);return r(k||!z||z&&g,dt),k&&z&&!m&&console.error(dt),ie(h,[l]),null!=o&&o.domain&&o.domain.hooks.store(h),k||(h.reinit=p({named:'reinit'}),h.reset(h.reinit)),s.meta=h.graphite.meta,re(h.graphite),h}function m(...e){let t,a,n;[e,n]=l(e);let i,o,s,d=e[e.length-1],u=!E(d)&&se(d),p=u&&d,f=u?e[e.length-2]:d;if(le(f)?(a=e.slice(0,u?-2:-1),t=f):a=e,1===a.length){let e=a[0];E(e)||(i=e,o=1)}if(!o&&(i=a,t)){s=1;let e=t;t=t=>e(...t)}return r(se(i),'shape should be an object'),pt(Array.isArray(i),!s,i,n,t,p)}function g(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function h(e,t={}){let a=Xe(le(e)?{handler:e}:e,t),o=p(le(e)?{handler:e}:e,{...t,actualOp:"effect"}),s=z(o);q(s,'op',o.kind="effect"),o.use=e=>(r(le(e),'.use argument should be a function'),h.scope.handler=e,o),o.use.getCurrent=()=>h.scope.handler;let l=o.finally=p({named:'finally',derived:1}),d=o.done=l.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),u=o.fail=l.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),f=o.doneData=d.map({named:'doneData',fn:({result:e})=>e}),m=o.failData=u.map({named:'failData',fn:({error:e})=>e}),h=n({scope:{handler:o.defaultConfig.handler||(()=>r(0,`no handler used in ${o.getType()}`))},node:[we(((e,t,r)=>{let a=t.handler,n=O(r);if(n){let e=n.handlers.unitMap.get(o)||n.handlers.sidMap[o.sid];e&&(a=e)}return e.handler=a,e}),0,1),we((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=ct(e,t,1,l,i),s=ct(e,t,0,l,i),[d,u]=ft(r,s,a);d&&(se(u)&&le(u.then)?u.then(o,s):o(u))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=h,U(s.seq,we(((e,{runner:t},r)=>{let a=I(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:ee()}),i({target:t,params:a,defer:1,scope:O(r),meta:r.meta}),a.params}))),o.create=e=>{let t=g(),r={params:e,req:t};if(Ee&&!Te){let e=Ee;t.req.finally((()=>{Le(e)})).catch((()=>{}))}return i({target:o,params:r,scope:Ee}),t.req};let y=o.inFlight=c(0,{serialize:'ignore',named:(R(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(l,'needFxCounter','dec'),q(o,'needFxCounter',1);let b=o.pending=y.map({fn:e=>e>0,named:'pending'});return ie(o,[l,d,u,f,m,b,y]),null!=a&&a.domain&&a.domain.hooks.effect(o),o}function y(e,t){fe(e,'merge','first argument');let r=p({name:o(e,'merge'),derived:1,and:t});return at(e,r,[],'merge'),r}function b(e,a){let n=0;return t(gt,(t=>{t in e&&(r(null!=e[t],ht(a,t)),n=1)})),n}function v(e,r,a){let n=[];(function e(i){G(n,i)||(U(n,i),"store"===R(i,'op')&&(a||R(i,'sid'))&&r(i,R(i,'sid')),t(i.next,e),t(A(i),e),t($(i),e))})(e)}function k(e,a){let n=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(n instanceof Map){let e={};return t(n,((t,n)=>{r(F(n),'Map key should be a unit'),a&&a(n,t),n.sid&&(n.sid in e&&(o=1),e[n.sid]=t),i.set(n,t)})),{sidMap:e,unitMap:i,hasSidDoubles:o}}return{sidMap:n,unitMap:i}}function x(e,t){return E(t)?[ze.mov({store:t.stateRef,to:'stack'}),...e]:e}Object.defineProperty(exports,'__esModule',{value:1});let w='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',S='map',M='stack',z=e=>e.graphite||e,A=e=>e.family.owners,$=e=>e.family.links,C=e=>e.stateRef,j=e=>e.value,N=e=>e.subscribers,I=e=>e.parent,O=e=>e.scope,R=(e,t)=>z(e).meta[t],q=(e,t,r)=>z(e).meta[t]=r,D=e=>e.compositeName,F=e=>(le(e)||se(e))&&'kind'in e;const _=e=>t=>F(t)&&t.kind===e;let E=_("store"),P=_("event"),T=_("effect"),V=e=>F(e)&&!!e.targetable,B=_("domain"),L=_("scope");var W={__proto__:null,unit:F,store:E,event:P,effect:T,targetable:V,domain:B,scope:L,attached:e=>T(e)&&1==R(e,'attached')};let G=(e,t)=>e.includes(t),H=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},U=(e,t)=>e.push(t),J=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const K=()=>{let e=0;return()=>""+ ++e};let Q,X=K(),Y=K(),Z=K(),ee=K(),te=null,re=e=>{Q&&Q(e,te)},ae=()=>te&&te.template,ne=e=>(e&&te&&te.sidRoot&&(e=`${te.sidRoot}|${e}`),e),ie=(e,r)=>{let a=z(e);t(r,(e=>{let t=z(e);"domain"!==a.family.type&&(t.family.type="crosslink"),U(A(t),a),U($(a),t)}))},oe=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(z),se=e=>'object'==typeof e&&null!==e,le=e=>'function'==typeof e,de=e=>void 0===e,ue=e=>r(se(e)||le(e),'expect first argument be an object');const pe=(e,t,a,n)=>r(!(!se(e)&&!le(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${a} to be a unit (store, event or effect)${n}`);let fe=(e,r,a)=>{Array.isArray(e)?t(e,((e,t)=>pe(e,r,`${t} item of ${a}`,''))):pe(e,r,a,' or array of units')},ce=(e,a,n="target")=>t(oe(a),(t=>r(!R(t,'derived'),`${e}: derived unit in "${n}" is not supported, use createStore/createEvent instead"`))),me=(e,{fn:t},{a:r})=>t(e,r),ge=(e,{fn:t},{a:r})=>t(r,e),he=(e,{fn:t})=>t(e);const ye=(e,t,r,a)=>{let n={id:Y(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++be)),n};let be=0,ve=({from:e="store",store:t,target:r,to:a=(r?"store":M),batch:n,priority:i})=>ye('mov',{from:e,store:t,to:a,target:r},i,n),ke=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>ye('compute',{fn:e,safe:a,filter:n,pure:i},r,t),xe=({fn:e})=>ke({fn:e,priority:"effect"}),we=(e,t,r)=>ke({fn:e,safe:1,filter:t,priority:r&&"effect"}),Se=(e,t,r)=>ve({store:e,to:t?M:"a",priority:r&&"sampler",batch:1}),Me=(e=he,t)=>ke({fn:e,pure:1,filter:t}),ze={mov:ve,compute:ke,filter:({fn:e,pure:t})=>ke({fn:e,filter:1,pure:t}),run:xe},Ae=e=>({id:Y(),current:e,initial:e}),$e=({current:e})=>e,Ce=(e,t)=>{e.before||(e.before=[]),U(e.before,t)},je=null;const Ne=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Fe(e.v.type)>Fe(t.v.type))&&(r=e,e=t,t=r),r=Ne(e.r,t),e.r=e.l,e.l=r,e},Ie=[];let Oe=0;for(;Oe<6;)U(Ie,{first:null,last:null,size:0}),Oe+=1;const Re=()=>{for(let e=0;e<6;e++){let t=Ie[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=je.v;return je=Ne(je.l,je.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},qe=(e,t,r,a,n,i,o)=>De(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),De=(e,t,r,a=0)=>{let n=Fe(r),i=Ie[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?je=Ne(je,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Fe=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case"barrier":return 3;case"sampler":return 4;case"effect":return 5;default:return-1}},_e=new Set;let Ee,Pe=1,Te=0,Ve=0,Be=null,Le=e=>{Ee=e},We=e=>{Be=e};const Ge=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=I(e);if(e)return e}return null};let He,Ue=(e,t,r,a,n)=>{let i=Ge(e,a.id);return i?i.reg[a.id]:t?(Ke(t,a,n),t.reg[a.id]):a};const Je=e=>e;let Ke=(e,r,a,n,i)=>{var o;let s=e.reg;if(s[r.id])return;let l=r.sid,d=null==r||null===(o=r.meta)||void 0===o?void 0:o.serialize,u=e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Je,p={id:r.id,current:r.initial,meta:r.meta};if(p.id in e.values.idMap)p.current=e.values.idMap[p.id];else if(l&&l in e.values.sidMap&&!(l in e.sidIdMap))p.current=u(e.values.sidMap[l]);else if(r.before&&!i){let i=0,o=a||!r.noInit||n;t(r.before,(t=>{switch(t.type){case S:{let r=t.from;if(r||t.fn){r&&Ke(e,r,a,n);let i=r&&s[r.id].current;o&&(p.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,p.current=Array.isArray(p.current)?[...p.current]:{...p.current}),Ke(e,t.from,a,n),o&&(p.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=r.id),s[r.id]=p};const Qe=(e,t,r)=>{try{return t(j(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let Xe=(t,r={})=>(se(t)&&(Xe(t.or,r),e(t,((e,t)=>{de(e)||'or'===t||'and'===t||(r[t]=e)})),Xe(t.and,r)),r);const Ye=(e,t)=>{H(e.next,t),H(A(e),t),H($(e),t)},Ze=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=$(e);for(;a=n.pop();)Ye(a,e),(t||r&&'sample'!==R(e,'op')||"crosslink"===a.family.type)&&Ze(a,t,'on'!==R(a,'op')&&r);for(n=A(e);a=n.pop();)Ye(a,e),r&&"crosslink"===a.family.type&&Ze(a,t,'on'!==R(a,'op')&&r)},et=e=>e.clear();let tt=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),E(e))et(N(e));else if(B(e)){r=1;let t=e.history;et(t.events),et(t.effects),et(t.stores),et(t.domains)}Ze(z(e),!!t,r)},rt=e=>d((()=>tt(e))),at=(e,t,r,a,i)=>n({node:r,parent:e,child:t,scope:{fn:i},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),nt=(e,t)=>(r(le(t),'.watch argument should be a function'),rt(n({scope:{fn:t},node:[xe({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),ot=(e,t,r="event")=>{I(e)&&I(e).hooks[r](t)},st=(e,t,r)=>{let a=Xe(r),n="domain"===e,i=X(),{sid:o=null,named:l=null,domain:d=null,parent:u=d}=a,p=l||a.name||(n?'':i),f=s(p,u),c={op:t.kind=e,name:t.shortName=p,sid:t.sid=ne(o),named:l,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.targetable=!a.derived,t.parent=u,t.compositeName=f,t.defaultConfig=a,t.getType=()=>(J(0,'getType','compositeName.fullName'),f.fullName),!n){t.subscribe=e=>(ue(e),t.watch(le(e)?e:t=>e.next&&e.next(t))),t[w]=()=>t;let e=ae();e&&(c.nativeTemplate=e)}return c};const lt=(e,t,r,a)=>{let n;se(r)&&(n=r,r=r.fn);let i=p({name:`${e.shortName} \u2192 *`,derived:1,and:n});return at(e,i,a,t,r),i};let dt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option';const ut=(e,t,r,a,n)=>{let i=C(t),o=ve({store:i,to:"a",priority:'read'});r===S&&(o.data.softRead=1);let s=[o,Me(a)];return u('storeOnMap',i,s,E(e)&&C(e)),at(e,t,s,r,n)},pt=(t,a,n,i,s,l)=>{let d=t?e=>[...e]:e=>({...e}),p=t?[]:{},f=d(p),m=Ae(f),g=Ae(1);m.type=t?'list':'shape',m.noInit=1,u('combineBase',m,g);let h=c(f,{name:o(n),derived:1,...l,and:i}),y=C(h);y.noInit=1,q(h,'isCombine',1);let b=Se(m);b.order={priority:'barrier'};let v=ve({store:y,to:'b',priority:'read'});v.data.softRead=1;let k=[we(((e,t,r)=>(r.scope&&!r.scope.reg[m.id]&&(r.c=1),e))),b,ve({store:g,to:'b'}),we(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return a&&r.b&&(r.a=d(r.a)),r.a[t]=e,1}),1),ve({from:"a",target:m}),ve({from:"value",store:0,target:g}),ve({from:"value",store:1,target:g,priority:"barrier",batch:1}),Se(m,1,1),s&&Me(),v];if(e(n,((e,t)=>{if(!E(e))return r(!F(e)&&!de(e),`combine expects a store in a field ${t}`),void(f[t]=p[t]=e);p[t]=e.defaultState,f[t]=e.getState();let a=at(e,h,k,'combine',s);a.scope.key=t;let n=C(e);Ce(m,{type:'field',field:t,from:n}),u('combineField',n,a)})),h.defaultShape=n,Ce(y,{type:S,from:m,fn:s}),!ae())if(s){let e=s(f);!de(e)||l&&"skipVoid"in l||console.error(dt),y.current=e,y.initial=e,h.defaultState=e}else h.defaultState=p;return h};let ft=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ct=(e,t,r,a,n)=>o=>{i({target:[a,mt],params:[r?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:n.scope,meta:n.meta})};const mt=n({node:[xe({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),gt=['source','clock','target'],ht=(e,t)=>e+`: ${t} should be defined`;let yt=(e,t,a,n,i,o,s,l,d,f,g,h)=>{let b=!!i;r(!de(a)||!de(t),ht(e,'either source or clock'));let v=0;de(a)?v=1:F(a)||(a=m(a)),de(t)?t=a:(fe(t,e,'clock'),Array.isArray(t)&&(t=y(t))),v&&(a=t),l||s||(s=a.shortName);let k='none';(g||n)&&(F(n)?k='unit':(r(le(n),'`filter` should be function or unit'),k='fn')),i?(fe(i,e,'target'),ce(e,i)):'none'===k&&f&&E(a)&&E(t)?i=c(o?o($e(C(a)),$e(C(t))):$e(C(a)),{name:s,sid:h,or:l}):(i=p({name:s,derived:1,or:l}),u('sampleTarget',z(i)));let x=Ae(),w=[];if('unit'===k){let[r,a]=vt(n,i,t,x,e);w=[...bt(a),...bt(r)]}let[S,A]=vt(a,i,t,x,e),$=at(t,i,[u('sampleSourceLoader'),ve({from:M,target:x}),...bt(A),Se(S,1,d),...w,Se(x),'fn'===k&&Me(((e,t,{a:r})=>n(e,r)),1),o&&Me(me),u('sampleSourceUpward',b)],e,o);return ie(a,[$]),Object.assign($.meta,l,{joint:1}),i};const bt=e=>[Se(e),we(((e,t,{a:r})=>r),1)],vt=(e,t,r,a,i)=>{let o=E(e),s=o?C(e):Ae(),l=Ae(o);return o||n({parent:e,node:[ve({from:M,target:s}),ve({from:"value",store:1,target:l})],family:{owners:[e,t,r],links:t},meta:{op:i},regional:1}),u('sampleSource',l,s,a),[s,l]},kt=(e,t,r,a)=>{let n=e[t];n&&i({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},xt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!F(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||P(e)||E(e)||L(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));L(e)&&(t=e);let a=g();a.parentFork=Ee;let{fxCount:n}=t;U(n.scope.defers,a);let o=[],s=[];return L(e)||(U(o,e),U(s,T(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),U(o,n),U(s,null),i({target:o,params:s,scope:t}),a.req},exports.attach=e=>{let t;[e,t]=l(e,1);let{source:a,effect:n,mapParams:o,domain:d}=e;T(n)&&r(de(d),'`domain` can only be used with a plain function');let u=h(e,t);q(u,'attached',1);let p,{runner:f}=z(u).scope,c=we(((e,t,r)=>{let n,{params:s,req:l,handler:d}=e,p=u.finally,f=ct(s,l,0,p,r),c=r.a,m=T(d),g=1;if(o?[g,n]=ft(o,f,[s,c]):n=a&&m?c:s,g){if(!m)return e.args=[c,n],1;i({target:d,params:{params:n,req:{rs:ct(s,l,1,p,r),rj:f}},page:r.page,defer:1,meta:r.meta})}}),1,1);if(a){let e;E(a)?(e=a,ie(e,[u])):(e=m(a),ie(u,[e])),p=[Se(C(e)),c]}else p=[c];f.seq.splice(1,0,...p),u.use(n);let g=I(n);return g&&(Object.assign(D(u),s(u.shortName,g)),u.defaultConfig.parent=g),ot(n,u,"effect"),u},exports.clearNode=tt,exports.combine=m,exports.createApi=(...t)=>{let[[r,a],n]=l(t),i={};return e(a,((e,t)=>{let a=i[t]=p(t,{parent:I(r),config:n});r.on(a,e),ot(r,a)})),i},exports.createDomain=function r(a,o){let s=Xe({or:o,and:'string'==typeof a?{name:a}:a}),l=n({family:{type:"domain"},regional:1,parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent)}),d={history:{},graphite:l,hooks:{}};l.meta=st("domain",d,{parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent),or:{...s,derived:1}}),e({Event:p,Effect:h,Store:c,Domain:r},((e,r)=>{let a=r.toLowerCase(),n=p({named:`on${r}`});d.hooks[a]=n;let o=new Set;d.history[`${a}s`]=o,n.create=e=>(i(n,e),e),U(z(n).seq,we(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ie(d,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),I(e)||(e.parent=d)})),ie(d,[n]),d[`onCreate${r}`]=e=>(t(o,e),n.watch(e)),d[`create${r}`]=d[a]=(t,r)=>{let a=Xe({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let u=I(d);return u&&e(d.hooks,((e,t)=>at(e,u.hooks[t]))),null!=s&&s.domain&&s.domain.hooks.domain(d),d},exports.createEffect=h,exports.createEvent=p,exports.createNode=n,exports.createStore=c,exports.createWatch=({unit:e,fn:t,scope:r,batch:a})=>{let i=[ze.run({fn:e=>t(e)})];a&&i.unshift(ze.compute({priority:'sampler',batch:1})),E(e)&&i.unshift(ze.mov({store:e.stateRef,to:'stack'}));let o=Array.isArray(e)?e:[e];if(r){let e=[],t=r.additionalLinks;return o.forEach((r=>{let a=t[r.graphite.id]||[];t[r.graphite.id]=a;let o=n({node:x(i,r),meta:{watchOp:r.kind}});a.push(o),e.push((()=>{let e=a.indexOf(o);-1!==e&&a.splice(e,1),tt(o)}))})),d((()=>{e.forEach((e=>e()))}))}{let e=n({node:i,parent:o,family:{owners:o}});return d((()=>{tt(e)}))}},exports.fork=(e,a)=>{let i,o=e;B(e)&&(J(0,'fork(domain)','fork()'),i=e,o=a);let s=(e=>{let r=n({scope:{defers:[],inFlight:0,fxID:0},node:[we(((e,t,r)=>{I(r)?'dec'===R(I(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),ke({priority:"sampler",batch:1}),we(((e,r)=>{let{defers:a,fxID:n}=r;r.inFlight>0||0===a.length||Promise.resolve().then((()=>{r.fxID===n&&t(a.splice(0,a.length),(e=>{Le(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=n({node:[we(((e,t,r)=>{let a=I(r);if(a){let t=a.node;if(!R(t,'isCombine')||I(a)&&'combine'!==R(I(a).node,'op')){let a=O(r),n=t.scope.state.id,i=R(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=R(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),i=n({node:[we(((e,t,r)=>{let a=O(r);if(a){let e=I(r);e&&(!R(e.node,'isCombine')||I(e)&&'combine'!==R(I(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return Ue(Be,o,null,e).current;let t=z(e);return Ue(Be,o,t,t.scope.state,1).current},kind:"scope",graphite:n({family:{type:"domain",links:[r,a,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:a,warnSerializeNode:i};return o})(i);if(o){if(o.values){let{sidMap:e,unitMap:a,hasSidDoubles:n}=k(o.values,(e=>r(E(e)&&V(e),'Values map can contain only writable stores as keys')));Object.assign(s.values.sidMap,e),t(a,((e,t)=>{s.values.idMap[t.stateRef.id]=e;let r=R(t,'serialize'),a=R(t,'sid');'ignore'===r&&s.sidSerializeSettings.set(a,{ignore:1})})),s.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),s.hasSidDoubles=n}o.handlers&&(J(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),s.handlers=k(o.handlers,(e=>r(T(e),"Handlers map can contain only effects as keys"))))}return s},exports.forward=e=>{J(0,'forward','sample');let t='forward',[{from:r,to:a},i]=l(e,1);return fe(r,t,'"from"'),fe(a,t,'"to"'),ce(t,a,'to'),rt(n({parent:r,child:a,meta:{op:t,config:i},family:{},regional:1}))},exports.fromObservable=e=>{ue(e);let t=w in e?e[w]():e;r(t.subscribe,'expect observable to have .subscribe');let a=p(),n=rt(a);return t.subscribe({next:a,error:n,complete:n}),a},exports.guard=(...e)=>{J(0,'guard','sample');let[[t,r],a]=l(e);return r||(r=t,t=r.source),b(r,'guard'),yt('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},exports.hydrate=(e,{values:a})=>{r(se(a),'values property should be an object');let{sidMap:n,unitMap:o}=k(a),s=Object.getOwnPropertyNames(n),l={};t(o,((e,t)=>{l[t.stateRef.id]=t}));let d,u,p,f=[],c=[];L(e)?(d=e,p=1,r(d.cloneOf,'scope should be created from domain'),J(0,'hydrate(fork(domain), { values })','fork({ values })'),u=z(d.cloneOf)):B(e)?(J(0,'hydrate(domain, { values })','fork({ values })'),u=z(e)):r(0,'first argument of hydrate should be domain or scope'),v(u,((e,t)=>{if(t&&G(s,t)){U(f,e);let r=R(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),U(c,n[t])}else e.scope.state.id in l&&(U(f,e),U(c,o.get(l[e.scope.state.id])))}),1),i({target:f,params:c,scope:d}),p&&Object.assign(d.values.sidMap,n)},exports.is=W,exports.launch=i,exports.merge=y,exports.restore=(t,r,a)=>{if(E(t))return J(0,'restore($store)'),t;if(P(t)||T(t)){let e=I(t),n=c(r,{parent:e,name:t.shortName,and:a});return at(T(t)?t.doneData:t,n),e&&e.hooks.store(n),n}let n=Array.isArray(t)?[]:{};return e(t,((e,t)=>n[t]=E(e)?e:c(e,{name:t}))),n},exports.sample=(...e)=>{let t,r,a,n,[[i,o,s],d]=l(e),u=1;return de(o)&&se(i)&&b(i,"sample")&&(o=i.clock,s=i.fn,'batch'in i?u=i.batch:(J(!('greedy'in i),'greedy in sample','batch'),u=!i.greedy),n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),yt("sample",o,i,n,t,s,r,d,u,1,0,a)},exports.scopeBind=(e,{scope:t,safe:a}={})=>{r(t||Ee||a,'scopeBind: scope not found');let n=t||Ee;return T(e)?t=>{let r=g();return i({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(i({target:e,params:t,scope:n}),t)},exports.serialize=(t,a={})=>{t.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),r(!t.hasSidDoubles,'duplicate sid found in this scope');let n=a.ignore?a.ignore.map((({sid:e})=>e)):[],i={};return e(t.values.sidMap,((e,r)=>{var a;if(G(n,r))return;let o=t.sidIdMap[r],s=null!==(a=t.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:xt};s.ignore||(i[r]=(0,s.write)(o&&o in t.reg?t.reg[o].current:e))})),'onlyChanges'in a&&(J(0,'onlyChanges'),a.onlyChanges||(r(t.cloneOf,'scope should be created from domain'),v(z(t.cloneOf),((e,r)=>{r in i||G(n,r)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[r]=t.getState(e))})))),i},exports.setGraphInspector=e=>{Q=e},exports.setInspector=e=>{He=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(D(e),s(t,I(e)))},exports.split=(...t)=>{let a,i,o='split',[[s,d],f]=l(t),c=!d;c&&(a=s.cases,d=s.match,i=s.clock,s=s.source);let m=E(d),g=!F(d)&&le(d),h=!m&&!g&&se(d);r(F(s),'source must be a unit'),a||(a={}),c?e(a,((e,t)=>ce(o,e,`cases.${t}`))):(r(h,'match should be an object'),e(d,((e,t)=>a[t]=p({derived:1,named:`cases.${t}`,and:f}))),a.__=p({derived:1,named:'cases.__',and:f}));let y,b=new Set([].concat(s,i||[],Object.values(a))),v=Object.keys(m||g?a:d);if(m||g)m&&b.add(d),y=[m&&Se(C(d),0,1),ke({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:d(e));kt(t,G(v,a)?a:'__',e,r)}})];else if(h){let t=Ae({});t.type='shape';let r,a=[];e(d,((e,n)=>{if(F(e)){r=1,U(a,n),b.add(e);let i=at(e,[],[Se(t),we(((e,t,{a:r})=>r[n]=e))]);if(E(e)){t.current[n]=e.getState();let r=C(e);Ce(t,{from:r,field:n,type:'field'}),u('splitMatchStore',r,i)}}})),r&&u('splitBase',t),y=[r&&Se(t,0,1),Me(((e,t,r)=>{for(let n=0;n<v.length;n++){let i=v[n];if(G(a,i)?r.a[i]:d[i](e))return void kt(t,i,e,r)}kt(t,'__',e,r)}),1)]}else r(0,'expect match to be unit, function or object');let k=n({meta:{op:o},parent:i?[]:s,scope:a,node:y,family:{owners:Array.from(b)},regional:1});if(i&&yt(o,i,s,null,k,null,o,f,0,0,0),!c)return a},exports.step=ze,exports.version="23.0.0-rc.4",exports.withFactory=({sid:e,name:t,loc:r,method:i,fn:o})=>a(n({meta:{sidRoot:ne(e),sid:e,name:t,loc:r,method:i,type:'factory'}}),o),exports.withRegion=a; | ||
//# sourceMappingURL=effector.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e='undefined'!=typeof globalThis?globalThis:e||self).effector={})})(this,(e=>{function t(e,t){for(let r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function a(e,t){if(!e)throw Error(t)}function n(e,t){let r=_(e).meta||{};pe={id:_(e).id,parent:pe,value:e,template:r.template||ge(),sidRoot:r.sidRoot||pe&&pe.sidRoot,meta:r};try{return t()}finally{me('region'),pe=L(pe)}}function i({node:e=[],from:t,source:a,parent:n=t||a,to:i,target:o,child:s=i||o,scope:l={},meta:d={},family:u={type:'regular'},regional:f}={}){let c=be(n),p=be(u.links),m=be(u.owners),g=[];r(e,(e=>e&&ie(g,e)));let h={id:fe(),seq:g,next:be(s),meta:d,scope:l,family:{type:u.type||N,links:p,owners:m}};return r(p,(e=>ie(E(e),h))),r(m,(e=>ie(P(e),h))),r(c,(e=>ie(e.next,h))),f&&pe&&ye(V(pe),[h]),h}function o(e,t,a){let n,i=et,o=null,s=Qe;if(e.target&&(t=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),s=W(e)||s,e=e.target),s&&Qe&&s!==Qe&&(Qe=null),Array.isArray(e))for(let r=0;r<e.length;r++)He('pure',i,_(e[r]),o,t[r],s,n);else He('pure',i,_(e),o,t,s,n);if(a&&!Xe)return;let l,d,u,f,c,p,m={isRoot:Xe,currentPage:et,scope:Qe,isWatch:Ye,isPure:Ze};Xe=0;e:for(;f=Ge();){let{idx:e,stack:t,type:a}=f;u=t.node,et=c=t.page,Qe=W(t),c?p=c.reg:Qe&&(p=Qe.reg);let n=!!c,i=!!Qe,o={fail:0,scope:u.scope};l=d=0;for(let r=e;r<u.seq.length&&!l;r++){let s=u.seq[r];if(s.order){let{priority:n,barrierID:i}=s.order,o=i?c?`${c.fullID}_${i}`:i:0;if(r!==e||a!==n){i?Ke.has(o)||(Ke.add(o),Ue(r,t,n,i)):Ue(r,t,n);continue e}i&&Ke.delete(o)}switch(s.type){case'mov':{let e,r=s.data;switch(r.from){case O:e=V(t);break;case F:case'b':e=t[r.from];break;case q:e=r.store;break;case x:if(p&&!p[r.store.id])if(n){let e=at(c,r.store.id);t.page=c=e,e?p=e.reg:i?(lt(Qe,r.store,0,1,r.softRead),p=Qe.reg):p=void 0}else i&<(Qe,r.store,0,1,r.softRead);e=Pe(p&&p[r.store.id]||r.store)}switch(r.to){case O:t.value=e;break;case F:case'b':t[r.to]=e;break;case x:ot(c,Qe,u,r.target).current=e}break}case'compute':let e=s.data;if(e.fn){Ye='watch'===G(u,'op'),Ze=e.pure;let r=e.safe?(0,e.fn)(V(t),o.scope,t):dt(o,e.fn,t);e.filter?d=!r:t.value=r,Ye=m.isWatch,Ze=m.isPure}}l=o.fail||d}if(nt&&nt(t,o),!l){let e=V(t),a=W(t);if(r(u.next,(r=>{He('child',c,r,t,e,a)})),a){G(u,'needFxCounter')&&He('child',c,a.fxCount,t,e,a),G(u,'storeChange')&&He('child',c,a.storeChange,t,e,a),G(u,'warnSerialize')&&He('child',c,a.warnSerializeNode,t,e,a);let n=a.additionalLinks[u.id];n&&r(n,(r=>{He('child',c,r,t,e,a)}))}}}Xe=m.isRoot,et=m.currentPage,Qe=W(m)}function s(e,r="combine"){let a=r+'(',n='',i=0;return t(e,(e=>{i<25&&(null!=e&&(a+=n,a+=J(e)?U(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function l(e,t){let r,a,n=e;if(t){let n=U(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function d(e,t){let r=t?e:e[0];Se(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(ve(r)&&'and'in r){let r=d(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function u(e){let t=()=>e();return t.unsubscribe=()=>e(),t}function f(e,...t){let r=ge();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function c(e,t){let r=ut({or:t,and:'string'==typeof e?{name:e}:e}),n=(e,...t)=>(a(!G(n,'derived'),'call of derived event is not supported, use createEvent instead'),a(!Ze,'unit call from pure function is not supported, use operators like sample instead'),et?((e,t,r,a)=>{let n=et,i=null;if(t)for(i=et;i&&i.template!==t;)i=L(i);rt(i);let o=e.create(r,a);return rt(n),o})(n,s,e,t):n.create(e,t)),s=ge(),l=Object.assign(n,{graphite:i({meta:vt(r.actualOp||z,n,r),regional:1}),create:e=>(o({target:n,params:e,scope:Qe}),e),watch:e=>yt(n,e),map:e=>kt(n,I,e,[Fe()]),filter:e=>kt(n,"filter",e.fn?e:e.fn,[Fe(je,1)]),filterMap:e=>kt(n,'filterMap',e,[Fe(),qe((e=>!we(e)),1)]),prepend(e){a(n.targetable,'.prepend of derived event is not supported, call source event instead');let t=c('* \u2192 '+n.shortName,{parent:L(n)});return f('eventPrepend',_(t)),ht(t,n,[Fe()],'prepend',e),bt(n,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(l),H(l,'id',l.graphite.id),me(l.graphite),l}function p(e,t,n,i){return xe(n,t,'first argument'),a(ke(i),'second argument should be a function'),oe(!G(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`),r(Array.isArray(n)?n:[n],(t=>{e.off(t),B(e).set(t,gt(St(t,e,'on',$e,i)))})),e}function m(e,t){let n=ut(t),s=Ee(e),l=c({named:'updates',derived:1});f('storeBase',s);let d=s.id,u='skipVoid'in n,g=u&&!n.skipVoid;oe(!(u&&n.skipVoid),'{skipVoid: true}','updateFilter');let h={subscribers:new Map,updates:l,defaultState:e,stateRef:s,getState(){let e,t=s;if(et){let t=et;for(;t&&!t.reg[d];)t=L(t);t&&(e=t)}return!e&&Qe&&(lt(Qe,s,1),e=Qe),e&&(t=e.reg[d]),Pe(t)},setState:e=>o({target:h,params:e,defer:1,scope:Qe}),reset:(...e)=>(a(h.targetable,'.reset of derived store is not supported'),r(e,(e=>p(h,'.reset',e,(()=>h.defaultState)))),h),on:(e,t)=>(a(h.targetable,'.on of derived store is not supported'),p(h,'.on',e,t)),off(e){let t=B(h).get(e);return t&&(t(),B(h).delete(e)),h},map(e,t){let r,a;ve(e)&&(r=e,e=e.fn);let n=h.getState(),i=we(n);ge()?a=null:(!i||i&&g)&&(a=e(n));let o=m(a,{name:`${h.shortName} \u2192 *`,derived:1,...t,and:r}),l=St(h,o,I,je,e);return Te(T(o),{type:I,fn:e,from:s}),T(o).noInit=1,f('storeMap',s,l),o},watch(e,t){if(oe(!t,'watch second argument','sample'),!t||!J(e)){let t=yt(h,e);return f('storeWatch',s,e)||e(h.getState()),t}return a(ke(t),'second argument should be a function'),e.watch((e=>t(h.getState(),e)))}},y=vt(x,h,n),b=h.defaultConfig.updateFilter;h.graphite=i({scope:{state:s,fn:b},node:[qe(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),De(s),qe(((e,t,{a:r,b:a})=>{let n=we(e);return n&&!u&&console.error(wt),(n&&g||!n)&&(e!==r||a)}),1),b&&Fe(Ae,1),Ie({from:O,target:s})],child:l,meta:{...y,defaultState:e},regional:1}),H(h,'id',h.graphite.id),H(h,'rootStateRefId',d);let v=G(h,'serialize'),k=G(h,'derived'),w='ignore'===v,S=G(h,'sid');S&&(H(h,'storeChange',1),s.sid=S),S||w||k||H(h,'warnSerialize',1);let M=we(e);return a(k||!M||M&&g,wt),k&&M&&!u&&console.error(wt),ye(h,[l]),null!=n&&n.domain&&n.domain.hooks.store(h),k||(h.reinit=c({named:'reinit'}),h.reset(h.reinit)),s.meta=h.graphite.meta,me(h.graphite),h}function g(...e){let t,r,n;[e,n]=d(e);let i,o,s,l=e[e.length-1],u=!Q(l)&&ve(l),f=u&&l,c=u?e[e.length-2]:l;if(ke(c)?(r=e.slice(0,u?-2:-1),t=c):r=e,1===r.length){let e=r[0];Q(e)||(i=e,o=1)}if(!o&&(i=r,t)){s=1;let e=t;t=t=>e(...t)}return a(ve(i),'shape should be an object'),Mt(Array.isArray(i),!s,i,n,t,f)}function h(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function y(e,t={}){let r=ut(ke(e)?{handler:e}:e,t),n=c(ke(e)?{handler:e}:e,{...t,actualOp:A}),s=_(n);H(s,'op',n.kind=A),n.use=e=>(a(ke(e),'.use argument should be a function'),g.scope.handler=e,n),n.use.getCurrent=()=>g.scope.handler;let l=n.finally=c({named:'finally',derived:1}),d=n.done=l.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),u=n.fail=l.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),f=n.doneData=d.map({named:'doneData',fn:({result:e})=>e}),p=n.failData=u.map({named:'failData',fn:({error:e})=>e}),g=i({scope:{handler:n.defaultConfig.handler||(()=>a(0,`no handler used in ${n.getType()}`))},node:[qe(((e,t,r)=>{let a=t.handler,i=W(r);if(i){let e=i.handlers.unitMap.get(n)||i.handlers.sidMap[n.sid];e&&(a=e)}return e.handler=a,e}),0,1),qe((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=zt(e,t,1,l,i),s=zt(e,t,0,l,i),[d,u]=xt(r,s,a);d&&(ve(u)&&ke(u.then)?u.then(o,s):o(u))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=g,ie(s.seq,qe(((e,{runner:t},r)=>{let a=L(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:ce()}),o({target:t,params:a,defer:1,scope:W(r),meta:r.meta}),a.params}))),n.create=e=>{let t=h(),r={params:e,req:t};if(Qe&&!Ye){let e=Qe;t.req.finally((()=>{tt(e)})).catch((()=>{}))}return o({target:n,params:r,scope:Qe}),t.req};let y=n.inFlight=m(0,{serialize:'ignore',named:(G(n,'name')||n.graphite.id)+'.inFlight'}).on(n,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});H(l,'needFxCounter','dec'),H(n,'needFxCounter',1);let b=n.pending=y.map({fn:e=>e>0,named:'pending'});return ye(n,[l,d,u,f,p,b,y]),null!=r&&r.domain&&r.domain.hooks.effect(n),n}function b(e,t){xe(e,'merge','first argument');let r=c({name:s(e,'merge'),derived:1,and:t});return ht(e,r,[],'merge'),r}function v(e,t){let n=0;return r($t,(r=>{r in e&&(a(null!=e[r],jt(t,r)),n=1)})),n}function k(e,t,a){let n=[];(function e(i){ae(n,i)||(ie(n,i),G(i,'op')===x&&(a||G(i,'sid'))&&t(i,G(i,'sid')),r(i.next,e),r(E(i),e),r(P(i),e))})(e)}function w(e,t){let n=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(n instanceof Map){let e={};return r(n,((r,n)=>{a(J(n),'Map key should be a unit'),t&&t(n,r),n.sid&&(n.sid in e&&(o=1),e[n.sid]=r),i.set(n,r)})),{sidMap:e,unitMap:i,hasSidDoubles:o}}return{sidMap:n,unitMap:i}}function S(e,t){return Q(t)?[_e.mov({store:t.stateRef,to:'stack'}),...e]:e}let M='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',x='store',z='event',A='effect',$='domain',j='scope',C='sampler',N='crosslink',I='map',O='stack',R='barrier',q='value',D='sample',F='a',_=e=>e.graphite||e,E=e=>e.family.owners,P=e=>e.family.links,T=e=>e.stateRef,V=e=>e.value,B=e=>e.subscribers,L=e=>e.parent,W=e=>e.scope,G=(e,t)=>_(e).meta[t],H=(e,t,r)=>_(e).meta[t]=r,U=e=>e.compositeName,J=e=>(ke(e)||ve(e))&&'kind'in e;const K=e=>t=>J(t)&&t.kind===e;let Q=K(x),X=K(z),Y=K(A),Z=e=>J(e)&&!!e.targetable,ee=K($),te=K(j);var re={__proto__:null,unit:J,store:Q,event:X,effect:Y,targetable:Z,domain:ee,scope:te,attached:e=>Y(e)&&1==G(e,'attached')};let ae=(e,t)=>e.includes(t),ne=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},ie=(e,t)=>e.push(t),oe=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const se=()=>{let e=0;return()=>""+ ++e};let le,de=se(),ue=se(),fe=se(),ce=se(),pe=null,me=e=>{le&&le(e,pe)},ge=()=>pe&&pe.template,he=e=>(e&&pe&&pe.sidRoot&&(e=`${pe.sidRoot}|${e}`),e),ye=(e,t)=>{let a=_(e);r(t,(e=>{let t=_(e);a.family.type!==$&&(t.family.type=N),ie(E(t),a),ie(P(a),t)}))},be=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(_),ve=e=>'object'==typeof e&&null!==e,ke=e=>'function'==typeof e,we=e=>void 0===e,Se=e=>a(ve(e)||ke(e),'expect first argument be an object');const Me=(e,t,r,n)=>a(!(!ve(e)&&!ke(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${n}`);let xe=(e,t,a)=>{Array.isArray(e)?r(e,((e,r)=>Me(e,t,`${r} item of ${a}`,''))):Me(e,t,a,' or array of units')},ze=(e,t,n="target")=>r(be(t),(t=>a(!G(t,'derived'),`${e}: derived unit in "${n}" is not supported, use createStore/createEvent instead"`))),Ae=(e,{fn:t},{a:r})=>t(e,r),$e=(e,{fn:t},{a:r})=>t(r,e),je=(e,{fn:t})=>t(e);const Ce=(e,t,r,a)=>{let n={id:ue(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++Ne)),n};let Ne=0,Ie=({from:e=x,store:t,target:r,to:a=(r?x:O),batch:n,priority:i})=>Ce('mov',{from:e,store:t,to:a,target:r},i,n),Oe=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>Ce('compute',{fn:e,safe:a,filter:n,pure:i},r,t),Re=({fn:e})=>Oe({fn:e,priority:A}),qe=(e,t,r)=>Oe({fn:e,safe:1,filter:t,priority:r&&A}),De=(e,t,r)=>Ie({store:e,to:t?O:F,priority:r&&C,batch:1}),Fe=(e=je,t)=>Oe({fn:e,pure:1,filter:t}),_e={mov:Ie,compute:Oe,filter:({fn:e,pure:t})=>Oe({fn:e,filter:1,pure:t}),run:Re},Ee=e=>({id:ue(),current:e,initial:e}),Pe=({current:e})=>e,Te=(e,t)=>{e.before||(e.before=[]),ie(e.before,t)},Ve=null;const Be=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Je(e.v.type)>Je(t.v.type))&&(r=e,e=t,t=r),r=Be(e.r,t),e.r=e.l,e.l=r,e},Le=[];let We=0;for(;We<6;)ie(Le,{first:null,last:null,size:0}),We+=1;const Ge=()=>{for(let e=0;e<6;e++){let t=Le[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=Ve.v;return Ve=Be(Ve.l,Ve.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},He=(e,t,r,a,n,i,o)=>Ue(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),Ue=(e,t,r,a=0)=>{let n=Je(r),i=Le[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?Ve=Be(Ve,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Je=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case R:return 3;case C:return 4;case A:return 5;default:return-1}},Ke=new Set;let Qe,Xe=1,Ye=0,Ze=0,et=null,tt=e=>{Qe=e},rt=e=>{et=e};const at=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=L(e);if(e)return e}return null};let nt,ot=(e,t,r,a,n)=>{let i=at(e,a.id);return i?i.reg[a.id]:t?(lt(t,a,n),t.reg[a.id]):a};const st=e=>e;let lt=(e,t,a,n,i)=>{var o;let s=e.reg;if(s[t.id])return;let l=t.sid,d=null==t||null===(o=t.meta)||void 0===o?void 0:o.serialize,u=e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||st,f={id:t.id,current:t.initial,meta:t.meta};if(f.id in e.values.idMap)f.current=e.values.idMap[f.id];else if(l&&l in e.values.sidMap&&!(l in e.sidIdMap))f.current=u(e.values.sidMap[l]);else if(t.before&&!i){let i=0,o=a||!t.noInit||n;r(t.before,(t=>{switch(t.type){case I:{let r=t.from;if(r||t.fn){r&<(e,r,a,n);let i=r&&s[r.id].current;o&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),lt(e,t.from,a,n),o&&(f.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=t.id),s[t.id]=f};const dt=(e,t,r)=>{try{return t(V(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let ut=(e,r={})=>(ve(e)&&(ut(e.or,r),t(e,((e,t)=>{we(e)||'or'===t||'and'===t||(r[t]=e)})),ut(e.and,r)),r);const ft=(e,t)=>{ne(e.next,t),ne(E(e),t),ne(P(e),t)},ct=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=P(e);for(;a=n.pop();)ft(a,e),(t||r&&'sample'!==G(e,'op')||a.family.type===N)&&ct(a,t,'on'!==G(a,'op')&&r);for(n=E(e);a=n.pop();)ft(a,e),r&&a.family.type===N&&ct(a,t,'on'!==G(a,'op')&&r)},pt=e=>e.clear();let mt=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),Q(e))pt(B(e));else if(ee(e)){r=1;let t=e.history;pt(t.events),pt(t.effects),pt(t.stores),pt(t.domains)}ct(_(e),!!t,r)},gt=e=>u((()=>mt(e))),ht=(e,t,r,a,n)=>i({node:r,parent:e,child:t,scope:{fn:n},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),yt=(e,t)=>(a(ke(t),'.watch argument should be a function'),gt(i({scope:{fn:t},node:[Re({fn:je})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),bt=(e,t,r=z)=>{L(e)&&L(e).hooks[r](t)},vt=(e,t,r)=>{let a=ut(r),n=e===$,i=de(),{sid:o=null,named:s=null,domain:d=null,parent:u=d}=a,f=s||a.name||(n?'':i),c=l(f,u),p={op:t.kind=e,name:t.shortName=f,sid:t.sid=he(o),named:s,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.targetable=!a.derived,t.parent=u,t.compositeName=c,t.defaultConfig=a,t.getType=()=>(oe(0,'getType','compositeName.fullName'),c.fullName),!n){t.subscribe=e=>(Se(e),t.watch(ke(e)?e:t=>e.next&&e.next(t))),t[M]=()=>t;let e=ge();e&&(p.nativeTemplate=e)}return p};const kt=(e,t,r,a)=>{let n;ve(r)&&(n=r,r=r.fn);let i=c({name:`${e.shortName} \u2192 *`,derived:1,and:n});return ht(e,i,a,t,r),i};let wt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option';const St=(e,t,r,a,n)=>{let i=T(t),o=Ie({store:i,to:F,priority:'read'});r===I&&(o.data.softRead=1);let s=[o,Fe(a)];return f('storeOnMap',i,s,Q(e)&&T(e)),ht(e,t,s,r,n)},Mt=(e,r,n,i,o,l)=>{let d=e?e=>[...e]:e=>({...e}),u=e?[]:{},c=d(u),p=Ee(c),g=Ee(1);p.type=e?'list':'shape',p.noInit=1,f('combineBase',p,g);let h=m(c,{name:s(n),derived:1,...l,and:i}),y=T(h);y.noInit=1,H(h,'isCombine',1);let b=De(p);b.order={priority:'barrier'};let v=Ie({store:y,to:'b',priority:'read'});v.data.softRead=1;let k=[qe(((e,t,r)=>(r.scope&&!r.scope.reg[p.id]&&(r.c=1),e))),b,Ie({store:g,to:'b'}),qe(((e,{key:t},a)=>{if(a.c||e!==a.a[t])return r&&a.b&&(a.a=d(a.a)),a.a[t]=e,1}),1),Ie({from:F,target:p}),Ie({from:q,store:0,target:g}),Ie({from:q,store:1,target:g,priority:R,batch:1}),De(p,1,1),o&&Fe(),v];if(t(n,((e,t)=>{if(!Q(e))return a(!J(e)&&!we(e),`combine expects a store in a field ${t}`),void(c[t]=u[t]=e);u[t]=e.defaultState,c[t]=e.getState();let r=ht(e,h,k,'combine',o);r.scope.key=t;let n=T(e);Te(p,{type:'field',field:t,from:n}),f('combineField',n,r)})),h.defaultShape=n,Te(y,{type:I,from:p,fn:o}),!ge())if(o){let e=o(c);!we(e)||l&&"skipVoid"in l||console.error(wt),y.current=e,y.initial=e,h.defaultState=e}else h.defaultState=u;return h};let xt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},zt=(e,t,r,a,n)=>i=>{o({target:[a,At],params:[r?{status:'done',params:e,result:i}:{status:'fail',params:e,error:i},{value:i,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:n.scope,meta:n.meta})};const At=i({node:[Re({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),$t=['source','clock','target'],jt=(e,t)=>e+`: ${t} should be defined`;let Ct=(e,t,r,n,i,o,s,l,d,u,p,h)=>{let y=!!i;a(!we(r)||!we(t),jt(e,'either source or clock'));let v=0;we(r)?v=1:J(r)||(r=g(r)),we(t)?t=r:(xe(t,e,'clock'),Array.isArray(t)&&(t=b(t))),v&&(r=t),l||s||(s=r.shortName);let k='none';(p||n)&&(J(n)?k='unit':(a(ke(n),'`filter` should be function or unit'),k='fn')),i?(xe(i,e,'target'),ze(e,i)):'none'===k&&u&&Q(r)&&Q(t)?i=m(o?o(Pe(T(r)),Pe(T(t))):Pe(T(r)),{name:s,sid:h,or:l}):(i=c({name:s,derived:1,or:l}),f('sampleTarget',_(i)));let w=Ee(),S=[];if('unit'===k){let[r,a]=It(n,i,t,w,e);S=[...Nt(a),...Nt(r)]}let[M,x]=It(r,i,t,w,e),z=ht(t,i,[f('sampleSourceLoader'),Ie({from:O,target:w}),...Nt(x),De(M,1,d),...S,De(w),'fn'===k&&Fe(((e,t,{a:r})=>n(e,r)),1),o&&Fe(Ae),f('sampleSourceUpward',y)],e,o);return ye(r,[z]),Object.assign(z.meta,l,{joint:1}),i};const Nt=e=>[De(e),qe(((e,t,{a:r})=>r),1)],It=(e,t,r,a,n)=>{let o=Q(e),s=o?T(e):Ee(),l=Ee(o);return o||i({parent:e,node:[Ie({from:O,target:s}),Ie({from:q,store:1,target:l})],family:{owners:[e,t,r],links:t},meta:{op:n},regional:1}),f('sampleSource',l,s,a),[s,l]},Ot=(e,t,r,a)=>{let n=e[t];n&&o({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},Rt=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!J(e))return Promise.reject(new Error('first argument should be unit'));if(!(Y(e)||X(e)||Q(e)||te(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));te(e)&&(t=e);let a=h();a.parentFork=Qe;let{fxCount:n}=t;ie(n.scope.defers,a);let i=[],s=[];return te(e)||(ie(i,e),ie(s,Y(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),ie(i,n),ie(s,null),o({target:i,params:s,scope:t}),a.req},e.attach=e=>{let t;[e,t]=d(e,1);let{source:r,effect:n,mapParams:i,domain:s}=e;Y(n)&&a(we(s),'`domain` can only be used with a plain function');let u=y(e,t);H(u,'attached',1);let f,{runner:c}=_(u).scope,p=qe(((e,t,a)=>{let n,{params:s,req:l,handler:d}=e,f=u.finally,c=zt(s,l,0,f,a),p=a.a,m=Y(d),g=1;if(i?[g,n]=xt(i,c,[s,p]):n=r&&m?p:s,g){if(!m)return e.args=[p,n],1;o({target:d,params:{params:n,req:{rs:zt(s,l,1,f,a),rj:c}},page:a.page,defer:1,meta:a.meta})}}),1,1);if(r){let e;Q(r)?(e=r,ye(e,[u])):(e=g(r),ye(u,[e])),f=[De(T(e)),p]}else f=[p];c.seq.splice(1,0,...f),u.use(n);let m=L(n);return m&&(Object.assign(U(u),l(u.shortName,m)),u.defaultConfig.parent=m),bt(n,u,A),u},e.clearNode=mt,e.combine=g,e.createApi=(...e)=>{let[[r,a],n]=d(e),i={};return t(a,((e,t)=>{let a=i[t]=c(t,{parent:L(r),config:n});r.on(a,e),bt(r,a)})),i},e.createDomain=function e(a,n){let s=ut({or:n,and:'string'==typeof a?{name:a}:a}),l=i({family:{type:$},regional:1,parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent)}),d={history:{},graphite:l,hooks:{}};l.meta=vt($,d,{parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent),or:{...s,derived:1}}),t({Event:c,Effect:y,Store:m,Domain:e},((e,t)=>{let a=t.toLowerCase(),n=(e=>c({named:e}))(`on${t}`);d.hooks[a]=n;let i=new Set;d.history[`${a}s`]=i,n.create=e=>(o(n,e),e),ie(_(n).seq,qe(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ye(d,[e]),i.add(e),e.ownerSet||(e.ownerSet=i),L(e)||(e.parent=d)})),ye(d,[n]),d[`onCreate${t}`]=e=>(r(i,e),n.watch(e)),d[`create${t}`]=d[a]=(t,r)=>{let a=ut({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let u=L(d);return u&&t(d.hooks,((e,t)=>ht(e,u.hooks[t]))),null!=s&&s.domain&&s.domain.hooks.domain(d),d},e.createEffect=y,e.createEvent=c,e.createNode=i,e.createStore=m,e.createWatch=({unit:e,fn:t,scope:r,batch:a})=>{let n=[_e.run({fn:e=>t(e)})];a&&n.unshift(_e.compute({priority:'sampler',batch:1})),Q(e)&&n.unshift(_e.mov({store:e.stateRef,to:'stack'}));let o=Array.isArray(e)?e:[e];if(r){let e=[],t=r.additionalLinks;return o.forEach((r=>{let a=t[r.graphite.id]||[];t[r.graphite.id]=a;let o=i({node:S(n,r),meta:{watchOp:r.kind}});a.push(o),e.push((()=>{let e=a.indexOf(o);-1!==e&&a.splice(e,1),mt(o)}))})),u((()=>{e.forEach((e=>e()))}))}{let e=i({node:n,parent:o,family:{owners:o}});return u((()=>{mt(e)}))}},e.fork=(e,t)=>{let n,o=e;ee(e)&&(oe(0,'fork(domain)','fork()'),n=e,o=t);let s=(e=>{let t=i({scope:{defers:[],inFlight:0,fxID:0},node:[qe(((e,t,r)=>{L(r)?'dec'===G(L(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Oe({priority:C,batch:1}),qe(((e,t)=>{let{defers:a,fxID:n}=t;t.inFlight>0||0===a.length||Promise.resolve().then((()=>{t.fxID===n&&r(a.splice(0,a.length),(e=>{tt(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=i({node:[qe(((e,t,r)=>{let a=L(r);if(a){let t=a.node;if(!G(t,'isCombine')||L(a)&&'combine'!==G(L(a).node,'op')){let a=W(r),n=t.scope.state.id,i=G(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=G(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),n=i({node:[qe(((e,t,r)=>{let a=W(r);if(a){let e=L(r);e&&(!G(e.node,'isCombine')||L(e)&&'combine'!==G(L(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return ot(et,o,null,e).current;let t=_(e);return ot(et,o,t,t.scope.state,1).current},kind:j,graphite:i({family:{type:$,links:[t,a,n]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:a,warnSerializeNode:n};return o})(n);if(o){if(o.values){let{sidMap:e,unitMap:t,hasSidDoubles:n}=w(o.values,(e=>a(Q(e)&&Z(e),'Values map can contain only writable stores as keys')));Object.assign(s.values.sidMap,e),r(t,((e,t)=>{s.values.idMap[t.stateRef.id]=e;let r=G(t,'serialize'),a=G(t,'sid');'ignore'===r&&s.sidSerializeSettings.set(a,{ignore:1})})),s.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),s.hasSidDoubles=n}o.handlers&&(oe(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),s.handlers=w(o.handlers,(e=>a(Y(e),"Handlers map can contain only effects as keys"))))}return s},e.forward=e=>{oe(0,'forward','sample');let t='forward',[{from:r,to:a},n]=d(e,1);return xe(r,t,'"from"'),xe(a,t,'"to"'),ze(t,a,'to'),gt(i({parent:r,child:a,meta:{op:t,config:n},family:{},regional:1}))},e.fromObservable=e=>{Se(e);let t=M in e?e[M]():e;a(t.subscribe,'expect observable to have .subscribe');let r=c(),n=gt(r);return t.subscribe({next:r,error:n,complete:n}),r},e.guard=(...e)=>{oe(0,'guard','sample');let[[t,r],a]=d(e);return r||(r=t,t=r.source),v(r,'guard'),Ct('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{a(ve(t),'values property should be an object');let{sidMap:n,unitMap:i}=w(t),s=Object.getOwnPropertyNames(n),l={};r(i,((e,t)=>{l[t.stateRef.id]=t}));let d,u,f,c=[],p=[];te(e)?(d=e,f=1,a(d.cloneOf,'scope should be created from domain'),oe(0,'hydrate(fork(domain), { values })','fork({ values })'),u=_(d.cloneOf)):ee(e)?(oe(0,'hydrate(domain, { values })','fork({ values })'),u=_(e)):a(0,'first argument of hydrate should be domain or scope'),k(u,((e,t)=>{if(t&&ae(s,t)){ie(c,e);let r=G(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),ie(p,n[t])}else e.scope.state.id in l&&(ie(c,e),ie(p,i.get(l[e.scope.state.id])))}),1),o({target:c,params:p,scope:d}),f&&Object.assign(d.values.sidMap,n)},e.is=re,e.launch=o,e.merge=b,e.restore=(e,r,a)=>{if(Q(e))return oe(0,'restore($store)'),e;if(X(e)||Y(e)){let t=L(e),n=m(r,{parent:t,name:e.shortName,and:a});return ht(Y(e)?e.doneData:e,n),t&&t.hooks.store(n),n}let n=Array.isArray(e)?[]:{};return t(e,((e,t)=>n[t]=Q(e)?e:m(e,{name:t}))),n},e.sample=(...e)=>{let t,r,a,n,[[i,o,s],l]=d(e),u=1;return we(o)&&ve(i)&&v(i,D)&&(o=i.clock,s=i.fn,'batch'in i?u=i.batch:(oe(!('greedy'in i),'greedy in sample','batch'),u=!i.greedy),n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),Ct(D,o,i,n,t,s,r,l,u,1,0,a)},e.scopeBind=(e,{scope:t,safe:r}={})=>{a(t||Qe||r,'scopeBind: scope not found');let n=t||Qe;return Y(e)?t=>{let r=h();return o({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(o({target:e,params:t,scope:n}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),a(!e.hasSidDoubles,'duplicate sid found in this scope');let n=r.ignore?r.ignore.map((({sid:e})=>e)):[],i={};return t(e.values.sidMap,((t,r)=>{var a;if(ae(n,r))return;let o=e.sidIdMap[r],s=null!==(a=e.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:Rt};s.ignore||(i[r]=(0,s.write)(o&&o in e.reg?e.reg[o].current:t))})),'onlyChanges'in r&&(oe(0,'onlyChanges'),r.onlyChanges||(a(e.cloneOf,'scope should be created from domain'),k(_(e.cloneOf),((t,r)=>{r in i||ae(n,r)||G(t,'isCombine')||'ignore'===G(t,'serialize')||(i[r]=e.getState(t))})))),i},e.setGraphInspector=e=>{le=e},e.setInspector=e=>{nt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(U(e),l(t,L(e)))},e.split=(...e)=>{let r,n,o='split',[[s,l],u]=d(e),p=!l;p&&(r=s.cases,l=s.match,n=s.clock,s=s.source);let m=Q(l),g=!J(l)&&ke(l),h=!m&&!g&&ve(l);a(J(s),'source must be a unit'),r||(r={}),p?t(r,((e,t)=>ze(o,e,`cases.${t}`))):(a(h,'match should be an object'),t(l,((e,t)=>r[t]=c({derived:1,named:`cases.${t}`,and:u}))),r.__=c({derived:1,named:'cases.__',and:u}));let y,b=new Set([].concat(s,n||[],Object.values(r))),v=Object.keys(m||g?r:l);if(m||g)m&&b.add(l),y=[m&&De(T(l),0,1),Oe({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:l(e));Ot(t,ae(v,a)?a:'__',e,r)}})];else if(h){let e=Ee({});e.type='shape';let r,a=[];t(l,((t,n)=>{if(J(t)){r=1,ie(a,n),b.add(t);let i=ht(t,[],[De(e),qe(((e,t,{a:r})=>r[n]=e))]);if(Q(t)){e.current[n]=t.getState();let r=T(t);Te(e,{from:r,field:n,type:'field'}),f('splitMatchStore',r,i)}}})),r&&f('splitBase',e),y=[r&&De(e,0,1),Fe(((e,t,r)=>{for(let n=0;n<v.length;n++){let i=v[n];if(ae(a,i)?r.a[i]:l[i](e))return void Ot(t,i,e,r)}Ot(t,'__',e,r)}),1)]}else a(0,'expect match to be unit, function or object');let k=i({meta:{op:o},parent:n?[]:s,scope:r,node:y,family:{owners:Array.from(b)},regional:1});if(n&&Ct(o,n,s,null,k,null,o,u,0,0,0),!p)return r},e.step=_e,e.version="23.0.0-rc.3",e.withFactory=({sid:e,name:t,loc:r,method:a,fn:o})=>n(i({meta:{sidRoot:he(e),sid:e,name:t,loc:r,method:a,type:'factory'}}),o),e.withRegion=n,Object.defineProperty(e,'__esModule',{value:1})})); | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e='undefined'!=typeof globalThis?globalThis:e||self).effector={})})(this,(e=>{function t(e,t){for(let r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function a(e,t){if(!e)throw Error(t)}function n(e,t){let r=_(e).meta||{};pe={id:_(e).id,parent:pe,value:e,template:r.template||ge(),sidRoot:r.sidRoot||pe&&pe.sidRoot,meta:r};try{return t()}finally{me('region'),pe=L(pe)}}function i({node:e=[],from:t,source:a,parent:n=t||a,to:i,target:o,child:s=i||o,scope:l={},meta:d={},family:u={type:'regular'},regional:f}={}){let c=be(n),p=be(u.links),m=be(u.owners),g=[];r(e,(e=>e&&ie(g,e)));let h={id:fe(),seq:g,next:be(s),meta:d,scope:l,family:{type:u.type||N,links:p,owners:m}};return r(p,(e=>ie(E(e),h))),r(m,(e=>ie(P(e),h))),r(c,(e=>ie(e.next,h))),f&&pe&&ye(V(pe),[h]),h}function o(e,t,a){let n,i=et,o=null,s=Qe;if(e.target&&(t=e.params,a=e.defer,n=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),s=W(e)||s,e=e.target),s&&Qe&&s!==Qe&&(Qe=null),Array.isArray(e))for(let r=0;r<e.length;r++)He('pure',i,_(e[r]),o,t[r],s,n);else He('pure',i,_(e),o,t,s,n);if(a&&!Xe)return;let l,d,u,f,c,p,m={isRoot:Xe,currentPage:et,scope:Qe,isWatch:Ye,isPure:Ze};Xe=0;e:for(;f=Ge();){let{idx:e,stack:t,type:a}=f;u=t.node,et=c=t.page,Qe=W(t),c?p=c.reg:Qe&&(p=Qe.reg);let n=!!c,i=!!Qe,o={fail:0,scope:u.scope};l=d=0;for(let r=e;r<u.seq.length&&!l;r++){let s=u.seq[r];if(s.order){let{priority:n,barrierID:i}=s.order,o=i?c?`${c.fullID}_${i}`:i:0;if(r!==e||a!==n){i?Ke.has(o)||(Ke.add(o),Ue(r,t,n,i)):Ue(r,t,n);continue e}i&&Ke.delete(o)}switch(s.type){case'mov':{let e,r=s.data;switch(r.from){case O:e=V(t);break;case F:case'b':e=t[r.from];break;case q:e=r.store;break;case x:if(p&&!p[r.store.id])if(n){let e=at(c,r.store.id);t.page=c=e,e?p=e.reg:i?(lt(Qe,r.store,0,1,r.softRead),p=Qe.reg):p=void 0}else i&<(Qe,r.store,0,1,r.softRead);e=Pe(p&&p[r.store.id]||r.store)}switch(r.to){case O:t.value=e;break;case F:case'b':t[r.to]=e;break;case x:ot(c,Qe,u,r.target).current=e}break}case'compute':let e=s.data;if(e.fn){Ye='watch'===G(u,'op'),Ze=e.pure;let r=e.safe?(0,e.fn)(V(t),o.scope,t):dt(o,e.fn,t);e.filter?d=!r:t.value=r,Ye=m.isWatch,Ze=m.isPure}}l=o.fail||d}if(nt&&nt(t,o),!l){let e=V(t),a=W(t);if(r(u.next,(r=>{He('child',c,r,t,e,a)})),a){G(u,'needFxCounter')&&He('child',c,a.fxCount,t,e,a),G(u,'storeChange')&&He('child',c,a.storeChange,t,e,a),G(u,'warnSerialize')&&He('child',c,a.warnSerializeNode,t,e,a);let n=a.additionalLinks[u.id];n&&r(n,(r=>{He('child',c,r,t,e,a)}))}}}Xe=m.isRoot,et=m.currentPage,Qe=W(m)}function s(e,r="combine"){let a=r+'(',n='',i=0;return t(e,(e=>{i<25&&(null!=e&&(a+=n,a+=J(e)?U(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function l(e,t){let r,a,n=e;if(t){let n=U(t);0===e.length?(r=n.path,a=n.fullName):(r=n.path.concat([e]),a=0===n.fullName.length?e:n.fullName+'/'+e)}else r=0===e.length?[]:[e],a=e;return{shortName:n,fullName:a,path:r}}function d(e,t){let r=t?e:e[0];Se(r);let a=r.or,n=r.and;if(n){let r=t?n:n[0];if(ve(r)&&'and'in r){let r=d(n,t);e=r[0],a={...a,...r[1]}}else e=n}return[e,a]}function u(e){let t=()=>e();return t.unsubscribe=()=>e(),t}function f(e,...t){let r=ge();if(r){let a=r.handlers[e];if(a)return a(r,...t)}}function c(e,t){let r=ut({or:t,and:'string'==typeof e?{name:e}:e}),n=(e,...t)=>(a(!G(n,'derived'),'call of derived event is not supported, use createEvent instead'),a(!Ze,'unit call from pure function is not supported, use operators like sample instead'),et?((e,t,r,a)=>{let n=et,i=null;if(t)for(i=et;i&&i.template!==t;)i=L(i);rt(i);let o=e.create(r,a);return rt(n),o})(n,s,e,t):n.create(e,t)),s=ge(),l=Object.assign(n,{graphite:i({meta:vt(r.actualOp||z,n,r),regional:1}),create:e=>(o({target:n,params:e,scope:Qe}),e),watch:e=>yt(n,e),map:e=>kt(n,I,e,[Fe()]),filter:e=>kt(n,"filter",e.fn?e:e.fn,[Fe(je,1)]),filterMap:e=>kt(n,'filterMap',e,[Fe(),qe((e=>!we(e)),1)]),prepend(e){a(n.targetable,'.prepend of derived event is not supported, call source event instead');let t=c('* \u2192 '+n.shortName,{parent:L(n)});return f('eventPrepend',_(t)),ht(t,n,[Fe()],'prepend',e),bt(n,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(l),H(l,'id',l.graphite.id),me(l.graphite),l}function p(e,t,n,i){return xe(n,t,'first argument'),a(ke(i),'second argument should be a function'),oe(!G(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`),r(Array.isArray(n)?n:[n],(t=>{e.off(t),B(e).set(t,gt(St(t,e,'on',$e,i)))})),e}function m(e,t){let n=ut(t),s=Ee(e),l=c({named:'updates',derived:1});f('storeBase',s);let d=s.id,u='skipVoid'in n,g=u&&!n.skipVoid;oe(!(u&&n.skipVoid),'{skipVoid: true}','updateFilter');let h={subscribers:new Map,updates:l,defaultState:e,stateRef:s,getState(){let e,t=s;if(et){let t=et;for(;t&&!t.reg[d];)t=L(t);t&&(e=t)}return!e&&Qe&&(lt(Qe,s,1),e=Qe),e&&(t=e.reg[d]),Pe(t)},setState:e=>o({target:h,params:e,defer:1,scope:Qe}),reset:(...e)=>(a(h.targetable,'.reset of derived store is not supported'),r(e,(e=>p(h,'.reset',e,(()=>h.defaultState)))),h),on:(e,t)=>(a(h.targetable,'.on of derived store is not supported'),p(h,'.on',e,t)),off(e){let t=B(h).get(e);return t&&(t(),B(h).delete(e)),h},map(e,t){let r,a;ve(e)&&(r=e,e=e.fn);let n=h.getState(),i=we(n);ge()?a=null:(!i||i&&g)&&(a=e(n));let o=m(a,{name:`${h.shortName} \u2192 *`,derived:1,...t,and:r}),l=St(h,o,I,je,e);return Te(T(o),{type:I,fn:e,from:s}),T(o).noInit=1,f('storeMap',s,l),o},watch(e,t){if(oe(!t,'watch second argument','sample'),!t||!J(e)){let t=yt(h,e);return f('storeWatch',s,e)||e(h.getState()),t}return a(ke(t),'second argument should be a function'),e.watch((e=>t(h.getState(),e)))}},y=vt(x,h,n),b=h.defaultConfig.updateFilter;h.graphite=i({scope:{state:s,fn:b},node:[qe(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),De(s),qe(((e,t,{a:r,b:a})=>{let n=we(e);return n&&!u&&console.error(wt),(n&&g||!n)&&(e!==r||a)}),1),b&&Fe(Ae,1),Ie({from:O,target:s})],child:l,meta:{...y,defaultState:e},regional:1}),H(h,'id',h.graphite.id),H(h,'rootStateRefId',d);let v=G(h,'serialize'),k=G(h,'derived'),w='ignore'===v,S=G(h,'sid');S&&(H(h,'storeChange',1),s.sid=S),S||w||k||H(h,'warnSerialize',1);let M=we(e);return a(k||!M||M&&g,wt),k&&M&&!u&&console.error(wt),ye(h,[l]),null!=n&&n.domain&&n.domain.hooks.store(h),k||(h.reinit=c({named:'reinit'}),h.reset(h.reinit)),s.meta=h.graphite.meta,me(h.graphite),h}function g(...e){let t,r,n;[e,n]=d(e);let i,o,s,l=e[e.length-1],u=!Q(l)&&ve(l),f=u&&l,c=u?e[e.length-2]:l;if(ke(c)?(r=e.slice(0,u?-2:-1),t=c):r=e,1===r.length){let e=r[0];Q(e)||(i=e,o=1)}if(!o&&(i=r,t)){s=1;let e=t;t=t=>e(...t)}return a(ve(i),'shape should be an object'),Mt(Array.isArray(i),!s,i,n,t,f)}function h(){let e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function y(e,t={}){let r=ut(ke(e)?{handler:e}:e,t),n=c(ke(e)?{handler:e}:e,{...t,actualOp:A}),s=_(n);H(s,'op',n.kind=A),n.use=e=>(a(ke(e),'.use argument should be a function'),g.scope.handler=e,n),n.use.getCurrent=()=>g.scope.handler;let l=n.finally=c({named:'finally',derived:1}),d=n.done=l.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),u=n.fail=l.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),f=n.doneData=d.map({named:'doneData',fn:({result:e})=>e}),p=n.failData=u.map({named:'failData',fn:({error:e})=>e}),g=i({scope:{handler:n.defaultConfig.handler||(()=>a(0,`no handler used in ${n.getType()}`))},node:[qe(((e,t,r)=>{let a=t.handler,i=W(r);if(i){let e=i.handlers.unitMap.get(n)||i.handlers.sidMap[n.sid];e&&(a=e)}return e.handler=a,e}),0,1),qe((({params:e,req:t,handler:r,args:a=[e]},n,i)=>{let o=zt(e,t,1,l,i),s=zt(e,t,0,l,i),[d,u]=xt(r,s,a);d&&(ve(u)&&ke(u.then)?u.then(o,s):o(u))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=g,ie(s.seq,qe(((e,{runner:t},r)=>{let a=L(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:ce()}),o({target:t,params:a,defer:1,scope:W(r),meta:r.meta}),a.params}))),n.create=e=>{let t=h(),r={params:e,req:t};if(Qe&&!Ye){let e=Qe;t.req.finally((()=>{tt(e)})).catch((()=>{}))}return o({target:n,params:r,scope:Qe}),t.req};let y=n.inFlight=m(0,{serialize:'ignore',named:(G(n,'name')||n.graphite.id)+'.inFlight'}).on(n,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});H(l,'needFxCounter','dec'),H(n,'needFxCounter',1);let b=n.pending=y.map({fn:e=>e>0,named:'pending'});return ye(n,[l,d,u,f,p,b,y]),null!=r&&r.domain&&r.domain.hooks.effect(n),n}function b(e,t){xe(e,'merge','first argument');let r=c({name:s(e,'merge'),derived:1,and:t});return ht(e,r,[],'merge'),r}function v(e,t){let n=0;return r($t,(r=>{r in e&&(a(null!=e[r],jt(t,r)),n=1)})),n}function k(e,t,a){let n=[];(function e(i){ae(n,i)||(ie(n,i),G(i,'op')===x&&(a||G(i,'sid'))&&t(i,G(i,'sid')),r(i.next,e),r(E(i),e),r(P(i),e))})(e)}function w(e,t){let n=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(n instanceof Map){let e={};return r(n,((r,n)=>{a(J(n),'Map key should be a unit'),t&&t(n,r),n.sid&&(n.sid in e&&(o=1),e[n.sid]=r),i.set(n,r)})),{sidMap:e,unitMap:i,hasSidDoubles:o}}return{sidMap:n,unitMap:i}}function S(e,t){return Q(t)?[_e.mov({store:t.stateRef,to:'stack'}),...e]:e}let M='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',x='store',z='event',A='effect',$='domain',j='scope',C='sampler',N='crosslink',I='map',O='stack',R='barrier',q='value',D='sample',F='a',_=e=>e.graphite||e,E=e=>e.family.owners,P=e=>e.family.links,T=e=>e.stateRef,V=e=>e.value,B=e=>e.subscribers,L=e=>e.parent,W=e=>e.scope,G=(e,t)=>_(e).meta[t],H=(e,t,r)=>_(e).meta[t]=r,U=e=>e.compositeName,J=e=>(ke(e)||ve(e))&&'kind'in e;const K=e=>t=>J(t)&&t.kind===e;let Q=K(x),X=K(z),Y=K(A),Z=e=>J(e)&&!!e.targetable,ee=K($),te=K(j);var re={__proto__:null,unit:J,store:Q,event:X,effect:Y,targetable:Z,domain:ee,scope:te,attached:e=>Y(e)&&1==G(e,'attached')};let ae=(e,t)=>e.includes(t),ne=(e,t)=>{let r=e.indexOf(t);-1!==r&&e.splice(r,1)},ie=(e,t)=>e.push(t),oe=(e,t,r)=>!e&&console.error(`${t} is deprecated${r?`, use ${r} instead`:''}`);const se=()=>{let e=0;return()=>""+ ++e};let le,de=se(),ue=se(),fe=se(),ce=se(),pe=null,me=e=>{le&&le(e,pe)},ge=()=>pe&&pe.template,he=e=>(e&&pe&&pe.sidRoot&&(e=`${pe.sidRoot}|${e}`),e),ye=(e,t)=>{let a=_(e);r(t,(e=>{let t=_(e);a.family.type!==$&&(t.family.type=N),ie(E(t),a),ie(P(a),t)}))},be=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(_),ve=e=>'object'==typeof e&&null!==e,ke=e=>'function'==typeof e,we=e=>void 0===e,Se=e=>a(ve(e)||ke(e),'expect first argument be an object');const Me=(e,t,r,n)=>a(!(!ve(e)&&!ke(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${n}`);let xe=(e,t,a)=>{Array.isArray(e)?r(e,((e,r)=>Me(e,t,`${r} item of ${a}`,''))):Me(e,t,a,' or array of units')},ze=(e,t,n="target")=>r(be(t),(t=>a(!G(t,'derived'),`${e}: derived unit in "${n}" is not supported, use createStore/createEvent instead"`))),Ae=(e,{fn:t},{a:r})=>t(e,r),$e=(e,{fn:t},{a:r})=>t(r,e),je=(e,{fn:t})=>t(e);const Ce=(e,t,r,a)=>{let n={id:ue(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++Ne)),n};let Ne=0,Ie=({from:e=x,store:t,target:r,to:a=(r?x:O),batch:n,priority:i})=>Ce('mov',{from:e,store:t,to:a,target:r},i,n),Oe=({fn:e,batch:t,priority:r,safe:a=0,filter:n=0,pure:i=0})=>Ce('compute',{fn:e,safe:a,filter:n,pure:i},r,t),Re=({fn:e})=>Oe({fn:e,priority:A}),qe=(e,t,r)=>Oe({fn:e,safe:1,filter:t,priority:r&&A}),De=(e,t,r)=>Ie({store:e,to:t?O:F,priority:r&&C,batch:1}),Fe=(e=je,t)=>Oe({fn:e,pure:1,filter:t}),_e={mov:Ie,compute:Oe,filter:({fn:e,pure:t})=>Oe({fn:e,filter:1,pure:t}),run:Re},Ee=e=>({id:ue(),current:e,initial:e}),Pe=({current:e})=>e,Te=(e,t)=>{e.before||(e.before=[]),ie(e.before,t)},Ve=null;const Be=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Je(e.v.type)>Je(t.v.type))&&(r=e,e=t,t=r),r=Be(e.r,t),e.r=e.l,e.l=r,e},Le=[];let We=0;for(;We<6;)ie(Le,{first:null,last:null,size:0}),We+=1;const Ge=()=>{for(let e=0;e<6;e++){let t=Le[e];if(t.size>0){if(3===e||4===e){t.size-=1;let e=Ve.v;return Ve=Be(Ve.l,Ve.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},He=(e,t,r,a,n,i,o)=>Ue(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),Ue=(e,t,r,a=0)=>{let n=Je(r),i=Le[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?Ve=Be(Ve,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Je=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case R:return 3;case C:return 4;case A:return 5;default:return-1}},Ke=new Set;let Qe,Xe=1,Ye=0,Ze=0,et=null,tt=e=>{Qe=e},rt=e=>{et=e};const at=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=L(e);if(e)return e}return null};let nt,ot=(e,t,r,a,n)=>{let i=at(e,a.id);return i?i.reg[a.id]:t?(lt(t,a,n),t.reg[a.id]):a};const st=e=>e;let lt=(e,t,a,n,i)=>{var o;let s=e.reg;if(s[t.id])return;let l=t.sid,d=null==t||null===(o=t.meta)||void 0===o?void 0:o.serialize,u=e.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||st,f={id:t.id,current:t.initial,meta:t.meta};if(f.id in e.values.idMap)f.current=e.values.idMap[f.id];else if(l&&l in e.values.sidMap&&!(l in e.sidIdMap))f.current=u(e.values.sidMap[l]);else if(t.before&&!i){let i=0,o=a||!t.noInit||n;r(t.before,(t=>{switch(t.type){case I:{let r=t.from;if(r||t.fn){r&<(e,r,a,n);let i=r&&s[r.id].current;o&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),lt(e,t.from,a,n),o&&(f.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=t.id),s[t.id]=f};const dt=(e,t,r)=>{try{return t(V(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}};let ut=(e,r={})=>(ve(e)&&(ut(e.or,r),t(e,((e,t)=>{we(e)||'or'===t||'and'===t||(r[t]=e)})),ut(e.and,r)),r);const ft=(e,t)=>{ne(e.next,t),ne(E(e),t),ne(P(e),t)},ct=(e,t,r)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let n=P(e);for(;a=n.pop();)ft(a,e),(t||r&&'sample'!==G(e,'op')||a.family.type===N)&&ct(a,t,'on'!==G(a,'op')&&r);for(n=E(e);a=n.pop();)ft(a,e),r&&a.family.type===N&&ct(a,t,'on'!==G(a,'op')&&r)},pt=e=>e.clear();let mt=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),Q(e))pt(B(e));else if(ee(e)){r=1;let t=e.history;pt(t.events),pt(t.effects),pt(t.stores),pt(t.domains)}ct(_(e),!!t,r)},gt=e=>u((()=>mt(e))),ht=(e,t,r,a,n)=>i({node:r,parent:e,child:t,scope:{fn:n},meta:{op:a},family:{owners:[e,t],links:t},regional:1}),yt=(e,t)=>(a(ke(t),'.watch argument should be a function'),gt(i({scope:{fn:t},node:[Re({fn:je})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),bt=(e,t,r=z)=>{L(e)&&L(e).hooks[r](t)},vt=(e,t,r)=>{let a=ut(r),n=e===$,i=de(),{sid:o=null,named:s=null,domain:d=null,parent:u=d}=a,f=s||a.name||(n?'':i),c=l(f,u),p={op:t.kind=e,name:t.shortName=f,sid:t.sid=he(o),named:s,unitId:t.id=i,serialize:a.serialize,derived:a.derived,config:a};if(t.targetable=!a.derived,t.parent=u,t.compositeName=c,t.defaultConfig=a,t.getType=()=>(oe(0,'getType','compositeName.fullName'),c.fullName),!n){t.subscribe=e=>(Se(e),t.watch(ke(e)?e:t=>e.next&&e.next(t))),t[M]=()=>t;let e=ge();e&&(p.nativeTemplate=e)}return p};const kt=(e,t,r,a)=>{let n;ve(r)&&(n=r,r=r.fn);let i=c({name:`${e.shortName} \u2192 *`,derived:1,and:n});return ht(e,i,a,t,r),i};let wt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option';const St=(e,t,r,a,n)=>{let i=T(t),o=Ie({store:i,to:F,priority:'read'});r===I&&(o.data.softRead=1);let s=[o,Fe(a)];return f('storeOnMap',i,s,Q(e)&&T(e)),ht(e,t,s,r,n)},Mt=(e,r,n,i,o,l)=>{let d=e?e=>[...e]:e=>({...e}),u=e?[]:{},c=d(u),p=Ee(c),g=Ee(1);p.type=e?'list':'shape',p.noInit=1,f('combineBase',p,g);let h=m(c,{name:s(n),derived:1,...l,and:i}),y=T(h);y.noInit=1,H(h,'isCombine',1);let b=De(p);b.order={priority:'barrier'};let v=Ie({store:y,to:'b',priority:'read'});v.data.softRead=1;let k=[qe(((e,t,r)=>(r.scope&&!r.scope.reg[p.id]&&(r.c=1),e))),b,Ie({store:g,to:'b'}),qe(((e,{key:t},a)=>{if(a.c||e!==a.a[t])return r&&a.b&&(a.a=d(a.a)),a.a[t]=e,1}),1),Ie({from:F,target:p}),Ie({from:q,store:0,target:g}),Ie({from:q,store:1,target:g,priority:R,batch:1}),De(p,1,1),o&&Fe(),v];if(t(n,((e,t)=>{if(!Q(e))return a(!J(e)&&!we(e),`combine expects a store in a field ${t}`),void(c[t]=u[t]=e);u[t]=e.defaultState,c[t]=e.getState();let r=ht(e,h,k,'combine',o);r.scope.key=t;let n=T(e);Te(p,{type:'field',field:t,from:n}),f('combineField',n,r)})),h.defaultShape=n,Te(y,{type:I,from:p,fn:o}),!ge())if(o){let e=o(c);!we(e)||l&&"skipVoid"in l||console.error(wt),y.current=e,y.initial=e,h.defaultState=e}else h.defaultState=u;return h};let xt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},zt=(e,t,r,a,n)=>i=>{o({target:[a,At],params:[r?{status:'done',params:e,result:i}:{status:'fail',params:e,error:i},{value:i,fn:r?t.rs:t.rj}],defer:1,page:n.page,scope:n.scope,meta:n.meta})};const At=i({node:[Re({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),$t=['source','clock','target'],jt=(e,t)=>e+`: ${t} should be defined`;let Ct=(e,t,r,n,i,o,s,l,d,u,p,h)=>{let y=!!i;a(!we(r)||!we(t),jt(e,'either source or clock'));let v=0;we(r)?v=1:J(r)||(r=g(r)),we(t)?t=r:(xe(t,e,'clock'),Array.isArray(t)&&(t=b(t))),v&&(r=t),l||s||(s=r.shortName);let k='none';(p||n)&&(J(n)?k='unit':(a(ke(n),'`filter` should be function or unit'),k='fn')),i?(xe(i,e,'target'),ze(e,i)):'none'===k&&u&&Q(r)&&Q(t)?i=m(o?o(Pe(T(r)),Pe(T(t))):Pe(T(r)),{name:s,sid:h,or:l}):(i=c({name:s,derived:1,or:l}),f('sampleTarget',_(i)));let w=Ee(),S=[];if('unit'===k){let[r,a]=It(n,i,t,w,e);S=[...Nt(a),...Nt(r)]}let[M,x]=It(r,i,t,w,e),z=ht(t,i,[f('sampleSourceLoader'),Ie({from:O,target:w}),...Nt(x),De(M,1,d),...S,De(w),'fn'===k&&Fe(((e,t,{a:r})=>n(e,r)),1),o&&Fe(Ae),f('sampleSourceUpward',y)],e,o);return ye(r,[z]),Object.assign(z.meta,l,{joint:1}),i};const Nt=e=>[De(e),qe(((e,t,{a:r})=>r),1)],It=(e,t,r,a,n)=>{let o=Q(e),s=o?T(e):Ee(),l=Ee(o);return o||i({parent:e,node:[Ie({from:O,target:s}),Ie({from:q,store:1,target:l})],family:{owners:[e,t,r],links:t},meta:{op:n},regional:1}),f('sampleSource',l,s,a),[s,l]},Ot=(e,t,r,a)=>{let n=e[t];n&&o({target:n,params:Array.isArray(n)?n.map((()=>r)):r,defer:1,stack:a})},Rt=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!J(e))return Promise.reject(new Error('first argument should be unit'));if(!(Y(e)||X(e)||Q(e)||te(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));te(e)&&(t=e);let a=h();a.parentFork=Qe;let{fxCount:n}=t;ie(n.scope.defers,a);let i=[],s=[];return te(e)||(ie(i,e),ie(s,Y(e)?{params:r,req:{rs(e){a.value={status:'done',value:e}},rj(e){a.value={status:'fail',value:e}}}}:r)),ie(i,n),ie(s,null),o({target:i,params:s,scope:t}),a.req},e.attach=e=>{let t;[e,t]=d(e,1);let{source:r,effect:n,mapParams:i,domain:s}=e;Y(n)&&a(we(s),'`domain` can only be used with a plain function');let u=y(e,t);H(u,'attached',1);let f,{runner:c}=_(u).scope,p=qe(((e,t,a)=>{let n,{params:s,req:l,handler:d}=e,f=u.finally,c=zt(s,l,0,f,a),p=a.a,m=Y(d),g=1;if(i?[g,n]=xt(i,c,[s,p]):n=r&&m?p:s,g){if(!m)return e.args=[p,n],1;o({target:d,params:{params:n,req:{rs:zt(s,l,1,f,a),rj:c}},page:a.page,defer:1,meta:a.meta})}}),1,1);if(r){let e;Q(r)?(e=r,ye(e,[u])):(e=g(r),ye(u,[e])),f=[De(T(e)),p]}else f=[p];c.seq.splice(1,0,...f),u.use(n);let m=L(n);return m&&(Object.assign(U(u),l(u.shortName,m)),u.defaultConfig.parent=m),bt(n,u,A),u},e.clearNode=mt,e.combine=g,e.createApi=(...e)=>{let[[r,a],n]=d(e),i={};return t(a,((e,t)=>{let a=i[t]=c(t,{parent:L(r),config:n});r.on(a,e),bt(r,a)})),i},e.createDomain=function e(a,n){let s=ut({or:n,and:'string'==typeof a?{name:a}:a}),l=i({family:{type:$},regional:1,parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent)}),d={history:{},graphite:l,hooks:{}};l.meta=vt($,d,{parent:(null==s?void 0:s.domain)||(null==s?void 0:s.parent),or:{...s,derived:1}}),t({Event:c,Effect:y,Store:m,Domain:e},((e,t)=>{let a=t.toLowerCase(),n=(e=>c({named:e}))(`on${t}`);d.hooks[a]=n;let i=new Set;d.history[`${a}s`]=i,n.create=e=>(o(n,e),e),ie(_(n).seq,qe(((e,t,r)=>(r.scope=null,e)))),n.watch((e=>{ye(d,[e]),i.add(e),e.ownerSet||(e.ownerSet=i),L(e)||(e.parent=d)})),ye(d,[n]),d[`onCreate${t}`]=e=>(r(i,e),n.watch(e)),d[`create${t}`]=d[a]=(t,r)=>{let a=ut({and:r,or:t});return null!=a&&a.domain?e(t,r):n(e(t,{parent:d,or:a}))}}));let u=L(d);return u&&t(d.hooks,((e,t)=>ht(e,u.hooks[t]))),null!=s&&s.domain&&s.domain.hooks.domain(d),d},e.createEffect=y,e.createEvent=c,e.createNode=i,e.createStore=m,e.createWatch=({unit:e,fn:t,scope:r,batch:a})=>{let n=[_e.run({fn:e=>t(e)})];a&&n.unshift(_e.compute({priority:'sampler',batch:1})),Q(e)&&n.unshift(_e.mov({store:e.stateRef,to:'stack'}));let o=Array.isArray(e)?e:[e];if(r){let e=[],t=r.additionalLinks;return o.forEach((r=>{let a=t[r.graphite.id]||[];t[r.graphite.id]=a;let o=i({node:S(n,r),meta:{watchOp:r.kind}});a.push(o),e.push((()=>{let e=a.indexOf(o);-1!==e&&a.splice(e,1),mt(o)}))})),u((()=>{e.forEach((e=>e()))}))}{let e=i({node:n,parent:o,family:{owners:o}});return u((()=>{mt(e)}))}},e.fork=(e,t)=>{let n,o=e;ee(e)&&(oe(0,'fork(domain)','fork()'),n=e,o=t);let s=(e=>{let t=i({scope:{defers:[],inFlight:0,fxID:0},node:[qe(((e,t,r)=>{L(r)?'dec'===G(L(r).node,'needFxCounter')?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Oe({priority:C,batch:1}),qe(((e,t)=>{let{defers:a,fxID:n}=t;t.inFlight>0||0===a.length||Promise.resolve().then((()=>{t.fxID===n&&r(a.splice(0,a.length),(e=>{tt(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),a=i({node:[qe(((e,t,r)=>{let a=L(r);if(a){let t=a.node;if(!G(t,'isCombine')||L(a)&&'combine'!==G(L(a).node,'op')){let a=W(r),n=t.scope.state.id,i=G(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=G(t,'serialize');o&&a.sidSerializeSettings.set(i,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),n=i({node:[qe(((e,t,r)=>{let a=W(r);if(a){let e=L(r);e&&(!G(e.node,'isCombine')||L(e)&&'combine'!==G(L(e).node,'op'))&&(a.warnSerialize=1)}}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return ot(et,o,null,e).current;let t=_(e);return ot(et,o,t,t.scope.state,1).current},kind:j,graphite:i({family:{type:$,links:[t,a,n]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:a,warnSerializeNode:n};return o})(n);if(o){if(o.values){let{sidMap:e,unitMap:t,hasSidDoubles:n}=w(o.values,(e=>a(Q(e)&&Z(e),'Values map can contain only writable stores as keys')));Object.assign(s.values.sidMap,e),r(t,((e,t)=>{s.values.idMap[t.stateRef.id]=e;let r=G(t,'serialize'),a=G(t,'sid');'ignore'===r&&s.sidSerializeSettings.set(a,{ignore:1})})),s.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),s.hasSidDoubles=n}o.handlers&&(oe(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),s.handlers=w(o.handlers,(e=>a(Y(e),"Handlers map can contain only effects as keys"))))}return s},e.forward=e=>{oe(0,'forward','sample');let t='forward',[{from:r,to:a},n]=d(e,1);return xe(r,t,'"from"'),xe(a,t,'"to"'),ze(t,a,'to'),gt(i({parent:r,child:a,meta:{op:t,config:n},family:{},regional:1}))},e.fromObservable=e=>{Se(e);let t=M in e?e[M]():e;a(t.subscribe,'expect observable to have .subscribe');let r=c(),n=gt(r);return t.subscribe({next:r,error:n,complete:n}),r},e.guard=(...e)=>{oe(0,'guard','sample');let[[t,r],a]=d(e);return r||(r=t,t=r.source),v(r,'guard'),Ct('guard',r.clock,t,r.filter,r.target,null,r.name,a,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{a(ve(t),'values property should be an object');let{sidMap:n,unitMap:i}=w(t),s=Object.getOwnPropertyNames(n),l={};r(i,((e,t)=>{l[t.stateRef.id]=t}));let d,u,f,c=[],p=[];te(e)?(d=e,f=1,a(d.cloneOf,'scope should be created from domain'),oe(0,'hydrate(fork(domain), { values })','fork({ values })'),u=_(d.cloneOf)):ee(e)?(oe(0,'hydrate(domain, { values })','fork({ values })'),u=_(e)):a(0,'first argument of hydrate should be domain or scope'),k(u,((e,t)=>{if(t&&ae(s,t)){ie(c,e);let r=G(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),ie(p,n[t])}else e.scope.state.id in l&&(ie(c,e),ie(p,i.get(l[e.scope.state.id])))}),1),o({target:c,params:p,scope:d}),f&&Object.assign(d.values.sidMap,n)},e.is=re,e.launch=o,e.merge=b,e.restore=(e,r,a)=>{if(Q(e))return oe(0,'restore($store)'),e;if(X(e)||Y(e)){let t=L(e),n=m(r,{parent:t,name:e.shortName,and:a});return ht(Y(e)?e.doneData:e,n),t&&t.hooks.store(n),n}let n=Array.isArray(e)?[]:{};return t(e,((e,t)=>n[t]=Q(e)?e:m(e,{name:t}))),n},e.sample=(...e)=>{let t,r,a,n,[[i,o,s],l]=d(e),u=1;return we(o)&&ve(i)&&v(i,D)&&(o=i.clock,s=i.fn,'batch'in i?u=i.batch:(oe(!('greedy'in i),'greedy in sample','batch'),u=!i.greedy),n=i.filter,t=i.target,r=i.name,a=i.sid,i=i.source),Ct(D,o,i,n,t,s,r,l,u,1,0,a)},e.scopeBind=(e,{scope:t,safe:r}={})=>{a(t||Qe||r,'scopeBind: scope not found');let n=t||Qe;return Y(e)?t=>{let r=h();return o({target:e,params:{params:t,req:r},scope:n}),r.req}:t=>(o({target:e,params:t,scope:n}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),a(!e.hasSidDoubles,'duplicate sid found in this scope');let n=r.ignore?r.ignore.map((({sid:e})=>e)):[],i={};return t(e.values.sidMap,((t,r)=>{var a;if(ae(n,r))return;let o=e.sidIdMap[r],s=null!==(a=e.sidSerializeSettings.get(r))&&void 0!==a?a:{ignore:0,write:Rt};s.ignore||(i[r]=(0,s.write)(o&&o in e.reg?e.reg[o].current:t))})),'onlyChanges'in r&&(oe(0,'onlyChanges'),r.onlyChanges||(a(e.cloneOf,'scope should be created from domain'),k(_(e.cloneOf),((t,r)=>{r in i||ae(n,r)||G(t,'isCombine')||'ignore'===G(t,'serialize')||(i[r]=e.getState(t))})))),i},e.setGraphInspector=e=>{le=e},e.setInspector=e=>{nt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(U(e),l(t,L(e)))},e.split=(...e)=>{let r,n,o='split',[[s,l],u]=d(e),p=!l;p&&(r=s.cases,l=s.match,n=s.clock,s=s.source);let m=Q(l),g=!J(l)&&ke(l),h=!m&&!g&&ve(l);a(J(s),'source must be a unit'),r||(r={}),p?t(r,((e,t)=>ze(o,e,`cases.${t}`))):(a(h,'match should be an object'),t(l,((e,t)=>r[t]=c({derived:1,named:`cases.${t}`,and:u}))),r.__=c({derived:1,named:'cases.__',and:u}));let y,b=new Set([].concat(s,n||[],Object.values(r))),v=Object.keys(m||g?r:l);if(m||g)m&&b.add(l),y=[m&&De(T(l),0,1),Oe({safe:m,filter:1,pure:!m,fn(e,t,r){let a=String(m?r.a:l(e));Ot(t,ae(v,a)?a:'__',e,r)}})];else if(h){let e=Ee({});e.type='shape';let r,a=[];t(l,((t,n)=>{if(J(t)){r=1,ie(a,n),b.add(t);let i=ht(t,[],[De(e),qe(((e,t,{a:r})=>r[n]=e))]);if(Q(t)){e.current[n]=t.getState();let r=T(t);Te(e,{from:r,field:n,type:'field'}),f('splitMatchStore',r,i)}}})),r&&f('splitBase',e),y=[r&&De(e,0,1),Fe(((e,t,r)=>{for(let n=0;n<v.length;n++){let i=v[n];if(ae(a,i)?r.a[i]:l[i](e))return void Ot(t,i,e,r)}Ot(t,'__',e,r)}),1)]}else a(0,'expect match to be unit, function or object');let k=i({meta:{op:o},parent:n?[]:s,scope:r,node:y,family:{owners:Array.from(b)},regional:1});if(n&&Ct(o,n,s,null,k,null,o,u,0,0,0),!p)return r},e.step=_e,e.version="23.0.0-rc.4",e.withFactory=({sid:e,name:t,loc:r,method:a,fn:o})=>n(i({meta:{sidRoot:he(e),sid:e,name:t,loc:r,method:a,type:'factory'}}),o),e.withRegion=n,Object.defineProperty(e,'__esModule',{value:1})})); | ||
//# sourceMappingURL=effector.umd.js.map |
{ | ||
"name": "effector", | ||
"version": "23.0.0-rc.3", | ||
"version": "23.0.0-rc.4", | ||
"description": "Business logic with ease", | ||
@@ -5,0 +5,0 @@ "main": "effector.cjs.js", |
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
1375374
17158