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

forest

Package Overview
Dependencies
Maintainers
3
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.17.3 to 0.18.0

68

forest.cjs.d.ts

@@ -1,4 +0,3 @@

import {Store, Event, Step} from 'effector'
import {Store, Event, Fork} from 'effector'
export type Signal = Step
export type StoreOrData<T> = Store<T> | T

@@ -12,34 +11,18 @@ export type DOMProperty = string | number | null | boolean

>
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type TransformMap = {
translate:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
export type HandlerMap =
| Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
| {
config?: {
passive?: boolean
capture?: boolean
prevent?: boolean
stop?: boolean
}
scale:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
}
rotate: StoreOrData<
| {
angle?: number
x?: number
y?: number
}
| number
>
skewX: StoreOrData<number>
skewY: StoreOrData<number>
}
on: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
}
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type DOMElement = HTMLElement | SVGElement

@@ -79,2 +62,3 @@ export type AttributeStore =

onComplete?: () => void
scope?: Fork
},

@@ -86,3 +70,2 @@ ): void

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -92,9 +75,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
}): void

@@ -123,3 +100,2 @@ export function handler(

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -129,9 +105,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
fn?: () => void

@@ -249,1 +219,3 @@ },

): void
export function block(config: {fn: () => void; env: any}): () => void

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

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

@@ -1,4 +0,3 @@

import {Store, Event, Step} from 'effector'
import {Store, Event, Fork} from 'effector'
export type Signal = Step
export type StoreOrData<T> = Store<T> | T

@@ -12,34 +11,18 @@ export type DOMProperty = string | number | null | boolean

>
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type TransformMap = {
translate:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
export type HandlerMap =
| Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
| {
config?: {
passive?: boolean
capture?: boolean
prevent?: boolean
stop?: boolean
}
scale:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
}
rotate: StoreOrData<
| {
angle?: number
x?: number
y?: number
}
| number
>
skewX: StoreOrData<number>
skewY: StoreOrData<number>
}
on: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
}
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type DOMElement = HTMLElement | SVGElement

@@ -79,2 +62,3 @@ export type AttributeStore =

onComplete?: () => void
scope?: Fork
},

@@ -86,3 +70,2 @@ ): void

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -92,9 +75,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
}): void

@@ -123,3 +100,2 @@ export function handler(

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -129,9 +105,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
fn?: () => void

@@ -249,1 +219,3 @@ },

): void
export function block(config: {fn: () => void; env: any}): () => void

@@ -1,4 +0,3 @@

import {Store, Event, Step} from 'effector'
import {Store, Event, Fork} from 'effector'
export type Signal = Step
export type StoreOrData<T> = Store<T> | T

@@ -12,34 +11,18 @@ export type DOMProperty = string | number | null | boolean

>
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type TransformMap = {
translate:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
export type HandlerMap =
| Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
| {
config?: {
passive?: boolean
capture?: boolean
prevent?: boolean
stop?: boolean
}
scale:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
}
rotate: StoreOrData<
| {
angle?: number
x?: number
y?: number
}
| number
>
skewX: StoreOrData<number>
skewY: StoreOrData<number>
}
on: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
}
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type DOMElement = HTMLElement | SVGElement

@@ -79,2 +62,3 @@ export type AttributeStore =

onComplete?: () => void
scope?: Fork
},

@@ -86,3 +70,2 @@ ): void

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -92,9 +75,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
}): void

@@ -123,3 +100,2 @@ export function handler(

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -129,9 +105,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
fn?: () => void

@@ -249,1 +219,3 @@ },

): void
export function block(config: {fn: () => void; env: any}): () => void

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

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

@@ -1,4 +0,3 @@

import {Store, Event, Step} from 'effector'
import {Store, Event, Fork} from 'effector'
export type Signal = Step
export type StoreOrData<T> = Store<T> | T

@@ -12,34 +11,18 @@ export type DOMProperty = string | number | null | boolean

>
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type TransformMap = {
translate:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
export type HandlerMap =
| Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
| {
config?: {
passive?: boolean
capture?: boolean
prevent?: boolean
stop?: boolean
}
scale:
| Store<{
x?: number
y?: number
}>
| {
x?: StoreOrData<number>
y?: StoreOrData<number>
}
rotate: StoreOrData<
| {
angle?: number
x?: number
y?: number
}
| number
>
skewX: StoreOrData<number>
skewY: StoreOrData<number>
}
on: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
}
export type DOMTag = keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap
export type DOMElement = HTMLElement | SVGElement

@@ -79,2 +62,3 @@ export type AttributeStore =

onComplete?: () => void
scope?: Fork
},

@@ -86,3 +70,2 @@ ): void

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -92,9 +75,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
}): void

@@ -123,3 +100,2 @@ export function handler(

data?: PropertyMap
transform?: Partial<TransformMap>
text?: DOMProperty | AttributeStore | Array<DOMProperty | AttributeStore>

@@ -129,9 +105,3 @@ visible?: Store<boolean>

styleVar?: PropertyMap
focus?: {
focus?: Event<any>
blur?: Event<any>
}
handler?: Partial<
{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
>
handler?: HandlerMap
fn?: () => void

@@ -249,1 +219,3 @@ },

): void
export function block(config: {fn: () => void; env: any}): () => void
{
"name": "forest",
"version": "0.17.3",
"version": "0.18.0",
"description": "UI engine for web",

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

"peerDependencies": {
"effector": "^21.0.3"
"effector": "^21.1.0"
},

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

@@ -1,1 +0,6 @@

export function renderStatic(cb: () => void): Promise<string>
import {Fork} from 'effector'
export function renderStatic(fn: () => void): Promise<string>
export function renderStatic(config: {
scope?: Fork
fn: () => void
}): Promise<string>

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

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('forest');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},createDocumentFragment:()=>new u}},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))}})})};
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('forest');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,a={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},createDocumentFragment:()=>new u}},c=a.document.createDocumentFragment();return'object'==typeof t&&null!==t&&(n=t.scope,t=t.fn),new Promise(i=>{l.using(c,{fn:t,env:a,scope: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})(c))}})})};
//# 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

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