Comparing version 0.20.3 to 0.21.0
@@ -11,2 +11,4 @@ import {Store, Event, Scope} from 'effector' | ||
> | ||
export type ClassListMap = {[cssClass: string]: StoreOrData<boolean>} | ||
export type ClassListArray = Array<Store<string | null> | string> | ||
@@ -66,2 +68,3 @@ export type HandlerMap = | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -98,2 +101,3 @@ }): void | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -100,0 +104,0 @@ fn?: () => 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,l;e.status='active',t=a(e),(l=e).cursor.prev&&(l.cursor.prev.cursor.next=l.cursor.next),l.cursor.next&&(l.cursor.next.cursor.prev=l.cursor.prev),t.last===l&&(t.last=l.cursor.prev),t.first===l&&(t.first=l.cursor.next),l.cursor.prev=null,l.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function l(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function n(l,n){if(n.value.active===l)return n.value.pending=l,void('pending'===n.status&&(t(n),a(n).first||e(n.group,n.priority)));var r,o,i,s;'active'===n.status&&(n.status='pending',a(n).first||((i=n.group).queue[s=n.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=n,(r=a(n)).last?(o.cursor.prev=r.last,r.last.cursor.next=o,r.last=o):r.first=r.last=o),n.value.pending=l,n.group.queue.rafID||(n.group.queue.rafID=ce(n.group.queue.execQueue))}function r(a){ie('execQueue');let l,n,r=ae(),o=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(ae()-r>=1e3){o=1;break e}let i=!!a.props.first;for(i&&ie('props');l=a.props.first;){for(;n=l.activeChilds.props.first;){if(ae()-r>=1e3){o=1,se('props');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(l,'props')}i&&se('props');let s=!!a.tree.first;for(s&&ie('tree');l=a.tree.first;){for(;n=l.activeChilds.tree.first;){if(ae()-r>=1e3){o=1,se('tree');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(l,'tree')}s&&se('tree');let c=!!a.data.first;for(c&&ie('data');l=a.data.first;){for(;n=l.activeChilds.data.first;){if(ae()-r>=1e3){o=1,se('data');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(l,'data')}c&&se('data')}if(se('execQueue'),o)a.rafID=ce(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:l}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:l,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=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 c({value:e,group:t,onInit:a,onChange:l}){let r=o({value:e,group:t,runOp(e){i.status='A',l(e)},priority:'data'}),i={status:'IA',value:r.value,ops:{init:o({value:0,group:t,runOp(e){i.status='A',a(i.value.active)},priority:'data'}),change:r,terminate:o({value:0,group:t,runOp(e){i.status='T'},priority:'data'})}};return n(1,i.ops.init),i}function u(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',n(1,e.ops.terminate);break;case'AA':e.status='AT',n(1,e.ops.terminate),n(e.value.active,e.ops.change);break;case'IA':e.status='T',n(0,e.ops.init)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',n(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',n(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){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function f(e,t){for(let a=0;a<t.length;a++){let{type:l,field:n,value:r}=t[a];ue[l](e,n,r)}}function v(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function m(e,t,a){v(a)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${a}`)}function h(e,t,a){v(a)?delete e.style[t]:e.style[t]=`${a}`}function g(e,t,a){v(a)?delete e.dataset[t]:e.dataset[t]=`${a}`}function b(e,t,a){if(v(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 k({fn:e,state:t={},defer:a=0,name:l="",draft:n,isSvgRoot:r,namespace:o,env:i,isBlock:s=0}){let c=me,u={id:++fe,name:l,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],handlers:de,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.root.activeSpawns.has(a.page.fullID))return console.count('inactive page upward'),0;let l=[a.page.template],n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),l.push(e.template),e=e.parent}return a.node.next.forEach((t=>{let r=t.meta.nativeTemplate;if(r)if(l.includes(r)){let o=n[l.indexOf(r)];effector.launch({target:t,params:e,defer:1,page:o,stack:a,scope:a.scope})}else console.error('context drift',{stack:a,node:t});else effector.launch({target:t,params:e,defer:1,page:a.page,stack:a,scope:a.scope})})),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let t=a.scope?a.scope.graphite.id:null;if(a.page){if(!a.page.root.activeSpawns.has(a.page.fullID))return console.count('inactive page loader'),0;if(a.page.template===u)return 1;if(a.page.root.childSpawns[a.page.fullID][u.id])a.page.root.childSpawns[a.page.fullID][u.id].forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));else{let l=a.page.fullID,n='rec'===a.page.template.name;u.pages.forEach((r=>{if(!t||r.root.scope&&t===r.root.scope.graphite.id)if(r.fullID===l||r.fullID.startsWith(`${l}_`)){let t=1;if(n){let e=a.page.template.id,l=r.parent;for(;l&&l!==a.page;){if(l.template.id===e){t=0;break}l=l.parent}}t&&effector.launch({params:e,target:a.node,page:r,defer:1,scope:a.scope})}else l.startsWith(`${r.fullID}_`)&&effector.launch({params:e,target:a.node,page:a.page,defer:1,scope:a.scope})}))}}else u.pages.forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));return 0}return 1}}),parent:c,node:null,api:null,trigger:{mount:effector.createEvent({named:'mount'})},draft:n,isSvgRoot:r,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};c&&c.childTemplates.push(u);let p=effector.createNode({meta:{template:u}});return u.node=p,me=u,a?u.deferredInit=()=>{let a=me;me=u,u.deferredInit=null;try{effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a}))}finally{me=a}}:effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a})),me=c,u}function I(e,t){let a;switch(a=t?t.getState(e):e.current,e.type){case'list':return[...a];case'shape':return{...a};default:return a}}function x(e,t,a){let l=t;for(;l&&!ge(l,e);)l=l.parent;return l?ge(l,e):a?(a.getState(e),a.reg[e.id]):e}function w(e,t){ge(t,e)||(t.reg[e.id]=x(e,t.parent,t.root.scope))}function S(e,t,a){t in a||(a[t]=[]),a[t].push(...e)}function D(e,{values:t={},parentLeaf:a,mountNode:l,svgRoot:n,leafData:r,opGroup:o,domSubtree:i,hydration:s,root:c}){function u(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t,l=a.from;if(!a.fn&&!l)break;l&&(w(l,f),t=d[l.id].current),d[e.id].current=a.fn?a.fn(t):t;break}case'field':{let t=a.from;w(t,f),d[e.id].current[a.field]=d[t.id].current;break}case'closure':w(a.of,f)}}}function p(e,t,a){let l;t.stop=1;try{for(;t.i<e.length;)l=e[t.i],t.i++,l.fn(a[l.of.id]?a[l.of.id].current:x(l.of,f.parent,f.root.scope).current)}catch(e){console.error(e),t.stop=0}}let d={},f={draft:e.draft,svgRoot:n,data:r,parent:a,hydration:s,mountNode:l,root:c,id:++ve,fullID:'',reg:d,template:e};e.pages.push(f);let v=he;he=f,a&&S([f],e.id,c.childSpawns[a.fullID]),f.fullID=a?`${a.fullID}_${f.id}`:`${f.id}`,c.childSpawns[f.fullID]={},c.activeSpawns.add(f.fullID),c.leafOps[f.fullID]={group:o,domSubtree:i};for(let t=0;t<e.closure.length;t++){let a=e.closure[t],l=a,n=f.parent;e:for(;n;){if(ge(n,a)){l=ge(n,a);break e}n=n.parent}!n&&c.scope&&(c.scope.getState(a),l=c.scope.reg[a.id]),d[a.id]=l}for(let t=0;t<e.plain.length;t++){let a=e.plain[t],l={id:a.id,current:I(a,c.scope)};d[a.id]=l}for(let a in t){let l=e.nameMap[a].stateRef.id;d[l]={id:l,current:t[a]}}e.closure.forEach(u),e.plain.forEach(u);let m={i:0,stop:0};for(;!m.stop;)p(e.watch,m,d);if(a)for(let e in c.childSpawns[f.fullID])S(c.childSpawns[f.fullID][e],e,c.childSpawns[a.fullID]);if(be)be.steps.push({target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope});else{let t;be={parent:be,steps:[{target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope}]};do{for(;t=be.steps.shift();)be={parent:be,steps:[]},effector.launch(t)}while(be=be.parent)}return he=v,f}function C(e){let t=e.parent;for(;'element'!==t.type&&'using'!==t.type;)t=t.parent;return t?t.value:null}function O(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'LF':case'route':case'rec':case'recItem':case'block':case'blockItem':for(let t=e.child.length-1;t>=0;t--){let a=O(e.child[t]);if(a)return a}return null;case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=O(t);if(e)return e;t=t.left}return null}default:return null}}function T(e){switch(e.type){case'using':return null;case'LF':{let t=e.left;for(;t;){let e=O(t);if(e)return e;t=t.left}return T(e.parent)}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 l=O(e);if(l)return l}switch(t.type){case'element':case'using':return null}return T(t)}default:return null}}function q(e){let t=T(e);return t?t.value:null}function R(e,t){if(!e)throw Error(t)}function A(e,t){if(!e)throw Error(`${t}() called outside from using() closure`)}function P(e){if(!me)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(me.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=me.draft.childCount,me.draft.childCount+=1,me.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentTemplate type ${me.draft.type}`)}}function E(e,{parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r}){e.childTemplates.forEach((e=>{N({parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r,actor:e})}))}function N({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:l,svgRoot:n,values:r}){let i;R(ye.includes(e.type),`incorrect parent ${e.type}`);let{draft:c}=l,{queue:u}=t.root.leafOps[t.fullID].group,p=s(u),d=t.root.leafOps[t.fullID].domSubtree,v=d;switch(c.type){case'route':{let t={type:'route',parent:e,child:[],visible:0,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'route',block:t,ops:{},initialized:0,pendingInit:null};break}case'element':{let a;if(l.isBlock){let e,l,n=t;for(;n&&(!l||!e);){n.template.env&&(e=n.template.env);let{draft:t}=n;'element'===t.type&&('svg'===t.tag?l='svg':'foreignObject'===t.tag&&(l='html')),n=n.parent}l||(l='html'),e&&(a='svg'===l?e.document.createElementNS('http://www.w3.org/2000/svg',c.tag):e.document.createElement(c.tag),f(a,c.staticSeq))}else a=c.stencil.cloneNode();let n={type:'element',parent:e,child:[],value:a,visible:0,index:c.inParentIndex};e.child[c.inParentIndex]=n,i={type:'element',block:n,ops:{visible:o({value:0,priority:'tree',runOp(e){if(e){M(n);let e=i;e.needToCallNode&&(e.needToCallNode=0,effector.launch({target:ke,params:{element:n.value,fns:c.node},page:m,scope:t.root.scope})),n.visible=1}else n.value.remove(),n.visible=0},group:d})},needToCallNode:c.node.length>0},v=s(u);break}case'list':{let t={type:'list',parent:e,child:[],lastChild:null,visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'list',draft:c,block:t,records:[],pendingUpdate:null};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,i={type:'block item',block:t};break}default:console.warn(`unexpected draft type ${c.type}`)}let m=D(l,{values:r,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:i,opGroup:p,domSubtree:v,hydration:t.hydration,root:t.root})}function M(e){let t=q(e);t?t.after(e.value):C(e).prepend(e.value),e.visible=1}function B({mount:e,state:t,onMount:a,onState:l}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:l,greedy:1})}}function F(e,t){for(let a in e)t(e[a],a)}function _(e,t){if(!me)return;let a=me.draft;R('element'===a.type,`"handler" extension can be used only with element nodes, got "${a.type}"`),void 0===t&&(t=e,e={});for(let e in t)R(effector.is.unit(t[e]),`handler for "${e}" should be event`);let{passive:l=0,capture:n=0,prevent:r=0,stop:o=0}=e;a.handler.push({options:{prevent:r,stop:o},domConfig:{passive:r?0:l,capture:n},map:t})}function $(e){A(me,'spec');let t=me.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,l=t.childCount;Array.isArray(a)?(t.text.push(...a.map(((e,t)=>({index:t+l,value:e})))),t.childCount+=a.length):(t.text.push({index:l,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[d(t)]=e.style[t];t.style.push(a)}if(e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?_(t.config||{},t.on):_(t)}e.\u0254&&$(e.\u0254)}function V(e,{initCtx:t,runOp:a,hooks:{onMount:l,onState:r}}){let i=e.opsAmount++;l.watch((({value:e,leaf:l})=>{let n=o({value:e,priority:'props',runOp(e){a(e,r)},group:l.root.leafOps[l.fullID].group});l.root.leafOps[l.fullID].group.ops[i]=n;let r=t(e,l)})),r.watch((({value:e,leaf:t})=>{n(e,t.root.leafOps[t.fullID].group.ops[i])}))}function U(e,t,a){e[t].forEach((e=>{F(e,((e,l)=>{switch(t){case'data':case'styleVar':a[t][l]=e;break;case'attr':a.attr['xlink:href'===l?'href':l]=e;break;case'style':l.startsWith('--')?a.styleVar[l.slice(2)]=e:a.style[l]=e}}))}))}function j(e,t,a){let l=e.data.block,n={type:'text',parent:l,visible:0,index:a,value:null};if(l.child[a]=n,e.hydration){let a=T(n);if(a)switch(a.type){case'text':n.value=e.root.env.document.createTextNode(t),a.value.after(n.value);break;case'element':n.value=a.value.nextSibling,y(n.value,t)}else{let e=C(n);n.value=e.firstChild,y(n.value,t)}n.visible=1}else n.value=e.root.env.document.createTextNode(t),M(n);return n}function L(e){let t=e.stateRef,a=me;a.plain.includes(t)||a.closure.includes(t)||a.closure.push(t)}function z(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function G(e,t){let a=e.root.childSpawns[e.fullID];for(let e in a){let l=a[e];for(let e=0;e<l.length;e++)t(l[e])}}function Q(e,t){let a=t=>{let l=t.data;if(e&&'list'===l.type&&l.pendingUpdate){let e=l.pendingUpdate;l.pendingUpdate=null,effector.launch({target:t.template.api.pendingUpdate,params:e,defer:1,page:t,scope:t.root.scope})}if(e&&'route'===l.type)if(l.pendingInit){let e=l.pendingInit.value;l.pendingInit=null,effector.launch({target:t.template.api.pendingInit,params:e,defer:1,page:t,scope:t.root.scope})}else if(!l.block.visible)return;switch(l.type){case'element':n(e,l.ops.visible);break;case'route':case'list':case'list item':G(t,a);break;default:console.log('unsupported type',l.type)}};G(t,a)}function W(e){e.root.activeSpawns.delete(e.fullID),G(e,H)}function Z(e){J(e,e.root.childSpawns[e.parent.fullID][e.template.id]),J(e,e.template.pages)}function H(e){let{data:t,root:a}=e;switch(t.type){case'element':J(e,a.childSpawns[e.parent.fullID][e.template.id]),function e(t){a.activeSpawns.delete(t.fullID);let l=a.childSpawns[t.fullID];delete a.childSpawns[t.fullID],delete a.leafOps[t.fullID],J(t,t.template.pages);for(let t in l)l[t].forEach(e)}(e),n(0,t.ops.visible);break;case'list':{let a=t.records;for(let e=0;e<a.length;e++){let t=a[e];t.instance&&H(t.instance),t.active=0}e.root.activeSpawns.delete(e.fullID),Z(e);break}case'list item':{let a=t.block;J(a,a.parent.child);let l=a.left,n=a.right;l&&(l.right=n,n||a.parent.lastChild!==a||(a.parent.lastChild=l)),n&&(n.left=l),l||n||a.parent.lastChild!==a||(a.parent.lastChild=null),a.left=null,a.right=null,W(e),Z(e);break}case'route':W(e),Z(e);break;case'block':case'block item':case'rec':case'rec item':W(e)}delete a.childSpawns[e.fullID],delete a.leafOps[e.fullID]}function J(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function K(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 l in t){let n=t[l];a[l]=e.map('function'==typeof n?e=>n(e):e=>e[n])}return a}return e.map((e=>e[t]))}function X(e,t){A(me,'list'),'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:l,source:n,fields:r=[]}=e,o=void 0!==l?'function'==typeof l?l:e=>e[l]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},{env:d,namespace:f}=me;P(k({name:'list',draft:i,isSvgRoot:0,namespace:f,fn(e,{mount:t}){let l=k({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:l}){a({store:t,key:e,fields:K(t,r)});let n=effector.createEvent({named:'itemUpdater'});if(t.on(n,((e,t)=>t)),i.itemVisible){let{onMount:e,onState:t}=B({mount:l,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&E(i,{parentBlockFragment:a,leaf:t})})),t.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?Q(e,t):e&&(a.childInitialized=1,E(i,{parentBlockFragment:a,leaf:t}))}))}else l.watch(Se.listItem);return{itemUpdater:n}},env:d}),v=effector.createStore([]),m=n.map((e=>e)),h=effector.sample({source:n,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),g=effector.createEvent(),b=effector.sample({source:h,clock:[m,g],fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});return effector.sample({source:v,clock:[h,b],greedy:1,fn(e,{updates:t,leaf:a,hydration:r}){let d=a.data,f=a;for(;f;){if('route'===f.data.type&&!f.data.block.visible)return void(d.pendingUpdate=t);f=f.parent}let v=d.block;ie('list update ['+n.shortName+']');let m=Array(t.length).fill(0),h=t.map(o),g=[];for(let a=0;a<e.length;a++){let l=e[a],n=h.indexOf(l.key);-1!==n?(g.push(l),m[n]=1,p(t[n],l.asyncValue)):(l.active=0,l.instance&&H(l.instance),u(l.asyncValue))}for(let e=0;e<t.length;e++){if(m[e])continue;let n=t[e],o=h[e],u=s(a.root.leafOps[a.fullID].group.queue),p={type:'LF',parent:v,child:[],childInitialized:0,visible:0,left:null,right:null},d={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:c({value:n,group:u,onChange(e){d.instance&&effector.launch({target:d.instance.template.api.itemUpdater,params:e,defer:1,page:d.instance,scope:d.instance.root.scope})},onInit(e){d.active&&(r||(d.instance=D(l,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:u,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root})))}})},f=g.length;g.push(d);let b=f>0?g[f-1].leafData:null;if(v.child.push(p),b){let e=b.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):v.lastChild=p,e.right=p}else v.lastChild=p;r&&(d.instance=D(l,{values:{id:o,store:n},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:u,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root}))}return se('list update ['+n.shortName+']'),0===g.length&&(v.lastChild=null),d.records=g,g},target:v}),{pendingUpdate:g}},env:d}))}function Y({source:e,visible:t,fn:a}){A(me,'route');let{env:l,namespace:n}=me,r=k({name:'route',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:o}){let i;if(effector.is.store(t))i=effector.combine({value:e,visible:t});else{let a=t;i=e.map((e=>({value:e,visible:a(e)})))}let s=k({name:'route item',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let l=effector.createEvent({named:'itemUpdater'});e.on(l,((e,t)=>t)),a({store:e});let n=effector.sample({source:t,clock:i,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(Se.routeItem),n.watch((({leaf:e,visible:t,value:a})=>{if(e.data.block.visible=t,t&&effector.launch({target:l,params:a,defer:1,page:e,scope:e.root.scope}),t){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return;t=t.parent}}Q(t,e)}))}});P(s);let{onMount:c,onState:u}=B({mount:o,state:i,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})}),p=effector.createEvent(),d=effector.sample({source:o,clock:p,greedy:1,fn:(e,t)=>({leaf:e,value:t,visible:1})});return effector.merge([c,u,d]).watch((({leaf:e,visible:t,value:a})=>{let l=e.data;if(l.block.visible=t,t||l.initialized||!l.pendingInit){if(t&&!l.initialized){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return void(l.pendingInit={value:a});t=t.parent}}t&&!l.initialized&&(N({parentBlockFragment:l.block,leaf:e,actor:s,values:{store:a}}),l.initialized=1)}else l.pendingInit=null})),{pendingInit:p}}});P(r)}function ee(e){let t='function'==typeof e?e:e.fn,a=k({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let l=effector.createEvent({named:'itemUpdater'});return e.on(l,((e,t)=>t)),a.watch(Se.rec),{itemUpdater:l}}});return({store:e,state:t=e})=>{A(me,'(rec instance)');let{env:l,namespace:n}=me;a.deferredInit&&a.deferredInit(),P(k({name:'rec item',isSvgRoot:0,namespace:n,env:l,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:l}){let{onMount:n,onState:r}=B({state:t,mount:l,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});r.watch((({state:e,leaf:t})=>{G(t,(a=>{effector.launch({target:a.template.api.itemUpdater,params:e,defer:1,page:t,scope:t.root.scope})}))})),n.watch((({leaf:e,state:t})=>{N({parentBlockFragment:e.data.block,leaf:e,actor:a,values:{store:t}})}))}}))}}function te(e,t){if(0===t.length)return e;let a=[e[0]];for(let l=0;l<t.length;l++)a.push(t[l],e[l+1]);return a}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let ae;ae='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 le=new Map;const ne=[],re=e=>{let t=le.get(e);t||(t={calls:0,time:0,label:e,childTime:0},le.set(e,t)),t.calls+=1,ne.push({bucket:t,pendingStart:ae()})},oe=e=>{let t=le.get(e),a=ne.pop().pendingStart,l=ae()-a;t.time+=l,ne.length>0&&(ne[ne.length-1].bucket.childTime+=l)};let ie,se;'undefined'!=typeof performance&&performance.mark?(ie=e=>{performance.mark('\u2604\ufe0f '+e+' start'),re(e)},se=e=>{oe(e);try{performance.measure('\u2604\ufe0f '+e,'\u2604\ufe0f '+e+' start')}catch(e){}performance.clearMarks('\u2604\ufe0f '+e+' start'),performance.clearMeasures('\u2604\ufe0f '+e)}):(ie=e=>{re(e)},se=e=>{oe(e)});let ce='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const ue={attr:b,data:g,style:h,styleVar:m},pe=(e,t)=>e.includes(t);let de={storeBase(e,t){e.plain.push(t)},storeOnMap(e,t,a,l){var n,r;a.unshift(e.loader),a.push(e.upward),l&&(pe(e.plain,l)||(pe(e.closure,l)||e.closure.push(l),r={type:'closure',of:l},(n=t).before||(n.before=[]),n.before.push(r)))},storeMap(e,t,a){pe(e.plain,t)||pe(a.seq,e.loader)||a.seq.unshift(e.loader)},storeWatch:(e,t,a)=>(e.watch.push({of:t,fn:a}),1),eventPrepend(e,t){t.seq.push(e.upward)},combineBase(e,t,a){e.plain.push(t,a)},combineField(e,t,a){pe(e.plain,t)||a.seq.unshift(e.loader)},splitBase(e,t){e.plain.push(t)},splitMatchStore(e,t,a){pe(e.plain,t)||a.seq.unshift(e.loader)},sampleSource(e,t,a,l){t.current?pe(e.plain,a)||pe(e.closure,a)||e.closure.push(a):e.plain.push(a),e.plain.push(t),pe(e.plain,l)||e.plain.push(l)},sampleTarget(e,t){t.seq.push(e.loader)},sampleSourceLoader:e=>e.loader,sampleSourceUpward:(e,t)=>t&&e.upward},fe=0,ve=0,me=null,he=null;const ge=(e,t)=>e.reg[t.id];let be=null;const ye=['LF','using','element','recItem','rec','block','blockItem','route'];let ke=effector.createEvent({named:'onMount'});ke.watch((({fns:e,element:t})=>{e.forEach((e=>{e(t)}))}));const Ie=[{type:'attr',field:'value'},{type:'attr',field:'checked'},{type:'attr',field:'min'},{type:'attr',field:'max'}],xe={attr:b,data:g,style:h,styleVar:m},we=e=>e.data.block.value;let Se={using(e){let t=e.data;E(t.draft,{parentBlockFragment:t.block,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.visible=1,E(t,{parentBlockFragment:a.block,leaf:e})},block(e){E(e.draft,{parentBlockFragment:e.data.block,leaf:e})},blockItem(e){N({parentBlockFragment:e.data.block,leaf:e,actor:e.draft.itemOf})},rec(e){E(e.draft,{parentBlockFragment:e.data.block,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,E(t.listDraft,{parentBlockFragment:a,leaf:e})}};exports.block=({fn:e,env:t,namespace:a="html"})=>{let l=k({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(Se.block)}});return()=>{A(me,'(block instance)');let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:l},{env:t,namespace:a}=me;P(k({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(Se.blockItem)}}))}},exports.h=(e,t)=>{let a,r=0,o=0;'function'==typeof t?(r=1,a=t):t&&(o=1,t.fn&&(r=1,a=t.fn),t.\u0254&&('function'==typeof t.\u0254?(r=1,a=t.\u0254):'function'==typeof t.\u0254.fn&&(r=1,a=t.\u0254.fn))),A(me,'h');let i,s=me.env,c=me.namespace,u=c,p='html';u=p='svg'===c?'svg':'html','svg'===e&&(p='svg',u='svg'),me.isBlock||(i='svg'===p?s.document.createElementNS('http://www.w3.org/2000/svg',e):s.document.createElement(e));let d=i,v={type:'element',tag:e,attr:[],data:[],text:[],style:[],styleVar:[],handler:[],stencil:d,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===c?(v.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),u='html'):'svg'===e?(v.attr.push({xmlns:'http://www.w3.org/2000/svg'}),u='svg'):'foreignObject'===e&&(u='foreignObject');let m=k({name:'element',draft:v,isSvgRoot:'svg'===e,namespace:u,fn(e,{mount:i}){let s=effector.createEvent({named:'domElementCreated'});r&&a(),o&&$(t),effector.is.unit(v.visible)&&(v.seq.push({type:'visible',value:v.visible}),L(v.visible));let c={attr:{},data:{},style:{},styleVar:{}};U(v,'attr',c),U(v,'data',c),U(v,'style',c),U(v,'styleVar',c),F(c,((e,t)=>{F(e,((e,a)=>{effector.is.unit(e)?(v.seq.push({type:t,field:a,value:e}),L(e)):v.staticSeq.push({type:t,field:a,value:e})}))})),v.text.forEach((e=>{null!==e.value&&(effector.is.unit(e.value)?(v.seq.push({type:'dynamicText',value:e.value,childIndex:e.index}),L(e.value)):v.seq.push({type:'staticText',value:String(e.value),childIndex:e.index}))})),v.handler.forEach((e=>{F(e.map,((t,a)=>{v.seq.push({type:'handler',for:a,handler:t,options:e.options,domConfig:e.domConfig})}))})),d&&f(d,v.staticSeq),v.seq.forEach((e=>{switch(e.type){case'visible':{let{onMount:t,onState:a}=B({mount:i,state:e.value,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});t.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=q(r);if(e=t?t.nextSibling:C(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}E(v,{parentBlockFragment:r,leaf:e,node:r.value,svgRoot:m.isSvgRoot?r.value:null}),t&&n.needToCallNode&&(n.needToCallNode=0,effector.launch({target:ke,params:{element:n.block.value,fns:v.node},page:e,defer:1,scope:e.root.scope})),effector.launch({target:s,params:e,defer:1,page:e,scope:e.root.scope})})),effector.merge([a,t]).watch((({leaf:e,value:t,hydration:a})=>{a||n(t,e.data.ops.visible)}));break}case'attr':case'data':case'style':case'styleVar':{let t=xe[e.type],a=Ie.some((({type:t,field:a})=>e.type===t&&e.field===a)),l=B({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})});a?effector.merge([l.onState,l.onMount]).watch((({leaf:a,value:l})=>{t(we(a),e.field,l)})):V(v,{initCtx(a,l){let n=we(l);return t(n,e.field,a),n},runOp(a,l){t(l,e.field,a)},hooks:l});break}case'dynamicText':V(v,{initCtx:(t,a)=>j(a,t,e.childIndex),runOp(e,t){y(t.value,e)},hooks:B({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:String(e)}),onState:(e,t)=>({leaf:e,value:String(t)})})});break;case'staticText':s.watch((t=>{j(t,e.value,e.childIndex)}));break;case'handler':{let t=e.handler.graphite.meta.nativeTemplate||null;s.watch((a=>{let l=null;if(t){let e=0,n=a;for(;!e&&n;)n.template===t?(e=1,l=n):n=n.parent}else l=null;we(a).addEventListener(e.for,(t=>{e.options.prevent&&t.preventDefault(),e.options.stop&&t.stopPropagation(),effector.launch({target:e.handler,params:t,page:l,scope:a.root.scope})}),e.domConfig)}));break}}})),i.watch((e=>{let t=e.data;if(!v.visible){let a=t.ops.visible,r=t.block;if(e.hydration){l(1,a);let e,t=q(r);if(e=t?t.nextSibling:C(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}E(v,{parentBlockFragment:r,leaf:e,node:r.value,svgRoot:m.isSvgRoot?r.value:null}),effector.launch({target:s,params:e,defer:1,page:e,scope:e.root.scope}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:ke,params:{element:t.block.value,fns:v.node},page:e,defer:1,scope:e.root.scope})):n(1,a)}}))},env:s});P(m)},exports.handler=_,exports.list=X,exports.node=e=>{A(me,'node');let t=me.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=ee,exports.remap=K,exports.route=Y,exports.spec=$,exports.text=(e,...t)=>{Array.isArray(e)?$({text:te(e,t)}):$({text:e})},exports.tree=({source:e,key:t,child:a,fn:l})=>{let n=ee((({store:e})=>{X({source:e,key:t,fn({store:e}){let t=e.map((e=>e[a]||[]));l({store:e,child(){n({store:t})}})}})}));n({store:e})},exports.using=(e,t)=>{let a,l,n,r,o,c;if('function'==typeof t)a=t,n=z(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:z(),r=t.hydrate,l=t.onComplete,o=t.onRoot,c=t.scope}R(e,'using() first argument is missing');let u={scope:c,env:n,activeSpawns:new Set,childSpawns:{},leafOps:{}},p=e.namespaceURI,d=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},v=k({name:'using',draft:f,isSvgRoot:'svg'===d,namespace:'http://www.w3.org/2000/svg'===p?'svg':'foreignobject'===d?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(Se.using)},env:n}),m={type:'using',child:[],value:e},h=i({onComplete:l}),g=D(v,{parentLeaf:he||null,mountNode:e,svgRoot:v.isSvgRoot?e:he?he.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:m},opGroup:s(h),domSubtree:s(h),hydration:r,root:u});if(o&&o({template:v,leaf:g}),h.onDrain&&!h.rafID){let e=h.onDrain;h.onDrain=null,e()}},exports.val=(e,...t)=>t.every((e=>!effector.is.store(e)))?te(e,t).join(''):effector.combine(t,(t=>te(e,t).join(''))),exports.variant=({source:e,cases:t,key:a})=>{let l;A(me,'variant'),R(effector.is.unit(e),'variant({source}) should be unit'),l='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let n=0;for(let a in t)'__'!==a?Y({source:e,visible:e=>l(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);Y({source:e,visible:e=>!a.includes(l(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,l;e.status='active',t=a(e),(l=e).cursor.prev&&(l.cursor.prev.cursor.next=l.cursor.next),l.cursor.next&&(l.cursor.next.cursor.prev=l.cursor.prev),t.last===l&&(t.last=l.cursor.prev),t.first===l&&(t.first=l.cursor.next),l.cursor.prev=null,l.cursor.next=null}function a(e){return e.group.activeChilds[e.priority]}function l(e,a){a.value.active=a.value.pending=e,'active'!==a.status&&t(a)}function n(l,n){if(n.value.active===l)return n.value.pending=l,void('pending'===n.status&&(t(n),a(n).first||e(n.group,n.priority)));var r,o,s,i;'active'===n.status&&(n.status='pending',a(n).first||((s=n.group).queue[i=n.priority].last?(s.cursor[i].prev=s.queue[i].last,s.queue[i].last.cursor[i].next=s,s.queue[i].last=s):s.queue[i].first=s.queue[i].last=s),o=n,(r=a(n)).last?(o.cursor.prev=r.last,r.last.cursor.next=o,r.last=o):r.first=r.last=o),n.value.pending=l,n.group.queue.rafID||(n.group.queue.rafID=ue(n.group.queue.execQueue))}function r(a){ie('execQueue');let l,n,r=le(),o=0;e:for(;a.props.first||a.tree.first||a.data.first;){if(le()-r>=1e3){o=1;break e}let s=!!a.props.first;for(s&&ie('props');l=a.props.first;){for(;n=l.activeChilds.props.first;){if(le()-r>=1e3){o=1,ce('props');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(l,'props')}s&&ce('props');let i=!!a.tree.first;for(i&&ie('tree');l=a.tree.first;){for(;n=l.activeChilds.tree.first;){if(le()-r>=1e3){o=1,ce('tree');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(l,'tree')}i&&ce('tree');let c=!!a.data.first;for(c&&ie('data');l=a.data.first;){for(;n=l.activeChilds.data.first;){if(le()-r>=1e3){o=1,ce('data');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,t(n)}e(l,'data')}c&&ce('data')}if(ce('execQueue'),o)a.rafID=ue(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:l}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:l,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=r.bind(null,t),t}function i(e){return{ops:[],queue:e,activeChilds:{props:{first:null,last:null},tree:{first:null,last:null},data:{first:null,last:null}},cursor:{props:{prev:null,next:null},tree:{prev:null,next:null},data:{prev:null,next:null}}}}function c({value:e,group:t,onInit:a,onChange:l}){let r=o({value:e,group:t,runOp(e){s.status='A',l(e)},priority:'data'}),s={status:'IA',value:r.value,ops:{init:o({value:0,group:t,runOp(e){s.status='A',a(s.value.active)},priority:'data'}),change:r,terminate:o({value:0,group:t,runOp(e){s.status='T'},priority:'data'})}};return n(1,s.ops.init),s}function u(e){switch(e.status){case'I':case'T':case'AT':return;case'A':e.status='AT',n(1,e.ops.terminate);break;case'AA':e.status='AT',n(1,e.ops.terminate),n(e.value.active,e.ops.change);break;case'IA':e.status='T',n(0,e.ops.init)}}function p(e,t){switch(t.status){case'I':case'T':return;case'A':t.value.active!==e&&(t.status='AA',n(e,t.ops.change));break;case'AA':t.value.active===e?(t.status='A',n(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){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function f(e,t){for(let a=0;a<t.length;a++){let{type:l,field:n,value:r}=t[a];pe[l](e,n,r)}}function m(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function v(e,t,a){m(a)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${a}`)}function h(e,t,a){m(a)?delete e.style[t]:e.style[t]=`${a}`}function g(e,t,a){t&&t.trim().length>0&&(a?e.classList.add(t):(e.classList.remove(t),0===e.classList.length&&e.removeAttribute('class')))}function b(e,t,a){m(a)?delete e.dataset[t]:e.dataset[t]=`${a}`}function y(e,t,a){if(m(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 x({fn:e,state:t={},defer:a=0,name:l="",draft:n,isSvgRoot:r,namespace:o,env:s,isBlock:i=0}){let c=he,u={id:++me,name:l,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],handlers:fe,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.root.activeSpawns.has(a.page.fullID))return console.count('inactive page upward'),0;let l=[a.page.template],n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),l.push(e.template),e=e.parent}return a.node.next.forEach((t=>{let r=t.meta.nativeTemplate;if(r)if(l.includes(r)){let o=n[l.indexOf(r)];effector.launch({target:t,params:e,defer:1,page:o,stack:a,scope:a.scope})}else console.error('context drift',{stack:a,node:t});else effector.launch({target:t,params:e,defer:1,page:a.page,stack:a,scope:a.scope})})),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let t=a.scope?a.scope.graphite.id:null;if(a.page){if(!a.page.root.activeSpawns.has(a.page.fullID))return console.count('inactive page loader'),0;if(a.page.template===u)return 1;if(a.page.root.childSpawns[a.page.fullID][u.id])a.page.root.childSpawns[a.page.fullID][u.id].forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));else{let l=a.page.fullID,n='rec'===a.page.template.name;u.pages.forEach((r=>{if(!t||r.root.scope&&t===r.root.scope.graphite.id)if(r.fullID===l||r.fullID.startsWith(`${l}_`)){let t=1;if(n){let e=a.page.template.id,l=r.parent;for(;l&&l!==a.page;){if(l.template.id===e){t=0;break}l=l.parent}}t&&effector.launch({params:e,target:a.node,page:r,defer:1,scope:a.scope})}else l.startsWith(`${r.fullID}_`)&&effector.launch({params:e,target:a.node,page:a.page,defer:1,scope:a.scope})}))}}else u.pages.forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));return 0}return 1}}),parent:c,node:null,api:null,trigger:{mount:effector.createEvent({named:'mount'})},draft:n,isSvgRoot:r,namespace:o,env:s,isBlock:i||!(!c||!c.isBlock)};c&&c.childTemplates.push(u);let p=effector.createNode({meta:{template:u}});return u.node=p,he=u,a?u.deferredInit=()=>{let a=he;he=u,u.deferredInit=null;try{effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a}))}finally{he=a}}:effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a})),he=c,u}function I(e,t){let a;switch(a=t?t.getState(e):e.current,e.type){case'list':return[...a];case'shape':return{...a};default:return a}}function w(e,t,a){let l=t;for(;l&&!be(l,e);)l=l.parent;return l?be(l,e):a?(a.getState(e),a.reg[e.id]):e}function S(e,t){be(t,e)||(t.reg[e.id]=w(e,t.parent,t.root.scope))}function D(e,t,a){t in a||(a[t]=[]),a[t].push(...e)}function C(e,{values:t={},parentLeaf:a,mountNode:l,svgRoot:n,leafData:r,opGroup:o,domSubtree:s,hydration:i,root:c}){function u(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t,l=a.from;if(!a.fn&&!l)break;l&&(S(l,f),t=d[l.id].current),d[e.id].current=a.fn?a.fn(t):t;break}case'field':{let t=a.from;S(t,f),d[e.id].current[a.field]=d[t.id].current;break}case'closure':S(a.of,f)}}}function p(e,t,a){let l;t.stop=1;try{for(;t.i<e.length;)l=e[t.i],t.i++,l.fn(a[l.of.id]?a[l.of.id].current:w(l.of,f.parent,f.root.scope).current)}catch(e){console.error(e),t.stop=0}}let d={},f={draft:e.draft,svgRoot:n,data:r,parent:a,hydration:i,mountNode:l,root:c,id:++ve,fullID:'',reg:d,template:e};e.pages.push(f);let m=ge;ge=f,a&&D([f],e.id,c.childSpawns[a.fullID]),f.fullID=a?`${a.fullID}_${f.id}`:`${f.id}`,c.childSpawns[f.fullID]={},c.activeSpawns.add(f.fullID),c.leafOps[f.fullID]={group:o,domSubtree:s};for(let t=0;t<e.closure.length;t++){let a=e.closure[t],l=a,n=f.parent;e:for(;n;){if(be(n,a)){l=be(n,a);break e}n=n.parent}!n&&c.scope&&(c.scope.getState(a),l=c.scope.reg[a.id]),d[a.id]=l}for(let t=0;t<e.plain.length;t++){let a=e.plain[t],l={id:a.id,current:I(a,c.scope)};d[a.id]=l}for(let a in t){let l=e.nameMap[a].stateRef.id;d[l]={id:l,current:t[a]}}e.closure.forEach(u),e.plain.forEach(u);let v={i:0,stop:0};for(;!v.stop;)p(e.watch,v,d);if(a)for(let e in c.childSpawns[f.fullID])D(c.childSpawns[f.fullID][e],e,c.childSpawns[a.fullID]);if(ye)ye.steps.push({target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope});else{let t;ye={parent:ye,steps:[{target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope}]};do{for(;t=ye.steps.shift();)ye={parent:ye,steps:[]},effector.launch(t)}while(ye=ye.parent)}return ge=m,f}function O(e){let t=e.parent;for(;'element'!==t.type&&'using'!==t.type;)t=t.parent;return t?t.value:null}function T(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'LF':case'route':case'rec':case'recItem':case'block':case'blockItem':for(let t=e.child.length-1;t>=0;t--){let a=T(e.child[t]);if(a)return a}return null;case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=T(t);if(e)return e;t=t.left}return null}default:return null}}function q(e){switch(e.type){case'using':return null;case'LF':{let t=e.left;for(;t;){let e=T(t);if(e)return e;t=t.left}return q(e.parent)}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 l=T(e);if(l)return l}switch(t.type){case'element':case'using':return null}return q(t)}default:return null}}function R(e){let t=q(e);return t?t.value:null}function A(e,t){if(!e)throw Error(t)}function E(e,t){if(!e)throw Error(`${t}() called outside from using() closure`)}function P(e){if(!he)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(he.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=he.draft.childCount,he.draft.childCount+=1,he.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentTemplate type ${he.draft.type}`)}}function M(e,{parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r}){e.childTemplates.forEach((e=>{N({parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r,actor:e})}))}function N({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:l,svgRoot:n,values:r}){let s;A(ke.includes(e.type),`incorrect parent ${e.type}`);let{draft:c}=l,{queue:u}=t.root.leafOps[t.fullID].group,p=i(u),d=t.root.leafOps[t.fullID].domSubtree,m=d;switch(c.type){case'route':{let t={type:'route',parent:e,child:[],visible:0,index:c.inParentIndex};e.child[c.inParentIndex]=t,s={type:'route',block:t,ops:{},initialized:0,pendingInit:null};break}case'element':{let a;if(l.isBlock){let e,l,n=t;for(;n&&(!l||!e);){n.template.env&&(e=n.template.env);let{draft:t}=n;'element'===t.type&&('svg'===t.tag?l='svg':'foreignObject'===t.tag&&(l='html')),n=n.parent}l||(l='html'),e&&(a='svg'===l?e.document.createElementNS('http://www.w3.org/2000/svg',c.tag):e.document.createElement(c.tag),f(a,c.staticSeq))}else a=c.stencil.cloneNode();let n={type:'element',parent:e,child:[],value:a,visible:0,index:c.inParentIndex};e.child[c.inParentIndex]=n,s={type:'element',block:n,ops:{visible:o({value:0,priority:'tree',runOp(e){if(e){L(n);let e=s;e.needToCallNode&&(e.needToCallNode=0,effector.launch({target:xe,params:{element:n.value,fns:c.node},page:v,scope:t.root.scope})),n.visible=1}else n.value.remove(),n.visible=0},group:d})},needToCallNode:c.node.length>0},m=i(u);break}case'list':{let t={type:'list',parent:e,child:[],lastChild:null,visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,s={type:'list',draft:c,block:t,records:[],pendingUpdate:null};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,s={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,s={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,s={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:[],visible:1,index:c.inParentIndex};e.child[c.inParentIndex]=t,s={type:'block item',block:t};break}default:console.warn(`unexpected draft type ${c.type}`)}let v=C(l,{values:r,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:s,opGroup:p,domSubtree:m,hydration:t.hydration,root:t.root})}function L(e){let t=R(e);t?t.after(e.value):O(e).prepend(e.value),e.visible=1}function B({mount:e,state:t,onMount:a,onState:l}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:l,greedy:1})}}function F(e,t){for(let a in e)t(e[a],a)}function _(e,t){if(!he)return;let a=he.draft;A('element'===a.type,`"handler" extension can be used only with element nodes, got "${a.type}"`),void 0===t&&(t=e,e={});for(let e in t)A(effector.is.unit(t[e]),`handler for "${e}" should be event`);let{passive:l=0,capture:n=0,prevent:r=0,stop:o=0}=e;a.handler.push({options:{prevent:r,stop:o},domConfig:{passive:r?0:l,capture:n},map:t})}function $(e){E(he,'spec');let t=he.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,l=t.childCount;Array.isArray(a)?(t.text.push(...a.map(((e,t)=>({index:t+l,value:e})))),t.childCount+=a.length):(t.text.push({index:l,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[d(t)]=e.style[t];t.style.push(a)}var a,l;if(e.classList&&(a=e.classList,l=e=>t.classList.push(e),Array.isArray(a)?a.forEach((e=>{let t='string'==typeof e?e:e.map((e=>e||'')),a='string'==typeof e?1:e.map((e=>null!==e));l({name:t,enabled:a})})):F(a,((e,t)=>{l({name:t,enabled:e})}))),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?_(t.config||{},t.on):_(t)}e.\u0254&&$(e.\u0254)}function V(e,{initCtx:t,runOp:a,hooks:{onMount:l,onState:r}}){let s=e.opsAmount++;l.watch((({value:e,leaf:l})=>{let n=t(e,l),r=o({value:e,priority:'props',runOp(e){a(e,n)},group:l.root.leafOps[l.fullID].group});l.root.leafOps[l.fullID].group.ops[s]=r})),r.watch((({value:e,leaf:t})=>{n(e,t.root.leafOps[t.fullID].group.ops[s])}))}function U(e,t,a){e[t].forEach((e=>{F(e,((e,l)=>{switch(t){case'data':case'styleVar':a[t][l]=e;break;case'attr':a.attr['xlink:href'===l?'href':l]=e;break;case'style':l.startsWith('--')?a.styleVar[l.slice(2)]=e:a.style[l]=e}}))}))}function j(e,t,a){let l=e.data.block,n={type:'text',parent:l,visible:0,index:a,value:null};if(l.child[a]=n,e.hydration){let a=q(n);if(a)switch(a.type){case'text':n.value=e.root.env.document.createTextNode(t),a.value.after(n.value);break;case'element':n.value=a.value.nextSibling,k(n.value,t)}else{let e=O(n);n.value=e.firstChild,k(n.value,t)}n.visible=1}else n.value=e.root.env.document.createTextNode(t),L(n);return n}function z(e){let t=e.stateRef,a=he;a.plain.includes(t)||a.closure.includes(t)||a.closure.push(t)}function G(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function Q(e,t){let a=e.root.childSpawns[e.fullID];for(let e in a){let l=a[e];for(let e=0;e<l.length;e++)t(l[e])}}function W(e,t){let a=t=>{let l=t.data;if(e&&'list'===l.type&&l.pendingUpdate){let e=l.pendingUpdate;l.pendingUpdate=null,effector.launch({target:t.template.api.pendingUpdate,params:e,defer:1,page:t,scope:t.root.scope})}if(e&&'route'===l.type)if(l.pendingInit){let e=l.pendingInit.value;l.pendingInit=null,effector.launch({target:t.template.api.pendingInit,params:e,defer:1,page:t,scope:t.root.scope})}else if(!l.block.visible)return;switch(l.type){case'element':n(e,l.ops.visible);break;case'route':case'list':case'list item':Q(t,a);break;default:console.log('unsupported type',l.type)}};Q(t,a)}function Z(e){e.root.activeSpawns.delete(e.fullID),Q(e,J)}function H(e){K(e,e.root.childSpawns[e.parent.fullID][e.template.id]),K(e,e.template.pages)}function J(e){let{data:t,root:a}=e;switch(t.type){case'element':K(e,a.childSpawns[e.parent.fullID][e.template.id]),function e(t){a.activeSpawns.delete(t.fullID);let l=a.childSpawns[t.fullID];delete a.childSpawns[t.fullID],delete a.leafOps[t.fullID],K(t,t.template.pages);for(let t in l)l[t].forEach(e)}(e),n(0,t.ops.visible);break;case'list':{let a=t.records;for(let e=0;e<a.length;e++){let t=a[e];t.instance&&J(t.instance),t.active=0}e.root.activeSpawns.delete(e.fullID),H(e);break}case'list item':{let a=t.block;K(a,a.parent.child);let l=a.left,n=a.right;l&&(l.right=n,n||a.parent.lastChild!==a||(a.parent.lastChild=l)),n&&(n.left=l),l||n||a.parent.lastChild!==a||(a.parent.lastChild=null),a.left=null,a.right=null,Z(e),H(e);break}case'route':Z(e),H(e);break;case'block':case'block item':case'rec':case'rec item':Z(e)}delete a.childSpawns[e.fullID],delete a.leafOps[e.fullID]}function K(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function X(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 l in t){let n=t[l];a[l]=e.map('function'==typeof n?e=>n(e):e=>e[n])}return a}return e.map((e=>e[t]))}function Y(e,t){E(he,'list'),'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:l,source:n,fields:r=[]}=e,o=void 0!==l?'function'==typeof l?l:e=>e[l]:(e,t)=>t,s={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},{env:d,namespace:f}=he;P(x({name:'list',draft:s,isSvgRoot:0,namespace:f,fn(e,{mount:t}){let l=x({name:'list item',state:{id:-1,store:null},draft:s,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:l}){a({store:t,key:e,fields:X(t,r)});let n=effector.createEvent({named:'itemUpdater'});if(t.on(n,((e,t)=>t)),s.itemVisible){let{onMount:e,onState:t}=B({mount:l,state:s.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&M(s,{parentBlockFragment:a,leaf:t})})),t.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?W(e,t):e&&(a.childInitialized=1,M(s,{parentBlockFragment:a,leaf:t}))}))}else l.watch(De.listItem);return{itemUpdater:n}},env:d}),m=effector.createStore([]),v=n.map((e=>e)),h=effector.sample({source:n,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),g=effector.createEvent(),b=effector.sample({source:h,clock:[v,g],fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});return effector.sample({source:m,clock:[h,b],greedy:1,fn(e,{updates:t,leaf:a,hydration:r}){let d=a.data,f=a;for(;f;){if('route'===f.data.type&&!f.data.block.visible)return void(d.pendingUpdate=t);f=f.parent}let m=d.block;ie('list update ['+n.shortName+']');let v=Array(t.length).fill(0),h=t.map(o),g=[];for(let a=0;a<e.length;a++){let l=e[a],n=h.indexOf(l.key);-1!==n?(g.push(l),v[n]=1,p(t[n],l.asyncValue)):(l.active=0,l.instance&&J(l.instance),u(l.asyncValue))}for(let e=0;e<t.length;e++){if(v[e])continue;let n=t[e],o=h[e],u=i(a.root.leafOps[a.fullID].group.queue),p={type:'LF',parent:m,child:[],childInitialized:0,visible:0,left:null,right:null},d={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:s},asyncValue:c({value:n,group:u,onChange(e){d.instance&&effector.launch({target:d.instance.template.api.itemUpdater,params:e,defer:1,page:d.instance,scope:d.instance.root.scope})},onInit(e){d.active&&(r||(d.instance=C(l,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:u,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root})))}})},f=g.length;g.push(d);let b=f>0?g[f-1].leafData:null;if(m.child.push(p),b){let e=b.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):m.lastChild=p,e.right=p}else m.lastChild=p;r&&(d.instance=C(l,{values:{id:o,store:n},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:u,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root}))}return ce('list update ['+n.shortName+']'),0===g.length&&(m.lastChild=null),d.records=g,g},target:m}),{pendingUpdate:g}},env:d}))}function ee({source:e,visible:t,fn:a}){E(he,'route');let{env:l,namespace:n}=he,r=x({name:'route',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:o}){let s;if(effector.is.store(t))s=effector.combine({value:e,visible:t});else{let a=t;s=e.map((e=>({value:e,visible:a(e)})))}let i=x({name:'route item',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let l=effector.createEvent({named:'itemUpdater'});e.on(l,((e,t)=>t)),a({store:e});let n=effector.sample({source:t,clock:s,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(De.routeItem),n.watch((({leaf:e,visible:t,value:a})=>{if(e.data.block.visible=t,t&&effector.launch({target:l,params:a,defer:1,page:e,scope:e.root.scope}),t){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return;t=t.parent}}W(t,e)}))}});P(i);let{onMount:c,onState:u}=B({mount:o,state:s,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})}),p=effector.createEvent(),d=effector.sample({source:o,clock:p,greedy:1,fn:(e,t)=>({leaf:e,value:t,visible:1})});return effector.merge([c,u,d]).watch((({leaf:e,visible:t,value:a})=>{let l=e.data;if(l.block.visible=t,t||l.initialized||!l.pendingInit){if(t&&!l.initialized){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return void(l.pendingInit={value:a});t=t.parent}}t&&!l.initialized&&(N({parentBlockFragment:l.block,leaf:e,actor:i,values:{store:a}}),l.initialized=1)}else l.pendingInit=null})),{pendingInit:p}}});P(r)}function te(e){let t='function'==typeof e?e:e.fn,a=x({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let l=effector.createEvent({named:'itemUpdater'});return e.on(l,((e,t)=>t)),a.watch(De.rec),{itemUpdater:l}}});return({store:e,state:t=e})=>{E(he,'(rec instance)');let{env:l,namespace:n}=he;a.deferredInit&&a.deferredInit(),P(x({name:'rec item',isSvgRoot:0,namespace:n,env:l,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:l}){let{onMount:n,onState:r}=B({state:t,mount:l,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});r.watch((({state:e,leaf:t})=>{Q(t,(a=>{effector.launch({target:a.template.api.itemUpdater,params:e,defer:1,page:t,scope:t.root.scope})}))})),n.watch((({leaf:e,state:t})=>{N({parentBlockFragment:e.data.block,leaf:e,actor:a,values:{store:t}})}))}}))}}function ae(e,t){if(0===t.length)return e;let a=[e[0]];for(let l=0;l<t.length;l++)a.push(t[l],e[l+1]);return a}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector');let le;le='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let ne=new Map;const re=[],oe=e=>{let t=ne.get(e);t||(t={calls:0,time:0,label:e,childTime:0},ne.set(e,t)),t.calls+=1,re.push({bucket:t,pendingStart:le()})},se=e=>{let t=ne.get(e),a=re.pop().pendingStart,l=le()-a;t.time+=l,re.length>0&&(re[re.length-1].bucket.childTime+=l)};let ie,ce;'undefined'!=typeof performance&&performance.mark?(ie=e=>{performance.mark('\u2604\ufe0f '+e+' start'),oe(e)},ce=e=>{se(e);try{performance.measure('\u2604\ufe0f '+e,'\u2604\ufe0f '+e+' start')}catch(e){}performance.clearMarks('\u2604\ufe0f '+e+' start'),performance.clearMeasures('\u2604\ufe0f '+e)}):(ie=e=>{oe(e)},ce=e=>{se(e)});let ue='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const pe={attr:y,data:b,style:h,styleVar:v,classList:g},de=(e,t)=>e.includes(t);let fe={storeBase(e,t){e.plain.push(t)},storeOnMap(e,t,a,l){var n,r;a.unshift(e.loader),a.push(e.upward),l&&(de(e.plain,l)||(de(e.closure,l)||e.closure.push(l),r={type:'closure',of:l},(n=t).before||(n.before=[]),n.before.push(r)))},storeMap(e,t,a){de(e.plain,t)||de(a.seq,e.loader)||a.seq.unshift(e.loader)},storeWatch:(e,t,a)=>(e.watch.push({of:t,fn:a}),1),eventPrepend(e,t){t.seq.push(e.upward)},combineBase(e,t,a){e.plain.push(t,a)},combineField(e,t,a){de(e.plain,t)||a.seq.unshift(e.loader)},splitBase(e,t){e.plain.push(t)},splitMatchStore(e,t,a){de(e.plain,t)||a.seq.unshift(e.loader)},sampleSource(e,t,a,l){t.current?de(e.plain,a)||de(e.closure,a)||e.closure.push(a):e.plain.push(a),e.plain.push(t),de(e.plain,l)||e.plain.push(l)},sampleTarget(e,t){t.seq.push(e.loader)},sampleSourceLoader:e=>e.loader,sampleSourceUpward:(e,t)=>t&&e.upward},me=0,ve=0,he=null,ge=null;const be=(e,t)=>e.reg[t.id];let ye=null;const ke=['LF','using','element','recItem','rec','block','blockItem','route'];let xe=effector.createEvent({named:'onMount'});xe.watch((({fns:e,element:t})=>{e.forEach((e=>{e(t)}))}));const Ie=[{type:'attr',field:'value'},{type:'attr',field:'checked'},{type:'attr',field:'min'},{type:'attr',field:'max'}],we={attr:y,data:b,style:h,styleVar:v,classList:g},Se=e=>e.data.block.value;let De={using(e){let t=e.data;M(t.draft,{parentBlockFragment:t.block,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.visible=1,M(t,{parentBlockFragment:a.block,leaf:e})},block(e){M(e.draft,{parentBlockFragment:e.data.block,leaf:e})},blockItem(e){N({parentBlockFragment:e.data.block,leaf:e,actor:e.draft.itemOf})},rec(e){M(e.draft,{parentBlockFragment:e.data.block,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,M(t.listDraft,{parentBlockFragment:a,leaf:e})}};exports.block=({fn:e,env:t,namespace:a="html"})=>{let l=x({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(De.block)}});return()=>{E(he,'(block instance)');let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:l},{env:t,namespace:a}=he;P(x({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(De.blockItem)}}))}},exports.h=(e,t)=>{let a,r=0,o=0;'function'==typeof t?(r=1,a=t):t&&(o=1,t.fn&&(r=1,a=t.fn),t.\u0254&&('function'==typeof t.\u0254?(r=1,a=t.\u0254):'function'==typeof t.\u0254.fn&&(r=1,a=t.\u0254.fn))),E(he,'h');let s,i=he.env,c=he.namespace,u=c,p='html';u=p='svg'===c?'svg':'html','svg'===e&&(p='svg',u='svg'),he.isBlock||(s='svg'===p?i.document.createElementNS('http://www.w3.org/2000/svg',e):i.document.createElement(e));let d=s,m={type:'element',tag:e,attr:[],data:[],text:[],style:[],styleVar:[],classList:[],handler:[],stencil:d,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===c?(m.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),u='html'):'svg'===e?(m.attr.push({xmlns:'http://www.w3.org/2000/svg'}),u='svg'):'foreignObject'===e&&(u='foreignObject');let v=x({name:'element',draft:m,isSvgRoot:'svg'===e,namespace:u,fn(e,{mount:s}){let i=effector.createEvent({named:'domElementCreated'});r&&a(),o&&$(t),effector.is.unit(m.visible)&&(m.seq.push({type:'visible',value:m.visible}),z(m.visible));let c={attr:{},data:{},style:{},styleVar:{}};U(m,'attr',c),U(m,'data',c),U(m,'style',c),U(m,'styleVar',c),F(c,((e,t)=>{F(e,((e,a)=>{effector.is.unit(e)?(m.seq.push({type:t,field:a,value:e}),z(e)):m.staticSeq.push({type:t,field:a,value:e})}))})),m.classList.forEach((e=>{if(effector.is.unit(e.name)||effector.is.unit(e.enabled)){let t=effector.is.unit(e.name)?e.name:effector.createStore(e.name),a=effector.is.unit(e.enabled)?e.enabled:effector.createStore(e.enabled);m.seq.push({type:'classList',field:t,value:a}),z(t),z(a)}else effector.is.unit(e.name)||m.staticSeq.push({type:'classList',field:e.name,value:1})})),m.text.forEach((e=>{null!==e.value&&(effector.is.unit(e.value)?(m.seq.push({type:'dynamicText',value:e.value,childIndex:e.index}),z(e.value)):m.seq.push({type:'staticText',value:String(e.value),childIndex:e.index}))})),m.handler.forEach((e=>{F(e.map,((t,a)=>{m.seq.push({type:'handler',for:a,handler:t,options:e.options,domConfig:e.domConfig})}))})),d&&f(d,m.staticSeq),m.seq.forEach((e=>{switch(e.type){case'visible':{let{onMount:t,onState:a}=B({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});t.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:O(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}M(m,{parentBlockFragment:r,leaf:e,node:r.value,svgRoot:v.isSvgRoot?r.value:null}),t&&n.needToCallNode&&(n.needToCallNode=0,effector.launch({target:xe,params:{element:n.block.value,fns:m.node},page:e,defer:1,scope:e.root.scope})),effector.launch({target:i,params:e,defer:1,page:e,scope:e.root.scope})})),effector.merge([a,t]).watch((({leaf:e,value:t,hydration:a})=>{a||n(t,e.data.ops.visible)}));break}case'attr':case'data':case'style':case'styleVar':{let t=we[e.type],a=Ie.some((({type:t,field:a})=>e.type===t&&e.field===a)),l=B({mount:i,state:e.value,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})});a?effector.merge([l.onState,l.onMount]).watch((({leaf:a,value:l})=>{t(Se(a),e.field,l)})):V(m,{initCtx(a,l){let n=Se(l);return t(n,e.field,a),n},runOp(a,l){t(l,e.field,a)},hooks:l});break}case'classList':{let t=we.classList,a=effector.createStore({prev:'',curr:e.field.getState()}).on(e.field,(({curr:e},t)=>({prev:e,curr:t}))),l=B({mount:i,state:effector.combine({name:a,enabled:e.value}),onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})});V(m,{initCtx(e,a){let l=Se(a);return t(l,e.name.curr,e.enabled),l},runOp(e,a){e.name.prev!==e.name.curr&&t(a,e.name.prev,0),t(a,e.name.curr,e.enabled)},hooks:l});break}case'dynamicText':V(m,{initCtx:(t,a)=>j(a,t,e.childIndex),runOp(e,t){k(t.value,e)},hooks:B({mount:i,state:e.value,onMount:(e,t)=>({leaf:t,value:String(e)}),onState:(e,t)=>({leaf:e,value:String(t)})})});break;case'staticText':i.watch((t=>{j(t,e.value,e.childIndex)}));break;case'handler':{let t=e.handler.graphite.meta.nativeTemplate||null;i.watch((a=>{let l=null;if(t){let e=0,n=a;for(;!e&&n;)n.template===t?(e=1,l=n):n=n.parent}else l=null;Se(a).addEventListener(e.for,(t=>{e.options.prevent&&t.preventDefault(),e.options.stop&&t.stopPropagation(),effector.launch({target:e.handler,params:t,page:l,scope:a.root.scope})}),e.domConfig)}));break}}})),s.watch((e=>{let t=e.data;if(!m.visible){let a=t.ops.visible,r=t.block;if(e.hydration){l(1,a);let e,t=R(r);if(e=t?t.nextSibling:O(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}M(m,{parentBlockFragment:r,leaf:e,node:r.value,svgRoot:v.isSvgRoot?r.value:null}),effector.launch({target:i,params:e,defer:1,page:e,scope:e.root.scope}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:xe,params:{element:t.block.value,fns:m.node},page:e,defer:1,scope:e.root.scope})):n(1,a)}}))},env:i});P(v)},exports.handler=_,exports.list=Y,exports.node=e=>{E(he,'node');let t=he.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=te,exports.remap=X,exports.route=ee,exports.spec=$,exports.text=(e,...t)=>{Array.isArray(e)?$({text:ae(e,t)}):$({text:e})},exports.tree=({source:e,key:t,child:a,fn:l})=>{let n=te((({store:e})=>{Y({source:e,key:t,fn({store:e}){let t=e.map((e=>e[a]||[]));l({store:e,child(){n({store:t})}})}})}));n({store:e})},exports.using=(e,t)=>{let a,l,n,r,o,c;if('function'==typeof t)a=t,n=G(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:G(),r=t.hydrate,l=t.onComplete,o=t.onRoot,c=t.scope}A(e,'using() first argument is missing');let u={scope:c,env:n,activeSpawns:new Set,childSpawns:{},leafOps:{}},p=e.namespaceURI,d=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},m=x({name:'using',draft:f,isSvgRoot:'svg'===d,namespace:'http://www.w3.org/2000/svg'===p?'svg':'foreignobject'===d?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(De.using)},env:n}),v={type:'using',child:[],value:e},h=s({onComplete:l}),g=C(m,{parentLeaf:ge||null,mountNode:e,svgRoot:m.isSvgRoot?e:ge?ge.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:v},opGroup:i(h),domSubtree:i(h),hydration:r,root:u});if(o&&o({template:m,leaf:g}),h.onDrain&&!h.rafID){let e=h.onDrain;h.onDrain=null,e()}},exports.val=(e,...t)=>t.every((e=>!effector.is.store(e)))?ae(e,t).join(''):effector.combine(t,(t=>ae(e,t).join(''))),exports.variant=({source:e,cases:t,key:a})=>{let l;E(he,'variant'),A(effector.is.unit(e),'variant({source}) should be unit'),l='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let n=0;for(let a in t)'__'!==a?ee({source:e,visible:e=>l(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);ee({source:e,visible:e=>!a.includes(l(e)),fn:t.__})}}; | ||
//# sourceMappingURL=forest.cjs.js.map |
@@ -11,2 +11,4 @@ import {Store, Event, Scope} from 'effector' | ||
> | ||
export type ClassListMap = {[cssClass: string]: StoreOrData<boolean>} | ||
export type ClassListArray = Array<Store<string | null> | string> | ||
@@ -66,2 +68,3 @@ export type HandlerMap = | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -98,2 +101,3 @@ }): void | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -100,0 +104,0 @@ fn?: () => void |
@@ -11,2 +11,4 @@ import {Store, Event, Scope} from 'effector' | ||
> | ||
export type ClassListMap = {[cssClass: string]: StoreOrData<boolean>} | ||
export type ClassListArray = Array<Store<string | null> | string> | ||
@@ -66,2 +68,3 @@ export type HandlerMap = | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -98,2 +101,3 @@ }): void | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -100,0 +104,0 @@ fn?: () => 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='undefined'!=typeof globalThis?globalThis: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})(l(e),e)}function l(e){return e.group.activeChilds[e.priority]}function n(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&a(t)}function r(e,n){if(n.value.active===e)return n.value.pending=e,void('pending'===n.status&&(a(n),l(n).first||t(n.group,n.priority)));'active'===n.status&&(n.status='pending',l(n).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})(n.group,n.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(l(n),n)),n.value.pending=e,n.group.queue.rafID||(n.group.queue.rafID=de(n.group.queue.execQueue))}function o(e){ue('execQueue');let l,n,r=ne(),o=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(ne()-r>=re){o=1;break e}let i=!!e.props.first;for(i&&ue('props');l=e.props.first;){for(;n=l.activeChilds.props.first;){if(ne()-r>=re){o=1,pe('props');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,a(n)}t(l,'props')}i&&pe('props');let s=!!e.tree.first;for(s&&ue('tree');l=e.tree.first;){for(;n=l.activeChilds.tree.first;){if(ne()-r>=re){o=1,pe('tree');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,a(n)}t(l,'tree')}s&&pe('tree');let c=!!e.data.first;for(c&&ue('data');l=e.data.first;){for(;n=l.activeChilds.data.first;){if(ne()-r>=re){o=1,pe('data');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,a(n)}t(l,'data')}c&&pe('data')}if(pe('execQueue'),o)e.rafID=de(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:l}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:l,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 c(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:l}){let n=i({value:e,group:t,runOp(e){o.status='A',l(e)},priority:'data'}),o={status:'IA',value:n.value,ops:{init:i({value:0,group:t,runOp(e){o.status='A',a(o.value.active)},priority:'data'}),change:n,terminate:i({value:0,group:t,runOp(e){o.status='T'},priority:'data'})}};return r(1,o.ops.init),o}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)}}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){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function m(e,t){for(let a=0;a<t.length;a++){let{type:l,field:n,value:r}=t[a];fe[l](e,n,r)}}function h(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function v(e,t,a){h(a)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${a}`)}function g(e,t,a){h(a)?delete e.style[t]:e.style[t]=`${a}`}function b(e,t,a){h(a)?delete e.dataset[t]:e.dataset[t]=`${a}`}function y(e,t,a){if(h(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 I({fn:e,state:t={},defer:a=0,name:l="",draft:n,isSvgRoot:r,namespace:o,env:i,isBlock:s=0}){let c=be,u={id:++ve,name:l,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],handlers:he,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.root.activeSpawns.has(a.page.fullID))return console.count('inactive page upward'),0;let l=[a.page.template],n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),l.push(e.template),e=e.parent}return a.node.next.forEach((t=>{let r=t.meta.nativeTemplate;if(r)if(l.includes(r)){let o=n[l.indexOf(r)];effector.launch({target:t,params:e,defer:1,page:o,stack:a,scope:a.scope})}else console.error('context drift',{stack:a,node:t});else effector.launch({target:t,params:e,defer:1,page:a.page,stack:a,scope:a.scope})})),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let t=a.scope?a.scope.graphite.id:null;if(a.page){if(!a.page.root.activeSpawns.has(a.page.fullID))return console.count('inactive page loader'),0;if(a.page.template===u)return 1;if(a.page.root.childSpawns[a.page.fullID][u.id])a.page.root.childSpawns[a.page.fullID][u.id].forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));else{let l=a.page.fullID,n='rec'===a.page.template.name;u.pages.forEach((r=>{if(!t||r.root.scope&&t===r.root.scope.graphite.id)if(r.fullID===l||r.fullID.startsWith(`${l}_`)){let t=1;if(n){let e=a.page.template.id,l=r.parent;for(;l&&l!==a.page;){if(l.template.id===e){t=0;break}l=l.parent}}t&&effector.launch({params:e,target:a.node,page:r,defer:1,scope:a.scope})}else l.startsWith(`${r.fullID}_`)&&effector.launch({params:e,target:a.node,page:a.page,defer:1,scope:a.scope})}))}}else u.pages.forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));return 0}return 1}}),parent:c,node:null,api:null,trigger:{mount:effector.createEvent({named:'mount'})},draft:n,isSvgRoot:r,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};c&&c.childTemplates.push(u);let p=effector.createNode({meta:{template:u}});return u.node=p,be=u,a?u.deferredInit=()=>{let a=be;be=u,u.deferredInit=null;try{effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a}))}finally{be=a}}:effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a})),be=c,u}function x(e,t){let a;switch(a=t?t.getState(e):e.current,e.type){case'list':return[...a];case'shape':return{...a};default:return a}}function w(e,t,a){let l=t;for(;l&&!ke(l,e);)l=l.parent;return l?ke(l,e):a?(a.getState(e),a.reg[e.id]):e}function S(e,t,a){return w(e,t,a).current}function D(e,t){ke(t,e)||(t.reg[e.id]=w(e,t.parent,t.root.scope))}function C(e,t,a){t in a||(a[t]=[]),a[t].push(...e)}function T(e,{values:t={},parentLeaf:a,mountNode:l,svgRoot:n,leafData:r,opGroup:o,domSubtree:i,hydration:s,root:c}){function u(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t,l=a.from;if(!a.fn&&!l)break;l&&(D(l,f),t=d[l.id].current),d[e.id].current=a.fn?a.fn(t):t;break}case'field':{let t=a.from;D(t,f),d[e.id].current[a.field]=d[t.id].current;break}case'closure':D(a.of,f)}}}function p(e,t,a){let l;t.stop=1;try{for(;t.i<e.length;)l=e[t.i],t.i++,l.fn(a[l.of.id]?a[l.of.id].current:S(l.of,f.parent,f.root.scope))}catch(e){console.error(e),t.stop=0}}let d={},f={draft:e.draft,svgRoot:n,data:r,parent:a,hydration:s,mountNode:l,root:c,id:++ge,fullID:'',reg:d,template:e};e.pages.push(f);let m=ye;ye=f,a&&C([f],e.id,c.childSpawns[a.fullID]),f.fullID=a?`${a.fullID}_${f.id}`:`${f.id}`,c.childSpawns[f.fullID]={},c.activeSpawns.add(f.fullID),c.leafOps[f.fullID]={group:o,domSubtree:i};for(let t=0;t<e.closure.length;t++){let a=e.closure[t],l=a,n=f.parent;e:for(;n;){if(ke(n,a)){l=ke(n,a);break e}n=n.parent}!n&&c.scope&&(c.scope.getState(a),l=c.scope.reg[a.id]),d[a.id]=l}for(let t=0;t<e.plain.length;t++){let a=e.plain[t],l={id:a.id,current:x(a,c.scope)};d[a.id]=l}for(let a in t){let l=e.nameMap[a].stateRef.id;d[l]={id:l,current:t[a]}}e.closure.forEach(u),e.plain.forEach(u);let h={i:0,stop:0};for(;!h.stop;)p(e.watch,h,d);if(a)for(let e in c.childSpawns[f.fullID])C(c.childSpawns[f.fullID][e],e,c.childSpawns[a.fullID]);if(Ie)Ie.steps.push({target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope});else{let t;Ie={parent:Ie,steps:[{target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope}]};do{for(;t=Ie.steps.shift();)Ie={parent:Ie,steps:[]},effector.launch(t)}while(Ie=Ie.parent)}return ye=m,f}function O(e){let t=e.parent;for(;'element'!==t.type&&'using'!==t.type;)t=t.parent;return t?t.value:null}function q(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'LF':case'route':case'rec':case'recItem':case'block':case'blockItem':for(let t=e.child.length-1;t>=0;t--){let a=q(e.child[t]);if(a)return a}return null;case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=q(t);if(e)return e;t=t.left}return null}default:return null}}function R(e){switch(e.type){case'using':return null;case'LF':{let t=e.left;for(;t;){let e=q(t);if(e)return e;t=t.left}return R(e.parent)}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 l=q(e);if(l)return l}switch(t.type){case'element':case'using':return null}return R(t)}default:return null}}function A(e){let t=R(e);return t?t.value:null}function P(e,t){if(!e)throw Error(t)}function E(e,t){if(!e)throw Error(`${t}() called outside from using() closure`)}function N(e){if(!be)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(be.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=be.draft.childCount,be.draft.childCount+=1,be.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentTemplate type ${be.draft.type}`)}}function M(e,{parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r}){e.childTemplates.forEach((e=>{B({parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r,actor:e})}))}function B({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:l,svgRoot:n,values:r}){let o;P(xe.includes(e.type),`incorrect parent ${e.type}`);let{draft:s}=l,{queue:u}=t.root.leafOps[t.fullID].group,p=c(u),d=t.root.leafOps[t.fullID].domSubtree,f=d;switch(s.type){case'route':{let t={type:'route',parent:e,child:[],visible:0,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'route',block:t,ops:{},initialized:0,pendingInit:null};break}case'element':{let a;if(l.isBlock){let e,l,n=t;for(;n&&(!l||!e);){n.template.env&&(e=n.template.env);let{draft:t}=n;'element'===t.type&&('svg'===t.tag?l='svg':'foreignObject'===t.tag&&(l='html')),n=n.parent}l||(l='html'),e&&(a='svg'===l?e.document.createElementNS('http://www.w3.org/2000/svg',s.tag):e.document.createElement(s.tag),m(a,s.staticSeq))}else a=s.stencil.cloneNode();let n={type:'element',parent:e,child:[],value:a,visible:0,index:s.inParentIndex};e.child[s.inParentIndex]=n,o={type:'element',block:n,ops:{visible:i({value:0,priority:'tree',runOp(e){if(e){F(n);let e=o;e.needToCallNode&&(e.needToCallNode=0,effector.launch({target:we,params:{element:n.value,fns:s.node},page:h,scope:t.root.scope})),n.visible=1}else n.value.remove(),n.visible=0},group:d})},needToCallNode:s.node.length>0},f=c(u);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,records:[],pendingUpdate:null};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'block item',block:t};break}default:console.warn(`unexpected draft type ${s.type}`)}let h=T(l,{values:r,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:o,opGroup:p,domSubtree:f,hydration:t.hydration,root:t.root})}function F(e){let t=A(e);t?t.after(e.value):O(e).prepend(e.value),e.visible=1}function _({mount:e,state:t,onMount:a,onState:l}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:l,greedy:1})}}function $(e,t){for(let a in e)t(e[a],a)}function V(e,t){if(!be)return;let a=be.draft;P('element'===a.type,`"handler" extension can be used only with element nodes, got "${a.type}"`),void 0===t&&(t=e,e={});for(let e in t)P(effector.is.unit(t[e]),`handler for "${e}" should be event`);let{passive:l=0,capture:n=0,prevent:r=0,stop:o=0}=e;a.handler.push({options:{prevent:r,stop:o},domConfig:{passive:r?0:l,capture:n},map:t})}function U(e){E(be,'spec');let t=be.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,l=t.childCount;Array.isArray(a)?(t.text.push(...a.map(((e,t)=>({index:t+l,value:e})))),t.childCount+=a.length):(t.text.push({index:l,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[f(t)]=e.style[t];t.style.push(a)}if(e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?V(t.config||{},t.on):V(t)}e.\u0254&&U(e.\u0254)}function j(e,{initCtx:t,runOp:a,hooks:{onMount:l,onState:n}}){let o=e.opsAmount++;l.watch((({value:e,leaf:l})=>{let n=i({value:e,priority:'props',runOp(e){a(e,r)},group:l.root.leafOps[l.fullID].group});l.root.leafOps[l.fullID].group.ops[o]=n;let r=t(e,l)})),n.watch((({value:e,leaf:t})=>{r(e,t.root.leafOps[t.fullID].group.ops[o])}))}function L(e,t,a){e[t].forEach((e=>{$(e,((e,l)=>{switch(t){case'data':case'styleVar':a[t][l]=e;break;case'attr':a.attr['xlink:href'===l?'href':l]=e;break;case'style':l.startsWith('--')?a.styleVar[l.slice(2)]=e:a.style[l]=e}}))}))}function z(e,t,a){let l=e.data.block,n={type:'text',parent:l,visible:0,index:a,value:null};if(l.child[a]=n,e.hydration){let a=R(n);if(a)switch(a.type){case'text':n.value=e.root.env.document.createTextNode(t),a.value.after(n.value);break;case'element':n.value=a.value.nextSibling,k(n.value,t)}else{let e=O(n);n.value=e.firstChild,k(n.value,t)}n.visible=1}else n.value=e.root.env.document.createTextNode(t),F(n);return n}function G(e){let t=e.stateRef,a=be;a.plain.includes(t)||a.closure.includes(t)||a.closure.push(t)}function Q(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function W(e,t){let a=e.root.childSpawns[e.fullID];for(let e in a){let l=a[e];for(let e=0;e<l.length;e++)t(l[e])}}function Z(e,t){let a=t=>{let l=t.data;if(e&&'list'===l.type&&l.pendingUpdate){let e=l.pendingUpdate;l.pendingUpdate=null,effector.launch({target:t.template.api.pendingUpdate,params:e,defer:1,page:t,scope:t.root.scope})}if(e&&'route'===l.type)if(l.pendingInit){let e=l.pendingInit.value;l.pendingInit=null,effector.launch({target:t.template.api.pendingInit,params:e,defer:1,page:t,scope:t.root.scope})}else if(!l.block.visible)return;switch(l.type){case'element':r(e,l.ops.visible);break;case'route':case'list':case'list item':W(t,a);break;default:console.log('unsupported type',l.type)}};W(t,a)}function H(e){e.root.activeSpawns.delete(e.fullID),W(e,K)}function J(e){X(e,e.root.childSpawns[e.parent.fullID][e.template.id]),X(e,e.template.pages)}function K(e){let{data:t,root:a}=e;switch(t.type){case'element':X(e,a.childSpawns[e.parent.fullID][e.template.id]),function e(t){a.activeSpawns.delete(t.fullID);let l=a.childSpawns[t.fullID];delete a.childSpawns[t.fullID],delete a.leafOps[t.fullID],X(t,t.template.pages);for(let t in l)l[t].forEach(e)}(e),r(0,t.ops.visible);break;case'list':{let a=t.records;for(let e=0;e<a.length;e++){let t=a[e];t.instance&&K(t.instance),t.active=0}e.root.activeSpawns.delete(e.fullID),J(e);break}case'list item':{let a=t.block;X(a,a.parent.child);let l=a.left,n=a.right;l&&(l.right=n,n||a.parent.lastChild!==a||(a.parent.lastChild=l)),n&&(n.left=l),l||n||a.parent.lastChild!==a||(a.parent.lastChild=null),a.left=null,a.right=null,H(e),J(e);break}case'route':H(e),J(e);break;case'block':case'block item':case'rec':case'rec item':H(e)}delete a.childSpawns[e.fullID],delete a.leafOps[e.fullID]}function X(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function Y(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 l in t){let n=t[l];a[l]=e.map('function'==typeof n?e=>n(e):e=>e[n])}return a}return e.map((e=>e[t]))}function ee(e,t){E(be,'list'),'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:l,source:n,fields:r=[]}=e,o=void 0!==l?'function'==typeof l?l:e=>e[l]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},{env:s,namespace:f}=be;N(I({name:'list',draft:i,isSvgRoot:0,namespace:f,fn(e,{mount:t}){let l=I({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:l}){a({store:t,key:e,fields:Y(t,r)});let n=effector.createEvent({named:'itemUpdater'});if(t.on(n,((e,t)=>t)),i.itemVisible){let{onMount:e,onState:t}=_({mount:l,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&M(i,{parentBlockFragment:a,leaf:t})})),t.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?Z(e,t):e&&(a.childInitialized=1,M(i,{parentBlockFragment:a,leaf:t}))}))}else l.watch(Te.listItem);return{itemUpdater:n}},env:s}),m=effector.createStore([]),h=n.map((e=>e)),v=effector.sample({source:n,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),g=effector.createEvent(),b=effector.sample({source:v,clock:[h,g],fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});return effector.sample({source:m,clock:[v,b],greedy:1,fn(e,{updates:t,leaf:a,hydration:r}){let s=a.data,f=a;for(;f;){if('route'===f.data.type&&!f.data.block.visible)return void(s.pendingUpdate=t);f=f.parent}let m=s.block;ue('list update ['+n.shortName+']');let h=Array(t.length).fill(0),v=t.map(o),g=[];for(let a=0;a<e.length;a++){let l=e[a],n=v.indexOf(l.key);-1!==n?(g.push(l),h[n]=1,d(t[n],l.asyncValue)):(l.active=0,l.instance&&K(l.instance),p(l.asyncValue))}for(let e=0;e<t.length;e++){if(h[e])continue;let n=t[e],o=v[e],s=c(a.root.leafOps[a.fullID].group.queue),p={type:'LF',parent:m,child:[],childInitialized:0,visible:0,left:null,right:null},d={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:u({value:n,group:s,onChange(e){d.instance&&effector.launch({target:d.instance.template.api.itemUpdater,params:e,defer:1,page:d.instance,scope:d.instance.root.scope})},onInit(e){d.active&&(r||(d.instance=T(l,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:s,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root})))}})},f=g.length;g.push(d);let b=f>0?g[f-1].leafData:null;if(m.child.push(p),b){let e=b.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):m.lastChild=p,e.right=p}else m.lastChild=p;r&&(d.instance=T(l,{values:{id:o,store:n},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:s,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root}))}return pe('list update ['+n.shortName+']'),0===g.length&&(m.lastChild=null),s.records=g,g},target:m}),{pendingUpdate:g}},env:s}))}function te({source:e,visible:t,fn:a}){E(be,'route');let{env:l,namespace:n}=be,r=I({name:'route',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:o}){let i;if(effector.is.store(t))i=effector.combine({value:e,visible:t});else{let a=t;i=e.map((e=>({value:e,visible:a(e)})))}let s=I({name:'route item',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let l=effector.createEvent({named:'itemUpdater'});e.on(l,((e,t)=>t)),a({store:e});let n=effector.sample({source:t,clock:i,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(Te.routeItem),n.watch((({leaf:e,visible:t,value:a})=>{if(e.data.block.visible=t,t&&effector.launch({target:l,params:a,defer:1,page:e,scope:e.root.scope}),t){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return;t=t.parent}}Z(t,e)}))}});N(s);let{onMount:c,onState:u}=_({mount:o,state:i,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})}),p=effector.createEvent(),d=effector.sample({source:o,clock:p,greedy:1,fn:(e,t)=>({leaf:e,value:t,visible:1})});return effector.merge([c,u,d]).watch((({leaf:e,visible:t,value:a})=>{let l=e.data;if(l.block.visible=t,t||l.initialized||!l.pendingInit){if(t&&!l.initialized){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return void(l.pendingInit={value:a});t=t.parent}}t&&!l.initialized&&(B({parentBlockFragment:l.block,leaf:e,actor:s,values:{store:a}}),l.initialized=1)}else l.pendingInit=null})),{pendingInit:p}}});N(r)}function ae(e){let t='function'==typeof e?e:e.fn,a=I({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let l=effector.createEvent({named:'itemUpdater'});return e.on(l,((e,t)=>t)),a.watch(Te.rec),{itemUpdater:l}}});return({store:e,state:t=e})=>{E(be,'(rec instance)');let{env:l,namespace:n}=be;a.deferredInit&&a.deferredInit(),N(I({name:'rec item',isSvgRoot:0,namespace:n,env:l,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:l}){let{onMount:n,onState:r}=_({state:t,mount:l,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});r.watch((({state:e,leaf:t})=>{W(t,(a=>{effector.launch({target:a.template.api.itemUpdater,params:e,defer:1,page:t,scope:t.root.scope})}))})),n.watch((({leaf:e,state:t})=>{B({parentBlockFragment:e.data.block,leaf:e,actor:a,values:{store:t}})}))}}))}}function le(e,t){if(0===t.length)return e;let a=[e[0]];for(let l=0;l<t.length;l++)a.push(t[l],e[l+1]);return a}let ne,re=1e3;ne='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 oe=new Map;const ie=[],se=e=>{let t=oe.get(e);t||(t={calls:0,time:0,label:e,childTime:0},oe.set(e,t)),t.calls+=1,ie.push({bucket:t,pendingStart:ne()})},ce=e=>{let t=oe.get(e),a=ie.pop().pendingStart,l=ne()-a;t.time+=l,ie.length>0&&(ie[ie.length-1].bucket.childTime+=l)};let ue,pe;'undefined'!=typeof performance&&performance.mark?(ue=e=>{performance.mark('\u2604\ufe0f '+e+' start'),se(e)},pe=e=>{ce(e);try{performance.measure('\u2604\ufe0f '+e,'\u2604\ufe0f '+e+' start')}catch(e){}performance.clearMarks('\u2604\ufe0f '+e+' start'),performance.clearMeasures('\u2604\ufe0f '+e)}):(ue=e=>{se(e)},pe=e=>{ce(e)});let de='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const fe={attr:y,data:b,style:g,styleVar:v},me=(e,t)=>e.includes(t);let he={storeBase(e,t){e.plain.push(t)},storeOnMap(e,t,a,l){a.unshift(e.loader),a.push(e.upward),l&&(me(e.plain,l)||(me(e.closure,l)||e.closure.push(l),((e,t)=>{e.before||(e.before=[]),e.before.push(t)})(t,{type:'closure',of:l})))},storeMap(e,t,a){me(e.plain,t)||me(a.seq,e.loader)||a.seq.unshift(e.loader)},storeWatch:(e,t,a)=>(e.watch.push({of:t,fn:a}),1),eventPrepend(e,t){t.seq.push(e.upward)},combineBase(e,t,a){e.plain.push(t,a)},combineField(e,t,a){me(e.plain,t)||a.seq.unshift(e.loader)},splitBase(e,t){e.plain.push(t)},splitMatchStore(e,t,a){me(e.plain,t)||a.seq.unshift(e.loader)},sampleSource(e,t,a,l){t.current?me(e.plain,a)||me(e.closure,a)||e.closure.push(a):e.plain.push(a),e.plain.push(t),me(e.plain,l)||e.plain.push(l)},sampleTarget(e,t){t.seq.push(e.loader)},sampleSourceLoader:e=>e.loader,sampleSourceUpward:(e,t)=>t&&e.upward},ve=0,ge=0,be=null,ye=null;const ke=(e,t)=>e.reg[t.id];let Ie=null;const xe=['LF','using','element','recItem','rec','block','blockItem','route'];let we=effector.createEvent({named:'onMount'});we.watch((({fns:e,element:t})=>{e.forEach((e=>{e(t)}))}));const Se=[{type:'attr',field:'value'},{type:'attr',field:'checked'},{type:'attr',field:'min'},{type:'attr',field:'max'}],De={attr:y,data:b,style:g,styleVar:v},Ce=e=>e.data.block.value;let Te={using(e){let t=e.data;M(t.draft,{parentBlockFragment:t.block,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.visible=1,M(t,{parentBlockFragment:a.block,leaf:e})},block(e){M(e.draft,{parentBlockFragment:e.data.block,leaf:e})},blockItem(e){B({parentBlockFragment:e.data.block,leaf:e,actor:e.draft.itemOf})},rec(e){M(e.draft,{parentBlockFragment:e.data.block,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,M(t.listDraft,{parentBlockFragment:a,leaf:e})}};e.block=({fn:e,env:t,namespace:a="html"})=>{let l=I({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(Te.block)}});return()=>{E(be,'(block instance)');let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:l},{env:t,namespace:a}=be;N(I({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(Te.blockItem)}}))}},e.h=(e,t)=>{let a,l=0,o=0;'function'==typeof t?(l=1,a=t):t&&(o=1,t.fn&&(l=1,a=t.fn),t.\u0254&&('function'==typeof t.\u0254?(l=1,a=t.\u0254):'function'==typeof t.\u0254.fn&&(l=1,a=t.\u0254.fn))),E(be,'h');let i,s=be.env,c=be.namespace,u=c,p='html';u=p='svg'===c?'svg':'html','svg'===e&&(p='svg',u='svg'),be.isBlock||(i='svg'===p?s.document.createElementNS('http://www.w3.org/2000/svg',e):s.document.createElement(e));let d=i,f={type:'element',tag:e,attr:[],data:[],text:[],style:[],styleVar:[],handler:[],stencil:d,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===c?(f.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),u='html'):'svg'===e?(f.attr.push({xmlns:'http://www.w3.org/2000/svg'}),u='svg'):'foreignObject'===e&&(u='foreignObject');let h=I({name:'element',draft:f,isSvgRoot:'svg'===e,namespace:u,fn(e,{mount:i}){let s=effector.createEvent({named:'domElementCreated'});l&&a(),o&&U(t),effector.is.unit(f.visible)&&(f.seq.push({type:'visible',value:f.visible}),G(f.visible));let c={attr:{},data:{},style:{},styleVar:{}};L(f,'attr',c),L(f,'data',c),L(f,'style',c),L(f,'styleVar',c),$(c,((e,t)=>{$(e,((e,a)=>{effector.is.unit(e)?(f.seq.push({type:t,field:a,value:e}),G(e)):f.staticSeq.push({type:t,field:a,value:e})}))})),f.text.forEach((e=>{null!==e.value&&(effector.is.unit(e.value)?(f.seq.push({type:'dynamicText',value:e.value,childIndex:e.index}),G(e.value)):f.seq.push({type:'staticText',value:String(e.value),childIndex:e.index}))})),f.handler.forEach((e=>{$(e.map,((t,a)=>{f.seq.push({type:'handler',for:a,handler:t,options:e.options,domConfig:e.domConfig})}))})),d&&m(d,f.staticSeq),f.seq.forEach((e=>{switch(e.type){case'visible':{let{onMount:t,onState:a}=_({mount:i,state:e.value,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});t.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=A(r);if(e=t?t.nextSibling:O(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}M(f,{parentBlockFragment:r,leaf:e,node:r.value,svgRoot:h.isSvgRoot?r.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,effector.launch({target:we,params:{element:l.block.value,fns:f.node},page:e,defer:1,scope:e.root.scope})),effector.launch({target:s,params:e,defer:1,page:e,scope:e.root.scope})})),effector.merge([a,t]).watch((({leaf:e,value:t,hydration:a})=>{a||r(t,e.data.ops.visible)}));break}case'attr':case'data':case'style':case'styleVar':{let t=De[e.type],a=Se.some((({type:t,field:a})=>e.type===t&&e.field===a)),l=_({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})});a?effector.merge([l.onState,l.onMount]).watch((({leaf:a,value:l})=>{t(Ce(a),e.field,l)})):j(f,{initCtx(a,l){let n=Ce(l);return t(n,e.field,a),n},runOp(a,l){t(l,e.field,a)},hooks:l});break}case'dynamicText':j(f,{initCtx:(t,a)=>z(a,t,e.childIndex),runOp(e,t){k(t.value,e)},hooks:_({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:String(e)}),onState:(e,t)=>({leaf:e,value:String(t)})})});break;case'staticText':s.watch((t=>{z(t,e.value,e.childIndex)}));break;case'handler':{let t=e.handler.graphite.meta.nativeTemplate||null;s.watch((a=>{let l=null;if(t){let e=0,n=a;for(;!e&&n;)n.template===t?(e=1,l=n):n=n.parent}else l=null;Ce(a).addEventListener(e.for,(t=>{e.options.prevent&&t.preventDefault(),e.options.stop&&t.stopPropagation(),effector.launch({target:e.handler,params:t,page:l,scope:a.root.scope})}),e.domConfig)}));break}}})),i.watch((e=>{let t=e.data;if(!f.visible){let a=t.ops.visible,l=t.block;if(e.hydration){n(1,a);let e,t=A(l);if(e=t?t.nextSibling:O(l).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}l.value=e,l.visible=1}M(f,{parentBlockFragment:l,leaf:e,node:l.value,svgRoot:h.isSvgRoot?l.value:null}),effector.launch({target:s,params:e,defer:1,page:e,scope:e.root.scope}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:we,params:{element:t.block.value,fns:f.node},page:e,defer:1,scope:e.root.scope})):r(1,a)}}))},env:s});N(h)},e.handler=V,e.list=ee,e.node=e=>{E(be,'node');let t=be.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=ae,e.remap=Y,e.route=te,e.spec=U,e.text=(e,...t)=>{Array.isArray(e)?U({text:le(e,t)}):U({text:e})},e.tree=({source:e,key:t,child:a,fn:l})=>{let n=ae((({store:e})=>{ee({source:e,key:t,fn({store:e}){let t=e.map((e=>e[a]||[]));l({store:e,child(){n({store:t})}})}})}));n({store:e})},e.using=(e,t)=>{let a,l,n,r,o,i;if('function'==typeof t)a=t,n=Q(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:Q(),r=t.hydrate,l=t.onComplete,o=t.onRoot,i=t.scope}P(e,'using() first argument is missing');let u={scope:i,env:n,activeSpawns:new Set,childSpawns:{},leafOps:{}},p=e.namespaceURI,d=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},m=I({name:'using',draft:f,isSvgRoot:'svg'===d,namespace:'http://www.w3.org/2000/svg'===p?'svg':'foreignobject'===d?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(Te.using)},env:n}),h={type:'using',child:[],value:e},v=s({onComplete:l}),g=T(m,{parentLeaf:ye||null,mountNode:e,svgRoot:m.isSvgRoot?e:ye?ye.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:h},opGroup:c(v),domSubtree:c(v),hydration:r,root:u});if(o&&o({template:m,leaf:g}),v.onDrain&&!v.rafID){let e=v.onDrain;v.onDrain=null,e()}},e.val=(e,...t)=>t.every((e=>!effector.is.store(e)))?le(e,t).join(''):effector.combine(t,(t=>le(e,t).join(''))),e.variant=({source:e,cases:t,key:a})=>{let l;E(be,'variant'),P(effector.is.unit(e),'variant({source}) should be unit'),l='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let n=0;for(let a in t)'__'!==a?te({source:e,visible:e=>l(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);te({source:e,visible:e=>!a.includes(l(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='undefined'!=typeof globalThis?globalThis: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})(l(e),e)}function l(e){return e.group.activeChilds[e.priority]}function n(e,t){t.value.active=t.value.pending=e,'active'!==t.status&&a(t)}function r(e,n){if(n.value.active===e)return n.value.pending=e,void('pending'===n.status&&(a(n),l(n).first||t(n.group,n.priority)));'active'===n.status&&(n.status='pending',l(n).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})(n.group,n.priority),((e,t)=>{e.last?(t.cursor.prev=e.last,e.last.cursor.next=t,e.last=t):e.first=e.last=t})(l(n),n)),n.value.pending=e,n.group.queue.rafID||(n.group.queue.rafID=fe(n.group.queue.execQueue))}function o(e){pe('execQueue');let l,n,r=re(),o=0;e:for(;e.props.first||e.tree.first||e.data.first;){if(re()-r>=oe){o=1;break e}let i=!!e.props.first;for(i&&pe('props');l=e.props.first;){for(;n=l.activeChilds.props.first;){if(re()-r>=oe){o=1,de('props');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,a(n)}t(l,'props')}i&&de('props');let s=!!e.tree.first;for(s&&pe('tree');l=e.tree.first;){for(;n=l.activeChilds.tree.first;){if(re()-r>=oe){o=1,de('tree');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,a(n)}t(l,'tree')}s&&de('tree');let c=!!e.data.first;for(c&&pe('data');l=e.data.first;){for(;n=l.activeChilds.data.first;){if(re()-r>=oe){o=1,de('data');break e}n.runOp(n.value.pending),n.value.active=n.value.pending,a(n)}t(l,'data')}c&&de('data')}if(de('execQueue'),o)e.rafID=fe(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:l}){return{value:{active:e,pending:e},runOp:t,status:'active',priority:l,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 c(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:l}){let n=i({value:e,group:t,runOp(e){o.status='A',l(e)},priority:'data'}),o={status:'IA',value:n.value,ops:{init:i({value:0,group:t,runOp(e){o.status='A',a(o.value.active)},priority:'data'}),change:n,terminate:i({value:0,group:t,runOp(e){o.status='T'},priority:'data'})}};return r(1,o.ops.init),o}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)}}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){switch(e=String(e)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return e.replace(/[^a-zA-Z0-9\-_]/g,'')}}function m(e,t){for(let a=0;a<t.length;a++){let{type:l,field:n,value:r}=t[a];me[l](e,n,r)}}function v(e){return''!==e&&0!==e&&'0'!==e&&(0==e||null==e)}function h(e,t,a){v(a)?e.style.removeProperty(`--${t}`):e.style.setProperty(`--${t}`,`${a}`)}function g(e,t,a){v(a)?delete e.style[t]:e.style[t]=`${a}`}function b(e,t,a){t&&t.trim().length>0&&(a?e.classList.add(t):(e.classList.remove(t),0===e.classList.length&&e.removeAttribute('class')))}function y(e,t,a){v(a)?delete e.dataset[t]:e.dataset[t]=`${a}`}function k(e,t,a){if(v(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 I(e,t){e.replaceData(0,(e.textContent||'').length,String(t))}function x({fn:e,state:t={},defer:a=0,name:l="",draft:n,isSvgRoot:r,namespace:o,env:i,isBlock:s=0}){let c=ye,u={id:++ge,name:l,plain:[],watch:[],nameMap:{},pages:[],closure:[],childTemplates:[],handlers:he,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.root.activeSpawns.has(a.page.fullID))return console.count('inactive page upward'),0;let l=[a.page.template],n=[a.page];{let e=a.page.parent;for(;e;)n.push(e),l.push(e.template),e=e.parent}return a.node.next.forEach((t=>{let r=t.meta.nativeTemplate;if(r)if(l.includes(r)){let o=n[l.indexOf(r)];effector.launch({target:t,params:e,defer:1,page:o,stack:a,scope:a.scope})}else console.error('context drift',{stack:a,node:t});else effector.launch({target:t,params:e,defer:1,page:a.page,stack:a,scope:a.scope})})),0}}),loader:effector.step.filter({fn(e,t,a){if(a.parent){let t=a.scope?a.scope.graphite.id:null;if(a.page){if(!a.page.root.activeSpawns.has(a.page.fullID))return console.count('inactive page loader'),0;if(a.page.template===u)return 1;if(a.page.root.childSpawns[a.page.fullID][u.id])a.page.root.childSpawns[a.page.fullID][u.id].forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));else{let l=a.page.fullID,n='rec'===a.page.template.name;u.pages.forEach((r=>{if(!t||r.root.scope&&t===r.root.scope.graphite.id)if(r.fullID===l||r.fullID.startsWith(`${l}_`)){let t=1;if(n){let e=a.page.template.id,l=r.parent;for(;l&&l!==a.page;){if(l.template.id===e){t=0;break}l=l.parent}}t&&effector.launch({params:e,target:a.node,page:r,defer:1,scope:a.scope})}else l.startsWith(`${r.fullID}_`)&&effector.launch({params:e,target:a.node,page:a.page,defer:1,scope:a.scope})}))}}else u.pages.forEach((l=>{(!t||l.root.scope&&t===l.root.scope.graphite.id)&&effector.launch({params:e,target:a.node,page:l,defer:1,scope:a.scope})}));return 0}return 1}}),parent:c,node:null,api:null,trigger:{mount:effector.createEvent({named:'mount'})},draft:n,isSvgRoot:r,namespace:o,env:i,isBlock:s||!(!c||!c.isBlock)};c&&c.childTemplates.push(u);let p=effector.createNode({meta:{template:u}});return u.node=p,ye=u,a?u.deferredInit=()=>{let a=ye;ye=u,u.deferredInit=null;try{effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a}))}finally{ye=a}}:effector.withRegion(p,(()=>{let a=effector.restore(t);u.api=e(a,u.trigger),u.nameMap=a})),ye=c,u}function w(e,t){let a;switch(a=t?t.getState(e):e.current,e.type){case'list':return[...a];case'shape':return{...a};default:return a}}function S(e,t,a){let l=t;for(;l&&!Ie(l,e);)l=l.parent;return l?Ie(l,e):a?(a.getState(e),a.reg[e.id]):e}function D(e,t,a){return S(e,t,a).current}function C(e,t){Ie(t,e)||(t.reg[e.id]=S(e,t.parent,t.root.scope))}function T(e,t,a){t in a||(a[t]=[]),a[t].push(...e)}function O(e,{values:t={},parentLeaf:a,mountNode:l,svgRoot:n,leafData:r,opGroup:o,domSubtree:i,hydration:s,root:c}){function u(e){if(e.before)for(let t=0;t<e.before.length;t++){let a=e.before[t];switch(a.type){case'map':{let t,l=a.from;if(!a.fn&&!l)break;l&&(C(l,f),t=d[l.id].current),d[e.id].current=a.fn?a.fn(t):t;break}case'field':{let t=a.from;C(t,f),d[e.id].current[a.field]=d[t.id].current;break}case'closure':C(a.of,f)}}}function p(e,t,a){let l;t.stop=1;try{for(;t.i<e.length;)l=e[t.i],t.i++,l.fn(a[l.of.id]?a[l.of.id].current:D(l.of,f.parent,f.root.scope))}catch(e){console.error(e),t.stop=0}}let d={},f={draft:e.draft,svgRoot:n,data:r,parent:a,hydration:s,mountNode:l,root:c,id:++be,fullID:'',reg:d,template:e};e.pages.push(f);let m=ke;ke=f,a&&T([f],e.id,c.childSpawns[a.fullID]),f.fullID=a?`${a.fullID}_${f.id}`:`${f.id}`,c.childSpawns[f.fullID]={},c.activeSpawns.add(f.fullID),c.leafOps[f.fullID]={group:o,domSubtree:i};for(let t=0;t<e.closure.length;t++){let a=e.closure[t],l=a,n=f.parent;e:for(;n;){if(Ie(n,a)){l=Ie(n,a);break e}n=n.parent}!n&&c.scope&&(c.scope.getState(a),l=c.scope.reg[a.id]),d[a.id]=l}for(let t=0;t<e.plain.length;t++){let a=e.plain[t],l={id:a.id,current:w(a,c.scope)};d[a.id]=l}for(let a in t){let l=e.nameMap[a].stateRef.id;d[l]={id:l,current:t[a]}}e.closure.forEach(u),e.plain.forEach(u);let v={i:0,stop:0};for(;!v.stop;)p(e.watch,v,d);if(a)for(let e in c.childSpawns[f.fullID])T(c.childSpawns[f.fullID][e],e,c.childSpawns[a.fullID]);if(xe)xe.steps.push({target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope});else{let t;xe={parent:xe,steps:[{target:e.trigger.mount,params:f,defer:1,page:f,scope:c.scope}]};do{for(;t=xe.steps.shift();)xe={parent:xe,steps:[]},effector.launch(t)}while(xe=xe.parent)}return ke=m,f}function q(e){let t=e.parent;for(;'element'!==t.type&&'using'!==t.type;)t=t.parent;return t?t.value:null}function R(e){if(!e.visible)return null;switch(e.type){case'text':case'element':return e;case'LF':case'route':case'rec':case'recItem':case'block':case'blockItem':for(let t=e.child.length-1;t>=0;t--){let a=R(e.child[t]);if(a)return a}return null;case'list':{let t=e.lastChild;if(!t)return null;for(;t;){let e=R(t);if(e)return e;t=t.left}return null}default:return null}}function A(e){switch(e.type){case'using':return null;case'LF':{let t=e.left;for(;t;){let e=R(t);if(e)return e;t=t.left}return A(e.parent)}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 l=R(e);if(l)return l}switch(t.type){case'element':case'using':return null}return A(t)}default:return null}}function E(e){let t=A(e);return t?t.value:null}function P(e,t){if(!e)throw Error(t)}function M(e,t){if(!e)throw Error(`${t}() called outside from using() closure`)}function N(e){if(!ye)return;let{draft:t}=e;if('listItem'!==t.type&&'rec'!==t.type)switch(ye.draft.type){case'element':case'using':case'route':case'list':case'rec':case'recItem':case'block':case'blockItem':t.inParentIndex=ye.draft.childCount,ye.draft.childCount+=1,ye.draft.childTemplates.push(e);break;default:console.warn(`unexpected currentTemplate type ${ye.draft.type}`)}}function L(e,{parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r}){e.childTemplates.forEach((e=>{B({parentBlockFragment:t,leaf:a,node:l,svgRoot:n,values:r,actor:e})}))}function B({parentBlockFragment:e,leaf:t,node:a=t.mountNode,actor:l,svgRoot:n,values:r}){let o;P(we.includes(e.type),`incorrect parent ${e.type}`);let{draft:s}=l,{queue:u}=t.root.leafOps[t.fullID].group,p=c(u),d=t.root.leafOps[t.fullID].domSubtree,f=d;switch(s.type){case'route':{let t={type:'route',parent:e,child:[],visible:0,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'route',block:t,ops:{},initialized:0,pendingInit:null};break}case'element':{let a;if(l.isBlock){let e,l,n=t;for(;n&&(!l||!e);){n.template.env&&(e=n.template.env);let{draft:t}=n;'element'===t.type&&('svg'===t.tag?l='svg':'foreignObject'===t.tag&&(l='html')),n=n.parent}l||(l='html'),e&&(a='svg'===l?e.document.createElementNS('http://www.w3.org/2000/svg',s.tag):e.document.createElement(s.tag),m(a,s.staticSeq))}else a=s.stencil.cloneNode();let n={type:'element',parent:e,child:[],value:a,visible:0,index:s.inParentIndex};e.child[s.inParentIndex]=n,o={type:'element',block:n,ops:{visible:i({value:0,priority:'tree',runOp(e){if(e){F(n);let e=o;e.needToCallNode&&(e.needToCallNode=0,effector.launch({target:Se,params:{element:n.value,fns:s.node},page:v,scope:t.root.scope})),n.visible=1}else n.value.remove(),n.visible=0},group:d})},needToCallNode:s.node.length>0},f=c(u);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,records:[],pendingUpdate:null};break}case'using':case'listItem':break;case'rec':{let t={type:'rec',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'rec',block:t};break}case'recItem':{let t={type:'recItem',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'rec item',block:t};break}case'block':{let t={type:'block',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'block',block:t};break}case'blockItem':{let t={type:'blockItem',parent:e,child:[],visible:1,index:s.inParentIndex};e.child[s.inParentIndex]=t,o={type:'block item',block:t};break}default:console.warn(`unexpected draft type ${s.type}`)}let v=O(l,{values:r,parentLeaf:t,mountNode:a,svgRoot:n||t.svgRoot,leafData:o,opGroup:p,domSubtree:f,hydration:t.hydration,root:t.root})}function F(e){let t=E(e);t?t.after(e.value):q(e).prepend(e.value),e.visible=1}function _({mount:e,state:t,onMount:a,onState:l}){return{onMount:effector.sample({source:t,clock:e,fn:a,greedy:1}),onState:effector.sample({source:e,clock:t,fn:l,greedy:1})}}function $(e,t){for(let a in e)t(e[a],a)}function V(e,t){if(!ye)return;let a=ye.draft;P('element'===a.type,`"handler" extension can be used only with element nodes, got "${a.type}"`),void 0===t&&(t=e,e={});for(let e in t)P(effector.is.unit(t[e]),`handler for "${e}" should be event`);let{passive:l=0,capture:n=0,prevent:r=0,stop:o=0}=e;a.handler.push({options:{prevent:r,stop:o},domConfig:{passive:r?0:l,capture:n},map:t})}function U(e){M(ye,'spec');let t=ye.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,l=t.childCount;Array.isArray(a)?(t.text.push(...a.map(((e,t)=>({index:t+l,value:e})))),t.childCount+=a.length):(t.text.push({index:l,value:a}),t.childCount+=1)}if(e.style){let a={};for(let t in e.style)a[f(t)]=e.style[t];t.style.push(a)}if(e.classList&&((e,t)=>{Array.isArray(e)?e.forEach((e=>{let a='string'==typeof e?e:e.map((e=>e||'')),l='string'==typeof e?1:e.map((e=>null!==e));t({name:a,enabled:l})})):$(e,((e,a)=>{t({name:a,enabled:e})}))})(e.classList,(e=>t.classList.push(e))),e.styleVar&&t.styleVar.push(e.styleVar),e.visible&&(t.visible=e.visible),e.handler){let t=e.handler;'object'==typeof t.on?V(t.config||{},t.on):V(t)}e.\u0254&&U(e.\u0254)}function j(e,{initCtx:t,runOp:a,hooks:{onMount:l,onState:n}}){let o=e.opsAmount++;l.watch((({value:e,leaf:l})=>{let n=t(e,l),r=i({value:e,priority:'props',runOp(e){a(e,n)},group:l.root.leafOps[l.fullID].group});l.root.leafOps[l.fullID].group.ops[o]=r})),n.watch((({value:e,leaf:t})=>{r(e,t.root.leafOps[t.fullID].group.ops[o])}))}function z(e,t,a){e[t].forEach((e=>{$(e,((e,l)=>{switch(t){case'data':case'styleVar':a[t][l]=e;break;case'attr':a.attr['xlink:href'===l?'href':l]=e;break;case'style':l.startsWith('--')?a.styleVar[l.slice(2)]=e:a.style[l]=e}}))}))}function G(e,t,a){let l=e.data.block,n={type:'text',parent:l,visible:0,index:a,value:null};if(l.child[a]=n,e.hydration){let a=A(n);if(a)switch(a.type){case'text':n.value=e.root.env.document.createTextNode(t),a.value.after(n.value);break;case'element':n.value=a.value.nextSibling,I(n.value,t)}else{let e=q(n);n.value=e.firstChild,I(n.value,t)}n.visible=1}else n.value=e.root.env.document.createTextNode(t),F(n);return n}function Q(e){let t=e.stateRef,a=ye;a.plain.includes(t)||a.closure.includes(t)||a.closure.push(t)}function W(){if('undefined'!=typeof document)return{document};throw Error('your environment has no document')}function Z(e,t){let a=e.root.childSpawns[e.fullID];for(let e in a){let l=a[e];for(let e=0;e<l.length;e++)t(l[e])}}function H(e,t){let a=t=>{let l=t.data;if(e&&'list'===l.type&&l.pendingUpdate){let e=l.pendingUpdate;l.pendingUpdate=null,effector.launch({target:t.template.api.pendingUpdate,params:e,defer:1,page:t,scope:t.root.scope})}if(e&&'route'===l.type)if(l.pendingInit){let e=l.pendingInit.value;l.pendingInit=null,effector.launch({target:t.template.api.pendingInit,params:e,defer:1,page:t,scope:t.root.scope})}else if(!l.block.visible)return;switch(l.type){case'element':r(e,l.ops.visible);break;case'route':case'list':case'list item':Z(t,a);break;default:console.log('unsupported type',l.type)}};Z(t,a)}function J(e){e.root.activeSpawns.delete(e.fullID),Z(e,X)}function K(e){Y(e,e.root.childSpawns[e.parent.fullID][e.template.id]),Y(e,e.template.pages)}function X(e){let{data:t,root:a}=e;switch(t.type){case'element':Y(e,a.childSpawns[e.parent.fullID][e.template.id]),function e(t){a.activeSpawns.delete(t.fullID);let l=a.childSpawns[t.fullID];delete a.childSpawns[t.fullID],delete a.leafOps[t.fullID],Y(t,t.template.pages);for(let t in l)l[t].forEach(e)}(e),r(0,t.ops.visible);break;case'list':{let a=t.records;for(let e=0;e<a.length;e++){let t=a[e];t.instance&&X(t.instance),t.active=0}e.root.activeSpawns.delete(e.fullID),K(e);break}case'list item':{let a=t.block;Y(a,a.parent.child);let l=a.left,n=a.right;l&&(l.right=n,n||a.parent.lastChild!==a||(a.parent.lastChild=l)),n&&(n.left=l),l||n||a.parent.lastChild!==a||(a.parent.lastChild=null),a.left=null,a.right=null,J(e),K(e);break}case'route':J(e),K(e);break;case'block':case'block item':case'rec':case'rec item':J(e)}delete a.childSpawns[e.fullID],delete a.leafOps[e.fullID]}function Y(e,t){if(!t)return;let a=t.indexOf(e);-1!==a&&t.splice(a,1)}function ee(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 l in t){let n=t[l];a[l]=e.map('function'==typeof n?e=>n(e):e=>e[n])}return a}return e.map((e=>e[t]))}function te(e,t){M(ye,'list'),'function'==typeof t&&(effector.is.unit(e)?e={source:e,fn:t}:e.fn=t);let{fn:a,key:l,source:n,fields:r=[]}=e,o=void 0!==l?'function'==typeof l?l:e=>e[l]:(e,t)=>t,i={type:'list',key:effector.is.store(e)?{type:'index'}:{type:'key',key:e.key},childTemplates:[],childCount:0,inParentIndex:-1},{env:s,namespace:f}=ye;N(x({name:'list',draft:i,isSvgRoot:0,namespace:f,fn(e,{mount:t}){let l=x({name:'list item',state:{id:-1,store:null},draft:i,isSvgRoot:0,namespace:f,fn({id:e,store:t},{mount:l}){a({store:t,key:e,fields:ee(t,r)});let n=effector.createEvent({named:'itemUpdater'});if(t.on(n,((e,t)=>t)),i.itemVisible){let{onMount:e,onState:t}=_({mount:l,state:i.itemVisible,onMount:(e,t)=>({visible:e,leaf:t}),onState:(e,t)=>({visible:t,leaf:e})});e.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized=e,e&&L(i,{parentBlockFragment:a,leaf:t})})),t.watch((({visible:e,leaf:t})=>{let a=t.data.block;a.visible=e,a.childInitialized?H(e,t):e&&(a.childInitialized=1,L(i,{parentBlockFragment:a,leaf:t}))}))}else l.watch(Oe.listItem);return{itemUpdater:n}},env:s}),m=effector.createStore([]),v=n.map((e=>e)),h=effector.sample({source:n,clock:t,fn:(e,t)=>({updates:e,leaf:t,hydration:t.hydration}),greedy:1}),g=effector.createEvent(),b=effector.sample({source:h,clock:[v,g],fn:({leaf:e},t)=>({updates:t,leaf:e,hydration:0}),greedy:1});return effector.sample({source:m,clock:[h,b],greedy:1,fn(e,{updates:t,leaf:a,hydration:r}){let s=a.data,f=a;for(;f;){if('route'===f.data.type&&!f.data.block.visible)return void(s.pendingUpdate=t);f=f.parent}let m=s.block;pe('list update ['+n.shortName+']');let v=Array(t.length).fill(0),h=t.map(o),g=[];for(let a=0;a<e.length;a++){let l=e[a],n=h.indexOf(l.key);-1!==n?(g.push(l),v[n]=1,d(t[n],l.asyncValue)):(l.active=0,l.instance&&X(l.instance),p(l.asyncValue))}for(let e=0;e<t.length;e++){if(v[e])continue;let n=t[e],o=h[e],s=c(a.root.leafOps[a.fullID].group.queue),p={type:'LF',parent:m,child:[],childInitialized:0,visible:0,left:null,right:null},d={type:'listItem',key:o,index:o,active:1,leafData:{type:'list item',block:p,listDraft:i},asyncValue:u({value:n,group:s,onChange(e){d.instance&&effector.launch({target:d.instance.template.api.itemUpdater,params:e,defer:1,page:d.instance,scope:d.instance.root.scope})},onInit(e){d.active&&(r||(d.instance=O(l,{values:{id:o,store:e},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:s,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root})))}})},f=g.length;g.push(d);let b=f>0?g[f-1].leafData:null;if(m.child.push(p),b){let e=b.block;p.left=e;let t=e.right;t?(t.left=p,p.right=t):m.lastChild=p,e.right=p}else m.lastChild=p;r&&(d.instance=O(l,{values:{id:o,store:n},parentLeaf:a,mountNode:a.mountNode,svgRoot:a.svgRoot,leafData:d.leafData,opGroup:s,domSubtree:a.root.leafOps[a.fullID].domSubtree,hydration:r,root:a.root}))}return de('list update ['+n.shortName+']'),0===g.length&&(m.lastChild=null),s.records=g,g},target:m}),{pendingUpdate:g}},env:s}))}function ae({source:e,visible:t,fn:a}){M(ye,'route');let{env:l,namespace:n}=ye,r=x({name:'route',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},fn(r,{mount:o}){let i;if(effector.is.store(t))i=effector.combine({value:e,visible:t});else{let a=t;i=e.map((e=>({value:e,visible:a(e)})))}let s=x({name:'route item',isSvgRoot:0,namespace:n,env:l,draft:{type:'route',childTemplates:[],childCount:0,inParentIndex:-1},state:{store:null},fn({store:e},{mount:t}){let l=effector.createEvent({named:'itemUpdater'});e.on(l,((e,t)=>t)),a({store:e});let n=effector.sample({source:t,clock:i,fn:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a}),greedy:1});t.watch(Oe.routeItem),n.watch((({leaf:e,visible:t,value:a})=>{if(e.data.block.visible=t,t&&effector.launch({target:l,params:a,defer:1,page:e,scope:e.root.scope}),t){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return;t=t.parent}}H(t,e)}))}});N(s);let{onMount:c,onState:u}=_({mount:o,state:i,onMount:({visible:e,value:t},a)=>({leaf:a,visible:e,value:t}),onState:(e,{visible:t,value:a})=>({leaf:e,visible:t,value:a})}),p=effector.createEvent(),d=effector.sample({source:o,clock:p,greedy:1,fn:(e,t)=>({leaf:e,value:t,visible:1})});return effector.merge([c,u,d]).watch((({leaf:e,visible:t,value:a})=>{let l=e.data;if(l.block.visible=t,t||l.initialized||!l.pendingInit){if(t&&!l.initialized){let t=e.parent;for(;t;){if('route'===t.data.type&&!t.data.block.visible)return void(l.pendingInit={value:a});t=t.parent}}t&&!l.initialized&&(B({parentBlockFragment:l.block,leaf:e,actor:s,values:{store:a}}),l.initialized=1)}else l.pendingInit=null})),{pendingInit:p}}});N(r)}function le(e){let t='function'==typeof e?e:e.fn,a=x({name:'rec',state:{store:null},isSvgRoot:0,namespace:null,env:null,draft:{type:'rec',childTemplates:[],childCount:0,inParentIndex:0},defer:1,isBlock:1,fn({store:e},{mount:a}){t({store:e,state:e});let l=effector.createEvent({named:'itemUpdater'});return e.on(l,((e,t)=>t)),a.watch(Oe.rec),{itemUpdater:l}}});return({store:e,state:t=e})=>{M(ye,'(rec instance)');let{env:l,namespace:n}=ye;a.deferredInit&&a.deferredInit(),N(x({name:'rec item',isSvgRoot:0,namespace:n,env:l,draft:{type:'recItem',childTemplates:[],childCount:0,inParentIndex:-1},fn(e,{mount:l}){let{onMount:n,onState:r}=_({state:t,mount:l,onMount:(e,t)=>({state:e,leaf:t}),onState:(e,t)=>({state:t,leaf:e})});r.watch((({state:e,leaf:t})=>{Z(t,(a=>{effector.launch({target:a.template.api.itemUpdater,params:e,defer:1,page:t,scope:t.root.scope})}))})),n.watch((({leaf:e,state:t})=>{B({parentBlockFragment:e.data.block,leaf:e,actor:a,values:{store:t}})}))}}))}}function ne(e,t){if(0===t.length)return e;let a=[e[0]];for(let l=0;l<t.length;l++)a.push(t[l],e[l+1]);return a}let re,oe=1e3;re='undefined'!=typeof performance&&performance.now?()=>performance.now():'undefined'!=typeof process&&process.hrtime?()=>{let e=process.hrtime();return(1e9*e[0]+e[1])/1e6}:()=>Date.now();let ie=new Map;const se=[],ce=e=>{let t=ie.get(e);t||(t={calls:0,time:0,label:e,childTime:0},ie.set(e,t)),t.calls+=1,se.push({bucket:t,pendingStart:re()})},ue=e=>{let t=ie.get(e),a=se.pop().pendingStart,l=re()-a;t.time+=l,se.length>0&&(se[se.length-1].bucket.childTime+=l)};let pe,de;'undefined'!=typeof performance&&performance.mark?(pe=e=>{performance.mark('\u2604\ufe0f '+e+' start'),ce(e)},de=e=>{ue(e);try{performance.measure('\u2604\ufe0f '+e,'\u2604\ufe0f '+e+' start')}catch(e){}performance.clearMarks('\u2604\ufe0f '+e+' start'),performance.clearMeasures('\u2604\ufe0f '+e)}):(pe=e=>{ce(e)},de=e=>{ue(e)});let fe='undefined'!=typeof requestAnimationFrame?requestAnimationFrame:e=>setTimeout(e,0);const me={attr:k,data:y,style:g,styleVar:h,classList:b},ve=(e,t)=>e.includes(t);let he={storeBase(e,t){e.plain.push(t)},storeOnMap(e,t,a,l){a.unshift(e.loader),a.push(e.upward),l&&(ve(e.plain,l)||(ve(e.closure,l)||e.closure.push(l),((e,t)=>{e.before||(e.before=[]),e.before.push(t)})(t,{type:'closure',of:l})))},storeMap(e,t,a){ve(e.plain,t)||ve(a.seq,e.loader)||a.seq.unshift(e.loader)},storeWatch:(e,t,a)=>(e.watch.push({of:t,fn:a}),1),eventPrepend(e,t){t.seq.push(e.upward)},combineBase(e,t,a){e.plain.push(t,a)},combineField(e,t,a){ve(e.plain,t)||a.seq.unshift(e.loader)},splitBase(e,t){e.plain.push(t)},splitMatchStore(e,t,a){ve(e.plain,t)||a.seq.unshift(e.loader)},sampleSource(e,t,a,l){t.current?ve(e.plain,a)||ve(e.closure,a)||e.closure.push(a):e.plain.push(a),e.plain.push(t),ve(e.plain,l)||e.plain.push(l)},sampleTarget(e,t){t.seq.push(e.loader)},sampleSourceLoader:e=>e.loader,sampleSourceUpward:(e,t)=>t&&e.upward},ge=0,be=0,ye=null,ke=null;const Ie=(e,t)=>e.reg[t.id];let xe=null;const we=['LF','using','element','recItem','rec','block','blockItem','route'];let Se=effector.createEvent({named:'onMount'});Se.watch((({fns:e,element:t})=>{e.forEach((e=>{e(t)}))}));const De=[{type:'attr',field:'value'},{type:'attr',field:'checked'},{type:'attr',field:'min'},{type:'attr',field:'max'}],Ce={attr:k,data:y,style:g,styleVar:h,classList:b},Te=e=>e.data.block.value;let Oe={using(e){let t=e.data;L(t.draft,{parentBlockFragment:t.block,leaf:e})},routeItem(e){let t=e.draft,a=e.data;a.block.visible=1,L(t,{parentBlockFragment:a.block,leaf:e})},block(e){L(e.draft,{parentBlockFragment:e.data.block,leaf:e})},blockItem(e){B({parentBlockFragment:e.data.block,leaf:e,actor:e.draft.itemOf})},rec(e){L(e.draft,{parentBlockFragment:e.data.block,leaf:e})},listItem(e){let t=e.data,a=t.block;a.visible=1,a.childInitialized=1,L(t.listDraft,{parentBlockFragment:a,leaf:e})}};e.block=({fn:e,env:t,namespace:a="html"})=>{let l=x({name:'block',isSvgRoot:0,namespace:a,env:t,draft:{type:'block',childTemplates:[],childCount:0,inParentIndex:0},isBlock:1,fn({},{mount:t}){e(),t.watch(Oe.block)}});return()=>{M(ye,'(block instance)');let e={type:'blockItem',childTemplates:[],childCount:0,inParentIndex:-1,itemOf:l},{env:t,namespace:a}=ye;N(x({name:'block item',isSvgRoot:0,namespace:a,env:t,draft:e,fn(e,{mount:t}){t.watch(Oe.blockItem)}}))}},e.h=(e,t)=>{let a,l=0,o=0;'function'==typeof t?(l=1,a=t):t&&(o=1,t.fn&&(l=1,a=t.fn),t.\u0254&&('function'==typeof t.\u0254?(l=1,a=t.\u0254):'function'==typeof t.\u0254.fn&&(l=1,a=t.\u0254.fn))),M(ye,'h');let i,s=ye.env,c=ye.namespace,u=c,p='html';u=p='svg'===c?'svg':'html','svg'===e&&(p='svg',u='svg'),ye.isBlock||(i='svg'===p?s.document.createElementNS('http://www.w3.org/2000/svg',e):s.document.createElement(e));let d=i,f={type:'element',tag:e,attr:[],data:[],text:[],style:[],styleVar:[],classList:[],handler:[],stencil:d,seq:[],staticSeq:[],childTemplates:[],childCount:0,inParentIndex:-1,opsAmount:1,node:[]};'foreignObject'===c?(f.attr.push({xmlns:'http://www.w3.org/1999/xhtml'}),u='html'):'svg'===e?(f.attr.push({xmlns:'http://www.w3.org/2000/svg'}),u='svg'):'foreignObject'===e&&(u='foreignObject');let v=x({name:'element',draft:f,isSvgRoot:'svg'===e,namespace:u,fn(e,{mount:i}){let s=effector.createEvent({named:'domElementCreated'});l&&a(),o&&U(t),effector.is.unit(f.visible)&&(f.seq.push({type:'visible',value:f.visible}),Q(f.visible));let c={attr:{},data:{},style:{},styleVar:{}};z(f,'attr',c),z(f,'data',c),z(f,'style',c),z(f,'styleVar',c),$(c,((e,t)=>{$(e,((e,a)=>{effector.is.unit(e)?(f.seq.push({type:t,field:a,value:e}),Q(e)):f.staticSeq.push({type:t,field:a,value:e})}))})),f.classList.forEach((e=>{if(effector.is.unit(e.name)||effector.is.unit(e.enabled)){let t=effector.is.unit(e.name)?e.name:effector.createStore(e.name),a=effector.is.unit(e.enabled)?e.enabled:effector.createStore(e.enabled);f.seq.push({type:'classList',field:t,value:a}),Q(t),Q(a)}else effector.is.unit(e.name)||f.staticSeq.push({type:'classList',field:e.name,value:1})})),f.text.forEach((e=>{null!==e.value&&(effector.is.unit(e.value)?(f.seq.push({type:'dynamicText',value:e.value,childIndex:e.index}),Q(e.value)):f.seq.push({type:'staticText',value:String(e.value),childIndex:e.index}))})),f.handler.forEach((e=>{$(e.map,((t,a)=>{f.seq.push({type:'handler',for:a,handler:t,options:e.options,domConfig:e.domConfig})}))})),d&&m(d,f.staticSeq),f.seq.forEach((e=>{switch(e.type){case'visible':{let{onMount:t,onState:a}=_({mount:i,state:e.value,onMount:(e,t)=>({leaf:t,value:e,hydration:t.hydration}),onState:(e,t)=>({leaf:e,value:t,hydration:0})});t.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=E(r);if(e=t?t.nextSibling:q(r).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}r.value=e,r.visible=1}L(f,{parentBlockFragment:r,leaf:e,node:r.value,svgRoot:v.isSvgRoot?r.value:null}),t&&l.needToCallNode&&(l.needToCallNode=0,effector.launch({target:Se,params:{element:l.block.value,fns:f.node},page:e,defer:1,scope:e.root.scope})),effector.launch({target:s,params:e,defer:1,page:e,scope:e.root.scope})})),effector.merge([a,t]).watch((({leaf:e,value:t,hydration:a})=>{a||r(t,e.data.ops.visible)}));break}case'attr':case'data':case'style':case'styleVar':{let t=Ce[e.type],a=De.some((({type:t,field:a})=>e.type===t&&e.field===a)),l=_({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})});a?effector.merge([l.onState,l.onMount]).watch((({leaf:a,value:l})=>{t(Te(a),e.field,l)})):j(f,{initCtx(a,l){let n=Te(l);return t(n,e.field,a),n},runOp(a,l){t(l,e.field,a)},hooks:l});break}case'classList':{let t=Ce.classList,a=effector.createStore({prev:'',curr:e.field.getState()}).on(e.field,(({curr:e},t)=>({prev:e,curr:t}))),l=_({mount:s,state:effector.combine({name:a,enabled:e.value}),onMount:(e,t)=>({leaf:t,value:e}),onState:(e,t)=>({leaf:e,value:t})});j(f,{initCtx(e,a){let l=Te(a);return t(l,e.name.curr,e.enabled),l},runOp(e,a){e.name.prev!==e.name.curr&&t(a,e.name.prev,0),t(a,e.name.curr,e.enabled)},hooks:l});break}case'dynamicText':j(f,{initCtx:(t,a)=>G(a,t,e.childIndex),runOp(e,t){I(t.value,e)},hooks:_({mount:s,state:e.value,onMount:(e,t)=>({leaf:t,value:String(e)}),onState:(e,t)=>({leaf:e,value:String(t)})})});break;case'staticText':s.watch((t=>{G(t,e.value,e.childIndex)}));break;case'handler':{let t=e.handler.graphite.meta.nativeTemplate||null;s.watch((a=>{let l=null;if(t){let e=0,n=a;for(;!e&&n;)n.template===t?(e=1,l=n):n=n.parent}else l=null;Te(a).addEventListener(e.for,(t=>{e.options.prevent&&t.preventDefault(),e.options.stop&&t.stopPropagation(),effector.launch({target:e.handler,params:t,page:l,scope:a.root.scope})}),e.domConfig)}));break}}})),i.watch((e=>{let t=e.data;if(!f.visible){let a=t.ops.visible,l=t.block;if(e.hydration){n(1,a);let e,t=E(l);if(e=t?t.nextSibling:q(l).firstChild,'#text'===e.nodeName){let t=e;e=e.nextSibling,t.remove()}l.value=e,l.visible=1}L(f,{parentBlockFragment:l,leaf:e,node:l.value,svgRoot:v.isSvgRoot?l.value:null}),effector.launch({target:s,params:e,defer:1,page:e,scope:e.root.scope}),e.hydration?t.needToCallNode&&(t.needToCallNode=0,effector.launch({target:Se,params:{element:t.block.value,fns:f.node},page:e,defer:1,scope:e.root.scope})):r(1,a)}}))},env:s});N(v)},e.handler=V,e.list=te,e.node=e=>{M(ye,'node');let t=ye.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=le,e.remap=ee,e.route=ae,e.spec=U,e.text=(e,...t)=>{Array.isArray(e)?U({text:ne(e,t)}):U({text:e})},e.tree=({source:e,key:t,child:a,fn:l})=>{let n=le((({store:e})=>{te({source:e,key:t,fn({store:e}){let t=e.map((e=>e[a]||[]));l({store:e,child(){n({store:t})}})}})}));n({store:e})},e.using=(e,t)=>{let a,l,n,r,o,i;if('function'==typeof t)a=t,n=W(),r=0;else{if(!t)throw Error('using() second argument is missing');a=t.fn,n=t.env?t.env:W(),r=t.hydrate,l=t.onComplete,o=t.onRoot,i=t.scope}P(e,'using() first argument is missing');let u={scope:i,env:n,activeSpawns:new Set,childSpawns:{},leafOps:{}},p=e.namespaceURI,d=e.tagName.toLowerCase(),f={type:'using',childTemplates:[],childCount:0,inParentIndex:-1},m=x({name:'using',draft:f,isSvgRoot:'svg'===d,namespace:'http://www.w3.org/2000/svg'===p?'svg':'foreignobject'===d?'foreignObject':'html',fn(e,{mount:t}){a(),t.watch(Oe.using)},env:n}),v={type:'using',child:[],value:e},h=s({onComplete:l}),g=O(m,{parentLeaf:ke||null,mountNode:e,svgRoot:m.isSvgRoot?e:ke?ke.svgRoot:null,leafData:{type:'using',draft:f,element:e,block:v},opGroup:c(h),domSubtree:c(h),hydration:r,root:u});if(o&&o({template:m,leaf:g}),h.onDrain&&!h.rafID){let e=h.onDrain;h.onDrain=null,e()}},e.val=(e,...t)=>t.every((e=>!effector.is.store(e)))?ne(e,t).join(''):effector.combine(t,(t=>ne(e,t).join(''))),e.variant=({source:e,cases:t,key:a})=>{let l;M(ye,'variant'),P(effector.is.unit(e),'variant({source}) should be unit'),l='function'==typeof a?a:null==a?e=>String(e):e=>String(e[a]);let n=0;for(let a in t)'__'!==a?ae({source:e,visible:e=>l(e)===a,fn:t[a]}):n=1;if(n){let a=Object.keys(t);ae({source:e,visible:e=>!a.includes(l(e)),fn:t.__})}},Object.defineProperty(e,'__esModule',{value:1})})); | ||
//# sourceMappingURL=forest.umd.js.map |
@@ -11,2 +11,4 @@ import {Store, Event, Scope} from 'effector' | ||
> | ||
export type ClassListMap = {[cssClass: string]: StoreOrData<boolean>} | ||
export type ClassListArray = Array<Store<string | null> | string> | ||
@@ -66,2 +68,3 @@ export type HandlerMap = | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -98,2 +101,3 @@ }): void | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
handler?: HandlerMap | ||
@@ -100,0 +104,0 @@ fn?: () => void |
{ | ||
"name": "forest", | ||
"version": "0.20.3", | ||
"version": "0.21.0", | ||
"description": "UI engine for web", | ||
@@ -29,2 +29,6 @@ "main": "forest.cjs.js", | ||
"keywords": [ | ||
"business", | ||
"logic", | ||
"data", | ||
"flow", | ||
"state management", | ||
@@ -31,0 +35,0 @@ "state manager", |
137
README.md
@@ -36,2 +36,3 @@ # forest | ||
attr: {type: 'password', placeholder: 'Password'}, | ||
classList: ['w-full', 'py-2', 'px-4'], | ||
handler: {input: change('password')}, | ||
@@ -43,3 +44,5 @@ }) | ||
attr: { | ||
disabled: $fields.map(fields => !(fields.username && fields.password)), | ||
disabled: $fields.map( | ||
fields => !(fields.username && fields.password), | ||
), | ||
}, | ||
@@ -61,6 +64,6 @@ }) | ||
const $fields = createStore({}) | ||
.on(changed, (fields, {name, value}) => ({ | ||
...fields, [name]: value | ||
})) | ||
const $fields = createStore({}).on(changed, (fields, {name, value}) => ({ | ||
...fields, | ||
[name]: value, | ||
})) | ||
@@ -89,3 +92,4 @@ const change = name => changed.prepend(e => ({name, value: e.target.value})) | ||
Start an application from given root dom node. Can accept forked [Scope](https://effector.dev/docs/api/effector/scope). Set `hydrate: true` to reuse `root` html content (useful for ssr) | ||
Start an application from given root dom node. Can accept forked [Scope](https://effector.dev/docs/api/effector/scope). | ||
Set `hydrate: true` to reuse `root` html content (useful for ssr) | ||
@@ -118,2 +122,3 @@ ```typescript | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
data?: PropertyMap | ||
@@ -142,10 +147,18 @@ text?: Property | Property[] | ||
- **attr**: add HTML attributes, e.g. `class` or input's `value`. `{value: createStore('initial')}` will become `"value"="initial"` | ||
- **attr**: add HTML attributes, e.g. `class` or input's `value`. `{value: createStore('initial')}` will | ||
become `"value"="initial"` | ||
- **style**: add inline styles. All `style` objects will be merged to single `style` html attribute. Object fields in camel case will be converted to dash-style, e.g. `{borderRadius: '3px'}` will become `"style"="border-radius: 3px"`. | ||
- **style**: add inline styles. All `style` objects will be merged to single `style` html attribute. Object fields in | ||
camel case will be converted to dash-style, e.g. `{borderRadius: '3px'}` will become `"style"="border-radius: 3px"`. | ||
- **styleVar**: add css variables to inline styles. `{themeColor: createStore('red')}` will become `"style"="--themeColor: red"` | ||
- **styleVar**: add css variables to inline styles. `{themeColor: createStore('red')}` will | ||
become `"style"="--themeColor: red"` | ||
- **data**: add [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes). Object fields in camel case will be converted to dash-style, e.g. `{buttonType: 'outline'}` will become `"data-button-type"="outline"` and might be queried in css in this way: | ||
- **classList**: add class names to `class` attribute. `{active: true}` will become `"class"="active"` | ||
, `['active', 'disabled']` will become `"class"="active disabled"` and so on with `Store` support. | ||
- **data**: add [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes). Object | ||
fields in camel case will be converted to dash-style, e.g. `{buttonType: 'outline'}` will | ||
become `"data-button-type"="outline"` and might be queried in css in this way: | ||
```css | ||
@@ -160,3 +173,4 @@ [data-button-type='outline'] { | ||
- **handler**: add event handlers to dom node. In cases when `preventDefault` or `stopPropagation` is needed, extended form with config object can be used | ||
- **handler**: add event handlers to dom node. In cases when `preventDefault` or `stopPropagation` is needed, extended | ||
form with config object can be used | ||
@@ -191,3 +205,4 @@ ```typescript | ||
Add new properties to dom element. Designed to call from [h](#h) callbacks and has the same fields as in `h(tag, config)`. Can be called as many times as needed | ||
Add new properties to dom element. Designed to call from [h](#h) callbacks and has the same fields as | ||
in `h(tag, config)`. Can be called as many times as needed | ||
@@ -199,2 +214,3 @@ ```typescript | ||
styleVar?: PropertyMap | ||
classList?: ClassListMap | ClassListArray | ||
data?: PropertyMap | ||
@@ -217,2 +233,37 @@ text?: Property | Property[] | ||
#### classList | ||
Property `classList` has two forms, each optionally reactive: | ||
- **object map** | ||
```ts | ||
const $isEnabled = createStore(true) | ||
spec({classList: {first: true, second: $isEnabled}}) | ||
``` | ||
- **array list** | ||
> Be careful, each array item will be treated as a single class name, so it should not have a spaces. | ||
```ts | ||
const $class = createStore('active') | ||
spec({classList: ['size-big', $class]}) | ||
``` | ||
If spec with classList called twice or more, all enabled classes will be merged in the order of appearance.<br/> | ||
Also, `classList` will be merged with static `class` attribute: | ||
```ts | ||
h('div', { | ||
attr: {class: 'first second'}, | ||
classList: ['third'], | ||
fn() { | ||
spec({classList: {fourth: true}}) | ||
}, | ||
}) | ||
// => <div class="first second third fourth"></div> | ||
``` | ||
### list | ||
@@ -237,8 +288,12 @@ | ||
- **key**: field name which value will be used as key for given item | ||
- **fn**: function which will be used as a template for every list item. Receive item value and item key as stores and `fields` as array of stores if provided. All fields are strongly typed and inferred from config definition | ||
- **fields**: array of item field names which will be passed to `fn` as array of separate stores. Useful to avoid `store.map` and [`remap`](#remap) calls | ||
- **fn**: function which will be used as a template for every list item. Receive item value and item key as stores | ||
and `fields` as array of stores if provided. All fields are strongly typed and inferred from config definition | ||
- **fields**: array of item field names which will be passed to `fn` as array of separate stores. Useful to | ||
avoid `store.map` and [`remap`](#remap) calls | ||
### variant | ||
Mount one of given cases by selecting a specific one by the current value of the `key` field of `source` store value. Type of `store` in `cases` functions will be inferred from a case type. Optional default case - `__` (like in [split](https://effector.dev/docs/api/effector/split)) | ||
Mount one of given cases by selecting a specific one by the current value of the `key` field of `source` store value. | ||
Type of `store` in `cases` functions will be inferred from a case type. Optional default case - `__` (like | ||
in [split](https://effector.dev/docs/api/effector/split)) | ||
@@ -249,4 +304,6 @@ ```typescript | ||
key: string | ||
cases: {[caseName: string]: ({store: Store<T>}) => void} | ||
}): void | ||
cases: {[caseName: string]: ({store: Store<T>}) => void | ||
} | ||
}): | ||
void | ||
``` | ||
@@ -256,3 +313,5 @@ | ||
Generalized route is a combination of state and visibility status. `fn` content will be mounted until `visible` called with `source` value will return `true`. In case of store in `visible` field, content will be mounted while that store contain `true`. [variant](#variant) is shorthand for creating several routes at once | ||
Generalized route is a combination of state and visibility status. `fn` content will be mounted until `visible` called | ||
with `source` value will return `true`. In case of store in `visible` field, content will be mounted while that store | ||
contain `true`. [variant](#variant) is shorthand for creating several routes at once | ||
@@ -303,3 +362,5 @@ ```typescript | ||
Method from `forest/server` to render given application to string. Can accept forked [Scope](https://effector.dev/docs/api/effector/scope), in which case `fn` children must be wrapped in [block](#block) to ensure that all units are created before [fork](https://effector.dev/docs/api/effector/fork) call | ||
Method from `forest/server` to render given application to string. Can accept | ||
forked [Scope](https://effector.dev/docs/api/effector/scope), in which case `fn` children must be wrapped | ||
in [block](#block) to ensure that all units are created before [fork](https://effector.dev/docs/api/effector/fork) call | ||
@@ -314,3 +375,5 @@ ```typescript | ||
Helper for retrieving value fields from single store. Shorthand for several `store.map(val => val[fieldName])` calls. Infer types when used with either single key or with `as const`: `const [id, name] = remap(user, ['id', 'name'] as const)` | ||
Helper for retrieving value fields from single store. Shorthand for several `store.map(val => val[fieldName])` calls. | ||
Infer types when used with either single key or | ||
with `as const`: `const [id, name] = remap(user, ['id', 'name'] as const)` | ||
@@ -325,3 +388,4 @@ ```typescript | ||
Helper for joining [properties](#property) to single string with template literals. If only [plain values](#plainproperty) are passed, the method returns `string` | ||
Helper for joining [properties](#property) to single string with template literals. If | ||
only [plain values](#plainproperty) are passed, the method returns `string` | ||
@@ -351,3 +415,5 @@ ```typescript | ||
Value types accepted by methods, which write values to dom properties. Strings are written as is, numbers are converted to strings, `null` and `false` mean no value (property deletion), `true` is used when the specific property value is not needed. | ||
Value types accepted by methods, which write values to dom properties. Strings are written as is, numbers are converted | ||
to strings, `null` and `false` mean no value (property deletion), `true` is used when the specific property value is not | ||
needed. | ||
@@ -373,1 +439,28 @@ ```typescript | ||
``` | ||
### ClassListMap | ||
Object with class names as keys and boolean values, possibly reactive | ||
```typescript | ||
type ClassListMap = {[className: string]: Store<boolean> | boolean} | ||
``` | ||
```ts | ||
spec({ | ||
classList: { | ||
'class-name': true, | ||
'class-name-2': $booleanStore, | ||
}, | ||
}) | ||
``` | ||
### ClassListArray | ||
Array with class names, possibly reactive | ||
```typescript | ||
type ClassListArray = Array<Store<string> | string> | ||
``` | ||
spec({ classList: { classList: ['class-name', $stringStore] } }) |
@@ -1,2 +0,2 @@ | ||
function t(t){switch(t=String(t)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return t.replace(/[^a-zA-Z0-9\-_]/g,'')}}function e(t,e){t.sibling.right=e,t.nextSibling=e}function i(t){return`-${t.toLowerCase()}`}function s(t){switch(t){case'&':return'&';case'<':return'<';case'>':return'>';case'"':return'"';case"'":return''';default:return t}}function n(t){return String(t).replace(c,'')}function l(e,r){if(null!==e.textContent){let t=e.textContent;e.parent&&'script'===e.parent.tagName||(t=String(t).replace(u,s)),r.push(t)}if(e.isFragment){let t=e.firstChild;for(;t;)l(t,r),t=t.sibling.right;return}r.push('<',e.tagName);for(let t in e.attributes)r.push(' ',t,'=','"',n(e.attributes[t]),'"');for(let s in e.dataset)r.push(' ','data-',t(s).replace(g,i),'=','"',n(e.dataset[s]),'"');let h=[];for(let t in e.style){let i=e.style[t];if(t.startsWith('--'))h.push(`${t}: ${i}`);else{let e=t.replace(/[A-Z]/g,(t=>`-${t.toLowerCase()}`));(t.startsWith('webkit')||t.startsWith('moz'))&&(e=`-${e}`),h.push(`${e}: ${i}`)}}if(h.length>0&&r.push(' ','style','=','"',h.join(';'),'"'),r.push('>'),d.includes(e.tagName))return;let a='script'===e.tagName?[]:r,c=e.firstChild;for(;c;)l(c,a),c=c.sibling.right;if('script'===e.tagName){let t=a.join('');r.push(t.replace(o,'<\\/script'))}r.push('</',e.tagName,'>')}function r(t){let e=[];l(t,e);let i=e.join('');return h(t)?`<!DOCTYPE html>${i}`:i}function h(t){if('html'===t.tagName)return 1;if(t.isFragment&&null===t.textContent){let e=t.firstChild;if(e&&t.child.last===e)return h(e)}return 0}Object.defineProperty(exports,'__esModule',{value:1});var a=require('forest');const c=/[\\<>"]/g,g=/[A-Z]/g,u=/[&<>'"]/g,o=/<\/(\s|\\n)*script/gim;class f{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 p,this.value=void 0,this.firstChild=null,this.nextSibling=null,this.isFragment=1,this.attributes=Object.create(null),this.textContent=null,this.__STATIC__=1}cloneNode(){let t=new f;return t.tagName=this.tagName,t.nodeName=this.nodeName,t.namespaceURI=this.namespaceURI,Object.assign(t.dataset,this.dataset),Object.assign(t.style,this.style),t.value=this.value,t.isFragment=this.isFragment,Object.assign(t.attributes,this.attributes),t.textContent=this.textContent,t}after(t){this.sibling.right!==t&&(t.parent&&t.remove(),this.parent&&(this.sibling.right?(this.sibling.right.sibling.left=t,e(t,this.sibling.right)):this.parent.child.last=t,e(this,t),t.sibling.left=this,t.parent=this.parent))}prepend(t){t.parent&&t.remove(),this.child.last?(this.child.first.sibling.left=t,e(t,this.child.first)):(this.child.first=t,this.child.last=t),this.child.first=t,this.firstChild=t,t.parent=this}remove(){if(!this.parent)return;let{parent:t}=this;t.child.first===this&&t.child.last===this?(t.firstChild=null,t.child.first=null,t.child.last=null):t.child.first===this?(t.child.first=this.sibling.right,t.firstChild=this.sibling.right,this.sibling.right.sibling.left=null):t.child.last===this?(t.child.last=this.sibling.left,e(this.sibling.left,null)):(this.sibling.right.sibling.left=this.sibling.left,e(this.sibling.left,this.sibling.right)),this.sibling.left=null,e(this,null),this.parent=null}addEventListener(t,e,i){}removeEventListener(t,e,i){}setAttribute(e,i){this.attributes[t(e)]=n(i)}removeAttribute(e){delete this.attributes[t(e)]}replaceWith(t){if(!this.parent)return;let{parent:i}=this;t.parent&&t.remove(),i.child.first===this&&i.child.last===this?(i.firstChild=t,i.child.first=t,i.child.last=t):i.child.first===this?(i.child.first=t,i.firstChild=t,this.sibling.right.sibling.left=t):i.child.last===this?(i.child.last=t,e(this.sibling.left,t)):(this.sibling.right.sibling.left=t,e(this.sibling.left,t)),t.sibling.left=this.sibling.left,e(t,this.sibling.right),t.parent=i,this.sibling.left=null,e(this,null),this.parent=null}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 f;return e.nodeName='#text',e.textContent=this.textContent.slice(t),this.textContent=this.textContent.slice(0,t),this.after(e),e}}class p{setProperty(e,i){this[t(e)]=n(i)}removeProperty(e){delete this[t(e)]}}const d=['area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'];exports.renderStatic=e=>{let i,s={document:{createTextNode(t){let e=new f;return e.textContent=String(t),e.nodeName='#text',e},createElement(e){let i=new f;return i.tagName=t(e),i.isFragment=0,i},createElementNS(e,i){switch(e){case'http://www.w3.org/1999/xhtml':case'http://www.w3.org/2000/svg':break;default:e='http://www.w3.org/1999/xhtml'}let s=new f;return s.tagName=t(i),s.namespaceURI=e,s.isFragment=0,s},createDocumentFragment:()=>new f}},n=s.document.createDocumentFragment();return'object'==typeof e&&null!==e&&(i=e.scope,e=e.fn),new Promise((t=>{a.using(n,{fn:e,env:s,scope:i,onComplete(){t(r(n))}})}))}; | ||
function t(t){switch(t=String(t)){case'__proto__':case'__defineGetter__':case'__defineSetter__':case'constructor':case'prototype':case'hasOwnProperty':case'toString':case'valueOf':case'setProperty':case'removeProperty':return'forbidden';default:return t.replace(/[^a-zA-Z0-9\-_]/g,'')}}function e(t,e){t.sibling.right=e,t.nextSibling=e}function i(t){return`-${t.toLowerCase()}`}function s(t){switch(t){case'&':return'&';case'<':return'<';case'>':return'>';case'"':return'"';case"'":return''';default:return t}}function l(t){return String(t).replace(c,'')}function n(e,r){if(null!==e.textContent){let t=e.textContent;e.parent&&'script'===e.parent.tagName||(t=String(t).replace(u,s)),r.push(t)}if(e.isFragment){let t=e.firstChild;for(;t;)n(t,r),t=t.sibling.right;return}r.push('<',e.tagName);let a=0;for(let t in e.attributes){let i=e.attributes[t],s='';'class'===t&&e.classList.classes.size>0?(s=l(`${i} ${e.classList._toString()}`),a=1):s=l(i),r.push(' ',t,'=','"',s,'"')}if(!a&&e.classList.classes.size>0){let t=e.classList._toString();r.push(' class=','"',l(t),'"')}for(let s in e.dataset)r.push(' ','data-',t(s).replace(o,i),'=','"',l(e.dataset[s]),'"');let h=[];for(let t in e.style){let i=e.style[t];if(t.startsWith('--'))h.push(`${t}: ${i}`);else{let e=t.replace(/[A-Z]/g,(t=>`-${t.toLowerCase()}`));(t.startsWith('webkit')||t.startsWith('moz'))&&(e=`-${e}`),h.push(`${e}: ${i}`)}}if(h.length>0&&r.push(' ','style','=','"',h.join(';'),'"'),r.push('>'),m.includes(e.tagName))return;let c='script'===e.tagName?[]:r,f=e.firstChild;for(;f;)n(f,c),f=f.sibling.right;if('script'===e.tagName){let t=c.join('');r.push(t.replace(g,'<\\/script'))}r.push('</',e.tagName,'>')}function r(t){let e=[];n(t,e);let i=e.join('');return a(t)?`<!DOCTYPE html>${i}`:i}function a(t){if('html'===t.tagName)return 1;if(t.isFragment&&null===t.textContent){let e=t.firstChild;if(e&&t.child.last===e)return a(e)}return 0}Object.defineProperty(exports,'__esModule',{value:1});var h=require('forest');const c=/[\\<>"]/g,o=/[A-Z]/g,u=/[&<>'"]/g,g=/<\/(\s|\\n)*script/gim;class f{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.classList=new p,this.style=new d,this.value=void 0,this.firstChild=null,this.nextSibling=null,this.isFragment=1,this.attributes=Object.create(null),this.textContent=null,this.__STATIC__=1}cloneNode(){let t=new f;return t.tagName=this.tagName,t.nodeName=this.nodeName,t.namespaceURI=this.namespaceURI,Object.assign(t.dataset,this.dataset),Object.assign(t.style,this.style),t.classList=this.classList._clone(),t.value=this.value,t.isFragment=this.isFragment,Object.assign(t.attributes,this.attributes),t.textContent=this.textContent,t}after(t){this.sibling.right!==t&&(t.parent&&t.remove(),this.parent&&(this.sibling.right?(this.sibling.right.sibling.left=t,e(t,this.sibling.right)):this.parent.child.last=t,e(this,t),t.sibling.left=this,t.parent=this.parent))}prepend(t){t.parent&&t.remove(),this.child.last?(this.child.first.sibling.left=t,e(t,this.child.first)):(this.child.first=t,this.child.last=t),this.child.first=t,this.firstChild=t,t.parent=this}remove(){if(!this.parent)return;let{parent:t}=this;t.child.first===this&&t.child.last===this?(t.firstChild=null,t.child.first=null,t.child.last=null):t.child.first===this?(t.child.first=this.sibling.right,t.firstChild=this.sibling.right,this.sibling.right.sibling.left=null):t.child.last===this?(t.child.last=this.sibling.left,e(this.sibling.left,null)):(this.sibling.right.sibling.left=this.sibling.left,e(this.sibling.left,this.sibling.right)),this.sibling.left=null,e(this,null),this.parent=null}addEventListener(t,e,i){}removeEventListener(t,e,i){}setAttribute(e,i){this.attributes[t(e)]=l(i)}removeAttribute(e){delete this.attributes[t(e)]}replaceWith(t){if(!this.parent)return;let{parent:i}=this;t.parent&&t.remove(),i.child.first===this&&i.child.last===this?(i.firstChild=t,i.child.first=t,i.child.last=t):i.child.first===this?(i.child.first=t,i.firstChild=t,this.sibling.right.sibling.left=t):i.child.last===this?(i.child.last=t,e(this.sibling.left,t)):(this.sibling.right.sibling.left=t,e(this.sibling.left,t)),t.sibling.left=this.sibling.left,e(t,this.sibling.right),t.parent=i,this.sibling.left=null,e(this,null),this.parent=null}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 f;return e.nodeName='#text',e.textContent=this.textContent.slice(t),this.textContent=this.textContent.slice(0,t),this.after(e),e}}class p{constructor(){this.classes=new Set}add(t){this.classes.add(t)}remove(t){this.classes.delete(t)}_clone(){let t=new p;return t.classes=new Set(this.classes),t}_toString(){return Array.from(this.classes).join(' ')}}class d{setProperty(e,i){this[t(e)]=l(i)}removeProperty(e){delete this[t(e)]}}const m=['area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'];exports.renderStatic=e=>{let i,s={document:{createTextNode(t){let e=new f;return e.textContent=String(t),e.nodeName='#text',e},createElement(e){let i=new f;return i.tagName=t(e),i.isFragment=0,i},createElementNS(e,i){switch(e){case'http://www.w3.org/1999/xhtml':case'http://www.w3.org/2000/svg':break;default:e='http://www.w3.org/1999/xhtml'}let s=new f;return s.tagName=t(i),s.namespaceURI=e,s.isFragment=0,s},createDocumentFragment:()=>new f}},l=s.document.createDocumentFragment();return'object'==typeof e&&null!==e&&(i=e.scope,e=e.fn),new Promise((t=>{h.using(l,{fn:e,env:s,scope:i,onComplete(){t(r(l))}})}))}; | ||
//# 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
663631
1370
449