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 22.4.1 to 22.5.0

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

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

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

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

@@ -57,14 +57,5 @@ <p align="center">

with **pnpm**
```sh
pnpm add effector
```
> You can use any package manager
with **yarn**
```sh
yarn add effector
```
with **npm**
```sh
```bash
npm add effector

@@ -77,31 +68,16 @@ ```

with **pnpm**
```sh
pnpm add effector effector-react
```
with **yarn**
```sh
yarn add effector effector-react
```
with **npm**
```sh
```bash
npm add effector effector-react
```
**Vue**
**SolidJS**
with **pnpm**
```sh
pnpm add effector effector-vue
```bash
npm add effector effector-solid
```
with **yarn**
```sh
yarn add effector effector-vue
```
**Vue**
with **npm**
```sh
```bash
npm add effector effector-vue

@@ -398,2 +374,11 @@ ```

<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/Kelin2025>
<img src=https://avatars.githubusercontent.com/u/4208480?v=4 width="100;" alt=Anton Kosykh/>
<br />
<sub style="font-size:14px"><b>Anton Kosykh</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/yurovant>

@@ -405,4 +390,2 @@ <img src=https://avatars.githubusercontent.com/u/11337124?v=4 width="100;" alt=Anton Yurovskykh/>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -443,2 +426,4 @@ <a href=https://github.com/gamtiq>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -451,4 +436,2 @@ <a href=https://github.com/Tauka>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -489,2 +472,4 @@ <a href=https://github.com/aldibatyr>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -497,4 +482,2 @@ <a href=https://github.com/45m0d3u5>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -535,2 +518,4 @@ <a href=https://github.com/7iomka>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -543,4 +528,2 @@ <a href=https://github.com/sanohin>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -561,13 +544,13 @@ <a href=https://github.com/mihasia20008>

<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/Kelin2025>
<img src=https://avatars.githubusercontent.com/u/4208480?v=4 width="100;" alt=Anton Kosykh/>
<a href=https://github.com/rymarchikbot>
<img src=https://avatars.githubusercontent.com/u/43807162?v=4 width="100;" alt=rymarchikbot/>
<br />
<sub style="font-size:14px"><b>Anton Kosykh</b></sub>
<sub style="font-size:14px"><b>rymarchikbot</b></sub>
</a>
</td>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/rymarchikbot>
<img src=https://avatars.githubusercontent.com/u/43807162?v=4 width="100;" alt=rymarchikbot/>
<a href=https://github.com/mindyourlifeguide>
<img src=https://avatars.githubusercontent.com/u/35348648?v=4 width="100;" alt=Bohdan Petrov/>
<br />
<sub style="font-size:14px"><b>rymarchikbot</b></sub>
<sub style="font-size:14px"><b>Bohdan Petrov</b></sub>
</a>

@@ -582,2 +565,4 @@ </td>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -590,4 +575,2 @@ <a href=https://github.com/hyposlasher>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -628,2 +611,4 @@ <a href=https://github.com/dskiba>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -636,4 +621,2 @@ <a href=https://github.com/newbornfrontender>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -674,2 +657,4 @@ <a href=https://github.com/vanpav>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -682,4 +667,2 @@ <a href=https://github.com/RubaXa>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -720,2 +703,4 @@ <a href=https://github.com/lud>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -728,4 +713,2 @@ <a href=https://github.com/bigslycat>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -753,2 +736,9 @@ <a href=https://github.com/rachaeldawn>

<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/GTech1256>
<img src=https://avatars.githubusercontent.com/u/18086485?v=4 width="100;" alt=Roman/>
<br />
<sub style="font-size:14px"><b>Roman</b></sub>
</a>
</td>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/satyarohith>

@@ -760,2 +750,4 @@ <img src=https://avatars.githubusercontent.com/u/29819102?v=4 width="100;" alt=Satya Rohith/>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -775,4 +767,2 @@ <a href=https://github.com/belozer>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -787,5 +777,5 @@ <a href=https://github.com/usmanyunusov>

<a href=https://github.com/VadimFilimonov>
<img src=https://avatars.githubusercontent.com/u/11225648?v=4 width="100;" alt=Vadim Filimonov/>
<img src=https://avatars.githubusercontent.com/u/11225648?v=4 width="100;" alt=VadimFilimonov/>
<br />
<sub style="font-size:14px"><b>Vadim Filimonov</b></sub>
<sub style="font-size:14px"><b>VadimFilimonov</b></sub>
</a>

@@ -807,2 +797,4 @@ </td>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -822,4 +814,2 @@ <a href=https://github.com/yumauri>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -853,2 +843,4 @@ <a href=https://github.com/Victor-Nikliaiev>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -868,4 +860,2 @@ <a href=https://github.com/WoodenPC>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -899,2 +889,4 @@ <a href=https://github.com/anatolykopyl>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -914,4 +906,2 @@ <a href=https://github.com/nonzzz>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -945,2 +935,4 @@ <a href=https://github.com/miyaokamarina>

</td>
</tr>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">

@@ -947,0 +939,0 @@ <a href=https://github.com/xxxxue>

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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