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

forest

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forest - npm Package Compare versions

Comparing version 0.16.1 to 0.16.2

2

forest.cjs.js

@@ -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,a;e.status='active',t=n(e),(a=e).cursor.prev&&(a.cursor.prev.cursor.next=a.cursor.next),a.cursor.next&&(a.cursor.next.cursor.prev=a.cursor.prev),t.last===a&&(t.last=a.cursor.prev),t.first===a&&(t.first=a.cursor.next),a.cursor.prev=null,a.cursor.next=null}function n(e){return e.group.activeChilds[e.priority]}function a(e,n){n.value.active=n.value.pending=e,'active'!==n.status&&t(n)}function r(a,r){if(r.value.active===a)return r.value.pending=a,void('pending'===r.status&&(t(r),n(r).first||e(r.group,r.priority)));var o,l,s,i;'active'===r.status&&(r.status='pending',n(r).first||((s=r.group).queue[i=r.priority].last?(s.cursor[i].prev=s.queue[i].last,s.queue[i].last.cursor[i].next=s,s.queue[i].last=s):s.queue[i].first=s.queue[i].last=s),l=r,(o=n(r)).last?(l.cursor.prev=o.last,o.last.cursor.next=l,o.last=l):o.first=o.last=l),r.value.pending=a,r.group.queue.rafID||(r.group.queue.rafID=U(r.group.queue.execQueue))}function o(n){L('execQueue');const a=z();let r,o,l=0;e:for(;n.props.first||n.tree.first||n.data.first;){if(z()-a>=10){l=1;break e}const s=!!n.props.first;for(s&&L('props');r=n.props.first;){for(;o=r.activeChilds.props.first;){if(z()-a>=10){l=1,j('props');break e}o.runOp(o.value.pending),o.value.active=o.value.pending,t(o)}e(r,'props')}s&&j('props');const i=!!n.tree.first;for(i&&L('tree');r=n.tree.first;){for(;o=r.activeChilds.tree.first;){if(z()-a>=10){l=1,j('tree');break e}o.runOp(o.value.pending),o.value.active=o.value.pending,t(o)}e(r,'tree')}i&&j('tree');const c=!!n.data.first;for(c&&L('data');r=n.data.first;){for(;o=r.activeChilds.data.first;){if(z()-a>=10){l=1,j('data');break e}o.runOp(o.value.pending),o.value.active=o.value.pending,t(o)}e(r,'data')}c&&j('data')}if(j('execQueue'),l)n.rafID=U(n.execQueue);else if(n.rafID=null,n.onDrain){const e=n.onDrain;n.onDrain=null,e()}}function l({value:e,runOp:t,group:n,priority:a}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:a,group:n,cursor:{prev:null,next:null}}}function s({onComplete:e}){const t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=o.bind(null,t),t}function i(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 c({value:e,group:t,onInit:n,onChange:a,onTerminate:o}){const s=l({value:e,group:t,runOp(e){i.status='A',a(e)},priority:'data'}),i={status:'IA',value:s.value,hooks:{onTerminate:o},ops:{init:l({value:0,group:t,runOp(e){i.status='A',n(i.value.active)},priority:'data'}),change:s,terminate:l({value:0,group:t,runOp(e){i.status='T',i.hooks.onTerminate(1)},priority:'data'})}};return r(1,i.ops.init),i}function u(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',r(1,e.ops.terminate);break;case'AA':e.status='AT',r(1,e.ops.terminate),r(e.value.active,e.ops.change);break;case'IA':e.status='T',r(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',r(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',r(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,n){d(n)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${n}`)}function h(e,t,n){d(n)?delete e.style[t]:e.style[t]=`${n}`}function v(e,t,n){d(n)?delete e.dataset[t]:e.dataset[t]=`${n}`}function m(e,t,n){if(d(n)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==n)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=`${n}`;break;case'checked':e.checked=`${n}`}e.setAttribute(t,`${n}`)}}function g(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function y({fn:e,state:t={},defer:n=0,name:a="",draft:r,isSvgRoot:o,namespace:l,env:s}){const i=H,c=G,u={id:++_,name:a,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,n){if(!n.page)return console.error('context lost',n),0;if(!n.page.active)return 0;const a=[n.page.template],r=[n.page];{let e=n.page.parent;for(;e;)r.push(e),a.push(e.template),e=e.parent}return n.node.next.forEach(t=>{const o=t.meta.nativeTemplate;o?a.includes(o)?effector.launch({target:t,params:e,defer:1,page:r[a.indexOf(o)],stack:n}):console.error('context drift',{stack:n,node:t}):effector.launch({target:t,params:e,defer:1,page:null,stack:n})}),0}}),loader:effector.step.filter({fn(e,t,n){if(n.parent){if(n.page){if(!n.page.active)return 0;if(n.page.template===u)return 1;if(n.page.childSpawns[u.id])n.page.childSpawns[u.id].forEach(t=>{effector.launch({params:e,target:n.node,page:t,defer:1})});else if(t.targetTemplate){const a=[n.page];{let e=n.page.parent;for(;e;)a.push(e),e=e.parent}const r=a.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===r?{params:e,target:n.node,page:null,defer:1}:{params:e,target:n.node,page:a[r],defer:1})}else u.pages.forEach(t=>{t.fullID.startsWith(n.page.fullID)&&effector.launch({params:e,target:n.node,page:t,defer:1})})}else u.pages.forEach(t=>{effector.launch({params:e,target:n.node,page:t,defer:1})});return 0}return 1}}),parent:c};c&&c.childTemplates.push(u);const p=effector.createNode({meta:{template:u}});G=u;const d=H={template:u,node:p,api:null,trigger:{mount:effector.createEvent(),unmount:effector.createEvent()},draft:r,isSvgRoot:o,namespace:l,env:s};return n?d.deferredInit=()=>{const n=H,a=G;H=d,G=u,d.deferredInit=null;try{effector.withRegion(p,()=>{const n=effector.restore(t);d.api=e(n,d.trigger),u.nameMap=n})}finally{H=n,G=a}}:effector.withRegion(p,()=>{const n=effector.restore(t);d.api=e(n,d.trigger),u.nameMap=n}),H=i,G=c,u.actor=d,d}function b(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function x(e,{values:t={},parentLeaf:n,mountNode:a,svgRoot:r,leafData:o,opGroup:l,domSubtree:s,hydration:i}){function c(e){if(e.before)for(const t of e.before)switch(t.type){case'map':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current=t.fn(f[n.id].current);break}case'field':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current[t.field]=f[n.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;const t=f[e.id].current;for(const n of e.after){const e=n.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),n.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=n.fn(t)}}}function u(e,t,n){let a;t.stop=1;try{for(;t.i<e.length;)a=e[t.i],t.i++,a.fn(n[a.of.id].current)}catch(e){console.error(e),t.stop=0}}const p=n?n.spawn:null,d=e.template,f={},h={id:++Q,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);const v={},m={spawn:h,api:v,draft:e.draft,ops:{group:l,domSubtree:s},svgRoot:r,data:o,parentLeaf:n,hydration:i},g=W;W=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(const e of d.closure){let t=e,n=h.parent;e:for(;n;){if(e.id in n.reg){t=n.reg[e.id];break e}n=n.parent}f[e.id]=t}for(const e of d.plain){const t={id:e.id,current:b(e)};f[e.id]=t}for(const e in t){const n=d.nameMap[e].stateRef.id;f[n]={id:n,current:t[e]}}for(const e of d.closure)c(e);for(const e of d.plain)c(e);const y={i:0,stop:0};for(;!y.stop;)u(d.watch,y,f);if(p)for(const e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,n=1)=>effector.launch({target:e.trigger.mount,params:t,defer:n,page:h}),v.unmount=(t,n=1)=>effector.launch({target:e.trigger.unmount,params:t,defer:n,page:h}),e.api)for(const t in e.api)v[t]=(n,a=1)=>effector.launch({target:e.api[t],params:n,defer:a,page:h});return m.spawn.api=v,m.spawn.leaf=m,m.api.mount({node:a,leaf:m}),W=g,m}function w(e){const t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent;case'tree':return e(t.parent.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'FTree':return S(e.child.child);case'FRec':case'FRecItem':return S(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){const e=k(t);if(e)return e;t=t.left}return null}default:return null}}function S(e){const t=e.child;for(let e=t.length-1;e>=0;e--){const n=k(t[e]);if(n)return n}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':{const t=e.parent.parent.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=k(n.child[e]);if(t)return t}return I(n)}case'FF':{const t=e.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=k(n.child[e]);if(t)return t}return I(n)}case'LF':{let t=e.parent.left;for(;t;){const e=k(t);if(e)return e;t=t.left}return I(e.parent.parent)}case'tree':{const t=e.parent.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=k(n.child[e]);if(t)return t}return I(n)}default:return null}if('route'===e.type){const t=e.parent.parent;for(let n=e.parent.index-1;n>=0;n--){const e=t.child[n];if(!e)continue;const a=k(e);if(a)return a}return I(t)}const t=e.parent.parent;for(let n=e.parent.index-1;n>=0;n--){const e=t.child[n];if(!e)continue;const a=k(e);if(a)return a}return I(t)}function F(e){const t=I(e);return t?t.value:null}function C(e,{parentBlockFragment:t,leaf:n,node:a,svgRoot:r,values:o}){e.childTemplates.forEach(e=>{R({parentBlockFragment:t,leaf:n,node:a,svgRoot:r,values:o,actor:e})})}function R({parentBlockFragment:e,leaf:t,node:n,actor:a,svgRoot:r,values:o}){let s;const{draft:c}=a,{queue:u}=t.ops.group,p=i(u),d=t.ops.domSubtree;let f=d;switch(c.type){case'route':{const t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:c.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[c.inParentIndex]=t.parent,s={type:'route',block:t,ops:{},initialized:0};break}case'element':{const t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:c.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:c.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[c.inParentIndex]=t.parent,s={type:'element',block:t,ops:{visible:l({value:0,priority:'tree',runOp(e){e?(T(t),s.needToCallNode&&(s.needToCallNode=0,effector.launch({target:J,params:{element:t.value,fns:c.node},page:h.spawn}))):(t.value.remove(),t.parent.visible=0)},group:d})},needToCallNode:c.node.length>0},f=i(u);break}case'list':{const t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:c.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[c.inParentIndex]=t.parent,s={type:'list',draft:c,block:t};break}case'tree':{const t={type:'tree',parent:{type:'FTree',parent:e,child:null,visible:1,index:c.inParentIndex},child:{type:'fragment',parent:null,child:[]}};t.parent.child=t,t.child.parent=t,e.child[c.inParentIndex]=t.parent,s={type:'tree',block:t};break}case'using':case'listItem':break;case'rec':{const t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:c.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[c.inParentIndex]=t.parent,s={type:'rec',block:t};break}case'recItem':{const t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:c.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[c.inParentIndex]=t.parent,s={type:'rec item',block:t};break}default:console.warn(`unexpected draft type ${c.type}`)}const h=x(a,{values:o,parentLeaf:t,mountNode:n,svgRoot:r||t.svgRoot,leafData:s,opGroup:p,domSubtree:f,hydration:t.hydration})}function T(e){const t=F(e);t?t.after(e.value):w(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){const n={};for(const a in t){const r=t[a];n[a]=e.map('function'==typeof r?e=>r(e):e=>e[r])}return n}return e.map(e=>e[t])}function P(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function q(e){const t=H.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'tree':case'treeItem':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){const n=e.text,a=t.childCount;Array.isArray(n)?(t.text.push(...n.map((e,t)=>({index:t+a,value:e}))),t.childCount+=n.length):(t.text.push({index:a,value:n}),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){const t=e.handler;'object'==typeof t.on?D(t.config||{},t.on):D(t)}e.ɔ&&q(e.ɔ)}function D(e,t){const n=H.draft;if('element'!==n.type)throw Error(`"handler" extension can be used only with element nodes, got "${n.type}"`);void 0===t&&(t=e,e={});const{passive:a=1,capture:r=0,prevent:o=0,stop:l=0}=e;n.handler.push({options:{prevent:o,stop:l},domConfig:{passive:o?0:a,capture:r},map:t})}function E({source:e,visible:t,fn:n}){const a=y({name:'route',isSvgRoot:0,namespace:H.namespace,env:H.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(a,{mount:o,unmount:l}){const s=e.map(e=>({value:e,visible:t(e)})),i={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},c=y({name:'route item',isSvgRoot:0,namespace:H.namespace,env:H.env,draft:i,state:{store:null},fn({store:e},{mount:t,unmount:a}){const o=effector.createEvent();e.on(o,(e,t)=>t),n({store:e});const l=effector.sample({source:t,clock:s,fn:({leaf:e,node:t},{visible:n,value:a})=>({leaf:e,visible:n,node:t,value:a}),greedy:1});t.watch(({leaf:e,node:t})=>{const n=e.data;n.block.child.visible=1,C(i,{parentBlockFragment:n.block.child.child,leaf:e,node:t})}),l.watch(({leaf:e,visible:t,value:n})=>{e.data.block.child.visible=t,t&&effector.launch({target:o,params:n,defer:1,page:e.spawn}),O(e,e=>{const n=e.data;switch(n.type){case'element':r(t,n.ops.visible);break;default:console.log('unsupported type',n.type)}})}),effector.sample(t,a).watch(({leaf:e})=>{O(e,e=>{e.api.unmount()});const{spawn:t}=e;t.active=0,$(t,t.parent.childSpawns[t.template.id]),$(t,t.template.pages)})}});V(c);const{onMount:u,onState:p}=B({mount:o,state:s,onMount:({visible:e,value:t},{leaf:n,node:a})=>({leaf:n,visible:e,node:a,value:t}),onState:({leaf:e,node:t},{visible:n,value:a})=>({leaf:e,visible:n,node:t,value:a}),greedy:1});effector.merge([u,p]).watch(({leaf:e,visible:t,value:n,node:a})=>{const r=e.data;r.block.child.visible=t,t&&!r.initialized&&(R({parentBlockFragment:r.block.child.child,leaf:e,node:a,actor:c,values:{store:n}}),r.initialized=1)}),effector.sample(o,l).watch(({leaf:e})=>{O(e,e=>{e.api.unmount()});const{spawn:t}=e;t.active=0,$(t,t.parent.childSpawns[t.template.id]),$(t,t.template.pages)})}});V(a)}function O(e,t){const{spawn:n}=e;for(const e in n.childSpawns){const a=n.childSpawns[e];for(let e=0;e<a.length;e++)t(a[e].leaf)}}function M(e){const t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},n=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:H.namespace,env:H.env,draft:t,defer:1,fn({store:n},{mount:a,unmount:r}){e({state:n});const o=effector.createEvent();return n.on(o,(e,t)=>t),a.watch(({node:e,leaf:n})=>{C(t,{parentBlockFragment:n.data.block.child.child,leaf:n,node:e})}),effector.sample(a,r).watch(({leaf:e})=>{e.spawn.active=0,O(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{n.deferredInit&&n.deferredInit();const{env:t,namespace:a}=H;V(y({name:'rec item',isSvgRoot:0,namespace:a,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:a,unmount:r}){const{onMount:o,onState:l}=B({state:e,mount:a,onMount:(e,{leaf:t,node:n})=>({state:e,leaf:t,node:n}),onState:({leaf:e,node:t},n)=>({state:n,leaf:e,node:t}),greedy:1});effector.sample(a,r).watch(({leaf:e})=>{e.spawn.active=0,O(e,e=>{e.api.unmount()})}),l.watch(({state:e,leaf:t})=>{O(t,t=>{t.api.itemUpdater(e)})}),o.watch(({node:e,leaf:t,state:a})=>{R({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:n,values:{store:a}})})}}))}}function N(e,t){'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);const{fn:n,key:a,source:o,fields:l=[]}=e,s=void 0!==a?'function'==typeof a?a:e=>e[a]:(e,t)=>t,d={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},f=H.env,h=H.namespace;V(y({name:'list',draft:d,isSvgRoot:0,namespace:h,fn(e,{mount:t,unmount:a}){const v=y({name:'list item',state:{id:-1,store:null},draft:d,isSvgRoot:0,namespace:h,fn({id:e,store:t},{mount:a,unmount:o}){n({store:t,key:e,fields:A(t,l)});const s=effector.createEvent();t.on(s,(e,t)=>t);const i=effector.createStore({leaf:null});if(effector.sample(i,o).watch(({leaf:e})=>{const t=e.data.block;$(t,t.parent.child);const n=t.left,a=t.right;n&&(n.right=a,a||t.parent.lastChild!==t||(t.parent.lastChild=n)),a&&(a.left=n),n||a||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,O(e,e=>{e.api.unmount()});const{spawn:r}=e;r.active=0,$(r,r.parent.childSpawns[r.template.id]),$(r,r.template.pages)}),d.itemVisible){const{onMount:e,onState:t}=B({mount:a,state:d.itemVisible,onMount:(e,{node:t,leaf:n})=>({visible:e,node:t,leaf:n}),onState:({node:e,leaf:t},n)=>({visible:n,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:n})=>{i.setState({leaf:n});const a=n.data.block;a.visible=e,a.childInitialized=e,e&&C(d,{parentBlockFragment:a.child,leaf:n,node:t})}),t.watch(({visible:e,node:t,leaf:n})=>{const a=n.data.block;a.visible=e,a.childInitialized?O(n,t=>{const n=t.data;switch(n.type){case'element':r(e,n.ops.visible);break;default:console.log('unsupported type',n.type)}}):e&&(a.childInitialized=1,C(d,{parentBlockFragment:a.child,leaf:n,node:t}))})}else a.watch(({node:e,leaf:t})=>{i.setState({leaf:t});const n=t.data.block;n.visible=1,n.childInitialized=1,C(d,{parentBlockFragment:n.child,leaf:t,node:e})});return{itemUpdater:s}},env:f}),m=effector.createStore([]),g=o.map(e=>e),b=effector.sample({source:o,clock:t,fn:(e,{node:t,leaf:n})=>({updates:e,node:t,leaf:n,hydration:n.hydration}),greedy:1}),w=effector.sample({source:b,clock:g,fn:({node:e,leaf:t},n)=>({updates:n,node:e,leaf:t,hydration:0}),greedy:1}),k=effector.merge([b,w]);effector.sample({source:m,clock:k,greedy:1,fn(e,{node:t,updates:n,leaf:a,hydration:r}){const l=a.data.block;L('list update ['+o.shortName+']');const d=Array(n.length).fill(0),f=n.map(s),h=[];for(let t=0;t<e.length;t++){const a=e[t],r=f.indexOf(a.key);-1!==r?(h.push(a),d[r]=1,p(n[r],a.asyncValue)):(a.active=0,a.instance&&a.instance.api.unmount(),u(a.asyncValue))}for(let e=0;e<n.length;e++){if(d[e])continue;const o=n[e],s=f[e],u=i(a.ops.group.queue),p={type:'LF',parent:l,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:s,index:s,active:1,leafData:{type:'list item',block:p},asyncValue:c({value:o,group:u,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(r||(m.instance=x(v,{values:{id:s,store:e},parentLeaf:a,mountNode:t,svgRoot:a.svgRoot,leafData:m.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:r})))}})},g=h.length;h.push(m);const y=g>0?h[g-1].leafData:null;if(p.child.parent=p,l.child.push(p),y){const e=y.block;p.left=e;const t=e.right;t?(t.left=p,p.right=t):l.lastChild=p,e.right=p}else l.lastChild=p;r&&(m.instance=x(v,{values:{id:s,store:o},parentLeaf:a,mountNode:t,svgRoot:a.svgRoot,leafData:m.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:r}))}return j('list update ['+o.shortName+']'),0===h.length&&(l.lastChild=null),h},target:m}),effector.sample({source:t,clock:effector.sample(m,a),fn:({leaf:e},t)=>({leaf:e,records:t})}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){const n=t[e];n.instance&&n.instance.api.unmount(),n.active=0}const{spawn:n}=e;n.active=0,$(n,n.parent.childSpawns[n.template.id]),$(n,n.template.pages)})},env:f}))}function V(e){if(!H)return;const{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(H.draft.type){case'element':case'using':case'route':case'list':case'tree':case'treeItem':case'rec':case'recItem':t.inParentIndex=H.draft.childCount,H.draft.childCount+=1,H.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentActor type ${H.draft.type}`)}}function $(e,t){if(!t)return;const n=t.indexOf(e);-1!==n&&t.splice(n,1)}function B({mount:e,state:t,onMount:n,onState:a,greedy:r=0}){return{onMount:effector.sample({source:t,clock:e,fn:n,greedy:r}),onState:effector.sample({source:e,clock:t,fn:a,greedy:r})}}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let L,j,z;'undefined'!=typeof performance&&performance.mark?(L=e=>{performance.mark('☄️ '+e+' start')},j=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(L=()=>{},j=()=>{}),z='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{const e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();const U='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);let _=0,Q=0,G=null,W=null,H=null;const J=effector.createEvent();J.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),exports.h=(e,t)=>{function n(e){return e.data.block.value}function o(e,t,n){const a=e.data.block.child.child,r={type:'text',parent:{type:'FT',parent:a,child:null,visible:0,index:n},value:null};if(r.parent.child=r,a.child[n]=r.parent,e.hydration){const e=I(r);if(e)switch(e.type){case'text':r.value=u.document.createTextNode(t),e.value.after(r.value);break;case'element':r.value=e.value.nextSibling,g(r.value,t)}else{const e=w(r);r.value=e.firstChild,g(r.value,t)}r.parent.visible=1}else r.value=u.document.createTextNode(t),T(r);return r}let s,i=0,c=0;'function'==typeof t?(i=1,s=t):t&&(c=1,t.fn&&(i=1,s=t.fn),t.ɔ&&('function'==typeof t.ɔ?(i=1,s=t.ɔ):'function'==typeof t.ɔ.fn&&(i=1,s=t.ɔ.fn)));const u=H.env,p=H.namespace;let d=p,b='html';d=b='svg'===p?'svg':'html','svg'===e&&(b='svg',d='svg');const x='svg'===b?u.document.createElementNS('http://www.w3.org/2000/svg',e):u.document.createElement(e);'foreignObject'===p?(x.setAttribute('xmlns','http://www.w3.org/1999/xhtml'),d='html'):'svg'===e?(x.setAttribute('xmlns','http://www.w3.org/2000/svg'),d='svg'):'foreignObject'===e&&(d='foreignObject');const k=x,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:u,unmount:p}){function d(e){return B({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}const y=effector.createEvent(),b=u.map(({leaf:e})=>e);i&&s(),c&&q(t);const x={attr:{},data:{},text:S.text,styleProp:{},styleVar:{},visible:S.visible||null,handler:S.handler};for(let e=0;e<S.attr.length;e++){const t=S.attr[e];for(const e in t)'xlink:href'===e?x.attr.href=t[e]:x.attr[e]=t[e]}for(let e=0;e<S.data.length;e++){const t=S.data[e];for(const e in t)x.data[e]=t[e]}for(let e=0;e<S.styleProp.length;e++){const t=S.styleProp[e];for(const e in t)e.startsWith('--')?x.styleVar[e.slice(2)]=t[e]:x.styleProp[e]=t[e]}for(let e=0;e<S.styleVar.length;e++){const t=S.styleVar[e];for(const e in t)x.styleVar[e]=t[e]}x.visible&&S.seq.push({type:'visible',value:x.visible});for(const e in x.attr){const t=x.attr[e];effector.is.unit(t)?S.seq.push({type:'attr',field:e,value:t}):m(k,e,t)}for(const e in x.data){const t=x.data[e];effector.is.unit(t)?S.seq.push({type:'data',field:e,value:t}):v(k,e,t)}for(const e in x.styleProp){const t=x.styleProp[e];effector.is.unit(t)?S.seq.push({type:'style',field:e,value:t}):h(k,e,t)}for(const e in x.styleVar){const t=x.styleVar[e];effector.is.unit(t)?S.seq.push({type:'styleVar',field:e,value:t}):f(k,e,t)}for(let e=0;e<x.text.length;e++){const t=x.text[e];if(null!==t.value)if(effector.is.unit(t.value)){S.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});const e=t.value.stateRef,n=G;n.plain.includes(e)||n.closure.includes(e)||n.closure.push(e)}else S.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<x.handler.length;e++){const t=x.handler[e];for(const e in t.map)S.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(x.visible){const{onMount:e,onState:t}=B({mount:b,state:x.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0}),greedy:1});e.watch(({leaf:e,value:t,hydration:n})=>{const r=e.data,o=r.block;if(n&&(a(t,r.ops.visible),t)){const e=F(o);let t;if(t=e?e.nextSibling:w(o).firstChild,'#text'===t.nodeName){const e=t;t=t.nextSibling,e.remove()}o.value=t,o.parent.visible=1}C(S,{parentBlockFragment:o.child.child,leaf:e,node:o.value,svgRoot:R.isSvgRoot?o.value:null}),t&&r.needToCallNode&&(r.needToCallNode=0,effector.launch({target:J,params:{element:r.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:n})=>{n||r(t,e.data.ops.visible)})}for(let e=0;e<S.seq.length;e++){const t=S.seq[e];switch(t.type){case'visible':break;case'attr':{const{field:e}=t,a='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:o,onState:s}=d(t.value);if(a)effector.merge([s,o]).watch(({leaf:t,value:a})=>{m(n(t),e,a)});else{const t=S.opsAmount++;o.watch(({value:a,leaf:r})=>{const o=n(r),s=l({value:a,priority:'props',runOp(t){m(o,e,t)},group:r.ops.group});r.ops.group.ops[t]=s,m(o,e,a)}),s.watch(({value:e,leaf:n})=>{r(e,n.ops.group.ops[t])})}break}case'data':{const{field:e}=t,{onMount:a,onState:o}=d(t.value),s=S.opsAmount++;a.watch(({value:t,leaf:a})=>{const r=n(a),o=l({value:t,priority:'props',runOp(t){v(r,e,t)},group:a.ops.group});a.ops.group.ops[s]=o,v(r,e,t)}),o.watch(({value:e,leaf:t})=>{r(e,t.ops.group.ops[s])});break}case'style':{const e=S.opsAmount++,{field:a}=t,{onMount:o,onState:s}=d(t.value);o.watch(({value:t,leaf:r})=>{const o=n(r),s=l({value:t,priority:'props',runOp(e){h(o,a,e)},group:r.ops.group});r.ops.group.ops[e]=s,h(o,a,t)}),s.watch(({value:t,leaf:n})=>{r(t,n.ops.group.ops[e])});break}case'styleVar':{const{field:e}=t,{onMount:a,onState:o}=d(t.value),s=S.opsAmount++;a.watch(({value:t,leaf:a})=>{const r=n(a),o=l({value:t,priority:'props',runOp(t){f(r,e,t)},group:a.ops.group});a.ops.group.ops[s]=o,f(r,e,t)}),o.watch(({value:e,leaf:t})=>{r(e,t.ops.group.ops[s])});break}case'staticText':y.map(e=>e).watch(e=>{o(e,t.value,t.childIndex)});break;case'dynamicText':{const e=S.opsAmount++;effector.sample({source:t.value,clock:y,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:n,leaf:a})=>{const r=l({value:n,priority:'props',runOp(e){g(s.value,e)},group:a.ops.group});a.ops.group.ops[e]=r;const s=o(a,n,t.childIndex)}),effector.sample({source:y,clock:t.value,fn:(e,t)=>({leaf:e,text:t})}).watch(({leaf:t,text:n})=>{r(n,t.ops.group.ops[e])});break}case'handler':{const e=t.handler.graphite.meta.nativeTemplate||null;y.watch(a=>{let r=null;if(e){let t=0,n=a.spawn;for(;!t&&n;)n.template===e?(t=1,r=n):n=n.parent}n(a).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),effector.launch({target:t.handler,params:e,page:r})},t.domConfig)});break}}}effector.sample(b,p).watch(e=>{const{spawn:t}=e;$(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,$(t,t.template.pages);for(const n in t.childSpawns)t.childSpawns[n].forEach(e)}(t),r(0,e.data.ops.visible)}),u.watch(({leaf:e})=>{const t=e.data;if(!S.visible){const n=t.ops.visible,o=t.block;if(e.hydration){a(1,n);const e=F(o);let t;if(t=e?e.nextSibling:w(o).firstChild,'#text'===t.nodeName){const e=t;t=t.nextSibling,e.remove()}o.value=t,o.parent.visible=1}C(S,{parentBlockFragment:o.child.child,leaf:e,node:o.value,svgRoot:R.isSvgRoot?o.value:null}),effector.launch({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:J,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):r(1,n)}})},env:u});V(R)},exports.handler=D,exports.list=N,exports.node=e=>{const t=H.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'tree':case'treeItem':case'rec':case'recItem':return}t.node.push(e)},exports.rec=M,exports.remap=A,exports.route=E,exports.spec=q,exports.text=(e,...t)=>{const n=[e[0]];for(let a=0;a<t.length;a++)n.push(t[a],e[a+1]);q({text:n})},exports.tree=({source:e,child:t,fn:n})=>{const a=M(({state:e})=>{N({source:e,fn({store:e}){const r=e.map(e=>e[t]||[]);n({store:e,child(){a({state:r})}})}})});a({state:e})},exports.using=(e,t)=>{let n,a,r,o,l;'function'==typeof t?(n=t,r=P(),o=0):(n=t.fn,r=t.env?t.env:P(),o=t.hydrate,a=t.onComplete,l=t.onRoot);const c=e.namespaceURI,u=e.tagName.toLowerCase(),p={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:p,isSvgRoot:'svg'===u,namespace:'http://www.w3.org/2000/svg'===c?'svg':'foreignobject'===u?'foreignObject':'html',fn(e,{mount:t}){n(),t.watch(({node:e,leaf:t})=>{C(p,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:r}),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;const h=s({onComplete:a}),v=x(d,{parentLeaf:W||null,mountNode:e,svgRoot:d.isSvgRoot?e:W?W.svgRoot:null,leafData:{type:'using',draft:p,element:e,block:f},opGroup:i(h),domSubtree:i(h),hydration:o});l&&l({template:d,leaf:v})},exports.variant=({source:e,cases:t,key:n})=>{const a='function'==typeof n?n:e=>String(e[n]);let r=0;for(const n in t)'__'!==n?E({source:e,visible:e=>a(e)===n,fn:t[n]}):r=1;if(r){const n=Object.keys(t);E({source:e,visible:e=>!n.includes(a(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=_(l.group.queue.execQueue))}function r(a){j('execQueue');let n,l,r=U(),i=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(U()-r>=10){i=1;break e}let o=!!a.props.first;for(o&&j('props');n=a.props.first;){for(;l=n.activeChilds.props.first;){if(U()-r>=10){i=1,z('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'props')}o&&z('props');let s=!!a.tree.first;for(s&&j('tree');n=a.tree.first;){for(;l=n.activeChilds.tree.first;){if(U()-r>=10){i=1,z('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'tree')}s&&z('tree');let u=!!a.data.first;for(u&&j('data');n=a.data.first;){for(;l=n.activeChilds.data.first;){if(U()-r>=10){i=1,z('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'data')}u&&z('data')}if(z('execQueue'),i)a.rafID=_(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 p(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 c(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=H,u=$,p={id:++Q,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===p)return 1;if(a.page.childSpawns[p.id])a.page.childSpawns[p.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 p.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&effector.launch({params:e,target:a.node,page:t,defer:1})})}else p.pages.forEach(t=>{effector.launch({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(p);let c=effector.createNode({meta:{template:p}});$=p;let d=H={template:p,node:c,api:null,trigger:{mount:effector.createEvent(),unmount:effector.createEvent()},draft:l,isSvgRoot:r,namespace:i,env:o};return a?d.deferredInit=()=>{let a=H,n=$;H=d,$=p,d.deferredInit=null;try{effector.withRegion(c,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a})}finally{H=a,$=n}}:effector.withRegion(c,()=>{let a=effector.restore(t);d.api=e(a,d.trigger),p.nameMap=a}),H=s,$=u,p.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 p(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 c=a?a.spawn:null,d=e.template,f={},h={id:++G,fullID:'',reg:f,template:d,parent:c,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=W;W=m,c&&(c.childSpawns[d.id]||(c.childSpawns[d.id]=[]),c.childSpawns[d.id].push(h)),h.fullID=c?`${c.fullID}_${h.id}`:""+h.id,c&&Object.assign(f,c.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;)p(d.watch,y,f);if(c)for(let e in h.childSpawns)e in c.childSpawns||(c.childSpawns[e]=[]),c.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}),W=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:p}=t.ops.group,c=s(p),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:J,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(p);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:c,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=H.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?D(t.config||{},t.on):D(t)}e.ɔ&&P(e.ɔ)}function D(e,t){let a=H.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 E({source:e,visible:t,fn:a}){let n=y({name:'route',isSvgRoot:0,namespace:H.namespace,env:H.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:r,unmount:i}){let o=e.map(e=>({value:e,visible:t(e)})),s={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},u=y({name:'route item',isSvgRoot:0,namespace:H.namespace,env:H.env,draft:s,state:{store:null},fn({store:e},{mount:t,unmount:n}){let r=effector.createEvent();e.on(r,(e,t)=>t),a({store:e});let i=effector.sample({source:t,clock:o,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(s,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),i.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&effector.launch({target:r,params:a,defer:1,page:e.spawn}),O(e,e=>{let a=e.data;switch(a.type){case'element':l(t,a.ops.visible);break;default:console.log('unsupported type',a.type)}})}),effector.sample({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{O(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,B(t,t.parent.childSpawns[t.template.id]),B(t,t.template.pages)})}});V(u);let{onMount:p,onState:c}=L({mount:r,state:o,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([p,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:u,values:{store:a}}),l.initialized=1)}),effector.sample({source:r,clock:i,greedy:1}).watch(({leaf:e})=>{O(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,B(t,t.parent.childSpawns[t.template.id]),B(t,t.template.pages)})}});V(n)}function O(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 M(e){let t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},a=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:H.namespace,env:H.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,O(e,e=>{e.api.unmount()})}),{itemUpdater:r}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=H;V(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}=L({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,O(e,e=>{e.api.unmount()})}),i.watch(({state:e,leaf:t})=>{O(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 N(e,t){'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:r,fields:i=[]}=e,o=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,d={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},f=H.env,h=H.namespace;V(y({name:'list',draft:d,isSvgRoot:0,namespace:h,fn(e,{mount:t,unmount:n}){let v=y({name:'list item',state:{id:-1,store:null},draft:d,isSvgRoot:0,namespace:h,fn({id:e,store:t},{mount:n,unmount:r}){a({store:t,key:e,fields:A(t,i)});let o=effector.createEvent();t.on(o,(e,t)=>t);let s=effector.createStore({leaf:null});if(effector.sample({source:s,clock:r,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;B(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,O(e,e=>{e.api.unmount()});let{spawn:l}=e;l.active=0,B(l,l.parent.childSpawns[l.template.id]),B(l,l.template.pages)}),d.itemVisible){let{onMount:e,onState:t}=L({mount:n,state:d.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(d,{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(a,t=>{let a=t.data;switch(a.type){case'element':l(e,a.ops.visible);break;default:console.log('unsupported type',a.type)}}):e&&(n.childInitialized=1,F(d,{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(d,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:o}},env:f}),m=effector.createStore([]),g=r.map(e=>e),b=effector.sample({source:r,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),x=effector.sample({source:b,clock:g,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1}),k=effector.merge([b,x]);effector.sample({source:m,clock:k,greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:l}){let i=n.data.block;j('list update ['+r.shortName+']');let d=Array(a.length).fill(0),f=a.map(o),h=[];for(let t=0;t<e.length;t++){let n=e[t],l=f.indexOf(n.key);-1!==l?(h.push(n),d[l]=1,c(a[l],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),p(n.asyncValue))}for(let e=0;e<a.length;e++){if(d[e])continue;let r=a[e],o=f[e],p=s(n.ops.group.queue),c={type:'LF',parent:i,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:c},asyncValue:u({value:r,group:p,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(l||(m.instance=w(v,{values:{id:o,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:p,domSubtree:n.ops.domSubtree,hydration:l})))}})},g=h.length;h.push(m);let y=g>0?h[g-1].leafData:null;if(c.child.parent=c,i.child.push(c),y){let e=y.block;c.left=e;let t=e.right;t?(t.left=c,c.right=t):i.lastChild=c,e.right=c}else i.lastChild=c;l&&(m.instance=w(v,{values:{id:o,store:r},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:p,domSubtree:n.ops.domSubtree,hydration:l}))}return z('list update ['+r.shortName+']'),0===h.length&&(i.lastChild=null),h},target:m}),effector.sample({source:t,clock:effector.sample({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,B(a,a.parent.childSpawns[a.template.id]),B(a,a.template.pages)})},env:f}))}function V(e){if(!H)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(H.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':t.inParentIndex=H.draft.childCount,H.draft.childCount+=1,H.draft.childTemplates.push(e);break;default:console.warn("unexpected currentActor type "+H.draft.type)}}function B(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function L({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 j,z,U;'undefined'!=typeof performance&&performance.mark?(j=e=>{performance.mark('☄️ '+e+' start')},z=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(j=()=>{},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 _='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),Q=0,G=0,$=null,W=null,H=null,J=effector.createEvent();J.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=p.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=p.document.createTextNode(t),T(l);return l}let o,s=0,u=0;'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)));let p=H.env,c=H.namespace,d=c,b='html';d=b='svg'===c?'svg':'html','svg'===e&&(b='svg',d='svg');let w='svg'===b?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e);'foreignObject'===c?(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:p,unmount:c}){function d(e){return L({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let y=effector.createEvent(),b=p.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=$;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}=L({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:J,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:c,greedy:1}).watch(e=>{let{spawn:t}=e;B(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,B(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,e.data.ops.visible)}),p.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:J,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):l(1,a)}})},env:p});V(R)},exports.handler=D,exports.list=N,exports.node=e=>{let t=H.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'rec':case'recItem':return}t.node.push(e)},exports.rec=M,exports.remap=A,exports.route=E,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=M(({state:e})=>{N({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;'function'==typeof t?(a=t,l=q(),r=0):(a=t.fn,l=t.env?t.env:q(),r=t.hydrate,n=t.onComplete,i=t.onRoot);let u=e.namespaceURI,p=e.tagName.toLowerCase(),c={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:c,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{F(c,{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:W||null,mountNode:e,svgRoot:d.isSvgRoot?e:W?W.svgRoot:null,leafData:{type:'using',draft:c,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?E({source:e,visible:e=>n(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);E({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}};
//# sourceMappingURL=forest.cjs.js.map

@@ -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,a;e.status='active',t=n(e),(a=e).cursor.prev&&(a.cursor.prev.cursor.next=a.cursor.next),a.cursor.next&&(a.cursor.next.cursor.prev=a.cursor.prev),t.last===a&&(t.last=a.cursor.prev),t.first===a&&(t.first=a.cursor.next),a.cursor.prev=null,a.cursor.next=null}function n(e){return e.group.activeChilds[e.priority]}function a(e,n){n.value.active=n.value.pending=e,'active'!==n.status&&t(n)}function r(a,r){if(r.value.active===a)return r.value.pending=a,void('pending'===r.status&&(t(r),n(r).first||e(r.group,r.priority)));var o,l,s,i;'active'===r.status&&(r.status='pending',n(r).first||((s=r.group).queue[i=r.priority].last?(s.cursor[i].prev=s.queue[i].last,s.queue[i].last.cursor[i].next=s,s.queue[i].last=s):s.queue[i].first=s.queue[i].last=s),l=r,(o=n(r)).last?(l.cursor.prev=o.last,o.last.cursor.next=l,o.last=l):o.first=o.last=l),r.value.pending=a,r.group.queue.rafID||(r.group.queue.rafID=oe(r.group.queue.execQueue))}function o(n){ne('execQueue');const a=re();let r,o,l=0;e:for(;n.props.first||n.tree.first||n.data.first;){if(re()-a>=10){l=1;break e}const s=!!n.props.first;for(s&&ne('props');r=n.props.first;){for(;o=r.activeChilds.props.first;){if(re()-a>=10){l=1,ae('props');break e}o.runOp(o.value.pending),o.value.active=o.value.pending,t(o)}e(r,'props')}s&&ae('props');const i=!!n.tree.first;for(i&&ne('tree');r=n.tree.first;){for(;o=r.activeChilds.tree.first;){if(re()-a>=10){l=1,ae('tree');break e}o.runOp(o.value.pending),o.value.active=o.value.pending,t(o)}e(r,'tree')}i&&ae('tree');const c=!!n.data.first;for(c&&ne('data');r=n.data.first;){for(;o=r.activeChilds.data.first;){if(re()-a>=10){l=1,ae('data');break e}o.runOp(o.value.pending),o.value.active=o.value.pending,t(o)}e(r,'data')}c&&ae('data')}if(ae('execQueue'),l)n.rafID=oe(n.execQueue);else if(n.rafID=null,n.onDrain){const e=n.onDrain;n.onDrain=null,e()}}function l({value:e,runOp:t,group:n,priority:a}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:a,group:n,cursor:{prev:null,next:null}}}function s({onComplete:e}){const t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=o.bind(null,t),t}function i(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 c({value:e,group:t,onInit:n,onChange:a,onTerminate:o}){const s=l({value:e,group:t,runOp(e){i.status='A',a(e)},priority:'data'}),i={status:'IA',value:s.value,hooks:{onTerminate:o},ops:{init:l({value:0,group:t,runOp(e){i.status='A',n(i.value.active)},priority:'data'}),change:s,terminate:l({value:0,group:t,runOp(e){i.status='T',i.hooks.onTerminate(1)},priority:'data'})}};return r(1,i.ops.init),i}function u(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',r(1,e.ops.terminate);break;case'AA':e.status='AT',r(1,e.ops.terminate),r(e.value.active,e.ops.change);break;case'IA':e.status='T',r(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',r(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',r(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,n){d(n)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${n}`)}function h(e,t,n){d(n)?delete e.style[t]:e.style[t]=`${n}`}function v(e,t,n){d(n)?delete e.dataset[t]:e.dataset[t]=`${n}`}function m(e,t,n){if(d(n)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==n)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=`${n}`;break;case'checked':e.checked=`${n}`}e.setAttribute(t,`${n}`)}}function g(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function y({fn:e,state:t={},defer:n=0,name:a="",draft:r,isSvgRoot:o,namespace:l,env:s}){const i=ue,c=ie,u={id:++le,name:a,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:_.filter({fn(e,t,n){if(!n.page)return console.error('context lost',n),0;if(!n.page.active)return 0;const a=[n.page.template],r=[n.page];{let e=n.page.parent;for(;e;)r.push(e),a.push(e.template),e=e.parent}return n.node.next.forEach(t=>{const o=t.meta.nativeTemplate;o?a.includes(o)?W({target:t,params:e,defer:1,page:r[a.indexOf(o)],stack:n}):console.error('context drift',{stack:n,node:t}):W({target:t,params:e,defer:1,page:null,stack:n})}),0}}),loader:_.filter({fn(e,t,n){if(n.parent){if(n.page){if(!n.page.active)return 0;if(n.page.template===u)return 1;if(n.page.childSpawns[u.id])n.page.childSpawns[u.id].forEach(t=>{W({params:e,target:n.node,page:t,defer:1})});else if(t.targetTemplate){const a=[n.page];{let e=n.page.parent;for(;e;)a.push(e),e=e.parent}const r=a.findIndex(e=>t.targetTemplate===e.template);W(-1===r?{params:e,target:n.node,page:null,defer:1}:{params:e,target:n.node,page:a[r],defer:1})}else u.pages.forEach(t=>{t.fullID.startsWith(n.page.fullID)&&W({params:e,target:n.node,page:t,defer:1})})}else u.pages.forEach(t=>{W({params:e,target:n.node,page:t,defer:1})});return 0}return 1}}),parent:c};c&&c.childTemplates.push(u);const p=H({meta:{template:u}});ie=u;const d=ue={template:u,node:p,api:null,trigger:{mount:J(),unmount:J()},draft:r,isSvgRoot:o,namespace:l,env:s};return n?d.deferredInit=()=>{const n=ue,a=ie;ue=d,ie=u,d.deferredInit=null;try{K(p,()=>{const n=X(t);d.api=e(n,d.trigger),u.nameMap=n})}finally{ue=n,ie=a}}:K(p,()=>{const n=X(t);d.api=e(n,d.trigger),u.nameMap=n}),ue=i,ie=c,u.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:n,mountNode:a,svgRoot:r,leafData:o,opGroup:l,domSubtree:s,hydration:i}){function c(e){if(e.before)for(const t of e.before)switch(t.type){case'map':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current=t.fn(f[n.id].current);break}case'field':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current[t.field]=f[n.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;const t=f[e.id].current;for(const n of e.after){const e=n.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),n.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=n.fn(t)}}}function u(e,t,n){let a;t.stop=1;try{for(;t.i<e.length;)a=e[t.i],t.i++,a.fn(n[a.of.id].current)}catch(e){console.error(e),t.stop=0}}const p=n?n.spawn:null,d=e.template,f={},h={id:++se,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);const v={},m={spawn:h,api:v,draft:e.draft,ops:{group:l,domSubtree:s},svgRoot:r,data:o,parentLeaf:n,hydration:i},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(const e of d.closure){let t=e,n=h.parent;e:for(;n;){if(e.id in n.reg){t=n.reg[e.id];break e}n=n.parent}f[e.id]=t}for(const e of d.plain){const t={id:e.id,current:b(e)};f[e.id]=t}for(const e in t){const n=d.nameMap[e].stateRef.id;f[n]={id:n,current:t[e]}}for(const e of d.closure)c(e);for(const e of d.plain)c(e);const y={i:0,stop:0};for(;!y.stop;)u(d.watch,y,f);if(p)for(const e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,n=1)=>W({target:e.trigger.mount,params:t,defer:n,page:h}),v.unmount=(t,n=1)=>W({target:e.trigger.unmount,params:t,defer:n,page:h}),e.api)for(const t in e.api)v[t]=(n,a=1)=>W({target:e.api[t],params:n,defer:a,page:h});return m.spawn.api=v,m.spawn.leaf=m,m.api.mount({node:a,leaf:m}),ce=g,m}function k(e){const t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent;case'tree':return e(t.parent.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 I(e.child);case'FTree':return I(e.child.child);case'FRec':case'FRecItem':return I(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){const e=x(t);if(e)return e;t=t.left}return null}default:return null}}function I(e){const t=e.child;for(let e=t.length-1;e>=0;e--){const n=x(t[e]);if(n)return n}return null}function S(e){if('fragment'===e.type)switch(e.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{const t=e.parent.parent.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=x(n.child[e]);if(t)return t}return S(n)}case'FF':{const t=e.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=x(n.child[e]);if(t)return t}return S(n)}case'LF':{let t=e.parent.left;for(;t;){const e=x(t);if(e)return e;t=t.left}return S(e.parent.parent)}case'tree':{const t=e.parent.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=x(n.child[e]);if(t)return t}return S(n)}default:return null}if('route'===e.type){const t=e.parent.parent;for(let n=e.parent.index-1;n>=0;n--){const e=t.child[n];if(!e)continue;const a=x(e);if(a)return a}return S(t)}const t=e.parent.parent;for(let n=e.parent.index-1;n>=0;n--){const e=t.child[n];if(!e)continue;const a=x(e);if(a)return a}return S(t)}function F(e){const t=S(e);return t?t.value:null}function C(e,{parentBlockFragment:t,leaf:n,node:a,svgRoot:r,values:o}){e.childTemplates.forEach(e=>{R({parentBlockFragment:t,leaf:n,node:a,svgRoot:r,values:o,actor:e})})}function R({parentBlockFragment:e,leaf:t,node:n,actor:a,svgRoot:r,values:o}){let s;const{draft:c}=a,{queue:u}=t.ops.group,p=i(u),d=t.ops.domSubtree;let f=d;switch(c.type){case'route':{const t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:c.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[c.inParentIndex]=t.parent,s={type:'route',block:t,ops:{},initialized:0};break}case'element':{const t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:c.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:c.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[c.inParentIndex]=t.parent,s={type:'element',block:t,ops:{visible:l({value:0,priority:'tree',runOp(e){e?(T(t),s.needToCallNode&&(s.needToCallNode=0,W({target:pe,params:{element:t.value,fns:c.node},page:h.spawn}))):(t.value.remove(),t.parent.visible=0)},group:d})},needToCallNode:c.node.length>0},f=i(u);break}case'list':{const t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:c.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[c.inParentIndex]=t.parent,s={type:'list',draft:c,block:t};break}case'tree':{const t={type:'tree',parent:{type:'FTree',parent:e,child:null,visible:1,index:c.inParentIndex},child:{type:'fragment',parent:null,child:[]}};t.parent.child=t,t.child.parent=t,e.child[c.inParentIndex]=t.parent,s={type:'tree',block:t};break}case'using':case'listItem':break;case'rec':{const t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:c.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[c.inParentIndex]=t.parent,s={type:'rec',block:t};break}case'recItem':{const t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:c.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[c.inParentIndex]=t.parent,s={type:'rec item',block:t};break}default:console.warn(`unexpected draft type ${c.type}`)}const h=w(a,{values:o,parentLeaf:t,mountNode:n,svgRoot:r||t.svgRoot,leafData:s,opGroup:p,domSubtree:f,hydration:t.hydration})}function T(e){const t=F(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){const n={};for(const a in t){const r=t[a];n[a]=e.map('function'==typeof r?e=>r(e):e=>e[r])}return n}return e.map(e=>e[t])}function P(e,t){function n(e){return e.data.block.value}function o(e,t,n){const a=e.data.block.child.child,r={type:'text',parent:{type:'FT',parent:a,child:null,visible:0,index:n},value:null};if(r.parent.child=r,a.child[n]=r.parent,e.hydration){const e=S(r);if(e)switch(e.type){case'text':r.value=u.document.createTextNode(t),e.value.after(r.value);break;case'element':r.value=e.value.nextSibling,g(r.value,t)}else{const e=k(r);r.value=e.firstChild,g(r.value,t)}r.parent.visible=1}else r.value=u.document.createTextNode(t),T(r);return r}let s,i=0,c=0;'function'==typeof t?(i=1,s=t):t&&(c=1,t.fn&&(i=1,s=t.fn),t.ɔ&&('function'==typeof t.ɔ?(i=1,s=t.ɔ):'function'==typeof t.ɔ.fn&&(i=1,s=t.ɔ.fn)));const u=ue.env,p=ue.namespace;let d=p,b='html';d=b='svg'===p?'svg':'html','svg'===e&&(b='svg',d='svg');const w='svg'===b?u.document.createElementNS('http://www.w3.org/2000/svg',e):u.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');const x=w,I={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:I,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:u,unmount:p}){function d(e){return Q({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}const y=J(),b=u.map(({leaf:e})=>e);i&&s(),c&&M(t);const w={attr:{},data:{},text:I.text,styleProp:{},styleVar:{},visible:I.visible||null,handler:I.handler};for(let e=0;e<I.attr.length;e++){const t=I.attr[e];for(const e in t)'xlink:href'===e?w.attr.href=t[e]:w.attr[e]=t[e]}for(let e=0;e<I.data.length;e++){const t=I.data[e];for(const e in t)w.data[e]=t[e]}for(let e=0;e<I.styleProp.length;e++){const t=I.styleProp[e];for(const e in t)e.startsWith('--')?w.styleVar[e.slice(2)]=t[e]:w.styleProp[e]=t[e]}for(let e=0;e<I.styleVar.length;e++){const t=I.styleVar[e];for(const e in t)w.styleVar[e]=t[e]}w.visible&&I.seq.push({type:'visible',value:w.visible});for(const e in w.attr){const t=w.attr[e];ee.unit(t)?I.seq.push({type:'attr',field:e,value:t}):m(x,e,t)}for(const e in w.data){const t=w.data[e];ee.unit(t)?I.seq.push({type:'data',field:e,value:t}):v(x,e,t)}for(const e in w.styleProp){const t=w.styleProp[e];ee.unit(t)?I.seq.push({type:'style',field:e,value:t}):h(x,e,t)}for(const e in w.styleVar){const t=w.styleVar[e];ee.unit(t)?I.seq.push({type:'styleVar',field:e,value:t}):f(x,e,t)}for(let e=0;e<w.text.length;e++){const t=w.text[e];if(null!==t.value)if(ee.unit(t.value)){I.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});const e=t.value.stateRef,n=ie;n.plain.includes(e)||n.closure.includes(e)||n.closure.push(e)}else I.seq.push({type:'staticText',value:String(t.value),childIndex:t.index})}for(let e=0;e<w.handler.length;e++){const t=w.handler[e];for(const e in t.map)I.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){const{onMount:e,onState:t}=Q({mount:b,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0}),greedy:1});e.watch(({leaf:e,value:t,hydration:n})=>{const r=e.data,o=r.block;if(n&&(a(t,r.ops.visible),t)){const e=F(o);let t;if(t=e?e.nextSibling:k(o).firstChild,'#text'===t.nodeName){const e=t;t=t.nextSibling,e.remove()}o.value=t,o.parent.visible=1}C(I,{parentBlockFragment:o.child.child,leaf:e,node:o.value,svgRoot:R.isSvgRoot?o.value:null}),t&&r.needToCallNode&&(r.needToCallNode=0,W({target:pe,params:{element:r.block.value,fns:I.node},page:e.spawn,defer:1})),W({target:y,params:e,defer:1,page:e.spawn})}),Z([t,e]).watch(({leaf:e,value:t,hydration:n})=>{n||r(t,e.data.ops.visible)})}for(let e=0;e<I.seq.length;e++){const t=I.seq[e];switch(t.type){case'visible':break;case'attr':{const{field:e}=t,a='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:o,onState:s}=d(t.value);if(a)Z([s,o]).watch(({leaf:t,value:a})=>{m(n(t),e,a)});else{const t=I.opsAmount++;o.watch(({value:a,leaf:r})=>{const o=n(r),s=l({value:a,priority:'props',runOp(t){m(o,e,t)},group:r.ops.group});r.ops.group.ops[t]=s,m(o,e,a)}),s.watch(({value:e,leaf:n})=>{r(e,n.ops.group.ops[t])})}break}case'data':{const{field:e}=t,{onMount:a,onState:o}=d(t.value),s=I.opsAmount++;a.watch(({value:t,leaf:a})=>{const r=n(a),o=l({value:t,priority:'props',runOp(t){v(r,e,t)},group:a.ops.group});a.ops.group.ops[s]=o,v(r,e,t)}),o.watch(({value:e,leaf:t})=>{r(e,t.ops.group.ops[s])});break}case'style':{const e=I.opsAmount++,{field:a}=t,{onMount:o,onState:s}=d(t.value);o.watch(({value:t,leaf:r})=>{const o=n(r),s=l({value:t,priority:'props',runOp(e){h(o,a,e)},group:r.ops.group});r.ops.group.ops[e]=s,h(o,a,t)}),s.watch(({value:t,leaf:n})=>{r(t,n.ops.group.ops[e])});break}case'styleVar':{const{field:e}=t,{onMount:a,onState:o}=d(t.value),s=I.opsAmount++;a.watch(({value:t,leaf:a})=>{const r=n(a),o=l({value:t,priority:'props',runOp(t){f(r,e,t)},group:a.ops.group});a.ops.group.ops[s]=o,f(r,e,t)}),o.watch(({value:e,leaf:t})=>{r(e,t.ops.group.ops[s])});break}case'staticText':y.map(e=>e).watch(e=>{o(e,t.value,t.childIndex)});break;case'dynamicText':{const e=I.opsAmount++;Y({source:t.value,clock:y,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:n,leaf:a})=>{const r=l({value:n,priority:'props',runOp(e){g(s.value,e)},group:a.ops.group});a.ops.group.ops[e]=r;const s=o(a,n,t.childIndex)}),Y({source:y,clock:t.value,fn:(e,t)=>({leaf:e,text:t})}).watch(({leaf:t,text:n})=>{r(n,t.ops.group.ops[e])});break}case'handler':{const e=t.handler.graphite.meta.nativeTemplate||null;y.watch(a=>{let r=null;if(e){let t=0,n=a.spawn;for(;!t&&n;)n.template===e?(t=1,r=n):n=n.parent}n(a).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),W({target:t.handler,params:e,page:r})},t.domConfig)});break}}}Y(b,p).watch(e=>{const{spawn:t}=e;U(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,U(t,t.template.pages);for(const n in t.childSpawns)t.childSpawns[n].forEach(e)}(t),r(0,e.data.ops.visible)}),u.watch(({leaf:e})=>{const t=e.data;if(!I.visible){const n=t.ops.visible,o=t.block;if(e.hydration){a(1,n);const e=F(o);let t;if(t=e?e.nextSibling:k(o).firstChild,'#text'===t.nodeName){const e=t;t=t.nextSibling,e.remove()}o.value=t,o.parent.visible=1}C(I,{parentBlockFragment:o.child.child,leaf:e,node:o.value,svgRoot:R.isSvgRoot?o.value:null}),W({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,W({target:pe,params:{element:t.block.value,fns:I.node},page:e.spawn,defer:1})):r(1,n)}})},env:u});z(R)}function q(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function D(e,t){let n,a,r,o,l;'function'==typeof t?(n=t,r=q(),o=0):(n=t.fn,r=t.env?t.env:q(),o=t.hydrate,a=t.onComplete,l=t.onRoot);const c=e.namespaceURI,u=e.tagName.toLowerCase(),p={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:p,isSvgRoot:'svg'===u,namespace:'http://www.w3.org/2000/svg'===c?'svg':'foreignobject'===u?'foreignObject':'html',fn(e,{mount:t}){n(),t.watch(({node:e,leaf:t})=>{C(p,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:r}),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;const h=s({onComplete:a}),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:i(h),domSubtree:i(h),hydration:o});l&&l({template:d,leaf:v})}function O(e){const t=ue.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'tree':case'treeItem':case'rec':case'recItem':return}t.node.push(e)}function M(e){const t=ue.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'tree':case'treeItem':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){const n=e.text,a=t.childCount;Array.isArray(n)?(t.text.push(...n.map((e,t)=>({index:t+a,value:e}))),t.childCount+=n.length):(t.text.push({index:a,value:n}),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){const t=e.handler;'object'==typeof t.on?N(t.config||{},t.on):N(t)}e.ɔ&&M(e.ɔ)}function N(e,t){const n=ue.draft;if('element'!==n.type)throw Error(`"handler" extension can be used only with element nodes, got "${n.type}"`);void 0===t&&(t=e,e={});const{passive:a=1,capture:r=0,prevent:o=0,stop:l=0}=e;n.handler.push({options:{prevent:o,stop:l},domConfig:{passive:o?0:a,capture:r},map:t})}function V({source:e,cases:t,key:n}){const a='function'==typeof n?n:e=>String(e[n]);let r=0;for(const n in t)'__'!==n?E({source:e,visible:e=>a(e)===n,fn:t[n]}):r=1;if(r){const n=Object.keys(t);E({source:e,visible:e=>!n.includes(a(e)),fn:t.__})}}function E({source:e,visible:t,fn:n}){const a=y({name:'route',isSvgRoot:0,namespace:ue.namespace,env:ue.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(a,{mount:o,unmount:l}){const s=e.map(e=>({value:e,visible:t(e)})),i={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},c=y({name:'route item',isSvgRoot:0,namespace:ue.namespace,env:ue.env,draft:i,state:{store:null},fn({store:e},{mount:t,unmount:a}){const o=J();e.on(o,(e,t)=>t),n({store:e});const l=Y({source:t,clock:s,fn:({leaf:e,node:t},{visible:n,value:a})=>({leaf:e,visible:n,node:t,value:a}),greedy:1});t.watch(({leaf:e,node:t})=>{const n=e.data;n.block.child.visible=1,C(i,{parentBlockFragment:n.block.child.child,leaf:e,node:t})}),l.watch(({leaf:e,visible:t,value:n})=>{e.data.block.child.visible=t,t&&W({target:o,params:n,defer:1,page:e.spawn}),$(e,e=>{const n=e.data;switch(n.type){case'element':r(t,n.ops.visible);break;default:console.log('unsupported type',n.type)}})}),Y(t,a).watch(({leaf:e})=>{$(e,e=>{e.api.unmount()});const{spawn:t}=e;t.active=0,U(t,t.parent.childSpawns[t.template.id]),U(t,t.template.pages)})}});z(c);const{onMount:u,onState:p}=Q({mount:o,state:s,onMount:({visible:e,value:t},{leaf:n,node:a})=>({leaf:n,visible:e,node:a,value:t}),onState:({leaf:e,node:t},{visible:n,value:a})=>({leaf:e,visible:n,node:t,value:a}),greedy:1});Z([u,p]).watch(({leaf:e,visible:t,value:n,node:a})=>{const r=e.data;r.block.child.visible=t,t&&!r.initialized&&(R({parentBlockFragment:r.block.child.child,leaf:e,node:a,actor:c,values:{store:n}}),r.initialized=1)}),Y(o,l).watch(({leaf:e})=>{$(e,e=>{e.api.unmount()});const{spawn:t}=e;t.active=0,U(t,t.parent.childSpawns[t.template.id]),U(t,t.template.pages)})}});z(a)}function $(e,t){const{spawn:n}=e;for(const e in n.childSpawns){const a=n.childSpawns[e];for(let e=0;e<a.length;e++)t(a[e].leaf)}}function B(e){const t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},n=y({name:'rec',state:{store:null},isSvgRoot:0,namespace:ue.namespace,env:ue.env,draft:t,defer:1,fn({store:n},{mount:a,unmount:r}){e({state:n});const o=J();return n.on(o,(e,t)=>t),a.watch(({node:e,leaf:n})=>{C(t,{parentBlockFragment:n.data.block.child.child,leaf:n,node:e})}),Y(a,r).watch(({leaf:e})=>{e.spawn.active=0,$(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{n.deferredInit&&n.deferredInit();const{env:t,namespace:a}=ue;z(y({name:'rec item',isSvgRoot:0,namespace:a,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:a,unmount:r}){const{onMount:o,onState:l}=Q({state:e,mount:a,onMount:(e,{leaf:t,node:n})=>({state:e,leaf:t,node:n}),onState:({leaf:e,node:t},n)=>({state:n,leaf:e,node:t}),greedy:1});Y(a,r).watch(({leaf:e})=>{e.spawn.active=0,$(e,e=>{e.api.unmount()})}),l.watch(({state:e,leaf:t})=>{$(t,t=>{t.api.itemUpdater(e)})}),o.watch(({node:e,leaf:t,state:a})=>{R({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:n,values:{store:a}})})}}))}}function L({source:e,child:t,fn:n}){const a=B(({state:e})=>{j({source:e,fn({store:e}){const r=e.map(e=>e[t]||[]);n({store:e,child(){a({state:r})}})}})});a({state:e})}function j(e,t){'function'==typeof t&&(ee.unit(e)?e={source:e,fn:t}:e.fn=t);const{fn:n,key:a,source:o,fields:l=[]}=e,s=void 0!==a?'function'==typeof a?a:e=>e[a]:(e,t)=>t,d={type:'list',key:ee.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},f=ue.env,h=ue.namespace;z(y({name:'list',draft:d,isSvgRoot:0,namespace:h,fn(e,{mount:t,unmount:a}){const v=y({name:'list item',state:{id:-1,store:null},draft:d,isSvgRoot:0,namespace:h,fn({id:e,store:t},{mount:a,unmount:o}){n({store:t,key:e,fields:A(t,l)});const s=J();t.on(s,(e,t)=>t);const i=te({leaf:null});if(Y(i,o).watch(({leaf:e})=>{const t=e.data.block;U(t,t.parent.child);const n=t.left,a=t.right;n&&(n.right=a,a||t.parent.lastChild!==t||(t.parent.lastChild=n)),a&&(a.left=n),n||a||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,$(e,e=>{e.api.unmount()});const{spawn:r}=e;r.active=0,U(r,r.parent.childSpawns[r.template.id]),U(r,r.template.pages)}),d.itemVisible){const{onMount:e,onState:t}=Q({mount:a,state:d.itemVisible,onMount:(e,{node:t,leaf:n})=>({visible:e,node:t,leaf:n}),onState:({node:e,leaf:t},n)=>({visible:n,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:n})=>{i.setState({leaf:n});const a=n.data.block;a.visible=e,a.childInitialized=e,e&&C(d,{parentBlockFragment:a.child,leaf:n,node:t})}),t.watch(({visible:e,node:t,leaf:n})=>{const a=n.data.block;a.visible=e,a.childInitialized?$(n,t=>{const n=t.data;switch(n.type){case'element':r(e,n.ops.visible);break;default:console.log('unsupported type',n.type)}}):e&&(a.childInitialized=1,C(d,{parentBlockFragment:a.child,leaf:n,node:t}))})}else a.watch(({node:e,leaf:t})=>{i.setState({leaf:t});const n=t.data.block;n.visible=1,n.childInitialized=1,C(d,{parentBlockFragment:n.child,leaf:t,node:e})});return{itemUpdater:s}},env:f}),m=te([]),g=o.map(e=>e),b=Y({source:o,clock:t,fn:(e,{node:t,leaf:n})=>({updates:e,node:t,leaf:n,hydration:n.hydration}),greedy:1}),k=Y({source:b,clock:g,fn:({node:e,leaf:t},n)=>({updates:n,node:e,leaf:t,hydration:0}),greedy:1}),x=Z([b,k]);Y({source:m,clock:x,greedy:1,fn(e,{node:t,updates:n,leaf:a,hydration:r}){const l=a.data.block;ne('list update ['+o.shortName+']');const d=Array(n.length).fill(0),f=n.map(s),h=[];for(let t=0;t<e.length;t++){const a=e[t],r=f.indexOf(a.key);-1!==r?(h.push(a),d[r]=1,p(n[r],a.asyncValue)):(a.active=0,a.instance&&a.instance.api.unmount(),u(a.asyncValue))}for(let e=0;e<n.length;e++){if(d[e])continue;const o=n[e],s=f[e],u=i(a.ops.group.queue),p={type:'LF',parent:l,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:s,index:s,active:1,leafData:{type:'list item',block:p},asyncValue:c({value:o,group:u,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(r||(m.instance=w(v,{values:{id:s,store:e},parentLeaf:a,mountNode:t,svgRoot:a.svgRoot,leafData:m.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:r})))}})},g=h.length;h.push(m);const y=g>0?h[g-1].leafData:null;if(p.child.parent=p,l.child.push(p),y){const e=y.block;p.left=e;const t=e.right;t?(t.left=p,p.right=t):l.lastChild=p,e.right=p}else l.lastChild=p;r&&(m.instance=w(v,{values:{id:s,store:o},parentLeaf:a,mountNode:t,svgRoot:a.svgRoot,leafData:m.leafData,opGroup:u,domSubtree:a.ops.domSubtree,hydration:r}))}return ae('list update ['+o.shortName+']'),0===h.length&&(l.lastChild=null),h},target:m}),Y({source:t,clock:Y(m,a),fn:({leaf:e},t)=>({leaf:e,records:t})}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){const n=t[e];n.instance&&n.instance.api.unmount(),n.active=0}const{spawn:n}=e;n.active=0,U(n,n.parent.childSpawns[n.template.id]),U(n,n.template.pages)})},env:f}))}function z(e){if(!ue)return;const{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(ue.draft.type){case'element':case'using':case'route':case'list':case'tree':case'treeItem':case'rec':case'recItem':t.inParentIndex=ue.draft.childCount,ue.draft.childCount+=1,ue.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentActor type ${ue.draft.type}`)}}function U(e,t){if(!t)return;const n=t.indexOf(e);-1!==n&&t.splice(n,1)}function Q({mount:e,state:t,onMount:n,onState:a,greedy:r=0}){return{onMount:Y({source:t,clock:e,fn:n,greedy:r}),onState:Y({source:e,clock:t,fn:a,greedy:r})}}function G(e,...t){const n=[e[0]];for(let a=0;a<t.length;a++)n.push(t[a],e[a+1]);M({text:n})}import{step as _,launch as W,createNode as H,createEvent as J,withRegion as K,restore as X,sample as Y,merge as Z,is as ee,createStore as te}from'effector';let ne,ae,re;'undefined'!=typeof performance&&performance.mark?(ne=e=>{performance.mark('☄️ '+e+' start')},ae=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(ne=()=>{},ae=()=>{}),re='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{const e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();const oe='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);let le=0,se=0,ie=null,ce=null,ue=null;const pe=J();pe.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});export{P as h,N as handler,j as list,O as node,B as rec,A as remap,E as route,M as spec,G as text,L as tree,D as using,V 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=re(l.group.queue.execQueue))}function r(a){ae('execQueue');let n,l,r=le(),i=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(le()-r>=10){i=1;break e}let o=!!a.props.first;for(o&&ae('props');n=a.props.first;){for(;l=n.activeChilds.props.first;){if(le()-r>=10){i=1,ne('props');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'props')}o&&ne('props');let s=!!a.tree.first;for(s&&ae('tree');n=a.tree.first;){for(;l=n.activeChilds.tree.first;){if(le()-r>=10){i=1,ne('tree');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'tree')}s&&ne('tree');let u=!!a.data.first;for(u&&ae('data');n=a.data.first;){for(;l=n.activeChilds.data.first;){if(le()-r>=10){i=1,ne('data');break e}l.runOp(l.value.pending),l.value.active=l.value.pending,t(l)}e(n,'data')}u&&ne('data')}if(ne('execQueue'),i)a.rafID=re(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 p(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 c(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=se,p={id:++ie,name:n,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:$.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)?W({target:t,params:e,defer:1,page:l[n.indexOf(r)],stack:a}):console.error('context drift',{stack:a,node:t}):W({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:$.filter({fn(e,t,a){if(a.parent){if(a.page){if(!a.page.active)return 0;if(a.page.template===p)return 1;if(a.page.childSpawns[p.id])a.page.childSpawns[p.id].forEach(t=>{W({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);W(-1===l?{params:e,target:a.node,page:null,defer:1}:{params:e,target:a.node,page:n[l],defer:1})}else p.pages.forEach(t=>{t.fullID.startsWith(a.page.fullID)&&W({params:e,target:a.node,page:t,defer:1})})}else p.pages.forEach(t=>{W({params:e,target:a.node,page:t,defer:1})});return 0}return 1}}),parent:u};u&&u.childTemplates.push(p);let c=H({meta:{template:p}});se=p;let d=pe={template:p,node:c,api:null,trigger:{mount:J(),unmount:J()},draft:l,isSvgRoot:r,namespace:i,env:o};return a?d.deferredInit=()=>{let a=pe,n=se;pe=d,se=p,d.deferredInit=null;try{K(c,()=>{let a=X(t);d.api=e(a,d.trigger),p.nameMap=a})}finally{pe=a,se=n}}:K(c,()=>{let a=X(t);d.api=e(a,d.trigger),p.nameMap=a}),pe=s,se=u,p.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 p(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 c=a?a.spawn:null,d=e.template,f={},h={id:++oe,fullID:'',reg:f,template:d,parent:c,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=ue;ue=m,c&&(c.childSpawns[d.id]||(c.childSpawns[d.id]=[]),c.childSpawns[d.id].push(h)),h.fullID=c?`${c.fullID}_${h.id}`:""+h.id,c&&Object.assign(f,c.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;)p(d.watch,y,f);if(c)for(let e in h.childSpawns)e in c.childSpawns||(c.childSpawns[e]=[]),c.childSpawns[e].push(...h.childSpawns[e]);if(v.mount=(t,a=1)=>W({target:e.trigger.mount,params:t,defer:a,page:h}),v.unmount=(t,a=1)=>W({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)v[t]=(a,n=1)=>W({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}),ue=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:p}=t.ops.group,c=s(p),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,W({target:ce,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(p);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:c,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=p.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=p.document.createTextNode(t),T(l);return l}let o,s=0,u=0;'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)));let p=pe.env,c=pe.namespace,d=c,b='html';d=b='svg'===c?'svg':'html','svg'===e&&(b='svg',d='svg');let w='svg'===b?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e);'foreignObject'===c?(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:p,unmount:c}){function d(e){return G({mount:y,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let y=J(),b=p.map(({leaf:e})=>e);s&&o(),u&&M(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];ee.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];ee.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];ee.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];ee.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(ee.unit(t.value)){S.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});let e=t.value.stateRef,a=se;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}=G({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,W({target:ce,params:{element:l.block.value,fns:S.node},page:e.spawn,defer:1})),W({target:y,params:e,defer:1,page:e.spawn})}),Z([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)Z([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++;Y({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)}),Y({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(),W({target:t.handler,params:e,page:l})},t.domConfig)});break}}}Y({source:b,clock:c,greedy:1}).watch(e=>{let{spawn:t}=e;Q(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,Q(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),l(0,e.data.ops.visible)}),p.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}),W({target:y,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,W({target:ce,params:{element:t.block.value,fns:S.node},page:e.spawn,defer:1})):l(1,a)}})},env:p});U(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;'function'==typeof t?(a=t,l=P(),r=0):(a=t.fn,l=t.env?t.env:P(),r=t.hydrate,n=t.onComplete,i=t.onRoot);let u=e.namespaceURI,p=e.tagName.toLowerCase(),c={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},d=y({name:'using',draft:c,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===u?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(({node:e,leaf:t})=>{F(c,{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:ue||null,mountNode:e,svgRoot:d.isSvgRoot?e:ue?ue.svgRoot:null,leafData:{type:'using',draft:c,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 M(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?N(t.config||{},t.on):N(t)}e.ɔ&&M(e.ɔ)}function N(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 V({source:e,cases:t,key:a}){let n='function'==typeof a?a:e=>String(e[a]),l=0;for(let a in t)'__'!==a?E({source:e,visible:e=>n(e)===a,fn:t[a]}):l=1;if(l){let a=Object.keys(t);E({source:e,visible:e=>!a.includes(n(e)),fn:t.__})}}function E({source:e,visible:t,fn:a}){let n=y({name:'route',isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(n,{mount:r,unmount:i}){let o=e.map(e=>({value:e,visible:t(e)})),s={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},u=y({name:'route item',isSvgRoot:0,namespace:pe.namespace,env:pe.env,draft:s,state:{store:null},fn({store:e},{mount:t,unmount:n}){let r=J();e.on(r,(e,t)=>t),a({store:e});let i=Y({source:t,clock:o,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(s,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),i.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&W({target:r,params:a,defer:1,page:e.spawn}),B(e,e=>{let a=e.data;switch(a.type){case'element':l(t,a.ops.visible);break;default:console.log('unsupported type',a.type)}})}),Y({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{B(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,Q(t,t.parent.childSpawns[t.template.id]),Q(t,t.template.pages)})}});U(u);let{onMount:p,onState:c}=G({mount:r,state:o,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})});Z([p,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:u,values:{store:a}}),l.initialized=1)}),Y({source:r,clock:i,greedy:1}).watch(({leaf:e})=>{B(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,Q(t,t.parent.childSpawns[t.template.id]),Q(t,t.template.pages)})}});U(n)}function B(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 L(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=J();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})}),Y({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,B(e,e=>{e.api.unmount()})}),{itemUpdater:r}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=pe;U(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}=G({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})});Y({source:n,clock:l,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,B(e,e=>{e.api.unmount()})}),i.watch(({state:e,leaf:t})=>{B(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 j({source:e,child:t,fn:a}){let n=L(({state:e})=>{z({source:e,fn({store:e}){let l=e.map(e=>e[t]||[]);a({store:e,child(){n({state:l})}})}})});n({state:e})}function z(e,t){'function'==typeof t&&(ee.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:r,fields:i=[]}=e,o=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,d={type:'list',key:ee.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},f=pe.env,h=pe.namespace;U(y({name:'list',draft:d,isSvgRoot:0,namespace:h,fn(e,{mount:t,unmount:n}){let v=y({name:'list item',state:{id:-1,store:null},draft:d,isSvgRoot:0,namespace:h,fn({id:e,store:t},{mount:n,unmount:r}){a({store:t,key:e,fields:A(t,i)});let o=J();t.on(o,(e,t)=>t);let s=te({leaf:null});if(Y({source:s,clock:r,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;Q(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,B(e,e=>{e.api.unmount()});let{spawn:l}=e;l.active=0,Q(l,l.parent.childSpawns[l.template.id]),Q(l,l.template.pages)}),d.itemVisible){let{onMount:e,onState:t}=G({mount:n,state:d.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(d,{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(a,t=>{let a=t.data;switch(a.type){case'element':l(e,a.ops.visible);break;default:console.log('unsupported type',a.type)}}):e&&(n.childInitialized=1,F(d,{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(d,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:o}},env:f}),m=te([]),g=r.map(e=>e),b=Y({source:r,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),k=Y({source:b,clock:g,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1}),x=Z([b,k]);Y({source:m,clock:x,greedy:1,fn(e,{node:t,updates:a,leaf:n,hydration:l}){let i=n.data.block;ae('list update ['+r.shortName+']');let d=Array(a.length).fill(0),f=a.map(o),h=[];for(let t=0;t<e.length;t++){let n=e[t],l=f.indexOf(n.key);-1!==l?(h.push(n),d[l]=1,c(a[l],n.asyncValue)):(n.active=0,n.instance&&n.instance.api.unmount(),p(n.asyncValue))}for(let e=0;e<a.length;e++){if(d[e])continue;let r=a[e],o=f[e],p=s(n.ops.group.queue),c={type:'LF',parent:i,child:{type:'fragment',parent:null,child:[]},childInitialized:0,visible:0,left:null,right:null},m={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:c},asyncValue:u({value:r,group:p,onTerminate(e){},onChange(e){m.instance&&m.instance.api.itemUpdater(e)},onInit(e){m.active&&(l||(m.instance=w(v,{values:{id:o,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:p,domSubtree:n.ops.domSubtree,hydration:l})))}})},g=h.length;h.push(m);let y=g>0?h[g-1].leafData:null;if(c.child.parent=c,i.child.push(c),y){let e=y.block;c.left=e;let t=e.right;t?(t.left=c,c.right=t):i.lastChild=c,e.right=c}else i.lastChild=c;l&&(m.instance=w(v,{values:{id:o,store:r},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:m.leafData,opGroup:p,domSubtree:n.ops.domSubtree,hydration:l}))}return ne('list update ['+r.shortName+']'),0===h.length&&(i.lastChild=null),h},target:m}),Y({source:t,clock:Y({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,Q(a,a.parent.childSpawns[a.template.id]),Q(a,a.template.pages)})},env:f}))}function U(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 Q(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function G({mount:e,state:t,onMount:a,onState:n}){return{onMount:Y({source:t,clock:e,fn:a,greedy:1}),onState:Y({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]);M({text:a})}import{step as $,launch as W,createNode as H,createEvent as J,withRegion as K,restore as X,sample as Y,merge as Z,is as ee,createStore as te}from'effector';let ae,ne,le;'undefined'!=typeof performance&&performance.mark?(ae=e=>{performance.mark('☄️ '+e+' start')},ne=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(ae=()=>{},ne=()=>{}),le='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 re='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0),ie=0,oe=0,se=null,ue=null,pe=null,ce=J();ce.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})});export{q as h,N as handler,z as list,O as node,L as rec,A as remap,E as route,M as spec,_ as text,j as tree,D as using,V as variant};
//# sourceMappingURL=forest.es.js.map

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

((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports):'function'==typeof define&&define.amd?define(['exports'],t):t((e=e||self).forest={})})(this,e=>{function t(e,t="combine"){let n=t+'(',a='',r=0;for(let t in e){let l=e[t];if(null!=l&&(n+=a,n+=K(l)?l.compositeName.fullName:l.toString()),r+=1,25===r)break;a=', '}return n+=')',n}function n({node:e=[],from:t,source:n,parent:a=t||n,to:r,target:l,child:o=r||l,scope:s={},meta:i={},family:c={type:'regular'}}){let u=$e(a),p=$e(c.links),d=$e(c.owners),f=[],h={};for(let t=0;t<e.length;t++){let n=e[t];n&&(f.push(n),ze(n,h))}let m={seq:f,next:$e(o),meta:i,scope:s,family:{type:c.type||'crosslink',links:p,owners:d},reg:h};for(let e=0;e<p.length;e++)oe(p[e]).push(m);for(let e=0;e<d.length;e++)se(d[e]).push(m);for(let e=0;e<u.length;e++)u[e].next.push(m);return m}function a(e,t){st={parent:st,value:e,template:le(e).meta.template||st&&st.template};try{return t()}finally{st=fe(st)}}function r(e,t){let a=(e,...t)=>a.create(e,t,t);a.graphite=n({meta:ht('event',a,t,e)}),a.create=e=>(Ye(a,e),e),a.watch=ke(pt,a),a.map=e=>{let t,n;ae(e)&&(t=e,n=e.name,e=e.fn);let l=r(me(a,n),t);return mt(a,l,'map',e),l},a.filter=e=>re(e)?(console.error('.filter(fn) is deprecated, use .filterMap instead'),l(a,e)):vt(a,'filter',e.fn,[Ae({fn:Ve})]),a.filterMap=ke(l,a),a.prepend=e=>{let t=r('* → '+a.shortName,{parent:fe(a)}),n=ct();return n&&le(t).seq.push(n.upward),mt(t,a,'prepend',e),((e,t)=>{fe(e)&&fe(e).hooks.event(t)})(a,t),t},gt(a,a);let o=ct();return o&&(le(a).meta.nativeTemplate=o),ot(a)}function l(e,t){return vt(e,'filterMap',t,[Ce({fn:Ve}),Fe()])}function o(e,t){function a(e,t){u.off(e),de(u).set(e,lt(yt(e,u,'on',1,t)))}let l=Pe(e),s=Pe(e),i=(()=>r({named:'updates'}))(),c=ct();l.after=[{type:'copy',to:s}],c&&c.plain.push(l);let u={subscribers:new Map,updates:i,defaultState:e,stateRef:l,getState(){let e=Xe();return De(e&&e.reg[l.id]?e.reg[l.id]:l)},setState(e){Ye({target:u,params:e,defer:1})},reset(...e){for(let t of e)u.on(t,()=>u.defaultState);return u},on(e,t){if(Array.isArray(e))for(let n of e)a(n,t);else a(e,t);return u},off(e){let t=de(u).get(e);return t&&(t(),de(u).delete(e)),u},map(e,t){let n,a,r;ae(e)&&(n=e,a=e.name,t=e.firstState,e=e.fn);let s=u.getState(),i=ct();i?r=null:void 0!==s&&(r=e(s,t));let c=o(r,{name:me(u,a),config:n,strict:0}),p=yt(u,c,'map',0,e);return ie(c).before=[{type:'map',fn:e,from:l}],i&&(i.plain.includes(l)||p.seq.includes(i.loader)||p.seq.unshift(i.loader)),c},[ve]:()=>gt(u,{})};return u.graphite=n({scope:{state:l},node:[Fe(),Ne({store:l}),Re({store:s}),Ne({store:s})],child:i,meta:ht('store',u,t)}),ft&&void 0===e&&ne("current state can't be undefined, use null instead"),c&&(le(u).meta.nativeTemplate=c),u.watch=u.subscribe=(e,t)=>{if(!t||!K(e)){re(e)||ne('watch requires function handler');let t=ct();return t?t.watch.push({of:l,fn:e}):e(u.getState()),pt(u,e)}return re(t)||ne('second argument should be a function'),e.watch(e=>t(u.getState(),e))},Ee(u,[i]),ot(u)}function s(...e){let t,a,l;ue(e[0])&&(l=ce(e[0]),e=ue(e[0]));let s,[i,c,u,p=0]=e;void 0===c&&'source'in i&&('clock'in i&&null==i.clock&&ne('config.clock should be defined'),c=i.clock,u=i.fn,p=i.greedy,t=i.target,a=i.name,s=i.sid,i=i.source),void 0===c&&(c=i),a=l||a||i.shortName,i=St(i),c=St(c),'boolean'==typeof u&&(p=u,u=null);let d=ct(),f=!!t;t||(Y(i)&&Y(c)?t=o(u?u(De(ie(i)),De(ie(c))):De(ie(i)),{name:a,sid:s}):(t=r(a),d&&le(t).seq.push(d.loader)));let h=f&&K(t)&&le(t).meta.nativeTemplate;if(Y(i))Ee(i,[ut(c,t,{scope:{fn:u,targetTemplate:h},node:[d&&d.loader,!p&&Ie({priority:'sampler'}),Te({store:ie(i),to:u?'a':'stack'}),u&&Ce({fn:Oe}),d&&f&&d.upward],meta:{op:'sample',sample:'store'}})]);else{let e=Pe(0),a=Pe(),r=Pe();d&&d.plain.push(e,a,r),ot(n({parent:i,node:[Ne({store:a}),Te({from:'value',store:1,target:e})],family:{owners:[i,t,c],links:t},meta:{op:'sample',sample:'source'}})),Ee(i,[ut(c,t,{scope:{fn:u,targetTemplate:h},node:[d&&d.loader,Ne({store:r}),Te({store:e}),Ae({fn:e=>e}),!p&&Ie({priority:'sampler'}),Te({store:a}),Te({store:r,to:'a'}),u&&Ce({fn:Me}),d&&f&&d.upward],meta:{op:'sample',sample:'clock'}})])}return t}function i(e){let a=r(t(e,'merge'));return(e=>{let t;ue(e)&&(t=ce(e),e=ue(e));let{from:a,to:r,meta:l={op:'forward'}}=e;a&&r||ne('from and to fields should be defined'),t&&(l.config=t),lt(ot(n({parent:a,child:r,meta:l,family:{}})))})({from:e,to:a,meta:{op:'merge'}}),a}function c(e,t,n){if(Y(e))return e;if(K(e)){let a,r=fe(e);return Z(e)&&(a=o(t,{parent:r,name:e.shortName,"ɔ":n}).on(e,(e,t)=>t)),ee(e)&&(a=o(t,{parent:r,name:e.shortName,"ɔ":n}).on(e.done,(e,{result:t})=>t)),r&&r.hooks.store(a),a}let a={};return bt(e,(e,t)=>{a[t]=Y(e)?e:o(e,{name:t})}),a}function u(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||u(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=It(t.group.queue.execQueue))}function m(e){kt('execQueue');const t=xt();let n,a,r=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(xt()-t>=10){r=1;break e}const l=!!e.props.first;for(l&&kt('props');n=e.props.first;){for(;a=n.activeChilds.props.first;){if(xt()-t>=10){r=1,wt('props');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}u(n,'props')}l&&wt('props');const o=!!e.tree.first;for(o&&kt('tree');n=e.tree.first;){for(;a=n.activeChilds.tree.first;){if(xt()-t>=10){r=1,wt('tree');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}u(n,'tree')}o&&wt('tree');const s=!!e.data.first;for(s&&kt('data');n=e.data.first;){for(;a=n.activeChilds.data.first;){if(xt()-t>=10){r=1,wt('data');break e}a.runOp(a.value.pending),a.value.active=a.value.pending,p(a)}u(n,'data')}s&&wt('data')}if(wt('execQueue'),r)e.rafID=It(e.execQueue);else if(e.rafID=null,e.onDrain){const t=e.onDrain;e.onDrain=null,t()}}function v({value:e,runOp:t,group:n,priority:a}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:a,group:n,cursor:{prev:null,next:null}}}function g({onComplete:e}){const 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:n,onChange:a,onTerminate:r}){const l=v({value:e,group:t,runOp(e){o.status='A',a(e)},priority:'data'}),o={status:'IA',value:l.value,hooks:{onTerminate:r},ops:{init:v({value:0,group:t,runOp(e){o.status='A',n(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,n){x(n)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${n}`)}function I(e,t,n){x(n)?delete e.style[t]:e.style[t]=`${n}`}function T(e,t,n){x(n)?delete e.dataset[t]:e.dataset[t]=`${n}`}function F(e,t,n){if(x(n)){switch(t){case'value':delete e.value;break;case'checked':e.checked=0;break;case'spellcheck':if(0==n)return void e.setAttribute('spellcheck','false')}e.removeAttribute(t)}else{switch(t){case'value':e.value=`${n}`;break;case'checked':e.checked=`${n}`}e.setAttribute(t,`${n}`)}}function R(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function C({fn:e,state:t={},defer:l=0,name:o="",draft:s,isSvgRoot:i,namespace:u,env:p}){const d=At,f=Rt,h={id:++Tt,name:o,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:Ae({fn(e,t,n){if(!n.page)return console.error('context lost',n),0;if(!n.page.active)return 0;const a=[n.page.template],r=[n.page];{let e=n.page.parent;for(;e;)r.push(e),a.push(e.template),e=e.parent}return n.node.next.forEach(t=>{const l=t.meta.nativeTemplate;l?a.includes(l)?Ye({target:t,params:e,defer:1,page:r[a.indexOf(l)],stack:n}):console.error('context drift',{stack:n,node:t}):Ye({target:t,params:e,defer:1,page:null,stack:n})}),0}}),loader:Ae({fn(e,t,n){if(n.parent){if(n.page){if(!n.page.active)return 0;if(n.page.template===h)return 1;if(n.page.childSpawns[h.id])n.page.childSpawns[h.id].forEach(t=>{Ye({params:e,target:n.node,page:t,defer:1})});else if(t.targetTemplate){const a=[n.page];{let e=n.page.parent;for(;e;)a.push(e),e=e.parent}const r=a.findIndex(e=>t.targetTemplate===e.template);Ye(-1===r?{params:e,target:n.node,page:null,defer:1}:{params:e,target:n.node,page:a[r],defer:1})}else h.pages.forEach(t=>{t.fullID.startsWith(n.page.fullID)&&Ye({params:e,target:n.node,page:t,defer:1})})}else h.pages.forEach(t=>{Ye({params:e,target:n.node,page:t,defer:1})});return 0}return 1}}),parent:f};f&&f.childTemplates.push(h);const m=n({meta:{template:h}});Rt=h;const v=At={template:h,node:m,api:null,trigger:{mount:r(),unmount:r()},draft:s,isSvgRoot:i,namespace:u,env:p};return l?v.deferredInit=()=>{const n=At,r=Rt;At=v,Rt=h,v.deferredInit=null;try{a(m,()=>{const n=c(t);v.api=e(n,v.trigger),h.nameMap=n})}finally{At=n,Rt=r}}:a(m,()=>{const n=c(t);v.api=e(n,v.trigger),h.nameMap=n}),At=d,Rt=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:n,mountNode:a,svgRoot:r,leafData:l,opGroup:o,domSubtree:s,hydration:i}){function c(e){if(e.before)for(const t of e.before)switch(t.type){case'map':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current=t.fn(f[n.id].current);break}case'field':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current[t.field]=f[n.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;const t=f[e.id].current;for(const n of e.after){const e=n.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),n.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=n.fn(t)}}}function u(e,t,n){let a;t.stop=1;try{for(;t.i<e.length;)a=e[t.i],t.i++,a.fn(n[a.of.id].current)}catch(e){console.error(e),t.stop=0}}const p=n?n.spawn:null,d=e.template,f={},h={id:++Ft,fullID:'',reg:f,template:d,parent:p,childSpawns:{},active:1};d.pages.push(h);const m={},v={spawn:h,api:m,draft:e.draft,ops:{group:o,domSubtree:s},svgRoot:r,data:l,parentLeaf:n,hydration:i},g=Ct;Ct=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(const e of d.closure){let t=e,n=h.parent;e:for(;n;){if(e.id in n.reg){t=n.reg[e.id];break e}n=n.parent}f[e.id]=t}for(const e of d.plain){const t={id:e.id,current:A(e)};f[e.id]=t}for(const e in t){const n=d.nameMap[e].stateRef.id;f[n]={id:n,current:t[e]}}for(const e of d.closure)c(e);for(const e of d.plain)c(e);const y={i:0,stop:0};for(;!y.stop;)u(d.watch,y,f);if(p)for(const e in h.childSpawns)e in p.childSpawns||(p.childSpawns[e]=[]),p.childSpawns[e].push(...h.childSpawns[e]);if(m.mount=(t,n=1)=>Ye({target:e.trigger.mount,params:t,defer:n,page:h}),m.unmount=(t,n=1)=>Ye({target:e.trigger.unmount,params:t,defer:n,page:h}),e.api)for(const t in e.api)m[t]=(n,a=1)=>Ye({target:e.api[t],params:n,defer:a,page:h});return v.spawn.api=m,v.spawn.leaf=v,v.api.mount({node:a,leaf:v}),Ct=g,v}function N(e){const t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent;case'tree':return e(t.parent.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'FTree':return D(e.child.child);case'FRec':case'FRecItem':return D(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){const e=P(t);if(e)return e;t=t.left}return null}default:return null}}function D(e){const t=e.child;for(let e=t.length-1;e>=0;e--){const n=P(t[e]);if(n)return n}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':{const t=e.parent.parent.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=P(n.child[e]);if(t)return t}return M(n)}case'FF':{const t=e.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=P(n.child[e]);if(t)return t}return M(n)}case'LF':{let t=e.parent.left;for(;t;){const e=P(t);if(e)return e;t=t.left}return M(e.parent.parent)}case'tree':{const t=e.parent.parent,n=t.parent;for(let e=t.index-1;e>=0;e--){const t=P(n.child[e]);if(t)return t}return M(n)}default:return null}if('route'===e.type){const t=e.parent.parent;for(let n=e.parent.index-1;n>=0;n--){const e=t.child[n];if(!e)continue;const a=P(e);if(a)return a}return M(t)}const t=e.parent.parent;for(let n=e.parent.index-1;n>=0;n--){const e=t.child[n];if(!e)continue;const a=P(e);if(a)return a}return M(t)}function O(e){const t=M(e);return t?t.value:null}function V(e,{parentBlockFragment:t,leaf:n,node:a,svgRoot:r,values:l}){e.childTemplates.forEach(e=>{E({parentBlockFragment:t,leaf:n,node:a,svgRoot:r,values:l,actor:e})})}function E({parentBlockFragment:e,leaf:t,node:n,actor:a,svgRoot:r,values:l}){let o;const{draft:s}=a,{queue:i}=t.ops.group,c=y(i),u=t.ops.domSubtree;let p=u;switch(s.type){case'route':{const t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:s.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[s.inParentIndex]=t.parent,o={type:'route',block:t,ops:{},initialized:0};break}case'element':{const t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:s.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:s.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[s.inParentIndex]=t.parent,o={type:'element',block:t,ops:{visible:v({value:0,priority:'tree',runOp(e){e?($(t),o.needToCallNode&&(o.needToCallNode=0,Ye({target:qt,params:{element:t.value,fns:s.node},page:d.spawn}))):(t.value.remove(),t.parent.visible=0)},group:u})},needToCallNode:s.node.length>0},p=y(i);break}case'list':{const t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:s.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[s.inParentIndex]=t.parent,o={type:'list',draft:s,block:t};break}case'tree':{const t={type:'tree',parent:{type:'FTree',parent:e,child:null,visible:1,index:s.inParentIndex},child:{type:'fragment',parent:null,child:[]}};t.parent.child=t,t.child.parent=t,e.child[s.inParentIndex]=t.parent,o={type:'tree',block:t};break}case'using':case'listItem':break;case'rec':{const t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:s.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[s.inParentIndex]=t.parent,o={type:'rec',block:t};break}case'recItem':{const t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:s.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[s.inParentIndex]=t.parent,o={type:'rec item',block:t};break}default:console.warn(`unexpected draft type ${s.type}`)}const d=q(a,{values:l,parentLeaf:t,mountNode:n,svgRoot:r||t.svgRoot,leafData:o,opGroup:c,domSubtree:p,hydration:t.hydration})}function $(e){const t=O(e);t?t.after(e.value):N(e).prepend(e.value),e.parent.visible=1}function z(e,t){if(Array.isArray(t))return t.map(t=>e.map(e=>e[t]));if('object'==typeof t&&null!==t){const n={};for(const a in t){const r=t[a];n[a]=e.map('function'==typeof r?e=>r(e):e=>e[r])}return n}return e.map(e=>e[t])}function j(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function B(e){const t=At.draft;switch(t.type){case'list':return void(e.visible&&(t.itemVisible=e.visible));case'listItem':case'using':case'route':case'tree':case'treeItem':case'rec':case'recItem':return}if(e.attr&&t.attr.push(e.attr),e.data&&t.data.push(e.data),'text'in e){const n=e.text,a=t.childCount;Array.isArray(n)?(t.text.push(...n.map((e,t)=>({index:t+a,value:e}))),t.childCount+=n.length):(t.text.push({index:a,value:n}),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){const t=e.handler;'object'==typeof t.on?L(t.config||{},t.on):L(t)}e.ɔ&&B(e.ɔ)}function L(e,t){const n=At.draft;if('element'!==n.type)throw Error(`"handler" extension can be used only with element nodes, got "${n.type}"`);void 0===t&&(t=e,e={});const{passive:a=1,capture:r=0,prevent:l=0,stop:o=0}=e;n.handler.push({options:{prevent:l,stop:o},domConfig:{passive:l?0:a,capture:r},map:t})}function U({source:e,visible:t,fn:n}){const a=C({name:'route',isSvgRoot:0,namespace:At.namespace,env:At.env,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(a,{mount:l,unmount:o}){const c=e.map(e=>({value:e,visible:t(e)})),u={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},p=C({name:'route item',isSvgRoot:0,namespace:At.namespace,env:At.env,draft:u,state:{store:null},fn({store:e},{mount:t,unmount:a}){const l=r();e.on(l,(e,t)=>t),n({store:e});const o=s({source:t,clock:c,fn:({leaf:e,node:t},{visible:n,value:a})=>({leaf:e,visible:n,node:t,value:a}),greedy:1});t.watch(({leaf:e,node:t})=>{const n=e.data;n.block.child.visible=1,V(u,{parentBlockFragment:n.block.child.child,leaf:e,node:t})}),o.watch(({leaf:e,visible:t,value:n})=>{e.data.block.child.visible=t,t&&Ye({target:l,params:n,defer:1,page:e.spawn}),_(e,e=>{const n=e.data;switch(n.type){case'element':h(t,n.ops.visible);break;default:console.log('unsupported type',n.type)}})}),s(t,a).watch(({leaf:e})=>{_(e,e=>{e.api.unmount()});const{spawn:t}=e;t.active=0,H(t,t.parent.childSpawns[t.template.id]),H(t,t.template.pages)})}});W(p);const{onMount:d,onState:f}=J({mount:l,state:c,onMount:({visible:e,value:t},{leaf:n,node:a})=>({leaf:n,visible:e,node:a,value:t}),onState:({leaf:e,node:t},{visible:n,value:a})=>({leaf:e,visible:n,node:t,value:a}),greedy:1});i([d,f]).watch(({leaf:e,visible:t,value:n,node:a})=>{const r=e.data;r.block.child.visible=t,t&&!r.initialized&&(E({parentBlockFragment:r.block.child.child,leaf:e,node:a,actor:p,values:{store:n}}),r.initialized=1)}),s(l,o).watch(({leaf:e})=>{_(e,e=>{e.api.unmount()});const{spawn:t}=e;t.active=0,H(t,t.parent.childSpawns[t.template.id]),H(t,t.template.pages)})}});W(a)}function _(e,t){const{spawn:n}=e;for(const e in n.childSpawns){const a=n.childSpawns[e];for(let e=0;e<a.length;e++)t(a[e].leaf)}}function Q(e){const t={type:'rec',childTemplates:[],childCount:0,inParentIndex:0},n=C({name:'rec',state:{store:null},isSvgRoot:0,namespace:At.namespace,env:At.env,draft:t,defer:1,fn({store:n},{mount:a,unmount:l}){e({state:n});const o=r();return n.on(o,(e,t)=>t),a.watch(({node:e,leaf:n})=>{V(t,{parentBlockFragment:n.data.block.child.child,leaf:n,node:e})}),s(a,l).watch(({leaf:e})=>{e.spawn.active=0,_(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{n.deferredInit&&n.deferredInit();const{env:t,namespace:a}=At;W(C({name:'rec item',isSvgRoot:0,namespace:a,env:t,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(t,{mount:a,unmount:r}){const{onMount:l,onState:o}=J({state:e,mount:a,onMount:(e,{leaf:t,node:n})=>({state:e,leaf:t,node:n}),onState:({leaf:e,node:t},n)=>({state:n,leaf:e,node:t}),greedy:1});s(a,r).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:a})=>{E({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:n,values:{store:a}})})}}))}}function G(e,t){'function'==typeof t&&(K(e)?e={source:e,fn:t}:e.fn=t);const{fn:n,key:a,source:l,fields:c=[]}=e,u=void 0!==a?'function'==typeof a?a:e=>e[a]:(e,t)=>t,p={type:'list',key:Y(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},d=At.env,f=At.namespace;W(C({name:'list',draft:p,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:a}){const m=C({name:'list item',state:{id:-1,store:null},draft:p,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:a,unmount:l}){n({store:t,key:e,fields:z(t,c)});const i=r();t.on(i,(e,t)=>t);const u=o({leaf:null});if(s(u,l).watch(({leaf:e})=>{const t=e.data.block;H(t,t.parent.child);const n=t.left,a=t.right;n&&(n.right=a,a||t.parent.lastChild!==t||(t.parent.lastChild=n)),a&&(a.left=n),n||a||t.parent.lastChild!==t||(t.parent.lastChild=null),t.left=null,t.right=null,_(e,e=>{e.api.unmount()});const{spawn:r}=e;r.active=0,H(r,r.parent.childSpawns[r.template.id]),H(r,r.template.pages)}),p.itemVisible){const{onMount:e,onState:t}=J({mount:a,state:p.itemVisible,onMount:(e,{node:t,leaf:n})=>({visible:e,node:t,leaf:n}),onState:({node:e,leaf:t},n)=>({visible:n,node:e,leaf:t})});e.watch(({visible:e,node:t,leaf:n})=>{u.setState({leaf:n});const a=n.data.block;a.visible=e,a.childInitialized=e,e&&V(p,{parentBlockFragment:a.child,leaf:n,node:t})}),t.watch(({visible:e,node:t,leaf:n})=>{const a=n.data.block;a.visible=e,a.childInitialized?_(n,t=>{const n=t.data;switch(n.type){case'element':h(e,n.ops.visible);break;default:console.log('unsupported type',n.type)}}):e&&(a.childInitialized=1,V(p,{parentBlockFragment:a.child,leaf:n,node:t}))})}else a.watch(({node:e,leaf:t})=>{u.setState({leaf:t});const n=t.data.block;n.visible=1,n.childInitialized=1,V(p,{parentBlockFragment:n.child,leaf:t,node:e})});return{itemUpdater:i}},env:d}),v=o([]),g=l.map(e=>e),x=s({source:l,clock:t,fn:(e,{node:t,leaf:n})=>({updates:e,node:t,leaf:n,hydration:n.hydration}),greedy:1}),S=s({source:x,clock:g,fn:({node:e,leaf:t},n)=>({updates:n,node:e,leaf:t,hydration:0}),greedy:1});s({source:v,clock:i([x,S]),greedy:1,fn(e,{node:t,updates:n,leaf:a,hydration:r}){const o=a.data.block;kt('list update ['+l.shortName+']');const s=Array(n.length).fill(0),i=n.map(u),c=[];for(let t=0;t<e.length;t++){const a=e[t],r=i.indexOf(a.key);-1!==r?(c.push(a),s[r]=1,w(n[r],a.asyncValue)):(a.active=0,a.instance&&a.instance.api.unmount(),k(a.asyncValue))}for(let e=0;e<n.length;e++){if(s[e])continue;const l=n[e],u=i[e],p=y(a.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:u,index:u,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(m,{values:{id:u,store:e},parentLeaf:a,mountNode:t,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:a.ops.domSubtree,hydration:r})))}})},h=c.length;c.push(f);const v=h>0?c[h-1].leafData:null;if(d.child.parent=d,o.child.push(d),v){const e=v.block;d.left=e;const t=e.right;t?(t.left=d,d.right=t):o.lastChild=d,e.right=d}else o.lastChild=d;r&&(f.instance=q(m,{values:{id:u,store:l},parentLeaf:a,mountNode:t,svgRoot:a.svgRoot,leafData:f.leafData,opGroup:p,domSubtree:a.ops.domSubtree,hydration:r}))}return wt('list update ['+l.shortName+']'),0===c.length&&(o.lastChild=null),c},target:v}),s({source:t,clock:s(v,a),fn:({leaf:e},t)=>({leaf:e,records:t})}).watch(({leaf:e,records:t})=>{for(let e=0;e<t.length;e++){const n=t[e];n.instance&&n.instance.api.unmount(),n.active=0}const{spawn:n}=e;n.active=0,H(n,n.parent.childSpawns[n.template.id]),H(n,n.template.pages)})},env:d}))}function W(e){if(!At)return;const{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(At.draft.type){case'element':case'using':case'route':case'list':case'tree':case'treeItem':case'rec':case'recItem':t.inParentIndex=At.draft.childCount,At.draft.childCount+=1,At.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentActor type ${At.draft.type}`)}}function H(e,t){if(!t)return;const n=t.indexOf(e);-1!==n&&t.splice(n,1)}function J({mount:e,state:t,onMount:n,onState:a,greedy:r=0}){return{onMount:s({source:t,clock:e,fn:n,greedy:r}),onState:s({source:e,clock:t,fn:a,greedy:r})}}let K=e=>(re(e)||ae(e))&&'kind'in e;const X=e=>t=>K(t)&&t.kind===e;let Y=X('store'),Z=X('event'),ee=X('effect'),te=X('domain'),ne=e=>{throw Error(e)},ae=e=>'object'==typeof e&&null!==e,re=e=>'function'==typeof e,le=e=>e.graphite||e,oe=e=>e.family.owners,se=e=>e.family.links,ie=e=>e.stateRef,ce=e=>e.config,ue=e=>e.ɔ,pe=e=>e.value,de=e=>e.subscribers,fe=e=>e.parent,he=(e,t)=>''+e.shortName+t,me=(e,t)=>null==t?he(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 ge=()=>{let e=0;return()=>(++e).toString(36)};let ye=ge(),be=ge(),ke=(e,t)=>e.bind(null,t),we=(e,t,n)=>e.bind(null,t,n);const xe=(e,t,n)=>({id:be(),type:e,data:n,hasRef:t});let Se=0,Ie=({priority:e="barrier"})=>xe('barrier',0,{barrierID:++Se,priority:e}),Te=({from:e="store",store:t,target:n,to:a=(n?'store':'stack')})=>xe('mov','store'===e,{from:e,store:t,to:a,target:n}),Fe=()=>xe('check',0,{type:'defined'}),Re=({store:e})=>xe('check',1,{type:'changed',store:e}),Ce=we(xe,'compute',0),Ae=we(xe,'filter',0),qe=we(xe,'run',0),Ne=({store:e})=>Te({from:'stack',target:e}),Pe=e=>({id:be(),current:e}),De=({current:e})=>e,Me=(e,{fn:t},{a:n})=>t(e,n),Oe=(e,{fn:t},{a:n})=>t(n,e),Ve=(e,{fn:t})=>t(e),Ee=(e,t)=>{let n=le(e);for(let e=0;e<t.length;e++){let a=le(t[e]);'domain'!==n.family.type&&(a.family.type='crosslink'),oe(a).push(n),se(n).push(a)}};const $e=(e=[])=>{let t=[];if(Array.isArray(e))for(let n=0;n<e.length;n++)Array.isArray(e[n])?t.push(...e[n]):t.push(e[n]);else t.push(e);return t.map(le)};let ze=({hasRef:e,type:t,data:n},a)=>{let r;e&&(r=n.store,a[r.id]=r),'mov'===t&&'store'===n.to&&(r=n.target,a[r.id]=r)},je=null;const Be=(e,t)=>{if(!e)return t;if(!t)return e;let n,a=e.v.type===t.v.type;return(a&&e.v.id>t.v.id||!a&&'sampler'===e.v.type)&&(n=e,e=t,t=n),n=Be(e.r,t),e.r=e.l,e.l=n,e},Le=[];let Ue=0;for(;Ue<5;)Le.push({first:null,last:null,size:0}),Ue+=1;const _e=()=>{for(let e=0;e<5;e++){let t=Le[e];if(t.size>0){if(2===e||3===e){t.size-=1;let e=je.v;return je=Be(je.l,je.r),e}1===t.size&&(t.last=null);let n=t.first;return t.first=n.r,t.size-=1,n.v}}},Qe=(e,t,n,a,r)=>Ge(0,{a:null,b:null,node:n,parent:a,value:r,page:t},e),Ge=(e,t,n,a=0)=>{let r=We(n),l=Le[r],o={v:{idx:e,stack:t,type:n,id:a},l:0,r:0};2===r||3===r?je=Be(je,o):(0===l.size?l.first=o:l.last.r=o,l.last=o),l.size+=1},We=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}},He=new Set;let Je=0,Ke=null,Xe=()=>Ke,Ye=(e,t,n)=>{let a=Ke,r=null;if(e.target&&(t=e.params,n=e.defer,a='page'in e?e.page:a,e.stack&&(r=e.stack),e=e.target),Array.isArray(e))for(let n=0;n<e.length;n++)Qe('pure',a,le(e[n]),r,t[n]);else Qe('pure',a,le(e),r,t);n&&Je||(()=>{let e,t,n,a,r,l,o={alreadyStarted:Je,currentPage:Ke};Je=1;e:for(;a=_e();){let{idx:o,stack:s,type:i}=a;n=s.node,Ke=r=s.page,l=(r||n).reg;let c={fail:0,scope:n.scope};e=t=0;for(let a=o;a<n.seq.length&&!e;a++){let u=n.seq[a],p=u.data;switch(u.type){case'barrier':{let e=p.barrierID;r&&(e=`${r.fullID}_${e}`);let t=p.priority;if(a!==o||i!==t){He.has(e)||(He.add(e),Ge(a,s,t,e));continue e}He.delete(e);break}case'mov':{let e;switch(p.from){case'stack':e=pe(s);break;case'a':e=s.a;break;case'b':e=s.b;break;case'value':e=p.store;break;case'store':l[p.store.id]||(s.page=r=null,l=n.reg),e=De(l[p.store.id])}switch(p.to){case'stack':s.value=e;break;case'a':s.a=e;break;case'b':s.b=e;break;case'store':l[p.target.id].current=e}break}case'check':switch(p.type){case'defined':t=void 0===pe(s);break;case'changed':t=pe(s)===De(l[p.store.id])}break;case'filter':t=!Ze(c,p,s);break;case'run':if(a!==o||'effect'!==i){Ge(a,s,'effect');continue e}case'compute':s.value=Ze(c,p,s)}e=c.fail||t}if(!e)for(let e=0;e<n.next.length;e++)Qe('child',r,n.next[e],s,pe(s))}Je=o.alreadyStarted,Ke=o.currentPage})()};const Ze=(e,{fn:t},n)=>{try{return t(pe(n),e.scope,n)}catch(t){console.error(t),e.fail=1}},et=(e,t)=>{let n=e.indexOf(t);-1!==n&&e.splice(n,1)},tt=(e,t)=>{et(e.next,t),et(oe(e),t),et(se(e),t)},nt=(e,t,n)=>{let a;e.next.length=0,e.seq.length=0,e.scope=null;let r=se(e);for(;a=r.pop();)tt(a,e),(t||n&&!e.meta.sample||'crosslink'===a.family.type)&&nt(a,t,n);for(r=oe(e);a=r.pop();)tt(a,e),n&&'crosslink'===a.family.type&&nt(a,t,n)},at=e=>e.clear();let rt=(e,{deep:t}={})=>{let n=0;if(e.ownerSet&&e.ownerSet.delete(e),Y(e))at(de(e));else if(te(e)){n=1;let t=e.history;at(t.events),at(t.effects),at(t.stores),at(t.domains)}nt(le(e),!!t,n)},lt=e=>{let t=we(rt,e,void 0);return t.unsubscribe=t,t},ot=e=>(st&&Ee(pe(st),[e]),e),st=null,ct=()=>st&&st.template,ut=(e,t,{node:a,scope:r,meta:l})=>ot(n({node:a,parent:e,child:t,scope:r,meta:l,family:{owners:[e,t],links:t}})),pt=(e,t)=>lt(ot(n({scope:{fn:t},node:[qe({fn:Ve})],parent:e,meta:{op:'watch'},family:{owners:e}})));const dt=(e,t)=>(ae(e)&&(dt(ce(e),t),null!=e.name&&(ae(e.name)?dt(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),fe(e)&&(t.parent=fe(e)),'strict'in e&&(t.strict=e.strict),e.named&&(t.named=e.named),dt(ue(e),t)),t);let ft,ht=(e,t,n,a)=>{let r=dt({name:a,config:n},{}),l=ye(),{parent:o=null,sid:s=null,strict:i=1,named:c=null}=r,u=c||r.name||('domain'===e?'':l),p=((e,t)=>{let n,a,r,l=e;return t?(r=t.compositeName,0===e.length?(n=r.path,a=r.fullName):(n=r.path.concat([e]),a=0===r.fullName.length?e:r.fullName+'/'+e)):(n=0===e.length?[]:[e],a=e),{shortName:l,fullName:a,path:n}})(u,o);return t.kind=e,t.id=l,t.sid=s,t.shortName=u,t.parent=o,t.compositeName=p,t.defaultConfig=r,t.thru=e=>e(t),t.getType=()=>p.fullName,ft=i,{unit:e,name:u,sid:s,named:c}};const mt=(e,t,n,a)=>ut(e,t,{scope:{fn:a},node:[Ce({fn:Ve})],meta:{op:n}}),vt=(e,t,n,a)=>{let l;ae(n)&&(l=n,n=n.fn);let o=r(he(e,' →? *'),l);return ut(e,o,{scope:{fn:n},node:a,meta:{op:t}}),o},gt=(e,t)=>(t.subscribe=t=>((e=>{ae(e)||re(e)||ne('expect value to be an object')})(t),e.watch(e=>{t.next&&t.next(e)})),t[ve]=()=>t,t),yt=(e,t,n,a,r)=>{let l=ie(t),o=[Te({store:l,to:'a'}),Ce({fn:a?Oe:Me}),Fe(),Re({store:l}),Ne({store:l})],s=ct();if(s&&(o.unshift(s.loader),o.push(s.upward),Y(e))){let t=ie(e);s.plain.includes(t)||(s.closure.includes(t)||s.closure.push(t),l.before||(l.before=[]),l.before.push({type:'closure',of:t}))}return ut(e,t,{scope:{fn:r},node:o,meta:{op:n}})};let bt=(e,t)=>{for(let n in e)t(e[n],n)};n({node:[qe({fn({fn:e,value:t}){e(t)}})],meta:{op:'fx',fx:'sidechain'}});let kt,wt,xt,St=e=>K(e)?e:((...e)=>{let n,a,r;0===e.length&&ne('at least one argument required'),ue(e[0])&&(r=ce(e[0]),e=ue(e[0]));let l,s,i=e[e.length-1];if(re(i)?(a=e.slice(0,-1),n=i):a=e,1===a.length){let e=a[0];Y(e)||(l=e,s=1)}return s||(l=a,n&&(n=(e=>t=>e(...t))(n))),((e,n,a,r)=>{let l=e?e=>e.slice():e=>Object.assign({},e),s=e?[]:{},i=ct(),c=l(s),u=Pe(c),p=Pe(1);u.type=e?'list':'shape',i&&i.plain.push(u,p);let d=o(c,{name:a||t(n)}),f=[Fe(),Te({store:u,to:'a'}),Ae({fn:(e,{key:t},{a:n})=>e!==n[t]}),Te({store:p,to:'b'}),Ce({fn(e,{clone:t,key:n},a){a.b&&(a.a=t(a.a)),a.a[n]=e}}),Te({from:'a',target:u}),Te({from:'value',store:0,target:p}),Ie({priority:'barrier'}),Te({from:'value',store:1,target:p}),Te({store:u}),r&&Ce({fn:r}),Re({store:ie(d)})],h=u.before=[];return bt(n,(e,t)=>{if(!Y(e))return void(c[t]=s[t]=e);s[t]=e.defaultState,c[t]=e.getState();let n=ut(e,d,{scope:{key:t,clone:l},node:f,meta:{op:'combine'}}),a=ie(e);h.push({type:'field',field:t,from:a}),i&&(i.plain.includes(a)||n.seq.unshift(i.loader))}),d.defaultShape=n,u.after=[r?{type:'map',to:ie(d),fn:r}:{type:'copy',to:ie(d)}],i||(d.defaultState=r?ie(d).current=r(c):s),d})(Array.isArray(l),l,r,n)})(e);Ae({fn:(e,{state:t})=>void 0!==e&&e!==De(t)}),Ce({fn:e=>e}),'undefined'!=typeof performance&&performance.mark?(kt=e=>{performance.mark('☄️ '+e+' start')},wt=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(kt=()=>{},wt=()=>{}),xt='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{const e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();const It='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);let Tt=0,Ft=0,Rt=null,Ct=null,At=null;const qt=r();qt.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),e.h=(e,t)=>{function n(e){return e.data.block.value}function a(e,t,n){const a=e.data.block.child.child,r={type:'text',parent:{type:'FT',parent:a,child:null,visible:0,index:n},value:null};if(r.parent.child=r,a.child[n]=r.parent,e.hydration){const e=M(r);if(e)switch(e.type){case'text':r.value=u.document.createTextNode(t),e.value.after(r.value);break;case'element':r.value=e.value.nextSibling,R(r.value,t)}else{const e=N(r);r.value=e.firstChild,R(r.value,t)}r.parent.visible=1}else r.value=u.document.createTextNode(t),$(r);return r}let l,o=0,c=0;'function'==typeof t?(o=1,l=t):t&&(c=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)));const u=At.env,p=At.namespace;let d=p,m='html';d=m='svg'===p?'svg':'html','svg'===e&&(m='svg',d='svg');const g='svg'===m?u.document.createElementNS('http://www.w3.org/2000/svg',e):u.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');const 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=C({name:'element',draft:b,isSvgRoot:'svg'===e,namespace:d,fn(e,{mount:u,unmount:p}){function d(e){return J({mount:m,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}const m=r(),g=u.map(({leaf:e})=>e);o&&l(),c&&B(t);const w={attr:{},data:{},text:b.text,styleProp:{},styleVar:{},visible:b.visible||null,handler:b.handler};for(let e=0;e<b.attr.length;e++){const t=b.attr[e];for(const 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++){const t=b.data[e];for(const e in t)w.data[e]=t[e]}for(let e=0;e<b.styleProp.length;e++){const t=b.styleProp[e];for(const 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++){const t=b.styleVar[e];for(const e in t)w.styleVar[e]=t[e]}w.visible&&b.seq.push({type:'visible',value:w.visible});for(const e in w.attr){const t=w.attr[e];K(t)?b.seq.push({type:'attr',field:e,value:t}):F(y,e,t)}for(const e in w.data){const t=w.data[e];K(t)?b.seq.push({type:'data',field:e,value:t}):T(y,e,t)}for(const e in w.styleProp){const t=w.styleProp[e];K(t)?b.seq.push({type:'style',field:e,value:t}):I(y,e,t)}for(const e in w.styleVar){const t=w.styleVar[e];K(t)?b.seq.push({type:'styleVar',field:e,value:t}):S(y,e,t)}for(let e=0;e<w.text.length;e++){const t=w.text[e];if(null!==t.value)if(K(t.value)){b.seq.push({type:'dynamicText',value:t.value,childIndex:t.index});const e=t.value.stateRef,n=Rt;n.plain.includes(e)||n.closure.includes(e)||n.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++){const t=w.handler[e];for(const e in t.map)b.seq.push({type:'handler',for:e,handler:t.map[e],options:t.options,domConfig:t.domConfig})}if(w.visible){const{onMount:e,onState:t}=J({mount:g,state:w.visible,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0}),greedy:1});e.watch(({leaf:e,value:t,hydration:n})=>{const a=e.data,r=a.block;if(n&&(f(t,a.ops.visible),t)){const e=O(r);let t;if(t=e?e.nextSibling:N(r).firstChild,'#text'===t.nodeName){const e=t;t=t.nextSibling,e.remove()}r.value=t,r.parent.visible=1}V(b,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:k.isSvgRoot?r.value:null}),t&&a.needToCallNode&&(a.needToCallNode=0,Ye({target:qt,params:{element:a.block.value,fns:b.node},page:e.spawn,defer:1})),Ye({target:m,params:e,defer:1,page:e.spawn})}),i([t,e]).watch(({leaf:e,value:t,hydration:n})=>{n||h(t,e.data.ops.visible)})}for(let e=0;e<b.seq.length;e++){const t=b.seq[e];switch(t.type){case'visible':break;case'attr':{const{field:e}=t,a='value'===e||'checked'===e||'min'===e||'max'===e,{onMount:r,onState:l}=d(t.value);if(a)i([l,r]).watch(({leaf:t,value:a})=>{F(n(t),e,a)});else{const t=b.opsAmount++;r.watch(({value:a,leaf:r})=>{const l=n(r),o=v({value:a,priority:'props',runOp(t){F(l,e,t)},group:r.ops.group});r.ops.group.ops[t]=o,F(l,e,a)}),l.watch(({value:e,leaf:n})=>{h(e,n.ops.group.ops[t])})}break}case'data':{const{field:e}=t,{onMount:a,onState:r}=d(t.value),l=b.opsAmount++;a.watch(({value:t,leaf:a})=>{const r=n(a),o=v({value:t,priority:'props',runOp(t){T(r,e,t)},group:a.ops.group});a.ops.group.ops[l]=o,T(r,e,t)}),r.watch(({value:e,leaf:t})=>{h(e,t.ops.group.ops[l])});break}case'style':{const e=b.opsAmount++,{field:a}=t,{onMount:r,onState:l}=d(t.value);r.watch(({value:t,leaf:r})=>{const l=n(r),o=v({value:t,priority:'props',runOp(e){I(l,a,e)},group:r.ops.group});r.ops.group.ops[e]=o,I(l,a,t)}),l.watch(({value:t,leaf:n})=>{h(t,n.ops.group.ops[e])});break}case'styleVar':{const{field:e}=t,{onMount:a,onState:r}=d(t.value),l=b.opsAmount++;a.watch(({value:t,leaf:a})=>{const r=n(a),o=v({value:t,priority:'props',runOp(t){S(r,e,t)},group:a.ops.group});a.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=>{a(e,t.value,t.childIndex)});break;case'dynamicText':{const e=b.opsAmount++;s({source:t.value,clock:m,fn:(e,t)=>({value:String(e),leaf:t}),greedy:1}).watch(({value:n,leaf:r})=>{const l=v({value:n,priority:'props',runOp(e){R(o.value,e)},group:r.ops.group});r.ops.group.ops[e]=l;const o=a(r,n,t.childIndex)}),s({source:m,clock:t.value,fn:(e,t)=>({leaf:e,text:t})}).watch(({leaf:t,text:n})=>{h(n,t.ops.group.ops[e])});break}case'handler':{const e=t.handler.graphite.meta.nativeTemplate||null;m.watch(a=>{let r=null;if(e){let t=0,n=a.spawn;for(;!t&&n;)n.template===e?(t=1,r=n):n=n.parent}n(a).addEventListener(t.for,e=>{t.options.prevent&&e.preventDefault(),t.options.stop&&e.stopPropagation(),Ye({target:t.handler,params:e,page:r})},t.domConfig)});break}}}s(g,p).watch(e=>{const{spawn:t}=e;H(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,H(t,t.template.pages);for(const n in t.childSpawns)t.childSpawns[n].forEach(e)}(t),h(0,e.data.ops.visible)}),u.watch(({leaf:e})=>{const t=e.data;if(!b.visible){const n=t.ops.visible,a=t.block;if(e.hydration){f(1,n);const e=O(a);let t;if(t=e?e.nextSibling:N(a).firstChild,'#text'===t.nodeName){const e=t;t=t.nextSibling,e.remove()}a.value=t,a.parent.visible=1}V(b,{parentBlockFragment:a.child.child,leaf:e,node:a.value,svgRoot:k.isSvgRoot?a.value:null}),Ye({target:m,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,Ye({target:qt,params:{element:t.block.value,fns:b.node},page:e.spawn,defer:1})):h(1,n)}})},env:u});W(k)},e.handler=L,e.list=G,e.node=e=>{const t=At.draft;switch(t.type){case'list':case'listItem':case'using':case'route':case'tree':case'treeItem':case'rec':case'recItem':return}t.node.push(e)},e.rec=Q,e.remap=z,e.route=U,e.spec=B,e.text=(e,...t)=>{const n=[e[0]];for(let a=0;a<t.length;a++)n.push(t[a],e[a+1]);B({text:n})},e.tree=({source:e,child:t,fn:n})=>{const a=Q(({state:e})=>{G({source:e,fn({store:e}){const r=e.map(e=>e[t]||[]);n({store:e,child(){a({state:r})}})}})});a({state:e})},e.using=(e,t)=>{let n,a,r,l,o;'function'==typeof t?(n=t,r=j(),l=0):(n=t.fn,r=t.env?t.env:j(),l=t.hydrate,a=t.onComplete,o=t.onRoot);const s=e.namespaceURI,i=e.tagName.toLowerCase(),c={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},u=C({name:'using',draft:c,isSvgRoot:'svg'===i,namespace:'http://www.w3.org/2000/svg'===s?'svg':'foreignobject'===i?'foreignObject':'html',fn(e,{mount:t}){n(),t.watch(({node:e,leaf:t})=>{V(c,{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;const d=g({onComplete:a}),f=q(u,{parentLeaf:Ct||null,mountNode:e,svgRoot:u.isSvgRoot?e:Ct?Ct.svgRoot:null,leafData:{type:'using',draft:c,element:e,block:p},opGroup:y(d),domSubtree:y(d),hydration:l});o&&o({template:u,leaf:f})},e.variant=({source:e,cases:t,key:n})=>{const a='function'==typeof n?n:e=>String(e[n]);let r=0;for(const n in t)'__'!==n?U({source:e,visible:e=>a(e)===n,fn:t[n]}):r=1;if(r){const n=Object.keys(t);U({source:e,visible:e=>!n.includes(a(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+'(',n='',r=0;for(let t in e){let l=e[t];if(null!=l&&(a+=n,a+=K(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 p=ze(n),c=ze(u.links),d=ze(u.owners),f=[],h={};for(let t=0;t<e.length;t++){let a=e[t];a&&(f.push(a),je(a,h))}let m={seq:f,next:ze(o),meta:s,scope:i,family:{type:u.type||'crosslink',links:c,owners:d},reg:h};for(let e=0;e<c.length;e++)oe(c[e]).push(m);for(let e=0;e<d.length;e++)ie(d[e]).push(m);for(let e=0;e<p.length;e++)p[e].next.push(m);return m}function n(e,t){ut={parent:ut,value:e,template:le(e).meta.template||ut&&ut.template};try{return t()}finally{ut=fe(ut)}}function r(e,t){let n=(e,...t)=>n.create(e,t,t);n.graphite=a({meta:mt('event',n,t,e)}),n.create=e=>(Ye(n,e),e),n.watch=ke(dt,n),n.map=e=>{let t,a;ne(e)&&(t=e,a=e.name,e=e.fn);let l=r(me(n,a),t);return vt(n,l,'map',e),l},n.filter=e=>re(e)?(console.error('.filter(fn) is deprecated, use .filterMap instead'),l(n,e)):gt(n,'filter',e.fn,[Ae({fn:Ve})]),n.filterMap=ke(l,n),n.prepend=e=>{let t=r('* → '+n.shortName,{parent:fe(n)}),a=pt();return a&&le(t).seq.push(a.upward),vt(t,n,'prepend',e),((e,t)=>{fe(e)&&fe(e).hooks.event(t)})(n,t),t},yt(n,n);let o=pt();return o&&(le(n).meta.nativeTemplate=o),st(n)}function l(e,t){return gt(e,'filterMap',t,[Fe({fn:Ve}),Te()])}function o(e,t){function n(e,t){p.off(e),de(p).set(e,ot(bt(e,p,'on',1,t)))}let l=Pe(e),i=Pe(e),s=(()=>r({named:'updates'}))(),u=pt();l.after=[{type:'copy',to:i}],u&&u.plain.push(l);let p={subscribers:new Map,updates:s,defaultState:e,stateRef:l,getState(){let e=Xe();return De(e&&e.reg[l.id]?e.reg[l.id]:l)},setState(e){Ye({target:p,params:e,defer:1})},reset(...e){for(let t of e)p.on(t,()=>p.defaultState);return p},on(e,t){if(Array.isArray(e))for(let a of e)n(a,t);else n(e,t);return p},off(e){let t=de(p).get(e);return t&&(t(),de(p).delete(e)),p},map(e,t){let a,n,r;ne(e)&&(a=e,n=e.name,t=e.firstState,e=e.fn);let i=p.getState(),s=pt();s?r=null:void 0!==i&&(r=e(i,t));let u=o(r,{name:me(p,n),config:a,strict:0}),c=bt(p,u,'map',0,e);return se(u).before=[{type:'map',fn:e,from:l}],s&&(s.plain.includes(l)||c.seq.includes(s.loader)||c.seq.unshift(s.loader)),u},[ve]:()=>yt(p,{})};return p.graphite=a({scope:{state:l},node:[Te(),Ne({store:l}),Ce({store:i}),Ne({store:i})],child:s,meta:mt('store',p,t)}),ht&&void 0===e&&ae("current state can't be undefined, use null instead"),u&&(le(p).meta.nativeTemplate=u),p.watch=p.subscribe=(e,t)=>{if(!t||!K(e)){re(e)||ae('watch requires function handler');let t=pt();return t?t.watch.push({of:l,fn:e}):e(p.getState()),dt(p,e)}return re(t)||ae('second argument should be a function'),e.watch(e=>t(p.getState(),e))},Ee(p,[s]),st(p)}function i(...e){let t,n,l;et(e[0],(t,a)=>{l=t,e=a});let i,[s,u,p,c=0]=e;void 0===u&&'source'in s&&('clock'in s&&null==s.clock&&ae('config.clock should be defined'),u=s.clock,p=s.fn,c=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 p&&(c=p,p=null);let d=pt(),f=!!t;t||(Y(s)&&Y(u)?t=o(p?p(De(se(s)),De(se(u))):De(se(s)),{name:n,sid:i}):(t=r(n),d&&le(t).seq.push(d.loader)));let h=f&&K(t)&&le(t).meta.nativeTemplate;if(Y(s))Ee(s,[ct(u,t,{scope:{fn:p,targetTemplate:h},node:[d&&d.loader,!c&&Ie({priority:'sampler'}),Re({store:se(s),to:p?'a':'stack'}),p&&Fe({fn:Oe}),d&&f&&d.upward],meta:{op:'sample',sample:'store'}})]);else{let e=Pe(0),n=Pe(),r=Pe();d&&d.plain.push(e,n,r),st(a({parent:s,node:[Ne({store:n}),Re({from:'value',store:1,target:e})],family:{owners:[s,t,u],links:t},meta:{op:'sample',sample:'source'}})),Ee(s,[ct(u,t,{scope:{fn:p,targetTemplate:h},node:[d&&d.loader,Ne({store:r}),Re({store:e}),Ae({fn:e=>e}),!c&&Ie({priority:'sampler'}),Re({store:n}),Re({store:r,to:'a'}),p&&Fe({fn:Me}),d&&f&&d.upward],meta:{op:'sample',sample:'clock'}})])}return t}function s(e){let n=r(t(e,'merge'));return(e=>{let t;et(e,(a,n)=>{t=a,e=n});let{from:n,to:r,meta:l={op:'forward'}}=e;n&&r||ae('from and to fields should be defined'),t&&(l.config=t),ot(st(a({parent:n,child:r,meta:l,family:{}})))})({from:e,to:n,meta:{op:'merge'}}),n}function u(e,t,a){if(Y(e))return e;if(K(e)){let n,r=fe(e);return Z(e)&&(n=o(t,{parent:r,name:e.shortName,ɔ:a}).on(e,(e,t)=>t)),ee(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]=Y(e)?e:o(e,{name:t})}),n}function p(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 c(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&&c(t)}function h(e,t){if(t.value.active===e)return t.value.pending=e,void('pending'===t.status&&(c(t),d(t).first||p(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,c(a)}p(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,c(a)}p(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,c(a)}p(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:p,env:c}){let d=qt,f=Ft,h={id:++Tt,name:o,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:Ae({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)?Ye({target:t,params:e,defer:1,page:r[n.indexOf(l)],stack:a}):console.error('context drift',{stack:a,node:t}):Ye({target:t,params:e,defer:1,page:null,stack:a})}),0}}),loader:Ae({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=>{Ye({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);Ye(-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)&&Ye({params:e,target:a.node,page:t,defer:1})})}else h.pages.forEach(t=>{Ye({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:p,env:c};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 p(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 c=a?a.spawn:null,d=e.template,f={},h={id:++Ct,fullID:'',reg:f,template:d,parent:c,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,c&&(c.childSpawns[d.id]||(c.childSpawns[d.id]=[]),c.childSpawns[d.id].push(h)),h.fullID=c?`${c.fullID}_${h.id}`:""+h.id,c&&Object.assign(f,c.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;)p(d.watch,y,f);if(c)for(let e in h.childSpawns)e in c.childSpawns||(c.childSpawns[e]=[]),c.childSpawns[e].push(...h.childSpawns[e]);if(m.mount=(t,a=1)=>Ye({target:e.trigger.mount,params:t,defer:a,page:h}),m.unmount=(t,a=1)=>Ye({target:e.trigger.unmount,params:t,defer:a,page:h}),e.api)for(let t in e.api)m[t]=(a,n=1)=>Ye({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 V(e,{parentBlockFragment:t,leaf:a,node:n,svgRoot:r,values:l}){e.childTemplates.forEach(e=>{E({parentBlockFragment:t,leaf:a,node:n,svgRoot:r,values:l,actor:e})})}function E({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),p=t.ops.domSubtree,c=p;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,Ye({target:Nt,params:{element:t.value,fns:i.node},page:d.spawn}))):(t.value.remove(),t.parent.visible=0)},group:p})},needToCallNode:i.node.length>0},c=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:c,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}){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)})),p={type:'route',childTemplates:[],childCount:0,inParentIndex:-1},c=F({name:'route item',isSvgRoot:0,namespace:qt.namespace,env:qt.env,draft:p,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,V(p,{parentBlockFragment:a.block.child.child,leaf:e,node:t})}),o.watch(({leaf:e,visible:t,value:a})=>{e.data.block.child.visible=t,t&&Ye({target:l,params:a,defer:1,page:e.spawn}),Q(e,e=>{let a=e.data;switch(a.type){case'element':h(t,a.ops.visible);break;default:console.log('unsupported type',a.type)}})}),i({source:t,clock:n,greedy:1}).watch(({leaf:e})=>{Q(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,H(t,t.parent.childSpawns[t.template.id]),H(t,t.template.pages)})}});W(c);let{onMount:d,onState:f}=J({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&&(E({parentBlockFragment:r.block.child.child,leaf:e,node:n,actor:c,values:{store:a}}),r.initialized=1)}),i({source:l,clock:o,greedy:1}).watch(({leaf:e})=>{Q(e,e=>{e.api.unmount()});let{spawn:t}=e;t.active=0,H(t,t.parent.childSpawns[t.template.id]),H(t,t.template.pages)})}});W(n)}function Q(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 G(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})=>{V(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,Q(e,e=>{e.api.unmount()})}),{itemUpdater:o}}});return({state:e})=>{a.deferredInit&&a.deferredInit();let{env:t,namespace:n}=qt;W(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}=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})});i({source:n,clock:r,greedy:1}).watch(({leaf:e})=>{e.spawn.active=0,Q(e,e=>{e.api.unmount()})}),o.watch(({state:e,leaf:t})=>{Q(t,t=>{t.api.itemUpdater(e)})}),l.watch(({node:e,leaf:t,state:n})=>{E({parentBlockFragment:t.data.block.child.child,leaf:t,node:e,actor:a,values:{store:n}})})}}))}}function $(e,t){'function'==typeof t&&(K(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:n,source:l,fields:u=[]}=e,p=void 0!==n?'function'==typeof n?n:e=>e[n]:(e,t)=>t,c={type:'list',key:Y(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},d=qt.env,f=qt.namespace;W(F({name:'list',draft:c,isSvgRoot:0,namespace:f,fn(e,{mount:t,unmount:n}){let m=F({name:'list item',state:{id:-1,store:null},draft:c,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 p=o({leaf:null});if(i({source:p,clock:l,greedy:1}).watch(({leaf:e})=>{let t=e.data.block;H(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,Q(e,e=>{e.api.unmount()});let{spawn:r}=e;r.active=0,H(r,r.parent.childSpawns[r.template.id]),H(r,r.template.pages)}),c.itemVisible){let{onMount:e,onState:t}=J({mount:n,state:c.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})=>{p.setState({leaf:a});let n=a.data.block;n.visible=e,n.childInitialized=e,e&&V(c,{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(a,t=>{let a=t.data;switch(a.type){case'element':h(e,a.ops.visible);break;default:console.log('unsupported type',a.type)}}):e&&(n.childInitialized=1,V(c,{parentBlockFragment:n.child,leaf:a,node:t}))})}else n.watch(({node:e,leaf:t})=>{p.setState({leaf:t});let a=t.data.block;a.visible=1,a.childInitialized=1,V(c,{parentBlockFragment:a.child,leaf:t,node:e})});return{itemUpdater:s}},env:d}),v=o([]),g=l.map(e=>e),x=i({source:l,clock:t,fn:(e,{node:t,leaf:a})=>({updates:e,node:t,leaf:a,hydration:a.hydration}),greedy:1}),S=i({source:x,clock:g,fn:({node:e,leaf:t},a)=>({updates:a,node:e,leaf:t,hydration:0}),greedy:1});i({source:v,clock:s([x,S]),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(p),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],p=s[e],c=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:p,index:p,active:1,leafData:{type:'list item',block:d},asyncValue:b({value:l,group:c,onTerminate(e){},onChange(e){f.instance&&f.instance.api.itemUpdater(e)},onInit(e){f.active&&(r||(f.instance=q(m,{values:{id:p,store:e},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:f.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r})))}})},h=u.length;u.push(f);let v=h>0?u[h-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(m,{values:{id:p,store:l},parentLeaf:n,mountNode:t,svgRoot:n.svgRoot,leafData:f.leafData,opGroup:c,domSubtree:n.ops.domSubtree,hydration:r}))}return xt('list update ['+l.shortName+']'),0===u.length&&(o.lastChild=null),u},target:v}),i({source:t,clock:i({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,H(a,a.parent.childSpawns[a.template.id]),H(a,a.template.pages)})},env:d}))}function W(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 H(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:i({source:t,clock:e,fn:a,greedy:1}),onState:i({source:e,clock:t,fn:n,greedy:1})}}let K=e=>(re(e)||ne(e))&&'kind'in e;const X=e=>t=>K(t)&&t.kind===e;let Y=X('store'),Z=X('event'),ee=X('effect'),te=X('domain'),ae=e=>{throw Error(e)},ne=e=>'object'==typeof e&&null!==e,re=e=>'function'==typeof e,le=e=>e.graphite||e,oe=e=>e.family.owners,ie=e=>e.family.links,se=e=>e.stateRef,ue=e=>e.config,pe=e=>e.ɔ,ce=e=>e.value,de=e=>e.subscribers,fe=e=>e.parent,he=(e,t)=>''+e.shortName+t,me=(e,t)=>null==t?he(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 ge=()=>{let e=0;return()=>(++e).toString(36)};let ye=ge(),be=ge(),ke=(e,t)=>e.bind(null,t),we=(e,t,a)=>e.bind(null,t,a);const xe=(e,t,a)=>({id:be(),type:e,data:a,hasRef:t});let Se=0,Ie=({priority:e="barrier"})=>xe('barrier',0,{barrierID:++Se,priority:e}),Re=({from:e="store",store:t,target:a,to:n=(a?'store':'stack')})=>xe('mov','store'===e,{from:e,store:t,to:n,target:a}),Te=()=>xe('check',0,{type:'defined'}),Ce=({store:e})=>xe('check',1,{type:'changed',store:e}),Fe=we(xe,'compute',0),Ae=we(xe,'filter',0),qe=we(xe,'run',0),Ne=({store:e})=>Re({from:'stack',target:e}),Pe=e=>({id:be(),current:e}),De=({current:e})=>e,Me=(e,{fn:t},{a})=>t(e,a),Oe=(e,{fn:t},{a})=>t(a,e),Ve=(e,{fn:t})=>t(e),Ee=(e,t)=>{let a=le(e);for(let e=0;e<t.length;e++){let n=le(t[e]);'domain'!==a.family.type&&(n.family.type='crosslink'),oe(n).push(a),ie(a).push(n)}};const ze=(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(le)};let je=({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)},Be=null;const Le=(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=Le(e.r,t),e.r=e.l,e.l=a,e},Ue=[];let _e=0;for(;_e<5;)Ue.push({first:null,last:null,size:0}),_e+=1;const Qe=()=>{for(let e=0;e<5;e++){let t=Ue[e];if(t.size>0){if(2===e||3===e){t.size-=1;let e=Be.v;return Be=Le(Be.l,Be.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,n,r)=>$e(0,{a:null,b:null,node:a,parent:n,value:r,page:t},e),$e=(e,t,a,n=0)=>{let r=We(a),l=Ue[r],o={v:{idx:e,stack:t,type:a,id:n},l:0,r:0};2===r||3===r?Be=Le(Be,o):(0===l.size?l.first=o:l.last.r=o,l.last=o),l.size+=1},We=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}},He=new Set;let Je=0,Ke=null,Xe=()=>Ke,Ye=(e,t,a)=>{let n=Ke,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++)Ge('pure',n,le(e[a]),r,t[a]);else Ge('pure',n,le(e),r,t);a&&Je||(()=>{let e,t,a,n,r,l,o={alreadyStarted:Je,currentPage:Ke};Je=1;e:for(;n=Qe();){let{idx:o,stack:i,type:s}=n;a=i.node,Ke=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 p=a.seq[n],c=p.data;switch(p.type){case'barrier':{let e=c.barrierID;r&&(e=`${r.fullID}_${e}`);let t=c.priority;if(n!==o||s!==t){He.has(e)||(He.add(e),$e(n,i,t,e));continue e}He.delete(e);break}case'mov':{let e;switch(c.from){case'stack':e=ce(i);break;case'a':e=i.a;break;case'b':e=i.b;break;case'value':e=c.store;break;case'store':l[c.store.id]||(i.page=r=null,l=a.reg),e=De(l[c.store.id])}switch(c.to){case'stack':i.value=e;break;case'a':i.a=e;break;case'b':i.b=e;break;case'store':l[c.target.id].current=e}break}case'check':switch(c.type){case'defined':t=void 0===ce(i);break;case'changed':t=ce(i)===De(l[c.store.id])}break;case'filter':t=!Ze(u,c,i);break;case'run':if(n!==o||'effect'!==s){$e(n,i,'effect');continue e}case'compute':i.value=Ze(u,c,i)}e=u.fail||t}if(!e)for(let e=0;e<a.next.length;e++)Ge('child',r,a.next[e],i,ce(i))}Je=o.alreadyStarted,Ke=o.currentPage})()};const Ze=(e,{fn:t},a)=>{try{return t(ce(a),e.scope,a)}catch(t){console.error(t),e.fail=1}};let et=(e,t)=>{pe(e)&&t(ue(e),pe(e))};const tt=(e,t)=>{let a=e.indexOf(t);-1!==a&&e.splice(a,1)},at=(e,t)=>{tt(e.next,t),tt(oe(e),t),tt(ie(e),t)},nt=(e,t,a)=>{let n;e.next.length=0,e.seq.length=0,e.scope=null;let r=ie(e);for(;n=r.pop();)at(n,e),(t||a&&!e.meta.sample||'crosslink'===n.family.type)&&nt(n,t,a);for(r=oe(e);n=r.pop();)at(n,e),a&&'crosslink'===n.family.type&&nt(n,t,a)},rt=e=>e.clear();let lt=(e,{deep:t}={})=>{let a=0;if(e.ownerSet&&e.ownerSet.delete(e),Y(e))rt(de(e));else if(te(e)){a=1;let t=e.history;rt(t.events),rt(t.effects),rt(t.stores),rt(t.domains)}nt(le(e),!!t,a)},ot=e=>{let t=we(lt,e,void 0);return t.unsubscribe=t,t},st=e=>(ut&&Ee(ce(ut),[e]),e),ut=null,pt=()=>ut&&ut.template,ct=(e,t,{node:n,scope:r,meta:l})=>st(a({node:n,parent:e,child:t,scope:r,meta:l,family:{owners:[e,t],links:t}})),dt=(e,t)=>ot(st(a({scope:{fn:t},node:[qe({fn:Ve})],parent:e,meta:{op:'watch'},family:{owners:e}})));const ft=(e,t)=>(ne(e)&&(ft(ue(e),t),null!=e.name&&(ne(e.name)?ft(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),fe(e)&&(t.parent=fe(e)),'strict'in e&&(t.strict=e.strict),e.named&&(t.named=e.named),ft(pe(e),t)),t);let ht,mt=(e,t,a,n)=>{let r=ft({name:n,config:a},{}),l=ye(),{parent:o=null,sid:i=null,strict:s=1,named:u=null}=r,p=u||r.name||('domain'===e?'':l),c=((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}})(p,o);return t.kind=e,t.id=l,t.sid=i,t.shortName=p,t.parent=o,t.compositeName=c,t.defaultConfig=r,t.thru=e=>e(t),t.getType=()=>c.fullName,ht=s,{unit:e,name:p,sid:i,named:u}};const vt=(e,t,a,n)=>ct(e,t,{scope:{fn:n},node:[Fe({fn:Ve})],meta:{op:a}}),gt=(e,t,a,n)=>{let l;ne(a)&&(l=a,a=a.fn);let o=r(he(e,' →? *'),l);return ct(e,o,{scope:{fn:a},node:n,meta:{op:t}}),o},yt=(e,t)=>(t.subscribe=t=>((e=>{ne(e)||re(e)||ae('expect value to be an object')})(t),e.watch(e=>{t.next&&t.next(e)})),t[ve]=()=>t,t),bt=(e,t,a,n,r)=>{let l=se(t),o=[Re({store:l,to:'a'}),Fe({fn:n?Oe:Me}),Te(),Ce({store:l}),Ne({store:l})],i=pt();if(i&&(o.unshift(i.loader),o.push(i.upward),Y(e))){let t=se(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 ct(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:[qe({fn({fn:e,value:t}){e(t)}})],meta:{op:'fx',fx:'sidechain'}});let wt,xt,St,It=e=>K(e)?e:((...e)=>{let a,n,r;0===e.length&&ae('at least one argument required'),et(e[0],(t,a)=>{r=t,e=a});let l,i,s=e[e.length-1];if(re(s)?(n=e.slice(0,-1),a=s):n=e,1===n.length){let e=n[0];Y(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),p=Pe(u),c=Pe(1);p.type=e?'list':'shape',s&&s.plain.push(p,c);let d=o(u,{name:n||t(a)}),f=[Te(),Re({store:p,to:'a'}),Ae({fn:(e,{key:t},{a})=>e!==a[t]}),Re({store:c,to:'b'}),Fe({fn(e,{clone:t,key:a},n){n.b&&(n.a=t(n.a)),n.a[a]=e}}),Re({from:'a',target:p}),Re({from:'value',store:0,target:c}),Ie({priority:'barrier'}),Re({from:'value',store:1,target:c}),Re({store:p}),r&&Fe({fn:r}),Ce({store:se(d)})],h=p.before=[];return kt(a,(e,t)=>{if(!Y(e))return void(u[t]=i[t]=e);i[t]=e.defaultState,u[t]=e.getState();let a=ct(e,d,{scope:{key:t,clone:l},node:f,meta:{op:'combine'}}),n=se(e);h.push({type:'field',field:t,from:n}),s&&(s.plain.includes(n)||a.seq.unshift(s.loader))}),d.defaultShape=a,p.after=[r?{type:'map',to:se(d),fn:r}:{type:'copy',to:se(d)}],s||(d.defaultState=r?se(d).current=r(u):i),d})(Array.isArray(l),l,r,a)})(e);Ae({fn:(e,{state:t})=>void 0!==e&&e!==De(t)}),Fe({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=p.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=p.document.createTextNode(t),z(r);return r}let l,o=0,u=0;'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)));let p=qt.env,c=qt.namespace,d=c,m='html';d=m='svg'===c?'svg':'html','svg'===e&&(m='svg',d='svg');let g='svg'===m?p.document.createElementNS('http://www.w3.org/2000/svg',e):p.document.createElement(e);'foreignObject'===c?(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:p,unmount:c}){function d(e){return J({mount:m,state:e,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})})}let m=r(),g=p.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];K(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];K(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];K(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];K(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(K(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}=J({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}V(b,{parentBlockFragment:r.child.child,leaf:e,node:r.value,svgRoot:k.isSvgRoot?r.value:null}),t&&n.needToCallNode&&(n.needToCallNode=0,Ye({target:Nt,params:{element:n.block.value,fns:b.node},page:e.spawn,defer:1})),Ye({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(),Ye({target:t.handler,params:e,page:r})},t.domConfig)});break}}}i({source:g,clock:c,greedy:1}).watch(e=>{let{spawn:t}=e;H(t,t.parent.childSpawns[t.template.id]),function e(t){t.active=0,H(t,t.template.pages);for(let a in t.childSpawns)t.childSpawns[a].forEach(e)}(t),h(0,e.data.ops.visible)}),p.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}V(b,{parentBlockFragment:n.child.child,leaf:e,node:n.value,svgRoot:k.isSvgRoot?n.value:null}),Ye({target:m,params:e,defer:1,page:e.spawn}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,Ye({target:Nt,params:{element:t.block.value,fns:b.node},page:e.spawn,defer:1})):h(1,a)}})},env:p});W(k)},e.handler=U,e.list=$,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=G,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=G(({state:e})=>{$({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;'function'==typeof t?(a=t,r=B(),l=0):(a=t.fn,r=t.env?t.env:B(),l=t.hydrate,n=t.onComplete,o=t.onRoot);let i=e.namespaceURI,s=e.tagName.toLowerCase(),u={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},p=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})=>{V(u,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:r}),c={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};c.child.parent=c,c.child.child.parent=c.child;let d=g({onComplete:n}),f=q(p,{parentLeaf:At||null,mountNode:e,svgRoot:p.isSvgRoot?e:At?At.svgRoot:null,leafData:{type:'using',draft:u,element:e,block:c},opGroup:y(d),domSubtree:y(d),hydration:l});o&&o({template:p,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})});
//# sourceMappingURL=forest.umd.js.map
{
"name": "forest",
"version": "0.16.1",
"version": "0.16.2",
"description": "UI engine for web",

@@ -12,3 +12,3 @@ "main": "forest.cjs.js",

"peerDependencies": {
"effector": "^20.15.6"
"effector": "^20.15.9"
},

@@ -15,0 +15,0 @@ "keywords": [

@@ -8,42 +8,72 @@ # forest

```js
import {createStore, createEvent} from 'effector'
import {using, spec, list, h} from 'forest'
import {createStore, createEvent, sample} from 'effector'
import {using, spec, h} from 'forest'
using(document.body, () => {
const addLine = createEvent()
const code = createStore(['let foo = 0']).on(addLine, list => [
...list,
`foo += ${Math.random()}`,
])
const color = createStore('cornsilk').on(addLine, color => {
switch (color) {
case 'cornsilk':
return 'aliceblue'
case 'aliceblue':
return 'cornsilk'
}
})
const {change, submit, state} = formModel()
h('section', () => {
spec({
style: {
backgroundColor: color,
padding: '1em',
},
spec({style: {width: '15em'}})
h('form', () => {
spec({
handler: {
config: {prevent: true},
on: {submit},
},
style: {
display: 'flex',
flexDirection: 'column',
},
})
h('input', {
attr: {placeholder: 'Username'},
handler: {input: change('username')},
})
h('input', {
attr: {type: 'password', placeholder: 'Password'},
handler: {input: change('password')},
})
h('button', {
text: 'Submit',
attr: {
disabled: state.map(values => !(values.username && values.password)),
},
})
})
list(code, ({store}) => {
h('div', {text: store})
h('section', () => {
spec({style: {marginTop: '1em'}})
h('div', {text: 'Reactive form debug:'})
h('pre', {text: state.map(stringify)})
})
})
h('section', {
data: {section: 'controls'},
fn() {
h('button', {
handler: {click: addLine},
text: 'Add line',
style: {padding: '1em'},
})
},
})
})
function formModel() {
const state = createStore({})
const changed = createEvent()
const submit = createEvent()
state.on(changed, (data, {name, value}) => ({...data, [name]: value}))
const change = name => changed.prepend(e => ({name, value: e.target.value}))
sample({
source: state,
clock: submit,
fn: stringify,
}).watch(alert)
return {change, submit, state}
}
function stringify(values) {
return JSON.stringify(values, null, 2)
}
```
[Try it](https://share.effector.dev/e2FuOsag)

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

function e(e,t){e.sibling.right=t,e.nextSibling=t}function t(e){return`-${e.toLowerCase()}`}function n(e){switch(e){case'&':return'&amp;';case'<':return'&lt;';case'>':return'&gt;';case'"':return'&quot;';case"'":return'&#39;';default:return e}}function r(e){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':return'blacklisted';default:return e.replace(m,'')}}function i(e){return String(e).replace(v,'')}function a(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 s(e){var t,n;e.status='active',t=(e=>e.group.activeChilds[e.priority])(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 l(e){I('execQueue');const t=S();let n,r,i=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(S()-t>=10){i=1;break e}const l=!!e.props.first;for(l&&I('props');n=e.props.first;){for(;r=n.activeChilds.props.first;){if(S()-t>=10){i=1,R('props');break e}r.runOp(r.value.pending),r.value.active=r.value.pending,s(r)}a(n,'props')}l&&R('props');const c=!!e.tree.first;for(c&&I('tree');n=e.tree.first;){for(;r=n.activeChilds.tree.first;){if(S()-t>=10){i=1,R('tree');break e}r.runOp(r.value.pending),r.value.active=r.value.pending,s(r)}a(n,'tree')}c&&R('tree');const o=!!e.data.first;for(o&&I('data');n=e.data.first;){for(;r=n.activeChilds.data.first;){if(S()-t>=10){i=1,R('data');break e}r.runOp(r.value.pending),r.value.active=r.value.pending,s(r)}a(n,'data')}o&&R('data')}if(R('execQueue'),i)e.rafID=N(e.execQueue);else if(e.rafID=null,e.onDrain){const t=e.onDrain;e.onDrain=null,t()}}function c({value:e,runOp:t,group:n,priority:r}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:r,group:n,cursor:{prev:null,next:null}}}function o({onComplete:e}){const t={props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null},rafID:null,execQueue(){},onDrain:e};return t.execQueue=l.bind(null,t),t}function u(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 p(e){switch(e.type){case'list':return[...e.current];case'shape':return{...e.current};default:return e.current}}function d(e,{values:t={},parentLeaf:n,mountNode:r,svgRoot:i,leafData:a,opGroup:s,domSubtree:l,hydration:c}){function o(e){if(e.before)for(const t of e.before)switch(t.type){case'map':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current=t.fn(f[n.id].current);break}case'field':{const n=t.from;f[n.id]||(f[n.id]=n),f[e.id].current[t.field]=f[n.id].current;break}case'closure':f[t.of.id]||(f[t.of.id]=t.of)}if(!e.after)return;const t=f[e.id].current;for(const n of e.after){const e=n.to;switch(f[e.id]||(f[e.id]={id:e.id,current:e.current}),n.type){case'copy':f[e.id].current=t;break;case'map':f[e.id].current=n.fn(t)}}}function u(e,t,n){let r;t.stop=1;try{for(;t.i<e.length;)r=e[t.i],t.i++,r.fn(n[r.of.id].current)}catch(e){console.error(e),t.stop=0}}const d=n?n.spawn:null,h=e.template,f={},g={id:++T,fullID:'',reg:f,template:h,parent:d,childSpawns:{},active:1};h.pages.push(g);const m={},v={spawn:g,api:m,draft:e.draft,ops:{group:s,domSubtree:l},svgRoot:i,data:a,parentLeaf:n,hydration:c},b=D;D=v,d&&(d.childSpawns[h.id]||(d.childSpawns[h.id]=[]),d.childSpawns[h.id].push(g)),g.fullID=d?`${d.fullID}_${g.id}`:`${g.id}`,d&&Object.assign(f,d.reg);for(const e of h.closure){let t=e,n=g.parent;e:for(;n;){if(e.id in n.reg){t=n.reg[e.id];break e}n=n.parent}f[e.id]=t}for(const e of h.plain){const t={id:e.id,current:p(e)};f[e.id]=t}for(const e in t){const n=h.nameMap[e].stateRef.id;f[n]={id:n,current:t[e]}}for(const e of h.closure)o(e);for(const e of h.plain)o(e);const y={i:0,stop:0};for(;!y.stop;)u(h.watch,y,f);if(d)for(const e in g.childSpawns)e in d.childSpawns||(d.childSpawns[e]=[]),d.childSpawns[e].push(...g.childSpawns[e]);if(m.mount=(t,n=1)=>effector.launch({target:e.trigger.mount,params:t,defer:n,page:g}),m.unmount=(t,n=1)=>effector.launch({target:e.trigger.unmount,params:t,defer:n,page:g}),e.api)for(const t in e.api)m[t]=(n,r=1)=>effector.launch({target:e.api[t],params:n,defer:r,page:g});return v.spawn.api=m,v.spawn.leaf=v,v.api.mount({node:r,leaf:v}),D=b,v}function h(e){if(!e.visible)return null;switch(e.type){case'FE':case'FT':return e.child;case'FR':return h(e.child.child);case'LF':case'RF':case'FF':return f(e.child);case'FTree':return f(e.child.child);case'FRec':case'FRecItem':return f(e.child.child.child);case'FL':{let t=e.child.lastChild;if(!t)return null;for(;t;){const e=h(t);if(e)return e;t=t.left}return null}default:return null}}function f(e){const t=e.child;for(let e=t.length-1;e>=0;e--){const n=h(t[e]);if(n)return n}return null}function g(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');const m=/[^a-zA-Z0-9\-]/g,v=/[\\<>"]/g,b=/[A-Z]/g,y=/[&<>'"]/g;class w{constructor(){this.child={first:null,last:null},this.sibling={left:null,right:null},this.parent=null,this.tagName='',this.nodeName='',this.namespaceURI='http://www.w3.org/1999/xhtml',this.dataset=Object.create(null),this.style=new x,this.firstChild=null,this.nextSibling=null,this.transform={baseVal:new F},this.isFragment=1,this.attributes=Object.create(null),this.textContent=null,this.__STATIC__=1}cloneNode(){const e=new w;e.tagName=this.tagName,e.nodeName=this.nodeName,e.namespaceURI=this.namespaceURI,Object.assign(e.dataset,this.dataset),Object.assign(e.style.properties,this.style.properties),e.value=this.value;for(const{value:t}of this.transform.baseVal.items){const n=new C;n.value=t,e.transform.baseVal.items.push(n)}return e.isFragment=this.isFragment,Object.assign(e.attributes,this.attributes),e.textContent=this.textContent,e}after(t){this.sibling.right!==t&&(t.parent&&t.remove(),this.parent&&(this.sibling.right?(this.sibling.right.sibling.left=t,e(t,this.sibling.right)):this.parent.child.last=t,e(this,t),t.sibling.left=this,t.parent=this.parent))}prepend(t){t.parent&&t.remove(),this.child.last?(this.child.first.sibling.left=t,e(t,this.child.first)):(this.child.first=t,this.child.last=t),this.child.first=t,this.firstChild=t,t.parent=this}remove(){if(!this.parent)return;const{parent:t}=this;t.child.first===this&&t.child.last===this?(t.firstChild=null,t.child.first=null,t.child.last=null):t.child.first===this?(t.child.first=this.sibling.right,t.firstChild=this.sibling.right,this.sibling.right.sibling.left=null):t.child.last===this?(t.child.last=this.sibling.left,e(this.sibling.left,null)):(this.sibling.right.sibling.left=this.sibling.left,e(this.sibling.left,this.sibling.right)),this.sibling.left=null,e(this,null),this.parent=null}addEventListener(e,t,n){}removeEventListener(e,t,n){}setAttribute(e,t){this.attributes[r(e)]=i(t)}removeAttribute(e){delete this.attributes[r(e)]}replaceWith(t){if(!this.parent)return;const{parent:n}=this;t.parent&&t.remove(),n.child.first===this&&n.child.last===this?(n.firstChild=t,n.child.first=t,n.child.last=t):n.child.first===this?(n.child.first=t,n.firstChild=t,this.sibling.right.sibling.left=t):n.child.last===this?(n.child.last=t,e(this.sibling.left,t)):(this.sibling.right.sibling.left=t,e(this.sibling.left,t)),t.sibling.left=this.sibling.left,e(t,this.sibling.right),t.parent=n,this.sibling.left=null,e(this,null),this.parent=null}createSVGTransform(){return new C}replaceData(e,t,n){'string'==typeof this.textContent&&(this.textContent=`${this.textContent.slice(0,e)}${n}${this.textContent.slice(e+t)}`)}splitText(e){if('string'!=typeof this.textContent)return null;const t=new w;return t.nodeName='#text',t.textContent=this.textContent.slice(e),this.textContent=this.textContent.slice(0,e),this.after(t),t}}class x{constructor(){this.properties=Object.create(null)}setProperty(e,t){this.properties[r(e)]=i(t)}removeProperty(e){delete this.properties[r(e)]}}class F{constructor(){this.items=[]}appendItem(e){this.items.push(e)}}class C{constructor(){this.value=''}setTranslate(e,t){this.value=`translate(${e} ${t})`}setScale(e,t){this.value=`scale(${e} ${t})`}setRotate(e,t,n){this.value=0!==t||0!==n?`rotate(${e} ${t} ${n})`:`rotate(${e})`}setSkewX(e){this.value=`skewX(${e})`}setSkewY(e){this.value=`skewY(${e})`}}const k=['area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'];let I,R,S;'undefined'!=typeof performance&&performance.mark?(I=e=>{performance.mark('☄️ '+e+' start')},R=e=>{try{performance.measure('☄️ '+e,'☄️ '+e+' start')}catch(e){}performance.clearMarks('☄️ '+e+' start'),performance.clearMeasures('☄️ '+e)}):(I=()=>{},R=()=>{}),S='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{const e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();const N='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);let $=0,T=0,E=null,D=null,O=null;const P=effector.createEvent();P.watch(({fns:e,element:t})=>{e.forEach(e=>{e(t)})}),exports.renderStatic=e=>{const a={document:{createTextNode(e){const t=new w;return t.textContent=String(e).replace(y,n),t.nodeName='#text',t},createElement(e){const t=new w;return t.tagName=r(e),t.isFragment=0,t},createElementNS(e,t){switch(e){case'http://www.w3.org/1999/xhtml':case'http://www.w3.org/2000/svg':break;default:e='http://www.w3.org/1999/xhtml'}const n=new w;return n.tagName=r(t),n.namespaceURI=e,n.isFragment=0,n}}},s=a.document.createDocumentFragment();return new Promise(n=>{((e,t)=>{let n,r,i,a,s;'function'==typeof t?(n=t,i=g(),a=0):(n=t.fn,i=t.env?t.env:g(),a=t.hydrate,r=t.onComplete,s=t.onRoot);const l=e.namespaceURI,p=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},m=(({fn:e,state:t={},defer:n=0,name:r="",draft:i,isSvgRoot:a,namespace:s,env:l})=>{const c=O,o=E,u={id:++$,name:r,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],upward:effector.step.filter({fn(e,t,n){if(!n.page)return console.error('context lost',n),0;if(!n.page.active)return 0;const r=[n.page.template],i=[n.page];{let e=n.page.parent;for(;e;)i.push(e),r.push(e.template),e=e.parent}return n.node.next.forEach(t=>{const a=t.meta.nativeTemplate;a?r.includes(a)?effector.launch({target:t,params:e,defer:1,page:i[r.indexOf(a)],stack:n}):console.error('context drift',{stack:n,node:t}):effector.launch({target:t,params:e,defer:1,page:null,stack:n})}),0}}),loader:effector.step.filter({fn(e,t,n){if(n.parent){if(n.page){if(!n.page.active)return 0;if(n.page.template===u)return 1;if(n.page.childSpawns[u.id])n.page.childSpawns[u.id].forEach(t=>{effector.launch({params:e,target:n.node,page:t,defer:1})});else if(t.targetTemplate){const r=[n.page];{let e=n.page.parent;for(;e;)r.push(e),e=e.parent}const i=r.findIndex(e=>t.targetTemplate===e.template);effector.launch(-1===i?{params:e,target:n.node,page:null,defer:1}:{params:e,target:n.node,page:r[i],defer:1})}else u.pages.forEach(t=>{t.fullID.startsWith(n.page.fullID)&&effector.launch({params:e,target:n.node,page:t,defer:1})})}else u.pages.forEach(t=>{effector.launch({params:e,target:n.node,page:t,defer:1})});return 0}return 1}}),parent:o};o&&o.childTemplates.push(u);const p=effector.createNode({meta:{template:u}});E=u;const d=O={template:u,node:p,api:null,trigger:{mount:effector.createEvent(),unmount:effector.createEvent()},draft:i,isSvgRoot:a,namespace:s,env:l};return n?d.deferredInit=()=>{const n=O,r=E;O=d,E=u,d.deferredInit=null;try{effector.withRegion(p,()=>{const n=effector.restore(t);d.api=e(n,d.trigger),u.nameMap=n})}finally{O=n,E=r}}:effector.withRegion(p,()=>{const n=effector.restore(t);d.api=e(n,d.trigger),u.nameMap=n}),O=c,E=o,u.actor=d,d})({name:'using',draft:f,isSvgRoot:'svg'===p,namespace:'http://www.w3.org/2000/svg'===l?'svg':'foreignobject'===p?'foreignObject':'html',fn(e,{mount:t}){n(),t.watch(({node:e,leaf:t})=>{(function(e,{parentBlockFragment:t,leaf:n,node:r,svgRoot:i,values:a}){e.childTemplates.forEach(e=>{(({parentBlockFragment:e,leaf:t,node:n,actor:r,svgRoot:i,values:a})=>{let s;const{draft:l}=r,{queue:o}=t.ops.group,p=u(o),f=t.ops.domSubtree;let g=f;switch(l.type){case'route':{const t={type:'route',parent:{type:'FR',parent:e,child:null,visible:1,index:l.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[l.inParentIndex]=t.parent,s={type:'route',block:t,ops:{},initialized:0};break}case'element':{const t={type:'element',parent:{type:'FE',parent:e,child:null,visible:0,index:l.inParentIndex},child:{type:'EF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:l.stencil.cloneNode()};t.parent.child=t,t.child.parent=t,t.child.child.parent=t.child,e.child[l.inParentIndex]=t.parent,s={type:'element',block:t,ops:{visible:c({value:0,priority:'tree',runOp(e){e?((e=>{const t=(e=>{const t=function e(t){if('fragment'===t.type)switch(t.parent.type){case'EF':case'UF':return null;case'RecF':case'RecItemF':case'RF':{const n=t.parent.parent.parent,r=n.parent;for(let e=n.index-1;e>=0;e--){const t=h(r.child[e]);if(t)return t}return e(r)}case'FF':{const n=t.parent,r=n.parent;for(let e=n.index-1;e>=0;e--){const t=h(r.child[e]);if(t)return t}return e(r)}case'LF':{let n=t.parent.left;for(;n;){const e=h(n);if(e)return e;n=n.left}return e(t.parent.parent)}case'tree':{const n=t.parent.parent,r=n.parent;for(let e=n.index-1;e>=0;e--){const t=h(r.child[e]);if(t)return t}return e(r)}default:return null}if('route'===t.type){const n=t.parent.parent;for(let e=t.parent.index-1;e>=0;e--){const t=n.child[e];if(!t)continue;const r=h(t);if(r)return r}return e(n)}const n=t.parent.parent;for(let e=t.parent.index-1;e>=0;e--){const t=n.child[e];if(!t)continue;const r=h(t);if(r)return r}return e(n)}(e);return t?t.value:null})(e);t?t.after(e.value):(e=>{const t=function e(t){switch(t.type){case'fragment':switch(t.parent.type){case'EF':case'UF':return t.parent.parent;case'tree':return e(t.parent.parent.parent)}return e(t.parent.parent);case'route':default:return e(t.parent.parent)}}(e);return t?t.value:null})(e).prepend(e.value),e.parent.visible=1})(t),s.needToCallNode&&(s.needToCallNode=0,effector.launch({target:P,params:{element:t.value,fns:l.node},page:m.spawn}))):(t.value.remove(),t.parent.visible=0)},group:f})},needToCallNode:l.node.length>0},g=u(o);break}case'list':{const t={type:'list',parent:{type:'FL',parent:e,child:null,visible:1,index:l.inParentIndex},child:[],lastChild:null};t.parent.child=t,e.child[l.inParentIndex]=t.parent,s={type:'list',draft:l,block:t};break}case'tree':{const t={type:'tree',parent:{type:'FTree',parent:e,child:null,visible:1,index:l.inParentIndex},child:{type:'fragment',parent:null,child:[]}};t.parent.child=t,t.child.parent=t,e.child[l.inParentIndex]=t.parent,s={type:'tree',block:t};break}case'using':case'listItem':break;case'rec':{const t={type:'rec',parent:{type:'FRec',parent:e,child:null,visible:1,index:l.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[l.inParentIndex]=t.parent,s={type:'rec',block:t};break}case'recItem':{const t={type:'recItem',parent:{type:'FRecItem',parent:e,child:null,visible:1,index:l.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[l.inParentIndex]=t.parent,s={type:'rec item',block:t};break}default:console.warn(`unexpected draft type ${l.type}`)}const m=d(r,{values:a,parentLeaf:t,mountNode:n,svgRoot:i||t.svgRoot,leafData:s,opGroup:p,domSubtree:g,hydration:t.hydration})})({parentBlockFragment:t,leaf:n,node:r,svgRoot:i,values:a,actor:e})})})(f,{parentBlockFragment:t.data.block.child.child,leaf:t,node:e})})},env:i}),v={type:'using',child:{type:'UF',parent:null,child:{type:'fragment',parent:null,child:[]}},value:e};v.child.parent=v,v.child.child.parent=v.child;const b=o({onComplete:r}),y=d(m,{parentLeaf:D||null,mountNode:e,svgRoot:m.isSvgRoot?e:D?D.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:v},opGroup:u(b),domSubtree:u(b),hydration:a});s&&s({template:m,leaf:y})})(s,{fn:e,env:a,onComplete(){n((e=>{const n=[];(function e(n,a){if(null!==n.textContent&&a.push(n.textContent),n.isFragment){let t=n.firstChild;for(;t;)e(t,a),t=t.sibling.right;return}a.push('<',n.tagName);for(const e in n.attributes)a.push(' ',e,'=','"',i(n.attributes[e]),'"');for(const e in n.dataset)a.push(' ','data-',r(e).replace(b,t),'=','"',i(n.dataset[e]),'"');const s=[];for(const e in n.style.properties)if(e.startsWith('--'))s.push(`${e}: ${n.style.properties[e]}`);else{const t=e.replace(/[A-Z]/,e=>`-${e.toLowerCase()}`);s.push(`${t}: ${n.style.properties[e]}`)}if(s.length>0&&a.push(' ','style','=','"',s.join(';'),'"'),n.transform.baseVal.items.length>0){a.push(' ','transform','=','"');const e=n.transform.baseVal.items.map(({value:e})=>e);a.push(e.join(' '),'"')}if(a.push('>'),k.includes(n.tagName))return;let l=n.firstChild;for(;l;)e(l,a),l=l.sibling.right;a.push('</',n.tagName,'>')})(e,n);const a=n.join('');return function e(t){if('html'===t.tagName)return 1;if(t.isFragment&&null===t.textContent){const n=t.firstChild;if(n&&t.child.last===n)return e(n)}return 0}(e)?`<!DOCTYPE html>${a}`:a})(s))}})})};
function t(t,e){t.sibling.right=e,t.nextSibling=e}function e(t){return"-"+t.toLowerCase()}function i(t){switch(t){case'&':return'&amp;';case'<':return'&lt;';case'>':return'&gt;';case'"':return'&quot;';case"'":return'&#39;';default:return t}}function s(t){switch(t=String(t)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':return'blacklisted';default:return t.replace(n,'')}}function r(t){return String(t).replace(a,'')}Object.defineProperty(exports,'__esModule',{value:1});var l=require('effector-dom');const n=/[^a-zA-Z0-9\-]/g,a=/[\\<>"]/g,h=/[A-Z]/g,o=/[&<>'"]/g;class u{constructor(){this.child={first:null,last:null},this.sibling={left:null,right:null},this.parent=null,this.tagName='',this.nodeName='',this.namespaceURI='http://www.w3.org/1999/xhtml',this.dataset=Object.create(null),this.style=new c,this.value=void 0,this.firstChild=null,this.nextSibling=null,this.transform={baseVal:new g},this.isFragment=1,this.attributes=Object.create(null),this.textContent=null,this.__STATIC__=1}cloneNode(){let t=new u;t.tagName=this.tagName,t.nodeName=this.nodeName,t.namespaceURI=this.namespaceURI,Object.assign(t.dataset,this.dataset),Object.assign(t.style.properties,this.style.properties),t.value=this.value;for(let{value:e}of this.transform.baseVal.items){let i=new f;i.value=e,t.transform.baseVal.items.push(i)}return t.isFragment=this.isFragment,Object.assign(t.attributes,this.attributes),t.textContent=this.textContent,t}after(e){this.sibling.right!==e&&(e.parent&&e.remove(),this.parent&&(this.sibling.right?(this.sibling.right.sibling.left=e,t(e,this.sibling.right)):this.parent.child.last=e,t(this,e),e.sibling.left=this,e.parent=this.parent))}prepend(e){e.parent&&e.remove(),this.child.last?(this.child.first.sibling.left=e,t(e,this.child.first)):(this.child.first=e,this.child.last=e),this.child.first=e,this.firstChild=e,e.parent=this}remove(){if(!this.parent)return;let{parent:e}=this;e.child.first===this&&e.child.last===this?(e.firstChild=null,e.child.first=null,e.child.last=null):e.child.first===this?(e.child.first=this.sibling.right,e.firstChild=this.sibling.right,this.sibling.right.sibling.left=null):e.child.last===this?(e.child.last=this.sibling.left,t(this.sibling.left,null)):(this.sibling.right.sibling.left=this.sibling.left,t(this.sibling.left,this.sibling.right)),this.sibling.left=null,t(this,null),this.parent=null}addEventListener(t,e,i){}removeEventListener(t,e,i){}setAttribute(t,e){this.attributes[s(t)]=r(e)}removeAttribute(t){delete this.attributes[s(t)]}replaceWith(e){if(!this.parent)return;let{parent:i}=this;e.parent&&e.remove(),i.child.first===this&&i.child.last===this?(i.firstChild=e,i.child.first=e,i.child.last=e):i.child.first===this?(i.child.first=e,i.firstChild=e,this.sibling.right.sibling.left=e):i.child.last===this?(i.child.last=e,t(this.sibling.left,e)):(this.sibling.right.sibling.left=e,t(this.sibling.left,e)),e.sibling.left=this.sibling.left,t(e,this.sibling.right),e.parent=i,this.sibling.left=null,t(this,null),this.parent=null}createSVGTransform(){return new f}replaceData(t,e,i){'string'==typeof this.textContent&&(this.textContent=`${this.textContent.slice(0,t)}${i}${this.textContent.slice(t+e)}`)}splitText(t){if('string'!=typeof this.textContent)return null;let e=new u;return e.nodeName='#text',e.textContent=this.textContent.slice(t),this.textContent=this.textContent.slice(0,t),this.after(e),e}}class c{constructor(){this.properties=Object.create(null)}setProperty(t,e){this.properties[s(t)]=r(e)}removeProperty(t){delete this.properties[s(t)]}}class g{constructor(){this.items=[]}appendItem(t){this.items.push(t)}}class f{constructor(){this.value=''}setTranslate(t,e){this.value=`translate(${t} ${e})`}setScale(t,e){this.value=`scale(${t} ${e})`}setRotate(t,e,i){this.value=0!==e||0!==i?`rotate(${t} ${e} ${i})`:`rotate(${t})`}setSkewX(t){this.value=`skewX(${t})`}setSkewY(t){this.value=`skewY(${t})`}}const p=['area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'];exports.renderStatic=t=>{let n={document:{createTextNode(t){let e=new u;return e.textContent=String(t).replace(o,i),e.nodeName='#text',e},createElement(t){let e=new u;return e.tagName=s(t),e.isFragment=0,e},createElementNS(t,e){switch(t){case'http://www.w3.org/1999/xhtml':case'http://www.w3.org/2000/svg':break;default:t='http://www.w3.org/1999/xhtml'}let i=new u;return i.tagName=s(e),i.namespaceURI=t,i.isFragment=0,i}}},a=n.document.createDocumentFragment();return new Promise(i=>{l.using(a,{fn:t,env:n,onComplete(){i((t=>{let i=[];(function t(i,l){if(null!==i.textContent&&l.push(i.textContent),i.isFragment){let e=i.firstChild;for(;e;)t(e,l),e=e.sibling.right;return}l.push('<',i.tagName);for(let t in i.attributes)l.push(' ',t,'=','"',r(i.attributes[t]),'"');for(let t in i.dataset)l.push(' ','data-',s(t).replace(h,e),'=','"',r(i.dataset[t]),'"');let n=[];for(let t in i.style.properties)if(t.startsWith('--'))n.push(`${t}: ${i.style.properties[t]}`);else{let e=t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase());(t.startsWith('webkit')||t.startsWith('moz'))&&(e="-"+e),n.push(`${e}: ${i.style.properties[t]}`)}if(n.length>0&&l.push(' ','style','=','"',n.join(';'),'"'),i.transform.baseVal.items.length>0){l.push(' ','transform','=','"');let t=i.transform.baseVal.items.map(({value:t})=>t);l.push(t.join(' '),'"')}if(l.push('>'),p.includes(i.tagName))return;let a=i.firstChild;for(;a;)t(a,l),a=a.sibling.right;l.push('</',i.tagName,'>')})(t,i);let l=i.join('');return function t(e){if('html'===e.tagName)return 1;if(e.isFragment&&null===e.textContent){let i=e.firstChild;if(i&&e.child.last===i)return t(i)}return 0}(t)?"<!DOCTYPE html>"+l:l})(a))}})})};
//# sourceMappingURL=server.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc