tutuca 0.9.0

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