Comparing version 23.0.0-rc.6 to 23.0.0
@@ -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,n){if(!e)throw Error((n?n+': ':'')+r)}function t(e,r){var n=j(e).meta||{};re={id:j(e).id,parent:re,value:e,template:n.template||te(),sidRoot:n.sidRoot||re&&re.sidRoot,meta:n};try{return r()}finally{ne('region'),re=q(re)}}function a(e){var n=void 0===e?{}:e,t=n.node,a=void 0===t?[]:t,i=n.parent,o=n.child,u=void 0===o?n.to||n.target:o,s=n.scope,f=void 0===s?{}:s,c=n.meta,d=void 0===c?{}:c,l=n.family,p=void 0===l?{type:'regular'}:l,v=n.regional,m=oe(void 0===i?n.from||n.source:i),g=oe(p.links),h=oe(p.owners),y=[];r(a,(function(e){return e&&J(y,e)}));var b={id:Z(),seq:y,next:oe(u),meta:d,scope:f,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return J(O(e),b)})),r(h,(function(e){return J(z(e),b)})),r(m,(function(e){return J(e.next,b)})),v&&re&&ie(C(re),[b]),b}function i(e,n,t){var a,i=We,o=null,u=Fe;if(e.target&&(n=e.params,t=e.defer,a=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),u=F(e)||u,e=e.target),u&&Fe&&u!==Fe&&(Fe=null),Array.isArray(e))for(var s=0;s<e.length;s++)_e('pure',i,j(e[s]),o,n[s],u,a);else _e('pure',i,j(e),o,n,u,a);if(!t||Le){var f,c,d,l,p,v,m={isRoot:Le,currentPage:We,scope:Fe,isWatch:Te,isPure:Be};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,We=p=n.page,Fe=F(n),p?v=p.reg:Fe&&(v=Fe.reg);var a=!!p,i=!!Fe,o={fail:0,scope:d.scope};f=c=0;for(var u=e;u<d.seq.length&&!f;u++){var s=d.seq[u];if(s.order){var g=s.order,h=g.priority,y=g.barrierID,b=y?p?p.fullID+"_"+y:y:0;if(u!==e||t!==h)return y?Ve.has(b)||(Ve.add(b),Ee(u,n,h,y)):Ee(u,n,h,0),"continue|kernelLoop";y&&Ve.delete(b)}switch(s.type){case'mov':var k=s.data,w=void 0;switch(k.from){case'stack':w=C(n);break;case'a':case'b':w=n[k.from];break;case'value':w=k.store;break;case'store':if(v&&!v[k.store.id])if(a){var x=Ue(p,k.store.id);n.page=p=x,x?v=x.reg:i?(Ke(Fe,k.store,0,1,k.softRead),v=Fe.reg):v=void 0}else i&&Ke(Fe,k.store,0,1,k.softRead);w=Oe(v&&v[k.store.id]||k.store)}switch(k.to){case'stack':n.value=w;break;case'a':case'b':n[k.to]=w;break;case'store':$e(p,Fe,k.target,0).current=w}break;case'compute':var S=s.data;if(S.fn){Te='watch'===d.meta.op,Be=S.pure;var M=S.safe?(0,S.fn)(C(n),o.scope,n):Qe(o,S.fn,n);S.filter?c=!M:n.value=M,Te=m.isWatch,Be=m.isPure}}f=o.fail||c}if(Re&&Re(n,o),!f){var A=C(n),j=F(n);if(r(d.next,(function(e){_e('child',p,e,n,A,j)})),j){d.meta.needFxCounter&&_e('child',p,j.fxCount,n,A,j),d.meta.storeChange&&_e('child',p,j.storeChange,n,A,j),d.meta.warnSerialize&&_e('child',p,j.warnSerializeNode,n,A,j);var O=j.additionalLinks[d.id];O&&r(O,(function(e){_e('child',p,e,n,A,j)}))}}};l=De();)g();Le=m.isRoot,We=m.currentPage,Fe=F(m)}}function o(r,n){void 0===n&&(n='combine');var t=n+'(',a='',i=0;return e(r,(function(e){i<25&&(null!=e&&(t+=a,t+=E(e)?_(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=_(r);0===e.length?(n=i.path,t=i.fullName):(n=i.path.concat([e]),t=0===i.fullName.length?e:i.fullName+'/'+e)}else n=0===e.length?[]:[e],t=e;return{shortName:a,fullName:t,path:n}}function s(e,r){if(!r)return e;if(!r.name&&!r.named&&!r.loc)return e;var n="["+e+"]",t=r.named||r.name;t&&(n+=" unit '"+t+"'");var a=r.loc;return!t&&a&&(n+=" ("+a.file+":"+a.line+":"+a.column+")"),n}function f(e,r){var n=r?e:e[0];ce(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(ue(i)&&'and'in i){var o=f(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function c(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}function d(e){var r=te();if(r){for(var n=r.handlers[e],t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];if(n)return n.apply(void 0,[r].concat(a))}}function l(e,r,n,t){var a=We,i=null;if(r)for(i=We;i&&i.template!==r;)i=q(i);He(i);var o=e.create(n,t);return He(a),o}function p(e,r){var t=Xe({or:r,and:'string'==typeof e?{name:e}:e}),o=s('event',t),u=function e(r){n(!R(e,'derived'),'call of derived event is not supported, use createEvent instead',o),n(!Be,'unit call from pure function is not supported, use operators like sample instead',o);for(var t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];return We?l(e,f,r,a):e.create(r,a)},f=te(),c=Object.assign(u,{graphite:a({meta:or(t.actualOp||"event",u,t),regional:1}),create:function(e){return i({target:u,params:e,scope:Fe}),e},watch:function(e){return ar(u,e)},map:function(e){return ur(u,"map",e,[Me()])},filter:function(e){return ur(u,'filter',e.fn?e:e.fn,[Me(ge,1)])},filterMap:function(e){return ur(u,'filterMap',e,[Me(),xe((function(e){return!fe(e)}),1)])},prepend:function(e){n(u.targetable,'.prepend of derived event is not supported, call source event instead',o);var r=p('* \u2192 '+u.shortName,{parent:q(u)});return d('eventPrepend',j(r)),tr(r,u,[Me()],'prepend',e),ir(u,r),r}});return null!=t&&t.domain&&t.domain.hooks.event(c),D(c,'id',c.graphite.id),ne(c.graphite),c}function v(e,t,a,i,o){return le(a,o+" "+t,'first argument'),n(se(i),'second argument should be a function',o),K(!R(e,'derived'),t+" in derived store",t+" in store created via createStore",o),r(Array.isArray(a)?a:[a],(function(r){e.off(r),I(e).set(r,nr(fr(r,e,'on',me,i)))})),e}function m(e,t){var o=Xe(t),u=je(e),f=s('store',o),c=p({named:'updates',derived:1});d('storeBase',u);var l=u.id,g='skipVoid'in o,h=g&&!o.skipVoid;K(!(g&&o.skipVoid),'{skipVoid: true}','updateFilter',f);var y={subscribers:new Map,updates:c,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(We){for(var n=We;n&&!n.reg[l];)n=q(n);n&&(e=n)}return!e&&Fe&&(Ke(Fe,u,1),e=Fe),e&&(r=e.reg[l]),Oe(r)},setState:function(e){return i({target:y,params:e,defer:1,scope:Fe})},reset:function(){n(y.targetable,'.reset of derived store is not supported',f);for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r(t,(function(e){return v(y,'.reset',e,(function(){return y.defaultState}),f)})),y},on:function(e,r){return n(y.targetable,'.on of derived store is not supported',f),v(y,'.on',e,r,f)},off:function(e){var r=I(y).get(e);return r&&(r(),I(y).delete(e)),y},map:function(e,r){var n,t;ue(e)&&(n=e,e=e.fn);var a=y.getState(),i=fe(a);te()?t=null:(!i||i&&h)&&(t=e(a));var o=m(t,Object.assign({name:y.shortName+" \u2192 *",derived:1},r,{and:n})),s=fr(y,o,"map",ge,e);return ze(N(o),{type:"map",fn:e,from:u}),N(o).noInit=1,d('storeMap',u,s),o},watch:function(e,r){if(K(!r,'watch second argument','sample',f),!r||!E(e)){var t=ar(y,e);return d('storeWatch',u,e)||e(y.getState()),t}return n(se(r),'second argument should be a function',f),e.watch((function(e){return r(y.getState(),e)}))}},b=or("store",y,o),k=y.defaultConfig.updateFilter;y.graphite=a({scope:{state:u,fn:k},node:[xe((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),Se(u),xe((function(e,r,n){var t=n.a,a=n.b,i=fe(e);return i&&!g&&console.error(f+": "+sr),(i&&h||!i)&&(e!==t||a)}),1),k&&Me(ve,1),be({from:"stack",target:u})],child:c,meta:Object.assign({},b,{defaultState:e}),regional:1}),D(y,'id',y.graphite.id),D(y,'rootStateRefId',l);var w=R(y,'serialize'),x=R(y,'derived'),S='ignore'===w,M=R(y,'sid');M&&(D(y,'storeChange',1),u.sid=M),M||S||x||D(y,'warnSerialize',1);var A=fe(e);return n(x||!A||A&&h,sr,f),x&&A&&!g&&console.error(f+": "+sr),ie(y,[c]),null!=o&&o.domain&&o.domain.hooks.store(y),x||(y.reinit=p({named:'reinit'}),y.reset(y.reinit)),u.meta=y.graphite.meta,ne(y.graphite),y}function g(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=f(r);r=u[0];var c,d,l,p=s('combine',o=u[1]),v=r[r.length-1],m=!V(v)&&ue(v),g=m&&v,h=m?r[r.length-2]:v;if(se(h)?(i=r.slice(0,m?-2:-1),a=h):i=r,1===i.length){var y=i[0];V(y)||(c=y,d=1)}if(!d&&(c=i,a)){l=1;var b=a;a=function(e){return b.apply(void 0,e)}}return n(ue(c),p+": shape should be an object"),cr(Array.isArray(c),!l,c,o,a,g)}function h(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function y(e,r){void 0===r&&(r={});var t=Xe(se(e)?{handler:e}:e,r),o=s('effect',t),u=p(se(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),f=j(u);D(f,'op',u.kind="effect"),u.use=function(e){return n(se(e),'.use argument should be a function',o),y.scope.handler=e,u},u.use.getCurrent=function(){return y.scope.handler};var c=u.finally=p({named:'finally',derived:1}),d=u.done=c.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),l=u.fail=c.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),v=u.doneData=d.map({named:'doneData',fn:function(e){return e.result}}),g=u.failData=l.map({named:'failData',fn:function(e){return e.error}}),y=a({scope:{handler:u.defaultConfig.handler||function(){return n(0,"no handler used in "+u.compositeName.fullName)}},node:[xe((function(e,r,n){var t=r.handler,a=F(n);if(a){var i=a.handlers.unitMap.get(u)||a.handlers.sidMap[u.sid];i&&(t=i)}return e.handler=t,e}),0,1),xe((function(e,r,n){if(!r.runnerFn||r.runnerFn(e,null,n)){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,s=lr(t,a,1,c,n),f=lr(t,a,0,c,n),d=dr(i,f,u),l=d[1];d[0]&&(ue(l)&&se(l.then)?l.then(s,f):s(l))}}),0,1)],meta:{op:'fx',fx:'runner'}});f.scope.runner=y,J(f.seq,xe((function(e,r,n){var t=r.runner,a=q(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:ee()}),i({target:t,params:a,defer:1,scope:F(n),meta:n.meta}),a.params}))),u.create=function(e){var r=h(),n={params:e,req:r};if(Fe&&!Te){var t=Fe;r.req.finally((function(){Ge(t)})).catch((function(){}))}return i({target:u,params:n,scope:Fe}),r.req};var b=u.inFlight=m(0,{serialize:'ignore',named:(R(u,'name')||u.graphite.id)+'.inFlight'}).on(u,(function(e){return e+1})).on(c,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});D(c,'needFxCounter','dec'),D(u,'needFxCounter',1);var k=u.pending=b.map({fn:function(e){return e>0},named:'pending'});return ie(u,[c,d,l,v,g,k,b]),null!=t&&t.domain&&t.domain.hooks.effect(u),u}function b(e,r){var n=s('merge',r);le(e,n,'first argument');var t=p({name:o(e,'merge'),derived:1,and:r});return tr(e,t,[],'merge'),t}function k(e,t){var a=0;return r(vr,(function(r){r in e&&(n(null!=e[r],mr(t,r)),a=1)})),a}function w(e,n,t){var a=[];(function e(i){U(a,i)||(J(a,i),"store"===R(i,'op')&&(t||R(i,'sid'))&&n(i,R(i,'sid')),r(i.next,e),r(O(i),e),r(z(i),e))})(e)}function x(e,t){var a=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(a instanceof Map){var u={};return r(a,(function(e,r){n(E(r),'Map key should be a unit'),t&&t(r,e),r.sid&&(r.sid in u&&(o=1),u[r.sid]=e),i.set(r,e)})),{sidMap:u,unitMap:i,hasSidDoubles:o}}return{sidMap:a,unitMap:i}}function S(e,r){return V(r)?[Ae.mov({store:r.stateRef,to:'stack'})].concat(e):e}Object.defineProperty(exports,'__esModule',{value:1});for(var M,A='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',j=function(e){return e.graphite||e},O=function(e){return e.family.owners},z=function(e){return e.family.links},N=function(e){return e.stateRef},C=function(e){return e.value},I=function(e){return e.subscribers},q=function(e){return e.parent},F=function(e){return e.scope},R=function(e,r){return j(e).meta[r]},D=function(e,r,n){return j(e).meta[r]=n},_=function(e){return e.compositeName},E=function(e){return(se(e)||ue(e))&&'kind'in e},P=function(e){return function(r){return E(r)&&r.kind===e}},V=P("store"),L=P("event"),T=P("effect"),B=function(e){return E(e)&&!!e.targetable},W=P("domain"),G=P("scope"),H={__proto__:null,unit:E,store:V,event:L,effect:T,targetable:B,domain:W,scope:G,attached:function(e){return T(e)&&1==R(e,'attached')}},U=function(e,r){return e.includes(r)},$=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},J=function(e,r){return e.push(r)},K=function(e,r,n,t){return!e&&console.error((t?t+': ':'')+r+" is deprecated"+(n?", use "+n+" instead":''))},Q=function(){var e=0;return function(){return""+ ++e}},X=Q(),Y=Q(),Z=Q(),ee=Q(),re=null,ne=function(e){M&&M(e,re)},te=function(){return re&&re.template},ae=function(e){return e&&re&&re.sidRoot&&(e=re.sidRoot+"|"+e),e},ie=function(e,n){var t=j(e);r(n,(function(e){var r=j(e);"domain"!==t.family.type&&(r.family.type="crosslink"),J(O(r),t),J(z(t),r)}))},oe=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(j)},ue=function(e){return'object'==typeof e&&null!==e},se=function(e){return'function'==typeof e},fe=function(e){return void 0===e},ce=function(e){return n(ue(e)||se(e),'expect first argument be an object')},de=function(e,r,t,a){return n(!(!ue(e)&&!se(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},le=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return de(e,n,r+" item of "+t,'')})):de(e,n,t,' or array of units')},pe=function(e,t,a){return void 0===a&&(a='target'),r(oe(t),(function(r){return n(!R(r,'derived'),e+": derived unit in \""+a+"\" is not supported, use createStore/createEvent instead\"")}))},ve=function(e,r,n){return(0,r.fn)(e,n.a)},me=function(e,r,n){return(0,r.fn)(n.a,e)},ge=function(e,r){return(0,r.fn)(e)},he=function(e,r,n,t){var a={id:Y(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++ye)),a},ye=0,be=function(e){var r=e.from,n=e.target,t=e.to;return he('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":"stack":t,target:n},e.priority,e.batch)},ke=function(e){var r=e.safe,n=e.filter,t=e.pure;return he('compute',{fn:e.fn,safe:void 0===r?0:r,filter:void 0===n?0:n,pure:void 0===t?0:t},e.priority,e.batch)},we=function(e){return ke({fn:e.fn,priority:"effect"})},xe=function(e,r,n){return ke({fn:e,safe:1,filter:r,priority:n&&"effect"})},Se=function(e,r,n){return be({store:e,to:r?"stack":"a",priority:n&&"sampler",batch:1})},Me=function(e,r){return void 0===e&&(e=ge),ke({fn:e,pure:1,filter:r})},Ae={mov:be,compute:ke,filter:function(e){return ke({fn:e.fn,filter:1,pure:e.pure})},run:we},je=function(e){return{id:Y(),current:e,initial:e}},Oe=function(e){return e.current},ze=function(e,r){e.before||(e.before=[]),J(e.before,r)},Ne=null,Ce=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||Pe(r.v.type)>Pe(n.v.type))&&(t=r,r=n,n=t),t=e(r.r,n),r.r=r.l,r.l=t,r):r:n;var t},Ie=[],qe=0;qe<6;)J(Ie,{first:null,last:null,size:0}),qe+=1;var Fe,Re,De=function(){for(var e=0;e<6;e++){var r=Ie[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=Ne.v;return Ne=Ce(Ne.l,Ne.r),n}1===r.size&&(r.last=null);var t=r.first;return r.first=t.r,r.size-=1,t.v}}},_e=function(e,r,n,t,a,i,o){return Ee(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e,0)},Ee=function(e,r,n,t){var a=Pe(n),i=Ie[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?Ne=Ce(Ne,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Pe=function(e){switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case'barrier':return 3;case'sampler':return 4;case'effect':return 5;default:return-1}},Ve=new Set,Le=1,Te=0,Be=0,We=null,Ge=function(e){Fe=e},He=function(e){We=e},Ue=function(e,r){if(e){for(;e&&!e.reg[r];)e=e.parent;if(e)return e}return null},$e=function(e,r,n,t){var a=Ue(e,n.id);return a?a.reg[n.id]:r?(Ke(r,n,t),r.reg[n.id]):n},Je=function(e){return e},Ke=function e(n,t,a,i,o){var u=n.reg;if(!u[t.id]){var s=t.sid,f={id:t.id,current:t.initial,meta:t.meta};if(f.id in n.values.idMap)f.current=n.values.idMap[f.id];else if(s&&s in n.values.sidMap&&!(s in n.sidIdMap)){var c,d=null==t||null===(c=t.meta)||void 0===c?void 0:c.serialize;f.current=(n.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Je)(n.values.sidMap[s])}else if(t.before&&!o){var l=0,p=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case'map':var t=r.from;if((t||r.fn)&&(t&&e(n,t,a,i),p)){var o=t&&u[t.id].current;f.current=r.fn?r.fn(o):o}break;case'field':e(n,r.from,a,i),l||(l=1,f.current=Array.isArray(f.current)?[].concat(f.current):Object.assign({},f.current)),p&&(f.current[r.field]=u[u[r.from.id].id].current)}}))}s&&(n.sidIdMap[s]=t.id),u[t.id]=f}},Qe=function(e,r,n){try{return r(C(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Xe=function r(n,t){return void 0===t&&(t={}),ue(n)&&(r(n.or,t),e(n,(function(e,r){fe(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Ye=function(e,r){$(e.next,r),$(O(e),r),$(z(e),r)},Ze=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=z(r);a=i.pop();)Ye(a,r),(n||t&&'sample'!==r.meta.op||"crosslink"===a.family.type)&&e(a,n,'on'!==a.meta.op&&t);for(i=O(r);a=i.pop();)Ye(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==a.meta.op&&t)},er=function(e){return e.clear()},rr=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),V(e))er(I(e));else if(W(e)){t=1;var a=e.history;er(a.events),er(a.effects),er(a.stores),er(a.domains)}Ze(j(e),!!n,t)},nr=function(e){return c((function(){return rr(e)}))},tr=function(e,r,n,t,i){return a({node:n,parent:e,child:r,scope:{fn:i},meta:{op:t},family:{owners:[e,r],links:r},regional:1})},ar=function(e,r){return n(se(r),'.watch argument should be a function'),nr(a({scope:{fn:r},node:[we({fn:ge})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},ir=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},or=function(e,r,n){var t=Xe(n),a="domain"===e,i=X(),o=t.sid,s=void 0===o?null:o,f=t.named,c=void 0===f?null:f,d=t.domain,l=t.parent,p=void 0===l?void 0===d?null:d:l,v=c||t.name||(a?'':i),m=u(v,p),g={op:r.kind=e,name:r.shortName=v,sid:r.sid=ae(s),named:c,unitId:r.id=i,serialize:t.serialize,derived:t.derived,config:t};if(r.targetable=!t.derived,r.parent=p,r.compositeName=m,r.defaultConfig=t,r.getType=function(){return K(0,'getType','compositeName.fullName'),m.fullName},!a){r.subscribe=function(e){return ce(e),r.watch(se(e)?e:function(r){return e.next&&e.next(r)})},r[A]=function(){return r};var h=te();h&&(g.nativeTemplate=h)}return g},ur=function(e,r,n,t){var a;ue(n)&&(a=n,n=n.fn);var i=p({name:e.shortName+" \u2192 *",derived:1,and:a});return tr(e,i,t,r,n),i},sr='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',fr=function(e,r,n,t,a){var i=N(r),o=be({store:i,to:"a",priority:'read'});"map"===n&&(o.data.softRead=1);var u=[o,Me(t)];return d('storeOnMap',i,u,V(e)&&N(e)),tr(e,r,u,n,a)},cr=function(r,t,a,i,u,f){var c=s('combine',i),l=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},p=r?[]:{},v=l(p),g=je(v),h=je(1);g.type=r?'list':'shape',g.noInit=1,d('combineBase',g,h);var y=m(v,Object.assign({name:o(a),derived:1},f,{and:i})),b=N(y);b.noInit=1,D(y,'isCombine',1);var k=Se(g);k.order={priority:'barrier'};var w=be({store:b,to:'b',priority:'read'});w.data.softRead=1;var x=[xe((function(e,r,n){return n.scope&&!n.scope.reg[g.id]&&(n.c=1),e})),k,be({store:h,to:'b'}),xe((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=l(n.a)),n.a[a]=e,1}),1),be({from:"a",target:g}),be({from:"value",store:0,target:h}),be({from:"value",store:1,target:h,priority:'barrier',batch:1}),Se(g,1,1),u&&Me(),w];if(e(a,(function(e,r){if(!V(e))return n(!E(e)&&!fe(e),"combine expects a store in a field "+r,c),void(v[r]=p[r]=e);p[r]=e.defaultState,v[r]=e.getState();var t=tr(e,y,x,'combine',u);t.scope.key=r;var a=N(e);ze(g,{type:'field',field:r,from:a}),d('combineField',a,t)})),y.defaultShape=a,ze(b,{type:"map",from:g,fn:u}),!te())if(u){var S=u(v);!fe(S)||f&&'skipVoid'in f||console.error(c+": "+sr),b.current=S,b.initial=S,y.defaultState=S}else y.defaultState=p;return y},dr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},lr=function(e,r,n,t,a){return function(o){i({target:[t,pr],params:[n?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:n?r.rs:r.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})}},pr=a({node:[we({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),vr=['source','clock','target'],mr=function(e,r){return e+": "+r+" should be defined"},gr=function(e,r,t,a,i,o,u,f,c,l,v,h){var y=s(e,f),k=!!i;n(!fe(t)||!fe(r),mr(y,'either source or clock'));var w=0;fe(t)?w=1:E(t)||(t=g(t)),fe(r)?r=t:(le(r,y,'clock'),Array.isArray(r)&&(r=b(r))),w&&(t=r),f||u||(u=t.shortName);var x='none';(v||a)&&(E(a)?x='unit':(n(se(a),'`filter` should be function or unit'),x='fn')),i?(le(i,y,'target'),pe(y,i)):'none'===x&&l&&V(t)&&V(r)?i=m(o?o(Oe(N(t)),Oe(N(r))):Oe(N(t)),{name:u,sid:h,or:f}):(i=p({name:u,derived:1,or:f}),d('sampleTarget',j(i)));var S=je(),M=[];if('unit'===x){var A=yr(a,i,r,S,e),O=A[0];A[2]||M.push.apply(M,hr(A[1])),M.push.apply(M,hr(O))}var z=[];if(w)c&&z.push(Se(S,1,1));else{var C=yr(t,i,r,S,e),I=C[0];C[2]||z.push.apply(z,hr(C[1])),z.push(Se(I,1,c))}var q=tr(r,i,[d('sampleSourceLoader'),be({from:"stack",target:S})].concat(z,M,[Se(S),'fn'===x&&Me((function(e,r,n){return a(e,n.a)}),1),o&&Me(ve),d('sampleSourceUpward',k)]),e,o);return ie(t,[q]),Object.assign(q.meta,f,{joint:1}),i},hr=function(e){return[Se(e),xe((function(e,r,n){return n.a}),1)]},yr=function(e,r,n,t,i){var o=V(e),u=o?N(e):je(),s=je(o);return o||a({parent:e,node:[be({from:"stack",target:u}),be({from:"value",store:1,target:s})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),d('sampleSource',s,u,t),[u,s,o]},br=function(e,r,n,t){var a=e[r];a&&i({target:a,params:Array.isArray(a)?a.map((function(){return n})):n,defer:1,stack:t})},kr=function(e){return!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op},wr=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!E(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||L(e)||V(e)||G(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));G(e)&&(t=e);var o=h();o.parentFork=Fe;var u=t.fxCount;J(u.scope.defers,o);var s=[],f=[];return G(e)||(J(s,e),J(f,T(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),J(s,u),J(f,null),i({target:s,params:f,scope:t}),o.req},exports.attach=function(e){var r,t,a=f(e,1);e=a[0];var o=s('attach',t=a[1]),c=e.source,d=e.effect,l=e.mapParams,p=e.domain;T(d)&&n(fe(p),'`domain` can only be used with a plain function',o);var v=y(e,t);D(v,'attached',1);var m,h,b=j(v).scope.runner,k=function(e,r,n){var t,a=e.params,o=e.req,u=e.handler,s=v.finally,f=lr(a,o,0,s,n),d=n.a,p=T(u),m=1;if(l){var g=dr(l,f,[a,d]);m=g[0],t=g[1]}else t=c&&p?d:a;if(m){if(!p)return e.args=[d,t],1;i({target:u,params:{params:t,req:{rs:lr(a,o,1,s,n),rj:f}},page:n.page,defer:1,meta:n.meta})}};c?(b.scope.runnerFn=k,V(c)?ie(h=c,[v]):(h=g(c),ie(v,[h])),m=[xe((function(e){return e}),0,1),Se(N(h))],delete b.seq[1].order):m=[xe(k,1,1)],(r=b.seq).splice.apply(r,[1,0].concat(m)),v.use(d);var w=q(d);return w&&(Object.assign(_(v),u(v.shortName,w)),v.defaultConfig.parent=w),ir(d,v,"effect"),v},exports.clearNode=rr,exports.combine=g,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=f(n),i=a[0],o=i[0],u=i[1],s=a[1],c={};return e(u,(function(e,r){var n=c[r]=p(r,{parent:q(o),config:s});o.on(n,e),ir(o,n)})),c},exports.createDomain=function n(t,o){var u=Xe({or:o,and:'string'==typeof t?{name:t}:t}),s=a({family:{type:"domain"},regional:1,parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent)}),f={history:{},graphite:s,hooks:{}};s.meta=or("domain",f,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:Object.assign({},u,{derived:1})}),e({Event:p,Effect:y,Store:m,Domain:n},(function(e,n){var t=n.toLowerCase(),a=p({named:"on"+n});f.hooks[t]=a;var o=new Set;f.history[t+"s"]=o,a.create=function(e){return i(a,e),e},J(j(a).seq,xe((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){ie(f,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=f)})),ie(f,[a]),f["onCreate"+n]=function(e){return r(o,e),a.watch(e)},f["create"+n]=f[t]=function(r,n){var t=Xe({and:n,or:r});return null!=t&&t.domain?e(r,n):a(e(r,{parent:f,or:t}))}}));var c=q(f);return c&&e(f.hooks,(function(e,r){return tr(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(f),f},exports.createEffect=y,exports.createEvent=p,exports.createNode=a,exports.createStore=m,exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=e.batch,o=[Ae.run({fn:function(e){return n(e)}})];i&&o.unshift(Ae.compute({priority:'sampler',batch:1})),V(r)&&o.unshift(Ae.mov({store:r.stateRef,to:'stack'}));var u=Array.isArray(r)?r:[r];if(t){var s=[],f=t.additionalLinks;return u.forEach((function(e){var r=f[e.graphite.id]||[];f[e.graphite.id]=r;var n=a({node:S(o,e),meta:{watchOp:e.kind}});r.push(n),s.push((function(){var e=r.indexOf(n);-1!==e&&r.splice(e,1),rr(n)}))})),c((function(){s.forEach((function(e){return e()}))}))}var d=a({node:o,parent:u,family:{owners:u}});return c((function(){rr(d)}))},exports.fork=function(e,t){var i,o=e;W(e)&&(K(0,'fork(domain)','fork()'),i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[xe((function(e,r,n){n.parent?'dec'===n.parent.node.meta.needFxCounter?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),ke({priority:"sampler",batch:1}),xe((function(e,n){var t=n.defers,a=n.fxID;n.inFlight>0||0===t.length||Promise.resolve().then((function(){n.fxID===a&&r(t.splice(0,t.length),(function(e){Ge(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[xe((function(e,r,n){var t=n.parent;if(t){var a=t.node;if(kr(t)){var i=F(n),o=a.meta.sid;i.sidIdMap[o]=a.scope.state.id,i.values.sidMap[o]=e;var u=a.meta.serialize;u&&i.sidSerializeSettings.set(o,'ignore'===u?{ignore:1}:{ignore:0,write:u.write})}}}))]}),i=a({node:[xe((function(e,r,n){var t=F(n);t&&n.parent&&kr(n.parent)&&(t.warnSerialize=1)}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return $e(We,o,e,0).current;var r=j(e);return $e(We,o,r.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[n,t,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:n}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:n,storeChange:t,warnSerializeNode:i};return o}(i);if(o){if(o.values){var s=x(o.values,(function(e){return n(V(e)&&B(e),'Values map can contain only writable stores as keys')})),f=s.unitMap,c=s.hasSidDoubles;Object.assign(u.values.sidMap,s.sidMap),r(f,(function(e,r){if(u.values.idMap[r.stateRef.id]=e,'ignore'===R(r,'serialize')){var n=R(r,'sid');u.sidSerializeSettings.set(n,{ignore:1})}})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),u.hasSidDoubles=c}o.handlers&&(K(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),u.handlers=x(o.handlers,(function(e){return n(T(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){var r='forward',n=f(e,1),t=n[0],i=t.from,o=t.to,u=n[1],c=s(r,u);return K(0,r,'sample',c),le(i,c,'"from"'),le(o,c,'"to"'),pe(c,o,'to'),nr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){ce(e);var r=A in e?e[A]():e;n(r.subscribe,'expect observable to have .subscribe');var t=p(),a=nr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=f(r),a=t[0],i=a[0],o=a[1],u=t[1],c=s('guard',u);return K(0,'guard','sample',c),o||(i=(o=i).source),k(o,c),gr('guard',o.clock,i,o.filter,o.target,null,o.name,u,!o.greedy,0,1)},exports.hydrate=function(e,t){var a=t.values;n(ue(a),'values property should be an object');var o=x(a),u=o.sidMap,s=o.unitMap,f=Object.getOwnPropertyNames(u),c={};r(s,(function(e,r){c[r.stateRef.id]=r}));var d,l,p,v=[],m=[];G(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),K(0,'hydrate(fork(domain), { values })','fork({ values })'),l=j(d.cloneOf)):W(e)?(K(0,'hydrate(domain, { values })','fork({ values })'),l=j(e)):n(0,'first argument of hydrate should be domain or scope'),w(l,(function(e,r){if(r&&U(f,r)){J(v,e);var n=R(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),J(m,u[r])}else e.scope.state.id in c&&(J(v,e),J(m,s.get(c[e.scope.state.id])))}),1),i({target:v,params:m,scope:d}),p&&Object.assign(d.values.sidMap,u)},exports.is=H,exports.launch=i,exports.merge=b,exports.restore=function(r,n,t){var a=s('restore',t);if(V(r))return K(0,'restore($store)',void 0,a),r;if(L(r)||T(r)){var i=q(r),o=m(n,{parent:i,name:r.shortName,and:t});return tr(T(r)?r.doneData:r,o),i&&i.hooks.store(o),o}var u=Array.isArray(r)?[]:{};return e(r,(function(e,r){return u[r]=V(e)?e:m(e,{name:r})})),u},exports.sample=function(){for(var e,r,n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];var i,o,u=f(t),c=u[0],d=c[0],l=c[1],p=c[2],v=u[1],m=1,g=s('sample',v);return fe(l)&&ue(d)&&k(d,g)&&(l=d.clock,p=d.fn,'batch'in d?m=d.batch:(K(!('greedy'in d),'greedy in sample','batch',g),m=!d.greedy),o=d.filter,e=d.target,r=d.name,i=d.sid,d=d.source),gr('sample',l,d,o,e,p,r,v,m,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||Fe||t.safe,'scopeBind: scope not found');var o=a||Fe;return T(e)?function(r){var n=h();return i({target:e,params:{params:r,req:n},scope:o}),n.req}:function(r){return i({target:e,params:r,scope:o}),r}},exports.serialize=function(r,t){void 0===t&&(t={}),r.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!r.hasSidDoubles,'duplicate sid found in this scope');var a=t.ignore?t.ignore.map((function(e){return e.sid})):[],i={};return e(r.values.sidMap,(function(e,n){var t;if(!U(a,n)){var o=r.sidIdMap[n],u=null!==(t=r.sidSerializeSettings.get(n))&&void 0!==t?t:{ignore:0,write:wr};u.ignore||(i[n]=(0,u.write)(o&&o in r.reg?r.reg[o].current:e))}})),'onlyChanges'in t&&(K(0,'onlyChanges'),t.onlyChanges||(n(r.cloneOf,'scope should be created from domain'),w(j(r.cloneOf),(function(e,n){n in i||U(a,n)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[n]=r.getState(e))})))),i},exports.setGraphInspector=function(e){M=e},exports.setInspector=function(e){Re=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(_(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];var l=f(u),v=l[0],m=v[0],g=v[1],h=l[1],y=s(i,h),b=!g;b&&(r=m.cases,g=m.match,t=m.clock,m=m.source);var k=V(g),w=!E(g)&&se(g),x=!k&&!w&&ue(g);n(E(m),'source must be a unit',y),r||(r={}),b?e(r,(function(e,r){return pe(y,e,"cases."+r)})):(n(x,'match should be an object',y),e(g,(function(e,n){return r[n]=p({derived:1,named:"cases."+n,and:h})})),r.__=p({derived:1,named:'cases.__',and:h}));var S,M=new Set([].concat(m,t||[],Object.values(r))),A=Object.keys(k||w?r:g);if(k||w)k&&M.add(g),S=[k&&Se(N(g),0,1),ke({safe:k,filter:1,pure:!k,fn:function(e,r,n){var t=String(k?n.a:g(e));br(r,U(A,t)?t:'__',e,n)}})];else if(x){var j=je({});j.type='shape';var O,z=[];e(g,(function(e,r){if(E(e)){O=1,J(z,r),M.add(e);var n=tr(e,[],[Se(j),xe((function(e,n,t){return t.a[r]=e}))]);if(V(e)){j.current[r]=e.getState();var t=N(e);ze(j,{from:t,field:r,type:'field'}),d('splitMatchStore',t,n)}}})),O&&d('splitBase',j),S=[O&&Se(j,0,1),Me((function(e,r,n){for(var t=0;t<A.length;t++){var a=A[t];if(U(z,a)?n.a[a]:g[a](e))return void br(r,a,e,n)}br(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var C=a({meta:{op:i},parent:t?[]:m,scope:r,node:S,family:{owners:Array.from(M)},regional:1});if(t&&gr(i,t,m,null,C,null,i,h,0,0,0),!b)return r},exports.step=Ae,exports.version="23.0.0-rc.6",exports.withFactory=function(e){var r=e.sid,n=e.name,i=e.loc,o=e.method,u=e.fn;return t(a({meta:{sidRoot:ae(r),sid:r,name:n,loc:i,method:o,type:'factory'}}),u)},exports.withRegion=t; | ||
'use strict';function e(e,r){for(var n in e)r(e[n],n)}function r(e,r){e.forEach(r)}function n(e,r,n){if(!e)throw Error((n?n+': ':'')+r)}function t(e,r){var n=j(e).meta||{};re={id:j(e).id,parent:re,value:e,template:n.template||te(),sidRoot:n.sidRoot||re&&re.sidRoot,meta:n};try{return r()}finally{ne('region'),re=q(re)}}function a(e){var n=void 0===e?{}:e,t=n.node,a=void 0===t?[]:t,i=n.parent,o=n.child,u=void 0===o?n.to||n.target:o,s=n.scope,f=void 0===s?{}:s,c=n.meta,d=void 0===c?{}:c,l=n.family,p=void 0===l?{type:'regular'}:l,v=n.regional,m=oe(void 0===i?n.from||n.source:i),g=oe(p.links),h=oe(p.owners),y=[];r(a,(function(e){return e&&J(y,e)}));var b={id:Z(),seq:y,next:oe(u),meta:d,scope:f,family:{type:p.type||"crosslink",links:g,owners:h}};return r(g,(function(e){return J(O(e),b)})),r(h,(function(e){return J(z(e),b)})),r(m,(function(e){return J(e.next,b)})),v&&re&&ie(C(re),[b]),b}function i(e,n,t){var a,i=We,o=null,u=Fe;if(e.target&&(n=e.params,t=e.defer,a=e.meta,i='page'in e?e.page:i,e.stack&&(o=e.stack),u=F(e)||u,e=e.target),u&&Fe&&u!==Fe&&(Fe=null),Array.isArray(e))for(var s=0;s<e.length;s++)_e('pure',i,j(e[s]),o,n[s],u,a);else _e('pure',i,j(e),o,n,u,a);if(!t||Le){var f,c,d,l,p,v,m={isRoot:Le,currentPage:We,scope:Fe,isWatch:Te,isPure:Be};Le=0;for(var g=function(){var e=l.idx,n=l.stack,t=l.type;d=n.node,We=p=n.page,Fe=F(n),p?v=p.reg:Fe&&(v=Fe.reg);var a=!!p,i=!!Fe,o={fail:0,scope:d.scope};f=c=0;for(var u=e;u<d.seq.length&&!f;u++){var s=d.seq[u];if(s.order){var g=s.order,h=g.priority,y=g.barrierID,b=y?p?p.fullID+"_"+y:y:0;if(u!==e||t!==h)return y?Ve.has(b)||(Ve.add(b),Ee(u,n,h,y)):Ee(u,n,h,0),"continue|kernelLoop";y&&Ve.delete(b)}switch(s.type){case'mov':var k=s.data,w=void 0;switch(k.from){case'stack':w=C(n);break;case'a':case'b':w=n[k.from];break;case'value':w=k.store;break;case'store':if(v&&!v[k.store.id])if(a){var x=Ue(p,k.store.id);n.page=p=x,x?v=x.reg:i?(Ke(Fe,k.store,0,1,k.softRead),v=Fe.reg):v=void 0}else i&&Ke(Fe,k.store,0,1,k.softRead);w=Oe(v&&v[k.store.id]||k.store)}switch(k.to){case'stack':n.value=w;break;case'a':case'b':n[k.to]=w;break;case'store':$e(p,Fe,k.target,0).current=w}break;case'compute':var S=s.data;if(S.fn){Te='watch'===d.meta.op,Be=S.pure;var M=S.safe?(0,S.fn)(C(n),o.scope,n):Qe(o,S.fn,n);S.filter?c=!M:n.value=M,Te=m.isWatch,Be=m.isPure}}f=o.fail||c}if(Re&&Re(n,o),!f){var A=C(n),j=F(n);if(r(d.next,(function(e){_e('child',p,e,n,A,j)})),j){d.meta.needFxCounter&&_e('child',p,j.fxCount,n,A,j),d.meta.storeChange&&_e('child',p,j.storeChange,n,A,j),d.meta.warnSerialize&&_e('child',p,j.warnSerializeNode,n,A,j);var O=j.additionalLinks[d.id];O&&r(O,(function(e){_e('child',p,e,n,A,j)}))}}};l=De();)g();Le=m.isRoot,We=m.currentPage,Fe=F(m)}}function o(r,n){void 0===n&&(n='combine');var t=n+'(',a='',i=0;return e(r,(function(e){i<25&&(null!=e&&(t+=a,t+=E(e)?_(e).fullName:e.toString()),i+=1,a=', ')})),t+')'}function u(e,r){var n,t,a=e;if(r){var i=_(r);0===e.length?(n=i.path,t=i.fullName):(n=i.path.concat([e]),t=0===i.fullName.length?e:i.fullName+'/'+e)}else n=0===e.length?[]:[e],t=e;return{shortName:a,fullName:t,path:n}}function s(e,r){if(!r)return e;if(!r.name&&!r.named&&!r.loc)return e;var n="["+e+"]",t=r.named||r.name;t&&(n+=" unit '"+t+"'");var a=r.loc;return!t&&a&&(n+=" ("+a.file+":"+a.line+":"+a.column+")"),n}function f(e,r){var n=r?e:e[0];ce(n);var t=n.or,a=n.and;if(a){var i=r?a:a[0];if(ue(i)&&'and'in i){var o=f(a,r);e=o[0],t=Object.assign({},t,o[1])}else e=a}return[e,t]}function c(e){var r=function(){return e()};return r.unsubscribe=function(){return e()},r}function d(e){var r=te();if(r){for(var n=r.handlers[e],t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];if(n)return n.apply(void 0,[r].concat(a))}}function l(e,r,n,t){var a=We,i=null;if(r)for(i=We;i&&i.template!==r;)i=q(i);He(i);var o=e.create(n,t);return He(a),o}function p(e,r){var t=Xe({or:r,and:'string'==typeof e?{name:e}:e}),o=s('event',t),u=function e(r){n(!R(e,'derived'),'call of derived event is not supported, use createEvent instead',o),n(!Be,'unit call from pure function is not supported, use operators like sample instead',o);for(var t=arguments.length,a=new Array(t>1?t-1:0),i=1;i<t;i++)a[i-1]=arguments[i];return We?l(e,f,r,a):e.create(r,a)},f=te(),c=Object.assign(u,{graphite:a({meta:or(t.actualOp||"event",u,t),regional:1}),create:function(e){return i({target:u,params:e,scope:Fe}),e},watch:function(e){return ar(u,e)},map:function(e){return ur(u,"map",e,[Me()])},filter:function(e){return ur(u,'filter',e.fn?e:e.fn,[Me(ge,1)])},filterMap:function(e){return ur(u,'filterMap',e,[Me(),xe((function(e){return!fe(e)}),1)])},prepend:function(e){n(u.targetable,'.prepend of derived event is not supported, call source event instead',o);var r=p('* \u2192 '+u.shortName,{parent:q(u)});return d('eventPrepend',j(r)),tr(r,u,[Me()],'prepend',e),ir(u,r),r}});return null!=t&&t.domain&&t.domain.hooks.event(c),D(c,'id',c.graphite.id),ne(c.graphite),c}function v(e,t,a,i,o){return le(a,o+" "+t,'first argument'),n(se(i),'second argument should be a function',o),K(!R(e,'derived'),t+" in derived store",t+" in store created via createStore",o),r(Array.isArray(a)?a:[a],(function(r){e.off(r),I(e).set(r,nr(fr(r,e,'on',me,i)))})),e}function m(e,t){var o=Xe(t),u=je(e),f=s('store',o),c=p({named:'updates',derived:1});d('storeBase',u);var l=u.id,g='skipVoid'in o,h=g&&!o.skipVoid;K(!(g&&o.skipVoid),'{skipVoid: true}','updateFilter',f);var y={subscribers:new Map,updates:c,defaultState:e,stateRef:u,getState:function(){var e,r=u;if(We){for(var n=We;n&&!n.reg[l];)n=q(n);n&&(e=n)}return!e&&Fe&&(Ke(Fe,u,1),e=Fe),e&&(r=e.reg[l]),Oe(r)},setState:function(e){return i({target:y,params:e,defer:1,scope:Fe})},reset:function(){n(y.targetable,'.reset of derived store is not supported',f);for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r(t,(function(e){return v(y,'.reset',e,(function(){return y.defaultState}),f)})),y},on:function(e,r){return n(y.targetable,'.on of derived store is not supported',f),v(y,'.on',e,r,f)},off:function(e){var r=I(y).get(e);return r&&(r(),I(y).delete(e)),y},map:function(e,r){var n,t;ue(e)&&(n=e,e=e.fn);var a=y.getState(),i=fe(a);te()?t=null:(!i||i&&h)&&(t=e(a));var o=m(t,Object.assign({name:y.shortName+" \u2192 *",derived:1},r,{and:n})),s=fr(y,o,"map",ge,e);return ze(N(o),{type:"map",fn:e,from:u}),N(o).noInit=1,d('storeMap',u,s),o},watch:function(e,r){if(K(!r,'watch second argument','sample',f),!r||!E(e)){var t=ar(y,e);return d('storeWatch',u,e)||e(y.getState()),t}return n(se(r),'second argument should be a function',f),e.watch((function(e){return r(y.getState(),e)}))}},b=or("store",y,o),k=y.defaultConfig.updateFilter;y.graphite=a({scope:{state:u,fn:k},node:[xe((function(e,r,n){return n.scope&&!n.scope.reg[u.id]&&(n.b=1),e})),Se(u),xe((function(e,r,n){var t=n.a,a=n.b,i=fe(e);return i&&!g&&console.error(f+": "+sr),(i&&h||!i)&&(e!==t||a)}),1),k&&Me(ve,1),be({from:"stack",target:u})],child:c,meta:Object.assign({},b,{defaultState:e}),regional:1}),D(y,'id',y.graphite.id),D(y,'rootStateRefId',l);var w=R(y,'serialize'),x=R(y,'derived'),S='ignore'===w,M=R(y,'sid');M&&(D(y,'storeChange',1),u.sid=M),M||S||x||D(y,'warnSerialize',1);var A=fe(e);return n(x||!A||A&&h,sr,f),x&&A&&!g&&console.error(f+": "+sr),ie(y,[c]),null!=o&&o.domain&&o.domain.hooks.store(y),x||(y.reinit=p({named:'reinit'}),y.reset(y.reinit)),u.meta=y.graphite.meta,ne(y.graphite),y}function g(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a,i,o,u=f(r);r=u[0];var c,d,l,p=s('combine',o=u[1]),v=r[r.length-1],m=!V(v)&&ue(v),g=m&&v,h=m?r[r.length-2]:v;if(se(h)?(i=r.slice(0,m?-2:-1),a=h):i=r,1===i.length){var y=i[0];V(y)||(c=y,d=1)}if(!d&&(c=i,a)){l=1;var b=a;a=function(e){return b.apply(void 0,e)}}return n(ue(c),p+": shape should be an object"),cr(Array.isArray(c),!l,c,o,a,g)}function h(){var e={};return e.req=new Promise((function(r,n){e.rs=r,e.rj=n})),e.req.catch((function(){})),e}function y(e,r){void 0===r&&(r={});var t=Xe(se(e)?{handler:e}:e,r),o=s('effect',t),u=p(se(e)?{handler:e}:e,Object.assign({},r,{actualOp:"effect"})),f=j(u);D(f,'op',u.kind="effect"),u.use=function(e){return n(se(e),'.use argument should be a function',o),y.scope.handler=e,u},u.use.getCurrent=function(){return y.scope.handler};var c=u.finally=p({named:'finally',derived:1}),d=u.done=c.filterMap({named:'done',fn:function(e){if('done'===e.status)return{params:e.params,result:e.result}}}),l=u.fail=c.filterMap({named:'fail',fn:function(e){if('fail'===e.status)return{params:e.params,error:e.error}}}),v=u.doneData=d.map({named:'doneData',fn:function(e){return e.result}}),g=u.failData=l.map({named:'failData',fn:function(e){return e.error}}),y=a({scope:{handler:u.defaultConfig.handler||function(){return n(0,"no handler used in "+u.compositeName.fullName)}},node:[xe((function(e,r,n){var t=r.handler,a=F(n);if(a){var i=a.handlers.unitMap.get(u)||a.handlers.sidMap[u.sid];i&&(t=i)}return e.handler=t,e}),0,1),xe((function(e,r,n){if(!r.runnerFn||r.runnerFn(e,null,n)){var t=e.params,a=e.req,i=e.handler,o=e.args,u=void 0===o?[t]:o,s=lr(t,a,1,c,n),f=lr(t,a,0,c,n),d=dr(i,f,u),l=d[1];d[0]&&(ue(l)&&se(l.then)?l.then(s,f):s(l))}}),0,1)],meta:{op:'fx',fx:'runner'}});f.scope.runner=y,J(f.seq,xe((function(e,r,n){var t=r.runner,a=q(n)?{params:e,req:{rs:function(){},rj:function(){}}}:e;return n.meta||(n.meta={fxID:ee()}),i({target:t,params:a,defer:1,scope:F(n),meta:n.meta}),a.params}))),u.create=function(e){var r=h(),n={params:e,req:r};if(Fe&&!Te){var t=Fe;r.req.finally((function(){Ge(t)})).catch((function(){}))}return i({target:u,params:n,scope:Fe}),r.req};var b=u.inFlight=m(0,{serialize:'ignore',named:(R(u,'name')||u.graphite.id)+'.inFlight'}).on(u,(function(e){return e+1})).on(c,(function(e){return e-1})).map({fn:function(e){return e},named:'inFlight'});D(c,'needFxCounter','dec'),D(u,'needFxCounter',1);var k=u.pending=b.map({fn:function(e){return e>0},named:'pending'});return ie(u,[c,d,l,v,g,k,b]),null!=t&&t.domain&&t.domain.hooks.effect(u),u}function b(e,r){var n=s('merge',r);le(e,n,'first argument');var t=p({name:o(e,'merge'),derived:1,and:r});return tr(e,t,[],'merge'),t}function k(e,t){var a=0;return r(vr,(function(r){r in e&&(n(null!=e[r],mr(t,r)),a=1)})),a}function w(e,n,t){var a=[];(function e(i){U(a,i)||(J(a,i),"store"===R(i,'op')&&(t||R(i,'sid'))&&n(i,R(i,'sid')),r(i.next,e),r(O(i),e),r(z(i),e))})(e)}function x(e,t){var a=Array.isArray(e)?new Map(e):e,i=new Map,o=0;if(a instanceof Map){var u={};return r(a,(function(e,r){n(E(r),'Map key should be a unit'),t&&t(r,e),r.sid&&(r.sid in u&&(o=1),u[r.sid]=e),i.set(r,e)})),{sidMap:u,unitMap:i,hasSidDoubles:o}}return{sidMap:a,unitMap:i}}function S(e,r){return V(r)?[Ae.mov({store:r.stateRef,to:'stack'})].concat(e):e}Object.defineProperty(exports,'__esModule',{value:1});for(var M,A='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',j=function(e){return e.graphite||e},O=function(e){return e.family.owners},z=function(e){return e.family.links},N=function(e){return e.stateRef},C=function(e){return e.value},I=function(e){return e.subscribers},q=function(e){return e.parent},F=function(e){return e.scope},R=function(e,r){return j(e).meta[r]},D=function(e,r,n){return j(e).meta[r]=n},_=function(e){return e.compositeName},E=function(e){return(se(e)||ue(e))&&'kind'in e},P=function(e){return function(r){return E(r)&&r.kind===e}},V=P("store"),L=P("event"),T=P("effect"),B=function(e){return E(e)&&!!e.targetable},W=P("domain"),G=P("scope"),H={__proto__:null,unit:E,store:V,event:L,effect:T,targetable:B,domain:W,scope:G,attached:function(e){return T(e)&&1==R(e,'attached')}},U=function(e,r){return e.includes(r)},$=function(e,r){var n=e.indexOf(r);-1!==n&&e.splice(n,1)},J=function(e,r){return e.push(r)},K=function(e,r,n,t){return!e&&console.error((t?t+': ':'')+r+" is deprecated"+(n?", use "+n+" instead":''))},Q=function(){var e=0;return function(){return""+ ++e}},X=Q(),Y=Q(),Z=Q(),ee=Q(),re=null,ne=function(e){M&&M(e,re)},te=function(){return re&&re.template},ae=function(e){return e&&re&&re.sidRoot&&(e=re.sidRoot+"|"+e),e},ie=function(e,n){var t=j(e);r(n,(function(e){var r=j(e);"domain"!==t.family.type&&(r.family.type="crosslink"),J(O(r),t),J(z(t),r)}))},oe=function(e){return void 0===e&&(e=[]),(Array.isArray(e)?e:[e]).flat().map(j)},ue=function(e){return'object'==typeof e&&null!==e},se=function(e){return'function'==typeof e},fe=function(e){return void 0===e},ce=function(e){return n(ue(e)||se(e),'expect first argument be an object')},de=function(e,r,t,a){return n(!(!ue(e)&&!se(e)||!('family'in e)&&!('graphite'in e)),r+": expect "+t+" to be a unit (store, event or effect)"+a)},le=function(e,n,t){Array.isArray(e)?r(e,(function(e,r){return de(e,n,r+" item of "+t,'')})):de(e,n,t,' or array of units')},pe=function(e,t,a){return void 0===a&&(a='target'),r(oe(t),(function(r){return n(!R(r,'derived'),e+": derived unit in \""+a+"\" is not supported, use createStore/createEvent instead\"")}))},ve=function(e,r,n){return(0,r.fn)(e,n.a)},me=function(e,r,n){return(0,r.fn)(n.a,e)},ge=function(e,r){return(0,r.fn)(e)},he=function(e,r,n,t){var a={id:Y(),type:e,data:r};return n&&(a.order={priority:n},t&&(a.order.barrierID=++ye)),a},ye=0,be=function(e){var r=e.from,n=e.target,t=e.to;return he('mov',{from:void 0===r?"store":r,store:e.store,to:void 0===t?n?"store":"stack":t,target:n},e.priority,e.batch)},ke=function(e){var r=e.safe,n=e.filter,t=e.pure;return he('compute',{fn:e.fn,safe:void 0===r?0:r,filter:void 0===n?0:n,pure:void 0===t?0:t},e.priority,e.batch)},we=function(e){return ke({fn:e.fn,priority:"effect"})},xe=function(e,r,n){return ke({fn:e,safe:1,filter:r,priority:n&&"effect"})},Se=function(e,r,n){return be({store:e,to:r?"stack":"a",priority:n&&"sampler",batch:1})},Me=function(e,r){return void 0===e&&(e=ge),ke({fn:e,pure:1,filter:r})},Ae={mov:be,compute:ke,filter:function(e){return ke({fn:e.fn,filter:1,pure:e.pure})},run:we},je=function(e){return{id:Y(),current:e,initial:e}},Oe=function(e){return e.current},ze=function(e,r){e.before||(e.before=[]),J(e.before,r)},Ne=null,Ce=function e(r,n){return r?n?((r.v.type===n.v.type&&r.v.id>n.v.id||Pe(r.v.type)>Pe(n.v.type))&&(t=r,r=n,n=t),t=e(r.r,n),r.r=r.l,r.l=t,r):r:n;var t},Ie=[],qe=0;qe<6;)J(Ie,{first:null,last:null,size:0}),qe+=1;var Fe,Re,De=function(){for(var e=0;e<6;e++){var r=Ie[e];if(r.size>0){if(3===e||4===e){r.size-=1;var n=Ne.v;return Ne=Ce(Ne.l,Ne.r),n}1===r.size&&(r.last=null);var t=r.first;return r.first=t.r,r.size-=1,t.v}}},_e=function(e,r,n,t,a,i,o){return Ee(0,{a:null,b:null,node:n,parent:t,value:a,page:r,scope:i,meta:o},e,0)},Ee=function(e,r,n,t){var a=Pe(n),i=Ie[a],o={v:{idx:e,stack:r,type:n,id:t},l:null,r:null};3===a||4===a?Ne=Ce(Ne,o):(0===i.size?i.first=o:i.last.r=o,i.last=o),i.size+=1},Pe=function(e){switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case'barrier':return 3;case'sampler':return 4;case'effect':return 5;default:return-1}},Ve=new Set,Le=1,Te=0,Be=0,We=null,Ge=function(e){Fe=e},He=function(e){We=e},Ue=function(e,r){if(e){for(;e&&!e.reg[r];)e=e.parent;if(e)return e}return null},$e=function(e,r,n,t){var a=Ue(e,n.id);return a?a.reg[n.id]:r?(Ke(r,n,t),r.reg[n.id]):n},Je=function(e){return e},Ke=function e(n,t,a,i,o){var u=n.reg;if(!u[t.id]){var s=t.sid,f={id:t.id,current:t.initial,meta:t.meta};if(f.id in n.values.idMap)f.current=n.values.idMap[f.id];else if(s&&s in n.values.sidMap&&!(s in n.sidIdMap)){var c,d=null==t||null===(c=t.meta)||void 0===c?void 0:c.serialize;f.current=(n.fromSerialize&&'ignore'!==d&&(null==d?void 0:d.read)||Je)(n.values.sidMap[s])}else if(t.before&&!o){var l=0,p=a||!t.noInit||i;r(t.before,(function(r){switch(r.type){case'map':var t=r.from;if((t||r.fn)&&(t&&e(n,t,a,i),p)){var o=t&&u[t.id].current;f.current=r.fn?r.fn(o):o}break;case'field':e(n,r.from,a,i),l||(l=1,f.current=Array.isArray(f.current)?[].concat(f.current):Object.assign({},f.current)),p&&(f.current[r.field]=u[u[r.from.id].id].current)}}))}s&&(n.sidIdMap[s]=t.id),u[t.id]=f}},Qe=function(e,r,n){try{return r(C(n),e.scope,n)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Xe=function r(n,t){return void 0===t&&(t={}),ue(n)&&(r(n.or,t),e(n,(function(e,r){fe(e)||'or'===r||'and'===r||(t[r]=e)})),r(n.and,t)),t},Ye=function(e,r){$(e.next,r),$(O(e),r),$(z(e),r)},Ze=function e(r,n,t){var a;r.next.length=0,r.seq.length=0,r.scope=null;for(var i=z(r);a=i.pop();)Ye(a,r),(n||t&&'sample'!==r.meta.op||"crosslink"===a.family.type)&&e(a,n,'on'!==a.meta.op&&t);for(i=O(r);a=i.pop();)Ye(a,r),t&&"crosslink"===a.family.type&&e(a,n,'on'!==a.meta.op&&t)},er=function(e){return e.clear()},rr=function(e,r){var n=(void 0===r?{}:r).deep,t=0;if(e.ownerSet&&e.ownerSet.delete(e),V(e))er(I(e));else if(W(e)){t=1;var a=e.history;er(a.events),er(a.effects),er(a.stores),er(a.domains)}Ze(j(e),!!n,t)},nr=function(e){return c((function(){return rr(e)}))},tr=function(e,r,n,t,i){return a({node:n,parent:e,child:r,scope:{fn:i},meta:{op:t},family:{owners:[e,r],links:r},regional:1})},ar=function(e,r){return n(se(r),'.watch argument should be a function'),nr(a({scope:{fn:r},node:[we({fn:ge})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))},ir=function(e,r,n){void 0===n&&(n="event"),q(e)&&q(e).hooks[n](r)},or=function(e,r,n){var t=Xe(n),a="domain"===e,i=X(),o=t.sid,s=void 0===o?null:o,f=t.named,c=void 0===f?null:f,d=t.domain,l=t.parent,p=void 0===l?void 0===d?null:d:l,v=c||t.name||(a?'':i),m=u(v,p),g={op:r.kind=e,name:r.shortName=v,sid:r.sid=ae(s),named:c,unitId:r.id=i,serialize:t.serialize,derived:t.derived,config:t};if(r.targetable=!t.derived,r.parent=p,r.compositeName=m,r.defaultConfig=t,r.getType=function(){return K(0,'getType','compositeName.fullName'),m.fullName},!a){r.subscribe=function(e){return ce(e),r.watch(se(e)?e:function(r){return e.next&&e.next(r)})},r[A]=function(){return r};var h=te();h&&(g.nativeTemplate=h)}return g},ur=function(e,r,n,t){var a;ue(n)&&(a=n,n=n.fn);var i=p({name:e.shortName+" \u2192 *",derived:1,and:a});return tr(e,i,t,r,n),i},sr='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',fr=function(e,r,n,t,a){var i=N(r),o=be({store:i,to:"a",priority:'read'});"map"===n&&(o.data.softRead=1);var u=[o,Me(t)];return d('storeOnMap',i,u,V(e)&&N(e)),tr(e,r,u,n,a)},cr=function(r,t,a,i,u,f){var c=s('combine',i),l=r?function(e){return[].concat(e)}:function(e){return Object.assign({},e)},p=r?[]:{},v=l(p),g=je(v),h=je(1);g.type=r?'list':'shape',g.noInit=1,d('combineBase',g,h);var y=m(v,Object.assign({name:o(a),derived:1},f,{and:i})),b=N(y);b.noInit=1,D(y,'isCombine',1);var k=Se(g);k.order={priority:'barrier'};var w=be({store:b,to:'b',priority:'read'});w.data.softRead=1;var x=[xe((function(e,r,n){return n.scope&&!n.scope.reg[g.id]&&(n.c=1),e})),k,be({store:h,to:'b'}),xe((function(e,r,n){var a=r.key;if(n.c||e!==n.a[a])return t&&n.b&&(n.a=l(n.a)),n.a[a]=e,1}),1),be({from:"a",target:g}),be({from:"value",store:0,target:h}),be({from:"value",store:1,target:h,priority:'barrier',batch:1}),Se(g,1,1),u&&Me(),w];if(e(a,(function(e,r){if(!V(e))return n(!E(e)&&!fe(e),"combine expects a store in a field "+r,c),void(v[r]=p[r]=e);p[r]=e.defaultState,v[r]=e.getState();var t=tr(e,y,x,'combine',u);t.scope.key=r;var a=N(e);ze(g,{type:'field',field:r,from:a}),d('combineField',a,t)})),y.defaultShape=a,ze(b,{type:"map",from:g,fn:u}),!te())if(u){var S=u(v);!fe(S)||f&&'skipVoid'in f||console.error(c+": "+sr),b.current=S,b.initial=S,y.defaultState=S}else y.defaultState=p;return y},dr=function(e,r,n){try{return[1,e.apply(void 0,n)]}catch(t){return r(t),[0,null]}},lr=function(e,r,n,t,a){return function(o){i({target:[t,pr],params:[n?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:n?r.rs:r.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})}},pr=a({node:[we({fn:function(e){return(0,e.fn)(e.value)}})],meta:{op:'fx',fx:'sidechain'}}),vr=['source','clock','target'],mr=function(e,r){return e+": "+r+" should be defined"},gr=function(e,r,t,a,i,o,u,f,c,l,v,h){var y=s(e,f),k=!!i;n(!fe(t)||!fe(r),mr(y,'either source or clock'));var w=0;fe(t)?w=1:E(t)||(t=g(t)),fe(r)?r=t:(le(r,y,'clock'),Array.isArray(r)&&(r=b(r))),w&&(t=r),f||u||(u=t.shortName);var x='none';(v||a)&&(E(a)?x='unit':(n(se(a),'`filter` should be function or unit'),x='fn')),i?(le(i,y,'target'),pe(y,i)):'none'===x&&l&&V(t)&&V(r)?i=m(o?o(Oe(N(t)),Oe(N(r))):Oe(N(t)),{name:u,sid:h,or:f}):(i=p({name:u,derived:1,or:f}),d('sampleTarget',j(i)));var S=je(),M=[];if('unit'===x){var A=yr(a,i,r,S,e),O=A[0];A[2]||M.push.apply(M,hr(A[1])),M.push.apply(M,hr(O))}var z=[];if(w)c&&z.push(Se(S,1,1));else{var C=yr(t,i,r,S,e),I=C[0];C[2]||z.push.apply(z,hr(C[1])),z.push(Se(I,1,c))}var q=tr(r,i,[d('sampleSourceLoader'),be({from:"stack",target:S})].concat(z,M,[Se(S),'fn'===x&&Me((function(e,r,n){return a(e,n.a)}),1),o&&Me(ve),d('sampleSourceUpward',k)]),e,o);return ie(t,[q]),Object.assign(q.meta,f,{joint:1}),i},hr=function(e){return[Se(e),xe((function(e,r,n){return n.a}),1)]},yr=function(e,r,n,t,i){var o=V(e),u=o?N(e):je(),s=je(o);return o||a({parent:e,node:[be({from:"stack",target:u}),be({from:"value",store:1,target:s})],family:{owners:[e,r,n],links:r},meta:{op:i},regional:1}),d('sampleSource',s,u,t),[u,s,o]},br=function(e,r,n,t){var a=e[r];a&&i({target:a,params:Array.isArray(a)?a.map((function(){return n})):n,defer:1,stack:t})},kr=function(e){return!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op},wr=function(e){return e};exports.allSettled=function(e,r){var n=void 0===r?{}:r,t=n.scope,a=n.params;if(!E(e))return Promise.reject(new Error('first argument should be unit'));if(!(T(e)||L(e)||V(e)||G(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));G(e)&&(t=e);var o=h();o.parentFork=Fe;var u=t.fxCount;J(u.scope.defers,o);var s=[],f=[];return G(e)||(J(s,e),J(f,T(e)?{params:a,req:{rs:function(e){o.value={status:'done',value:e}},rj:function(e){o.value={status:'fail',value:e}}}}:a)),J(s,u),J(f,null),i({target:s,params:f,scope:t}),o.req},exports.attach=function(e){var r,t,a=f(e,1);e=a[0];var o=s('attach',t=a[1]),c=e.source,d=e.effect,l=e.mapParams,p=e.domain;T(d)&&n(fe(p),'`domain` can only be used with a plain function',o);var v=y(e,t);D(v,'attached',1);var m,h,b=j(v).scope.runner,k=function(e,r,n){var t,a=e.params,o=e.req,u=e.handler,s=v.finally,f=lr(a,o,0,s,n),d=n.a,p=T(u),m=1;if(l){var g=dr(l,f,[a,d]);m=g[0],t=g[1]}else t=c&&p?d:a;if(m){if(!p)return e.args=[d,t],1;i({target:u,params:{params:t,req:{rs:lr(a,o,1,s,n),rj:f}},page:n.page,defer:1,meta:n.meta})}};c?(b.scope.runnerFn=k,V(c)?ie(h=c,[v]):(h=g(c),ie(v,[h])),m=[xe((function(e){return e}),0,1),Se(N(h))],delete b.seq[1].order):m=[xe(k,1,1)],(r=b.seq).splice.apply(r,[1,0].concat(m)),v.use(d);var w=q(d);return w&&(Object.assign(_(v),u(v.shortName,w)),v.defaultConfig.parent=w),ir(d,v,"effect"),v},exports.clearNode=rr,exports.combine=g,exports.createApi=function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];var a=f(n),i=a[0],o=i[0],u=i[1],s=a[1],c={};return e(u,(function(e,r){var n=c[r]=p(r,{parent:q(o),config:s});o.on(n,e),ir(o,n)})),c},exports.createDomain=function n(t,o){var u=Xe({or:o,and:'string'==typeof t?{name:t}:t}),s=a({family:{type:"domain"},regional:1,parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent)}),f={history:{},graphite:s,hooks:{}};s.meta=or("domain",f,{parent:(null==u?void 0:u.domain)||(null==u?void 0:u.parent),or:Object.assign({},u,{derived:1})}),e({Event:p,Effect:y,Store:m,Domain:n},(function(e,n){var t=n.toLowerCase(),a=p({named:"on"+n});f.hooks[t]=a;var o=new Set;f.history[t+"s"]=o,a.create=function(e){return i(a,e),e},J(j(a).seq,xe((function(e,r,n){return n.scope=null,e}))),a.watch((function(e){ie(f,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),q(e)||(e.parent=f)})),ie(f,[a]),f["onCreate"+n]=function(e){return r(o,e),a.watch(e)},f["create"+n]=f[t]=function(r,n){var t=Xe({and:n,or:r});return null!=t&&t.domain?e(r,n):a(e(r,{parent:f,or:t}))}}));var c=q(f);return c&&e(f.hooks,(function(e,r){return tr(e,c.hooks[r])})),null!=u&&u.domain&&u.domain.hooks.domain(f),f},exports.createEffect=y,exports.createEvent=p,exports.createNode=a,exports.createStore=m,exports.createWatch=function(e){var r=e.unit,n=e.fn,t=e.scope,i=e.batch,o=[Ae.run({fn:function(e){return n(e)}})];i&&o.unshift(Ae.compute({priority:'sampler',batch:1})),V(r)&&o.unshift(Ae.mov({store:r.stateRef,to:'stack'}));var u=Array.isArray(r)?r:[r];if(t){var s=[],f=t.additionalLinks;return u.forEach((function(e){var r=f[e.graphite.id]||[];f[e.graphite.id]=r;var n=a({node:S(o,e),meta:{watchOp:e.kind}});r.push(n),s.push((function(){var e=r.indexOf(n);-1!==e&&r.splice(e,1),rr(n)}))})),c((function(){s.forEach((function(e){return e()}))}))}var d=a({node:o,parent:u,family:{owners:u}});return c((function(){rr(d)}))},exports.fork=function(e,t){var i,o=e;W(e)&&(K(0,'fork(domain)','fork()'),i=e,o=t);var u=function(e){var n=a({scope:{defers:[],inFlight:0,fxID:0},node:[xe((function(e,r,n){n.parent?'dec'===n.parent.node.meta.needFxCounter?r.inFlight-=1:(r.inFlight+=1,r.fxID+=1):r.fxID+=1})),ke({priority:"sampler",batch:1}),xe((function(e,n){var t=n.defers,a=n.fxID;n.inFlight>0||0===t.length||Promise.resolve().then((function(){n.fxID===a&&r(t.splice(0,t.length),(function(e){Ge(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),t=a({node:[xe((function(e,r,n){var t=n.parent;if(t){var a=t.node;if(kr(t)){var i=F(n),o=a.meta.sid;i.sidIdMap[o]=a.scope.state.id,i.values.sidMap[o]=e;var u=a.meta.serialize;u&&i.sidSerializeSettings.set(o,'ignore'===u?{ignore:1}:{ignore:0,write:u.write})}}}))]}),i=a({node:[xe((function(e,r,n){var t=F(n);t&&n.parent&&kr(n.parent)&&(t.warnSerialize=1)}))]}),o={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState:function(e){if('current'in e)return $e(We,o,e,0).current;var r=j(e);return $e(We,o,r.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[n,t,i]},meta:{unit:'fork'},scope:{forkInFlightCounter:n}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:n,storeChange:t,warnSerializeNode:i};return o}(i);if(o){if(o.values){var s=x(o.values,(function(e){return n(V(e)&&B(e),'Values map can contain only writable stores as keys')})),f=s.unitMap,c=s.hasSidDoubles;Object.assign(u.values.sidMap,s.sidMap),r(f,(function(e,r){if(u.values.idMap[r.stateRef.id]=e,'ignore'===R(r,'serialize')){var n=R(r,'sid');u.sidSerializeSettings.set(n,{ignore:1})}})),u.fromSerialize=!(Array.isArray(o.values)||o.values instanceof Map),u.hasSidDoubles=c}o.handlers&&(K(o.handlers instanceof Map||Array.isArray(o.handlers),'object with handlers','array'),u.handlers=x(o.handlers,(function(e){return n(T(e),"Handlers map can contain only effects as keys")})))}return u},exports.forward=function(e){var r='forward',n=f(e,1),t=n[0],i=t.from,o=t.to,u=n[1],c=s(r,u);return K(0,r,'sample',c),le(i,c,'"from"'),le(o,c,'"to"'),pe(c,o,'to'),nr(a({parent:i,child:o,meta:{op:r,config:u},family:{},regional:1}))},exports.fromObservable=function(e){ce(e);var r=A in e?e[A]():e;n(r.subscribe,'expect observable to have .subscribe');var t=p(),a=nr(t);return r.subscribe({next:t,error:a,complete:a}),t},exports.guard=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var t=f(r),a=t[0],i=a[0],o=a[1],u=t[1],c=s('guard',u);return K(0,'guard','sample',c),o||(i=(o=i).source),k(o,c),gr('guard',o.clock,i,o.filter,o.target,null,o.name,u,!o.greedy,0,1)},exports.hydrate=function(e,t){var a=t.values;n(ue(a),'values property should be an object');var o=x(a),u=o.sidMap,s=o.unitMap,f=Object.getOwnPropertyNames(u),c={};r(s,(function(e,r){c[r.stateRef.id]=r}));var d,l,p,v=[],m=[];G(e)?(p=1,n((d=e).cloneOf,'scope should be created from domain'),K(0,'hydrate(fork(domain), { values })','fork({ values })'),l=j(d.cloneOf)):W(e)?(K(0,'hydrate(domain, { values })','fork({ values })'),l=j(e)):n(0,'first argument of hydrate should be domain or scope'),w(l,(function(e,r){if(r&&U(f,r)){J(v,e);var n=R(e,'serialize');n&&'ignore'!==n&&(u[r]=n.read(u[r])),J(m,u[r])}else e.scope.state.id in c&&(J(v,e),J(m,s.get(c[e.scope.state.id])))}),1),i({target:v,params:m,scope:d}),p&&Object.assign(d.values.sidMap,u)},exports.is=H,exports.launch=i,exports.merge=b,exports.restore=function(r,t,a){var i=s('restore',a);if(n(!V(r),'restore($store) is not supported',i),L(r)||T(r)){var o=q(r),u=m(t,{parent:o,name:r.shortName,and:a});return tr(T(r)?r.doneData:r,u),o&&o.hooks.store(u),u}var f=Array.isArray(r)?[]:{};return e(r,(function(e,r){return f[r]=V(e)?e:m(e,{name:r})})),f},exports.sample=function(){for(var e,r,n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];var i,o,u=f(t),c=u[0],d=c[0],l=c[1],p=c[2],v=u[1],m=1,g=s('sample',v);return fe(l)&&ue(d)&&k(d,g)&&(l=d.clock,p=d.fn,'batch'in d?m=d.batch:(K(!('greedy'in d),'greedy in sample','batch',g),m=!d.greedy),o=d.filter,e=d.target,r=d.name,i=d.sid,d=d.source),gr('sample',l,d,o,e,p,r,v,m,1,0,i)},exports.scopeBind=function(e,r){var t=void 0===r?{}:r,a=t.scope;n(a||Fe||t.safe,'scopeBind: scope not found');var o=a||Fe;return T(e)?function(r){var n=h();return i({target:e,params:{params:r,req:n},scope:o}),n.req}:function(r){return i({target:e,params:r,scope:o}),r}},exports.serialize=function(r,t){void 0===t&&(t={}),r.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!r.hasSidDoubles,'duplicate sid found in this scope');var a=t.ignore?t.ignore.map((function(e){return e.sid})):[],i={};return e(r.values.sidMap,(function(e,n){var t;if(!U(a,n)){var o=r.sidIdMap[n],u=null!==(t=r.sidSerializeSettings.get(n))&&void 0!==t?t:{ignore:0,write:wr};u.ignore||(i[n]=(0,u.write)(o&&o in r.reg?r.reg[o].current:e))}})),'onlyChanges'in t&&(K(0,'onlyChanges'),t.onlyChanges||(n(r.cloneOf,'scope should be created from domain'),w(j(r.cloneOf),(function(e,n){n in i||U(a,n)||R(e,'isCombine')||'ignore'===R(e,'serialize')||(i[n]=r.getState(e))})))),i},exports.setGraphInspector=function(e){M=e},exports.setInspector=function(e){Re=e},exports.setStoreName=function(e,r){e.shortName=r,Object.assign(_(e),u(r,q(e)))},exports.split=function(){for(var r,t,i='split',o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];var l=f(u),v=l[0],m=v[0],g=v[1],h=l[1],y=s(i,h),b=!g;b&&(r=m.cases,g=m.match,t=m.clock,m=m.source);var k=V(g),w=!E(g)&&se(g),x=!k&&!w&&ue(g);n(E(m),'source must be a unit',y),r||(r={}),b?e(r,(function(e,r){return pe(y,e,"cases."+r)})):(n(x,'match should be an object',y),e(g,(function(e,n){return r[n]=p({derived:1,named:"cases."+n,and:h})})),r.__=p({derived:1,named:'cases.__',and:h}));var S,M=new Set([].concat(m,t||[],Object.values(r))),A=Object.keys(k||w?r:g);if(k||w)k&&M.add(g),S=[k&&Se(N(g),0,1),ke({safe:k,filter:1,pure:!k,fn:function(e,r,n){var t=String(k?n.a:g(e));br(r,U(A,t)?t:'__',e,n)}})];else if(x){var j=je({});j.type='shape';var O,z=[];e(g,(function(e,r){if(E(e)){O=1,J(z,r),M.add(e);var n=tr(e,[],[Se(j),xe((function(e,n,t){return t.a[r]=e}))]);if(V(e)){j.current[r]=e.getState();var t=N(e);ze(j,{from:t,field:r,type:'field'}),d('splitMatchStore',t,n)}}})),O&&d('splitBase',j),S=[O&&Se(j,0,1),Me((function(e,r,n){for(var t=0;t<A.length;t++){var a=A[t];if(U(z,a)?n.a[a]:g[a](e))return void br(r,a,e,n)}br(r,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');var C=a({meta:{op:i},parent:t?[]:m,scope:r,node:S,family:{owners:Array.from(M)},regional:1});if(t&&gr(i,t,m,null,C,null,i,h,0,0,0),!b)return r},exports.step=Ae,exports.version="23.0.0",exports.withFactory=function(e){var r=e.sid,n=e.name,i=e.loc,o=e.method,u=e.fn;return t(a({meta:{sidRoot:ae(r),sid:r,name:n,loc:i,method:o,type:'factory'}}),u)},exports.withRegion=t; | ||
//# sourceMappingURL=compat.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e,t){for(const r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t,r){if(!e)throw Error(`${r?r+': ':''}${t}`)}function n(e,t){const r=M(e).meta||{};ee={id:M(e).id,parent:ee,value:e,template:r.template||re(),sidRoot:r.sidRoot||ee&&ee.sidRoot,meta:r};try{return t()}finally{te('region'),ee=C(ee)}}function a({node:e=[],from:r,source:n,parent:a=r||n,to:o,target:s,child:i=o||s,scope:c={},meta:l={},family:d={type:'regular'},regional:p}={}){const u=oe(a),f=oe(d.links),m=oe(d.owners),h=[];t(e,(e=>e&&H(h,e)));const g={id:X(),seq:h,next:oe(i),meta:l,scope:c,family:{type:d.type||"crosslink",links:f,owners:m}};return t(f,(e=>H($(e),g))),t(m,(e=>H(z(e),g))),t(u,(e=>H(e.next,g))),p&&ee&&ae(N(ee),[g]),g}function o(e,r,n){let a,o=Te,s=null,i=_e;if(e.target&&(r=e.params,n=e.defer,a=e.meta,o='page'in e?e.page:o,e.stack&&(s=e.stack),i=I(e)||i,e=e.target),i&&_e&&i!==_e&&(_e=null),Array.isArray(e))for(let t=0;t<e.length;t++)qe('pure',o,M(e[t]),s,r[t],i,a);else qe('pure',o,M(e),s,r,i,a);if(n&&!Ee)return;const c={isRoot:Ee,currentPage:Te,scope:_e,isWatch:Pe,isPure:Ve};let l,d,p,u,f,m;Ee=0;e:for(;u=Oe();){const{idx:e,stack:r,type:n}=u;p=r.node,Te=f=r.page,_e=I(r),f?m=f.reg:_e&&(m=_e.reg);const a=!!f,o=!!_e,s={fail:0,scope:p.scope};l=d=0;for(let t=e;t<p.seq.length&&!l;t++){const i=p.seq[t];if(i.order){const{priority:a,barrierID:o}=i.order,s=o?f?`${f.fullID}_${o}`:o:0;if(t!==e||n!==a){o?De.has(s)||(De.add(s),Fe(t,r,a,o)):Fe(t,r,a,0);continue e}o&&De.delete(s)}switch(i.type){case'mov':{const e=i.data;let t;switch(e.from){case'stack':t=N(r);break;case'a':case'b':t=r[e.from];break;case'value':t=e.store;break;case'store':if(m&&!m[e.store.id])if(a){const t=We(f,e.store.id);r.page=f=t,t?m=t.reg:o?(Je(_e,e.store,0,1,e.softRead),m=_e.reg):m=void 0}else o&&Je(_e,e.store,0,1,e.softRead);t=ze(m&&m[e.store.id]||e.store)}switch(e.to){case'stack':r.value=t;break;case'a':case'b':r[e.to]=t;break;case'store':Ge(f,_e,e.target,0).current=t}break}case'compute':const e=i.data;if(e.fn){Pe='watch'===p.meta.op,Ve=e.pure;const t=e.safe?(0,e.fn)(N(r),s.scope,r):Ke(s,e.fn,r);e.filter?d=!t:r.value=t,Pe=c.isWatch,Ve=c.isPure}}l=s.fail||d}if(He&&He(r,s),!l){const e=N(r),n=I(r);if(t(p.next,(t=>{qe('child',f,t,r,e,n)})),n){p.meta.needFxCounter&&qe('child',f,n.fxCount,r,e,n),p.meta.storeChange&&qe('child',f,n.storeChange,r,e,n),p.meta.warnSerialize&&qe('child',f,n.warnSerializeNode,r,e,n);const a=n.additionalLinks[p.id];a&&t(a,(t=>{qe('child',f,t,r,e,n)}))}}}Ee=c.isRoot,Te=c.currentPage,_e=I(c)}function s(t,r="combine"){let n=r+'(',a='',o=0;return e(t,(e=>{o<25&&(null!=e&&(n+=a,n+=R(e)?F(e).fullName:e.toString()),o+=1,a=', ')})),n+')'}function i(e,t){let r,n;const a=e;if(t){const a=F(t);0===e.length?(r=a.path,n=a.fullName):(r=a.path.concat([e]),n=0===a.fullName.length?e:a.fullName+'/'+e)}else r=0===e.length?[]:[e],n=e;return{shortName:a,fullName:n,path:r}}function c(e,t){if(!t)return e;if(!t.name&&!t.named&&!t.loc)return e;let r=`[${e}]`;const n=t.named||t.name;n&&(r+=` unit '${n}'`);const a=t.loc;return!n&&a&&(r+=` (${a.file}:${a.line}:${a.column})`),r}function l(e,t){const r=t?e:e[0];le(r);let n=r.or;const a=r.and;if(a){const r=t?a:a[0];if(se(r)&&'and'in r){const r=l(a,t);e=r[0],n={...n,...r[1]}}else e=a}return[e,n]}function d(e){const t=()=>e();return t.unsubscribe=()=>e(),t}function p(e,...t){const r=re();if(r){const n=r.handlers[e];if(n)return n(r,...t)}}function u(e,t){const n=Qe({or:t,and:'string'==typeof e?{name:e}:e}),s=c('event',n),i=(e,...t)=>(r(!O(i,'derived'),'call of derived event is not supported, use createEvent instead',s),r(!Ve,'unit call from pure function is not supported, use operators like sample instead',s),Te?((e,t,r,n)=>{const a=Te;let o=null;if(t)for(o=Te;o&&o.template!==t;)o=C(o);Le(o);const s=e.create(r,n);return Le(a),s})(i,l,e,t):i.create(e,t)),l=re(),d=Object.assign(i,{graphite:a({meta:ot(n.actualOp||"event",i,n),regional:1}),create:e=>(o({target:i,params:e,scope:_e}),e),watch:e=>nt(i,e),map:e=>st(i,"map",e,[Se()]),filter:e=>st(i,'filter',e.fn?e:e.fn,[Se(he,1)]),filterMap:e=>st(i,'filterMap',e,[Se(),xe((e=>!ce(e)),1)]),prepend(e){r(i.targetable,'.prepend of derived event is not supported, call source event instead',s);const t=u('* \u2192 '+i.shortName,{parent:C(i)});return p('eventPrepend',M(t)),rt(t,i,[Se()],'prepend',e),at(i,t),t}});return null!=n&&n.domain&&n.domain.hooks.event(d),q(d,'id',d.graphite.id),te(d.graphite),d}function f(e,n,a,o,s){return pe(a,`${s} ${n}`,'first argument'),r(ie(o),'second argument should be a function',s),U(!O(e,'derived'),`${n} in derived store`,`${n} in store created via createStore`,s),t(Array.isArray(a)?a:[a],(t=>{e.off(t),j(e).set(t,tt(lt(t,e,'on',me,o)))})),e}function m(e,n){const s=Qe(n),i=$e(e),l=c('store',s),d=u({named:'updates',derived:1});p('storeBase',i);const h=i.id,g='skipVoid'in s,y=g&&!s.skipVoid;U(!(g&&s.skipVoid),'{skipVoid: true}','updateFilter',l);const v={subscribers:new Map,updates:d,defaultState:e,stateRef:i,getState(){let e,t=i;if(Te){let t=Te;for(;t&&!t.reg[h];)t=C(t);t&&(e=t)}return!e&&_e&&(Je(_e,i,1),e=_e),e&&(t=e.reg[h]),ze(t)},setState:e=>o({target:v,params:e,defer:1,scope:_e}),reset:(...e)=>(r(v.targetable,'.reset of derived store is not supported',l),t(e,(e=>f(v,'.reset',e,(()=>v.defaultState),l))),v),on:(e,t)=>(r(v.targetable,'.on of derived store is not supported',l),f(v,'.on',e,t,l)),off(e){const t=j(v).get(e);return t&&(t(),j(v).delete(e)),v},map(e,t){let r,n;se(e)&&(r=e,e=e.fn);const a=v.getState(),o=ce(a);re()?n=null:(!o||o&&y)&&(n=e(a));const s=m(n,{name:`${v.shortName} \u2192 *`,derived:1,...t,and:r}),c=lt(v,s,"map",he,e);return Ae(A(s),{type:"map",fn:e,from:i}),A(s).noInit=1,p('storeMap',i,c),s},watch(e,t){if(U(!t,'watch second argument','sample',l),!t||!R(e)){const t=nt(v,e);return p('storeWatch',i,e)||e(v.getState()),t}return r(ie(t),'second argument should be a function',l),e.watch((e=>t(v.getState(),e)))}},b=ot("store",v,s),k=v.defaultConfig.updateFilter;v.graphite=a({scope:{state:i,fn:k},node:[xe(((e,t,r)=>(r.scope&&!r.scope.reg[i.id]&&(r.b=1),e))),we(i),xe(((e,t,{a:r,b:n})=>{const a=ce(e);return a&&!g&&console.error(`${l}: ${ct}`),(a&&y||!a)&&(e!==r||n)}),1),k&&Se(fe,1),ve({from:"stack",target:i})],child:d,meta:{...b,defaultState:e},regional:1}),q(v,'id',v.graphite.id),q(v,'rootStateRefId',h);const x=O(v,'serialize'),w=O(v,'derived'),S='ignore'===x,M=O(v,'sid');M&&(q(v,'storeChange',1),i.sid=M),M||S||w||q(v,'warnSerialize',1);const $=ce(e);return r(w||!$||$&&y,ct,l),w&&$&&!g&&console.error(`${l}: ${ct}`),ae(v,[d]),null!=s&&s.domain&&s.domain.hooks.store(v),w||(v.reinit=u({named:'reinit'}),v.reset(v.reinit)),i.meta=v.graphite.meta,te(v.graphite),v}function h(...e){let t,n,a;[e,a]=l(e);const o=c('combine',a),s=e[e.length-1],i=!_(s)&&se(s),d=i&&s,p=i?e[e.length-2]:s;let u,f,m;if(ie(p)?(n=e.slice(0,i?-2:-1),t=p):n=e,1===n.length){const e=n[0];_(e)||(u=e,f=1)}if(!f&&(u=n,t)){m=1;const e=t;t=t=>e(...t)}return r(se(u),`${o}: shape should be an object`),dt(Array.isArray(u),!m,u,a,t,d)}function g(){const e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function y(e,t={}){const n=Qe(ie(e)?{handler:e}:e,t),s=c('effect',n),i=u(ie(e)?{handler:e}:e,{...t,actualOp:"effect"}),l=M(i);q(l,'op',i.kind="effect"),i.use=e=>(r(ie(e),'.use argument should be a function',s),v.scope.handler=e,i),i.use.getCurrent=()=>v.scope.handler;const d=i.finally=u({named:'finally',derived:1}),p=i.done=d.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=i.fail=d.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),h=i.doneData=p.map({named:'doneData',fn:({result:e})=>e}),y=i.failData=f.map({named:'failData',fn:({error:e})=>e}),v=a({scope:{handler:i.defaultConfig.handler||(()=>r(0,`no handler used in ${i.compositeName.fullName}`))},node:[xe(((e,t,r)=>{let n=t.handler;const a=I(r);if(a){const e=a.handlers.unitMap.get(i)||a.handlers.sidMap[i.sid];e&&(n=e)}return e.handler=n,e}),0,1),xe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;const{params:n,req:a,handler:o,args:s=[n]}=e,i=ut(n,a,1,d,r),c=ut(n,a,0,d,r),[l,p]=pt(o,c,s);l&&(se(p)&&ie(p.then)?p.then(i,c):i(p))}),0,1)],meta:{op:'fx',fx:'runner'}});l.scope.runner=v,H(l.seq,xe(((e,{runner:t},r)=>{const n=C(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:Y()}),o({target:t,params:n,defer:1,scope:I(r),meta:r.meta}),n.params}))),i.create=e=>{const t=g(),r={params:e,req:t};if(_e&&!Pe){const e=_e;t.req.finally((()=>{Be(e)})).catch((()=>{}))}return o({target:i,params:r,scope:_e}),t.req};const b=i.inFlight=m(0,{serialize:'ignore',named:(O(i,'name')||i.graphite.id)+'.inFlight'}).on(i,(e=>e+1)).on(d,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(d,'needFxCounter','dec'),q(i,'needFxCounter',1);const k=i.pending=b.map({fn:e=>e>0,named:'pending'});return ae(i,[d,p,f,h,y,k,b]),null!=n&&n.domain&&n.domain.hooks.effect(i),i}function v(e,t){const r=c('merge',t);pe(e,r,'first argument');const n=u({name:s(e,'merge'),derived:1,and:t});return rt(e,n,[],'merge'),n}function b(e,n){let a=0;return t(mt,(t=>{t in e&&(r(null!=e[t],ht(n,t)),a=1)})),a}function k(e,r,n){const a=[];(function e(o){W(a,o)||(H(a,o),"store"===O(o,'op')&&(n||O(o,'sid'))&&r(o,O(o,'sid')),t(o.next,e),t($(o),e),t(z(o),e))})(e)}function x(e,n){const a=Array.isArray(e)?new Map(e):e,o=new Map;let s=0;if(a instanceof Map){const e={};return t(a,((t,a)=>{r(R(a),'Map key should be a unit'),n&&n(a,t),a.sid&&(a.sid in e&&(s=1),e[a.sid]=t),o.set(a,t)})),{sidMap:e,unitMap:o,hasSidDoubles:s}}return{sidMap:a,unitMap:o}}function w(e,t){return _(t)?[Me.mov({store:t.stateRef,to:'stack'}),...e]:e}Object.defineProperty(exports,'__esModule',{value:1});const S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M=e=>e.graphite||e,$=e=>e.family.owners,z=e=>e.family.links,A=e=>e.stateRef,N=e=>e.value,j=e=>e.subscribers,C=e=>e.parent,I=e=>e.scope,O=(e,t)=>M(e).meta[t],q=(e,t,r)=>M(e).meta[t]=r,F=e=>e.compositeName,R=e=>(ie(e)||se(e))&&'kind'in e,D=e=>t=>R(t)&&t.kind===e,_=D("store"),E=D("event"),P=D("effect"),V=e=>R(e)&&!!e.targetable,T=D("domain"),B=D("scope");var L={__proto__:null,unit:R,store:_,event:E,effect:P,targetable:V,domain:T,scope:B,attached:e=>P(e)&&1==O(e,'attached')};const W=(e,t)=>e.includes(t),G=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},H=(e,t)=>e.push(t),U=(e,t,r,n)=>!e&&console.error(`${n?n+': ':''}${t} is deprecated${r?`, use ${r} instead`:''}`),J=()=>{let e=0;return()=>""+ ++e},K=J(),Q=J(),X=J(),Y=J();let Z,ee=null;const te=e=>{Z&&Z(e,ee)},re=()=>ee&&ee.template,ne=e=>(e&&ee&&ee.sidRoot&&(e=`${ee.sidRoot}|${e}`),e),ae=(e,r)=>{const n=M(e);t(r,(e=>{const t=M(e);"domain"!==n.family.type&&(t.family.type="crosslink"),H($(t),n),H(z(n),t)}))},oe=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(M),se=e=>'object'==typeof e&&null!==e,ie=e=>'function'==typeof e,ce=e=>void 0===e,le=e=>r(se(e)||ie(e),'expect first argument be an object'),de=(e,t,n,a)=>r(!(!se(e)&&!ie(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${n} to be a unit (store, event or effect)${a}`),pe=(e,r,n)=>{Array.isArray(e)?t(e,((e,t)=>de(e,r,`${t} item of ${n}`,''))):de(e,r,n,' or array of units')},ue=(e,n,a="target")=>t(oe(n),(t=>r(!O(t,'derived'),`${e}: derived unit in "${a}" is not supported, use createStore/createEvent instead"`))),fe=(e,{fn:t},{a:r})=>t(e,r),me=(e,{fn:t},{a:r})=>t(r,e),he=(e,{fn:t})=>t(e),ge=(e,t,r,n)=>{const a={id:Q(),type:e,data:t};return r&&(a.order={priority:r},n&&(a.order.barrierID=++ye)),a};let ye=0;const ve=({from:e="store",store:t,target:r,to:n=(r?"store":"stack"),batch:a,priority:o})=>ge('mov',{from:e,store:t,to:n,target:r},o,a),be=({fn:e,batch:t,priority:r,safe:n=0,filter:a=0,pure:o=0})=>ge('compute',{fn:e,safe:n,filter:a,pure:o},r,t),ke=({fn:e})=>be({fn:e,priority:"effect"}),xe=(e,t,r)=>be({fn:e,safe:1,filter:t,priority:r&&"effect"}),we=(e,t,r)=>ve({store:e,to:t?"stack":"a",priority:r&&"sampler",batch:1}),Se=(e=he,t)=>be({fn:e,pure:1,filter:t}),Me={mov:ve,compute:be,filter:({fn:e,pure:t})=>be({fn:e,filter:1,pure:t}),run:ke},$e=e=>({id:Q(),current:e,initial:e}),ze=({current:e})=>e,Ae=(e,t)=>{e.before||(e.before=[]),H(e.before,t)};let Ne=null;const je=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Re(e.v.type)>Re(t.v.type))&&(r=e,e=t,t=r),r=je(e.r,t),e.r=e.l,e.l=r,e},Ce=[];let Ie=0;for(;Ie<6;)H(Ce,{first:null,last:null,size:0}),Ie+=1;const Oe=()=>{for(let e=0;e<6;e++){const t=Ce[e];if(t.size>0){if(3===e||4===e){t.size-=1;const e=Ne.v;return Ne=je(Ne.l,Ne.r),e}1===t.size&&(t.last=null);const r=t.first;return t.first=r.r,t.size-=1,r.v}}},qe=(e,t,r,n,a,o,s)=>Fe(0,{a:null,b:null,node:r,parent:n,value:a,page:t,scope:o,meta:s},e,0),Fe=(e,t,r,n)=>{const a=Re(r),o=Ce[a],s={v:{idx:e,stack:t,type:r,id:n},l:null,r:null};3===a||4===a?Ne=je(Ne,s):(0===o.size?o.first=s:o.last.r=s,o.last=s),o.size+=1},Re=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case'barrier':return 3;case'sampler':return 4;case'effect':return 5;default:return-1}},De=new Set;let _e,Ee=1,Pe=0,Ve=0,Te=null;const Be=e=>{_e=e},Le=e=>{Te=e},We=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=e.parent;if(e)return e}return null},Ge=(e,t,r,n)=>{const a=We(e,r.id);return a?a.reg[r.id]:t?(Je(t,r,n),t.reg[r.id]):r};let He;const Ue=e=>e,Je=(e,r,n,a,o)=>{const s=e.reg;if(s[r.id])return;const i=r.sid,c={id:r.id,current:r.initial,meta:r.meta};if(c.id in e.values.idMap)c.current=e.values.idMap[c.id];else if(i&&i in e.values.sidMap&&!(i in e.sidIdMap)){var l;const t=null==r||null===(l=r.meta)||void 0===l?void 0:l.serialize;c.current=(e.fromSerialize&&'ignore'!==t&&(null==t?void 0:t.read)||Ue)(e.values.sidMap[i])}else if(r.before&&!o){let o=0;const i=n||!r.noInit||a;t(r.before,(t=>{switch(t.type){case'map':{const r=t.from;if((r||t.fn)&&(r&&Je(e,r,n,a),i)){const e=r&&s[r.id].current;c.current=t.fn?t.fn(e):e}break}case'field':Je(e,t.from,n,a),o||(o=1,c.current=Array.isArray(c.current)?[...c.current]:{...c.current}),i&&(c.current[t.field]=s[s[t.from.id].id].current)}}))}i&&(e.sidIdMap[i]=r.id),s[r.id]=c},Ke=(e,t,r)=>{try{return t(N(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Qe=(t,r={})=>(se(t)&&(Qe(t.or,r),e(t,((e,t)=>{ce(e)||'or'===t||'and'===t||(r[t]=e)})),Qe(t.and,r)),r),Xe=(e,t)=>{G(e.next,t),G($(e),t),G(z(e),t)},Ye=(e,t,r)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let a=z(e);for(;n=a.pop();)Xe(n,e),(t||r&&'sample'!==e.meta.op||"crosslink"===n.family.type)&&Ye(n,t,'on'!==n.meta.op&&r);for(a=$(e);n=a.pop();)Xe(n,e),r&&"crosslink"===n.family.type&&Ye(n,t,'on'!==n.meta.op&&r)},Ze=e=>e.clear(),et=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),_(e))Ze(j(e));else if(T(e)){r=1;const t=e.history;Ze(t.events),Ze(t.effects),Ze(t.stores),Ze(t.domains)}Ye(M(e),!!t,r)},tt=e=>d((()=>et(e))),rt=(e,t,r,n,o)=>a({node:r,parent:e,child:t,scope:{fn:o},meta:{op:n},family:{owners:[e,t],links:t},regional:1}),nt=(e,t)=>(r(ie(t),'.watch argument should be a function'),tt(a({scope:{fn:t},node:[ke({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),at=(e,t,r="event")=>{C(e)&&C(e).hooks[r](t)},ot=(e,t,r)=>{const n=Qe(r),a="domain"===e,o=K(),{sid:s=null,named:c=null,domain:l=null,parent:d=l}=n,p=c||n.name||(a?'':o),u=i(p,d),f={op:t.kind=e,name:t.shortName=p,sid:t.sid=ne(s),named:c,unitId:t.id=o,serialize:n.serialize,derived:n.derived,config:n};if(t.targetable=!n.derived,t.parent=d,t.compositeName=u,t.defaultConfig=n,t.getType=()=>(U(0,'getType','compositeName.fullName'),u.fullName),!a){t.subscribe=e=>(le(e),t.watch(ie(e)?e:t=>e.next&&e.next(t))),t[S]=()=>t;const e=re();e&&(f.nativeTemplate=e)}return f},st=(e,t,r,n)=>{let a;se(r)&&(a=r,r=r.fn);const o=u({name:`${e.shortName} \u2192 *`,derived:1,and:a});return rt(e,o,n,t,r),o},ct='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',lt=(e,t,r,n,a)=>{const o=A(t),s=ve({store:o,to:"a",priority:'read'});"map"===r&&(s.data.softRead=1);const i=[s,Se(n)];return p('storeOnMap',o,i,_(e)&&A(e)),rt(e,t,i,r,a)},dt=(t,n,a,o,i,l)=>{const d=c('combine',o),u=t?e=>[...e]:e=>({...e}),f=t?[]:{},h=u(f),g=$e(h),y=$e(1);g.type=t?'list':'shape',g.noInit=1,p('combineBase',g,y);const v=m(h,{name:s(a),derived:1,...l,and:o}),b=A(v);b.noInit=1,q(v,'isCombine',1);const k=we(g);k.order={priority:'barrier'};const x=ve({store:b,to:'b',priority:'read'});x.data.softRead=1;const w=[xe(((e,t,r)=>(r.scope&&!r.scope.reg[g.id]&&(r.c=1),e))),k,ve({store:y,to:'b'}),xe(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return n&&r.b&&(r.a=u(r.a)),r.a[t]=e,1}),1),ve({from:"a",target:g}),ve({from:"value",store:0,target:y}),ve({from:"value",store:1,target:y,priority:'barrier',batch:1}),we(g,1,1),i&&Se(),x];if(e(a,((e,t)=>{if(!_(e))return r(!R(e)&&!ce(e),`combine expects a store in a field ${t}`,d),void(h[t]=f[t]=e);f[t]=e.defaultState,h[t]=e.getState();const n=rt(e,v,w,'combine',i);n.scope.key=t;const a=A(e);Ae(g,{type:'field',field:t,from:a}),p('combineField',a,n)})),v.defaultShape=a,Ae(b,{type:"map",from:g,fn:i}),!re())if(i){const e=i(h);!ce(e)||l&&'skipVoid'in l||console.error(`${d}: ${ct}`),b.current=e,b.initial=e,v.defaultState=e}else v.defaultState=f;return v},pt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ut=(e,t,r,n,a)=>s=>{o({target:[n,ft],params:[r?{status:'done',params:e,result:s}:{status:'fail',params:e,error:s},{value:s,fn:r?t.rs:t.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})},ft=a({node:[ke({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),mt=['source','clock','target'],ht=(e,t)=>e+`: ${t} should be defined`,gt=(e,t,n,a,o,s,i,l,d,f,g,y)=>{const b=c(e,l),k=!!o;r(!ce(n)||!ce(t),ht(b,'either source or clock'));let x=0;ce(n)?x=1:R(n)||(n=h(n)),ce(t)?t=n:(pe(t,b,'clock'),Array.isArray(t)&&(t=v(t))),x&&(n=t),l||i||(i=n.shortName);let w='none';(g||a)&&(R(a)?w='unit':(r(ie(a),'`filter` should be function or unit'),w='fn')),o?(pe(o,b,'target'),ue(b,o)):'none'===w&&f&&_(n)&&_(t)?o=m(s?s(ze(A(n)),ze(A(t))):ze(A(n)),{name:i,sid:y,or:l}):(o=u({name:i,derived:1,or:l}),p('sampleTarget',M(o)));const S=$e();let $=[];if('unit'===w){const[r,n,s]=vt(a,o,t,S,e);s||$.push(...yt(n)),$.push(...yt(r))}const z=[];if(x)d&&z.push(we(S,1,1));else{const[r,a,s]=vt(n,o,t,S,e);s||z.push(...yt(a)),z.push(we(r,1,d))}const N=rt(t,o,[p('sampleSourceLoader'),ve({from:"stack",target:S}),...z,...$,we(S),'fn'===w&&Se(((e,t,{a:r})=>a(e,r)),1),s&&Se(fe),p('sampleSourceUpward',k)],e,s);return ae(n,[N]),Object.assign(N.meta,l,{joint:1}),o},yt=e=>[we(e),xe(((e,t,{a:r})=>r),1)],vt=(e,t,r,n,o)=>{const s=_(e),i=s?A(e):$e(),c=$e(s);return s||a({parent:e,node:[ve({from:"stack",target:i}),ve({from:"value",store:1,target:c})],family:{owners:[e,t,r],links:t},meta:{op:o},regional:1}),p('sampleSource',c,i,n),[i,c,s]},bt=(e,t,r,n)=>{const a=e[t];a&&o({target:a,params:Array.isArray(a)?a.map((()=>r)):r,defer:1,stack:n})},kt=e=>!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op,xt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!R(e))return Promise.reject(new Error('first argument should be unit'));if(!(P(e)||E(e)||_(e)||B(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));B(e)&&(t=e);const n=g();n.parentFork=_e;const{fxCount:a}=t;H(a.scope.defers,n);const s=[],i=[];return B(e)||(H(s,e),H(i,P(e)?{params:r,req:{rs(e){n.value={status:'done',value:e}},rj(e){n.value={status:'fail',value:e}}}}:r)),H(s,a),H(i,null),o({target:s,params:i,scope:t}),n.req},exports.attach=e=>{let t;[e,t]=l(e,1);const n=c('attach',t);let{source:a,effect:s,mapParams:d,domain:p}=e;P(s)&&r(ce(p),'`domain` can only be used with a plain function',n);const u=y(e,t);q(u,'attached',1);const{runner:f}=M(u).scope;let m;const g=(e,t,r)=>{const{params:n,req:s,handler:i}=e,c=u.finally,l=ut(n,s,0,c,r),p=r.a,f=P(i);let m,h=1;if(d?[h,m]=pt(d,l,[n,p]):m=a&&f?p:n,h){if(!f)return e.args=[p,m],1;o({target:i,params:{params:m,req:{rs:ut(n,s,1,c,r),rj:l}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;f.scope.runnerFn=g,_(a)?(e=a,ae(e,[u])):(e=h(a),ae(u,[e])),m=[xe((e=>e),0,1),we(A(e))],delete f.seq[1].order}else m=[xe(g,1,1)];f.seq.splice(1,0,...m),u.use(s);const v=C(s);return v&&(Object.assign(F(u),i(u.shortName,v)),u.defaultConfig.parent=v),at(s,u,"effect"),u},exports.clearNode=et,exports.combine=h,exports.createApi=(...t)=>{let[[r,n],a]=l(t);const o={};return e(n,((e,t)=>{const n=o[t]=u(t,{parent:C(r),config:a});r.on(n,e),at(r,n)})),o},exports.createDomain=function r(n,s){const i=Qe({or:s,and:'string'==typeof n?{name:n}:n}),c=a({family:{type:"domain"},regional:1,parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent)}),l={history:{},graphite:c,hooks:{}};c.meta=ot("domain",l,{parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent),or:{...i,derived:1}}),e({Event:u,Effect:y,Store:m,Domain:r},((e,r)=>{const n=r.toLowerCase(),a=u({named:`on${r}`});l.hooks[n]=a;const s=new Set;l.history[`${n}s`]=s,a.create=e=>(o(a,e),e),H(M(a).seq,xe(((e,t,r)=>(r.scope=null,e)))),a.watch((e=>{ae(l,[e]),s.add(e),e.ownerSet||(e.ownerSet=s),C(e)||(e.parent=l)})),ae(l,[a]),l[`onCreate${r}`]=e=>(t(s,e),a.watch(e)),l[`create${r}`]=l[n]=(t,r)=>{const n=Qe({and:r,or:t});return null!=n&&n.domain?e(t,r):a(e(t,{parent:l,or:n}))}}));const d=C(l);return d&&e(l.hooks,((e,t)=>rt(e,d.hooks[t]))),null!=i&&i.domain&&i.domain.hooks.domain(l),l},exports.createEffect=y,exports.createEvent=u,exports.createNode=a,exports.createStore=m,exports.createWatch=({unit:e,fn:t,scope:r,batch:n})=>{const o=[Me.run({fn:e=>t(e)})];n&&o.unshift(Me.compute({priority:'sampler',batch:1})),_(e)&&o.unshift(Me.mov({store:e.stateRef,to:'stack'}));const s=Array.isArray(e)?e:[e];if(r){const e=[],t=r.additionalLinks;return s.forEach((r=>{const n=t[r.graphite.id]||[];t[r.graphite.id]=n;const s=a({node:w(o,r),meta:{watchOp:r.kind}});n.push(s),e.push((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),et(s)}))})),d((()=>{e.forEach((e=>e()))}))}{const e=a({node:o,parent:s,family:{owners:s}});return d((()=>{et(e)}))}},exports.fork=(e,n)=>{let o,s=e;T(e)&&(U(0,'fork(domain)','fork()'),o=e,s=n);const i=(e=>{const r=a({scope:{defers:[],inFlight:0,fxID:0},node:[xe(((e,t,r)=>{r.parent?'dec'===r.parent.node.meta.needFxCounter?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),be({priority:"sampler",batch:1}),xe(((e,r)=>{const{defers:n,fxID:a}=r;r.inFlight>0||0===n.length||Promise.resolve().then((()=>{r.fxID===a&&t(n.splice(0,n.length),(e=>{Be(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),n=a({node:[xe(((e,t,r)=>{const n=r.parent;if(n){const t=n.node;if(kt(n)){const n=I(r),a=t.meta.sid;n.sidIdMap[a]=t.scope.state.id,n.values.sidMap[a]=e;const o=t.meta.serialize;o&&n.sidSerializeSettings.set(a,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),o=a({node:[xe(((e,t,r)=>{const n=I(r);n&&r.parent&&kt(r.parent)&&(n.warnSerialize=1)}))]}),s={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return Ge(Te,s,e,0).current;const t=M(e);return Ge(Te,s,t.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[r,n,o]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:n,warnSerializeNode:o};return s})(o);if(s){if(s.values){const{sidMap:e,unitMap:n,hasSidDoubles:a}=x(s.values,(e=>r(_(e)&&V(e),'Values map can contain only writable stores as keys')));Object.assign(i.values.sidMap,e),t(n,((e,t)=>{if(i.values.idMap[t.stateRef.id]=e,'ignore'===O(t,'serialize')){const e=O(t,'sid');i.sidSerializeSettings.set(e,{ignore:1})}})),i.fromSerialize=!(Array.isArray(s.values)||s.values instanceof Map),i.hasSidDoubles=a}s.handlers&&(U(s.handlers instanceof Map||Array.isArray(s.handlers),'object with handlers','array'),i.handlers=x(s.handlers,(e=>r(P(e),"Handlers map can contain only effects as keys"))))}return i},exports.forward=e=>{const t='forward',[{from:r,to:n},o]=l(e,1),s=c(t,o);return U(0,t,'sample',s),pe(r,s,'"from"'),pe(n,s,'"to"'),ue(s,n,'to'),tt(a({parent:r,child:n,meta:{op:t,config:o},family:{},regional:1}))},exports.fromObservable=e=>{le(e);const t=S in e?e[S]():e;r(t.subscribe,'expect observable to have .subscribe');const n=u(),a=tt(n);return t.subscribe({next:n,error:a,complete:a}),n},exports.guard=(...e)=>{let[[t,r],n]=l(e);const a=c('guard',n);return U(0,'guard','sample',a),r||(r=t,t=r.source),b(r,a),gt('guard',r.clock,t,r.filter,r.target,null,r.name,n,!r.greedy,0,1)},exports.hydrate=(e,{values:n})=>{r(se(n),'values property should be an object');const{sidMap:a,unitMap:s}=x(n),i=Object.getOwnPropertyNames(a),c={};t(s,((e,t)=>{c[t.stateRef.id]=t}));const l=[],d=[];let p,u,f;B(e)?(p=e,f=1,r(p.cloneOf,'scope should be created from domain'),U(0,'hydrate(fork(domain), { values })','fork({ values })'),u=M(p.cloneOf)):T(e)?(U(0,'hydrate(domain, { values })','fork({ values })'),u=M(e)):r(0,'first argument of hydrate should be domain or scope'),k(u,((e,t)=>{if(t&&W(i,t)){H(l,e);const r=O(e,'serialize');r&&'ignore'!==r&&(a[t]=r.read(a[t])),H(d,a[t])}else e.scope.state.id in c&&(H(l,e),H(d,s.get(c[e.scope.state.id])))}),1),o({target:l,params:d,scope:p}),f&&Object.assign(p.values.sidMap,a)},exports.is=L,exports.launch=o,exports.merge=v,exports.restore=(t,r,n)=>{const a=c('restore',n);if(_(t))return U(0,'restore($store)',void 0,a),t;if(E(t)||P(t)){const e=C(t),a=m(r,{parent:e,name:t.shortName,and:n});return rt(P(t)?t.doneData:t,a),e&&e.hooks.store(a),a}const o=Array.isArray(t)?[]:{};return e(t,((e,t)=>o[t]=_(e)?e:m(e,{name:t}))),o},exports.sample=(...e)=>{let t,r,n,a,[[o,s,i],d]=l(e),p=1;const u=c('sample',d);return ce(s)&&se(o)&&b(o,u)&&(s=o.clock,i=o.fn,'batch'in o?p=o.batch:(U(!('greedy'in o),'greedy in sample','batch',u),p=!o.greedy),a=o.filter,t=o.target,r=o.name,n=o.sid,o=o.source),gt('sample',s,o,a,t,i,r,d,p,1,0,n)},exports.scopeBind=(e,{scope:t,safe:n}={})=>{r(t||_e||n,'scopeBind: scope not found');const a=t||_e;return P(e)?t=>{const r=g();return o({target:e,params:{params:t,req:r},scope:a}),r.req}:t=>(o({target:e,params:t,scope:a}),t)},exports.serialize=(t,n={})=>{t.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),r(!t.hasSidDoubles,'duplicate sid found in this scope');const a=n.ignore?n.ignore.map((({sid:e})=>e)):[],o={};return e(t.values.sidMap,((e,r)=>{var n;if(W(a,r))return;const s=t.sidIdMap[r],i=null!==(n=t.sidSerializeSettings.get(r))&&void 0!==n?n:{ignore:0,write:xt};i.ignore||(o[r]=(0,i.write)(s&&s in t.reg?t.reg[s].current:e))})),'onlyChanges'in n&&(U(0,'onlyChanges'),n.onlyChanges||(r(t.cloneOf,'scope should be created from domain'),k(M(t.cloneOf),((e,r)=>{r in o||W(a,r)||O(e,'isCombine')||'ignore'===O(e,'serialize')||(o[r]=t.getState(e))})))),o},exports.setGraphInspector=e=>{Z=e},exports.setInspector=e=>{He=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(F(e),i(t,C(e)))},exports.split=(...t)=>{const n='split';let o,s,[[i,d],f]=l(t);const m=c(n,f),h=!d;h&&(o=i.cases,d=i.match,s=i.clock,i=i.source);const g=_(d),y=!R(d)&&ie(d),v=!g&&!y&&se(d);r(R(i),'source must be a unit',m),o||(o={}),h?e(o,((e,t)=>ue(m,e,`cases.${t}`))):(r(v,'match should be an object',m),e(d,((e,t)=>o[t]=u({derived:1,named:`cases.${t}`,and:f}))),o.__=u({derived:1,named:'cases.__',and:f}));const b=new Set([].concat(i,s||[],Object.values(o))),k=Object.keys(g||y?o:d);let x;if(g||y)g&&b.add(d),x=[g&&we(A(d),0,1),be({safe:g,filter:1,pure:!g,fn(e,t,r){const n=String(g?r.a:d(e));bt(t,W(k,n)?n:'__',e,r)}})];else if(v){const t=$e({});t.type='shape';const r=[];let n;e(d,((e,a)=>{if(R(e)){n=1,H(r,a),b.add(e);const o=rt(e,[],[we(t),xe(((e,t,{a:r})=>r[a]=e))]);if(_(e)){t.current[a]=e.getState();const r=A(e);Ae(t,{from:r,field:a,type:'field'}),p('splitMatchStore',r,o)}}})),n&&p('splitBase',t),x=[n&&we(t,0,1),Se(((e,t,n)=>{for(let a=0;a<k.length;a++){const o=k[a];if(W(r,o)?n.a[o]:d[o](e))return void bt(t,o,e,n)}bt(t,'__',e,n)}),1)]}else r(0,'expect match to be unit, function or object');const w=a({meta:{op:n},parent:s?[]:i,scope:o,node:x,family:{owners:Array.from(b)},regional:1});if(s&>(n,s,i,null,w,null,n,f,0,0,0),!h)return o},exports.step=Me,exports.version="23.0.0-rc.6",exports.withFactory=({sid:e,name:t,loc:r,method:o,fn:s})=>n(a({meta:{sidRoot:ne(e),sid:e,name:t,loc:r,method:o,type:'factory'}}),s),exports.withRegion=n; | ||
function e(e,t){for(const r in e)t(e[r],r)}function t(e,t){e.forEach(t)}function r(e,t,r){if(!e)throw Error(`${r?r+': ':''}${t}`)}function n(e,t){const r=M(e).meta||{};ee={id:M(e).id,parent:ee,value:e,template:r.template||re(),sidRoot:r.sidRoot||ee&&ee.sidRoot,meta:r};try{return t()}finally{te('region'),ee=C(ee)}}function a({node:e=[],from:r,source:n,parent:a=r||n,to:o,target:s,child:i=o||s,scope:c={},meta:l={},family:d={type:'regular'},regional:p}={}){const u=oe(a),f=oe(d.links),m=oe(d.owners),h=[];t(e,(e=>e&&H(h,e)));const g={id:X(),seq:h,next:oe(i),meta:l,scope:c,family:{type:d.type||"crosslink",links:f,owners:m}};return t(f,(e=>H($(e),g))),t(m,(e=>H(z(e),g))),t(u,(e=>H(e.next,g))),p&&ee&&ae(N(ee),[g]),g}function o(e,r,n){let a,o=Te,s=null,i=_e;if(e.target&&(r=e.params,n=e.defer,a=e.meta,o='page'in e?e.page:o,e.stack&&(s=e.stack),i=I(e)||i,e=e.target),i&&_e&&i!==_e&&(_e=null),Array.isArray(e))for(let t=0;t<e.length;t++)qe('pure',o,M(e[t]),s,r[t],i,a);else qe('pure',o,M(e),s,r,i,a);if(n&&!Ee)return;const c={isRoot:Ee,currentPage:Te,scope:_e,isWatch:Pe,isPure:Ve};let l,d,p,u,f,m;Ee=0;e:for(;u=Oe();){const{idx:e,stack:r,type:n}=u;p=r.node,Te=f=r.page,_e=I(r),f?m=f.reg:_e&&(m=_e.reg);const a=!!f,o=!!_e,s={fail:0,scope:p.scope};l=d=0;for(let t=e;t<p.seq.length&&!l;t++){const i=p.seq[t];if(i.order){const{priority:a,barrierID:o}=i.order,s=o?f?`${f.fullID}_${o}`:o:0;if(t!==e||n!==a){o?De.has(s)||(De.add(s),Fe(t,r,a,o)):Fe(t,r,a,0);continue e}o&&De.delete(s)}switch(i.type){case'mov':{const e=i.data;let t;switch(e.from){case'stack':t=N(r);break;case'a':case'b':t=r[e.from];break;case'value':t=e.store;break;case'store':if(m&&!m[e.store.id])if(a){const t=We(f,e.store.id);r.page=f=t,t?m=t.reg:o?(Je(_e,e.store,0,1,e.softRead),m=_e.reg):m=void 0}else o&&Je(_e,e.store,0,1,e.softRead);t=ze(m&&m[e.store.id]||e.store)}switch(e.to){case'stack':r.value=t;break;case'a':case'b':r[e.to]=t;break;case'store':Ge(f,_e,e.target,0).current=t}break}case'compute':const e=i.data;if(e.fn){Pe='watch'===p.meta.op,Ve=e.pure;const t=e.safe?(0,e.fn)(N(r),s.scope,r):Ke(s,e.fn,r);e.filter?d=!t:r.value=t,Pe=c.isWatch,Ve=c.isPure}}l=s.fail||d}if(He&&He(r,s),!l){const e=N(r),n=I(r);if(t(p.next,(t=>{qe('child',f,t,r,e,n)})),n){p.meta.needFxCounter&&qe('child',f,n.fxCount,r,e,n),p.meta.storeChange&&qe('child',f,n.storeChange,r,e,n),p.meta.warnSerialize&&qe('child',f,n.warnSerializeNode,r,e,n);const a=n.additionalLinks[p.id];a&&t(a,(t=>{qe('child',f,t,r,e,n)}))}}}Ee=c.isRoot,Te=c.currentPage,_e=I(c)}function s(t,r="combine"){let n=r+'(',a='',o=0;return e(t,(e=>{o<25&&(null!=e&&(n+=a,n+=R(e)?F(e).fullName:e.toString()),o+=1,a=', ')})),n+')'}function i(e,t){let r,n;const a=e;if(t){const a=F(t);0===e.length?(r=a.path,n=a.fullName):(r=a.path.concat([e]),n=0===a.fullName.length?e:a.fullName+'/'+e)}else r=0===e.length?[]:[e],n=e;return{shortName:a,fullName:n,path:r}}function c(e,t){if(!t)return e;if(!t.name&&!t.named&&!t.loc)return e;let r=`[${e}]`;const n=t.named||t.name;n&&(r+=` unit '${n}'`);const a=t.loc;return!n&&a&&(r+=` (${a.file}:${a.line}:${a.column})`),r}function l(e,t){const r=t?e:e[0];le(r);let n=r.or;const a=r.and;if(a){const r=t?a:a[0];if(se(r)&&'and'in r){const r=l(a,t);e=r[0],n={...n,...r[1]}}else e=a}return[e,n]}function d(e){const t=()=>e();return t.unsubscribe=()=>e(),t}function p(e,...t){const r=re();if(r){const n=r.handlers[e];if(n)return n(r,...t)}}function u(e,t){const n=Qe({or:t,and:'string'==typeof e?{name:e}:e}),s=c('event',n),i=(e,...t)=>(r(!O(i,'derived'),'call of derived event is not supported, use createEvent instead',s),r(!Ve,'unit call from pure function is not supported, use operators like sample instead',s),Te?((e,t,r,n)=>{const a=Te;let o=null;if(t)for(o=Te;o&&o.template!==t;)o=C(o);Le(o);const s=e.create(r,n);return Le(a),s})(i,l,e,t):i.create(e,t)),l=re(),d=Object.assign(i,{graphite:a({meta:ot(n.actualOp||"event",i,n),regional:1}),create:e=>(o({target:i,params:e,scope:_e}),e),watch:e=>nt(i,e),map:e=>st(i,"map",e,[Se()]),filter:e=>st(i,'filter',e.fn?e:e.fn,[Se(he,1)]),filterMap:e=>st(i,'filterMap',e,[Se(),xe((e=>!ce(e)),1)]),prepend(e){r(i.targetable,'.prepend of derived event is not supported, call source event instead',s);const t=u('* \u2192 '+i.shortName,{parent:C(i)});return p('eventPrepend',M(t)),rt(t,i,[Se()],'prepend',e),at(i,t),t}});return null!=n&&n.domain&&n.domain.hooks.event(d),q(d,'id',d.graphite.id),te(d.graphite),d}function f(e,n,a,o,s){return pe(a,`${s} ${n}`,'first argument'),r(ie(o),'second argument should be a function',s),U(!O(e,'derived'),`${n} in derived store`,`${n} in store created via createStore`,s),t(Array.isArray(a)?a:[a],(t=>{e.off(t),j(e).set(t,tt(lt(t,e,'on',me,o)))})),e}function m(e,n){const s=Qe(n),i=$e(e),l=c('store',s),d=u({named:'updates',derived:1});p('storeBase',i);const h=i.id,g='skipVoid'in s,y=g&&!s.skipVoid;U(!(g&&s.skipVoid),'{skipVoid: true}','updateFilter',l);const v={subscribers:new Map,updates:d,defaultState:e,stateRef:i,getState(){let e,t=i;if(Te){let t=Te;for(;t&&!t.reg[h];)t=C(t);t&&(e=t)}return!e&&_e&&(Je(_e,i,1),e=_e),e&&(t=e.reg[h]),ze(t)},setState:e=>o({target:v,params:e,defer:1,scope:_e}),reset:(...e)=>(r(v.targetable,'.reset of derived store is not supported',l),t(e,(e=>f(v,'.reset',e,(()=>v.defaultState),l))),v),on:(e,t)=>(r(v.targetable,'.on of derived store is not supported',l),f(v,'.on',e,t,l)),off(e){const t=j(v).get(e);return t&&(t(),j(v).delete(e)),v},map(e,t){let r,n;se(e)&&(r=e,e=e.fn);const a=v.getState(),o=ce(a);re()?n=null:(!o||o&&y)&&(n=e(a));const s=m(n,{name:`${v.shortName} \u2192 *`,derived:1,...t,and:r}),c=lt(v,s,"map",he,e);return Ae(A(s),{type:"map",fn:e,from:i}),A(s).noInit=1,p('storeMap',i,c),s},watch(e,t){if(U(!t,'watch second argument','sample',l),!t||!R(e)){const t=nt(v,e);return p('storeWatch',i,e)||e(v.getState()),t}return r(ie(t),'second argument should be a function',l),e.watch((e=>t(v.getState(),e)))}},b=ot("store",v,s),k=v.defaultConfig.updateFilter;v.graphite=a({scope:{state:i,fn:k},node:[xe(((e,t,r)=>(r.scope&&!r.scope.reg[i.id]&&(r.b=1),e))),we(i),xe(((e,t,{a:r,b:n})=>{const a=ce(e);return a&&!g&&console.error(`${l}: ${ct}`),(a&&y||!a)&&(e!==r||n)}),1),k&&Se(fe,1),ve({from:"stack",target:i})],child:d,meta:{...b,defaultState:e},regional:1}),q(v,'id',v.graphite.id),q(v,'rootStateRefId',h);const x=O(v,'serialize'),w=O(v,'derived'),S='ignore'===x,M=O(v,'sid');M&&(q(v,'storeChange',1),i.sid=M),M||S||w||q(v,'warnSerialize',1);const $=ce(e);return r(w||!$||$&&y,ct,l),w&&$&&!g&&console.error(`${l}: ${ct}`),ae(v,[d]),null!=s&&s.domain&&s.domain.hooks.store(v),w||(v.reinit=u({named:'reinit'}),v.reset(v.reinit)),i.meta=v.graphite.meta,te(v.graphite),v}function h(...e){let t,n,a;[e,a]=l(e);const o=c('combine',a),s=e[e.length-1],i=!_(s)&&se(s),d=i&&s,p=i?e[e.length-2]:s;let u,f,m;if(ie(p)?(n=e.slice(0,i?-2:-1),t=p):n=e,1===n.length){const e=n[0];_(e)||(u=e,f=1)}if(!f&&(u=n,t)){m=1;const e=t;t=t=>e(...t)}return r(se(u),`${o}: shape should be an object`),dt(Array.isArray(u),!m,u,a,t,d)}function g(){const e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function y(e,t={}){const n=Qe(ie(e)?{handler:e}:e,t),s=c('effect',n),i=u(ie(e)?{handler:e}:e,{...t,actualOp:"effect"}),l=M(i);q(l,'op',i.kind="effect"),i.use=e=>(r(ie(e),'.use argument should be a function',s),v.scope.handler=e,i),i.use.getCurrent=()=>v.scope.handler;const d=i.finally=u({named:'finally',derived:1}),p=i.done=d.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=i.fail=d.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),h=i.doneData=p.map({named:'doneData',fn:({result:e})=>e}),y=i.failData=f.map({named:'failData',fn:({error:e})=>e}),v=a({scope:{handler:i.defaultConfig.handler||(()=>r(0,`no handler used in ${i.compositeName.fullName}`))},node:[xe(((e,t,r)=>{let n=t.handler;const a=I(r);if(a){const e=a.handlers.unitMap.get(i)||a.handlers.sidMap[i.sid];e&&(n=e)}return e.handler=n,e}),0,1),xe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;const{params:n,req:a,handler:o,args:s=[n]}=e,i=ut(n,a,1,d,r),c=ut(n,a,0,d,r),[l,p]=pt(o,c,s);l&&(se(p)&&ie(p.then)?p.then(i,c):i(p))}),0,1)],meta:{op:'fx',fx:'runner'}});l.scope.runner=v,H(l.seq,xe(((e,{runner:t},r)=>{const n=C(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:Y()}),o({target:t,params:n,defer:1,scope:I(r),meta:r.meta}),n.params}))),i.create=e=>{const t=g(),r={params:e,req:t};if(_e&&!Pe){const e=_e;t.req.finally((()=>{Be(e)})).catch((()=>{}))}return o({target:i,params:r,scope:_e}),t.req};const b=i.inFlight=m(0,{serialize:'ignore',named:(O(i,'name')||i.graphite.id)+'.inFlight'}).on(i,(e=>e+1)).on(d,(e=>e-1)).map({fn:e=>e,named:'inFlight'});q(d,'needFxCounter','dec'),q(i,'needFxCounter',1);const k=i.pending=b.map({fn:e=>e>0,named:'pending'});return ae(i,[d,p,f,h,y,k,b]),null!=n&&n.domain&&n.domain.hooks.effect(i),i}function v(e,t){const r=c('merge',t);pe(e,r,'first argument');const n=u({name:s(e,'merge'),derived:1,and:t});return rt(e,n,[],'merge'),n}function b(e,n){let a=0;return t(mt,(t=>{t in e&&(r(null!=e[t],ht(n,t)),a=1)})),a}function k(e,r,n){const a=[];(function e(o){W(a,o)||(H(a,o),"store"===O(o,'op')&&(n||O(o,'sid'))&&r(o,O(o,'sid')),t(o.next,e),t($(o),e),t(z(o),e))})(e)}function x(e,n){const a=Array.isArray(e)?new Map(e):e,o=new Map;let s=0;if(a instanceof Map){const e={};return t(a,((t,a)=>{r(R(a),'Map key should be a unit'),n&&n(a,t),a.sid&&(a.sid in e&&(s=1),e[a.sid]=t),o.set(a,t)})),{sidMap:e,unitMap:o,hasSidDoubles:s}}return{sidMap:a,unitMap:o}}function w(e,t){return _(t)?[Me.mov({store:t.stateRef,to:'stack'}),...e]:e}Object.defineProperty(exports,'__esModule',{value:1});const S='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',M=e=>e.graphite||e,$=e=>e.family.owners,z=e=>e.family.links,A=e=>e.stateRef,N=e=>e.value,j=e=>e.subscribers,C=e=>e.parent,I=e=>e.scope,O=(e,t)=>M(e).meta[t],q=(e,t,r)=>M(e).meta[t]=r,F=e=>e.compositeName,R=e=>(ie(e)||se(e))&&'kind'in e,D=e=>t=>R(t)&&t.kind===e,_=D("store"),E=D("event"),P=D("effect"),V=e=>R(e)&&!!e.targetable,T=D("domain"),B=D("scope");var L={__proto__:null,unit:R,store:_,event:E,effect:P,targetable:V,domain:T,scope:B,attached:e=>P(e)&&1==O(e,'attached')};const W=(e,t)=>e.includes(t),G=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},H=(e,t)=>e.push(t),U=(e,t,r,n)=>!e&&console.error(`${n?n+': ':''}${t} is deprecated${r?`, use ${r} instead`:''}`),J=()=>{let e=0;return()=>""+ ++e},K=J(),Q=J(),X=J(),Y=J();let Z,ee=null;const te=e=>{Z&&Z(e,ee)},re=()=>ee&&ee.template,ne=e=>(e&&ee&&ee.sidRoot&&(e=`${ee.sidRoot}|${e}`),e),ae=(e,r)=>{const n=M(e);t(r,(e=>{const t=M(e);"domain"!==n.family.type&&(t.family.type="crosslink"),H($(t),n),H(z(n),t)}))},oe=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(M),se=e=>'object'==typeof e&&null!==e,ie=e=>'function'==typeof e,ce=e=>void 0===e,le=e=>r(se(e)||ie(e),'expect first argument be an object'),de=(e,t,n,a)=>r(!(!se(e)&&!ie(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${n} to be a unit (store, event or effect)${a}`),pe=(e,r,n)=>{Array.isArray(e)?t(e,((e,t)=>de(e,r,`${t} item of ${n}`,''))):de(e,r,n,' or array of units')},ue=(e,n,a="target")=>t(oe(n),(t=>r(!O(t,'derived'),`${e}: derived unit in "${a}" is not supported, use createStore/createEvent instead"`))),fe=(e,{fn:t},{a:r})=>t(e,r),me=(e,{fn:t},{a:r})=>t(r,e),he=(e,{fn:t})=>t(e),ge=(e,t,r,n)=>{const a={id:Q(),type:e,data:t};return r&&(a.order={priority:r},n&&(a.order.barrierID=++ye)),a};let ye=0;const ve=({from:e="store",store:t,target:r,to:n=(r?"store":"stack"),batch:a,priority:o})=>ge('mov',{from:e,store:t,to:n,target:r},o,a),be=({fn:e,batch:t,priority:r,safe:n=0,filter:a=0,pure:o=0})=>ge('compute',{fn:e,safe:n,filter:a,pure:o},r,t),ke=({fn:e})=>be({fn:e,priority:"effect"}),xe=(e,t,r)=>be({fn:e,safe:1,filter:t,priority:r&&"effect"}),we=(e,t,r)=>ve({store:e,to:t?"stack":"a",priority:r&&"sampler",batch:1}),Se=(e=he,t)=>be({fn:e,pure:1,filter:t}),Me={mov:ve,compute:be,filter:({fn:e,pure:t})=>be({fn:e,filter:1,pure:t}),run:ke},$e=e=>({id:Q(),current:e,initial:e}),ze=({current:e})=>e,Ae=(e,t)=>{e.before||(e.before=[]),H(e.before,t)};let Ne=null;const je=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||Re(e.v.type)>Re(t.v.type))&&(r=e,e=t,t=r),r=je(e.r,t),e.r=e.l,e.l=r,e},Ce=[];let Ie=0;for(;Ie<6;)H(Ce,{first:null,last:null,size:0}),Ie+=1;const Oe=()=>{for(let e=0;e<6;e++){const t=Ce[e];if(t.size>0){if(3===e||4===e){t.size-=1;const e=Ne.v;return Ne=je(Ne.l,Ne.r),e}1===t.size&&(t.last=null);const r=t.first;return t.first=r.r,t.size-=1,r.v}}},qe=(e,t,r,n,a,o,s)=>Fe(0,{a:null,b:null,node:r,parent:n,value:a,page:t,scope:o,meta:s},e,0),Fe=(e,t,r,n)=>{const a=Re(r),o=Ce[a],s={v:{idx:e,stack:t,type:r,id:n},l:null,r:null};3===a||4===a?Ne=je(Ne,s):(0===o.size?o.first=s:o.last.r=s,o.last=s),o.size+=1},Re=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case'barrier':return 3;case'sampler':return 4;case'effect':return 5;default:return-1}},De=new Set;let _e,Ee=1,Pe=0,Ve=0,Te=null;const Be=e=>{_e=e},Le=e=>{Te=e},We=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=e.parent;if(e)return e}return null},Ge=(e,t,r,n)=>{const a=We(e,r.id);return a?a.reg[r.id]:t?(Je(t,r,n),t.reg[r.id]):r};let He;const Ue=e=>e,Je=(e,r,n,a,o)=>{const s=e.reg;if(s[r.id])return;const i=r.sid,c={id:r.id,current:r.initial,meta:r.meta};if(c.id in e.values.idMap)c.current=e.values.idMap[c.id];else if(i&&i in e.values.sidMap&&!(i in e.sidIdMap)){var l;const t=null==r||null===(l=r.meta)||void 0===l?void 0:l.serialize;c.current=(e.fromSerialize&&'ignore'!==t&&(null==t?void 0:t.read)||Ue)(e.values.sidMap[i])}else if(r.before&&!o){let o=0;const i=n||!r.noInit||a;t(r.before,(t=>{switch(t.type){case'map':{const r=t.from;if((r||t.fn)&&(r&&Je(e,r,n,a),i)){const e=r&&s[r.id].current;c.current=t.fn?t.fn(e):e}break}case'field':Je(e,t.from,n,a),o||(o=1,c.current=Array.isArray(c.current)?[...c.current]:{...c.current}),i&&(c.current[t.field]=s[s[t.from.id].id].current)}}))}i&&(e.sidIdMap[i]=r.id),s[r.id]=c},Ke=(e,t,r)=>{try{return t(N(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}},Qe=(t,r={})=>(se(t)&&(Qe(t.or,r),e(t,((e,t)=>{ce(e)||'or'===t||'and'===t||(r[t]=e)})),Qe(t.and,r)),r),Xe=(e,t)=>{G(e.next,t),G($(e),t),G(z(e),t)},Ye=(e,t,r)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let a=z(e);for(;n=a.pop();)Xe(n,e),(t||r&&'sample'!==e.meta.op||"crosslink"===n.family.type)&&Ye(n,t,'on'!==n.meta.op&&r);for(a=$(e);n=a.pop();)Xe(n,e),r&&"crosslink"===n.family.type&&Ye(n,t,'on'!==n.meta.op&&r)},Ze=e=>e.clear(),et=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),_(e))Ze(j(e));else if(T(e)){r=1;const t=e.history;Ze(t.events),Ze(t.effects),Ze(t.stores),Ze(t.domains)}Ye(M(e),!!t,r)},tt=e=>d((()=>et(e))),rt=(e,t,r,n,o)=>a({node:r,parent:e,child:t,scope:{fn:o},meta:{op:n},family:{owners:[e,t],links:t},regional:1}),nt=(e,t)=>(r(ie(t),'.watch argument should be a function'),tt(a({scope:{fn:t},node:[ke({fn:he})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),at=(e,t,r="event")=>{C(e)&&C(e).hooks[r](t)},ot=(e,t,r)=>{const n=Qe(r),a="domain"===e,o=K(),{sid:s=null,named:c=null,domain:l=null,parent:d=l}=n,p=c||n.name||(a?'':o),u=i(p,d),f={op:t.kind=e,name:t.shortName=p,sid:t.sid=ne(s),named:c,unitId:t.id=o,serialize:n.serialize,derived:n.derived,config:n};if(t.targetable=!n.derived,t.parent=d,t.compositeName=u,t.defaultConfig=n,t.getType=()=>(U(0,'getType','compositeName.fullName'),u.fullName),!a){t.subscribe=e=>(le(e),t.watch(ie(e)?e:t=>e.next&&e.next(t))),t[S]=()=>t;const e=re();e&&(f.nativeTemplate=e)}return f},st=(e,t,r,n)=>{let a;se(r)&&(a=r,r=r.fn);const o=u({name:`${e.shortName} \u2192 *`,derived:1,and:a});return rt(e,o,n,t,r),o},ct='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',lt=(e,t,r,n,a)=>{const o=A(t),s=ve({store:o,to:"a",priority:'read'});"map"===r&&(s.data.softRead=1);const i=[s,Se(n)];return p('storeOnMap',o,i,_(e)&&A(e)),rt(e,t,i,r,a)},dt=(t,n,a,o,i,l)=>{const d=c('combine',o),u=t?e=>[...e]:e=>({...e}),f=t?[]:{},h=u(f),g=$e(h),y=$e(1);g.type=t?'list':'shape',g.noInit=1,p('combineBase',g,y);const v=m(h,{name:s(a),derived:1,...l,and:o}),b=A(v);b.noInit=1,q(v,'isCombine',1);const k=we(g);k.order={priority:'barrier'};const x=ve({store:b,to:'b',priority:'read'});x.data.softRead=1;const w=[xe(((e,t,r)=>(r.scope&&!r.scope.reg[g.id]&&(r.c=1),e))),k,ve({store:y,to:'b'}),xe(((e,{key:t},r)=>{if(r.c||e!==r.a[t])return n&&r.b&&(r.a=u(r.a)),r.a[t]=e,1}),1),ve({from:"a",target:g}),ve({from:"value",store:0,target:y}),ve({from:"value",store:1,target:y,priority:'barrier',batch:1}),we(g,1,1),i&&Se(),x];if(e(a,((e,t)=>{if(!_(e))return r(!R(e)&&!ce(e),`combine expects a store in a field ${t}`,d),void(h[t]=f[t]=e);f[t]=e.defaultState,h[t]=e.getState();const n=rt(e,v,w,'combine',i);n.scope.key=t;const a=A(e);Ae(g,{type:'field',field:t,from:a}),p('combineField',a,n)})),v.defaultShape=a,Ae(b,{type:"map",from:g,fn:i}),!re())if(i){const e=i(h);!ce(e)||l&&'skipVoid'in l||console.error(`${d}: ${ct}`),b.current=e,b.initial=e,v.defaultState=e}else v.defaultState=f;return v},pt=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},ut=(e,t,r,n,a)=>s=>{o({target:[n,ft],params:[r?{status:'done',params:e,result:s}:{status:'fail',params:e,error:s},{value:s,fn:r?t.rs:t.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})},ft=a({node:[ke({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),mt=['source','clock','target'],ht=(e,t)=>e+`: ${t} should be defined`,gt=(e,t,n,a,o,s,i,l,d,f,g,y)=>{const b=c(e,l),k=!!o;r(!ce(n)||!ce(t),ht(b,'either source or clock'));let x=0;ce(n)?x=1:R(n)||(n=h(n)),ce(t)?t=n:(pe(t,b,'clock'),Array.isArray(t)&&(t=v(t))),x&&(n=t),l||i||(i=n.shortName);let w='none';(g||a)&&(R(a)?w='unit':(r(ie(a),'`filter` should be function or unit'),w='fn')),o?(pe(o,b,'target'),ue(b,o)):'none'===w&&f&&_(n)&&_(t)?o=m(s?s(ze(A(n)),ze(A(t))):ze(A(n)),{name:i,sid:y,or:l}):(o=u({name:i,derived:1,or:l}),p('sampleTarget',M(o)));const S=$e();let $=[];if('unit'===w){const[r,n,s]=vt(a,o,t,S,e);s||$.push(...yt(n)),$.push(...yt(r))}const z=[];if(x)d&&z.push(we(S,1,1));else{const[r,a,s]=vt(n,o,t,S,e);s||z.push(...yt(a)),z.push(we(r,1,d))}const N=rt(t,o,[p('sampleSourceLoader'),ve({from:"stack",target:S}),...z,...$,we(S),'fn'===w&&Se(((e,t,{a:r})=>a(e,r)),1),s&&Se(fe),p('sampleSourceUpward',k)],e,s);return ae(n,[N]),Object.assign(N.meta,l,{joint:1}),o},yt=e=>[we(e),xe(((e,t,{a:r})=>r),1)],vt=(e,t,r,n,o)=>{const s=_(e),i=s?A(e):$e(),c=$e(s);return s||a({parent:e,node:[ve({from:"stack",target:i}),ve({from:"value",store:1,target:c})],family:{owners:[e,t,r],links:t},meta:{op:o},regional:1}),p('sampleSource',c,i,n),[i,c,s]},bt=(e,t,r,n)=>{const a=e[t];a&&o({target:a,params:Array.isArray(a)?a.map((()=>r)):r,defer:1,stack:n})},kt=e=>!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op,xt=e=>e;exports.allSettled=(e,{scope:t,params:r}={})=>{if(!R(e))return Promise.reject(new Error('first argument should be unit'));if(!(P(e)||E(e)||_(e)||B(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));B(e)&&(t=e);const n=g();n.parentFork=_e;const{fxCount:a}=t;H(a.scope.defers,n);const s=[],i=[];return B(e)||(H(s,e),H(i,P(e)?{params:r,req:{rs(e){n.value={status:'done',value:e}},rj(e){n.value={status:'fail',value:e}}}}:r)),H(s,a),H(i,null),o({target:s,params:i,scope:t}),n.req},exports.attach=e=>{let t;[e,t]=l(e,1);const n=c('attach',t);let{source:a,effect:s,mapParams:d,domain:p}=e;P(s)&&r(ce(p),'`domain` can only be used with a plain function',n);const u=y(e,t);q(u,'attached',1);const{runner:f}=M(u).scope;let m;const g=(e,t,r)=>{const{params:n,req:s,handler:i}=e,c=u.finally,l=ut(n,s,0,c,r),p=r.a,f=P(i);let m,h=1;if(d?[h,m]=pt(d,l,[n,p]):m=a&&f?p:n,h){if(!f)return e.args=[p,m],1;o({target:i,params:{params:m,req:{rs:ut(n,s,1,c,r),rj:l}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;f.scope.runnerFn=g,_(a)?(e=a,ae(e,[u])):(e=h(a),ae(u,[e])),m=[xe((e=>e),0,1),we(A(e))],delete f.seq[1].order}else m=[xe(g,1,1)];f.seq.splice(1,0,...m),u.use(s);const v=C(s);return v&&(Object.assign(F(u),i(u.shortName,v)),u.defaultConfig.parent=v),at(s,u,"effect"),u},exports.clearNode=et,exports.combine=h,exports.createApi=(...t)=>{let[[r,n],a]=l(t);const o={};return e(n,((e,t)=>{const n=o[t]=u(t,{parent:C(r),config:a});r.on(n,e),at(r,n)})),o},exports.createDomain=function r(n,s){const i=Qe({or:s,and:'string'==typeof n?{name:n}:n}),c=a({family:{type:"domain"},regional:1,parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent)}),l={history:{},graphite:c,hooks:{}};c.meta=ot("domain",l,{parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent),or:{...i,derived:1}}),e({Event:u,Effect:y,Store:m,Domain:r},((e,r)=>{const n=r.toLowerCase(),a=u({named:`on${r}`});l.hooks[n]=a;const s=new Set;l.history[`${n}s`]=s,a.create=e=>(o(a,e),e),H(M(a).seq,xe(((e,t,r)=>(r.scope=null,e)))),a.watch((e=>{ae(l,[e]),s.add(e),e.ownerSet||(e.ownerSet=s),C(e)||(e.parent=l)})),ae(l,[a]),l[`onCreate${r}`]=e=>(t(s,e),a.watch(e)),l[`create${r}`]=l[n]=(t,r)=>{const n=Qe({and:r,or:t});return null!=n&&n.domain?e(t,r):a(e(t,{parent:l,or:n}))}}));const d=C(l);return d&&e(l.hooks,((e,t)=>rt(e,d.hooks[t]))),null!=i&&i.domain&&i.domain.hooks.domain(l),l},exports.createEffect=y,exports.createEvent=u,exports.createNode=a,exports.createStore=m,exports.createWatch=({unit:e,fn:t,scope:r,batch:n})=>{const o=[Me.run({fn:e=>t(e)})];n&&o.unshift(Me.compute({priority:'sampler',batch:1})),_(e)&&o.unshift(Me.mov({store:e.stateRef,to:'stack'}));const s=Array.isArray(e)?e:[e];if(r){const e=[],t=r.additionalLinks;return s.forEach((r=>{const n=t[r.graphite.id]||[];t[r.graphite.id]=n;const s=a({node:w(o,r),meta:{watchOp:r.kind}});n.push(s),e.push((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),et(s)}))})),d((()=>{e.forEach((e=>e()))}))}{const e=a({node:o,parent:s,family:{owners:s}});return d((()=>{et(e)}))}},exports.fork=(e,n)=>{let o,s=e;T(e)&&(U(0,'fork(domain)','fork()'),o=e,s=n);const i=(e=>{const r=a({scope:{defers:[],inFlight:0,fxID:0},node:[xe(((e,t,r)=>{r.parent?'dec'===r.parent.node.meta.needFxCounter?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),be({priority:"sampler",batch:1}),xe(((e,r)=>{const{defers:n,fxID:a}=r;r.inFlight>0||0===n.length||Promise.resolve().then((()=>{r.fxID===a&&t(n.splice(0,n.length),(e=>{Be(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),n=a({node:[xe(((e,t,r)=>{const n=r.parent;if(n){const t=n.node;if(kt(n)){const n=I(r),a=t.meta.sid;n.sidIdMap[a]=t.scope.state.id,n.values.sidMap[a]=e;const o=t.meta.serialize;o&&n.sidSerializeSettings.set(a,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),o=a({node:[xe(((e,t,r)=>{const n=I(r);n&&r.parent&&kt(r.parent)&&(n.warnSerialize=1)}))]}),s={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return Ge(Te,s,e,0).current;const t=M(e);return Ge(Te,s,t.scope.state,1).current},kind:"scope",graphite:a({family:{type:"domain",links:[r,n,o]},meta:{unit:'fork'},scope:{forkInFlightCounter:r}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:r,storeChange:n,warnSerializeNode:o};return s})(o);if(s){if(s.values){const{sidMap:e,unitMap:n,hasSidDoubles:a}=x(s.values,(e=>r(_(e)&&V(e),'Values map can contain only writable stores as keys')));Object.assign(i.values.sidMap,e),t(n,((e,t)=>{if(i.values.idMap[t.stateRef.id]=e,'ignore'===O(t,'serialize')){const e=O(t,'sid');i.sidSerializeSettings.set(e,{ignore:1})}})),i.fromSerialize=!(Array.isArray(s.values)||s.values instanceof Map),i.hasSidDoubles=a}s.handlers&&(U(s.handlers instanceof Map||Array.isArray(s.handlers),'object with handlers','array'),i.handlers=x(s.handlers,(e=>r(P(e),"Handlers map can contain only effects as keys"))))}return i},exports.forward=e=>{const t='forward',[{from:r,to:n},o]=l(e,1),s=c(t,o);return U(0,t,'sample',s),pe(r,s,'"from"'),pe(n,s,'"to"'),ue(s,n,'to'),tt(a({parent:r,child:n,meta:{op:t,config:o},family:{},regional:1}))},exports.fromObservable=e=>{le(e);const t=S in e?e[S]():e;r(t.subscribe,'expect observable to have .subscribe');const n=u(),a=tt(n);return t.subscribe({next:n,error:a,complete:a}),n},exports.guard=(...e)=>{let[[t,r],n]=l(e);const a=c('guard',n);return U(0,'guard','sample',a),r||(r=t,t=r.source),b(r,a),gt('guard',r.clock,t,r.filter,r.target,null,r.name,n,!r.greedy,0,1)},exports.hydrate=(e,{values:n})=>{r(se(n),'values property should be an object');const{sidMap:a,unitMap:s}=x(n),i=Object.getOwnPropertyNames(a),c={};t(s,((e,t)=>{c[t.stateRef.id]=t}));const l=[],d=[];let p,u,f;B(e)?(p=e,f=1,r(p.cloneOf,'scope should be created from domain'),U(0,'hydrate(fork(domain), { values })','fork({ values })'),u=M(p.cloneOf)):T(e)?(U(0,'hydrate(domain, { values })','fork({ values })'),u=M(e)):r(0,'first argument of hydrate should be domain or scope'),k(u,((e,t)=>{if(t&&W(i,t)){H(l,e);const r=O(e,'serialize');r&&'ignore'!==r&&(a[t]=r.read(a[t])),H(d,a[t])}else e.scope.state.id in c&&(H(l,e),H(d,s.get(c[e.scope.state.id])))}),1),o({target:l,params:d,scope:p}),f&&Object.assign(p.values.sidMap,a)},exports.is=L,exports.launch=o,exports.merge=v,exports.restore=(t,n,a)=>{const o=c('restore',a);if(r(!_(t),'restore($store) is not supported',o),E(t)||P(t)){const e=C(t),r=m(n,{parent:e,name:t.shortName,and:a});return rt(P(t)?t.doneData:t,r),e&&e.hooks.store(r),r}const s=Array.isArray(t)?[]:{};return e(t,((e,t)=>s[t]=_(e)?e:m(e,{name:t}))),s},exports.sample=(...e)=>{let t,r,n,a,[[o,s,i],d]=l(e),p=1;const u=c('sample',d);return ce(s)&&se(o)&&b(o,u)&&(s=o.clock,i=o.fn,'batch'in o?p=o.batch:(U(!('greedy'in o),'greedy in sample','batch',u),p=!o.greedy),a=o.filter,t=o.target,r=o.name,n=o.sid,o=o.source),gt('sample',s,o,a,t,i,r,d,p,1,0,n)},exports.scopeBind=(e,{scope:t,safe:n}={})=>{r(t||_e||n,'scopeBind: scope not found');const a=t||_e;return P(e)?t=>{const r=g();return o({target:e,params:{params:t,req:r},scope:a}),r.req}:t=>(o({target:e,params:t,scope:a}),t)},exports.serialize=(t,n={})=>{t.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),r(!t.hasSidDoubles,'duplicate sid found in this scope');const a=n.ignore?n.ignore.map((({sid:e})=>e)):[],o={};return e(t.values.sidMap,((e,r)=>{var n;if(W(a,r))return;const s=t.sidIdMap[r],i=null!==(n=t.sidSerializeSettings.get(r))&&void 0!==n?n:{ignore:0,write:xt};i.ignore||(o[r]=(0,i.write)(s&&s in t.reg?t.reg[s].current:e))})),'onlyChanges'in n&&(U(0,'onlyChanges'),n.onlyChanges||(r(t.cloneOf,'scope should be created from domain'),k(M(t.cloneOf),((e,r)=>{r in o||W(a,r)||O(e,'isCombine')||'ignore'===O(e,'serialize')||(o[r]=t.getState(e))})))),o},exports.setGraphInspector=e=>{Z=e},exports.setInspector=e=>{He=e},exports.setStoreName=(e,t)=>{e.shortName=t,Object.assign(F(e),i(t,C(e)))},exports.split=(...t)=>{const n='split';let o,s,[[i,d],f]=l(t);const m=c(n,f),h=!d;h&&(o=i.cases,d=i.match,s=i.clock,i=i.source);const g=_(d),y=!R(d)&&ie(d),v=!g&&!y&&se(d);r(R(i),'source must be a unit',m),o||(o={}),h?e(o,((e,t)=>ue(m,e,`cases.${t}`))):(r(v,'match should be an object',m),e(d,((e,t)=>o[t]=u({derived:1,named:`cases.${t}`,and:f}))),o.__=u({derived:1,named:'cases.__',and:f}));const b=new Set([].concat(i,s||[],Object.values(o))),k=Object.keys(g||y?o:d);let x;if(g||y)g&&b.add(d),x=[g&&we(A(d),0,1),be({safe:g,filter:1,pure:!g,fn(e,t,r){const n=String(g?r.a:d(e));bt(t,W(k,n)?n:'__',e,r)}})];else if(v){const t=$e({});t.type='shape';const r=[];let n;e(d,((e,a)=>{if(R(e)){n=1,H(r,a),b.add(e);const o=rt(e,[],[we(t),xe(((e,t,{a:r})=>r[a]=e))]);if(_(e)){t.current[a]=e.getState();const r=A(e);Ae(t,{from:r,field:a,type:'field'}),p('splitMatchStore',r,o)}}})),n&&p('splitBase',t),x=[n&&we(t,0,1),Se(((e,t,n)=>{for(let a=0;a<k.length;a++){const o=k[a];if(W(r,o)?n.a[o]:d[o](e))return void bt(t,o,e,n)}bt(t,'__',e,n)}),1)]}else r(0,'expect match to be unit, function or object');const w=a({meta:{op:n},parent:s?[]:i,scope:o,node:x,family:{owners:Array.from(b)},regional:1});if(s&>(n,s,i,null,w,null,n,f,0,0,0),!h)return o},exports.step=Me,exports.version="23.0.0",exports.withFactory=({sid:e,name:t,loc:r,method:o,fn:s})=>n(a({meta:{sidRoot:ne(e),sid:e,name:t,loc:r,method:o,type:'factory'}}),s),exports.withRegion=n; | ||
//# sourceMappingURL=effector.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e='undefined'!=typeof globalThis?globalThis:e||self).effector={})})(this,(e=>{function t(e,t){for(const r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function n(e,t,r){if(!e)throw Error(`${r?r+': ':''}${t}`)}function a(e,t){const r=R(e).meta||{};ue={id:R(e).id,parent:ue,value:e,template:r.template||pe(),sidRoot:r.sidRoot||ue&&ue.sidRoot,meta:r};try{return t()}finally{fe('region'),ue=V(ue)}}function o({node:e=[],from:t,source:n,parent:a=t||n,to:o,target:s,child:i=o||s,scope:c={},meta:l={},family:d={type:'regular'},regional:u}={}){const f=ge(a),p=ge(d.links),m=ge(d.owners),h=[];r(e,(e=>e&&ne(h,e)));const g={id:ce(),seq:h,next:ge(i),meta:l,scope:c,family:{type:d.type||I,links:p,owners:m}};return r(p,(e=>ne(D(e),g))),r(m,(e=>ne(_(e),g))),r(f,(e=>ne(e.next,g))),u&&ue&&he(P(ue),[g]),g}function s(e,t,n){let a,o=Ye,s=null,i=Je;if(e.target&&(t=e.params,n=e.defer,a=e.meta,o='page'in e?e.page:o,e.stack&&(s=e.stack),i=B(e)||i,e=e.target),i&&Je&&i!==Je&&(Je=null),Array.isArray(e))for(let r=0;r<e.length;r++)We('pure',o,R(e[r]),s,t[r],i,a);else We('pure',o,R(e),s,t,i,a);if(n&&!Ke)return;const c={isRoot:Ke,currentPage:Ye,scope:Je,isWatch:Qe,isPure:Xe};let l,d,u,f,p,m;Ke=0;e:for(;f=Le();){const{idx:e,stack:t,type:n}=f;u=t.node,Ye=p=t.page,Je=B(t),p?m=p.reg:Je&&(m=Je.reg);const a=!!p,o=!!Je,s={fail:0,scope:u.scope};l=d=0;for(let r=e;r<u.seq.length&&!l;r++){const i=u.seq[r];if(i.order){const{priority:a,barrierID:o}=i.order,s=o?p?`${p.fullID}_${o}`:o:0;if(r!==e||n!==a){o?Ue.has(s)||(Ue.add(s),Ge(r,t,a,o)):Ge(r,t,a,0);continue e}o&&Ue.delete(s)}switch(i.type){case'mov':{const e=i.data;let r;switch(e.from){case'stack':r=P(t);break;case'a':case'b':r=t[e.from];break;case'value':r=e.store;break;case'store':if(m&&!m[e.store.id])if(a){const r=tt(p,e.store.id);t.page=p=r,r?m=r.reg:o?(ot(Je,e.store,0,1,e.softRead),m=Je.reg):m=void 0}else o&&ot(Je,e.store,0,1,e.softRead);r=_e(m&&m[e.store.id]||e.store)}switch(e.to){case'stack':t.value=r;break;case'a':case'b':t[e.to]=r;break;case'store':rt(p,Je,e.target,0).current=r}break}case'compute':const e=i.data;if(e.fn){Qe='watch'===u.meta.op,Xe=e.pure;const r=e.safe?(0,e.fn)(P(t),s.scope,t):st(s,e.fn,t);e.filter?d=!r:t.value=r,Qe=c.isWatch,Xe=c.isPure}}l=s.fail||d}if(nt&&nt(t,s),!l){const e=P(t),n=B(t);if(r(u.next,(r=>{We('child',p,r,t,e,n)})),n){u.meta.needFxCounter&&We('child',p,n.fxCount,t,e,n),u.meta.storeChange&&We('child',p,n.storeChange,t,e,n),u.meta.warnSerialize&&We('child',p,n.warnSerializeNode,t,e,n);const a=n.additionalLinks[u.id];a&&r(a,(r=>{We('child',p,r,t,e,n)}))}}}Ke=c.isRoot,Ye=c.currentPage,Je=B(c)}function i(e,r="combine"){let n=r+'(',a='',o=0;return t(e,(e=>{o<25&&(null!=e&&(n+=a,n+=H(e)?G(e).fullName:e.toString()),o+=1,a=', ')})),n+')'}function c(e,t){let r,n;const a=e;if(t){const a=G(t);0===e.length?(r=a.path,n=a.fullName):(r=a.path.concat([e]),n=0===a.fullName.length?e:a.fullName+'/'+e)}else r=0===e.length?[]:[e],n=e;return{shortName:a,fullName:n,path:r}}function l(e,t){if(!t)return e;if(!t.name&&!t.named&&!t.loc)return e;let r=`[${e}]`;const n=t.named||t.name;n&&(r+=` unit '${n}'`);const a=t.loc;return!n&&a&&(r+=` (${a.file}:${a.line}:${a.column})`),r}function d(e,t){const r=t?e:e[0];ke(r);let n=r.or;const a=r.and;if(a){const r=t?a:a[0];if(ye(r)&&'and'in r){const r=d(a,t);e=r[0],n={...n,...r[1]}}else e=a}return[e,n]}function u(e){const t=()=>e();return t.unsubscribe=()=>e(),t}function f(e,...t){const r=pe();if(r){const n=r.handlers[e];if(n)return n(r,...t)}}function p(e,t){const r=ct({or:t,and:'string'==typeof e?{name:e}:e}),a=l('event',r),i=(e,...t)=>(n(!L(i,'derived'),'call of derived event is not supported, use createEvent instead',a),n(!Xe,'unit call from pure function is not supported, use operators like sample instead',a),Ye?((e,t,r,n)=>{const a=Ye;let o=null;if(t)for(o=Ye;o&&o.template!==t;)o=V(o);et(o);const s=e.create(r,n);return et(a),s})(i,c,e,t):i.create(e,t)),c=pe(),d=Object.assign(i,{graphite:o({meta:yt(r.actualOp||z,i,r),regional:1}),create:e=>(s({target:i,params:e,scope:Je}),e),watch:e=>ht(i,e),map:e=>bt(i,O,e,[Fe()]),filter:e=>bt(i,'filter',e.fn?e:e.fn,[Fe(ze,1)]),filterMap:e=>bt(i,'filterMap',e,[Fe(),Oe((e=>!ve(e)),1)]),prepend(e){n(i.targetable,'.prepend of derived event is not supported, call source event instead',a);const t=p('* \u2192 '+i.shortName,{parent:V(i)});return f('eventPrepend',R(t)),mt(t,i,[Fe()],'prepend',e),gt(i,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(d),W(d,'id',d.graphite.id),fe(d.graphite),d}function m(e,t,a,o,s){return Se(a,`${s} ${t}`,'first argument'),n(be(o),'second argument should be a function',s),ae(!L(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`,s),r(Array.isArray(a)?a:[a],(t=>{e.off(t),T(e).set(t,pt(kt(t,e,'on',xe,o)))})),e}function h(e,t){const a=ct(t),i=De(e),c=l('store',a),d=p({named:'updates',derived:1});f('storeBase',i);const u=i.id,g='skipVoid'in a,y=g&&!a.skipVoid;ae(!(g&&a.skipVoid),'{skipVoid: true}','updateFilter',c);const b={subscribers:new Map,updates:d,defaultState:e,stateRef:i,getState(){let e,t=i;if(Ye){let t=Ye;for(;t&&!t.reg[u];)t=V(t);t&&(e=t)}return!e&&Je&&(ot(Je,i,1),e=Je),e&&(t=e.reg[u]),_e(t)},setState:e=>s({target:b,params:e,defer:1,scope:Je}),reset:(...e)=>(n(b.targetable,'.reset of derived store is not supported',c),r(e,(e=>m(b,'.reset',e,(()=>b.defaultState),c))),b),on:(e,t)=>(n(b.targetable,'.on of derived store is not supported',c),m(b,'.on',e,t,c)),off(e){const t=T(b).get(e);return t&&(t(),T(b).delete(e)),b},map(e,t){let r,n;ye(e)&&(r=e,e=e.fn);const a=b.getState(),o=ve(a);pe()?n=null:(!o||o&&y)&&(n=e(a));const s=h(n,{name:`${b.shortName} \u2192 *`,derived:1,...t,and:r}),c=kt(b,s,O,ze,e);return Ee(E(s),{type:O,fn:e,from:i}),E(s).noInit=1,f('storeMap',i,c),s},watch(e,t){if(ae(!t,'watch second argument','sample',c),!t||!H(e)){const t=ht(b,e);return f('storeWatch',i,e)||e(b.getState()),t}return n(be(t),'second argument should be a function',c),e.watch((e=>t(b.getState(),e)))}},v=yt(x,b,a),k=b.defaultConfig.updateFilter;b.graphite=o({scope:{state:i,fn:k},node:[Oe(((e,t,r)=>(r.scope&&!r.scope.reg[i.id]&&(r.b=1),e))),qe(i),Oe(((e,t,{a:r,b:n})=>{const a=ve(e);return a&&!g&&console.error(`${c}: ${vt}`),(a&&y||!a)&&(e!==r||n)}),1),k&&Fe($e,1),je({from:q,target:i})],child:d,meta:{...v,defaultState:e},regional:1}),W(b,'id',b.graphite.id),W(b,'rootStateRefId',u);const w=L(b,'serialize'),S=L(b,'derived'),M='ignore'===w,$=L(b,'sid');$&&(W(b,'storeChange',1),i.sid=$),$||M||S||W(b,'warnSerialize',1);const z=ve(e);return n(S||!z||z&&y,vt,c),S&&z&&!g&&console.error(`${c}: ${vt}`),he(b,[d]),null!=a&&a.domain&&a.domain.hooks.store(b),S||(b.reinit=p({named:'reinit'}),b.reset(b.reinit)),i.meta=b.graphite.meta,fe(b.graphite),b}function g(...e){let t,r,a;[e,a]=d(e);const o=l('combine',a),s=e[e.length-1],i=!J(s)&&ye(s),c=i&&s,u=i?e[e.length-2]:s;let f,p,m;if(be(u)?(r=e.slice(0,i?-2:-1),t=u):r=e,1===r.length){const e=r[0];J(e)||(f=e,p=1)}if(!p&&(f=r,t)){m=1;const e=t;t=t=>e(...t)}return n(ye(f),`${o}: shape should be an object`),wt(Array.isArray(f),!m,f,a,t,c)}function y(){const e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function b(e,t={}){const r=ct(be(e)?{handler:e}:e,t),a=l('effect',r),i=p(be(e)?{handler:e}:e,{...t,actualOp:A}),c=R(i);W(c,'op',i.kind=A),i.use=e=>(n(be(e),'.use argument should be a function',a),b.scope.handler=e,i),i.use.getCurrent=()=>b.scope.handler;const d=i.finally=p({named:'finally',derived:1}),u=i.done=d.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=i.fail=d.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),m=i.doneData=u.map({named:'doneData',fn:({result:e})=>e}),g=i.failData=f.map({named:'failData',fn:({error:e})=>e}),b=o({scope:{handler:i.defaultConfig.handler||(()=>n(0,`no handler used in ${i.compositeName.fullName}`))},node:[Oe(((e,t,r)=>{let n=t.handler;const a=B(r);if(a){const e=a.handlers.unitMap.get(i)||a.handlers.sidMap[i.sid];e&&(n=e)}return e.handler=n,e}),0,1),Oe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;const{params:n,req:a,handler:o,args:s=[n]}=e,i=Mt(n,a,1,d,r),c=Mt(n,a,0,d,r),[l,u]=St(o,c,s);l&&(ye(u)&&be(u.then)?u.then(i,c):i(u))}),0,1)],meta:{op:'fx',fx:'runner'}});c.scope.runner=b,ne(c.seq,Oe(((e,{runner:t},r)=>{const n=V(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:le()}),s({target:t,params:n,defer:1,scope:B(r),meta:r.meta}),n.params}))),i.create=e=>{const t=y(),r={params:e,req:t};if(Je&&!Qe){const e=Je;t.req.finally((()=>{Ze(e)})).catch((()=>{}))}return s({target:i,params:r,scope:Je}),t.req};const v=i.inFlight=h(0,{serialize:'ignore',named:(L(i,'name')||i.graphite.id)+'.inFlight'}).on(i,(e=>e+1)).on(d,(e=>e-1)).map({fn:e=>e,named:'inFlight'});W(d,'needFxCounter','dec'),W(i,'needFxCounter',1);const k=i.pending=v.map({fn:e=>e>0,named:'pending'});return he(i,[d,u,f,m,g,k,v]),null!=r&&r.domain&&r.domain.hooks.effect(i),i}function v(e,t){const r=l('merge',t);Se(e,r,'first argument');const n=p({name:i(e,'merge'),derived:1,and:t});return mt(e,n,[],'merge'),n}function k(e,t){let a=0;return r(xt,(r=>{r in e&&(n(null!=e[r],zt(t,r)),a=1)})),a}function w(e,t,n){const a=[];(function e(o){te(a,o)||(ne(a,o),L(o,'op')===x&&(n||L(o,'sid'))&&t(o,L(o,'sid')),r(o.next,e),r(D(o),e),r(_(o),e))})(e)}function S(e,t){const a=Array.isArray(e)?new Map(e):e,o=new Map;let s=0;if(a instanceof Map){const e={};return r(a,((r,a)=>{n(H(a),'Map key should be a unit'),t&&t(a,r),a.sid&&(a.sid in e&&(s=1),e[a.sid]=r),o.set(a,r)})),{sidMap:e,unitMap:o,hasSidDoubles:s}}return{sidMap:a,unitMap:o}}function M(e,t){return J(t)?[Re.mov({store:t.stateRef,to:'stack'}),...e]:e}const $='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',x='store',z='event',A='effect',N='domain',j='scope',C='sampler',I='crosslink',O='map',q='stack',F='value',R=e=>e.graphite||e,D=e=>e.family.owners,_=e=>e.family.links,E=e=>e.stateRef,P=e=>e.value,T=e=>e.subscribers,V=e=>e.parent,B=e=>e.scope,L=(e,t)=>R(e).meta[t],W=(e,t,r)=>R(e).meta[t]=r,G=e=>e.compositeName,H=e=>(be(e)||ye(e))&&'kind'in e,U=e=>t=>H(t)&&t.kind===e,J=U(x),K=U(z),Q=U(A),X=e=>H(e)&&!!e.targetable,Y=U(N),Z=U(j);var ee={__proto__:null,unit:H,store:J,event:K,effect:Q,targetable:X,domain:Y,scope:Z,attached:e=>Q(e)&&1==L(e,'attached')};const te=(e,t)=>e.includes(t),re=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},ne=(e,t)=>e.push(t),ae=(e,t,r,n)=>!e&&console.error(`${n?n+': ':''}${t} is deprecated${r?`, use ${r} instead`:''}`),oe=()=>{let e=0;return()=>""+ ++e},se=oe(),ie=oe(),ce=oe(),le=oe();let de,ue=null;const fe=e=>{de&&de(e,ue)},pe=()=>ue&&ue.template,me=e=>(e&&ue&&ue.sidRoot&&(e=`${ue.sidRoot}|${e}`),e),he=(e,t)=>{const n=R(e);r(t,(e=>{const t=R(e);n.family.type!==N&&(t.family.type=I),ne(D(t),n),ne(_(n),t)}))},ge=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(R),ye=e=>'object'==typeof e&&null!==e,be=e=>'function'==typeof e,ve=e=>void 0===e,ke=e=>n(ye(e)||be(e),'expect first argument be an object'),we=(e,t,r,a)=>n(!(!ye(e)&&!be(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${a}`),Se=(e,t,n)=>{Array.isArray(e)?r(e,((e,r)=>we(e,t,`${r} item of ${n}`,''))):we(e,t,n,' or array of units')},Me=(e,t,a="target")=>r(ge(t),(t=>n(!L(t,'derived'),`${e}: derived unit in "${a}" is not supported, use createStore/createEvent instead"`))),$e=(e,{fn:t},{a:r})=>t(e,r),xe=(e,{fn:t},{a:r})=>t(r,e),ze=(e,{fn:t})=>t(e),Ae=(e,t,r,n)=>{const a={id:ie(),type:e,data:t};return r&&(a.order={priority:r},n&&(a.order.barrierID=++Ne)),a};let Ne=0;const je=({from:e=x,store:t,target:r,to:n=(r?x:q),batch:a,priority:o})=>Ae('mov',{from:e,store:t,to:n,target:r},o,a),Ce=({fn:e,batch:t,priority:r,safe:n=0,filter:a=0,pure:o=0})=>Ae('compute',{fn:e,safe:n,filter:a,pure:o},r,t),Ie=({fn:e})=>Ce({fn:e,priority:A}),Oe=(e,t,r)=>Ce({fn:e,safe:1,filter:t,priority:r&&A}),qe=(e,t,r)=>je({store:e,to:t?q:"a",priority:r&&C,batch:1}),Fe=(e=ze,t)=>Ce({fn:e,pure:1,filter:t}),Re={mov:je,compute:Ce,filter:({fn:e,pure:t})=>Ce({fn:e,filter:1,pure:t}),run:Ie},De=e=>({id:ie(),current:e,initial:e}),_e=({current:e})=>e,Ee=(e,t)=>{e.before||(e.before=[]),ne(e.before,t)};let Pe=null;const Te=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||He(e.v.type)>He(t.v.type))&&(r=e,e=t,t=r),r=Te(e.r,t),e.r=e.l,e.l=r,e},Ve=[];let Be=0;for(;Be<6;)ne(Ve,{first:null,last:null,size:0}),Be+=1;const Le=()=>{for(let e=0;e<6;e++){const t=Ve[e];if(t.size>0){if(3===e||4===e){t.size-=1;const e=Pe.v;return Pe=Te(Pe.l,Pe.r),e}1===t.size&&(t.last=null);const r=t.first;return t.first=r.r,t.size-=1,r.v}}},We=(e,t,r,n,a,o,s)=>Ge(0,{a:null,b:null,node:r,parent:n,value:a,page:t,scope:o,meta:s},e,0),Ge=(e,t,r,n)=>{const a=He(r),o=Ve[a],s={v:{idx:e,stack:t,type:r,id:n},l:null,r:null};3===a||4===a?Pe=Te(Pe,s):(0===o.size?o.first=s:o.last.r=s,o.last=s),o.size+=1},He=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case'barrier':return 3;case'sampler':return 4;case'effect':return 5;default:return-1}},Ue=new Set;let Je,Ke=1,Qe=0,Xe=0,Ye=null;const Ze=e=>{Je=e},et=e=>{Ye=e},tt=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=e.parent;if(e)return e}return null},rt=(e,t,r,n)=>{const a=tt(e,r.id);return a?a.reg[r.id]:t?(ot(t,r,n),t.reg[r.id]):r};let nt;const at=e=>e,ot=(e,t,n,a,o)=>{const s=e.reg;if(s[t.id])return;const i=t.sid,c={id:t.id,current:t.initial,meta:t.meta};if(c.id in e.values.idMap)c.current=e.values.idMap[c.id];else if(i&&i in e.values.sidMap&&!(i in e.sidIdMap)){var l;const r=null==t||null===(l=t.meta)||void 0===l?void 0:l.serialize;c.current=(e.fromSerialize&&'ignore'!==r&&(null==r?void 0:r.read)||at)(e.values.sidMap[i])}else if(t.before&&!o){let o=0;const i=n||!t.noInit||a;r(t.before,(t=>{switch(t.type){case'map':{const r=t.from;if((r||t.fn)&&(r&&ot(e,r,n,a),i)){const e=r&&s[r.id].current;c.current=t.fn?t.fn(e):e}break}case'field':ot(e,t.from,n,a),o||(o=1,c.current=Array.isArray(c.current)?[...c.current]:{...c.current}),i&&(c.current[t.field]=s[s[t.from.id].id].current)}}))}i&&(e.sidIdMap[i]=t.id),s[t.id]=c},st=(e,t,r)=>{try{return t(P(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}},ct=(e,r={})=>(ye(e)&&(ct(e.or,r),t(e,((e,t)=>{ve(e)||'or'===t||'and'===t||(r[t]=e)})),ct(e.and,r)),r),lt=(e,t)=>{re(e.next,t),re(D(e),t),re(_(e),t)},dt=(e,t,r)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let a=_(e);for(;n=a.pop();)lt(n,e),(t||r&&'sample'!==e.meta.op||n.family.type===I)&&dt(n,t,'on'!==n.meta.op&&r);for(a=D(e);n=a.pop();)lt(n,e),r&&n.family.type===I&&dt(n,t,'on'!==n.meta.op&&r)},ut=e=>e.clear(),ft=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),J(e))ut(T(e));else if(Y(e)){r=1;const t=e.history;ut(t.events),ut(t.effects),ut(t.stores),ut(t.domains)}dt(R(e),!!t,r)},pt=e=>u((()=>ft(e))),mt=(e,t,r,n,a)=>o({node:r,parent:e,child:t,scope:{fn:a},meta:{op:n},family:{owners:[e,t],links:t},regional:1}),ht=(e,t)=>(n(be(t),'.watch argument should be a function'),pt(o({scope:{fn:t},node:[Ie({fn:ze})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),gt=(e,t,r=z)=>{V(e)&&V(e).hooks[r](t)},yt=(e,t,r)=>{const n=ct(r),a=e===N,o=se(),{sid:s=null,named:i=null,domain:l=null,parent:d=l}=n,u=i||n.name||(a?'':o),f=c(u,d),p={op:t.kind=e,name:t.shortName=u,sid:t.sid=me(s),named:i,unitId:t.id=o,serialize:n.serialize,derived:n.derived,config:n};if(t.targetable=!n.derived,t.parent=d,t.compositeName=f,t.defaultConfig=n,t.getType=()=>(ae(0,'getType','compositeName.fullName'),f.fullName),!a){t.subscribe=e=>(ke(e),t.watch(be(e)?e:t=>e.next&&e.next(t))),t[$]=()=>t;const e=pe();e&&(p.nativeTemplate=e)}return p},bt=(e,t,r,n)=>{let a;ye(r)&&(a=r,r=r.fn);const o=p({name:`${e.shortName} \u2192 *`,derived:1,and:a});return mt(e,o,n,t,r),o},vt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',kt=(e,t,r,n,a)=>{const o=E(t),s=je({store:o,to:"a",priority:'read'});r===O&&(s.data.softRead=1);const i=[s,Fe(n)];return f('storeOnMap',o,i,J(e)&&E(e)),mt(e,t,i,r,a)},wt=(e,r,a,o,s,c)=>{const d=l('combine',o),u=e?e=>[...e]:e=>({...e}),p=e?[]:{},m=u(p),g=De(m),y=De(1);g.type=e?'list':'shape',g.noInit=1,f('combineBase',g,y);const b=h(m,{name:i(a),derived:1,...c,and:o}),v=E(b);v.noInit=1,W(b,'isCombine',1);const k=qe(g);k.order={priority:'barrier'};const w=je({store:v,to:'b',priority:'read'});w.data.softRead=1;const S=[Oe(((e,t,r)=>(r.scope&&!r.scope.reg[g.id]&&(r.c=1),e))),k,je({store:y,to:'b'}),Oe(((e,{key:t},n)=>{if(n.c||e!==n.a[t])return r&&n.b&&(n.a=u(n.a)),n.a[t]=e,1}),1),je({from:"a",target:g}),je({from:F,store:0,target:y}),je({from:F,store:1,target:y,priority:'barrier',batch:1}),qe(g,1,1),s&&Fe(),w];if(t(a,((e,t)=>{if(!J(e))return n(!H(e)&&!ve(e),`combine expects a store in a field ${t}`,d),void(m[t]=p[t]=e);p[t]=e.defaultState,m[t]=e.getState();const r=mt(e,b,S,'combine',s);r.scope.key=t;const a=E(e);Ee(g,{type:'field',field:t,from:a}),f('combineField',a,r)})),b.defaultShape=a,Ee(v,{type:O,from:g,fn:s}),!pe())if(s){const e=s(m);!ve(e)||c&&'skipVoid'in c||console.error(`${d}: ${vt}`),v.current=e,v.initial=e,b.defaultState=e}else b.defaultState=p;return b},St=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},Mt=(e,t,r,n,a)=>o=>{s({target:[n,$t],params:[r?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:r?t.rs:t.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})},$t=o({node:[Ie({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),xt=['source','clock','target'],zt=(e,t)=>e+`: ${t} should be defined`,At=(e,t,r,a,o,s,i,c,d,u,m,y)=>{const b=l(e,c),k=!!o;n(!ve(r)||!ve(t),zt(b,'either source or clock'));let w=0;ve(r)?w=1:H(r)||(r=g(r)),ve(t)?t=r:(Se(t,b,'clock'),Array.isArray(t)&&(t=v(t))),w&&(r=t),c||i||(i=r.shortName);let S='none';(m||a)&&(H(a)?S='unit':(n(be(a),'`filter` should be function or unit'),S='fn')),o?(Se(o,b,'target'),Me(b,o)):'none'===S&&u&&J(r)&&J(t)?o=h(s?s(_e(E(r)),_e(E(t))):_e(E(r)),{name:i,sid:y,or:c}):(o=p({name:i,derived:1,or:c}),f('sampleTarget',R(o)));const M=De();let $=[];if('unit'===S){const[r,n,s]=jt(a,o,t,M,e);s||$.push(...Nt(n)),$.push(...Nt(r))}const x=[];if(w)d&&x.push(qe(M,1,1));else{const[n,a,s]=jt(r,o,t,M,e);s||x.push(...Nt(a)),x.push(qe(n,1,d))}const z=mt(t,o,[f('sampleSourceLoader'),je({from:q,target:M}),...x,...$,qe(M),'fn'===S&&Fe(((e,t,{a:r})=>a(e,r)),1),s&&Fe($e),f('sampleSourceUpward',k)],e,s);return he(r,[z]),Object.assign(z.meta,c,{joint:1}),o},Nt=e=>[qe(e),Oe(((e,t,{a:r})=>r),1)],jt=(e,t,r,n,a)=>{const s=J(e),i=s?E(e):De(),c=De(s);return s||o({parent:e,node:[je({from:q,target:i}),je({from:F,store:1,target:c})],family:{owners:[e,t,r],links:t},meta:{op:a},regional:1}),f('sampleSource',c,i,n),[i,c,s]},Ct=(e,t,r,n)=>{const a=e[t];a&&s({target:a,params:Array.isArray(a)?a.map((()=>r)):r,defer:1,stack:n})},It=e=>!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op,Ot=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!H(e))return Promise.reject(new Error('first argument should be unit'));if(!(Q(e)||K(e)||J(e)||Z(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));Z(e)&&(t=e);const n=y();n.parentFork=Je;const{fxCount:a}=t;ne(a.scope.defers,n);const o=[],i=[];return Z(e)||(ne(o,e),ne(i,Q(e)?{params:r,req:{rs(e){n.value={status:'done',value:e}},rj(e){n.value={status:'fail',value:e}}}}:r)),ne(o,a),ne(i,null),s({target:o,params:i,scope:t}),n.req},e.attach=e=>{let t;[e,t]=d(e,1);const r=l('attach',t);let{source:a,effect:o,mapParams:i,domain:u}=e;Q(o)&&n(ve(u),'`domain` can only be used with a plain function',r);const f=b(e,t);W(f,'attached',1);const{runner:p}=R(f).scope;let m;const h=(e,t,r)=>{const{params:n,req:o,handler:c}=e,l=f.finally,d=Mt(n,o,0,l,r),u=r.a,p=Q(c);let m,h=1;if(i?[h,m]=St(i,d,[n,u]):m=a&&p?u:n,h){if(!p)return e.args=[u,m],1;s({target:c,params:{params:m,req:{rs:Mt(n,o,1,l,r),rj:d}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;p.scope.runnerFn=h,J(a)?(e=a,he(e,[f])):(e=g(a),he(f,[e])),m=[Oe((e=>e),0,1),qe(E(e))],delete p.seq[1].order}else m=[Oe(h,1,1)];p.seq.splice(1,0,...m),f.use(o);const y=V(o);return y&&(Object.assign(G(f),c(f.shortName,y)),f.defaultConfig.parent=y),gt(o,f,A),f},e.clearNode=ft,e.combine=g,e.createApi=(...e)=>{let[[r,n],a]=d(e);const o={};return t(n,((e,t)=>{const n=o[t]=p(t,{parent:V(r),config:a});r.on(n,e),gt(r,n)})),o},e.createDomain=function e(n,a){const i=ct({or:a,and:'string'==typeof n?{name:n}:n}),c=o({family:{type:N},regional:1,parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent)}),l={history:{},graphite:c,hooks:{}};c.meta=yt(N,l,{parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent),or:{...i,derived:1}}),t({Event:p,Effect:b,Store:h,Domain:e},((e,t)=>{const n=t.toLowerCase(),a=(e=>p({named:e}))(`on${t}`);l.hooks[n]=a;const o=new Set;l.history[`${n}s`]=o,a.create=e=>(s(a,e),e),ne(R(a).seq,Oe(((e,t,r)=>(r.scope=null,e)))),a.watch((e=>{he(l,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),V(e)||(e.parent=l)})),he(l,[a]),l[`onCreate${t}`]=e=>(r(o,e),a.watch(e)),l[`create${t}`]=l[n]=(t,r)=>{const n=ct({and:r,or:t});return null!=n&&n.domain?e(t,r):a(e(t,{parent:l,or:n}))}}));const d=V(l);return d&&t(l.hooks,((e,t)=>mt(e,d.hooks[t]))),null!=i&&i.domain&&i.domain.hooks.domain(l),l},e.createEffect=b,e.createEvent=p,e.createNode=o,e.createStore=h,e.createWatch=({unit:e,fn:t,scope:r,batch:n})=>{const a=[Re.run({fn:e=>t(e)})];n&&a.unshift(Re.compute({priority:'sampler',batch:1})),J(e)&&a.unshift(Re.mov({store:e.stateRef,to:'stack'}));const s=Array.isArray(e)?e:[e];if(r){const e=[],t=r.additionalLinks;return s.forEach((r=>{const n=t[r.graphite.id]||[];t[r.graphite.id]=n;const s=o({node:M(a,r),meta:{watchOp:r.kind}});n.push(s),e.push((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),ft(s)}))})),u((()=>{e.forEach((e=>e()))}))}{const e=o({node:a,parent:s,family:{owners:s}});return u((()=>{ft(e)}))}},e.fork=(e,t)=>{let a,s=e;Y(e)&&(ae(0,'fork(domain)','fork()'),a=e,s=t);const i=(e=>{const t=o({scope:{defers:[],inFlight:0,fxID:0},node:[Oe(((e,t,r)=>{r.parent?'dec'===r.parent.node.meta.needFxCounter?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Ce({priority:C,batch:1}),Oe(((e,t)=>{const{defers:n,fxID:a}=t;t.inFlight>0||0===n.length||Promise.resolve().then((()=>{t.fxID===a&&r(n.splice(0,n.length),(e=>{Ze(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),n=o({node:[Oe(((e,t,r)=>{const n=r.parent;if(n){const t=n.node;if(It(n)){const n=B(r),a=t.meta.sid;n.sidIdMap[a]=t.scope.state.id,n.values.sidMap[a]=e;const o=t.meta.serialize;o&&n.sidSerializeSettings.set(a,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),a=o({node:[Oe(((e,t,r)=>{const n=B(r);n&&r.parent&&It(r.parent)&&(n.warnSerialize=1)}))]}),s={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return rt(Ye,s,e,0).current;const t=R(e);return rt(Ye,s,t.scope.state,1).current},kind:j,graphite:o({family:{type:N,links:[t,n,a]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:n,warnSerializeNode:a};return s})(a);if(s){if(s.values){const{sidMap:e,unitMap:t,hasSidDoubles:a}=S(s.values,(e=>n(J(e)&&X(e),'Values map can contain only writable stores as keys')));Object.assign(i.values.sidMap,e),r(t,((e,t)=>{if(i.values.idMap[t.stateRef.id]=e,'ignore'===L(t,'serialize')){const e=L(t,'sid');i.sidSerializeSettings.set(e,{ignore:1})}})),i.fromSerialize=!(Array.isArray(s.values)||s.values instanceof Map),i.hasSidDoubles=a}s.handlers&&(ae(s.handlers instanceof Map||Array.isArray(s.handlers),'object with handlers','array'),i.handlers=S(s.handlers,(e=>n(Q(e),"Handlers map can contain only effects as keys"))))}return i},e.forward=e=>{const t='forward',[{from:r,to:n},a]=d(e,1),s=l(t,a);return ae(0,t,'sample',s),Se(r,s,'"from"'),Se(n,s,'"to"'),Me(s,n,'to'),pt(o({parent:r,child:n,meta:{op:t,config:a},family:{},regional:1}))},e.fromObservable=e=>{ke(e);const t=$ in e?e[$]():e;n(t.subscribe,'expect observable to have .subscribe');const r=p(),a=pt(r);return t.subscribe({next:r,error:a,complete:a}),r},e.guard=(...e)=>{let[[t,r],n]=d(e);const a=l('guard',n);return ae(0,'guard','sample',a),r||(r=t,t=r.source),k(r,a),At('guard',r.clock,t,r.filter,r.target,null,r.name,n,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{n(ye(t),'values property should be an object');const{sidMap:a,unitMap:o}=S(t),i=Object.getOwnPropertyNames(a),c={};r(o,((e,t)=>{c[t.stateRef.id]=t}));const l=[],d=[];let u,f,p;Z(e)?(u=e,p=1,n(u.cloneOf,'scope should be created from domain'),ae(0,'hydrate(fork(domain), { values })','fork({ values })'),f=R(u.cloneOf)):Y(e)?(ae(0,'hydrate(domain, { values })','fork({ values })'),f=R(e)):n(0,'first argument of hydrate should be domain or scope'),w(f,((e,t)=>{if(t&&te(i,t)){ne(l,e);const r=L(e,'serialize');r&&'ignore'!==r&&(a[t]=r.read(a[t])),ne(d,a[t])}else e.scope.state.id in c&&(ne(l,e),ne(d,o.get(c[e.scope.state.id])))}),1),s({target:l,params:d,scope:u}),p&&Object.assign(u.values.sidMap,a)},e.is=ee,e.launch=s,e.merge=v,e.restore=(e,r,n)=>{const a=l('restore',n);if(J(e))return ae(0,'restore($store)',void 0,a),e;if(K(e)||Q(e)){const t=V(e),a=h(r,{parent:t,name:e.shortName,and:n});return mt(Q(e)?e.doneData:e,a),t&&t.hooks.store(a),a}const o=Array.isArray(e)?[]:{};return t(e,((e,t)=>o[t]=J(e)?e:h(e,{name:t}))),o},e.sample=(...e)=>{let t,r,n,a,[[o,s,i],c]=d(e),u=1;const f=l('sample',c);return ve(s)&&ye(o)&&k(o,f)&&(s=o.clock,i=o.fn,'batch'in o?u=o.batch:(ae(!('greedy'in o),'greedy in sample','batch',f),u=!o.greedy),a=o.filter,t=o.target,r=o.name,n=o.sid,o=o.source),At('sample',s,o,a,t,i,r,c,u,1,0,n)},e.scopeBind=(e,{scope:t,safe:r}={})=>{n(t||Je||r,'scopeBind: scope not found');const a=t||Je;return Q(e)?t=>{const r=y();return s({target:e,params:{params:t,req:r},scope:a}),r.req}:t=>(s({target:e,params:t,scope:a}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!e.hasSidDoubles,'duplicate sid found in this scope');const a=r.ignore?r.ignore.map((({sid:e})=>e)):[],o={};return t(e.values.sidMap,((t,r)=>{var n;if(te(a,r))return;const s=e.sidIdMap[r],i=null!==(n=e.sidSerializeSettings.get(r))&&void 0!==n?n:{ignore:0,write:Ot};i.ignore||(o[r]=(0,i.write)(s&&s in e.reg?e.reg[s].current:t))})),'onlyChanges'in r&&(ae(0,'onlyChanges'),r.onlyChanges||(n(e.cloneOf,'scope should be created from domain'),w(R(e.cloneOf),((t,r)=>{r in o||te(a,r)||L(t,'isCombine')||'ignore'===L(t,'serialize')||(o[r]=e.getState(t))})))),o},e.setGraphInspector=e=>{de=e},e.setInspector=e=>{nt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(G(e),c(t,V(e)))},e.split=(...e)=>{const r='split';let a,s,[[i,c],u]=d(e);const m=l(r,u),h=!c;h&&(a=i.cases,c=i.match,s=i.clock,i=i.source);const g=J(c),y=!H(c)&&be(c),b=!g&&!y&&ye(c);n(H(i),'source must be a unit',m),a||(a={}),h?t(a,((e,t)=>Me(m,e,`cases.${t}`))):(n(b,'match should be an object',m),t(c,((e,t)=>a[t]=p({derived:1,named:`cases.${t}`,and:u}))),a.__=p({derived:1,named:'cases.__',and:u}));const v=new Set([].concat(i,s||[],Object.values(a))),k=Object.keys(g||y?a:c);let w;if(g||y)g&&v.add(c),w=[g&&qe(E(c),0,1),Ce({safe:g,filter:1,pure:!g,fn(e,t,r){const n=String(g?r.a:c(e));Ct(t,te(k,n)?n:'__',e,r)}})];else if(b){const e=De({});e.type='shape';const r=[];let n;t(c,((t,a)=>{if(H(t)){n=1,ne(r,a),v.add(t);const o=mt(t,[],[qe(e),Oe(((e,t,{a:r})=>r[a]=e))]);if(J(t)){e.current[a]=t.getState();const r=E(t);Ee(e,{from:r,field:a,type:'field'}),f('splitMatchStore',r,o)}}})),n&&f('splitBase',e),w=[n&&qe(e,0,1),Fe(((e,t,n)=>{for(let a=0;a<k.length;a++){const o=k[a];if(te(r,o)?n.a[o]:c[o](e))return void Ct(t,o,e,n)}Ct(t,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');const S=o({meta:{op:r},parent:s?[]:i,scope:a,node:w,family:{owners:Array.from(v)},regional:1});if(s&&At(r,s,i,null,S,null,r,u,0,0,0),!h)return a},e.step=Re,e.version="23.0.0-rc.6",e.withFactory=({sid:e,name:t,loc:r,method:n,fn:s})=>a(o({meta:{sidRoot:me(e),sid:e,name:t,loc:r,method:n,type:'factory'}}),s),e.withRegion=a,Object.defineProperty(e,'__esModule',{value:1})})); | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e='undefined'!=typeof globalThis?globalThis:e||self).effector={})})(this,(e=>{function t(e,t){for(const r in e)t(e[r],r)}function r(e,t){e.forEach(t)}function n(e,t,r){if(!e)throw Error(`${r?r+': ':''}${t}`)}function a(e,t){const r=R(e).meta||{};ue={id:R(e).id,parent:ue,value:e,template:r.template||pe(),sidRoot:r.sidRoot||ue&&ue.sidRoot,meta:r};try{return t()}finally{fe('region'),ue=V(ue)}}function o({node:e=[],from:t,source:n,parent:a=t||n,to:o,target:s,child:i=o||s,scope:c={},meta:l={},family:d={type:'regular'},regional:u}={}){const f=ge(a),p=ge(d.links),m=ge(d.owners),h=[];r(e,(e=>e&&ne(h,e)));const g={id:ce(),seq:h,next:ge(i),meta:l,scope:c,family:{type:d.type||I,links:p,owners:m}};return r(p,(e=>ne(D(e),g))),r(m,(e=>ne(_(e),g))),r(f,(e=>ne(e.next,g))),u&&ue&&he(P(ue),[g]),g}function s(e,t,n){let a,o=Ye,s=null,i=Je;if(e.target&&(t=e.params,n=e.defer,a=e.meta,o='page'in e?e.page:o,e.stack&&(s=e.stack),i=B(e)||i,e=e.target),i&&Je&&i!==Je&&(Je=null),Array.isArray(e))for(let r=0;r<e.length;r++)We('pure',o,R(e[r]),s,t[r],i,a);else We('pure',o,R(e),s,t,i,a);if(n&&!Ke)return;const c={isRoot:Ke,currentPage:Ye,scope:Je,isWatch:Qe,isPure:Xe};let l,d,u,f,p,m;Ke=0;e:for(;f=Le();){const{idx:e,stack:t,type:n}=f;u=t.node,Ye=p=t.page,Je=B(t),p?m=p.reg:Je&&(m=Je.reg);const a=!!p,o=!!Je,s={fail:0,scope:u.scope};l=d=0;for(let r=e;r<u.seq.length&&!l;r++){const i=u.seq[r];if(i.order){const{priority:a,barrierID:o}=i.order,s=o?p?`${p.fullID}_${o}`:o:0;if(r!==e||n!==a){o?Ue.has(s)||(Ue.add(s),Ge(r,t,a,o)):Ge(r,t,a,0);continue e}o&&Ue.delete(s)}switch(i.type){case'mov':{const e=i.data;let r;switch(e.from){case'stack':r=P(t);break;case'a':case'b':r=t[e.from];break;case'value':r=e.store;break;case'store':if(m&&!m[e.store.id])if(a){const r=tt(p,e.store.id);t.page=p=r,r?m=r.reg:o?(ot(Je,e.store,0,1,e.softRead),m=Je.reg):m=void 0}else o&&ot(Je,e.store,0,1,e.softRead);r=_e(m&&m[e.store.id]||e.store)}switch(e.to){case'stack':t.value=r;break;case'a':case'b':t[e.to]=r;break;case'store':rt(p,Je,e.target,0).current=r}break}case'compute':const e=i.data;if(e.fn){Qe='watch'===u.meta.op,Xe=e.pure;const r=e.safe?(0,e.fn)(P(t),s.scope,t):st(s,e.fn,t);e.filter?d=!r:t.value=r,Qe=c.isWatch,Xe=c.isPure}}l=s.fail||d}if(nt&&nt(t,s),!l){const e=P(t),n=B(t);if(r(u.next,(r=>{We('child',p,r,t,e,n)})),n){u.meta.needFxCounter&&We('child',p,n.fxCount,t,e,n),u.meta.storeChange&&We('child',p,n.storeChange,t,e,n),u.meta.warnSerialize&&We('child',p,n.warnSerializeNode,t,e,n);const a=n.additionalLinks[u.id];a&&r(a,(r=>{We('child',p,r,t,e,n)}))}}}Ke=c.isRoot,Ye=c.currentPage,Je=B(c)}function i(e,r="combine"){let n=r+'(',a='',o=0;return t(e,(e=>{o<25&&(null!=e&&(n+=a,n+=H(e)?G(e).fullName:e.toString()),o+=1,a=', ')})),n+')'}function c(e,t){let r,n;const a=e;if(t){const a=G(t);0===e.length?(r=a.path,n=a.fullName):(r=a.path.concat([e]),n=0===a.fullName.length?e:a.fullName+'/'+e)}else r=0===e.length?[]:[e],n=e;return{shortName:a,fullName:n,path:r}}function l(e,t){if(!t)return e;if(!t.name&&!t.named&&!t.loc)return e;let r=`[${e}]`;const n=t.named||t.name;n&&(r+=` unit '${n}'`);const a=t.loc;return!n&&a&&(r+=` (${a.file}:${a.line}:${a.column})`),r}function d(e,t){const r=t?e:e[0];ke(r);let n=r.or;const a=r.and;if(a){const r=t?a:a[0];if(ye(r)&&'and'in r){const r=d(a,t);e=r[0],n={...n,...r[1]}}else e=a}return[e,n]}function u(e){const t=()=>e();return t.unsubscribe=()=>e(),t}function f(e,...t){const r=pe();if(r){const n=r.handlers[e];if(n)return n(r,...t)}}function p(e,t){const r=ct({or:t,and:'string'==typeof e?{name:e}:e}),a=l('event',r),i=(e,...t)=>(n(!L(i,'derived'),'call of derived event is not supported, use createEvent instead',a),n(!Xe,'unit call from pure function is not supported, use operators like sample instead',a),Ye?((e,t,r,n)=>{const a=Ye;let o=null;if(t)for(o=Ye;o&&o.template!==t;)o=V(o);et(o);const s=e.create(r,n);return et(a),s})(i,c,e,t):i.create(e,t)),c=pe(),d=Object.assign(i,{graphite:o({meta:yt(r.actualOp||z,i,r),regional:1}),create:e=>(s({target:i,params:e,scope:Je}),e),watch:e=>ht(i,e),map:e=>bt(i,O,e,[Fe()]),filter:e=>bt(i,'filter',e.fn?e:e.fn,[Fe(ze,1)]),filterMap:e=>bt(i,'filterMap',e,[Fe(),Oe((e=>!ve(e)),1)]),prepend(e){n(i.targetable,'.prepend of derived event is not supported, call source event instead',a);const t=p('* \u2192 '+i.shortName,{parent:V(i)});return f('eventPrepend',R(t)),mt(t,i,[Fe()],'prepend',e),gt(i,t),t}});return null!=r&&r.domain&&r.domain.hooks.event(d),W(d,'id',d.graphite.id),fe(d.graphite),d}function m(e,t,a,o,s){return Se(a,`${s} ${t}`,'first argument'),n(be(o),'second argument should be a function',s),ae(!L(e,'derived'),`${t} in derived store`,`${t} in store created via createStore`,s),r(Array.isArray(a)?a:[a],(t=>{e.off(t),T(e).set(t,pt(kt(t,e,'on',xe,o)))})),e}function h(e,t){const a=ct(t),i=De(e),c=l('store',a),d=p({named:'updates',derived:1});f('storeBase',i);const u=i.id,g='skipVoid'in a,y=g&&!a.skipVoid;ae(!(g&&a.skipVoid),'{skipVoid: true}','updateFilter',c);const b={subscribers:new Map,updates:d,defaultState:e,stateRef:i,getState(){let e,t=i;if(Ye){let t=Ye;for(;t&&!t.reg[u];)t=V(t);t&&(e=t)}return!e&&Je&&(ot(Je,i,1),e=Je),e&&(t=e.reg[u]),_e(t)},setState:e=>s({target:b,params:e,defer:1,scope:Je}),reset:(...e)=>(n(b.targetable,'.reset of derived store is not supported',c),r(e,(e=>m(b,'.reset',e,(()=>b.defaultState),c))),b),on:(e,t)=>(n(b.targetable,'.on of derived store is not supported',c),m(b,'.on',e,t,c)),off(e){const t=T(b).get(e);return t&&(t(),T(b).delete(e)),b},map(e,t){let r,n;ye(e)&&(r=e,e=e.fn);const a=b.getState(),o=ve(a);pe()?n=null:(!o||o&&y)&&(n=e(a));const s=h(n,{name:`${b.shortName} \u2192 *`,derived:1,...t,and:r}),c=kt(b,s,O,ze,e);return Ee(E(s),{type:O,fn:e,from:i}),E(s).noInit=1,f('storeMap',i,c),s},watch(e,t){if(ae(!t,'watch second argument','sample',c),!t||!H(e)){const t=ht(b,e);return f('storeWatch',i,e)||e(b.getState()),t}return n(be(t),'second argument should be a function',c),e.watch((e=>t(b.getState(),e)))}},v=yt(x,b,a),k=b.defaultConfig.updateFilter;b.graphite=o({scope:{state:i,fn:k},node:[Oe(((e,t,r)=>(r.scope&&!r.scope.reg[i.id]&&(r.b=1),e))),qe(i),Oe(((e,t,{a:r,b:n})=>{const a=ve(e);return a&&!g&&console.error(`${c}: ${vt}`),(a&&y||!a)&&(e!==r||n)}),1),k&&Fe($e,1),je({from:q,target:i})],child:d,meta:{...v,defaultState:e},regional:1}),W(b,'id',b.graphite.id),W(b,'rootStateRefId',u);const w=L(b,'serialize'),S=L(b,'derived'),M='ignore'===w,$=L(b,'sid');$&&(W(b,'storeChange',1),i.sid=$),$||M||S||W(b,'warnSerialize',1);const z=ve(e);return n(S||!z||z&&y,vt,c),S&&z&&!g&&console.error(`${c}: ${vt}`),he(b,[d]),null!=a&&a.domain&&a.domain.hooks.store(b),S||(b.reinit=p({named:'reinit'}),b.reset(b.reinit)),i.meta=b.graphite.meta,fe(b.graphite),b}function g(...e){let t,r,a;[e,a]=d(e);const o=l('combine',a),s=e[e.length-1],i=!J(s)&&ye(s),c=i&&s,u=i?e[e.length-2]:s;let f,p,m;if(be(u)?(r=e.slice(0,i?-2:-1),t=u):r=e,1===r.length){const e=r[0];J(e)||(f=e,p=1)}if(!p&&(f=r,t)){m=1;const e=t;t=t=>e(...t)}return n(ye(f),`${o}: shape should be an object`),wt(Array.isArray(f),!m,f,a,t,c)}function y(){const e={};return e.req=new Promise(((t,r)=>{e.rs=t,e.rj=r})),e.req.catch((()=>{})),e}function b(e,t={}){const r=ct(be(e)?{handler:e}:e,t),a=l('effect',r),i=p(be(e)?{handler:e}:e,{...t,actualOp:A}),c=R(i);W(c,'op',i.kind=A),i.use=e=>(n(be(e),'.use argument should be a function',a),b.scope.handler=e,i),i.use.getCurrent=()=>b.scope.handler;const d=i.finally=p({named:'finally',derived:1}),u=i.done=d.filterMap({named:'done',fn({status:e,params:t,result:r}){if('done'===e)return{params:t,result:r}}}),f=i.fail=d.filterMap({named:'fail',fn({status:e,params:t,error:r}){if('fail'===e)return{params:t,error:r}}}),m=i.doneData=u.map({named:'doneData',fn:({result:e})=>e}),g=i.failData=f.map({named:'failData',fn:({error:e})=>e}),b=o({scope:{handler:i.defaultConfig.handler||(()=>n(0,`no handler used in ${i.compositeName.fullName}`))},node:[Oe(((e,t,r)=>{let n=t.handler;const a=B(r);if(a){const e=a.handlers.unitMap.get(i)||a.handlers.sidMap[i.sid];e&&(n=e)}return e.handler=n,e}),0,1),Oe(((e,t,r)=>{if(t.runnerFn&&!t.runnerFn(e,null,r))return;const{params:n,req:a,handler:o,args:s=[n]}=e,i=Mt(n,a,1,d,r),c=Mt(n,a,0,d,r),[l,u]=St(o,c,s);l&&(ye(u)&&be(u.then)?u.then(i,c):i(u))}),0,1)],meta:{op:'fx',fx:'runner'}});c.scope.runner=b,ne(c.seq,Oe(((e,{runner:t},r)=>{const n=V(r)?{params:e,req:{rs(e){},rj(e){}}}:e;return r.meta||(r.meta={fxID:le()}),s({target:t,params:n,defer:1,scope:B(r),meta:r.meta}),n.params}))),i.create=e=>{const t=y(),r={params:e,req:t};if(Je&&!Qe){const e=Je;t.req.finally((()=>{Ze(e)})).catch((()=>{}))}return s({target:i,params:r,scope:Je}),t.req};const v=i.inFlight=h(0,{serialize:'ignore',named:(L(i,'name')||i.graphite.id)+'.inFlight'}).on(i,(e=>e+1)).on(d,(e=>e-1)).map({fn:e=>e,named:'inFlight'});W(d,'needFxCounter','dec'),W(i,'needFxCounter',1);const k=i.pending=v.map({fn:e=>e>0,named:'pending'});return he(i,[d,u,f,m,g,k,v]),null!=r&&r.domain&&r.domain.hooks.effect(i),i}function v(e,t){const r=l('merge',t);Se(e,r,'first argument');const n=p({name:i(e,'merge'),derived:1,and:t});return mt(e,n,[],'merge'),n}function k(e,t){let a=0;return r(xt,(r=>{r in e&&(n(null!=e[r],zt(t,r)),a=1)})),a}function w(e,t,n){const a=[];(function e(o){te(a,o)||(ne(a,o),L(o,'op')===x&&(n||L(o,'sid'))&&t(o,L(o,'sid')),r(o.next,e),r(D(o),e),r(_(o),e))})(e)}function S(e,t){const a=Array.isArray(e)?new Map(e):e,o=new Map;let s=0;if(a instanceof Map){const e={};return r(a,((r,a)=>{n(H(a),'Map key should be a unit'),t&&t(a,r),a.sid&&(a.sid in e&&(s=1),e[a.sid]=r),o.set(a,r)})),{sidMap:e,unitMap:o,hasSidDoubles:s}}return{sidMap:a,unitMap:o}}function M(e,t){return J(t)?[Re.mov({store:t.stateRef,to:'stack'}),...e]:e}const $='undefined'!=typeof Symbol&&Symbol.observable||'@@observable',x='store',z='event',A='effect',N='domain',j='scope',C='sampler',I='crosslink',O='map',q='stack',F='value',R=e=>e.graphite||e,D=e=>e.family.owners,_=e=>e.family.links,E=e=>e.stateRef,P=e=>e.value,T=e=>e.subscribers,V=e=>e.parent,B=e=>e.scope,L=(e,t)=>R(e).meta[t],W=(e,t,r)=>R(e).meta[t]=r,G=e=>e.compositeName,H=e=>(be(e)||ye(e))&&'kind'in e,U=e=>t=>H(t)&&t.kind===e,J=U(x),K=U(z),Q=U(A),X=e=>H(e)&&!!e.targetable,Y=U(N),Z=U(j);var ee={__proto__:null,unit:H,store:J,event:K,effect:Q,targetable:X,domain:Y,scope:Z,attached:e=>Q(e)&&1==L(e,'attached')};const te=(e,t)=>e.includes(t),re=(e,t)=>{const r=e.indexOf(t);-1!==r&&e.splice(r,1)},ne=(e,t)=>e.push(t),ae=(e,t,r,n)=>!e&&console.error(`${n?n+': ':''}${t} is deprecated${r?`, use ${r} instead`:''}`),oe=()=>{let e=0;return()=>""+ ++e},se=oe(),ie=oe(),ce=oe(),le=oe();let de,ue=null;const fe=e=>{de&&de(e,ue)},pe=()=>ue&&ue.template,me=e=>(e&&ue&&ue.sidRoot&&(e=`${ue.sidRoot}|${e}`),e),he=(e,t)=>{const n=R(e);r(t,(e=>{const t=R(e);n.family.type!==N&&(t.family.type=I),ne(D(t),n),ne(_(n),t)}))},ge=(e=[])=>(Array.isArray(e)?e:[e]).flat().map(R),ye=e=>'object'==typeof e&&null!==e,be=e=>'function'==typeof e,ve=e=>void 0===e,ke=e=>n(ye(e)||be(e),'expect first argument be an object'),we=(e,t,r,a)=>n(!(!ye(e)&&!be(e)||!('family'in e)&&!('graphite'in e)),`${t}: expect ${r} to be a unit (store, event or effect)${a}`),Se=(e,t,n)=>{Array.isArray(e)?r(e,((e,r)=>we(e,t,`${r} item of ${n}`,''))):we(e,t,n,' or array of units')},Me=(e,t,a="target")=>r(ge(t),(t=>n(!L(t,'derived'),`${e}: derived unit in "${a}" is not supported, use createStore/createEvent instead"`))),$e=(e,{fn:t},{a:r})=>t(e,r),xe=(e,{fn:t},{a:r})=>t(r,e),ze=(e,{fn:t})=>t(e),Ae=(e,t,r,n)=>{const a={id:ie(),type:e,data:t};return r&&(a.order={priority:r},n&&(a.order.barrierID=++Ne)),a};let Ne=0;const je=({from:e=x,store:t,target:r,to:n=(r?x:q),batch:a,priority:o})=>Ae('mov',{from:e,store:t,to:n,target:r},o,a),Ce=({fn:e,batch:t,priority:r,safe:n=0,filter:a=0,pure:o=0})=>Ae('compute',{fn:e,safe:n,filter:a,pure:o},r,t),Ie=({fn:e})=>Ce({fn:e,priority:A}),Oe=(e,t,r)=>Ce({fn:e,safe:1,filter:t,priority:r&&A}),qe=(e,t,r)=>je({store:e,to:t?q:"a",priority:r&&C,batch:1}),Fe=(e=ze,t)=>Ce({fn:e,pure:1,filter:t}),Re={mov:je,compute:Ce,filter:({fn:e,pure:t})=>Ce({fn:e,filter:1,pure:t}),run:Ie},De=e=>({id:ie(),current:e,initial:e}),_e=({current:e})=>e,Ee=(e,t)=>{e.before||(e.before=[]),ne(e.before,t)};let Pe=null;const Te=(e,t)=>{if(!e)return t;if(!t)return e;let r;return(e.v.type===t.v.type&&e.v.id>t.v.id||He(e.v.type)>He(t.v.type))&&(r=e,e=t,t=r),r=Te(e.r,t),e.r=e.l,e.l=r,e},Ve=[];let Be=0;for(;Be<6;)ne(Ve,{first:null,last:null,size:0}),Be+=1;const Le=()=>{for(let e=0;e<6;e++){const t=Ve[e];if(t.size>0){if(3===e||4===e){t.size-=1;const e=Pe.v;return Pe=Te(Pe.l,Pe.r),e}1===t.size&&(t.last=null);const r=t.first;return t.first=r.r,t.size-=1,r.v}}},We=(e,t,r,n,a,o,s)=>Ge(0,{a:null,b:null,node:r,parent:n,value:a,page:t,scope:o,meta:s},e,0),Ge=(e,t,r,n)=>{const a=He(r),o=Ve[a],s={v:{idx:e,stack:t,type:r,id:n},l:null,r:null};3===a||4===a?Pe=Te(Pe,s):(0===o.size?o.first=s:o.last.r=s,o.last=s),o.size+=1},He=e=>{switch(e){case'child':return 0;case'pure':return 1;case'read':return 2;case'barrier':return 3;case'sampler':return 4;case'effect':return 5;default:return-1}},Ue=new Set;let Je,Ke=1,Qe=0,Xe=0,Ye=null;const Ze=e=>{Je=e},et=e=>{Ye=e},tt=(e,t)=>{if(e){for(;e&&!e.reg[t];)e=e.parent;if(e)return e}return null},rt=(e,t,r,n)=>{const a=tt(e,r.id);return a?a.reg[r.id]:t?(ot(t,r,n),t.reg[r.id]):r};let nt;const at=e=>e,ot=(e,t,n,a,o)=>{const s=e.reg;if(s[t.id])return;const i=t.sid,c={id:t.id,current:t.initial,meta:t.meta};if(c.id in e.values.idMap)c.current=e.values.idMap[c.id];else if(i&&i in e.values.sidMap&&!(i in e.sidIdMap)){var l;const r=null==t||null===(l=t.meta)||void 0===l?void 0:l.serialize;c.current=(e.fromSerialize&&'ignore'!==r&&(null==r?void 0:r.read)||at)(e.values.sidMap[i])}else if(t.before&&!o){let o=0;const i=n||!t.noInit||a;r(t.before,(t=>{switch(t.type){case'map':{const r=t.from;if((r||t.fn)&&(r&&ot(e,r,n,a),i)){const e=r&&s[r.id].current;c.current=t.fn?t.fn(e):e}break}case'field':ot(e,t.from,n,a),o||(o=1,c.current=Array.isArray(c.current)?[...c.current]:{...c.current}),i&&(c.current[t.field]=s[s[t.from.id].id].current)}}))}i&&(e.sidIdMap[i]=t.id),s[t.id]=c},st=(e,t,r)=>{try{return t(P(r),e.scope,r)}catch(t){console.error(t),e.fail=1,e.failReason=t}},ct=(e,r={})=>(ye(e)&&(ct(e.or,r),t(e,((e,t)=>{ve(e)||'or'===t||'and'===t||(r[t]=e)})),ct(e.and,r)),r),lt=(e,t)=>{re(e.next,t),re(D(e),t),re(_(e),t)},dt=(e,t,r)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let a=_(e);for(;n=a.pop();)lt(n,e),(t||r&&'sample'!==e.meta.op||n.family.type===I)&&dt(n,t,'on'!==n.meta.op&&r);for(a=D(e);n=a.pop();)lt(n,e),r&&n.family.type===I&&dt(n,t,'on'!==n.meta.op&&r)},ut=e=>e.clear(),ft=(e,{deep:t}={})=>{let r=0;if(e.ownerSet&&e.ownerSet.delete(e),J(e))ut(T(e));else if(Y(e)){r=1;const t=e.history;ut(t.events),ut(t.effects),ut(t.stores),ut(t.domains)}dt(R(e),!!t,r)},pt=e=>u((()=>ft(e))),mt=(e,t,r,n,a)=>o({node:r,parent:e,child:t,scope:{fn:a},meta:{op:n},family:{owners:[e,t],links:t},regional:1}),ht=(e,t)=>(n(be(t),'.watch argument should be a function'),pt(o({scope:{fn:t},node:[Ie({fn:ze})],parent:e,meta:{op:'watch'},family:{owners:e},regional:1}))),gt=(e,t,r=z)=>{V(e)&&V(e).hooks[r](t)},yt=(e,t,r)=>{const n=ct(r),a=e===N,o=se(),{sid:s=null,named:i=null,domain:l=null,parent:d=l}=n,u=i||n.name||(a?'':o),f=c(u,d),p={op:t.kind=e,name:t.shortName=u,sid:t.sid=me(s),named:i,unitId:t.id=o,serialize:n.serialize,derived:n.derived,config:n};if(t.targetable=!n.derived,t.parent=d,t.compositeName=f,t.defaultConfig=n,t.getType=()=>(ae(0,'getType','compositeName.fullName'),f.fullName),!a){t.subscribe=e=>(ke(e),t.watch(be(e)?e:t=>e.next&&e.next(t))),t[$]=()=>t;const e=pe();e&&(p.nativeTemplate=e)}return p},bt=(e,t,r,n)=>{let a;ye(r)&&(a=r,r=r.fn);const o=p({name:`${e.shortName} \u2192 *`,derived:1,and:a});return mt(e,o,n,t,r),o},vt='undefined is used to skip updates. To allow undefined as a value provide explicit { skipVoid: false } option',kt=(e,t,r,n,a)=>{const o=E(t),s=je({store:o,to:"a",priority:'read'});r===O&&(s.data.softRead=1);const i=[s,Fe(n)];return f('storeOnMap',o,i,J(e)&&E(e)),mt(e,t,i,r,a)},wt=(e,r,a,o,s,c)=>{const d=l('combine',o),u=e?e=>[...e]:e=>({...e}),p=e?[]:{},m=u(p),g=De(m),y=De(1);g.type=e?'list':'shape',g.noInit=1,f('combineBase',g,y);const b=h(m,{name:i(a),derived:1,...c,and:o}),v=E(b);v.noInit=1,W(b,'isCombine',1);const k=qe(g);k.order={priority:'barrier'};const w=je({store:v,to:'b',priority:'read'});w.data.softRead=1;const S=[Oe(((e,t,r)=>(r.scope&&!r.scope.reg[g.id]&&(r.c=1),e))),k,je({store:y,to:'b'}),Oe(((e,{key:t},n)=>{if(n.c||e!==n.a[t])return r&&n.b&&(n.a=u(n.a)),n.a[t]=e,1}),1),je({from:"a",target:g}),je({from:F,store:0,target:y}),je({from:F,store:1,target:y,priority:'barrier',batch:1}),qe(g,1,1),s&&Fe(),w];if(t(a,((e,t)=>{if(!J(e))return n(!H(e)&&!ve(e),`combine expects a store in a field ${t}`,d),void(m[t]=p[t]=e);p[t]=e.defaultState,m[t]=e.getState();const r=mt(e,b,S,'combine',s);r.scope.key=t;const a=E(e);Ee(g,{type:'field',field:t,from:a}),f('combineField',a,r)})),b.defaultShape=a,Ee(v,{type:O,from:g,fn:s}),!pe())if(s){const e=s(m);!ve(e)||c&&'skipVoid'in c||console.error(`${d}: ${vt}`),v.current=e,v.initial=e,b.defaultState=e}else b.defaultState=p;return b},St=(e,t,r)=>{try{return[1,e(...r)]}catch(e){return t(e),[0,null]}},Mt=(e,t,r,n,a)=>o=>{s({target:[n,$t],params:[r?{status:'done',params:e,result:o}:{status:'fail',params:e,error:o},{value:o,fn:r?t.rs:t.rj}],defer:1,page:a.page,scope:a.scope,meta:a.meta})},$t=o({node:[Ie({fn:({fn:e,value:t})=>e(t)})],meta:{op:'fx',fx:'sidechain'}}),xt=['source','clock','target'],zt=(e,t)=>e+`: ${t} should be defined`,At=(e,t,r,a,o,s,i,c,d,u,m,y)=>{const b=l(e,c),k=!!o;n(!ve(r)||!ve(t),zt(b,'either source or clock'));let w=0;ve(r)?w=1:H(r)||(r=g(r)),ve(t)?t=r:(Se(t,b,'clock'),Array.isArray(t)&&(t=v(t))),w&&(r=t),c||i||(i=r.shortName);let S='none';(m||a)&&(H(a)?S='unit':(n(be(a),'`filter` should be function or unit'),S='fn')),o?(Se(o,b,'target'),Me(b,o)):'none'===S&&u&&J(r)&&J(t)?o=h(s?s(_e(E(r)),_e(E(t))):_e(E(r)),{name:i,sid:y,or:c}):(o=p({name:i,derived:1,or:c}),f('sampleTarget',R(o)));const M=De();let $=[];if('unit'===S){const[r,n,s]=jt(a,o,t,M,e);s||$.push(...Nt(n)),$.push(...Nt(r))}const x=[];if(w)d&&x.push(qe(M,1,1));else{const[n,a,s]=jt(r,o,t,M,e);s||x.push(...Nt(a)),x.push(qe(n,1,d))}const z=mt(t,o,[f('sampleSourceLoader'),je({from:q,target:M}),...x,...$,qe(M),'fn'===S&&Fe(((e,t,{a:r})=>a(e,r)),1),s&&Fe($e),f('sampleSourceUpward',k)],e,s);return he(r,[z]),Object.assign(z.meta,c,{joint:1}),o},Nt=e=>[qe(e),Oe(((e,t,{a:r})=>r),1)],jt=(e,t,r,n,a)=>{const s=J(e),i=s?E(e):De(),c=De(s);return s||o({parent:e,node:[je({from:q,target:i}),je({from:F,store:1,target:c})],family:{owners:[e,t,r],links:t},meta:{op:a},regional:1}),f('sampleSource',c,i,n),[i,c,s]},Ct=(e,t,r,n)=>{const a=e[t];a&&s({target:a,params:Array.isArray(a)?a.map((()=>r)):r,defer:1,stack:n})},It=e=>!e.node.meta.isCombine||e.parent&&'combine'!==e.parent.node.meta.op,Ot=e=>e;e.allSettled=(e,{scope:t,params:r}={})=>{if(!H(e))return Promise.reject(new Error('first argument should be unit'));if(!(Q(e)||K(e)||J(e)||Z(e)))return Promise.reject(new Error('first argument accepts only effects, events, stores or scopes'));Z(e)&&(t=e);const n=y();n.parentFork=Je;const{fxCount:a}=t;ne(a.scope.defers,n);const o=[],i=[];return Z(e)||(ne(o,e),ne(i,Q(e)?{params:r,req:{rs(e){n.value={status:'done',value:e}},rj(e){n.value={status:'fail',value:e}}}}:r)),ne(o,a),ne(i,null),s({target:o,params:i,scope:t}),n.req},e.attach=e=>{let t;[e,t]=d(e,1);const r=l('attach',t);let{source:a,effect:o,mapParams:i,domain:u}=e;Q(o)&&n(ve(u),'`domain` can only be used with a plain function',r);const f=b(e,t);W(f,'attached',1);const{runner:p}=R(f).scope;let m;const h=(e,t,r)=>{const{params:n,req:o,handler:c}=e,l=f.finally,d=Mt(n,o,0,l,r),u=r.a,p=Q(c);let m,h=1;if(i?[h,m]=St(i,d,[n,u]):m=a&&p?u:n,h){if(!p)return e.args=[u,m],1;s({target:c,params:{params:m,req:{rs:Mt(n,o,1,l,r),rj:d}},page:r.page,defer:1,meta:r.meta})}};if(a){let e;p.scope.runnerFn=h,J(a)?(e=a,he(e,[f])):(e=g(a),he(f,[e])),m=[Oe((e=>e),0,1),qe(E(e))],delete p.seq[1].order}else m=[Oe(h,1,1)];p.seq.splice(1,0,...m),f.use(o);const y=V(o);return y&&(Object.assign(G(f),c(f.shortName,y)),f.defaultConfig.parent=y),gt(o,f,A),f},e.clearNode=ft,e.combine=g,e.createApi=(...e)=>{let[[r,n],a]=d(e);const o={};return t(n,((e,t)=>{const n=o[t]=p(t,{parent:V(r),config:a});r.on(n,e),gt(r,n)})),o},e.createDomain=function e(n,a){const i=ct({or:a,and:'string'==typeof n?{name:n}:n}),c=o({family:{type:N},regional:1,parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent)}),l={history:{},graphite:c,hooks:{}};c.meta=yt(N,l,{parent:(null==i?void 0:i.domain)||(null==i?void 0:i.parent),or:{...i,derived:1}}),t({Event:p,Effect:b,Store:h,Domain:e},((e,t)=>{const n=t.toLowerCase(),a=(e=>p({named:e}))(`on${t}`);l.hooks[n]=a;const o=new Set;l.history[`${n}s`]=o,a.create=e=>(s(a,e),e),ne(R(a).seq,Oe(((e,t,r)=>(r.scope=null,e)))),a.watch((e=>{he(l,[e]),o.add(e),e.ownerSet||(e.ownerSet=o),V(e)||(e.parent=l)})),he(l,[a]),l[`onCreate${t}`]=e=>(r(o,e),a.watch(e)),l[`create${t}`]=l[n]=(t,r)=>{const n=ct({and:r,or:t});return null!=n&&n.domain?e(t,r):a(e(t,{parent:l,or:n}))}}));const d=V(l);return d&&t(l.hooks,((e,t)=>mt(e,d.hooks[t]))),null!=i&&i.domain&&i.domain.hooks.domain(l),l},e.createEffect=b,e.createEvent=p,e.createNode=o,e.createStore=h,e.createWatch=({unit:e,fn:t,scope:r,batch:n})=>{const a=[Re.run({fn:e=>t(e)})];n&&a.unshift(Re.compute({priority:'sampler',batch:1})),J(e)&&a.unshift(Re.mov({store:e.stateRef,to:'stack'}));const s=Array.isArray(e)?e:[e];if(r){const e=[],t=r.additionalLinks;return s.forEach((r=>{const n=t[r.graphite.id]||[];t[r.graphite.id]=n;const s=o({node:M(a,r),meta:{watchOp:r.kind}});n.push(s),e.push((()=>{const e=n.indexOf(s);-1!==e&&n.splice(e,1),ft(s)}))})),u((()=>{e.forEach((e=>e()))}))}{const e=o({node:a,parent:s,family:{owners:s}});return u((()=>{ft(e)}))}},e.fork=(e,t)=>{let a,s=e;Y(e)&&(ae(0,'fork(domain)','fork()'),a=e,s=t);const i=(e=>{const t=o({scope:{defers:[],inFlight:0,fxID:0},node:[Oe(((e,t,r)=>{r.parent?'dec'===r.parent.node.meta.needFxCounter?t.inFlight-=1:(t.inFlight+=1,t.fxID+=1):t.fxID+=1})),Ce({priority:C,batch:1}),Oe(((e,t)=>{const{defers:n,fxID:a}=t;t.inFlight>0||0===n.length||Promise.resolve().then((()=>{t.fxID===a&&r(n.splice(0,n.length),(e=>{Ze(e.parentFork),e.rs(e.value)}))}))}),0,1)]}),n=o({node:[Oe(((e,t,r)=>{const n=r.parent;if(n){const t=n.node;if(It(n)){const n=B(r),a=t.meta.sid;n.sidIdMap[a]=t.scope.state.id,n.values.sidMap[a]=e;const o=t.meta.serialize;o&&n.sidSerializeSettings.set(a,'ignore'===o?{ignore:1}:{ignore:0,write:o.write})}}}))]}),a=o({node:[Oe(((e,t,r)=>{const n=B(r);n&&r.parent&&It(r.parent)&&(n.warnSerialize=1)}))]}),s={cloneOf:e,reg:{},values:{sidMap:{},idMap:{}},sidIdMap:{},sidSerializeSettings:new Map,getState(e){if('current'in e)return rt(Ye,s,e,0).current;const t=R(e);return rt(Ye,s,t.scope.state,1).current},kind:j,graphite:o({family:{type:N,links:[t,n,a]},meta:{unit:'fork'},scope:{forkInFlightCounter:t}}),additionalLinks:{},handlers:{sidMap:{},unitMap:new Map},fxCount:t,storeChange:n,warnSerializeNode:a};return s})(a);if(s){if(s.values){const{sidMap:e,unitMap:t,hasSidDoubles:a}=S(s.values,(e=>n(J(e)&&X(e),'Values map can contain only writable stores as keys')));Object.assign(i.values.sidMap,e),r(t,((e,t)=>{if(i.values.idMap[t.stateRef.id]=e,'ignore'===L(t,'serialize')){const e=L(t,'sid');i.sidSerializeSettings.set(e,{ignore:1})}})),i.fromSerialize=!(Array.isArray(s.values)||s.values instanceof Map),i.hasSidDoubles=a}s.handlers&&(ae(s.handlers instanceof Map||Array.isArray(s.handlers),'object with handlers','array'),i.handlers=S(s.handlers,(e=>n(Q(e),"Handlers map can contain only effects as keys"))))}return i},e.forward=e=>{const t='forward',[{from:r,to:n},a]=d(e,1),s=l(t,a);return ae(0,t,'sample',s),Se(r,s,'"from"'),Se(n,s,'"to"'),Me(s,n,'to'),pt(o({parent:r,child:n,meta:{op:t,config:a},family:{},regional:1}))},e.fromObservable=e=>{ke(e);const t=$ in e?e[$]():e;n(t.subscribe,'expect observable to have .subscribe');const r=p(),a=pt(r);return t.subscribe({next:r,error:a,complete:a}),r},e.guard=(...e)=>{let[[t,r],n]=d(e);const a=l('guard',n);return ae(0,'guard','sample',a),r||(r=t,t=r.source),k(r,a),At('guard',r.clock,t,r.filter,r.target,null,r.name,n,!r.greedy,0,1)},e.hydrate=(e,{values:t})=>{n(ye(t),'values property should be an object');const{sidMap:a,unitMap:o}=S(t),i=Object.getOwnPropertyNames(a),c={};r(o,((e,t)=>{c[t.stateRef.id]=t}));const l=[],d=[];let u,f,p;Z(e)?(u=e,p=1,n(u.cloneOf,'scope should be created from domain'),ae(0,'hydrate(fork(domain), { values })','fork({ values })'),f=R(u.cloneOf)):Y(e)?(ae(0,'hydrate(domain, { values })','fork({ values })'),f=R(e)):n(0,'first argument of hydrate should be domain or scope'),w(f,((e,t)=>{if(t&&te(i,t)){ne(l,e);const r=L(e,'serialize');r&&'ignore'!==r&&(a[t]=r.read(a[t])),ne(d,a[t])}else e.scope.state.id in c&&(ne(l,e),ne(d,o.get(c[e.scope.state.id])))}),1),s({target:l,params:d,scope:u}),p&&Object.assign(u.values.sidMap,a)},e.is=ee,e.launch=s,e.merge=v,e.restore=(e,r,a)=>{const o=l('restore',a);if(n(!J(e),'restore($store) is not supported',o),K(e)||Q(e)){const t=V(e),n=h(r,{parent:t,name:e.shortName,and:a});return mt(Q(e)?e.doneData:e,n),t&&t.hooks.store(n),n}const s=Array.isArray(e)?[]:{};return t(e,((e,t)=>s[t]=J(e)?e:h(e,{name:t}))),s},e.sample=(...e)=>{let t,r,n,a,[[o,s,i],c]=d(e),u=1;const f=l('sample',c);return ve(s)&&ye(o)&&k(o,f)&&(s=o.clock,i=o.fn,'batch'in o?u=o.batch:(ae(!('greedy'in o),'greedy in sample','batch',f),u=!o.greedy),a=o.filter,t=o.target,r=o.name,n=o.sid,o=o.source),At('sample',s,o,a,t,i,r,c,u,1,0,n)},e.scopeBind=(e,{scope:t,safe:r}={})=>{n(t||Je||r,'scopeBind: scope not found');const a=t||Je;return Q(e)?t=>{const r=y();return s({target:e,params:{params:t,req:r},scope:a}),r.req}:t=>(s({target:e,params:t,scope:a}),t)},e.serialize=(e,r={})=>{e.warnSerialize&&console.error('There is a store without sid in this scope, its value is omitted'),n(!e.hasSidDoubles,'duplicate sid found in this scope');const a=r.ignore?r.ignore.map((({sid:e})=>e)):[],o={};return t(e.values.sidMap,((t,r)=>{var n;if(te(a,r))return;const s=e.sidIdMap[r],i=null!==(n=e.sidSerializeSettings.get(r))&&void 0!==n?n:{ignore:0,write:Ot};i.ignore||(o[r]=(0,i.write)(s&&s in e.reg?e.reg[s].current:t))})),'onlyChanges'in r&&(ae(0,'onlyChanges'),r.onlyChanges||(n(e.cloneOf,'scope should be created from domain'),w(R(e.cloneOf),((t,r)=>{r in o||te(a,r)||L(t,'isCombine')||'ignore'===L(t,'serialize')||(o[r]=e.getState(t))})))),o},e.setGraphInspector=e=>{de=e},e.setInspector=e=>{nt=e},e.setStoreName=(e,t)=>{e.shortName=t,Object.assign(G(e),c(t,V(e)))},e.split=(...e)=>{const r='split';let a,s,[[i,c],u]=d(e);const m=l(r,u),h=!c;h&&(a=i.cases,c=i.match,s=i.clock,i=i.source);const g=J(c),y=!H(c)&&be(c),b=!g&&!y&&ye(c);n(H(i),'source must be a unit',m),a||(a={}),h?t(a,((e,t)=>Me(m,e,`cases.${t}`))):(n(b,'match should be an object',m),t(c,((e,t)=>a[t]=p({derived:1,named:`cases.${t}`,and:u}))),a.__=p({derived:1,named:'cases.__',and:u}));const v=new Set([].concat(i,s||[],Object.values(a))),k=Object.keys(g||y?a:c);let w;if(g||y)g&&v.add(c),w=[g&&qe(E(c),0,1),Ce({safe:g,filter:1,pure:!g,fn(e,t,r){const n=String(g?r.a:c(e));Ct(t,te(k,n)?n:'__',e,r)}})];else if(b){const e=De({});e.type='shape';const r=[];let n;t(c,((t,a)=>{if(H(t)){n=1,ne(r,a),v.add(t);const o=mt(t,[],[qe(e),Oe(((e,t,{a:r})=>r[a]=e))]);if(J(t)){e.current[a]=t.getState();const r=E(t);Ee(e,{from:r,field:a,type:'field'}),f('splitMatchStore',r,o)}}})),n&&f('splitBase',e),w=[n&&qe(e,0,1),Fe(((e,t,n)=>{for(let a=0;a<k.length;a++){const o=k[a];if(te(r,o)?n.a[o]:c[o](e))return void Ct(t,o,e,n)}Ct(t,'__',e,n)}),1)]}else n(0,'expect match to be unit, function or object');const S=o({meta:{op:r},parent:s?[]:i,scope:a,node:w,family:{owners:Array.from(v)},regional:1});if(s&&At(r,s,i,null,S,null,r,u,0,0,0),!h)return a},e.step=Re,e.version="23.0.0",e.withFactory=({sid:e,name:t,loc:r,method:n,fn:s})=>a(o({meta:{sidRoot:me(e),sid:e,name:t,loc:r,method:n,type:'factory'}}),s),e.withRegion=a,Object.defineProperty(e,'__esModule',{value:1})})); | ||
//# sourceMappingURL=effector.umd.js.map |
{ | ||
"name": "effector", | ||
"version": "23.0.0-rc.6", | ||
"version": "23.0.0", | ||
"description": "Business logic with ease", | ||
@@ -5,0 +5,0 @@ "main": "effector.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
1401381