Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

effector

Package Overview
Dependencies
Maintainers
5
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effector - npm Package Compare versions

Comparing version 23.0.0-rc.5 to 23.0.0-rc.6

2

compat.js

@@ -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=F(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(N(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=Re;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=R(e)||u,e=e.target),u&&Re&&u!==Re&&(Re=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||Te){var f,c,d,l,p,v,m={isRoot:Te,currentPage:Ge,scope:Re,isWatch:Be,isPure:We};Te=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,Ge=p=n.page,Re=R(n),p?v=p.reg:Re&&(v=Re.reg);var a=!!p,i=!!Re,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?Le.has(b)||(Le.add(b),Pe(u,n,h,y)):Pe(u,n,h),"continue|kernelLoop";y&&Le.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(Re,k.store,0,1,k.softRead),v=Re.reg):v=void 0}else i&&Qe(Re,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,Re,d,k.target).current=w}break;case'compute':var S=s.data;if(S.fn){Be='watch'===D(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(De&&De(n,o),!f){var A=I(n),O=R(n);if(r(d.next,(function(e){Ee('child',p,e,n,A,O)})),O){D(d,'needFxCounter')&&Ee('child',p,O.fxCount,n,A,O),D(d,'storeChange')&&Ee('child',p,O.storeChange,n,A,O),D(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();Te=m.isRoot,Ge=m.currentPage,Re=R(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=F(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(!D(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:Re}),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:F(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(!D(e,'derived'),t+" in derived store",t+" in store created via createStore"),r(Array.isArray(a)?a:[a],(function(r){e.off(r),q(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=F(n);n&&(e=n)}return!e&&Re&&(Qe(Re,u,1),e=Re),e&&(r=e.reg[f]),ze(r)},setState:function(e){return i({target:g,params:e,defer:1,scope:Re})},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=q(g).get(e);return r&&(r(),q(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 Ne(C(o),{type:A,fn:e,from:u}),C(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=D(g,'serialize'),k=D(g,'derived'),w='ignore'===b,x=D(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=!L(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];L(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.compositeName.fullName)}},node:[Se((function(e,r,n){var t=r.handler,a=R(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){if(!r.runnerFn||r.runnerFn(e,null,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=F(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:re()}),i({target:t,params:a,defer:1,scope:R(n),meta:n.meta}),a.params}))),o.create=function(e){var r=g(),n={params:e,req:r};if(Re&&!Be){var t=Re;r.req.finally((function(){He(t)})).catch((function(){}))}return i({target:o,params:n,scope:Re}),r.req};var h=o.inFlight=v(0,{serialize:'ignore',named:(D(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"===D(i,'op')&&(t||D(i,'sid'))&&n(i,D(i,'sid')),r(i.next,e),r(z(i),e),r(N(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 L(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},N=function(e){return e.family.links},C=function(e){return e.stateRef},I=function(e){return e.value},q=function(e){return e.subscribers},F=function(e){return e.parent},R=function(e){return e.scope},D=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},V=function(e){return function(r){return P(r)&&r.kind===e}},L=V("store"),T=V("event"),B=V("effect"),W=function(e){return P(e)&&!!e.targetable},G=V("domain"),H=V("scope"),U={__proto__:null,unit:P,store:L,event:T,effect:B,targetable:W,domain:G,scope:H,attached:function(e){return B(e)&&1==D(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(N(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(!D(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},Ne=function(e,r){e.before||(e.before=[]),K(e.before,r)},Ce=null,Ie=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||Ve(r.v.type)>Ve(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},qe=[],Fe=0;Fe<6;)K(qe,{first:null,last:null,size:0}),Fe+=1;var Re,De,_e=function(){for(var e=0;e<6;e++){var r=qe[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=Ce.v;return Ce=Ie(Ce.l,Ce.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=Ve(n),i=qe[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?Ce=Ie(Ce,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Ve=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}},Le=new Set,Te=1,Be=0,We=0,Ge=null,He=function(e){Re=e},Ue=function(e){Ge=e},$e=function(e,r){if(e){for(;e&&!e.reg[r];)e=F(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(N(e),r)},er=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=N(r);a=i.pop();)Ze(a,r),(n||t&&'sample'!==D(r,'op')||"crosslink"===a.family.type)&&e(a,n,'on'!==D(a,'op')&&t);for(i=z(r);a=i.pop();)Ze(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==D(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),L(e))rr(q(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"),F(e)&&F(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=C(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,L(e)&&C(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=C(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(!L(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=C(e);Ne(p,{type:'field',field:r,from:a}),c('combineField',a,t)})),g.defaultShape=a,Ne(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&&L(t)&&L(r)?i=v(o?o(ze(C(t)),ze(C(r))):ze(C(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],N=A[1],I=ar(r,i,[c('sampleSourceLoader'),ke({from:j,target:w})].concat(yr(N),[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=L(e),u=o?C(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)||T(e)||L(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=Re;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=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})}};o?(g.scope.runnerFn=y,L(o)?oe(v=o,[l]):(v=m(o),oe(l,[v])),p=[Se((function(e){return e}),0,1),Me(C(v))],delete g.seq[1].order):p=[Se(y,1,1)],(r=g.seq).splice.apply(r,[1,0].concat(p)),l.use(f);var b=F(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:F(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),F(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=F(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})),L(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){F(n)?'dec'===D(F(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=F(n);if(t){var a=t.node;if(!D(a,'isCombine')||F(t)&&'combine'!==D(F(t).node,'op')){var i=R(n),o=a.scope.state.id,u=D(a,'sid');i.sidIdMap[u]=o,i.values.sidMap[u]=e;var s=D(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=R(n);if(t){var a=F(n);a&&(!D(a.node,'isCombine')||F(a)&&'combine'!==D(F(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(L(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=D(r,'serialize'),t=D(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=D(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(L(r))return Q(0,'restore($store)'),r;if(T(r)||B(r)){var a=F(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]=L(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||Re||t.safe,'scopeBind: scope not found');var o=a||Re;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)||D(e,'isCombine')||'ignore'===D(e,'serialize')||(i[n]=r.getState(e))})))),i},exports.setGraphInspector=function(e){S=e},exports.setInspector=function(e){De=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(E(e),u(r,F(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=L(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(C(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(L(e)){M.current[r]=e.getState();var t=C(e);Ne(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.5",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,n){if(!e)throw Error((n?n+': ':'')+r)}function t(e,r){var n=j(e).meta||{};re={id:j(e).id,parent:re,value:e,template:n.template||te(),sidRoot:n.sidRoot||re&&re.sidRoot,meta:n};try{return r()}finally{ne('region'),re=q(re)}}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=oe(void 0===i?n.from||n.source:i),g=oe(p.links),h=oe(p.owners),y=[];r(a,(function(e){return e&&J(y,e)}));var b={id:Z(),seq:y,next:oe(u),meta:d,scope:f,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return J(O(e),b)})),r(h,(function(e){return J(z(e),b)})),r(m,(function(e){return J(e.next,b)})),v&&re&&ie(C(re),[b]),b}function i(e,n,t){var a,i=We,o=null,u=Fe;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=F(e)||u,e=e.target),u&&Fe&&u!==Fe&&(Fe=null),Array.isArray(e))for(var s=0;s<e.length;s++)_e('pure',i,j(e[s]),o,n[s],u,a);else _e('pure',i,j(e),o,n,u,a);if(!t||Le){var f,c,d,l,p,v,m={isRoot:Le,currentPage:We,scope:Fe,isWatch:Te,isPure:Be};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,We=p=n.page,Fe=F(n),p?v=p.reg:Fe&&(v=Fe.reg);var a=!!p,i=!!Fe,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),Ee(u,n,h,y)):Ee(u,n,h,0),"continue|kernelLoop";y&&Ve.delete(b)}switch(s.type){case'mov':var k=s.data,w=void 0;switch(k.from){case'stack':w=C(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=Ue(p,k.store.id);n.page=p=x,x?v=x.reg:i?(Ke(Fe,k.store,0,1,k.softRead),v=Fe.reg):v=void 0}else i&&Ke(Fe,k.store,0,1,k.softRead);w=Oe(v&&v[k.store.id]||k.store)}switch(k.to){case'stack':n.value=w;break;case'a':case'b':n[k.to]=w;break;case'store':$e(p,Fe,k.target,0).current=w}break;case'compute':var S=s.data;if(S.fn){Te='watch'===d.meta.op,Be=S.pure;var M=S.safe?(0,S.fn)(C(n),o.scope,n):Qe(o,S.fn,n);S.filter?c=!M:n.value=M,Te=m.isWatch,Be=m.isPure}}f=o.fail||c}if(Re&&Re(n,o),!f){var A=C(n),j=F(n);if(r(d.next,(function(e){_e('child',p,e,n,A,j)})),j){d.meta.needFxCounter&&_e('child',p,j.fxCount,n,A,j),d.meta.storeChange&&_e('child',p,j.storeChange,n,A,j),d.meta.warnSerialize&&_e('child',p,j.warnSerializeNode,n,A,j);var O=j.additionalLinks[d.id];O&&r(O,(function(e){_e('child',p,e,n,A,j)}))}}};l=De();)g();Le=m.isRoot,We=m.currentPage,Fe=F(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+=E(e)?_(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=_(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){if(!r)return e;if(!r.name&&!r.named&&!r.loc)return e;var n="["+e+"]",t=r.named||r.name;t&&(n+=" unit '"+t+"'");var a=r.loc;return!t&&a&&(n+=" ("+a.file+":"+a.line+":"+a.column+")"),n}function f(e,r){var n=r?e:e[0];ce(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(ue(i)&&'and'in i){var o=f(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function c(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}function d(e){var r=te();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 l(e,r,n,t){var a=We,i=null;if(r)for(i=We;i&&i.template!==r;)i=q(i);He(i);var o=e.create(n,t);return He(a),o}function p(e,r){var t=Xe({or:r,and:'string'==typeof e?{name:e}:e}),o=s('event',t),u=function e(r){n(!R(e,'derived'),'call of derived event is not supported, use createEvent instead',o),n(!Be,'unit call from pure function is not supported, use operators like sample instead',o);for(var t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];return We?l(e,f,r,a):e.create(r,a)},f=te(),c=Object.assign(u,{graphite:a({meta:or(t.actualOp||"event",u,t),regional:1}),create:function(e){return i({target:u,params:e,scope:Fe}),e},watch:function(e){return ar(u,e)},map:function(e){return ur(u,"map",e,[Me()])},filter:function(e){return ur(u,'filter',e.fn?e:e.fn,[Me(ge,1)])},filterMap:function(e){return ur(u,'filterMap',e,[Me(),xe((function(e){return!fe(e)}),1)])},prepend:function(e){n(u.targetable,'.prepend of derived event is not supported, call source event instead',o);var r=p('* \u2192 '+u.shortName,{parent:q(u)});return d('eventPrepend',j(r)),tr(r,u,[Me()],'prepend',e),ir(u,r),r}});return null!=t&&t.domain&&t.domain.hooks.event(c),D(c,'id',c.graphite.id),ne(c.graphite),c}function v(e,t,a,i,o){return le(a,o+" "+t,'first argument'),n(se(i),'second argument should be a function',o),K(!R(e,'derived'),t+" in derived store",t+" in store created via createStore",o),r(Array.isArray(a)?a:[a],(function(r){e.off(r),I(e).set(r,nr(fr(r,e,'on',me,i)))})),e}function m(e,t){var o=Xe(t),u=je(e),f=s('store',o),c=p({named:'updates',derived:1});d('storeBase',u);var l=u.id,g='skipVoid'in o,h=g&&!o.skipVoid;K(!(g&&o.skipVoid),'{skipVoid: true}','updateFilter',f);var y={subscribers:new Map,updates:c,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(We){for(var n=We;n&&!n.reg[l];)n=q(n);n&&(e=n)}return!e&&Fe&&(Ke(Fe,u,1),e=Fe),e&&(r=e.reg[l]),Oe(r)},setState:function(e){return i({target:y,params:e,defer:1,scope:Fe})},reset:function(){n(y.targetable,'.reset of derived store is not supported',f);for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r(t,(function(e){return v(y,'.reset',e,(function(){return y.defaultState}),f)})),y},on:function(e,r){return n(y.targetable,'.on of derived store is not supported',f),v(y,'.on',e,r,f)},off:function(e){var r=I(y).get(e);return r&&(r(),I(y).delete(e)),y},map:function(e,r){var n,t;ue(e)&&(n=e,e=e.fn);var a=y.getState(),i=fe(a);te()?t=null:(!i||i&&h)&&(t=e(a));var o=m(t,Object.assign({name:y.shortName+" \u2192 *",derived:1},r,{and:n})),s=fr(y,o,"map",ge,e);return ze(N(o),{type:"map",fn:e,from:u}),N(o).noInit=1,d('storeMap',u,s),o},watch:function(e,r){if(K(!r,'watch second argument','sample',f),!r||!E(e)){var t=ar(y,e);return d('storeWatch',u,e)||e(y.getState()),t}return n(se(r),'second argument should be a function',f),e.watch((function(e){return r(y.getState(),e)}))}},b=or("store",y,o),k=y.defaultConfig.updateFilter;y.graphite=a({scope:{state:u,fn:k},node:[xe((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),Se(u),xe((function(e,r,n){var t=n.a,a=n.b,i=fe(e);return i&&!g&&console.error(f+": "+sr),(i&&h||!i)&&(e!==t||a)}),1),k&&Me(ve,1),be({from:"stack",target:u})],child:c,meta:Object.assign({},b,{defaultState:e}),regional:1}),D(y,'id',y.graphite.id),D(y,'rootStateRefId',l);var w=R(y,'serialize'),x=R(y,'derived'),S='ignore'===w,M=R(y,'sid');M&&(D(y,'storeChange',1),u.sid=M),M||S||x||D(y,'warnSerialize',1);var A=fe(e);return n(x||!A||A&&h,sr,f),x&&A&&!g&&console.error(f+": "+sr),ie(y,[c]),null!=o&&o.domain&&o.domain.hooks.store(y),x||(y.reinit=p({named:'reinit'}),y.reset(y.reinit)),u.meta=y.graphite.meta,ne(y.graphite),y}function g(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=f(r);r=u[0];var c,d,l,p=s('combine',o=u[1]),v=r[r.length-1],m=!V(v)&&ue(v),g=m&&v,h=m?r[r.length-2]:v;if(se(h)?(i=r.slice(0,m?-2:-1),a=h):i=r,1===i.length){var y=i[0];V(y)||(c=y,d=1)}if(!d&&(c=i,a)){l=1;var b=a;a=function(e){return b.apply(void 0,e)}}return n(ue(c),p+": shape should be an object"),cr(Array.isArray(c),!l,c,o,a,g)}function h(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function y(e,r){void 0===r&&(r={});var t=Xe(se(e)?{handler:e}:e,r),o=s('effect',t),u=p(se(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),f=j(u);D(f,'op',u.kind="effect"),u.use=function(e){return n(se(e),'.use argument should be a function',o),y.scope.handler=e,u},u.use.getCurrent=function(){return y.scope.handler};var c=u.finally=p({named:'finally',derived:1}),d=u.done=c.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),l=u.fail=c.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),v=u.doneData=d.map({named:'doneData',fn:function(e){return e.result}}),g=u.failData=l.map({named:'failData',fn:function(e){return e.error}}),y=a({scope:{handler:u.defaultConfig.handler||function(){return n(0,"no handler used in "+u.compositeName.fullName)}},node:[xe((function(e,r,n){var t=r.handler,a=F(n);if(a){var i=a.handlers.unitMap.get(u)||a.handlers.sidMap[u.sid];i&&(t=i)}return e.handler=t,e}),0,1),xe((function(e,r,n){if(!r.runnerFn||r.runnerFn(e,null,n)){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,s=lr(t,a,1,c,n),f=lr(t,a,0,c,n),d=dr(i,f,u),l=d[1];d[0]&&(ue(l)&&se(l.then)?l.then(s,f):s(l))}}),0,1)],meta:{op:'fx',fx:'runner'}});f.scope.runner=y,J(f.seq,xe((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:ee()}),i({target:t,params:a,defer:1,scope:F(n),meta:n.meta}),a.params}))),u.create=function(e){var r=h(),n={params:e,req:r};if(Fe&&!Te){var t=Fe;r.req.finally((function(){Ge(t)})).catch((function(){}))}return i({target:u,params:n,scope:Fe}),r.req};var b=u.inFlight=m(0,{serialize:'ignore',named:(R(u,'name')||u.graphite.id)+'.inFlight'}).on(u,(function(e){return e+1})).on(c,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});D(c,'needFxCounter','dec'),D(u,'needFxCounter',1);var k=u.pending=b.map({fn:function(e){return e>0},named:'pending'});return ie(u,[c,d,l,v,g,k,b]),null!=t&&t.domain&&t.domain.hooks.effect(u),u}function b(e,r){var n=s('merge',r);le(e,n,'first argument');var t=p({name:o(e,'merge'),derived:1,and:r});return tr(e,t,[],'merge'),t}function k(e,t){var a=0;return r(vr,(function(r){r in e&&(n(null!=e[r],mr(t,r)),a=1)})),a}function w(e,n,t){var a=[];(function e(i){U(a,i)||(J(a,i),"store"===R(i,'op')&&(t||R(i,'sid'))&&n(i,R(i,'sid')),r(i.next,e),r(O(i),e),r(z(i),e))})(e)}function x(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(E(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 S(e,r){return V(r)?[Ae.mov({store:r.stateRef,to:'stack'})].concat(e):e}Object.defineProperty(exports,'__esModule',{value:1});for(var M,A='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',j=function(e){return e.graphite||e},O=function(e){return e.family.owners},z=function(e){return e.family.links},N=function(e){return e.stateRef},C=function(e){return e.value},I=function(e){return e.subscribers},q=function(e){return e.parent},F=function(e){return e.scope},R=function(e,r){return j(e).meta[r]},D=function(e,r,n){return j(e).meta[r]=n},_=function(e){return e.compositeName},E=function(e){return(se(e)||ue(e))&&'kind'in e},P=function(e){return function(r){return E(r)&&r.kind===e}},V=P("store"),L=P("event"),T=P("effect"),B=function(e){return E(e)&&!!e.targetable},W=P("domain"),G=P("scope"),H={__proto__:null,unit:E,store:V,event:L,effect:T,targetable:B,domain:W,scope:G,attached:function(e){return T(e)&&1==R(e,'attached')}},U=function(e,r){return e.includes(r)},$=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},J=function(e,r){return e.push(r)},K=function(e,r,n,t){return!e&&console.error((t?t+': ':'')+r+" is deprecated"+(n?", use "+n+" instead":''))},Q=function(){var e=0;return function(){return""+ ++e}},X=Q(),Y=Q(),Z=Q(),ee=Q(),re=null,ne=function(e){M&&M(e,re)},te=function(){return re&&re.template},ae=function(e){return e&&re&&re.sidRoot&&(e=re.sidRoot+"|"+e),e},ie=function(e,n){var t=j(e);r(n,(function(e){var r=j(e);"domain"!==t.family.type&&(r.family.type="crosslink"),J(O(r),t),J(z(t),r)}))},oe=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(j)},ue=function(e){return'object'==typeof e&&null!==e},se=function(e){return'function'==typeof e},fe=function(e){return void 0===e},ce=function(e){return n(ue(e)||se(e),'expect first argument be an object')},de=function(e,r,t,a){return n(!(!ue(e)&&!se(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},le=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return de(e,n,r+" item of "+t,'')})):de(e,n,t,' or array of units')},pe=function(e,t,a){return void 0===a&&(a='target'),r(oe(t),(function(r){return n(!R(r,'derived'),e+": derived unit in \""+a+"\" is not supported, use createStore/createEvent instead\"")}))},ve=function(e,r,n){return(0,r.fn)(e,n.a)},me=function(e,r,n){return(0,r.fn)(n.a,e)},ge=function(e,r){return(0,r.fn)(e)},he=function(e,r,n,t){var a={id:Y(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++ye)),a},ye=0,be=function(e){var r=e.from,n=e.target,t=e.to;return he('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":"stack":t,target:n},e.priority,e.batch)},ke=function(e){var r=e.safe,n=e.filter,t=e.pure;return he('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)},we=function(e){return ke({fn:e.fn,priority:"effect"})},xe=function(e,r,n){return ke({fn:e,safe:1,filter:r,priority:n&&"effect"})},Se=function(e,r,n){return be({store:e,to:r?"stack":"a",priority:n&&"sampler",batch:1})},Me=function(e,r){return void 0===e&&(e=ge),ke({fn:e,pure:1,filter:r})},Ae={mov:be,compute:ke,filter:function(e){return ke({fn:e.fn,filter:1,pure:e.pure})},run:we},je=function(e){return{id:Y(),current:e,initial:e}},Oe=function(e){return e.current},ze=function(e,r){e.before||(e.before=[]),J(e.before,r)},Ne=null,Ce=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||Pe(r.v.type)>Pe(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},Ie=[],qe=0;qe<6;)J(Ie,{first:null,last:null,size:0}),qe+=1;var Fe,Re,De=function(){for(var e=0;e<6;e++){var r=Ie[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=Ne.v;return Ne=Ce(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}}},_e=function(e,r,n,t,a,i,o){return Ee(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e,0)},Ee=function(e,r,n,t){var a=Pe(n),i=Ie[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?Ne=Ce(Ne,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Pe=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,Te=0,Be=0,We=null,Ge=function(e){Fe=e},He=function(e){We=e},Ue=function(e,r){if(e){for(;e&&!e.reg[r];)e=e.parent;if(e)return e}return null},$e=function(e,r,n,t){var a=Ue(e,n.id);return a?a.reg[n.id]:r?(Ke(r,n,t),r.reg[n.id]):n},Je=function(e){return e},Ke=function e(n,t,a,i,o){var u=n.reg;if(!u[t.id]){var s=t.sid,f={id:t.id,current:t.initial,meta:t.meta};if(f.id in n.values.idMap)f.current=n.values.idMap[f.id];else if(s&&s in n.values.sidMap&&!(s in n.sidIdMap)){var c,d=null==t||null===(c=t.meta)||void 0===c?void 0:c.serialize;f.current=(n.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Je)(n.values.sidMap[s])}else if(t.before&&!o){var l=0,p=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case'map':var t=r.from;if((t||r.fn)&&(t&&e(n,t,a,i),p)){var o=t&&u[t.id].current;f.current=r.fn?r.fn(o):o}break;case'field':e(n,r.from,a,i),l||(l=1,f.current=Array.isArray(f.current)?[].concat(f.current):Object.assign({},f.current)),p&&(f.current[r.field]=u[u[r.from.id].id].current)}}))}s&&(n.sidIdMap[s]=t.id),u[t.id]=f}},Qe=function(e,r,n){try{return r(C(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Xe=function r(n,t){return void 0===t&&(t={}),ue(n)&&(r(n.or,t),e(n,(function(e,r){fe(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Ye=function(e,r){$(e.next,r),$(O(e),r),$(z(e),r)},Ze=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=z(r);a=i.pop();)Ye(a,r),(n||t&&'sample'!==r.meta.op||"crosslink"===a.family.type)&&e(a,n,'on'!==a.meta.op&&t);for(i=O(r);a=i.pop();)Ye(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==a.meta.op&&t)},er=function(e){return e.clear()},rr=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),V(e))er(I(e));else if(W(e)){t=1;var a=e.history;er(a.events),er(a.effects),er(a.stores),er(a.domains)}Ze(j(e),!!n,t)},nr=function(e){return c((function(){return rr(e)}))},tr=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})},ar=function(e,r){return n(se(r),'.watch argument should be a function'),nr(a({scope:{fn:r},node:[we({fn:ge})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},ir=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},or=function(e,r,n){var t=Xe(n),a="domain"===e,i=X(),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=ae(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 K(0,'getType','compositeName.fullName'),m.fullName},!a){r.subscribe=function(e){return ce(e),r.watch(se(e)?e:function(r){return e.next&&e.next(r)})},r[A]=function(){return r};var h=te();h&&(g.nativeTemplate=h)}return g},ur=function(e,r,n,t){var a;ue(n)&&(a=n,n=n.fn);var i=p({name:e.shortName+" \u2192 *",derived:1,and:a});return tr(e,i,t,r,n),i},sr='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',fr=function(e,r,n,t,a){var i=N(r),o=be({store:i,to:"a",priority:'read'});"map"===n&&(o.data.softRead=1);var u=[o,Me(t)];return d('storeOnMap',i,u,V(e)&&N(e)),tr(e,r,u,n,a)},cr=function(r,t,a,i,u,f){var c=s('combine',i),l=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},p=r?[]:{},v=l(p),g=je(v),h=je(1);g.type=r?'list':'shape',g.noInit=1,d('combineBase',g,h);var y=m(v,Object.assign({name:o(a),derived:1},f,{and:i})),b=N(y);b.noInit=1,D(y,'isCombine',1);var k=Se(g);k.order={priority:'barrier'};var w=be({store:b,to:'b',priority:'read'});w.data.softRead=1;var x=[xe((function(e,r,n){return n.scope&&!n.scope.reg[g.id]&&(n.c=1),e})),k,be({store:h,to:'b'}),xe((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=l(n.a)),n.a[a]=e,1}),1),be({from:"a",target:g}),be({from:"value",store:0,target:h}),be({from:"value",store:1,target:h,priority:'barrier',batch:1}),Se(g,1,1),u&&Me(),w];if(e(a,(function(e,r){if(!V(e))return n(!E(e)&&!fe(e),"combine expects a store in a field "+r,c),void(v[r]=p[r]=e);p[r]=e.defaultState,v[r]=e.getState();var t=tr(e,y,x,'combine',u);t.scope.key=r;var a=N(e);ze(g,{type:'field',field:r,from:a}),d('combineField',a,t)})),y.defaultShape=a,ze(b,{type:"map",from:g,fn:u}),!te())if(u){var S=u(v);!fe(S)||f&&'skipVoid'in f||console.error(c+": "+sr),b.current=S,b.initial=S,y.defaultState=S}else y.defaultState=p;return y},dr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},lr=function(e,r,n,t,a){return function(o){i({target:[t,pr],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})}},pr=a({node:[we({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),vr=['source','clock','target'],mr=function(e,r){return e+": "+r+" should be defined"},gr=function(e,r,t,a,i,o,u,f,c,l,v,h){var y=s(e,f),k=!!i;n(!fe(t)||!fe(r),mr(y,'either source or clock'));var w=0;fe(t)?w=1:E(t)||(t=g(t)),fe(r)?r=t:(le(r,y,'clock'),Array.isArray(r)&&(r=b(r))),w&&(t=r),f||u||(u=t.shortName);var x='none';(v||a)&&(E(a)?x='unit':(n(se(a),'`filter` should be function or unit'),x='fn')),i?(le(i,y,'target'),pe(y,i)):'none'===x&&l&&V(t)&&V(r)?i=m(o?o(Oe(N(t)),Oe(N(r))):Oe(N(t)),{name:u,sid:h,or:f}):(i=p({name:u,derived:1,or:f}),d('sampleTarget',j(i)));var S=je(),M=[];if('unit'===x){var A=yr(a,i,r,S,e),O=A[0];A[2]||M.push.apply(M,hr(A[1])),M.push.apply(M,hr(O))}var z=[];if(w)c&&z.push(Se(S,1,1));else{var C=yr(t,i,r,S,e),I=C[0];C[2]||z.push.apply(z,hr(C[1])),z.push(Se(I,1,c))}var q=tr(r,i,[d('sampleSourceLoader'),be({from:"stack",target:S})].concat(z,M,[Se(S),'fn'===x&&Me((function(e,r,n){return a(e,n.a)}),1),o&&Me(ve),d('sampleSourceUpward',k)]),e,o);return ie(t,[q]),Object.assign(q.meta,f,{joint:1}),i},hr=function(e){return[Se(e),xe((function(e,r,n){return n.a}),1)]},yr=function(e,r,n,t,i){var o=V(e),u=o?N(e):je(),s=je(o);return o||a({parent:e,node:[be({from:"stack",target:u}),be({from:"value",store:1,target:s})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),d('sampleSource',s,u,t),[u,s,o]},br=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})},kr=function(e){return!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op},wr=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!E(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||L(e)||V(e)||G(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));G(e)&&(t=e);var o=h();o.parentFork=Fe;var u=t.fxCount;J(u.scope.defers,o);var s=[],f=[];return G(e)||(J(s,e),J(f,T(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),J(s,u),J(f,null),i({target:s,params:f,scope:t}),o.req},exports.attach=function(e){var r,t,a=f(e,1);e=a[0];var o=s('attach',t=a[1]),c=e.source,d=e.effect,l=e.mapParams,p=e.domain;T(d)&&n(fe(p),'`domain` can only be used with a plain function',o);var v=y(e,t);D(v,'attached',1);var m,h,b=j(v).scope.runner,k=function(e,r,n){var t,a=e.params,o=e.req,u=e.handler,s=v.finally,f=lr(a,o,0,s,n),d=n.a,p=T(u),m=1;if(l){var g=dr(l,f,[a,d]);m=g[0],t=g[1]}else t=c&&p?d:a;if(m){if(!p)return e.args=[d,t],1;i({target:u,params:{params:t,req:{rs:lr(a,o,1,s,n),rj:f}},page:n.page,defer:1,meta:n.meta})}};c?(b.scope.runnerFn=k,V(c)?ie(h=c,[v]):(h=g(c),ie(v,[h])),m=[xe((function(e){return e}),0,1),Se(N(h))],delete b.seq[1].order):m=[xe(k,1,1)],(r=b.seq).splice.apply(r,[1,0].concat(m)),v.use(d);var w=q(d);return w&&(Object.assign(_(v),u(v.shortName,w)),v.defaultConfig.parent=w),ir(d,v,"effect"),v},exports.clearNode=rr,exports.combine=g,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=f(n),i=a[0],o=i[0],u=i[1],s=a[1],c={};return e(u,(function(e,r){var n=c[r]=p(r,{parent:q(o),config:s});o.on(n,e),ir(o,n)})),c},exports.createDomain=function n(t,o){var u=Xe({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=or("domain",f,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:Object.assign({},u,{derived:1})}),e({Event:p,Effect:y,Store:m,Domain:n},(function(e,n){var t=n.toLowerCase(),a=p({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},J(j(a).seq,xe((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){ie(f,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=f)})),ie(f,[a]),f["onCreate"+n]=function(e){return r(o,e),a.watch(e)},f["create"+n]=f[t]=function(r,n){var t=Xe({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 tr(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(f),f},exports.createEffect=y,exports.createEvent=p,exports.createNode=a,exports.createStore=m,exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=e.batch,o=[Ae.run({fn:function(e){return n(e)}})];i&&o.unshift(Ae.compute({priority:'sampler',batch:1})),V(r)&&o.unshift(Ae.mov({store:r.stateRef,to:'stack'}));var u=Array.isArray(r)?r:[r];if(t){var s=[],f=t.additionalLinks;return u.forEach((function(e){var r=f[e.graphite.id]||[];f[e.graphite.id]=r;var n=a({node:S(o,e),meta:{watchOp:e.kind}});r.push(n),s.push((function(){var e=r.indexOf(n);-1!==e&&r.splice(e,1),rr(n)}))})),c((function(){s.forEach((function(e){return e()}))}))}var d=a({node:o,parent:u,family:{owners:u}});return c((function(){rr(d)}))},exports.fork=function(e,t){var i,o=e;W(e)&&(K(0,'fork(domain)','fork()'),i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[xe((function(e,r,n){n.parent?'dec'===n.parent.node.meta.needFxCounter?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),ke({priority:"sampler",batch:1}),xe((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){Ge(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[xe((function(e,r,n){var t=n.parent;if(t){var a=t.node;if(kr(t)){var i=F(n),o=a.meta.sid;i.sidIdMap[o]=a.scope.state.id,i.values.sidMap[o]=e;var u=a.meta.serialize;u&&i.sidSerializeSettings.set(o,'ignore'===u?{ignore:1}:{ignore:0,write:u.write})}}}))]}),i=a({node:[xe((function(e,r,n){var t=F(n);t&&n.parent&&kr(n.parent)&&(t.warnSerialize=1)}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return $e(We,o,e,0).current;var r=j(e);return $e(We,o,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=x(o.values,(function(e){return n(V(e)&&B(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){if(u.values.idMap[r.stateRef.id]=e,'ignore'===R(r,'serialize')){var n=R(r,'sid');u.sidSerializeSettings.set(n,{ignore:1})}})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),u.hasSidDoubles=c}o.handlers&&(K(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),u.handlers=x(o.handlers,(function(e){return n(T(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){var r='forward',n=f(e,1),t=n[0],i=t.from,o=t.to,u=n[1],c=s(r,u);return K(0,r,'sample',c),le(i,c,'"from"'),le(o,c,'"to"'),pe(c,o,'to'),nr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){ce(e);var r=A in e?e[A]():e;n(r.subscribe,'expect observable to have .subscribe');var t=p(),a=nr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=f(r),a=t[0],i=a[0],o=a[1],u=t[1],c=s('guard',u);return K(0,'guard','sample',c),o||(i=(o=i).source),k(o,c),gr('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(ue(a),'values property should be an object');var o=x(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=[];G(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),K(0,'hydrate(fork(domain), { values })','fork({ values })'),l=j(d.cloneOf)):W(e)?(K(0,'hydrate(domain, { values })','fork({ values })'),l=j(e)):n(0,'first argument of hydrate should be domain or scope'),w(l,(function(e,r){if(r&&U(f,r)){J(v,e);var n=R(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),J(m,u[r])}else e.scope.state.id in c&&(J(v,e),J(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=H,exports.launch=i,exports.merge=b,exports.restore=function(r,n,t){var a=s('restore',t);if(V(r))return K(0,'restore($store)',void 0,a),r;if(L(r)||T(r)){var i=q(r),o=m(n,{parent:i,name:r.shortName,and:t});return tr(T(r)?r.doneData:r,o),i&&i.hooks.store(o),o}var u=Array.isArray(r)?[]:{};return e(r,(function(e,r){return u[r]=V(e)?e:m(e,{name:r})})),u},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=f(t),c=u[0],d=c[0],l=c[1],p=c[2],v=u[1],m=1,g=s('sample',v);return fe(l)&&ue(d)&&k(d,g)&&(l=d.clock,p=d.fn,'batch'in d?m=d.batch:(K(!('greedy'in d),'greedy in sample','batch',g),m=!d.greedy),o=d.filter,e=d.target,r=d.name,i=d.sid,d=d.source),gr('sample',l,d,o,e,p,r,v,m,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||Fe||t.safe,'scopeBind: scope not found');var o=a||Fe;return T(e)?function(r){var n=h();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(!U(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&&(K(0,'onlyChanges'),t.onlyChanges||(n(r.cloneOf,'scope should be created from domain'),w(j(r.cloneOf),(function(e,n){n in i||U(a,n)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[n]=r.getState(e))})))),i},exports.setGraphInspector=function(e){M=e},exports.setInspector=function(e){Re=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(_(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];var l=f(u),v=l[0],m=v[0],g=v[1],h=l[1],y=s(i,h),b=!g;b&&(r=m.cases,g=m.match,t=m.clock,m=m.source);var k=V(g),w=!E(g)&&se(g),x=!k&&!w&&ue(g);n(E(m),'source must be a unit',y),r||(r={}),b?e(r,(function(e,r){return pe(y,e,"cases."+r)})):(n(x,'match should be an object',y),e(g,(function(e,n){return r[n]=p({derived:1,named:"cases."+n,and:h})})),r.__=p({derived:1,named:'cases.__',and:h}));var S,M=new Set([].concat(m,t||[],Object.values(r))),A=Object.keys(k||w?r:g);if(k||w)k&&M.add(g),S=[k&&Se(N(g),0,1),ke({safe:k,filter:1,pure:!k,fn:function(e,r,n){var t=String(k?n.a:g(e));br(r,U(A,t)?t:'__',e,n)}})];else if(x){var j=je({});j.type='shape';var O,z=[];e(g,(function(e,r){if(E(e)){O=1,J(z,r),M.add(e);var n=tr(e,[],[Se(j),xe((function(e,n,t){return t.a[r]=e}))]);if(V(e)){j.current[r]=e.getState();var t=N(e);ze(j,{from:t,field:r,type:'field'}),d('splitMatchStore',t,n)}}})),O&&d('splitBase',j),S=[O&&Se(j,0,1),Me((function(e,r,n){for(var t=0;t<A.length;t++){var a=A[t];if(U(z,a)?n.a[a]:g[a](e))return void br(r,a,e,n)}br(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var C=a({meta:{op:i},parent:t?[]:m,scope:r,node:S,family:{owners:Array.from(M)},regional:1});if(t&&gr(i,t,m,null,C,null,i,h,0,0,0),!b)return r},exports.step=Ae,exports.version="23.0.0-rc.6",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:ae(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:f}={}){let p=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(p,(e=>U(e.next,h))),f&&te&&ie(C(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++)Fe('pure',i,z(e[t]),o,r[t],s,n);else Fe('pure',i,z(e),o,r,s,n);if(a&&!Pe)return;let l,d,u,f,p,c,m={isRoot:Pe,currentPage:Be,scope:Ee,isWatch:Ve,isPure:Te};Pe=0;e:for(;f=qe();){let{idx:e,stack:r,type:a}=f;u=r.node,Be=p=r.page,Ee=O(r),p?c=p.reg:Ee&&(c=Ee.reg);let n=!!p,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?p?`${p.fullID}_${i}`:i:0;if(t!==e||a!==n){i?_e.has(o)||(_e.add(o),Re(t,r,n,i)):Re(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=C(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(p,t.store.id);r.page=p=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(p,Ee,u,t.target).current=e}break}case'compute':let e=s.data;if(e.fn){Ve='watch'===q(u,'op'),Te=e.pure;let t=e.safe?(0,e.fn)(C(r),o.scope,r):Qe(o,e.fn,r);e.filter?d=!t:r.value=t,Ve=m.isWatch,Te=m.isPure}}l=o.fail||d}if(He&&He(r,o),!l){let e=C(r),a=O(r);if(t(u.next,(t=>{Fe('child',p,t,r,e,a)})),a){q(u,'needFxCounter')&&Fe('child',p,a.fxCount,r,e,a),q(u,'storeChange')&&Fe('child',p,a.storeChange,r,e,a),q(u,'warnSerialize')&&Fe('child',p,a.warnSerializeNode,r,e,a);let n=a.additionalLinks[u.id];n&&t(n,(t=>{Fe('child',p,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+=D(e)?R(e).fullName:e.toString()),i+=1,n=', ')})),a+')'}function s(e,t){let r,a,n=e;if(t){let n=R(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 f(e,t){let a=Xe({or:t,and:'string'==typeof e?{name:e}:e}),o=(e,...t)=>(r(!q(o,'derived'),'call of derived event is not supported, use createEvent instead'),r(!Te,'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=f('* \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),F(l,'id',l.graphite.id),re(l.graphite),l}function p(e,a,n,i){return pe(n,a,'first argument'),r(le(i),'second argument should be a function'),J(!q(e,'derived'),`${a} in derived store`,`${a} in store created via createStore`),t(Array.isArray(n)?n:[n],(t=>{e.off(t),j(e).set(t,rt(ut(t,e,'on',ge,i)))})),e}function c(e,a){let o=Xe(a),s=Ae(e),l=f({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=>p(h,'.reset',e,(()=>h.defaultState)))),h),on:(e,t)=>(r(h.targetable,'.on of derived store is not supported'),p(h,'.on',e,t)),off(e){let t=j(h).get(e);return t&&(t(),j(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 Ne(N(o),{type:S,fn:e,from:s}),N(o).noInit=1,u('storeMap',s,l),o},watch(e,t){if(J(!t,'watch second argument','sample'),!t||!D(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}),F(h,'id',h.graphite.id),F(h,'rootStateRefId',d);let v=q(h,'serialize'),k=q(h,'derived'),x='ignore'===v,w=q(h,'sid');w&&(F(h,'storeChange',1),s.sid=w),w||x||k||F(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=f({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),f=u&&d,p=u?e[e.length-2]:d;if(le(p)?(a=e.slice(0,u?-2:-1),t=p):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'),ft(Array.isArray(i),!s,i,n,t,f)}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=f(le(e)?{handler:e}:e,{...t,actualOp:"effect"}),s=z(o);F(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=f({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}}}),p=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.compositeName.fullName}`))},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(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;let{params:a,req:n,handler:i,args:o=[a]}=e,s=ct(a,n,1,l,r),d=ct(a,n,0,l,r),[u,f]=pt(i,d,o);u&&(se(f)&&le(f.then)?f.then(s,d):s(f))}),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&&!Ve){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:(q(o,'name')||o.graphite.id)+'.inFlight'}).on(o,(e=>e+1)).on(l,(e=>e-1)).map({fn:e=>e,named:'inFlight'});F(l,'needFxCounter','dec'),F(o,'needFxCounter',1);let b=o.pending=y.map({fn:e=>e>0,named:'pending'});return ie(o,[l,d,u,p,m,b,y]),null!=a&&a.domain&&a.domain.hooks.effect(o),o}function y(e,t){pe(e,'merge','first argument');let r=f({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"===q(i,'op')&&(a||q(i,'sid'))&&r(i,q(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(D(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,N=e=>e.stateRef,C=e=>e.value,j=e=>e.subscribers,I=e=>e.parent,O=e=>e.scope,q=(e,t)=>z(e).meta[t],F=(e,t,r)=>z(e).meta[t]=r,R=e=>e.compositeName,D=e=>(le(e)||se(e))&&'kind'in e;const _=e=>t=>D(t)&&t.kind===e;let E=_("store"),P=_("event"),V=_("effect"),T=e=>D(e)&&!!e.targetable,B=_("domain"),L=_("scope");var W={__proto__:null,unit:D,store:E,event:P,effect:V,targetable:T,domain:B,scope:L,attached:e=>V(e)&&1==q(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 fe=(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 pe=(e,r,a)=>{Array.isArray(e)?t(e,((e,t)=>fe(e,r,`${t} item of ${a}`,''))):fe(e,r,a,' or array of units')},ce=(e,a,n="target")=>t(oe(a),(t=>r(!q(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,Ne=(e,t)=>{e.before||(e.before=[]),U(e.before,t)},Ce=null;const je=(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||De(e.v.type)>De(t.v.type))&&(r=e,e=t,t=r),r=je(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 qe=()=>{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=Ce.v;return Ce=je(Ce.l,Ce.r),e}1===t.size&&(t.last=null);let r=t.first;return t.first=r.r,t.size-=1,r.v}}},Fe=(e,t,r,a,n,i,o)=>Re(0,{a:null,b:null,node:r,parent:a,value:n,page:t,scope:i,meta:o},e),Re=(e,t,r,a=0)=>{let n=De(r),i=Ie[n],o={v:{idx:e,stack:t,type:r,id:a},l:null,r:null};3===n||4===n?Ce=je(Ce,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},De=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,Ve=0,Te=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,f={id:r.id,current:r.initial,meta:r.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(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&&(f.current=t.fn?t.fn(i):i)}break}case'field':i||(i=1,f.current=Array.isArray(f.current)?[...f.current]:{...f.current}),Ke(e,t.from,a,n),o&&(f.current[t.field]=s[s[t.from.id].id].current)}}))}l&&(e.sidIdMap[l]=r.id),s[r.id]=f};const Qe=(e,t,r)=>{try{return t(C(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'!==q(e,'op')||"crosslink"===a.family.type)&&Ze(a,t,'on'!==q(a,'op')&&r);for(n=A(e);a=n.pop();)Ye(a,e),r&&"crosslink"===a.family.type&&Ze(a,t,'on'!==q(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(j(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,f=l||a.name||(n?'':i),p=s(f,u),c={op:t.kind=e,name:t.shortName=f,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=p,t.defaultConfig=a,t.getType=()=>(J(0,'getType','compositeName.fullName'),p.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=f({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=N(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)&&N(e)),at(e,t,s,r,n)},ft=(t,a,n,i,s,l)=>{let d=t?e=>[...e]:e=>({...e}),f=t?[]:{},p=d(f),m=Ae(p),g=Ae(1);m.type=t?'list':'shape',m.noInit=1,u('combineBase',m,g);let h=c(p,{name:o(n),derived:1,...l,and:i}),y=N(h);y.noInit=1,F(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(!D(e)&&!de(e),`combine expects a store in a field ${t}`),void(p[t]=f[t]=e);f[t]=e.defaultState,p[t]=e.getState();let a=at(e,h,k,'combine',s);a.scope.key=t;let n=N(e);Ne(m,{type:'field',field:t,from:n}),u('combineField',n,a)})),h.defaultShape=n,Ne(y,{type:S,from:m,fn:s}),!ae())if(s){let e=s(p);!de(e)||l&&"skipVoid"in l||console.error(dt),y.current=e,y.initial=e,h.defaultState=e}else h.defaultState=f;return h};let pt=(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,p,g,h)=>{let b=!!i;r(!de(a)||!de(t),ht(e,'either source or clock'));let v=0;de(a)?v=1:D(a)||(a=m(a)),de(t)?t=a:(pe(t,e,'clock'),Array.isArray(t)&&(t=y(t))),v&&(a=t),l||s||(s=a.shortName);let k='none';(g||n)&&(D(n)?k='unit':(r(le(n),'`filter` should be function or unit'),k='fn')),i?(pe(i,e,'target'),ce(e,i)):'none'===k&&p&&E(a)&&E(t)?i=c(o?o($e(N(a)),$e(N(t))):$e(N(a)),{name:s,sid:h,or:l}):(i=f({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?N(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(!D(e))return Promise.reject(new Error('first argument should be unit'));if(!(V(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,V(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;V(n)&&r(de(d),'`domain` can only be used with a plain function');let u=h(e,t);F(u,'attached',1);let f,{runner:p}=z(u).scope,c=(e,t,r)=>{let n,{params:s,req:l,handler:d}=e,f=u.finally,p=ct(s,l,0,f,r),c=r.a,m=V(d),g=1;if(o?[g,n]=pt(o,p,[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,f,r),rj:p}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;p.scope.runnerFn=c,E(a)?(e=a,ie(e,[u])):(e=m(a),ie(u,[e])),f=[we((e=>e),0,1),Se(N(e))],delete p.seq[1].order}else f=[we(c,1,1)];p.seq.splice(1,0,...f),u.use(n);let g=I(n);return g&&(Object.assign(R(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]=f(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:f,Effect:h,Store:c,Domain:r},((e,r)=>{let a=r.toLowerCase(),n=f({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=f,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'===q(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(!q(t,'isCombine')||I(a)&&'combine'!==q(I(a).node,'op')){let a=O(r),n=t.scope.state.id,i=q(t,'sid');a.sidIdMap[i]=n,a.values.sidMap[i]=e;let o=q(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&&(!q(e.node,'isCombine')||I(e)&&'combine'!==q(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)&&T(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=q(t,'serialize'),a=q(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(V(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 pe(r,t,'"from"'),pe(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=f(),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,f,p=[],c=[];L(e)?(d=e,f=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(p,e);let r=q(e,'serialize');r&&'ignore'!==r&&(n[t]=r.read(n[t])),U(c,n[t])}else e.scope.state.id in l&&(U(p,e),U(c,o.get(l[e.scope.state.id])))}),1),i({target:p,params:c,scope:d}),f&&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)||V(t)){let e=I(t),n=c(r,{parent:e,name:t.shortName,and:a});return at(V(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 V(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)||q(e,'isCombine')||'ignore'===q(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(R(e),s(t,I(e)))},exports.split=(...t)=>{let a,i,o='split',[[s,d],p]=l(t),c=!d;c&&(a=s.cases,d=s.match,i=s.clock,s=s.source);let m=E(d),g=!D(d)&&le(d),h=!m&&!g&&se(d);r(D(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]=f({derived:1,named:`cases.${t}`,and:p}))),a.__=f({derived:1,named:'cases.__',and:p}));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(N(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(D(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=N(e);Ne(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,p,0,0,0),!c)return a},exports.step=ze,exports.version="23.0.0-rc.5",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(const r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t,r){if(!e)throw Error(`${r?r+': ':''}${t}`)}function n(e,t){const r=M(e).meta||{};ee={id:M(e).id,parent:ee,value:e,template:r.template||re(),sidRoot:r.sidRoot||ee&&ee.sidRoot,meta:r};try{return t()}finally{te('region'),ee=C(ee)}}function a({node:e=[],from:r,source:n,parent:a=r||n,to:o,target:s,child:i=o||s,scope:c={},meta:l={},family:d={type:'regular'},regional:p}={}){const u=oe(a),f=oe(d.links),m=oe(d.owners),h=[];t(e,(e=>e&&H(h,e)));const g={id:X(),seq:h,next:oe(i),meta:l,scope:c,family:{type:d.type||"crosslink",links:f,owners:m}};return t(f,(e=>H($(e),g))),t(m,(e=>H(z(e),g))),t(u,(e=>H(e.next,g))),p&&ee&&ae(N(ee),[g]),g}function o(e,r,n){let a,o=Te,s=null,i=_e;if(e.target&&(r=e.params,n=e.defer,a=e.meta,o='page'in e?e.page:o,e.stack&&(s=e.stack),i=I(e)||i,e=e.target),i&&_e&&i!==_e&&(_e=null),Array.isArray(e))for(let t=0;t<e.length;t++)qe('pure',o,M(e[t]),s,r[t],i,a);else qe('pure',o,M(e),s,r,i,a);if(n&&!Ee)return;const c={isRoot:Ee,currentPage:Te,scope:_e,isWatch:Pe,isPure:Ve};let l,d,p,u,f,m;Ee=0;e:for(;u=Oe();){const{idx:e,stack:r,type:n}=u;p=r.node,Te=f=r.page,_e=I(r),f?m=f.reg:_e&&(m=_e.reg);const a=!!f,o=!!_e,s={fail:0,scope:p.scope};l=d=0;for(let t=e;t<p.seq.length&&!l;t++){const i=p.seq[t];if(i.order){const{priority:a,barrierID:o}=i.order,s=o?f?`${f.fullID}_${o}`:o:0;if(t!==e||n!==a){o?De.has(s)||(De.add(s),Fe(t,r,a,o)):Fe(t,r,a,0);continue e}o&&De.delete(s)}switch(i.type){case'mov':{const e=i.data;let t;switch(e.from){case'stack':t=N(r);break;case'a':case'b':t=r[e.from];break;case'value':t=e.store;break;case'store':if(m&&!m[e.store.id])if(a){const t=We(f,e.store.id);r.page=f=t,t?m=t.reg:o?(Je(_e,e.store,0,1,e.softRead),m=_e.reg):m=void 0}else o&&Je(_e,e.store,0,1,e.softRead);t=ze(m&&m[e.store.id]||e.store)}switch(e.to){case'stack':r.value=t;break;case'a':case'b':r[e.to]=t;break;case'store':Ge(f,_e,e.target,0).current=t}break}case'compute':const e=i.data;if(e.fn){Pe='watch'===p.meta.op,Ve=e.pure;const t=e.safe?(0,e.fn)(N(r),s.scope,r):Ke(s,e.fn,r);e.filter?d=!t:r.value=t,Pe=c.isWatch,Ve=c.isPure}}l=s.fail||d}if(He&&He(r,s),!l){const e=N(r),n=I(r);if(t(p.next,(t=>{qe('child',f,t,r,e,n)})),n){p.meta.needFxCounter&&qe('child',f,n.fxCount,r,e,n),p.meta.storeChange&&qe('child',f,n.storeChange,r,e,n),p.meta.warnSerialize&&qe('child',f,n.warnSerializeNode,r,e,n);const a=n.additionalLinks[p.id];a&&t(a,(t=>{qe('child',f,t,r,e,n)}))}}}Ee=c.isRoot,Te=c.currentPage,_e=I(c)}function s(t,r="combine"){let n=r+'(',a='',o=0;return e(t,(e=>{o<25&&(null!=e&&(n+=a,n+=R(e)?F(e).fullName:e.toString()),o+=1,a=', ')})),n+')'}function i(e,t){let r,n;const a=e;if(t){const a=F(t);0===e.length?(r=a.path,n=a.fullName):(r=a.path.concat([e]),n=0===a.fullName.length?e:a.fullName+'/'+e)}else r=0===e.length?[]:[e],n=e;return{shortName:a,fullName:n,path:r}}function c(e,t){if(!t)return e;if(!t.name&&!t.named&&!t.loc)return e;let r=`[${e}]`;const n=t.named||t.name;n&&(r+=` unit '${n}'`);const a=t.loc;return!n&&a&&(r+=` (${a.file}:${a.line}:${a.column})`),r}function l(e,t){const r=t?e:e[0];le(r);let n=r.or;const a=r.and;if(a){const r=t?a:a[0];if(se(r)&&'and'in r){const r=l(a,t);e=r[0],n={...n,...r[1]}}else e=a}return[e,n]}function d(e){const t=()=>e();return t.unsubscribe=()=>e(),t}function p(e,...t){const r=re();if(r){const n=r.handlers[e];if(n)return n(r,...t)}}function u(e,t){const n=Qe({or:t,and:'string'==typeof e?{name:e}:e}),s=c('event',n),i=(e,...t)=>(r(!O(i,'derived'),'call of derived event is not supported, use createEvent instead',s),r(!Ve,'unit call from pure function is not supported, use operators like sample instead',s),Te?((e,t,r,n)=>{const a=Te;let o=null;if(t)for(o=Te;o&&o.template!==t;)o=C(o);Le(o);const s=e.create(r,n);return Le(a),s})(i,l,e,t):i.create(e,t)),l=re(),d=Object.assign(i,{graphite:a({meta:ot(n.actualOp||"event",i,n),regional:1}),create:e=>(o({target:i,params:e,scope:_e}),e),watch:e=>nt(i,e),map:e=>st(i,"map",e,[Se()]),filter:e=>st(i,'filter',e.fn?e:e.fn,[Se(he,1)]),filterMap:e=>st(i,'filterMap',e,[Se(),xe((e=>!ce(e)),1)]),prepend(e){r(i.targetable,'.prepend of derived event is not supported, call source event instead',s);const t=u('* \u2192 '+i.shortName,{parent:C(i)});return p('eventPrepend',M(t)),rt(t,i,[Se()],'prepend',e),at(i,t),t}});return null!=n&&n.domain&&n.domain.hooks.event(d),q(d,'id',d.graphite.id),te(d.graphite),d}function f(e,n,a,o,s){return pe(a,`${s} ${n}`,'first argument'),r(ie(o),'second argument should be a function',s),U(!O(e,'derived'),`${n} in derived store`,`${n} in store created via createStore`,s),t(Array.isArray(a)?a:[a],(t=>{e.off(t),j(e).set(t,tt(lt(t,e,'on',me,o)))})),e}function m(e,n){const s=Qe(n),i=$e(e),l=c('store',s),d=u({named:'updates',derived:1});p('storeBase',i);const h=i.id,g='skipVoid'in s,y=g&&!s.skipVoid;U(!(g&&s.skipVoid),'{skipVoid: true}','updateFilter',l);const v={subscribers:new Map,updates:d,defaultState:e,stateRef:i,getState(){let e,t=i;if(Te){let t=Te;for(;t&&!t.reg[h];)t=C(t);t&&(e=t)}return!e&&_e&&(Je(_e,i,1),e=_e),e&&(t=e.reg[h]),ze(t)},setState:e=>o({target:v,params:e,defer:1,scope:_e}),reset:(...e)=>(r(v.targetable,'.reset of derived store is not supported',l),t(e,(e=>f(v,'.reset',e,(()=>v.defaultState),l))),v),on:(e,t)=>(r(v.targetable,'.on of derived store is not supported',l),f(v,'.on',e,t,l)),off(e){const t=j(v).get(e);return t&&(t(),j(v).delete(e)),v},map(e,t){let r,n;se(e)&&(r=e,e=e.fn);const a=v.getState(),o=ce(a);re()?n=null:(!o||o&&y)&&(n=e(a));const s=m(n,{name:`${v.shortName} \u2192 *`,derived:1,...t,and:r}),c=lt(v,s,"map",he,e);return Ae(A(s),{type:"map",fn:e,from:i}),A(s).noInit=1,p('storeMap',i,c),s},watch(e,t){if(U(!t,'watch second argument','sample',l),!t||!R(e)){const t=nt(v,e);return p('storeWatch',i,e)||e(v.getState()),t}return r(ie(t),'second argument should be a function',l),e.watch((e=>t(v.getState(),e)))}},b=ot("store",v,s),k=v.defaultConfig.updateFilter;v.graphite=a({scope:{state:i,fn:k},node:[xe(((e,t,r)=>(r.scope&&!r.scope.reg[i.id]&&(r.b=1),e))),we(i),xe(((e,t,{a:r,b:n})=>{const a=ce(e);return a&&!g&&console.error(`${l}: ${ct}`),(a&&y||!a)&&(e!==r||n)}),1),k&&Se(fe,1),ve({from:"stack",target:i})],child:d,meta:{...b,defaultState:e},regional:1}),q(v,'id',v.graphite.id),q(v,'rootStateRefId',h);const x=O(v,'serialize'),w=O(v,'derived'),S='ignore'===x,M=O(v,'sid');M&&(q(v,'storeChange',1),i.sid=M),M||S||w||q(v,'warnSerialize',1);const $=ce(e);return r(w||!$||$&&y,ct,l),w&&$&&!g&&console.error(`${l}: ${ct}`),ae(v,[d]),null!=s&&s.domain&&s.domain.hooks.store(v),w||(v.reinit=u({named:'reinit'}),v.reset(v.reinit)),i.meta=v.graphite.meta,te(v.graphite),v}function h(...e){let t,n,a;[e,a]=l(e);const o=c('combine',a),s=e[e.length-1],i=!_(s)&&se(s),d=i&&s,p=i?e[e.length-2]:s;let u,f,m;if(ie(p)?(n=e.slice(0,i?-2:-1),t=p):n=e,1===n.length){const e=n[0];_(e)||(u=e,f=1)}if(!f&&(u=n,t)){m=1;const e=t;t=t=>e(...t)}return r(se(u),`${o}: shape should be an object`),dt(Array.isArray(u),!m,u,a,t,d)}function g(){const e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function y(e,t={}){const n=Qe(ie(e)?{handler:e}:e,t),s=c('effect',n),i=u(ie(e)?{handler:e}:e,{...t,actualOp:"effect"}),l=M(i);q(l,'op',i.kind="effect"),i.use=e=>(r(ie(e),'.use argument should be a function',s),v.scope.handler=e,i),i.use.getCurrent=()=>v.scope.handler;const d=i.finally=u({named:'finally',derived:1}),p=i.done=d.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=i.fail=d.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),h=i.doneData=p.map({named:'doneData',fn:({result:e})=>e}),y=i.failData=f.map({named:'failData',fn:({error:e})=>e}),v=a({scope:{handler:i.defaultConfig.handler||(()=>r(0,`no handler used in ${i.compositeName.fullName}`))},node:[xe(((e,t,r)=>{let n=t.handler;const a=I(r);if(a){const e=a.handlers.unitMap.get(i)||a.handlers.sidMap[i.sid];e&&(n=e)}return e.handler=n,e}),0,1),xe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;const{params:n,req:a,handler:o,args:s=[n]}=e,i=ut(n,a,1,d,r),c=ut(n,a,0,d,r),[l,p]=pt(o,c,s);l&&(se(p)&&ie(p.then)?p.then(i,c):i(p))}),0,1)],meta:{op:'fx',fx:'runner'}});l.scope.runner=v,H(l.seq,xe(((e,{runner:t},r)=>{const n=C(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:Y()}),o({target:t,params:n,defer:1,scope:I(r),meta:r.meta}),n.params}))),i.create=e=>{const t=g(),r={params:e,req:t};if(_e&&!Pe){const e=_e;t.req.finally((()=>{Be(e)})).catch((()=>{}))}return o({target:i,params:r,scope:_e}),t.req};const b=i.inFlight=m(0,{serialize:'ignore',named:(O(i,'name')||i.graphite.id)+'.inFlight'}).on(i,(e=>e+1)).on(d,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(d,'needFxCounter','dec'),q(i,'needFxCounter',1);const k=i.pending=b.map({fn:e=>e>0,named:'pending'});return ae(i,[d,p,f,h,y,k,b]),null!=n&&n.domain&&n.domain.hooks.effect(i),i}function v(e,t){const r=c('merge',t);pe(e,r,'first argument');const n=u({name:s(e,'merge'),derived:1,and:t});return rt(e,n,[],'merge'),n}function b(e,n){let a=0;return t(mt,(t=>{t in e&&(r(null!=e[t],ht(n,t)),a=1)})),a}function k(e,r,n){const a=[];(function e(o){W(a,o)||(H(a,o),"store"===O(o,'op')&&(n||O(o,'sid'))&&r(o,O(o,'sid')),t(o.next,e),t($(o),e),t(z(o),e))})(e)}function x(e,n){const a=Array.isArray(e)?new Map(e):e,o=new Map;let s=0;if(a instanceof Map){const e={};return t(a,((t,a)=>{r(R(a),'Map key should be a unit'),n&&n(a,t),a.sid&&(a.sid in e&&(s=1),e[a.sid]=t),o.set(a,t)})),{sidMap:e,unitMap:o,hasSidDoubles:s}}return{sidMap:a,unitMap:o}}function w(e,t){return _(t)?[Me.mov({store:t.stateRef,to:'stack'}),...e]:e}Object.defineProperty(exports,'__esModule',{value:1});const S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M=e=>e.graphite||e,$=e=>e.family.owners,z=e=>e.family.links,A=e=>e.stateRef,N=e=>e.value,j=e=>e.subscribers,C=e=>e.parent,I=e=>e.scope,O=(e,t)=>M(e).meta[t],q=(e,t,r)=>M(e).meta[t]=r,F=e=>e.compositeName,R=e=>(ie(e)||se(e))&&'kind'in e,D=e=>t=>R(t)&&t.kind===e,_=D("store"),E=D("event"),P=D("effect"),V=e=>R(e)&&!!e.targetable,T=D("domain"),B=D("scope");var L={__proto__:null,unit:R,store:_,event:E,effect:P,targetable:V,domain:T,scope:B,attached:e=>P(e)&&1==O(e,'attached')};const W=(e,t)=>e.includes(t),G=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},H=(e,t)=>e.push(t),U=(e,t,r,n)=>!e&&console.error(`${n?n+': ':''}${t} is deprecated${r?`, use ${r} instead`:''}`),J=()=>{let e=0;return()=>""+ ++e},K=J(),Q=J(),X=J(),Y=J();let Z,ee=null;const te=e=>{Z&&Z(e,ee)},re=()=>ee&&ee.template,ne=e=>(e&&ee&&ee.sidRoot&&(e=`${ee.sidRoot}|${e}`),e),ae=(e,r)=>{const n=M(e);t(r,(e=>{const t=M(e);"domain"!==n.family.type&&(t.family.type="crosslink"),H($(t),n),H(z(n),t)}))},oe=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(M),se=e=>'object'==typeof e&&null!==e,ie=e=>'function'==typeof e,ce=e=>void 0===e,le=e=>r(se(e)||ie(e),'expect first argument be an object'),de=(e,t,n,a)=>r(!(!se(e)&&!ie(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${n} to be a unit (store, event or effect)${a}`),pe=(e,r,n)=>{Array.isArray(e)?t(e,((e,t)=>de(e,r,`${t} item of ${n}`,''))):de(e,r,n,' or array of units')},ue=(e,n,a="target")=>t(oe(n),(t=>r(!O(t,'derived'),`${e}: derived unit in "${a}" is not supported, use createStore/createEvent instead"`))),fe=(e,{fn:t},{a:r})=>t(e,r),me=(e,{fn:t},{a:r})=>t(r,e),he=(e,{fn:t})=>t(e),ge=(e,t,r,n)=>{const a={id:Q(),type:e,data:t};return r&&(a.order={priority:r},n&&(a.order.barrierID=++ye)),a};let ye=0;const ve=({from:e="store",store:t,target:r,to:n=(r?"store":"stack"),batch:a,priority:o})=>ge('mov',{from:e,store:t,to:n,target:r},o,a),be=({fn:e,batch:t,priority:r,safe:n=0,filter:a=0,pure:o=0})=>ge('compute',{fn:e,safe:n,filter:a,pure:o},r,t),ke=({fn:e})=>be({fn:e,priority:"effect"}),xe=(e,t,r)=>be({fn:e,safe:1,filter:t,priority:r&&"effect"}),we=(e,t,r)=>ve({store:e,to:t?"stack":"a",priority:r&&"sampler",batch:1}),Se=(e=he,t)=>be({fn:e,pure:1,filter:t}),Me={mov:ve,compute:be,filter:({fn:e,pure:t})=>be({fn:e,filter:1,pure:t}),run:ke},$e=e=>({id:Q(),current:e,initial:e}),ze=({current:e})=>e,Ae=(e,t)=>{e.before||(e.before=[]),H(e.before,t)};let Ne=null;const je=(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||Re(e.v.type)>Re(t.v.type))&&(r=e,e=t,t=r),r=je(e.r,t),e.r=e.l,e.l=r,e},Ce=[];let Ie=0;for(;Ie<6;)H(Ce,{first:null,last:null,size:0}),Ie+=1;const Oe=()=>{for(let e=0;e<6;e++){const t=Ce[e];if(t.size>0){if(3===e||4===e){t.size-=1;const e=Ne.v;return Ne=je(Ne.l,Ne.r),e}1===t.size&&(t.last=null);const r=t.first;return t.first=r.r,t.size-=1,r.v}}},qe=(e,t,r,n,a,o,s)=>Fe(0,{a:null,b:null,node:r,parent:n,value:a,page:t,scope:o,meta:s},e,0),Fe=(e,t,r,n)=>{const a=Re(r),o=Ce[a],s={v:{idx:e,stack:t,type:r,id:n},l:null,r:null};3===a||4===a?Ne=je(Ne,s):(0===o.size?o.first=s:o.last.r=s,o.last=s),o.size+=1},Re=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}},De=new Set;let _e,Ee=1,Pe=0,Ve=0,Te=null;const Be=e=>{_e=e},Le=e=>{Te=e},We=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=e.parent;if(e)return e}return null},Ge=(e,t,r,n)=>{const a=We(e,r.id);return a?a.reg[r.id]:t?(Je(t,r,n),t.reg[r.id]):r};let He;const Ue=e=>e,Je=(e,r,n,a,o)=>{const s=e.reg;if(s[r.id])return;const i=r.sid,c={id:r.id,current:r.initial,meta:r.meta};if(c.id in e.values.idMap)c.current=e.values.idMap[c.id];else if(i&&i in e.values.sidMap&&!(i in e.sidIdMap)){var l;const t=null==r||null===(l=r.meta)||void 0===l?void 0:l.serialize;c.current=(e.fromSerialize&&'ignore'!==t&&(null==t?void 0:t.read)||Ue)(e.values.sidMap[i])}else if(r.before&&!o){let o=0;const i=n||!r.noInit||a;t(r.before,(t=>{switch(t.type){case'map':{const r=t.from;if((r||t.fn)&&(r&&Je(e,r,n,a),i)){const e=r&&s[r.id].current;c.current=t.fn?t.fn(e):e}break}case'field':Je(e,t.from,n,a),o||(o=1,c.current=Array.isArray(c.current)?[...c.current]:{...c.current}),i&&(c.current[t.field]=s[s[t.from.id].id].current)}}))}i&&(e.sidIdMap[i]=r.id),s[r.id]=c},Ke=(e,t,r)=>{try{return t(N(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Qe=(t,r={})=>(se(t)&&(Qe(t.or,r),e(t,((e,t)=>{ce(e)||'or'===t||'and'===t||(r[t]=e)})),Qe(t.and,r)),r),Xe=(e,t)=>{G(e.next,t),G($(e),t),G(z(e),t)},Ye=(e,t,r)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let a=z(e);for(;n=a.pop();)Xe(n,e),(t||r&&'sample'!==e.meta.op||"crosslink"===n.family.type)&&Ye(n,t,'on'!==n.meta.op&&r);for(a=$(e);n=a.pop();)Xe(n,e),r&&"crosslink"===n.family.type&&Ye(n,t,'on'!==n.meta.op&&r)},Ze=e=>e.clear(),et=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),_(e))Ze(j(e));else if(T(e)){r=1;const t=e.history;Ze(t.events),Ze(t.effects),Ze(t.stores),Ze(t.domains)}Ye(M(e),!!t,r)},tt=e=>d((()=>et(e))),rt=(e,t,r,n,o)=>a({node:r,parent:e,child:t,scope:{fn:o},meta:{op:n},family:{owners:[e,t],links:t},regional:1}),nt=(e,t)=>(r(ie(t),'.watch argument should be a function'),tt(a({scope:{fn:t},node:[ke({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),at=(e,t,r="event")=>{C(e)&&C(e).hooks[r](t)},ot=(e,t,r)=>{const n=Qe(r),a="domain"===e,o=K(),{sid:s=null,named:c=null,domain:l=null,parent:d=l}=n,p=c||n.name||(a?'':o),u=i(p,d),f={op:t.kind=e,name:t.shortName=p,sid:t.sid=ne(s),named:c,unitId:t.id=o,serialize:n.serialize,derived:n.derived,config:n};if(t.targetable=!n.derived,t.parent=d,t.compositeName=u,t.defaultConfig=n,t.getType=()=>(U(0,'getType','compositeName.fullName'),u.fullName),!a){t.subscribe=e=>(le(e),t.watch(ie(e)?e:t=>e.next&&e.next(t))),t[S]=()=>t;const e=re();e&&(f.nativeTemplate=e)}return f},st=(e,t,r,n)=>{let a;se(r)&&(a=r,r=r.fn);const o=u({name:`${e.shortName} \u2192 *`,derived:1,and:a});return rt(e,o,n,t,r),o},ct='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',lt=(e,t,r,n,a)=>{const o=A(t),s=ve({store:o,to:"a",priority:'read'});"map"===r&&(s.data.softRead=1);const i=[s,Se(n)];return p('storeOnMap',o,i,_(e)&&A(e)),rt(e,t,i,r,a)},dt=(t,n,a,o,i,l)=>{const d=c('combine',o),u=t?e=>[...e]:e=>({...e}),f=t?[]:{},h=u(f),g=$e(h),y=$e(1);g.type=t?'list':'shape',g.noInit=1,p('combineBase',g,y);const v=m(h,{name:s(a),derived:1,...l,and:o}),b=A(v);b.noInit=1,q(v,'isCombine',1);const k=we(g);k.order={priority:'barrier'};const x=ve({store:b,to:'b',priority:'read'});x.data.softRead=1;const w=[xe(((e,t,r)=>(r.scope&&!r.scope.reg[g.id]&&(r.c=1),e))),k,ve({store:y,to:'b'}),xe(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return n&&r.b&&(r.a=u(r.a)),r.a[t]=e,1}),1),ve({from:"a",target:g}),ve({from:"value",store:0,target:y}),ve({from:"value",store:1,target:y,priority:'barrier',batch:1}),we(g,1,1),i&&Se(),x];if(e(a,((e,t)=>{if(!_(e))return r(!R(e)&&!ce(e),`combine expects a store in a field ${t}`,d),void(h[t]=f[t]=e);f[t]=e.defaultState,h[t]=e.getState();const n=rt(e,v,w,'combine',i);n.scope.key=t;const a=A(e);Ae(g,{type:'field',field:t,from:a}),p('combineField',a,n)})),v.defaultShape=a,Ae(b,{type:"map",from:g,fn:i}),!re())if(i){const e=i(h);!ce(e)||l&&'skipVoid'in l||console.error(`${d}: ${ct}`),b.current=e,b.initial=e,v.defaultState=e}else v.defaultState=f;return v},pt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ut=(e,t,r,n,a)=>s=>{o({target:[n,ft],params:[r?{status:'done',params:e,result:s}:{status:'fail',params:e,error:s},{value:s,fn:r?t.rs:t.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})},ft=a({node:[ke({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),mt=['source','clock','target'],ht=(e,t)=>e+`: ${t} should be defined`,gt=(e,t,n,a,o,s,i,l,d,f,g,y)=>{const b=c(e,l),k=!!o;r(!ce(n)||!ce(t),ht(b,'either source or clock'));let x=0;ce(n)?x=1:R(n)||(n=h(n)),ce(t)?t=n:(pe(t,b,'clock'),Array.isArray(t)&&(t=v(t))),x&&(n=t),l||i||(i=n.shortName);let w='none';(g||a)&&(R(a)?w='unit':(r(ie(a),'`filter` should be function or unit'),w='fn')),o?(pe(o,b,'target'),ue(b,o)):'none'===w&&f&&_(n)&&_(t)?o=m(s?s(ze(A(n)),ze(A(t))):ze(A(n)),{name:i,sid:y,or:l}):(o=u({name:i,derived:1,or:l}),p('sampleTarget',M(o)));const S=$e();let $=[];if('unit'===w){const[r,n,s]=vt(a,o,t,S,e);s||$.push(...yt(n)),$.push(...yt(r))}const z=[];if(x)d&&z.push(we(S,1,1));else{const[r,a,s]=vt(n,o,t,S,e);s||z.push(...yt(a)),z.push(we(r,1,d))}const N=rt(t,o,[p('sampleSourceLoader'),ve({from:"stack",target:S}),...z,...$,we(S),'fn'===w&&Se(((e,t,{a:r})=>a(e,r)),1),s&&Se(fe),p('sampleSourceUpward',k)],e,s);return ae(n,[N]),Object.assign(N.meta,l,{joint:1}),o},yt=e=>[we(e),xe(((e,t,{a:r})=>r),1)],vt=(e,t,r,n,o)=>{const s=_(e),i=s?A(e):$e(),c=$e(s);return s||a({parent:e,node:[ve({from:"stack",target:i}),ve({from:"value",store:1,target:c})],family:{owners:[e,t,r],links:t},meta:{op:o},regional:1}),p('sampleSource',c,i,n),[i,c,s]},bt=(e,t,r,n)=>{const a=e[t];a&&o({target:a,params:Array.isArray(a)?a.map((()=>r)):r,defer:1,stack:n})},kt=e=>!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op,xt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!R(e))return Promise.reject(new Error('first argument should be unit'));if(!(P(e)||E(e)||_(e)||B(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));B(e)&&(t=e);const n=g();n.parentFork=_e;const{fxCount:a}=t;H(a.scope.defers,n);const s=[],i=[];return B(e)||(H(s,e),H(i,P(e)?{params:r,req:{rs(e){n.value={status:'done',value:e}},rj(e){n.value={status:'fail',value:e}}}}:r)),H(s,a),H(i,null),o({target:s,params:i,scope:t}),n.req},exports.attach=e=>{let t;[e,t]=l(e,1);const n=c('attach',t);let{source:a,effect:s,mapParams:d,domain:p}=e;P(s)&&r(ce(p),'`domain` can only be used with a plain function',n);const u=y(e,t);q(u,'attached',1);const{runner:f}=M(u).scope;let m;const g=(e,t,r)=>{const{params:n,req:s,handler:i}=e,c=u.finally,l=ut(n,s,0,c,r),p=r.a,f=P(i);let m,h=1;if(d?[h,m]=pt(d,l,[n,p]):m=a&&f?p:n,h){if(!f)return e.args=[p,m],1;o({target:i,params:{params:m,req:{rs:ut(n,s,1,c,r),rj:l}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;f.scope.runnerFn=g,_(a)?(e=a,ae(e,[u])):(e=h(a),ae(u,[e])),m=[xe((e=>e),0,1),we(A(e))],delete f.seq[1].order}else m=[xe(g,1,1)];f.seq.splice(1,0,...m),u.use(s);const v=C(s);return v&&(Object.assign(F(u),i(u.shortName,v)),u.defaultConfig.parent=v),at(s,u,"effect"),u},exports.clearNode=et,exports.combine=h,exports.createApi=(...t)=>{let[[r,n],a]=l(t);const o={};return e(n,((e,t)=>{const n=o[t]=u(t,{parent:C(r),config:a});r.on(n,e),at(r,n)})),o},exports.createDomain=function r(n,s){const i=Qe({or:s,and:'string'==typeof n?{name:n}:n}),c=a({family:{type:"domain"},regional:1,parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent)}),l={history:{},graphite:c,hooks:{}};c.meta=ot("domain",l,{parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent),or:{...i,derived:1}}),e({Event:u,Effect:y,Store:m,Domain:r},((e,r)=>{const n=r.toLowerCase(),a=u({named:`on${r}`});l.hooks[n]=a;const s=new Set;l.history[`${n}s`]=s,a.create=e=>(o(a,e),e),H(M(a).seq,xe(((e,t,r)=>(r.scope=null,e)))),a.watch((e=>{ae(l,[e]),s.add(e),e.ownerSet||(e.ownerSet=s),C(e)||(e.parent=l)})),ae(l,[a]),l[`onCreate${r}`]=e=>(t(s,e),a.watch(e)),l[`create${r}`]=l[n]=(t,r)=>{const n=Qe({and:r,or:t});return null!=n&&n.domain?e(t,r):a(e(t,{parent:l,or:n}))}}));const d=C(l);return d&&e(l.hooks,((e,t)=>rt(e,d.hooks[t]))),null!=i&&i.domain&&i.domain.hooks.domain(l),l},exports.createEffect=y,exports.createEvent=u,exports.createNode=a,exports.createStore=m,exports.createWatch=({unit:e,fn:t,scope:r,batch:n})=>{const o=[Me.run({fn:e=>t(e)})];n&&o.unshift(Me.compute({priority:'sampler',batch:1})),_(e)&&o.unshift(Me.mov({store:e.stateRef,to:'stack'}));const s=Array.isArray(e)?e:[e];if(r){const e=[],t=r.additionalLinks;return s.forEach((r=>{const n=t[r.graphite.id]||[];t[r.graphite.id]=n;const s=a({node:w(o,r),meta:{watchOp:r.kind}});n.push(s),e.push((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),et(s)}))})),d((()=>{e.forEach((e=>e()))}))}{const e=a({node:o,parent:s,family:{owners:s}});return d((()=>{et(e)}))}},exports.fork=(e,n)=>{let o,s=e;T(e)&&(U(0,'fork(domain)','fork()'),o=e,s=n);const i=(e=>{const r=a({scope:{defers:[],inFlight:0,fxID:0},node:[xe(((e,t,r)=>{r.parent?'dec'===r.parent.node.meta.needFxCounter?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),be({priority:"sampler",batch:1}),xe(((e,r)=>{const{defers:n,fxID:a}=r;r.inFlight>0||0===n.length||Promise.resolve().then((()=>{r.fxID===a&&t(n.splice(0,n.length),(e=>{Be(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),n=a({node:[xe(((e,t,r)=>{const n=r.parent;if(n){const t=n.node;if(kt(n)){const n=I(r),a=t.meta.sid;n.sidIdMap[a]=t.scope.state.id,n.values.sidMap[a]=e;const o=t.meta.serialize;o&&n.sidSerializeSettings.set(a,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),o=a({node:[xe(((e,t,r)=>{const n=I(r);n&&r.parent&&kt(r.parent)&&(n.warnSerialize=1)}))]}),s={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return Ge(Te,s,e,0).current;const t=M(e);return Ge(Te,s,t.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[r,n,o]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:n,warnSerializeNode:o};return s})(o);if(s){if(s.values){const{sidMap:e,unitMap:n,hasSidDoubles:a}=x(s.values,(e=>r(_(e)&&V(e),'Values map can contain only writable stores as keys')));Object.assign(i.values.sidMap,e),t(n,((e,t)=>{if(i.values.idMap[t.stateRef.id]=e,'ignore'===O(t,'serialize')){const e=O(t,'sid');i.sidSerializeSettings.set(e,{ignore:1})}})),i.fromSerialize=!(Array.isArray(s.values)||s.values instanceof Map),i.hasSidDoubles=a}s.handlers&&(U(s.handlers instanceof Map||Array.isArray(s.handlers),'object with handlers','array'),i.handlers=x(s.handlers,(e=>r(P(e),"Handlers map can contain only effects as keys"))))}return i},exports.forward=e=>{const t='forward',[{from:r,to:n},o]=l(e,1),s=c(t,o);return U(0,t,'sample',s),pe(r,s,'"from"'),pe(n,s,'"to"'),ue(s,n,'to'),tt(a({parent:r,child:n,meta:{op:t,config:o},family:{},regional:1}))},exports.fromObservable=e=>{le(e);const t=S in e?e[S]():e;r(t.subscribe,'expect observable to have .subscribe');const n=u(),a=tt(n);return t.subscribe({next:n,error:a,complete:a}),n},exports.guard=(...e)=>{let[[t,r],n]=l(e);const a=c('guard',n);return U(0,'guard','sample',a),r||(r=t,t=r.source),b(r,a),gt('guard',r.clock,t,r.filter,r.target,null,r.name,n,!r.greedy,0,1)},exports.hydrate=(e,{values:n})=>{r(se(n),'values property should be an object');const{sidMap:a,unitMap:s}=x(n),i=Object.getOwnPropertyNames(a),c={};t(s,((e,t)=>{c[t.stateRef.id]=t}));const l=[],d=[];let p,u,f;B(e)?(p=e,f=1,r(p.cloneOf,'scope should be created from domain'),U(0,'hydrate(fork(domain), { values })','fork({ values })'),u=M(p.cloneOf)):T(e)?(U(0,'hydrate(domain, { values })','fork({ values })'),u=M(e)):r(0,'first argument of hydrate should be domain or scope'),k(u,((e,t)=>{if(t&&W(i,t)){H(l,e);const r=O(e,'serialize');r&&'ignore'!==r&&(a[t]=r.read(a[t])),H(d,a[t])}else e.scope.state.id in c&&(H(l,e),H(d,s.get(c[e.scope.state.id])))}),1),o({target:l,params:d,scope:p}),f&&Object.assign(p.values.sidMap,a)},exports.is=L,exports.launch=o,exports.merge=v,exports.restore=(t,r,n)=>{const a=c('restore',n);if(_(t))return U(0,'restore($store)',void 0,a),t;if(E(t)||P(t)){const e=C(t),a=m(r,{parent:e,name:t.shortName,and:n});return rt(P(t)?t.doneData:t,a),e&&e.hooks.store(a),a}const o=Array.isArray(t)?[]:{};return e(t,((e,t)=>o[t]=_(e)?e:m(e,{name:t}))),o},exports.sample=(...e)=>{let t,r,n,a,[[o,s,i],d]=l(e),p=1;const u=c('sample',d);return ce(s)&&se(o)&&b(o,u)&&(s=o.clock,i=o.fn,'batch'in o?p=o.batch:(U(!('greedy'in o),'greedy in sample','batch',u),p=!o.greedy),a=o.filter,t=o.target,r=o.name,n=o.sid,o=o.source),gt('sample',s,o,a,t,i,r,d,p,1,0,n)},exports.scopeBind=(e,{scope:t,safe:n}={})=>{r(t||_e||n,'scopeBind: scope not found');const a=t||_e;return P(e)?t=>{const r=g();return o({target:e,params:{params:t,req:r},scope:a}),r.req}:t=>(o({target:e,params:t,scope:a}),t)},exports.serialize=(t,n={})=>{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');const a=n.ignore?n.ignore.map((({sid:e})=>e)):[],o={};return e(t.values.sidMap,((e,r)=>{var n;if(W(a,r))return;const s=t.sidIdMap[r],i=null!==(n=t.sidSerializeSettings.get(r))&&void 0!==n?n:{ignore:0,write:xt};i.ignore||(o[r]=(0,i.write)(s&&s in t.reg?t.reg[s].current:e))})),'onlyChanges'in n&&(U(0,'onlyChanges'),n.onlyChanges||(r(t.cloneOf,'scope should be created from domain'),k(M(t.cloneOf),((e,r)=>{r in o||W(a,r)||O(e,'isCombine')||'ignore'===O(e,'serialize')||(o[r]=t.getState(e))})))),o},exports.setGraphInspector=e=>{Z=e},exports.setInspector=e=>{He=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(F(e),i(t,C(e)))},exports.split=(...t)=>{const n='split';let o,s,[[i,d],f]=l(t);const m=c(n,f),h=!d;h&&(o=i.cases,d=i.match,s=i.clock,i=i.source);const g=_(d),y=!R(d)&&ie(d),v=!g&&!y&&se(d);r(R(i),'source must be a unit',m),o||(o={}),h?e(o,((e,t)=>ue(m,e,`cases.${t}`))):(r(v,'match should be an object',m),e(d,((e,t)=>o[t]=u({derived:1,named:`cases.${t}`,and:f}))),o.__=u({derived:1,named:'cases.__',and:f}));const b=new Set([].concat(i,s||[],Object.values(o))),k=Object.keys(g||y?o:d);let x;if(g||y)g&&b.add(d),x=[g&&we(A(d),0,1),be({safe:g,filter:1,pure:!g,fn(e,t,r){const n=String(g?r.a:d(e));bt(t,W(k,n)?n:'__',e,r)}})];else if(v){const t=$e({});t.type='shape';const r=[];let n;e(d,((e,a)=>{if(R(e)){n=1,H(r,a),b.add(e);const o=rt(e,[],[we(t),xe(((e,t,{a:r})=>r[a]=e))]);if(_(e)){t.current[a]=e.getState();const r=A(e);Ae(t,{from:r,field:a,type:'field'}),p('splitMatchStore',r,o)}}})),n&&p('splitBase',t),x=[n&&we(t,0,1),Se(((e,t,n)=>{for(let a=0;a<k.length;a++){const o=k[a];if(W(r,o)?n.a[o]:d[o](e))return void bt(t,o,e,n)}bt(t,'__',e,n)}),1)]}else r(0,'expect match to be unit, function or object');const w=a({meta:{op:n},parent:s?[]:i,scope:o,node:x,family:{owners:Array.from(b)},regional:1});if(s&&gt(n,s,i,null,w,null,n,f,0,0,0),!h)return o},exports.step=Me,exports.version="23.0.0-rc.6",exports.withFactory=({sid:e,name:t,loc:r,method:o,fn:s})=>n(a({meta:{sidRoot:ne(e),sid:e,name:t,loc:r,method:o,type:'factory'}}),s),exports.withRegion=n;
//# 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||he(),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),h=[];r(e,(e=>e&&ie(h,e)));let g={id:fe(),seq:h,next:be(s),meta:d,scope:l,family:{type:u.type||C,links:p,owners:m}};return r(p,(e=>ie(E(e),g))),r(m,(e=>ie(P(e),g))),r(c,(e=>ie(e.next,g))),f&&pe&&ye(V(pe),[g]),g}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 D:case'b':e=t[r.from];break;case F: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&&lt(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 D: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=he();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=he(),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,[De()]),filter:e=>kt(n,"filter",e.fn?e:e.fn,[De(Ne,1)]),filterMap:e=>kt(n,'filterMap',e,[De(),Fe((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)),gt(t,n,[De()],'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,ht(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,h=u&&!n.skipVoid;oe(!(u&&n.skipVoid),'{skipVoid: true}','updateFilter');let g={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:g,params:e,defer:1,scope:Qe}),reset:(...e)=>(a(g.targetable,'.reset of derived store is not supported'),r(e,(e=>p(g,'.reset',e,(()=>g.defaultState)))),g),on:(e,t)=>(a(g.targetable,'.on of derived store is not supported'),p(g,'.on',e,t)),off(e){let t=B(g).get(e);return t&&(t(),B(g).delete(e)),g},map(e,t){let r,a;ve(e)&&(r=e,e=e.fn);let n=g.getState(),i=we(n);he()?a=null:(!i||i&&h)&&(a=e(n));let o=m(a,{name:`${g.shortName} \u2192 *`,derived:1,...t,and:r}),l=St(g,o,I,Ne,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(g,e);return f('storeWatch',s,e)||e(g.getState()),t}return a(ke(t),'second argument should be a function'),e.watch((e=>t(g.getState(),e)))}},y=vt(x,g,n),b=g.defaultConfig.updateFilter;g.graphite=i({scope:{state:s,fn:b},node:[Fe(((e,t,r)=>(r.scope&&!r.scope.reg[s.id]&&(r.b=1),e))),Re(s),Fe(((e,t,{a:r,b:a})=>{let n=we(e);return n&&!u&&console.error(wt),(n&&h||!n)&&(e!==r||a)}),1),b&&De(Ae,1),Ie({from:O,target:s})],child:l,meta:{...y,defaultState:e},regional:1}),H(g,'id',g.graphite.id),H(g,'rootStateRefId',d);let v=G(g,'serialize'),k=G(g,'derived'),w='ignore'===v,S=G(g,'sid');S&&(H(g,'storeChange',1),s.sid=S),S||w||k||H(g,'warnSerialize',1);let M=we(e);return a(k||!M||M&&h,wt),k&&M&&!u&&console.error(wt),ye(g,[l]),null!=n&&n.domain&&n.domain.hooks.store(g),k||(g.reinit=c({named:'reinit'}),g.reset(g.reinit)),s.meta=g.graphite.meta,me(g.graphite),g}function h(...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 g(){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'),h.scope.handler=e,n),n.use.getCurrent=()=>h.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}),h=i({scope:{handler:n.defaultConfig.handler||(()=>a(0,`no handler used in ${n.compositeName.fullName}`))},node:[Fe(((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),Fe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;let{params:a,req:n,handler:i,args:o=[a]}=e,s=zt(a,n,1,l,r),d=zt(a,n,0,l,r),[u,f]=xt(i,d,o);u&&(ve(f)&&ke(f.then)?f.then(s,d):s(f))}),0,1)],meta:{op:'fx',fx:'runner'}});s.scope.runner=h,ie(s.seq,Fe(((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=g(),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 gt(e,r,[],'merge'),r}function v(e,t){let n=0;return r($t,(r=>{r in e&&(a(null!=e[r],Nt(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',N='scope',j='sampler',C='crosslink',I='map',O='stack',q='barrier',F='value',R='sample',D='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(N);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)},he=()=>pe&&pe.template,ge=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=C),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),Ne=(e,{fn:t})=>t(e);const je=(e,t,r,a)=>{let n={id:ue(),type:e,data:t};return r&&(n.order={priority:r},a&&(n.order.barrierID=++Ce)),n};let Ce=0,Ie=({from:e=x,store:t,target:r,to:a=(r?x:O),batch:n,priority:i})=>je('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})=>je('compute',{fn:e,safe:a,filter:n,pure:i},r,t),qe=({fn:e})=>Oe({fn:e,priority:A}),Fe=(e,t,r)=>Oe({fn:e,safe:1,filter:t,priority:r&&A}),Re=(e,t,r)=>Ie({store:e,to:t?O:D,priority:r&&j,batch:1}),De=(e=Ne,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:qe},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 q:return 3;case j: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&&lt(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===C)&&ct(a,t,'on'!==G(a,'op')&&r);for(n=E(e);a=n.pop();)ft(a,e),r&&a.family.type===C&&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)},ht=e=>u((()=>mt(e))),gt=(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'),ht(i({scope:{fn:t},node:[qe({fn:Ne})],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=ge(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=he();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 gt(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:D,priority:'read'});r===I&&(o.data.softRead=1);let s=[o,De(a)];return f('storeOnMap',i,s,Q(e)&&T(e)),gt(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),h=Ee(1);p.type=e?'list':'shape',p.noInit=1,f('combineBase',p,h);let g=m(c,{name:s(n),derived:1,...l,and:i}),y=T(g);y.noInit=1,H(g,'isCombine',1);let b=Re(p);b.order={priority:'barrier'};let v=Ie({store:y,to:'b',priority:'read'});v.data.softRead=1;let k=[Fe(((e,t,r)=>(r.scope&&!r.scope.reg[p.id]&&(r.c=1),e))),b,Ie({store:h,to:'b'}),Fe(((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:D,target:p}),Ie({from:F,store:0,target:h}),Ie({from:F,store:1,target:h,priority:q,batch:1}),Re(p,1,1),o&&De(),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=gt(e,g,k,'combine',o);r.scope.key=t;let n=T(e);Te(p,{type:'field',field:t,from:n}),f('combineField',n,r)})),g.defaultShape=n,Te(y,{type:I,from:p,fn:o}),!he())if(o){let e=o(c);!we(e)||l&&"skipVoid"in l||console.error(wt),y.current=e,y.initial=e,g.defaultState=e}else g.defaultState=u;return g};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:[qe({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),$t=['source','clock','target'],Nt=(e,t)=>e+`: ${t} should be defined`;let jt=(e,t,r,n,i,o,s,l,d,u,p,g)=>{let y=!!i;a(!we(r)||!we(t),Nt(e,'either source or clock'));let v=0;we(r)?v=1:J(r)||(r=h(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:g,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=[...Ct(a),...Ct(r)]}let[M,x]=It(r,i,t,w,e),z=gt(t,i,[f('sampleSourceLoader'),Ie({from:O,target:w}),...Ct(x),Re(M,1,d),...S,Re(w),'fn'===k&&De(((e,t,{a:r})=>n(e,r)),1),o&&De(Ae),f('sampleSourceUpward',y)],e,o);return ye(r,[z]),Object.assign(z.meta,l,{joint:1}),i};const Ct=e=>[Re(e),Fe(((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:F,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})},qt=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=g();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=(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),h=1;if(i?[h,n]=xt(i,c,[s,p]):n=r&&m?p:s,h){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})}};if(r){let e;c.scope.runnerFn=p,Q(r)?(e=r,ye(e,[u])):(e=h(r),ye(u,[e])),f=[Fe((e=>e),0,1),Re(T(e))],delete c.seq[1].order}else f=[Fe(p,1,1)];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=h,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,Fe(((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)=>gt(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:[Fe(((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:j,batch:1}),Fe(((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:[Fe(((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:[Fe(((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:N,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'),ht(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=ht(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'),jt('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 gt(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,R)&&(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),jt(R,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=g();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:qt};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),h=!J(l)&&ke(l),g=!m&&!h&&ve(l);a(J(s),'source must be a unit'),r||(r={}),p?t(r,((e,t)=>ze(o,e,`cases.${t}`))):(a(g,'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||h?r:l);if(m||h)m&&b.add(l),y=[m&&Re(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(g){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=gt(t,[],[Re(e),Fe(((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&&Re(e,0,1),De(((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&&jt(o,n,s,null,k,null,o,u,0,0,0),!p)return r},e.step=_e,e.version="23.0.0-rc.5",e.withFactory=({sid:e,name:t,loc:r,method:a,fn:o})=>n(i({meta:{sidRoot:ge(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(const r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function n(e,t,r){if(!e)throw Error(`${r?r+': ':''}${t}`)}function a(e,t){const r=R(e).meta||{};ue={id:R(e).id,parent:ue,value:e,template:r.template||pe(),sidRoot:r.sidRoot||ue&&ue.sidRoot,meta:r};try{return t()}finally{fe('region'),ue=V(ue)}}function o({node:e=[],from:t,source:n,parent:a=t||n,to:o,target:s,child:i=o||s,scope:c={},meta:l={},family:d={type:'regular'},regional:u}={}){const f=ge(a),p=ge(d.links),m=ge(d.owners),h=[];r(e,(e=>e&&ne(h,e)));const g={id:ce(),seq:h,next:ge(i),meta:l,scope:c,family:{type:d.type||I,links:p,owners:m}};return r(p,(e=>ne(D(e),g))),r(m,(e=>ne(_(e),g))),r(f,(e=>ne(e.next,g))),u&&ue&&he(P(ue),[g]),g}function s(e,t,n){let a,o=Ye,s=null,i=Je;if(e.target&&(t=e.params,n=e.defer,a=e.meta,o='page'in e?e.page:o,e.stack&&(s=e.stack),i=B(e)||i,e=e.target),i&&Je&&i!==Je&&(Je=null),Array.isArray(e))for(let r=0;r<e.length;r++)We('pure',o,R(e[r]),s,t[r],i,a);else We('pure',o,R(e),s,t,i,a);if(n&&!Ke)return;const c={isRoot:Ke,currentPage:Ye,scope:Je,isWatch:Qe,isPure:Xe};let l,d,u,f,p,m;Ke=0;e:for(;f=Le();){const{idx:e,stack:t,type:n}=f;u=t.node,Ye=p=t.page,Je=B(t),p?m=p.reg:Je&&(m=Je.reg);const a=!!p,o=!!Je,s={fail:0,scope:u.scope};l=d=0;for(let r=e;r<u.seq.length&&!l;r++){const i=u.seq[r];if(i.order){const{priority:a,barrierID:o}=i.order,s=o?p?`${p.fullID}_${o}`:o:0;if(r!==e||n!==a){o?Ue.has(s)||(Ue.add(s),Ge(r,t,a,o)):Ge(r,t,a,0);continue e}o&&Ue.delete(s)}switch(i.type){case'mov':{const e=i.data;let r;switch(e.from){case'stack':r=P(t);break;case'a':case'b':r=t[e.from];break;case'value':r=e.store;break;case'store':if(m&&!m[e.store.id])if(a){const r=tt(p,e.store.id);t.page=p=r,r?m=r.reg:o?(ot(Je,e.store,0,1,e.softRead),m=Je.reg):m=void 0}else o&&ot(Je,e.store,0,1,e.softRead);r=_e(m&&m[e.store.id]||e.store)}switch(e.to){case'stack':t.value=r;break;case'a':case'b':t[e.to]=r;break;case'store':rt(p,Je,e.target,0).current=r}break}case'compute':const e=i.data;if(e.fn){Qe='watch'===u.meta.op,Xe=e.pure;const r=e.safe?(0,e.fn)(P(t),s.scope,t):st(s,e.fn,t);e.filter?d=!r:t.value=r,Qe=c.isWatch,Xe=c.isPure}}l=s.fail||d}if(nt&&nt(t,s),!l){const e=P(t),n=B(t);if(r(u.next,(r=>{We('child',p,r,t,e,n)})),n){u.meta.needFxCounter&&We('child',p,n.fxCount,t,e,n),u.meta.storeChange&&We('child',p,n.storeChange,t,e,n),u.meta.warnSerialize&&We('child',p,n.warnSerializeNode,t,e,n);const a=n.additionalLinks[u.id];a&&r(a,(r=>{We('child',p,r,t,e,n)}))}}}Ke=c.isRoot,Ye=c.currentPage,Je=B(c)}function i(e,r="combine"){let n=r+'(',a='',o=0;return t(e,(e=>{o<25&&(null!=e&&(n+=a,n+=H(e)?G(e).fullName:e.toString()),o+=1,a=', ')})),n+')'}function c(e,t){let r,n;const a=e;if(t){const a=G(t);0===e.length?(r=a.path,n=a.fullName):(r=a.path.concat([e]),n=0===a.fullName.length?e:a.fullName+'/'+e)}else r=0===e.length?[]:[e],n=e;return{shortName:a,fullName:n,path:r}}function l(e,t){if(!t)return e;if(!t.name&&!t.named&&!t.loc)return e;let r=`[${e}]`;const n=t.named||t.name;n&&(r+=` unit '${n}'`);const a=t.loc;return!n&&a&&(r+=` (${a.file}:${a.line}:${a.column})`),r}function d(e,t){const r=t?e:e[0];ke(r);let n=r.or;const a=r.and;if(a){const r=t?a:a[0];if(ye(r)&&'and'in r){const r=d(a,t);e=r[0],n={...n,...r[1]}}else e=a}return[e,n]}function u(e){const t=()=>e();return t.unsubscribe=()=>e(),t}function f(e,...t){const r=pe();if(r){const n=r.handlers[e];if(n)return n(r,...t)}}function p(e,t){const r=ct({or:t,and:'string'==typeof e?{name:e}:e}),a=l('event',r),i=(e,...t)=>(n(!L(i,'derived'),'call of derived event is not supported, use createEvent instead',a),n(!Xe,'unit call from pure function is not supported, use operators like sample instead',a),Ye?((e,t,r,n)=>{const a=Ye;let o=null;if(t)for(o=Ye;o&&o.template!==t;)o=V(o);et(o);const s=e.create(r,n);return et(a),s})(i,c,e,t):i.create(e,t)),c=pe(),d=Object.assign(i,{graphite:o({meta:yt(r.actualOp||z,i,r),regional:1}),create:e=>(s({target:i,params:e,scope:Je}),e),watch:e=>ht(i,e),map:e=>bt(i,O,e,[Fe()]),filter:e=>bt(i,'filter',e.fn?e:e.fn,[Fe(ze,1)]),filterMap:e=>bt(i,'filterMap',e,[Fe(),Oe((e=>!ve(e)),1)]),prepend(e){n(i.targetable,'.prepend of derived event is not supported, call source event instead',a);const t=p('* \u2192 '+i.shortName,{parent:V(i)});return f('eventPrepend',R(t)),mt(t,i,[Fe()],'prepend',e),gt(i,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(d),W(d,'id',d.graphite.id),fe(d.graphite),d}function m(e,t,a,o,s){return Se(a,`${s} ${t}`,'first argument'),n(be(o),'second argument should be a function',s),ae(!L(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`,s),r(Array.isArray(a)?a:[a],(t=>{e.off(t),T(e).set(t,pt(kt(t,e,'on',xe,o)))})),e}function h(e,t){const a=ct(t),i=De(e),c=l('store',a),d=p({named:'updates',derived:1});f('storeBase',i);const u=i.id,g='skipVoid'in a,y=g&&!a.skipVoid;ae(!(g&&a.skipVoid),'{skipVoid: true}','updateFilter',c);const b={subscribers:new Map,updates:d,defaultState:e,stateRef:i,getState(){let e,t=i;if(Ye){let t=Ye;for(;t&&!t.reg[u];)t=V(t);t&&(e=t)}return!e&&Je&&(ot(Je,i,1),e=Je),e&&(t=e.reg[u]),_e(t)},setState:e=>s({target:b,params:e,defer:1,scope:Je}),reset:(...e)=>(n(b.targetable,'.reset of derived store is not supported',c),r(e,(e=>m(b,'.reset',e,(()=>b.defaultState),c))),b),on:(e,t)=>(n(b.targetable,'.on of derived store is not supported',c),m(b,'.on',e,t,c)),off(e){const t=T(b).get(e);return t&&(t(),T(b).delete(e)),b},map(e,t){let r,n;ye(e)&&(r=e,e=e.fn);const a=b.getState(),o=ve(a);pe()?n=null:(!o||o&&y)&&(n=e(a));const s=h(n,{name:`${b.shortName} \u2192 *`,derived:1,...t,and:r}),c=kt(b,s,O,ze,e);return Ee(E(s),{type:O,fn:e,from:i}),E(s).noInit=1,f('storeMap',i,c),s},watch(e,t){if(ae(!t,'watch second argument','sample',c),!t||!H(e)){const t=ht(b,e);return f('storeWatch',i,e)||e(b.getState()),t}return n(be(t),'second argument should be a function',c),e.watch((e=>t(b.getState(),e)))}},v=yt(x,b,a),k=b.defaultConfig.updateFilter;b.graphite=o({scope:{state:i,fn:k},node:[Oe(((e,t,r)=>(r.scope&&!r.scope.reg[i.id]&&(r.b=1),e))),qe(i),Oe(((e,t,{a:r,b:n})=>{const a=ve(e);return a&&!g&&console.error(`${c}: ${vt}`),(a&&y||!a)&&(e!==r||n)}),1),k&&Fe($e,1),je({from:q,target:i})],child:d,meta:{...v,defaultState:e},regional:1}),W(b,'id',b.graphite.id),W(b,'rootStateRefId',u);const w=L(b,'serialize'),S=L(b,'derived'),M='ignore'===w,$=L(b,'sid');$&&(W(b,'storeChange',1),i.sid=$),$||M||S||W(b,'warnSerialize',1);const z=ve(e);return n(S||!z||z&&y,vt,c),S&&z&&!g&&console.error(`${c}: ${vt}`),he(b,[d]),null!=a&&a.domain&&a.domain.hooks.store(b),S||(b.reinit=p({named:'reinit'}),b.reset(b.reinit)),i.meta=b.graphite.meta,fe(b.graphite),b}function g(...e){let t,r,a;[e,a]=d(e);const o=l('combine',a),s=e[e.length-1],i=!J(s)&&ye(s),c=i&&s,u=i?e[e.length-2]:s;let f,p,m;if(be(u)?(r=e.slice(0,i?-2:-1),t=u):r=e,1===r.length){const e=r[0];J(e)||(f=e,p=1)}if(!p&&(f=r,t)){m=1;const e=t;t=t=>e(...t)}return n(ye(f),`${o}: shape should be an object`),wt(Array.isArray(f),!m,f,a,t,c)}function y(){const e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function b(e,t={}){const r=ct(be(e)?{handler:e}:e,t),a=l('effect',r),i=p(be(e)?{handler:e}:e,{...t,actualOp:A}),c=R(i);W(c,'op',i.kind=A),i.use=e=>(n(be(e),'.use argument should be a function',a),b.scope.handler=e,i),i.use.getCurrent=()=>b.scope.handler;const d=i.finally=p({named:'finally',derived:1}),u=i.done=d.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=i.fail=d.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),m=i.doneData=u.map({named:'doneData',fn:({result:e})=>e}),g=i.failData=f.map({named:'failData',fn:({error:e})=>e}),b=o({scope:{handler:i.defaultConfig.handler||(()=>n(0,`no handler used in ${i.compositeName.fullName}`))},node:[Oe(((e,t,r)=>{let n=t.handler;const a=B(r);if(a){const e=a.handlers.unitMap.get(i)||a.handlers.sidMap[i.sid];e&&(n=e)}return e.handler=n,e}),0,1),Oe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;const{params:n,req:a,handler:o,args:s=[n]}=e,i=Mt(n,a,1,d,r),c=Mt(n,a,0,d,r),[l,u]=St(o,c,s);l&&(ye(u)&&be(u.then)?u.then(i,c):i(u))}),0,1)],meta:{op:'fx',fx:'runner'}});c.scope.runner=b,ne(c.seq,Oe(((e,{runner:t},r)=>{const n=V(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:le()}),s({target:t,params:n,defer:1,scope:B(r),meta:r.meta}),n.params}))),i.create=e=>{const t=y(),r={params:e,req:t};if(Je&&!Qe){const e=Je;t.req.finally((()=>{Ze(e)})).catch((()=>{}))}return s({target:i,params:r,scope:Je}),t.req};const v=i.inFlight=h(0,{serialize:'ignore',named:(L(i,'name')||i.graphite.id)+'.inFlight'}).on(i,(e=>e+1)).on(d,(e=>e-1)).map({fn:e=>e,named:'inFlight'});W(d,'needFxCounter','dec'),W(i,'needFxCounter',1);const k=i.pending=v.map({fn:e=>e>0,named:'pending'});return he(i,[d,u,f,m,g,k,v]),null!=r&&r.domain&&r.domain.hooks.effect(i),i}function v(e,t){const r=l('merge',t);Se(e,r,'first argument');const n=p({name:i(e,'merge'),derived:1,and:t});return mt(e,n,[],'merge'),n}function k(e,t){let a=0;return r(xt,(r=>{r in e&&(n(null!=e[r],zt(t,r)),a=1)})),a}function w(e,t,n){const a=[];(function e(o){te(a,o)||(ne(a,o),L(o,'op')===x&&(n||L(o,'sid'))&&t(o,L(o,'sid')),r(o.next,e),r(D(o),e),r(_(o),e))})(e)}function S(e,t){const a=Array.isArray(e)?new Map(e):e,o=new Map;let s=0;if(a instanceof Map){const e={};return r(a,((r,a)=>{n(H(a),'Map key should be a unit'),t&&t(a,r),a.sid&&(a.sid in e&&(s=1),e[a.sid]=r),o.set(a,r)})),{sidMap:e,unitMap:o,hasSidDoubles:s}}return{sidMap:a,unitMap:o}}function M(e,t){return J(t)?[Re.mov({store:t.stateRef,to:'stack'}),...e]:e}const $='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',x='store',z='event',A='effect',N='domain',j='scope',C='sampler',I='crosslink',O='map',q='stack',F='value',R=e=>e.graphite||e,D=e=>e.family.owners,_=e=>e.family.links,E=e=>e.stateRef,P=e=>e.value,T=e=>e.subscribers,V=e=>e.parent,B=e=>e.scope,L=(e,t)=>R(e).meta[t],W=(e,t,r)=>R(e).meta[t]=r,G=e=>e.compositeName,H=e=>(be(e)||ye(e))&&'kind'in e,U=e=>t=>H(t)&&t.kind===e,J=U(x),K=U(z),Q=U(A),X=e=>H(e)&&!!e.targetable,Y=U(N),Z=U(j);var ee={__proto__:null,unit:H,store:J,event:K,effect:Q,targetable:X,domain:Y,scope:Z,attached:e=>Q(e)&&1==L(e,'attached')};const te=(e,t)=>e.includes(t),re=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},ne=(e,t)=>e.push(t),ae=(e,t,r,n)=>!e&&console.error(`${n?n+': ':''}${t} is deprecated${r?`, use ${r} instead`:''}`),oe=()=>{let e=0;return()=>""+ ++e},se=oe(),ie=oe(),ce=oe(),le=oe();let de,ue=null;const fe=e=>{de&&de(e,ue)},pe=()=>ue&&ue.template,me=e=>(e&&ue&&ue.sidRoot&&(e=`${ue.sidRoot}|${e}`),e),he=(e,t)=>{const n=R(e);r(t,(e=>{const t=R(e);n.family.type!==N&&(t.family.type=I),ne(D(t),n),ne(_(n),t)}))},ge=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(R),ye=e=>'object'==typeof e&&null!==e,be=e=>'function'==typeof e,ve=e=>void 0===e,ke=e=>n(ye(e)||be(e),'expect first argument be an object'),we=(e,t,r,a)=>n(!(!ye(e)&&!be(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${a}`),Se=(e,t,n)=>{Array.isArray(e)?r(e,((e,r)=>we(e,t,`${r} item of ${n}`,''))):we(e,t,n,' or array of units')},Me=(e,t,a="target")=>r(ge(t),(t=>n(!L(t,'derived'),`${e}: derived unit in "${a}" is not supported, use createStore/createEvent instead"`))),$e=(e,{fn:t},{a:r})=>t(e,r),xe=(e,{fn:t},{a:r})=>t(r,e),ze=(e,{fn:t})=>t(e),Ae=(e,t,r,n)=>{const a={id:ie(),type:e,data:t};return r&&(a.order={priority:r},n&&(a.order.barrierID=++Ne)),a};let Ne=0;const je=({from:e=x,store:t,target:r,to:n=(r?x:q),batch:a,priority:o})=>Ae('mov',{from:e,store:t,to:n,target:r},o,a),Ce=({fn:e,batch:t,priority:r,safe:n=0,filter:a=0,pure:o=0})=>Ae('compute',{fn:e,safe:n,filter:a,pure:o},r,t),Ie=({fn:e})=>Ce({fn:e,priority:A}),Oe=(e,t,r)=>Ce({fn:e,safe:1,filter:t,priority:r&&A}),qe=(e,t,r)=>je({store:e,to:t?q:"a",priority:r&&C,batch:1}),Fe=(e=ze,t)=>Ce({fn:e,pure:1,filter:t}),Re={mov:je,compute:Ce,filter:({fn:e,pure:t})=>Ce({fn:e,filter:1,pure:t}),run:Ie},De=e=>({id:ie(),current:e,initial:e}),_e=({current:e})=>e,Ee=(e,t)=>{e.before||(e.before=[]),ne(e.before,t)};let Pe=null;const Te=(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||He(e.v.type)>He(t.v.type))&&(r=e,e=t,t=r),r=Te(e.r,t),e.r=e.l,e.l=r,e},Ve=[];let Be=0;for(;Be<6;)ne(Ve,{first:null,last:null,size:0}),Be+=1;const Le=()=>{for(let e=0;e<6;e++){const t=Ve[e];if(t.size>0){if(3===e||4===e){t.size-=1;const e=Pe.v;return Pe=Te(Pe.l,Pe.r),e}1===t.size&&(t.last=null);const r=t.first;return t.first=r.r,t.size-=1,r.v}}},We=(e,t,r,n,a,o,s)=>Ge(0,{a:null,b:null,node:r,parent:n,value:a,page:t,scope:o,meta:s},e,0),Ge=(e,t,r,n)=>{const a=He(r),o=Ve[a],s={v:{idx:e,stack:t,type:r,id:n},l:null,r:null};3===a||4===a?Pe=Te(Pe,s):(0===o.size?o.first=s:o.last.r=s,o.last=s),o.size+=1},He=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}},Ue=new Set;let Je,Ke=1,Qe=0,Xe=0,Ye=null;const Ze=e=>{Je=e},et=e=>{Ye=e},tt=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=e.parent;if(e)return e}return null},rt=(e,t,r,n)=>{const a=tt(e,r.id);return a?a.reg[r.id]:t?(ot(t,r,n),t.reg[r.id]):r};let nt;const at=e=>e,ot=(e,t,n,a,o)=>{const s=e.reg;if(s[t.id])return;const i=t.sid,c={id:t.id,current:t.initial,meta:t.meta};if(c.id in e.values.idMap)c.current=e.values.idMap[c.id];else if(i&&i in e.values.sidMap&&!(i in e.sidIdMap)){var l;const r=null==t||null===(l=t.meta)||void 0===l?void 0:l.serialize;c.current=(e.fromSerialize&&'ignore'!==r&&(null==r?void 0:r.read)||at)(e.values.sidMap[i])}else if(t.before&&!o){let o=0;const i=n||!t.noInit||a;r(t.before,(t=>{switch(t.type){case'map':{const r=t.from;if((r||t.fn)&&(r&&ot(e,r,n,a),i)){const e=r&&s[r.id].current;c.current=t.fn?t.fn(e):e}break}case'field':ot(e,t.from,n,a),o||(o=1,c.current=Array.isArray(c.current)?[...c.current]:{...c.current}),i&&(c.current[t.field]=s[s[t.from.id].id].current)}}))}i&&(e.sidIdMap[i]=t.id),s[t.id]=c},st=(e,t,r)=>{try{return t(P(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}},ct=(e,r={})=>(ye(e)&&(ct(e.or,r),t(e,((e,t)=>{ve(e)||'or'===t||'and'===t||(r[t]=e)})),ct(e.and,r)),r),lt=(e,t)=>{re(e.next,t),re(D(e),t),re(_(e),t)},dt=(e,t,r)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let a=_(e);for(;n=a.pop();)lt(n,e),(t||r&&'sample'!==e.meta.op||n.family.type===I)&&dt(n,t,'on'!==n.meta.op&&r);for(a=D(e);n=a.pop();)lt(n,e),r&&n.family.type===I&&dt(n,t,'on'!==n.meta.op&&r)},ut=e=>e.clear(),ft=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),J(e))ut(T(e));else if(Y(e)){r=1;const t=e.history;ut(t.events),ut(t.effects),ut(t.stores),ut(t.domains)}dt(R(e),!!t,r)},pt=e=>u((()=>ft(e))),mt=(e,t,r,n,a)=>o({node:r,parent:e,child:t,scope:{fn:a},meta:{op:n},family:{owners:[e,t],links:t},regional:1}),ht=(e,t)=>(n(be(t),'.watch argument should be a function'),pt(o({scope:{fn:t},node:[Ie({fn:ze})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),gt=(e,t,r=z)=>{V(e)&&V(e).hooks[r](t)},yt=(e,t,r)=>{const n=ct(r),a=e===N,o=se(),{sid:s=null,named:i=null,domain:l=null,parent:d=l}=n,u=i||n.name||(a?'':o),f=c(u,d),p={op:t.kind=e,name:t.shortName=u,sid:t.sid=me(s),named:i,unitId:t.id=o,serialize:n.serialize,derived:n.derived,config:n};if(t.targetable=!n.derived,t.parent=d,t.compositeName=f,t.defaultConfig=n,t.getType=()=>(ae(0,'getType','compositeName.fullName'),f.fullName),!a){t.subscribe=e=>(ke(e),t.watch(be(e)?e:t=>e.next&&e.next(t))),t[$]=()=>t;const e=pe();e&&(p.nativeTemplate=e)}return p},bt=(e,t,r,n)=>{let a;ye(r)&&(a=r,r=r.fn);const o=p({name:`${e.shortName} \u2192 *`,derived:1,and:a});return mt(e,o,n,t,r),o},vt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',kt=(e,t,r,n,a)=>{const o=E(t),s=je({store:o,to:"a",priority:'read'});r===O&&(s.data.softRead=1);const i=[s,Fe(n)];return f('storeOnMap',o,i,J(e)&&E(e)),mt(e,t,i,r,a)},wt=(e,r,a,o,s,c)=>{const d=l('combine',o),u=e?e=>[...e]:e=>({...e}),p=e?[]:{},m=u(p),g=De(m),y=De(1);g.type=e?'list':'shape',g.noInit=1,f('combineBase',g,y);const b=h(m,{name:i(a),derived:1,...c,and:o}),v=E(b);v.noInit=1,W(b,'isCombine',1);const k=qe(g);k.order={priority:'barrier'};const w=je({store:v,to:'b',priority:'read'});w.data.softRead=1;const S=[Oe(((e,t,r)=>(r.scope&&!r.scope.reg[g.id]&&(r.c=1),e))),k,je({store:y,to:'b'}),Oe(((e,{key:t},n)=>{if(n.c||e!==n.a[t])return r&&n.b&&(n.a=u(n.a)),n.a[t]=e,1}),1),je({from:"a",target:g}),je({from:F,store:0,target:y}),je({from:F,store:1,target:y,priority:'barrier',batch:1}),qe(g,1,1),s&&Fe(),w];if(t(a,((e,t)=>{if(!J(e))return n(!H(e)&&!ve(e),`combine expects a store in a field ${t}`,d),void(m[t]=p[t]=e);p[t]=e.defaultState,m[t]=e.getState();const r=mt(e,b,S,'combine',s);r.scope.key=t;const a=E(e);Ee(g,{type:'field',field:t,from:a}),f('combineField',a,r)})),b.defaultShape=a,Ee(v,{type:O,from:g,fn:s}),!pe())if(s){const e=s(m);!ve(e)||c&&'skipVoid'in c||console.error(`${d}: ${vt}`),v.current=e,v.initial=e,b.defaultState=e}else b.defaultState=p;return b},St=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},Mt=(e,t,r,n,a)=>o=>{s({target:[n,$t],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:a.page,scope:a.scope,meta:a.meta})},$t=o({node:[Ie({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),xt=['source','clock','target'],zt=(e,t)=>e+`: ${t} should be defined`,At=(e,t,r,a,o,s,i,c,d,u,m,y)=>{const b=l(e,c),k=!!o;n(!ve(r)||!ve(t),zt(b,'either source or clock'));let w=0;ve(r)?w=1:H(r)||(r=g(r)),ve(t)?t=r:(Se(t,b,'clock'),Array.isArray(t)&&(t=v(t))),w&&(r=t),c||i||(i=r.shortName);let S='none';(m||a)&&(H(a)?S='unit':(n(be(a),'`filter` should be function or unit'),S='fn')),o?(Se(o,b,'target'),Me(b,o)):'none'===S&&u&&J(r)&&J(t)?o=h(s?s(_e(E(r)),_e(E(t))):_e(E(r)),{name:i,sid:y,or:c}):(o=p({name:i,derived:1,or:c}),f('sampleTarget',R(o)));const M=De();let $=[];if('unit'===S){const[r,n,s]=jt(a,o,t,M,e);s||$.push(...Nt(n)),$.push(...Nt(r))}const x=[];if(w)d&&x.push(qe(M,1,1));else{const[n,a,s]=jt(r,o,t,M,e);s||x.push(...Nt(a)),x.push(qe(n,1,d))}const z=mt(t,o,[f('sampleSourceLoader'),je({from:q,target:M}),...x,...$,qe(M),'fn'===S&&Fe(((e,t,{a:r})=>a(e,r)),1),s&&Fe($e),f('sampleSourceUpward',k)],e,s);return he(r,[z]),Object.assign(z.meta,c,{joint:1}),o},Nt=e=>[qe(e),Oe(((e,t,{a:r})=>r),1)],jt=(e,t,r,n,a)=>{const s=J(e),i=s?E(e):De(),c=De(s);return s||o({parent:e,node:[je({from:q,target:i}),je({from:F,store:1,target:c})],family:{owners:[e,t,r],links:t},meta:{op:a},regional:1}),f('sampleSource',c,i,n),[i,c,s]},Ct=(e,t,r,n)=>{const a=e[t];a&&s({target:a,params:Array.isArray(a)?a.map((()=>r)):r,defer:1,stack:n})},It=e=>!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op,Ot=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!H(e))return Promise.reject(new Error('first argument should be unit'));if(!(Q(e)||K(e)||J(e)||Z(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));Z(e)&&(t=e);const n=y();n.parentFork=Je;const{fxCount:a}=t;ne(a.scope.defers,n);const o=[],i=[];return Z(e)||(ne(o,e),ne(i,Q(e)?{params:r,req:{rs(e){n.value={status:'done',value:e}},rj(e){n.value={status:'fail',value:e}}}}:r)),ne(o,a),ne(i,null),s({target:o,params:i,scope:t}),n.req},e.attach=e=>{let t;[e,t]=d(e,1);const r=l('attach',t);let{source:a,effect:o,mapParams:i,domain:u}=e;Q(o)&&n(ve(u),'`domain` can only be used with a plain function',r);const f=b(e,t);W(f,'attached',1);const{runner:p}=R(f).scope;let m;const h=(e,t,r)=>{const{params:n,req:o,handler:c}=e,l=f.finally,d=Mt(n,o,0,l,r),u=r.a,p=Q(c);let m,h=1;if(i?[h,m]=St(i,d,[n,u]):m=a&&p?u:n,h){if(!p)return e.args=[u,m],1;s({target:c,params:{params:m,req:{rs:Mt(n,o,1,l,r),rj:d}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;p.scope.runnerFn=h,J(a)?(e=a,he(e,[f])):(e=g(a),he(f,[e])),m=[Oe((e=>e),0,1),qe(E(e))],delete p.seq[1].order}else m=[Oe(h,1,1)];p.seq.splice(1,0,...m),f.use(o);const y=V(o);return y&&(Object.assign(G(f),c(f.shortName,y)),f.defaultConfig.parent=y),gt(o,f,A),f},e.clearNode=ft,e.combine=g,e.createApi=(...e)=>{let[[r,n],a]=d(e);const o={};return t(n,((e,t)=>{const n=o[t]=p(t,{parent:V(r),config:a});r.on(n,e),gt(r,n)})),o},e.createDomain=function e(n,a){const i=ct({or:a,and:'string'==typeof n?{name:n}:n}),c=o({family:{type:N},regional:1,parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent)}),l={history:{},graphite:c,hooks:{}};c.meta=yt(N,l,{parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent),or:{...i,derived:1}}),t({Event:p,Effect:b,Store:h,Domain:e},((e,t)=>{const n=t.toLowerCase(),a=(e=>p({named:e}))(`on${t}`);l.hooks[n]=a;const o=new Set;l.history[`${n}s`]=o,a.create=e=>(s(a,e),e),ne(R(a).seq,Oe(((e,t,r)=>(r.scope=null,e)))),a.watch((e=>{he(l,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),V(e)||(e.parent=l)})),he(l,[a]),l[`onCreate${t}`]=e=>(r(o,e),a.watch(e)),l[`create${t}`]=l[n]=(t,r)=>{const n=ct({and:r,or:t});return null!=n&&n.domain?e(t,r):a(e(t,{parent:l,or:n}))}}));const d=V(l);return d&&t(l.hooks,((e,t)=>mt(e,d.hooks[t]))),null!=i&&i.domain&&i.domain.hooks.domain(l),l},e.createEffect=b,e.createEvent=p,e.createNode=o,e.createStore=h,e.createWatch=({unit:e,fn:t,scope:r,batch:n})=>{const a=[Re.run({fn:e=>t(e)})];n&&a.unshift(Re.compute({priority:'sampler',batch:1})),J(e)&&a.unshift(Re.mov({store:e.stateRef,to:'stack'}));const s=Array.isArray(e)?e:[e];if(r){const e=[],t=r.additionalLinks;return s.forEach((r=>{const n=t[r.graphite.id]||[];t[r.graphite.id]=n;const s=o({node:M(a,r),meta:{watchOp:r.kind}});n.push(s),e.push((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),ft(s)}))})),u((()=>{e.forEach((e=>e()))}))}{const e=o({node:a,parent:s,family:{owners:s}});return u((()=>{ft(e)}))}},e.fork=(e,t)=>{let a,s=e;Y(e)&&(ae(0,'fork(domain)','fork()'),a=e,s=t);const i=(e=>{const t=o({scope:{defers:[],inFlight:0,fxID:0},node:[Oe(((e,t,r)=>{r.parent?'dec'===r.parent.node.meta.needFxCounter?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Ce({priority:C,batch:1}),Oe(((e,t)=>{const{defers:n,fxID:a}=t;t.inFlight>0||0===n.length||Promise.resolve().then((()=>{t.fxID===a&&r(n.splice(0,n.length),(e=>{Ze(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),n=o({node:[Oe(((e,t,r)=>{const n=r.parent;if(n){const t=n.node;if(It(n)){const n=B(r),a=t.meta.sid;n.sidIdMap[a]=t.scope.state.id,n.values.sidMap[a]=e;const o=t.meta.serialize;o&&n.sidSerializeSettings.set(a,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),a=o({node:[Oe(((e,t,r)=>{const n=B(r);n&&r.parent&&It(r.parent)&&(n.warnSerialize=1)}))]}),s={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return rt(Ye,s,e,0).current;const t=R(e);return rt(Ye,s,t.scope.state,1).current},kind:j,graphite:o({family:{type:N,links:[t,n,a]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:n,warnSerializeNode:a};return s})(a);if(s){if(s.values){const{sidMap:e,unitMap:t,hasSidDoubles:a}=S(s.values,(e=>n(J(e)&&X(e),'Values map can contain only writable stores as keys')));Object.assign(i.values.sidMap,e),r(t,((e,t)=>{if(i.values.idMap[t.stateRef.id]=e,'ignore'===L(t,'serialize')){const e=L(t,'sid');i.sidSerializeSettings.set(e,{ignore:1})}})),i.fromSerialize=!(Array.isArray(s.values)||s.values instanceof Map),i.hasSidDoubles=a}s.handlers&&(ae(s.handlers instanceof Map||Array.isArray(s.handlers),'object with handlers','array'),i.handlers=S(s.handlers,(e=>n(Q(e),"Handlers map can contain only effects as keys"))))}return i},e.forward=e=>{const t='forward',[{from:r,to:n},a]=d(e,1),s=l(t,a);return ae(0,t,'sample',s),Se(r,s,'"from"'),Se(n,s,'"to"'),Me(s,n,'to'),pt(o({parent:r,child:n,meta:{op:t,config:a},family:{},regional:1}))},e.fromObservable=e=>{ke(e);const t=$ in e?e[$]():e;n(t.subscribe,'expect observable to have .subscribe');const r=p(),a=pt(r);return t.subscribe({next:r,error:a,complete:a}),r},e.guard=(...e)=>{let[[t,r],n]=d(e);const a=l('guard',n);return ae(0,'guard','sample',a),r||(r=t,t=r.source),k(r,a),At('guard',r.clock,t,r.filter,r.target,null,r.name,n,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{n(ye(t),'values property should be an object');const{sidMap:a,unitMap:o}=S(t),i=Object.getOwnPropertyNames(a),c={};r(o,((e,t)=>{c[t.stateRef.id]=t}));const l=[],d=[];let u,f,p;Z(e)?(u=e,p=1,n(u.cloneOf,'scope should be created from domain'),ae(0,'hydrate(fork(domain), { values })','fork({ values })'),f=R(u.cloneOf)):Y(e)?(ae(0,'hydrate(domain, { values })','fork({ values })'),f=R(e)):n(0,'first argument of hydrate should be domain or scope'),w(f,((e,t)=>{if(t&&te(i,t)){ne(l,e);const r=L(e,'serialize');r&&'ignore'!==r&&(a[t]=r.read(a[t])),ne(d,a[t])}else e.scope.state.id in c&&(ne(l,e),ne(d,o.get(c[e.scope.state.id])))}),1),s({target:l,params:d,scope:u}),p&&Object.assign(u.values.sidMap,a)},e.is=ee,e.launch=s,e.merge=v,e.restore=(e,r,n)=>{const a=l('restore',n);if(J(e))return ae(0,'restore($store)',void 0,a),e;if(K(e)||Q(e)){const t=V(e),a=h(r,{parent:t,name:e.shortName,and:n});return mt(Q(e)?e.doneData:e,a),t&&t.hooks.store(a),a}const o=Array.isArray(e)?[]:{};return t(e,((e,t)=>o[t]=J(e)?e:h(e,{name:t}))),o},e.sample=(...e)=>{let t,r,n,a,[[o,s,i],c]=d(e),u=1;const f=l('sample',c);return ve(s)&&ye(o)&&k(o,f)&&(s=o.clock,i=o.fn,'batch'in o?u=o.batch:(ae(!('greedy'in o),'greedy in sample','batch',f),u=!o.greedy),a=o.filter,t=o.target,r=o.name,n=o.sid,o=o.source),At('sample',s,o,a,t,i,r,c,u,1,0,n)},e.scopeBind=(e,{scope:t,safe:r}={})=>{n(t||Je||r,'scopeBind: scope not found');const a=t||Je;return Q(e)?t=>{const r=y();return s({target:e,params:{params:t,req:r},scope:a}),r.req}:t=>(s({target:e,params:t,scope:a}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!e.hasSidDoubles,'duplicate sid found in this scope');const a=r.ignore?r.ignore.map((({sid:e})=>e)):[],o={};return t(e.values.sidMap,((t,r)=>{var n;if(te(a,r))return;const s=e.sidIdMap[r],i=null!==(n=e.sidSerializeSettings.get(r))&&void 0!==n?n:{ignore:0,write:Ot};i.ignore||(o[r]=(0,i.write)(s&&s in e.reg?e.reg[s].current:t))})),'onlyChanges'in r&&(ae(0,'onlyChanges'),r.onlyChanges||(n(e.cloneOf,'scope should be created from domain'),w(R(e.cloneOf),((t,r)=>{r in o||te(a,r)||L(t,'isCombine')||'ignore'===L(t,'serialize')||(o[r]=e.getState(t))})))),o},e.setGraphInspector=e=>{de=e},e.setInspector=e=>{nt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(G(e),c(t,V(e)))},e.split=(...e)=>{const r='split';let a,s,[[i,c],u]=d(e);const m=l(r,u),h=!c;h&&(a=i.cases,c=i.match,s=i.clock,i=i.source);const g=J(c),y=!H(c)&&be(c),b=!g&&!y&&ye(c);n(H(i),'source must be a unit',m),a||(a={}),h?t(a,((e,t)=>Me(m,e,`cases.${t}`))):(n(b,'match should be an object',m),t(c,((e,t)=>a[t]=p({derived:1,named:`cases.${t}`,and:u}))),a.__=p({derived:1,named:'cases.__',and:u}));const v=new Set([].concat(i,s||[],Object.values(a))),k=Object.keys(g||y?a:c);let w;if(g||y)g&&v.add(c),w=[g&&qe(E(c),0,1),Ce({safe:g,filter:1,pure:!g,fn(e,t,r){const n=String(g?r.a:c(e));Ct(t,te(k,n)?n:'__',e,r)}})];else if(b){const e=De({});e.type='shape';const r=[];let n;t(c,((t,a)=>{if(H(t)){n=1,ne(r,a),v.add(t);const o=mt(t,[],[qe(e),Oe(((e,t,{a:r})=>r[a]=e))]);if(J(t)){e.current[a]=t.getState();const r=E(t);Ee(e,{from:r,field:a,type:'field'}),f('splitMatchStore',r,o)}}})),n&&f('splitBase',e),w=[n&&qe(e,0,1),Fe(((e,t,n)=>{for(let a=0;a<k.length;a++){const o=k[a];if(te(r,o)?n.a[o]:c[o](e))return void Ct(t,o,e,n)}Ct(t,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');const S=o({meta:{op:r},parent:s?[]:i,scope:a,node:w,family:{owners:Array.from(v)},regional:1});if(s&&At(r,s,i,null,S,null,r,u,0,0,0),!h)return a},e.step=Re,e.version="23.0.0-rc.6",e.withFactory=({sid:e,name:t,loc:r,method:n,fn:s})=>a(o({meta:{sidRoot:me(e),sid:e,name:t,loc:r,method:n,type:'factory'}}),s),e.withRegion=a,Object.defineProperty(e,'__esModule',{value:1})}));
//# sourceMappingURL=effector.umd.js.map

@@ -1,2 +0,2 @@

function e(e){let t=()=>e();return t.unsubscribe=t,t}function t(e){let{node:t}=e;return r(t)}function r(e){let{meta:t,id:r}=e,n=(e=>e.config?e.config.loc:e.loc)(t),{sid:o,name:a,op:i}=t;return{meta:t,id:r,sid:o,name:a,kind:i,loc:n,derived:t.derived}}function n(e){let r=[],n=e.parent;for(;n;)r.push({type:'update',value:n.value,stack:n.meta||{},...t(n)}),n=n.parent;return r}function o(e){if(!e)return;let{parent:t,meta:r,id:n}=e,a=o(t)||void 0;if('factory'===r.type){let{sid:e,name:t,loc:o,method:i}=r;return{type:'factory',id:n,region:a,meta:r,sid:e,name:t,loc:o,method:i}}return{type:'region',id:n,region:a,meta:r}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');const a=new Set;effector.setInspector(((e,r)=>{let{scope:o}=e;a.forEach((a=>{a.scope!==o&&(a.scope||o)||a.fn({type:r.fail?'error':'update',value:e.value,error:r.fail?r.failReason:void 0,stack:e.meta||{},trace:a.trace?n(e):[],...t(e)})}))}));const i=new Set;effector.setGraphInspector(((e,t)=>{let n;n='region'===e?o(t):((e,t)=>{let n=r(e);return{type:'unit',region:o(t),...n}})(e,t),n&&i.forEach((e=>{e.fn(n)}))})),exports.inspect=t=>(a.add(t),e((()=>{a.delete(t)}))),exports.inspectGraph=t=>(i.add(t),e((()=>{i.delete(t)})));
function e(e){const t=()=>e();return t.unsubscribe=t,t}function t(e){return n(e.node)}function n(e){const{meta:t,id:n}=e,i=(e=>e.config?e.config.loc:e.loc)(t),{sid:r,name:d,op:o}=t;return{meta:t,id:n,sid:r,name:d,kind:o,loc:i,derived:t.derived}}function i(e){if(!e)return;const{parent:t,meta:n,id:r}=e,d=i(t)||void 0;if('factory'===n.type){const{sid:e,name:t,loc:i,method:o}=n;return{type:'factory',id:r,region:d,meta:n,sid:e,name:t,loc:i,method:o}}return{type:'region',id:r,region:d,meta:n}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');const r=new Set;effector.setInspector(((e,n)=>{const{scope:i}=e,d=t(e);let o;r.forEach((r=>{r.scope!==i&&(r.scope||i)||(r.trace&&!o&&(o=(e=>{const n=[];let i=e.parent;for(;i;){const e=t(i);n.push({type:'update',value:i.value,stack:i.meta||{},meta:e.meta,id:e.id,sid:e.sid,name:e.name,kind:e.kind,loc:e.loc,derived:e.derived}),i=i.parent}return n})(e)),r.fn({type:n.fail?'error':'update',value:e.value,error:n.fail?n.failReason:void 0,stack:e.meta||{},trace:r.trace?o:[],meta:d.meta,id:d.id,sid:d.sid,name:d.name,kind:d.kind,loc:d.loc,derived:d.derived}))}))}));const d=new Set;effector.setGraphInspector(((e,t)=>{let r;r='region'===e?i(t):((e,t)=>{const r=n(e);return{type:'unit',region:i(t),meta:r.meta,id:r.id,sid:r.sid,name:r.name,kind:r.kind,loc:r.loc,derived:r.derived}})(e,t),r&&d.forEach((e=>{e.fn(r)}))})),exports.inspect=t=>(r.add(t),e((()=>{r.delete(t)}))),exports.inspectGraph=t=>(d.add(t),e((()=>{d.delete(t)})));
//# sourceMappingURL=inspect.js.map
{
"name": "effector",
"version": "23.0.0-rc.5",
"version": "23.0.0-rc.6",
"description": "Business logic with ease",

@@ -5,0 +5,0 @@ "main": "effector.cjs.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc