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