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 Zt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class dt extends Zt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new dt({...this.binds,key:t})}withKey(t){return new dt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class _e extends Zt{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 Pe(this.field,t)}withKey(t){return new Be(this.field,t)}}class Ye extends Zt{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 Be extends Ye{}class Pe extends Ye{}var K=Symbol("NONE");class Ce extends Zt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,K),i=t?.get(this.keyField,K);return i!==K&&r?.get?r.get(i,e):e}setValue(t,e){let r=t?.get(this.seqField,K),i=t?.get(this.keyField,K);return r===K||i===K?t:t.set(this.seqField,r.set(i,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 i of this.steps)if(r=i.lookup(r,K),r===K)return e;return r}setValue(t,e){let r=Array(this.steps.length),i=t;for(let n=0;n<this.steps.length;n++)if(r[n]=i,i=this.steps[n].lookup(i,K),i===K)return t;let s=e;for(let n=this.steps.length-1;n>=0;n--)s=this.steps[n].setValue(r[n],s),r[n]=s;return s}buildStack(t){let e=t.it,r=e;for(let i of this.steps){if(r=i.lookup(r,K),r===K)return console.warn("bad PathItem",{root:e,curVal:r,step:i,path:this}),null;i.updateBindings(r,t.binds.head.bindings),t=t.enter(r,{},i.isFrame)}return t}static fromNodeAndEventName(t,e,r,i,s,n=!0){let h=[],u=0,o=[],f=null,c=[],_=!0;while(t&&t!==r&&u<i){if(t?.dataset){let{nid:l,si:a,sk:g}=Xi(t.previousSibling),{eid:p,cid:d,vid:q}=t.dataset;if(p!==void 0)o.push(p);if(d!==void 0){let zt=s.getComponentForId(+d,q);if(_){if(f=dh(zt,o,q,e),f===null&&n)return Mh;_=!1}let St=Oh(zt,c,q);if(St)h.push(St);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:g})}u+=1,t=t.parentNode}return[new m(h.reverse()),f]}static fromEvent(t,e,r,i,s=!0){let{type:n,target:h}=t;return m.fromNodeAndEventName(h,n,e,r,i,s)}}var Zi={};function Xi(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Xi(t.previousSibling);if(e!==Zi)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Zi}function dh(t,e,r,i){for(let s of e){let n=t.getEventForId(+s,r).getHandlersFor(i);if(n!==null)return n}return null}function Oh(t,e,r){for(let i=0;i<e.length;i++){let s=t.getNodeForId(+e[i].nid,r),n=s.pathInNext?i+1:i,{si:h,sk:u,nid:o}=e[n],f=s.pathInNext?t.getNodeForId(+o,r).val.toPathItem():s.toPathItem();if(f!==null)return h!==void 0?f.withIndex(+h):u?f.withKey(u):f}return null}var Mh=[null,null];class xe{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new _e(t))}index(t,e){return this.add(new Pe(t,e))}key(t,e){return this.add(new Be(t,e))}}var bh=/^[a-zA-Z][a-zA-Z0-9_]*$/,nt=(t)=>bh.test(t),Eh=/^-?[0-9]+(\.[0-9]+)?$/,Qi=(t,e)=>Ve.parse(t,e),Xt=(t,e)=>new T(t),qh=(t,e)=>nt(t)?new ht(t):null,jh=(t,e)=>nt(t)?new Pi(t):null,Uh=(t,e)=>nt(t)?new Ne(t):null,Ah=(t,e)=>nt(t)?new Fi(t):null,$h=(t,e)=>nt(t)?new Vi(t):null,Ih=(t,e)=>nt(t)?new ki(t):null,Lh=(t,e)=>nt(t)?new Ci(t):null;class Gi{constructor(){this.allowFieldOnly(),this.bindValIt=new Ne("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,i){return r?i(t,e):null}_parseSeqAccess(t,e){if(!this.okSeqAccess)return null;let r=t.indexOf("[");this.allowFieldOnly();let i=this.parse(t.slice(0,r),e),s=this.parse(t.slice(r+1,-1),e);return i&&s?new Ni(i,s):null}parse(t,e){switch(Kh(t)){case mi:return this.parseIfOk(t,e,this.okStrTpl,Qi);case ts:return this.parseIfOk(t,e,this.okStrTpl,Xt);case vi:return this._parseSeqAccess(t,e);case le:return this.parseIfOk(t,e,this.okStrTpl,Qi)}let r=t.charCodeAt(0);switch(r){case 94:{let s=e.frame.macroVars?.[t.slice(1)];if(s!==void 0)return this.parse(s,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,Uh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Ah);case 46:return this.parseIfOk(t.slice(1),e,this.okField,$h);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Ih);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Lh)}let i=Eh.test(t)?parseFloat(t):null;if(Number.isFinite(i))return this.parseIfOk(i,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,qh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,jh);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 i=this.parse(t,e);return i&&(i.toRawFieldVal?i.toRawFieldVal():new r(i.name))}parseHandlerName(t,e){return this._parseHandler(t,e,Ti)}parseAlter(t,e){return this._parseHandler(t,e,Yi)}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 ae{render(t,e){}eval(t){}toPathItem(){return null}}class T extends ae{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 Fe extends ae{}class Ve extends Fe{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),i=Array(r.length),s=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?w.parseText(h.slice(1,-1),e):new T(h);i[n]=o,s&&=o instanceof T}return s?new T(i.map((n)=>n.value).join("")):new Ve(i)}}class ht extends Fe{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Ti extends ht{eval(t){return t.getInputHandler(this.name)??Bi("input",this.name)}}class Yi extends ht{eval(t){return t.getAlterHandler(this.name)??Bi("alter",this.name)}}var Bi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class Pi extends ht{eval(t){return t.lookupType(this.name)}}class Ci extends ht{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class xi extends ht{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class ke extends ae{render(t,e){return this.eval(t)}}class Qt extends ke{constructor(t){super();this.name=t}}class Ne extends Qt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class Fi extends Qt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class Vi extends Qt{eval(t){return t.lookupField(this.name)}toPathItem(){return new _e(this.name)}toRawFieldVal(){return new xi(this.name)}toString(){return`.${this.name}`}}class ki extends Qt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ni extends ke{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new Ce(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 mi=0,vi=1,le=2,ts=3;function Kh(t){let e=0,r=0;for(let i=0;i<t.length;i++)switch(t.charCodeAt(i)){case 91:if(e>0)return le;e+=1;break;case 93:if(r>0||e===0)return le;r+=1;break;case 123:return mi;case 125:return ts}if(e>0||r>0)return e===1&&r===1?vi:le;return-1}var w=new Gi;class Ot{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return er(e).parse(t,r)}isConstant(){return!1}}var Dh="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",Wh=new Set(Dh.split(","));class es{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 i=r?w.parseAll(e,this.px):w.parseAttr(e,this.px);if(i!==null)this.attrs??=[],this.attrs.push(new ye(t,i)),this.hasDynamic||=!(i instanceof T)}pushWrapper(t,e,r){let i={name:t,val:r,raw:e};return this.wrapperAttrs??=[],this.wrapperAttrs.push(i),i}parseIf(t,e){let r=w.parseCondValue(e,this.px);if(r)this.ifAttr=new ss(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=w.parseAttr(t,this.px)??Gt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=w.parseAttr(t,this.px)??Gt}parseEvent(t,e){let[r,...i]=t.slice(3).split("+"),s=rr.parse(e,this.px);if(s){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new ge("data-eid",w.const(this.events.id)));this.events.add(r,s,i)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new is(w.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,w.const(t));return;case"push-view":this.pushWrapper("push-view",t,w.parseText(t,this.px));return;case"text":this.textChild=w.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,w.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,w.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,w.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=w.parseAlter(t,this.px);else this.pushWrapper("scope",t,w.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=w.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=w.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===""&&Wh.has(n)?!0:h;this.attrs.push(new ge(n,w.const(o)))}}let{attrs:r,hasDynamic:i}=this;return[i?new rs(r):ve.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class ve extends Ot{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new ve(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 rs extends Ot{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 ge(t,new T(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class tr{constructor(t){this.name=t}}class ye extends tr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class ge extends ye{}class is extends ye{constructor(t){super("dangerouslySetInnerHTML",t??w.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Gt=w.nullConstVal;class ss extends tr{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 me=null;function er(t){return me??=new es(t),me.clear(t),me}class rr{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let i=0;i<r.length;i++)r[i]=this.args[i].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...i]=t.trim().split(/\s+/),s=w.parseHandlerName(r,e);if(s===null)return null;let n=Array(i.length);w.allowHandlerArg();for(let h=0;h<i.length;h++){let u=w.parse(i[h],e);n[h]=u!==null?u:w.nullConstVal}return new rr(s,n)}}class ir{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 Mt{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 Yt extends Mt{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 Tt extends Yt{render(t,e){return e.renderComment(this.v)}}function Rh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new _r(r);else r.optimize()}}function ur(t){if(t.isConstant())return new _r(t);return t.optimize(),t}class or extends Mt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Rh(this.childs)}}class we extends or{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let i=0;i<r.length;i++)r[i]=this.childs[i]?.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 pe extends or{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 sr=(t)=>t.length===1?t[0]:new pe(t),Jh=/^[a-zA-Z][a-zA-Z0-9-]*$/,ns=null;class v extends Mt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){ns??=e.newDOMParser();let r=ns.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 Yt(t.textContent);else if(e.isCommentNode(t))return new Tt(t.textContent);let{childNodes:r,attributes:i,tagName:s}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=v.fromDOM(r[h],e);if(s==="X"){if(i.length===0)return sr(n);let{name:h,value:u}=i[0],o=i.getNamedItem("as")?.value??null;switch(h){case"slot":return new Se(null,w.const(u),sr(n));case"text":{let f=w.parseText(u,e);return f!==null?new hr(null,f):null}case"render":return e.addNodeIf(ls,w.parseRender(u,e),o);case"render-it":return e.addNodeIf(as,w.bindValIt,o);case"render-each":return cr.parse(e,w,u,o,i)}return new Tt(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(s.charCodeAt(1)===58&&s.charCodeAt(0)===88){let h=s.slice(2).toLowerCase();if(h==="slot"){let f=i.getNamedItem("name")?.value??"_";return e.frame.macroSlots[f]??sr(n)}let[u,o]=Ot.parse(i,e,!0);return e.onAttributes(u,o,null),hs(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Jh.test(s)){let[h,u,o]=Ot.parse(i,e);if(e.onAttributes(h,u,o),o)n.unshift(new hr(null,o));let f=s!=="PRE"?Gh(n):n;return hs(new we(s.toLowerCase(),h,f),e,u)}return new Tt(`Error: InvalidTagName ${s}`)}}function hs(t,e,r){if(r)for(let i=r.length-1;i>=0;i--){let s=Hh(r[i],e);if(s)s.wrapNode(t),t=s}return t}function Hh(t,e){let r=Qh[t.name],i=r.register?e.addNodeIf(r,t.val):t.val&&new r(null,t.val);if(i!==null&&t.name==="each")i.iterInfo.enrichWithVal=t.enrichWithVal??null,i.iterInfo.whenVal=t.whenVal??null,i.iterInfo.loopWithVal=t.loopWithVal??null;return i}class _s extends Mt{constructor(t,e,r,i){super();this.name=t,this.attrs=e,this.slots=r,this.px=i,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:i}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let s=t.lookupMacro(e);if(s===null)this.node=new Tt(`bad macro: ${e}`);else{let n={...s.defaults,...r};this.node=s.expand(this.px.enterMacro(e,n,i));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=ur(this.node)}}class fr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return v.parse(this.rawView,t)}}class ze extends v{constructor(t,e,r){super(t,e);this.viewId=r}}class ls extends ze{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class as extends ze{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class cr extends ze{constructor(t,e,r){super(t,e,r);this.iterInfo=new lr(e,null,null,null)}render(t,e){return e.renderEach(t,this.iterInfo,this.nodeId,this.viewId)}static parse(t,e,r,i,s){let n=t.addNodeIf(cr,e.parseEach(r,t),i);if(n!==null){let h=er(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=s.getNamedItem("when");u&&h._parseWhen(u.value);let o=s.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 hr extends v{render(t,e){return e.renderText(this.val.eval(t))}}class _r extends Mt{constructor(t){super();this.node=t,this._render=(e,r)=>{let i=t.render(e,r);return this._render=(s,n)=>i,i}}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=ur(this.node)}static register=!1}class gs extends ut{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class ys extends ut{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class ws extends ut{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Se extends ut{optimize(){this.node.optimize()}}class ps 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 dt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class zs extends ut{constructor(t,e){super(t,e);this.iterInfo=new lr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new dt({})}static register=!0}class lr{constructor(t,e,r,i){this.val=t,this.whenVal=e,this.loopWithVal=r,this.enrichWithVal=i}eval(t){let e=this.val.eval(t)??[],r=this.whenVal?.eval(t)??Zh,i=this.loopWithVal?.eval(t)??Xh,s=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:i,enricher:s}}}var Zh=(t,e,r)=>!0,Xh=(t)=>({seq:t}),Qh={slot:Se,show:gs,hide:ys,each:zs,scope:ps,"push-view":ws};class Bt{constructor(t,e,r,i,s,n,h,u){this.nodes=i??[],this.events=s??[],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:i,Text:s,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new Bt(i,s,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 i=this.nodes.length,s=new t(i,e,r);return this.nodes.push(s),s}return null}registerEvents(){let t=this.events.length,e=new Ss(t);return this.events.push(e),e}newMacroNode(t,e,r){let i=[],s={_:new pe(i)};for(let h of r)if(h instanceof Se)s[h.val.value]=h.node;else if(!(h instanceof Yt)||!h.isWhiteSpace())i.push(h);let n=new _s(t,e,s,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 nr=(t)=>t instanceof Yt&&t.isWhiteSpace(),us=(t)=>t instanceof we||t instanceof pe&&t.childs[0]instanceof we;function Gh(t){let e=t.length;if(e===0)return t;let r=0,i=!1;if(nr(t[0]))r=1,i=!0;if(e>1&&nr(t[e-1]))e-=1,i=!0;for(let s=1;s<e-1;s++){let n=t[s];if(nr(n)&&us(t[s-1])&&us(t[s+1])&&n.hasNewLine())n.condenseWhiteSpace()}return i?t.slice(r,e):t}class de{constructor(t,e,r="",i=null,s=null){this.name=t,this.anode=i,this.style=r,this.ctx=s,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=ur(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ss{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new ds(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 ds{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=xh(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 Th=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Oe=(t)=>(e)=>(r,i,s,n)=>t(n)?e(r,i,s,n):r,os=(t)=>Oe((e)=>e.e.key===t),fs=Oe(({e:t})=>Th&&t.metaKey||t.ctrlKey),Yh=Oe(({e:t})=>t.metaKey),Bh=Oe(({e:t})=>t.altKey),cs={ctrl:fs,cmd:fs,meta:Yh,alt:Bh},Ph={keydown:{send:os("Enter"),cancel:os("Escape"),...cs},click:{...cs}},Ch=(t,e)=>t;function xh(t,e){if(e.length===0)return Ch;let r=Ph[t]??{},i=(s,n,h,u)=>n.apply(s,h);for(let s of e){let n=r[s];if(n!==void 0)i=n(i)}return(s,n)=>function(...h){return i(this,s,h,n)}}class ar{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,i){}evict(){return{hit:0,miss:0,badKey:0}}}class gr{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 i=this.map.get(t);if(i)i[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,i){let s=this.map.get(t);if(s){let n=s.get(e);if(n)n[r]=i;else s.set(e,{[r]:i})}else if(typeof t==="object"&&typeof e==="object"){let n=new WeakMap;n.set(e,{[r]:i}),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 yr{getKey(t,e,r){return r.call(t)}}class wr{constructor(){this.map=new WeakMap}getKey(t,e,r){let i=this.map.get(t);if(i){let n=i[e];if(n!==void 0)return n;let h=r.call(t)??null;return i[e]=h,h}let s=r.call(t)??null;return this.map.set(t,{[e]:s}),s}}class Me{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new wr}setNullComputedCache(){this.computedCache=new yr}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:Ms}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 be{constructor(t=new Me,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new be(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let i=t[r];i.scope=this.enter(),this.comps.registerComponent(i),this.byName[i.name]=i;let s=e[i.name];if(s)this.byName[s]=i}}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 ir(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 pr{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 Os extends pr{constructor(t,e,r,i){super(t,e,null);this.compName=r,this.dynName=i}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var bt=(t)=>typeof t==="string",Fh=0;class zr{constructor(t,e,r,i={},s="",n="",h="",u={},o={},f={},c={},_={},l={},a={},g={}){this.id=Fh++,this.name=t,this.Class=e,this.views={main:new de("main",r,s)},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:g?.stackEnter??Ms};for(let p in i){let d=i[p],{view:q,style:zt}=bt(d)?{view:d}:d;this.views[p]=new de(p,q,zt)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(bt(r)){let i=w.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new pr(e,i,Symbol(e))}else if(bt(r?.default)&&bt(r?.for)){let i=w.parseDynamic(r.default,this.views.main.ctx),[s,n]=r.for.split(".");if(bt(s)&&bt(n))this.dynamic[e]=new Os(e,i,s,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:i}=this,s=e?[`[data-cid="${t}"]{${e}}`]:[];if(r!=="")s.push(r);for(let n in i){let{style:h}=i[n];if(h!=="")s.push(`[data-cid="${t}"][data-vid="${n}"]{${h}}`)}return s.join(`
3
- `)}}function Ms(t){return t}var bs=Symbol("STOP"),Or=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,i=this.head.lookup(t);return i===bs?e:i===Or?r!==null?r.lookup(t,e):e:i}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Sr{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?bs:Or:e}}class dr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Or:e}}class J{constructor(t,e,r,i,s,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=i,this.views=s,this.ctx=n;let h=[...s].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:i,ctx:s}=this;return e.head.isFrame?this:new J(t,e.tail.head.it,e.tail,r,i,s)}static root(t,e,r){let i=new Pt(new Sr(e,{it:e},!0),null),s=new Pt(new dr({}),null),n=new Pt("main",null);return new J(t,e,i,s,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:i,binds:s,dynBinds:n,views:h,ctx:u}=this,o=s.push(new Sr(t,e,r));return new J(i,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:i,dynBinds:s,views:n,ctx:h}=this;return new J(e,r,i,s,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:i,it:s,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new dr(e));return new J(i,s,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 i=t[r];if(i!==void 0)return i}return t[e]}}class qs{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 i of this.changeSubs)i({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class br{constructor(t,e){this.comps=t,this.transactions=[],this.state=new qs(e),this.onTransactionPushed=()=>{}}pushTransaction(t){return this.transactions.push(t),this.onTransactionPushed(t),t}pushLogic(t,e,r=[],i={},s=null){return this.pushTransaction(new jr(t,this,e,r,s,i))}pushBubble(t,e,r=[],i={},s=null){let n=i.skipSelf?{...i,skipSelf:!1}:i;return this.pushTransaction(new As(t,this,e,r,s,n))}async pushRequest(t,e,r=[],i={},s=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??Vh(e),o=i?.onResName??e,f=(c,_,l,a,g)=>{let d=new Us(t,this,c??_,c?[l]:[a,g],s);return this.pushTransaction(d)};try{let c=await u.fn.apply(null,r);return f(i?.onOkName,o,c,c,null)}catch(c){return f(i?.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,i){this.transact(new js(t,e,r,this,i))}}function Vh(t){return()=>{throw Error(`Request not found: ${t}`)}}function kh(){return this}class Er{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new $s,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 J.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[i,s]=this.getHandlerAndArgs(t,e,r);return i.apply(e,s)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),i=this.callHandler(t,r,e);return this._task?.complete?.({value:i,old:r}),r!==i?this.path.setValue(t,i):t}lookupName(t){return null}}var Nh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Es=(t)=>Number.isNaN(t)?null:t;function Mr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class js extends Er{constructor(t,e,r,i,s){super(t,i);this.e=e,this.handler=r,this.dragInfo=s}buildRootStack(t,e){return J.root(e,t,this)}getHandlerAndArgs(t,e,r){let i=this.buildStack(t,r),[s,n]=this.handler.getHandlerAndArgs(i,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new Ur(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[s,n]}lookupName(t){let{e}=this;switch(t){case"value":return Mr(e);case"valueAsInt":return Es(parseInt(Mr(e),10));case"valueAsFloat":return Es(parseFloat(Mr(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 Nh&&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 Ar(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class qr extends Er{constructor(t,e,r,i,s,n={}){super(t,e,s);this.name=r,this.args=i,this.opts=n}handlerProp=null;getHandlerForName(t){return t?.[this.handlerProp]?.[this.name]??kh}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Ar(this.path,this.transactor,this)]]}}class Us extends qr{handlerProp="response"}class jr extends qr{handlerProp="logic";run(t,e){return this.opts.skipSelf?t:this.updateRootValue(t,e)}afterTransaction(){let{path:t,name:e,args:r,opts:i}=this;if(i.bubbles&&t.steps.length>0)this.transactor.pushBubble(t.popStep(),e,r,i,this)}}class As extends jr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class $s{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 Ur{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Is(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,i){return this.transactor.pushLogic(t,e,r,i,this.parent)}request(t,e,r){return this.requestAtPath(this.path,t,e,r)}requestAtPath(t,e,r,i){return this.transactor.pushRequest(t,e,r,i,this.parent)}lookupTypeFor(t,e){return this.transactor.comps.getCompFor(e).scope.lookupComponent(t)}}class Ar extends Ur{stopPropagation(){return this.parent.stopPropagation()}}class Is extends xe{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 $r{constructor(t,e,r,i,s){this.rootNode=t,this.comps=r,this.compStack=new be(r),this.transactor=new br(r,null),this.ParseContext=s,this.renderer=i,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",i=t.type==="dragend",{rootNode:s,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||i),[o,f]=m.fromEvent(t,s,n,h,u);if(r){let c=mh(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 Ks(o,a,t,_,l,t.target)}else if(i)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 J.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()}),Ls("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 Ls(t,e,r=document.head){let i=document.createElement("style"),s=r.querySelector(`#${t}`);if(s)r.removeChild(s);i.id=t,i.innerHTML=e,r.appendChild(i)}function mh(t,e,r){let i=t;while(r-- >0&&i!==e){if(i.dataset?.droptarget!==void 0)return i;i=i.parentNode}return null}class Ks{constructor(t,e,r,i,s,n){this.path=t,this.stack=e,this.e=r,this.value=i,this.type=s,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}function Ct(t,e){if(!t)throw Error(e)}function A(t){Ct(t!==1/0,"Cannot perform this action with an infinite size.")}function Ds(t,e,r,i,s,n){return A(t.size),t.__iterate((h,u,o)=>{if(s)s=!1,r=h;else r=e.call(i,r,h,u,o)},n),r}var vh=(t,e)=>e,tu=(t,e)=>[e,t],Ir=(t)=>function(...e){return!t.apply(this,e)},Ws=(t)=>function(...e){return-t.apply(this,e)};function rn(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 Rs=(t,e)=>t<e?1:t>e?-1:0,$={done:!0,value:void 0};class sn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new sn(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 $})}var eu=L(()=>$),ot=()=>eu;function De(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return $;return r.value=e++,r})}function mt(t,e){return M((r)=>{let i=t.next();if(i.done)return!1;return e(i.value[0],i.value[1],r),!0})}function nn(t){if(Array.isArray(t))return!0;return!!We(t)}var ru=(t)=>!!(t&&typeof t.next==="function");function hn(t){return We(t)?.call(t)}function We(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function iu(t){let e=We(t);return e&&e===t.entries}function su(t){let e=We(t);return e&&e===t.keys}var vt="delete",S=5,E=1<<S,I=E-1,y={},Zr=()=>({value:!1});function R(t){if(t)t.value=!0}class Re{}function qt(t){if(t.size===void 0)t.size=t.__iterate(un);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?qt(t)+e:e}var un=()=>!0,on=(t)=>t<0||Object.is(t,-0),te=(t,e,r)=>(t===0&&!on(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),fn=(t,e,r)=>t===void 0?r:on(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Lt=(t,e)=>fn(t,e,0),ee=(t,e)=>fn(t,e,e),cn="@@__IMMUTABLE_ITERABLE__@@",Ue="@@__IMMUTABLE_KEYED__@@",Ae="@@__IMMUTABLE_INDEXED__@@",rt="@@__IMMUTABLE_ORDERED__@@",re="@@__IMMUTABLE_SEQ__@@",_n="@@__IMMUTABLE_LIST__@@",ln="@@__IMMUTABLE_MAP__@@",an="@@__IMMUTABLE_SET__@@",gn="@@__IMMUTABLE_STACK__@@",yn="@@__IMMUTABLE_RECORD__@@";function P(t,e){return typeof t==="object"&&t!==null&&e in t}var D=(t)=>P(t,cn),z=(t)=>P(t,Ue),j=(t)=>P(t,Ae),Br=(t)=>z(t)||j(t),x=(t)=>P(t,rt),Pr=(t)=>P(t,re),Cr=(t)=>P(t,_n),ie=(t)=>P(t,ln),xr=(t)=>P(t,an),Fr=(t)=>P(t,gn),lt=(t)=>P(t,yn),C=(t)=>D(t)||lt(t),Je=(t)=>ie(t)&&x(t),wn=(t)=>xr(t)&&x(t),Js=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function pn(t){let e=Y(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=Dt,e.__iterate=function(r,i){return t.__iterate((s,n)=>r(n,s,this),i)},e.__iteratorUncached=function(r){return mt(t.__iterator(r),(i,s,n)=>{n[0]=s,n[1]=i})},e}function zn(t,e,r){let i=Y(t);return i.size=t.size,i.has=(s)=>t.has(s),i.get=(s,n)=>{let h=t.get(s,y);return h===y?n:e.call(r,h,s,t)},i.__iterate=function(s,n){return t.__iterate((h,u)=>s(e.call(r,h,u,t),u,this),n)},i.__iteratorUncached=function(s){return mt(t.__iterator(s),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},i}function Sn(t,e){let r=Y(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let i=pn(t);return i.reverse=()=>t.flip(),i};return r.get=(i,s)=>t.get(e?i:-1-i,s),r.has=(i)=>t.has(e?i:-1-i),r.includes=(i)=>t.includes(i),r.cacheResult=Dt,r.__iterate=function(i,s){let n=0;if(s)qt(t);return t.__iterate((h,u)=>i(h,e?u:s?this.size-++n:n++,this),!s)},r.__iteratorUncached=function(i){let s=0;if(i)qt(t);let n=this.size;return mt(t.__iterator(!i),(h,u,o)=>{o[0]=e?h:i?n-++s:s++,o[1]=u})},r}function dn(t,e,r,i){let s=t.size;if(te(e,r,s))return t;if(s===void 0&&(e<0||r<0))return dn(t.toSeq().cacheResult(),e,r,i);let n=Lt(e,s),u=ee(r,s)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=Y(t);if(f.size=o===0?o:t.size&&o||void 0,!i&&Pr(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((g,p)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(g,i?p:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ot();let _=t.__iterator(c),l=0,a=0;if(i)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return $;let g=_.next();if(g.done)return g;return a++,g});return M((g)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let p=_.next();if(p.done)return!1;return a++,g[0]=a-1,g[1]=p.value[1],!0})},f}function Hs(t,e,r){if(!e)e=rn;let i=z(t),s=0,n=t.toSeq().map((h,u)=>[u,h,s++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(i?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),i?vr(n):j(t)?_t(n):Ft(n)}function Ee(t,e,r){if(!e)e=rn;if(r){let i=t.toSeq().map((s,n)=>[s,r(s,n,t)]).reduce((s,n)=>Zs(e,s[1],n[1])?n:s);return i&&i[0]}return t.reduce((i,s)=>Zs(e,i,s)?s:i)}function Zs(t,e,r){let i=t(r,e);return i===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||i>0}function Lr(t,e,r,i){let s=Y(t),n=new se(r).map((h)=>h.size);return s.size=i?n.max():n.min(),s.__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},s.__iteratorUncached=function(h){let u=r.map((_)=>{let l=F(_);return hn(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return M((_)=>{let l=i;for(let a=0;a<u.length;a++)f[a]=u[a].next(),l=i?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})},s}function On(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 nu(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,i=Object.getPrototypeOf(e);while(i!==null)r=i,i=Object.getPrototypeOf(r);return r===e}var it=(t)=>typeof t==="object"&&(C(t)||Array.isArray(t)||nu(t));function Mn(t){if(On(t)&&typeof t!=="string")return t;if(x(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var hu=(t,e)=>C(t)?t.has(e):it(t)&&Object.hasOwn(t,e);function bn(t,e,r){return C(t)?t.get(e,r):!hu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function Vr(t,e,r){let i=Mn(e),s=0;while(s!==i.length)if(t=bn(t,i[s++],y),t===y)return r;return t}var En=(t,e)=>Vr(t,e,y)!==y;function U(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!!(Js(t)&&Js(e)&&t.equals(e))}function $e(t){if(!t||typeof t!=="object")return t;if(!D(t)){if(!it(t))return t;t=st(t)}if(z(t)){let r={};return t.__iterate((i,s)=>{r[String(s)]=$e(i)}),r}let e=[];return t.__iterate((r)=>{e.push($e(r))}),e}function kr(t,e){if(t===e)return!0;if(!D(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||z(t)!==z(e)||j(t)!==j(e)||x(t)!==x(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!Br(t);if(x(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&U(f[1],u)&&(r||U(f[0],o))})&&h.next().done)}let i=!1;if(t.size===void 0)if(e.size===void 0){if(typeof t.cacheResult==="function")t.cacheResult()}else{i=!0;let h=t;t=e,e=h}let s=!0,n=e.__iterate((h,u)=>{if(r?!t.has(h):i?!U(h,t.get(u,y)):!U(t.get(u,y),h))return s=!1,!1;return!0});return s&&t.size===n}var He=(t)=>t>>>1&1073741824|t&3221225471;function H(t){if(t===null||t===void 0)return Xs(t);if(typeof t.hashCode==="function")return He(t.hashCode(t));let e=_u(t);if(e===null||e===void 0)return Xs(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return uu(e);case"string":return e.length>lu?ou(e):Xr(e);case"object":case"function":return cu(e);case"symbol":return fu(e);default:if(typeof e.toString==="function")return Xr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Xs=(t)=>t===null?1108378658:1108378659;function uu(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 He(e)}function ou(t){let e=Wr[t];if(e===void 0){if(e=Xr(t),Dr===au)Dr=0,Wr={};Dr++,Wr[t]=e}return e}function Xr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return He(e)}function fu(t){let e=Gs[t];if(e!==void 0)return e;return e=qn(),Gs[t]=e,e}function cu(t){let e=Qs.get(t);if(e!==void 0)return e;return e=qn(),Qs.set(t,e),e}var _u=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function qn(){let t=++Kr;if(Kr&1073741824)Kr=0;return t}var Qs=new WeakMap,Gs=Object.create(null),Kr=0,lu=16,au=255,Dr=0,Wr={};function gu(t){if(t.size===1/0)return 0;let e=x(t),r=z(t),i=e?1:0;return t.__iterate(r?e?(s,n)=>{i=31*i+Ts(H(s),H(n))|0}:(s,n)=>{i=i+Ts(H(s),H(n))|0}:e?(s)=>{i=31*i+H(s)|0}:(s)=>{i=i+H(s)|0}),yu(t.size,i)}var Ts=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function yu(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=He(e^e>>>16),e}function xt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:Pr(t)?e:t.create?t.create(e):t.constructor(e),wu=(t,e)=>O(t,(z(t)?X:j(t)?at:gt)(e)),Ys=(...t)=>t,F=(t)=>D(t)?t:st(t);class Z{size=0;static{this.prototype[cn]=!0,this.prototype.__toStringMapper=xt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return kr(this,t)}hashCode(){return this.__hash??(this.__hash=gu(this))}toArray(){A(this.size);let t=Array(this.size||0),e=z(this),r=0;return this.__iterate((i,s)=>{t[r++]=e?[s,i]:i}),t}toIndexedSeq(){return new In(this)}toJS(){return $e(this)}toKeyedSeq(){return new si(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){A(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 Ln(this)}toSeq(){return j(this)?this.toIndexedSeq():z(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=z(this),r=[this,...t].map((i)=>{if(!D(i))i=e?Un(i):An(Array.isArray(i)?i:[i]);else if(e)i=X(i);return i}).filter((i)=>i.size!==0);if(r.length===0)return this;if(r.length===1){let i=r[0];if(i===this||e&&z(i)||j(this)&&j(i))return i}return O(this,new $n(r))}includes(t){return this.some((e)=>U(e,t))}every(t,e){A(this.size);let r=!0;return this.__iterate((i,s,n)=>{if(!t.call(e,i,s,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,i=z(this),s=Y(r);if(i)s.has=(n)=>{let h=r.get(n,y);return h!==y&&!!t.call(e,h,n,r)},s.get=(n,h)=>{let u=r.get(n,y);return u!==y&&t.call(e,u,n,r)?u:h};return s.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,f)=>{if(t.call(e,o,f,r))return u++,n(o,i?f:u-1,this)},h),u},s.__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]=i?c:u++,o[1]=_,!0}})},O(this,s)}partition(t,e){let r=z(this),i=[[],[]];return this.__iterate((s,n)=>{i[t.call(e,s,n,this)?1:0].push(r?[n,s]:s)}),i.map((s)=>wu(this,s))}find(t,e,r){let i=this.findEntry(t,e);return i?i[1]:r}forEach(t,e){return A(this.size),this.__iterate(e?t.bind(e):t)}join(t){A(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((i)=>{if(r)r=!1;else e+=t;e+=i!==null&&i!==void 0?String(i):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return $;return e.value=r.value[0],e})}map(t,e){return O(this,zn(this,t,e))}reduce(t,e=y,r){return Ds(this,t,e,r,e===y,!1)}reduceRight(t,e=y,r){return Ds(this,t,e,r,e===y,!0)}reverse(){return O(this,Sn(this,z(this)))}slice(t,e){return O(this,dn(this,t,e,z(this)))}some(t,e){A(this.size);let r=!1;return this.__iterate((i,s,n)=>{if(t.call(e,i,s,n))return r=!0,!1}),r}sort(t){return O(this,Hs(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return $;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 qt(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 se(t._cache);let e=t.toSeq().map(tu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Ir(t),e)}findEntry(t,e,r){let i=r;return this.__iterate((s,n,h)=>{if(t.call(e,s,n,h))return i=[n,s],!1}),i}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(un,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,i)=>(z(this)?X:j(this)?at:gt)(t.call(e,r,i,this))).flatten(!0))}flatten(t){let e=this,r=z(this),i=Y(e);return i.__iterateUncached=function(s,n){if(n)return this.cacheResult().__iterate(s,n);let h=0,u=!1;function o(f,c){f.__iterate((_,l)=>{if((!t||c<t)&&D(_))o(_,c+1);else if(h++,s(_,r?l:h-1,i)===!1)u=!0;if(u)return!1},n)}return o(e,0),h},i.__iteratorUncached=function(s){if(s)return this.cacheResult().__iterator(s);let n=0,h=[{iterator:e.__iterator(s),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)&&D(c)){h.push({iterator:c.__iterator(s),depth:o.depth+1});continue}return u[0]=r?f.value[0]:n++,u[1]=c,!0}return!1})},O(this,i)}fromEntrySeq(){return new Kn(this)}get(t,e){return this.find((r,i)=>U(i,t),void 0,e)}getIn(t,e){return Vr(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,y)!==y}hasIn(t){return En(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:F(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:F(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>U(e,t))}keySeq(){return this.toSeq().map(vh).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Ee(this,t)}maxBy(t,e){return Ee(this,e,t)}min(t){return Ee(this,t?Ws(t):Rs)}minBy(t,e){return Ee(this,e?Ws(e):Rs,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,i=z(this),s=Y(r);return s.__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,i?c:o-1,this)},h),o},s.__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]=i?l:u++,c[1]=a,!0}})},O(this,s)}skipUntil(t,e){return this.skipWhile(Ir(t),e)}sortBy(t,e){return O(this,Hs(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,i=Y(r);return i.__iterateUncached=function(s,n){if(n)return this.cacheResult().__iterate(s,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,s(u,o,this)},n),h},i.__iteratorUncached=function(s){if(s)return this.cacheResult().__iterator(s);let n=r.__iterator(s),h=this,u=!1;return L(()=>{if(u)return $;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,$;return o})},O(this,i)}takeUntil(t,e){return this.takeWhile(Ir(t),e)}update(t){return t(this)}valueSeq(){return this.toIndexedSeq()}__iterate(t,e=!1){let r=this.__iterator(e),i=0,s;while(!(s=r.next()).done)if(i++,t(s.value[1],s.value[0],this)===!1)break;return i}__iterator(t=!1){throw Error("CollectionImpl does not implement __iterator. Use a subclass instead.")}}var X=(t)=>z(t)?t:vr(t);class Nr extends Z{static{this.prototype[Ue]=!0,this.prototype.__toStringMapper=(t,e)=>`${xt(e)}: ${xt(t)}`,this.prototype[Symbol.iterator]=Z.prototype.entries,this.prototype.toJSON=function(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,pn(this))}mapEntries(t,e){let r=0;return O(this,this.toSeq().map((i,s)=>t.call(e,[s,i],r++,this)).fromEntrySeq())}mapKeys(t,e){return O(this,this.toSeq().flip().map((r,i)=>t.call(e,r,i,this)).flip())}}var at=(t)=>j(t)?t:_t(t);class jt extends Z{static{this.prototype[Ae]=!0,this.prototype[rt]=!0}toKeyedSeq(){return new si(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=y,...r){if(t===void 0)return this;let i=e!==y;if(e=i?Math.max(e||0,0):0,i&&!e&&r.length===0)return this;t=Lt(t,t<0?this.count():this.size);let s=this.slice(0,t);return O(this,!i?s:s.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,i)=>i===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=Y(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(i,s){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(i(t,n++,this)===!1)return!1}return h=!1,i(u,n++,this)},s),n},r.__iteratorUncached=function(i){let s=e.__iterator(i),n=0,h=!0,u,o=!1;return M((f)=>{if(o)return o=!1,f[0]=n++,f[1]=u,!0;let c=s.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=Lr(this.toSeq(),_t.of,e),i=r.flatten(!0);if(r.size)i.size=r.size*e.length;return O(this,i)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(Ys,...t)}zipAll(...t){let e=[this,...t];return O(this,Lr(this,Ys,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,Lr(this,t,r))}}var gt=(t)=>D(t)&&!Br(t)?t:Ft(t);class Ze extends Z{static{this.prototype.has=Z.prototype.includes,this.prototype.contains=Z.prototype.includes,this.prototype.keys=Ze.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}F.Keyed=X;F.Indexed=at;F.Set=gt;var Rr=jt.prototype,st=(t)=>t===void 0||t===null?ri():C(t)?t.toSeq():pu(t),Y=(t)=>Object.create((z(t)?Kt:j(t)?yt:ti).prototype);class ft extends Z{static{this.prototype[re]=!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),i=0,s;while(!(s=r.next()).done)if(i++,t(s.value[1],s.value[0],this)===!1)break;return i}__iterate(t,e){let r=this._cache;if(r){let i=r.length,s=0;while(s!==i){let n=r[e?i-++s:s++];if(t(n[1],n[0],this)===!1)break}return s}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,i=0,s={done:!1,value:void 0};return L(()=>{if(i===r)return $;return s.value=e[t?r-++i:i++],s})}return this.__iteratorUncached(t)}}var mr={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},vr=(t)=>t===void 0||t===null?ri().toKeyedSeq():D(t)?z(t)?t.toSeq():t.fromEntrySeq():lt(t)?t.toSeq():Un(t);class Kt extends Nr{static{this.prototype[re]=!0,Object.assign(this.prototype,mr)}toSeq(){return this}toKeyedSeq(){return this}}var _t=(t)=>t===void 0||t===null?ri():D(t)?z(t)?t.entrySeq():t.toIndexedSeq():lt(t)?t.toSeq().entrySeq():An(t);_t.of=(...t)=>_t(t);class yt extends jt{static{this.prototype[re]=!0,Object.assign(this.prototype,mr)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var Ft=(t)=>(D(t)&&!Br(t)?t:_t(t)).toSetSeq();Ft.of=(...t)=>Ft(t);class ti extends Ze{static{this.prototype[re]=!0,Object.assign(this.prototype,mr)}toSeq(){return this}toSetSeq(){return this}}st.isSeq=Pr;st.Keyed=vr;st.Set=Ft;st.Indexed=_t;class se extends yt{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,i=r.length,s=0;while(s!==i){let n=e?i-++s:s++;if(t(r[n],n,this)===!1)break}return s}__iteratorUncached(t){let e=this._array,r=e.length,i=0;return M((s)=>{if(i===r)return!1;let n=t?r-++i:i++;return s[0]=n,s[1]=e[n],!0})}}class ei extends Kt{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,i=this._keys,s=i.length,n=0;while(n!==s){let h=i[e?s-++n:n++];if(t(r[h],h,this)===!1)break}return n}__iteratorUncached(t){let e=this._object,r=this._keys,i=r.length,s=0;return M((n)=>{if(s===i)return!1;let h=r[t?i-++s:s++];return n[0]=h,n[1]=e[h],!0})}}class jn extends yt{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 i of this._collection){if(t(i,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=hn(e);if(!ru(r))return ot();let i=0;return M((s)=>{let n=r.next();if(n.done)return!1;return s[0]=i++,s[1]=n.value,!0})}}var ri=()=>new se([]),ii=(t)=>On(t)?new se(t):nn(t)?new jn(t):void 0;function Un(t){let e=ii(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new ei(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function An(t){let e=ii(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function pu(t){let e=ii(t);if(e)return iu(t)?e.fromEntrySeq():su(t)?e.toSetSeq():e;if(typeof t==="object")return new ei(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class $n extends ft{constructor(t){super();let e=[],r=0,i=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),i){let u=h.size;if(u!==void 0)r+=u;else i=!1}}else if(e.push(n),i){let h=n.size;if(h!==void 0)r+=h;else i=!1}this._wrappedIterables=e,this.size=i?r:void 0;let s=this._wrappedIterables[0];if(s[Ue])this[Ue]=!0;if(s[Ae])this[Ae]=!0;if(s[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,i=!z(this),s=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,i?s++:o,this)===!1)return n=!0,!1},e),n)break;return s}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ot();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!z(this),i=0,s=e[0].__iterator(t);function n(){while(i<e.length){let h=s.next();if(!h.done)return h;if(i++,i<e.length)s=e[i].__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()||$)}}class si extends Kt{static{this.prototype[rt]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Dt.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=Sn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=zn(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 In extends yt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)qt(this);let i=this.size;return this._iter.__iterate((s)=>{let n=e?i-++r:r++;return t(s,n,this)},e),r}__iteratorUncached(t){let e=0;if(t)qt(this);let r=this.size;return mt(this._iter.__iterator(t),(i,s,n)=>{n[0]=t?r-++e:e++,n[1]=s})}}class Ln extends ti{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.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 mt(this._iter.__iterator(t),(e,r,i)=>{i[0]=r,i[1]=r})}}class Kn extends Kt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((i)=>{if(i){Bs(i),r++;let s=D(i);return t(s?i.get(1):i[1],s?i.get(0):i[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return M((r)=>{while(!0){let i=e.next();if(i.done)return!1;let s=i.value[1];if(s){Bs(s);let n=D(s);return r[0]=n?s.get(0):s[0],r[1]=n?s.get(1):s[1],!0}}})}}function Dt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function Bs(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var V=(t)=>t===void 0||t===null?Q():ie(t)&&!x(t)?t:Q().withMutations((e)=>{let r=X(t);A(r.size),r.forEach((i,s)=>e.set(s,i))});class ni extends Nr{static{pt(this,{asImmutable:ne,asMutable:he,deleteIn:Ut,merge:Qr,mergeWith:Xn,mergeDeep:Gn,mergeDeepWith:Tn,mergeDeepIn:zi,mergeIn:pi,setIn:gi,update:yi,updateIn:wi,wasAltered:ai,withMutations:ue,removeIn:Ut,concat:Qr,[ln]:!0,[vt]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,i){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=i,this.__altered=!1}create(t){return V(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 Cs(this,t,e)}remove(t){return Cs(this,t,y)}deleteAll(t){let e=F(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((i)=>r.remove(i))})}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 Q()}map(t,e){return this.withMutations((r)=>{r.forEach((i,s)=>{r.set(s,t.call(e,i,s,this))})})}keys(){if(!this._root)return ot();return qe(this._root,!1,0)}values(){if(!this._root)return ot();return qe(this._root,!1,1)}entries(){if(!this._root)return ot();return qe(this._root,!1)}__iterator(t){if(!this._root)return ot();return qe(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([i,s])=>{return r++,t(s,i,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Q();return this.__ownerID=t,this.__altered=!1,this}return oi(this.size,this._root,t,this.__hash)}}V.isMap=ie;class hi{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,i){return Dn(this.entries,r,i)}iterate(t,e){return Wn(this.entries,t,e)}update(t,e,r,i,s,n,h){let u=s===y,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(U(i,o[f][0]))break;let _=f<c;if(_?o[f][1]===s:u)return this;if(R(h),u||!_)R(n);if(u&&c===1)return;if(!_&&!u&&c>=bu)return zu(t,o,i,s);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]=[i,s];else a.push([i,s]);if(l)return this.entries=a,this;return new hi(t,a)}}class Xe{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Rn(this.nodes,t,e)}get(t,e,r,i){let s=1<<((t===0?e:e>>>t)&I),n=this.bitmap;return(n&s)===0?i:this.nodes[Fs(n&s-1)].get(t+S,e,r,i)}update(t,e,r,i,s,n,h){let u=(e===0?r:r>>>e)&I,o=1<<u,f=this.bitmap,c=(f&o)!==0;if(!c&&s===y)return this;let _=Fs(f&o-1),l=this.nodes,a=c?l[_]:void 0,g=fi(a,t,e+S,r,i,s,n,h);if(g===a)return this;if(!c&&g&&l.length>=Eu)return du(t,l,f,u,g);if(c&&!g&&l.length===2&&xs(l[_^1]))return l[_^1];if(c&&g&&l.length===1&&xs(g))return g;let p=t&&t===this.ownerID,d=c?g?f:f^o:f|o,q=c?g?Jn(l,_,g,p):Mu(l,_,p):Ou(l,_,g,p);if(p)return this.bitmap=d,this.nodes=q,this;return new Xe(t,d,q)}}class ui{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Rn(this.nodes,t,e)}get(t,e,r,i){let s=(t===0?e:e>>>t)&I,n=this.nodes[s];return n?n.get(t+S,e,r,i):i}update(t,e,r,i,s,n,h){let u=(e===0?r:r>>>e)&I,o=s===y,f=this.nodes,c=f[u];if(o&&!c)return this;let _=fi(c,t,e+S,r,i,s,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<qu)return Su(t,f,l,u)}let a=t&&t===this.ownerID,g=Jn(f,u,_,a);if(a)return this.count=l,this.nodes=g,this;return new ui(t,l,g)}}class Qe{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,i){return Dn(this.entries,r,i)}iterate(t,e){return Wn(this.entries,t,e)}update(t,e,r,i,s,n,h){if(r!==this.keyHash){if(s===y)return this;return R(h),R(n),ci(this,t,e,r,[i,s])}let u=s===y,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(U(i,o[f][0]))break;let _=f<c;if(_?o[f][1]===s:u)return this;if(R(h),u||!_)R(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]=[i,s];else a.push([i,s]);if(l)return this.entries=a,this;return new Qe(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,i){return U(r,this.entry[0])?this.entry[1]:i}update(t,e,r,i,s,n,h){let u=s===y,o=U(i,this.entry[0]);if(o?s===this.entry[1]:u)return this;if(R(h),u){R(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=s,this;return new wt(t,this.keyHash,[i,s])}return R(n),ci(this,t,e,H(i),[i,s])}}function Dn(t,e,r){for(let i=0,s=t.length;i<s;i++)if(U(e,t[i][0]))return t[i][1];return r}function Wn(t,e,r){for(let i=0,s=t.length-1;i<=s;i++)if(e(t[r?s-i:i])===!1)return!1}function Rn(t,e,r){for(let i=0,s=t.length-1;i<=s;i++)if(t[r?s-i:i]?.iterate(e,r)===!1)return!1}function qe(t,e,r){let i={node:t,index:0,__prev:null},s=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return L(()=>{while(i){let h=i.node,u=i.index++,o;if(h.entry){if(u===0)return n.value=s(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=s(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=s(f.entry),n;i={node:f,index:0,__prev:i}}continue}i=i.__prev}return $})}var oi=(t,e,r,i)=>new ni(t,e,r,i),Ps,Q=()=>Ps||(Ps=oi(0));function Cs(t,e,r){let i,s;if(!t._root){if(r===y)return t;s=1,i=new hi(t.__ownerID,[[e,r]])}else{let n=Zr(),h=Zr();if(i=fi(t._root,t.__ownerID,0,H(e),e,r,n,h),!h.value)return t;s=t.size+(n.value?r===y?-1:1:0)}if(t.__ownerID)return t.size=s,t._root=i,t.__hash=void 0,t.__altered=!0,t;return i?oi(s,i):Q()}function fi(t,e,r,i,s,n,h,u){if(!t){if(n===y)return t;return R(u),R(h),new wt(e,i,[s,n])}return t.update(e,r,i,s,n,h,u)}var xs=(t)=>t.constructor===wt||t.constructor===Qe;function ci(t,e,r,i,s){if(t.keyHash===i)return new Qe(e,i,[t.entry,s]);let n=(r===0?t.keyHash:t.keyHash>>>r)&I,h=(r===0?i:i>>>r)&I,u=new wt(e,i,s),o=n===h?[ci(t,e,r+S,i,s)]:n<h?[t,u]:[u,t];return new Xe(e,1<<n|1<<h,o)}function zu(t,e,r,i){if(!t)t=new Re;let s=new wt(t,H(r),[r,i]);for(let[n,h]of e)s=s.update(t,0,H(n),n,h);return s}function Su(t,e,r,i){let s=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!==i)s|=o,h[n++]=c}return new Xe(t,s,h)}function du(t,e,r,i,s){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[i]=s,new ui(t,n+1,h)}function Fs(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 Jn(t,e,r,i){let s=i?t:t.slice();return s[e]=r,s}function Ou(t,e,r,i){let s=t.length+1;if(i&&e+1===s)return t[e]=r,t;let n=Array(s),h=0;for(let u=0;u<s;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function Mu(t,e,r){let i=t.length-1;if(r&&e===i)return t.pop(),t;let s=Array(i),n=0;for(let h=0;h<i;h++){if(h===e)n=1;s[h]=t[h+n]}return s}var bu=E/4,Eu=E/2,qu=E/4;function Ie(t){if(Array.isArray(t))return t.slice();return{...t}}var _i=(t,e,r)=>li(t,e,ju(r));function li(t,e,r){if(!it(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(C(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let i=Array.isArray(t),s=t,n=i?at:X,h=i?(u)=>{if(s===t)s=Ie(s);s.push(u)}:(u,o)=>{let f=Object.hasOwn(s,o),c=f&&r?r(s[o],u,o):u;if(!f||c!==s[o]){if(s===t)s=Ie(s);s[o]=c}};for(let u of e)n(u).forEach(h);return s}function ju(t){function e(r,i,s){return it(r)&&it(i)&&Uu(r,i)?li(r,[i],e):t?t(r,i,s):i}return e}function Uu(t,e){let r=st(t),i=st(e);return j(r)===j(i)&&z(r)===z(i)}function Au(t,e){if(!it(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(C(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=Ie(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function $u(t,e,r){if(!it(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(C(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 i=Ie(t);return i[e]=r,i}function Wt(t,e,r,i){if(!i)i=r,r=void 0;let s=Hn(C(t),t,Mn(e),0,r,i);return s===y?r:s}function Hn(t,e,r,i,s,n){let h=e===y;if(i===r.length){let _=h?s:e,l=n(_);return l===_?e:l}if(!h&&!it(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,i).map(xt)}]: ${e}`);let u=r[i],o=h?y:bn(e,u,y),f=Hn(o===y?t:C(o),o,r,i+1,s,n);if(f===o)return e;if(f===y)return Au(e,u);let c=h?t?Q():{}:e;return $u(c,u,f)}var Iu=(t,e)=>Wt(t,e,()=>y),Lu=(t,e,r)=>Wt(t,e,y,()=>r);function Zn(t,e,r,i){return Wt(t,[e],r,i)}function ne(){return this.__ensureOwner()}function he(){return this.__ownerID?this:this.__ensureOwner(new Re)}function ai(){return this.__altered}function ue(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Ku(t,e){return Vr(this,t,e)}function Du(t){return En(this,t)}function Ut(t){return Iu(this,t)}function gi(t,e){return Lu(this,t,e)}function yi(t,e,r){return typeof t==="function"?t(this):Zn(this,t,e,r)}function wi(t,e,r){return Wt(this,t,e,r)}function Vs(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function Qr(...t){return Qn(this,t)}function Xn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Qn(this,e,t)}function Qn(t,e,r){let i=[];for(let s of e){let n=X(s);if(n.size!==0)i.push(n)}if(i.length===0)return t;if(t.toSeq().size===0&&!t.__ownerID&&i.length===1)return lt(t)?t:t.create(i[0]);return t.withMutations((s)=>{let n=r?(h,u)=>{Zn(s,u,y,(o)=>o===y?h:r(o,h,u))}:(h,u)=>{s.set(u,h)};for(let h of i)h.forEach(n)})}function Gn(...t){return _i(this,t)}function Tn(t,...e){return _i(this,e,t)}function pi(t,...e){return Wt(this,t,Q(),(r)=>li(r,e))}function zi(t,...e){return Wt(this,t,Q(),(r)=>_i(r,e))}function pt(t,e){Object.assign(t.prototype,e)}var W=(t)=>{let e=Vt();if(t===void 0||t===null)return e;if(Cr(t))return t;let r=at(t),i=r.size;if(i===0)return e;if(A(i),i>0&&i<E)return oe(0,i,S,null,new ct(r.toArray()));return e.withMutations((s)=>{s.setSize(i),r.forEach((n,h)=>s.set(h,n))})};W.of=(...t)=>W(t);class Yn extends jt{static{pt(this,{asImmutable:ne,asMutable:he,deleteIn:Ut,mergeDeepIn:zi,mergeIn:pi,setIn:gi,update:yi,updateIn:wi,wasAltered:ai,withMutations:ue,removeIn:Ut,[_n]:!0,[vt]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,i,s,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=i,this._tail=s,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return W(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=et(this,t),t>=0&&t<this.size){t+=this._origin;let r=Cn(this,t);return r&&r.array[t&I]}return e}set(t,e){return Ru(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=S,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return Vt()}push(...t){let e=this.size;return this.withMutations((r)=>{tt(r,0,e+t.length);for(let i=0;i<t.length;i++)r.set(e+i,t[i])})}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,i,s;while(r)i=Math.floor(t()*r--),s=e.get(i),e.set(i,e.get(r)),e.set(r,s)})}concat(...t){let e=[];for(let r of t){let i=at(typeof r!=="string"&&nn(r)?r:[r]);if(i.size!==0)e.push(i)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return W(e[0]);return this.withMutations((r)=>{e.forEach((i)=>i.forEach((s)=>r.push(s)))})}setSize(t){return tt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let i=0;i<this.size;i++)r.set(i,t.call(e,r.get(i),i,this))})}slice(t,e){let r=this.size;if(te(t,e,r))return this;return tt(this,Lt(t,r),ee(e,r))}__iterate(t,e){let r=e?this.size:0;return Wu(this,(i)=>t(i,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=ks(this,t);return M((i)=>{let s=r.next();if(s.done)return!1;return i[0]=t?--e:e++,i[1]=s.value,!0})}values(){return ks(this,!1)}keys(){return De(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Vt();return this.__ownerID=t,this.__altered=!1,this}return oe(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}W.isList=Cr;class ct{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+S)-1)===0||this.array.length===0)return this;let i=r>>>e&I;if(i>=this.array.length)return new ct([],t);let s=i===0,n;if(e>0){let u=this.array[i];if(n=u?.removeBefore(t,e-S,r),n===u&&s)return this}if(s&&!n)return this;let h=At(this,t);if(!s)for(let u=0;u<i;u++)h.array[u]=void 0;if(n)h.array[i]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+S:E)||this.array.length===0)return this;let i=r-1>>>e&I;if(i>=this.array.length)return this;let s;if(e>0){let h=this.array[i];if(s=h?.removeAfter(t,e-S,r),s===h&&i===this.array.length-1)return this}let n=At(this,t);if(n.array.splice(i+1),s)n.array[i]=s;return n}}function ks(t,e){let{_origin:r,_capacity:i}=t,s=$t(i),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-S,a=f.offset+(c<<f.level);o(_,l,a)}return $});function o(f,c,_){if(c===0){let l=_===s?n?.array:f?.array,a=_>r?0:r-_,g=i-_;if(g>E)g=E;if(a!==g)h.push({array:l,from:a,to:g,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,g=(i-_>>c)+1;if(g>E)g=E;if(a!==g)h.push({array:l,from:a,to:g,level:c,offset:_,isLeaf:!1})}}}function Wu(t,e,r){let{_origin:i,_capacity:s}=t,n=$t(s),h=t._tail,u=t._level,o=t._root;return u===0?Bn(o,0,i,s,n,h,e,r):Pn(o,u,0,i,s,n,h,e,r)}function Bn(t,e,r,i,s,n,h,u){let o=e===s?n?.array:t?.array,f=e>r?0:r-e,c=i-e;if(c>E)c=E;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function Pn(t,e,r,i,s,n,h,u,o){let f=t?.array,c=r>i?0:i-r>>e,_=(s-r>>e)+1;if(_>E)_=E;let l=e-S;while(c!==_){let a=o?--_:c++,g=r+(a<<e);if((l===0?Bn(f?.[a],g,i,s,n,h,u,o):Pn(f?.[a],l,g,i,s,n,h,u,o))===!1)return!1}}var oe=(t,e,r,i,s,n,h)=>new Yn(t,e,r,i,s,n,h),Vt=()=>oe(0,0,S);function Ru(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:i,_root:s}=t,n=Zr();if(e>=$t(t._capacity))i=Gr(i,t.__ownerID,0,e,r,n);else s=Gr(s,t.__ownerID,t._level,e,r,n);if(!n.value)return t;if(t.__ownerID)return t._root=s,t._tail=i,t.__hash=void 0,t.__altered=!0,t;return oe(t._origin,t._capacity,t._level,s,i)}function Gr(t,e,r,i,s,n){let h=i>>>r&I,u=t&&h<t.array.length;if(!u&&s===void 0)return t;let o;if(r>0){let f=t&&t.array[h],c=Gr(f,e,r-S,i,s,n);if(c===f)return t;return o=At(t,e),o.array[h]=c,o}if(u&&t.array[h]===s)return t;if(n)R(n);if(o=At(t,e),s===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=s;return o}function At(t,e){if(e&&e===t?.ownerID)return t;return new ct(t?.array.slice()??[],e)}function Cn(t,e){if(e>=$t(t._capacity))return t._tail;if(e<1<<t._level+S){let{_root:r,_level:i}=t;while(r&&i>0)r=r.array[e>>>i&I],i-=S;return r}}function tt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let i=t.__ownerID||new Re,s=t._origin,n=t._capacity,h=s+e,u=r===void 0?n:r<0?n+r:s+r;if(h===s&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:f}=t,c=0;while(h+c<0)f=new ct(f?.array.length?[void 0,f]:[],i),o+=S,c+=1<<o;if(c)h+=c,s+=c,u+=c,n+=c;let _=$t(n),l=$t(u);while(l>=1<<o+S)f=new ct(f?.array.length?[f]:[],i),o+=S;let a=t._tail,g=l<_?Cn(t,u-1):l>_?new ct([],i):a;if(a&&l>_&&h<n&&a.array.length){f=At(f,i);let p=f;for(let d=o;d>S;d-=S){let q=_>>>d&I;p=p.array[q]=At(p.array[q],i)}p.array[_>>>S&I]=a}if(u<n)g=g&&g.removeAfter(i,0,u);if(h>=l)h-=l,u-=l,o=S,f=null,g=g&&g.removeBefore(i,0,h);else if(h>s||l<_){c=0;while(f){let p=h>>>o&I;if(p!==l>>>o&I)break;if(p)c+=(1<<o)*p;o-=S,f=f.array[p]}if(f&&h>s)f=f.removeBefore(i,o,h-c);if(f&&l<_)f=f.removeAfter(i,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=g,t.__hash=void 0,t.__altered=!0,t;return oe(h,u,o,f,g)}var $t=(t)=>t<E?0:t-1>>>S<<S,B=(t)=>t===void 0||t===null?kt():Je(t)?t:kt().withMutations((e)=>{let r=X(t);A(r.size),r.forEach((i,s)=>e.set(s,i))});B.of=(...t)=>B(t);class xn extends ni{static{pt(this,{[rt]:!0,[vt]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:Z.prototype.keys,values:Z.prototype.values,__iterate:Z.prototype.__iterate})}constructor(t,e,r,i){super(t?t.size:0,void 0,r,i);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 kt()}set(t,e){return Ns(this,t,e)}remove(t){return Ns(this,t,y)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return M((r)=>{while(!0){let i=e.next();if(i.done)return!1;let s=i.value[1];if(s)return r[0]=s[0],r[1]=s[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 kt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Si(e,r,t,this.__hash)}}B.isOrderedMap=Je;var Si=(t,e,r,i)=>new xn(t,e,r,i),kt=()=>Si(Q(),Vt());function Ns(t,e,r){let{_map:i,_list:s}=t,n=i.get(e),h=n!==void 0,u,o;if(r===y){if(!h)return t;if(s.size>=E&&s.size>=i.size*2){let f=[];if(s.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=Vt().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=Q().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(f[_][0],_)}),t.__ownerID)u.__ownerID=o.__ownerID=t.__ownerID}else u=i.remove(e),o=n===s.size-1?s.pop():s.set(n,void 0)}else if(h){if(r===s.get(n)[1])return t;u=i,o=s.set(n,[e,r])}else{let f=s.size;u=i.set(e,f),o=s.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 Si(u,o)}var Le=(t)=>t===void 0||t===null?Ke():Fr(t)?t:Ke().pushAll(t);Le.of=(...t)=>Le(t);class Fn extends jt{static{pt(this,{asImmutable:ne,asMutable:he,wasAltered:ai,withMutations:ue,[gn]:!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,i){super();this.size=t,this._head=e,this.__ownerID=r,this.__hash=i,this.__altered=!1}create(t){return Le(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 i=t.length-1;i>=0;i--)r={value:t[i],next:r};return Jr(this,e,r)}pushAll(t){if(t=at(t),t.size===0)return this;if(this.size===0&&Fr(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((i)=>{e++,r={value:i,next:r}},!0),Jr(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 Ke()}slice(t,e){if(te(t,e,this.size))return this;let r=Lt(t,this.size);if(ee(e,this.size)!==this.size)return jt.prototype.slice.call(this,t,e);let s=this.size-r,n=this._head;while(r--)n=n.next;return Jr(this,s,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Ke();return this.__ownerID=t,this.__altered=!1,this}return di(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let s=this.toArray(),n=s.length,h=0;while(h!==n)if(t(s[n-++h],n-h,this)===!1)break;return h}let r=0,i=this._head;while(i){if(t(i.value,r++,this)===!1)break;i=i.next}return r}__iterator(t){if(t){let i=this.toArray(),s=i.length,n=0;return M((h)=>{if(n===s)return!1;let u=s-++n;return h[0]=u,h[1]=i[u],!0})}let e=0,r=this._head;return M((i)=>{if(!r)return!1;return i[0]=e++,i[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return L(()=>{if(!t)return $;return e.value=t.value,t=t.next,e})}keys(){return De(this.size)}}Le.isStack=Fr;function Jr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return di(e,r)}var di=(t,e,r,i)=>new Fn(t,e,r,i),ms,Ke=()=>ms||(ms=di(0)),b=(t)=>t===void 0||t===null?Nt():xr(t)&&!x(t)?t:Nt().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((i)=>e.add(i))});b.of=(...t)=>b(t);b.fromKeys=(t)=>b(X(t).keySeq());b.intersect=(t)=>{return t=F(t).toArray(),t.length?b(t.pop()).intersect(...t):Nt()};b.union=(t)=>{let e=F(t).toArray();return e.length?b(e.pop()).union(...e):Nt()};class Oi extends Ze{static{pt(this,{withMutations:ue,asImmutable:ne,asMutable:he,[an]:!0,[vt]: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 je(this,this._map.set(t,t))}remove(t){return je(this,this._map.remove(t))}clear(){return je(this,this._map.clear())}map(t,e){let r=!1,i=je(this,this._map.mapEntries(([,s])=>{let n=t.call(e,s,s,this);if(n!==s)r=!0;return[n,n]},e));return r?i: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((i)=>e.add(i))})}intersect(...t){return tn(this,t,(e,r)=>!r.every((i)=>i.includes(e)))}subtract(...t){return tn(this,t,(e,r)=>r.some((i)=>i.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return Nt()}__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=xr;var Vn=(t,e)=>new Oi(t,e),vs,Nt=()=>vs||(vs=Vn(Q()));function tn(t,e,r){if(e.length===0)return t;return e=e.map((i)=>gt(i)),t.withMutations((i)=>{t.forEach((s)=>{if(r(s,e))i.remove(s)})})}function je(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 It=(t)=>t===void 0||t===null?Tr():wn(t)?t:Tr().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((i)=>e.add(i))});It.of=(...t)=>It(t);It.fromKeys=(t)=>It(X(t).keySeq());class kn extends Oi{static{pt(this,{[rt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Rr.zip,zipWith:Rr.zipWith,zipAll:Rr.zipAll})}create(t){return It(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return Tr()}__make(t,e){return Nn(t,e)}}It.isOrderedSet=wn;var Nn=(t,e)=>new kn(t,e),Tr=()=>Nn(kt());function Ju(t){if(lt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(C(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 fe=(t,e)=>{let r;Ju(t);let i=function(h){if(h instanceof i)return h;if(!(this instanceof i))return new i(h);if(!r){r=!0;let u=Object.keys(t),o=s._indices={};s._keys=u,s._defaultValues=t;for(let f=0;f<u.length;f++){let c=u[f];if(o[c]=f,s[c])console.warn(`Cannot define ${Mi(this)} with property "${c}" since that property name is part of the Record API.`);else Zu(s,c)}}return this.__ownerID=void 0,this._values=W().withMutations((u)=>{u.setSize(this._keys.length),X(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},s=i.prototype=Object.create(Hu);if(s.constructor=i,s.create=i,e)i.displayName=e;return i};class mn{static{pt(this,{asImmutable:ne,asMutable:he,deleteIn:Ut,getIn:Ku,hasIn:Du,merge:Qr,mergeWith:Xn,mergeDeep:Gn,mergeDeepWith:Tn,mergeDeepIn:zi,mergeIn:pi,setIn:gi,toObject:Vs,update:yi,updateIn:wi,withMutations:ue,removeIn:Ut,toJSON:Vs,[yn]:!0,[vt]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${xt(this.get(e))}`).join(", ");return`${Mi(this)} { ${t} }`}equals(t){return this===t||lt(t)&&Et(this).equals(Et(t))}hashCode(){return Et(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],i=this._values.get(r);return i===void 0?this._defaultValues[t]:i}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 Hr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Hr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Et(this)}toJS(){return $e(this)}entries(){return this.__iterator()}__iterate(t,e){return Et(this).__iterate(t,e)}__iterator(t){return Et(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 Hr(this,e,t)}}fe.isRecord=lt;var Mi=(t)=>t.constructor.displayName||t.constructor.name||"Record";class vn extends Kt{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,i=r._keys,s=i.length,n=0;while(n!==s){let h=e?s-++n:n++,u=i[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,i=r.length,s=0;return M((n)=>{if(s===i)return!1;let h=t?i-++s:s++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var Et=(t)=>new vn(t);fe.getDescriptiveName=Mi;var Hu=mn.prototype;function Hr(t,e,r){let i=Object.create(Object.getPrototypeOf(t));return i._values=e,i.__ownerID=r,i}function Zu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){Ct(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var en=(t,e,r=1)=>{if(Ct(r!==0,"Cannot step a Range by 0"),Ct(t!==void 0,"You must define a start value when using Range"),Ct(e!==void 0,"You must define an end value when using Range"),r=Math.abs(r),e<t)r=-r;let i=Math.max(0,Math.ceil((e-t)/r-1)+1);return new bi(t,e,r,i)};class bi extends yt{_start;_end;_step;constructor(t,e,r,i){super();this._start=t,this._end=e,this._step=r,this.size=i}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(te(t,e,this.size))return this;if(t=Lt(t,this.size),e=ee(e,this.size),e<=t)return en(0,0);return en(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,i=this._step,s=e?this._start+(r-1)*i:this._start,n=0;while(n!==r){let h=s;s+=e?-i:i;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,i=t?this._start+(e-1)*r:this._start,s=0;return M((n)=>{if(s===e)return!1;let h=i;return i+=t?-r:r,n[0]=t?e-++s:s++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,i=0,s={done:!1,value:void 0};return L(()=>{if(i===t)return $;return s.value=r,r+=e,i++,s})}keys(){return De(this.size)}equals(t){return t instanceof bi?this._start===t._start&&this._end===t._end&&this._step===t._step:kr(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class Yr extends yt{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 U(this._value,t)}slice(t,e){let r=this.size;return te(t,e,r)?this:new Yr(this._value,ee(e,r)-Lt(t,r))}reverse(){return this}indexOf(t){if(U(this._value,t))return 0;return-1}lastIndexOf(t){if(U(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,i=0;while(i!==r)if(t(this._value,e?r-++i:i++,this)===!1)break;return i}__iteratorUncached(t){let e=this.size,r=this._value,i=0;return M((s)=>{if(i===e)return!1;return s[0]=t?e-++i:i++,s[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,i={done:!1,value:void 0};return L(()=>{if(r===t)return $;return r++,i.value=e,i})}keys(){return De(this.size)}equals(t){return t instanceof Yr?this.size===t.size&&U(this._value,t._value):kr(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Xu=["nid","cid","eid","vid","si","sk"];class Ei{constructor(t,e,r,i,s,n,h){this.comps=t,this.h=e,this.fragment=r,this.comment=i,this.renderFn=s,this.getSeqInfo=n??Pu,this.cache=h??new gr}setNullCache(){this.cache=new ar}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 i=this.renderToDOM(t,e,this.renderFn);if(r){let s=i.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of s)for(let h of Xu)delete n[h]}return i.innerHTML}renderRoot(t,e,r=null){let i=this.comps.getCompFor(e),s=i.getView(r).anode.nodeId??null;return i?this._rValComp(t,e,i,s,"ROOT",r):null}renderIt(t,e,r,i){let s=this.comps.getCompFor(t.it);return s?this._rValComp(t,t.it,s,e,r,i):null}_rValComp(t,e,r,i,s,n){let h=`${n??t.viewsId??""}${i}-${s}`,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:i}),c=this.renderFragment([f,o.render(t,this)]);return this.cache.set(e,h,c),c}renderEach(t,e,r,i){let{seq:s,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(s),f=[],c=h.call(t.it,s);for(let[_,l]of o(s))if(n.call(t.it,_,l,c)){let a=t.enter(l,{key:_},!0),g=this.renderIt(a,r,_,i);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(g)}return f}renderEachWhen(t,e,r,i){let{seq:s,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,f]=this.getSeqInfo(s),c=!!u,_=[],l=h.call(t.it,s);for(let[a,g]of f(s))if(n.call(t.it,a,g,l)){let p={key:a,value:g},d=`${i}-${a}`,q;if(c)u.call(t.it,p,a,g,l),q=this.cache.get2(t.it,g,d);else q=this.cache.get(g,d);if(q){_.push(this.renderMetadata("Each",{nid:i,[o]:a})),_.push(q);continue}let zt=t.enter(g,p,!1),St=r.render(zt,this);if(_.push(this.renderMetadata("Each",{nid:i,[o]:a})),c)this.cache.set2(t.it,g,d,St);else this.cache.set(g,d,St);_.push(St)}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*Qu(t){let e=0;for(let r of t)yield[e++,r]}function*Gu(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var th=new Map,Tu=["si",Qu],Yu=["sk",Gu],Bu=["si",function*(e){}];function Pu(t){return j(t)?Tu:z(t)?Yu:th.get(t?.constructor)??Bu}function ji(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function rh(t,e,r){for(let i in e){let s=e[i];if(s===void 0)Cu(t,i,r);else if(ji(i))t.setAttribute(i,s);else if(i==="dangerouslySetInnerHTML")t.innerHTML=s.__html??"";else if(typeof s==="object"&&s!==null)xu(t,r,i,s);else if(i==="className")t.setAttribute("class",s);else t[i]=s}}function Cu(t,e,r){let i=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(ji(e))t.removeAttribute(e);else if(typeof i==="string"){if(e!=="className")t[e]="";let s=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(s)}else t[e]=null}function xu(t,e,r,i){let s=e?.[r];if(s&&typeof s==="object"&&Object.getPrototypeOf(s)!==Object.getPrototypeOf(i)){t[r]=i;return}let n=t[r];if(typeof n!=="object"||n===null)t[r]={},n=t[r];let h=n;for(let u in i)h[u]=i[u]}class Ht{isEqualTo(t){return this===t}toDom(t){return null}}function qi(t){return t instanceof Jt?t.key:void 0}function Fu(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function Ui(t,e){if(e==null)return;if(Fu(e))for(let r of e)Ui(t,r);else if(e instanceof Ht)if(e instanceof k)t.push(...e.childs);else t.push(e);else t.push(new ce(e))}class ce extends Ht{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof ce&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Rt extends Ht{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Rt&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class k extends Ht{constructor(t){super();let e=[];Ui(e,t),this.childs=e}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof k)||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 i=r.toDom(t);if(i)e.appendChild(i)}return e}}class Jt extends Ht{constructor(t,e,r,i,s){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=i!=null?String(i):void 0,this.namespace=typeof s==="string"?s:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Jt)||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);rh(r,this.attrs,{});for(let i of this.childs){let s=i.toDom(t);if(s)r.appendChild(s)}return r}}function ih(t,e){let r=null;for(let i in t){if(!Object.hasOwn(e,i)){r??={},r[i]=void 0;continue}let s=t[i],n=e[i];if(s===n);else if(typeof s==="object"&&s!==null&&typeof n==="object"&&n!==null)if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(s))r??={},r[i]=n;else{let h=ih(s,n);if(h)r??={},r[i]=h}else r??={},r[i]=n}for(let i in e)if(!Object.hasOwn(t,i))r??={},r[i]=e[i];return r}function Vu(t,e,r){let i=t.parentNode,s=e.toDom(r);if(i&&s&&s!==t)i.replaceChild(s,t);return s||t}function sh(t,e,r,i){if(e===r||e.isEqualTo(r))return t;if(e instanceof ce&&r instanceof ce||e instanceof Rt&&r instanceof Rt)return t.data=r.text,t;if(e instanceof Jt&&r instanceof Jt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let s=ih(e.attrs,r.attrs);if(s)rh(t,s,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)eh(t,e.childs,r.childs,e.tag,i);return t}if(e instanceof k&&r instanceof k)return eh(t,e.childs,r.childs,null,i),t;return Vu(t,r,i)}function eh(t,e,r,i,s){if(e.length===0){for(let f of r){let c=f.toDom(s);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=qi(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],_=qi(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&qi(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],g=sh(a,e[l],c,s),p=t.childNodes[f]??null;if(g!==p)t.insertBefore(g,p)}else{let a=c.toDom(s);if(a){let g=t.childNodes[f]??null;t.insertBefore(a,g)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var Ge=new WeakMap;function nh(t,e,r){let i=Ge.get(e),s=t instanceof k;if(i){let h=i.vnode instanceof k;if(h===s){let u=h?e:i.dom,o=sh(u,i.vnode,t,r);return Ge.set(e,{vnode:t,dom:s?e:o}),o}Ge.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),Ge.set(e,{vnode:t,dom:s?e:n});return n}function hh(t,e,r){let i=t.toUpperCase(),s={},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")s.className=e[o];else if(o==="for")s.htmlFor=e[o];else if(ji(o))s[o]=String(e[o]);else s[o]=e[o];let u=[];return Ui(u,r),new Jt(i,s,u,n,h)}var uh=Symbol("BadValue"),_h=(t)=>t;class G{constructor(t,e,r,i,s=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=i,this.checks=[],this.defaultValue=s}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),i=`set${r}`,s=this;t[i]=function(n){let h=s.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[i](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,s.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 $i{isValid(t){return!0}getMessage(t){return"Invalid"}}class lh extends $i{}var ku=new lh;class N extends $i{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var Nu=new N((t)=>Number.isInteger(t),()=>"Integer expected"),mu=new N((t)=>Number.isFinite(t),()=>"Float expected"),vu=new N((t)=>typeof t==="boolean",()=>"Boolean expected"),to=new N((t)=>typeof t==="string",()=>"String expected"),eo=new N((t)=>W.isList(t),()=>"List expected"),ro=new N((t)=>V.isMap(t),()=>"Map expected"),io=new N((t)=>B.isOrderedMap(t),()=>"OrderedMap expected"),so=new N((t)=>b.isSet(t),()=>"Set expected"),no=(t)=>!!t;class Ii extends G{constructor(t,e=!1){super("bool",t,vu,no,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(i){return this.set(r,!!i)}}}class Te extends G{constructor(t,e=null){super("any",t,ku,_h,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ai(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var ho=(t)=>t?.toString?.()??"";class Li extends G{constructor(t,e=""){super("text",t,to,ho,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 uo=(t)=>Number.isFinite(t)?Math.trunc(t):null;class ah extends G{constructor(t,e=0){super("int",t,Nu,uo,e)}}var oo=(t)=>null;class Ki extends G{constructor(t,e=0){super("float",t,mu,oo,e)}}var Ai=(t)=>t?.constructor?.getMetaClass?.()?.name;class gh{constructor(t){this.typeName=t}isValid(t){return Ai(t)===this.typeName}getMessage(t){let e=Ai(t);return`Expected "${this.typeName}", got "${e}"`}}class yh extends G{constructor(t,e,r){super(t,e,new gh(t),_h,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var oh=Symbol("NONE");function Di(t,e,r){ph(t,e,wh),t[`setIn${r}At`]=function(s,n){return this.set(e,this.get(e).set(s,n))},t[`getIn${r}At`]=function(s,n){return this.get(e).get(s,n)},t[`updateIn${r}At`]=function(s,n){let h=this.get(e),u=h.get(s,oh);if(u!==oh)return this.set(e,h.set(s,n(u)));return console.warn("key",s,"not found in",e,h),this};function i(s){return this.set(e,this.get(e).delete(s))}t[`deleteIn${r}At`]=i,t[`removeIn${r}At`]=i}var wh=W(),fo=(t)=>Array.isArray(t)?W(t):null;class Wi extends G{constructor(t,e=wh){super("list",t,eo,fo,e)}extendProtoForType(t,e){let{name:r}=this;Di(t,r,e),t[`pushIn${e}`]=function(i){return this.set(r,this.get(r).push(i))},t[`insertIn${e}At`]=function(i,s){return this.set(r,this.get(r).insert(i,s))}}}var co=(t)=>V(t);class Ri extends G{constructor(t,e=V()){super("map",t,ro,co,e)}extendProtoForType(t,e){Di(t,this.name,e)}}var _o=(t)=>B(t);class Ji extends G{constructor(t,e=B()){super("omap",t,io,_o,e)}extendProtoForType(t,e){Di(t,this.name,e)}}function ph(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 fh=b(),lo=(t)=>Array.isArray(t)?b(t):t instanceof Set?b(t):null;class Hi extends G{constructor(t,e=fh){super("set",t,so,lo,e)}extendProtoForType(t,e){let{name:r}=this;ph(t,r,fh),t[`addIn${e}`]=function(i){return this.set(r,this.get(r).add(i))},t[`deleteIn${e}`]=function(i){return this.set(r,this.get(r).delete(i))},t[`removeIn${e}`]=t[`deleteIn${e}`],t[`hasIn${e}`]=function(i){return this.get(r).has(i)},t[`toggleIn${e}`]=function(i){let s=this.get(r);return this.set(r,s.has(i)?s.delete(i):s.add(i))}}}function ch(t,e,r){let i=e.lookupComponent(t.type);return console.assert(i!==null,"component not found",{field:t}),i?.make({...t.args,...r},{scope:e})??null}class zh{constructor(t){let e={},r=new Set;this.name=t,this.fields=e,this.compFields=r,this._methods={},this._statics={make:function(i={},s={}){let n={};for(let h in i){let u=e[h];if(r.has(h))n[h]=ch(u,s.scope,i[h]);else if(u===void 0){console.warn("extra argument to constructor:",t,h,i);continue}n[h]=u.coerceOrDefault(i[h])}for(let h of r)if(n[h]===void 0)n[h]=ch(e[h],s.scope,i[h]);return this(n)}}}build(){let t={},e={},{name:r,_methods:i,fields:s}=this;for(let u in s){let o=s[u];t[u]=o.defaultValue,o.extendProto(e)}let n={[r]:fe(t,r)}[r];Object.assign(n.prototype,e,i);let h={fields:s,name:r,methods:i};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 i in e)t[i]=e[i];return this}addField(t,e,r){let i=new r(t,e);return this.fields[t]=i,i}addCompField(t,e,r){let i=new yh(e,t,r);return this.compFields.add(t),this.fields[t]=i,i}}var Sh=new Map,ao={text:Li,int:ah,float:Ki,bool:Ii,list:Wi,map:Ri,omap:Ji,set:Hi,any:Te};function go(t,{fields:e={},methods:r,statics:i}){let s=new zh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")s.addField(n,h,Li);else if(u==="number")s.addField(n,h,Ki);else if(u==="boolean")s.addField(n,h,Ii);else if(W.isList(h)||Array.isArray(h))s.addField(n,W(h),Wi);else if(b.isSet(h)||h instanceof Set)s.addField(n,b(h),Hi);else if(B.isOrderedMap(h))s.addField(n,h,Ji);else if(h?.type&&h?.defaultValue!==void 0){let o=ao[h.type]??Te;s.addField(n,new o().coerceOr(h.defaultValue),o)}else if(h?.component&&h?.args!==void 0)s.addCompField(n,h.component,h.args);else if(V.isMap(h)||h?.constructor===Object)s.addField(n,V(h),Ri);else{let o=Sh.get(h?.constructor)??Te;s.addField(n,h,o)}}if(r)s.methods(r);if(i)s.statics(i);return s.build()}var yo=(t)=>new zr(t.name??"Comp",go(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{raw:ef,raw:rf}=String;function sf(t,e){return new fr(t,e)}var wo=(t)=>typeof t==="string"?document.querySelector(t):t;function nf(t){let e=wo(t),r=new Me,i=(o)=>new k(o),s=(o)=>new Rt(o),n={document},h=(o,f)=>nh(o,f,n),u=new Ei(r,hh,i,s,h);return new $r(e,h,r,u,Bt)}export{nf as tutuca,th as seqInfoByClass,sf as macro,Je as isOrderedMap,Je as isOMap,ie as isMap,Cr as isList,z as isKeyed,j as isIndexed,ie as isIMap,Ls as injectCss,rf as html,Sh as fieldsByClass,ef as css,yo as component,fe as Record,Bt as ParseContext,B as OMap,W as List,b as ISet,V as IMap};
1
+ class Jt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class dt extends Jt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new dt({...this.binds,key:t})}withKey(t){return new dt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class le extends Jt{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 Fe(this.field,t)}withKey(t){return new xe(this.field,t)}}class Pe extends Jt{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 xe extends Pe{}class Fe extends Pe{}var K=Symbol("NONE");class Ve extends Jt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,K),s=t?.get(this.keyField,K);return s!==K&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,K),s=t?.get(this.keyField,K);return r===K||s===K?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,K),r===K)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,K),s===K)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,K),r===K)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:g}=Bs(t.previousSibling),{eid:p,cid:d,vid:q}=t.dataset;if(p!==void 0)o.push(p);if(d!==void 0){let zt=i.getComponentForId(+d,q);if(_){if(f=bh(zt,o,q,e),f===null&&n)return qh;_=!1}let St=Eh(zt,c,q);if(St)h.push(St);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:g})}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 Ys={};function Bs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Bs(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 bh(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 Eh(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 qh=[null,null];class ke{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new le(t))}index(t,e){return this.add(new Fe(t,e))}key(t,e){return this.add(new xe(t,e))}}var jh=/^[a-zA-Z][a-zA-Z0-9_]*$/,nt=(t)=>jh.test(t),Uh=/^-?[0-9]+(\.[0-9]+)?$/,Cs=(t,e)=>me.parse(t,e),Zt=(t,e)=>new G(t),Ah=(t,e)=>nt(t)?new ht(t):null,$h=(t,e)=>nt(t)?new ks(t):null,Ih=(t,e)=>nt(t)?new tr(t):null,Lh=(t,e)=>nt(t)?new vs(t):null,Kh=(t,e)=>nt(t)?new ti(t):null,Dh=(t,e)=>nt(t)?new ei(t):null,Wh=(t,e)=>nt(t)?new Ns(t):null;class Ps{constructor(){this.allowFieldOnly(),this.bindValIt=new tr("it"),this.nullConstVal=new G(null)}const(t){return new G(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(Rh(t)){case si:return this.parseIfOk(t,e,this.okStrTpl,Cs);case ni:return this.parseIfOk(t,e,this.okStrTpl,Zt);case ii:return this._parseSeqAccess(t,e);case ae:return this.parseIfOk(t,e,this.okStrTpl,Cs)}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,Zt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Zt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Ih);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Lh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Kh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Dh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Wh)}let s=Uh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Zt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Zt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Ah);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,$h);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,xs)}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 G 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 Ne extends ge{}class me extends Ne{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)==="}"?w.parseText(h.slice(1,-1),e):new G(h);s[n]=o,i&&=o instanceof G}return i?new G(s.map((n)=>n.value).join("")):new me(s)}}class ht extends Ne{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class xs 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 ve extends ge{render(t,e){return this.eval(t)}}class Ht extends ve{constructor(t){super();this.name=t}}class tr extends Ht{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class vs extends Ht{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ti extends Ht{eval(t){return t.lookupField(this.name)}toPathItem(){return new le(this.name)}toRawFieldVal(){return new ms(this.name)}toString(){return`.${this.name}`}}class ei extends Ht{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class ri extends ve{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new Ve(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,ae=2,ni=3;function Rh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return ae;e+=1;break;case 93:if(r>0||e===0)return ae;r+=1;break;case 123:return si;case 125:return ni}if(e>0||r>0)return e===1&&r===1?ii:ae;return-1}var w=new Ps;class Ot{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return ir(e).parse(t,r)}isConstant(){return!1}}var Jh="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",Zh=new Set(Jh.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?w.parseAll(e,this.px):w.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new we(t,s)),this.hasDynamic||=!(s instanceof G)}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=w.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=w.parseAttr(t,this.px)??Xt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=w.parseAttr(t,this.px)??Xt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=nr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new ye("data-eid",w.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new oi(w.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,w.const(t));return;case"push-view":this.pushWrapper("push-view",t,w.parseText(t,this.px));return;case"text":this.textChild=w.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,w.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,w.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,w.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=w.parseAlter(t,this.px);else this.pushWrapper("scope",t,w.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=w.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=w.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===""&&Zh.has(n)?!0:h;this.attrs.push(new ye(n,w.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new ui(r):rr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class rr extends Ot{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new rr(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 Ot{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 ye(t,new G(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class sr{constructor(t){this.name=t}}class we extends sr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class ye extends we{}class oi extends we{constructor(t){super("dangerouslySetInnerHTML",t??w.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Xt=w.nullConstVal;class fi extends sr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Xt}get anyBranchIsSet(){return this.thenVal!==Xt||this.elseVal!==Xt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var er=null;function ir(t){return er??=new hi(t),er.clear(t),er}class nr{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=w.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);w.allowHandlerArg();for(let h=0;h<s.length;h++){let u=w.parse(s[h],e);n[h]=u!==null?u:w.nullConstVal}return new nr(i,n)}}class hr{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 Mt{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 Gt extends Mt{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 Qt extends Gt{render(t,e){return e.renderComment(this.v)}}function Hh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new ar(r);else r.optimize()}}function fr(t){if(t.isConstant())return new ar(t);return t.optimize(),t}class cr extends Mt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Hh(this.childs)}}class pe extends cr{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 cr{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 Tt=(t)=>t.length===1?t[0]:new ze(t),Xh=/^[a-zA-Z][a-zA-Z0-9-]*$/,ci=null;class m extends Mt{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 m.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Gt(t.textContent);else if(e.isCommentNode(t))return new Qt(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 Tt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new de(null,w.const(u),Tt(n));case"text":{let f=w.parseText(u,e);return f!==null?new or(null,f):null}case"render":return e.addNodeIf(pi,w.parseRender(u,e),o);case"render-it":return e.addNodeIf(zi,w.bindValIt,o);case"render-each":return lr.parse(e,w,u,o,s);case"show":return e.addNodeIf(gr,w.parseCondValue(u,e),Tt(n));case"hide":return e.addNodeIf(yr,w.parseCondValue(u,e),Tt(n))}return new Qt(`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]??Tt(n)}let[u,o]=Ot.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]=Ot.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new or(null,o));let f=i!=="PRE"?Bh(n):n;return _i(new pe(i.toLowerCase(),h,f),e,u)}return new Qt(`Error: InvalidTagName ${i}`)}}function _i(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Th(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Th(t,e){let r=Yh[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 wi extends Mt{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 Qt(`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=fr(this.node)}}class _r{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return m.parse(this.rawView,t)}}class Se extends m{constructor(t,e,r){super(t,e);this.viewId=r}}class pi extends Se{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class zi extends Se{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class lr extends Se{constructor(t,e,r){super(t,e,r);this.iterInfo=new wr(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(lr,e.parseEach(r,t),s);if(n!==null){let h=ir(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 or extends m{render(t,e){return e.renderText(this.val.eval(t))}}class ar extends Mt{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=fr(this.node)}static register=!1}class gr extends ut{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class yr extends ut{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Si extends ut{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class de extends ut{optimize(){this.node.optimize()}}class di 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 dt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Oi extends ut{constructor(t,e){super(t,e);this.iterInfo=new wr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new dt({})}static register=!0}class wr{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)??Qh,s=this.loopWithVal?.eval(t)??Gh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Qh=(t,e,r)=>!0,Gh=(t)=>({seq:t}),Yh={slot:de,show:gr,hide:yr,each:Oi,scope:di,"push-view":Si};class Yt{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 Yt(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 Mi(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 de)i[h.val.value]=h.node;else if(!(h instanceof Gt)||!h.isWhiteSpace())s.push(h);let n=new wi(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 ur=(t)=>t instanceof Gt&&t.isWhiteSpace(),li=(t)=>t instanceof pe||t instanceof ze&&t.childs[0]instanceof pe;function Bh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(ur(t[0]))r=1,s=!0;if(e>1&&ur(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(ur(n)&&li(t[i-1])&&li(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Oe{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=fr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Mi{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new bi(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 bi{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=kh(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 Ch=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Me=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,ai=(t)=>Me((e)=>e.e.key===t),gi=Me(({e:t})=>Ch&&t.metaKey||t.ctrlKey),Ph=Me(({e:t})=>t.metaKey),xh=Me(({e:t})=>t.altKey),yi={ctrl:gi,cmd:gi,meta:Ph,alt:xh},Fh={keydown:{send:ai("Enter"),cancel:ai("Escape"),...yi},click:{...yi}},Vh=(t,e)=>t;function kh(t,e){if(e.length===0)return Vh;let r=Fh[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 pr{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 zr{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 Sr{getKey(t,e,r){return r.call(t)}}class dr{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 be{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new dr}setNullComputedCache(){this.computedCache=new Sr}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:qi}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 Ee{constructor(t=new be,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ee(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 hr(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 Or{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 Ei extends Or{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 bt=(t)=>typeof t==="string",Nh=0;class Mr{constructor(t,e,r,s={},i="",n="",h="",u={},o={},f={},c={},_={},l={},a={},g={}){this.id=Nh++,this.name=t,this.Class=e,this.views={main:new Oe("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:g?.stackEnter??qi};for(let p in s){let d=s[p],{view:q,style:zt}=bt(d)?{view:d}:d;this.views[p]=new Oe(p,q,zt)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(bt(r)){let s=w.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Or(e,s,Symbol(e))}else if(bt(r?.default)&&bt(r?.for)){let s=w.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(bt(i)&&bt(n))this.dynamic[e]=new Ei(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 qi(t){return t}var ji=Symbol("STOP"),qr=Symbol("NEXT");class Bt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Bt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===ji?e:s===qr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class br{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?ji:qr:e}}class Er{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?qr:e}}class J{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 J(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Bt(new br(e,{it:e},!0),null),i=new Bt(new Er({}),null),n=new Bt("main",null);return new J(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 br(t,e,r));return new J(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 J(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 Er(e));return new J(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 Ai{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 Ai(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 Ir(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 Li(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)??mh(e),o=s?.onResName??e,f=(c,_,l,a,g)=>{let d=new Ii(t,this,c??_,c?[l]:[a,g],i);return this.pushTransaction(d)};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 $i(t,e,r,this,s))}}function mh(t){return()=>{throw Error(`Request not found: ${t}`)}}function vh(){return this}class Ar{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Ki,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 J.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 tu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ui=(t)=>Number.isNaN(t)?null:t;function jr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class $i extends Ar{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return J.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 Lr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return jr(e);case"valueAsInt":return Ui(parseInt(jr(e),10));case"valueAsFloat":return Ui(parseFloat(jr(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 tu&&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 Kr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class $r extends Ar{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]??vh}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Kr(this.path,this.transactor,this)]]}}class Ii extends $r{handlerProp="response"}class Ir extends $r{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 Li extends Ir{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Ki{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 Lr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Di(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 Kr extends Lr{stopPropagation(){return this.parent.stopPropagation()}}class Di extends ke{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 Dr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ee(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]=N.fromEvent(t,i,n,h,u);if(r){let c=eu(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 Ri(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 J.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()}),Wi("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 Wi(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 eu(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 Ri{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)}}function Ct(t,e){if(!t)throw Error(e)}function A(t){Ct(t!==1/0,"Cannot perform this action with an infinite size.")}function Ji(t,e,r,s,i,n){return A(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 ru=(t,e)=>e,su=(t,e)=>[e,t],Wr=(t)=>function(...e){return!t.apply(this,e)},Zi=(t)=>function(...e){return-t.apply(this,e)};function hn(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 Hi=(t,e)=>t<e?1:t>e?-1:0,$={done:!0,value:void 0};class un{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new un(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 $})}var iu=L(()=>$),ot=()=>iu;function We(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return $;return r.value=e++,r})}function Nt(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 on(t){if(Array.isArray(t))return!0;return!!Re(t)}var nu=(t)=>!!(t&&typeof t.next==="function");function fn(t){return Re(t)?.call(t)}function Re(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function hu(t){let e=Re(t);return e&&e===t.entries}function uu(t){let e=Re(t);return e&&e===t.keys}var mt="delete",S=5,E=1<<S,I=E-1,y={},Gr=()=>({value:!1});function R(t){if(t)t.value=!0}class Je{}function qt(t){if(t.size===void 0)t.size=t.__iterate(cn);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?qt(t)+e:e}var cn=()=>!0,_n=(t)=>t<0||Object.is(t,-0),vt=(t,e,r)=>(t===0&&!_n(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),ln=(t,e,r)=>t===void 0?r:_n(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Lt=(t,e)=>ln(t,e,0),te=(t,e)=>ln(t,e,e),an="@@__IMMUTABLE_ITERABLE__@@",Ae="@@__IMMUTABLE_KEYED__@@",$e="@@__IMMUTABLE_INDEXED__@@",et="@@__IMMUTABLE_ORDERED__@@",ee="@@__IMMUTABLE_SEQ__@@",gn="@@__IMMUTABLE_LIST__@@",yn="@@__IMMUTABLE_MAP__@@",wn="@@__IMMUTABLE_SET__@@",pn="@@__IMMUTABLE_STACK__@@",zn="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var D=(t)=>C(t,an),z=(t)=>C(t,Ae),j=(t)=>C(t,$e),Fr=(t)=>z(t)||j(t),x=(t)=>C(t,et),Vr=(t)=>C(t,ee),kr=(t)=>C(t,gn),re=(t)=>C(t,yn),Nr=(t)=>C(t,wn),mr=(t)=>C(t,pn),lt=(t)=>C(t,zn),P=(t)=>D(t)||lt(t),Ze=(t)=>re(t)&&x(t),Sn=(t)=>Nr(t)&&x(t),Xi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function dn(t){let e=Y(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=Dt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return Nt(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function On(t,e,r){let s=Y(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,y);return h===y?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 Nt(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function Mn(t,e){let r=Y(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=dn(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=Dt,r.__iterate=function(s,i){let n=0;if(i)qt(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)qt(t);let n=this.size;return Nt(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function bn(t,e,r,s){let i=t.size;if(vt(e,r,i))return t;if(i===void 0&&(e<0||r<0))return bn(t.toSeq().cacheResult(),e,r,s);let n=Lt(e,i),u=te(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=Y(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&Vr(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((g,p)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(g,s?p:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ot();let _=t.__iterator(c),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return $;let g=_.next();if(g.done)return g;return a++,g});return M((g)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let p=_.next();if(p.done)return!1;return a++,g[0]=a-1,g[1]=p.value[1],!0})},f}function Ti(t,e,r){if(!e)e=hn;let s=z(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?ss(n):j(t)?_t(n):xt(n)}function qe(t,e,r){if(!e)e=hn;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Qi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Qi(e,s,i)?i:s)}function Qi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Rr(t,e,r,s){let i=Y(t),n=new se(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=F(_);return fn(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 En(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 ou(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"&&(P(t)||Array.isArray(t)||ou(t));function qn(t){if(En(t)&&typeof t!=="string")return t;if(x(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var fu=(t,e)=>P(t)?t.has(e):rt(t)&&Object.hasOwn(t,e);function jn(t,e,r){return P(t)?t.get(e,r):!fu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function vr(t,e,r){let s=qn(e),i=0;while(i!==s.length)if(t=jn(t,s[i++],y),t===y)return r;return t}var Un=(t,e)=>vr(t,e,y)!==y;function U(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 Ie(t){if(!t||typeof t!=="object")return t;if(!D(t)){if(!rt(t))return t;t=st(t)}if(z(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Ie(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Ie(r))}),e}function ts(t,e){if(t===e)return!0;if(!D(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||z(t)!==z(e)||j(t)!==j(e)||x(t)!==x(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!Fr(t);if(x(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&U(f[1],u)&&(r||U(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?!U(h,t.get(u,y)):!U(t.get(u,y),h))return i=!1,!1;return!0});return i&&t.size===n}var He=(t)=>t>>>1&1073741824|t&3221225471;function Z(t){if(t===null||t===void 0)return Gi(t);if(typeof t.hashCode==="function")return He(t.hashCode(t));let e=gu(t);if(e===null||e===void 0)return Gi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return cu(e);case"string":return e.length>yu?_u(e):Yr(e);case"object":case"function":return au(e);case"symbol":return lu(e);default:if(typeof e.toString==="function")return Yr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Gi=(t)=>t===null?1108378658:1108378659;function cu(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 He(e)}function _u(t){let e=Hr[t];if(e===void 0){if(e=Yr(t),Zr===wu)Zr=0,Hr={};Zr++,Hr[t]=e}return e}function Yr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return He(e)}function lu(t){let e=Bi[t];if(e!==void 0)return e;return e=An(),Bi[t]=e,e}function au(t){let e=Yi.get(t);if(e!==void 0)return e;return e=An(),Yi.set(t,e),e}var gu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function An(){let t=++Jr;if(Jr&1073741824)Jr=0;return t}var Yi=new WeakMap,Bi=Object.create(null),Jr=0,yu=16,wu=255,Zr=0,Hr={};function pu(t){if(t.size===1/0)return 0;let e=x(t),r=z(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Ci(Z(i),Z(n))|0}:(i,n)=>{s=s+Ci(Z(i),Z(n))|0}:e?(i)=>{s=31*s+Z(i)|0}:(i)=>{s=s+Z(i)|0}),zu(t.size,s)}var Ci=(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=He(e^e>>>16),e}function Pt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:Vr(t)?e:t.create?t.create(e):t.constructor(e),Su=(t,e)=>O(t,(z(t)?X:j(t)?at:gt)(e)),Pi=(...t)=>t,F=(t)=>D(t)?t:st(t);class H{size=0;static{this.prototype[an]=!0,this.prototype.__toStringMapper=Pt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return ts(this,t)}hashCode(){return this.__hash??(this.__hash=pu(this))}toArray(){A(this.size);let t=Array(this.size||0),e=z(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Dn(this)}toJS(){return Ie(this)}toKeyedSeq(){return new os(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){A(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 Wn(this)}toSeq(){return j(this)?this.toIndexedSeq():z(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=z(this),r=[this,...t].map((s)=>{if(!D(s))s=e?In(s):Ln(Array.isArray(s)?s:[s]);else if(e)s=X(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&&z(s)||j(this)&&j(s))return s}return O(this,new Kn(r))}includes(t){return this.some((e)=>U(e,t))}every(t,e){A(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=z(this),i=Y(r);if(s)i.has=(n)=>{let h=r.get(n,y);return h!==y&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,y);return u!==y&&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=z(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 A(this.size),this.__iterate(e?t.bind(e):t)}join(t){A(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 $;return e.value=r.value[0],e})}map(t,e){return O(this,On(this,t,e))}reduce(t,e=y,r){return Ji(this,t,e,r,e===y,!1)}reduceRight(t,e=y,r){return Ji(this,t,e,r,e===y,!0)}reverse(){return O(this,Mn(this,z(this)))}slice(t,e){return O(this,bn(this,t,e,z(this)))}some(t,e){A(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,Ti(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return $;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 qt(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 se(t._cache);let e=t.toSeq().map(su).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Wr(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(cn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(z(this)?X:j(this)?at:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=z(this),s=Y(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)&&D(_))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)&&D(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 Rn(this)}get(t,e){return this.find((r,s)=>U(s,t),void 0,e)}getIn(t,e){return vr(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,y)!==y}hasIn(t){return Un(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:F(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:F(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>U(e,t))}keySeq(){return this.toSeq().map(ru).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return qe(this,t)}maxBy(t,e){return qe(this,e,t)}min(t){return qe(this,t?Zi(t):Hi)}minBy(t,e){return qe(this,e?Zi(e):Hi,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=z(this),i=Y(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(Wr(t),e)}sortBy(t,e){return O(this,Ti(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=Y(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 $;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,$;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(Wr(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 X=(t)=>z(t)?t:ss(t);class es extends H{static{this.prototype[Ae]=!0,this.prototype.__toStringMapper=(t,e)=>`${Pt(e)}: ${Pt(t)}`,this.prototype[Symbol.iterator]=H.prototype.entries,this.prototype.toJSON=function(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,dn(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 at=(t)=>j(t)?t:_t(t);class jt extends H{static{this.prototype[$e]=!0,this.prototype[et]=!0}toKeyedSeq(){return new os(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=y,...r){if(t===void 0)return this;let s=e!==y;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Lt(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=Y(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=Rr(this.toSeq(),_t.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,Rr(this,Pi,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,Rr(this,t,r))}}var gt=(t)=>D(t)&&!Fr(t)?t:xt(t);class Xe extends H{static{this.prototype.has=H.prototype.includes,this.prototype.contains=H.prototype.includes,this.prototype.keys=Xe.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}F.Keyed=X;F.Indexed=at;F.Set=gt;var Xr=jt.prototype,st=(t)=>t===void 0||t===null?hs():P(t)?t.toSeq():du(t),Y=(t)=>Object.create((z(t)?Kt:j(t)?yt:is).prototype);class ft extends H{static{this.prototype[ee]=!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 $;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var rs={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},ss=(t)=>t===void 0||t===null?hs().toKeyedSeq():D(t)?z(t)?t.toSeq():t.fromEntrySeq():lt(t)?t.toSeq():In(t);class Kt extends es{static{this.prototype[ee]=!0,Object.assign(this.prototype,rs)}toSeq(){return this}toKeyedSeq(){return this}}var _t=(t)=>t===void 0||t===null?hs():D(t)?z(t)?t.entrySeq():t.toIndexedSeq():lt(t)?t.toSeq().entrySeq():Ln(t);_t.of=(...t)=>_t(t);class yt extends jt{static{this.prototype[ee]=!0,Object.assign(this.prototype,rs)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var xt=(t)=>(D(t)&&!Fr(t)?t:_t(t)).toSetSeq();xt.of=(...t)=>xt(t);class is extends Xe{static{this.prototype[ee]=!0,Object.assign(this.prototype,rs)}toSeq(){return this}toSetSeq(){return this}}st.isSeq=Vr;st.Keyed=ss;st.Set=xt;st.Indexed=_t;class se extends yt{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 ns extends Kt{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 $n extends yt{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=fn(e);if(!nu(r))return ot();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 hs=()=>new se([]),us=(t)=>En(t)?new se(t):on(t)?new $n(t):void 0;function In(t){let e=us(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new ns(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Ln(t){let e=us(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function du(t){let e=us(t);if(e)return hu(t)?e.fromEntrySeq():uu(t)?e.toSetSeq():e;if(typeof t==="object")return new ns(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Kn extends ft{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[Ae])this[Ae]=!0;if(i[$e])this[$e]=!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=!z(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 ot();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!z(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()||$)}}class os extends Kt{static{this.prototype[et]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Dt.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=Mn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=On(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 Dn extends yt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)qt(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)qt(this);let r=this.size;return Nt(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Wn extends is{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.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 Nt(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Rn extends Kt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){xi(s),r++;let i=D(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){xi(i);let n=D(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Dt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function xi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var V=(t)=>t===void 0||t===null?T():re(t)&&!x(t)?t:T().withMutations((e)=>{let r=X(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});class fs extends es{static{pt(this,{asImmutable:ie,asMutable:ne,deleteIn:Ut,merge:Br,mergeWith:Gn,mergeDeep:Bn,mergeDeepWith:Cn,mergeDeepIn:Ms,mergeIn:Os,setIn:zs,update:Ss,updateIn:ds,wasAltered:ps,withMutations:he,removeIn:Ut,concat:Br,[yn]:!0,[mt]: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 V(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 Vi(this,t,e)}remove(t){return Vi(this,t,y)}deleteAll(t){let e=F(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 T()}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 ot();return je(this._root,!1,0)}values(){if(!this._root)return ot();return je(this._root,!1,1)}entries(){if(!this._root)return ot();return je(this._root,!1)}__iterator(t){if(!this._root)return ot();return je(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 T();return this.__ownerID=t,this.__altered=!1,this}return ls(this.size,this._root,t,this.__hash)}}V.isMap=re;class cs{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Jn(this.entries,r,s)}iterate(t,e){return Zn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===y,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(U(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(R(h),u||!_)R(n);if(u&&c===1)return;if(!_&&!u&&c>=ju)return Ou(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 cs(t,a)}}class Te{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Hn(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[Ni(n&i-1)].get(t+S,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===y)return this;let _=Ni(f&o-1),l=this.nodes,a=c?l[_]:void 0,g=as(a,t,e+S,r,s,i,n,h);if(g===a)return this;if(!c&&g&&l.length>=Uu)return bu(t,l,f,u,g);if(c&&!g&&l.length===2&&ki(l[_^1]))return l[_^1];if(c&&g&&l.length===1&&ki(g))return g;let p=t&&t===this.ownerID,d=c?g?f:f^o:f|o,q=c?g?Xn(l,_,g,p):qu(l,_,p):Eu(l,_,g,p);if(p)return this.bitmap=d,this.nodes=q,this;return new Te(t,d,q)}}class _s{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Hn(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+S,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=i===y,f=this.nodes,c=f[u];if(o&&!c)return this;let _=as(c,t,e+S,r,s,i,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<Au)return Mu(t,f,l,u)}let a=t&&t===this.ownerID,g=Xn(f,u,_,a);if(a)return this.count=l,this.nodes=g,this;return new _s(t,l,g)}}class Qe{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Jn(this.entries,r,s)}iterate(t,e){return Zn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===y)return this;return R(h),R(n),gs(this,t,e,r,[s,i])}let u=i===y,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(U(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(R(h),u||!_)R(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 Qe(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 U(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===y,o=U(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(R(h),u){R(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new wt(t,this.keyHash,[s,i])}return R(n),gs(this,t,e,Z(s),[s,i])}}function Jn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(U(e,t[s][0]))return t[s][1];return r}function Zn(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 Hn(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 je(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 $})}var ls=(t,e,r,s)=>new fs(t,e,r,s),Fi,T=()=>Fi||(Fi=ls(0));function Vi(t,e,r){let s,i;if(!t._root){if(r===y)return t;i=1,s=new cs(t.__ownerID,[[e,r]])}else{let n=Gr(),h=Gr();if(s=as(t._root,t.__ownerID,0,Z(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===y?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?ls(i,s):T()}function as(t,e,r,s,i,n,h,u){if(!t){if(n===y)return t;return R(u),R(h),new wt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var ki=(t)=>t.constructor===wt||t.constructor===Qe;function gs(t,e,r,s,i){if(t.keyHash===s)return new Qe(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?[gs(t,e,r+S,s,i)]:n<h?[t,u]:[u,t];return new Te(e,1<<n|1<<h,o)}function Ou(t,e,r,s){if(!t)t=new Je;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 Mu(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 Te(t,i,h)}function bu(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 _s(t,n+1,h)}function Ni(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 Eu(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 qu(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 ju=E/4,Uu=E/2,Au=E/4;function Le(t){if(Array.isArray(t))return t.slice();return{...t}}var ys=(t,e,r)=>ws(t,e,$u(r));function ws(t,e,r){if(!rt(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?at:X,h=s?(u)=>{if(i===t)i=Le(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=Le(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function $u(t){function e(r,s,i){return rt(r)&&rt(s)&&Iu(r,s)?ws(r,[s],e):t?t(r,s,i):s}return e}function Iu(t,e){let r=st(t),s=st(e);return j(r)===j(s)&&z(r)===z(s)}function Lu(t,e){if(!rt(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=Le(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Ku(t,e,r){if(!rt(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=Le(t);return s[e]=r,s}function Wt(t,e,r,s){if(!s)s=r,r=void 0;let i=Tn(P(t),t,qn(e),0,r,s);return i===y?r:i}function Tn(t,e,r,s,i,n){let h=e===y;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(Pt)}]: ${e}`);let u=r[s],o=h?y:jn(e,u,y),f=Tn(o===y?t:P(o),o,r,s+1,i,n);if(f===o)return e;if(f===y)return Lu(e,u);let c=h?t?T():{}:e;return Ku(c,u,f)}var Du=(t,e)=>Wt(t,e,()=>y),Wu=(t,e,r)=>Wt(t,e,y,()=>r);function Qn(t,e,r,s){return Wt(t,[e],r,s)}function ie(){return this.__ensureOwner()}function ne(){return this.__ownerID?this:this.__ensureOwner(new Je)}function ps(){return this.__altered}function he(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Ru(t,e){return vr(this,t,e)}function Ju(t){return Un(this,t)}function Ut(t){return Du(this,t)}function zs(t,e){return Wu(this,t,e)}function Ss(t,e,r){return typeof t==="function"?t(this):Qn(this,t,e,r)}function ds(t,e,r){return Wt(this,t,e,r)}function mi(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function Br(...t){return Yn(this,t)}function Gn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Yn(this,e,t)}function Yn(t,e,r){let s=[];for(let i of e){let n=X(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 lt(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Qn(i,u,y,(o)=>o===y?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function Bn(...t){return ys(this,t)}function Cn(t,...e){return ys(this,e,t)}function Os(t,...e){return Wt(this,t,T(),(r)=>ws(r,e))}function Ms(t,...e){return Wt(this,t,T(),(r)=>ys(r,e))}function pt(t,e){Object.assign(t.prototype,e)}var W=(t)=>{let e=Ft();if(t===void 0||t===null)return e;if(kr(t))return t;let r=at(t),s=r.size;if(s===0)return e;if(A(s),s>0&&s<E)return ue(0,s,S,null,new ct(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};W.of=(...t)=>W(t);class Pn extends jt{static{pt(this,{asImmutable:ie,asMutable:ne,deleteIn:Ut,mergeDeepIn:Ms,mergeIn:Os,setIn:zs,update:Ss,updateIn:ds,wasAltered:ps,withMutations:he,removeIn:Ut,[gn]:!0,[mt]: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 W(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 Hu(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=S,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return Ft()}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=at(typeof r!=="string"&&on(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 W(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(vt(t,e,r))return this;return v(this,Lt(t,r),te(e,r))}__iterate(t,e){let r=e?this.size:0;return Zu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=vi(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 vi(this,!1)}keys(){return We(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Ft();return this.__ownerID=t,this.__altered=!1,this}return ue(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}W.isList=kr;class ct{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+S)-1)===0||this.array.length===0)return this;let s=r>>>e&I;if(s>=this.array.length)return new ct([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-S,r),n===u&&i)return this}if(i&&!n)return this;let h=At(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+S: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-S,r),i===h&&s===this.array.length-1)return this}let n=At(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function vi(t,e){let{_origin:r,_capacity:s}=t,i=$t(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-S,a=f.offset+(c<<f.level);o(_,l,a)}return $});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,g=s-_;if(g>E)g=E;if(a!==g)h.push({array:l,from:a,to:g,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,g=(s-_>>c)+1;if(g>E)g=E;if(a!==g)h.push({array:l,from:a,to:g,level:c,offset:_,isLeaf:!1})}}}function Zu(t,e,r){let{_origin:s,_capacity:i}=t,n=$t(i),h=t._tail,u=t._level,o=t._root;return u===0?xn(o,0,s,i,n,h,e,r):Fn(o,u,0,s,i,n,h,e,r)}function xn(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 Fn(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-S;while(c!==_){let a=o?--_:c++,g=r+(a<<e);if((l===0?xn(f?.[a],g,s,i,n,h,u,o):Fn(f?.[a],l,g,s,i,n,h,u,o))===!1)return!1}}var ue=(t,e,r,s,i,n,h)=>new Pn(t,e,r,s,i,n,h),Ft=()=>ue(0,0,S);function Hu(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=Gr();if(e>=$t(t._capacity))s=Cr(s,t.__ownerID,0,e,r,n);else i=Cr(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 ue(t._origin,t._capacity,t._level,i,s)}function Cr(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=Cr(f,e,r-S,s,i,n);if(c===f)return t;return o=At(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)R(n);if(o=At(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function At(t,e){if(e&&e===t?.ownerID)return t;return new ct(t?.array.slice()??[],e)}function Vn(t,e){if(e>=$t(t._capacity))return t._tail;if(e<1<<t._level+S){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&I],s-=S;return r}}function v(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Je,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 ct(f?.array.length?[void 0,f]:[],s),o+=S,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=$t(n),l=$t(u);while(l>=1<<o+S)f=new ct(f?.array.length?[f]:[],s),o+=S;let a=t._tail,g=l<_?Vn(t,u-1):l>_?new ct([],s):a;if(a&&l>_&&h<n&&a.array.length){f=At(f,s);let p=f;for(let d=o;d>S;d-=S){let q=_>>>d&I;p=p.array[q]=At(p.array[q],s)}p.array[_>>>S&I]=a}if(u<n)g=g&&g.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=S,f=null,g=g&&g.removeBefore(s,0,h);else if(h>i||l<_){c=0;while(f){let p=h>>>o&I;if(p!==l>>>o&I)break;if(p)c+=(1<<o)*p;o-=S,f=f.array[p]}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=g,t.__hash=void 0,t.__altered=!0,t;return ue(h,u,o,f,g)}var $t=(t)=>t<E?0:t-1>>>S<<S,B=(t)=>t===void 0||t===null?Vt():Ze(t)?t:Vt().withMutations((e)=>{let r=X(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});B.of=(...t)=>B(t);class kn extends fs{static{pt(this,{[et]:!0,[mt]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:H.prototype.keys,values:H.prototype.values,__iterate:H.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 Vt()}set(t,e){return tn(this,t,e)}remove(t){return tn(this,t,y)}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 Vt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return bs(e,r,t,this.__hash)}}B.isOrderedMap=Ze;var bs=(t,e,r,s)=>new kn(t,e,r,s),Vt=()=>bs(T(),Ft());function tn(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===y){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=Ft().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=T().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 bs(u,o)}var Ke=(t)=>t===void 0||t===null?De():mr(t)?t:De().pushAll(t);Ke.of=(...t)=>Ke(t);class Nn extends jt{static{pt(this,{asImmutable:ie,asMutable:ne,wasAltered:ps,withMutations:he,[pn]:!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 Ke(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 Tr(this,e,r)}pushAll(t){if(t=at(t),t.size===0)return this;if(this.size===0&&mr(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Tr(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 De()}slice(t,e){if(vt(t,e,this.size))return this;let r=Lt(t,this.size);if(te(e,this.size)!==this.size)return jt.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return Tr(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return De();return this.__ownerID=t,this.__altered=!1,this}return Es(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 $;return e.value=t.value,t=t.next,e})}keys(){return We(this.size)}}Ke.isStack=mr;function Tr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Es(e,r)}var Es=(t,e,r,s)=>new Nn(t,e,r,s),en,De=()=>en||(en=Es(0)),b=(t)=>t===void 0||t===null?kt():Nr(t)&&!x(t)?t:kt().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((s)=>e.add(s))});b.of=(...t)=>b(t);b.fromKeys=(t)=>b(X(t).keySeq());b.intersect=(t)=>{return t=F(t).toArray(),t.length?b(t.pop()).intersect(...t):kt()};b.union=(t)=>{let e=F(t).toArray();return e.length?b(e.pop()).union(...e):kt()};class qs extends Xe{static{pt(this,{withMutations:he,asImmutable:ie,asMutable:ne,[wn]:!0,[mt]: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 Ue(this,this._map.set(t,t))}remove(t){return Ue(this,this._map.remove(t))}clear(){return Ue(this,this._map.clear())}map(t,e){let r=!1,s=Ue(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 sn(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return sn(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return kt()}__make(t,e){return mn(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=Nr;var mn=(t,e)=>new qs(t,e),rn,kt=()=>rn||(rn=mn(T()));function sn(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 Ue(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 It=(t)=>t===void 0||t===null?Pr():Sn(t)?t:Pr().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((s)=>e.add(s))});It.of=(...t)=>It(t);It.fromKeys=(t)=>It(X(t).keySeq());class vn extends qs{static{pt(this,{[et]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Xr.zip,zipWith:Xr.zipWith,zipAll:Xr.zipAll})}create(t){return It(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return Pr()}__make(t,e){return th(t,e)}}It.isOrderedSet=Sn;var th=(t,e)=>new vn(t,e),Pr=()=>th(Vt());function Xu(t){if(lt(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 oe=(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 ${js(this)} with property "${c}" since that property name is part of the Record API.`);else Qu(i,c)}}return this.__ownerID=void 0,this._values=W().withMutations((u)=>{u.setSize(this._keys.length),X(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(Tu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class eh{static{pt(this,{asImmutable:ie,asMutable:ne,deleteIn:Ut,getIn:Ru,hasIn:Ju,merge:Br,mergeWith:Gn,mergeDeep:Bn,mergeDeepWith:Cn,mergeDeepIn:Ms,mergeIn:Os,setIn:zs,toObject:mi,update:Ss,updateIn:ds,withMutations:he,removeIn:Ut,toJSON:mi,[zn]:!0,[mt]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${Pt(this.get(e))}`).join(", ");return`${js(this)} { ${t} }`}equals(t){return this===t||lt(t)&&Et(this).equals(Et(t))}hashCode(){return Et(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 Qr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Qr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Et(this)}toJS(){return Ie(this)}entries(){return this.__iterator()}__iterate(t,e){return Et(this).__iterate(t,e)}__iterator(t){return Et(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 Qr(this,e,t)}}oe.isRecord=lt;var js=(t)=>t.constructor.displayName||t.constructor.name||"Record";class rh extends Kt{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 Et=(t)=>new rh(t);oe.getDescriptiveName=js;var Tu=eh.prototype;function Qr(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Qu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){Ct(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var nn=(t,e,r=1)=>{if(Ct(r!==0,"Cannot step a Range by 0"),Ct(t!==void 0,"You must define a start value when using Range"),Ct(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 yt{_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(vt(t,e,this.size))return this;if(t=Lt(t,this.size),e=te(e,this.size),e<=t)return nn(0,0);return nn(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 $;return i.value=r,r+=e,s++,i})}keys(){return We(this.size)}equals(t){return t instanceof Us?this._start===t._start&&this._end===t._end&&this._step===t._step:ts(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class xr extends yt{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 U(this._value,t)}slice(t,e){let r=this.size;return vt(t,e,r)?this:new xr(this._value,te(e,r)-Lt(t,r))}reverse(){return this}indexOf(t){if(U(this._value,t))return 0;return-1}lastIndexOf(t){if(U(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 $;return r++,s.value=e,s})}keys(){return We(this.size)}equals(t){return t instanceof xr?this.size===t.size&&U(this._value,t._value):ts(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Gu=["nid","cid","eid","vid","si","sk"];class As{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??Fu,this.cache=h??new zr}setNullCache(){this.cache=new pr}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 Gu)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),g=this.renderIt(a,r,_,s);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(g)}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,g]of f(i))if(n.call(t.it,a,g,l)){let p={key:a,value:g},d=`${s}-${a}`,q;if(c)u.call(t.it,p,a,g,l),q=this.cache.get2(t.it,g,d);else q=this.cache.get(g,d);if(q){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(q);continue}let zt=t.enter(g,p,!1),St=r.render(zt,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,g,d,St);else this.cache.set(g,d,St);_.push(St)}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*Yu(t){let e=0;for(let r of t)yield[e++,r]}function*Bu(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var sh=new Map,Cu=["si",Yu],Pu=["sk",Bu],xu=["si",function*(e){}];function Fu(t){return j(t)?Cu:z(t)?Pu:sh.get(t?.constructor)??xu}var Is=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),fe=(t)=>t!==null&&typeof t==="object";function nh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)Vu(t,s,r);else if(Is(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(fe(i))ku(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function Vu(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(typeof s==="string"||Is(e)){let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function ku(t,e,r,s){let i=e?.[r];if(fe(i)&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(!fe(n))t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Rt{isEqualTo(t){return this===t}toDom(t){return null}}var $s=(t)=>t instanceof _e?t.key:void 0,Nu=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function Ls(t,e){if(e==null)return;if(Nu(e))for(let r of e)Ls(t,r);else if(e instanceof Rt)if(e instanceof it)t.push(...e.childs);else t.push(e);else t.push(new Be(e))}class Be extends Rt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof Be&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class ce extends Rt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof ce&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class it extends Rt{constructor(t){super();this.childs=[],Ls(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 _e extends Rt{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 _e)||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);nh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function hh(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(fe(i)&&fe(n))if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=hh(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 mu(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}var Ge=(t,e,r)=>t instanceof r&&e instanceof r;function uh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(Ge(e,r,Be)||Ge(e,r,ce))return t.data=r.text,t;if(Ge(e,r,_e)&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=hh(e.attrs,r.attrs);if(i)nh(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)ih(t,e.childs,r.childs,e.tag,s);return t}if(Ge(e,r,it))return ih(t,e.childs,r.childs,null,s),t;return mu(t,r,s)}function ih(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=$s(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],_=$s(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&$s(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],g=uh(a,e[l],c,i),p=t.childNodes[f]??null;if(g!==p)t.insertBefore(g,p)}else{let a=c.toDom(i);if(a){let g=t.childNodes[f]??null;t.insertBefore(a,g)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var Ye=new WeakMap;function oh(t,e,r){let s=Ye.get(e),i=t instanceof it;if(s){let h=s.vnode instanceof it;if(h===i){let u=h?e:s.dom,o=uh(u,s.vnode,t,r),f=i?e:o;return Ye.set(e,{vnode:t,dom:f}),o}Ye.delete(e)}let n=t.toDom(r);if(n){e.innerHTML="",e.appendChild(n);let h=i?e:n;Ye.set(e,{vnode:t,dom:h})}return n}function fh(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]=Is(o)?String(f):f}}let u=[];return Ls(u,r),new _e(s,i,u,n,h)}var ch=Symbol("BadValue"),gh=(t)=>t;class Q{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,ch);if(h===ch)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 Ds{isValid(t){return!0}getMessage(t){return"Invalid"}}class yh extends Ds{}var vu=new yh;class k extends Ds{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var to=new k((t)=>Number.isInteger(t),()=>"Integer expected"),eo=new k((t)=>Number.isFinite(t),()=>"Float expected"),ro=new k((t)=>typeof t==="boolean",()=>"Boolean expected"),so=new k((t)=>typeof t==="string",()=>"String expected"),io=new k((t)=>W.isList(t),()=>"List expected"),no=new k((t)=>V.isMap(t),()=>"Map expected"),ho=new k((t)=>B.isOrderedMap(t),()=>"OrderedMap expected"),uo=new k((t)=>b.isSet(t),()=>"Set expected"),oo=(t)=>!!t;class Ws extends Q{constructor(t,e=!1){super("bool",t,ro,oo,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 Ce extends Q{constructor(t,e=null){super("any",t,vu,gh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ks(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var fo=(t)=>t?.toString?.()??"";class Rs extends Q{constructor(t,e=""){super("text",t,so,fo,e)}extendProtoForType(t,e){Qs(t,this.name,e,"","length")}}var co=(t)=>Number.isFinite(t)?Math.trunc(t):null;class wh extends Q{constructor(t,e=0){super("int",t,to,co,e)}}var _o=(t)=>null;class Js extends Q{constructor(t,e=0){super("float",t,eo,_o,e)}}var Ks=(t)=>t?.constructor?.getMetaClass?.()?.name;class ph{constructor(t){this.typeName=t}isValid(t){return Ks(t)===this.typeName}getMessage(t){let e=Ks(t);return`Expected "${this.typeName}", got "${e}"`}}class zh extends Q{constructor(t,e,r){super(t,e,new ph(t),gh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var _h=Symbol("NONE");function Zs(t,e,r){Qs(t,e,r,dh),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,_h);if(h!==_h)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},Sh(t,e,`${r}At`)}function Sh(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var dh=W(),lo=(t)=>Array.isArray(t)?W(t):null;class Hs extends Q{constructor(t,e=dh){super("list",t,io,lo,e)}extendProtoForType(t,e){let{name:r}=this;Zs(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 ao=(t)=>V(t);class Xs extends Q{constructor(t,e=V()){super("map",t,no,ao,e)}extendProtoForType(t,e){Zs(t,this.name,e)}}var go=(t)=>B(t);class Ts extends Q{constructor(t,e=B()){super("omap",t,ho,go,e)}extendProtoForType(t,e){Zs(t,this.name,e)}}function Qs(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 lh=b(),yo=(t)=>Array.isArray(t)?b(t):t instanceof Set?b(t):null;class Gs extends Q{constructor(t,e=lh){super("set",t,uo,yo,e)}extendProtoForType(t,e){let{name:r}=this;Qs(t,r,e,lh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},Sh(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 ah(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 Oh{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]=ah(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]=ah(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]:oe(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 zh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var Mh=new Map,wo={text:Rs,int:wh,float:Js,bool:Ws,list:Hs,map:Xs,omap:Ts,set:Gs,any:Ce};function po(t,{fields:e={},methods:r,statics:s}){let i=new Oh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Rs);else if(u==="number")i.addField(n,h,Js);else if(u==="boolean")i.addField(n,h,Ws);else if(W.isList(h)||Array.isArray(h))i.addField(n,W(h),Hs);else if(b.isSet(h)||h instanceof Set)i.addField(n,b(h),Gs);else if(B.isOrderedMap(h))i.addField(n,h,Ts);else if(h?.type&&h?.defaultValue!==void 0){let o=wo[h.type]??Ce;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(V.isMap(h)||h?.constructor===Object)i.addField(n,V(h),Xs);else{let o=Mh.get(h?.constructor)??Ce;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var zo=(t)=>new Mr(t.name??"Comp",po(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{raw:nf,raw:hf}=String;function uf(t,e){return new _r(t,e)}var So=(t)=>typeof t==="string"?document.querySelector(t):t;function of(t){let e=So(t),r=new be,s=(o)=>new it(o),i=(o)=>new ce(o),n={document},h=(o,f)=>oh(o,f,n),u=new As(r,fh,s,i,h);return new Dr(e,h,r,u,Yt)}export{of as tutuca,sh as seqInfoByClass,uf as macro,Ze as isOrderedMap,Ze as isOMap,re as isMap,kr as isList,z as isKeyed,j as isIndexed,re as isIMap,Wi as injectCss,hf as html,Mh as fieldsByClass,nf as css,zo as component,oe as Record,Yt as ParseContext,B as OMap,W as List,b as ISet,V as IMap};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tutuca",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "type": "module",
5
5
  "description": "Zero-dependency SPA framework with immutable state and virtual DOM",
6
6
  "main": "./dist/tutuca.js",
@@ -11,6 +11,27 @@
11
11
  "./extra": "./dist/tutuca-extra.js",
12
12
  "./package.json": "./package.json"
13
13
  },
14
+ "scripts": {
15
+ "clean": "rm -rf dist",
16
+ "dist": "bun scripts/dist.js",
17
+ "dist-immutable": "bun scripts/dist-immutable.js",
18
+ "dist-all": "bun run dist-immutable && bun run dist",
19
+ "release": "bun run dist-all && npm publish --access public",
20
+ "release-dry": "bun run dist-all && npm publish --dry-run",
21
+ "test": "bun test test/*.test.js",
22
+ "test-watch": "bun test --watch test/*.test.js",
23
+ "format": "bunx @biomejs/biome format --write src test/*.js",
24
+ "lint": "bunx @biomejs/biome lint src test/*.js",
25
+ "lint-fix": "bunx @biomejs/biome lint --write src test/*.js",
26
+ "fix": "bunx @biomejs/biome check --write src test/*.js",
27
+ "render-examples": "bun tools/render-examples.js",
28
+ "component-api-docs": "bun tools/component-api-docs.js",
29
+ "vdom-stresstest": "bun tools/vdom-stresstest.js",
30
+ "smoke-test-cli-render-examples": "bun tools/render-examples.js ./test/todo.js && bun tools/render-examples.js ./test/json.js",
31
+ "smoke-test-cli-component-api-docs": "bun tools/component-api-docs.js ./test/todo.js && bun tools/component-api-docs.js ./test/json.js",
32
+ "smoke-test": "bun run smoke-test-cli-render-examples && bun run smoke-test-cli-component-api-docs",
33
+ "sync-playground": "cp src/util/docs.js docs/src/docs.js"
34
+ },
14
35
  "sideEffects": false,
15
36
  "files": [
16
37
  "dist/tutuca.js",