Comparing version 0.16.5 to 0.16.6
@@ -214,2 +214,13 @@ import {Store, Event, Step} from 'effector' | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => boolean | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
export function route<T, S extends T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => value is S | ||
fn: (config: {store: Store<S>}) => void | ||
}): void | ||
export function node(fn: (node: DOMElement) => void): void | ||
@@ -216,0 +227,0 @@ |
@@ -1,2 +0,2 @@ | ||
function e(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function t(e){var t,n;e.status='active',t=a(e),(n=e).cursor.prev&&(n.cursor.prev.cursor.next=n.cursor.next),n.cursor.next&&(n.cursor.next.cursor.prev=n.cursor.prev),t.last===n&&(t.last=n.cursor.prev),t.first===n&&(t.first=n.cursor.next),n.cursor.prev=null,n.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function n(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function l(n,l){if(l.value.active===n)return l.value.pending=n,void('pending'===l.status&&(t(l),a(l).first||e(l.group,l.priority)));var r,i,o,s;'active'===l.status&&(l.status='pending',a(l).first||((o=l.group).queue[s=l.priority].last?(o.cursor[s].prev=o.queue[s].last,o.queue[s].last.cursor[s].next=o,o.queue[s].last=o):o.queue[s].first=o.queue[s].last=o),i=l,(r=a(l)).last?(i.cursor.prev=r.last,r.last.cursor.next=i,r.last=i):r.first=r.last=i),l.value.pending=n,l.group.queue.rafID||(l.group.queue.rafID=Q(l.group.queue.execQueue))}function r(a){z('execQueue');let n,l,r=_(),i=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(_()-r>=10){i=1;break e}let o=!!a.props.first;for(o&&z('props');n=a.props.first;){for(;l=n.activeChilds.props.first;){if(_()-r>=10){i=1,U('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'props')}o&&U('props');let s=!!a.tree.first;for(s&&z('tree');n=a.tree.first;){for(;l=n.activeChilds.tree.first;){if(_()-r>=10){i=1,U('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'tree')}s&&U('tree');let u=!!a.data.first;for(u&&z('data');n=a.data.first;){for(;l=n.activeChilds.data.first;){if(_()-r>=10){i=1,U('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'data')}u&&U('data')}if(U('execQueue'),i)a.rafID=Q(a.execQueue);else if(a.rafID=null,a.onDrain){let e=a.onDrain;a.onDrain=null,e()}}function i({value:e,runOp:t,group:a,priority:n}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:n,group:a,cursor:{prev:null,next:null}}}function o({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=r.bind(null,t),t}function s(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function u({value:e,group:t,onInit:a,onChange:n,onTerminate:r}){let o=i({value:e,group:t,runOp(e){s.status='A',n(e)},priority:'data'}),s={status:'IA',value:o.value,hooks:{onTerminate:r},ops:{init:i({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:o,terminate:i({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return l(1,s.ops.init),s}function c(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',l(1,e.ops.terminate);break;case'AA':e.status='AT',l(1,e.ops.terminate),l(e.value.active,e.ops.change);break;case'IA':e.status='T',l(0,e.ops.init),e.hooks.onTerminate(0)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',l(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',l(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function d(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function f(e,t,a){d(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function h(e,t,a){d(a)?delete e.style[t]:e.style[t]=""+a}function v(e,t,a){d(a)?delete e.dataset[t]:e.dataset[t]=""+a}function m(e,t,a){if(d(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function g(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function y({fn:e,state:t={},defer:a=0,name:n="",draft:l,isSvgRoot:r,namespace:i,env:o}){let s=J,u=W,c={id:++G,name:n,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,a){if(!a.page)return console.error('context lost',a),0;if(!a.page.active)return 0;let n=[a.page.template],l=[a.page];{let e=a.page.parent;for(;e;)l.push(e),n.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let r=t.meta.nativeTemplate;r?n.includes(r)?effector.launch({target:t,params:e,defer:1,page:l[n.indexOf(r)],stack:a}):console.error('context drift',{stack:a,node:t}):effector.launch({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===c)return 1;if(a.page.childSpawns[c.id])a.page.childSpawns[c.id].forEach(t=>{effector.launch({params:e,target:a.node,page:t,defer:1})});else if(t.targetTemplate){let n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),e=e.parent}let l=n.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===l?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:n[l],defer:1})}else c.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:a.node,page:t,defer:1})})}else c.pages.forEach(t=>{effector.launch({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(c);let p=effector.createNode({meta:{template:c}});W=c;let d=J={template:c,node:p,api:null,trigger:{mount:effector.createEvent(),unmount:effector.createEvent()},draft:l,isSvgRoot:r,namespace:i,env:o};return a?d.deferredInit=()=>{let a=J,n=W;J=d,W=c,d.deferredInit=null;try{effector.withRegion(p,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),c.nameMap=a})}finally{J=a,W=n}}:effector.withRegion(p,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),c.nameMap=a}),J=s,W=u,c.actor=d,d}function b(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function w(e,{values:t={},parentLeaf:a,mountNode:n,svgRoot:l,leafData:r,opGroup:i,domSubtree:o,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(e,t,a){let n;t.stop=1;try{for(;t.i<e.length;)n=e[t.i],t.i++,n.fn(a[n.of.id].current)}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++$,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let v={},m={spawn:h,api:v,draft:e.draft,ops:{group:i,domSubtree:o},svgRoot:l,data:r,parentLeaf:a,hydration:s},g=H;H=m,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:b(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,a=1)=>effector.launch({target:e.trigger.mount,params:t,defer:a,page:h}),v.unmount=(t,a=1)=>effector.launch({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)v[t]=(a,n=1)=>effector.launch({target:e.api[t],params:a,defer:n,page:h});return m.spawn.api=v,m.spawn.leaf=m,m.api.mount({node:n,leaf:m}),H=g,m}function x(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function k(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return k(e.child.child);case'LF':case'RF':case'FF':return S(e.child);case'FRec':case'FRecItem':return S(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=k(t);if(e)return e;t=t.left}return null}default:return null}}function S(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=k(t[e]);if(a)return a}return null}function I(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=k(a.child[e]);if(t)return t}return I(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=k(a.child[e]);if(t)return t}return I(a)}case'LF':{let t=e.parent.left;for(;t;){let e=k(t);if(e)return e;t=t.left}return I(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=k(e);if(n)return n}return I(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=k(e);if(n)return n}return I(t)}function C(e){let t=I(e);return t?t.value:null}function F(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r}){e.childTemplates.forEach(e=>{R({parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r,actor:e})})}function R({parentBlockFragment:e,leaf:t,node:a,actor:n,svgRoot:l,values:r}){let o,{draft:u}=n,{queue:c}=t.ops.group,p=s(c),d=t.ops.domSubtree,f=d;switch(u.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:u.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:u.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:i({value:0,priority:'tree',runOp(e){e?(T(t),o.needToCallNode&&(o.needToCallNode=0,effector.launch({target:K,params:{element:t.value,fns:u.node},page:h.spawn}))):(t.value.remove(),t.parent.visible=0)},group:d})},needToCallNode:u.node.length>0},f=s(c);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:u.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[u.inParentIndex]=t.parent,o={type:'list',draft:u,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+u.type)}let h=w(n,{values:r,parentLeaf:t,mountNode:a,svgRoot:l||t.svgRoot,leafData:o,opGroup:p,domSubtree:f,hydration:t.hydration})}function T(e){let t=C(e);t?t.after(e.value):x(e).prepend(e.value),e.parent.visible=1}function A(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let n in t){let l=t[n];a[n]=e.map('function'==typeof l?e=>l(e):e=>e[l])}return a}return e.map(e=>e[t])}function q(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function P(e){let t=J.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,n=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+n,value:e}))),t.childCount+=a.length):(t.text.push({index:n,value:a}),t.childCount+=1)}if(e.style&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?E(t.config||{},t.on):E(t)}e.ɔ&&P(e.ɔ)}function E(e,t){let a=J.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});let{passive:n=1,capture:l=0,prevent:r=0,stop:i=0}=e;a.handler.push({options:{prevent:r,stop:i},domConfig:{passive:r?0:n,capture:l},map:t})}function D({source:e,visible:t,fn:a}){if(!J)throw Error('route() called outside from using() closure');let n=y({name:'route',isSvgRoot:0,namespace:J.namespace,env:J.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:l,unmount:r}){let i=e.map(e=>({value:e,visible:t(e)})),o={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},s=y({name:'route item',isSvgRoot:0,namespace:J.namespace,env:J.env,draft:o,state:{store:null},fn({store:e},{mount:t,unmount:n}){let l=effector.createEvent();e.on(l,(e,t)=>t),a({store:e});let r=effector.sample({source:t,clock:i,fn:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,F(o,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),r.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:l,params:a,defer:1,page:e.spawn}),O(t,e)}),effector.sample({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{M(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,L(t,t.parent.childSpawns[t.template.id]),L(t,t.template.pages)})}});B(s);let{onMount:u,onState:c}=j({mount:l,state:i,onMount:({visible:e,value:t},{leaf:a,node:n})=>({leaf:a,visible:e,node:n,value:t}),onState:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n})});effector.merge([u,c]).watch(({leaf:e,visible:t,value:a,node:n})=>{let l=e.data;l.block.child.visible=t,t&&!l.initialized&&(R({parentBlockFragment:l.block.child.child,leaf:e,node:n,actor:s,values:{store:a}}),l.initialized=1)}),effector.sample({source:l,clock:r,greedy:1}).watch(({leaf:e})=>{M(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,L(t,t.parent.childSpawns[t.template.id]),L(t,t.template.pages)})}});B(n)}function O(e,t){let a=t=>{let n=t.data;switch(n.type){case'element':l(e,n.ops.visible);break;case'route':case'list':case'list item':M(t,a);break;default:console.log('unsupported type',n.type)}};M(t,a)}function M(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let n=a.childSpawns[e];for(let e=0;e<n.length;e++)t(n[e].leaf)}}function N(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:J.namespace,env:J.env,draft:t,defer:1,fn({store:a},{mount:n,unmount:l}){e({state:a});let r=effector.createEvent();return a.on(r,(e,t)=>t),n.watch(({node:e,leaf:a})=>{F(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),effector.sample({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,M(e,e=>{e.api.unmount()})}),{itemUpdater:r}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=J;B(y({name:'rec item',isSvgRoot:0,namespace:n,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:n,unmount:l}){let{onMount:r,onState:i}=j({state:e,mount:n,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});effector.sample({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,M(e,e=>{e.api.unmount()})}),i.watch(({state:e,leaf:t})=>{M(t,t=>{t.api.itemUpdater(e)})}),r.watch(({node:e,leaf:t,state:n})=>{R({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:n}})})}}))}}function V(e,t){'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:l,fields:r=[]}=e,i=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,o={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!J)throw Error('list() called outside from using() closure');let d=J.env,f=J.namespace;B(y({name:'list',draft:o,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:n}){let h=y({name:'list item',state:{id:-1,store:null},draft:o,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:n,unmount:l}){a({store:t,key:e,fields:A(t,r)});let i=effector.createEvent();t.on(i,(e,t)=>t);let s=effector.createStore({leaf:null});if(effector.sample({source:s,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;L(t,t.parent.child);let a=t.left,n=t.right;a&&(a.right=n,n||t.parent.lastChild!==t||(t.parent.lastChild=a)),n&&(n.left=a),a||n||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,M(e,e=>{e.api.unmount()});let{spawn:l}=e;l.active=0,L(l,l.parent.childSpawns[l.template.id]),L(l,l.template.pages)}),o.itemVisible){let{onMount:e,onState:t}=j({mount:n,state:o.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{s.setState({leaf:a});let n=a.data.block;n.visible=e,n.childInitialized=e,e&&F(o,{parentBlockFragment:n.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let n=a.data.block;n.visible=e,n.childInitialized?O(e,a):e&&(n.childInitialized=1,F(o,{parentBlockFragment:n.child,leaf:a,node:t}))})}else n.watch(({node:e,leaf:t})=>{s.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,F(o,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:i}},env:d}),v=effector.createStore([]),m=l.map(e=>e),g=effector.sample({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),b=effector.sample({source:g,clock:m,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1}),x=effector.merge([g,b]);effector.sample({source:v,clock:x,greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:r}){let o=n.data.block;z('list update ['+l.shortName+']');let d=Array(a.length).fill(0),f=a.map(i),v=[];for(let t=0;t<e.length;t++){let n=e[t],l=f.indexOf(n.key);-1!==l?(v.push(n),d[l]=1,p(a[l],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),c(n.asyncValue))}for(let e=0;e<a.length;e++){if(d[e])continue;let l=a[e],i=f[e],c=s(n.ops.group.queue),p={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:i,index:i,active:1,leafData:{type:'list item',block:p},asyncValue:u({value:l,group:c,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(r||(m.instance=w(h,{values:{id:i,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r})))}})},g=v.length;v.push(m);let y=g>0?v[g-1].leafData:null;if(p.child.parent=p,o.child.push(p),y){let e=y.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):o.lastChild=p,e.right=p}else o.lastChild=p;r&&(m.instance=w(h,{values:{id:i,store:l},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r}))}return U('list update ['+l.shortName+']'),0===v.length&&(o.lastChild=null),v},target:v}),effector.sample({source:t,clock:effector.sample({source:v,clock:n,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,L(a,a.parent.childSpawns[a.template.id]),L(a,a.template.pages)})},env:d}))}function B(e){if(!J)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(J.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=J.draft.childCount,J.draft.childCount+=1,J.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+J.draft.type)}}function L(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function j({mount:e,state:t,onMount:a,onState:n}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:n,greedy:1})}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let z,U,_;'undefined'!=typeof performance&&performance.mark?(z=e=>{performance.mark('☄️ '+e+' start')},U=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(z=()=>{},U=()=>{}),_='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let Q='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),G=0,$=0,W=null,H=null,J=null,K=effector.createEvent();K.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),exports.h=(e,t)=>{function a(e){return e.data.block.value}function r(e,t,a){let n=e.data.block.child.child,l={type:'text',parent:{type:'FT',parent:n,child:null,visible:0,index:a},value:null};if(l.parent.child=l,n.child[a]=l.parent,e.hydration){let e=I(l);if(e)switch(e.type){case'text':l.value=c.document.createTextNode(t),e.value.after(l.value);break;case'element':l.value=e.value.nextSibling,g(l.value,t)}else{let e=x(l);l.value=e.firstChild,g(l.value,t)}l.parent.visible=1}else l.value=c.document.createTextNode(t),T(l);return l}let o,s=0,u=0;if('function'==typeof t?(s=1,o=t):t&&(u=1,t.fn&&(s=1,o=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,o=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,o=t.ɔ.fn))),!J)throw Error('h() called outside from using() closure');let c=J.env,p=J.namespace,d=p,b='html';d=b='svg'===p?'svg':'html','svg'===e&&(b='svg',d='svg');let w='svg'===b?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(w.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(w.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let k=w,S={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:k,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},R=y({name:'element',draft:S,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return j({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let y=effector.createEvent(),b=c.map(({leaf:e})=>e);s&&o(),u&&P(t);let w={attr:{},data:{},text:S.text,styleProp:{},styleVar:{},visible:S.visible||null,handler:S.handler};for(let e=0;e<S.attr.length;e++){let t=S.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<S.data.length;e++){let t=S.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<S.styleProp.length;e++){let t=S.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<S.styleVar.length;e++){let t=S.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&S.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];effector.is.unit(t)?S.seq.push({type:'attr',field:e,value:t}):m(k,e,t)}for(let e in w.data){let t=w.data[e];effector.is.unit(t)?S.seq.push({type:'data',field:e,value:t}):v(k,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];effector.is.unit(t)?S.seq.push({type:'style',field:e,value:t}):h(k,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];effector.is.unit(t)?S.seq.push({type:'styleVar',field:e,value:t}):f(k,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(effector.is.unit(t.value)){S.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=W;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else S.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)S.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=j({mount:b,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let l=e.data,r=l.block;if(a&&(n(t,l.ops.visible),t)){let e,t=C(r);if(e=t?t.nextSibling:x(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,effector.launch({target:K,params:{element:l.block.value,fns:S.node},page:e.spawn,defer:1})),effector.launch({target:y,params:e,defer:1,page:e.spawn})}),effector.merge([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||l(t,e.data.ops.visible)})}for(let e=0;e<S.seq.length;e++){let t=S.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,n='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:o}=d(t.value);if(n)effector.merge([o,r]).watch(({leaf:t,value:n})=>{m(a(t),e,n)});else{let t=S.opsAmount++;r.watch(({value:n,leaf:l})=>{let r=a(l),o=i({value:n,priority:'props',runOp(t){m(r,e,t)},group:l.ops.group});l.ops.group.ops[t]=o,m(r,e,n)}),o.watch(({value:e,leaf:a})=>{l(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){v(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,v(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'style':{let e=S.opsAmount++,{field:n}=t,{onMount:r,onState:o}=d(t.value);r.watch(({value:t,leaf:l})=>{let r=a(l),o=i({value:t,priority:'props',runOp(e){h(r,n,e)},group:l.ops.group});l.ops.group.ops[e]=o,h(r,n,t)}),o.watch(({value:t,leaf:a})=>{l(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){f(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,f(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'staticText':y.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=S.opsAmount++;effector.sample({source:t.value,clock:y,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=i({value:a,priority:'props',runOp(e){g(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),effector.sample({source:y,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{l(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;y.watch(n=>{let l=null;if(e){let t=0,a=n.spawn;for(;!t&&a;)a.template===e?(t=1,l=a):a=a.parent}a(n).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:t.handler,params:e,page:l})},t.domConfig)});break}}}effector.sample({source:b,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;L(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,L(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!S.visible){let a=t.ops.visible,r=t.block;if(e.hydration){n(1,a);let e,t=C(r);if(e=t?t.nextSibling:x(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),effector.launch({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:K,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):l(1,a)}})},env:c});B(R)},exports.handler=E,exports.list=V,exports.node=e=>{let t=J.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},exports.rec=N,exports.remap=A,exports.route=D,exports.spec=P,exports.text=(e,...t)=>{let a=[e[0]];for(let n=0;n<t.length;n++)a.push(t[n],e[n+1]);P({text:a})},exports.tree=({source:e,child:t,fn:a})=>{let n=N(({state:e})=>{V({source:e,fn({store:e}){let l=e.map(e=>e[t]||[]);a({store:e,child(){n({state:l})}})}})});n({state:e})},exports.using=(e,t)=>{let a,n,l,r,i;if('function'==typeof t)a=t,l=q(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,l=t.env?t.env:q(),r=t.hydrate,n=t.onComplete,i=t.onRoot}if(!e)throw Error('using() first argument is missing');let u=e.namespaceURI,c=e.tagName.toLowerCase(),p={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:p,isSvgRoot:'svg'===c,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===c?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{F(p,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:l}),f={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};f.child.parent=f,f.child.child.parent=f.child;let h=o({onComplete:n}),v=w(d,{parentLeaf:H||null,mountNode:e,svgRoot:d.isSvgRoot?e:H?H.svgRoot:null,leafData:{type:'using',draft:p,element:e,block:f},opGroup:s(h),domSubtree:s(h),hydration:r});i&&i({template:d,leaf:v})},exports.variant=({source:e,cases:t,key:a})=>{let n='function'==typeof a?a:e=>String(e[a]),l=0;for(let a in t)'__'!==a?D({source:e,visible:e=>n(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);D({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}}; | ||
function e(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function t(e){var t,n;e.status='active',t=a(e),(n=e).cursor.prev&&(n.cursor.prev.cursor.next=n.cursor.next),n.cursor.next&&(n.cursor.next.cursor.prev=n.cursor.prev),t.last===n&&(t.last=n.cursor.prev),t.first===n&&(t.first=n.cursor.next),n.cursor.prev=null,n.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function n(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function l(n,l){if(l.value.active===n)return l.value.pending=n,void('pending'===l.status&&(t(l),a(l).first||e(l.group,l.priority)));var r,i,o,s;'active'===l.status&&(l.status='pending',a(l).first||((o=l.group).queue[s=l.priority].last?(o.cursor[s].prev=o.queue[s].last,o.queue[s].last.cursor[s].next=o,o.queue[s].last=o):o.queue[s].first=o.queue[s].last=o),i=l,(r=a(l)).last?(i.cursor.prev=r.last,r.last.cursor.next=i,r.last=i):r.first=r.last=i),l.value.pending=n,l.group.queue.rafID||(l.group.queue.rafID=Q(l.group.queue.execQueue))}function r(a){z('execQueue');let n,l,r=_(),i=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(_()-r>=10){i=1;break e}let o=!!a.props.first;for(o&&z('props');n=a.props.first;){for(;l=n.activeChilds.props.first;){if(_()-r>=10){i=1,U('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'props')}o&&U('props');let s=!!a.tree.first;for(s&&z('tree');n=a.tree.first;){for(;l=n.activeChilds.tree.first;){if(_()-r>=10){i=1,U('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'tree')}s&&U('tree');let u=!!a.data.first;for(u&&z('data');n=a.data.first;){for(;l=n.activeChilds.data.first;){if(_()-r>=10){i=1,U('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'data')}u&&U('data')}if(U('execQueue'),i)a.rafID=Q(a.execQueue);else if(a.rafID=null,a.onDrain){let e=a.onDrain;a.onDrain=null,e()}}function i({value:e,runOp:t,group:a,priority:n}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:n,group:a,cursor:{prev:null,next:null}}}function o({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=r.bind(null,t),t}function s(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function u({value:e,group:t,onInit:a,onChange:n,onTerminate:r}){let o=i({value:e,group:t,runOp(e){s.status='A',n(e)},priority:'data'}),s={status:'IA',value:o.value,hooks:{onTerminate:r},ops:{init:i({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:o,terminate:i({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return l(1,s.ops.init),s}function c(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',l(1,e.ops.terminate);break;case'AA':e.status='AT',l(1,e.ops.terminate),l(e.value.active,e.ops.change);break;case'IA':e.status='T',l(0,e.ops.init),e.hooks.onTerminate(0)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',l(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',l(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function d(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function f(e,t,a){d(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function h(e,t,a){d(a)?delete e.style[t]:e.style[t]=""+a}function v(e,t,a){d(a)?delete e.dataset[t]:e.dataset[t]=""+a}function m(e,t,a){if(d(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function g(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function y({fn:e,state:t={},defer:a=0,name:n="",draft:l,isSvgRoot:r,namespace:i,env:o}){let s=J,u=W,c={id:++G,name:n,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,a){if(!a.page)return console.error('context lost',a),0;if(!a.page.active)return 0;let n=[a.page.template],l=[a.page];{let e=a.page.parent;for(;e;)l.push(e),n.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let r=t.meta.nativeTemplate;r?n.includes(r)?effector.launch({target:t,params:e,defer:1,page:l[n.indexOf(r)],stack:a}):console.error('context drift',{stack:a,node:t}):effector.launch({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===c)return 1;if(a.page.childSpawns[c.id])a.page.childSpawns[c.id].forEach(t=>{effector.launch({params:e,target:a.node,page:t,defer:1})});else if(t.targetTemplate){let n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),e=e.parent}let l=n.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===l?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:n[l],defer:1})}else c.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:a.node,page:t,defer:1})})}else c.pages.forEach(t=>{effector.launch({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(c);let p=effector.createNode({meta:{template:c}});W=c;let d=J={template:c,node:p,api:null,trigger:{mount:effector.createEvent(),unmount:effector.createEvent()},draft:l,isSvgRoot:r,namespace:i,env:o};return a?d.deferredInit=()=>{let a=J,n=W;J=d,W=c,d.deferredInit=null;try{effector.withRegion(p,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),c.nameMap=a})}finally{J=a,W=n}}:effector.withRegion(p,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),c.nameMap=a}),J=s,W=u,c.actor=d,d}function b(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function w(e,{values:t={},parentLeaf:a,mountNode:n,svgRoot:l,leafData:r,opGroup:i,domSubtree:o,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(e,t,a){let n;t.stop=1;try{for(;t.i<e.length;)n=e[t.i],t.i++,n.fn(a[n.of.id].current)}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++$,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let v={},m={spawn:h,api:v,draft:e.draft,ops:{group:i,domSubtree:o},svgRoot:l,data:r,parentLeaf:a,hydration:s},g=H;H=m,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:b(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,a=1)=>effector.launch({target:e.trigger.mount,params:t,defer:a,page:h}),v.unmount=(t,a=1)=>effector.launch({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)v[t]=(a,n=1)=>effector.launch({target:e.api[t],params:a,defer:n,page:h});return m.spawn.api=v,m.spawn.leaf=m,m.api.mount({node:n,leaf:m}),H=g,m}function x(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function k(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return k(e.child.child);case'LF':case'RF':case'FF':return S(e.child);case'FRec':case'FRecItem':return S(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=k(t);if(e)return e;t=t.left}return null}default:return null}}function S(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=k(t[e]);if(a)return a}return null}function I(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=k(a.child[e]);if(t)return t}return I(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=k(a.child[e]);if(t)return t}return I(a)}case'LF':{let t=e.parent.left;for(;t;){let e=k(t);if(e)return e;t=t.left}return I(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=k(e);if(n)return n}return I(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=k(e);if(n)return n}return I(t)}function C(e){let t=I(e);return t?t.value:null}function F(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r}){e.childTemplates.forEach(e=>{R({parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r,actor:e})})}function R({parentBlockFragment:e,leaf:t,node:a,actor:n,svgRoot:l,values:r}){let o,{draft:u}=n,{queue:c}=t.ops.group,p=s(c),d=t.ops.domSubtree,f=d;switch(u.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:u.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:u.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:i({value:0,priority:'tree',runOp(e){e?(T(t),o.needToCallNode&&(o.needToCallNode=0,effector.launch({target:K,params:{element:t.value,fns:u.node},page:h.spawn}))):(t.value.remove(),t.parent.visible=0)},group:d})},needToCallNode:u.node.length>0},f=s(c);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:u.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[u.inParentIndex]=t.parent,o={type:'list',draft:u,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+u.type)}let h=w(n,{values:r,parentLeaf:t,mountNode:a,svgRoot:l||t.svgRoot,leafData:o,opGroup:p,domSubtree:f,hydration:t.hydration})}function T(e){let t=C(e);t?t.after(e.value):x(e).prepend(e.value),e.parent.visible=1}function A(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let n in t){let l=t[n];a[n]=e.map('function'==typeof l?e=>l(e):e=>e[l])}return a}return e.map(e=>e[t])}function E(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function q(e){let t=J.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,n=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+n,value:e}))),t.childCount+=a.length):(t.text.push({index:n,value:a}),t.childCount+=1)}if(e.style&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?P(t.config||{},t.on):P(t)}e.ɔ&&q(e.ɔ)}function P(e,t){if(!J)return;let a=J.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});for(let e in t)if(!effector.is.unit(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:n=1,capture:l=0,prevent:r=0,stop:i=0}=e;a.handler.push({options:{prevent:r,stop:i},domConfig:{passive:r?0:n,capture:l},map:t})}function D({source:e,visible:t,fn:a}){if(!J)throw Error('route() called outside from using() closure');let n=y({name:'route',isSvgRoot:0,namespace:J.namespace,env:J.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:l,unmount:r}){let i=e.map(e=>({value:e,visible:t(e)})),o={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},s=y({name:'route item',isSvgRoot:0,namespace:J.namespace,env:J.env,draft:o,state:{store:null},fn({store:e},{mount:t,unmount:n}){let l=effector.createEvent();e.on(l,(e,t)=>t),a({store:e});let r=effector.sample({source:t,clock:i,fn:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,F(o,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),r.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:l,params:a,defer:1,page:e.spawn}),O(t,e)}),effector.sample({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{M(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,L(t,t.parent.childSpawns[t.template.id]),L(t,t.template.pages)})}});B(s);let{onMount:u,onState:c}=j({mount:l,state:i,onMount:({visible:e,value:t},{leaf:a,node:n})=>({leaf:a,visible:e,node:n,value:t}),onState:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n})});effector.merge([u,c]).watch(({leaf:e,visible:t,value:a,node:n})=>{let l=e.data;l.block.child.visible=t,t&&!l.initialized&&(R({parentBlockFragment:l.block.child.child,leaf:e,node:n,actor:s,values:{store:a}}),l.initialized=1)}),effector.sample({source:l,clock:r,greedy:1}).watch(({leaf:e})=>{M(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,L(t,t.parent.childSpawns[t.template.id]),L(t,t.template.pages)})}});B(n)}function O(e,t){let a=t=>{let n=t.data;switch(n.type){case'element':l(e,n.ops.visible);break;case'route':case'list':case'list item':M(t,a);break;default:console.log('unsupported type',n.type)}};M(t,a)}function M(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let n=a.childSpawns[e];for(let e=0;e<n.length;e++)t(n[e].leaf)}}function N(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:J.namespace,env:J.env,draft:t,defer:1,fn({store:a},{mount:n,unmount:l}){e({state:a});let r=effector.createEvent();return a.on(r,(e,t)=>t),n.watch(({node:e,leaf:a})=>{F(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),effector.sample({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,M(e,e=>{e.api.unmount()})}),{itemUpdater:r}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=J;B(y({name:'rec item',isSvgRoot:0,namespace:n,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:n,unmount:l}){let{onMount:r,onState:i}=j({state:e,mount:n,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});effector.sample({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,M(e,e=>{e.api.unmount()})}),i.watch(({state:e,leaf:t})=>{M(t,t=>{t.api.itemUpdater(e)})}),r.watch(({node:e,leaf:t,state:n})=>{R({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:n}})})}}))}}function V(e,t){'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:l,fields:r=[]}=e,i=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,o={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!J)throw Error('list() called outside from using() closure');let d=J.env,f=J.namespace;B(y({name:'list',draft:o,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:n}){let h=y({name:'list item',state:{id:-1,store:null},draft:o,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:n,unmount:l}){a({store:t,key:e,fields:A(t,r)});let i=effector.createEvent();t.on(i,(e,t)=>t);let s=effector.createStore({leaf:null});if(effector.sample({source:s,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;L(t,t.parent.child);let a=t.left,n=t.right;a&&(a.right=n,n||t.parent.lastChild!==t||(t.parent.lastChild=a)),n&&(n.left=a),a||n||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,M(e,e=>{e.api.unmount()});let{spawn:l}=e;l.active=0,L(l,l.parent.childSpawns[l.template.id]),L(l,l.template.pages)}),o.itemVisible){let{onMount:e,onState:t}=j({mount:n,state:o.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{s.setState({leaf:a});let n=a.data.block;n.visible=e,n.childInitialized=e,e&&F(o,{parentBlockFragment:n.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let n=a.data.block;n.visible=e,n.childInitialized?O(e,a):e&&(n.childInitialized=1,F(o,{parentBlockFragment:n.child,leaf:a,node:t}))})}else n.watch(({node:e,leaf:t})=>{s.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,F(o,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:i}},env:d}),v=effector.createStore([]),m=l.map(e=>e),g=effector.sample({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),b=effector.sample({source:g,clock:m,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1}),x=effector.merge([g,b]);effector.sample({source:v,clock:x,greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:r}){let o=n.data.block;z('list update ['+l.shortName+']');let d=Array(a.length).fill(0),f=a.map(i),v=[];for(let t=0;t<e.length;t++){let n=e[t],l=f.indexOf(n.key);-1!==l?(v.push(n),d[l]=1,p(a[l],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),c(n.asyncValue))}for(let e=0;e<a.length;e++){if(d[e])continue;let l=a[e],i=f[e],c=s(n.ops.group.queue),p={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:i,index:i,active:1,leafData:{type:'list item',block:p},asyncValue:u({value:l,group:c,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(r||(m.instance=w(h,{values:{id:i,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r})))}})},g=v.length;v.push(m);let y=g>0?v[g-1].leafData:null;if(p.child.parent=p,o.child.push(p),y){let e=y.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):o.lastChild=p,e.right=p}else o.lastChild=p;r&&(m.instance=w(h,{values:{id:i,store:l},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r}))}return U('list update ['+l.shortName+']'),0===v.length&&(o.lastChild=null),v},target:v}),effector.sample({source:t,clock:effector.sample({source:v,clock:n,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,L(a,a.parent.childSpawns[a.template.id]),L(a,a.template.pages)})},env:d}))}function B(e){if(!J)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(J.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=J.draft.childCount,J.draft.childCount+=1,J.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+J.draft.type)}}function L(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function j({mount:e,state:t,onMount:a,onState:n}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:n,greedy:1})}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let z,U,_;'undefined'!=typeof performance&&performance.mark?(z=e=>{performance.mark('☄️ '+e+' start')},U=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(z=()=>{},U=()=>{}),_='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let Q='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),G=0,$=0,W=null,H=null,J=null,K=effector.createEvent();K.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),exports.h=(e,t)=>{function a(e){return e.data.block.value}function r(e,t,a){let n=e.data.block.child.child,l={type:'text',parent:{type:'FT',parent:n,child:null,visible:0,index:a},value:null};if(l.parent.child=l,n.child[a]=l.parent,e.hydration){let e=I(l);if(e)switch(e.type){case'text':l.value=c.document.createTextNode(t),e.value.after(l.value);break;case'element':l.value=e.value.nextSibling,g(l.value,t)}else{let e=x(l);l.value=e.firstChild,g(l.value,t)}l.parent.visible=1}else l.value=c.document.createTextNode(t),T(l);return l}let o,s=0,u=0;if('function'==typeof t?(s=1,o=t):t&&(u=1,t.fn&&(s=1,o=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,o=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,o=t.ɔ.fn))),!J)throw Error('h() called outside from using() closure');let c=J.env,p=J.namespace,d=p,b='html';d=b='svg'===p?'svg':'html','svg'===e&&(b='svg',d='svg');let w='svg'===b?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(w.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(w.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let k=w,S={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:k,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},R=y({name:'element',draft:S,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return j({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let y=effector.createEvent(),b=c.map(({leaf:e})=>e);s&&o(),u&&q(t);let w={attr:{},data:{},text:S.text,styleProp:{},styleVar:{},visible:S.visible||null,handler:S.handler};for(let e=0;e<S.attr.length;e++){let t=S.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<S.data.length;e++){let t=S.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<S.styleProp.length;e++){let t=S.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<S.styleVar.length;e++){let t=S.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&S.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];effector.is.unit(t)?S.seq.push({type:'attr',field:e,value:t}):m(k,e,t)}for(let e in w.data){let t=w.data[e];effector.is.unit(t)?S.seq.push({type:'data',field:e,value:t}):v(k,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];effector.is.unit(t)?S.seq.push({type:'style',field:e,value:t}):h(k,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];effector.is.unit(t)?S.seq.push({type:'styleVar',field:e,value:t}):f(k,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(effector.is.unit(t.value)){S.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=W;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else S.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)S.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=j({mount:b,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let l=e.data,r=l.block;if(a&&(n(t,l.ops.visible),t)){let e,t=C(r);if(e=t?t.nextSibling:x(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,effector.launch({target:K,params:{element:l.block.value,fns:S.node},page:e.spawn,defer:1})),effector.launch({target:y,params:e,defer:1,page:e.spawn})}),effector.merge([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||l(t,e.data.ops.visible)})}for(let e=0;e<S.seq.length;e++){let t=S.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,n='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:o}=d(t.value);if(n)effector.merge([o,r]).watch(({leaf:t,value:n})=>{m(a(t),e,n)});else{let t=S.opsAmount++;r.watch(({value:n,leaf:l})=>{let r=a(l),o=i({value:n,priority:'props',runOp(t){m(r,e,t)},group:l.ops.group});l.ops.group.ops[t]=o,m(r,e,n)}),o.watch(({value:e,leaf:a})=>{l(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){v(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,v(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'style':{let e=S.opsAmount++,{field:n}=t,{onMount:r,onState:o}=d(t.value);r.watch(({value:t,leaf:l})=>{let r=a(l),o=i({value:t,priority:'props',runOp(e){h(r,n,e)},group:l.ops.group});l.ops.group.ops[e]=o,h(r,n,t)}),o.watch(({value:t,leaf:a})=>{l(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){f(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,f(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'staticText':y.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=S.opsAmount++;effector.sample({source:t.value,clock:y,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=i({value:a,priority:'props',runOp(e){g(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),effector.sample({source:y,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{l(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;y.watch(n=>{let l=null;if(e){let t=0,a=n.spawn;for(;!t&&a;)a.template===e?(t=1,l=a):a=a.parent}a(n).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:t.handler,params:e,page:l})},t.domConfig)});break}}}effector.sample({source:b,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;L(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,L(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!S.visible){let a=t.ops.visible,r=t.block;if(e.hydration){n(1,a);let e,t=C(r);if(e=t?t.nextSibling:x(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),effector.launch({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:K,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):l(1,a)}})},env:c});B(R)},exports.handler=P,exports.list=V,exports.node=e=>{let t=J.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},exports.rec=N,exports.remap=A,exports.route=D,exports.spec=q,exports.text=(e,...t)=>{let a=[e[0]];for(let n=0;n<t.length;n++)a.push(t[n],e[n+1]);q({text:a})},exports.tree=({source:e,child:t,fn:a})=>{let n=N(({state:e})=>{V({source:e,fn({store:e}){let l=e.map(e=>e[t]||[]);a({store:e,child(){n({state:l})}})}})});n({state:e})},exports.using=(e,t)=>{let a,n,l,r,i;if('function'==typeof t)a=t,l=E(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,l=t.env?t.env:E(),r=t.hydrate,n=t.onComplete,i=t.onRoot}if(!e)throw Error('using() first argument is missing');let u=e.namespaceURI,c=e.tagName.toLowerCase(),p={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:p,isSvgRoot:'svg'===c,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===c?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{F(p,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:l}),f={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};f.child.parent=f,f.child.child.parent=f.child;let h=o({onComplete:n}),v=w(d,{parentLeaf:H||null,mountNode:e,svgRoot:d.isSvgRoot?e:H?H.svgRoot:null,leafData:{type:'using',draft:p,element:e,block:f},opGroup:s(h),domSubtree:s(h),hydration:r});i&&i({template:d,leaf:v})},exports.variant=({source:e,cases:t,key:a})=>{if(!effector.is.unit(e))throw Error('variant({source}) should be unit');let n;n='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let l=0;for(let a in t)'__'!==a?D({source:e,visible:e=>n(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);D({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}}; | ||
//# sourceMappingURL=forest.cjs.js.map |
@@ -214,2 +214,13 @@ import {Store, Event, Step} from 'effector' | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => boolean | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
export function route<T, S extends T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => value is S | ||
fn: (config: {store: Store<S>}) => void | ||
}): void | ||
export function node(fn: (node: DOMElement) => void): void | ||
@@ -216,0 +227,0 @@ |
@@ -1,2 +0,2 @@ | ||
function e(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function t(e){var t,n;e.status='active',t=a(e),(n=e).cursor.prev&&(n.cursor.prev.cursor.next=n.cursor.next),n.cursor.next&&(n.cursor.next.cursor.prev=n.cursor.prev),t.last===n&&(t.last=n.cursor.prev),t.first===n&&(t.first=n.cursor.next),n.cursor.prev=null,n.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function n(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function l(n,l){if(l.value.active===n)return l.value.pending=n,void('pending'===l.status&&(t(l),a(l).first||e(l.group,l.priority)));var r,i,o,s;'active'===l.status&&(l.status='pending',a(l).first||((o=l.group).queue[s=l.priority].last?(o.cursor[s].prev=o.queue[s].last,o.queue[s].last.cursor[s].next=o,o.queue[s].last=o):o.queue[s].first=o.queue[s].last=o),i=l,(r=a(l)).last?(i.cursor.prev=r.last,r.last.cursor.next=i,r.last=i):r.first=r.last=i),l.value.pending=n,l.group.queue.rafID||(l.group.queue.rafID=ie(l.group.queue.execQueue))}function r(a){ne('execQueue');let n,l,r=re(),i=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(re()-r>=10){i=1;break e}let o=!!a.props.first;for(o&&ne('props');n=a.props.first;){for(;l=n.activeChilds.props.first;){if(re()-r>=10){i=1,le('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'props')}o&&le('props');let s=!!a.tree.first;for(s&&ne('tree');n=a.tree.first;){for(;l=n.activeChilds.tree.first;){if(re()-r>=10){i=1,le('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'tree')}s&&le('tree');let u=!!a.data.first;for(u&&ne('data');n=a.data.first;){for(;l=n.activeChilds.data.first;){if(re()-r>=10){i=1,le('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'data')}u&&le('data')}if(le('execQueue'),i)a.rafID=ie(a.execQueue);else if(a.rafID=null,a.onDrain){let e=a.onDrain;a.onDrain=null,e()}}function i({value:e,runOp:t,group:a,priority:n}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:n,group:a,cursor:{prev:null,next:null}}}function o({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=r.bind(null,t),t}function s(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function u({value:e,group:t,onInit:a,onChange:n,onTerminate:r}){let o=i({value:e,group:t,runOp(e){s.status='A',n(e)},priority:'data'}),s={status:'IA',value:o.value,hooks:{onTerminate:r},ops:{init:i({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:o,terminate:i({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return l(1,s.ops.init),s}function c(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',l(1,e.ops.terminate);break;case'AA':e.status='AT',l(1,e.ops.terminate),l(e.value.active,e.ops.change);break;case'IA':e.status='T',l(0,e.ops.init),e.hooks.onTerminate(0)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',l(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',l(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function d(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function f(e,t,a){d(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function h(e,t,a){d(a)?delete e.style[t]:e.style[t]=""+a}function v(e,t,a){d(a)?delete e.dataset[t]:e.dataset[t]=""+a}function m(e,t,a){if(d(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function g(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function y({fn:e,state:t={},defer:a=0,name:n="",draft:l,isSvgRoot:r,namespace:i,env:o}){let s=pe,u=ue,c={id:++oe,name:n,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:W.filter({fn(e,t,a){if(!a.page)return console.error('context lost',a),0;if(!a.page.active)return 0;let n=[a.page.template],l=[a.page];{let e=a.page.parent;for(;e;)l.push(e),n.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let r=t.meta.nativeTemplate;r?n.includes(r)?H({target:t,params:e,defer:1,page:l[n.indexOf(r)],stack:a}):console.error('context drift',{stack:a,node:t}):H({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:W.filter({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===c)return 1;if(a.page.childSpawns[c.id])a.page.childSpawns[c.id].forEach(t=>{H({params:e,target:a.node,page:t,defer:1})});else if(t.targetTemplate){let n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),e=e.parent}let l=n.findIndex(e=>t.targetTemplate===e.template);H(-1===l?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:n[l],defer:1})}else c.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&H({params:e,target:a.node,page:t,defer:1})})}else c.pages.forEach(t=>{H({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(c);let p=J({meta:{template:c}});ue=c;let d=pe={template:c,node:p,api:null,trigger:{mount:K(),unmount:K()},draft:l,isSvgRoot:r,namespace:i,env:o};return a?d.deferredInit=()=>{let a=pe,n=ue;pe=d,ue=c,d.deferredInit=null;try{X(p,()=>{let a=Y(t);d.api=e(a,d.trigger),c.nameMap=a})}finally{pe=a,ue=n}}:X(p,()=>{let a=Y(t);d.api=e(a,d.trigger),c.nameMap=a}),pe=s,ue=u,c.actor=d,d}function b(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function w(e,{values:t={},parentLeaf:a,mountNode:n,svgRoot:l,leafData:r,opGroup:i,domSubtree:o,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(e,t,a){let n;t.stop=1;try{for(;t.i<e.length;)n=e[t.i],t.i++,n.fn(a[n.of.id].current)}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++se,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let v={},m={spawn:h,api:v,draft:e.draft,ops:{group:i,domSubtree:o},svgRoot:l,data:r,parentLeaf:a,hydration:s},g=ce;ce=m,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:b(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,a=1)=>H({target:e.trigger.mount,params:t,defer:a,page:h}),v.unmount=(t,a=1)=>H({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)v[t]=(a,n=1)=>H({target:e.api[t],params:a,defer:n,page:h});return m.spawn.api=v,m.spawn.leaf=m,m.api.mount({node:n,leaf:m}),ce=g,m}function k(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function x(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return x(e.child.child);case'LF':case'RF':case'FF':return S(e.child);case'FRec':case'FRecItem':return S(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=x(t);if(e)return e;t=t.left}return null}default:return null}}function S(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=x(t[e]);if(a)return a}return null}function I(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=x(a.child[e]);if(t)return t}return I(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=x(a.child[e]);if(t)return t}return I(a)}case'LF':{let t=e.parent.left;for(;t;){let e=x(t);if(e)return e;t=t.left}return I(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=x(e);if(n)return n}return I(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=x(e);if(n)return n}return I(t)}function C(e){let t=I(e);return t?t.value:null}function F(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r}){e.childTemplates.forEach(e=>{R({parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r,actor:e})})}function R({parentBlockFragment:e,leaf:t,node:a,actor:n,svgRoot:l,values:r}){let o,{draft:u}=n,{queue:c}=t.ops.group,p=s(c),d=t.ops.domSubtree,f=d;switch(u.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:u.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:u.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:i({value:0,priority:'tree',runOp(e){e?(T(t),o.needToCallNode&&(o.needToCallNode=0,H({target:de,params:{element:t.value,fns:u.node},page:h.spawn}))):(t.value.remove(),t.parent.visible=0)},group:d})},needToCallNode:u.node.length>0},f=s(c);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:u.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[u.inParentIndex]=t.parent,o={type:'list',draft:u,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+u.type)}let h=w(n,{values:r,parentLeaf:t,mountNode:a,svgRoot:l||t.svgRoot,leafData:o,opGroup:p,domSubtree:f,hydration:t.hydration})}function T(e){let t=C(e);t?t.after(e.value):k(e).prepend(e.value),e.parent.visible=1}function A(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let n in t){let l=t[n];a[n]=e.map('function'==typeof l?e=>l(e):e=>e[l])}return a}return e.map(e=>e[t])}function q(e,t){function a(e){return e.data.block.value}function r(e,t,a){let n=e.data.block.child.child,l={type:'text',parent:{type:'FT',parent:n,child:null,visible:0,index:a},value:null};if(l.parent.child=l,n.child[a]=l.parent,e.hydration){let e=I(l);if(e)switch(e.type){case'text':l.value=c.document.createTextNode(t),e.value.after(l.value);break;case'element':l.value=e.value.nextSibling,g(l.value,t)}else{let e=k(l);l.value=e.firstChild,g(l.value,t)}l.parent.visible=1}else l.value=c.document.createTextNode(t),T(l);return l}let o,s=0,u=0;if('function'==typeof t?(s=1,o=t):t&&(u=1,t.fn&&(s=1,o=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,o=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,o=t.ɔ.fn))),!pe)throw Error('h() called outside from using() closure');let c=pe.env,p=pe.namespace,d=p,b='html';d=b='svg'===p?'svg':'html','svg'===e&&(b='svg',d='svg');let w='svg'===b?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(w.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(w.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let x=w,S={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:x,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},R=y({name:'element',draft:S,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return _({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let y=K(),b=c.map(({leaf:e})=>e);s&&o(),u&&E(t);let w={attr:{},data:{},text:S.text,styleProp:{},styleVar:{},visible:S.visible||null,handler:S.handler};for(let e=0;e<S.attr.length;e++){let t=S.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<S.data.length;e++){let t=S.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<S.styleProp.length;e++){let t=S.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<S.styleVar.length;e++){let t=S.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&S.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];Z.unit(t)?S.seq.push({type:'attr',field:e,value:t}):m(x,e,t)}for(let e in w.data){let t=w.data[e];Z.unit(t)?S.seq.push({type:'data',field:e,value:t}):v(x,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];Z.unit(t)?S.seq.push({type:'style',field:e,value:t}):h(x,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];Z.unit(t)?S.seq.push({type:'styleVar',field:e,value:t}):f(x,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(Z.unit(t.value)){S.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=ue;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else S.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)S.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=_({mount:b,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let l=e.data,r=l.block;if(a&&(n(t,l.ops.visible),t)){let e,t=C(r);if(e=t?t.nextSibling:k(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,H({target:de,params:{element:l.block.value,fns:S.node},page:e.spawn,defer:1})),H({target:y,params:e,defer:1,page:e.spawn})}),te([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||l(t,e.data.ops.visible)})}for(let e=0;e<S.seq.length;e++){let t=S.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,n='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:o}=d(t.value);if(n)te([o,r]).watch(({leaf:t,value:n})=>{m(a(t),e,n)});else{let t=S.opsAmount++;r.watch(({value:n,leaf:l})=>{let r=a(l),o=i({value:n,priority:'props',runOp(t){m(r,e,t)},group:l.ops.group});l.ops.group.ops[t]=o,m(r,e,n)}),o.watch(({value:e,leaf:a})=>{l(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){v(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,v(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'style':{let e=S.opsAmount++,{field:n}=t,{onMount:r,onState:o}=d(t.value);r.watch(({value:t,leaf:l})=>{let r=a(l),o=i({value:t,priority:'props',runOp(e){h(r,n,e)},group:l.ops.group});l.ops.group.ops[e]=o,h(r,n,t)}),o.watch(({value:t,leaf:a})=>{l(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){f(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,f(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'staticText':y.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=S.opsAmount++;ee({source:t.value,clock:y,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=i({value:a,priority:'props',runOp(e){g(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),ee({source:y,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{l(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;y.watch(n=>{let l=null;if(e){let t=0,a=n.spawn;for(;!t&&a;)a.template===e?(t=1,l=a):a=a.parent}a(n).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),H({target:t.handler,params:e,page:l})},t.domConfig)});break}}}ee({source:b,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;G(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,G(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!S.visible){let a=t.ops.visible,r=t.block;if(e.hydration){n(1,a);let e,t=C(r);if(e=t?t.nextSibling:k(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),H({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,H({target:de,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):l(1,a)}})},env:c});Q(R)}function P(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function D(e,t){let a,n,l,r,i;if('function'==typeof t)a=t,l=P(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,l=t.env?t.env:P(),r=t.hydrate,n=t.onComplete,i=t.onRoot}if(!e)throw Error('using() first argument is missing');let u=e.namespaceURI,c=e.tagName.toLowerCase(),p={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:p,isSvgRoot:'svg'===c,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===c?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{F(p,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:l}),f={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};f.child.parent=f,f.child.child.parent=f.child;let h=o({onComplete:n}),v=w(d,{parentLeaf:ce||null,mountNode:e,svgRoot:d.isSvgRoot?e:ce?ce.svgRoot:null,leafData:{type:'using',draft:p,element:e,block:f},opGroup:s(h),domSubtree:s(h),hydration:r});i&&i({template:d,leaf:v})}function O(e){let t=pe.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)}function E(e){let t=pe.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,n=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+n,value:e}))),t.childCount+=a.length):(t.text.push({index:n,value:a}),t.childCount+=1)}if(e.style&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?M(t.config||{},t.on):M(t)}e.ɔ&&E(e.ɔ)}function M(e,t){let a=pe.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});let{passive:n=1,capture:l=0,prevent:r=0,stop:i=0}=e;a.handler.push({options:{prevent:r,stop:i},domConfig:{passive:r?0:n,capture:l},map:t})}function N({source:e,cases:t,key:a}){let n='function'==typeof a?a:e=>String(e[a]),l=0;for(let a in t)'__'!==a?V({source:e,visible:e=>n(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);V({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}}function V({source:e,visible:t,fn:a}){if(!pe)throw Error('route() called outside from using() closure');let n=y({name:'route',isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:l,unmount:r}){let i=e.map(e=>({value:e,visible:t(e)})),o={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},s=y({name:'route item',isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:o,state:{store:null},fn({store:e},{mount:t,unmount:n}){let l=K();e.on(l,(e,t)=>t),a({store:e});let r=ee({source:t,clock:i,fn:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,F(o,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),r.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&H({target:l,params:a,defer:1,page:e.spawn}),B(t,e)}),ee({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{L(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,G(t,t.parent.childSpawns[t.template.id]),G(t,t.template.pages)})}});Q(s);let{onMount:u,onState:c}=_({mount:l,state:i,onMount:({visible:e,value:t},{leaf:a,node:n})=>({leaf:a,visible:e,node:n,value:t}),onState:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n})});te([u,c]).watch(({leaf:e,visible:t,value:a,node:n})=>{let l=e.data;l.block.child.visible=t,t&&!l.initialized&&(R({parentBlockFragment:l.block.child.child,leaf:e,node:n,actor:s,values:{store:a}}),l.initialized=1)}),ee({source:l,clock:r,greedy:1}).watch(({leaf:e})=>{L(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,G(t,t.parent.childSpawns[t.template.id]),G(t,t.template.pages)})}});Q(n)}function B(e,t){let a=t=>{let n=t.data;switch(n.type){case'element':l(e,n.ops.visible);break;case'route':case'list':case'list item':L(t,a);break;default:console.log('unsupported type',n.type)}};L(t,a)}function L(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let n=a.childSpawns[e];for(let e=0;e<n.length;e++)t(n[e].leaf)}}function j(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:t,defer:1,fn({store:a},{mount:n,unmount:l}){e({state:a});let r=K();return a.on(r,(e,t)=>t),n.watch(({node:e,leaf:a})=>{F(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),ee({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,L(e,e=>{e.api.unmount()})}),{itemUpdater:r}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=pe;Q(y({name:'rec item',isSvgRoot:0,namespace:n,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:n,unmount:l}){let{onMount:r,onState:i}=_({state:e,mount:n,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});ee({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,L(e,e=>{e.api.unmount()})}),i.watch(({state:e,leaf:t})=>{L(t,t=>{t.api.itemUpdater(e)})}),r.watch(({node:e,leaf:t,state:n})=>{R({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:n}})})}}))}}function z({source:e,child:t,fn:a}){let n=j(({state:e})=>{U({source:e,fn({store:e}){let l=e.map(e=>e[t]||[]);a({store:e,child(){n({state:l})}})}})});n({state:e})}function U(e,t){'function'==typeof t&&(Z.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:l,fields:r=[]}=e,i=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,o={type:'list',key:Z.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!pe)throw Error('list() called outside from using() closure');let d=pe.env,f=pe.namespace;Q(y({name:'list',draft:o,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:n}){let h=y({name:'list item',state:{id:-1,store:null},draft:o,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:n,unmount:l}){a({store:t,key:e,fields:A(t,r)});let i=K();t.on(i,(e,t)=>t);let s=ae({leaf:null});if(ee({source:s,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;G(t,t.parent.child);let a=t.left,n=t.right;a&&(a.right=n,n||t.parent.lastChild!==t||(t.parent.lastChild=a)),n&&(n.left=a),a||n||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,L(e,e=>{e.api.unmount()});let{spawn:l}=e;l.active=0,G(l,l.parent.childSpawns[l.template.id]),G(l,l.template.pages)}),o.itemVisible){let{onMount:e,onState:t}=_({mount:n,state:o.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{s.setState({leaf:a});let n=a.data.block;n.visible=e,n.childInitialized=e,e&&F(o,{parentBlockFragment:n.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let n=a.data.block;n.visible=e,n.childInitialized?B(e,a):e&&(n.childInitialized=1,F(o,{parentBlockFragment:n.child,leaf:a,node:t}))})}else n.watch(({node:e,leaf:t})=>{s.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,F(o,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:i}},env:d}),v=ae([]),m=l.map(e=>e),g=ee({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),b=ee({source:g,clock:m,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1}),k=te([g,b]);ee({source:v,clock:k,greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:r}){let o=n.data.block;ne('list update ['+l.shortName+']');let d=Array(a.length).fill(0),f=a.map(i),v=[];for(let t=0;t<e.length;t++){let n=e[t],l=f.indexOf(n.key);-1!==l?(v.push(n),d[l]=1,p(a[l],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),c(n.asyncValue))}for(let e=0;e<a.length;e++){if(d[e])continue;let l=a[e],i=f[e],c=s(n.ops.group.queue),p={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:i,index:i,active:1,leafData:{type:'list item',block:p},asyncValue:u({value:l,group:c,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(r||(m.instance=w(h,{values:{id:i,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r})))}})},g=v.length;v.push(m);let y=g>0?v[g-1].leafData:null;if(p.child.parent=p,o.child.push(p),y){let e=y.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):o.lastChild=p,e.right=p}else o.lastChild=p;r&&(m.instance=w(h,{values:{id:i,store:l},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r}))}return le('list update ['+l.shortName+']'),0===v.length&&(o.lastChild=null),v},target:v}),ee({source:t,clock:ee({source:v,clock:n,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,G(a,a.parent.childSpawns[a.template.id]),G(a,a.template.pages)})},env:d}))}function Q(e){if(!pe)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(pe.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=pe.draft.childCount,pe.draft.childCount+=1,pe.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+pe.draft.type)}}function G(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function _({mount:e,state:t,onMount:a,onState:n}){return{onMount:ee({source:t,clock:e,fn:a,greedy:1}),onState:ee({source:e,clock:t,fn:n,greedy:1})}}function $(e,...t){let a=[e[0]];for(let n=0;n<t.length;n++)a.push(t[n],e[n+1]);E({text:a})}import{step as W,launch as H,createNode as J,createEvent as K,withRegion as X,restore as Y,is as Z,sample as ee,merge as te,createStore as ae}from'effector';let ne,le,re;'undefined'!=typeof performance&&performance.mark?(ne=e=>{performance.mark('☄️ '+e+' start')},le=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(ne=()=>{},le=()=>{}),re='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let ie='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),oe=0,se=0,ue=null,ce=null,pe=null,de=K();de.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});export{q as h,M as handler,U as list,O as node,j as rec,A as remap,V as route,E as spec,$ as text,z as tree,D as using,N as variant}; | ||
function e(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function t(e){var t,n;e.status='active',t=a(e),(n=e).cursor.prev&&(n.cursor.prev.cursor.next=n.cursor.next),n.cursor.next&&(n.cursor.next.cursor.prev=n.cursor.prev),t.last===n&&(t.last=n.cursor.prev),t.first===n&&(t.first=n.cursor.next),n.cursor.prev=null,n.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function n(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function l(n,l){if(l.value.active===n)return l.value.pending=n,void('pending'===l.status&&(t(l),a(l).first||e(l.group,l.priority)));var r,i,o,s;'active'===l.status&&(l.status='pending',a(l).first||((o=l.group).queue[s=l.priority].last?(o.cursor[s].prev=o.queue[s].last,o.queue[s].last.cursor[s].next=o,o.queue[s].last=o):o.queue[s].first=o.queue[s].last=o),i=l,(r=a(l)).last?(i.cursor.prev=r.last,r.last.cursor.next=i,r.last=i):r.first=r.last=i),l.value.pending=n,l.group.queue.rafID||(l.group.queue.rafID=ie(l.group.queue.execQueue))}function r(a){ne('execQueue');let n,l,r=re(),i=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(re()-r>=10){i=1;break e}let o=!!a.props.first;for(o&&ne('props');n=a.props.first;){for(;l=n.activeChilds.props.first;){if(re()-r>=10){i=1,le('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'props')}o&&le('props');let s=!!a.tree.first;for(s&&ne('tree');n=a.tree.first;){for(;l=n.activeChilds.tree.first;){if(re()-r>=10){i=1,le('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'tree')}s&&le('tree');let u=!!a.data.first;for(u&&ne('data');n=a.data.first;){for(;l=n.activeChilds.data.first;){if(re()-r>=10){i=1,le('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'data')}u&&le('data')}if(le('execQueue'),i)a.rafID=ie(a.execQueue);else if(a.rafID=null,a.onDrain){let e=a.onDrain;a.onDrain=null,e()}}function i({value:e,runOp:t,group:a,priority:n}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:n,group:a,cursor:{prev:null,next:null}}}function o({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=r.bind(null,t),t}function s(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function u({value:e,group:t,onInit:a,onChange:n,onTerminate:r}){let o=i({value:e,group:t,runOp(e){s.status='A',n(e)},priority:'data'}),s={status:'IA',value:o.value,hooks:{onTerminate:r},ops:{init:i({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:o,terminate:i({value:0,group:t,runOp(e){s.status='T',s.hooks.onTerminate(1)},priority:'data'})}};return l(1,s.ops.init),s}function c(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',l(1,e.ops.terminate);break;case'AA':e.status='AT',l(1,e.ops.terminate),l(e.value.active,e.ops.change);break;case'IA':e.status='T',l(0,e.ops.init),e.hooks.onTerminate(0)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',l(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',l(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function d(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function f(e,t,a){d(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function h(e,t,a){d(a)?delete e.style[t]:e.style[t]=""+a}function v(e,t,a){d(a)?delete e.dataset[t]:e.dataset[t]=""+a}function m(e,t,a){if(d(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function g(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function y({fn:e,state:t={},defer:a=0,name:n="",draft:l,isSvgRoot:r,namespace:i,env:o}){let s=pe,u=ue,c={id:++oe,name:n,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:W.filter({fn(e,t,a){if(!a.page)return console.error('context lost',a),0;if(!a.page.active)return 0;let n=[a.page.template],l=[a.page];{let e=a.page.parent;for(;e;)l.push(e),n.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let r=t.meta.nativeTemplate;r?n.includes(r)?H({target:t,params:e,defer:1,page:l[n.indexOf(r)],stack:a}):console.error('context drift',{stack:a,node:t}):H({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:W.filter({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===c)return 1;if(a.page.childSpawns[c.id])a.page.childSpawns[c.id].forEach(t=>{H({params:e,target:a.node,page:t,defer:1})});else if(t.targetTemplate){let n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),e=e.parent}let l=n.findIndex(e=>t.targetTemplate===e.template);H(-1===l?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:n[l],defer:1})}else c.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&H({params:e,target:a.node,page:t,defer:1})})}else c.pages.forEach(t=>{H({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(c);let p=J({meta:{template:c}});ue=c;let d=pe={template:c,node:p,api:null,trigger:{mount:K(),unmount:K()},draft:l,isSvgRoot:r,namespace:i,env:o};return a?d.deferredInit=()=>{let a=pe,n=ue;pe=d,ue=c,d.deferredInit=null;try{X(p,()=>{let a=Y(t);d.api=e(a,d.trigger),c.nameMap=a})}finally{pe=a,ue=n}}:X(p,()=>{let a=Y(t);d.api=e(a,d.trigger),c.nameMap=a}),pe=s,ue=u,c.actor=d,d}function b(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function w(e,{values:t={},parentLeaf:a,mountNode:n,svgRoot:l,leafData:r,opGroup:i,domSubtree:o,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(e,t,a){let n;t.stop=1;try{for(;t.i<e.length;)n=e[t.i],t.i++,n.fn(a[n.of.id].current)}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++se,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let v={},m={spawn:h,api:v,draft:e.draft,ops:{group:i,domSubtree:o},svgRoot:l,data:r,parentLeaf:a,hydration:s},g=ce;ce=m,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:b(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,a=1)=>H({target:e.trigger.mount,params:t,defer:a,page:h}),v.unmount=(t,a=1)=>H({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)v[t]=(a,n=1)=>H({target:e.api[t],params:a,defer:n,page:h});return m.spawn.api=v,m.spawn.leaf=m,m.api.mount({node:n,leaf:m}),ce=g,m}function k(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function x(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return x(e.child.child);case'LF':case'RF':case'FF':return S(e.child);case'FRec':case'FRecItem':return S(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=x(t);if(e)return e;t=t.left}return null}default:return null}}function S(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=x(t[e]);if(a)return a}return null}function I(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=x(a.child[e]);if(t)return t}return I(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=x(a.child[e]);if(t)return t}return I(a)}case'LF':{let t=e.parent.left;for(;t;){let e=x(t);if(e)return e;t=t.left}return I(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=x(e);if(n)return n}return I(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=x(e);if(n)return n}return I(t)}function C(e){let t=I(e);return t?t.value:null}function F(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r}){e.childTemplates.forEach(e=>{R({parentBlockFragment:t,leaf:a,node:n,svgRoot:l,values:r,actor:e})})}function R({parentBlockFragment:e,leaf:t,node:a,actor:n,svgRoot:l,values:r}){let o,{draft:u}=n,{queue:c}=t.ops.group,p=s(c),d=t.ops.domSubtree,f=d;switch(u.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:u.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:u.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:i({value:0,priority:'tree',runOp(e){e?(T(t),o.needToCallNode&&(o.needToCallNode=0,H({target:de,params:{element:t.value,fns:u.node},page:h.spawn}))):(t.value.remove(),t.parent.visible=0)},group:d})},needToCallNode:u.node.length>0},f=s(c);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:u.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[u.inParentIndex]=t.parent,o={type:'list',draft:u,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:u.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[u.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+u.type)}let h=w(n,{values:r,parentLeaf:t,mountNode:a,svgRoot:l||t.svgRoot,leafData:o,opGroup:p,domSubtree:f,hydration:t.hydration})}function T(e){let t=C(e);t?t.after(e.value):k(e).prepend(e.value),e.parent.visible=1}function A(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let n in t){let l=t[n];a[n]=e.map('function'==typeof l?e=>l(e):e=>e[l])}return a}return e.map(e=>e[t])}function q(e,t){function a(e){return e.data.block.value}function r(e,t,a){let n=e.data.block.child.child,l={type:'text',parent:{type:'FT',parent:n,child:null,visible:0,index:a},value:null};if(l.parent.child=l,n.child[a]=l.parent,e.hydration){let e=I(l);if(e)switch(e.type){case'text':l.value=c.document.createTextNode(t),e.value.after(l.value);break;case'element':l.value=e.value.nextSibling,g(l.value,t)}else{let e=k(l);l.value=e.firstChild,g(l.value,t)}l.parent.visible=1}else l.value=c.document.createTextNode(t),T(l);return l}let o,s=0,u=0;if('function'==typeof t?(s=1,o=t):t&&(u=1,t.fn&&(s=1,o=t.fn),t.ɔ&&('function'==typeof t.ɔ?(s=1,o=t.ɔ):'function'==typeof t.ɔ.fn&&(s=1,o=t.ɔ.fn))),!pe)throw Error('h() called outside from using() closure');let c=pe.env,p=pe.namespace,d=p,b='html';d=b='svg'===p?'svg':'html','svg'===e&&(b='svg',d='svg');let w='svg'===b?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(w.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(w.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let x=w,S={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:x,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},R=y({name:'element',draft:S,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return _({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let y=K(),b=c.map(({leaf:e})=>e);s&&o(),u&&O(t);let w={attr:{},data:{},text:S.text,styleProp:{},styleVar:{},visible:S.visible||null,handler:S.handler};for(let e=0;e<S.attr.length;e++){let t=S.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<S.data.length;e++){let t=S.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<S.styleProp.length;e++){let t=S.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<S.styleVar.length;e++){let t=S.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&S.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];Z.unit(t)?S.seq.push({type:'attr',field:e,value:t}):m(x,e,t)}for(let e in w.data){let t=w.data[e];Z.unit(t)?S.seq.push({type:'data',field:e,value:t}):v(x,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];Z.unit(t)?S.seq.push({type:'style',field:e,value:t}):h(x,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];Z.unit(t)?S.seq.push({type:'styleVar',field:e,value:t}):f(x,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(Z.unit(t.value)){S.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=ue;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else S.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)S.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=_({mount:b,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let l=e.data,r=l.block;if(a&&(n(t,l.ops.visible),t)){let e,t=C(r);if(e=t?t.nextSibling:k(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,H({target:de,params:{element:l.block.value,fns:S.node},page:e.spawn,defer:1})),H({target:y,params:e,defer:1,page:e.spawn})}),te([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||l(t,e.data.ops.visible)})}for(let e=0;e<S.seq.length;e++){let t=S.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,n='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:o}=d(t.value);if(n)te([o,r]).watch(({leaf:t,value:n})=>{m(a(t),e,n)});else{let t=S.opsAmount++;r.watch(({value:n,leaf:l})=>{let r=a(l),o=i({value:n,priority:'props',runOp(t){m(r,e,t)},group:l.ops.group});l.ops.group.ops[t]=o,m(r,e,n)}),o.watch(({value:e,leaf:a})=>{l(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){v(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,v(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'style':{let e=S.opsAmount++,{field:n}=t,{onMount:r,onState:o}=d(t.value);r.watch(({value:t,leaf:l})=>{let r=a(l),o=i({value:t,priority:'props',runOp(e){h(r,n,e)},group:l.ops.group});l.ops.group.ops[e]=o,h(r,n,t)}),o.watch(({value:t,leaf:a})=>{l(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),o=S.opsAmount++;n.watch(({value:t,leaf:n})=>{let l=a(n),r=i({value:t,priority:'props',runOp(t){f(l,e,t)},group:n.ops.group});n.ops.group.ops[o]=r,f(l,e,t)}),r.watch(({value:e,leaf:t})=>{l(e,t.ops.group.ops[o])});break}case'staticText':y.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=S.opsAmount++;ee({source:t.value,clock:y,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=i({value:a,priority:'props',runOp(e){g(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),ee({source:y,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{l(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;y.watch(n=>{let l=null;if(e){let t=0,a=n.spawn;for(;!t&&a;)a.template===e?(t=1,l=a):a=a.parent}a(n).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),H({target:t.handler,params:e,page:l})},t.domConfig)});break}}}ee({source:b,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;G(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,G(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!S.visible){let a=t.ops.visible,r=t.block;if(e.hydration){n(1,a);let e,t=C(r);if(e=t?t.nextSibling:k(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}F(S,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:R.isSvgRoot?r.value:null}),H({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,H({target:de,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):l(1,a)}})},env:c});Q(R)}function P(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function D(e,t){let a,n,l,r,i;if('function'==typeof t)a=t,l=P(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,l=t.env?t.env:P(),r=t.hydrate,n=t.onComplete,i=t.onRoot}if(!e)throw Error('using() first argument is missing');let u=e.namespaceURI,c=e.tagName.toLowerCase(),p={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:p,isSvgRoot:'svg'===c,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===c?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{F(p,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:l}),f={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};f.child.parent=f,f.child.child.parent=f.child;let h=o({onComplete:n}),v=w(d,{parentLeaf:ce||null,mountNode:e,svgRoot:d.isSvgRoot?e:ce?ce.svgRoot:null,leafData:{type:'using',draft:p,element:e,block:f},opGroup:s(h),domSubtree:s(h),hydration:r});i&&i({template:d,leaf:v})}function E(e){let t=pe.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)}function O(e){let t=pe.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,n=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+n,value:e}))),t.childCount+=a.length):(t.text.push({index:n,value:a}),t.childCount+=1)}if(e.style&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?M(t.config||{},t.on):M(t)}e.ɔ&&O(e.ɔ)}function M(e,t){if(!pe)return;let a=pe.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});for(let e in t)if(!Z.unit(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:n=1,capture:l=0,prevent:r=0,stop:i=0}=e;a.handler.push({options:{prevent:r,stop:i},domConfig:{passive:r?0:n,capture:l},map:t})}function N({source:e,cases:t,key:a}){if(!Z.unit(e))throw Error('variant({source}) should be unit');let n;n='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let l=0;for(let a in t)'__'!==a?V({source:e,visible:e=>n(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);V({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}}function V({source:e,visible:t,fn:a}){if(!pe)throw Error('route() called outside from using() closure');let n=y({name:'route',isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:l,unmount:r}){let i=e.map(e=>({value:e,visible:t(e)})),o={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},s=y({name:'route item',isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:o,state:{store:null},fn({store:e},{mount:t,unmount:n}){let l=K();e.on(l,(e,t)=>t),a({store:e});let r=ee({source:t,clock:i,fn:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,F(o,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),r.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&H({target:l,params:a,defer:1,page:e.spawn}),B(t,e)}),ee({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{L(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,G(t,t.parent.childSpawns[t.template.id]),G(t,t.template.pages)})}});Q(s);let{onMount:u,onState:c}=_({mount:l,state:i,onMount:({visible:e,value:t},{leaf:a,node:n})=>({leaf:a,visible:e,node:n,value:t}),onState:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n})});te([u,c]).watch(({leaf:e,visible:t,value:a,node:n})=>{let l=e.data;l.block.child.visible=t,t&&!l.initialized&&(R({parentBlockFragment:l.block.child.child,leaf:e,node:n,actor:s,values:{store:a}}),l.initialized=1)}),ee({source:l,clock:r,greedy:1}).watch(({leaf:e})=>{L(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,G(t,t.parent.childSpawns[t.template.id]),G(t,t.template.pages)})}});Q(n)}function B(e,t){let a=t=>{let n=t.data;switch(n.type){case'element':l(e,n.ops.visible);break;case'route':case'list':case'list item':L(t,a);break;default:console.log('unsupported type',n.type)}};L(t,a)}function L(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let n=a.childSpawns[e];for(let e=0;e<n.length;e++)t(n[e].leaf)}}function j(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:t,defer:1,fn({store:a},{mount:n,unmount:l}){e({state:a});let r=K();return a.on(r,(e,t)=>t),n.watch(({node:e,leaf:a})=>{F(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),ee({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,L(e,e=>{e.api.unmount()})}),{itemUpdater:r}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=pe;Q(y({name:'rec item',isSvgRoot:0,namespace:n,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:n,unmount:l}){let{onMount:r,onState:i}=_({state:e,mount:n,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});ee({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,L(e,e=>{e.api.unmount()})}),i.watch(({state:e,leaf:t})=>{L(t,t=>{t.api.itemUpdater(e)})}),r.watch(({node:e,leaf:t,state:n})=>{R({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:n}})})}}))}}function z({source:e,child:t,fn:a}){let n=j(({state:e})=>{U({source:e,fn({store:e}){let l=e.map(e=>e[t]||[]);a({store:e,child(){n({state:l})}})}})});n({state:e})}function U(e,t){'function'==typeof t&&(Z.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:l,fields:r=[]}=e,i=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,o={type:'list',key:Z.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!pe)throw Error('list() called outside from using() closure');let d=pe.env,f=pe.namespace;Q(y({name:'list',draft:o,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:n}){let h=y({name:'list item',state:{id:-1,store:null},draft:o,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:n,unmount:l}){a({store:t,key:e,fields:A(t,r)});let i=K();t.on(i,(e,t)=>t);let s=ae({leaf:null});if(ee({source:s,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;G(t,t.parent.child);let a=t.left,n=t.right;a&&(a.right=n,n||t.parent.lastChild!==t||(t.parent.lastChild=a)),n&&(n.left=a),a||n||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,L(e,e=>{e.api.unmount()});let{spawn:l}=e;l.active=0,G(l,l.parent.childSpawns[l.template.id]),G(l,l.template.pages)}),o.itemVisible){let{onMount:e,onState:t}=_({mount:n,state:o.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{s.setState({leaf:a});let n=a.data.block;n.visible=e,n.childInitialized=e,e&&F(o,{parentBlockFragment:n.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let n=a.data.block;n.visible=e,n.childInitialized?B(e,a):e&&(n.childInitialized=1,F(o,{parentBlockFragment:n.child,leaf:a,node:t}))})}else n.watch(({node:e,leaf:t})=>{s.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,F(o,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:i}},env:d}),v=ae([]),m=l.map(e=>e),g=ee({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),b=ee({source:g,clock:m,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1}),k=te([g,b]);ee({source:v,clock:k,greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:r}){let o=n.data.block;ne('list update ['+l.shortName+']');let d=Array(a.length).fill(0),f=a.map(i),v=[];for(let t=0;t<e.length;t++){let n=e[t],l=f.indexOf(n.key);-1!==l?(v.push(n),d[l]=1,p(a[l],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),c(n.asyncValue))}for(let e=0;e<a.length;e++){if(d[e])continue;let l=a[e],i=f[e],c=s(n.ops.group.queue),p={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:i,index:i,active:1,leafData:{type:'list item',block:p},asyncValue:u({value:l,group:c,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(r||(m.instance=w(h,{values:{id:i,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r})))}})},g=v.length;v.push(m);let y=g>0?v[g-1].leafData:null;if(p.child.parent=p,o.child.push(p),y){let e=y.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):o.lastChild=p,e.right=p}else o.lastChild=p;r&&(m.instance=w(h,{values:{id:i,store:l},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r}))}return le('list update ['+l.shortName+']'),0===v.length&&(o.lastChild=null),v},target:v}),ee({source:t,clock:ee({source:v,clock:n,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,G(a,a.parent.childSpawns[a.template.id]),G(a,a.template.pages)})},env:d}))}function Q(e){if(!pe)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(pe.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=pe.draft.childCount,pe.draft.childCount+=1,pe.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+pe.draft.type)}}function G(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function _({mount:e,state:t,onMount:a,onState:n}){return{onMount:ee({source:t,clock:e,fn:a,greedy:1}),onState:ee({source:e,clock:t,fn:n,greedy:1})}}function $(e,...t){let a=[e[0]];for(let n=0;n<t.length;n++)a.push(t[n],e[n+1]);O({text:a})}import{step as W,launch as H,createNode as J,createEvent as K,withRegion as X,restore as Y,is as Z,sample as ee,merge as te,createStore as ae}from'effector';let ne,le,re;'undefined'!=typeof performance&&performance.mark?(ne=e=>{performance.mark('☄️ '+e+' start')},le=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(ne=()=>{},le=()=>{}),re='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let ie='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),oe=0,se=0,ue=null,ce=null,pe=null,de=K();de.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});export{q as h,M as handler,U as list,E as node,j as rec,A as remap,V as route,O as spec,$ as text,z as tree,D as using,N as variant}; | ||
//# sourceMappingURL=forest.es.js.map |
@@ -214,2 +214,13 @@ import {Store, Event, Step} from 'effector' | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => boolean | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
export function route<T, S extends T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => value is S | ||
fn: (config: {store: Store<S>}) => void | ||
}): void | ||
export function node(fn: (node: DOMElement) => void): void | ||
@@ -216,0 +227,0 @@ |
@@ -1,2 +0,2 @@ | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e=e||self).forest={})})(this,e=>{function t(e,t="combine"){let a=t+'(',n='',r=0;for(let t in e){let l=e[t];if(null!=l&&(a+=n,a+=X(l)?l.compositeName.fullName:l.toString()),r+=1,25===r)break;n=', '}return a+=')',a}function a({node:e=[],from:t,source:a,parent:n=t||a,to:r,target:l,child:o=r||l,scope:i={},meta:s={},family:u={type:'regular'}}={}){let c=je(n),p=je(u.links),d=je(u.owners),f=[],h={};for(let t=0;t<e.length;t++){let a=e[t];a&&(f.push(a),Be(a,h))}let m={seq:f,next:je(o),meta:s,scope:i,family:{type:u.type||'crosslink',links:p,owners:d},reg:h};for(let e=0;e<p.length;e++)ie(p[e]).push(m);for(let e=0;e<d.length;e++)se(d[e]).push(m);for(let e=0;e<c.length;e++)c[e].next.push(m);return m}function n(e,t){ct={parent:ct,value:e,template:oe(e).meta.template||ct&&ct.template};try{return t()}finally{ct=he(ct)}}function r(e,t){let n=(e,...t)=>n.create(e,t,t);n.graphite=a({meta:vt('event',n,t,e)}),n.create=e=>(Ze(n,e),e),n.watch=we(ft,n),n.map=e=>{let t,a;re(e)&&(t=e,a=e.name,e=e.fn);let l=r(ve(n,a),t);return gt(n,l,'map',e),l},n.filter=e=>le(e)?(console.error('.filter(fn) is deprecated, use .filterMap instead'),l(n,e)):yt(n,'filter',e.fn,[qe({fn:Ve})]),n.filterMap=we(l,n),n.prepend=e=>{let t=r('* → '+n.shortName,{parent:he(n)}),a=pt();return a&&oe(t).seq.push(a.upward),gt(t,n,'prepend',e),((e,t)=>{he(e)&&he(e).hooks.event(t)})(n,t),t};let o=pt();return o&&(oe(n).meta.nativeTemplate=o),ut(n)}function l(e,t){return yt(e,'filterMap',t,[Ae({fn:Ve}),Ce()])}function o(e,t){function n(e,t){c.off(e),fe(c).set(e,st(bt(e,c,'on',1,t)))}let l=De(e),i=De(e),s=(()=>r({named:'updates'}))(),u=pt();l.after=[{type:'copy',to:i}],u&&u.plain.push(l);let c={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e=Ye();return Me(e&&e.reg[l.id]?e.reg[l.id]:l)},setState(e){Ze({target:c,params:e,defer:1})},reset(...e){for(let t of e)c.on(t,()=>c.defaultState);return c},on(e,t){if(Array.isArray(e))for(let a of e)n(a,t);else n(e,t);return c},off(e){let t=fe(c).get(e);return t&&(t(),fe(c).delete(e)),c},map(e,t){let a,n,r;re(e)&&(a=e,n=e.name,t=e.firstState,e=e.fn);let i=c.getState(),s=pt();s?r=null:void 0!==i&&(r=e(i,t));let u=o(r,{name:ve(c,n),config:a,strict:0}),p=bt(c,u,'map',0,e);return ue(u).before=[{type:'map',fn:e,from:l}],s&&(s.plain.includes(l)||p.seq.includes(s.loader)||p.seq.unshift(s.loader)),u},watch(e,t){if(!t||!X(e)){le(e)||ne('watch requires function handler');let t=pt();return t?t.watch.push({of:l,fn:e}):e(c.getState()),ft(c,e)}return le(t)||ne('second argument should be a function'),e.watch(e=>t(c.getState(),e))}};return c.graphite=a({scope:{state:l},node:[Ce(),Pe({store:l}),Fe({store:i}),Pe({store:i})],child:s,meta:vt('store',c,t)}),mt&&void 0===e&&ne("current state can't be undefined, use null instead"),u&&(oe(c).meta.nativeTemplate=u),ze(c,[s]),ut(c)}function i(...e){let t,n,l;tt(e[0],(t,a)=>{l=t,e=a});let i,[s,u,c,p=0]=e;void 0===u&&'source'in s&&('clock'in s&&null==s.clock&&ne('config.clock should be defined'),u=s.clock,c=s.fn,p=s.greedy,t=s.target,n=s.name,i=s.sid,s=s.source),void 0===u&&(u=s),n=l||n||s.shortName,s=It(s),u=It(u),'boolean'==typeof c&&(p=c,c=null);let d=pt(),f=!!t;t||(Z(s)&&Z(u)?t=o(c?c(Me(ue(s)),Me(ue(u))):Me(ue(s)),{name:n,sid:i}):(t=r(n),d&&oe(t).seq.push(d.loader)));let h=f&&X(t)&&oe(t).meta.nativeTemplate;if(Z(s))ze(s,[dt(u,t,{scope:{fn:c,targetTemplate:h},node:[d&&d.loader,!p&&Re({priority:'sampler'}),Te({store:ue(s),to:c?'a':'stack'}),c&&Ae({fn:Ee}),d&&f&&d.upward],meta:{op:'sample',sample:'store'}})]);else{let e=De(0),n=De(),r=De();d&&d.plain.push(e,n,r),ut(a({parent:s,node:[Pe({store:n}),Te({from:'value',store:1,target:e})],family:{owners:[s,t,u],links:t},meta:{op:'sample',sample:'source'}})),ze(s,[dt(u,t,{scope:{fn:c,targetTemplate:h},node:[d&&d.loader,Pe({store:r}),Te({store:e}),qe({fn:e=>e}),!p&&Re({priority:'sampler'}),Te({store:n}),Te({store:r,to:'a'}),c&&Ae({fn:Oe}),d&&f&&d.upward],meta:{op:'sample',sample:'clock'}})])}return t}function s(e){let n=r(t(e,'merge'));return(e=>{let t;tt(e,(a,n)=>{t=a,e=n});let{from:n,to:r,meta:l={op:'forward'}}=e;n&&r||ne('from and to fields should be defined'),t&&(l.config=t),st(ut(a({parent:n,child:r,meta:l,family:{}})))})({from:e,to:n,meta:{op:'merge'}}),n}function u(e,t,a){if(Z(e))return e;if(X(e)){let n,r=he(e);return ee(e)&&(n=o(t,{parent:r,name:e.shortName,ɔ:a}).on(e,(e,t)=>t)),te(e)&&(n=o(t,{parent:r,name:e.shortName,ɔ:a}).on(e.done,(e,{result:t})=>t)),r&&r.hooks.store(n),n}let n={};return kt(e,(e,t)=>{n[t]=Z(e)?e:o(e,{name:t})}),n}function c(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function p(e){e.status='active',((e,t)=>{t.cursor.prev&&(t.cursor.prev.cursor.next=t.cursor.next),t.cursor.next&&(t.cursor.next.cursor.prev=t.cursor.prev),e.last===t&&(e.last=t.cursor.prev),e.first===t&&(e.first=t.cursor.next),t.cursor.prev=null,t.cursor.next=null})(d(e),e)}function d(e){return e.group.activeChilds[e.priority]}function f(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&p(t)}function h(e,t){if(t.value.active===e)return t.value.pending=e,void('pending'===t.status&&(p(t),d(t).first||c(t.group,t.priority)));'active'===t.status&&(t.status='pending',d(t).first||((e,t)=>{e.queue[t].last?(e.cursor[t].prev=e.queue[t].last,e.queue[t].last.cursor[t].next=e,e.queue[t].last=e):e.queue[t].first=e.queue[t].last=e})(t.group,t.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(d(t),t)),t.value.pending=e,t.group.queue.rafID||(t.group.queue.rafID=Rt(t.group.queue.execQueue))}function m(e){wt('execQueue');let t,a,n=St(),r=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(St()-n>=10){r=1;break e}let l=!!e.props.first;for(l&&wt('props');t=e.props.first;){for(;a=t.activeChilds.props.first;){if(St()-n>=10){r=1,xt('props');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'props')}l&&xt('props');let o=!!e.tree.first;for(o&&wt('tree');t=e.tree.first;){for(;a=t.activeChilds.tree.first;){if(St()-n>=10){r=1,xt('tree');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'tree')}o&&xt('tree');let i=!!e.data.first;for(i&&wt('data');t=e.data.first;){for(;a=t.activeChilds.data.first;){if(St()-n>=10){r=1,xt('data');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'data')}i&&xt('data')}if(xt('execQueue'),r)e.rafID=Rt(e.execQueue);else if(e.rafID=null,e.onDrain){let t=e.onDrain;e.onDrain=null,t()}}function v({value:e,runOp:t,group:a,priority:n}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:n,group:a,cursor:{prev:null,next:null}}}function g({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=m.bind(null,t),t}function y(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function b({value:e,group:t,onInit:a,onChange:n,onTerminate:r}){let l=v({value:e,group:t,runOp(e){o.status='A',n(e)},priority:'data'}),o={status:'IA',value:l.value,hooks:{onTerminate:r},ops:{init:v({value:0,group:t,runOp(e){o.status='A',a(o.value.active)},priority:'data'}),change:l,terminate:v({value:0,group:t,runOp(e){o.status='T',o.hooks.onTerminate(1)},priority:'data'})}};return h(1,o.ops.init),o}function k(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',h(1,e.ops.terminate);break;case'AA':e.status='AT',h(1,e.ops.terminate),h(e.value.active,e.ops.change);break;case'IA':e.status='T',h(0,e.ops.init),e.hooks.onTerminate(0)}}function w(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',h(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',h(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function x(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function S(e,t,a){x(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function I(e,t,a){x(a)?delete e.style[t]:e.style[t]=""+a}function R(e,t,a){x(a)?delete e.dataset[t]:e.dataset[t]=""+a}function T(e,t,a){if(x(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function C(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function F({fn:e,state:t={},defer:l=0,name:o="",draft:i,isSvgRoot:s,namespace:c,env:p}){let d=qt,f=Ft,h={id:++Tt,name:o,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:qe({fn(e,t,a){if(!a.page)return console.error('context lost',a),0;if(!a.page.active)return 0;let n=[a.page.template],r=[a.page];{let e=a.page.parent;for(;e;)r.push(e),n.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let l=t.meta.nativeTemplate;l?n.includes(l)?Ze({target:t,params:e,defer:1,page:r[n.indexOf(l)],stack:a}):console.error('context drift',{stack:a,node:t}):Ze({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:qe({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===h)return 1;if(a.page.childSpawns[h.id])a.page.childSpawns[h.id].forEach(t=>{Ze({params:e,target:a.node,page:t,defer:1})});else if(t.targetTemplate){let n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),e=e.parent}let r=n.findIndex(e=>t.targetTemplate===e.template);Ze(-1===r?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:n[r],defer:1})}else h.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&Ze({params:e,target:a.node,page:t,defer:1})})}else h.pages.forEach(t=>{Ze({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:f};f&&f.childTemplates.push(h);let m=a({meta:{template:h}});Ft=h;let v=qt={template:h,node:m,api:null,trigger:{mount:r(),unmount:r()},draft:i,isSvgRoot:s,namespace:c,env:p};return l?v.deferredInit=()=>{let a=qt,r=Ft;qt=v,Ft=h,v.deferredInit=null;try{n(m,()=>{let a=u(t);v.api=e(a,v.trigger),h.nameMap=a})}finally{qt=a,Ft=r}}:n(m,()=>{let a=u(t);v.api=e(a,v.trigger),h.nameMap=a}),qt=d,Ft=f,h.actor=v,v}function A(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function q(e,{values:t={},parentLeaf:a,mountNode:n,svgRoot:r,leafData:l,opGroup:o,domSubtree:i,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(e,t,a){let n;t.stop=1;try{for(;t.i<e.length;)n=e[t.i],t.i++,n.fn(a[n.of.id].current)}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++Ct,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let m={},v={spawn:h,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:r,data:l,parentLeaf:a,hydration:s},g=At;At=v,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:A(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(m.mount=(t,a=1)=>Ze({target:e.trigger.mount,params:t,defer:a,page:h}),m.unmount=(t,a=1)=>Ze({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)m[t]=(a,n=1)=>Ze({target:e.api[t],params:a,defer:n,page:h});return v.spawn.api=m,v.spawn.leaf=v,v.api.mount({node:n,leaf:v}),At=g,v}function N(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function P(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return P(e.child.child);case'LF':case'RF':case'FF':return D(e.child);case'FRec':case'FRecItem':return D(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=P(t);if(e)return e;t=t.left}return null}default:return null}}function D(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=P(t[e]);if(a)return a}return null}function M(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=P(a.child[e]);if(t)return t}return M(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=P(a.child[e]);if(t)return t}return M(a)}case'LF':{let t=e.parent.left;for(;t;){let e=P(t);if(e)return e;t=t.left}return M(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=P(e);if(n)return n}return M(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let n=P(e);if(n)return n}return M(t)}function O(e){let t=M(e);return t?t.value:null}function E(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:r,values:l}){e.childTemplates.forEach(e=>{V({parentBlockFragment:t,leaf:a,node:n,svgRoot:r,values:l,actor:e})})}function V({parentBlockFragment:e,leaf:t,node:a,actor:n,svgRoot:r,values:l}){let o,{draft:i}=n,{queue:s}=t.ops.group,u=y(s),c=t.ops.domSubtree,p=c;switch(i.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:i.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:i.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:v({value:0,priority:'tree',runOp(e){e?(z(t),o.needToCallNode&&(o.needToCallNode=0,Ze({target:Nt,params:{element:t.value,fns:i.node},page:d.spawn}))):(t.value.remove(),t.parent.visible=0)},group:c})},needToCallNode:i.node.length>0},p=y(s);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:i.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[i.inParentIndex]=t.parent,o={type:'list',draft:i,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+i.type)}let d=q(n,{values:l,parentLeaf:t,mountNode:a,svgRoot:r||t.svgRoot,leafData:o,opGroup:u,domSubtree:p,hydration:t.hydration})}function z(e){let t=O(e);t?t.after(e.value):N(e).prepend(e.value),e.parent.visible=1}function j(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let n in t){let r=t[n];a[n]=e.map('function'==typeof r?e=>r(e):e=>e[r])}return a}return e.map(e=>e[t])}function B(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function L(e){let t=qt.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,n=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+n,value:e}))),t.childCount+=a.length):(t.text.push({index:n,value:a}),t.childCount+=1)}if(e.style&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?U(t.config||{},t.on):U(t)}e.ɔ&&L(e.ɔ)}function U(e,t){let a=qt.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});let{passive:n=1,capture:r=0,prevent:l=0,stop:o=0}=e;a.handler.push({options:{prevent:l,stop:o},domConfig:{passive:l?0:n,capture:r},map:t})}function _({source:e,visible:t,fn:a}){if(!qt)throw Error('route() called outside from using() closure');let n=F({name:'route',isSvgRoot:0,namespace:qt.namespace,env:qt.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:l,unmount:o}){let u=e.map(e=>({value:e,visible:t(e)})),c={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},p=F({name:'route item',isSvgRoot:0,namespace:qt.namespace,env:qt.env,draft:c,state:{store:null},fn({store:e},{mount:t,unmount:n}){let l=r();e.on(l,(e,t)=>t),a({store:e});let o=i({source:t,clock:u,fn:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,E(c,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),o.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&Ze({target:l,params:a,defer:1,page:e.spawn}),Q(t,e)}),i({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{G(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,J(t,t.parent.childSpawns[t.template.id]),J(t,t.template.pages)})}});H(p);let{onMount:d,onState:f}=K({mount:l,state:u,onMount:({visible:e,value:t},{leaf:a,node:n})=>({leaf:a,visible:e,node:n,value:t}),onState:({leaf:e,node:t},{visible:a,value:n})=>({leaf:e,visible:a,node:t,value:n})});s([d,f]).watch(({leaf:e,visible:t,value:a,node:n})=>{let r=e.data;r.block.child.visible=t,t&&!r.initialized&&(V({parentBlockFragment:r.block.child.child,leaf:e,node:n,actor:p,values:{store:a}}),r.initialized=1)}),i({source:l,clock:o,greedy:1}).watch(({leaf:e})=>{G(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,J(t,t.parent.childSpawns[t.template.id]),J(t,t.template.pages)})}});H(n)}function Q(e,t){let a=t=>{let n=t.data;switch(n.type){case'element':h(e,n.ops.visible);break;case'route':case'list':case'list item':G(t,a);break;default:console.log('unsupported type',n.type)}};G(t,a)}function G(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let n=a.childSpawns[e];for(let e=0;e<n.length;e++)t(n[e].leaf)}}function $(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=F({name:'rec',state:{store:null},isSvgRoot:0,namespace:qt.namespace,env:qt.env,draft:t,defer:1,fn({store:a},{mount:n,unmount:l}){e({state:a});let o=r();return a.on(o,(e,t)=>t),n.watch(({node:e,leaf:a})=>{E(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),i({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,G(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=qt;H(F({name:'rec item',isSvgRoot:0,namespace:n,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:n,unmount:r}){let{onMount:l,onState:o}=K({state:e,mount:n,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});i({source:n,clock:r,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,G(e,e=>{e.api.unmount()})}),o.watch(({state:e,leaf:t})=>{G(t,t=>{t.api.itemUpdater(e)})}),l.watch(({node:e,leaf:t,state:n})=>{V({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:n}})})}}))}}function W(e,t){'function'==typeof t&&(X(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:l,fields:u=[]}=e,c=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,p={type:'list',key:Z(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!qt)throw Error('list() called outside from using() closure');let d=qt.env,f=qt.namespace;H(F({name:'list',draft:p,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:n}){let h=F({name:'list item',state:{id:-1,store:null},draft:p,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:n,unmount:l}){a({store:t,key:e,fields:j(t,u)});let s=r();t.on(s,(e,t)=>t);let c=o({leaf:null});if(i({source:c,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;J(t,t.parent.child);let a=t.left,n=t.right;a&&(a.right=n,n||t.parent.lastChild!==t||(t.parent.lastChild=a)),n&&(n.left=a),a||n||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,G(e,e=>{e.api.unmount()});let{spawn:r}=e;r.active=0,J(r,r.parent.childSpawns[r.template.id]),J(r,r.template.pages)}),p.itemVisible){let{onMount:e,onState:t}=K({mount:n,state:p.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{c.setState({leaf:a});let n=a.data.block;n.visible=e,n.childInitialized=e,e&&E(p,{parentBlockFragment:n.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let n=a.data.block;n.visible=e,n.childInitialized?Q(e,a):e&&(n.childInitialized=1,E(p,{parentBlockFragment:n.child,leaf:a,node:t}))})}else n.watch(({node:e,leaf:t})=>{c.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,E(p,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:s}},env:d}),m=o([]),v=l.map(e=>e),g=i({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),x=i({source:g,clock:v,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1});i({source:m,clock:s([g,x]),greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:r}){let o=n.data.block;wt('list update ['+l.shortName+']');let i=Array(a.length).fill(0),s=a.map(c),u=[];for(let t=0;t<e.length;t++){let n=e[t],r=s.indexOf(n.key);-1!==r?(u.push(n),i[r]=1,w(a[r],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),k(n.asyncValue))}for(let e=0;e<a.length;e++){if(i[e])continue;let l=a[e],c=s[e],p=y(n.ops.group.queue),d={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:c,index:c,active:1,leafData:{type:'list item',block:d},asyncValue:b({value:l,group:p,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(r||(f.instance=q(h,{values:{id:c,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:n.ops.domSubtree,hydration:r})))}})},m=u.length;u.push(f);let v=m>0?u[m-1].leafData:null;if(d.child.parent=d,o.child.push(d),v){let e=v.block;d.left=e;let t=e.right;t?(t.left=d,d.right=t):o.lastChild=d,e.right=d}else o.lastChild=d;r&&(f.instance=q(h,{values:{id:c,store:l},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:n.ops.domSubtree,hydration:r}))}return xt('list update ['+l.shortName+']'),0===u.length&&(o.lastChild=null),u},target:m}),i({source:t,clock:i({source:m,clock:n,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,J(a,a.parent.childSpawns[a.template.id]),J(a,a.template.pages)})},env:d}))}function H(e){if(!qt)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(qt.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=qt.draft.childCount,qt.draft.childCount+=1,qt.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+qt.draft.type)}}function J(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function K({mount:e,state:t,onMount:a,onState:n}){return{onMount:i({source:t,clock:e,fn:a,greedy:1}),onState:i({source:e,clock:t,fn:n,greedy:1})}}let X=e=>(le(e)||re(e))&&'kind'in e;const Y=e=>t=>X(t)&&t.kind===e;let Z=Y('store'),ee=Y('event'),te=Y('effect'),ae=Y('domain'),ne=e=>{throw Error(e)},re=e=>'object'==typeof e&&null!==e,le=e=>'function'==typeof e,oe=e=>e.graphite||e,ie=e=>e.family.owners,se=e=>e.family.links,ue=e=>e.stateRef,ce=e=>e.config,pe=e=>e.ɔ,de=e=>e.value,fe=e=>e.subscribers,he=e=>e.parent,me=(e,t)=>''+e.shortName+t,ve=(e,t)=>null==t?me(e,' → *'):t;var ge=(()=>{var e,t=('undefined'!=typeof self?self:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof module?module:Function("","return this")()).Symbol;return'function'==typeof t?t.observable?e=t.observable:(e=t('observable'),t.observable=e):e='@@observable',e})();const ye=()=>{let e=0;return()=>(++e).toString(36)};let be=ye(),ke=ye(),we=(e,t)=>e.bind(null,t),xe=(e,t,a)=>e.bind(null,t,a);const Se=(e,t,a)=>({id:ke(),type:e,data:a,hasRef:t});let Ie=0,Re=({priority:e="barrier"})=>Se('barrier',0,{barrierID:++Ie,priority:e}),Te=({from:e="store",store:t,target:a,to:n=(a?'store':'stack')})=>Se('mov','store'===e,{from:e,store:t,to:n,target:a}),Ce=()=>Se('check',0,{type:'defined'}),Fe=({store:e})=>Se('check',1,{type:'changed',store:e}),Ae=xe(Se,'compute',0),qe=xe(Se,'filter',0),Ne=xe(Se,'run',0),Pe=({store:e})=>Te({from:'stack',target:e}),De=e=>({id:ke(),current:e}),Me=({current:e})=>e,Oe=(e,{fn:t},{a})=>t(e,a),Ee=(e,{fn:t},{a})=>t(a,e),Ve=(e,{fn:t})=>t(e),ze=(e,t)=>{let a=oe(e);for(let e=0;e<t.length;e++){let n=oe(t[e]);'domain'!==a.family.type&&(n.family.type='crosslink'),ie(n).push(a),se(a).push(n)}};const je=(e=[])=>{let t=[];if(Array.isArray(e))for(let a=0;a<e.length;a++)Array.isArray(e[a])?t.push(...e[a]):t.push(e[a]);else t.push(e);return t.map(oe)};let Be=({hasRef:e,type:t,data:a},n)=>{let r;e&&(r=a.store,n[r.id]=r),'mov'===t&&'store'===a.to&&(r=a.target,n[r.id]=r)},Le=null;const Ue=(e,t)=>{if(!e)return t;if(!t)return e;let a,n=e.v.type===t.v.type;return(n&&e.v.id>t.v.id||!n&&'sampler'===e.v.type)&&(a=e,e=t,t=a),a=Ue(e.r,t),e.r=e.l,e.l=a,e},_e=[];let Qe=0;for(;Qe<5;)_e.push({first:null,last:null,size:0}),Qe+=1;const Ge=()=>{for(let e=0;e<5;e++){let t=_e[e];if(t.size>0){if(2===e||3===e){t.size-=1;let e=Le.v;return Le=Ue(Le.l,Le.r),e}1===t.size&&(t.last=null);let a=t.first;return t.first=a.r,t.size-=1,a.v}}},$e=(e,t,a,n,r)=>We(0,{a:null,b:null,node:a,parent:n,value:r,page:t},e),We=(e,t,a,n=0)=>{let r=He(a),l=_e[r],o={v:{idx:e,stack:t,type:a,id:n},l:0,r:0};2===r||3===r?Le=Ue(Le,o):(0===l.size?l.first=o:l.last.r=o,l.last=o),l.size+=1},He=e=>{switch(e){case'child':return 0;case'pure':return 1;case'barrier':return 2;case'sampler':return 3;case'effect':return 4;default:return-1}},Je=new Set;let Ke=0,Xe=null,Ye=()=>Xe,Ze=(e,t,a)=>{let n=Xe,r=null;if(e.target&&(t=e.params,a=e.defer,n='page'in e?e.page:n,e.stack&&(r=e.stack),e=e.target),Array.isArray(e))for(let a=0;a<e.length;a++)$e('pure',n,oe(e[a]),r,t[a]);else $e('pure',n,oe(e),r,t);a&&Ke||(()=>{let e,t,a,n,r,l,o={alreadyStarted:Ke,currentPage:Xe};Ke=1;e:for(;n=Ge();){let{idx:o,stack:i,type:s}=n;a=i.node,Xe=r=i.page,l=(r||a).reg;let u={fail:0,scope:a.scope};e=t=0;for(let n=o;n<a.seq.length&&!e;n++){let c=a.seq[n],p=c.data;switch(c.type){case'barrier':{let e=p.barrierID;r&&(e=`${r.fullID}_${e}`);let t=p.priority;if(n!==o||s!==t){Je.has(e)||(Je.add(e),We(n,i,t,e));continue e}Je.delete(e);break}case'mov':{let e;switch(p.from){case'stack':e=de(i);break;case'a':e=i.a;break;case'b':e=i.b;break;case'value':e=p.store;break;case'store':l[p.store.id]||(i.page=r=null,l=a.reg),e=Me(l[p.store.id])}switch(p.to){case'stack':i.value=e;break;case'a':i.a=e;break;case'b':i.b=e;break;case'store':l[p.target.id].current=e}break}case'check':switch(p.type){case'defined':t=void 0===de(i);break;case'changed':t=de(i)===Me(l[p.store.id])}break;case'filter':t=!et(u,p,i);break;case'run':if(n!==o||'effect'!==s){We(n,i,'effect');continue e}case'compute':i.value=et(u,p,i)}e=u.fail||t}if(!e)for(let e=0;e<a.next.length;e++)$e('child',r,a.next[e],i,de(i))}Ke=o.alreadyStarted,Xe=o.currentPage})()};const et=(e,{fn:t},a)=>{try{return t(de(a),e.scope,a)}catch(t){console.error(t),e.fail=1}};let tt=(e,t)=>{pe(e)&&t(ce(e),pe(e))};const at=(e,t)=>{let a=e.indexOf(t);-1!==a&&e.splice(a,1)},nt=(e,t)=>{at(e.next,t),at(ie(e),t),at(se(e),t)},rt=(e,t,a)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let r=se(e);for(;n=r.pop();)nt(n,e),(t||a&&!e.meta.sample||'crosslink'===n.family.type)&&rt(n,t,a);for(r=ie(e);n=r.pop();)nt(n,e),a&&'crosslink'===n.family.type&&rt(n,t,a)},lt=e=>e.clear();let ot=(e,{deep:t}={})=>{let a=0;if(e.ownerSet&&e.ownerSet.delete(e),Z(e))lt(fe(e));else if(ae(e)){a=1;let t=e.history;lt(t.events),lt(t.effects),lt(t.stores),lt(t.domains)}rt(oe(e),!!t,a)},st=e=>{let t=xe(ot,e,void 0);return t.unsubscribe=t,t},ut=e=>(ct&&ze(de(ct),[e]),e),ct=null,pt=()=>ct&&ct.template,dt=(e,t,{node:n,scope:r,meta:l})=>ut(a({node:n,parent:e,child:t,scope:r,meta:l,family:{owners:[e,t],links:t}})),ft=(e,t)=>st(ut(a({scope:{fn:t},node:[Ne({fn:Ve})],parent:e,meta:{op:'watch'},family:{owners:e}})));const ht=(e,t)=>(re(e)&&(ht(ce(e),t),null!=e.name&&(re(e.name)?ht(e.name,t):t.name=e.name),e.loc&&(t.loc=e.loc),(e.sid||null===e.sid)&&(t.sid=e.sid),e.handler&&(t.handler=e.handler),he(e)&&(t.parent=he(e)),'strict'in e&&(t.strict=e.strict),e.named&&(t.named=e.named),ht(pe(e),t)),t);let mt,vt=(e,t,a,n)=>{let r=ht({name:n,config:a},{}),l=be(),{parent:o=null,sid:i=null,strict:s=1,named:u=null}=r,c=u||r.name||('domain'===e?'':l),p=((e,t)=>{let a,n,r,l=e;return t?(r=t.compositeName,0===e.length?(a=r.path,n=r.fullName):(a=r.path.concat([e]),n=0===r.fullName.length?e:r.fullName+'/'+e)):(a=0===e.length?[]:[e],n=e),{shortName:l,fullName:n,path:a}})(c,o);return t.kind=e,t.id=l,t.sid=i,t.shortName=c,t.parent=o,t.compositeName=p,t.defaultConfig=r,t.thru=e=>e(t),t.getType=()=>p.fullName,'domain'!==e&&(t.subscribe=e=>((e=>{re(e)||le(e)||ne('expect value to be an object')})(e),t.watch(le(e)?e:t=>{e.next&&e.next(t)})),t[ge]=()=>t),mt=s,{unit:e,name:c,sid:i,named:u}};const gt=(e,t,a,n)=>dt(e,t,{scope:{fn:n},node:[Ae({fn:Ve})],meta:{op:a}}),yt=(e,t,a,n)=>{let l;re(a)&&(l=a,a=a.fn);let o=r(me(e,' →? *'),l);return dt(e,o,{scope:{fn:a},node:n,meta:{op:t}}),o},bt=(e,t,a,n,r)=>{let l=ue(t),o=[Te({store:l,to:'a'}),Ae({fn:n?Ee:Oe}),Ce(),Fe({store:l}),Pe({store:l})],i=pt();if(i&&(o.unshift(i.loader),o.push(i.upward),Z(e))){let t=ue(e);i.plain.includes(t)||(i.closure.includes(t)||i.closure.push(t),l.before||(l.before=[]),l.before.push({type:'closure',of:t}))}return dt(e,t,{scope:{fn:r},node:o,meta:{op:a}})};let kt=(e,t)=>{for(let a in e)t(e[a],a)};a({node:[Ne({fn({fn:e,value:t}){e(t)}})],meta:{op:'fx',fx:'sidechain'}});let wt,xt,St,It=e=>X(e)?e:((...e)=>{let a,n,r;0===e.length&&ne('at least one argument required'),tt(e[0],(t,a)=>{r=t,e=a});let l,i,s=e[e.length-1];if(le(s)?(n=e.slice(0,-1),a=s):n=e,1===n.length){let e=n[0];Z(e)||(l=e,i=1)}return i||(l=n,a&&(a=(e=>t=>e(...t))(a))),((e,a,n,r)=>{let l=e?e=>e.slice():e=>Object.assign({},e),i=e?[]:{},s=pt(),u=l(i),c=De(u),p=De(1);c.type=e?'list':'shape',s&&s.plain.push(c,p);let d=o(u,{name:n||t(a)}),f=[Ce(),Te({store:c,to:'a'}),qe({fn:(e,{key:t},{a})=>e!==a[t]}),Te({store:p,to:'b'}),Ae({fn(e,{clone:t,key:a},n){n.b&&(n.a=t(n.a)),n.a[a]=e}}),Te({from:'a',target:c}),Te({from:'value',store:0,target:p}),Re({priority:'barrier'}),Te({from:'value',store:1,target:p}),Te({store:c}),r&&Ae({fn:r}),Fe({store:ue(d)})],h=c.before=[];return kt(a,(e,t)=>{if(!Z(e))return void(u[t]=i[t]=e);i[t]=e.defaultState,u[t]=e.getState();let a=dt(e,d,{scope:{key:t,clone:l},node:f,meta:{op:'combine'}}),n=ue(e);h.push({type:'field',field:t,from:n}),s&&(s.plain.includes(n)||a.seq.unshift(s.loader))}),d.defaultShape=a,c.after=[r?{type:'map',to:ue(d),fn:r}:{type:'copy',to:ue(d)}],s||(d.defaultState=r?ue(d).current=r(u):i),d})(Array.isArray(l),l,r,a)})(e);qe({fn:(e,{state:t})=>void 0!==e&&e!==Me(t)}),Ae({fn:e=>e}),'undefined'!=typeof performance&&performance.mark?(wt=e=>{performance.mark('☄️ '+e+' start')},xt=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(wt=()=>{},xt=()=>{}),St='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let Rt='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),Tt=0,Ct=0,Ft=null,At=null,qt=null,Nt=r();Nt.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),e.h=(e,t)=>{function a(e){return e.data.block.value}function n(e,t,a){let n=e.data.block.child.child,r={type:'text',parent:{type:'FT',parent:n,child:null,visible:0,index:a},value:null};if(r.parent.child=r,n.child[a]=r.parent,e.hydration){let e=M(r);if(e)switch(e.type){case'text':r.value=c.document.createTextNode(t),e.value.after(r.value);break;case'element':r.value=e.value.nextSibling,C(r.value,t)}else{let e=N(r);r.value=e.firstChild,C(r.value,t)}r.parent.visible=1}else r.value=c.document.createTextNode(t),z(r);return r}let l,o=0,u=0;if('function'==typeof t?(o=1,l=t):t&&(u=1,t.fn&&(o=1,l=t.fn),t.ɔ&&('function'==typeof t.ɔ?(o=1,l=t.ɔ):'function'==typeof t.ɔ.fn&&(o=1,l=t.ɔ.fn))),!qt)throw Error('h() called outside from using() closure');let c=qt.env,p=qt.namespace,d=p,m='html';d=m='svg'===p?'svg':'html','svg'===e&&(m='svg',d='svg');let g='svg'===m?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(g.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(g.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let y=g,b={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:y,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},k=F({name:'element',draft:b,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return K({mount:m,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let m=r(),g=c.map(({leaf:e})=>e);o&&l(),u&&L(t);let w={attr:{},data:{},text:b.text,styleProp:{},styleVar:{},visible:b.visible||null,handler:b.handler};for(let e=0;e<b.attr.length;e++){let t=b.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<b.data.length;e++){let t=b.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<b.styleProp.length;e++){let t=b.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<b.styleVar.length;e++){let t=b.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&b.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];X(t)?b.seq.push({type:'attr',field:e,value:t}):T(y,e,t)}for(let e in w.data){let t=w.data[e];X(t)?b.seq.push({type:'data',field:e,value:t}):R(y,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];X(t)?b.seq.push({type:'style',field:e,value:t}):I(y,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];X(t)?b.seq.push({type:'styleVar',field:e,value:t}):S(y,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(X(t.value)){b.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=Ft;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else b.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)b.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=K({mount:g,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let n=e.data,r=n.block;if(a&&(f(t,n.ops.visible),t)){let e,t=O(r);if(e=t?t.nextSibling:N(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}E(b,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:k.isSvgRoot?r.value:null}),t&&n.needToCallNode&&(n.needToCallNode=0,Ze({target:Nt,params:{element:n.block.value,fns:b.node},page:e.spawn,defer:1})),Ze({target:m,params:e,defer:1,page:e.spawn})}),s([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||h(t,e.data.ops.visible)})}for(let e=0;e<b.seq.length;e++){let t=b.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,n='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:l}=d(t.value);if(n)s([l,r]).watch(({leaf:t,value:n})=>{T(a(t),e,n)});else{let t=b.opsAmount++;r.watch(({value:n,leaf:r})=>{let l=a(r),o=v({value:n,priority:'props',runOp(t){T(l,e,t)},group:r.ops.group});r.ops.group.ops[t]=o,T(l,e,n)}),l.watch(({value:e,leaf:a})=>{h(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),l=b.opsAmount++;n.watch(({value:t,leaf:n})=>{let r=a(n),o=v({value:t,priority:'props',runOp(t){R(r,e,t)},group:n.ops.group});n.ops.group.ops[l]=o,R(r,e,t)}),r.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'style':{let e=b.opsAmount++,{field:n}=t,{onMount:r,onState:l}=d(t.value);r.watch(({value:t,leaf:r})=>{let l=a(r),o=v({value:t,priority:'props',runOp(e){I(l,n,e)},group:r.ops.group});r.ops.group.ops[e]=o,I(l,n,t)}),l.watch(({value:t,leaf:a})=>{h(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:n,onState:r}=d(t.value),l=b.opsAmount++;n.watch(({value:t,leaf:n})=>{let r=a(n),o=v({value:t,priority:'props',runOp(t){S(r,e,t)},group:n.ops.group});n.ops.group.ops[l]=o,S(r,e,t)}),r.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'staticText':m.map(e=>e).watch(e=>{n(e,t.value,t.childIndex)});break;case'dynamicText':{let e=b.opsAmount++;i({source:t.value,clock:m,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:r})=>{let l=v({value:a,priority:'props',runOp(e){C(o.value,e)},group:r.ops.group});r.ops.group.ops[e]=l;let o=n(r,a,t.childIndex)}),i({source:m,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{h(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;m.watch(n=>{let r=null;if(e){let t=0,a=n.spawn;for(;!t&&a;)a.template===e?(t=1,r=a):a=a.parent}a(n).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),Ze({target:t.handler,params:e,page:r})},t.domConfig)});break}}}i({source:g,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;J(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,J(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),h(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!b.visible){let a=t.ops.visible,n=t.block;if(e.hydration){f(1,a);let e,t=O(n);if(e=t?t.nextSibling:N(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.parent.visible=1}E(b,{parentBlockFragment:n.child.child,leaf:e,node:n.value,svgRoot:k.isSvgRoot?n.value:null}),Ze({target:m,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,Ze({target:Nt,params:{element:t.block.value,fns:b.node},page:e.spawn,defer:1})):h(1,a)}})},env:c});H(k)},e.handler=U,e.list=W,e.node=e=>{let t=qt.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},e.rec=$,e.remap=j,e.route=_,e.spec=L,e.text=(e,...t)=>{let a=[e[0]];for(let n=0;n<t.length;n++)a.push(t[n],e[n+1]);L({text:a})},e.tree=({source:e,child:t,fn:a})=>{let n=$(({state:e})=>{W({source:e,fn({store:e}){let r=e.map(e=>e[t]||[]);a({store:e,child(){n({state:r})}})}})});n({state:e})},e.using=(e,t)=>{let a,n,r,l,o;if('function'==typeof t)a=t,r=B(),l=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,r=t.env?t.env:B(),l=t.hydrate,n=t.onComplete,o=t.onRoot}if(!e)throw Error('using() first argument is missing');let i=e.namespaceURI,s=e.tagName.toLowerCase(),u={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},c=F({name:'using',draft:u,isSvgRoot:'svg'===s,namespace:'http://www.w3.org/2000/svg'===i?'svg':'foreignobject'===s?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{E(u,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:r}),p={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};p.child.parent=p,p.child.child.parent=p.child;let d=g({onComplete:n}),f=q(c,{parentLeaf:At||null,mountNode:e,svgRoot:c.isSvgRoot?e:At?At.svgRoot:null,leafData:{type:'using',draft:u,element:e,block:p},opGroup:y(d),domSubtree:y(d),hydration:l});o&&o({template:c,leaf:f})},e.variant=({source:e,cases:t,key:a})=>{let n='function'==typeof a?a:e=>String(e[a]),r=0;for(let a in t)'__'!==a?_({source:e,visible:e=>n(e)===a,fn:t[a]}):r=1;if(r){let a=Object.keys(t);_({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}},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=e||self).forest={})})(this,e=>{function t(e,t="combine"){let a=t+'(',r='',n=0;for(let t in e){let l=e[t];if(null!=l&&(a+=r,a+=X(l)?l.compositeName.fullName:l.toString()),n+=1,25===n)break;r=', '}return a+=')',a}function a({node:e=[],from:t,source:a,parent:r=t||a,to:n,target:l,child:o=n||l,scope:i={},meta:s={},family:u={type:'regular'}}={}){let c=je(r),p=je(u.links),d=je(u.owners),f=[],h={};for(let t=0;t<e.length;t++){let a=e[t];a&&(f.push(a),Be(a,h))}let m={seq:f,next:je(o),meta:s,scope:i,family:{type:u.type||'crosslink',links:p,owners:d},reg:h};for(let e=0;e<p.length;e++)ie(p[e]).push(m);for(let e=0;e<d.length;e++)se(d[e]).push(m);for(let e=0;e<c.length;e++)c[e].next.push(m);return m}function r(e,t){pt={parent:pt,value:e,template:oe(e).meta.template||pt&&pt.template};try{return t()}finally{pt=he(pt)}}function n(e,t){let r=(e,...t)=>r.create(e,t,t);r.graphite=a({meta:vt('event',r,t,e)}),r.create=e=>(et(r,e),e),r.watch=we(ht,r),r.map=e=>{let t,a;ne(e)&&(t=e,a=e.name,e=e.fn);let l=n(ge(r,a),t);return yt(r,l,'map',e),l},r.filter=e=>le(e)?(console.error('.filter(fn) is deprecated, use .filterMap instead'),l(r,e)):bt(r,'filter',e.fn,[qe({fn:Ve})]),r.filterMap=we(l,r),r.prepend=e=>{let t=n('* → '+r.shortName,{parent:he(r)}),a=dt();return a&&oe(t).seq.push(a.upward),yt(t,r,'prepend',e),((e,t)=>{he(e)&&he(e).hooks.event(t)})(r,t),t};let o=dt();return o&&(oe(r).meta.nativeTemplate=o),ct(r)}function l(e,t){return bt(e,'filterMap',t,[Ae({fn:Ve}),Ce()])}function o(e,t){function r(e,t){c.off(e),fe(c).set(e,ut(kt(e,c,'on',1,t)))}let l=De(e),i=De(e),s=(()=>n({named:'updates'}))(),u=dt();l.after=[{type:'copy',to:i}],u&&u.plain.push(l);let c={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e=Ze();return Me(e&&e.reg[l.id]?e.reg[l.id]:l)},setState(e){et({target:c,params:e,defer:1})},reset(...e){for(let t of e)c.on(t,()=>c.defaultState);return c},on(e,t){if(Array.isArray(e))for(let a of e)r(a,t);else r(e,t);return c},off(e){let t=fe(c).get(e);return t&&(t(),fe(c).delete(e)),c},map(e,t){let a,r,n;ne(e)&&(a=e,r=e.name,t=e.firstState,e=e.fn);let i=c.getState(),s=dt();s?n=null:void 0!==i&&(n=e(i,t));let u=o(n,{name:ge(c,r),config:a,strict:0}),p=kt(c,u,'map',0,e);return ue(u).before=[{type:'map',fn:e,from:l}],s&&(s.plain.includes(l)||p.seq.includes(s.loader)||p.seq.unshift(s.loader)),u},watch(e,t){if(!t||!X(e)){le(e)||re('watch requires function handler');let t=dt();return t?t.watch.push({of:l,fn:e}):e(c.getState()),ht(c,e)}return le(t)||re('second argument should be a function'),e.watch(e=>t(c.getState(),e))}};return c.graphite=a({scope:{state:l},node:[Ce(),Ne({store:l}),Fe({store:i}),Ne({store:i})],child:s,meta:vt('store',c,t)}),gt&&void 0===e&&re("current state can't be undefined, use null instead"),u&&(oe(c).meta.nativeTemplate=u),ze(c,[s]),ct(c)}function i(...e){let t,r,l;at(e[0],(t,a)=>{l=t,e=a});let i,[s,u,c,p=0]=e;void 0===u&&'source'in s&&('clock'in s&&null==s.clock&&re('config.clock should be defined'),u=s.clock,c=s.fn,p=s.greedy,t=s.target,r=s.name,i=s.sid,s=s.source),void 0===u&&(u=s),r=l||r||s.shortName,s=Rt(s),u=Rt(u),'boolean'==typeof c&&(p=c,c=null);let d=dt(),f=!!t;t||(Z(s)&&Z(u)?t=o(c?c(Me(ue(s)),Me(ue(u))):Me(ue(s)),{name:r,sid:i}):(t=n(r),d&&oe(t).seq.push(d.loader)));let h=f&&X(t)&&oe(t).meta.nativeTemplate;if(Z(s))ze(s,[ft(u,t,{scope:{fn:c,targetTemplate:h},node:[d&&d.loader,!p&&Re({priority:'sampler'}),Te({store:ue(s),to:c?'a':'stack'}),c&&Ae({fn:Ee}),d&&f&&d.upward],meta:{op:'sample',sample:'store'}})]);else{let e=De(0),r=De(),n=De();d&&d.plain.push(e,r,n),ct(a({parent:s,node:[Ne({store:r}),Te({from:'value',store:1,target:e})],family:{owners:[s,t,u],links:t},meta:{op:'sample',sample:'source'}})),ze(s,[ft(u,t,{scope:{fn:c,targetTemplate:h},node:[d&&d.loader,Ne({store:n}),Te({store:e}),qe({fn:e=>e}),!p&&Re({priority:'sampler'}),Te({store:r}),Te({store:n,to:'a'}),c&&Ae({fn:Oe}),d&&f&&d.upward],meta:{op:'sample',sample:'clock'}})])}return t}function s(e){let r=n(t(e,'merge'));return(e=>{let t;at(e,(a,r)=>{t=a,e=r});let{from:r,to:n,meta:l={op:'forward'}}=e;r&&n||re('from and to fields should be defined'),t&&(l.config=t),ut(ct(a({parent:r,child:n,meta:l,family:{}})))})({from:e,to:r,meta:{op:'merge'}}),r}function u(e,t,a){if(Z(e))return e;if(X(e)){let r,n=he(e);return ee(e)&&(r=o(t,{parent:n,name:e.shortName,ɔ:a}).on(e,(e,t)=>t)),te(e)&&(r=o(t,{parent:n,name:e.shortName,ɔ:a}).on(e.done,(e,{result:t})=>t)),n&&n.hooks.store(r),r}let r={};return wt(e,(e,t)=>{r[t]=Z(e)?e:o(e,{name:t})}),r}function c(e,t){e.cursor[t].prev&&(e.cursor[t].prev.cursor[t].next=e.cursor[t].next),e.cursor[t].next&&(e.cursor[t].next.cursor[t].prev=e.cursor[t].prev),e.queue[t].last===e&&(e.queue[t].last=e.cursor[t].prev),e.queue[t].first===e&&(e.queue[t].first=e.cursor[t].next),e.cursor[t].prev=null,e.cursor[t].next=null}function p(e){e.status='active',((e,t)=>{t.cursor.prev&&(t.cursor.prev.cursor.next=t.cursor.next),t.cursor.next&&(t.cursor.next.cursor.prev=t.cursor.prev),e.last===t&&(e.last=t.cursor.prev),e.first===t&&(e.first=t.cursor.next),t.cursor.prev=null,t.cursor.next=null})(d(e),e)}function d(e){return e.group.activeChilds[e.priority]}function f(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&p(t)}function h(e,t){if(t.value.active===e)return t.value.pending=e,void('pending'===t.status&&(p(t),d(t).first||c(t.group,t.priority)));'active'===t.status&&(t.status='pending',d(t).first||((e,t)=>{e.queue[t].last?(e.cursor[t].prev=e.queue[t].last,e.queue[t].last.cursor[t].next=e,e.queue[t].last=e):e.queue[t].first=e.queue[t].last=e})(t.group,t.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(d(t),t)),t.value.pending=e,t.group.queue.rafID||(t.group.queue.rafID=Tt(t.group.queue.execQueue))}function m(e){xt('execQueue');let t,a,r=It(),n=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(It()-r>=10){n=1;break e}let l=!!e.props.first;for(l&&xt('props');t=e.props.first;){for(;a=t.activeChilds.props.first;){if(It()-r>=10){n=1,St('props');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'props')}l&&St('props');let o=!!e.tree.first;for(o&&xt('tree');t=e.tree.first;){for(;a=t.activeChilds.tree.first;){if(It()-r>=10){n=1,St('tree');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'tree')}o&&St('tree');let i=!!e.data.first;for(i&&xt('data');t=e.data.first;){for(;a=t.activeChilds.data.first;){if(It()-r>=10){n=1,St('data');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}c(t,'data')}i&&St('data')}if(St('execQueue'),n)e.rafID=Tt(e.execQueue);else if(e.rafID=null,e.onDrain){let t=e.onDrain;e.onDrain=null,t()}}function g({value:e,runOp:t,group:a,priority:r}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:r,group:a,cursor:{prev:null,next:null}}}function v({onComplete:e}){let t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=m.bind(null,t),t}function y(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function b({value:e,group:t,onInit:a,onChange:r,onTerminate:n}){let l=g({value:e,group:t,runOp(e){o.status='A',r(e)},priority:'data'}),o={status:'IA',value:l.value,hooks:{onTerminate:n},ops:{init:g({value:0,group:t,runOp(e){o.status='A',a(o.value.active)},priority:'data'}),change:l,terminate:g({value:0,group:t,runOp(e){o.status='T',o.hooks.onTerminate(1)},priority:'data'})}};return h(1,o.ops.init),o}function k(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',h(1,e.ops.terminate);break;case'AA':e.status='AT',h(1,e.ops.terminate),h(e.value.active,e.ops.change);break;case'IA':e.status='T',h(0,e.ops.init),e.hooks.onTerminate(0)}}function w(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',h(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',h(e,t.ops.change)):t.value.pending!==e&&(t.value.pending=e);break;case'IA':t.value.active=t.value.pending=e}}function x(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function S(e,t,a){x(a)?e.style.removeProperty("--"+t):e.style.setProperty("--"+t,""+a)}function I(e,t,a){x(a)?delete e.style[t]:e.style[t]=""+a}function R(e,t,a){x(a)?delete e.dataset[t]:e.dataset[t]=""+a}function T(e,t,a){if(x(a)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==a)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=""+a;break;case'checked':e.checked=""+a}e.setAttribute(t,""+a)}}function C(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function F({fn:e,state:t={},defer:l=0,name:o="",draft:i,isSvgRoot:s,namespace:c,env:p}){let d=Pt,f=At,h={id:++Ct,name:o,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:qe({fn(e,t,a){if(!a.page)return console.error('context lost',a),0;if(!a.page.active)return 0;let r=[a.page.template],n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),r.push(e.template),e=e.parent}return a.node.next.forEach(t=>{let l=t.meta.nativeTemplate;l?r.includes(l)?et({target:t,params:e,defer:1,page:n[r.indexOf(l)],stack:a}):console.error('context drift',{stack:a,node:t}):et({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:qe({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===h)return 1;if(a.page.childSpawns[h.id])a.page.childSpawns[h.id].forEach(t=>{et({params:e,target:a.node,page:t,defer:1})});else if(t.targetTemplate){let r=[a.page];{let e=a.page.parent;for(;e;)r.push(e),e=e.parent}let n=r.findIndex(e=>t.targetTemplate===e.template);et(-1===n?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:r[n],defer:1})}else h.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&et({params:e,target:a.node,page:t,defer:1})})}else h.pages.forEach(t=>{et({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:f};f&&f.childTemplates.push(h);let m=a({meta:{template:h}});At=h;let g=Pt={template:h,node:m,api:null,trigger:{mount:n(),unmount:n()},draft:i,isSvgRoot:s,namespace:c,env:p};return l?g.deferredInit=()=>{let a=Pt,n=At;Pt=g,At=h,g.deferredInit=null;try{r(m,()=>{let a=u(t);g.api=e(a,g.trigger),h.nameMap=a})}finally{Pt=a,At=n}}:r(m,()=>{let a=u(t);g.api=e(a,g.trigger),h.nameMap=a}),Pt=d,At=f,h.actor=g,g}function A(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function q(e,{values:t={},parentLeaf:a,mountNode:r,svgRoot:n,leafData:l,opGroup:o,domSubtree:i,hydration:s}){function u(e){if(e.before)for(let t of e.before)switch(t.type){case'map':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current=t.fn(f[a.id].current);break}case'field':{let a=t.from;f[a.id]||(f[a.id]=a),f[e.id].current[t.field]=f[a.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;let t=f[e.id].current;for(let a of e.after){let e=a.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),a.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=a.fn(t)}}}function c(e,t,a){let r;t.stop=1;try{for(;t.i<e.length;)r=e[t.i],t.i++,r.fn(a[r.of.id].current)}catch(e){console.error(e),t.stop=0}}let p=a?a.spawn:null,d=e.template,f={},h={id:++Ft,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);let m={},g={spawn:h,api:m,draft:e.draft,ops:{group:o,domSubtree:i},svgRoot:n,data:l,parentLeaf:a,hydration:s},v=qt;qt=g,p&&(p.childSpawns[d.id]||(p.childSpawns[d.id]=[]),p.childSpawns[d.id].push(h)),h.fullID=p?`${p.fullID}_${h.id}`:""+h.id,p&&Object.assign(f,p.reg);for(let e of d.closure){let t=e,a=h.parent;e:for(;a;){if(e.id in a.reg){t=a.reg[e.id];break e}a=a.parent}f[e.id]=t}for(let e of d.plain){let t={id:e.id,current:A(e)};f[e.id]=t}for(let e in t){let a=d.nameMap[e].stateRef.id;f[a]={id:a,current:t[e]}}for(let e of d.closure)u(e);for(let e of d.plain)u(e);let y={i:0,stop:0};for(;!y.stop;)c(d.watch,y,f);if(p)for(let e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(m.mount=(t,a=1)=>et({target:e.trigger.mount,params:t,defer:a,page:h}),m.unmount=(t,a=1)=>et({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)m[t]=(a,r=1)=>et({target:e.api[t],params:a,defer:r,page:h});return g.spawn.api=m,g.spawn.leaf=g,g.api.mount({node:r,leaf:g}),qt=v,g}function P(e){let t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null}function N(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return N(e.child.child);case'LF':case'RF':case'FF':return D(e.child);case'FRec':case'FRecItem':return D(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){let e=N(t);if(e)return e;t=t.left}return null}default:return null}}function D(e){let t=e.child;for(let e=t.length-1;e>=0;e--){let a=N(t[e]);if(a)return a}return null}function M(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{let t=e.parent.parent.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=N(a.child[e]);if(t)return t}return M(a)}case'FF':{let t=e.parent,a=t.parent;for(let e=t.index-1;e>=0;e--){let t=N(a.child[e]);if(t)return t}return M(a)}case'LF':{let t=e.parent.left;for(;t;){let e=N(t);if(e)return e;t=t.left}return M(e.parent.parent)}default:return null}if('route'===e.type){let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=N(e);if(r)return r}return M(t)}let t=e.parent.parent;for(let a=e.parent.index-1;a>=0;a--){let e=t.child[a];if(!e)continue;let r=N(e);if(r)return r}return M(t)}function O(e){let t=M(e);return t?t.value:null}function E(e,{parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l}){e.childTemplates.forEach(e=>{V({parentBlockFragment:t,leaf:a,node:r,svgRoot:n,values:l,actor:e})})}function V({parentBlockFragment:e,leaf:t,node:a,actor:r,svgRoot:n,values:l}){let o,{draft:i}=r,{queue:s}=t.ops.group,u=y(s),c=t.ops.domSubtree,p=c;switch(i.type){case'route':{let t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RF',parent:null,child:{type:'fragment',parent:null,child:[]},visible:0}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{let t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:i.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:i.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:g({value:0,priority:'tree',runOp(e){e?(z(t),o.needToCallNode&&(o.needToCallNode=0,et({target:Nt,params:{element:t.value,fns:i.node},page:d.spawn}))):(t.value.remove(),t.parent.visible=0)},group:c})},needToCallNode:i.node.length>0},p=y(s);break}case'list':{let t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:i.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[i.inParentIndex]=t.parent,o={type:'list',draft:i,block:t};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:i.inParentIndex},child:{type:'RecItemF',parent:null,child:{type:'fragment',parent:null,child:[]}}};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[i.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn("unexpected draft type "+i.type)}let d=q(r,{values:l,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:o,opGroup:u,domSubtree:p,hydration:t.hydration})}function z(e){let t=O(e);t?t.after(e.value):P(e).prepend(e.value),e.parent.visible=1}function j(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){let a={};for(let r in t){let n=t[r];a[r]=e.map('function'==typeof n?e=>n(e):e=>e[n])}return a}return e.map(e=>e[t])}function B(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function L(e){let t=Pt.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){let a=e.text,r=t.childCount;Array.isArray(a)?(t.text.push(...a.map((e,t)=>({index:t+r,value:e}))),t.childCount+=a.length):(t.text.push({index:r,value:a}),t.childCount+=1)}if(e.style&&t.styleProp.push(e.style),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?U(t.config||{},t.on):U(t)}e.ɔ&&L(e.ɔ)}function U(e,t){if(!Pt)return;let a=Pt.draft;if('element'!==a.type)throw Error(`"handler" extension can be used only with element nodes, got "${a.type}"`);void 0===t&&(t=e,e={});for(let e in t)if(!X(t[e]))throw Error(`handler for "${e}" should be event`);let{passive:r=1,capture:n=0,prevent:l=0,stop:o=0}=e;a.handler.push({options:{prevent:l,stop:o},domConfig:{passive:l?0:r,capture:n},map:t})}function _({source:e,visible:t,fn:a}){if(!Pt)throw Error('route() called outside from using() closure');let r=F({name:'route',isSvgRoot:0,namespace:Pt.namespace,env:Pt.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:l,unmount:o}){let u=e.map(e=>({value:e,visible:t(e)})),c={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},p=F({name:'route item',isSvgRoot:0,namespace:Pt.namespace,env:Pt.env,draft:c,state:{store:null},fn({store:e},{mount:t,unmount:r}){let l=n();e.on(l,(e,t)=>t),a({store:e});let o=i({source:t,clock:u,fn:({leaf:e,node:t},{visible:a,value:r})=>({leaf:e,visible:a,node:t,value:r}),greedy:1});t.watch(({leaf:e,node:t})=>{let a=e.data;a.block.child.visible=1,E(c,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),o.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&et({target:l,params:a,defer:1,page:e.spawn}),Q(t,e)}),i({source:t,clock:r,greedy:1}).watch(({leaf:e})=>{$(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,J(t,t.parent.childSpawns[t.template.id]),J(t,t.template.pages)})}});H(p);let{onMount:d,onState:f}=K({mount:l,state:u,onMount:({visible:e,value:t},{leaf:a,node:r})=>({leaf:a,visible:e,node:r,value:t}),onState:({leaf:e,node:t},{visible:a,value:r})=>({leaf:e,visible:a,node:t,value:r})});s([d,f]).watch(({leaf:e,visible:t,value:a,node:r})=>{let n=e.data;n.block.child.visible=t,t&&!n.initialized&&(V({parentBlockFragment:n.block.child.child,leaf:e,node:r,actor:p,values:{store:a}}),n.initialized=1)}),i({source:l,clock:o,greedy:1}).watch(({leaf:e})=>{$(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,J(t,t.parent.childSpawns[t.template.id]),J(t,t.template.pages)})}});H(r)}function Q(e,t){let a=t=>{let r=t.data;switch(r.type){case'element':h(e,r.ops.visible);break;case'route':case'list':case'list item':$(t,a);break;default:console.log('unsupported type',r.type)}};$(t,a)}function $(e,t){let{spawn:a}=e;for(let e in a.childSpawns){let r=a.childSpawns[e];for(let e=0;e<r.length;e++)t(r[e].leaf)}}function G(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=F({name:'rec',state:{store:null},isSvgRoot:0,namespace:Pt.namespace,env:Pt.env,draft:t,defer:1,fn({store:a},{mount:r,unmount:l}){e({state:a});let o=n();return a.on(o,(e,t)=>t),r.watch(({node:e,leaf:a})=>{E(t,{parentBlockFragment:a.data.block.child.child,leaf:a,node:e})}),i({source:r,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,$(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:r}=Pt;H(F({name:'rec item',isSvgRoot:0,namespace:r,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:r,unmount:n}){let{onMount:l,onState:o}=K({state:e,mount:r,onMount:(e,{leaf:t,node:a})=>({state:e,leaf:t,node:a}),onState:({leaf:e,node:t},a)=>({state:a,leaf:e,node:t})});i({source:r,clock:n,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,$(e,e=>{e.api.unmount()})}),o.watch(({state:e,leaf:t})=>{$(t,t=>{t.api.itemUpdater(e)})}),l.watch(({node:e,leaf:t,state:r})=>{V({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:r}})})}}))}}function W(e,t){'function'==typeof t&&(X(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:r,source:l,fields:u=[]}=e,c=void 0!==r?'function'==typeof r?r:e=>e[r]:(e,t)=>t,p={type:'list',key:Z(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1};if(!Pt)throw Error('list() called outside from using() closure');let d=Pt.env,f=Pt.namespace;H(F({name:'list',draft:p,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:r}){let h=F({name:'list item',state:{id:-1,store:null},draft:p,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:r,unmount:l}){a({store:t,key:e,fields:j(t,u)});let s=n();t.on(s,(e,t)=>t);let c=o({leaf:null});if(i({source:c,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;J(t,t.parent.child);let a=t.left,r=t.right;a&&(a.right=r,r||t.parent.lastChild!==t||(t.parent.lastChild=a)),r&&(r.left=a),a||r||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,$(e,e=>{e.api.unmount()});let{spawn:n}=e;n.active=0,J(n,n.parent.childSpawns[n.template.id]),J(n,n.template.pages)}),p.itemVisible){let{onMount:e,onState:t}=K({mount:r,state:p.itemVisible,onMount:(e,{node:t,leaf:a})=>({visible:e,node:t,leaf:a}),onState:({node:e,leaf:t},a)=>({visible:a,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:a})=>{c.setState({leaf:a});let r=a.data.block;r.visible=e,r.childInitialized=e,e&&E(p,{parentBlockFragment:r.child,leaf:a,node:t})}),t.watch(({visible:e,node:t,leaf:a})=>{let r=a.data.block;r.visible=e,r.childInitialized?Q(e,a):e&&(r.childInitialized=1,E(p,{parentBlockFragment:r.child,leaf:a,node:t}))})}else r.watch(({node:e,leaf:t})=>{c.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,E(p,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:s}},env:d}),m=o([]),g=l.map(e=>e),v=i({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),x=i({source:v,clock:g,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1});i({source:m,clock:s([v,x]),greedy:1,fn(e,{node:t,updates:a,leaf:r,hydration:n}){let o=r.data.block;xt('list update ['+l.shortName+']');let i=Array(a.length).fill(0),s=a.map(c),u=[];for(let t=0;t<e.length;t++){let r=e[t],n=s.indexOf(r.key);-1!==n?(u.push(r),i[n]=1,w(a[n],r.asyncValue)):(r.active=0,r.instance&&r.instance.api.unmount(),k(r.asyncValue))}for(let e=0;e<a.length;e++){if(i[e])continue;let l=a[e],c=s[e],p=y(r.ops.group.queue),d={type:'LF',parent:o,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},f={type:'listItem',key:c,index:c,active:1,leafData:{type:'list item',block:d},asyncValue:b({value:l,group:p,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(n||(f.instance=q(h,{values:{id:c,store:e},parentLeaf:r,mountNode:t,svgRoot:r.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:r.ops.domSubtree,hydration:n})))}})},m=u.length;u.push(f);let g=m>0?u[m-1].leafData:null;if(d.child.parent=d,o.child.push(d),g){let e=g.block;d.left=e;let t=e.right;t?(t.left=d,d.right=t):o.lastChild=d,e.right=d}else o.lastChild=d;n&&(f.instance=q(h,{values:{id:c,store:l},parentLeaf:r,mountNode:t,svgRoot:r.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:r.ops.domSubtree,hydration:n}))}return St('list update ['+l.shortName+']'),0===u.length&&(o.lastChild=null),u},target:m}),i({source:t,clock:i({source:m,clock:r,greedy:1}),fn:({leaf:e},t)=>({leaf:e,records:t}),greedy:1}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){let a=t[e];a.instance&&a.instance.api.unmount(),a.active=0}let{spawn:a}=e;a.active=0,J(a,a.parent.childSpawns[a.template.id]),J(a,a.template.pages)})},env:d}))}function H(e){if(!Pt)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(Pt.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=Pt.draft.childCount,Pt.draft.childCount+=1,Pt.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+Pt.draft.type)}}function J(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function K({mount:e,state:t,onMount:a,onState:r}){return{onMount:i({source:t,clock:e,fn:a,greedy:1}),onState:i({source:e,clock:t,fn:r,greedy:1})}}let X=e=>(le(e)||ne(e))&&'kind'in e;const Y=e=>t=>X(t)&&t.kind===e;let Z=Y('store'),ee=Y('event'),te=Y('effect'),ae=Y('domain'),re=e=>{throw Error(e)},ne=e=>'object'==typeof e&&null!==e,le=e=>'function'==typeof e,oe=e=>e.graphite||e,ie=e=>e.family.owners,se=e=>e.family.links,ue=e=>e.stateRef,ce=e=>e.config,pe=e=>e.ɔ,de=e=>e.value,fe=e=>e.subscribers,he=e=>e.parent,me=(e,t)=>''+e.shortName+t,ge=(e,t)=>null==t?me(e,' → *'):t;var ve=(()=>{var e,t=('undefined'!=typeof self?self:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof module?module:Function("","return this")()).Symbol;return'function'==typeof t?t.observable?e=t.observable:(e=t('observable'),t.observable=e):e='@@observable',e})();const ye=()=>{let e=0;return()=>(++e).toString(36)};let be=ye(),ke=ye(),we=(e,t)=>e.bind(null,t),xe=(e,t,a)=>e.bind(null,t,a);const Se=(e,t,a)=>({id:ke(),type:e,data:a,hasRef:t});let Ie=0,Re=({priority:e="barrier"})=>Se('barrier',0,{barrierID:++Ie,priority:e}),Te=({from:e="store",store:t,target:a,to:r=(a?'store':'stack')})=>Se('mov','store'===e,{from:e,store:t,to:r,target:a}),Ce=()=>Se('check',0,{type:'defined'}),Fe=({store:e})=>Se('check',1,{type:'changed',store:e}),Ae=xe(Se,'compute',0),qe=xe(Se,'filter',0),Pe=xe(Se,'run',0),Ne=({store:e})=>Te({from:'stack',target:e}),De=e=>({id:ke(),current:e}),Me=({current:e})=>e,Oe=(e,{fn:t},{a})=>t(e,a),Ee=(e,{fn:t},{a})=>t(a,e),Ve=(e,{fn:t})=>t(e),ze=(e,t)=>{let a=oe(e);for(let e=0;e<t.length;e++){let r=oe(t[e]);'domain'!==a.family.type&&(r.family.type='crosslink'),ie(r).push(a),se(a).push(r)}};const je=(e=[])=>{let t=[];if(Array.isArray(e))for(let a=0;a<e.length;a++)Array.isArray(e[a])?t.push(...e[a]):t.push(e[a]);else t.push(e);return t.map(oe)};let Be=({hasRef:e,type:t,data:a},r)=>{let n;e&&(n=a.store,r[n.id]=n),'mov'===t&&'store'===a.to&&(n=a.target,r[n.id]=n)},Le=null;const Ue=(e,t)=>{if(!e)return t;if(!t)return e;let a,r=e.v.type===t.v.type;return(r&&e.v.id>t.v.id||!r&&'sampler'===e.v.type)&&(a=e,e=t,t=a),a=Ue(e.r,t),e.r=e.l,e.l=a,e},_e=[];let Qe=0;for(;Qe<5;)_e.push({first:null,last:null,size:0}),Qe+=1;const $e=()=>{for(let e=0;e<5;e++){let t=_e[e];if(t.size>0){if(2===e||3===e){t.size-=1;let e=Le.v;return Le=Ue(Le.l,Le.r),e}1===t.size&&(t.last=null);let a=t.first;return t.first=a.r,t.size-=1,a.v}}},Ge=(e,t,a,r,n,l)=>We(0,{a:null,b:null,node:a,parent:r,value:n,page:t,forkPage:l},e),We=(e,t,a,r=0)=>{let n=He(a),l=_e[n],o={v:{idx:e,stack:t,type:a,id:r},l:0,r:0};2===n||3===n?Le=Ue(Le,o):(0===l.size?l.first=o:l.last.r=o,l.last=o),l.size+=1},He=e=>{switch(e){case'child':return 0;case'pure':return 1;case'barrier':return 2;case'sampler':return 3;case'effect':return 4;default:return-1}},Je=new Set;let Ke,Xe=0,Ye=null,Ze=()=>Ye,et=(e,t,a)=>{let r=Ye,n=null,l=Ke;if(e.target&&(t=e.params,a=e.defer,r='page'in e?e.page:r,e.stack&&(n=e.stack),l=e.forkPage||l,e=e.target),Array.isArray(e))for(let a=0;a<e.length;a++)Ge('pure',r,oe(e[a]),n,t[a],l);else Ge('pure',r,oe(e),n,t,l);a&&Xe||(()=>{let e,t,a,r,n,l,o={alreadyStarted:Xe,currentPage:Ye,forkPage:Ke};Xe=1;e:for(;r=$e();){let{idx:o,stack:i,type:s}=r;a=i.node,Ye=n=i.page,Ke=i.forkPage,l=(n||a).reg;let u={fail:0,scope:a.scope};e=t=0;for(let r=o;r<a.seq.length&&!e;r++){let c=a.seq[r],p=c.data;switch(c.type){case'barrier':{let e=p.barrierID;n&&(e=`${n.fullID}_${e}`);let t=p.priority;if(r!==o||s!==t){Je.has(e)||(Je.add(e),We(r,i,t,e));continue e}Je.delete(e);break}case'mov':{let e;switch(p.from){case'stack':e=de(i);break;case'a':e=i.a;break;case'b':e=i.b;break;case'value':e=p.store;break;case'store':l[p.store.id]||(i.page=n=null,l=a.reg),e=Me(l[p.store.id])}switch(p.to){case'stack':i.value=e;break;case'a':i.a=e;break;case'b':i.b=e;break;case'store':l[p.target.id].current=e}break}case'check':switch(p.type){case'defined':t=void 0===de(i);break;case'changed':t=de(i)===Me(l[p.store.id])}break;case'filter':t=!tt(u,p,i);break;case'run':if(r!==o||'effect'!==s){We(r,i,'effect');continue e}case'compute':i.value=tt(u,p,i)}e=u.fail||t}if(!e)for(let e=0;e<a.next.length;e++)Ge('child',n,a.next[e],i,de(i),i.forkPage)}Xe=o.alreadyStarted,Ye=o.currentPage,Ke=o.forkPage})()};const tt=(e,{fn:t},a)=>{try{return t(de(a),e.scope,a)}catch(t){console.error(t),e.fail=1}};let at=(e,t)=>{pe(e)&&t(ce(e),pe(e))};const rt=(e,t)=>{let a=e.indexOf(t);-1!==a&&e.splice(a,1)},nt=(e,t)=>{rt(e.next,t),rt(ie(e),t),rt(se(e),t)},lt=(e,t,a)=>{let r;e.next.length=0,e.seq.length=0,e.scope=null;let n=se(e);for(;r=n.pop();)nt(r,e),(t||a&&!e.meta.sample||'crosslink'===r.family.type)&<(r,t,a);for(n=ie(e);r=n.pop();)nt(r,e),a&&'crosslink'===r.family.type&<(r,t,a)},ot=e=>e.clear();let st=(e,{deep:t}={})=>{let a=0;if(e.ownerSet&&e.ownerSet.delete(e),Z(e))ot(fe(e));else if(ae(e)){a=1;let t=e.history;ot(t.events),ot(t.effects),ot(t.stores),ot(t.domains)}lt(oe(e),!!t,a)},ut=e=>{let t=xe(st,e,void 0);return t.unsubscribe=t,t},ct=e=>(pt&&ze(de(pt),[e]),e),pt=null,dt=()=>pt&&pt.template,ft=(e,t,{node:r,scope:n,meta:l})=>ct(a({node:r,parent:e,child:t,scope:n,meta:l,family:{owners:[e,t],links:t}})),ht=(e,t)=>ut(ct(a({scope:{fn:t},node:[Pe({fn:Ve})],parent:e,meta:{op:'watch'},family:{owners:e}})));const mt=(e,t)=>(ne(e)&&(mt(ce(e),t),null!=e.name&&(ne(e.name)?mt(e.name,t):t.name=e.name),e.loc&&(t.loc=e.loc),(e.sid||null===e.sid)&&(t.sid=e.sid),e.handler&&(t.handler=e.handler),he(e)&&(t.parent=he(e)),'strict'in e&&(t.strict=e.strict),e.named&&(t.named=e.named),mt(pe(e),t)),t);let gt,vt=(e,t,a,r)=>{let n=mt({name:r,config:a},{}),l=be(),{parent:o=null,sid:i=null,strict:s=1,named:u=null}=n,c=u||n.name||('domain'===e?'':l),p=((e,t)=>{let a,r,n,l=e;return t?(n=t.compositeName,0===e.length?(a=n.path,r=n.fullName):(a=n.path.concat([e]),r=0===n.fullName.length?e:n.fullName+'/'+e)):(a=0===e.length?[]:[e],r=e),{shortName:l,fullName:r,path:a}})(c,o);return t.kind=e,t.id=l,t.sid=i,t.shortName=c,t.parent=o,t.compositeName=p,t.defaultConfig=n,t.thru=e=>e(t),t.getType=()=>p.fullName,'domain'!==e&&(t.subscribe=e=>((e=>{ne(e)||le(e)||re('expect value to be an object')})(e),t.watch(le(e)?e:t=>{e.next&&e.next(t)})),t[ve]=()=>t),gt=s,{unit:e,name:c,sid:i,named:u}};const yt=(e,t,a,r)=>ft(e,t,{scope:{fn:r},node:[Ae({fn:Ve})],meta:{op:a}}),bt=(e,t,a,r)=>{let l;ne(a)&&(l=a,a=a.fn);let o=n(me(e,' →? *'),l);return ft(e,o,{scope:{fn:a},node:r,meta:{op:t}}),o},kt=(e,t,a,r,n)=>{let l=ue(t),o=[Te({store:l,to:'a'}),Ae({fn:r?Ee:Oe}),Ce(),Fe({store:l}),Ne({store:l})],i=dt();if(i&&(o.unshift(i.loader),o.push(i.upward),Z(e))){let t=ue(e);i.plain.includes(t)||(i.closure.includes(t)||i.closure.push(t),l.before||(l.before=[]),l.before.push({type:'closure',of:t}))}return ft(e,t,{scope:{fn:n},node:o,meta:{op:a}})};let wt=(e,t)=>{for(let a in e)t(e[a],a)};a({node:[Pe({fn({fn:e,value:t}){e(t)}})],meta:{op:'fx',fx:'sidechain'}});let xt,St,It,Rt=e=>X(e)?e:((...e)=>{let a,r,n;0===e.length&&re('at least one argument required'),at(e[0],(t,a)=>{n=t,e=a});let l,i,s=e[e.length-1];if(le(s)?(r=e.slice(0,-1),a=s):r=e,1===r.length){let e=r[0];Z(e)||(l=e,i=1)}return i||(l=r,a&&(a=(e=>t=>e(...t))(a))),((e,a,r,n)=>{let l=e?e=>e.slice():e=>Object.assign({},e),i=e?[]:{},s=dt(),u=l(i),c=De(u),p=De(1);c.type=e?'list':'shape',s&&s.plain.push(c,p);let d=o(u,{name:r||t(a)}),f=[Ce(),Te({store:c,to:'a'}),qe({fn:(e,{key:t},{a})=>e!==a[t]}),Te({store:p,to:'b'}),Ae({fn(e,{clone:t,key:a},r){r.b&&(r.a=t(r.a)),r.a[a]=e}}),Te({from:'a',target:c}),Te({from:'value',store:0,target:p}),Re({priority:'barrier'}),Te({from:'value',store:1,target:p}),Te({store:c}),n&&Ae({fn:n}),Fe({store:ue(d)})],h=c.before=[];return wt(a,(e,t)=>{if(!Z(e))return void(u[t]=i[t]=e);i[t]=e.defaultState,u[t]=e.getState();let a=ft(e,d,{scope:{key:t,clone:l},node:f,meta:{op:'combine'}}),r=ue(e);h.push({type:'field',field:t,from:r}),s&&(s.plain.includes(r)||a.seq.unshift(s.loader))}),d.defaultShape=a,c.after=[n?{type:'map',to:ue(d),fn:n}:{type:'copy',to:ue(d)}],s||(d.defaultState=n?ue(d).current=n(u):i),d})(Array.isArray(l),l,n,a)})(e);qe({fn:(e,{state:t})=>void 0!==e&&e!==Me(t)}),Ae({fn:e=>e}),'undefined'!=typeof performance&&performance.mark?(xt=e=>{performance.mark('☄️ '+e+' start')},St=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(xt=()=>{},St=()=>{}),It='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let Tt='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),Ct=0,Ft=0,At=null,qt=null,Pt=null,Nt=n();Nt.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),e.h=(e,t)=>{function a(e){return e.data.block.value}function r(e,t,a){let r=e.data.block.child.child,n={type:'text',parent:{type:'FT',parent:r,child:null,visible:0,index:a},value:null};if(n.parent.child=n,r.child[a]=n.parent,e.hydration){let e=M(n);if(e)switch(e.type){case'text':n.value=c.document.createTextNode(t),e.value.after(n.value);break;case'element':n.value=e.value.nextSibling,C(n.value,t)}else{let e=P(n);n.value=e.firstChild,C(n.value,t)}n.parent.visible=1}else n.value=c.document.createTextNode(t),z(n);return n}let l,o=0,u=0;if('function'==typeof t?(o=1,l=t):t&&(u=1,t.fn&&(o=1,l=t.fn),t.ɔ&&('function'==typeof t.ɔ?(o=1,l=t.ɔ):'function'==typeof t.ɔ.fn&&(o=1,l=t.ɔ.fn))),!Pt)throw Error('h() called outside from using() closure');let c=Pt.env,p=Pt.namespace,d=p,m='html';d=m='svg'===p?'svg':'html','svg'===e&&(m='svg',d='svg');let v='svg'===m?c.document.createElementNS('http://www.w3.org/2000/svg',e):c.document.createElement(e);'foreignObject'===p?(v.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(v.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');let y=v,b={type:'element',tag:e,attr:[],data:[],text:[],styleProp:[],styleVar:[],handler:[],stencil:y,seq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]},k=F({name:'element',draft:b,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:c,unmount:p}){function d(e){return K({mount:m,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let m=n(),v=c.map(({leaf:e})=>e);o&&l(),u&&L(t);let w={attr:{},data:{},text:b.text,styleProp:{},styleVar:{},visible:b.visible||null,handler:b.handler};for(let e=0;e<b.attr.length;e++){let t=b.attr[e];for(let e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<b.data.length;e++){let t=b.data[e];for(let e in t)w.data[e]=t[e]}for(let e=0;e<b.styleProp.length;e++){let t=b.styleProp[e];for(let e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<b.styleVar.length;e++){let t=b.styleVar[e];for(let e in t)w.styleVar[e]=t[e]}w.visible&&b.seq.push({type:'visible',value:w.visible});for(let e in w.attr){let t=w.attr[e];X(t)?b.seq.push({type:'attr',field:e,value:t}):T(y,e,t)}for(let e in w.data){let t=w.data[e];X(t)?b.seq.push({type:'data',field:e,value:t}):R(y,e,t)}for(let e in w.styleProp){let t=w.styleProp[e];X(t)?b.seq.push({type:'style',field:e,value:t}):I(y,e,t)}for(let e in w.styleVar){let t=w.styleVar[e];X(t)?b.seq.push({type:'styleVar',field:e,value:t}):S(y,e,t)}for(let e=0;e<w.text.length;e++){let t=w.text[e];if(null!==t.value)if(X(t.value)){b.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=At;a.plain.includes(e)||a.closure.includes(e)||a.closure.push(e)}else b.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){let t=w.handler[e];for(let e in t.map)b.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){let{onMount:e,onState:t}=K({mount:v,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});e.watch(({leaf:e,value:t,hydration:a})=>{let r=e.data,n=r.block;if(a&&(f(t,r.ops.visible),t)){let e,t=O(n);if(e=t?t.nextSibling:P(n).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}n.value=e,n.parent.visible=1}E(b,{parentBlockFragment:n.child.child,leaf:e,node:n.value,svgRoot:k.isSvgRoot?n.value:null}),t&&r.needToCallNode&&(r.needToCallNode=0,et({target:Nt,params:{element:r.block.value,fns:b.node},page:e.spawn,defer:1})),et({target:m,params:e,defer:1,page:e.spawn})}),s([t,e]).watch(({leaf:e,value:t,hydration:a})=>{a||h(t,e.data.ops.visible)})}for(let e=0;e<b.seq.length;e++){let t=b.seq[e];switch(t.type){case'visible':break;case'attr':{let{field:e}=t,r='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:n,onState:l}=d(t.value);if(r)s([l,n]).watch(({leaf:t,value:r})=>{T(a(t),e,r)});else{let t=b.opsAmount++;n.watch(({value:r,leaf:n})=>{let l=a(n),o=g({value:r,priority:'props',runOp(t){T(l,e,t)},group:n.ops.group});n.ops.group.ops[t]=o,T(l,e,r)}),l.watch(({value:e,leaf:a})=>{h(e,a.ops.group.ops[t])})}break}case'data':{let{field:e}=t,{onMount:r,onState:n}=d(t.value),l=b.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),o=g({value:t,priority:'props',runOp(t){R(n,e,t)},group:r.ops.group});r.ops.group.ops[l]=o,R(n,e,t)}),n.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'style':{let e=b.opsAmount++,{field:r}=t,{onMount:n,onState:l}=d(t.value);n.watch(({value:t,leaf:n})=>{let l=a(n),o=g({value:t,priority:'props',runOp(e){I(l,r,e)},group:n.ops.group});n.ops.group.ops[e]=o,I(l,r,t)}),l.watch(({value:t,leaf:a})=>{h(t,a.ops.group.ops[e])});break}case'styleVar':{let{field:e}=t,{onMount:r,onState:n}=d(t.value),l=b.opsAmount++;r.watch(({value:t,leaf:r})=>{let n=a(r),o=g({value:t,priority:'props',runOp(t){S(n,e,t)},group:r.ops.group});r.ops.group.ops[l]=o,S(n,e,t)}),n.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'staticText':m.map(e=>e).watch(e=>{r(e,t.value,t.childIndex)});break;case'dynamicText':{let e=b.opsAmount++;i({source:t.value,clock:m,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:a,leaf:n})=>{let l=g({value:a,priority:'props',runOp(e){C(o.value,e)},group:n.ops.group});n.ops.group.ops[e]=l;let o=r(n,a,t.childIndex)}),i({source:m,clock:t.value,fn:(e,t)=>({leaf:e,text:t}),greedy:1}).watch(({leaf:t,text:a})=>{h(a,t.ops.group.ops[e])});break}case'handler':{let e=t.handler.graphite.meta.nativeTemplate||null;m.watch(r=>{let n=null;if(e){let t=0,a=r.spawn;for(;!t&&a;)a.template===e?(t=1,n=a):a=a.parent}a(r).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),et({target:t.handler,params:e,page:n})},t.domConfig)});break}}}i({source:v,clock:p,greedy:1}).watch(e=>{let{spawn:t}=e;J(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,J(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),h(0,e.data.ops.visible)}),c.watch(({leaf:e})=>{let t=e.data;if(!b.visible){let a=t.ops.visible,r=t.block;if(e.hydration){f(1,a);let e,t=O(r);if(e=t?t.nextSibling:P(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.parent.visible=1}E(b,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:k.isSvgRoot?r.value:null}),et({target:m,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,et({target:Nt,params:{element:t.block.value,fns:b.node},page:e.spawn,defer:1})):h(1,a)}})},env:c});H(k)},e.handler=U,e.list=W,e.node=e=>{let t=Pt.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},e.rec=G,e.remap=j,e.route=_,e.spec=L,e.text=(e,...t)=>{let a=[e[0]];for(let r=0;r<t.length;r++)a.push(t[r],e[r+1]);L({text:a})},e.tree=({source:e,child:t,fn:a})=>{let r=G(({state:e})=>{W({source:e,fn({store:e}){let n=e.map(e=>e[t]||[]);a({store:e,child(){r({state:n})}})}})});r({state:e})},e.using=(e,t)=>{let a,r,n,l,o;if('function'==typeof t)a=t,n=B(),l=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:B(),l=t.hydrate,r=t.onComplete,o=t.onRoot}if(!e)throw Error('using() first argument is missing');let i=e.namespaceURI,s=e.tagName.toLowerCase(),u={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},c=F({name:'using',draft:u,isSvgRoot:'svg'===s,namespace:'http://www.w3.org/2000/svg'===i?'svg':'foreignobject'===s?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{E(u,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:n}),p={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};p.child.parent=p,p.child.child.parent=p.child;let d=v({onComplete:r}),f=q(c,{parentLeaf:qt||null,mountNode:e,svgRoot:c.isSvgRoot?e:qt?qt.svgRoot:null,leafData:{type:'using',draft:u,element:e,block:p},opGroup:y(d),domSubtree:y(d),hydration:l});o&&o({template:c,leaf:f})},e.variant=({source:e,cases:t,key:a})=>{if(!X(e))throw Error('variant({source}) should be unit');let r;r='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let n=0;for(let a in t)'__'!==a?_({source:e,visible:e=>r(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);_({source:e,visible:e=>!a.includes(r(e)),fn:t.__})}},Object.defineProperty(e,'__esModule',{value:1})}); | ||
//# sourceMappingURL=forest.umd.js.map |
@@ -214,2 +214,13 @@ import {Store, Event, Step} from 'effector' | ||
export function route<T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => boolean | ||
fn: (config: {store: Store<T>}) => void | ||
}): void | ||
export function route<T, S extends T>(config: { | ||
source: Store<T> | ||
visible: (value: T) => value is S | ||
fn: (config: {store: Store<S>}) => void | ||
}): void | ||
export function node(fn: (node: DOMElement) => void): void | ||
@@ -216,0 +227,0 @@ |
{ | ||
"name": "forest", | ||
"version": "0.16.5", | ||
"version": "0.16.6", | ||
"description": "UI engine for web", | ||
@@ -12,3 +12,3 @@ "main": "forest.cjs.js", | ||
"peerDependencies": { | ||
"effector": "^20.16.2" | ||
"effector": "^20.17.0" | ||
}, | ||
@@ -15,0 +15,0 @@ "keywords": [ |
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
634315
1467