tutuca 0.9.12 → 0.9.13
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/dist/tutuca-dev.js +2 -1
- package/dist/tutuca-dev.min.js +1 -1
- package/dist/tutuca-extra.js +2 -1
- package/dist/tutuca-extra.min.js +1 -1
- package/dist/tutuca.js +2 -1
- package/dist/tutuca.min.js +1 -1
- package/package.json +1 -1
package/dist/tutuca-dev.js
CHANGED
|
@@ -1202,7 +1202,8 @@ class RenderNode extends RenderViewId {
|
|
|
1202
1202
|
|
|
1203
1203
|
class RenderItNode extends RenderViewId {
|
|
1204
1204
|
render(stack, rx) {
|
|
1205
|
-
|
|
1205
|
+
const newStack = stack.enter(stack.it, {}, true);
|
|
1206
|
+
return rx.renderIt(newStack, this.nodeId, "", this.viewId);
|
|
1206
1207
|
}
|
|
1207
1208
|
pathInNext = true;
|
|
1208
1209
|
}
|
package/dist/tutuca-dev.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class Qt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class qt extends Qt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new qt({...this.binds,key:t})}withKey(t){return new qt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class Se extends Qt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new gr(this.field,t)}withKey(t){return new yr(this.field,t)}}class lr extends Qt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class yr extends lr{}class gr extends lr{}var J=Symbol("NONE");class dr extends Qt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return s!==J&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return r===J||s===J?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class rt{constructor(t=[]){this.steps=t}concat(t){return new rt(this.steps.concat(t))}popStep(){return new rt(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,J),r===J)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,J),s===J)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,J),r===J)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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:a,si:l,sk:y}=_i(t.previousSibling),{eid:p,cid:S,vid:T}=t.dataset;if(p!==void 0)o.push(p);if(S!==void 0){let et=i.getComponentForId(+S,T);if(_){if(c=Zh(et,o,T,e),c===null&&n)return Gh;_=!1}let ci=Xh(et,f,T);if(ci)h.push(ci);o=[],f=[]}if(a!==void 0)f.push({nid:a,si:l,sk:y})}u+=1,t=t.parentNode}return[new rt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return rt.fromNodeAndEventName(h,n,e,r,s,i)}}var fi={};function _i(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=_i(t.previousSibling);if(e!==fi)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return fi}function Zh(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 Xh(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],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Gh=[null,null];class pr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new Se(t))}index(t,e){return this.add(new gr(t,e))}key(t,e){return this.add(new yr(t,e))}}var Hh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ot=(t)=>Hh.test(t),Qh=/^-?[0-9]+(\.[0-9]+)?$/,ai=(t,e)=>zr.parse(t,e),Yt=(t,e)=>new L(t),Yh=(t,e)=>ot(t)?new k(t):null,Bh=(t,e)=>ot(t)?new qe(t):null,Ph=(t,e)=>ot(t)?new Or(t):null,Ch=(t,e)=>ot(t)?new di(t):null,xh=(t,e)=>ot(t)?new je(t):null,Fh=(t,e)=>ot(t)?new Ie(t):null,kh=(t,e)=>ot(t)?new Ee(t):null;class li{constructor(){this.allowFieldOnly(),this.bindValIt=new Or("it"),this.nullConstVal=new L(null)}const(t){return new L(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}_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 Ae(s,i):null}parse(t,e){switch(Vh(t)){case pi:return this.okStrTpl?ai(t,e):null;case zi:return this.okStrTpl?Yt(t,e):null;case wi:return this._parseSeqAccess(t,e);case Oe:return this.okStrTpl?ai(t,e):null}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.okStrTpl?Yt(t.slice(1),e):null;case 39:return this.okStrTpl?Yt(t.slice(1,-1),e):null;case 64:return this.okBind?Ph(t.slice(1),e):null;case 42:return this.okDyn?Ch(t.slice(1),e):null;case 46:return this.okField?xh(t.slice(1),e):null;case 36:return this.okComputed?Fh(t.slice(1),e):null;case 33:return this.okRequest?kh(t.slice(1),e):null}let s=Qh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.okConst?Yt(s,e):null;else if(t==="true"||t==="false")return this.okConst?Yt(t==="true",e):null;else if(r>=97&&r<=122)return this.okName?Yh(t,e):null;else if(r>=65&&r<=90)return this.okType?Bh(t,e):null;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,be)}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 Me{render(t,e){}eval(t){}toPathItem(){return null}}class L extends Me{constructor(t){super();this.val=t}render(t,e){return this.val}eval(t){return this.val}toString(){let t=this.val;return typeof t==="string"?`'${t}'`:`${t}`}}class wr extends Me{}class zr extends wr{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)==="}"?d.parseText(h.slice(1,-1),e):new L(h);s[n]=o,i&&=o instanceof L}return i?new L(s.map((n)=>n.val).join("")):new zr(s)}}class k extends wr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class be extends k{eval(t){return t.getHandlerFor(this.name,"input")??gi("input",this.name)}}class yi extends k{eval(t){return t.getHandlerFor(this.name,"alter")??gi("alter",this.name)}}var gi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class qe extends k{eval(t){return t.lookupType(this.name)}}class Ee extends k{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Bt extends k{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class Sr extends Me{render(t,e){return this.eval(t)}}class Pt extends Sr{constructor(t){super();this.name=t}}class Or extends Pt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class di extends Pt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class je extends Pt{eval(t){return t.lookupField(this.name)}toPathItem(){return new Se(this.name)}toRawFieldVal(){return new Bt(this.name)}toString(){return`.${this.name}`}}class Ie extends Pt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ae extends Sr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new dr(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 pi=0,wi=1,Oe=2,zi=3;function Vh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return Oe;e+=1;break;case 93:if(r>0||e===0)return Oe;r+=1;break;case 123:return pi;case 125:return zi}if(e>0||r>0)return e===1&&r===1?wi:Oe;return-1}var d=new li;class Et{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return Er(e).parse(t,r)}isConstant(){return!1}}var Nh="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",mh=new Set(Nh.split(","));class Si{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?d.parseAll(e,this.px):d.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new jt(t,s)),this.hasDynamic||=!(s instanceof L)}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=d.parseCondValue(e,this.px);if(r)this.ifAttr=new Mi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=d.parseAttr(t,this.px)??Ct}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=d.parseAttr(t,this.px)??Ct}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=jr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new $e("data-eid",d.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new Oi(d.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,d.const(t));return;case"push-view":this.pushWrapper("push-view",t,d.parseText(t,this.px));return;case"text":this.textChild=d.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,d.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,d.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,d.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=d.parseAlter(t,this.px);else this.pushWrapper("scope",t,d.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=d.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=d.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===""&&mh.has(n)?!0:h;this.attrs.push(new $e(n,d.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new Ke(r):br.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class br extends Et{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.val.eval(null);return new br(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 Ke extends Et{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 $e(t,new L(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.val.toString();return t}}class qr{constructor(t){this.name=t}}class jt extends qr{constructor(t,e){super(t);this.val=e}eval(t){return this.val.eval(t)}}class $e extends jt{}class Oi extends jt{constructor(t){super("dangerouslySetInnerHTML",t??d.nullConstVal)}eval(t){return{__html:`${this.val.eval(t)}`}}}var Ct=d.nullConstVal;class Mi extends qr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ct}get anyBranchIsSet(){return this.thenVal!==Ct||this.elseVal!==Ct}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var Mr=null;function Er(t){return Mr??=new Si(t),Mr.clear(t),Mr}class jr{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=d.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);d.allowHandlerArg();for(let h=0;h<s.length;h++){let u=d.parse(s[h],e);n[h]=u!==null?u:d.nullConstVal}return new jr(i,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 It{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 kt extends It{constructor(t){super();this.val=t}render(t,e){return e.renderText(this.val)}isWhiteSpace(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.val=""}isConstant(){return!0}setDataAttr(t,e){}}class Ft extends kt{render(t,e){return e.renderComment(this.val)}}function vh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Dr(r);else r.optimize()}}function Kr(t){if(t.isConstant())return new Dr(t);return t.optimize(),t}class Ur extends It{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){vh(this.childs)}}class Ue extends Ur{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 Le extends Ur{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 xt=(t)=>t.length===1?t[0]:new Le(t),tu=/^[a-zA-Z][a-zA-Z0-9-]*$/,bi=null;class st extends It{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){bi??=e.newDOMParser();let r=bi.parseFromString(t,"text/html").body.childNodes;return st.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new kt(t.textContent);else if(e.isCommentNode(t))return new Ft(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=st.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return xt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Re(null,d.const(u),xt(n));case"text":{let c=d.parseText(u,e);return c!==null?new $r(null,c):null}case"render":return e.addNodeIf(Ki,d.parseRender(u,e),o);case"render-it":return e.addNodeIf(We,d.bindValIt,o);case"render-each":return Vt.parse(e,d,u,o,s);case"show":return e.addNodeIf(Wr,d.parseCondValue(u,e),xt(n));case"hide":return e.addNodeIf(Rr,d.parseCondValue(u,e),xt(n))}return new Ft(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??xt(n)}let[u,o]=Et.parse(s,e,!0);return e.onAttributes(u,o,null),qi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(tu.test(i)){let[h,u,o]=Et.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new $r(null,o));let c=i!=="PRE"?nu(n):n;return qi(new Ue(i.toLowerCase(),h,c),e,u)}return new Ft(`Error: InvalidTagName ${i}`)}}function qi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=eu(r[s],e);if(i)i.wrapNode(t),t=i}return t}function eu(t,e){let r=iu[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 $i extends It{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 Ft(`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=Kr(this.node)}}class Lr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return st.parse(this.rawView,t)}}class De extends st{constructor(t,e,r){super(t,e);this.viewId=r}}class Ki extends De{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class We extends De{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Vt extends De{constructor(t,e,r){super(t,e,r);this.iterInfo=new Tr(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(Vt,e.parseEach(r,t),s);if(n!==null){let h=Er(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 $r extends st{render(t,e){return e.renderText(this.val.eval(t))}}class Dr extends It{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 ct extends st{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=Kr(this.node)}static register=!1}class Wr extends ct{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Rr extends ct{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Ui extends ct{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Re extends ct{optimize(){this.node.optimize()}}class Li extends ct{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 qt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Te extends ct{constructor(t,e){super(t,e);this.iterInfo=new Tr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new qt({})}static register=!0}class Tr{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)??ru,s=this.loopWithVal?.eval(t)??su,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var ru=(t,e,r)=>!0,su=(t)=>({seq:t}),iu={slot:Re,show:Wr,hide:Rr,each:Te,scope:Li,"push-view":Ui};class V{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 V(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 Di(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Le(s)};for(let h of r)if(h instanceof Re)i[h.val.val]=h.node;else if(!(h instanceof kt)||!h.isWhiteSpace())s.push(h);let n=new $i(t,e,i,this);return this.macroNodes.push(n),n}compile(t){for(let e=0;e<this.macroNodes.length;e++)this.macroNodes[e].compile(t)}*genEventNames(){for(let t of this.events)yield*t.genEventNames()}getEventForId(t){return this.events[t]??null}getNodeForId(t){return this.nodes[t]??null}onAttributes(t,e,r){}}var Ar=(t)=>t instanceof kt&&t.isWhiteSpace(),Ei=(t)=>t instanceof Ue||t instanceof Le&&t.childs[0]instanceof Ue;function nu(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(Ar(t[0]))r=1,s=!0;if(e>1&&Ar(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(Ar(n)&&Ei(t[i-1])&&Ei(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Je{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=st.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=Kr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Di{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Wi(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 Wi{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=fu(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 hu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ze=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,ji=(t)=>Ze((e)=>e.e.key===t),Ii=Ze(({e:t})=>hu&&t.metaKey||t.ctrlKey),uu=Ze(({e:t})=>t.metaKey),ou=Ze(({e:t})=>t.altKey),Ai={ctrl:Ii,cmd:Ii,meta:uu,alt:ou},Jr={keydown:{send:ji("Enter"),cancel:ji("Escape"),...Ai},click:{...Ai}},cu=(t,e)=>t;function fu(t,e){if(e.length===0)return cu;let r=Jr[t]??{},s=(i,n,h,u)=>n.apply(i,h);for(let i of e){let n=r[i];if(n!==void 0)s=n(s)}return(i,n)=>function(...h){return s(this,i,h,n)}}class Zr{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,s){}evict(){return{hit:0,miss:0,badKey:0}}}class Xr{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 Gr{getKey(t,e,r){return r.call(t)}}class Hr{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 Xe{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Hr}setNullComputedCache(){this.computedCache=new Gr}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:Ti}getHandlerFor(t,e,r){return this.getCompFor(t)?.[r][e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getHandlerFor(t,e,"computed");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(`
|
|
1
|
+
class Qt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class qt extends Qt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new qt({...this.binds,key:t})}withKey(t){return new qt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class Se extends Qt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new gr(this.field,t)}withKey(t){return new yr(this.field,t)}}class lr extends Qt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class yr extends lr{}class gr extends lr{}var J=Symbol("NONE");class dr extends Qt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return s!==J&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return r===J||s===J?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class rt{constructor(t=[]){this.steps=t}concat(t){return new rt(this.steps.concat(t))}popStep(){return new rt(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,J),r===J)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,J),s===J)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,J),r===J)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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:a,si:l,sk:y}=_i(t.previousSibling),{eid:p,cid:S,vid:T}=t.dataset;if(p!==void 0)o.push(p);if(S!==void 0){let et=i.getComponentForId(+S,T);if(_){if(c=Zh(et,o,T,e),c===null&&n)return Gh;_=!1}let ci=Xh(et,f,T);if(ci)h.push(ci);o=[],f=[]}if(a!==void 0)f.push({nid:a,si:l,sk:y})}u+=1,t=t.parentNode}return[new rt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return rt.fromNodeAndEventName(h,n,e,r,s,i)}}var fi={};function _i(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=_i(t.previousSibling);if(e!==fi)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return fi}function Zh(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 Xh(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],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Gh=[null,null];class pr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new Se(t))}index(t,e){return this.add(new gr(t,e))}key(t,e){return this.add(new yr(t,e))}}var Hh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ot=(t)=>Hh.test(t),Qh=/^-?[0-9]+(\.[0-9]+)?$/,ai=(t,e)=>zr.parse(t,e),Yt=(t,e)=>new L(t),Yh=(t,e)=>ot(t)?new k(t):null,Bh=(t,e)=>ot(t)?new qe(t):null,Ph=(t,e)=>ot(t)?new Or(t):null,Ch=(t,e)=>ot(t)?new di(t):null,xh=(t,e)=>ot(t)?new je(t):null,Fh=(t,e)=>ot(t)?new Ie(t):null,kh=(t,e)=>ot(t)?new Ee(t):null;class li{constructor(){this.allowFieldOnly(),this.bindValIt=new Or("it"),this.nullConstVal=new L(null)}const(t){return new L(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}_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 Ae(s,i):null}parse(t,e){switch(Vh(t)){case pi:return this.okStrTpl?ai(t,e):null;case zi:return this.okStrTpl?Yt(t,e):null;case wi:return this._parseSeqAccess(t,e);case Oe:return this.okStrTpl?ai(t,e):null}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.okStrTpl?Yt(t.slice(1),e):null;case 39:return this.okStrTpl?Yt(t.slice(1,-1),e):null;case 64:return this.okBind?Ph(t.slice(1),e):null;case 42:return this.okDyn?Ch(t.slice(1),e):null;case 46:return this.okField?xh(t.slice(1),e):null;case 36:return this.okComputed?Fh(t.slice(1),e):null;case 33:return this.okRequest?kh(t.slice(1),e):null}let s=Qh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.okConst?Yt(s,e):null;else if(t==="true"||t==="false")return this.okConst?Yt(t==="true",e):null;else if(r>=97&&r<=122)return this.okName?Yh(t,e):null;else if(r>=65&&r<=90)return this.okType?Bh(t,e):null;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,be)}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 Me{render(t,e){}eval(t){}toPathItem(){return null}}class L extends Me{constructor(t){super();this.val=t}render(t,e){return this.val}eval(t){return this.val}toString(){let t=this.val;return typeof t==="string"?`'${t}'`:`${t}`}}class wr extends Me{}class zr extends wr{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)==="}"?d.parseText(h.slice(1,-1),e):new L(h);s[n]=o,i&&=o instanceof L}return i?new L(s.map((n)=>n.val).join("")):new zr(s)}}class k extends wr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class be extends k{eval(t){return t.getHandlerFor(this.name,"input")??gi("input",this.name)}}class yi extends k{eval(t){return t.getHandlerFor(this.name,"alter")??gi("alter",this.name)}}var gi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class qe extends k{eval(t){return t.lookupType(this.name)}}class Ee extends k{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Bt extends k{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class Sr extends Me{render(t,e){return this.eval(t)}}class Pt extends Sr{constructor(t){super();this.name=t}}class Or extends Pt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class di extends Pt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class je extends Pt{eval(t){return t.lookupField(this.name)}toPathItem(){return new Se(this.name)}toRawFieldVal(){return new Bt(this.name)}toString(){return`.${this.name}`}}class Ie extends Pt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ae extends Sr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new dr(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 pi=0,wi=1,Oe=2,zi=3;function Vh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return Oe;e+=1;break;case 93:if(r>0||e===0)return Oe;r+=1;break;case 123:return pi;case 125:return zi}if(e>0||r>0)return e===1&&r===1?wi:Oe;return-1}var d=new li;class Et{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return Er(e).parse(t,r)}isConstant(){return!1}}var Nh="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",mh=new Set(Nh.split(","));class Si{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?d.parseAll(e,this.px):d.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new jt(t,s)),this.hasDynamic||=!(s instanceof L)}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=d.parseCondValue(e,this.px);if(r)this.ifAttr=new Mi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=d.parseAttr(t,this.px)??Ct}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=d.parseAttr(t,this.px)??Ct}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=jr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new $e("data-eid",d.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new Oi(d.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,d.const(t));return;case"push-view":this.pushWrapper("push-view",t,d.parseText(t,this.px));return;case"text":this.textChild=d.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,d.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,d.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,d.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=d.parseAlter(t,this.px);else this.pushWrapper("scope",t,d.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=d.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=d.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===""&&mh.has(n)?!0:h;this.attrs.push(new $e(n,d.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new Ke(r):br.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class br extends Et{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.val.eval(null);return new br(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 Ke extends Et{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 $e(t,new L(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.val.toString();return t}}class qr{constructor(t){this.name=t}}class jt extends qr{constructor(t,e){super(t);this.val=e}eval(t){return this.val.eval(t)}}class $e extends jt{}class Oi extends jt{constructor(t){super("dangerouslySetInnerHTML",t??d.nullConstVal)}eval(t){return{__html:`${this.val.eval(t)}`}}}var Ct=d.nullConstVal;class Mi extends qr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ct}get anyBranchIsSet(){return this.thenVal!==Ct||this.elseVal!==Ct}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var Mr=null;function Er(t){return Mr??=new Si(t),Mr.clear(t),Mr}class jr{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=d.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);d.allowHandlerArg();for(let h=0;h<s.length;h++){let u=d.parse(s[h],e);n[h]=u!==null?u:d.nullConstVal}return new jr(i,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 It{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 kt extends It{constructor(t){super();this.val=t}render(t,e){return e.renderText(this.val)}isWhiteSpace(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.val=""}isConstant(){return!0}setDataAttr(t,e){}}class Ft extends kt{render(t,e){return e.renderComment(this.val)}}function vh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Dr(r);else r.optimize()}}function Kr(t){if(t.isConstant())return new Dr(t);return t.optimize(),t}class Ur extends It{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){vh(this.childs)}}class Ue extends Ur{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 Le extends Ur{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 xt=(t)=>t.length===1?t[0]:new Le(t),tu=/^[a-zA-Z][a-zA-Z0-9-]*$/,bi=null;class st extends It{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){bi??=e.newDOMParser();let r=bi.parseFromString(t,"text/html").body.childNodes;return st.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new kt(t.textContent);else if(e.isCommentNode(t))return new Ft(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=st.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return xt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Re(null,d.const(u),xt(n));case"text":{let c=d.parseText(u,e);return c!==null?new $r(null,c):null}case"render":return e.addNodeIf(Ki,d.parseRender(u,e),o);case"render-it":return e.addNodeIf(We,d.bindValIt,o);case"render-each":return Vt.parse(e,d,u,o,s);case"show":return e.addNodeIf(Wr,d.parseCondValue(u,e),xt(n));case"hide":return e.addNodeIf(Rr,d.parseCondValue(u,e),xt(n))}return new Ft(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??xt(n)}let[u,o]=Et.parse(s,e,!0);return e.onAttributes(u,o,null),qi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(tu.test(i)){let[h,u,o]=Et.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new $r(null,o));let c=i!=="PRE"?nu(n):n;return qi(new Ue(i.toLowerCase(),h,c),e,u)}return new Ft(`Error: InvalidTagName ${i}`)}}function qi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=eu(r[s],e);if(i)i.wrapNode(t),t=i}return t}function eu(t,e){let r=iu[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 $i extends It{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 Ft(`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=Kr(this.node)}}class Lr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return st.parse(this.rawView,t)}}class De extends st{constructor(t,e,r){super(t,e);this.viewId=r}}class Ki extends De{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class We extends De{render(t,e){let r=t.enter(t.it,{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}pathInNext=!0}class Vt extends De{constructor(t,e,r){super(t,e,r);this.iterInfo=new Tr(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(Vt,e.parseEach(r,t),s);if(n!==null){let h=Er(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 $r extends st{render(t,e){return e.renderText(this.val.eval(t))}}class Dr extends It{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 ct extends st{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=Kr(this.node)}static register=!1}class Wr extends ct{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Rr extends ct{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Ui extends ct{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Re extends ct{optimize(){this.node.optimize()}}class Li extends ct{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 qt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Te extends ct{constructor(t,e){super(t,e);this.iterInfo=new Tr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new qt({})}static register=!0}class Tr{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)??ru,s=this.loopWithVal?.eval(t)??su,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var ru=(t,e,r)=>!0,su=(t)=>({seq:t}),iu={slot:Re,show:Wr,hide:Rr,each:Te,scope:Li,"push-view":Ui};class V{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 V(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 Di(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Le(s)};for(let h of r)if(h instanceof Re)i[h.val.val]=h.node;else if(!(h instanceof kt)||!h.isWhiteSpace())s.push(h);let n=new $i(t,e,i,this);return this.macroNodes.push(n),n}compile(t){for(let e=0;e<this.macroNodes.length;e++)this.macroNodes[e].compile(t)}*genEventNames(){for(let t of this.events)yield*t.genEventNames()}getEventForId(t){return this.events[t]??null}getNodeForId(t){return this.nodes[t]??null}onAttributes(t,e,r){}}var Ar=(t)=>t instanceof kt&&t.isWhiteSpace(),Ei=(t)=>t instanceof Ue||t instanceof Le&&t.childs[0]instanceof Ue;function nu(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(Ar(t[0]))r=1,s=!0;if(e>1&&Ar(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(Ar(n)&&Ei(t[i-1])&&Ei(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Je{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=st.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=Kr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Di{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Wi(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 Wi{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=fu(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 hu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ze=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,ji=(t)=>Ze((e)=>e.e.key===t),Ii=Ze(({e:t})=>hu&&t.metaKey||t.ctrlKey),uu=Ze(({e:t})=>t.metaKey),ou=Ze(({e:t})=>t.altKey),Ai={ctrl:Ii,cmd:Ii,meta:uu,alt:ou},Jr={keydown:{send:ji("Enter"),cancel:ji("Escape"),...Ai},click:{...Ai}},cu=(t,e)=>t;function fu(t,e){if(e.length===0)return cu;let r=Jr[t]??{},s=(i,n,h,u)=>n.apply(i,h);for(let i of e){let n=r[i];if(n!==void 0)s=n(s)}return(i,n)=>function(...h){return s(this,i,h,n)}}class Zr{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,s){}evict(){return{hit:0,miss:0,badKey:0}}}class Xr{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 Gr{getKey(t,e,r){return r.call(t)}}class Hr{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 Xe{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Hr}setNullComputedCache(){this.computedCache=new Gr}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:Ti}getHandlerFor(t,e,r){return this.getCompFor(t)?.[r][e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getHandlerFor(t,e,"computed");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
2
|
`)}}class Ge{constructor(t=new Xe,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ge(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 Ir(e,t[e])}lookupRequest(t){return this.reqsByName[t]??this.parent?.lookupRequest(t)??null}lookupComponent(t){return this.byName[t]??this.parent?.lookupComponent(t)??null}lookupMacro(t){return this.macros[t]??this.parent?.lookupMacro(t)??null}}class Qr{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 Ri extends Qr{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 At=(t)=>typeof t==="string",_u=0;class Yr{constructor(t,e,r,s={},i="",n="",h="",u={},o={},c={},f={},_={},a={},l={},y={}){this.id=_u++,this.name=t,this.Class=e,this.views={main:new Je("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=c,this.bubble=f,this.response=_,this.alter=a,this.on={stackEnter:y?.stackEnter??Ti};for(let p in s){let S=s[p],{view:T,style:et}=At(S)?{view:S}:S;this.views[p]=new Je(p,T,et)}this._rawDynamic=l,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(At(r)){let s=d.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Qr(e,s,Symbol(e))}else if(At(r?.default)&&At(r?.for)){let s=d.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(At(i)&&At(n))this.dynamic[e]=new Ri(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
3
|
`)}}function Ti(t){return t}var Ji=Symbol("STOP"),Cr=Symbol("NEXT");class Nt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Nt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Ji?e:s===Cr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Br{constructor(t,e,r){this.it=t,this.bindings=e,this.isFrame=r}lookup(t){let e=this.bindings[t];return e===void 0?this.isFrame?Ji:Cr:e}}class Pr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Cr:e}}class H{constructor(t,e,r,s,i,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=s,this.views=i,this.ctx=n;let h=[...i].join("");this.viewsId=h==="main"?"":h}_enrichOnEnter(){return this.comps.getOnEnterFor(this.it).call(this.it,this)??this}upToFrameBinds(){let{comps:t,binds:e,dynBinds:r,views:s,ctx:i}=this;return e.head.isFrame?this:new H(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Nt(new Br(e,{it:e},!0),null),i=new Nt(new Pr({}),null),n=new Nt("main",null);return new H(t,e,s,i,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:s,binds:i,dynBinds:n,views:h,ctx:u}=this,o=i.push(new Br(t,e,r));return new H(s,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:s,dynBinds:i,views:n,ctx:h}=this;return new H(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Pr(e));return new H(s,i,n,o,h,u)}lookupDynamic(t){let e=this.comps.getCompFor(this.it)?.dynamic[t];return e?this.dynBinds.lookup(e.getSymbol(this))??e.val.eval(this):null}lookupBind(t){return this.binds.lookup(t)}lookupType(t){return this.comps.getCompFor(this.it).scope.lookupComponent(t)}lookupFieldRaw(t){return this.it[t]??null}lookupField(t){let e=this.lookupFieldRaw(t);return e instanceof Function?e.call(this.it):e}lookupName(t){return this.ctx.lookupName(t)}lookupComputed(t){let e=this.binds.head.isFrame?this.binds.head:this.binds.tail.head;return this.comps.lookupComputed(e.it,t)}getHandlerFor(t,e){return this.comps.getHandlerFor(this.it,t,e)}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 Xi{constructor(t){this.val=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.val;this.val=t;for(let s of this.changeSubs)s({val:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.val),e)}}class Fr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Xi(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 Nr(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 Qi(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.val,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??au(e),o=s?.onResName??e,c=(f,_,a,l,y)=>{let S=new Hi(t,this,f??_,f?[a]:[l,y],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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.val,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 Gi(t,e,r,this,s))}}function au(t){return()=>{throw Error(`Request not found: ${t}`)}}function lu(){return this}class kr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parentTransaction=r,this._task=null}get task(){return this._task??=new Yi,this._task}getCompletionPromise(){return this.task.promise}setParent(t){this.parentTransaction=t,t.task.addDep(this.task)}run(t,e){return this.updateRootValue(t,e)}afterTransaction(){}buildRootStack(t,e){return H.root(e,t)}buildStack(t,e){let r=this.path.buildStack(this.buildRootStack(t,e));return r?r.upToFrameBinds():null}callHandler(t,e,r){let[s,i]=this.getHandlerAndArgs(t,e,r);return s.apply(e,i)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),s=this.callHandler(t,r,e);return this._task?.complete?.({value:s,old:r}),r!==s?this.path.setValue(t,s):t}lookupName(t){return null}}var yu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Zi=(t)=>Number.isNaN(t)?null:t;function xr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Gi extends kr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return H.root(e,t,this)}getHandlerAndArgs(t,e,r){let s=this.buildStack(t,r),[i,n]=this.handler.getHandlerAndArgs(s,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new mr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return xr(e);case"valueAsInt":return Zi(parseInt(xr(e),10));case"valueAsFloat":return Zi(parseFloat(xr(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 yu&&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 vr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Vr extends kr{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]??lu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new vr(this.path,this.transactor,this)]]}}class Hi extends Vr{handlerProp="response"}class Nr extends Vr{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 Qi extends Nr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Yi{constructor(t){this.info=t,this.deps=[],this.val=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.val=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class mr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Bi(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 vr extends mr{stopPropagation(){return this.parent.stopPropagation()}}class Bi extends pr{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 ts{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ge(r),this.transactor=new Fr(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,c]=rt.fromEvent(t,i,n,h,u);if(r){let f=gu(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.val,_=o.lookup(f),a=t.target.dataset.dragtype??"?",l=o.buildStack(this.makeStack(f));this.dragInfo=new Pi(o,l,t,_,a,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return H.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.val,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.val!==e.old)this.render()}),He("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 rt([]),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 He(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 gu(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 Pi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.val=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class $t extends V{constructor(...t){super(...t);this.classes=new Set}_addClasses(t){for(let e of t.split(/\s+/))this.classes.add(e)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,f=new $t(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f}onAttributes(t,e,r){if(Array.isArray(t.items))for(let s of t.items){if(s.name!=="class")continue;let{val:i,thenVal:n,elseVal:h}=s;if(n!==void 0)this._maybeAddVal(n),this._maybeAddVal(h);else this._maybeAddVal(i)}else{let s=t.items.class;if(s)this._addClasses(s)}}_maybeAddVal(t){if(!this._maybeAddStrTpl(t)&&typeof t?.val==="string")this._addClasses(t.val)}_maybeAddStrTpl(t){if(t?.vals!==void 0){for(let e of t.vals)if(e instanceof L&&e.val!=="")this._addClasses(e.val);return!0}return!1}}function mt(t,e){if(!t)throw Error(e)}function A(t){mt(t!==1/0,"Cannot perform this action with an infinite size.")}function Ci(t,e,r,s,i,n){return A(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var du=(t,e)=>e,pu=(t,e)=>[e,t],es=(t)=>function(...e){return!t.apply(this,e)},xi=(t)=>function(...e){return-t.apply(this,e)};function yn(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 Fi=(t,e)=>t<e?1:t>e?-1:0,$={done:!0,value:void 0};class gn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function W(t){return new gn(t)}function q(t){let e=[void 0,void 0],r={done:!1,value:void 0};return W(()=>{if(t(e))return r.value=[e[0],e[1]],r;return $})}var wu=W(()=>$),ft=()=>wu;function me(t){let e=0,r={done:!1,value:void 0};return W(()=>{if(e===t)return $;return r.value=e++,r})}function ue(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 gs(t){if(Array.isArray(t))return!0;return!!ve(t)}var zu=(t)=>typeof t?.next==="function";function dn(t){return ve(t)?.call(t)}function ve(t){let e=t?.[Symbol.iterator];if(typeof e==="function")return e}function Su(t){let e=ve(t);return e&&e===t.entries}function Ou(t){let e=ve(t);return e&&e===t.keys}var oe="delete",z=5,E=1<<z,K=E-1,g={},cs=()=>({value:!1});function G(t){if(t)t.value=!0}class tr{}function Lt(t){if(t.size===void 0)t.size=t.__iterate(pn);return t.size}function nt(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?Lt(t)+e:e}var pn=()=>!0,wn=(t)=>t<0||Object.is(t,-0),ce=(t,e,r)=>(t===0&&!wn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),zn=(t,e,r)=>t===void 0?r:wn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Tt=(t,e)=>zn(t,e,0),fe=(t,e)=>zn(t,e,e),Sn="@@__IMMUTABLE_ITERABLE__@@",Ce="@@__IMMUTABLE_KEYED__@@",xe="@@__IMMUTABLE_INDEXED__@@",ht="@@__IMMUTABLE_ORDERED__@@",_e="@@__IMMUTABLE_SEQ__@@",On="@@__IMMUTABLE_LIST__@@",Mn="@@__IMMUTABLE_MAP__@@",bn="@@__IMMUTABLE_SET__@@",qn="@@__IMMUTABLE_STACK__@@",En="@@__IMMUTABLE_RECORD__@@";function F(t,e){return typeof t==="object"&&t!==null&&e in t}var Z=(t)=>F(t,Sn),w=(t)=>F(t,Ce),j=(t)=>F(t,xe),ds=(t)=>w(t)||j(t),x=(t)=>F(t,ht),ps=(t)=>F(t,_e),jn=(t)=>F(t,On),er=(t)=>F(t,Mn),ws=(t)=>F(t,bn),zs=(t)=>F(t,qn),gt=(t)=>F(t,En),P=(t)=>Z(t)||gt(t),Ss=(t)=>er(t)&&x(t),In=(t)=>ws(t)&&x(t),ki=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function An(t){let e=C(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Zt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=(r)=>ue(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s}),e}function $n(t,e,r){let s=C(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,g);return h===g?n:e.call(r,h,i,t)},s.__iterate=function(i,n){return t.__iterate((h,u)=>i(e.call(r,h,u,t),u,this),n)},s.__iteratorUncached=(i)=>ue(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)}),s}function Kn(t,e){let r=C(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=An(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=Zt,r.__iterate=function(s,i){let n=0;if(i)Lt(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)Lt(t);let n=this.size;return ue(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function Un(t,e,r,s){let i=t.size;if(ce(e,r,i))return t;if(i===void 0&&(e<0||r<0))return Un(t.toSeq().cacheResult(),e,r,s);let n=Tt(e,i),u=fe(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=C(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&ps(t)&&o>=0)c.get=function(f,_){return f=nt(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let a=0,l=0;return t.__iterate((y,p)=>{if(a<n){a++;return}if(o!==void 0&&l>=o)return!1;if(l++,f(y,s?p:l-1,this)===!1)return!1},_),l},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ft();let _=t.__iterator(f),a=0,l=0;if(s)return W(()=>{while(a<n)a++,_.next();if(o!==void 0&&l>=o)return $;let y=_.next();if(y.done)return y;return l++,y});return q((y)=>{while(a<n)a++,_.next();if(o!==void 0&&l>=o)return!1;let p=_.next();if(p.done)return!1;return l++,y[0]=l-1,y[1]=p.value[1],!0})},c}function Ut(t,e,r){if(!e)e=yn;let s=w(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?js(n):j(t)?yt(n):te(n)}function Qe(t,e,r){if(!e)e=yn;if(r)return t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Vi(e,i[1],n[1])?n:i)?.[0];return t.reduce((s,i)=>Vi(e,s,i)?i:s)}function Vi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function rs(t,e,r,s){let i=C(t),n=new ae(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let a=m(_);return dn(h?a.reverse():a)}),o=0,c=Array(u.length),f=Array(u.length);return q((_)=>{let a=s;for(let l=0;l<u.length;l++)c[l]=u[l].next(),a=s?a&&c[l].done:a||c[l].done;if(a)return!1;for(let l=0;l<c.length;l++)f[l]=c[l].value;return _[0]=o++,_[1]=e(...f),!0})},i}function Os(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 Ln(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 ut=(t)=>typeof t==="object"&&(P(t)||Array.isArray(t)||Ln(t));function Dn(t){if(Os(t)&&typeof t!=="string")return t;if(x(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var Mu=(t,e)=>P(t)?t.has(e):ut(t)&&Object.hasOwn(t,e);function Wn(t,e,r){return P(t)?t.get(e,r):!Mu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function Ms(t,e,r){let s=Dn(e),i=0;while(i!==s.length)if(t=Wn(t,s[i++],g),t===g)return r;return t}var Rn=(t,e)=>Ms(t,e,g)!==g;function I(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!!(ki(t)&&ki(e)&&t.equals(e))}function Fe(t){if(!t||typeof t!=="object")return t;if(!Z(t)){if(!ut(t))return t;t=v(t)}if(w(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Fe(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Fe(r))}),e}function bs(t,e){if(t===e)return!0;if(!Z(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||w(t)!==w(e)||j(t)!==j(e)||x(t)!==x(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!ds(t);if(x(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&I(c[1],u)&&(r||I(c[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?!I(h,t.get(u,g)):!I(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var rr=(t)=>t>>>1&1073741824|t&3221225471;function Q(t){if(t===null||t===void 0)return Ni(t);if(typeof t.hashCode==="function")return rr(t.hashCode(t));let e=Iu(t);if(e===null||e===void 0)return Ni(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return bu(e);case"string":return e.length>Au?qu(e):fs(e);case"object":case"function":return ju(e);case"symbol":return Eu(e);default:if(typeof e.toString==="function")return fs(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Ni=(t)=>t===null?1108378658:1108378659;function bu(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 rr(e)}function qu(t){let e=ns[t];if(e===void 0){if(e=fs(t),is===$u)is=0,ns={};is++,ns[t]=e}return e}function fs(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return rr(e)}function Eu(t){let e=vi[t];if(e!==void 0)return e;return e=Tn(),vi[t]=e,e}function ju(t){let e=mi.get(t);if(e!==void 0)return e;return e=Tn(),mi.set(t,e),e}var Iu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Tn(){let t=++ss;if(ss&1073741824)ss=0;return t}var mi=new WeakMap,vi=Object.create(null),ss=0,Au=16,$u=255,is=0,ns={};function Ku(t){if(t.size===1/0)return 0;let e=x(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+tn(Q(i),Q(n))|0}:(i,n)=>{s=s+tn(Q(i),Q(n))|0}:e?(i)=>{s=31*s+Q(i)|0}:(i)=>{s=s+Q(i)|0}),Uu(t.size,s)}var tn=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Uu(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=rr(e^e>>>16),e}function vt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:ps(t)?e:t.create?t.create(e):t.constructor(e),Jn=(t,e)=>O(t,(w(t)?Y:j(t)?dt:pt)(e)),en=(...t)=>t,m=(t)=>Z(t)?t:v(t);class b{size=0;static{this.prototype[Sn]=!0,this.prototype.__toStringMapper=vt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return bs(this,t)}hashCode(){return this.__hash??(this.__hash=Ku(this))}toArray(){A(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Qn(this)}toJS(){return Fe(this)}toKeyedSeq(){return new Us(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 Yn(this)}toSeq(){return j(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!Z(s))s=e?Xn(s):Gn(Array.isArray(s)?s:[s]);else if(e)s=Y(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&&w(s)||j(this)&&j(s))return s}return O(this,new Hn(r))}includes(t){return this.some((e)=>I(e,t))}every(t,e){A(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=w(this),i=C(r);if(s)i.has=(n)=>{let h=r.get(n,g);return h!==g&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,g);return u!==g&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return q((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>Jn(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return A(this.size),this.__iterate(e?t.bind(e):t)}join(t){A(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return W(()=>{let r=t.next();if(r.done)return $;return e.value=r.value[0],e})}map(t,e){return O(this,$n(this,t,e))}reduce(t,e=g,r){return Ci(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Ci(this,t,e,r,e===g,!0)}reverse(){return O(this,Kn(this,w(this)))}slice(t,e){return O(this,Un(this,t,e,w(this)))}some(t,e){A(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return O(this,Ut(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return W(()=>{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 Lt(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 ae(t._cache);let e=t.toSeq().map(pu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(es(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){return this.findEntry(t,e)?.[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(pn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(w(this)?Y:j(this)?dt:pt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(this),s=C(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(c,f){c.__iterate((_,a)=>{if((!t||f<t)&&Z(_))o(_,f+1);else if(h++,i(_,r?a: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],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&Z(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},O(this,s)}fromEntrySeq(){return new Bn(this)}get(t,e){return this.find((r,s)=>I(s,t),void 0,e)}getIn(t,e){return Ms(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return Rn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:m(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:m(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>I(e,t))}keySeq(){return this.toSeq().map(du).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Qe(this,t)}maxBy(t,e){return Qe(this,e,t)}min(t){return Qe(this,t?xi(t):Fi)}minBy(t,e){return Qe(this,e?xi(e):Fi,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=w(this),i=C(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return q((f)=>{while(!0){let _=h.next();if(_.done)return!1;let a=_.value[0],l=_.value[1];if(c&&t.call(e,l,a,o))continue;return c=!1,f[0]=s?a:u++,f[1]=l,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(es(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=C(r);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,i(u,o,this)},n),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=r.__iterator(i),h=this,u=!1;return W(()=>{if(u)return $;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,$;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(es(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 Y=(t)=>w(t)?t:js(t);class qs extends b{static{this.prototype[Ce]=!0,this.prototype.__toStringMapper=(t,e)=>`${vt(e)}: ${vt(t)}`,this.prototype[Symbol.iterator]=b.prototype.entries,this.prototype.toJSON=function(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,An(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 dt=(t)=>j(t)?t:yt(t);class lt extends b{static{this.prototype[xe]=!0,this.prototype[ht]=!0}toKeyedSeq(){return new Us(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=Tt(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=nt(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=nt(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)}interpose(t){let e=this,r=C(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(s,i){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(s(t,n++,this)===!1)return!1}return h=!1,s(u,n++,this)},i),n},r.__iteratorUncached=function(s){let i=e.__iterator(s),n=0,h=!0,u,o=!1;return q((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=rs(this.toSeq(),yt.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(en,...t)}zipAll(...t){let e=[this,...t];return O(this,rs(this,en,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,rs(this,t,r))}}var pt=(t)=>Z(t)&&!ds(t)?t:te(t);class sr extends b{static{this.prototype.has=b.prototype.includes,this.prototype.contains=b.prototype.includes,this.prototype.keys=sr.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}m.Keyed=Y;m.Indexed=dt;m.Set=pt;var hs=lt.prototype,v=(t)=>t===void 0||t===null?$s():P(t)?t.toSeq():Lu(t),C=(t)=>Object.create((w(t)?Jt:j(t)?wt:Is).prototype);class _t extends b{static{this.prototype[_e]=!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 W(()=>{if(s===r)return $;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var Es={cacheResult:_t.prototype.cacheResult,__iterateUncached:_t.prototype.__iterateUncached,__iterate:_t.prototype.__iterate,__iterator:_t.prototype.__iterator},js=(t)=>t===void 0||t===null?$s().toKeyedSeq():Z(t)?w(t)?t.toSeq():t.fromEntrySeq():gt(t)?t.toSeq():Xn(t);class Jt extends qs{static{this.prototype[_e]=!0,Object.assign(this.prototype,Es)}toSeq(){return this}toKeyedSeq(){return this}}var yt=(t)=>t===void 0||t===null?$s():Z(t)?w(t)?t.entrySeq():t.toIndexedSeq():gt(t)?t.toSeq().entrySeq():Gn(t);yt.of=(...t)=>yt(t);class wt extends lt{static{this.prototype[_e]=!0,Object.assign(this.prototype,Es)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var te=(t)=>(Z(t)&&!ds(t)?t:yt(t)).toSetSeq();te.of=(...t)=>te(t);class Is extends sr{static{this.prototype[_e]=!0,Object.assign(this.prototype,Es)}toSeq(){return this}toSetSeq(){return this}}v.isSeq=ps;v.Keyed=js;v.Set=te;v.Indexed=yt;class ae extends wt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[nt(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 As extends Jt{static{this.prototype[ht]=!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 Zn 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=dn(e);if(!zu(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 ae([]),Ks=(t)=>Os(t)?new ae(t):gs(t)?new Zn(t):void 0;function Xn(t){let e=Ks(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new As(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Gn(t){let e=Ks(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Lu(t){let e=Ks(t);if(e)return Su(t)?e.fromEntrySeq():Ou(t)?e.toSetSeq():e;if(typeof t==="object")return new As(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Hn extends _t{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[Ce])this[Ce]=!0;if(i[xe])this[xe]=!0;if(i[ht])this[ht]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!w(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=!w(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 W(()=>n()||$)}}class Us extends Jt{static{this.prototype[ht]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Zt.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=Kn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=$n(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 Qn extends wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)Lt(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)Lt(this);let r=this.size;return ue(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Yn extends Is{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.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 ue(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Bn extends Jt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){rn(s),r++;let i=Z(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){rn(i);let n=Z(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Zt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return _t.prototype.cacheResult.call(this)}function rn(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var R=(t)=>t===void 0||t===null?B():er(t)&&!x(t)?t:B().withMutations((e)=>{let r=Y(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});class ee extends qs{static{St(this,{asImmutable:ge,asMutable:de,deleteIn:Dt,merge:_s,mergeWith:Nn,mergeDeep:vn,mergeDeepWith:th,mergeDeepIn:Qs,mergeIn:Hs,setIn:Zs,update:Xs,updateIn:Gs,wasAltered:Js,withMutations:pe,removeIn:Dt,concat:_s,[Mn]:!0,[oe]: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 R(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,Q(t),t,e):e}set(t,e){return nn(this,t,e)}remove(t){return nn(this,t,g)}deleteAll(t){let e=m(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 B()}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 Ye(this._root,!1,0)}values(){if(!this._root)return ft();return Ye(this._root,!1,1)}entries(){if(!this._root)return ft();return Ye(this._root,!1)}__iterator(t){if(!this._root)return ft();return Ye(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 B();return this.__ownerID=t,this.__altered=!1,this}return Ws(this.size,this._root,t,this.__hash)}}R.isMap=er;class Ls{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Pn(this.entries,r,s)}iterate(t,e){return Cn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===g,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(G(h),u||!_)G(n);if(u&&f===1)return;if(!_&&!u&&f>=Zu)return Du(t,o,s,i);let a=t&&t===this.ownerID,l=a?o:o.slice();if(_)if(u)if(c===f-1)l.pop();else l[c]=l.pop();else l[c]=[s,i];else l.push([s,i]);if(a)return this.entries=l,this;return new Ls(t,l)}}class ir{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return xn(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[un(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===g)return this;let _=un(c&o-1),a=this.nodes,l=f?a[_]:void 0,y=Rs(l,t,e+z,r,s,i,n,h);if(y===l)return this;if(!f&&y&&a.length>=Xu)return Ru(t,a,c,u,y);if(f&&!y&&a.length===2&&hn(a[_^1]))return a[_^1];if(f&&y&&a.length===1&&hn(y))return y;let p=t&&t===this.ownerID,S=f?y?c:c^o:c|o,T=f?y?Fn(a,_,y,p):Ju(a,_,p):Tu(a,_,y,p);if(p)return this.bitmap=S,this.nodes=T,this;return new ir(t,S,T)}}class Ds{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return xn(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+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=i===g,c=this.nodes,f=c[u];if(o&&!f)return this;let _=Rs(f,t,e+z,r,s,i,n,h);if(_===f)return this;let a=this.count;if(!f)a++;else if(!_){if(a--,a<Gu)return Wu(t,c,a,u)}let l=t&&t===this.ownerID,y=Fn(c,u,_,l);if(l)return this.count=a,this.nodes=y,this;return new Ds(t,a,y)}}class nr{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Pn(this.entries,r,s)}iterate(t,e){return Cn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return G(h),G(n),Ts(this,t,e,r,[s,i])}let u=i===g,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(G(h),u||!_)G(n);if(u&&f===2)return new zt(t,this.keyHash,o[c^1]);let a=t&&t===this.ownerID,l=a?o:o.slice();if(_)if(u)if(c===f-1)l.pop();else l[c]=l.pop();else l[c]=[s,i];else l.push([s,i]);if(a)return this.entries=l,this;return new nr(t,this.keyHash,l)}}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 I(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(G(h),u){G(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new zt(t,this.keyHash,[s,i])}return G(n),Ts(this,t,e,Q(s),[s,i])}}function Pn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(I(e,t[s][0]))return t[s][1];return r}function Cn(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 xn(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 Ye(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 W(()=>{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 c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return $})}var Ws=(t,e,r,s)=>new ee(t,e,r,s),sn,B=()=>sn||(sn=Ws(0));function nn(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new Ls(t.__ownerID,[[e,r]])}else{let n=cs(),h=cs();if(s=Rs(t._root,t.__ownerID,0,Q(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?Ws(i,s):B()}function Rs(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return G(u),G(h),new zt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var hn=(t)=>t.constructor===zt||t.constructor===nr;function Ts(t,e,r,s,i){if(t.keyHash===s)return new nr(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?[Ts(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new ir(e,1<<n|1<<h,o)}function Du(t,e,r,s){if(!t)t=new tr;let i=new zt(t,Q(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,Q(n),n,h);return i}function Wu(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new ir(t,i,h)}function Ru(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 Ds(t,n+1,h)}function un(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 Fn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Tu(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 Zu=E/4,Xu=E/2,Gu=E/4;function ke(t){if(Array.isArray(t))return t.slice();return{...t}}var Tc=(t,...e)=>ye(t,e),Jc=(t,e,...r)=>ye(e,r,t),le=(t,e,r)=>ye(t,e,Hu(r)),Zc=(t,...e)=>le(t,e),Xc=(t,e,...r)=>le(e,r,t);function ye(t,e,r){if(!ut(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(P(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?dt:Y,h=s?(u)=>{if(i===t)i=ke(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=ke(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Hu(t){function e(r,s,i){return ut(r)&&ut(s)&&Qu(r,s)?ye(r,[s],e):t?t(r,s,i):s}return e}function Qu(t,e){let r=v(t),s=v(e);return j(r)===j(s)&&w(r)===w(s)}function Yu(t,e){if(!ut(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=ke(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Bu(t,e,r){if(!ut(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=ke(t);return s[e]=r,s}function Xt(t,e,r,s){if(!s)s=r,r=void 0;let i=kn(P(t),t,Dn(e),0,r,s);return i===g?r:i}function kn(t,e,r,s,i,n){let h=e===g;if(s===r.length){let _=h?i:e,a=n(_);return a===_?e:a}if(!h&&!ut(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(vt)}]: ${e}`);let u=r[s],o=h?g:Wn(e,u,g),c=kn(o===g?t:P(o),o,r,s+1,i,n);if(c===o)return e;if(c===g)return Yu(e,u);let f=h?t?B():{}:e;return Bu(f,u,c)}var Pu=(t,e)=>Xt(t,e,()=>g),Cu=(t,e,r)=>Xt(t,e,g,()=>r);function Vn(t,e,r,s){return Xt(t,[e],r,s)}function ge(){return this.__ensureOwner()}function de(){return this.__ownerID?this:this.__ensureOwner(new tr)}function Js(){return this.__altered}function pe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function xu(t,e){return Ms(this,t,e)}function Fu(t){return Rn(this,t)}function Dt(t){return Pu(this,t)}function Zs(t,e){return Cu(this,t,e)}function Xs(t,e,r){return typeof t==="function"?t(this):Vn(this,t,e,r)}function Gs(t,e,r){return Xt(this,t,e,r)}function on(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function _s(...t){return mn(this,t)}function Nn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return mn(this,e,t)}function mn(t,e,r){let s=[];for(let i of e){let n=Y(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 gt(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Vn(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 vn(...t){return le(this,t)}function th(t,...e){return le(this,e,t)}function Hs(t,...e){return Xt(this,t,B(),(r)=>ye(r,e))}function Qs(t,...e){return Xt(this,t,B(),(r)=>le(r,e))}function St(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=re();if(t===void 0||t===null)return e;if(jn(t))return t;let r=dt(t),s=r.size;if(s===0)return e;if(A(s),s>0&&s<E)return we(0,s,z,null,new at(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class eh extends lt{static{St(this,{asImmutable:ge,asMutable:de,deleteIn:Dt,mergeDeepIn:Qs,mergeIn:Hs,setIn:Zs,update:Xs,updateIn:Gs,wasAltered:Js,withMutations:pe,removeIn:Dt,[On]:!0,[oe]: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 U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=nt(this,t),t>=0&&t<this.size)return t+=this._origin,ih(this,t)?.array[t&K];return e}set(t,e){return Vu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return re()}push(...t){let e=this.size;return this.withMutations((r)=>{it(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return it(this,0,-1)}unshift(...t){return this.withMutations((e)=>{it(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return it(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=dt(typeof r!=="string"&&gs(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 U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return it(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(ce(t,e,r))return this;return it(this,Tt(t,r),fe(e,r))}__iterate(t,e){let r=e?this.size:0;return ku(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=cn(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 cn(this,!1)}keys(){return me(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return re();return this.__ownerID=t,this.__altered=!1,this}return we(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=jn;class at{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&K;if(s>=this.array.length)return new at([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Wt(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:E)||this.array.length===0)return this;let s=r-1>>>e&K;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Wt(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function cn(t,e){let{_origin:r,_capacity:s}=t,i=Rt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return W(()=>{while(h.length>0){let c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],a=c.level-z,l=c.offset+(f<<c.level);o(_,a,l)}return $});function o(c,f,_){if(f===0){let a=_===i?n?.array:c?.array,l=_>r?0:r-_,y=s-_;if(y>E)y=E;if(l!==y)h.push({array:a,from:l,to:y,isLeaf:!0})}else{let a=c?.array,l=_>r?0:r-_>>f,y=(s-_>>f)+1;if(y>E)y=E;if(l!==y)h.push({array:a,from:l,to:y,level:f,offset:_,isLeaf:!1})}}}function ku(t,e,r){let{_origin:s,_capacity:i}=t,n=Rt(i),h=t._tail,u=t._level,o=t._root;return u===0?rh(o,0,s,i,n,h,e,r):sh(o,u,0,s,i,n,h,e,r)}function rh(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,c=e>r?0:r-e,f=s-e;if(f>E)f=E;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function sh(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let a=e-z;while(f!==_){let l=o?--_:f++,y=r+(l<<e);if((a===0?rh(c?.[l],y,s,i,n,h,u,o):sh(c?.[l],a,y,s,i,n,h,u,o))===!1)return!1}}var we=(t,e,r,s,i,n,h)=>new eh(t,e,r,s,i,n,h),re=()=>we(0,0,z);function Vu(t,e,r){if(e=nt(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)it(h,e).set(0,r);else it(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=cs();if(e>=Rt(t._capacity))s=as(s,t.__ownerID,0,e,r,n);else i=as(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 we(t._origin,t._capacity,t._level,i,s)}function as(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 c=t?.array[h],f=as(c,e,r-z,s,i,n);if(f===c)return t;return o=Wt(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)G(n);if(o=Wt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Wt(t,e){if(e&&e===t?.ownerID)return t;return new at(t?.array.slice()??[],e)}function ih(t,e){if(e>=Rt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&K],s-=z;return r}}function it(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new tr,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:c}=t,f=0;while(h+f<0)c=new at(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=Rt(n),a=Rt(u);while(a>=1<<o+z)c=new at(c?.array.length?[c]:[],s),o+=z;let l=t._tail,y=a<_?ih(t,u-1):a>_?new at([],s):l;if(l&&a>_&&h<n&&l.array.length){c=Wt(c,s);let p=c;for(let S=o;S>z;S-=z){let T=_>>>S&K;p=p.array[T]=Wt(p.array[T],s)}p.array[_>>>z&K]=l}if(u<n)y=y?.removeAfter(s,0,u);if(h>=a)h-=a,u-=a,o=z,c=null,y=y?.removeBefore(s,0,h);else if(h>i||a<_){f=0;while(c){let p=h>>>o&K;if(p!==a>>>o&K)break;if(p)f+=(1<<o)*p;o-=z,c=c.array[p]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&a<_)c=c.removeAfter(s,o,a-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return we(h,u,o,c,y)}var Rt=(t)=>t<E?0:t-1>>>z<<z,D=(t)=>t===void 0||t===null?se():Ss(t)?t:se().withMutations((e)=>{let r=Y(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});D.of=(...t)=>D(t);class nh extends ee{static{St(this,{[ht]:!0,[oe]: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 D(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 se()}set(t,e){return fn(this,t,e)}remove(t){return fn(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 se();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Ys(e,r,t,this.__hash)}}D.isOrderedMap=Ss;var Ys=(t,e,r,s)=>new nh(t,e,r,s),se=()=>Ys(B(),re());function fn(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 c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=re().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=B().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 Ys(u,o)}var ie=(t)=>t===void 0||t===null?Ve():zs(t)?t:Ve().pushAll(t);ie.of=(...t)=>ie(t);class hh extends lt{static{St(this,{asImmutable:ge,asMutable:de,wasAltered:Js,withMutations:pe,[qn]:!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 ie(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=nt(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 us(this,e,r)}pushAll(t){if(t=dt(t),t.size===0)return this;if(this.size===0&&zs(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),us(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 Ve()}slice(t,e){if(ce(t,e,this.size))return this;let r=Tt(t,this.size);if(fe(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 us(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Ve();return this.__ownerID=t,this.__altered=!1,this}return Bs(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 W(()=>{if(!t)return $;return e.value=t.value,t=t.next,e})}keys(){return me(this.size)}}ie.isStack=zs;function us(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Bs(e,r)}var Bs=(t,e,r,s)=>new hh(t,e,r,s),_n,Ve=()=>_n||(_n=Bs(0)),M=(t)=>t===void 0||t===null?he():ws(t)&&!x(t)?t:he().withMutations((e)=>{let r=pt(t);A(r.size),r.forEach((s)=>e.add(s))});M.of=(...t)=>M(t);M.fromKeys=(t)=>M(Y(t).keySeq());M.intersect=(t)=>{return t=m(t).toArray(),t.length?M(t.pop()).intersect(...t):he()};M.union=(t)=>{let e=m(t).toArray();return e.length?M(e.pop()).union(...e):he()};class ne extends sr{static{St(this,{withMutations:pe,asImmutable:ge,asMutable:de,[bn]:!0,[oe]: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 Be(this,this._map.set(t,t))}remove(t){return Be(this,this._map.remove(t))}clear(){return Be(this,this._map.clear())}map(t,e){let r=!1,s=Be(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 ln(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return ln(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return he()}__make(t,e){return uh(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=ws;var uh=(t,e)=>new ne(t,e),an,he=()=>an||(an=uh(B()));function ln(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 Be(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 N=(t)=>t===void 0||t===null?ls():In(t)?t:ls().withMutations((e)=>{let r=pt(t);A(r.size),r.forEach((s)=>e.add(s))});N.of=(...t)=>N(t);N.fromKeys=(t)=>N(Y(t).keySeq());class oh extends ne{static{St(this,{[ht]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:hs.zip,zipWith:hs.zipWith,zipAll:hs.zipAll})}create(t){return N(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return ls()}__make(t,e){return ch(t,e)}}N.isOrderedSet=In;var ch=(t,e)=>new oh(t,e),ls=()=>ch(se()),Gc={LeftThenRight:-1,RightThenLeft:1};function Nu(t){if(gt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(P(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var hr=(t,e)=>{let r;Nu(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 c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Ps(this)} with property "${f}" since that property name is part of the Record API.`);else vu(i,f)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),Y(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(mu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class fh{static{St(this,{asImmutable:ge,asMutable:de,deleteIn:Dt,getIn:xu,hasIn:Fu,merge:_s,mergeWith:Nn,mergeDeep:vn,mergeDeepWith:th,mergeDeepIn:Qs,mergeIn:Hs,setIn:Zs,toObject:on,update:Xs,updateIn:Gs,withMutations:pe,removeIn:Dt,toJSON:on,[En]:!0,[oe]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${vt(this.get(e))}`).join(", ");return`${Ps(this)} { ${t} }`}equals(t){return this===t||gt(t)&&Kt(this).equals(Kt(t))}hashCode(){return Kt(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 os(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:os(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Kt(this)}toJS(){return Fe(this)}entries(){return this.__iterator()}__iterate(t,e){return Kt(this).__iterate(t,e)}__iterator(t){return Kt(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 os(this,e,t)}}hr.isRecord=gt;var Ps=(t)=>t.constructor.displayName||t.constructor.name||"Record";class _h extends Jt{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 Kt=(t)=>new _h(t);hr.getDescriptiveName=Ps;var mu=fh.prototype;function os(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function vu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){mt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var ys=(t,e,r=1)=>{if(mt(r!==0,"Cannot step a Range by 0"),mt(t!==void 0,"You must define a start value when using Range"),mt(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 Cs(t,e,r,s)};class Cs 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+nt(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(ce(t,e,this.size))return this;if(t=Tt(t,this.size),e=fe(e,this.size),e<=t)return ys(0,0);return ys(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 W(()=>{if(s===t)return $;return i.value=r,r+=e,s++,i})}keys(){return me(this.size)}equals(t){return t instanceof Cs?this._start===t._start&&this._end===t._end&&this._step===t._step:bs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Hc=(t,e)=>{let r=e===void 0?1/0:Math.max(0,e);return new Ne(t,r)};class Ne 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 I(this._value,t)}slice(t,e){let r=this.size;return ce(t,e,r)?this:new Ne(this._value,fe(e,r)-Tt(t,r))}reverse(){return this}indexOf(t){if(I(this._value,t))return 0;return-1}lastIndexOf(t){if(I(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 W(()=>{if(r===t)return $;return r++,s.value=e,s})}keys(){return me(this.size)}equals(t){return t instanceof Ne?this.size===t.size&&I(this._value,t._value):bs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Qc=(t,e)=>ah([],e??to,t,"",e?.length>2?[]:void 0,{"":t});function ah(t,e,r,s,i,n){if(typeof r!=="string"&&!P(r)&&(Os(r)||gs(r)||Ln(r))){if(t.includes(r))throw TypeError("Cannot convert circular structure to Immutable");if(t.push(r),i&&s!=="")i.push(s);let h=e.call(n,s,v(r).map((u,o)=>ah(t,e,u,o,i,r)),i?.slice());if(t.pop(),i)i.pop();return h}return r}var to=(t,e)=>j(e)?e.toList():w(e)?e.toMap():e.toSet(),Pe=(t)=>w(t)?t.valueSeq():t;function eo(){b.prototype.toMap=function(){return R(this.toKeyedSeq())},b.prototype.toOrderedMap=function(){return D(this.toKeyedSeq())},b.prototype.toOrderedSet=function(){return N(Pe(this))},b.prototype.toSet=function(){return M(Pe(this))},b.prototype.toStack=function(){return ie(Pe(this))},b.prototype.toList=function(){return U(Pe(this))},b.prototype.countBy=function(e,r){let s=R().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=w(this),i=(x(this)?D():R()).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)=>Jn(this,n)).asImmutable()},lt.prototype.keySeq=function(){return ys(0,this.size)},ee.prototype.sort=function(e){return D(Ut(this,e))},ee.prototype.sortBy=function(e,r){return D(Ut(this,r,e))},ne.prototype.sort=function(e){return N(Ut(this,e))},ne.prototype.sortBy=function(e,r){return N(Ut(this,r,e))}}var ro="7.0.0",so={version:ro};eo();var{version:Yc}=so;var lh=Symbol("BadValue"),ph=(t)=>t;class X{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 Fs{isValid(t){return!0}getMessage(t){return"Invalid"}}class wh extends Fs{}var io=new wh;class tt extends Fs{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var no=new tt((t)=>Number.isInteger(t),()=>"Integer expected"),ho=new tt((t)=>Number.isFinite(t),()=>"Float expected"),uo=new tt((t)=>typeof t==="boolean",()=>"Boolean expected"),oo=new tt((t)=>typeof t==="string",()=>"String expected"),co=new tt((t)=>U.isList(t),()=>"List expected"),fo=new tt((t)=>R.isMap(t),()=>"Map expected"),_o=new tt((t)=>D.isOrderedMap(t),()=>"OrderedMap expected"),ao=new tt((t)=>M.isSet(t),()=>"Set expected"),lo=(t)=>!!t;class ks extends X{constructor(t,e=!1){super("bool",t,uo,lo,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 ur extends X{constructor(t,e=null){super("any",t,io,ph,e)}toDataDef(){let{defaultValue:t}=this;return{type:xs(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var yo=(t)=>t?.toString?.()??"";class Vs extends X{constructor(t,e=""){super("text",t,oo,yo,e)}extendProtoForType(t,e){ei(t,this.name,e,"","length")}}var go=(t)=>Number.isFinite(t)?Math.trunc(t):null;class zh extends X{constructor(t,e=0){super("int",t,no,go,e)}}var po=(t)=>null;class Ns extends X{constructor(t,e=0){super("float",t,ho,po,e)}}var xs=(t)=>t?.constructor?.getMetaClass?.()?.name;class Sh{constructor(t){this.typeName=t}isValid(t){return xs(t)===this.typeName}getMessage(t){let e=xs(t);return`Expected "${this.typeName}", got "${e}"`}}class Oh extends X{constructor(t,e,r){super(t,e,new Sh(t),ph,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var yh=Symbol("NONE");function Gt(t,e,r){ei(t,e,r,bh),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,yh);if(h!==yh)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},Mh(t,e,`${r}At`)}function Mh(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var bh=U(),wo=(t)=>Array.isArray(t)?U(t):null;class ms extends X{constructor(t,e=bh){super("list",t,co,wo,e)}extendProtoForType(t,e){let{name:r}=this;Gt(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 zo=(t)=>R(t);class vs extends X{constructor(t,e=R()){super("map",t,fo,zo,e)}extendProtoForType(t,e){Gt(t,this.name,e)}}var So=(t)=>D(t);class ti extends X{constructor(t,e=D()){super("omap",t,_o,So,e)}extendProtoForType(t,e){Gt(t,this.name,e)}}function ei(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 gh=M(),Oo=(t)=>Array.isArray(t)?M(t):t instanceof Set?M(t):null;class ri extends X{constructor(t,e=gh){super("set",t,ao,Oo,e)}extendProtoForType(t,e){let{name:r}=this;ei(t,r,e,gh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},Mh(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 dh(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 qh{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]=dh(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]=dh(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]:hr(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 Oh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var or=new Map,Mo={text:Vs,int:zh,float:Ns,bool:ks,list:ms,map:vs,omap:ti,set:ri,any:ur};function bo(t,{fields:e={},methods:r,statics:s}){let i=new qh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Vs);else if(u==="number")i.addField(n,h,Ns);else if(u==="boolean")i.addField(n,h,ks);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),ms);else if(M.isSet(h)||h instanceof Set)i.addField(n,M(h),ri);else if(D.isOrderedMap(h))i.addField(n,h,ti);else if(h?.type&&h?.defaultValue!==void 0){let o=Mo[h.type]??ur;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(R.isMap(h)||h?.constructor===Object)i.addField(n,R(h),vs);else{let o=or.get(h?.constructor)??ur;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var qo=(t)=>new Yr(t.name??"Comp",bo(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 Eo=["nid","cid","eid","vid","si","sk"];class si{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.renderComment=s,this.renderFn=i,this.getSeqInfo=n??Uo,this.cache=h??new Xr}setNullCache(){this.cache=new Zr}renderToDOM(t,e){let r=document.createElement("div");return this.renderFn(this.h("div",null,[this.renderRoot(t,e)]),r),r.childNodes[0]}renderToString(t,e,r=!0){let s=this.renderToDOM(t,e,this.renderFn);if(r){let i=s.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of i)for(let h of Eo)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,this.renderView(o,t)]);return this.cache.set(e,h,f),f}pushEachEntry(t,e,r,s,i){t.push(this.renderMetadata("Each",{nid:e,[r]:s}),i)}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,a]of o(i))if(n.call(t.it,_,a,f)){let l=t.enter(a,{key:_},!0),y=this.renderIt(l,r,_,s);this.pushEachEntry(c,r,u,_,y)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=[],_=h.call(t.it,i);for(let[a,l]of c(i))if(n.call(t.it,a,l,_)){let y={key:a,value:l},p=`${s}-${a}`,S;if(u)u.call(t.it,y,a,l,_),S=this.cache.get2(t.it,l,p);else S=this.cache.get(l,p);if(S){this.pushEachEntry(f,s,o,a,S);continue}let T=t.enter(l,y,!1),et=this.renderView(r,T);if(this.pushEachEntry(f,s,o,a,et),u)this.cache.set2(t.it,l,p,et);else this.cache.set(l,p,et)}return f}renderView(t,e){return t.render(e,this)}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderEmpty(){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*jo(t){let e=0;for(let r of t)yield[e++,r]}function*Io(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var cr=new Map,Ao=["si",jo],$o=["sk",Io],Ko=["si",function*(e){}];function Uo(t){return j(t)?Ao:w(t)?$o:cr.get(t?.constructor)??Ko}class Ot{constructor(t=R(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new Ot(t,e,this.$)}toJS(){return this.order.toArray().map((t)=>this.items.get(t))}set(t,e){let r=this.items.has(t)?this.order:this.order.push(t);return this._clonish(this.items.set(t,e),r,this.$)}get(t,e=null){return this.items.get(t,e)}_nextFreeKey(){let t=this.$;while(!0){let e=`§${t}§`;if(!this.items.has(e))return[e,t];t+=1}}push(t){let[e,r]=this._nextFreeKey(),s=this.set(e,t);return s.$=r,s}get size(){return this.items.size}delete(t){if(this.items.has(t)){let e=this.order.delete(this.order.indexOf(t));return this._clonish(this.items.delete(t),e)}return this}moveKeyBeforeKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),0)}moveKeyAfterKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),1)}moveKeyIndexToIndex(t,e,r){if(t===-1||e===-1||t===e)return this;let{order:s}=this,i=e+r,n=i<t?t+1:t,h=s.insert(i,s.get(t)).delete(n);return this._clonish(this.items,h)}}var Lo=(t)=>null;class Eh{isValid(t){return t instanceof Ot}getMessage(t){return"KList expected"}}var Do=new Eh;class jh extends X{constructor(t,e=new Ot){super("KList",t,Do,Lo,e)}extendProtoForType(t,e){Gt(t,this.name,e);let{name:r}=this;Gt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}or.set(Ot,jh);function*Wo(t){for(let e of t.order)yield[e,t.items.get(e)]}cr.set(Ot,["data-sk",Wo]);var ni=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),ze=(t)=>t!==null&&typeof t==="object",Ah=(t,e)=>Object.getPrototypeOf(t)!==Object.getPrototypeOf(e);function $h(t,e,r){for(let s in e){let i=e[s];if(i===void 0)Ro(t,s,r);else if(ni(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(ze(i))To(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function Ro(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.replaceChildren();else if(e==="className")t.removeAttribute("class");else if(e==="htmlFor")t.removeAttribute("for");else if(typeof s==="string"||ni(e))t.removeAttribute(e);else t[e]=null}function To(t,e,r,s){let i=e?.[r];if(ze(i)&&Ah(i,s)){t[r]=s;return}if(!ze(t[r]))t[r]={};let n=t[r];for(let h in s)n[h]=s[h]}class Ht{}var ii=(t)=>t instanceof ar?t.key:void 0,Jo=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function Kh(t,e){for(let r=0;r<t.length;r++)if(!t[r].isEqualTo(e[r]))return!1;return!0}function hi(t,e,r){for(let s of e)t.appendChild(s.toDom(r))}function ui(t,e){if(e==null)return;if(Jo(e))for(let r of e)ui(t,r);else if(e instanceof Ht)if(e instanceof Mt)t.push(...e.childs);else t.push(e);else t.push(new oi(e))}class oi extends Ht{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof oi&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class _r extends Ht{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof _r&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class Mt extends Ht{constructor(t){super();this.childs=[],ui(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof Mt)||this.childs.length!==t.childs.length)return!1;return Kh(this.childs,t.childs)}toDom(t){let e=t.document.createDocumentFragment();return hi(e,this.childs,t),e}}class ar extends Ht{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 ar)||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;return Kh(this.childs,t.childs)}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);return $h(r,this.attrs,{}),hi(r,this.childs,t),r}}function Uh(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)continue;if(ze(i)&&ze(n))if(Ah(n,i))r??={},r[s]=n;else{let h=Uh(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 Lh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;let i=e.nodeType;if(i===r.nodeType){if(i===3||i===8)return t.data=r.text,t;if(i===1&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let h=Uh(e.attrs,r.attrs);if(h)$h(t,h,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)Ih(t,e.childs,r.childs,s);return t}if(i===11)return Ih(t,e.childs,r.childs,s),t}let n=r.toDom(s);return t.parentNode?.replaceChild(n,t),n}function Ih(t,e,r,s){if(e.length===0){hi(t,r,s);return}if(r.length===0){t.replaceChildren();return}let i=Array.from(t.childNodes),n=Object.create(null);for(let o=0;o<e.length;o++){let c=ii(e[o]);if(c!=null)n[c]=o}let h=new Uint8Array(e.length),u=0;for(let o=0;o<r.length;o++){let c=r[o],f=ii(c),_=-1;if(f!=null){if(f in n&&!h[n[f]])_=n[f]}else while(u<e.length){if(!h[u]&&ii(e[u])==null){_=u++;break}u++}if(_>=0){h[_]=1;let a=Lh(i[_],e[_],c,s),l=t.childNodes[o]??null;if(a!==l)t.insertBefore(a,l)}else{let a=t.childNodes[o]??null;t.insertBefore(c.toDom(s),a)}}for(let o=e.length-1;o>=0;o--)if(!h[o]&&i[o].parentNode===t)t.removeChild(i[o])}var fr=new WeakMap;function Dh(t,e,r){let s=fr.get(e),i=t instanceof Mt;if(s&&s.vnode instanceof Mt===i){let h=i?e:s.dom,u=Lh(h,s.vnode,t,r);return fr.set(e,{vnode:t,dom:i?e:u}),u}fr.delete(e);let n=t.toDom(r);return e.replaceChildren(n),fr.set(e,{vnode:t,dom:i?e:n}),n}function Wh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e){let c=e[o];switch(o){case"key":n=c;break;case"namespace":h=c;break;case"class":i.className=c;break;case"for":i.htmlFor=c;break;default:i[o]=ni(o)?String(c):c}}let u=[];return ui(u,r),new ar(s,i,u,n,h)}var{raw:of,raw:cf}=String;function ff(t,e){return new Lr(t,e)}var Zo=(t)=>typeof t==="string"?document.querySelector(t):t;function _f(t){let e=Zo(t),r=new Xe,s=(o)=>new Mt(o),i=(o)=>new _r(o),n={document},h=(o,c)=>Dh(o,c,n),u=new si(r,Wh,s,i,h);return new ts(e,h,r,u,V)}async function Of(t,e,r="margaui-css"){let s=performance.now(),i=await Xo(t,e),n=performance.now();return He(r,i),n-s}async function Xo(t,e,r,s=$t){t.ParseContext=s,t.compile();let i=new Set(r??[]);for(let n of t.comps.byId.values())for(let h in n.views){let u=n.views[h];for(let o of u.ctx.classes)i.add(o)}return await e(Array.from(i))}var Go="RENDER_IT_OUTSIDE_OF_LOOP",Ho="UNKNOWN_EVENT_MODIFIER",Qo="UNKNOWN_HANDLER_ARG_NAME",Yo="INPUT_HANDLER_NOT_IMPLEMENTED",Bo="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Po="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",Co="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",xo="FIELD_VAL_NOT_DEFINED",Fo="COMPUTED_VAL_NOT_DEFINED",ko="UNKNOWN_REQUEST_NAME",Vo="UNKNOWN_COMPONENT_NAME",No="warn",Rh="error",mo="hint";function Af(t,e=new Th){hc(e,t),uc(e,t);for(let r in t.views)vo(e,t.views[r],t);return e}function vo(t,e,r){tc(t,e),rc(t,e),nc(t,e,r)}function tc(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof We){let n=r[s+1];if(!(n instanceof Te||n instanceof Vt))t.error(Go,{node:i})}}}var ec={};function rc(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Jr[i]??ec;for(let u of n)if(h[u]===void 0)t.warn(Ho,{name:i,modifier:u,handler:s,event:r})}}var sc=new Set(["value","valueAsInt","valueAsFloat","target","event","isAlt","isShift","isCtrl","isCmd","key","keyCode","isUpKey","isDownKey","isSend","isCancel","isTabKey","ctx","dragInfo"]);function ic(t){return sc.has(t)}function nc(t,e,r){let{computed:s,scope:i,Class:n}=r,{prototype:h}=n,{fields:u}=n.getMetaClass();for(let o of e.ctx.events)for(let c of o.handlers){let{args:f}=c.handlerCall;for(let _=0;_<f.length;_++){let a=f[_];bt(t,a,u,h,s,i)}}}function hc(t,e){let{input:r,views:s,Class:i}=e,{prototype:n}=i;for(let h in s){let u=s[h];for(let o of u.ctx.events)for(let c of o.handlers){let{handlerVal:f}=c.handlerCall;if(f instanceof be){if(r[f.name]===void 0){if(t.warn(Yo,{name:f.name,handler:c,event:o}),n[f.name]!==void 0)t.hint(Co,{name:f.name,handler:c,event:o})}}else if(f instanceof Bt){if(n[f.name]===void 0){if(t.warn(Bo,{name:f.name,handler:c,event:o}),r[f.name]!==void 0)t.hint(Po,{name:f.name,handler:c,event:o})}}}}}function bt(t,e,r,s,i,n){if(e instanceof je||e instanceof Bt){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(xo,{val:e,name:h})}else if(e instanceof Ie){let{name:h}=e;if(i[h]===void 0)t.error(Fo,{val:e,name:h})}else if(e instanceof Ae)bt(t,e.seqVal,r,s,i,n),bt(t,e.keyVal,r,s,i,n);else if(e instanceof Ee){if(n.lookupRequest(e.name)===null)t.warn(ko,{name:e.name})}else if(e instanceof qe){if(n.lookupComponent(e.name)===null)t.warn(Vo,{name:e.name})}else if(e instanceof k&&!ic(e.name))t.warn(Qo,{name:e.name});else if(!(e instanceof L))console.log(e)}function uc(t,e){let{computed:r,scope:s,views:i,Class:n}=e,{prototype:h}=n,{fields:u}=n.getMetaClass();for(let o in i){let c=i[o];for(let f of c.ctx.attrs){let{attrs:_,wrapperAttrs:a,textChild:l}=f;if(_ instanceof Ke){for(let y of _.items)if(y instanceof jt)bt(t,y.val,u,h,r,s)}if(a!==null)for(let{val:y}of a)bt(t,y,u,h,r,s);if(l)bt(t,l,u,h,r,s)}for(let f of c.ctx.nodes)if(f.val)bt(t,f.val,u,h,r,s)}}class Th{constructor(){this.reports=[]}error(t,e){this.report(t,e,Rh)}warn(t,e){this.report(t,e,No)}hint(t,e){this.report(t,e,mo)}report(t,e={},r=Rh){this.reports.push({id:t,info:e,level:r})}}class oc extends V{constructor(t,e,r){super(t,e,r);this.attrs=[]}onAttributes(t,e,r){this.attrs.push({attrs:t,wrapperAttrs:e,textChild:r})}}class Jh extends $t{constructor(...t){super(...t);this.attrs=[]}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,f=new Jh(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f.attrs=this.attrs,f}onAttributes(t,e,r){super.onAttributes(t,e,r),this.attrs.push({attrs:t,wrapperAttrs:e,textChild:r})}}export{Yc as version,Xt as updateIn,Vn as update,_f as tutuca,Cu as setIn,Bu as set,cr as seqInfoByClass,Pu as removeIn,Yu as remove,Jc as mergeWith,Xc as mergeDeepWith,Zc as mergeDeep,Tc as merge,ff as macro,ki as isValueObject,zs as isStack,ws as isSet,ps as isSeq,gt as isRecord,Ln as isPlainObject,In as isOrderedSet,Ss as isOrderedMap,x as isOrdered,Ss as isOMap,er as isMap,jn as isList,w as isKeyed,j as isIndexed,P as isImmutable,er as isIMap,Z as isCollection,ds as isAssociative,I as is,He as injectCss,cf as html,Q as hash,Rn as hasIn,Mu as has,Ms as getIn,Wn as get,Qc as fromJS,or as fieldsByClass,of as css,qo as component,Xo as compileClassesToStyleText,Of as compileClassesToStyle,vo as checkView,Af as checkComponent,ko as UNKNOWN_REQUEST_NAME,Qo as UNKNOWN_HANDLER_ARG_NAME,Ho as UNKNOWN_EVENT_MODIFIER,Vo as UNKNOWN_COMPONENT_NAME,ie as Stack,M as Set,v as Seq,Hc as Repeat,hr as Record,ys as Range,Go as RENDER_IT_OUTSIDE_OF_LOOP,V as ParseContext,Gc as PairSorting,N as OrderedSet,D as OrderedMap,D as OMap,R as Map,U as List,oc as LintParseContext,Th as LintContext,Jh as LintClassCollectorCtx,No as LEVEL_WARN,mo as LEVEL_HINT,Rh as LEVEL_ERROR,Ot as KList,M as ISet,Yo as INPUT_HANDLER_NOT_IMPLEMENTED,Bo as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,Co as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Po as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,R as IMap,xo as FIELD_VAL_NOT_DEFINED,m as Collection,Fo as COMPUTED_VAL_NOT_DEFINED};
|
package/dist/tutuca-extra.js
CHANGED
|
@@ -1202,7 +1202,8 @@ class RenderNode extends RenderViewId {
|
|
|
1202
1202
|
|
|
1203
1203
|
class RenderItNode extends RenderViewId {
|
|
1204
1204
|
render(stack, rx) {
|
|
1205
|
-
|
|
1205
|
+
const newStack = stack.enter(stack.it, {}, true);
|
|
1206
|
+
return rx.renderIt(newStack, this.nodeId, "", this.viewId);
|
|
1206
1207
|
}
|
|
1207
1208
|
pathInNext = true;
|
|
1208
1209
|
}
|
package/dist/tutuca-extra.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class Ht{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class bt extends Ht{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new bt({...this.binds,key:t})}withKey(t){return new bt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class de extends Ht{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new sr(this.field,t)}withKey(t){return new rr(this.field,t)}}class er extends Ht{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class rr extends er{}class sr extends er{}var R=Symbol("NONE");class ir extends Ht{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 tt{constructor(t=[]){this.steps=t}concat(t){return new tt(this.steps.concat(t))}popStep(){return new tt(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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=vs(t.previousSibling),{eid:g,cid:S,vid:T}=t.dataset;if(g!==void 0)o.push(g);if(S!==void 0){let v=i.getComponentForId(+S,T);if(_){if(c=Dh(v,o,T,e),c===null&&n)return Th;_=!1}let ms=Wh(v,f,T);if(ms)h.push(ms);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new tt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return tt.fromNodeAndEventName(h,n,e,r,s,i)}}var Ns={};function vs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=vs(t.previousSibling);if(e!==Ns)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Ns}function Dh(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 Wh(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],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Th=[null,null];class nr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new de(t))}index(t,e){return this.add(new sr(t,e))}key(t,e){return this.add(new rr(t,e))}}var Rh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ht=(t)=>Rh.test(t),Jh=/^-?[0-9]+(\.[0-9]+)?$/,ti=(t,e)=>ur.parse(t,e),Xt=(t,e)=>new H(t),Zh=(t,e)=>ht(t)?new ut(t):null,Hh=(t,e)=>ht(t)?new ni(t):null,Xh=(t,e)=>ht(t)?new cr(t):null,Gh=(t,e)=>ht(t)?new oi(t):null,Qh=(t,e)=>ht(t)?new ci(t):null,Ch=(t,e)=>ht(t)?new fi(t):null,Yh=(t,e)=>ht(t)?new hi(t):null;class ei{constructor(){this.allowFieldOnly(),this.bindValIt=new cr("it"),this.nullConstVal=new H(null)}const(t){return new H(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}_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 _i(s,i):null}parse(t,e){switch(Bh(t)){case li:return this.okStrTpl?ti(t,e):null;case yi:return this.okStrTpl?Xt(t,e):null;case ai:return this._parseSeqAccess(t,e);case pe:return this.okStrTpl?ti(t,e):null}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.okStrTpl?Xt(t.slice(1),e):null;case 39:return this.okStrTpl?Xt(t.slice(1,-1),e):null;case 64:return this.okBind?Xh(t.slice(1),e):null;case 42:return this.okDyn?Gh(t.slice(1),e):null;case 46:return this.okField?Qh(t.slice(1),e):null;case 36:return this.okComputed?Ch(t.slice(1),e):null;case 33:return this.okRequest?Yh(t.slice(1),e):null}let s=Jh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.okConst?Xt(s,e):null;else if(t==="true"||t==="false")return this.okConst?Xt(t==="true",e):null;else if(r>=97&&r<=122)return this.okName?Zh(t,e):null;else if(r>=65&&r<=90)return this.okType?Hh(t,e):null;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,ri)}parseAlter(t,e){return this._parseHandler(t,e,si)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class ge{render(t,e){}eval(t){}toPathItem(){return null}}class H extends ge{constructor(t){super();this.val=t}render(t,e){return this.val}eval(t){return this.val}toString(){let t=this.val;return typeof t==="string"?`'${t}'`:`${t}`}}class hr extends ge{}class ur extends hr{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 H(h);s[n]=o,i&&=o instanceof H}return i?new H(s.map((n)=>n.val).join("")):new ur(s)}}class ut extends hr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class ri extends ut{eval(t){return t.getHandlerFor(this.name,"input")??ii("input",this.name)}}class si extends ut{eval(t){return t.getHandlerFor(this.name,"alter")??ii("alter",this.name)}}var ii=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ni extends ut{eval(t){return t.lookupType(this.name)}}class hi extends ut{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class ui extends ut{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class or extends ge{render(t,e){return this.eval(t)}}class Gt extends or{constructor(t){super();this.name=t}}class cr extends Gt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class oi extends Gt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ci extends Gt{eval(t){return t.lookupField(this.name)}toPathItem(){return new de(this.name)}toRawFieldVal(){return new ui(this.name)}toString(){return`.${this.name}`}}class fi extends Gt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class _i extends or{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new ir(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 li=0,ai=1,pe=2,yi=3;function Bh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return pe;e+=1;break;case 93:if(r>0||e===0)return pe;r+=1;break;case 123:return li;case 125:return yi}if(e>0||r>0)return e===1&&r===1?ai:pe;return-1}var p=new ei;class qt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return ar(e).parse(t,r)}isConstant(){return!1}}var xh="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",Ph=new Set(xh.split(","));class di{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 ze(t,s)),this.hasDynamic||=!(s instanceof H)}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 wi(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)??Qt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Qt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=yr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new we("data-eid",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new gi(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===""&&Ph.has(n)?!0:h;this.attrs.push(new we(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new pi(r):_r.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class _r extends qt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.val.eval(null);return new _r(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 pi extends qt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new we(t,new H(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.val.toString();return t}}class lr{constructor(t){this.name=t}}class ze extends lr{constructor(t,e){super(t);this.val=e}eval(t){return this.val.eval(t)}}class we extends ze{}class gi extends ze{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.val.eval(t)}`}}}var Qt=p.nullConstVal;class wi extends lr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Qt}get anyBranchIsSet(){return this.thenVal!==Qt||this.elseVal!==Qt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var fr=null;function ar(t){return fr??=new di(t),fr.clear(t),fr}class yr{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 yr(i,n)}}class dr{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class Et{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class Bt extends Et{constructor(t){super();this.val=t}render(t,e){return e.renderText(this.val)}isWhiteSpace(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.val=""}isConstant(){return!0}setDataAttr(t,e){}}class Yt extends Bt{render(t,e){return e.renderComment(this.val)}}function Fh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Mr(r);else r.optimize()}}function wr(t){if(t.isConstant())return new Mr(t);return t.optimize(),t}class zr extends Et{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Fh(this.childs)}}class Se extends zr{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 Oe extends zr{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 Ct=(t)=>t.length===1?t[0]:new Oe(t),kh=/^[a-zA-Z][a-zA-Z0-9-]*$/,zi=null;class et extends Et{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){zi??=e.newDOMParser();let r=zi.parseFromString(t,"text/html").body.childNodes;return et.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Bt(t.textContent);else if(e.isCommentNode(t))return new Yt(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=et.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return Ct(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new be(null,p.const(u),Ct(n));case"text":{let c=p.parseText(u,e);return c!==null?new gr(null,c):null}case"render":return e.addNodeIf(Ii,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(Ai,p.bindValIt,o);case"render-each":return Or.parse(e,p,u,o,s);case"show":return e.addNodeIf(br,p.parseCondValue(u,e),Ct(n));case"hide":return e.addNodeIf(qr,p.parseCondValue(u,e),Ct(n))}return new Yt(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??Ct(n)}let[u,o]=qt.parse(s,e,!0);return e.onAttributes(u,o,null),Si(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(kh.test(i)){let[h,u,o]=qt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new gr(null,o));let c=i!=="PRE"?tu(n):n;return Si(new Se(i.toLowerCase(),h,c),e,u)}return new Yt(`Error: InvalidTagName ${i}`)}}function Si(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Vh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Vh(t,e){let r=vh[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 Ei extends Et{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Yt(`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=wr(this.node)}}class Sr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Me extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class Ii extends Me{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Ai extends Me{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Or extends Me{constructor(t,e,r){super(t,e,r);this.iterInfo=new Er(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(Or,e.parseEach(r,t),s);if(n!==null){let h=ar(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 gr extends et{render(t,e){return e.renderText(this.val.eval(t))}}class Mr extends Et{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ot extends et{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=wr(this.node)}static register=!1}class br extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class qr extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class ji extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class be extends ot{optimize(){this.node.optimize()}}class $i 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 bt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Ki extends ot{constructor(t,e){super(t,e);this.iterInfo=new Er(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new bt({})}static register=!0}class Er{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)??mh,s=this.loopWithVal?.eval(t)??Nh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var mh=(t,e,r)=>!0,Nh=(t)=>({seq:t}),vh={slot:be,show:br,hide:qr,each:Ki,scope:$i,"push-view":ji};class ct{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 ct(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 Ui(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Oe(s)};for(let h of r)if(h instanceof be)i[h.val.val]=h.node;else if(!(h instanceof Bt)||!h.isWhiteSpace())s.push(h);let n=new Ei(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 pr=(t)=>t instanceof Bt&&t.isWhiteSpace(),Oi=(t)=>t instanceof Se||t instanceof Oe&&t.childs[0]instanceof Se;function tu(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(pr(t[0]))r=1,s=!0;if(e>1&&pr(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(pr(n)&&Oi(t[i-1])&&Oi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class qe{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=et.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=wr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ui{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Li(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 Li{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=hu(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 eu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ee=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,Mi=(t)=>Ee((e)=>e.e.key===t),bi=Ee(({e:t})=>eu&&t.metaKey||t.ctrlKey),ru=Ee(({e:t})=>t.metaKey),su=Ee(({e:t})=>t.altKey),qi={ctrl:bi,cmd:bi,meta:ru,alt:su},iu={keydown:{send:Mi("Enter"),cancel:Mi("Escape"),...qi},click:{...qi}},nu=(t,e)=>t;function hu(t,e){if(e.length===0)return nu;let r=iu[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 Ir{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 Ar{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 jr{getKey(t,e,r){return r.call(t)}}class $r{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 Ie{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new $r}setNullComputedCache(){this.computedCache=new jr}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:Wi}getHandlerFor(t,e,r){return this.getCompFor(t)?.[r][e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getHandlerFor(t,e,"computed");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(`
|
|
1
|
+
class Ht{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class bt extends Ht{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new bt({...this.binds,key:t})}withKey(t){return new bt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class de extends Ht{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new sr(this.field,t)}withKey(t){return new rr(this.field,t)}}class er extends Ht{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class rr extends er{}class sr extends er{}var R=Symbol("NONE");class ir extends Ht{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 tt{constructor(t=[]){this.steps=t}concat(t){return new tt(this.steps.concat(t))}popStep(){return new tt(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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=vs(t.previousSibling),{eid:g,cid:S,vid:T}=t.dataset;if(g!==void 0)o.push(g);if(S!==void 0){let v=i.getComponentForId(+S,T);if(_){if(c=Dh(v,o,T,e),c===null&&n)return Th;_=!1}let ms=Wh(v,f,T);if(ms)h.push(ms);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new tt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return tt.fromNodeAndEventName(h,n,e,r,s,i)}}var Ns={};function vs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=vs(t.previousSibling);if(e!==Ns)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Ns}function Dh(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 Wh(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],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Th=[null,null];class nr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new de(t))}index(t,e){return this.add(new sr(t,e))}key(t,e){return this.add(new rr(t,e))}}var Rh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ht=(t)=>Rh.test(t),Jh=/^-?[0-9]+(\.[0-9]+)?$/,ti=(t,e)=>ur.parse(t,e),Xt=(t,e)=>new H(t),Zh=(t,e)=>ht(t)?new ut(t):null,Hh=(t,e)=>ht(t)?new ni(t):null,Xh=(t,e)=>ht(t)?new cr(t):null,Gh=(t,e)=>ht(t)?new oi(t):null,Qh=(t,e)=>ht(t)?new ci(t):null,Ch=(t,e)=>ht(t)?new fi(t):null,Yh=(t,e)=>ht(t)?new hi(t):null;class ei{constructor(){this.allowFieldOnly(),this.bindValIt=new cr("it"),this.nullConstVal=new H(null)}const(t){return new H(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}_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 _i(s,i):null}parse(t,e){switch(Bh(t)){case li:return this.okStrTpl?ti(t,e):null;case yi:return this.okStrTpl?Xt(t,e):null;case ai:return this._parseSeqAccess(t,e);case pe:return this.okStrTpl?ti(t,e):null}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.okStrTpl?Xt(t.slice(1),e):null;case 39:return this.okStrTpl?Xt(t.slice(1,-1),e):null;case 64:return this.okBind?Xh(t.slice(1),e):null;case 42:return this.okDyn?Gh(t.slice(1),e):null;case 46:return this.okField?Qh(t.slice(1),e):null;case 36:return this.okComputed?Ch(t.slice(1),e):null;case 33:return this.okRequest?Yh(t.slice(1),e):null}let s=Jh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.okConst?Xt(s,e):null;else if(t==="true"||t==="false")return this.okConst?Xt(t==="true",e):null;else if(r>=97&&r<=122)return this.okName?Zh(t,e):null;else if(r>=65&&r<=90)return this.okType?Hh(t,e):null;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,ri)}parseAlter(t,e){return this._parseHandler(t,e,si)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class ge{render(t,e){}eval(t){}toPathItem(){return null}}class H extends ge{constructor(t){super();this.val=t}render(t,e){return this.val}eval(t){return this.val}toString(){let t=this.val;return typeof t==="string"?`'${t}'`:`${t}`}}class hr extends ge{}class ur extends hr{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 H(h);s[n]=o,i&&=o instanceof H}return i?new H(s.map((n)=>n.val).join("")):new ur(s)}}class ut extends hr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class ri extends ut{eval(t){return t.getHandlerFor(this.name,"input")??ii("input",this.name)}}class si extends ut{eval(t){return t.getHandlerFor(this.name,"alter")??ii("alter",this.name)}}var ii=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ni extends ut{eval(t){return t.lookupType(this.name)}}class hi extends ut{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class ui extends ut{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class or extends ge{render(t,e){return this.eval(t)}}class Gt extends or{constructor(t){super();this.name=t}}class cr extends Gt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class oi extends Gt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ci extends Gt{eval(t){return t.lookupField(this.name)}toPathItem(){return new de(this.name)}toRawFieldVal(){return new ui(this.name)}toString(){return`.${this.name}`}}class fi extends Gt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class _i extends or{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new ir(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 li=0,ai=1,pe=2,yi=3;function Bh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return pe;e+=1;break;case 93:if(r>0||e===0)return pe;r+=1;break;case 123:return li;case 125:return yi}if(e>0||r>0)return e===1&&r===1?ai:pe;return-1}var p=new ei;class qt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return ar(e).parse(t,r)}isConstant(){return!1}}var xh="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",Ph=new Set(xh.split(","));class di{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 ze(t,s)),this.hasDynamic||=!(s instanceof H)}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 wi(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)??Qt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Qt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=yr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new we("data-eid",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new gi(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===""&&Ph.has(n)?!0:h;this.attrs.push(new we(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new pi(r):_r.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class _r extends qt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.val.eval(null);return new _r(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 pi extends qt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new we(t,new H(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.val.toString();return t}}class lr{constructor(t){this.name=t}}class ze extends lr{constructor(t,e){super(t);this.val=e}eval(t){return this.val.eval(t)}}class we extends ze{}class gi extends ze{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.val.eval(t)}`}}}var Qt=p.nullConstVal;class wi extends lr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Qt}get anyBranchIsSet(){return this.thenVal!==Qt||this.elseVal!==Qt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var fr=null;function ar(t){return fr??=new di(t),fr.clear(t),fr}class yr{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 yr(i,n)}}class dr{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class Et{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class Bt extends Et{constructor(t){super();this.val=t}render(t,e){return e.renderText(this.val)}isWhiteSpace(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.val=""}isConstant(){return!0}setDataAttr(t,e){}}class Yt extends Bt{render(t,e){return e.renderComment(this.val)}}function Fh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Mr(r);else r.optimize()}}function wr(t){if(t.isConstant())return new Mr(t);return t.optimize(),t}class zr extends Et{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Fh(this.childs)}}class Se extends zr{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 Oe extends zr{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 Ct=(t)=>t.length===1?t[0]:new Oe(t),kh=/^[a-zA-Z][a-zA-Z0-9-]*$/,zi=null;class et extends Et{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){zi??=e.newDOMParser();let r=zi.parseFromString(t,"text/html").body.childNodes;return et.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Bt(t.textContent);else if(e.isCommentNode(t))return new Yt(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=et.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return Ct(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new be(null,p.const(u),Ct(n));case"text":{let c=p.parseText(u,e);return c!==null?new gr(null,c):null}case"render":return e.addNodeIf(Ii,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(Ai,p.bindValIt,o);case"render-each":return Or.parse(e,p,u,o,s);case"show":return e.addNodeIf(br,p.parseCondValue(u,e),Ct(n));case"hide":return e.addNodeIf(qr,p.parseCondValue(u,e),Ct(n))}return new Yt(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??Ct(n)}let[u,o]=qt.parse(s,e,!0);return e.onAttributes(u,o,null),Si(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(kh.test(i)){let[h,u,o]=qt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new gr(null,o));let c=i!=="PRE"?tu(n):n;return Si(new Se(i.toLowerCase(),h,c),e,u)}return new Yt(`Error: InvalidTagName ${i}`)}}function Si(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Vh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Vh(t,e){let r=vh[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 Ei extends Et{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Yt(`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=wr(this.node)}}class Sr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Me extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class Ii extends Me{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Ai extends Me{render(t,e){let r=t.enter(t.it,{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}pathInNext=!0}class Or extends Me{constructor(t,e,r){super(t,e,r);this.iterInfo=new Er(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(Or,e.parseEach(r,t),s);if(n!==null){let h=ar(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 gr extends et{render(t,e){return e.renderText(this.val.eval(t))}}class Mr extends Et{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ot extends et{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=wr(this.node)}static register=!1}class br extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class qr extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class ji extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class be extends ot{optimize(){this.node.optimize()}}class $i 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 bt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Ki extends ot{constructor(t,e){super(t,e);this.iterInfo=new Er(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new bt({})}static register=!0}class Er{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)??mh,s=this.loopWithVal?.eval(t)??Nh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var mh=(t,e,r)=>!0,Nh=(t)=>({seq:t}),vh={slot:be,show:br,hide:qr,each:Ki,scope:$i,"push-view":ji};class ct{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 ct(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 Ui(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Oe(s)};for(let h of r)if(h instanceof be)i[h.val.val]=h.node;else if(!(h instanceof Bt)||!h.isWhiteSpace())s.push(h);let n=new Ei(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 pr=(t)=>t instanceof Bt&&t.isWhiteSpace(),Oi=(t)=>t instanceof Se||t instanceof Oe&&t.childs[0]instanceof Se;function tu(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(pr(t[0]))r=1,s=!0;if(e>1&&pr(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(pr(n)&&Oi(t[i-1])&&Oi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class qe{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=et.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=wr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ui{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Li(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 Li{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=hu(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 eu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ee=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,Mi=(t)=>Ee((e)=>e.e.key===t),bi=Ee(({e:t})=>eu&&t.metaKey||t.ctrlKey),ru=Ee(({e:t})=>t.metaKey),su=Ee(({e:t})=>t.altKey),qi={ctrl:bi,cmd:bi,meta:ru,alt:su},iu={keydown:{send:Mi("Enter"),cancel:Mi("Escape"),...qi},click:{...qi}},nu=(t,e)=>t;function hu(t,e){if(e.length===0)return nu;let r=iu[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 Ir{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 Ar{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 jr{getKey(t,e,r){return r.call(t)}}class $r{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 Ie{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new $r}setNullComputedCache(){this.computedCache=new jr}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:Wi}getHandlerFor(t,e,r){return this.getCompFor(t)?.[r][e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getHandlerFor(t,e,"computed");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
2
|
`)}}class Ae{constructor(t=new Ie,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 dr(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 Kr{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 Di extends Kr{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 It=(t)=>typeof t==="string",uu=0;class Ur{constructor(t,e,r,s={},i="",n="",h="",u={},o={},c={},f={},_={},l={},a={},y={}){this.id=uu++,this.name=t,this.Class=e,this.views={main:new qe("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=c,this.bubble=f,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Wi};for(let g in s){let S=s[g],{view:T,style:v}=It(S)?{view:S}:S;this.views[g]=new qe(g,T,v)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(It(r)){let s=p.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Kr(e,s,Symbol(e))}else if(It(r?.default)&&It(r?.for)){let s=p.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(It(i)&&It(n))this.dynamic[e]=new Di(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
3
|
`)}}function Wi(t){return t}var Ti=Symbol("STOP"),Wr=Symbol("NEXT");class xt{constructor(t,e){this.head=t,this.tail=e}push(t){return new xt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Ti?e:s===Wr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Lr{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?Ti:Wr:e}}class Dr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Wr:e}}class G{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 G(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new xt(new Lr(e,{it:e},!0),null),i=new xt(new Dr({}),null),n=new xt("main",null);return new G(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 Lr(t,e,r));return new G(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 G(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Dr(e));return new G(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)}getHandlerFor(t,e){return this.comps.getHandlerFor(this.it,t,e)}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 Ji{constructor(t){this.val=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.val;this.val=t;for(let s of this.changeSubs)s({val:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.val),e)}}class Rr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ji(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 Hr(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 Xi(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.val,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??ou(e),o=s?.onResName??e,c=(f,_,l,a,y)=>{let S=new Hi(t,this,f??_,f?[l]:[a,y],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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.val,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 Zi(t,e,r,this,s))}}function ou(t){return()=>{throw Error(`Request not found: ${t}`)}}function cu(){return this}class Jr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parentTransaction=r,this._task=null}get task(){return this._task??=new Gi,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 G.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 fu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ri=(t)=>Number.isNaN(t)?null:t;function Tr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Zi extends Jr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return G.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 Xr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return Tr(e);case"valueAsInt":return Ri(parseInt(Tr(e),10));case"valueAsFloat":return Ri(parseFloat(Tr(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 fu&&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 Gr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Zr extends Jr{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]??cu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Gr(this.path,this.transactor,this)]]}}class Hi extends Zr{handlerProp="response"}class Hr extends Zr{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 Xi extends Hr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Gi{constructor(t){this.info=t,this.deps=[],this.val=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.val=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class Xr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Qi(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 Gr extends Xr{stopPropagation(){return this.parent.stopPropagation()}}class Qi extends nr{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 Qr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ae(r),this.transactor=new Rr(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,c]=tt.fromEvent(t,i,n,h,u);if(r){let f=_u(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.val,_=o.lookup(f),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(f));this.dragInfo=new Ci(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return G.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.val,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.val!==e.old)this.render()}),je("tutuca-app",this.comps.compileStyles(),t?.head??document.head),t?.noCache)this.renderer.setNullCache(),this.comps.setNullComputedCache();else this.startCacheEvictionInterval();this.render()}stop(){this.stopCacheEvictionInterval();for(let t of this._eventNames)this.rootNode.removeEventListener(t,this)}dispatchLogicAtRoot(t,e,r){return this.transactor.pushLogic(new tt([]),t,e,r)}registerComponents(t,e){let r=this.compStack.enter();return r.registerComponents(t,e),r}_transactNextBatch(t=10){this._transactNextBatchId=null;let e=Date.now(),r=this.transactor;while(r.hasPendingTransactions&&Date.now()-e<t)r.transactNext();if(r.hasPendingTransactions)this._scheduleNextTransactionBatchExecution()}_scheduleNextTransactionBatchExecution(){this._transactNextBatchId=setTimeout(()=>this._transactNextBatch(),0)}startCacheEvictionInterval(t=30000){this._evictCacheId=setInterval(()=>this.renderer.cache.evict(),t)}stopCacheEvictionInterval(){clearInterval(this._evictCacheId),this._evictCacheId=null}}function je(t,e,r=document.head){let s=document.createElement("style"),i=r.querySelector(`#${t}`);if(i)r.removeChild(i);s.id=t,s.innerHTML=e,r.appendChild(s)}function _u(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 Ci{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.val=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class $e extends ct{constructor(...t){super(...t);this.classes=new Set}_addClasses(t){for(let e of t.split(/\s+/))this.classes.add(e)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,f=new $e(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f}onAttributes(t,e,r){if(Array.isArray(t.items))for(let s of t.items){if(s.name!=="class")continue;let{val:i,thenVal:n,elseVal:h}=s;if(n!==void 0)this._maybeAddVal(n),this._maybeAddVal(h);else this._maybeAddVal(i)}else{let s=t.items.class;if(s)this._addClasses(s)}}_maybeAddVal(t){if(!this._maybeAddStrTpl(t)&&typeof t?.val==="string")this._addClasses(t.val)}_maybeAddStrTpl(t){if(t?.vals!==void 0){for(let e of t.vals)if(e instanceof H&&e.val!=="")this._addClasses(e.val);return!0}return!1}}function Pt(t,e){if(!t)throw Error(e)}function j(t){Pt(t!==1/0,"Cannot perform this action with an infinite size.")}function Yi(t,e,r,s,i,n){return j(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 lu=(t,e)=>e,au=(t,e)=>[e,t],Cr=(t)=>function(...e){return!t.apply(this,e)},Bi=(t)=>function(...e){return-t.apply(this,e)};function ln(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 xi=(t,e)=>t<e?1:t>e?-1:0,$={done:!0,value:void 0};class an{constructor(t){this.next=t}[Symbol.iterator](){return this}}function D(t){return new an(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 $})}var yu=D(()=>$),ft=()=>yu;function Xe(t){let e=0,r={done:!1,value:void 0};return D(()=>{if(e===t)return $;return r.value=e++,r})}function re(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 ss(t){if(Array.isArray(t))return!0;return!!Ge(t)}var du=(t)=>typeof t?.next==="function";function yn(t){return Ge(t)?.call(t)}function Ge(t){let e=t?.[Symbol.iterator];if(typeof e==="function")return e}function pu(t){let e=Ge(t);return e&&e===t.entries}function gu(t){let e=Ge(t);return e&&e===t.keys}var se="delete",z=5,E=1<<z,K=E-1,d={},mr=()=>({value:!1});function X(t){if(t)t.value=!0}class Qe{}function $t(t){if(t.size===void 0)t.size=t.__iterate(dn);return t.size}function st(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?$t(t)+e:e}var dn=()=>!0,pn=(t)=>t<0||Object.is(t,-0),ie=(t,e,r)=>(t===0&&!pn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),gn=(t,e,r)=>t===void 0?r:pn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Dt=(t,e)=>gn(t,e,0),ne=(t,e)=>gn(t,e,e),wn="@@__IMMUTABLE_ITERABLE__@@",We="@@__IMMUTABLE_KEYED__@@",Te="@@__IMMUTABLE_INDEXED__@@",it="@@__IMMUTABLE_ORDERED__@@",he="@@__IMMUTABLE_SEQ__@@",zn="@@__IMMUTABLE_LIST__@@",Sn="@@__IMMUTABLE_MAP__@@",On="@@__IMMUTABLE_SET__@@",Mn="@@__IMMUTABLE_STACK__@@",bn="@@__IMMUTABLE_RECORD__@@";function F(t,e){return typeof t==="object"&&t!==null&&e in t}var J=(t)=>F(t,wn),w=(t)=>F(t,We),I=(t)=>F(t,Te),is=(t)=>w(t)||I(t),P=(t)=>F(t,it),ns=(t)=>F(t,he),qn=(t)=>F(t,zn),Ce=(t)=>F(t,Sn),hs=(t)=>F(t,On),us=(t)=>F(t,Mn),dt=(t)=>F(t,bn),B=(t)=>J(t)||dt(t),os=(t)=>Ce(t)&&P(t),En=(t)=>hs(t)&&P(t),Pi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function In(t){let e=x(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=Tt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=(r)=>re(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s}),e}function An(t,e,r){let s=x(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,d);return h===d?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=(i)=>re(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)}),s}function jn(t,e){let r=x(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=In(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=Tt,r.__iterate=function(s,i){let n=0;if(i)$t(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)$t(t);let n=this.size;return re(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function $n(t,e,r,s){let i=t.size;if(ie(e,r,i))return t;if(i===void 0&&(e<0||r<0))return $n(t.toSeq().cacheResult(),e,r,s);let n=Dt(e,i),u=ne(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=x(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&ns(t)&&o>=0)c.get=function(f,_){return f=st(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,g)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(y,s?g:a-1,this)===!1)return!1},_),a},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ft();let _=t.__iterator(f),l=0,a=0;if(s)return D(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return $;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 g=_.next();if(g.done)return!1;return a++,y[0]=a-1,y[1]=g.value[1],!0})},c}function jt(t,e,r){if(!e)e=ln;let s=w(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?ys(n):I(t)?yt(n):kt(n)}function Ke(t,e,r){if(!e)e=ln;if(r)return t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Fi(e,i[1],n[1])?n:i)?.[0];return t.reduce((s,i)=>Fi(e,s,i)?i:s)}function Fi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Yr(t,e,r,s){let i=x(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),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=V(_);return yn(h?l.reverse():l)}),o=0,c=Array(u.length),f=Array(u.length);return q((_)=>{let l=s;for(let a=0;a<u.length;a++)c[a]=u[a].next(),l=s?l&&c[a].done:l||c[a].done;if(l)return!1;for(let a=0;a<c.length;a++)f[a]=c[a].value;return _[0]=o++,_[1]=e(...f),!0})},i}function cs(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 Kn(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 nt=(t)=>typeof t==="object"&&(B(t)||Array.isArray(t)||Kn(t));function Un(t){if(cs(t)&&typeof t!=="string")return t;if(P(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var wu=(t,e)=>B(t)?t.has(e):nt(t)&&Object.hasOwn(t,e);function Ln(t,e,r){return B(t)?t.get(e,r):!wu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function fs(t,e,r){let s=Un(e),i=0;while(i!==s.length)if(t=Ln(t,s[i++],d),t===d)return r;return t}var Dn=(t,e)=>fs(t,e,d)!==d;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!!(Pi(t)&&Pi(e)&&t.equals(e))}function Re(t){if(!t||typeof t!=="object")return t;if(!J(t)){if(!nt(t))return t;t=m(t)}if(w(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 _s(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||w(t)!==w(e)||I(t)!==I(e)||P(t)!==P(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!is(t);if(P(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&A(c[1],u)&&(r||A(c[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,d)):!A(t.get(u,d),h))return i=!1,!1;return!0});return i&&t.size===n}var Ye=(t)=>t>>>1&1073741824|t&3221225471;function Q(t){if(t===null||t===void 0)return ki(t);if(typeof t.hashCode==="function")return Ye(t.hashCode(t));let e=bu(t);if(e===null||e===void 0)return ki(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return zu(e);case"string":return e.length>qu?Su(e):Nr(e);case"object":case"function":return Mu(e);case"symbol":return Ou(e);default:if(typeof e.toString==="function")return Nr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var ki=(t)=>t===null?1108378658:1108378659;function zu(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 Ye(e)}function Su(t){let e=Pr[t];if(e===void 0){if(e=Nr(t),xr===Eu)xr=0,Pr={};xr++,Pr[t]=e}return e}function Nr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return Ye(e)}function Ou(t){let e=mi[t];if(e!==void 0)return e;return e=Wn(),mi[t]=e,e}function Mu(t){let e=Vi.get(t);if(e!==void 0)return e;return e=Wn(),Vi.set(t,e),e}var bu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Wn(){let t=++Br;if(Br&1073741824)Br=0;return t}var Vi=new WeakMap,mi=Object.create(null),Br=0,qu=16,Eu=255,xr=0,Pr={};function Iu(t){if(t.size===1/0)return 0;let e=P(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Ni(Q(i),Q(n))|0}:(i,n)=>{s=s+Ni(Q(i),Q(n))|0}:e?(i)=>{s=31*s+Q(i)|0}:(i)=>{s=s+Q(i)|0}),Au(t.size,s)}var Ni=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Au(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=Ye(e^e>>>16),e}function Ft(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:ns(t)?e:t.create?t.create(e):t.constructor(e),Tn=(t,e)=>O(t,(w(t)?C:I(t)?pt:gt)(e)),vi=(...t)=>t,V=(t)=>J(t)?t:m(t);class b{size=0;static{this.prototype[wn]=!0,this.prototype.__toStringMapper=Ft,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return _s(this,t)}hashCode(){return this.__hash??(this.__hash=Iu(this))}toArray(){j(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Xn(this)}toJS(){return Re(this)}toKeyedSeq(){return new zs(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){j(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 Gn(this)}toSeq(){return I(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!J(s))s=e?Jn(s):Zn(Array.isArray(s)?s:[s]);else if(e)s=C(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&&w(s)||I(this)&&I(s))return s}return O(this,new Hn(r))}includes(t){return this.some((e)=>A(e,t))}every(t,e){j(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=w(this),i=x(r);if(s)i.has=(n)=>{let h=r.get(n,d);return h!==d&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,d);return u!==d&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return q((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>Tn(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return j(this.size),this.__iterate(e?t.bind(e):t)}join(t){j(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 $;return e.value=r.value[0],e})}map(t,e){return O(this,An(this,t,e))}reduce(t,e=d,r){return Yi(this,t,e,r,e===d,!1)}reduceRight(t,e=d,r){return Yi(this,t,e,r,e===d,!0)}reverse(){return O(this,jn(this,w(this)))}slice(t,e){return O(this,$n(this,t,e,w(this)))}some(t,e){j(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,jt(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return D(()=>{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 $t(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(au).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Cr(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){return this.findEntry(t,e)?.[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(dn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(w(this)?C:I(this)?pt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(this),s=x(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(c,f){c.__iterate((_,l)=>{if((!t||f<t)&&J(_))o(_,f+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],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&J(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},O(this,s)}fromEntrySeq(){return new Qn(this)}get(t,e){return this.find((r,s)=>A(s,t),void 0,e)}getIn(t,e){return fs(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,d)!==d}hasIn(t){return Dn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:V(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:V(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>A(e,t))}keySeq(){return this.toSeq().map(lu).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Ke(this,t)}maxBy(t,e){return Ke(this,e,t)}min(t){return Ke(this,t?Bi(t):xi)}minBy(t,e){return Ke(this,e?Bi(e):xi,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=w(this),i=x(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return q((f)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(c&&t.call(e,a,l,o))continue;return c=!1,f[0]=s?l:u++,f[1]=a,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(Cr(t),e)}sortBy(t,e){return O(this,jt(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=x(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 $;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,$;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(Cr(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 C=(t)=>w(t)?t:ys(t);class ls extends b{static{this.prototype[We]=!0,this.prototype.__toStringMapper=(t,e)=>`${Ft(e)}: ${Ft(t)}`,this.prototype[Symbol.iterator]=b.prototype.entries,this.prototype.toJSON=function(){j(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,In(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 pt=(t)=>I(t)?t:yt(t);class at extends b{static{this.prototype[Te]=!0,this.prototype[it]=!0}toKeyedSeq(){return new zs(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=d,...r){if(t===void 0)return this;let s=e!==d;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Dt(t,t<0?this.count():this.size);let i=this.slice(0,t);return O(this,!s?i:i.concat(r,this.slice(t+e)))}findLastIndex(t,e){let r=this.findLastEntry(t,e);return r?r[0]:-1}first(t){return this.get(0,t)}get(t,e){return t=st(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=st(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=x(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((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=Yr(this.toSeq(),yt.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(vi,...t)}zipAll(...t){let e=[this,...t];return O(this,Yr(this,vi,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,Yr(this,t,r))}}var gt=(t)=>J(t)&&!is(t)?t:kt(t);class Be extends b{static{this.prototype.has=b.prototype.includes,this.prototype.contains=b.prototype.includes,this.prototype.keys=Be.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}V.Keyed=C;V.Indexed=pt;V.Set=gt;var Fr=at.prototype,m=(t)=>t===void 0||t===null?gs():B(t)?t.toSeq():ju(t),x=(t)=>Object.create((w(t)?Wt:I(t)?wt:ds).prototype);class _t extends b{static{this.prototype[he]=!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 $;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var as={cacheResult:_t.prototype.cacheResult,__iterateUncached:_t.prototype.__iterateUncached,__iterate:_t.prototype.__iterate,__iterator:_t.prototype.__iterator},ys=(t)=>t===void 0||t===null?gs().toKeyedSeq():J(t)?w(t)?t.toSeq():t.fromEntrySeq():dt(t)?t.toSeq():Jn(t);class Wt extends ls{static{this.prototype[he]=!0,Object.assign(this.prototype,as)}toSeq(){return this}toKeyedSeq(){return this}}var yt=(t)=>t===void 0||t===null?gs():J(t)?w(t)?t.entrySeq():t.toIndexedSeq():dt(t)?t.toSeq().entrySeq():Zn(t);yt.of=(...t)=>yt(t);class wt extends at{static{this.prototype[he]=!0,Object.assign(this.prototype,as)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var kt=(t)=>(J(t)&&!is(t)?t:yt(t)).toSetSeq();kt.of=(...t)=>kt(t);class ds extends Be{static{this.prototype[he]=!0,Object.assign(this.prototype,as)}toSeq(){return this}toSetSeq(){return this}}m.isSeq=ns;m.Keyed=ys;m.Set=kt;m.Indexed=yt;class ue extends wt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[st(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 ps extends Wt{static{this.prototype[it]=!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 Rn 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=yn(e);if(!du(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 gs=()=>new ue([]),ws=(t)=>cs(t)?new ue(t):ss(t)?new Rn(t):void 0;function Jn(t){let e=ws(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new ps(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Zn(t){let e=ws(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function ju(t){let e=ws(t);if(e)return pu(t)?e.fromEntrySeq():gu(t)?e.toSetSeq():e;if(typeof t==="object")return new ps(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Hn extends _t{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[We])this[We]=!0;if(i[Te])this[Te]=!0;if(i[it])this[it]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!w(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=!w(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()||$)}}class zs extends Wt{static{this.prototype[it]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Tt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=jn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=An(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 Xn extends wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)$t(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)$t(this);let r=this.size;return re(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Gn extends ds{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.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 re(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Qn extends Wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){tn(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){tn(i);let n=J(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Tt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return _t.prototype.cacheResult.call(this)}function tn(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var W=(t)=>t===void 0||t===null?Y():Ce(t)&&!P(t)?t:Y().withMutations((e)=>{let r=C(t);j(r.size),r.forEach((s,i)=>e.set(i,s))});class Vt extends ls{static{St(this,{asImmutable:fe,asMutable:_e,deleteIn:Kt,merge:vr,mergeWith:kn,mergeDeep:mn,mergeDeepWith:Nn,mergeDeepIn:Ks,mergeIn:$s,setIn:Is,update:As,updateIn:js,wasAltered:Es,withMutations:le,removeIn:Kt,concat:vr,[Sn]:!0,[se]: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 W(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,Q(t),t,e):e}set(t,e){return rn(this,t,e)}remove(t){return rn(this,t,d)}deleteAll(t){let e=V(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return Y()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ft();return Ue(this._root,!1,0)}values(){if(!this._root)return ft();return Ue(this._root,!1,1)}entries(){if(!this._root)return ft();return Ue(this._root,!1)}__iterator(t){if(!this._root)return ft();return Ue(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Y();return this.__ownerID=t,this.__altered=!1,this}return Ms(this.size,this._root,t,this.__hash)}}W.isMap=Ce;class Ss{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Cn(this.entries,r,s)}iterate(t,e){return Yn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===d,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(A(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(X(h),u||!_)X(n);if(u&&f===1)return;if(!_&&!u&&f>=Wu)return $u(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ss(t,a)}}class xe{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Bn(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[nn(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===d)return this;let _=nn(c&o-1),l=this.nodes,a=f?l[_]:void 0,y=bs(a,t,e+z,r,s,i,n,h);if(y===a)return this;if(!f&&y&&l.length>=Tu)return Uu(t,l,c,u,y);if(f&&!y&&l.length===2&&sn(l[_^1]))return l[_^1];if(f&&y&&l.length===1&&sn(y))return y;let g=t&&t===this.ownerID,S=f?y?c:c^o:c|o,T=f?y?xn(l,_,y,g):Du(l,_,g):Lu(l,_,y,g);if(g)return this.bitmap=S,this.nodes=T,this;return new xe(t,S,T)}}class Os{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Bn(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+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=i===d,c=this.nodes,f=c[u];if(o&&!f)return this;let _=bs(f,t,e+z,r,s,i,n,h);if(_===f)return this;let l=this.count;if(!f)l++;else if(!_){if(l--,l<Ru)return Ku(t,c,l,u)}let a=t&&t===this.ownerID,y=xn(c,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Os(t,l,y)}}class Pe{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Cn(this.entries,r,s)}iterate(t,e){return Yn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===d)return this;return X(h),X(n),qs(this,t,e,r,[s,i])}let u=i===d,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(A(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(X(h),u||!_)X(n);if(u&&f===2)return new zt(t,this.keyHash,o[c^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[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===d,o=A(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(X(h),u){X(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new zt(t,this.keyHash,[s,i])}return X(n),qs(this,t,e,Q(s),[s,i])}}function Cn(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 Yn(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 Bn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(t[r?i-s:s]?.iterate(e,r)===!1)return!1}function Ue(t,e,r){let s={node:t,index:0,__prev:null},i=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return 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 c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return $})}var Ms=(t,e,r,s)=>new Vt(t,e,r,s),en,Y=()=>en||(en=Ms(0));function rn(t,e,r){let s,i;if(!t._root){if(r===d)return t;i=1,s=new Ss(t.__ownerID,[[e,r]])}else{let n=mr(),h=mr();if(s=bs(t._root,t.__ownerID,0,Q(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===d?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?Ms(i,s):Y()}function bs(t,e,r,s,i,n,h,u){if(!t){if(n===d)return t;return X(u),X(h),new zt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var sn=(t)=>t.constructor===zt||t.constructor===Pe;function qs(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?[qs(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new xe(e,1<<n|1<<h,o)}function $u(t,e,r,s){if(!t)t=new Qe;let i=new zt(t,Q(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,Q(n),n,h);return i}function Ku(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new xe(t,i,h)}function Uu(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 Os(t,n+1,h)}function nn(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function xn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Lu(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 Du(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 Wu=E/4,Tu=E/2,Ru=E/4;function Je(t){if(Array.isArray(t))return t.slice();return{...t}}var cc=(t,...e)=>ce(t,e),fc=(t,e,...r)=>ce(e,r,t),oe=(t,e,r)=>ce(t,e,Ju(r)),_c=(t,...e)=>oe(t,e),lc=(t,e,...r)=>oe(e,r,t);function ce(t,e,r){if(!nt(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(B(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?pt:C,h=s?(u)=>{if(i===t)i=Je(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=Je(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Ju(t){function e(r,s,i){return nt(r)&&nt(s)&&Zu(r,s)?ce(r,[s],e):t?t(r,s,i):s}return e}function Zu(t,e){let r=m(t),s=m(e);return I(r)===I(s)&&w(r)===w(s)}function Hu(t,e){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(B(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 Xu(t,e,r){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(B(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=Pn(B(t),t,Un(e),0,r,s);return i===d?r:i}function Pn(t,e,r,s,i,n){let h=e===d;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!nt(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(Ft)}]: ${e}`);let u=r[s],o=h?d:Ln(e,u,d),c=Pn(o===d?t:B(o),o,r,s+1,i,n);if(c===o)return e;if(c===d)return Hu(e,u);let f=h?t?Y():{}:e;return Xu(f,u,c)}var Gu=(t,e)=>Rt(t,e,()=>d),Qu=(t,e,r)=>Rt(t,e,d,()=>r);function Fn(t,e,r,s){return Rt(t,[e],r,s)}function fe(){return this.__ensureOwner()}function _e(){return this.__ownerID?this:this.__ensureOwner(new Qe)}function Es(){return this.__altered}function le(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Cu(t,e){return fs(this,t,e)}function Yu(t){return Dn(this,t)}function Kt(t){return Gu(this,t)}function Is(t,e){return Qu(this,t,e)}function As(t,e,r){return typeof t==="function"?t(this):Fn(this,t,e,r)}function js(t,e,r){return Rt(this,t,e,r)}function hn(){j(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function vr(...t){return Vn(this,t)}function kn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Vn(this,e,t)}function Vn(t,e,r){let s=[];for(let i of e){let n=C(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 dt(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Fn(i,u,d,(o)=>o===d?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function mn(...t){return oe(this,t)}function Nn(t,...e){return oe(this,e,t)}function $s(t,...e){return Rt(this,t,Y(),(r)=>ce(r,e))}function Ks(t,...e){return Rt(this,t,Y(),(r)=>oe(r,e))}function St(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=mt();if(t===void 0||t===null)return e;if(qn(t))return t;let r=pt(t),s=r.size;if(s===0)return e;if(j(s),s>0&&s<E)return ae(0,s,z,null,new lt(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class vn extends at{static{St(this,{asImmutable:fe,asMutable:_e,deleteIn:Kt,mergeDeepIn:Ks,mergeIn:$s,setIn:Is,update:As,updateIn:js,wasAltered:Es,withMutations:le,removeIn:Kt,[zn]:!0,[se]: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 U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=st(this,t),t>=0&&t<this.size)return t+=this._origin,rh(this,t)?.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=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return mt()}push(...t){let e=this.size;return this.withMutations((r)=>{rt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return rt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{rt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return rt(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=pt(typeof r!=="string"&&ss(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 U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return rt(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(ie(t,e,r))return this;return rt(this,Dt(t,r),ne(e,r))}__iterate(t,e){let r=e?this.size:0;return Bu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=un(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 un(this,!1)}keys(){return Xe(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return mt();return this.__ownerID=t,this.__altered=!1,this}return ae(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=qn;class lt{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&K;if(s>=this.array.length)return new lt([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Ut(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:E)||this.array.length===0)return this;let s=r-1>>>e&K;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Ut(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function un(t,e){let{_origin:r,_capacity:s}=t,i=Lt(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 c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],l=c.level-z,a=c.offset+(f<<c.level);o(_,l,a)}return $});function o(c,f,_){if(f===0){let l=_===i?n?.array:c?.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=c?.array,a=_>r?0:r-_>>f,y=(s-_>>f)+1;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,level:f,offset:_,isLeaf:!1})}}}function Bu(t,e,r){let{_origin:s,_capacity:i}=t,n=Lt(i),h=t._tail,u=t._level,o=t._root;return u===0?th(o,0,s,i,n,h,e,r):eh(o,u,0,s,i,n,h,e,r)}function th(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,c=e>r?0:r-e,f=s-e;if(f>E)f=E;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function eh(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let l=e-z;while(f!==_){let a=o?--_:f++,y=r+(a<<e);if((l===0?th(c?.[a],y,s,i,n,h,u,o):eh(c?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ae=(t,e,r,s,i,n,h)=>new vn(t,e,r,s,i,n,h),mt=()=>ae(0,0,z);function xu(t,e,r){if(e=st(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)rt(h,e).set(0,r);else rt(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=mr();if(e>=Lt(t._capacity))s=ts(s,t.__ownerID,0,e,r,n);else i=ts(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 ae(t._origin,t._capacity,t._level,i,s)}function ts(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 c=t?.array[h],f=ts(c,e,r-z,s,i,n);if(f===c)return t;return o=Ut(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)X(n);if(o=Ut(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Ut(t,e){if(e&&e===t?.ownerID)return t;return new lt(t?.array.slice()??[],e)}function rh(t,e){if(e>=Lt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&K],s-=z;return r}}function rt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Qe,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:c}=t,f=0;while(h+f<0)c=new lt(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=Lt(n),l=Lt(u);while(l>=1<<o+z)c=new lt(c?.array.length?[c]:[],s),o+=z;let a=t._tail,y=l<_?rh(t,u-1):l>_?new lt([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Ut(c,s);let g=c;for(let S=o;S>z;S-=z){let T=_>>>S&K;g=g.array[T]=Ut(g.array[T],s)}g.array[_>>>z&K]=a}if(u<n)y=y?.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,c=null,y=y?.removeBefore(s,0,h);else if(h>i||l<_){f=0;while(c){let g=h>>>o&K;if(g!==l>>>o&K)break;if(g)f+=(1<<o)*g;o-=z,c=c.array[g]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&l<_)c=c.removeAfter(s,o,l-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return ae(h,u,o,c,y)}var Lt=(t)=>t<E?0:t-1>>>z<<z,L=(t)=>t===void 0||t===null?Nt():os(t)?t:Nt().withMutations((e)=>{let r=C(t);j(r.size),r.forEach((s,i)=>e.set(i,s))});L.of=(...t)=>L(t);class sh extends Vt{static{St(this,{[it]:!0,[se]: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 L(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 on(this,t,e)}remove(t){return on(this,t,d)}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)}}L.isOrderedMap=os;var Us=(t,e,r,s)=>new sh(t,e,r,s),Nt=()=>Us(Y(),mt());function on(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===d){if(!h)return t;if(i.size>=E&&i.size>=s.size*2){let c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=mt().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=Y().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 vt=(t)=>t===void 0||t===null?Ze():us(t)?t:Ze().pushAll(t);vt.of=(...t)=>vt(t);class ih extends at{static{St(this,{asImmutable:fe,asMutable:_e,wasAltered:Es,withMutations:le,[Mn]:!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 vt(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=st(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 kr(this,e,r)}pushAll(t){if(t=pt(t),t.size===0)return this;if(this.size===0&&us(t))return t;j(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),kr(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(ie(t,e,this.size))return this;let r=Dt(t,this.size);if(ne(e,this.size)!==this.size)return at.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return kr(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 Ls(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 $;return e.value=t.value,t=t.next,e})}keys(){return Xe(this.size)}}vt.isStack=us;function kr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Ls(e,r)}var Ls=(t,e,r,s)=>new ih(t,e,r,s),cn,Ze=()=>cn||(cn=Ls(0)),M=(t)=>t===void 0||t===null?ee():hs(t)&&!P(t)?t:ee().withMutations((e)=>{let r=gt(t);j(r.size),r.forEach((s)=>e.add(s))});M.of=(...t)=>M(t);M.fromKeys=(t)=>M(C(t).keySeq());M.intersect=(t)=>{return t=V(t).toArray(),t.length?M(t.pop()).intersect(...t):ee()};M.union=(t)=>{let e=V(t).toArray();return e.length?M(e.pop()).union(...e):ee()};class te extends Be{static{St(this,{withMutations:le,asImmutable:fe,asMutable:_e,[On]:!0,[se]: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 Le(this,this._map.set(t,t))}remove(t){return Le(this,this._map.remove(t))}clear(){return Le(this,this._map.clear())}map(t,e){let r=!1,s=Le(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 gt(r).forEach((s)=>e.add(s))})}intersect(...t){return _n(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return _n(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return ee()}__make(t,e){return nh(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=hs;var nh=(t,e)=>new te(t,e),fn,ee=()=>fn||(fn=nh(Y()));function _n(t,e,r){if(e.length===0)return t;return e=e.map((s)=>gt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Le(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 k=(t)=>t===void 0||t===null?es():En(t)?t:es().withMutations((e)=>{let r=gt(t);j(r.size),r.forEach((s)=>e.add(s))});k.of=(...t)=>k(t);k.fromKeys=(t)=>k(C(t).keySeq());class hh extends te{static{St(this,{[it]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Fr.zip,zipWith:Fr.zipWith,zipAll:Fr.zipAll})}create(t){return k(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return es()}__make(t,e){return uh(t,e)}}k.isOrderedSet=En;var uh=(t,e)=>new hh(t,e),es=()=>uh(Nt()),ac={LeftThenRight:-1,RightThenLeft:1};function Pu(t){if(dt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(B(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;Pu(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 c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Ds(this)} with property "${f}" since that property name is part of the Record API.`);else ku(i,f)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),C(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(Fu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class oh{static{St(this,{asImmutable:fe,asMutable:_e,deleteIn:Kt,getIn:Cu,hasIn:Yu,merge:vr,mergeWith:kn,mergeDeep:mn,mergeDeepWith:Nn,mergeDeepIn:Ks,mergeIn:$s,setIn:Is,toObject:hn,update:As,updateIn:js,withMutations:le,removeIn:Kt,toJSON:hn,[bn]:!0,[se]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${Ft(this.get(e))}`).join(", ");return`${Ds(this)} { ${t} }`}equals(t){return this===t||dt(t)&&At(this).equals(At(t))}hashCode(){return At(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 Vr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Vr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return At(this)}toJS(){return Re(this)}entries(){return this.__iterator()}__iterate(t,e){return At(this).__iterate(t,e)}__iterator(t){return At(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 Vr(this,e,t)}}Fe.isRecord=dt;var Ds=(t)=>t.constructor.displayName||t.constructor.name||"Record";class ch extends Wt{constructor(t){super();this._record=t,this.size=t._keys.length}get(t,e){return this._record.get(t,e)}has(t){return this._record.has(t)}__iterateUncached(t,e){let r=this._record,s=r._keys,i=s.length,n=0;while(n!==i){let h=e?i-++n:n++,u=s[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,s=r.length,i=0;return 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 At=(t)=>new ch(t);Fe.getDescriptiveName=Ds;var Fu=oh.prototype;function Vr(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function ku(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){Pt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var rs=(t,e,r=1)=>{if(Pt(r!==0,"Cannot step a Range by 0"),Pt(t!==void 0,"You must define a start value when using Range"),Pt(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 Ws(t,e,r,s)};class Ws 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+st(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(ie(t,e,this.size))return this;if(t=Dt(t,this.size),e=ne(e,this.size),e<=t)return rs(0,0);return rs(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 $;return i.value=r,r+=e,s++,i})}keys(){return Xe(this.size)}equals(t){return t instanceof Ws?this._start===t._start&&this._end===t._end&&this._step===t._step:_s(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var yc=(t,e)=>{let r=e===void 0?1/0:Math.max(0,e);return new He(t,r)};class He 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 ie(t,e,r)?this:new He(this._value,ne(e,r)-Dt(t,r))}reverse(){return this}indexOf(t){if(A(this._value,t))return 0;return-1}lastIndexOf(t){if(A(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,s=0;while(s!==r)if(t(this._value,e?r-++s:s++,this)===!1)break;return s}__iteratorUncached(t){let e=this.size,r=this._value,s=0;return 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 $;return r++,s.value=e,s})}keys(){return Xe(this.size)}equals(t){return t instanceof He?this.size===t.size&&A(this._value,t._value):_s(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var dc=(t,e)=>fh([],e??Vu,t,"",e?.length>2?[]:void 0,{"":t});function fh(t,e,r,s,i,n){if(typeof r!=="string"&&!B(r)&&(cs(r)||ss(r)||Kn(r))){if(t.includes(r))throw TypeError("Cannot convert circular structure to Immutable");if(t.push(r),i&&s!=="")i.push(s);let h=e.call(n,s,m(r).map((u,o)=>fh(t,e,u,o,i,r)),i?.slice());if(t.pop(),i)i.pop();return h}return r}var Vu=(t,e)=>I(e)?e.toList():w(e)?e.toMap():e.toSet(),De=(t)=>w(t)?t.valueSeq():t;function mu(){b.prototype.toMap=function(){return W(this.toKeyedSeq())},b.prototype.toOrderedMap=function(){return L(this.toKeyedSeq())},b.prototype.toOrderedSet=function(){return k(De(this))},b.prototype.toSet=function(){return M(De(this))},b.prototype.toStack=function(){return vt(De(this))},b.prototype.toList=function(){return U(De(this))},b.prototype.countBy=function(e,r){let s=W().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=w(this),i=(P(this)?L():W()).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)=>Tn(this,n)).asImmutable()},at.prototype.keySeq=function(){return rs(0,this.size)},Vt.prototype.sort=function(e){return L(jt(this,e))},Vt.prototype.sortBy=function(e,r){return L(jt(this,r,e))},te.prototype.sort=function(e){return k(jt(this,e))},te.prototype.sortBy=function(e,r){return k(jt(this,r,e))}}var Nu="7.0.0",vu={version:Nu};mu();var{version:pc}=vu;var _h=Symbol("BadValue"),dh=(t)=>t;class Z{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,_h);if(h===_h)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[s](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,i.defaultValue)},t[`is${r}NotSet`]=function(){return this.get(e)==null},t[`is${r}Set`]=function(){return this.get(e)!=null},this.extendProtoForType(t,r)}}class Rs{isValid(t){return!0}getMessage(t){return"Invalid"}}class ph extends Rs{}var to=new ph;class N extends Rs{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var eo=new N((t)=>Number.isInteger(t),()=>"Integer expected"),ro=new N((t)=>Number.isFinite(t),()=>"Float expected"),so=new N((t)=>typeof t==="boolean",()=>"Boolean expected"),io=new N((t)=>typeof t==="string",()=>"String expected"),no=new N((t)=>U.isList(t),()=>"List expected"),ho=new N((t)=>W.isMap(t),()=>"Map expected"),uo=new N((t)=>L.isOrderedMap(t),()=>"OrderedMap expected"),oo=new N((t)=>M.isSet(t),()=>"Set expected"),co=(t)=>!!t;class Js extends Z{constructor(t,e=!1){super("bool",t,so,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 ke extends Z{constructor(t,e=null){super("any",t,to,dh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ts(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var fo=(t)=>t?.toString?.()??"";class Zs extends Z{constructor(t,e=""){super("text",t,io,fo,e)}extendProtoForType(t,e){Cs(t,this.name,e,"","length")}}var _o=(t)=>Number.isFinite(t)?Math.trunc(t):null;class gh extends Z{constructor(t,e=0){super("int",t,eo,_o,e)}}var lo=(t)=>null;class Hs extends Z{constructor(t,e=0){super("float",t,ro,lo,e)}}var Ts=(t)=>t?.constructor?.getMetaClass?.()?.name;class wh{constructor(t){this.typeName=t}isValid(t){return Ts(t)===this.typeName}getMessage(t){let e=Ts(t);return`Expected "${this.typeName}", got "${e}"`}}class zh extends Z{constructor(t,e,r){super(t,e,new wh(t),dh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var lh=Symbol("NONE");function Jt(t,e,r){Cs(t,e,r,Oh),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,lh);if(h!==lh)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},Sh(t,e,`${r}At`)}function Sh(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var Oh=U(),ao=(t)=>Array.isArray(t)?U(t):null;class Xs extends Z{constructor(t,e=Oh){super("list",t,no,ao,e)}extendProtoForType(t,e){let{name:r}=this;Jt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var yo=(t)=>W(t);class Gs extends Z{constructor(t,e=W()){super("map",t,ho,yo,e)}extendProtoForType(t,e){Jt(t,this.name,e)}}var po=(t)=>L(t);class Qs extends Z{constructor(t,e=L()){super("omap",t,uo,po,e)}extendProtoForType(t,e){Jt(t,this.name,e)}}function Cs(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 ah=M(),go=(t)=>Array.isArray(t)?M(t):t instanceof Set?M(t):null;class Ys extends Z{constructor(t,e=ah){super("set",t,oo,go,e)}extendProtoForType(t,e){let{name:r}=this;Cs(t,r,e,ah),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},Sh(t,r,e),t[`hasIn${e}`]=function(s){return this.get(r).has(s)},t[`toggleIn${e}`]=function(s){let i=this.get(r);return this.set(r,i.has(s)?i.delete(s):i.add(s))}}}function yh(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 Mh{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]=yh(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]=yh(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]:Fe(t,r)}[r];Object.assign(n.prototype,e,s);let h={fields:i,name:r,methods:s};return Object.assign(n,this._statics,{getMetaClass:()=>h}),n}methods(t){return this._mergeProto(this._methods,t,"method")}statics(t){return this._mergeProto(this._statics,t,"static")}_mergeProto(t,e,r){for(let s in e)t[s]=e[s];return this}addField(t,e,r){let s=new r(t,e);return this.fields[t]=s,s}addCompField(t,e,r){let s=new zh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var Ve=new Map,wo={text:Zs,int:gh,float:Hs,bool:Js,list:Xs,map:Gs,omap:Qs,set:Ys,any:ke};function zo(t,{fields:e={},methods:r,statics:s}){let i=new Mh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Zs);else if(u==="number")i.addField(n,h,Hs);else if(u==="boolean")i.addField(n,h,Js);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),Xs);else if(M.isSet(h)||h instanceof Set)i.addField(n,M(h),Ys);else if(L.isOrderedMap(h))i.addField(n,h,Qs);else if(h?.type&&h?.defaultValue!==void 0){let o=wo[h.type]??ke;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(W.isMap(h)||h?.constructor===Object)i.addField(n,W(h),Gs);else{let o=Ve.get(h?.constructor)??ke;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var So=(t)=>new Ur(t.name??"Comp",zo(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 Oo=["nid","cid","eid","vid","si","sk"];class Bs{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.renderComment=s,this.renderFn=i,this.getSeqInfo=n??Ao,this.cache=h??new Ar}setNullCache(){this.cache=new Ir}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 Oo)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,this.renderView(o,t)]);return this.cache.set(e,h,f),f}pushEachEntry(t,e,r,s,i){t.push(this.renderMetadata("Each",{nid:e,[r]:s}),i)}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,f)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);this.pushEachEntry(c,r,u,_,y)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=[],_=h.call(t.it,i);for(let[l,a]of c(i))if(n.call(t.it,l,a,_)){let y={key:l,value:a},g=`${s}-${l}`,S;if(u)u.call(t.it,y,l,a,_),S=this.cache.get2(t.it,a,g);else S=this.cache.get(a,g);if(S){this.pushEachEntry(f,s,o,l,S);continue}let T=t.enter(a,y,!1),v=this.renderView(r,T);if(this.pushEachEntry(f,s,o,l,v),u)this.cache.set2(t.it,a,g,v);else this.cache.set(a,g,v)}return f}renderView(t,e){return t.render(e,this)}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderEmpty(){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*Mo(t){let e=0;for(let r of t)yield[e++,r]}function*bo(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var me=new Map,qo=["si",Mo],Eo=["sk",bo],Io=["si",function*(e){}];function Ao(t){return I(t)?qo:w(t)?Eo:me.get(t?.constructor)??Io}class Ot{constructor(t=W(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new Ot(t,e,this.$)}toJS(){return this.order.toArray().map((t)=>this.items.get(t))}set(t,e){let r=this.items.has(t)?this.order:this.order.push(t);return this._clonish(this.items.set(t,e),r,this.$)}get(t,e=null){return this.items.get(t,e)}_nextFreeKey(){let t=this.$;while(!0){let e=`§${t}§`;if(!this.items.has(e))return[e,t];t+=1}}push(t){let[e,r]=this._nextFreeKey(),s=this.set(e,t);return s.$=r,s}get size(){return this.items.size}delete(t){if(this.items.has(t)){let e=this.order.delete(this.order.indexOf(t));return this._clonish(this.items.delete(t),e)}return this}moveKeyBeforeKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),0)}moveKeyAfterKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),1)}moveKeyIndexToIndex(t,e,r){if(t===-1||e===-1||t===e)return this;let{order:s}=this,i=e+r,n=i<t?t+1:t,h=s.insert(i,s.get(t)).delete(n);return this._clonish(this.items,h)}}var jo=(t)=>null;class bh{isValid(t){return t instanceof Ot}getMessage(t){return"KList expected"}}var $o=new bh;class qh extends Z{constructor(t,e=new Ot){super("KList",t,$o,jo,e)}extendProtoForType(t,e){Jt(t,this.name,e);let{name:r}=this;Jt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}Ve.set(Ot,qh);function*Ko(t){for(let e of t.order)yield[e,t.items.get(e)]}me.set(Ot,["data-sk",Ko]);var Ps=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),ye=(t)=>t!==null&&typeof t==="object",Ih=(t,e)=>Object.getPrototypeOf(t)!==Object.getPrototypeOf(e);function Ah(t,e,r){for(let s in e){let i=e[s];if(i===void 0)Uo(t,s,r);else if(Ps(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(ye(i))Lo(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function Uo(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.replaceChildren();else if(e==="className")t.removeAttribute("class");else if(e==="htmlFor")t.removeAttribute("for");else if(typeof s==="string"||Ps(e))t.removeAttribute(e);else t[e]=null}function Lo(t,e,r,s){let i=e?.[r];if(ye(i)&&Ih(i,s)){t[r]=s;return}if(!ye(t[r]))t[r]={};let n=t[r];for(let h in s)n[h]=s[h]}class Zt{}var xs=(t)=>t instanceof tr?t.key:void 0,Do=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function jh(t,e){for(let r=0;r<t.length;r++)if(!t[r].isEqualTo(e[r]))return!1;return!0}function Fs(t,e,r){for(let s of e)t.appendChild(s.toDom(r))}function ks(t,e){if(e==null)return;if(Do(e))for(let r of e)ks(t,r);else if(e instanceof Zt)if(e instanceof Mt)t.push(...e.childs);else t.push(e);else t.push(new Vs(e))}class Vs extends Zt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof Vs&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class ve extends Zt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof ve&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class Mt extends Zt{constructor(t){super();this.childs=[],ks(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof Mt)||this.childs.length!==t.childs.length)return!1;return jh(this.childs,t.childs)}toDom(t){let e=t.document.createDocumentFragment();return Fs(e,this.childs,t),e}}class tr extends Zt{constructor(t,e,r,s,i){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i==="string"?i:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof tr)||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;return jh(this.childs,t.childs)}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);return Ah(r,this.attrs,{}),Fs(r,this.childs,t),r}}function $h(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)continue;if(ye(i)&&ye(n))if(Ih(n,i))r??={},r[s]=n;else{let h=$h(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 Kh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;let i=e.nodeType;if(i===r.nodeType){if(i===3||i===8)return t.data=r.text,t;if(i===1&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let h=$h(e.attrs,r.attrs);if(h)Ah(t,h,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)Eh(t,e.childs,r.childs,s);return t}if(i===11)return Eh(t,e.childs,r.childs,s),t}let n=r.toDom(s);return t.parentNode?.replaceChild(n,t),n}function Eh(t,e,r,s){if(e.length===0){Fs(t,r,s);return}if(r.length===0){t.replaceChildren();return}let i=Array.from(t.childNodes),n=Object.create(null);for(let o=0;o<e.length;o++){let c=xs(e[o]);if(c!=null)n[c]=o}let h=new Uint8Array(e.length),u=0;for(let o=0;o<r.length;o++){let c=r[o],f=xs(c),_=-1;if(f!=null){if(f in n&&!h[n[f]])_=n[f]}else while(u<e.length){if(!h[u]&&xs(e[u])==null){_=u++;break}u++}if(_>=0){h[_]=1;let l=Kh(i[_],e[_],c,s),a=t.childNodes[o]??null;if(l!==a)t.insertBefore(l,a)}else{let l=t.childNodes[o]??null;t.insertBefore(c.toDom(s),l)}}for(let o=e.length-1;o>=0;o--)if(!h[o]&&i[o].parentNode===t)t.removeChild(i[o])}var Ne=new WeakMap;function Uh(t,e,r){let s=Ne.get(e),i=t instanceof Mt;if(s&&s.vnode instanceof Mt===i){let h=i?e:s.dom,u=Kh(h,s.vnode,t,r);return Ne.set(e,{vnode:t,dom:i?e:u}),u}Ne.delete(e);let n=t.toDom(r);return e.replaceChildren(n),Ne.set(e,{vnode:t,dom:i?e:n}),n}function Lh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e){let c=e[o];switch(o){case"key":n=c;break;case"namespace":h=c;break;case"class":i.className=c;break;case"for":i.htmlFor=c;break;default:i[o]=Ps(o)?String(c):c}}let u=[];return ks(u,r),new tr(s,i,u,n,h)}var{raw:Wc,raw:Tc}=String;function Rc(t,e){return new Sr(t,e)}var Wo=(t)=>typeof t==="string"?document.querySelector(t):t;function Jc(t){let e=Wo(t),r=new Ie,s=(o)=>new Mt(o),i=(o)=>new ve(o),n={document},h=(o,c)=>Uh(o,c,n),u=new Bs(r,Lh,s,i,h);return new Qr(e,h,r,u,ct)}async function Pc(t,e,r="margaui-css"){let s=performance.now(),i=await To(t,e),n=performance.now();return je(r,i),n-s}async function To(t,e,r,s=$e){t.ParseContext=s,t.compile();let i=new Set(r??[]);for(let n of t.comps.byId.values())for(let h in n.views){let u=n.views[h];for(let o of u.ctx.classes)i.add(o)}return await e(Array.from(i))}export{pc as version,Rt as updateIn,Fn as update,Jc as tutuca,Qu as setIn,Xu as set,me as seqInfoByClass,Gu as removeIn,Hu as remove,fc as mergeWith,lc as mergeDeepWith,_c as mergeDeep,cc as merge,Rc as macro,Pi as isValueObject,us as isStack,hs as isSet,ns as isSeq,dt as isRecord,Kn as isPlainObject,En as isOrderedSet,os as isOrderedMap,P as isOrdered,os as isOMap,Ce as isMap,qn as isList,w as isKeyed,I as isIndexed,B as isImmutable,Ce as isIMap,J as isCollection,is as isAssociative,A as is,je as injectCss,Tc as html,Q as hash,Dn as hasIn,wu as has,fs as getIn,Ln as get,dc as fromJS,Ve as fieldsByClass,Wc as css,So as component,To as compileClassesToStyleText,Pc as compileClassesToStyle,vt as Stack,M as Set,m as Seq,yc as Repeat,Fe as Record,rs as Range,ct as ParseContext,ac as PairSorting,k as OrderedSet,L as OrderedMap,L as OMap,W as Map,U as List,Ot as KList,M as ISet,W as IMap,V as Collection};
|
package/dist/tutuca.js
CHANGED
|
@@ -1202,7 +1202,8 @@ class RenderNode extends RenderViewId {
|
|
|
1202
1202
|
|
|
1203
1203
|
class RenderItNode extends RenderViewId {
|
|
1204
1204
|
render(stack, rx) {
|
|
1205
|
-
|
|
1205
|
+
const newStack = stack.enter(stack.it, {}, true);
|
|
1206
|
+
return rx.renderIt(newStack, this.nodeId, "", this.viewId);
|
|
1206
1207
|
}
|
|
1207
1208
|
pathInNext = true;
|
|
1208
1209
|
}
|
package/dist/tutuca.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class Jt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Ot extends Jt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Ot({...this.binds,key:t})}withKey(t){return new Ot({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class ae extends Jt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new Ne(this.field,t)}withKey(t){return new Ve(this.field,t)}}class ke extends Jt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class Ve extends ke{}class Ne extends ke{}var W=Symbol("NONE");class me extends Jt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,W),s=t?.get(this.keyField,W);return s!==W&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,W),s=t?.get(this.keyField,W);return r===W||s===W?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class tt{constructor(t=[]){this.steps=t}concat(t){return new tt(this.steps.concat(t))}popStep(){return new tt(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,W),r===W)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,W),s===W)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,W),r===W)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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=Fs(t.previousSibling),{eid:d,cid:S,vid:D}=t.dataset;if(d!==void 0)o.push(d);if(S!==void 0){let v=i.getComponentForId(+S,D);if(_){if(c=Uh(v,o,D,e),c===null&&n)return Kh;_=!1}let Ps=$h(v,f,D);if(Ps)h.push(Ps);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new tt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return tt.fromNodeAndEventName(h,n,e,r,s,i)}}var xs={};function Fs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Fs(t.previousSibling);if(e!==xs)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return xs}function Uh(t,e,r,s){for(let i of e){let n=t.getEventForId(+i,r).getHandlersFor(s);if(n!==null)return n}return null}function $h(t,e,r){for(let s=0;s<e.length;s++){let i=t.getNodeForId(+e[s].nid,r),n=i.pathInNext?s+1:s,{si:h,sk:u,nid:o}=e[n],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Kh=[null,null];class ve{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new ae(t))}index(t,e){return this.add(new Ne(t,e))}key(t,e){return this.add(new Ve(t,e))}}var Lh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ht=(t)=>Lh.test(t),Dh=/^-?[0-9]+(\.[0-9]+)?$/,ks=(t,e)=>er.parse(t,e),Tt=(t,e)=>new C(t),Wh=(t,e)=>ht(t)?new ut(t):null,Rh=(t,e)=>ht(t)?new ti(t):null,Jh=(t,e)=>ht(t)?new sr(t):null,Th=(t,e)=>ht(t)?new si(t):null,Zh=(t,e)=>ht(t)?new ii(t):null,Hh=(t,e)=>ht(t)?new ni(t):null,Xh=(t,e)=>ht(t)?new ei(t):null;class Vs{constructor(){this.allowFieldOnly(),this.bindValIt=new sr("it"),this.nullConstVal=new C(null)}const(t){return new C(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}_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 hi(s,i):null}parse(t,e){switch(Gh(t)){case ui:return this.okStrTpl?ks(t,e):null;case ci:return this.okStrTpl?Tt(t,e):null;case oi:return this._parseSeqAccess(t,e);case ye:return this.okStrTpl?ks(t,e):null}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.okStrTpl?Tt(t.slice(1),e):null;case 39:return this.okStrTpl?Tt(t.slice(1,-1),e):null;case 64:return this.okBind?Jh(t.slice(1),e):null;case 42:return this.okDyn?Th(t.slice(1),e):null;case 46:return this.okField?Zh(t.slice(1),e):null;case 36:return this.okComputed?Hh(t.slice(1),e):null;case 33:return this.okRequest?Xh(t.slice(1),e):null}let s=Dh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.okConst?Tt(s,e):null;else if(t==="true"||t==="false")return this.okConst?Tt(t==="true",e):null;else if(r>=97&&r<=122)return this.okName?Wh(t,e):null;else if(r>=65&&r<=90)return this.okType?Rh(t,e):null;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,Ns)}parseAlter(t,e){return this._parseHandler(t,e,ms)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class ge{render(t,e){}eval(t){}toPathItem(){return null}}class C extends ge{constructor(t){super();this.val=t}render(t,e){return this.val}eval(t){return this.val}toString(){let t=this.val;return typeof t==="string"?`'${t}'`:`${t}`}}class tr extends ge{}class er extends tr{constructor(t){super();this.vals=t}render(t,e){return this.eval(t)}eval(t){let e=Array(this.vals.length);for(let r=0;r<this.vals.length;r++)e[r]=this.vals[r]?.eval(t,"");return e.join("")}static parse(t,e){let r=t.split(/(\{[^}]+\})/g),s=Array(r.length),i=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?p.parseText(h.slice(1,-1),e):new C(h);s[n]=o,i&&=o instanceof C}return i?new C(s.map((n)=>n.val).join("")):new er(s)}}class ut extends tr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Ns extends ut{eval(t){return t.getHandlerFor(this.name,"input")??vs("input",this.name)}}class ms extends ut{eval(t){return t.getHandlerFor(this.name,"alter")??vs("alter",this.name)}}var vs=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ti extends ut{eval(t){return t.lookupType(this.name)}}class ei extends ut{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class ri extends ut{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class rr extends ge{render(t,e){return this.eval(t)}}class Zt extends rr{constructor(t){super();this.name=t}}class sr extends Zt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class si extends Zt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ii extends Zt{eval(t){return t.lookupField(this.name)}toPathItem(){return new ae(this.name)}toRawFieldVal(){return new ri(this.name)}toString(){return`.${this.name}`}}class ni extends Zt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class hi extends rr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new me(this.seqVal.name,this.keyVal.name)}eval(t){let e=this.keyVal.eval(t);return this.seqVal.eval(t).get(e,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}}var ui=0,oi=1,ye=2,ci=3;function Gh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return ye;e+=1;break;case 93:if(r>0||e===0)return ye;r+=1;break;case 123:return ui;case 125:return ci}if(e>0||r>0)return e===1&&r===1?oi:ye;return-1}var p=new Vs;class Mt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return ur(e).parse(t,r)}isConstant(){return!1}}var Qh="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",Yh=new Set(Qh.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 C)}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 ai(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)??Ht}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Ht}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=or.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new pe("data-eid",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new li(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===""&&Yh.has(n)?!0:h;this.attrs.push(new pe(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new _i(r):nr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class nr extends Mt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.val.eval(null);return new nr(e)}setDataAttr(t,e){this.items[t]=e}toMacroVars(){let t={};for(let e in this.items)t[e]=`'${this.items[e]}'`;return t}isConstant(){return!0}}class _i extends Mt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new pe(t,new C(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.val.toString();return t}}class hr{constructor(t){this.name=t}}class de extends hr{constructor(t,e){super(t);this.val=e}eval(t){return this.val.eval(t)}}class pe extends de{}class li extends de{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.val.eval(t)}`}}}var Ht=p.nullConstVal;class ai extends hr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ht}get anyBranchIsSet(){return this.thenVal!==Ht||this.elseVal!==Ht}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var ir=null;function ur(t){return ir??=new fi(t),ir.clear(t),ir}class or{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=p.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);p.allowHandlerArg();for(let h=0;h<s.length;h++){let u=p.parse(s[h],e);n[h]=u!==null?u:p.nullConstVal}return new or(i,n)}}class 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 Qt extends qt{constructor(t){super();this.val=t}render(t,e){return e.renderText(this.val)}isWhiteSpace(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.val=""}isConstant(){return!0}setDataAttr(t,e){}}class Gt extends Qt{render(t,e){return e.renderComment(this.val)}}function Bh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new pr(r);else r.optimize()}}function lr(t){if(t.isConstant())return new pr(t);return t.optimize(),t}class ar extends qt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Bh(this.childs)}}class we extends ar{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class ze extends ar{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 Xt=(t)=>t.length===1?t[0]:new ze(t),Ch=/^[a-zA-Z][a-zA-Z0-9-]*$/,yi=null;class et extends qt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){yi??=e.newDOMParser();let r=yi.parseFromString(t,"text/html").body.childNodes;return et.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Qt(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]=et.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return Xt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Oe(null,p.const(u),Xt(n));case"text":{let c=p.parseText(u,e);return c!==null?new _r(null,c):null}case"render":return e.addNodeIf(Oi,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(Mi,p.bindValIt,o);case"render-each":return gr.parse(e,p,u,o,s);case"show":return e.addNodeIf(dr,p.parseCondValue(u,e),Xt(n));case"hide":return e.addNodeIf(wr,p.parseCondValue(u,e),Xt(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 c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??Xt(n)}let[u,o]=Mt.parse(s,e,!0);return e.onAttributes(u,o,null),gi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Ch.test(i)){let[h,u,o]=Mt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new _r(null,o));let c=i!=="PRE"?Vh(n):n;return gi(new we(i.toLowerCase(),h,c),e,u)}return new Gt(`Error: InvalidTagName ${i}`)}}function gi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Ph(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Ph(t,e){let r=kh[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=lr(this.node)}}class yr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Se extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class Oi extends Se{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Mi extends Se{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class gr extends Se{constructor(t,e,r){super(t,e,r);this.iterInfo=new zr(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(gr,e.parseEach(r,t),s);if(n!==null){let h=ur(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=i.getNamedItem("when");u&&h._parseWhen(u.value);let o=i.getNamedItem("loop-with");o&&h._parseLoopWith(o.value),n.iterInfo.whenVal=h.eachAttr.whenVal??null,n.iterInfo.loopWithVal=h.eachAttr.loopWithVal??null}return n}}class _r extends et{render(t,e){return e.renderText(this.val.eval(t))}}class pr 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 et{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=lr(this.node)}static register=!1}class dr extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class wr extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class qi extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Oe 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 Ot({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Ei extends ot{constructor(t,e){super(t,e);this.iterInfo=new zr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Ot({})}static register=!0}class zr{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)??xh,s=this.loopWithVal?.eval(t)??Fh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var xh=(t,e,r)=>!0,Fh=(t)=>({seq:t}),kh={slot:Oe,show:dr,hide:wr,each:Ei,scope:bi,"push-view":qi};class Yt{constructor(t,e,r,s,i,n,h,u){this.nodes=s??[],this.events=i??[],this.macroNodes=n??[],this.parent=u??null,this.frame=h??{},this.DOMParser=t??globalThis.DOMParser,this.Text=e??globalThis.Text,this.Comment=r??globalThis.Comment,this.cacheConstNodes=!0}isInsideMacro(t){return this.frame.macroName===t||this.parent?.isInsideMacro(t)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new Yt(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this)}newDOMParser(){return new this.DOMParser}isTextNode(t){return t instanceof this.Text}isCommentNode(t){return t instanceof this.Comment}addNodeIf(t,e,r){if(e!==null){let s=this.nodes.length,i=new t(s,e,r);return this.nodes.push(i),i}return null}registerEvents(){let t=this.events.length,e=new ji(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new ze(s)};for(let h of r)if(h instanceof Oe)i[h.val.val]=h.node;else if(!(h instanceof Qt)||!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 fr=(t)=>t instanceof Qt&&t.isWhiteSpace(),pi=(t)=>t instanceof we||t instanceof ze&&t.childs[0]instanceof we;function Vh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(fr(t[0]))r=1,s=!0;if(e>1&&fr(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(fr(n)&&pi(t[i-1])&&pi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Me{constructor(t,e,r="",s=null,i=null){this.name=t,this.anode=s,this.style=r,this.ctx=i,this.rawView=e}compile(t,e,r){if(this.ctx=t,this.anode=et.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=lr(this.anode)}render(t,e){return this.anode.render(t,e)}}class ji{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Ii(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 Ii{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=ru(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 Nh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),qe=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,di=(t)=>qe((e)=>e.e.key===t),wi=qe(({e:t})=>Nh&&t.metaKey||t.ctrlKey),mh=qe(({e:t})=>t.metaKey),vh=qe(({e:t})=>t.altKey),zi={ctrl:wi,cmd:wi,meta:mh,alt:vh},tu={keydown:{send:di("Enter"),cancel:di("Escape"),...zi},click:{...zi}},eu=(t,e)=>t;function ru(t,e){if(e.length===0)return eu;let r=tu[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 Sr{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 Or{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 Mr{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 be{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new qr}setNullComputedCache(){this.computedCache=new Mr}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:Ui}getHandlerFor(t,e,r){return this.getCompFor(t)?.[r][e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getHandlerFor(t,e,"computed");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(`
|
|
1
|
+
class Jt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Ot extends Jt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Ot({...this.binds,key:t})}withKey(t){return new Ot({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class ae extends Jt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new Ne(this.field,t)}withKey(t){return new Ve(this.field,t)}}class ke extends Jt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class Ve extends ke{}class Ne extends ke{}var W=Symbol("NONE");class me extends Jt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,W),s=t?.get(this.keyField,W);return s!==W&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,W),s=t?.get(this.keyField,W);return r===W||s===W?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class tt{constructor(t=[]){this.steps=t}concat(t){return new tt(this.steps.concat(t))}popStep(){return new tt(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,W),r===W)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,W),s===W)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,W),r===W)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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=Fs(t.previousSibling),{eid:d,cid:S,vid:D}=t.dataset;if(d!==void 0)o.push(d);if(S!==void 0){let v=i.getComponentForId(+S,D);if(_){if(c=Uh(v,o,D,e),c===null&&n)return Kh;_=!1}let Ps=$h(v,f,D);if(Ps)h.push(Ps);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new tt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return tt.fromNodeAndEventName(h,n,e,r,s,i)}}var xs={};function Fs(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Fs(t.previousSibling);if(e!==xs)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return xs}function Uh(t,e,r,s){for(let i of e){let n=t.getEventForId(+i,r).getHandlersFor(s);if(n!==null)return n}return null}function $h(t,e,r){for(let s=0;s<e.length;s++){let i=t.getNodeForId(+e[s].nid,r),n=i.pathInNext?s+1:s,{si:h,sk:u,nid:o}=e[n],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Kh=[null,null];class ve{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new ae(t))}index(t,e){return this.add(new Ne(t,e))}key(t,e){return this.add(new Ve(t,e))}}var Lh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ht=(t)=>Lh.test(t),Dh=/^-?[0-9]+(\.[0-9]+)?$/,ks=(t,e)=>er.parse(t,e),Tt=(t,e)=>new C(t),Wh=(t,e)=>ht(t)?new ut(t):null,Rh=(t,e)=>ht(t)?new ti(t):null,Jh=(t,e)=>ht(t)?new sr(t):null,Th=(t,e)=>ht(t)?new si(t):null,Zh=(t,e)=>ht(t)?new ii(t):null,Hh=(t,e)=>ht(t)?new ni(t):null,Xh=(t,e)=>ht(t)?new ei(t):null;class Vs{constructor(){this.allowFieldOnly(),this.bindValIt=new sr("it"),this.nullConstVal=new C(null)}const(t){return new C(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}_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 hi(s,i):null}parse(t,e){switch(Gh(t)){case ui:return this.okStrTpl?ks(t,e):null;case ci:return this.okStrTpl?Tt(t,e):null;case oi:return this._parseSeqAccess(t,e);case ye:return this.okStrTpl?ks(t,e):null}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.okStrTpl?Tt(t.slice(1),e):null;case 39:return this.okStrTpl?Tt(t.slice(1,-1),e):null;case 64:return this.okBind?Jh(t.slice(1),e):null;case 42:return this.okDyn?Th(t.slice(1),e):null;case 46:return this.okField?Zh(t.slice(1),e):null;case 36:return this.okComputed?Hh(t.slice(1),e):null;case 33:return this.okRequest?Xh(t.slice(1),e):null}let s=Dh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.okConst?Tt(s,e):null;else if(t==="true"||t==="false")return this.okConst?Tt(t==="true",e):null;else if(r>=97&&r<=122)return this.okName?Wh(t,e):null;else if(r>=65&&r<=90)return this.okType?Rh(t,e):null;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,Ns)}parseAlter(t,e){return this._parseHandler(t,e,ms)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class ge{render(t,e){}eval(t){}toPathItem(){return null}}class C extends ge{constructor(t){super();this.val=t}render(t,e){return this.val}eval(t){return this.val}toString(){let t=this.val;return typeof t==="string"?`'${t}'`:`${t}`}}class tr extends ge{}class er extends tr{constructor(t){super();this.vals=t}render(t,e){return this.eval(t)}eval(t){let e=Array(this.vals.length);for(let r=0;r<this.vals.length;r++)e[r]=this.vals[r]?.eval(t,"");return e.join("")}static parse(t,e){let r=t.split(/(\{[^}]+\})/g),s=Array(r.length),i=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?p.parseText(h.slice(1,-1),e):new C(h);s[n]=o,i&&=o instanceof C}return i?new C(s.map((n)=>n.val).join("")):new er(s)}}class ut extends tr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Ns extends ut{eval(t){return t.getHandlerFor(this.name,"input")??vs("input",this.name)}}class ms extends ut{eval(t){return t.getHandlerFor(this.name,"alter")??vs("alter",this.name)}}var vs=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ti extends ut{eval(t){return t.lookupType(this.name)}}class ei extends ut{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class ri extends ut{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class rr extends ge{render(t,e){return this.eval(t)}}class Zt extends rr{constructor(t){super();this.name=t}}class sr extends Zt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class si extends Zt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ii extends Zt{eval(t){return t.lookupField(this.name)}toPathItem(){return new ae(this.name)}toRawFieldVal(){return new ri(this.name)}toString(){return`.${this.name}`}}class ni extends Zt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class hi extends rr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new me(this.seqVal.name,this.keyVal.name)}eval(t){let e=this.keyVal.eval(t);return this.seqVal.eval(t).get(e,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}}var ui=0,oi=1,ye=2,ci=3;function Gh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return ye;e+=1;break;case 93:if(r>0||e===0)return ye;r+=1;break;case 123:return ui;case 125:return ci}if(e>0||r>0)return e===1&&r===1?oi:ye;return-1}var p=new Vs;class Mt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return ur(e).parse(t,r)}isConstant(){return!1}}var Qh="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",Yh=new Set(Qh.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 C)}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 ai(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)??Ht}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Ht}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=or.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new pe("data-eid",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new li(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===""&&Yh.has(n)?!0:h;this.attrs.push(new pe(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new _i(r):nr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class nr extends Mt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.val.eval(null);return new nr(e)}setDataAttr(t,e){this.items[t]=e}toMacroVars(){let t={};for(let e in this.items)t[e]=`'${this.items[e]}'`;return t}isConstant(){return!0}}class _i extends Mt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new pe(t,new C(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.val.toString();return t}}class hr{constructor(t){this.name=t}}class de extends hr{constructor(t,e){super(t);this.val=e}eval(t){return this.val.eval(t)}}class pe extends de{}class li extends de{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.val.eval(t)}`}}}var Ht=p.nullConstVal;class ai extends hr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ht}get anyBranchIsSet(){return this.thenVal!==Ht||this.elseVal!==Ht}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var ir=null;function ur(t){return ir??=new fi(t),ir.clear(t),ir}class or{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=p.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);p.allowHandlerArg();for(let h=0;h<s.length;h++){let u=p.parse(s[h],e);n[h]=u!==null?u:p.nullConstVal}return new or(i,n)}}class 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 Qt extends qt{constructor(t){super();this.val=t}render(t,e){return e.renderText(this.val)}isWhiteSpace(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.val.length;t++){let e=this.val.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.val=""}isConstant(){return!0}setDataAttr(t,e){}}class Gt extends Qt{render(t,e){return e.renderComment(this.val)}}function Bh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new pr(r);else r.optimize()}}function lr(t){if(t.isConstant())return new pr(t);return t.optimize(),t}class ar extends qt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Bh(this.childs)}}class we extends ar{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class ze extends ar{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 Xt=(t)=>t.length===1?t[0]:new ze(t),Ch=/^[a-zA-Z][a-zA-Z0-9-]*$/,yi=null;class et extends qt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){yi??=e.newDOMParser();let r=yi.parseFromString(t,"text/html").body.childNodes;return et.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Qt(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]=et.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return Xt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Oe(null,p.const(u),Xt(n));case"text":{let c=p.parseText(u,e);return c!==null?new _r(null,c):null}case"render":return e.addNodeIf(Oi,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(Mi,p.bindValIt,o);case"render-each":return gr.parse(e,p,u,o,s);case"show":return e.addNodeIf(dr,p.parseCondValue(u,e),Xt(n));case"hide":return e.addNodeIf(wr,p.parseCondValue(u,e),Xt(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 c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??Xt(n)}let[u,o]=Mt.parse(s,e,!0);return e.onAttributes(u,o,null),gi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Ch.test(i)){let[h,u,o]=Mt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new _r(null,o));let c=i!=="PRE"?Vh(n):n;return gi(new we(i.toLowerCase(),h,c),e,u)}return new Gt(`Error: InvalidTagName ${i}`)}}function gi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Ph(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Ph(t,e){let r=kh[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=lr(this.node)}}class yr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Se extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class Oi extends Se{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Mi extends Se{render(t,e){let r=t.enter(t.it,{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}pathInNext=!0}class gr extends Se{constructor(t,e,r){super(t,e,r);this.iterInfo=new zr(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(gr,e.parseEach(r,t),s);if(n!==null){let h=ur(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=i.getNamedItem("when");u&&h._parseWhen(u.value);let o=i.getNamedItem("loop-with");o&&h._parseLoopWith(o.value),n.iterInfo.whenVal=h.eachAttr.whenVal??null,n.iterInfo.loopWithVal=h.eachAttr.loopWithVal??null}return n}}class _r extends et{render(t,e){return e.renderText(this.val.eval(t))}}class pr 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 et{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=lr(this.node)}static register=!1}class dr extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class wr extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class qi extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Oe 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 Ot({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Ei extends ot{constructor(t,e){super(t,e);this.iterInfo=new zr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Ot({})}static register=!0}class zr{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)??xh,s=this.loopWithVal?.eval(t)??Fh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var xh=(t,e,r)=>!0,Fh=(t)=>({seq:t}),kh={slot:Oe,show:dr,hide:wr,each:Ei,scope:bi,"push-view":qi};class Yt{constructor(t,e,r,s,i,n,h,u){this.nodes=s??[],this.events=i??[],this.macroNodes=n??[],this.parent=u??null,this.frame=h??{},this.DOMParser=t??globalThis.DOMParser,this.Text=e??globalThis.Text,this.Comment=r??globalThis.Comment,this.cacheConstNodes=!0}isInsideMacro(t){return this.frame.macroName===t||this.parent?.isInsideMacro(t)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new Yt(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this)}newDOMParser(){return new this.DOMParser}isTextNode(t){return t instanceof this.Text}isCommentNode(t){return t instanceof this.Comment}addNodeIf(t,e,r){if(e!==null){let s=this.nodes.length,i=new t(s,e,r);return this.nodes.push(i),i}return null}registerEvents(){let t=this.events.length,e=new ji(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new ze(s)};for(let h of r)if(h instanceof Oe)i[h.val.val]=h.node;else if(!(h instanceof Qt)||!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 fr=(t)=>t instanceof Qt&&t.isWhiteSpace(),pi=(t)=>t instanceof we||t instanceof ze&&t.childs[0]instanceof we;function Vh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(fr(t[0]))r=1,s=!0;if(e>1&&fr(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(fr(n)&&pi(t[i-1])&&pi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Me{constructor(t,e,r="",s=null,i=null){this.name=t,this.anode=s,this.style=r,this.ctx=i,this.rawView=e}compile(t,e,r){if(this.ctx=t,this.anode=et.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=lr(this.anode)}render(t,e){return this.anode.render(t,e)}}class ji{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Ii(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 Ii{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=ru(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 Nh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),qe=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,di=(t)=>qe((e)=>e.e.key===t),wi=qe(({e:t})=>Nh&&t.metaKey||t.ctrlKey),mh=qe(({e:t})=>t.metaKey),vh=qe(({e:t})=>t.altKey),zi={ctrl:wi,cmd:wi,meta:mh,alt:vh},tu={keydown:{send:di("Enter"),cancel:di("Escape"),...zi},click:{...zi}},eu=(t,e)=>t;function ru(t,e){if(e.length===0)return eu;let r=tu[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 Sr{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 Or{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 Mr{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 be{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new qr}setNullComputedCache(){this.computedCache=new Mr}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:Ui}getHandlerFor(t,e,r){return this.getCompFor(t)?.[r][e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getHandlerFor(t,e,"computed");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
2
|
`)}}class Ee{constructor(t=new be,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ee(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let s=t[r];s.scope=this.enter(),this.comps.registerComponent(s),this.byName[s.name]=s;let i=e[s.name];if(i)this.byName[i]=s}}registerMacros(t){Object.assign(this.macros,t)}getCompFor(t){return this.comps.getCompFor(t)}registerRequestHandlers(t){for(let e in t)this.reqsByName[e]=new 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 br{constructor(t,e,r){this.name=t,this.val=e,this.symbol=r}getSymbol(t){return this.symbol}evalAndBind(t,e){e[this.getSymbol(t)]=this.val.eval(t)}}class Ai extends br{constructor(t,e,r,s){super(t,e,null);this.compName=r,this.dynName=s}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var bt=(t)=>typeof t==="string",su=0;class Er{constructor(t,e,r,s={},i="",n="",h="",u={},o={},c={},f={},_={},l={},a={},y={}){this.id=su++,this.name=t,this.Class=e,this.views={main:new Me("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=c,this.bubble=f,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Ui};for(let d in s){let S=s[d],{view:D,style:v}=bt(S)?{view:S}:S;this.views[d]=new Me(d,D,v)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(bt(r)){let s=p.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new br(e,s,Symbol(e))}else if(bt(r?.default)&&bt(r?.for)){let s=p.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(bt(i)&&bt(n))this.dynamic[e]=new Ai(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
3
|
`)}}function Ui(t){return t}var $i=Symbol("STOP"),Ar=Symbol("NEXT");class Bt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Bt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===$i?e:s===Ar?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class jr{constructor(t,e,r){this.it=t,this.bindings=e,this.isFrame=r}lookup(t){let e=this.bindings[t];return e===void 0?this.isFrame?$i:Ar:e}}class Ir{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Ar:e}}class H{constructor(t,e,r,s,i,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=s,this.views=i,this.ctx=n;let h=[...i].join("");this.viewsId=h==="main"?"":h}_enrichOnEnter(){return this.comps.getOnEnterFor(this.it).call(this.it,this)??this}upToFrameBinds(){let{comps:t,binds:e,dynBinds:r,views:s,ctx:i}=this;return e.head.isFrame?this:new H(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Bt(new jr(e,{it:e},!0),null),i=new Bt(new Ir({}),null),n=new Bt("main",null);return new H(t,e,s,i,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:s,binds:i,dynBinds:n,views:h,ctx:u}=this,o=i.push(new jr(t,e,r));return new H(s,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:s,dynBinds:i,views:n,ctx:h}=this;return new H(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Ir(e));return new H(s,i,n,o,h,u)}lookupDynamic(t){let e=this.comps.getCompFor(this.it)?.dynamic[t];return e?this.dynBinds.lookup(e.getSymbol(this))??e.val.eval(this):null}lookupBind(t){return this.binds.lookup(t)}lookupType(t){return this.comps.getCompFor(this.it).scope.lookupComponent(t)}lookupFieldRaw(t){return this.it[t]??null}lookupField(t){let e=this.lookupFieldRaw(t);return e instanceof Function?e.call(this.it):e}lookupName(t){return this.ctx.lookupName(t)}lookupComputed(t){let e=this.binds.head.isFrame?this.binds.head:this.binds.tail.head;return this.comps.lookupComputed(e.it,t)}getHandlerFor(t,e){return this.comps.getHandlerFor(this.it,t,e)}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 Li{constructor(t){this.val=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.val;this.val=t;for(let s of this.changeSubs)s({val:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.val),e)}}class $r{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Li(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 Dr(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 Ri(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.val,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??iu(e),o=s?.onResName??e,c=(f,_,l,a,y)=>{let S=new Wi(t,this,f??_,f?[l]:[a,y],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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.val,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 Di(t,e,r,this,s))}}function iu(t){return()=>{throw Error(`Request not found: ${t}`)}}function nu(){return this}class Kr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parentTransaction=r,this._task=null}get task(){return this._task??=new Ji,this._task}getCompletionPromise(){return this.task.promise}setParent(t){this.parentTransaction=t,t.task.addDep(this.task)}run(t,e){return this.updateRootValue(t,e)}afterTransaction(){}buildRootStack(t,e){return H.root(e,t)}buildStack(t,e){let r=this.path.buildStack(this.buildRootStack(t,e));return r?r.upToFrameBinds():null}callHandler(t,e,r){let[s,i]=this.getHandlerAndArgs(t,e,r);return s.apply(e,i)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),s=this.callHandler(t,r,e);return this._task?.complete?.({value:s,old:r}),r!==s?this.path.setValue(t,s):t}lookupName(t){return null}}var hu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ki=(t)=>Number.isNaN(t)?null:t;function Ur(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Di extends Kr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return H.root(e,t,this)}getHandlerAndArgs(t,e,r){let s=this.buildStack(t,r),[i,n]=this.handler.getHandlerAndArgs(s,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new Wr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return Ur(e);case"valueAsInt":return Ki(parseInt(Ur(e),10));case"valueAsFloat":return Ki(parseFloat(Ur(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 hu&&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 Rr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Lr extends Kr{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]??nu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Rr(this.path,this.transactor,this)]]}}class Wi extends Lr{handlerProp="response"}class Dr extends Lr{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 Ri extends Dr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Ji{constructor(t){this.info=t,this.deps=[],this.val=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.val=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class Wr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Ti(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 Rr extends Wr{stopPropagation(){return this.parent.stopPropagation()}}class Ti extends ve{constructor(t){super();this.dispatcher=t}logic(t,e,r){return this.dispatcher.logicAtPath(this.buildPath(),t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}buildPath(){return this.dispatcher.path.concat(this.pathChanges)}}class Jr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ee(r),this.transactor=new $r(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,c]=tt.fromEvent(t,i,n,h,u);if(r){let f=uu(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.val,_=o.lookup(f),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(f));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&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return H.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.val,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.val!==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 tt([]),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 uu(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.val=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}function Ct(t,e){if(!t)throw Error(e)}function A(t){Ct(t!==1/0,"Cannot perform this action with an infinite size.")}function Xi(t,e,r,s,i,n){return A(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var ou=(t,e)=>e,cu=(t,e)=>[e,t],Tr=(t)=>function(...e){return!t.apply(this,e)},Gi=(t)=>function(...e){return-t.apply(this,e)};function on(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,U={done:!0,value:void 0};class cn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new cn(t)}function b(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return U})}var fu=L(()=>U),ct=()=>fu;function Je(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return U;return r.value=e++,r})}function te(t,e){return b((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function Nr(t){if(Array.isArray(t))return!0;return!!Te(t)}var _u=(t)=>typeof t?.next==="function";function fn(t){return Te(t)?.call(t)}function Te(t){let e=t?.[Symbol.iterator];if(typeof e==="function")return e}function lu(t){let e=Te(t);return e&&e===t.entries}function au(t){let e=Te(t);return e&&e===t.keys}var ee="delete",z=5,E=1<<z,$=E-1,g={},Cr=()=>({value:!1});function T(t){if(t)t.value=!0}class Ze{}function It(t){if(t.size===void 0)t.size=t.__iterate(_n);return t.size}function st(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?It(t)+e:e}var _n=()=>!0,ln=(t)=>t<0||Object.is(t,-0),re=(t,e,r)=>(t===0&&!ln(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),an=(t,e,r)=>t===void 0?r:ln(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Kt=(t,e)=>an(t,e,0),se=(t,e)=>an(t,e,e),yn="@@__IMMUTABLE_ITERABLE__@@",$e="@@__IMMUTABLE_KEYED__@@",Ke="@@__IMMUTABLE_INDEXED__@@",it="@@__IMMUTABLE_ORDERED__@@",ie="@@__IMMUTABLE_SEQ__@@",gn="@@__IMMUTABLE_LIST__@@",pn="@@__IMMUTABLE_MAP__@@",dn="@@__IMMUTABLE_SET__@@",wn="@@__IMMUTABLE_STACK__@@",zn="@@__IMMUTABLE_RECORD__@@";function F(t,e){return typeof t==="object"&&t!==null&&e in t}var R=(t)=>F(t,yn),w=(t)=>F(t,$e),j=(t)=>F(t,Ke),mr=(t)=>w(t)||j(t),x=(t)=>F(t,it),vr=(t)=>F(t,ie),Sn=(t)=>F(t,gn),He=(t)=>F(t,pn),ts=(t)=>F(t,dn),es=(t)=>F(t,wn),yt=(t)=>F(t,zn),Y=(t)=>R(t)||yt(t),rs=(t)=>He(t)&&x(t),On=(t)=>ts(t)&&x(t),Yi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function Mn(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=Dt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=(r)=>te(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s}),e}function qn(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=(i)=>te(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)}),s}function bn(t,e){let r=P(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=Mn(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Dt,r.__iterate=function(s,i){let n=0;if(i)It(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)It(t);let n=this.size;return te(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function En(t,e,r,s){let i=t.size;if(re(e,r,i))return t;if(i===void 0&&(e<0||r<0))return En(t.toSeq().cacheResult(),e,r,s);let n=Kt(e,i),u=se(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=P(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&vr(t)&&o>=0)c.get=function(f,_){return f=st(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,d)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(y,s?d:a-1,this)===!1)return!1},_),a},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ct();let _=t.__iterator(f),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return U;let y=_.next();if(y.done)return y;return a++,y});return b((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let d=_.next();if(d.done)return!1;return a++,y[0]=a-1,y[1]=d.value[1],!0})},c}function jt(t,e,r){if(!e)e=on;let s=w(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):j(t)?at(n):xt(n)}function je(t,e,r){if(!e)e=on;if(r)return t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Bi(e,i[1],n[1])?n:i)?.[0];return t.reduce((s,i)=>Bi(e,s,i)?i:s)}function Bi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Zr(t,e,r,s){let i=P(t),n=new ne(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=V(_);return fn(h?l.reverse():l)}),o=0,c=Array(u.length),f=Array(u.length);return b((_)=>{let l=s;for(let a=0;a<u.length;a++)c[a]=u[a].next(),l=s?l&&c[a].done:l||c[a].done;if(l)return!1;for(let a=0;a<c.length;a++)f[a]=c[a].value;return _[0]=o++,_[1]=e(...f),!0})},i}function ss(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 jn(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 nt=(t)=>typeof t==="object"&&(Y(t)||Array.isArray(t)||jn(t));function In(t){if(ss(t)&&typeof t!=="string")return t;if(x(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var yu=(t,e)=>Y(t)?t.has(e):nt(t)&&Object.hasOwn(t,e);function An(t,e,r){return Y(t)?t.get(e,r):!yu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function is(t,e,r){let s=In(e),i=0;while(i!==s.length)if(t=An(t,s[i++],g),t===g)return r;return t}var Un=(t,e)=>is(t,e,g)!==g;function I(t,e){if(t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1;if(typeof t.valueOf==="function"&&typeof e.valueOf==="function"){if(t=t.valueOf(),e=e.valueOf(),t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1}return!!(Yi(t)&&Yi(e)&&t.equals(e))}function Le(t){if(!t||typeof t!=="object")return t;if(!R(t)){if(!nt(t))return t;t=N(t)}if(w(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Le(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Le(r))}),e}function ns(t,e){if(t===e)return!0;if(!R(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||w(t)!==w(e)||j(t)!==j(e)||x(t)!==x(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!mr(t);if(x(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&I(c[1],u)&&(r||I(c[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?!I(h,t.get(u,g)):!I(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var Xe=(t)=>t>>>1&1073741824|t&3221225471;function X(t){if(t===null||t===void 0)return Ci(t);if(typeof t.hashCode==="function")return Xe(t.hashCode(t));let e=zu(t);if(e===null||e===void 0)return Ci(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return gu(e);case"string":return e.length>Su?pu(e):Pr(e);case"object":case"function":return wu(e);case"symbol":return du(e);default:if(typeof e.toString==="function")return Pr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Ci=(t)=>t===null?1108378658:1108378659;function gu(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 Xe(e)}function pu(t){let e=Gr[t];if(e===void 0){if(e=Pr(t),Xr===Ou)Xr=0,Gr={};Xr++,Gr[t]=e}return e}function Pr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return Xe(e)}function du(t){let e=xi[t];if(e!==void 0)return e;return e=$n(),xi[t]=e,e}function wu(t){let e=Pi.get(t);if(e!==void 0)return e;return e=$n(),Pi.set(t,e),e}var zu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function $n(){let t=++Hr;if(Hr&1073741824)Hr=0;return t}var Pi=new WeakMap,xi=Object.create(null),Hr=0,Su=16,Ou=255,Xr=0,Gr={};function Mu(t){if(t.size===1/0)return 0;let e=x(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Fi(X(i),X(n))|0}:(i,n)=>{s=s+Fi(X(i),X(n))|0}:e?(i)=>{s=31*s+X(i)|0}:(i)=>{s=s+X(i)|0}),qu(t.size,s)}var Fi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function qu(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=Xe(e^e>>>16),e}function Pt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:vr(t)?e:t.create?t.create(e):t.constructor(e),Kn=(t,e)=>O(t,(w(t)?G:j(t)?gt:pt)(e)),ki=(...t)=>t,V=(t)=>R(t)?t:N(t);class q{size=0;static{this.prototype[yn]=!0,this.prototype.__toStringMapper=Pt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return ns(this,t)}hashCode(){return this.__hash??(this.__hash=Mu(this))}toArray(){A(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Jn(this)}toJS(){return Le(this)}toKeyedSeq(){return new as(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 Tn(this)}toSeq(){return j(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!R(s))s=e?Dn(s):Wn(Array.isArray(s)?s:[s]);else if(e)s=G(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&&w(s)||j(this)&&j(s))return s}return O(this,new Rn(r))}includes(t){return this.some((e)=>I(e,t))}every(t,e){A(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=w(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,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return b((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>Kn(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return A(this.size),this.__iterate(e?t.bind(e):t)}join(t){A(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[0],e})}map(t,e){return O(this,qn(this,t,e))}reduce(t,e=g,r){return Xi(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Xi(this,t,e,r,e===g,!0)}reverse(){return O(this,bn(this,w(this)))}slice(t,e){return O(this,En(this,t,e,w(this)))}some(t,e){A(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return O(this,jt(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return It(t?this.toSeq().filter(t,e):this)}countBy(t,e){throw Error("countBy: not patched — import CollectionConversions")}entrySeq(){let t=this;if(t._cache)return new ne(t._cache);let e=t.toSeq().map(cu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Tr(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){return this.findEntry(t,e)?.[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)=>(w(this)?G:j(this)?gt:pt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(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(c,f){c.__iterate((_,l)=>{if((!t||f<t)&&R(_))o(_,f+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 b((u)=>{while(h.length>0){let o=h[h.length-1],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&R(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},O(this,s)}fromEntrySeq(){return new Zn(this)}get(t,e){return this.find((r,s)=>I(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 Un(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:V(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:V(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>I(e,t))}keySeq(){return this.toSeq().map(ou).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return je(this,t)}maxBy(t,e){return je(this,e,t)}min(t){return je(this,t?Gi(t):Qi)}minBy(t,e){return je(this,e?Gi(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=w(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((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return b((f)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(c&&t.call(e,a,l,o))continue;return c=!1,f[0]=s?l:u++,f[1]=a,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(Tr(t),e)}sortBy(t,e){return O(this,jt(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 L(()=>{if(u)return U;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,U;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(Tr(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 G=(t)=>w(t)?t:os(t);class hs extends q{static{this.prototype[$e]=!0,this.prototype.__toStringMapper=(t,e)=>`${Pt(e)}: ${Pt(t)}`,this.prototype[Symbol.iterator]=q.prototype.entries,this.prototype.toJSON=function(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,Mn(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)=>j(t)?t:at(t);class lt extends q{static{this.prototype[Ke]=!0,this.prototype[it]=!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=Kt(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=st(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=st(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 b((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=Zr(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(ki,...t)}zipAll(...t){let e=[this,...t];return O(this,Zr(this,ki,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,Zr(this,t,r))}}var pt=(t)=>R(t)&&!mr(t)?t:xt(t);class Ge extends q{static{this.prototype.has=q.prototype.includes,this.prototype.contains=q.prototype.includes,this.prototype.keys=Ge.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}V.Keyed=G;V.Indexed=gt;V.Set=pt;var Qr=lt.prototype,N=(t)=>t===void 0||t===null?_s():Y(t)?t.toSeq():bu(t),P=(t)=>Object.create((w(t)?Lt:j(t)?dt:cs).prototype);class ft extends q{static{this.prototype[ie]=!0}toSeq(){return this}toString(){return this.__toString("Seq {","}")}cacheResult(){if(!this._cache&&this.__iterateUncached)this._cache=this.entrySeq().toArray(),this.size=this._cache.length;return this}__iterateUncached(t,e){let r=this.__iteratorUncached(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterate(t,e){let r=this._cache;if(r){let s=r.length,i=0;while(i!==s){let n=r[e?s-++i:i++];if(t(n[1],n[0],this)===!1)break}return i}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,s=0,i={done:!1,value:void 0};return L(()=>{if(s===r)return U;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var us={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},os=(t)=>t===void 0||t===null?_s().toKeyedSeq():R(t)?w(t)?t.toSeq():t.fromEntrySeq():yt(t)?t.toSeq():Dn(t);class Lt extends hs{static{this.prototype[ie]=!0,Object.assign(this.prototype,us)}toSeq(){return this}toKeyedSeq(){return this}}var at=(t)=>t===void 0||t===null?_s():R(t)?w(t)?t.entrySeq():t.toIndexedSeq():yt(t)?t.toSeq().entrySeq():Wn(t);at.of=(...t)=>at(t);class dt extends lt{static{this.prototype[ie]=!0,Object.assign(this.prototype,us)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var xt=(t)=>(R(t)&&!mr(t)?t:at(t)).toSetSeq();xt.of=(...t)=>xt(t);class cs extends Ge{static{this.prototype[ie]=!0,Object.assign(this.prototype,us)}toSeq(){return this}toSetSeq(){return this}}N.isSeq=vr;N.Keyed=os;N.Set=xt;N.Indexed=at;class ne extends dt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[st(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 b((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class fs extends Lt{static{this.prototype[it]=!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 b((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class Ln extends dt{constructor(t){super();this._collection=t,this.size=t.length||t.size}__iterateUncached(t,e){if(e)return this.cacheResult().__iterate(t,e);let r=0;for(let s of this._collection){if(t(s,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=fn(e);if(!_u(r))return ct();let s=0;return b((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var _s=()=>new ne([]),ls=(t)=>ss(t)?new ne(t):Nr(t)?new Ln(t):void 0;function Dn(t){let e=ls(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new fs(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Wn(t){let e=ls(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function bu(t){let e=ls(t);if(e)return lu(t)?e.fromEntrySeq():au(t)?e.toSetSeq():e;if(typeof t==="object")return new fs(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Rn extends ft{constructor(t){super();let e=[],r=0,s=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),s){let u=h.size;if(u!==void 0)r+=u;else s=!1}}else if(e.push(n),s){let h=n.size;if(h!==void 0)r+=h;else s=!1}this._wrappedIterables=e,this.size=s?r:void 0;let i=this._wrappedIterables[0];if(i[$e])this[$e]=!0;if(i[Ke])this[Ke]=!0;if(i[it])this[it]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!w(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 ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!w(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 b((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return L(()=>n()||U)}}class as extends Lt{static{this.prototype[it]=!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=bn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=qn(this,t,e);if(!this._useKeys)r.valueSeq=()=>this._iter.toSeq().map(t,e);return r}__iterateUncached(t,e){return this._iter.__iterate(t,e)}__iteratorUncached(t){return this._iter.__iterator(t)}}class Jn extends dt{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)It(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)It(this);let r=this.size;return te(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Tn extends cs{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 te(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Zn extends Lt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){Vi(s),r++;let i=R(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 b((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){Vi(i);let n=R(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Dt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function Vi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var Z=(t)=>t===void 0||t===null?Q():He(t)&&!x(t)?t:Q().withMutations((e)=>{let r=G(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});class Ft extends hs{static{zt(this,{asImmutable:oe,asMutable:ce,deleteIn:At,merge:xr,mergeWith:Cn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:bs,mergeIn:qs,setIn:Ss,update:Os,updateIn:Ms,wasAltered:zs,withMutations:fe,removeIn:At,concat:xr,[pn]:!0,[ee]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,s){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return Z(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,X(t),t,e):e}set(t,e){return mi(this,t,e)}remove(t){return mi(this,t,g)}deleteAll(t){let e=V(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return Q()}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 ct();return Ie(this._root,!1,0)}values(){if(!this._root)return ct();return Ie(this._root,!1,1)}entries(){if(!this._root)return ct();return Ie(this._root,!1)}__iterator(t){if(!this._root)return ct();return Ie(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Q();return this.__ownerID=t,this.__altered=!1,this}return ps(this.size,this._root,t,this.__hash)}}Z.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,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===1)return;if(!_&&!u&&f>=$u)return Eu(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new ys(t,a)}}class Qe{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Gn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&$),n=this.bitmap;return(n&i)===0?s:this.nodes[tn(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&$,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===g)return this;let _=tn(c&o-1),l=this.nodes,a=f?l[_]:void 0,y=ds(a,t,e+z,r,s,i,n,h);if(y===a)return this;if(!f&&y&&l.length>=Ku)return Iu(t,l,c,u,y);if(f&&!y&&l.length===2&&vi(l[_^1]))return l[_^1];if(f&&y&&l.length===1&&vi(y))return y;let d=t&&t===this.ownerID,S=f?y?c:c^o:c|o,D=f?y?Qn(l,_,y,d):Uu(l,_,d):Au(l,_,y,d);if(d)return this.bitmap=S,this.nodes=D,this;return new Qe(t,S,D)}}class gs{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Gn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&$,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&$,o=i===g,c=this.nodes,f=c[u];if(o&&!f)return this;let _=ds(f,t,e+z,r,s,i,n,h);if(_===f)return this;let l=this.count;if(!f)l++;else if(!_){if(l--,l<Lu)return ju(t,c,l,u)}let a=t&&t===this.ownerID,y=Qn(c,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new gs(t,l,y)}}class Ye{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 T(h),T(n),ws(this,t,e,r,[s,i])}let u=i===g,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===2)return new wt(t,this.keyHash,o[c^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ye(t,this.keyHash,a)}}class wt{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}iterate(t,e){return t(this.entry)}get(t,e,r,s){return I(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(T(h),u){T(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new wt(t,this.keyHash,[s,i])}return T(n),ws(this,t,e,X(s),[s,i])}}function Hn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(I(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 Gn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(t[r?i-s:s]?.iterate(e,r)===!1)return!1}function Ie(t,e,r){let s={node:t,index:0,__prev:null},i=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return L(()=>{while(s){let h=s.node,u=s.index++,o;if(h.entry){if(u===0)return n.value=i(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=i(h.entries[e?o-u:u]),n}else if(o=h.nodes.length-1,u<=o){let c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return U})}var ps=(t,e,r,s)=>new Ft(t,e,r,s),Ni,Q=()=>Ni||(Ni=ps(0));function mi(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=ds(t._root,t.__ownerID,0,X(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):Q()}function ds(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return T(u),T(h),new wt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var vi=(t)=>t.constructor===wt||t.constructor===Ye;function ws(t,e,r,s,i){if(t.keyHash===s)return new Ye(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&$,h=(r===0?s:s>>>r)&$,u=new wt(e,s,i),o=n===h?[ws(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new Qe(e,1<<n|1<<h,o)}function Eu(t,e,r,s){if(!t)t=new Ze;let i=new wt(t,X(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,X(n),n,h);return i}function ju(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new Qe(t,i,h)}function Iu(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 tn(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 Au(t,e,r,s){let i=t.length+1;if(s&&e+1===i)return t[e]=r,t;let n=Array(i),h=0;for(let u=0;u<i;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function Uu(t,e,r){let s=t.length-1;if(r&&e===s)return t.pop(),t;let i=Array(s),n=0;for(let h=0;h<s;h++){if(h===e)n=1;i[h]=t[h+n]}return i}var $u=E/4,Ku=E/2,Lu=E/4;function De(t){if(Array.isArray(t))return t.slice();return{...t}}var mo=(t,...e)=>ue(t,e),vo=(t,e,...r)=>ue(e,r,t),he=(t,e,r)=>ue(t,e,Du(r)),tc=(t,...e)=>he(t,e),ec=(t,e,...r)=>he(e,r,t);function ue(t,e,r){if(!nt(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(Y(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:G,h=s?(u)=>{if(i===t)i=De(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=De(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Du(t){function e(r,s,i){return nt(r)&&nt(s)&&Wu(r,s)?ue(r,[s],e):t?t(r,s,i):s}return e}function Wu(t,e){let r=N(t),s=N(e);return j(r)===j(s)&&w(r)===w(s)}function Ru(t,e){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(Y(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=De(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Ju(t,e,r){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(Y(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=De(t);return s[e]=r,s}function Wt(t,e,r,s){if(!s)s=r,r=void 0;let i=Yn(Y(t),t,In(e),0,r,s);return i===g?r:i}function Yn(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&&!nt(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(Pt)}]: ${e}`);let u=r[s],o=h?g:An(e,u,g),c=Yn(o===g?t:Y(o),o,r,s+1,i,n);if(c===o)return e;if(c===g)return Ru(e,u);let f=h?t?Q():{}:e;return Ju(f,u,c)}var Tu=(t,e)=>Wt(t,e,()=>g),Zu=(t,e,r)=>Wt(t,e,g,()=>r);function Bn(t,e,r,s){return Wt(t,[e],r,s)}function oe(){return this.__ensureOwner()}function ce(){return this.__ownerID?this:this.__ensureOwner(new Ze)}function zs(){return this.__altered}function fe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Hu(t,e){return is(this,t,e)}function Xu(t){return Un(this,t)}function At(t){return Tu(this,t)}function Ss(t,e){return Zu(this,t,e)}function Os(t,e,r){return typeof t==="function"?t(this):Bn(this,t,e,r)}function Ms(t,e,r){return Wt(this,t,e,r)}function en(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function xr(...t){return Pn(this,t)}function Cn(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=G(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)=>{Bn(i,u,g,(o)=>o===g?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function xn(...t){return he(this,t)}function Fn(t,...e){return he(this,e,t)}function qs(t,...e){return Wt(this,t,Q(),(r)=>ue(r,e))}function bs(t,...e){return Wt(this,t,Q(),(r)=>he(r,e))}function zt(t,e){Object.assign(t.prototype,e)}var J=(t)=>{let e=kt();if(t===void 0||t===null)return e;if(Sn(t))return t;let r=gt(t),s=r.size;if(s===0)return e;if(A(s),s>0&&s<E)return _e(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};J.of=(...t)=>J(t);class kn extends lt{static{zt(this,{asImmutable:oe,asMutable:ce,deleteIn:At,mergeDeepIn:bs,mergeIn:qs,setIn:Ss,update:Os,updateIn:Ms,wasAltered:zs,withMutations:fe,removeIn:At,[gn]:!0,[ee]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return J(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=st(this,t),t>=0&&t<this.size)return t+=this._origin,mn(this,t)?.array[t&$];return e}set(t,e){return Qu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return kt()}push(...t){let e=this.size;return this.withMutations((r)=>{rt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return rt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{rt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return rt(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"&&Nr(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 J(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return rt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(re(t,e,r))return this;return rt(this,Kt(t,r),se(e,r))}__iterate(t,e){let r=e?this.size:0;return Gu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=rn(this,t);return b((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return rn(this,!1)}keys(){return Je(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)}}J.isList=Sn;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&$;if(s>=this.array.length)return new _t([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Ut(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:E)||this.array.length===0)return this;let s=r-1>>>e&$;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Ut(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function rn(t,e){let{_origin:r,_capacity:s}=t,i=$t(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],l=c.level-z,a=c.offset+(f<<c.level);o(_,l,a)}return U});function o(c,f,_){if(f===0){let l=_===i?n?.array:c?.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=c?.array,a=_>r?0:r-_>>f,y=(s-_>>f)+1;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,level:f,offset:_,isLeaf:!1})}}}function Gu(t,e,r){let{_origin:s,_capacity:i}=t,n=$t(i),h=t._tail,u=t._level,o=t._root;return u===0?Vn(o,0,s,i,n,h,e,r):Nn(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,c=e>r?0:r-e,f=s-e;if(f>E)f=E;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function Nn(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let l=e-z;while(f!==_){let a=o?--_:f++,y=r+(a<<e);if((l===0?Vn(c?.[a],y,s,i,n,h,u,o):Nn(c?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var _e=(t,e,r,s,i,n,h)=>new kn(t,e,r,s,i,n,h),kt=()=>_e(0,0,z);function Qu(t,e,r){if(e=st(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)rt(h,e).set(0,r);else rt(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=Cr();if(e>=$t(t._capacity))s=Fr(s,t.__ownerID,0,e,r,n);else i=Fr(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 Fr(t,e,r,s,i,n){let h=s>>>r&$,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let c=t?.array[h],f=Fr(c,e,r-z,s,i,n);if(f===c)return t;return o=Ut(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)T(n);if(o=Ut(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Ut(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function mn(t,e){if(e>=$t(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&$],s-=z;return r}}function rt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ze,i=t._origin,n=t._capacity,h=i+e,u=r===void 0?n:r<0?n+r:i+r;if(h===i&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:c}=t,f=0;while(h+f<0)c=new _t(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=$t(n),l=$t(u);while(l>=1<<o+z)c=new _t(c?.array.length?[c]:[],s),o+=z;let a=t._tail,y=l<_?mn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Ut(c,s);let d=c;for(let S=o;S>z;S-=z){let D=_>>>S&$;d=d.array[D]=Ut(d.array[D],s)}d.array[_>>>z&$]=a}if(u<n)y=y?.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,c=null,y=y?.removeBefore(s,0,h);else if(h>i||l<_){f=0;while(c){let d=h>>>o&$;if(d!==l>>>o&$)break;if(d)f+=(1<<o)*d;o-=z,c=c.array[d]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&l<_)c=c.removeAfter(s,o,l-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return _e(h,u,o,c,y)}var $t=(t)=>t<E?0:t-1>>>z<<z,K=(t)=>t===void 0||t===null?Vt():rs(t)?t:Vt().withMutations((e)=>{let r=G(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});K.of=(...t)=>K(t);class vn extends Ft{static{zt(this,{[it]:!0,[ee]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:q.prototype.keys,values:q.prototype.values,__iterate:q.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 K(t)}toString(){return this.__toString("OrderedMap {","}")}get(t,e){let r=this._map.get(t);return r!==void 0?this._list.get(r)[1]:e}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this;return Vt()}set(t,e){return sn(this,t,e)}remove(t){return sn(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return b((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i)return r[0]=i[0],r[1]=i[1],!0}})}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);if(!t){if(this.size===0)return Vt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Es(e,r,t,this.__hash)}}K.isOrderedMap=rs;var Es=(t,e,r,s)=>new vn(t,e,r,s),Vt=()=>Es(Q(),kt());function sn(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 c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=kt().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=Q().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 Es(u,o)}var Nt=(t)=>t===void 0||t===null?We():es(t)?t:We().pushAll(t);Nt.of=(...t)=>Nt(t);class th extends lt{static{zt(this,{asImmutable:oe,asMutable:ce,wasAltered:zs,withMutations:fe,[wn]:!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 Nt(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=st(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 Yr(this,e,r)}pushAll(t){if(t=gt(t),t.size===0)return this;if(this.size===0&&es(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Yr(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 We()}slice(t,e){if(re(t,e,this.size))return this;let r=Kt(t,this.size);if(se(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 Yr(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return We();return this.__ownerID=t,this.__altered=!1,this}return js(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let i=this.toArray(),n=i.length,h=0;while(h!==n)if(t(i[n-++h],n-h,this)===!1)break;return h}let r=0,s=this._head;while(s){if(t(s.value,r++,this)===!1)break;s=s.next}return r}__iterator(t){if(t){let s=this.toArray(),i=s.length,n=0;return b((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 b((s)=>{if(!r)return!1;return s[0]=e++,s[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return L(()=>{if(!t)return U;return e.value=t.value,t=t.next,e})}keys(){return Je(this.size)}}Nt.isStack=es;function Yr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return js(e,r)}var js=(t,e,r,s)=>new th(t,e,r,s),nn,We=()=>nn||(nn=js(0)),M=(t)=>t===void 0||t===null?vt():ts(t)&&!x(t)?t:vt().withMutations((e)=>{let r=pt(t);A(r.size),r.forEach((s)=>e.add(s))});M.of=(...t)=>M(t);M.fromKeys=(t)=>M(G(t).keySeq());M.intersect=(t)=>{return t=V(t).toArray(),t.length?M(t.pop()).intersect(...t):vt()};M.union=(t)=>{let e=V(t).toArray();return e.length?M(e.pop()).union(...e):vt()};class mt extends Ge{static{zt(this,{withMutations:fe,asImmutable:oe,asMutable:ce,[dn]:!0,[ee]:this.prototype.remove,merge:this.prototype.union,concat:this.prototype.union,[Symbol.toStringTag]:"Immutable.Set"})}constructor(t,e){super();this.size=t?t.size:0,this._map=t,this.__ownerID=e}create(t){return M(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ae(this,this._map.set(t,t))}remove(t){return Ae(this,this._map.remove(t))}clear(){return Ae(this,this._map.clear())}map(t,e){let r=!1,s=Ae(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 un(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return un(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return vt()}__make(t,e){return eh(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=ts;var eh=(t,e)=>new mt(t,e),hn,vt=()=>hn||(hn=eh(Q()));function un(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 Ae(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 k=(t)=>t===void 0||t===null?kr():On(t)?t:kr().withMutations((e)=>{let r=pt(t);A(r.size),r.forEach((s)=>e.add(s))});k.of=(...t)=>k(t);k.fromKeys=(t)=>k(G(t).keySeq());class rh extends mt{static{zt(this,{[it]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Qr.zip,zipWith:Qr.zipWith,zipAll:Qr.zipAll})}create(t){return k(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return kr()}__make(t,e){return sh(t,e)}}k.isOrderedSet=On;var sh=(t,e)=>new rh(t,e),kr=()=>sh(Vt()),rc={LeftThenRight:-1,RightThenLeft:1};function Yu(t){if(yt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(Y(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 Be=(t,e)=>{let r;Yu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._name=e,i._keys=u,i._defaultValues=t;for(let c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Is(this)} with property "${f}" since that property name is part of the Record API.`);else Cu(i,f)}}return this.__ownerID=void 0,this._values=J().withMutations((u)=>{u.setSize(this._keys.length),G(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(Bu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class ih{static{zt(this,{asImmutable:oe,asMutable:ce,deleteIn:At,getIn:Hu,hasIn:Xu,merge:xr,mergeWith:Cn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:bs,mergeIn:qs,setIn:Ss,toObject:en,update:Os,updateIn:Ms,withMutations:fe,removeIn:At,toJSON:en,[zn]:!0,[ee]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${Pt(this.get(e))}`).join(", ");return`${Is(this)} { ${t} }`}equals(t){return this===t||yt(t)&&Et(this).equals(Et(t))}hashCode(){return Et(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return Br(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Br(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Et(this)}toJS(){return Le(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 Br(this,e,t)}}Be.isRecord=yt;var Is=(t)=>t.constructor.displayName||t.constructor.name||"Record";class nh extends Lt{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 b((n)=>{if(i===s)return!1;let h=t?s-++i:i++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var Et=(t)=>new nh(t);Be.getDescriptiveName=Is;var Bu=ih.prototype;function Br(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Cu(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 Vr=(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 As(t,e,r,s)};class As extends dt{_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+st(this,t)*this._step:e}includes(t){let e=(t-this._start)/this._step;return e>=0&&e<this.size&&e===Math.floor(e)}slice(t,e){if(re(t,e,this.size))return this;if(t=Kt(t,this.size),e=se(e,this.size),e<=t)return Vr(0,0);return Vr(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 b((n)=>{if(i===e)return!1;let h=s;return s+=t?-r:r,n[0]=t?e-++i:i++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,s=0,i={done:!1,value:void 0};return L(()=>{if(s===t)return U;return i.value=r,r+=e,s++,i})}keys(){return Je(this.size)}equals(t){return t instanceof As?this._start===t._start&&this._end===t._end&&this._step===t._step:ns(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var sc=(t,e)=>{let r=e===void 0?1/0:Math.max(0,e);return new Re(t,r)};class Re extends dt{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 I(this._value,t)}slice(t,e){let r=this.size;return re(t,e,r)?this:new Re(this._value,se(e,r)-Kt(t,r))}reverse(){return this}indexOf(t){if(I(this._value,t))return 0;return-1}lastIndexOf(t){if(I(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 b((i)=>{if(s===e)return!1;return i[0]=t?e-++s:s++,i[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,s={done:!1,value:void 0};return L(()=>{if(r===t)return U;return r++,s.value=e,s})}keys(){return Je(this.size)}equals(t){return t instanceof Re?this.size===t.size&&I(this._value,t._value):ns(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var ic=(t,e)=>hh([],e??Pu,t,"",e?.length>2?[]:void 0,{"":t});function hh(t,e,r,s,i,n){if(typeof r!=="string"&&!Y(r)&&(ss(r)||Nr(r)||jn(r))){if(t.includes(r))throw TypeError("Cannot convert circular structure to Immutable");if(t.push(r),i&&s!=="")i.push(s);let h=e.call(n,s,N(r).map((u,o)=>hh(t,e,u,o,i,r)),i?.slice());if(t.pop(),i)i.pop();return h}return r}var Pu=(t,e)=>j(e)?e.toList():w(e)?e.toMap():e.toSet(),Ue=(t)=>w(t)?t.valueSeq():t;function xu(){q.prototype.toMap=function(){return Z(this.toKeyedSeq())},q.prototype.toOrderedMap=function(){return K(this.toKeyedSeq())},q.prototype.toOrderedSet=function(){return k(Ue(this))},q.prototype.toSet=function(){return M(Ue(this))},q.prototype.toStack=function(){return Nt(Ue(this))},q.prototype.toList=function(){return J(Ue(this))},q.prototype.countBy=function(e,r){let s=Z().asMutable();return this.__iterate((i,n)=>{s.update(e.call(r,i,n,this),0,(h)=>h+1)}),s.asImmutable()},q.prototype.groupBy=function(e,r){let s=w(this),i=(x(this)?K():Z()).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)=>Kn(this,n)).asImmutable()},lt.prototype.keySeq=function(){return Vr(0,this.size)},Ft.prototype.sort=function(e){return K(jt(this,e))},Ft.prototype.sortBy=function(e,r){return K(jt(this,r,e))},mt.prototype.sort=function(e){return k(jt(this,e))},mt.prototype.sortBy=function(e,r){return k(jt(this,r,e))}}var Fu="7.0.0",ku={version:Fu};xu();var{version:nc}=ku;var Vu=["nid","cid","eid","vid","si","sk"];class Us{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.renderComment=s,this.renderFn=i,this.getSeqInfo=n??ro,this.cache=h??new Or}setNullCache(){this.cache=new Sr}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 Vu)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,this.renderView(o,t)]);return this.cache.set(e,h,f),f}pushEachEntry(t,e,r,s,i){t.push(this.renderMetadata("Each",{nid:e,[r]:s}),i)}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,f)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);this.pushEachEntry(c,r,u,_,y)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=[],_=h.call(t.it,i);for(let[l,a]of c(i))if(n.call(t.it,l,a,_)){let y={key:l,value:a},d=`${s}-${l}`,S;if(u)u.call(t.it,y,l,a,_),S=this.cache.get2(t.it,a,d);else S=this.cache.get(a,d);if(S){this.pushEachEntry(f,s,o,l,S);continue}let D=t.enter(a,y,!1),v=this.renderView(r,D);if(this.pushEachEntry(f,s,o,l,v),u)this.cache.set2(t.it,a,d,v);else this.cache.set(a,d,v)}return f}renderView(t,e){return t.render(e,this)}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderEmpty(){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*Nu(t){let e=0;for(let r of t)yield[e++,r]}function*mu(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var uh=new Map,vu=["si",Nu],to=["sk",mu],eo=["si",function*(e){}];function ro(t){return j(t)?vu:w(t)?to:uh.get(t?.constructor)??eo}var Ks=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),le=(t)=>t!==null&&typeof t==="object",ch=(t,e)=>Object.getPrototypeOf(t)!==Object.getPrototypeOf(e);function fh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)so(t,s,r);else if(Ks(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(le(i))io(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function so(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.replaceChildren();else if(e==="className")t.removeAttribute("class");else if(e==="htmlFor")t.removeAttribute("for");else if(typeof s==="string"||Ks(e))t.removeAttribute(e);else t[e]=null}function io(t,e,r,s){let i=e?.[r];if(le(i)&&ch(i,s)){t[r]=s;return}if(!le(t[r]))t[r]={};let n=t[r];for(let h in s)n[h]=s[h]}class Rt{}var $s=(t)=>t instanceof xe?t.key:void 0,no=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function _h(t,e){for(let r=0;r<t.length;r++)if(!t[r].isEqualTo(e[r]))return!1;return!0}function Ls(t,e,r){for(let s of e)t.appendChild(s.toDom(r))}function Ds(t,e){if(e==null)return;if(no(e))for(let r of e)Ds(t,r);else if(e instanceof Rt)if(e instanceof St)t.push(...e.childs);else t.push(e);else t.push(new Ws(e))}class Ws extends Rt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof Ws&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Pe extends Rt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Pe&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class St extends Rt{constructor(t){super();this.childs=[],Ds(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof St)||this.childs.length!==t.childs.length)return!1;return _h(this.childs,t.childs)}toDom(t){let e=t.document.createDocumentFragment();return Ls(e,this.childs,t),e}}class xe extends Rt{constructor(t,e,r,s,i){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i==="string"?i:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof xe)||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;return _h(this.childs,t.childs)}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);return fh(r,this.attrs,{}),Ls(r,this.childs,t),r}}function lh(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)continue;if(le(i)&&le(n))if(ch(n,i))r??={},r[s]=n;else{let h=lh(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 ah(t,e,r,s){if(e===r||e.isEqualTo(r))return t;let i=e.nodeType;if(i===r.nodeType){if(i===3||i===8)return t.data=r.text,t;if(i===1&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let h=lh(e.attrs,r.attrs);if(h)fh(t,h,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)oh(t,e.childs,r.childs,s);return t}if(i===11)return oh(t,e.childs,r.childs,s),t}let n=r.toDom(s);return t.parentNode?.replaceChild(n,t),n}function oh(t,e,r,s){if(e.length===0){Ls(t,r,s);return}if(r.length===0){t.replaceChildren();return}let i=Array.from(t.childNodes),n=Object.create(null);for(let o=0;o<e.length;o++){let c=$s(e[o]);if(c!=null)n[c]=o}let h=new Uint8Array(e.length),u=0;for(let o=0;o<r.length;o++){let c=r[o],f=$s(c),_=-1;if(f!=null){if(f in n&&!h[n[f]])_=n[f]}else while(u<e.length){if(!h[u]&&$s(e[u])==null){_=u++;break}u++}if(_>=0){h[_]=1;let l=ah(i[_],e[_],c,s),a=t.childNodes[o]??null;if(l!==a)t.insertBefore(l,a)}else{let l=t.childNodes[o]??null;t.insertBefore(c.toDom(s),l)}}for(let o=e.length-1;o>=0;o--)if(!h[o]&&i[o].parentNode===t)t.removeChild(i[o])}var Ce=new WeakMap;function yh(t,e,r){let s=Ce.get(e),i=t instanceof St;if(s&&s.vnode instanceof St===i){let h=i?e:s.dom,u=ah(h,s.vnode,t,r);return Ce.set(e,{vnode:t,dom:i?e:u}),u}Ce.delete(e);let n=t.toDom(r);return e.replaceChildren(n),Ce.set(e,{vnode:t,dom:i?e:n}),n}function gh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e){let c=e[o];switch(o){case"key":n=c;break;case"namespace":h=c;break;case"class":i.className=c;break;case"for":i.htmlFor=c;break;default:i[o]=Ks(o)?String(c):c}}let u=[];return Ds(u,r),new xe(s,i,u,n,h)}var ph=Symbol("BadValue"),Sh=(t)=>t;class B{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,ph);if(h===ph)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 Oh extends Js{}var ho=new Oh;class m 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 uo=new m((t)=>Number.isInteger(t),()=>"Integer expected"),oo=new m((t)=>Number.isFinite(t),()=>"Float expected"),co=new m((t)=>typeof t==="boolean",()=>"Boolean expected"),fo=new m((t)=>typeof t==="string",()=>"String expected"),_o=new m((t)=>J.isList(t),()=>"List expected"),lo=new m((t)=>Z.isMap(t),()=>"Map expected"),ao=new m((t)=>K.isOrderedMap(t),()=>"OrderedMap expected"),yo=new m((t)=>M.isSet(t),()=>"Set expected"),go=(t)=>!!t;class Ts extends B{constructor(t,e=!1){super("bool",t,co,go,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 Fe extends B{constructor(t,e=null){super("any",t,ho,Sh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Rs(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var po=(t)=>t?.toString?.()??"";class Zs extends B{constructor(t,e=""){super("text",t,fo,po,e)}extendProtoForType(t,e){Bs(t,this.name,e,"","length")}}var wo=(t)=>Number.isFinite(t)?Math.trunc(t):null;class Mh extends B{constructor(t,e=0){super("int",t,uo,wo,e)}}var zo=(t)=>null;class Hs extends B{constructor(t,e=0){super("float",t,oo,zo,e)}}var Rs=(t)=>t?.constructor?.getMetaClass?.()?.name;class qh{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 bh extends B{constructor(t,e,r){super(t,e,new qh(t),Sh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var dh=Symbol("NONE");function Xs(t,e,r){Bs(t,e,r,jh),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,dh);if(h!==dh)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},Eh(t,e,`${r}At`)}function Eh(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var jh=J(),So=(t)=>Array.isArray(t)?J(t):null;class Gs extends B{constructor(t,e=jh){super("list",t,_o,So,e)}extendProtoForType(t,e){let{name:r}=this;Xs(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 Oo=(t)=>Z(t);class Qs extends B{constructor(t,e=Z()){super("map",t,lo,Oo,e)}extendProtoForType(t,e){Xs(t,this.name,e)}}var Mo=(t)=>K(t);class Ys extends B{constructor(t,e=K()){super("omap",t,ao,Mo,e)}extendProtoForType(t,e){Xs(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 wh=M(),qo=(t)=>Array.isArray(t)?M(t):t instanceof Set?M(t):null;class Cs extends B{constructor(t,e=wh){super("set",t,yo,qo,e)}extendProtoForType(t,e){let{name:r}=this;Bs(t,r,e,wh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},Eh(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 zh(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 Ih{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]=zh(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]=zh(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]:Be(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 bh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var Ah=new Map,bo={text:Zs,int:Mh,float:Hs,bool:Ts,list:Gs,map:Qs,omap:Ys,set:Cs,any:Fe};function Eo(t,{fields:e={},methods:r,statics:s}){let i=new Ih(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Zs);else if(u==="number")i.addField(n,h,Hs);else if(u==="boolean")i.addField(n,h,Ts);else if(J.isList(h)||Array.isArray(h))i.addField(n,J(h),Gs);else if(M.isSet(h)||h instanceof Set)i.addField(n,M(h),Cs);else if(K.isOrderedMap(h))i.addField(n,h,Ys);else if(h?.type&&h?.defaultValue!==void 0){let o=bo[h.type]??Fe;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(Z.isMap(h)||h?.constructor===Object)i.addField(n,Z(h),Qs);else{let o=Ah.get(h?.constructor)??Fe;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var jo=(t)=>new Er(t.name??"Comp",Eo(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:zc,raw:Sc}=String;function Oc(t,e){return new yr(t,e)}var Io=(t)=>typeof t==="string"?document.querySelector(t):t;function Mc(t){let e=Io(t),r=new be,s=(o)=>new St(o),i=(o)=>new Pe(o),n={document},h=(o,c)=>yh(o,c,n),u=new Us(r,gh,s,i,h);return new Jr(e,h,r,u,Yt)}export{nc as version,Wt as updateIn,Bn as update,Mc as tutuca,Zu as setIn,Ju as set,uh as seqInfoByClass,Tu as removeIn,Ru as remove,vo as mergeWith,ec as mergeDeepWith,tc as mergeDeep,mo as merge,Oc as macro,Yi as isValueObject,es as isStack,ts as isSet,vr as isSeq,yt as isRecord,jn as isPlainObject,On as isOrderedSet,rs as isOrderedMap,x as isOrdered,rs as isOMap,He as isMap,Sn as isList,w as isKeyed,j as isIndexed,Y as isImmutable,He as isIMap,R as isCollection,mr as isAssociative,I as is,Zi as injectCss,Sc as html,X as hash,Un as hasIn,yu as has,is as getIn,An as get,ic as fromJS,Ah as fieldsByClass,zc as css,jo as component,Nt as Stack,M as Set,N as Seq,sc as Repeat,Be as Record,Vr as Range,Yt as ParseContext,rc as PairSorting,k as OrderedSet,K as OrderedMap,K as OMap,Z as Map,J as List,M as ISet,Z as IMap,V as Collection};
|