tutuca 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- class Qt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Mt extends Qt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Mt({...this.binds,key:t})}withKey(t){return new Mt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class ae extends Qt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new Ne(this.field,t)}withKey(t){return new ke(this.field,t)}}class Ve extends Qt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class ke extends Ve{}class Ne extends Ve{}var D=Symbol("NONE");class me extends Qt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return s!==D&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return r===D||s===D?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class m{constructor(t=[]){this.steps=t}concat(t){return new m(this.steps.concat(t))}popStep(){return new m(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,D),r===D)return e;return r}setValue(t,e){let r=Array(this.steps.length),s=t;for(let n=0;n<this.steps.length;n++)if(r[n]=s,s=this.steps[n].lookup(s,D),s===D)return t;let i=e;for(let n=this.steps.length-1;n>=0;n--)i=this.steps[n].setValue(r[n],i),r[n]=i;return i}buildStack(t){let e=t.it,r=e;for(let s of this.steps){if(r=s.lookup(r,D),r===D)return console.warn("bad PathItem",{root:e,curVal:r,step:s,path:this}),null;s.updateBindings(r,t.binds.head.bindings),t=t.enter(r,{},s.isFrame)}return t}static fromNodeAndEventName(t,e,r,s,i,n=!0){let h=[],u=0,o=[],f=null,c=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=Cs(t.previousSibling),{eid:w,cid:S,vid:q}=t.dataset;if(w!==void 0)o.push(w);if(S!==void 0){let St=i.getComponentForId(+S,q);if(_){if(f=Eh(St,o,q,e),f===null&&n)return jh;_=!1}let Ot=qh(St,c,q);if(Ot)h.push(Ot);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new m(h.reverse()),f]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return m.fromNodeAndEventName(h,n,e,r,s,i)}}var Ys={};function Cs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Cs(t.previousSibling);if(e!==Ys)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Ys}function Eh(t,e,r,s){for(let i of e){let n=t.getEventForId(+i,r).getHandlersFor(s);if(n!==null)return n}return null}function qh(t,e,r){for(let s=0;s<e.length;s++){let i=t.getNodeForId(+e[s].nid,r),n=i.pathInNext?s+1:s,{si:h,sk:u,nid:o}=e[n],f=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(f!==null)return h!==void 0?f.withIndex(+h):u?f.withKey(u):f}return null}var jh=[null,null];class ve{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new ae(t))}index(t,e){return this.add(new Ne(t,e))}key(t,e){return this.add(new ke(t,e))}}var Ah=/^[a-zA-Z][a-zA-Z0-9_]*$/,nt=(t)=>Ah.test(t),$h=/^-?[0-9]+(\.[0-9]+)?$/,Bs=(t,e)=>er.parse(t,e),Gt=(t,e)=>new J(t),Uh=(t,e)=>nt(t)?new ht(t):null,Ih=(t,e)=>nt(t)?new ks(t):null,Kh=(t,e)=>nt(t)?new sr(t):null,Lh=(t,e)=>nt(t)?new vs(t):null,Dh=(t,e)=>nt(t)?new ti(t):null,Wh=(t,e)=>nt(t)?new ei(t):null,Rh=(t,e)=>nt(t)?new Ns(t):null;class xs{constructor(){this.allowFieldOnly(),this.bindValIt=new sr("it"),this.nullConstVal=new J(null)}const(t){return new J(t)}allowFieldOnly(){this.okField=!0,this.okBind=!1,this.okComputed=!1,this.okDyn=!1,this.okType=!1,this.okRequest=!1,this.okName=!1,this.okConst=!1,this.okStrTpl=!1,this.okSeqAccess=!1}parseIfOk(t,e,r,s){return r?s(t,e):null}_parseSeqAccess(t,e){if(!this.okSeqAccess)return null;let r=t.indexOf("[");this.allowFieldOnly();let s=this.parse(t.slice(0,r),e),i=this.parse(t.slice(r+1,-1),e);return s&&i?new ri(s,i):null}parse(t,e){switch(Jh(t)){case si:return this.parseIfOk(t,e,this.okStrTpl,Bs);case ni:return this.parseIfOk(t,e,this.okStrTpl,Gt);case ii:return this._parseSeqAccess(t,e);case ye:return this.parseIfOk(t,e,this.okStrTpl,Bs)}let r=t.charCodeAt(0);switch(r){case 94:{let i=e.frame.macroVars?.[t.slice(1)];if(i!==void 0)return this.parse(i,e);return null}case 126:return this.parseIfOk(t.slice(1),e,this.okStrTpl,Gt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Gt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Kh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Lh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Dh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Wh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Rh)}let s=$h.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Gt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Gt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Uh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Ih);return null}parseDynamic(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.parse(t,e)}parseEach(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.okDyn=!0,this.parse(t,e)}allowHandlerArg(){this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okType=!0,this.okRequest=!0,this.okName=!0,this.okConst=!0}parseHandlerArg(t,e){return this.allowHandlerArg(),this.parse(t,e)}_parseHandler(t,e,r){this.allowFieldOnly(),this.okName=!0;let s=this.parse(t,e);return s&&(s.toRawFieldVal?s.toRawFieldVal():new r(s.name))}parseHandlerName(t,e){return this._parseHandler(t,e,Ps)}parseAlter(t,e){return this._parseHandler(t,e,Fs)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class ge{render(t,e){}eval(t){}toPathItem(){return null}}class J extends ge{constructor(t){super();this.value=t}render(t,e){return this.value}eval(t){return this.value}toString(){let t=this.value;return typeof t==="string"?`'${t}'`:`${t}`}}class tr extends ge{}class er extends tr{constructor(t){super();this.vals=t}render(t,e){return this.eval(t)}eval(t){let e=Array(this.vals.length);for(let r=0;r<this.vals.length;r++)e[r]=this.vals[r]?.eval(t,"");return e.join("")}static parse(t,e){let r=t.split(/(\{[^}]+\})/g),s=Array(r.length),i=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?p.parseText(h.slice(1,-1),e):new J(h);s[n]=o,i&&=o instanceof J}return i?new J(s.map((n)=>n.value).join("")):new er(s)}}class ht extends tr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Ps extends ht{eval(t){return t.getInputHandler(this.name)??Vs("input",this.name)}}class Fs extends ht{eval(t){return t.getAlterHandler(this.name)??Vs("alter",this.name)}}var Vs=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ks extends ht{eval(t){return t.lookupType(this.name)}}class Ns extends ht{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class ms extends ht{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class rr extends ge{render(t,e){return this.eval(t)}}class Yt extends rr{constructor(t){super();this.name=t}}class sr extends Yt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class vs extends Yt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ti extends Yt{eval(t){return t.lookupField(this.name)}toPathItem(){return new ae(this.name)}toRawFieldVal(){return new ms(this.name)}toString(){return`.${this.name}`}}class ei extends Yt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class ri extends rr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new me(this.seqVal.name,this.keyVal.name)}eval(t){let e=this.keyVal.eval(t);return this.seqVal.eval(t).get(e,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}}var si=0,ii=1,ye=2,ni=3;function Jh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return ye;e+=1;break;case 93:if(r>0||e===0)return ye;r+=1;break;case 123:return si;case 125:return ni}if(e>0||r>0)return e===1&&r===1?ii:ye;return-1}var p=new xs;class bt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return ur(e).parse(t,r)}isConstant(){return!1}}var Th="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",Hh=new Set(Th.split(","));class hi{constructor(t){this.clear(t)}clear(t){this.px=t,this.attrs=null,this.hasDynamic=!1,this.wrapperAttrs=null,this.textChild=null,this.eachAttr=null,this.ifAttr=null,this.events=null}parseAttr(t,e,r=!1){let s=r?p.parseAll(e,this.px):p.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new we(t,s)),this.hasDynamic||=!(s instanceof J)}pushWrapper(t,e,r){let s={name:t,val:r,raw:e};return this.wrapperAttrs??=[],this.wrapperAttrs.push(s),s}parseIf(t,e){let r=p.parseCondValue(e,this.px);if(r)this.ifAttr=new fi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=p.parseAttr(t,this.px)??Ct}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Ct}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=or.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new pe("data-eid",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new oi(p.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,p.const(t));return;case"push-view":this.pushWrapper("push-view",t,p.parseText(t,this.px));return;case"text":this.textChild=p.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,p.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,p.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,p.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=p.parseAlter(t,this.px);else this.pushWrapper("scope",t,p.parseAlter(t,this.px));return;case"when":this._parseWhen(t);return;case"loop-with":this._parseLoopWith(t);return;case"then":this.parseThen(t);return;case"else":this.parseElse(t);return}if(e.startsWith("on."))this.parseEvent(e,t);else if(e.startsWith("if."))this.parseIf(e,t);else if(e.startsWith("then."))this.parseThen(t);else if(e.startsWith("else."))this.parseElse(t)}_parseWhen(t){if(this.eachAttr!==null)this.eachAttr.whenVal=p.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=p.parseAlter(t,this.px)}parse(t,e=!1){for(let{name:n,value:h}of t){let u=n.charCodeAt(0);if(u===58)this.parseAttr(n===":viewbox"?"viewBox":n.slice(1),h,e);else if(u===64)this.parseDirective(h,n.slice(1));else{this.attrs??=[];let o=h===""&&Hh.has(n)?!0:h;this.attrs.push(new pe(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new ui(r):nr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class nr extends bt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new nr(e)}setDataAttr(t,e){this.items[t]=e}toMacroVars(){let t={};for(let e in this.items)t[e]=`'${this.items[e]}'`;return t}isConstant(){return!0}}class ui extends bt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new pe(t,new J(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class hr{constructor(t){this.name=t}}class we extends hr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class pe extends we{}class oi extends we{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Ct=p.nullConstVal;class fi extends hr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ct}get anyBranchIsSet(){return this.thenVal!==Ct||this.elseVal!==Ct}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var ir=null;function ur(t){return ir??=new hi(t),ir.clear(t),ir}class or{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=p.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);p.allowHandlerArg();for(let h=0;h<s.length;h++){let u=p.parse(s[h],e);n[h]=u!==null?u:p.nullConstVal}return new or(i,n)}}class fr{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class Et{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class xt extends Et{constructor(t){super();this.v=t}render(t,e){return e.renderText(this.v)}isWhiteSpace(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.v=""}isConstant(){return!0}setDataAttr(t,e){}}class Bt extends xt{render(t,e){return e.renderComment(this.v)}}function Zh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new wr(r);else r.optimize()}}function ar(t){if(t.isConstant())return new wr(t);return t.optimize(),t}class yr extends Et{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Zh(this.childs)}}class de extends yr{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class ze extends yr{render(t,e){return e.renderFragment(this.childs.map((r)=>r?.render(t,e)))}setDataAttr(t,e){for(let r of this.childs)r.setDataAttr(t,e)}}var cr=(t)=>t.length===1?t[0]:new ze(t),Xh=/^[a-zA-Z][a-zA-Z0-9-]*$/,ci=null;class v extends Et{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){ci??=e.newDOMParser();let r=ci.parseFromString(t,"text/html").body.childNodes;return v.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new xt(t.textContent);else if(e.isCommentNode(t))return new Bt(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=v.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return cr(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Oe(null,p.const(u),cr(n));case"text":{let f=p.parseText(u,e);return f!==null?new lr(null,f):null}case"render":return e.addNodeIf(wi,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(di,p.bindValIt,o);case"render-each":return pr.parse(e,p,u,o,s)}return new Bt(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let f=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[f]??cr(n)}let[u,o]=bt.parse(s,e,!0);return e.onAttributes(u,o,null),_i(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Xh.test(i)){let[h,u,o]=bt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new lr(null,o));let f=i!=="PRE"?Bh(n):n;return _i(new de(i.toLowerCase(),h,f),e,u)}return new Bt(`Error: InvalidTagName ${i}`)}}function _i(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Qh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Qh(t,e){let r=Ch[t.name],s=r.register?e.addNodeIf(r,t.val):t.val&&new r(null,t.val);if(s!==null&&t.name==="each")s.iterInfo.enrichWithVal=t.enrichWithVal??null,s.iterInfo.whenVal=t.whenVal??null,s.iterInfo.loopWithVal=t.loopWithVal??null;return s}class pi extends Et{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Bt(`bad macro: ${e}`);else{let n={...i.defaults,...r};this.node=i.expand(this.px.enterMacro(e,n,s));for(let h in this.dataAttrs)this.node.setDataAttr(h,this.dataAttrs[h])}}render(t,e){return this.node.render(t,e)}setDataAttr(t,e){this.dataAttrs[t]=e}isConstant(){return this.node.isConstant()}optimize(){this.node=ar(this.node)}}class gr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return v.parse(this.rawView,t)}}class Se extends v{constructor(t,e,r){super(t,e);this.viewId=r}}class wi extends Se{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class di extends Se{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class pr extends Se{constructor(t,e,r){super(t,e,r);this.iterInfo=new dr(e,null,null,null)}render(t,e){return e.renderEach(t,this.iterInfo,this.nodeId,this.viewId)}static parse(t,e,r,s,i){let n=t.addNodeIf(pr,e.parseEach(r,t),s);if(n!==null){let h=ur(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=i.getNamedItem("when");u&&h._parseWhen(u.value);let o=i.getNamedItem("loop-with");o&&h._parseLoopWith(o.value),n.iterInfo.whenVal=h.eachAttr.whenVal??null,n.iterInfo.loopWithVal=h.eachAttr.loopWithVal??null}return n}}class lr extends v{render(t,e){return e.renderText(this.val.eval(t))}}class wr extends Et{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ut extends v{constructor(t,e,r=null){super(t,e);this.node=r}wrapNode(t){this.node=t}setDataAttr(t,e){this.node.setDataAttr(t,e)}optimize(){this.node=ar(this.node)}static register=!1}class zi extends ut{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Si extends ut{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Oi extends ut{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Oe extends ut{optimize(){this.node.optimize()}}class Mi extends ut{render(t,e){let r=this.val.eval(t)?.call(t.it)??{};return this.node.render(t.enter(t.it,r,!1),e)}toPathItem(){return new Mt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class bi extends ut{constructor(t,e){super(t,e);this.iterInfo=new dr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Mt({})}static register=!0}class dr{constructor(t,e,r,s){this.val=t,this.whenVal=e,this.loopWithVal=r,this.enrichWithVal=s}eval(t){let e=this.val.eval(t)??[],r=this.whenVal?.eval(t)??Gh,s=this.loopWithVal?.eval(t)??Yh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Gh=(t,e,r)=>!0,Yh=(t)=>({seq:t}),Ch={slot:Oe,show:zi,hide:Si,each:bi,scope:Mi,"push-view":Oi};class ot{constructor(t,e,r,s,i,n,h,u){this.nodes=s??[],this.events=i??[],this.macroNodes=n??[],this.parent=u??null,this.frame=h??{},this.DOMParser=t??globalThis.DOMParser,this.Text=e??globalThis.Text,this.Comment=r??globalThis.Comment,this.cacheConstNodes=!0}isInsideMacro(t){return this.frame.macroName===t||this.parent?.isInsideMacro(t)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new ot(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this)}newDOMParser(){return new this.DOMParser}isTextNode(t){return t instanceof this.Text}isCommentNode(t){return t instanceof this.Comment}addNodeIf(t,e,r){if(e!==null){let s=this.nodes.length,i=new t(s,e,r);return this.nodes.push(i),i}return null}registerEvents(){let t=this.events.length,e=new Ei(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new ze(s)};for(let h of r)if(h instanceof Oe)i[h.val.value]=h.node;else if(!(h instanceof xt)||!h.isWhiteSpace())s.push(h);let n=new pi(t,e,i,this);return this.macroNodes.push(n),n}compile(t){for(let e=0;e<this.macroNodes.length;e++)this.macroNodes[e].compile(t)}*genEventNames(){for(let t of this.events)yield*t.genEventNames()}getEventForId(t){return this.events[t]??null}getNodeForId(t){return this.nodes[t]??null}onAttributes(t,e,r){}}var _r=(t)=>t instanceof xt&&t.isWhiteSpace(),li=(t)=>t instanceof de||t instanceof ze&&t.childs[0]instanceof de;function Bh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(_r(t[0]))r=1,s=!0;if(e>1&&_r(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(_r(n)&&li(t[i-1])&&li(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Me{constructor(t,e,r="",s=null,i=null){this.name=t,this.anode=s,this.style=r,this.ctx=i,this.rawView=e}compile(t,e,r){if(this.ctx=t,this.anode=v.parse(this.rawView,t),this.anode.setDataAttr("data-cid",r),this.anode.setDataAttr("data-vid",this.name),this.ctx.compile(e),t.cacheConstNodes)this.anode=ar(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ei{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new qi(t,e,r))}*genEventNames(){for(let t of this.handlers)yield t.name}getHandlersFor(t){let e=null;for(let r of this.handlers)if(r.handlesEventName(t))e??=[],e.push(r);return e}}class qi{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=Nh(t,r),this.modifiers=r}handlesEventName(t){return this.name===t}getHandlerAndArgs(t,e){let r=this.handlerCall.getHandlerAndArgs(t,e);return r[0]=this.modifierWrapper(r[0],e),r}}var xh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),be=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,ai=(t)=>be((e)=>e.e.key===t),yi=be(({e:t})=>xh&&t.metaKey||t.ctrlKey),Ph=be(({e:t})=>t.metaKey),Fh=be(({e:t})=>t.altKey),gi={ctrl:yi,cmd:yi,meta:Ph,alt:Fh},Vh={keydown:{send:ai("Enter"),cancel:ai("Escape"),...gi},click:{...gi}},kh=(t,e)=>t;function Nh(t,e){if(e.length===0)return kh;let r=Vh[t]??{},s=(i,n,h,u)=>n.apply(i,h);for(let i of e){let n=r[i];if(n!==void 0)s=n(s)}return(i,n)=>function(...h){return s(this,i,h,n)}}class zr{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,s){}evict(){return{hit:0,miss:0,badKey:0}}}class Sr{constructor(){this.hit=this.miss=this.badKey=0,this.map=new WeakMap}_returnValue(t){if(t===void 0)this.miss+=1;else this.hit+=1;return t}get(t,e){return this._returnValue(this.map.get(t)?.[e])}set(t,e,r){let s=this.map.get(t);if(s)s[e]=r;else if(typeof t==="object")this.map.set(t,{[e]:r});else this.badKey+=1}get2(t,e,r){return this._returnValue(this.map.get(t)?.get?.(e)?.[r])}set2(t,e,r,s){let i=this.map.get(t);if(i){let n=i.get(e);if(n)n[r]=s;else i.set(e,{[r]:s})}else if(typeof t==="object"&&typeof e==="object"){let n=new WeakMap;n.set(e,{[r]:s}),this.map.set(t,n)}else this.badKey+=1}evict(){let{hit:t,miss:e,badKey:r}=this;return this.hit=this.miss=this.badKey=0,this.map=new WeakMap,{hit:t,miss:e,badKey:r}}}class Or{getKey(t,e,r){return r.call(t)}}class Mr{constructor(){this.map=new WeakMap}getKey(t,e,r){let s=this.map.get(t);if(s){let n=s[e];if(n!==void 0)return n;let h=r.call(t)??null;return s[e]=h,h}let i=r.call(t)??null;return this.map.set(t,{[e]:i}),i}}class Ee{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Mr}setNullComputedCache(){this.computedCache=new Or}registerComponent(t){t.Class.prototype[this.getComponentSymbol]=()=>t,this.byId.set(t.id,t)}getComponentForId(t){return this.byId.get(t)??null}getCompFor(t){return t?.[this.getComponentSymbol]?.()??null}getOnEnterFor(t){let e=this.getCompFor(t);return e?e.on.stackEnter:Ai}getInputHandlerFor(t,e){return this.getCompFor(t)?.input[e]??null}getAlterHandlerFor(t,e){return this.getCompFor(t)?.alter[e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getCompFor(t)?.computed[e];return r?this.computedCache.getKey(t,e,r):null}compileStyles(){let t=[];for(let e of this.byId.values())t.push(e.compileStyle());return t.join(`
2
- `)}}class qe{constructor(t=new Ee,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new qe(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let s=t[r];s.scope=this.enter(),this.comps.registerComponent(s),this.byName[s.name]=s;let i=e[s.name];if(i)this.byName[i]=s}}registerMacros(t){Object.assign(this.macros,t)}getCompFor(t){return this.comps.getCompFor(t)}registerRequestHandlers(t){for(let e in t)this.reqsByName[e]=new fr(e,t[e])}lookupRequest(t){return this.reqsByName[t]??this.parent?.lookupRequest(t)??null}lookupComponent(t){return this.byName[t]??this.parent?.lookupComponent(t)??null}lookupMacro(t){return this.macros[t]??this.parent?.lookupMacro(t)??null}}class br{constructor(t,e,r){this.name=t,this.val=e,this.symbol=r}getSymbol(t){return this.symbol}evalAndBind(t,e){e[this.getSymbol(t)]=this.val.eval(t)}}class ji extends br{constructor(t,e,r,s){super(t,e,null);this.compName=r,this.dynName=s}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var qt=(t)=>typeof t==="string",mh=0;class Er{constructor(t,e,r,s={},i="",n="",h="",u={},o={},f={},c={},_={},l={},a={},y={}){this.id=mh++,this.name=t,this.Class=e,this.views={main:new Me("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=f,this.bubble=c,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Ai};for(let w in s){let S=s[w],{view:q,style:St}=qt(S)?{view:S}:S;this.views[w]=new Me(w,q,St)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(qt(r)){let s=p.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new br(e,s,Symbol(e))}else if(qt(r?.default)&&qt(r?.for)){let s=p.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(qt(i)&&qt(n))this.dynamic[e]=new ji(e,s,i,n)}}for(let e in this.views)this.views[e].compile(new t,this.scope,this.id)}make(t,e){return this.Class.make(t,e)}getView(t){return this.views[t]??this.views.main}getEventForId(t,e="main"){return this.getView(e).ctx.getEventForId(t)}getNodeForId(t,e="main"){return this.getView(e).ctx.getNodeForId(t)}compileStyle(){let{id:t,commonStyle:e,globalStyle:r,views:s}=this,i=e?[`[data-cid="${t}"]{${e}}`]:[];if(r!=="")i.push(r);for(let n in s){let{style:h}=s[n];if(h!=="")i.push(`[data-cid="${t}"][data-vid="${n}"]{${h}}`)}return i.join(`
3
- `)}}function Ai(t){return t}var $i=Symbol("STOP"),Ar=Symbol("NEXT");class Pt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Pt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===$i?e:s===Ar?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class qr{constructor(t,e,r){this.it=t,this.bindings=e,this.isFrame=r}lookup(t){let e=this.bindings[t];return e===void 0?this.isFrame?$i:Ar:e}}class jr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Ar:e}}class H{constructor(t,e,r,s,i,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=s,this.views=i,this.ctx=n;let h=[...i].join("");this.viewsId=h==="main"?"":h}_enrichOnEnter(){return this.comps.getOnEnterFor(this.it).call(this.it,this)??this}upToFrameBinds(){let{comps:t,binds:e,dynBinds:r,views:s,ctx:i}=this;return e.head.isFrame?this:new H(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Pt(new qr(e,{it:e},!0),null),i=new Pt(new jr({}),null),n=new Pt("main",null);return new H(t,e,s,i,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:s,binds:i,dynBinds:n,views:h,ctx:u}=this,o=i.push(new qr(t,e,r));return new H(s,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:s,dynBinds:i,views:n,ctx:h}=this;return new H(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let f of t)r.dynamic[f].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new jr(e));return new H(s,i,n,o,h,u)}lookupDynamic(t){let e=this.comps.getCompFor(this.it)?.dynamic[t];return e?this.dynBinds.lookup(e.getSymbol(this))??e.val.eval(this):null}lookupBind(t){return this.binds.lookup(t)}lookupType(t){return this.comps.getCompFor(this.it).scope.lookupComponent(t)}lookupFieldRaw(t){return this.it[t]??null}lookupField(t){let e=this.lookupFieldRaw(t);return e instanceof Function?e.call(this.it):e}lookupName(t){return this.ctx.lookupName(t)}lookupComputed(t){let e=this.binds.head.isFrame?this.binds.head:this.binds.tail.head;return this.comps.lookupComputed(e.it,t)}getInputHandler(t){return this.comps.getInputHandlerFor(this.it,t)}getAlterHandler(t){return this.comps.getAlterHandlerFor(this.it,t)}lookupRequest(t){return this.comps.getRequestFor(this.it,t)}lookupBestView(t,e){for(let r of this.views){let s=t[r];if(s!==void 0)return s}return t[e]}}class Ii{constructor(t){this.value=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.value;this.value=t;for(let s of this.changeSubs)s({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class Ur{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ii(e),this.onTransactionPushed=()=>{}}pushTransaction(t){return this.transactions.push(t),this.onTransactionPushed(t),t}pushLogic(t,e,r=[],s={},i=null){return this.pushTransaction(new Lr(t,this,e,r,i,s))}pushBubble(t,e,r=[],s={},i=null){let n=s.skipSelf?{...s,skipSelf:!1}:s;return this.pushTransaction(new Di(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??vh(e),o=s?.onResName??e,f=(c,_,l,a,y)=>{let S=new Li(t,this,c??_,c?[l]:[a,y],i);return this.pushTransaction(S)};try{let c=await u.fn.apply(null,r);return f(s?.onOkName,o,c,c,null)}catch(c){return f(s?.onErrorName,o,c,null,c)}}get hasPendingTransactions(){return this.transactions.length>0}transactNext(){if(this.hasPendingTransactions)this.transact(this.transactions.shift())}transactAll(){while(this.hasPendingTransactions)this.transact(this.transactions.shift())}transact(t){let e=this.state.value,r=t.run(e,this.comps);if(r!==void 0)this.state.set(r,{transaction:t}),t.afterTransaction();else console.warn("undefined new state",{curState:e,transaction:t})}transactInputNow(t,e,r,s){this.transact(new Ki(t,e,r,this,s))}}function vh(t){return()=>{throw Error(`Request not found: ${t}`)}}function tu(){return this}class Ir{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Wi,this._task}getCompletionPromise(){return this.task.promise}setParent(t){this.parentTransaction=t,t.task.addDep(this.task)}run(t,e){return this.updateRootValue(t,e)}afterTransaction(){}buildRootStack(t,e){return H.root(e,t)}buildStack(t,e){let r=this.path.buildStack(this.buildRootStack(t,e));return r?r.upToFrameBinds():null}callHandler(t,e,r){let[s,i]=this.getHandlerAndArgs(t,e,r);return s.apply(e,i)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),s=this.callHandler(t,r,e);return this._task?.complete?.({value:s,old:r}),r!==s?this.path.setValue(t,s):t}lookupName(t){return null}}var eu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ui=(t)=>Number.isNaN(t)?null:t;function $r(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Ki extends Ir{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return H.root(e,t,this)}getHandlerAndArgs(t,e,r){let s=this.buildStack(t,r),[i,n]=this.handler.getHandlerAndArgs(s,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new Dr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return $r(e);case"valueAsInt":return Ui(parseInt($r(e),10));case"valueAsFloat":return Ui(parseFloat($r(e)));case"target":return e.target;case"event":return e;case"isAlt":return e.altKey;case"isShift":return e.shiftKey;case"isCtrl":case"isCmd":return eu&&e.metaKey||e.ctrlKey;case"key":return e.key;case"keyCode":return e.keyCode;case"isUpKey":return e.key==="ArrowUp";case"isDownKey":return e.key==="ArrowDown";case"isSend":return e.key==="Enter";case"isCancel":return e.key==="Escape";case"isTabKey":return e.key==="Tab";case"ctx":return new Wr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Kr extends Ir{constructor(t,e,r,s,i,n={}){super(t,e,i);this.name=r,this.args=s,this.opts=n}handlerProp=null;getHandlerForName(t){return t?.[this.handlerProp]?.[this.name]??tu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Wr(this.path,this.transactor,this)]]}}class Li extends Kr{handlerProp="response"}class Lr extends Kr{handlerProp="logic";run(t,e){return this.opts.skipSelf?t:this.updateRootValue(t,e)}afterTransaction(){let{path:t,name:e,args:r,opts:s}=this;if(s.bubbles&&t.steps.length>0)this.transactor.pushBubble(t.popStep(),e,r,s,this)}}class Di extends Lr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Wi{constructor(t){this.info=t,this.deps=[],this.value=this.resolve=this.reject=null,this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r}),this.isCompleted=!1}addDep(t){console.assert(!this.isCompleted,"addDep for completed task",this,t),this.deps.push(t),t.promise.then((e)=>this._check())}complete(t){this.value=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class Dr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Ri(this)}logic(t,e,r){return this.logicAtPath(this.path,t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}logicAtPath(t,e,r,s){return this.transactor.pushLogic(t,e,r,s,this.parent)}request(t,e,r){return this.requestAtPath(this.path,t,e,r)}requestAtPath(t,e,r,s){return this.transactor.pushRequest(t,e,r,s,this.parent)}lookupTypeFor(t,e){return this.transactor.comps.getCompFor(e).scope.lookupComponent(t)}}class Wr extends Dr{stopPropagation(){return this.parent.stopPropagation()}}class Ri extends ve{constructor(t){super();this.dispatcher=t}logic(t,e,r){return this.dispatcher.logicAtPath(this.buildPath(),t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}buildPath(){return this.dispatcher.path.concat(this.pathChanges)}}class Rr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new qe(r),this.transactor=new Ur(r,null),this.ParseContext=i,this.renderer=s,this.renderFn=e,this.maxEventNodeDepth=1/0,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(["dragstart","dragover","dragend"]),this.dragInfo=this.curDragOver=null,this.transactor.onTransactionPushed=(n)=>{if(this._transactNextBatchId===null)this._scheduleNextTransactionBatchExecution()},this._compiled=!1}get state(){return this.transactor.state}handleEvent(t){let e=t.type==="dragstart",r=t.type==="dragover",s=t.type==="dragend",{rootNode:i,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||s),[o,f]=m.fromEvent(t,i,n,h,u);if(r){let c=ru(t.target,this.rootNode,50);if(c!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=c,c.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let c=this.state.value,_=o.lookup(c),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(c));this.dragInfo=new Ji(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&f!==null)for(let c of f)this.transactor.transactInputNow(o,t,c,this.dragInfo)}makeStack(t){return H.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.value,e=this.makeStack(t);return this.renderFn(this.renderer.renderRoot(e,t),this.rootNode)}onChange(t){this.transactor.state.onChange(t)}compile(){for(let t of this.comps.byId.values()){t.compile(this.ParseContext);for(let e in t.views)for(let r of t.views[e].ctx.genEventNames())this._eventNames.add(r)}this._compiled=!0}start(t){if(!this._compiled)this.compile();for(let e of this._eventNames)this.rootNode.addEventListener(e,this);if(this.onChange((e)=>{if(e.value!==e.old)this.render()}),je("tutuca-app",this.comps.compileStyles(),t?.head??document.head),t?.noCache)this.renderer.setNullCache(),this.comps.setNullComputedCache();else this.startCacheEvictionInterval();this.render()}stop(){this.stopCacheEvictionInterval();for(let t of this._eventNames)this.rootNode.removeEventListener(t,this)}dispatchLogicAtRoot(t,e,r){return this.transactor.pushLogic(new m([]),t,e,r)}registerComponents(t,e){let r=this.compStack.enter();return r.registerComponents(t,e),r}_transactNextBatch(t=10){this._transactNextBatchId=null;let e=Date.now(),r=this.transactor;while(r.hasPendingTransactions&&Date.now()-e<t)r.transactNext();if(r.hasPendingTransactions)this._scheduleNextTransactionBatchExecution()}_scheduleNextTransactionBatchExecution(){this._transactNextBatchId=setTimeout(()=>this._transactNextBatch(),0)}startCacheEvictionInterval(t=30000){this._evictCacheId=setInterval(()=>this.renderer.cache.evict(),t)}stopCacheEvictionInterval(){clearInterval(this._evictCacheId),this._evictCacheId=null}}function je(t,e,r=document.head){let s=document.createElement("style"),i=r.querySelector(`#${t}`);if(i)r.removeChild(i);s.id=t,s.innerHTML=e,r.appendChild(s)}function ru(t,e,r){let s=t;while(r-- >0&&s!==e){if(s.dataset?.droptarget!==void 0)return s;s=s.parentNode}return null}class Ji{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class Ae extends ot{constructor(...t){super(...t);this.classes=new Set}_addClasses(t){for(let e of t.split(/\s+/))this.classes.add(e)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,c=new Ae(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return c.classes=this.classes,c}onAttributes(t,e,r){if(Array.isArray(t.items))for(let s of t.items){if(s.name!=="class")continue;let{value:i,thenVal:n,elseVal:h}=s;if(n!==void 0)this._maybeAddVal(n),this._maybeAddVal(h);else this._maybeAddVal(i)}else{let s=t.items.class;if(s)this._addClasses(s)}}_maybeAddVal(t){if(!this._maybeAddStrTpl(t)&&typeof t?.value==="string")this._addClasses(t.value)}_maybeAddStrTpl(t){if(t?.vals!==void 0){for(let e of t.vals)if(e instanceof J&&e.value!=="")this._addClasses(e.value);return!0}return!1}}function Ft(t,e){if(!t)throw Error(e)}function $(t){Ft(t!==1/0,"Cannot perform this action with an infinite size.")}function Ti(t,e,r,s,i,n){return $(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var su=(t,e)=>e,iu=(t,e)=>[e,t],Jr=(t)=>function(...e){return!t.apply(this,e)},Hi=(t)=>function(...e){return-t.apply(this,e)};function un(t,e){if(t===void 0&&e===void 0)return 0;if(t===void 0)return 1;if(e===void 0)return-1;return t>e?1:t<e?-1:0}var Zi=(t,e)=>t<e?1:t>e?-1:0,U={done:!0,value:void 0};class on{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new on(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return U})}var nu=L(()=>U),ft=()=>nu;function Te(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return U;return r.value=e++,r})}function te(t,e){return M((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function fn(t){if(Array.isArray(t))return!0;return!!He(t)}var hu=(t)=>!!(t&&typeof t.next==="function");function cn(t){return He(t)?.call(t)}function He(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function uu(t){let e=He(t);return e&&e===t.entries}function ou(t){let e=He(t);return e&&e===t.keys}var ee="delete",z=5,E=1<<z,I=E-1,g={},Cr=()=>({value:!1});function T(t){if(t)t.value=!0}class Ze{}function At(t){if(t.size===void 0)t.size=t.__iterate(_n);return t.size}function et(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?At(t)+e:e}var _n=()=>!0,ln=(t)=>t<0||Object.is(t,-0),re=(t,e,r)=>(t===0&&!ln(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),an=(t,e,r)=>t===void 0?r:ln(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Dt=(t,e)=>an(t,e,0),se=(t,e)=>an(t,e,e),yn="@@__IMMUTABLE_ITERABLE__@@",Ke="@@__IMMUTABLE_KEYED__@@",Le="@@__IMMUTABLE_INDEXED__@@",rt="@@__IMMUTABLE_ORDERED__@@",ie="@@__IMMUTABLE_SEQ__@@",gn="@@__IMMUTABLE_LIST__@@",pn="@@__IMMUTABLE_MAP__@@",wn="@@__IMMUTABLE_SET__@@",dn="@@__IMMUTABLE_STACK__@@",zn="@@__IMMUTABLE_RECORD__@@";function x(t,e){return typeof t==="object"&&t!==null&&e in t}var W=(t)=>x(t,yn),d=(t)=>x(t,Ke),j=(t)=>x(t,Le),kr=(t)=>d(t)||j(t),F=(t)=>x(t,rt),Nr=(t)=>x(t,ie),mr=(t)=>x(t,gn),ne=(t)=>x(t,pn),vr=(t)=>x(t,wn),ts=(t)=>x(t,dn),at=(t)=>x(t,zn),P=(t)=>W(t)||at(t),Xe=(t)=>ne(t)&&F(t),Sn=(t)=>vr(t)&&F(t),Xi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function On(t){let e=C(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Rt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return te(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function Mn(t,e,r){let s=C(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,g);return h===g?n:e.call(r,h,i,t)},s.__iterate=function(i,n){return t.__iterate((h,u)=>i(e.call(r,h,u,t),u,this),n)},s.__iteratorUncached=function(i){return te(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function bn(t,e){let r=C(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=On(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Rt,r.__iterate=function(s,i){let n=0;if(i)At(t);return t.__iterate((h,u)=>s(h,e?u:i?this.size-++n:n++,this),!i)},r.__iteratorUncached=function(s){let i=0;if(s)At(t);let n=this.size;return te(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function En(t,e,r,s){let i=t.size;if(re(e,r,i))return t;if(i===void 0&&(e<0||r<0))return En(t.toSeq().cacheResult(),e,r,s);let n=Dt(e,i),u=se(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=C(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&Nr(t)&&o>=0)f.get=function(c,_){return c=et(this,c),c>=0&&c<o?t.get(c+n,_):_};return f.__iterateUncached=function(c,_){if(o!==0&&_)return this.cacheResult().__iterate(c,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,w)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(y,s?w:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ft();let _=t.__iterator(c),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return U;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let w=_.next();if(w.done)return!1;return a++,y[0]=a-1,y[1]=w.value[1],!0})},f}function Qi(t,e,r){if(!e)e=un;let s=d(t),i=0,n=t.toSeq().map((h,u)=>[u,h,i++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(s?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),s?ns(n):j(t)?lt(n):kt(n)}function $e(t,e,r){if(!e)e=un;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Gi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Gi(e,s,i)?i:s)}function Gi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Tr(t,e,r,s){let i=C(t),n=new he(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),f=0,c;while(!(c=o.next()).done)if(h(c.value[1],f++,this)===!1)break;return f},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=V(_);return cn(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return M((_)=>{let l=s;for(let a=0;a<u.length;a++)f[a]=u[a].next(),l=s?l&&f[a].done:l||f[a].done;if(l)return!1;for(let a=0;a<f.length;a++)c[a]=f[a].value;return _[0]=o++,_[1]=e(...c),!0})},i}function qn(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function fu(t){if(!t||typeof t!=="object"||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let r=e,s=Object.getPrototypeOf(e);while(s!==null)r=s,s=Object.getPrototypeOf(r);return r===e}var st=(t)=>typeof t==="object"&&(P(t)||Array.isArray(t)||fu(t));function jn(t){if(qn(t)&&typeof t!=="string")return t;if(F(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var cu=(t,e)=>P(t)?t.has(e):st(t)&&Object.hasOwn(t,e);function An(t,e,r){return P(t)?t.get(e,r):!cu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function es(t,e,r){let s=jn(e),i=0;while(i!==s.length)if(t=An(t,s[i++],g),t===g)return r;return t}var $n=(t,e)=>es(t,e,g)!==g;function A(t,e){if(t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1;if(typeof t.valueOf==="function"&&typeof e.valueOf==="function"){if(t=t.valueOf(),e=e.valueOf(),t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1}return!!(Xi(t)&&Xi(e)&&t.equals(e))}function De(t){if(!t||typeof t!=="object")return t;if(!W(t)){if(!st(t))return t;t=it(t)}if(d(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=De(s)}),r}let e=[];return t.__iterate((r)=>{e.push(De(r))}),e}function rs(t,e){if(t===e)return!0;if(!W(e)||t.size!==void 0&&e.size!==void 0&&t.size!==e.size||t.__hash!==void 0&&e.__hash!==void 0&&t.__hash!==e.__hash||d(t)!==d(e)||j(t)!==j(e)||F(t)!==F(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!kr(t);if(F(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&A(f[1],u)&&(r||A(f[0],o))})&&h.next().done)}let s=!1;if(t.size===void 0)if(e.size===void 0){if(typeof t.cacheResult==="function")t.cacheResult()}else{s=!0;let h=t;t=e,e=h}let i=!0,n=e.__iterate((h,u)=>{if(r?!t.has(h):s?!A(h,t.get(u,g)):!A(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var Qe=(t)=>t>>>1&1073741824|t&3221225471;function Z(t){if(t===null||t===void 0)return Yi(t);if(typeof t.hashCode==="function")return Qe(t.hashCode(t));let e=gu(t);if(e===null||e===void 0)return Yi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return _u(e);case"string":return e.length>pu?lu(e):Br(e);case"object":case"function":return yu(e);case"symbol":return au(e);default:if(typeof e.toString==="function")return Br(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Yi=(t)=>t===null?1108378658:1108378659;function _u(t){if(Number.isNaN(t)||t===1/0)return 0;let e=t|0;if(e!==t)e^=t*4294967295;while(t>4294967295)t/=4294967295,e^=t;return Qe(e)}function lu(t){let e=Xr[t];if(e===void 0){if(e=Br(t),Zr===wu)Zr=0,Xr={};Zr++,Xr[t]=e}return e}function Br(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return Qe(e)}function au(t){let e=Bi[t];if(e!==void 0)return e;return e=Un(),Bi[t]=e,e}function yu(t){let e=Ci.get(t);if(e!==void 0)return e;return e=Un(),Ci.set(t,e),e}var gu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Un(){let t=++Hr;if(Hr&1073741824)Hr=0;return t}var Ci=new WeakMap,Bi=Object.create(null),Hr=0,pu=16,wu=255,Zr=0,Xr={};function du(t){if(t.size===1/0)return 0;let e=F(t),r=d(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+xi(Z(i),Z(n))|0}:(i,n)=>{s=s+xi(Z(i),Z(n))|0}:e?(i)=>{s=31*s+Z(i)|0}:(i)=>{s=s+Z(i)|0}),zu(t.size,s)}var xi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function zu(t,e){return e=Math.imul(e,3432918353),e=Math.imul(e<<15|e>>>-15,461845907),e=Math.imul(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),e=Qe(e^e>>>16),e}function Vt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:Nr(t)?e:t.create?t.create(e):t.constructor(e),Su=(t,e)=>O(t,(d(t)?Q:j(t)?yt:gt)(e)),Pi=(...t)=>t,V=(t)=>W(t)?t:it(t);class X{size=0;static{this.prototype[yn]=!0,this.prototype.__toStringMapper=Vt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return rs(this,t)}hashCode(){return this.__hash??(this.__hash=du(this))}toArray(){$(this.size);let t=Array(this.size||0),e=d(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Wn(this)}toJS(){return De(this)}toKeyedSeq(){return new cs(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}toOrderedMap(){throw Error("toOrderedMap: not patched — import CollectionConversions")}toOrderedSet(){throw Error("toOrderedSet: not patched — import CollectionConversions")}toSet(){throw Error("toSet: not patched — import CollectionConversions")}toSetSeq(){return new Rn(this)}toSeq(){return j(this)?this.toIndexedSeq():d(this)?this.toKeyedSeq():this.toSetSeq()}toStack(){throw Error("toStack: not patched — import CollectionConversions")}toList(){throw Error("toList: not patched — import CollectionConversions")}toString(){return"[Collection]"}__toString(t,e){if(this.size===0)return`${t}${e}`;return`${t} ${this.toSeq().map(this.__toStringMapper).join(", ")} ${e}`}concat(...t){let e=d(this),r=[this,...t].map((s)=>{if(!W(s))s=e?Kn(s):Ln(Array.isArray(s)?s:[s]);else if(e)s=Q(s);return s}).filter((s)=>s.size!==0);if(r.length===0)return this;if(r.length===1){let s=r[0];if(s===this||e&&d(s)||j(this)&&j(s))return s}return O(this,new Dn(r))}includes(t){return this.some((e)=>A(e,t))}every(t,e){$(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=d(this),i=C(r);if(s)i.has=(n)=>{let h=r.get(n,g);return h!==g&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,g);return u!==g&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,f)=>{if(t.call(e,o,f,r))return u++,n(o,s?f:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return M((o)=>{while(!0){let f=h.next();if(f.done)return!1;let c=f.value[0],_=f.value[1];if(t.call(e,_,c,r))return o[0]=s?c:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=d(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>Su(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return $(this.size),this.__iterate(e?t.bind(e):t)}join(t){$(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[0],e})}map(t,e){return O(this,Mn(this,t,e))}reduce(t,e=g,r){return Ti(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Ti(this,t,e,r,e===g,!0)}reverse(){return O(this,bn(this,d(this)))}slice(t,e){return O(this,En(this,t,e,d(this)))}some(t,e){$(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return O(this,Qi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return At(t?this.toSeq().filter(t,e):this)}countBy(t,e){throw Error("countBy: not patched — import CollectionConversions")}entrySeq(){let t=this;if(t._cache)return new he(t._cache);let e=t.toSeq().map(iu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Jr(t),e)}findEntry(t,e,r){let s=r;return this.__iterate((i,n,h)=>{if(t.call(e,i,n,h))return s=[n,i],!1}),s}findKey(t,e){let r=this.findEntry(t,e);return r&&r[0]}findLast(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)}findLastEntry(t,e,r){return this.toKeyedSeq().reverse().findEntry(t,e,r)}findLastKey(t,e){return this.toKeyedSeq().reverse().findKey(t,e)}first(t){return this.find(_n,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(d(this)?Q:j(this)?yt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=d(this),s=C(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(f,c){f.__iterate((_,l)=>{if((!t||c<t)&&W(_))o(_,c+1);else if(h++,i(_,r?l:h-1,s)===!1)u=!0;if(u)return!1},n)}return o(e,0),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=0,h=[{iterator:e.__iterator(i),depth:0}];return M((u)=>{while(h.length>0){let o=h[h.length-1],f=o.iterator.next();if(f.done){h.pop();continue}let c=f.value[1];if((!t||o.depth<t)&&W(c)){h.push({iterator:c.__iterator(i),depth:o.depth+1});continue}return u[0]=r?f.value[0]:n++,u[1]=c,!0}return!1})},O(this,s)}fromEntrySeq(){return new Jn(this)}get(t,e){return this.find((r,s)=>A(s,t),void 0,e)}getIn(t,e){return es(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return $n(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:V(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:V(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>A(e,t))}keySeq(){return this.toSeq().map(su).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return $e(this,t)}maxBy(t,e){return $e(this,e,t)}min(t){return $e(this,t?Hi(t):Zi)}minBy(t,e){return $e(this,e?Hi(e):Zi,t)}rest(){return this.slice(1)}skip(t){return t===0?this:this.slice(Math.max(0,t))}skipLast(t){return t===0?this:this.slice(0,-Math.max(0,t))}skipWhile(t,e){let r=this,s=d(this),i=C(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((f,c)=>{if(u&&t.call(e,f,c,this))return;return u=!1,o++,n(f,s?c:o-1,this)},h),o},i.__iteratorUncached=function(n){if(n)return this.cacheResult().__iterator(n);let h=r.__iterator(n),u=0,o=this,f=!0;return M((c)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(f&&t.call(e,a,l,o))continue;return f=!1,c[0]=s?l:u++,c[1]=a,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(Jr(t),e)}sortBy(t,e){return O(this,Qi(this,e,t))}take(t){return this.slice(0,Math.max(0,t))}takeLast(t){return this.slice(-Math.max(0,t))}takeWhile(t,e){let r=this,s=C(r);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,i(u,o,this)},n),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=r.__iterator(i),h=this,u=!1;return L(()=>{if(u)return U;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,U;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(Jr(t),e)}update(t){return t(this)}valueSeq(){return this.toIndexedSeq()}__iterate(t,e=!1){let r=this.__iterator(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterator(t=!1){throw Error("CollectionImpl does not implement __iterator. Use a subclass instead.")}}var Q=(t)=>d(t)?t:ns(t);class ss extends X{static{this.prototype[Ke]=!0,this.prototype.__toStringMapper=(t,e)=>`${Vt(e)}: ${Vt(t)}`,this.prototype[Symbol.iterator]=X.prototype.entries,this.prototype.toJSON=function(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,On(this))}mapEntries(t,e){let r=0;return O(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return O(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var yt=(t)=>j(t)?t:lt(t);class $t extends X{static{this.prototype[Le]=!0,this.prototype[rt]=!0}toKeyedSeq(){return new cs(this,!1)}findIndex(t,e){let r=this.findEntry(t,e);return r?r[0]:-1}indexOf(t){let e=this.keyOf(t);return e===void 0?-1:e}lastIndexOf(t){let e=this.lastKeyOf(t);return e===void 0?-1:e}splice(t,e=g,...r){if(t===void 0)return this;let s=e!==g;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Dt(t,t<0?this.count():this.size);let i=this.slice(0,t);return O(this,!s?i:i.concat(r,this.slice(t+e)))}findLastIndex(t,e){let r=this.findLastEntry(t,e);return r?r[0]:-1}first(t){return this.get(0,t)}get(t,e){return t=et(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?e:this.find((r,s)=>s===t,void 0,e)}has(t){return t=et(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)}interpose(t){let e=this,r=C(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(s,i){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(s(t,n++,this)===!1)return!1}return h=!1,s(u,n++,this)},i),n},r.__iteratorUncached=function(s){let i=e.__iterator(s),n=0,h=!0,u,o=!1;return M((f)=>{if(o)return o=!1,f[0]=n++,f[1]=u,!0;let c=i.next();if(c.done)return!1;let _=c.value[1];if(!h)return u=_,o=!0,f[0]=n++,f[1]=t,!0;return h=!1,f[0]=n++,f[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=Tr(this.toSeq(),lt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return O(this,s)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(Pi,...t)}zipAll(...t){let e=[this,...t];return O(this,Tr(this,Pi,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,Tr(this,t,r))}}var gt=(t)=>W(t)&&!kr(t)?t:kt(t);class Ge extends X{static{this.prototype.has=X.prototype.includes,this.prototype.contains=X.prototype.includes,this.prototype.keys=Ge.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}V.Keyed=Q;V.Indexed=yt;V.Set=gt;var Qr=$t.prototype,it=(t)=>t===void 0||t===null?os():P(t)?t.toSeq():Ou(t),C=(t)=>Object.create((d(t)?Wt:j(t)?pt:hs).prototype);class ct extends X{static{this.prototype[ie]=!0}toSeq(){return this}toString(){return this.__toString("Seq {","}")}cacheResult(){if(!this._cache&&this.__iterateUncached)this._cache=this.entrySeq().toArray(),this.size=this._cache.length;return this}__iterateUncached(t,e){let r=this.__iteratorUncached(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterate(t,e){let r=this._cache;if(r){let s=r.length,i=0;while(i!==s){let n=r[e?s-++i:i++];if(t(n[1],n[0],this)===!1)break}return i}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,s=0,i={done:!1,value:void 0};return L(()=>{if(s===r)return U;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var is={cacheResult:ct.prototype.cacheResult,__iterateUncached:ct.prototype.__iterateUncached,__iterate:ct.prototype.__iterate,__iterator:ct.prototype.__iterator},ns=(t)=>t===void 0||t===null?os().toKeyedSeq():W(t)?d(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Kn(t);class Wt extends ss{static{this.prototype[ie]=!0,Object.assign(this.prototype,is)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?os():W(t)?d(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Ln(t);lt.of=(...t)=>lt(t);class pt extends $t{static{this.prototype[ie]=!0,Object.assign(this.prototype,is)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var kt=(t)=>(W(t)&&!kr(t)?t:lt(t)).toSetSeq();kt.of=(...t)=>kt(t);class hs extends Ge{static{this.prototype[ie]=!0,Object.assign(this.prototype,is)}toSeq(){return this}toSetSeq(){return this}}it.isSeq=Nr;it.Keyed=ns;it.Set=kt;it.Indexed=lt;class he extends pt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[et(this,t)]:e}__iterateUncached(t,e){let r=this._array,s=r.length,i=0;while(i!==s){let n=e?s-++i:i++;if(t(r[n],n,this)===!1)break}return i}__iteratorUncached(t){let e=this._array,r=e.length,s=0;return M((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class us extends Wt{static{this.prototype[rt]=!0}constructor(t){super();let e=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];this._object=t,this._keys=e,this.size=e.length}get(t,e){if(e!==void 0&&!this.has(t))return e;return this._object[t]}has(t){return Object.hasOwn(this._object,t)}__iterateUncached(t,e){let r=this._object,s=this._keys,i=s.length,n=0;while(n!==i){let h=s[e?i-++n:n++];if(t(r[h],h,this)===!1)break}return n}__iteratorUncached(t){let e=this._object,r=this._keys,s=r.length,i=0;return M((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class In extends pt{constructor(t){super();this._collection=t,this.size=t.length||t.size}__iterateUncached(t,e){if(e)return this.cacheResult().__iterate(t,e);let r=0;for(let s of this._collection){if(t(s,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=cn(e);if(!hu(r))return ft();let s=0;return M((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var os=()=>new he([]),fs=(t)=>qn(t)?new he(t):fn(t)?new In(t):void 0;function Kn(t){let e=fs(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new us(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Ln(t){let e=fs(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Ou(t){let e=fs(t);if(e)return uu(t)?e.fromEntrySeq():ou(t)?e.toSetSeq():e;if(typeof t==="object")return new us(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Dn extends ct{constructor(t){super();let e=[],r=0,s=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),s){let u=h.size;if(u!==void 0)r+=u;else s=!1}}else if(e.push(n),s){let h=n.size;if(h!==void 0)r+=h;else s=!1}this._wrappedIterables=e,this.size=s?r:void 0;let i=this._wrappedIterables[0];if(i[Ke])this[Ke]=!0;if(i[Le])this[Le]=!0;if(i[rt])this[rt]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!d(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ft();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!d(this),s=0,i=e[0].__iterator(t);function n(){while(s<e.length){let h=i.next();if(!h.done)return h;if(s++,s<e.length)i=e[s].__iterator(t)}return}if(r){let h=0;return M((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return L(()=>n()||U)}}class cs extends Wt{static{this.prototype[rt]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Rt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=bn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=Mn(this,t,e);if(!this._useKeys)r.valueSeq=()=>this._iter.toSeq().map(t,e);return r}__iterateUncached(t,e){return this._iter.__iterate(t,e)}__iteratorUncached(t){return this._iter.__iterator(t)}}class Wn extends pt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Rt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)At(this);let s=this.size;return this._iter.__iterate((i)=>{let n=e?s-++r:r++;return t(i,n,this)},e),r}__iteratorUncached(t){let e=0;if(t)At(this);let r=this.size;return te(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Rn extends hs{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Rt.call(this)}has(t){return this._iter.includes(t)}__iterateUncached(t,e){return this._iter.__iterate((r)=>t(r,r,this),e)}__iteratorUncached(t){return te(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Jn extends Wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Rt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){Fi(s),r++;let i=W(s);return t(i?s.get(1):s[1],i?s.get(0):s[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){Fi(i);let n=W(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Rt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ct.prototype.cacheResult.call(this)}function Fi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var Y=(t)=>t===void 0||t===null?G():ne(t)&&!F(t)?t:G().withMutations((e)=>{let r=Q(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});class _s extends ss{static{dt(this,{asImmutable:ue,asMutable:oe,deleteIn:Ut,merge:xr,mergeWith:Yn,mergeDeep:Bn,mergeDeepWith:xn,mergeDeepIn:Es,mergeIn:bs,setIn:Ss,update:Os,updateIn:Ms,wasAltered:zs,withMutations:fe,removeIn:Ut,concat:xr,[pn]:!0,[ee]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,s){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return Y(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,Z(t),t,e):e}set(t,e){return ki(this,t,e)}remove(t){return ki(this,t,g)}deleteAll(t){let e=V(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return G()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ft();return Ue(this._root,!1,0)}values(){if(!this._root)return ft();return Ue(this._root,!1,1)}entries(){if(!this._root)return ft();return Ue(this._root,!1)}__iterator(t){if(!this._root)return ft();return Ue(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return G();return this.__ownerID=t,this.__altered=!1,this}return ys(this.size,this._root,t,this.__hash)}}Y.isMap=ne;class ls{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Tn(this.entries,r,s)}iterate(t,e){return Hn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&c===1)return;if(!_&&!u&&c>=Au)return Mu(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new ls(t,a)}}class Ye{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Zn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&I),n=this.bitmap;return(n&i)===0?s:this.nodes[mi(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=1<<u,f=this.bitmap,c=(f&o)!==0;if(!c&&i===g)return this;let _=mi(f&o-1),l=this.nodes,a=c?l[_]:void 0,y=gs(a,t,e+z,r,s,i,n,h);if(y===a)return this;if(!c&&y&&l.length>=$u)return Eu(t,l,f,u,y);if(c&&!y&&l.length===2&&Ni(l[_^1]))return l[_^1];if(c&&y&&l.length===1&&Ni(y))return y;let w=t&&t===this.ownerID,S=c?y?f:f^o:f|o,q=c?y?Xn(l,_,y,w):ju(l,_,w):qu(l,_,y,w);if(w)return this.bitmap=S,this.nodes=q,this;return new Ye(t,S,q)}}class as{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Zn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&I,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=i===g,f=this.nodes,c=f[u];if(o&&!c)return this;let _=gs(c,t,e+z,r,s,i,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<Uu)return bu(t,f,l,u)}let a=t&&t===this.ownerID,y=Xn(f,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new as(t,l,y)}}class Ce{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Tn(this.entries,r,s)}iterate(t,e){return Hn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return T(h),T(n),ps(this,t,e,r,[s,i])}let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&c===2)return new wt(t,this.keyHash,o[f^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ce(t,this.keyHash,a)}}class wt{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}iterate(t,e){return t(this.entry)}get(t,e,r,s){return A(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=A(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(T(h),u){T(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new wt(t,this.keyHash,[s,i])}return T(n),ps(this,t,e,Z(s),[s,i])}}function Tn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(A(e,t[s][0]))return t[s][1];return r}function Hn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(e(t[r?i-s:s])===!1)return!1}function Zn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(t[r?i-s:s]?.iterate(e,r)===!1)return!1}function Ue(t,e,r){let s={node:t,index:0,__prev:null},i=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return L(()=>{while(s){let h=s.node,u=s.index++,o;if(h.entry){if(u===0)return n.value=i(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=i(h.entries[e?o-u:u]),n}else if(o=h.nodes.length-1,u<=o){let f=h.nodes[e?o-u:u];if(f){if(f.entry)return n.value=i(f.entry),n;s={node:f,index:0,__prev:s}}continue}s=s.__prev}return U})}var ys=(t,e,r,s)=>new _s(t,e,r,s),Vi,G=()=>Vi||(Vi=ys(0));function ki(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new ls(t.__ownerID,[[e,r]])}else{let n=Cr(),h=Cr();if(s=gs(t._root,t.__ownerID,0,Z(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===g?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?ys(i,s):G()}function gs(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return T(u),T(h),new wt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var Ni=(t)=>t.constructor===wt||t.constructor===Ce;function ps(t,e,r,s,i){if(t.keyHash===s)return new Ce(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&I,h=(r===0?s:s>>>r)&I,u=new wt(e,s,i),o=n===h?[ps(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new Ye(e,1<<n|1<<h,o)}function Mu(t,e,r,s){if(!t)t=new Ze;let i=new wt(t,Z(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,Z(n),n,h);return i}function bu(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,f=e.length;u<f;u++,o<<=1){let c=e[u];if(c!==void 0&&u!==s)i|=o,h[n++]=c}return new Ye(t,i,h)}function Eu(t,e,r,s,i){let n=0,h=Array(E);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[s]=i,new as(t,n+1,h)}function mi(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function Xn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function qu(t,e,r,s){let i=t.length+1;if(s&&e+1===i)return t[e]=r,t;let n=Array(i),h=0;for(let u=0;u<i;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function ju(t,e,r){let s=t.length-1;if(r&&e===s)return t.pop(),t;let i=Array(s),n=0;for(let h=0;h<s;h++){if(h===e)n=1;i[h]=t[h+n]}return i}var Au=E/4,$u=E/2,Uu=E/4;function We(t){if(Array.isArray(t))return t.slice();return{...t}}var ws=(t,e,r)=>ds(t,e,Iu(r));function ds(t,e,r){if(!st(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(P(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?yt:Q,h=s?(u)=>{if(i===t)i=We(i);i.push(u)}:(u,o)=>{let f=Object.hasOwn(i,o),c=f&&r?r(i[o],u,o):u;if(!f||c!==i[o]){if(i===t)i=We(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function Iu(t){function e(r,s,i){return st(r)&&st(s)&&Ku(r,s)?ds(r,[s],e):t?t(r,s,i):s}return e}function Ku(t,e){let r=it(t),s=it(e);return j(r)===j(s)&&d(r)===d(s)}function Lu(t,e){if(!st(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=We(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Du(t,e,r){if(!st(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=We(t);return s[e]=r,s}function Jt(t,e,r,s){if(!s)s=r,r=void 0;let i=Qn(P(t),t,jn(e),0,r,s);return i===g?r:i}function Qn(t,e,r,s,i,n){let h=e===g;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!st(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(Vt)}]: ${e}`);let u=r[s],o=h?g:An(e,u,g),f=Qn(o===g?t:P(o),o,r,s+1,i,n);if(f===o)return e;if(f===g)return Lu(e,u);let c=h?t?G():{}:e;return Du(c,u,f)}var Wu=(t,e)=>Jt(t,e,()=>g),Ru=(t,e,r)=>Jt(t,e,g,()=>r);function Gn(t,e,r,s){return Jt(t,[e],r,s)}function ue(){return this.__ensureOwner()}function oe(){return this.__ownerID?this:this.__ensureOwner(new Ze)}function zs(){return this.__altered}function fe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Ju(t,e){return es(this,t,e)}function Tu(t){return $n(this,t)}function Ut(t){return Wu(this,t)}function Ss(t,e){return Ru(this,t,e)}function Os(t,e,r){return typeof t==="function"?t(this):Gn(this,t,e,r)}function Ms(t,e,r){return Jt(this,t,e,r)}function vi(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function xr(...t){return Cn(this,t)}function Yn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Cn(this,e,t)}function Cn(t,e,r){let s=[];for(let i of e){let n=Q(i);if(n.size!==0)s.push(n)}if(s.length===0)return t;if(t.toSeq().size===0&&!t.__ownerID&&s.length===1)return at(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Gn(i,u,g,(o)=>o===g?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function Bn(...t){return ws(this,t)}function xn(t,...e){return ws(this,e,t)}function bs(t,...e){return Jt(this,t,G(),(r)=>ds(r,e))}function Es(t,...e){return Jt(this,t,G(),(r)=>ws(r,e))}function dt(t,e){Object.assign(t.prototype,e)}var K=(t)=>{let e=Nt();if(t===void 0||t===null)return e;if(mr(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if($(s),s>0&&s<E)return ce(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};K.of=(...t)=>K(t);class Pn extends $t{static{dt(this,{asImmutable:ue,asMutable:oe,deleteIn:Ut,mergeDeepIn:Es,mergeIn:bs,setIn:Ss,update:Os,updateIn:Ms,wasAltered:zs,withMutations:fe,removeIn:Ut,[gn]:!0,[ee]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return K(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=et(this,t),t>=0&&t<this.size){t+=this._origin;let r=kn(this,t);return r&&r.array[t&I]}return e}set(t,e){return Zu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return Nt()}push(...t){let e=this.size;return this.withMutations((r)=>{tt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return tt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{tt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return tt(this,1)}shuffle(t=Math.random){return this.withMutations((e)=>{let r=e.size,s,i;while(r)s=Math.floor(t()*r--),i=e.get(s),e.set(s,e.get(r)),e.set(r,i)})}concat(...t){let e=[];for(let r of t){let s=yt(typeof r!=="string"&&fn(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return K(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return tt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(re(t,e,r))return this;return tt(this,Dt(t,r),se(e,r))}__iterate(t,e){let r=e?this.size:0;return Hu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=tn(this,t);return M((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return tn(this,!1)}keys(){return Te(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Nt();return this.__ownerID=t,this.__altered=!1,this}return ce(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}K.isList=mr;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&I;if(s>=this.array.length)return new _t([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-z,r),n===u&&i)return this}if(i&&!n)return this;let h=It(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:E)||this.array.length===0)return this;let s=r-1>>>e&I;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=It(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function tn(t,e){let{_origin:r,_capacity:s}=t,i=Kt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let f=h[h.length-1];if(f.from===f.to){h.pop();continue}let c=e?--f.to:f.from++;if(f.isLeaf)return u.value=f.array?.[c],u;let _=f.array?.[c],l=f.level-z,a=f.offset+(c<<f.level);o(_,l,a)}return U});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,y=s-_;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,y=(s-_>>c)+1;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,level:c,offset:_,isLeaf:!1})}}}function Hu(t,e,r){let{_origin:s,_capacity:i}=t,n=Kt(i),h=t._tail,u=t._level,o=t._root;return u===0?Fn(o,0,s,i,n,h,e,r):Vn(o,u,0,s,i,n,h,e,r)}function Fn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,f=e>r?0:r-e,c=s-e;if(c>E)c=E;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function Vn(t,e,r,s,i,n,h,u,o){let f=t?.array,c=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let l=e-z;while(c!==_){let a=o?--_:c++,y=r+(a<<e);if((l===0?Fn(f?.[a],y,s,i,n,h,u,o):Vn(f?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ce=(t,e,r,s,i,n,h)=>new Pn(t,e,r,s,i,n,h),Nt=()=>ce(0,0,z);function Zu(t,e,r){if(e=et(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)tt(h,e).set(0,r);else tt(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=Cr();if(e>=Kt(t._capacity))s=Pr(s,t.__ownerID,0,e,r,n);else i=Pr(i,t.__ownerID,t._level,e,r,n);if(!n.value)return t;if(t.__ownerID)return t._root=i,t._tail=s,t.__hash=void 0,t.__altered=!0,t;return ce(t._origin,t._capacity,t._level,i,s)}function Pr(t,e,r,s,i,n){let h=s>>>r&I,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let f=t&&t.array[h],c=Pr(f,e,r-z,s,i,n);if(c===f)return t;return o=It(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)T(n);if(o=It(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function It(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function kn(t,e){if(e>=Kt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&I],s-=z;return r}}function tt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ze,i=t._origin,n=t._capacity,h=i+e,u=r===void 0?n:r<0?n+r:i+r;if(h===i&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:f}=t,c=0;while(h+c<0)f=new _t(f?.array.length?[void 0,f]:[],s),o+=z,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=Kt(n),l=Kt(u);while(l>=1<<o+z)f=new _t(f?.array.length?[f]:[],s),o+=z;let a=t._tail,y=l<_?kn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){f=It(f,s);let w=f;for(let S=o;S>z;S-=z){let q=_>>>S&I;w=w.array[q]=It(w.array[q],s)}w.array[_>>>z&I]=a}if(u<n)y=y&&y.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,f=null,y=y&&y.removeBefore(s,0,h);else if(h>i||l<_){c=0;while(f){let w=h>>>o&I;if(w!==l>>>o&I)break;if(w)c+=(1<<o)*w;o-=z,f=f.array[w]}if(f&&h>i)f=f.removeBefore(s,o,h-c);if(f&&l<_)f=f.removeAfter(s,o,l-c);if(c)h-=c,u-=c}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=f,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return ce(h,u,o,f,y)}var Kt=(t)=>t<E?0:t-1>>>z<<z,B=(t)=>t===void 0||t===null?mt():Xe(t)?t:mt().withMutations((e)=>{let r=Q(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});B.of=(...t)=>B(t);class Nn extends _s{static{dt(this,{[rt]:!0,[ee]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:X.prototype.keys,values:X.prototype.values,__iterate:X.prototype.__iterate})}constructor(t,e,r,s){super(t?t.size:0,void 0,r,s);this._map=t,this._list=e}create(t){return B(t)}toString(){return this.__toString("OrderedMap {","}")}get(t,e){let r=this._map.get(t);return r!==void 0?this._list.get(r)[1]:e}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this;return mt()}set(t,e){return en(this,t,e)}remove(t){return en(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i)return r[0]=i[0],r[1]=i[1],!0}})}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);if(!t){if(this.size===0)return mt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return qs(e,r,t,this.__hash)}}B.isOrderedMap=Xe;var qs=(t,e,r,s)=>new Nn(t,e,r,s),mt=()=>qs(G(),Nt());function en(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===g){if(!h)return t;if(i.size>=E&&i.size>=s.size*2){let f=[];if(i.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=Nt().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=G().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(f[_][0],_)}),t.__ownerID)u.__ownerID=o.__ownerID=t.__ownerID}else u=s.remove(e),o=n===i.size-1?i.pop():i.set(n,void 0)}else if(h){if(r===i.get(n)[1])return t;u=s,o=i.set(n,[e,r])}else{let f=i.size;u=s.set(e,f),o=i.set(f,[e,r])}if(t.__ownerID)return t.size=u.size,t._map=u,t._list=o,t.__hash=void 0,t.__altered=!0,t;return qs(u,o)}var Re=(t)=>t===void 0||t===null?Je():ts(t)?t:Je().pushAll(t);Re.of=(...t)=>Re(t);class mn extends $t{static{dt(this,{asImmutable:ue,asMutable:oe,wasAltered:zs,withMutations:fe,[dn]:!0,shift:this.prototype.pop,unshift:this.prototype.push,unshiftAll:this.prototype.pushAll,[Symbol.toStringTag]:"Immutable.Stack",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s){super();this.size=t,this._head=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return Re(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=et(this,t);while(r&&t--)r=r.next;return r?r.value:e}peek(){return this._head?.value}push(...t){if(t.length===0)return this;let e=this.size+t.length,r=this._head;for(let s=t.length-1;s>=0;s--)r={value:t[s],next:r};return Gr(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&ts(t))return t;$(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Gr(this,e,r)}pop(){return this.slice(1)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this;return Je()}slice(t,e){if(re(t,e,this.size))return this;let r=Dt(t,this.size);if(se(e,this.size)!==this.size)return $t.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return Gr(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Je();return this.__ownerID=t,this.__altered=!1,this}return js(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let i=this.toArray(),n=i.length,h=0;while(h!==n)if(t(i[n-++h],n-h,this)===!1)break;return h}let r=0,s=this._head;while(s){if(t(s.value,r++,this)===!1)break;s=s.next}return r}__iterator(t){if(t){let s=this.toArray(),i=s.length,n=0;return M((h)=>{if(n===i)return!1;let u=i-++n;return h[0]=u,h[1]=s[u],!0})}let e=0,r=this._head;return M((s)=>{if(!r)return!1;return s[0]=e++,s[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return L(()=>{if(!t)return U;return e.value=t.value,t=t.next,e})}keys(){return Te(this.size)}}Re.isStack=ts;function Gr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return js(e,r)}var js=(t,e,r,s)=>new mn(t,e,r,s),rn,Je=()=>rn||(rn=js(0)),b=(t)=>t===void 0||t===null?vt():vr(t)&&!F(t)?t:vt().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});b.of=(...t)=>b(t);b.fromKeys=(t)=>b(Q(t).keySeq());b.intersect=(t)=>{return t=V(t).toArray(),t.length?b(t.pop()).intersect(...t):vt()};b.union=(t)=>{let e=V(t).toArray();return e.length?b(e.pop()).union(...e):vt()};class As extends Ge{static{dt(this,{withMutations:fe,asImmutable:ue,asMutable:oe,[wn]:!0,[ee]:this.prototype.remove,merge:this.prototype.union,concat:this.prototype.union,[Symbol.toStringTag]:"Immutable.Set"})}constructor(t,e){super();this.size=t?t.size:0,this._map=t,this.__ownerID=e}create(t){return b(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ie(this,this._map.set(t,t))}remove(t){return Ie(this,this._map.remove(t))}clear(){return Ie(this,this._map.clear())}map(t,e){let r=!1,s=Ie(this,this._map.mapEntries(([,i])=>{let n=t.call(e,i,i,this);if(n!==i)r=!0;return[n,n]},e));return r?s:this}union(...t){if(t=t.filter((e)=>e.size!==0),t.length===0)return this;if(this.size===0&&!this.__ownerID&&t.length===1)return b(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else gt(r).forEach((s)=>e.add(s))})}intersect(...t){return nn(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return nn(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return vt()}__make(t,e){return vn(t,e)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t);if(!t){if(this.size===0)return this.__empty();return this.__ownerID=t,this._map=e,this}return this.__make(e,t)}}b.isSet=vr;var vn=(t,e)=>new As(t,e),sn,vt=()=>sn||(sn=vn(G()));function nn(t,e,r){if(e.length===0)return t;return e=e.map((s)=>gt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Ie(t,e){if(t.__ownerID)return t.size=e.size,t._map=e,t;return e===t._map?t:e.size===0?t.__empty():t.__make(e)}var Lt=(t)=>t===void 0||t===null?Fr():Sn(t)?t:Fr().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});Lt.of=(...t)=>Lt(t);Lt.fromKeys=(t)=>Lt(Q(t).keySeq());class th extends As{static{dt(this,{[rt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Qr.zip,zipWith:Qr.zipWith,zipAll:Qr.zipAll})}create(t){return Lt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return Fr()}__make(t,e){return eh(t,e)}}Lt.isOrderedSet=Sn;var eh=(t,e)=>new th(t,e),Fr=()=>eh(mt());function Xu(t){if(at(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(P(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var _e=(t,e)=>{let r;Xu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._keys=u,i._defaultValues=t;for(let f=0;f<u.length;f++){let c=u[f];if(o[c]=f,i[c])console.warn(`Cannot define ${$s(this)} with property "${c}" since that property name is part of the Record API.`);else Gu(i,c)}}return this.__ownerID=void 0,this._values=K().withMutations((u)=>{u.setSize(this._keys.length),Q(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(Qu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class rh{static{dt(this,{asImmutable:ue,asMutable:oe,deleteIn:Ut,getIn:Ju,hasIn:Tu,merge:xr,mergeWith:Yn,mergeDeep:Bn,mergeDeepWith:xn,mergeDeepIn:Es,mergeIn:bs,setIn:Ss,toObject:vi,update:Os,updateIn:Ms,withMutations:fe,removeIn:Ut,toJSON:vi,[zn]:!0,[ee]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${Vt(this.get(e))}`).join(", ");return`${$s(this)} { ${t} }`}equals(t){return this===t||at(t)&&jt(this).equals(jt(t))}hashCode(){return jt(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return Yr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Yr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return jt(this)}toJS(){return De(this)}entries(){return this.__iterator()}__iterate(t,e){return jt(this).__iterate(t,e)}__iterator(t){return jt(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return Yr(this,e,t)}}_e.isRecord=at;var $s=(t)=>t.constructor.displayName||t.constructor.name||"Record";class sh extends Wt{constructor(t){super();this._record=t,this.size=t._keys.length}get(t,e){return this._record.get(t,e)}has(t){return this._record.has(t)}__iterateUncached(t,e){let r=this._record,s=r._keys,i=s.length,n=0;while(n!==i){let h=e?i-++n:n++,u=s[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,s=r.length,i=0;return M((n)=>{if(i===s)return!1;let h=t?s-++i:i++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var jt=(t)=>new sh(t);_e.getDescriptiveName=$s;var Qu=rh.prototype;function Yr(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Gu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){Ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var hn=(t,e,r=1)=>{if(Ft(r!==0,"Cannot step a Range by 0"),Ft(t!==void 0,"You must define a start value when using Range"),Ft(e!==void 0,"You must define an end value when using Range"),r=Math.abs(r),e<t)r=-r;let s=Math.max(0,Math.ceil((e-t)/r-1)+1);return new Us(t,e,r,s)};class Us extends pt{_start;_end;_step;constructor(t,e,r,s){super();this._start=t,this._end=e,this._step=r,this.size=s}toString(){return this.size===0?"Range []":`Range [ ${this._start}...${this._end}${this._step!==1?` by ${this._step}`:""} ]`}get(t,e){return this.has(t)?this._start+et(this,t)*this._step:e}includes(t){let e=(t-this._start)/this._step;return e>=0&&e<this.size&&e===Math.floor(e)}slice(t,e){if(re(t,e,this.size))return this;if(t=Dt(t,this.size),e=se(e,this.size),e<=t)return hn(0,0);return hn(this.get(t,this._end),this.get(e,this._end),this._step)}indexOf(t){let e=t-this._start;if(e%this._step===0){let r=e/this._step;if(r>=0&&r<this.size)return r}return-1}lastIndexOf(t){return this.indexOf(t)}__iterateUncached(t,e=!1){let r=this.size,s=this._step,i=e?this._start+(r-1)*s:this._start,n=0;while(n!==r){let h=i;i+=e?-s:s;let u=e?r-++n:n++;if(t(h,u,this)===!1)break}return n}__iteratorUncached(t=!1){let e=this.size,r=this._step,s=t?this._start+(e-1)*r:this._start,i=0;return M((n)=>{if(i===e)return!1;let h=s;return s+=t?-r:r,n[0]=t?e-++i:i++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,s=0,i={done:!1,value:void 0};return L(()=>{if(s===t)return U;return i.value=r,r+=e,s++,i})}keys(){return Te(this.size)}equals(t){return t instanceof Us?this._start===t._start&&this._end===t._end&&this._step===t._step:rs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class Vr extends pt{constructor(t,e){super();this._value=t,this.size=e}toString(){if(this.size===0)return"Repeat []";return`Repeat [ ${this._value} ${this.size} times ]`}get(t,e){return this.has(t)?this._value:e}includes(t){return A(this._value,t)}slice(t,e){let r=this.size;return re(t,e,r)?this:new Vr(this._value,se(e,r)-Dt(t,r))}reverse(){return this}indexOf(t){if(A(this._value,t))return 0;return-1}lastIndexOf(t){if(A(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,s=0;while(s!==r)if(t(this._value,e?r-++s:s++,this)===!1)break;return s}__iteratorUncached(t){let e=this.size,r=this._value,s=0;return M((i)=>{if(s===e)return!1;return i[0]=t?e-++s:s++,i[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,s={done:!1,value:void 0};return L(()=>{if(r===t)return U;return r++,s.value=e,s})}keys(){return Te(this.size)}equals(t){return t instanceof Vr?this.size===t.size&&A(this._value,t._value):rs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var ih=Symbol("BadValue"),oh=(t)=>t;class R{constructor(t,e,r,s,i=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=s,this.checks=[],this.defaultValue=i}toDataDef(){let{type:t,defaultValue:e}=this;return{type:t,defaultValue:e?.toJS?e.toJS():e}}getFirstFailingCheck(t){if(!this.typeCheck.isValid(t))return this.typeCheck;for(let e of this.checks)if(!e.isValid(t))return e;return null}isValid(t){return this.getFirstFailingCheck(t)===null}addCheck(t){return this.checks.push(t),this}coerceOr(t,e=null){if(this.isValid(t))return t;let r=this.coercer(t);return this.isValid(r)?r:e}coerceOrDefault(t){return this.coerceOr(t,this.defaultValue)}extendProtoForType(t,e){}extendProto(t){let{name:e}=this,r=e[0].toUpperCase()+e.slice(1),s=`set${r}`,i=this;t[s]=function(n){let h=i.coerceOr(n,ih);if(h===ih)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[s](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,i.defaultValue)},t[`is${r}NotSet`]=function(){return this.get(e)==null},t[`is${r}Set`]=function(){return this.get(e)!=null},this.extendProtoForType(t,r)}}class Ks{isValid(t){return!0}getMessage(t){return"Invalid"}}class fh extends Ks{}var Yu=new fh;class k extends Ks{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var Cu=new k((t)=>Number.isInteger(t),()=>"Integer expected"),Bu=new k((t)=>Number.isFinite(t),()=>"Float expected"),xu=new k((t)=>typeof t==="boolean",()=>"Boolean expected"),Pu=new k((t)=>typeof t==="string",()=>"String expected"),Fu=new k((t)=>K.isList(t),()=>"List expected"),Vu=new k((t)=>Y.isMap(t),()=>"Map expected"),ku=new k((t)=>B.isOrderedMap(t),()=>"OrderedMap expected"),Nu=new k((t)=>b.isSet(t),()=>"Set expected"),mu=(t)=>!!t;class Ls extends R{constructor(t,e=!1){super("bool",t,xu,mu,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(s){return this.set(r,!!s)}}}class Be extends R{constructor(t,e=null){super("any",t,Yu,oh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Is(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var vu=(t)=>t?.toString?.()??"";class Ds extends R{constructor(t,e=""){super("text",t,Pu,vu,e)}extendProtoForType(t,e){let{name:r}=this;t[`${r}IsEmpty`]=function(){return this.get(r,"").length===0},t[`${r}Len`]=function(){return this.get(r,"").length}}}var to=(t)=>Number.isFinite(t)?Math.trunc(t):null;class ch extends R{constructor(t,e=0){super("int",t,Cu,to,e)}}var eo=(t)=>null;class Ws extends R{constructor(t,e=0){super("float",t,Bu,eo,e)}}var Is=(t)=>t?.constructor?.getMetaClass?.()?.name;class _h{constructor(t){this.typeName=t}isValid(t){return Is(t)===this.typeName}getMessage(t){let e=Is(t);return`Expected "${this.typeName}", got "${e}"`}}class lh extends R{constructor(t,e,r){super(t,e,new _h(t),oh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var nh=Symbol("NONE");function Tt(t,e,r){yh(t,e,ah),t[`setIn${r}At`]=function(i,n){return this.set(e,this.get(e).set(i,n))},t[`getIn${r}At`]=function(i,n){return this.get(e).get(i,n)},t[`updateIn${r}At`]=function(i,n){let h=this.get(e),u=h.get(i,nh);if(u!==nh)return this.set(e,h.set(i,n(u)));return console.warn("key",i,"not found in",e,h),this};function s(i){return this.set(e,this.get(e).delete(i))}t[`deleteIn${r}At`]=s,t[`removeIn${r}At`]=s}var ah=K(),ro=(t)=>Array.isArray(t)?K(t):null;class Rs extends R{constructor(t,e=ah){super("list",t,Fu,ro,e)}extendProtoForType(t,e){let{name:r}=this;Tt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var so=(t)=>Y(t);class Js extends R{constructor(t,e=Y()){super("map",t,Vu,so,e)}extendProtoForType(t,e){Tt(t,this.name,e)}}var io=(t)=>B(t);class Ts extends R{constructor(t,e=B()){super("omap",t,ku,io,e)}extendProtoForType(t,e){Tt(t,this.name,e)}}function yh(t,e,r){t[`${e}IsEmpty`]=function(){return this.get(e,r).size===0},t[`${e}Len`]=function(){return this.get(e,r).size}}var hh=b(),no=(t)=>Array.isArray(t)?b(t):t instanceof Set?b(t):null;class Hs extends R{constructor(t,e=hh){super("set",t,Nu,no,e)}extendProtoForType(t,e){let{name:r}=this;yh(t,r,hh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},t[`deleteIn${e}`]=function(s){return this.set(r,this.get(r).delete(s))},t[`removeIn${e}`]=t[`deleteIn${e}`],t[`hasIn${e}`]=function(s){return this.get(r).has(s)},t[`toggleIn${e}`]=function(s){let i=this.get(r);return this.set(r,i.has(s)?i.delete(s):i.add(s))}}}function uh(t,e,r){let s=e.lookupComponent(t.type);return console.assert(s!==null,"component not found",{field:t}),s?.make({...t.args,...r},{scope:e})??null}class gh{constructor(t){let e={},r=new Set;this.name=t,this.fields=e,this.compFields=r,this._methods={},this._statics={make:function(s={},i={}){let n={};for(let h in s){let u=e[h];if(r.has(h))n[h]=uh(u,i.scope,s[h]);else if(u===void 0){console.warn("extra argument to constructor:",t,h,s);continue}n[h]=u.coerceOrDefault(s[h])}for(let h of r)if(n[h]===void 0)n[h]=uh(e[h],i.scope,s[h]);return this(n)}}}build(){let t={},e={},{name:r,_methods:s,fields:i}=this;for(let u in i){let o=i[u];t[u]=o.defaultValue,o.extendProto(e)}let n={[r]:_e(t,r)}[r];Object.assign(n.prototype,e,s);let h={fields:i,name:r,methods:s};return Object.assign(n,this._statics,{getMetaClass:()=>h}),n}methods(t){return this._mergeProto(this._methods,t,"method")}statics(t){return this._mergeProto(this._statics,t,"static")}_mergeProto(t,e,r){for(let s in e)t[s]=e[s];return this}addField(t,e,r){let s=new r(t,e);return this.fields[t]=s,s}addCompField(t,e,r){let s=new lh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var xe=new Map,ho={text:Ds,int:ch,float:Ws,bool:Ls,list:Rs,map:Js,omap:Ts,set:Hs,any:Be};function uo(t,{fields:e={},methods:r,statics:s}){let i=new gh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Ds);else if(u==="number")i.addField(n,h,Ws);else if(u==="boolean")i.addField(n,h,Ls);else if(K.isList(h)||Array.isArray(h))i.addField(n,K(h),Rs);else if(b.isSet(h)||h instanceof Set)i.addField(n,b(h),Hs);else if(B.isOrderedMap(h))i.addField(n,h,Ts);else if(h?.type&&h?.defaultValue!==void 0){let o=ho[h.type]??Be;i.addField(n,new o().coerceOr(h.defaultValue),o)}else if(h?.component&&h?.args!==void 0)i.addCompField(n,h.component,h.args);else if(Y.isMap(h)||h?.constructor===Object)i.addField(n,Y(h),Js);else{let o=xe.get(h?.constructor)??Be;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var oo=(t)=>new Er(t.name??"Comp",uo(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var fo=["nid","cid","eid","vid","si","sk"];class Zs{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.comment=s,this.renderFn=i,this.getSeqInfo=n??go,this.cache=h??new Sr}setNullCache(){this.cache=new zr}renderToDOM(t,e){let r=document.createElement("div");return this.renderFn(this.h("div",null,[this.renderRoot(t,e)]),r),r.childNodes[0]}renderToString(t,e,r=!0){let s=this.renderToDOM(t,e,this.renderFn);if(r){let i=s.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of i)for(let h of fo)delete n[h]}return s.innerHTML}renderRoot(t,e,r=null){let s=this.comps.getCompFor(e),i=s.getView(r).anode.nodeId??null;return s?this._rValComp(t,e,s,i,"ROOT",r):null}renderIt(t,e,r,s){let i=this.comps.getCompFor(t.it);return i?this._rValComp(t,t.it,i,e,r,s):null}_rValComp(t,e,r,s,i,n){let h=`${n??t.viewsId??""}${s}-${i}`,u=this.cache.get(e,h);if(u)return u;let o=n?r.getView(n):t.lookupBestView(r.views,"main"),f=this.renderMetadata("Comp",{nid:s}),c=this.renderFragment([f,o.render(t,this)]);return this.cache.set(e,h,c),c}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),f=[],c=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,c)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(y)}return f}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,f]=this.getSeqInfo(i),c=!!u,_=[],l=h.call(t.it,i);for(let[a,y]of f(i))if(n.call(t.it,a,y,l)){let w={key:a,value:y},S=`${s}-${a}`,q;if(c)u.call(t.it,w,a,y,l),q=this.cache.get2(t.it,y,S);else q=this.cache.get(y,S);if(q){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(q);continue}let St=t.enter(y,w,!1),Ot=r.render(St,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,y,S,Ot);else this.cache.set(y,S,Ot);_.push(Ot)}return _}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderComment(t){return this.comment(t)}renderEmpty(t){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*co(t){let e=0;for(let r of t)yield[e++,r]}function*_o(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var Pe=new Map,lo=["si",co],ao=["sk",_o],yo=["si",function*(e){}];function go(t){return j(t)?lo:d(t)?ao:Pe.get(t?.constructor)??yo}class zt{constructor(t=Y(),e=K()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new zt(t,e,this.$)}toJS(){return this.order.toArray().map((t)=>this.items.get(t))}set(t,e){let r=this.items.has(t)?this.order:this.order.push(t);return this._clonish(this.items.set(t,e),r,this.$)}get(t,e=null){return this.items.get(t,e)}_nextFreeKey(){let t=this.$;while(!0){let e=`§${t}§`;if(!this.items.has(e))return[e,t];t+=1}}push(t){let[e,r]=this._nextFreeKey(),s=this.set(e,t);return s.$=r,s}get size(){return this.items.size}delete(t){if(this.items.has(t)){let e=this.order.delete(this.order.indexOf(t));return this._clonish(this.items.delete(t),e)}return this}moveKeyBeforeKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),0)}moveKeyAfterKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),1)}moveKeyIndexToIndex(t,e,r){if(t===-1||e===-1||t===e)return this;let{order:s}=this,i=e+r,n=i<t?t+1:t,h=s.insert(i,s.get(t)).delete(n);return this._clonish(this.items,h)}}var po=(t)=>null;class ph{isValid(t){return t instanceof zt}getMessage(t){return"KList expected"}}var wo=new ph;class wh extends R{constructor(t,e=new zt){super("KList",t,wo,po,e)}extendProtoForType(t,e){Tt(t,this.name,e);let{name:r}=this;Tt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}xe.set(zt,wh);function*zo(t){for(let e of t.order)yield[e,t.items.get(e)]}Pe.set(zt,["data-sk",zo]);function Qs(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function zh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)So(t,s,r);else if(Qs(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(typeof i==="object"&&i!==null)Oo(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function So(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(Qs(e))t.removeAttribute(e);else if(typeof s==="string"){if(e!=="className")t[e]="";let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function Oo(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(typeof n!=="object"||n===null)t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Xt{isEqualTo(t){return this===t}toDom(t){return null}}function Xs(t){return t instanceof Zt?t.key:void 0}function Mo(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function Gs(t,e){if(e==null)return;if(Mo(e))for(let r of e)Gs(t,r);else if(e instanceof Xt)if(e instanceof N)t.push(...e.childs);else t.push(e);else t.push(new le(e))}class le extends Xt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof le&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Ht extends Xt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Ht&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class N extends Xt{constructor(t){super();let e=[];Gs(e,t),this.childs=e}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof N)||this.childs.length!==t.childs.length)return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document.createDocumentFragment();for(let r of this.childs){let s=r.toDom(t);if(s)e.appendChild(s)}return e}}class Zt extends Xt{constructor(t,e,r,s,i){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i==="string"?i:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Zt)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.childs.length!==t.childs.length)return!1;for(let e in this.attrs)if(this.attrs[e]!==t.attrs[e])return!1;for(let e in t.attrs)if(!Object.hasOwn(this.attrs,e))return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);zh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function Sh(t,e){let r=null;for(let s in t){if(!Object.hasOwn(e,s)){r??={},r[s]=void 0;continue}let i=t[s],n=e[s];if(i===n);else if(typeof i==="object"&&i!==null&&typeof n==="object"&&n!==null)if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=Sh(i,n);if(h)r??={},r[s]=h}else r??={},r[s]=n}for(let s in e)if(!Object.hasOwn(t,s))r??={},r[s]=e[s];return r}function bo(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function Oh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof le&&r instanceof le||e instanceof Ht&&r instanceof Ht)return t.data=r.text,t;if(e instanceof Zt&&r instanceof Zt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Sh(e.attrs,r.attrs);if(i)zh(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)dh(t,e.childs,r.childs,e.tag,s);return t}if(e instanceof N&&r instanceof N)return dh(t,e.childs,r.childs,null,s),t;return bo(t,r,s)}function dh(t,e,r,s,i){if(e.length===0){for(let f of r){let c=f.toDom(i);if(c)t.appendChild(c)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Array.from(t.childNodes),h={};for(let f=0;f<e.length;f++){let c=Xs(e[f]);if(c!=null)h[c]=f}let u=new Uint8Array(e.length),o=0;for(let f=0;f<r.length;f++){let c=r[f],_=Xs(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&Xs(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],y=Oh(a,e[l],c,i),w=t.childNodes[f]??null;if(y!==w)t.insertBefore(y,w)}else{let a=c.toDom(i);if(a){let y=t.childNodes[f]??null;t.insertBefore(a,y)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var Fe=new WeakMap;function Mh(t,e,r){let s=Fe.get(e),i=t instanceof N;if(s){let h=s.vnode instanceof N;if(h===i){let u=h?e:s.dom,o=Oh(u,s.vnode,t,r);return Fe.set(e,{vnode:t,dom:i?e:o}),o}Fe.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),Fe.set(e,{vnode:t,dom:i?e:n});return n}function bh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e)if(o==="key")n=e[o];else if(o==="namespace")h=e[o];else if(o==="class")i.className=e[o];else if(o==="for")i.htmlFor=e[o];else if(Qs(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return Gs(u,r),new Zt(s,i,u,n,h)}var{raw:wf,raw:df}=String;function zf(t,e){return new gr(t,e)}var Eo=(t)=>typeof t==="string"?document.querySelector(t):t;function Sf(t){let e=Eo(t),r=new Ee,s=(o)=>new N(o),i=(o)=>new Ht(o),n={document},h=(o,f)=>Mh(o,f,n),u=new Zs(r,bh,s,i,h);return new Rr(e,h,r,u,ot)}async function Uf(t,e,r="margaui-css"){let s=performance.now(),i=await qo(t,e),n=performance.now();return je(r,i),n-s}async function qo(t,e,r){t.ParseContext=Ae,t.compile();let s=new Set(r??[]);for(let i of t.comps.byId.values())for(let n in i.views){let h=i.views[n];for(let u of h.ctx.classes)s.add(u)}return await e(Array.from(s))}export{Sf as tutuca,Pe as seqInfoByClass,zf as macro,Xe as isOrderedMap,Xe as isOMap,ne as isMap,mr as isList,d as isKeyed,j as isIndexed,ne as isIMap,je as injectCss,df as html,xe as fieldsByClass,wf as css,oo as component,qo as compileClassesToStyleText,Uf as compileClassesToStyle,_e as Record,ot as ParseContext,B as OMap,K as List,zt as KList,b as ISet,Y as IMap};
1
+ class Ht{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Mt extends Ht{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Mt({...this.binds,key:t})}withKey(t){return new Mt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class ye extends Ht{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new tr(this.field,t)}withKey(t){return new ve(this.field,t)}}class me extends Ht{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class ve extends me{}class tr extends me{}var D=Symbol("NONE");class er extends Ht{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return s!==D&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return r===D||s===D?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class N{constructor(t=[]){this.steps=t}concat(t){return new N(this.steps.concat(t))}popStep(){return new N(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,D),r===D)return e;return r}setValue(t,e){let r=Array(this.steps.length),s=t;for(let n=0;n<this.steps.length;n++)if(r[n]=s,s=this.steps[n].lookup(s,D),s===D)return t;let i=e;for(let n=this.steps.length-1;n>=0;n--)i=this.steps[n].setValue(r[n],i),r[n]=i;return i}buildStack(t){let e=t.it,r=e;for(let s of this.steps){if(r=s.lookup(r,D),r===D)return console.warn("bad PathItem",{root:e,curVal:r,step:s,path:this}),null;s.updateBindings(r,t.binds.head.bindings),t=t.enter(r,{},s.isFrame)}return t}static fromNodeAndEventName(t,e,r,s,i,n=!0){let h=[],u=0,o=[],f=null,c=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=Vs(t.previousSibling),{eid:w,cid:S,vid:q}=t.dataset;if(w!==void 0)o.push(w);if(S!==void 0){let St=i.getComponentForId(+S,q);if(_){if(f=Ah(St,o,q,e),f===null&&n)return Uh;_=!1}let Ot=$h(St,c,q);if(Ot)h.push(Ot);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new N(h.reverse()),f]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return N.fromNodeAndEventName(h,n,e,r,s,i)}}var Fs={};function Vs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Vs(t.previousSibling);if(e!==Fs)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Fs}function Ah(t,e,r,s){for(let i of e){let n=t.getEventForId(+i,r).getHandlersFor(s);if(n!==null)return n}return null}function $h(t,e,r){for(let s=0;s<e.length;s++){let i=t.getNodeForId(+e[s].nid,r),n=i.pathInNext?s+1:s,{si:h,sk:u,nid:o}=e[n],f=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(f!==null)return h!==void 0?f.withIndex(+h):u?f.withKey(u):f}return null}var Uh=[null,null];class rr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new ye(t))}index(t,e){return this.add(new tr(t,e))}key(t,e){return this.add(new ve(t,e))}}var Ih=/^[a-zA-Z][a-zA-Z0-9_]*$/,nt=(t)=>Ih.test(t),Kh=/^-?[0-9]+(\.[0-9]+)?$/,ks=(t,e)=>ir.parse(t,e),Xt=(t,e)=>new T(t),Lh=(t,e)=>nt(t)?new ht(t):null,Dh=(t,e)=>nt(t)?new ei(t):null,Wh=(t,e)=>nt(t)?new hr(t):null,Rh=(t,e)=>nt(t)?new ii(t):null,Th=(t,e)=>nt(t)?new ni(t):null,Jh=(t,e)=>nt(t)?new hi(t):null,Zh=(t,e)=>nt(t)?new ri(t):null;class Ns{constructor(){this.allowFieldOnly(),this.bindValIt=new hr("it"),this.nullConstVal=new T(null)}const(t){return new T(t)}allowFieldOnly(){this.okField=!0,this.okBind=!1,this.okComputed=!1,this.okDyn=!1,this.okType=!1,this.okRequest=!1,this.okName=!1,this.okConst=!1,this.okStrTpl=!1,this.okSeqAccess=!1}parseIfOk(t,e,r,s){return r?s(t,e):null}_parseSeqAccess(t,e){if(!this.okSeqAccess)return null;let r=t.indexOf("[");this.allowFieldOnly();let s=this.parse(t.slice(0,r),e),i=this.parse(t.slice(r+1,-1),e);return s&&i?new ui(s,i):null}parse(t,e){switch(Hh(t)){case oi:return this.parseIfOk(t,e,this.okStrTpl,ks);case ci:return this.parseIfOk(t,e,this.okStrTpl,Xt);case fi:return this._parseSeqAccess(t,e);case ge:return this.parseIfOk(t,e,this.okStrTpl,ks)}let r=t.charCodeAt(0);switch(r){case 94:{let i=e.frame.macroVars?.[t.slice(1)];if(i!==void 0)return this.parse(i,e);return null}case 126:return this.parseIfOk(t.slice(1),e,this.okStrTpl,Xt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Xt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Wh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Rh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Th);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Jh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Zh)}let s=Kh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Xt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Xt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Lh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Dh);return null}parseDynamic(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.parse(t,e)}parseEach(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.okDyn=!0,this.parse(t,e)}allowHandlerArg(){this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okType=!0,this.okRequest=!0,this.okName=!0,this.okConst=!0}parseHandlerArg(t,e){return this.allowHandlerArg(),this.parse(t,e)}_parseHandler(t,e,r){this.allowFieldOnly(),this.okName=!0;let s=this.parse(t,e);return s&&(s.toRawFieldVal?s.toRawFieldVal():new r(s.name))}parseHandlerName(t,e){return this._parseHandler(t,e,ms)}parseAlter(t,e){return this._parseHandler(t,e,vs)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class pe{render(t,e){}eval(t){}toPathItem(){return null}}class T extends pe{constructor(t){super();this.value=t}render(t,e){return this.value}eval(t){return this.value}toString(){let t=this.value;return typeof t==="string"?`'${t}'`:`${t}`}}class sr extends pe{}class ir extends sr{constructor(t){super();this.vals=t}render(t,e){return this.eval(t)}eval(t){let e=Array(this.vals.length);for(let r=0;r<this.vals.length;r++)e[r]=this.vals[r]?.eval(t,"");return e.join("")}static parse(t,e){let r=t.split(/(\{[^}]+\})/g),s=Array(r.length),i=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?p.parseText(h.slice(1,-1),e):new T(h);s[n]=o,i&&=o instanceof T}return i?new T(s.map((n)=>n.value).join("")):new ir(s)}}class ht extends sr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class ms extends ht{eval(t){return t.getInputHandler(this.name)??ti("input",this.name)}}class vs extends ht{eval(t){return t.getAlterHandler(this.name)??ti("alter",this.name)}}var ti=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ei extends ht{eval(t){return t.lookupType(this.name)}}class ri extends ht{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class si extends ht{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class nr extends pe{render(t,e){return this.eval(t)}}class Qt extends nr{constructor(t){super();this.name=t}}class hr extends Qt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class ii extends Qt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ni extends Qt{eval(t){return t.lookupField(this.name)}toPathItem(){return new ye(this.name)}toRawFieldVal(){return new si(this.name)}toString(){return`.${this.name}`}}class hi extends Qt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class ui extends nr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new er(this.seqVal.name,this.keyVal.name)}eval(t){let e=this.keyVal.eval(t);return this.seqVal.eval(t).get(e,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}}var oi=0,fi=1,ge=2,ci=3;function Hh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return ge;e+=1;break;case 93:if(r>0||e===0)return ge;r+=1;break;case 123:return oi;case 125:return ci}if(e>0||r>0)return e===1&&r===1?fi:ge;return-1}var p=new Ns;class bt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return cr(e).parse(t,r)}isConstant(){return!1}}var Xh="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",Qh=new Set(Xh.split(","));class _i{constructor(t){this.clear(t)}clear(t){this.px=t,this.attrs=null,this.hasDynamic=!1,this.wrapperAttrs=null,this.textChild=null,this.eachAttr=null,this.ifAttr=null,this.events=null}parseAttr(t,e,r=!1){let s=r?p.parseAll(e,this.px):p.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new de(t,s)),this.hasDynamic||=!(s instanceof T)}pushWrapper(t,e,r){let s={name:t,val:r,raw:e};return this.wrapperAttrs??=[],this.wrapperAttrs.push(s),s}parseIf(t,e){let r=p.parseCondValue(e,this.px);if(r)this.ifAttr=new yi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=p.parseAttr(t,this.px)??Gt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Gt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=_r.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new we("data-eid",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new ai(p.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,p.const(t));return;case"push-view":this.pushWrapper("push-view",t,p.parseText(t,this.px));return;case"text":this.textChild=p.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,p.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,p.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,p.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=p.parseAlter(t,this.px);else this.pushWrapper("scope",t,p.parseAlter(t,this.px));return;case"when":this._parseWhen(t);return;case"loop-with":this._parseLoopWith(t);return;case"then":this.parseThen(t);return;case"else":this.parseElse(t);return}if(e.startsWith("on."))this.parseEvent(e,t);else if(e.startsWith("if."))this.parseIf(e,t);else if(e.startsWith("then."))this.parseThen(t);else if(e.startsWith("else."))this.parseElse(t)}_parseWhen(t){if(this.eachAttr!==null)this.eachAttr.whenVal=p.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=p.parseAlter(t,this.px)}parse(t,e=!1){for(let{name:n,value:h}of t){let u=n.charCodeAt(0);if(u===58)this.parseAttr(n===":viewbox"?"viewBox":n.slice(1),h,e);else if(u===64)this.parseDirective(h,n.slice(1));else{this.attrs??=[];let o=h===""&&Qh.has(n)?!0:h;this.attrs.push(new we(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new li(r):or.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class or extends bt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new or(e)}setDataAttr(t,e){this.items[t]=e}toMacroVars(){let t={};for(let e in this.items)t[e]=`'${this.items[e]}'`;return t}isConstant(){return!0}}class li extends bt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new we(t,new T(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class fr{constructor(t){this.name=t}}class de extends fr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class we extends de{}class ai extends de{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Gt=p.nullConstVal;class yi extends fr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Gt}get anyBranchIsSet(){return this.thenVal!==Gt||this.elseVal!==Gt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var ur=null;function cr(t){return ur??=new _i(t),ur.clear(t),ur}class _r{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=p.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);p.allowHandlerArg();for(let h=0;h<s.length;h++){let u=p.parse(s[h],e);n[h]=u!==null?u:p.nullConstVal}return new _r(i,n)}}class lr{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class Et{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class Bt extends Et{constructor(t){super();this.v=t}render(t,e){return e.renderText(this.v)}isWhiteSpace(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.v=""}isConstant(){return!0}setDataAttr(t,e){}}class Ct extends Bt{render(t,e){return e.renderComment(this.v)}}function Gh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new zr(r);else r.optimize()}}function gr(t){if(t.isConstant())return new zr(t);return t.optimize(),t}class pr extends Et{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Gh(this.childs)}}class ze extends pr{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class Se extends pr{render(t,e){return e.renderFragment(this.childs.map((r)=>r?.render(t,e)))}setDataAttr(t,e){for(let r of this.childs)r.setDataAttr(t,e)}}var Yt=(t)=>t.length===1?t[0]:new Se(t),Yh=/^[a-zA-Z][a-zA-Z0-9-]*$/,gi=null;class m extends Et{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){gi??=e.newDOMParser();let r=gi.parseFromString(t,"text/html").body.childNodes;return m.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Bt(t.textContent);else if(e.isCommentNode(t))return new Ct(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=m.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return Yt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Me(null,p.const(u),Yt(n));case"text":{let f=p.parseText(u,e);return f!==null?new yr(null,f):null}case"render":return e.addNodeIf(Mi,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(bi,p.bindValIt,o);case"render-each":return dr.parse(e,p,u,o,s);case"show":return e.addNodeIf(Sr,p.parseCondValue(u,e),Yt(n));case"hide":return e.addNodeIf(Or,p.parseCondValue(u,e),Yt(n))}return new Ct(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let f=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[f]??Yt(n)}let[u,o]=bt.parse(s,e,!0);return e.onAttributes(u,o,null),pi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Yh.test(i)){let[h,u,o]=bt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new yr(null,o));let f=i!=="PRE"?Fh(n):n;return pi(new ze(i.toLowerCase(),h,f),e,u)}return new Ct(`Error: InvalidTagName ${i}`)}}function pi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Ch(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Ch(t,e){let r=xh[t.name],s=r.register?e.addNodeIf(r,t.val):t.val&&new r(null,t.val);if(s!==null&&t.name==="each")s.iterInfo.enrichWithVal=t.enrichWithVal??null,s.iterInfo.whenVal=t.whenVal??null,s.iterInfo.loopWithVal=t.loopWithVal??null;return s}class Oi extends Et{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Ct(`bad macro: ${e}`);else{let n={...i.defaults,...r};this.node=i.expand(this.px.enterMacro(e,n,s));for(let h in this.dataAttrs)this.node.setDataAttr(h,this.dataAttrs[h])}}render(t,e){return this.node.render(t,e)}setDataAttr(t,e){this.dataAttrs[t]=e}isConstant(){return this.node.isConstant()}optimize(){this.node=gr(this.node)}}class wr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return m.parse(this.rawView,t)}}class Oe extends m{constructor(t,e,r){super(t,e);this.viewId=r}}class Mi extends Oe{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class bi extends Oe{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class dr extends Oe{constructor(t,e,r){super(t,e,r);this.iterInfo=new Mr(e,null,null,null)}render(t,e){return e.renderEach(t,this.iterInfo,this.nodeId,this.viewId)}static parse(t,e,r,s,i){let n=t.addNodeIf(dr,e.parseEach(r,t),s);if(n!==null){let h=cr(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=i.getNamedItem("when");u&&h._parseWhen(u.value);let o=i.getNamedItem("loop-with");o&&h._parseLoopWith(o.value),n.iterInfo.whenVal=h.eachAttr.whenVal??null,n.iterInfo.loopWithVal=h.eachAttr.loopWithVal??null}return n}}class yr extends m{render(t,e){return e.renderText(this.val.eval(t))}}class zr extends Et{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ut extends m{constructor(t,e,r=null){super(t,e);this.node=r}wrapNode(t){this.node=t}setDataAttr(t,e){this.node.setDataAttr(t,e)}optimize(){this.node=gr(this.node)}static register=!1}class Sr extends ut{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Or extends ut{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Ei extends ut{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Me extends ut{optimize(){this.node.optimize()}}class qi extends ut{render(t,e){let r=this.val.eval(t)?.call(t.it)??{};return this.node.render(t.enter(t.it,r,!1),e)}toPathItem(){return new Mt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class ji extends ut{constructor(t,e){super(t,e);this.iterInfo=new Mr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Mt({})}static register=!0}class Mr{constructor(t,e,r,s){this.val=t,this.whenVal=e,this.loopWithVal=r,this.enrichWithVal=s}eval(t){let e=this.val.eval(t)??[],r=this.whenVal?.eval(t)??Bh,s=this.loopWithVal?.eval(t)??Ph,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Bh=(t,e,r)=>!0,Ph=(t)=>({seq:t}),xh={slot:Me,show:Sr,hide:Or,each:ji,scope:qi,"push-view":Ei};class ot{constructor(t,e,r,s,i,n,h,u){this.nodes=s??[],this.events=i??[],this.macroNodes=n??[],this.parent=u??null,this.frame=h??{},this.DOMParser=t??globalThis.DOMParser,this.Text=e??globalThis.Text,this.Comment=r??globalThis.Comment,this.cacheConstNodes=!0}isInsideMacro(t){return this.frame.macroName===t||this.parent?.isInsideMacro(t)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new ot(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this)}newDOMParser(){return new this.DOMParser}isTextNode(t){return t instanceof this.Text}isCommentNode(t){return t instanceof this.Comment}addNodeIf(t,e,r){if(e!==null){let s=this.nodes.length,i=new t(s,e,r);return this.nodes.push(i),i}return null}registerEvents(){let t=this.events.length,e=new Ai(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Se(s)};for(let h of r)if(h instanceof Me)i[h.val.value]=h.node;else if(!(h instanceof Bt)||!h.isWhiteSpace())s.push(h);let n=new Oi(t,e,i,this);return this.macroNodes.push(n),n}compile(t){for(let e=0;e<this.macroNodes.length;e++)this.macroNodes[e].compile(t)}*genEventNames(){for(let t of this.events)yield*t.genEventNames()}getEventForId(t){return this.events[t]??null}getNodeForId(t){return this.nodes[t]??null}onAttributes(t,e,r){}}var ar=(t)=>t instanceof Bt&&t.isWhiteSpace(),wi=(t)=>t instanceof ze||t instanceof Se&&t.childs[0]instanceof ze;function Fh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(ar(t[0]))r=1,s=!0;if(e>1&&ar(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(ar(n)&&wi(t[i-1])&&wi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class be{constructor(t,e,r="",s=null,i=null){this.name=t,this.anode=s,this.style=r,this.ctx=i,this.rawView=e}compile(t,e,r){if(this.ctx=t,this.anode=m.parse(this.rawView,t),this.anode.setDataAttr("data-cid",r),this.anode.setDataAttr("data-vid",this.name),this.ctx.compile(e),t.cacheConstNodes)this.anode=gr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ai{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new $i(t,e,r))}*genEventNames(){for(let t of this.handlers)yield t.name}getHandlersFor(t){let e=null;for(let r of this.handlers)if(r.handlesEventName(t))e??=[],e.push(r);return e}}class $i{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=tu(t,r),this.modifiers=r}handlesEventName(t){return this.name===t}getHandlerAndArgs(t,e){let r=this.handlerCall.getHandlerAndArgs(t,e);return r[0]=this.modifierWrapper(r[0],e),r}}var Vh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ee=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,di=(t)=>Ee((e)=>e.e.key===t),zi=Ee(({e:t})=>Vh&&t.metaKey||t.ctrlKey),kh=Ee(({e:t})=>t.metaKey),Nh=Ee(({e:t})=>t.altKey),Si={ctrl:zi,cmd:zi,meta:kh,alt:Nh},mh={keydown:{send:di("Enter"),cancel:di("Escape"),...Si},click:{...Si}},vh=(t,e)=>t;function tu(t,e){if(e.length===0)return vh;let r=mh[t]??{},s=(i,n,h,u)=>n.apply(i,h);for(let i of e){let n=r[i];if(n!==void 0)s=n(s)}return(i,n)=>function(...h){return s(this,i,h,n)}}class br{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,s){}evict(){return{hit:0,miss:0,badKey:0}}}class Er{constructor(){this.hit=this.miss=this.badKey=0,this.map=new WeakMap}_returnValue(t){if(t===void 0)this.miss+=1;else this.hit+=1;return t}get(t,e){return this._returnValue(this.map.get(t)?.[e])}set(t,e,r){let s=this.map.get(t);if(s)s[e]=r;else if(typeof t==="object")this.map.set(t,{[e]:r});else this.badKey+=1}get2(t,e,r){return this._returnValue(this.map.get(t)?.get?.(e)?.[r])}set2(t,e,r,s){let i=this.map.get(t);if(i){let n=i.get(e);if(n)n[r]=s;else i.set(e,{[r]:s})}else if(typeof t==="object"&&typeof e==="object"){let n=new WeakMap;n.set(e,{[r]:s}),this.map.set(t,n)}else this.badKey+=1}evict(){let{hit:t,miss:e,badKey:r}=this;return this.hit=this.miss=this.badKey=0,this.map=new WeakMap,{hit:t,miss:e,badKey:r}}}class qr{getKey(t,e,r){return r.call(t)}}class jr{constructor(){this.map=new WeakMap}getKey(t,e,r){let s=this.map.get(t);if(s){let n=s[e];if(n!==void 0)return n;let h=r.call(t)??null;return s[e]=h,h}let i=r.call(t)??null;return this.map.set(t,{[e]:i}),i}}class qe{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new jr}setNullComputedCache(){this.computedCache=new qr}registerComponent(t){t.Class.prototype[this.getComponentSymbol]=()=>t,this.byId.set(t.id,t)}getComponentForId(t){return this.byId.get(t)??null}getCompFor(t){return t?.[this.getComponentSymbol]?.()??null}getOnEnterFor(t){let e=this.getCompFor(t);return e?e.on.stackEnter:Ii}getInputHandlerFor(t,e){return this.getCompFor(t)?.input[e]??null}getAlterHandlerFor(t,e){return this.getCompFor(t)?.alter[e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getCompFor(t)?.computed[e];return r?this.computedCache.getKey(t,e,r):null}compileStyles(){let t=[];for(let e of this.byId.values())t.push(e.compileStyle());return t.join(`
2
+ `)}}class je{constructor(t=new qe,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new je(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let s=t[r];s.scope=this.enter(),this.comps.registerComponent(s),this.byName[s.name]=s;let i=e[s.name];if(i)this.byName[i]=s}}registerMacros(t){Object.assign(this.macros,t)}getCompFor(t){return this.comps.getCompFor(t)}registerRequestHandlers(t){for(let e in t)this.reqsByName[e]=new lr(e,t[e])}lookupRequest(t){return this.reqsByName[t]??this.parent?.lookupRequest(t)??null}lookupComponent(t){return this.byName[t]??this.parent?.lookupComponent(t)??null}lookupMacro(t){return this.macros[t]??this.parent?.lookupMacro(t)??null}}class Ar{constructor(t,e,r){this.name=t,this.val=e,this.symbol=r}getSymbol(t){return this.symbol}evalAndBind(t,e){e[this.getSymbol(t)]=this.val.eval(t)}}class Ui extends Ar{constructor(t,e,r,s){super(t,e,null);this.compName=r,this.dynName=s}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var qt=(t)=>typeof t==="string",eu=0;class $r{constructor(t,e,r,s={},i="",n="",h="",u={},o={},f={},c={},_={},l={},a={},y={}){this.id=eu++,this.name=t,this.Class=e,this.views={main:new be("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=f,this.bubble=c,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Ii};for(let w in s){let S=s[w],{view:q,style:St}=qt(S)?{view:S}:S;this.views[w]=new be(w,q,St)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(qt(r)){let s=p.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Ar(e,s,Symbol(e))}else if(qt(r?.default)&&qt(r?.for)){let s=p.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(qt(i)&&qt(n))this.dynamic[e]=new Ui(e,s,i,n)}}for(let e in this.views)this.views[e].compile(new t,this.scope,this.id)}make(t,e){return this.Class.make(t,e)}getView(t){return this.views[t]??this.views.main}getEventForId(t,e="main"){return this.getView(e).ctx.getEventForId(t)}getNodeForId(t,e="main"){return this.getView(e).ctx.getNodeForId(t)}compileStyle(){let{id:t,commonStyle:e,globalStyle:r,views:s}=this,i=e?[`[data-cid="${t}"]{${e}}`]:[];if(r!=="")i.push(r);for(let n in s){let{style:h}=s[n];if(h!=="")i.push(`[data-cid="${t}"][data-vid="${n}"]{${h}}`)}return i.join(`
3
+ `)}}function Ii(t){return t}var Ki=Symbol("STOP"),Kr=Symbol("NEXT");class Pt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Pt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Ki?e:s===Kr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Ur{constructor(t,e,r){this.it=t,this.bindings=e,this.isFrame=r}lookup(t){let e=this.bindings[t];return e===void 0?this.isFrame?Ki:Kr:e}}class Ir{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Kr:e}}class Z{constructor(t,e,r,s,i,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=s,this.views=i,this.ctx=n;let h=[...i].join("");this.viewsId=h==="main"?"":h}_enrichOnEnter(){return this.comps.getOnEnterFor(this.it).call(this.it,this)??this}upToFrameBinds(){let{comps:t,binds:e,dynBinds:r,views:s,ctx:i}=this;return e.head.isFrame?this:new Z(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Pt(new Ur(e,{it:e},!0),null),i=new Pt(new Ir({}),null),n=new Pt("main",null);return new Z(t,e,s,i,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:s,binds:i,dynBinds:n,views:h,ctx:u}=this,o=i.push(new Ur(t,e,r));return new Z(s,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:s,dynBinds:i,views:n,ctx:h}=this;return new Z(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let f of t)r.dynamic[f].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Ir(e));return new Z(s,i,n,o,h,u)}lookupDynamic(t){let e=this.comps.getCompFor(this.it)?.dynamic[t];return e?this.dynBinds.lookup(e.getSymbol(this))??e.val.eval(this):null}lookupBind(t){return this.binds.lookup(t)}lookupType(t){return this.comps.getCompFor(this.it).scope.lookupComponent(t)}lookupFieldRaw(t){return this.it[t]??null}lookupField(t){let e=this.lookupFieldRaw(t);return e instanceof Function?e.call(this.it):e}lookupName(t){return this.ctx.lookupName(t)}lookupComputed(t){let e=this.binds.head.isFrame?this.binds.head:this.binds.tail.head;return this.comps.lookupComputed(e.it,t)}getInputHandler(t){return this.comps.getInputHandlerFor(this.it,t)}getAlterHandler(t){return this.comps.getAlterHandlerFor(this.it,t)}lookupRequest(t){return this.comps.getRequestFor(this.it,t)}lookupBestView(t,e){for(let r of this.views){let s=t[r];if(s!==void 0)return s}return t[e]}}class Di{constructor(t){this.value=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.value;this.value=t;for(let s of this.changeSubs)s({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class Dr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Di(e),this.onTransactionPushed=()=>{}}pushTransaction(t){return this.transactions.push(t),this.onTransactionPushed(t),t}pushLogic(t,e,r=[],s={},i=null){return this.pushTransaction(new Tr(t,this,e,r,i,s))}pushBubble(t,e,r=[],s={},i=null){let n=s.skipSelf?{...s,skipSelf:!1}:s;return this.pushTransaction(new Ti(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??ru(e),o=s?.onResName??e,f=(c,_,l,a,y)=>{let S=new Ri(t,this,c??_,c?[l]:[a,y],i);return this.pushTransaction(S)};try{let c=await u.fn.apply(null,r);return f(s?.onOkName,o,c,c,null)}catch(c){return f(s?.onErrorName,o,c,null,c)}}get hasPendingTransactions(){return this.transactions.length>0}transactNext(){if(this.hasPendingTransactions)this.transact(this.transactions.shift())}transactAll(){while(this.hasPendingTransactions)this.transact(this.transactions.shift())}transact(t){let e=this.state.value,r=t.run(e,this.comps);if(r!==void 0)this.state.set(r,{transaction:t}),t.afterTransaction();else console.warn("undefined new state",{curState:e,transaction:t})}transactInputNow(t,e,r,s){this.transact(new Wi(t,e,r,this,s))}}function ru(t){return()=>{throw Error(`Request not found: ${t}`)}}function su(){return this}class Wr{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Ji,this._task}getCompletionPromise(){return this.task.promise}setParent(t){this.parentTransaction=t,t.task.addDep(this.task)}run(t,e){return this.updateRootValue(t,e)}afterTransaction(){}buildRootStack(t,e){return Z.root(e,t)}buildStack(t,e){let r=this.path.buildStack(this.buildRootStack(t,e));return r?r.upToFrameBinds():null}callHandler(t,e,r){let[s,i]=this.getHandlerAndArgs(t,e,r);return s.apply(e,i)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),s=this.callHandler(t,r,e);return this._task?.complete?.({value:s,old:r}),r!==s?this.path.setValue(t,s):t}lookupName(t){return null}}var iu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Li=(t)=>Number.isNaN(t)?null:t;function Lr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Wi extends Wr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return Z.root(e,t,this)}getHandlerAndArgs(t,e,r){let s=this.buildStack(t,r),[i,n]=this.handler.getHandlerAndArgs(s,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new Jr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return Lr(e);case"valueAsInt":return Li(parseInt(Lr(e),10));case"valueAsFloat":return Li(parseFloat(Lr(e)));case"target":return e.target;case"event":return e;case"isAlt":return e.altKey;case"isShift":return e.shiftKey;case"isCtrl":case"isCmd":return iu&&e.metaKey||e.ctrlKey;case"key":return e.key;case"keyCode":return e.keyCode;case"isUpKey":return e.key==="ArrowUp";case"isDownKey":return e.key==="ArrowDown";case"isSend":return e.key==="Enter";case"isCancel":return e.key==="Escape";case"isTabKey":return e.key==="Tab";case"ctx":return new Zr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Rr extends Wr{constructor(t,e,r,s,i,n={}){super(t,e,i);this.name=r,this.args=s,this.opts=n}handlerProp=null;getHandlerForName(t){return t?.[this.handlerProp]?.[this.name]??su}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Zr(this.path,this.transactor,this)]]}}class Ri extends Rr{handlerProp="response"}class Tr extends Rr{handlerProp="logic";run(t,e){return this.opts.skipSelf?t:this.updateRootValue(t,e)}afterTransaction(){let{path:t,name:e,args:r,opts:s}=this;if(s.bubbles&&t.steps.length>0)this.transactor.pushBubble(t.popStep(),e,r,s,this)}}class Ti extends Tr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Ji{constructor(t){this.info=t,this.deps=[],this.value=this.resolve=this.reject=null,this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r}),this.isCompleted=!1}addDep(t){console.assert(!this.isCompleted,"addDep for completed task",this,t),this.deps.push(t),t.promise.then((e)=>this._check())}complete(t){this.value=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class Jr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Zi(this)}logic(t,e,r){return this.logicAtPath(this.path,t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}logicAtPath(t,e,r,s){return this.transactor.pushLogic(t,e,r,s,this.parent)}request(t,e,r){return this.requestAtPath(this.path,t,e,r)}requestAtPath(t,e,r,s){return this.transactor.pushRequest(t,e,r,s,this.parent)}lookupTypeFor(t,e){return this.transactor.comps.getCompFor(e).scope.lookupComponent(t)}}class Zr extends Jr{stopPropagation(){return this.parent.stopPropagation()}}class Zi extends rr{constructor(t){super();this.dispatcher=t}logic(t,e,r){return this.dispatcher.logicAtPath(this.buildPath(),t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}buildPath(){return this.dispatcher.path.concat(this.pathChanges)}}class Hr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new je(r),this.transactor=new Dr(r,null),this.ParseContext=i,this.renderer=s,this.renderFn=e,this.maxEventNodeDepth=1/0,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(["dragstart","dragover","dragend"]),this.dragInfo=this.curDragOver=null,this.transactor.onTransactionPushed=(n)=>{if(this._transactNextBatchId===null)this._scheduleNextTransactionBatchExecution()},this._compiled=!1}get state(){return this.transactor.state}handleEvent(t){let e=t.type==="dragstart",r=t.type==="dragover",s=t.type==="dragend",{rootNode:i,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||s),[o,f]=N.fromEvent(t,i,n,h,u);if(r){let c=nu(t.target,this.rootNode,50);if(c!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=c,c.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let c=this.state.value,_=o.lookup(c),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(c));this.dragInfo=new Hi(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&f!==null)for(let c of f)this.transactor.transactInputNow(o,t,c,this.dragInfo)}makeStack(t){return Z.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.value,e=this.makeStack(t);return this.renderFn(this.renderer.renderRoot(e,t),this.rootNode)}onChange(t){this.transactor.state.onChange(t)}compile(){for(let t of this.comps.byId.values()){t.compile(this.ParseContext);for(let e in t.views)for(let r of t.views[e].ctx.genEventNames())this._eventNames.add(r)}this._compiled=!0}start(t){if(!this._compiled)this.compile();for(let e of this._eventNames)this.rootNode.addEventListener(e,this);if(this.onChange((e)=>{if(e.value!==e.old)this.render()}),Ae("tutuca-app",this.comps.compileStyles(),t?.head??document.head),t?.noCache)this.renderer.setNullCache(),this.comps.setNullComputedCache();else this.startCacheEvictionInterval();this.render()}stop(){this.stopCacheEvictionInterval();for(let t of this._eventNames)this.rootNode.removeEventListener(t,this)}dispatchLogicAtRoot(t,e,r){return this.transactor.pushLogic(new N([]),t,e,r)}registerComponents(t,e){let r=this.compStack.enter();return r.registerComponents(t,e),r}_transactNextBatch(t=10){this._transactNextBatchId=null;let e=Date.now(),r=this.transactor;while(r.hasPendingTransactions&&Date.now()-e<t)r.transactNext();if(r.hasPendingTransactions)this._scheduleNextTransactionBatchExecution()}_scheduleNextTransactionBatchExecution(){this._transactNextBatchId=setTimeout(()=>this._transactNextBatch(),0)}startCacheEvictionInterval(t=30000){this._evictCacheId=setInterval(()=>this.renderer.cache.evict(),t)}stopCacheEvictionInterval(){clearInterval(this._evictCacheId),this._evictCacheId=null}}function Ae(t,e,r=document.head){let s=document.createElement("style"),i=r.querySelector(`#${t}`);if(i)r.removeChild(i);s.id=t,s.innerHTML=e,r.appendChild(s)}function nu(t,e,r){let s=t;while(r-- >0&&s!==e){if(s.dataset?.droptarget!==void 0)return s;s=s.parentNode}return null}class Hi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class $e extends ot{constructor(...t){super(...t);this.classes=new Set}_addClasses(t){for(let e of t.split(/\s+/))this.classes.add(e)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,c=new $e(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return c.classes=this.classes,c}onAttributes(t,e,r){if(Array.isArray(t.items))for(let s of t.items){if(s.name!=="class")continue;let{value:i,thenVal:n,elseVal:h}=s;if(n!==void 0)this._maybeAddVal(n),this._maybeAddVal(h);else this._maybeAddVal(i)}else{let s=t.items.class;if(s)this._addClasses(s)}}_maybeAddVal(t){if(!this._maybeAddStrTpl(t)&&typeof t?.value==="string")this._addClasses(t.value)}_maybeAddStrTpl(t){if(t?.vals!==void 0){for(let e of t.vals)if(e instanceof T&&e.value!=="")this._addClasses(e.value);return!0}return!1}}function xt(t,e){if(!t)throw Error(e)}function $(t){xt(t!==1/0,"Cannot perform this action with an infinite size.")}function Xi(t,e,r,s,i,n){return $(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var hu=(t,e)=>e,uu=(t,e)=>[e,t],Xr=(t)=>function(...e){return!t.apply(this,e)},Qi=(t)=>function(...e){return-t.apply(this,e)};function cn(t,e){if(t===void 0&&e===void 0)return 0;if(t===void 0)return 1;if(e===void 0)return-1;return t>e?1:t<e?-1:0}var Gi=(t,e)=>t<e?1:t>e?-1:0,U={done:!0,value:void 0};class _n{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new _n(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return U})}var ou=L(()=>U),ft=()=>ou;function Ze(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return U;return r.value=e++,r})}function vt(t,e){return M((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function ln(t){if(Array.isArray(t))return!0;return!!He(t)}var fu=(t)=>!!(t&&typeof t.next==="function");function an(t){return He(t)?.call(t)}function He(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function cu(t){let e=He(t);return e&&e===t.entries}function _u(t){let e=He(t);return e&&e===t.keys}var te="delete",z=5,E=1<<z,I=E-1,g={},Fr=()=>({value:!1});function J(t){if(t)t.value=!0}class Xe{}function At(t){if(t.size===void 0)t.size=t.__iterate(yn);return t.size}function tt(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?At(t)+e:e}var yn=()=>!0,gn=(t)=>t<0||Object.is(t,-0),ee=(t,e,r)=>(t===0&&!gn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),pn=(t,e,r)=>t===void 0?r:gn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Dt=(t,e)=>pn(t,e,0),re=(t,e)=>pn(t,e,e),wn="@@__IMMUTABLE_ITERABLE__@@",Le="@@__IMMUTABLE_KEYED__@@",De="@@__IMMUTABLE_INDEXED__@@",et="@@__IMMUTABLE_ORDERED__@@",se="@@__IMMUTABLE_SEQ__@@",dn="@@__IMMUTABLE_LIST__@@",zn="@@__IMMUTABLE_MAP__@@",Sn="@@__IMMUTABLE_SET__@@",On="@@__IMMUTABLE_STACK__@@",Mn="@@__IMMUTABLE_RECORD__@@";function P(t,e){return typeof t==="object"&&t!==null&&e in t}var W=(t)=>P(t,wn),d=(t)=>P(t,Le),j=(t)=>P(t,De),ts=(t)=>d(t)||j(t),F=(t)=>P(t,et),es=(t)=>P(t,se),rs=(t)=>P(t,dn),ie=(t)=>P(t,zn),ss=(t)=>P(t,Sn),is=(t)=>P(t,On),at=(t)=>P(t,Mn),x=(t)=>W(t)||at(t),Qe=(t)=>ie(t)&&F(t),bn=(t)=>ss(t)&&F(t),Yi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function En(t){let e=C(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Rt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return vt(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function qn(t,e,r){let s=C(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,g);return h===g?n:e.call(r,h,i,t)},s.__iterate=function(i,n){return t.__iterate((h,u)=>i(e.call(r,h,u,t),u,this),n)},s.__iteratorUncached=function(i){return vt(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function jn(t,e){let r=C(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=En(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Rt,r.__iterate=function(s,i){let n=0;if(i)At(t);return t.__iterate((h,u)=>s(h,e?u:i?this.size-++n:n++,this),!i)},r.__iteratorUncached=function(s){let i=0;if(s)At(t);let n=this.size;return vt(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function An(t,e,r,s){let i=t.size;if(ee(e,r,i))return t;if(i===void 0&&(e<0||r<0))return An(t.toSeq().cacheResult(),e,r,s);let n=Dt(e,i),u=re(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=C(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&es(t)&&o>=0)f.get=function(c,_){return c=tt(this,c),c>=0&&c<o?t.get(c+n,_):_};return f.__iterateUncached=function(c,_){if(o!==0&&_)return this.cacheResult().__iterate(c,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,w)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(y,s?w:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ft();let _=t.__iterator(c),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return U;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let w=_.next();if(w.done)return!1;return a++,y[0]=a-1,y[1]=w.value[1],!0})},f}function Ci(t,e,r){if(!e)e=cn;let s=d(t),i=0,n=t.toSeq().map((h,u)=>[u,h,i++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(s?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),s?fs(n):j(t)?lt(n):Vt(n)}function Ue(t,e,r){if(!e)e=cn;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Bi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Bi(e,s,i)?i:s)}function Bi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Qr(t,e,r,s){let i=C(t),n=new ne(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),f=0,c;while(!(c=o.next()).done)if(h(c.value[1],f++,this)===!1)break;return f},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=V(_);return an(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return M((_)=>{let l=s;for(let a=0;a<u.length;a++)f[a]=u[a].next(),l=s?l&&f[a].done:l||f[a].done;if(l)return!1;for(let a=0;a<f.length;a++)c[a]=f[a].value;return _[0]=o++,_[1]=e(...c),!0})},i}function $n(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function lu(t){if(!t||typeof t!=="object"||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let r=e,s=Object.getPrototypeOf(e);while(s!==null)r=s,s=Object.getPrototypeOf(r);return r===e}var rt=(t)=>typeof t==="object"&&(x(t)||Array.isArray(t)||lu(t));function Un(t){if($n(t)&&typeof t!=="string")return t;if(F(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var au=(t,e)=>x(t)?t.has(e):rt(t)&&Object.hasOwn(t,e);function In(t,e,r){return x(t)?t.get(e,r):!au(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function ns(t,e,r){let s=Un(e),i=0;while(i!==s.length)if(t=In(t,s[i++],g),t===g)return r;return t}var Kn=(t,e)=>ns(t,e,g)!==g;function A(t,e){if(t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1;if(typeof t.valueOf==="function"&&typeof e.valueOf==="function"){if(t=t.valueOf(),e=e.valueOf(),t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1}return!!(Yi(t)&&Yi(e)&&t.equals(e))}function We(t){if(!t||typeof t!=="object")return t;if(!W(t)){if(!rt(t))return t;t=st(t)}if(d(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=We(s)}),r}let e=[];return t.__iterate((r)=>{e.push(We(r))}),e}function hs(t,e){if(t===e)return!0;if(!W(e)||t.size!==void 0&&e.size!==void 0&&t.size!==e.size||t.__hash!==void 0&&e.__hash!==void 0&&t.__hash!==e.__hash||d(t)!==d(e)||j(t)!==j(e)||F(t)!==F(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!ts(t);if(F(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&A(f[1],u)&&(r||A(f[0],o))})&&h.next().done)}let s=!1;if(t.size===void 0)if(e.size===void 0){if(typeof t.cacheResult==="function")t.cacheResult()}else{s=!0;let h=t;t=e,e=h}let i=!0,n=e.__iterate((h,u)=>{if(r?!t.has(h):s?!A(h,t.get(u,g)):!A(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var Ge=(t)=>t>>>1&1073741824|t&3221225471;function H(t){if(t===null||t===void 0)return Pi(t);if(typeof t.hashCode==="function")return Ge(t.hashCode(t));let e=du(t);if(e===null||e===void 0)return Pi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return yu(e);case"string":return e.length>zu?gu(e):Vr(e);case"object":case"function":return wu(e);case"symbol":return pu(e);default:if(typeof e.toString==="function")return Vr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Pi=(t)=>t===null?1108378658:1108378659;function yu(t){if(Number.isNaN(t)||t===1/0)return 0;let e=t|0;if(e!==t)e^=t*4294967295;while(t>4294967295)t/=4294967295,e^=t;return Ge(e)}function gu(t){let e=Cr[t];if(e===void 0){if(e=Vr(t),Yr===Su)Yr=0,Cr={};Yr++,Cr[t]=e}return e}function Vr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return Ge(e)}function pu(t){let e=Fi[t];if(e!==void 0)return e;return e=Ln(),Fi[t]=e,e}function wu(t){let e=xi.get(t);if(e!==void 0)return e;return e=Ln(),xi.set(t,e),e}var du=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Ln(){let t=++Gr;if(Gr&1073741824)Gr=0;return t}var xi=new WeakMap,Fi=Object.create(null),Gr=0,zu=16,Su=255,Yr=0,Cr={};function Ou(t){if(t.size===1/0)return 0;let e=F(t),r=d(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Vi(H(i),H(n))|0}:(i,n)=>{s=s+Vi(H(i),H(n))|0}:e?(i)=>{s=31*s+H(i)|0}:(i)=>{s=s+H(i)|0}),Mu(t.size,s)}var Vi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Mu(t,e){return e=Math.imul(e,3432918353),e=Math.imul(e<<15|e>>>-15,461845907),e=Math.imul(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),e=Ge(e^e>>>16),e}function Ft(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:es(t)?e:t.create?t.create(e):t.constructor(e),bu=(t,e)=>O(t,(d(t)?Q:j(t)?yt:gt)(e)),ki=(...t)=>t,V=(t)=>W(t)?t:st(t);class X{size=0;static{this.prototype[wn]=!0,this.prototype.__toStringMapper=Ft,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return hs(this,t)}hashCode(){return this.__hash??(this.__hash=Ou(this))}toArray(){$(this.size);let t=Array(this.size||0),e=d(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Jn(this)}toJS(){return We(this)}toKeyedSeq(){return new ys(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}toOrderedMap(){throw Error("toOrderedMap: not patched — import CollectionConversions")}toOrderedSet(){throw Error("toOrderedSet: not patched — import CollectionConversions")}toSet(){throw Error("toSet: not patched — import CollectionConversions")}toSetSeq(){return new Zn(this)}toSeq(){return j(this)?this.toIndexedSeq():d(this)?this.toKeyedSeq():this.toSetSeq()}toStack(){throw Error("toStack: not patched — import CollectionConversions")}toList(){throw Error("toList: not patched — import CollectionConversions")}toString(){return"[Collection]"}__toString(t,e){if(this.size===0)return`${t}${e}`;return`${t} ${this.toSeq().map(this.__toStringMapper).join(", ")} ${e}`}concat(...t){let e=d(this),r=[this,...t].map((s)=>{if(!W(s))s=e?Wn(s):Rn(Array.isArray(s)?s:[s]);else if(e)s=Q(s);return s}).filter((s)=>s.size!==0);if(r.length===0)return this;if(r.length===1){let s=r[0];if(s===this||e&&d(s)||j(this)&&j(s))return s}return O(this,new Tn(r))}includes(t){return this.some((e)=>A(e,t))}every(t,e){$(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=d(this),i=C(r);if(s)i.has=(n)=>{let h=r.get(n,g);return h!==g&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,g);return u!==g&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,f)=>{if(t.call(e,o,f,r))return u++,n(o,s?f:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return M((o)=>{while(!0){let f=h.next();if(f.done)return!1;let c=f.value[0],_=f.value[1];if(t.call(e,_,c,r))return o[0]=s?c:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=d(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>bu(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return $(this.size),this.__iterate(e?t.bind(e):t)}join(t){$(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[0],e})}map(t,e){return O(this,qn(this,t,e))}reduce(t,e=g,r){return Xi(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Xi(this,t,e,r,e===g,!0)}reverse(){return O(this,jn(this,d(this)))}slice(t,e){return O(this,An(this,t,e,d(this)))}some(t,e){$(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return O(this,Ci(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return At(t?this.toSeq().filter(t,e):this)}countBy(t,e){throw Error("countBy: not patched — import CollectionConversions")}entrySeq(){let t=this;if(t._cache)return new ne(t._cache);let e=t.toSeq().map(uu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Xr(t),e)}findEntry(t,e,r){let s=r;return this.__iterate((i,n,h)=>{if(t.call(e,i,n,h))return s=[n,i],!1}),s}findKey(t,e){let r=this.findEntry(t,e);return r&&r[0]}findLast(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)}findLastEntry(t,e,r){return this.toKeyedSeq().reverse().findEntry(t,e,r)}findLastKey(t,e){return this.toKeyedSeq().reverse().findKey(t,e)}first(t){return this.find(yn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(d(this)?Q:j(this)?yt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=d(this),s=C(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(f,c){f.__iterate((_,l)=>{if((!t||c<t)&&W(_))o(_,c+1);else if(h++,i(_,r?l:h-1,s)===!1)u=!0;if(u)return!1},n)}return o(e,0),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=0,h=[{iterator:e.__iterator(i),depth:0}];return M((u)=>{while(h.length>0){let o=h[h.length-1],f=o.iterator.next();if(f.done){h.pop();continue}let c=f.value[1];if((!t||o.depth<t)&&W(c)){h.push({iterator:c.__iterator(i),depth:o.depth+1});continue}return u[0]=r?f.value[0]:n++,u[1]=c,!0}return!1})},O(this,s)}fromEntrySeq(){return new Hn(this)}get(t,e){return this.find((r,s)=>A(s,t),void 0,e)}getIn(t,e){return ns(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return Kn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:V(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:V(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>A(e,t))}keySeq(){return this.toSeq().map(hu).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Ue(this,t)}maxBy(t,e){return Ue(this,e,t)}min(t){return Ue(this,t?Qi(t):Gi)}minBy(t,e){return Ue(this,e?Qi(e):Gi,t)}rest(){return this.slice(1)}skip(t){return t===0?this:this.slice(Math.max(0,t))}skipLast(t){return t===0?this:this.slice(0,-Math.max(0,t))}skipWhile(t,e){let r=this,s=d(this),i=C(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((f,c)=>{if(u&&t.call(e,f,c,this))return;return u=!1,o++,n(f,s?c:o-1,this)},h),o},i.__iteratorUncached=function(n){if(n)return this.cacheResult().__iterator(n);let h=r.__iterator(n),u=0,o=this,f=!0;return M((c)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(f&&t.call(e,a,l,o))continue;return f=!1,c[0]=s?l:u++,c[1]=a,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(Xr(t),e)}sortBy(t,e){return O(this,Ci(this,e,t))}take(t){return this.slice(0,Math.max(0,t))}takeLast(t){return this.slice(-Math.max(0,t))}takeWhile(t,e){let r=this,s=C(r);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,i(u,o,this)},n),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=r.__iterator(i),h=this,u=!1;return L(()=>{if(u)return U;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,U;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(Xr(t),e)}update(t){return t(this)}valueSeq(){return this.toIndexedSeq()}__iterate(t,e=!1){let r=this.__iterator(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterator(t=!1){throw Error("CollectionImpl does not implement __iterator. Use a subclass instead.")}}var Q=(t)=>d(t)?t:fs(t);class us extends X{static{this.prototype[Le]=!0,this.prototype.__toStringMapper=(t,e)=>`${Ft(e)}: ${Ft(t)}`,this.prototype[Symbol.iterator]=X.prototype.entries,this.prototype.toJSON=function(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,En(this))}mapEntries(t,e){let r=0;return O(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return O(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var yt=(t)=>j(t)?t:lt(t);class $t extends X{static{this.prototype[De]=!0,this.prototype[et]=!0}toKeyedSeq(){return new ys(this,!1)}findIndex(t,e){let r=this.findEntry(t,e);return r?r[0]:-1}indexOf(t){let e=this.keyOf(t);return e===void 0?-1:e}lastIndexOf(t){let e=this.lastKeyOf(t);return e===void 0?-1:e}splice(t,e=g,...r){if(t===void 0)return this;let s=e!==g;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Dt(t,t<0?this.count():this.size);let i=this.slice(0,t);return O(this,!s?i:i.concat(r,this.slice(t+e)))}findLastIndex(t,e){let r=this.findLastEntry(t,e);return r?r[0]:-1}first(t){return this.get(0,t)}get(t,e){return t=tt(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?e:this.find((r,s)=>s===t,void 0,e)}has(t){return t=tt(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)}interpose(t){let e=this,r=C(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(s,i){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(s(t,n++,this)===!1)return!1}return h=!1,s(u,n++,this)},i),n},r.__iteratorUncached=function(s){let i=e.__iterator(s),n=0,h=!0,u,o=!1;return M((f)=>{if(o)return o=!1,f[0]=n++,f[1]=u,!0;let c=i.next();if(c.done)return!1;let _=c.value[1];if(!h)return u=_,o=!0,f[0]=n++,f[1]=t,!0;return h=!1,f[0]=n++,f[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=Qr(this.toSeq(),lt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return O(this,s)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(ki,...t)}zipAll(...t){let e=[this,...t];return O(this,Qr(this,ki,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,Qr(this,t,r))}}var gt=(t)=>W(t)&&!ts(t)?t:Vt(t);class Ye extends X{static{this.prototype.has=X.prototype.includes,this.prototype.contains=X.prototype.includes,this.prototype.keys=Ye.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}V.Keyed=Q;V.Indexed=yt;V.Set=gt;var Br=$t.prototype,st=(t)=>t===void 0||t===null?ls():x(t)?t.toSeq():Eu(t),C=(t)=>Object.create((d(t)?Wt:j(t)?pt:cs).prototype);class ct extends X{static{this.prototype[se]=!0}toSeq(){return this}toString(){return this.__toString("Seq {","}")}cacheResult(){if(!this._cache&&this.__iterateUncached)this._cache=this.entrySeq().toArray(),this.size=this._cache.length;return this}__iterateUncached(t,e){let r=this.__iteratorUncached(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterate(t,e){let r=this._cache;if(r){let s=r.length,i=0;while(i!==s){let n=r[e?s-++i:i++];if(t(n[1],n[0],this)===!1)break}return i}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,s=0,i={done:!1,value:void 0};return L(()=>{if(s===r)return U;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var os={cacheResult:ct.prototype.cacheResult,__iterateUncached:ct.prototype.__iterateUncached,__iterate:ct.prototype.__iterate,__iterator:ct.prototype.__iterator},fs=(t)=>t===void 0||t===null?ls().toKeyedSeq():W(t)?d(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Wn(t);class Wt extends us{static{this.prototype[se]=!0,Object.assign(this.prototype,os)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?ls():W(t)?d(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Rn(t);lt.of=(...t)=>lt(t);class pt extends $t{static{this.prototype[se]=!0,Object.assign(this.prototype,os)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var Vt=(t)=>(W(t)&&!ts(t)?t:lt(t)).toSetSeq();Vt.of=(...t)=>Vt(t);class cs extends Ye{static{this.prototype[se]=!0,Object.assign(this.prototype,os)}toSeq(){return this}toSetSeq(){return this}}st.isSeq=es;st.Keyed=fs;st.Set=Vt;st.Indexed=lt;class ne extends pt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[tt(this,t)]:e}__iterateUncached(t,e){let r=this._array,s=r.length,i=0;while(i!==s){let n=e?s-++i:i++;if(t(r[n],n,this)===!1)break}return i}__iteratorUncached(t){let e=this._array,r=e.length,s=0;return M((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class _s extends Wt{static{this.prototype[et]=!0}constructor(t){super();let e=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];this._object=t,this._keys=e,this.size=e.length}get(t,e){if(e!==void 0&&!this.has(t))return e;return this._object[t]}has(t){return Object.hasOwn(this._object,t)}__iterateUncached(t,e){let r=this._object,s=this._keys,i=s.length,n=0;while(n!==i){let h=s[e?i-++n:n++];if(t(r[h],h,this)===!1)break}return n}__iteratorUncached(t){let e=this._object,r=this._keys,s=r.length,i=0;return M((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class Dn extends pt{constructor(t){super();this._collection=t,this.size=t.length||t.size}__iterateUncached(t,e){if(e)return this.cacheResult().__iterate(t,e);let r=0;for(let s of this._collection){if(t(s,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=an(e);if(!fu(r))return ft();let s=0;return M((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var ls=()=>new ne([]),as=(t)=>$n(t)?new ne(t):ln(t)?new Dn(t):void 0;function Wn(t){let e=as(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new _s(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Rn(t){let e=as(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Eu(t){let e=as(t);if(e)return cu(t)?e.fromEntrySeq():_u(t)?e.toSetSeq():e;if(typeof t==="object")return new _s(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Tn extends ct{constructor(t){super();let e=[],r=0,s=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),s){let u=h.size;if(u!==void 0)r+=u;else s=!1}}else if(e.push(n),s){let h=n.size;if(h!==void 0)r+=h;else s=!1}this._wrappedIterables=e,this.size=s?r:void 0;let i=this._wrappedIterables[0];if(i[Le])this[Le]=!0;if(i[De])this[De]=!0;if(i[et])this[et]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!d(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ft();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!d(this),s=0,i=e[0].__iterator(t);function n(){while(s<e.length){let h=i.next();if(!h.done)return h;if(s++,s<e.length)i=e[s].__iterator(t)}return}if(r){let h=0;return M((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return L(()=>n()||U)}}class ys extends Wt{static{this.prototype[et]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Rt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=jn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=qn(this,t,e);if(!this._useKeys)r.valueSeq=()=>this._iter.toSeq().map(t,e);return r}__iterateUncached(t,e){return this._iter.__iterate(t,e)}__iteratorUncached(t){return this._iter.__iterator(t)}}class Jn extends pt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Rt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)At(this);let s=this.size;return this._iter.__iterate((i)=>{let n=e?s-++r:r++;return t(i,n,this)},e),r}__iteratorUncached(t){let e=0;if(t)At(this);let r=this.size;return vt(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Zn extends cs{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Rt.call(this)}has(t){return this._iter.includes(t)}__iterateUncached(t,e){return this._iter.__iterate((r)=>t(r,r,this),e)}__iteratorUncached(t){return vt(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Hn extends Wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Rt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){Ni(s),r++;let i=W(s);return t(i?s.get(1):s[1],i?s.get(0):s[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){Ni(i);let n=W(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Rt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ct.prototype.cacheResult.call(this)}function Ni(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var Y=(t)=>t===void 0||t===null?G():ie(t)&&!F(t)?t:G().withMutations((e)=>{let r=Q(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});class gs extends us{static{dt(this,{asImmutable:he,asMutable:ue,deleteIn:Ut,merge:kr,mergeWith:Pn,mergeDeep:Fn,mergeDeepWith:Vn,mergeDeepIn:$s,mergeIn:As,setIn:Es,update:qs,updateIn:js,wasAltered:bs,withMutations:oe,removeIn:Ut,concat:kr,[zn]:!0,[te]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,s){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return Y(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,H(t),t,e):e}set(t,e){return vi(this,t,e)}remove(t){return vi(this,t,g)}deleteAll(t){let e=V(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return G()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ft();return Ie(this._root,!1,0)}values(){if(!this._root)return ft();return Ie(this._root,!1,1)}entries(){if(!this._root)return ft();return Ie(this._root,!1)}__iterator(t){if(!this._root)return ft();return Ie(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return G();return this.__ownerID=t,this.__altered=!1,this}return ds(this.size,this._root,t,this.__hash)}}Y.isMap=ie;class ps{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Xn(this.entries,r,s)}iterate(t,e){return Qn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(J(h),u||!_)J(n);if(u&&c===1)return;if(!_&&!u&&c>=Iu)return qu(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new ps(t,a)}}class Ce{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Gn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&I),n=this.bitmap;return(n&i)===0?s:this.nodes[en(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=1<<u,f=this.bitmap,c=(f&o)!==0;if(!c&&i===g)return this;let _=en(f&o-1),l=this.nodes,a=c?l[_]:void 0,y=zs(a,t,e+z,r,s,i,n,h);if(y===a)return this;if(!c&&y&&l.length>=Ku)return Au(t,l,f,u,y);if(c&&!y&&l.length===2&&tn(l[_^1]))return l[_^1];if(c&&y&&l.length===1&&tn(y))return y;let w=t&&t===this.ownerID,S=c?y?f:f^o:f|o,q=c?y?Yn(l,_,y,w):Uu(l,_,w):$u(l,_,y,w);if(w)return this.bitmap=S,this.nodes=q,this;return new Ce(t,S,q)}}class ws{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Gn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&I,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=i===g,f=this.nodes,c=f[u];if(o&&!c)return this;let _=zs(c,t,e+z,r,s,i,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<Lu)return ju(t,f,l,u)}let a=t&&t===this.ownerID,y=Yn(f,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new ws(t,l,y)}}class Be{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Xn(this.entries,r,s)}iterate(t,e){return Qn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return J(h),J(n),Ss(this,t,e,r,[s,i])}let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(J(h),u||!_)J(n);if(u&&c===2)return new wt(t,this.keyHash,o[f^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Be(t,this.keyHash,a)}}class wt{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}iterate(t,e){return t(this.entry)}get(t,e,r,s){return A(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=A(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(J(h),u){J(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new wt(t,this.keyHash,[s,i])}return J(n),Ss(this,t,e,H(s),[s,i])}}function Xn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(A(e,t[s][0]))return t[s][1];return r}function Qn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(e(t[r?i-s:s])===!1)return!1}function Gn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(t[r?i-s:s]?.iterate(e,r)===!1)return!1}function Ie(t,e,r){let s={node:t,index:0,__prev:null},i=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return L(()=>{while(s){let h=s.node,u=s.index++,o;if(h.entry){if(u===0)return n.value=i(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=i(h.entries[e?o-u:u]),n}else if(o=h.nodes.length-1,u<=o){let f=h.nodes[e?o-u:u];if(f){if(f.entry)return n.value=i(f.entry),n;s={node:f,index:0,__prev:s}}continue}s=s.__prev}return U})}var ds=(t,e,r,s)=>new gs(t,e,r,s),mi,G=()=>mi||(mi=ds(0));function vi(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new ps(t.__ownerID,[[e,r]])}else{let n=Fr(),h=Fr();if(s=zs(t._root,t.__ownerID,0,H(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===g?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?ds(i,s):G()}function zs(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return J(u),J(h),new wt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var tn=(t)=>t.constructor===wt||t.constructor===Be;function Ss(t,e,r,s,i){if(t.keyHash===s)return new Be(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&I,h=(r===0?s:s>>>r)&I,u=new wt(e,s,i),o=n===h?[Ss(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new Ce(e,1<<n|1<<h,o)}function qu(t,e,r,s){if(!t)t=new Xe;let i=new wt(t,H(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,H(n),n,h);return i}function ju(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,f=e.length;u<f;u++,o<<=1){let c=e[u];if(c!==void 0&&u!==s)i|=o,h[n++]=c}return new Ce(t,i,h)}function Au(t,e,r,s,i){let n=0,h=Array(E);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[s]=i,new ws(t,n+1,h)}function en(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function Yn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function $u(t,e,r,s){let i=t.length+1;if(s&&e+1===i)return t[e]=r,t;let n=Array(i),h=0;for(let u=0;u<i;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function Uu(t,e,r){let s=t.length-1;if(r&&e===s)return t.pop(),t;let i=Array(s),n=0;for(let h=0;h<s;h++){if(h===e)n=1;i[h]=t[h+n]}return i}var Iu=E/4,Ku=E/2,Lu=E/4;function Re(t){if(Array.isArray(t))return t.slice();return{...t}}var Os=(t,e,r)=>Ms(t,e,Du(r));function Ms(t,e,r){if(!rt(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(x(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?yt:Q,h=s?(u)=>{if(i===t)i=Re(i);i.push(u)}:(u,o)=>{let f=Object.hasOwn(i,o),c=f&&r?r(i[o],u,o):u;if(!f||c!==i[o]){if(i===t)i=Re(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function Du(t){function e(r,s,i){return rt(r)&&rt(s)&&Wu(r,s)?Ms(r,[s],e):t?t(r,s,i):s}return e}function Wu(t,e){let r=st(t),s=st(e);return j(r)===j(s)&&d(r)===d(s)}function Ru(t,e){if(!rt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(x(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=Re(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Tu(t,e,r){if(!rt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(x(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=Re(t);return s[e]=r,s}function Tt(t,e,r,s){if(!s)s=r,r=void 0;let i=Cn(x(t),t,Un(e),0,r,s);return i===g?r:i}function Cn(t,e,r,s,i,n){let h=e===g;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!rt(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(Ft)}]: ${e}`);let u=r[s],o=h?g:In(e,u,g),f=Cn(o===g?t:x(o),o,r,s+1,i,n);if(f===o)return e;if(f===g)return Ru(e,u);let c=h?t?G():{}:e;return Tu(c,u,f)}var Ju=(t,e)=>Tt(t,e,()=>g),Zu=(t,e,r)=>Tt(t,e,g,()=>r);function Bn(t,e,r,s){return Tt(t,[e],r,s)}function he(){return this.__ensureOwner()}function ue(){return this.__ownerID?this:this.__ensureOwner(new Xe)}function bs(){return this.__altered}function oe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Hu(t,e){return ns(this,t,e)}function Xu(t){return Kn(this,t)}function Ut(t){return Ju(this,t)}function Es(t,e){return Zu(this,t,e)}function qs(t,e,r){return typeof t==="function"?t(this):Bn(this,t,e,r)}function js(t,e,r){return Tt(this,t,e,r)}function rn(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function kr(...t){return xn(this,t)}function Pn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return xn(this,e,t)}function xn(t,e,r){let s=[];for(let i of e){let n=Q(i);if(n.size!==0)s.push(n)}if(s.length===0)return t;if(t.toSeq().size===0&&!t.__ownerID&&s.length===1)return at(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Bn(i,u,g,(o)=>o===g?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function Fn(...t){return Os(this,t)}function Vn(t,...e){return Os(this,e,t)}function As(t,...e){return Tt(this,t,G(),(r)=>Ms(r,e))}function $s(t,...e){return Tt(this,t,G(),(r)=>Os(r,e))}function dt(t,e){Object.assign(t.prototype,e)}var K=(t)=>{let e=kt();if(t===void 0||t===null)return e;if(rs(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if($(s),s>0&&s<E)return fe(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};K.of=(...t)=>K(t);class kn extends $t{static{dt(this,{asImmutable:he,asMutable:ue,deleteIn:Ut,mergeDeepIn:$s,mergeIn:As,setIn:Es,update:qs,updateIn:js,wasAltered:bs,withMutations:oe,removeIn:Ut,[dn]:!0,[te]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return K(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=tt(this,t),t>=0&&t<this.size){t+=this._origin;let r=vn(this,t);return r&&r.array[t&I]}return e}set(t,e){return Gu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return kt()}push(...t){let e=this.size;return this.withMutations((r)=>{v(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return v(this,0,-1)}unshift(...t){return this.withMutations((e)=>{v(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return v(this,1)}shuffle(t=Math.random){return this.withMutations((e)=>{let r=e.size,s,i;while(r)s=Math.floor(t()*r--),i=e.get(s),e.set(s,e.get(r)),e.set(r,i)})}concat(...t){let e=[];for(let r of t){let s=yt(typeof r!=="string"&&ln(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return K(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return v(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(ee(t,e,r))return this;return v(this,Dt(t,r),re(e,r))}__iterate(t,e){let r=e?this.size:0;return Qu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=sn(this,t);return M((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return sn(this,!1)}keys(){return Ze(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return kt();return this.__ownerID=t,this.__altered=!1,this}return fe(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}K.isList=rs;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&I;if(s>=this.array.length)return new _t([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-z,r),n===u&&i)return this}if(i&&!n)return this;let h=It(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:E)||this.array.length===0)return this;let s=r-1>>>e&I;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=It(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function sn(t,e){let{_origin:r,_capacity:s}=t,i=Kt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let f=h[h.length-1];if(f.from===f.to){h.pop();continue}let c=e?--f.to:f.from++;if(f.isLeaf)return u.value=f.array?.[c],u;let _=f.array?.[c],l=f.level-z,a=f.offset+(c<<f.level);o(_,l,a)}return U});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,y=s-_;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,y=(s-_>>c)+1;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,level:c,offset:_,isLeaf:!1})}}}function Qu(t,e,r){let{_origin:s,_capacity:i}=t,n=Kt(i),h=t._tail,u=t._level,o=t._root;return u===0?Nn(o,0,s,i,n,h,e,r):mn(o,u,0,s,i,n,h,e,r)}function Nn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,f=e>r?0:r-e,c=s-e;if(c>E)c=E;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function mn(t,e,r,s,i,n,h,u,o){let f=t?.array,c=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let l=e-z;while(c!==_){let a=o?--_:c++,y=r+(a<<e);if((l===0?Nn(f?.[a],y,s,i,n,h,u,o):mn(f?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var fe=(t,e,r,s,i,n,h)=>new kn(t,e,r,s,i,n,h),kt=()=>fe(0,0,z);function Gu(t,e,r){if(e=tt(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)v(h,e).set(0,r);else v(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=Fr();if(e>=Kt(t._capacity))s=Nr(s,t.__ownerID,0,e,r,n);else i=Nr(i,t.__ownerID,t._level,e,r,n);if(!n.value)return t;if(t.__ownerID)return t._root=i,t._tail=s,t.__hash=void 0,t.__altered=!0,t;return fe(t._origin,t._capacity,t._level,i,s)}function Nr(t,e,r,s,i,n){let h=s>>>r&I,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let f=t&&t.array[h],c=Nr(f,e,r-z,s,i,n);if(c===f)return t;return o=It(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)J(n);if(o=It(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function It(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function vn(t,e){if(e>=Kt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&I],s-=z;return r}}function v(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Xe,i=t._origin,n=t._capacity,h=i+e,u=r===void 0?n:r<0?n+r:i+r;if(h===i&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:f}=t,c=0;while(h+c<0)f=new _t(f?.array.length?[void 0,f]:[],s),o+=z,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=Kt(n),l=Kt(u);while(l>=1<<o+z)f=new _t(f?.array.length?[f]:[],s),o+=z;let a=t._tail,y=l<_?vn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){f=It(f,s);let w=f;for(let S=o;S>z;S-=z){let q=_>>>S&I;w=w.array[q]=It(w.array[q],s)}w.array[_>>>z&I]=a}if(u<n)y=y&&y.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,f=null,y=y&&y.removeBefore(s,0,h);else if(h>i||l<_){c=0;while(f){let w=h>>>o&I;if(w!==l>>>o&I)break;if(w)c+=(1<<o)*w;o-=z,f=f.array[w]}if(f&&h>i)f=f.removeBefore(s,o,h-c);if(f&&l<_)f=f.removeAfter(s,o,l-c);if(c)h-=c,u-=c}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=f,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return fe(h,u,o,f,y)}var Kt=(t)=>t<E?0:t-1>>>z<<z,B=(t)=>t===void 0||t===null?Nt():Qe(t)?t:Nt().withMutations((e)=>{let r=Q(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});B.of=(...t)=>B(t);class th extends gs{static{dt(this,{[et]:!0,[te]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:X.prototype.keys,values:X.prototype.values,__iterate:X.prototype.__iterate})}constructor(t,e,r,s){super(t?t.size:0,void 0,r,s);this._map=t,this._list=e}create(t){return B(t)}toString(){return this.__toString("OrderedMap {","}")}get(t,e){let r=this._map.get(t);return r!==void 0?this._list.get(r)[1]:e}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this;return Nt()}set(t,e){return nn(this,t,e)}remove(t){return nn(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i)return r[0]=i[0],r[1]=i[1],!0}})}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);if(!t){if(this.size===0)return Nt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Us(e,r,t,this.__hash)}}B.isOrderedMap=Qe;var Us=(t,e,r,s)=>new th(t,e,r,s),Nt=()=>Us(G(),kt());function nn(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===g){if(!h)return t;if(i.size>=E&&i.size>=s.size*2){let f=[];if(i.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=kt().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=G().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(f[_][0],_)}),t.__ownerID)u.__ownerID=o.__ownerID=t.__ownerID}else u=s.remove(e),o=n===i.size-1?i.pop():i.set(n,void 0)}else if(h){if(r===i.get(n)[1])return t;u=s,o=i.set(n,[e,r])}else{let f=i.size;u=s.set(e,f),o=i.set(f,[e,r])}if(t.__ownerID)return t.size=u.size,t._map=u,t._list=o,t.__hash=void 0,t.__altered=!0,t;return Us(u,o)}var Te=(t)=>t===void 0||t===null?Je():is(t)?t:Je().pushAll(t);Te.of=(...t)=>Te(t);class eh extends $t{static{dt(this,{asImmutable:he,asMutable:ue,wasAltered:bs,withMutations:oe,[On]:!0,shift:this.prototype.pop,unshift:this.prototype.push,unshiftAll:this.prototype.pushAll,[Symbol.toStringTag]:"Immutable.Stack",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s){super();this.size=t,this._head=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return Te(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=tt(this,t);while(r&&t--)r=r.next;return r?r.value:e}peek(){return this._head?.value}push(...t){if(t.length===0)return this;let e=this.size+t.length,r=this._head;for(let s=t.length-1;s>=0;s--)r={value:t[s],next:r};return Pr(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&is(t))return t;$(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Pr(this,e,r)}pop(){return this.slice(1)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this;return Je()}slice(t,e){if(ee(t,e,this.size))return this;let r=Dt(t,this.size);if(re(e,this.size)!==this.size)return $t.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return Pr(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Je();return this.__ownerID=t,this.__altered=!1,this}return Is(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let i=this.toArray(),n=i.length,h=0;while(h!==n)if(t(i[n-++h],n-h,this)===!1)break;return h}let r=0,s=this._head;while(s){if(t(s.value,r++,this)===!1)break;s=s.next}return r}__iterator(t){if(t){let s=this.toArray(),i=s.length,n=0;return M((h)=>{if(n===i)return!1;let u=i-++n;return h[0]=u,h[1]=s[u],!0})}let e=0,r=this._head;return M((s)=>{if(!r)return!1;return s[0]=e++,s[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return L(()=>{if(!t)return U;return e.value=t.value,t=t.next,e})}keys(){return Ze(this.size)}}Te.isStack=is;function Pr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Is(e,r)}var Is=(t,e,r,s)=>new eh(t,e,r,s),hn,Je=()=>hn||(hn=Is(0)),b=(t)=>t===void 0||t===null?mt():ss(t)&&!F(t)?t:mt().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});b.of=(...t)=>b(t);b.fromKeys=(t)=>b(Q(t).keySeq());b.intersect=(t)=>{return t=V(t).toArray(),t.length?b(t.pop()).intersect(...t):mt()};b.union=(t)=>{let e=V(t).toArray();return e.length?b(e.pop()).union(...e):mt()};class Ks extends Ye{static{dt(this,{withMutations:oe,asImmutable:he,asMutable:ue,[Sn]:!0,[te]:this.prototype.remove,merge:this.prototype.union,concat:this.prototype.union,[Symbol.toStringTag]:"Immutable.Set"})}constructor(t,e){super();this.size=t?t.size:0,this._map=t,this.__ownerID=e}create(t){return b(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ke(this,this._map.set(t,t))}remove(t){return Ke(this,this._map.remove(t))}clear(){return Ke(this,this._map.clear())}map(t,e){let r=!1,s=Ke(this,this._map.mapEntries(([,i])=>{let n=t.call(e,i,i,this);if(n!==i)r=!0;return[n,n]},e));return r?s:this}union(...t){if(t=t.filter((e)=>e.size!==0),t.length===0)return this;if(this.size===0&&!this.__ownerID&&t.length===1)return b(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else gt(r).forEach((s)=>e.add(s))})}intersect(...t){return on(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return on(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return mt()}__make(t,e){return rh(t,e)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t);if(!t){if(this.size===0)return this.__empty();return this.__ownerID=t,this._map=e,this}return this.__make(e,t)}}b.isSet=ss;var rh=(t,e)=>new Ks(t,e),un,mt=()=>un||(un=rh(G()));function on(t,e,r){if(e.length===0)return t;return e=e.map((s)=>gt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Ke(t,e){if(t.__ownerID)return t.size=e.size,t._map=e,t;return e===t._map?t:e.size===0?t.__empty():t.__make(e)}var Lt=(t)=>t===void 0||t===null?mr():bn(t)?t:mr().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});Lt.of=(...t)=>Lt(t);Lt.fromKeys=(t)=>Lt(Q(t).keySeq());class sh extends Ks{static{dt(this,{[et]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Br.zip,zipWith:Br.zipWith,zipAll:Br.zipAll})}create(t){return Lt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return mr()}__make(t,e){return ih(t,e)}}Lt.isOrderedSet=bn;var ih=(t,e)=>new sh(t,e),mr=()=>ih(Nt());function Yu(t){if(at(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var ce=(t,e)=>{let r;Yu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._keys=u,i._defaultValues=t;for(let f=0;f<u.length;f++){let c=u[f];if(o[c]=f,i[c])console.warn(`Cannot define ${Ls(this)} with property "${c}" since that property name is part of the Record API.`);else Bu(i,c)}}return this.__ownerID=void 0,this._values=K().withMutations((u)=>{u.setSize(this._keys.length),Q(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(Cu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class nh{static{dt(this,{asImmutable:he,asMutable:ue,deleteIn:Ut,getIn:Hu,hasIn:Xu,merge:kr,mergeWith:Pn,mergeDeep:Fn,mergeDeepWith:Vn,mergeDeepIn:$s,mergeIn:As,setIn:Es,toObject:rn,update:qs,updateIn:js,withMutations:oe,removeIn:Ut,toJSON:rn,[Mn]:!0,[te]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${Ft(this.get(e))}`).join(", ");return`${Ls(this)} { ${t} }`}equals(t){return this===t||at(t)&&jt(this).equals(jt(t))}hashCode(){return jt(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return xr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:xr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return jt(this)}toJS(){return We(this)}entries(){return this.__iterator()}__iterate(t,e){return jt(this).__iterate(t,e)}__iterator(t){return jt(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return xr(this,e,t)}}ce.isRecord=at;var Ls=(t)=>t.constructor.displayName||t.constructor.name||"Record";class hh extends Wt{constructor(t){super();this._record=t,this.size=t._keys.length}get(t,e){return this._record.get(t,e)}has(t){return this._record.has(t)}__iterateUncached(t,e){let r=this._record,s=r._keys,i=s.length,n=0;while(n!==i){let h=e?i-++n:n++,u=s[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,s=r.length,i=0;return M((n)=>{if(i===s)return!1;let h=t?s-++i:i++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var jt=(t)=>new hh(t);ce.getDescriptiveName=Ls;var Cu=nh.prototype;function xr(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Bu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){xt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var fn=(t,e,r=1)=>{if(xt(r!==0,"Cannot step a Range by 0"),xt(t!==void 0,"You must define a start value when using Range"),xt(e!==void 0,"You must define an end value when using Range"),r=Math.abs(r),e<t)r=-r;let s=Math.max(0,Math.ceil((e-t)/r-1)+1);return new Ds(t,e,r,s)};class Ds extends pt{_start;_end;_step;constructor(t,e,r,s){super();this._start=t,this._end=e,this._step=r,this.size=s}toString(){return this.size===0?"Range []":`Range [ ${this._start}...${this._end}${this._step!==1?` by ${this._step}`:""} ]`}get(t,e){return this.has(t)?this._start+tt(this,t)*this._step:e}includes(t){let e=(t-this._start)/this._step;return e>=0&&e<this.size&&e===Math.floor(e)}slice(t,e){if(ee(t,e,this.size))return this;if(t=Dt(t,this.size),e=re(e,this.size),e<=t)return fn(0,0);return fn(this.get(t,this._end),this.get(e,this._end),this._step)}indexOf(t){let e=t-this._start;if(e%this._step===0){let r=e/this._step;if(r>=0&&r<this.size)return r}return-1}lastIndexOf(t){return this.indexOf(t)}__iterateUncached(t,e=!1){let r=this.size,s=this._step,i=e?this._start+(r-1)*s:this._start,n=0;while(n!==r){let h=i;i+=e?-s:s;let u=e?r-++n:n++;if(t(h,u,this)===!1)break}return n}__iteratorUncached(t=!1){let e=this.size,r=this._step,s=t?this._start+(e-1)*r:this._start,i=0;return M((n)=>{if(i===e)return!1;let h=s;return s+=t?-r:r,n[0]=t?e-++i:i++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,s=0,i={done:!1,value:void 0};return L(()=>{if(s===t)return U;return i.value=r,r+=e,s++,i})}keys(){return Ze(this.size)}equals(t){return t instanceof Ds?this._start===t._start&&this._end===t._end&&this._step===t._step:hs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class vr extends pt{constructor(t,e){super();this._value=t,this.size=e}toString(){if(this.size===0)return"Repeat []";return`Repeat [ ${this._value} ${this.size} times ]`}get(t,e){return this.has(t)?this._value:e}includes(t){return A(this._value,t)}slice(t,e){let r=this.size;return ee(t,e,r)?this:new vr(this._value,re(e,r)-Dt(t,r))}reverse(){return this}indexOf(t){if(A(this._value,t))return 0;return-1}lastIndexOf(t){if(A(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,s=0;while(s!==r)if(t(this._value,e?r-++s:s++,this)===!1)break;return s}__iteratorUncached(t){let e=this.size,r=this._value,s=0;return M((i)=>{if(s===e)return!1;return i[0]=t?e-++s:s++,i[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,s={done:!1,value:void 0};return L(()=>{if(r===t)return U;return r++,s.value=e,s})}keys(){return Ze(this.size)}equals(t){return t instanceof vr?this.size===t.size&&A(this._value,t._value):hs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var uh=Symbol("BadValue"),_h=(t)=>t;class R{constructor(t,e,r,s,i=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=s,this.checks=[],this.defaultValue=i}toDataDef(){let{type:t,defaultValue:e}=this;return{type:t,defaultValue:e?.toJS?e.toJS():e}}getFirstFailingCheck(t){if(!this.typeCheck.isValid(t))return this.typeCheck;for(let e of this.checks)if(!e.isValid(t))return e;return null}isValid(t){return this.getFirstFailingCheck(t)===null}addCheck(t){return this.checks.push(t),this}coerceOr(t,e=null){if(this.isValid(t))return t;let r=this.coercer(t);return this.isValid(r)?r:e}coerceOrDefault(t){return this.coerceOr(t,this.defaultValue)}extendProtoForType(t,e){}extendProto(t){let{name:e}=this,r=e[0].toUpperCase()+e.slice(1),s=`set${r}`,i=this;t[s]=function(n){let h=i.coerceOr(n,uh);if(h===uh)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[s](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,i.defaultValue)},t[`is${r}NotSet`]=function(){return this.get(e)==null},t[`is${r}Set`]=function(){return this.get(e)!=null},this.extendProtoForType(t,r)}}class Rs{isValid(t){return!0}getMessage(t){return"Invalid"}}class lh extends Rs{}var Pu=new lh;class k extends Rs{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var xu=new k((t)=>Number.isInteger(t),()=>"Integer expected"),Fu=new k((t)=>Number.isFinite(t),()=>"Float expected"),Vu=new k((t)=>typeof t==="boolean",()=>"Boolean expected"),ku=new k((t)=>typeof t==="string",()=>"String expected"),Nu=new k((t)=>K.isList(t),()=>"List expected"),mu=new k((t)=>Y.isMap(t),()=>"Map expected"),vu=new k((t)=>B.isOrderedMap(t),()=>"OrderedMap expected"),to=new k((t)=>b.isSet(t),()=>"Set expected"),eo=(t)=>!!t;class Ts extends R{constructor(t,e=!1){super("bool",t,Vu,eo,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(s){return this.set(r,!!s)}}}class Pe extends R{constructor(t,e=null){super("any",t,Pu,_h,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ws(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var ro=(t)=>t?.toString?.()??"";class Js extends R{constructor(t,e=""){super("text",t,ku,ro,e)}extendProtoForType(t,e){Gs(t,this.name,e,"","length")}}var so=(t)=>Number.isFinite(t)?Math.trunc(t):null;class ah extends R{constructor(t,e=0){super("int",t,xu,so,e)}}var io=(t)=>null;class Zs extends R{constructor(t,e=0){super("float",t,Fu,io,e)}}var Ws=(t)=>t?.constructor?.getMetaClass?.()?.name;class yh{constructor(t){this.typeName=t}isValid(t){return Ws(t)===this.typeName}getMessage(t){let e=Ws(t);return`Expected "${this.typeName}", got "${e}"`}}class gh extends R{constructor(t,e,r){super(t,e,new yh(t),_h,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var oh=Symbol("NONE");function Jt(t,e,r){Gs(t,e,r,wh),t[`setIn${r}At`]=function(s,i){return this.set(e,this.get(e).set(s,i))},t[`getIn${r}At`]=function(s,i){return this.get(e).get(s,i)},t[`updateIn${r}At`]=function(s,i){let n=this.get(e),h=n.get(s,oh);if(h!==oh)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},ph(t,e,`${r}At`)}function ph(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var wh=K(),no=(t)=>Array.isArray(t)?K(t):null;class Hs extends R{constructor(t,e=wh){super("list",t,Nu,no,e)}extendProtoForType(t,e){let{name:r}=this;Jt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var ho=(t)=>Y(t);class Xs extends R{constructor(t,e=Y()){super("map",t,mu,ho,e)}extendProtoForType(t,e){Jt(t,this.name,e)}}var uo=(t)=>B(t);class Qs extends R{constructor(t,e=B()){super("omap",t,vu,uo,e)}extendProtoForType(t,e){Jt(t,this.name,e)}}function Gs(t,e,r,s,i="size"){t[`is${r}Empty`]=function(){return this.get(e,s)[i]===0},t[`${e}Len`]=function(){return this.get(e,s)[i]}}var fh=b(),oo=(t)=>Array.isArray(t)?b(t):t instanceof Set?b(t):null;class Ys extends R{constructor(t,e=fh){super("set",t,to,oo,e)}extendProtoForType(t,e){let{name:r}=this;Gs(t,r,e,fh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},ph(t,r,e),t[`hasIn${e}`]=function(s){return this.get(r).has(s)},t[`toggleIn${e}`]=function(s){let i=this.get(r);return this.set(r,i.has(s)?i.delete(s):i.add(s))}}}function ch(t,e,r){let s=e.lookupComponent(t.type);return console.assert(s!==null,"component not found",{field:t}),s?.make({...t.args,...r},{scope:e})??null}class dh{constructor(t){let e={},r=new Set;this.name=t,this.fields=e,this.compFields=r,this._methods={},this._statics={make:function(s={},i={}){let n={};for(let h in s){let u=e[h];if(r.has(h))n[h]=ch(u,i.scope,s[h]);else if(u===void 0){console.warn("extra argument to constructor:",t,h,s);continue}n[h]=u.coerceOrDefault(s[h])}for(let h of r)if(n[h]===void 0)n[h]=ch(e[h],i.scope,s[h]);return this(n)}}}build(){let t={},e={},{name:r,_methods:s,fields:i}=this;for(let u in i){let o=i[u];t[u]=o.defaultValue,o.extendProto(e)}let n={[r]:ce(t,r)}[r];Object.assign(n.prototype,e,s);let h={fields:i,name:r,methods:s};return Object.assign(n,this._statics,{getMetaClass:()=>h}),n}methods(t){return this._mergeProto(this._methods,t,"method")}statics(t){return this._mergeProto(this._statics,t,"static")}_mergeProto(t,e,r){for(let s in e)t[s]=e[s];return this}addField(t,e,r){let s=new r(t,e);return this.fields[t]=s,s}addCompField(t,e,r){let s=new gh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var xe=new Map,fo={text:Js,int:ah,float:Zs,bool:Ts,list:Hs,map:Xs,omap:Qs,set:Ys,any:Pe};function co(t,{fields:e={},methods:r,statics:s}){let i=new dh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Js);else if(u==="number")i.addField(n,h,Zs);else if(u==="boolean")i.addField(n,h,Ts);else if(K.isList(h)||Array.isArray(h))i.addField(n,K(h),Hs);else if(b.isSet(h)||h instanceof Set)i.addField(n,b(h),Ys);else if(B.isOrderedMap(h))i.addField(n,h,Qs);else if(h?.type&&h?.defaultValue!==void 0){let o=fo[h.type]??Pe;i.addField(n,new o().coerceOr(h.defaultValue),o)}else if(h?.component&&h?.args!==void 0)i.addCompField(n,h.component,h.args);else if(Y.isMap(h)||h?.constructor===Object)i.addField(n,Y(h),Xs);else{let o=xe.get(h?.constructor)??Pe;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var _o=(t)=>new $r(t.name??"Comp",co(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var lo=["nid","cid","eid","vid","si","sk"];class Cs{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.comment=s,this.renderFn=i,this.getSeqInfo=n??zo,this.cache=h??new Er}setNullCache(){this.cache=new br}renderToDOM(t,e){let r=document.createElement("div");return this.renderFn(this.h("div",null,[this.renderRoot(t,e)]),r),r.childNodes[0]}renderToString(t,e,r=!0){let s=this.renderToDOM(t,e,this.renderFn);if(r){let i=s.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of i)for(let h of lo)delete n[h]}return s.innerHTML}renderRoot(t,e,r=null){let s=this.comps.getCompFor(e),i=s.getView(r).anode.nodeId??null;return s?this._rValComp(t,e,s,i,"ROOT",r):null}renderIt(t,e,r,s){let i=this.comps.getCompFor(t.it);return i?this._rValComp(t,t.it,i,e,r,s):null}_rValComp(t,e,r,s,i,n){let h=`${n??t.viewsId??""}${s}-${i}`,u=this.cache.get(e,h);if(u)return u;let o=n?r.getView(n):t.lookupBestView(r.views,"main"),f=this.renderMetadata("Comp",{nid:s}),c=this.renderFragment([f,o.render(t,this)]);return this.cache.set(e,h,c),c}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),f=[],c=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,c)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(y)}return f}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,f]=this.getSeqInfo(i),c=!!u,_=[],l=h.call(t.it,i);for(let[a,y]of f(i))if(n.call(t.it,a,y,l)){let w={key:a,value:y},S=`${s}-${a}`,q;if(c)u.call(t.it,w,a,y,l),q=this.cache.get2(t.it,y,S);else q=this.cache.get(y,S);if(q){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(q);continue}let St=t.enter(y,w,!1),Ot=r.render(St,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,y,S,Ot);else this.cache.set(y,S,Ot);_.push(Ot)}return _}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderComment(t){return this.comment(t)}renderEmpty(t){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*ao(t){let e=0;for(let r of t)yield[e++,r]}function*yo(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var Fe=new Map,go=["si",ao],po=["sk",yo],wo=["si",function*(e){}];function zo(t){return j(t)?go:d(t)?po:Fe.get(t?.constructor)??wo}class zt{constructor(t=Y(),e=K()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new zt(t,e,this.$)}toJS(){return this.order.toArray().map((t)=>this.items.get(t))}set(t,e){let r=this.items.has(t)?this.order:this.order.push(t);return this._clonish(this.items.set(t,e),r,this.$)}get(t,e=null){return this.items.get(t,e)}_nextFreeKey(){let t=this.$;while(!0){let e=`§${t}§`;if(!this.items.has(e))return[e,t];t+=1}}push(t){let[e,r]=this._nextFreeKey(),s=this.set(e,t);return s.$=r,s}get size(){return this.items.size}delete(t){if(this.items.has(t)){let e=this.order.delete(this.order.indexOf(t));return this._clonish(this.items.delete(t),e)}return this}moveKeyBeforeKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),0)}moveKeyAfterKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),1)}moveKeyIndexToIndex(t,e,r){if(t===-1||e===-1||t===e)return this;let{order:s}=this,i=e+r,n=i<t?t+1:t,h=s.insert(i,s.get(t)).delete(n);return this._clonish(this.items,h)}}var So=(t)=>null;class zh{isValid(t){return t instanceof zt}getMessage(t){return"KList expected"}}var Oo=new zh;class Sh extends R{constructor(t,e=new zt){super("KList",t,Oo,So,e)}extendProtoForType(t,e){Jt(t,this.name,e);let{name:r}=this;Jt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}xe.set(zt,Sh);function*Mo(t){for(let e of t.order)yield[e,t.items.get(e)]}Fe.set(zt,["data-sk",Mo]);var Ps=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),_e=(t)=>t!==null&&typeof t==="object";function Mh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)bo(t,s,r);else if(Ps(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(_e(i))Eo(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function bo(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(typeof s==="string"||Ps(e)){let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function Eo(t,e,r,s){let i=e?.[r];if(_e(i)&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(!_e(n))t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Zt{isEqualTo(t){return this===t}toDom(t){return null}}var Bs=(t)=>t instanceof ae?t.key:void 0,qo=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function xs(t,e){if(e==null)return;if(qo(e))for(let r of e)xs(t,r);else if(e instanceof Zt)if(e instanceof it)t.push(...e.childs);else t.push(e);else t.push(new Ne(e))}class Ne extends Zt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof Ne&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class le extends Zt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof le&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class it extends Zt{constructor(t){super();this.childs=[],xs(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof it)||this.childs.length!==t.childs.length)return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document.createDocumentFragment();for(let r of this.childs){let s=r.toDom(t);if(s)e.appendChild(s)}return e}}class ae extends Zt{constructor(t,e,r,s,i){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i==="string"?i:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof ae)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.childs.length!==t.childs.length)return!1;for(let e in this.attrs)if(this.attrs[e]!==t.attrs[e])return!1;for(let e in t.attrs)if(!Object.hasOwn(this.attrs,e))return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);Mh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function bh(t,e){let r=null;for(let s in t){if(!Object.hasOwn(e,s)){r??={},r[s]=void 0;continue}let i=t[s],n=e[s];if(i===n);else if(_e(i)&&_e(n))if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=bh(i,n);if(h)r??={},r[s]=h}else r??={},r[s]=n}for(let s in e)if(!Object.hasOwn(t,s))r??={},r[s]=e[s];return r}function jo(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}var Ve=(t,e,r)=>t instanceof r&&e instanceof r;function Eh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(Ve(e,r,Ne)||Ve(e,r,le))return t.data=r.text,t;if(Ve(e,r,ae)&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=bh(e.attrs,r.attrs);if(i)Mh(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)Oh(t,e.childs,r.childs,e.tag,s);return t}if(Ve(e,r,it))return Oh(t,e.childs,r.childs,null,s),t;return jo(t,r,s)}function Oh(t,e,r,s,i){if(e.length===0){for(let f of r){let c=f.toDom(i);if(c)t.appendChild(c)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Array.from(t.childNodes),h={};for(let f=0;f<e.length;f++){let c=Bs(e[f]);if(c!=null)h[c]=f}let u=new Uint8Array(e.length),o=0;for(let f=0;f<r.length;f++){let c=r[f],_=Bs(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&Bs(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],y=Eh(a,e[l],c,i),w=t.childNodes[f]??null;if(y!==w)t.insertBefore(y,w)}else{let a=c.toDom(i);if(a){let y=t.childNodes[f]??null;t.insertBefore(a,y)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var ke=new WeakMap;function qh(t,e,r){let s=ke.get(e),i=t instanceof it;if(s){let h=s.vnode instanceof it;if(h===i){let u=h?e:s.dom,o=Eh(u,s.vnode,t,r),f=i?e:o;return ke.set(e,{vnode:t,dom:f}),o}ke.delete(e)}let n=t.toDom(r);if(n){e.innerHTML="",e.appendChild(n);let h=i?e:n;ke.set(e,{vnode:t,dom:h})}return n}function jh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e){let f=e[o];switch(o){case"key":n=f;break;case"namespace":h=f;break;case"class":i.className=f;break;case"for":i.htmlFor=f;break;default:i[o]=Ps(o)?String(f):f}}let u=[];return xs(u,r),new ae(s,i,u,n,h)}var{raw:Sf,raw:Of}=String;function Mf(t,e){return new wr(t,e)}var Ao=(t)=>typeof t==="string"?document.querySelector(t):t;function bf(t){let e=Ao(t),r=new qe,s=(o)=>new it(o),i=(o)=>new le(o),n={document},h=(o,f)=>qh(o,f,n),u=new Cs(r,jh,s,i,h);return new Hr(e,h,r,u,ot)}async function Lf(t,e,r="margaui-css"){let s=performance.now(),i=await $o(t,e),n=performance.now();return Ae(r,i),n-s}async function $o(t,e,r){t.ParseContext=$e,t.compile();let s=new Set(r??[]);for(let i of t.comps.byId.values())for(let n in i.views){let h=i.views[n];for(let u of h.ctx.classes)s.add(u)}return await e(Array.from(s))}export{bf as tutuca,Fe as seqInfoByClass,Mf as macro,Qe as isOrderedMap,Qe as isOMap,ie as isMap,rs as isList,d as isKeyed,j as isIndexed,ie as isIMap,Ae as injectCss,Of as html,xe as fieldsByClass,Sf as css,_o as component,$o as compileClassesToStyleText,Lf as compileClassesToStyle,ce as Record,ot as ParseContext,B as OMap,K as List,zt as KList,b as ISet,Y as IMap};