@wcstack/state 4.0.0-rc.3 → 4.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +16 -16
- package/README.md +16 -16
- package/dist/auto.min.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/manifest.d.ts +2 -2
- package/dist/manifest.esm.js +69 -78
- package/dist/parser.esm.js +40 -26
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/chunk-372Y2FIC.js +1 -0
- package/dist/split/chunks/{chunk-I2V4DGEI.js → chunk-5D34CGCF.js} +1 -1
- package/dist/split/chunks/{chunk-YZ4LWPXN.js → chunk-5LIOXC7W.js} +1 -1
- package/dist/split/chunks/chunk-6GES2BK3.js +1 -0
- package/dist/split/chunks/chunk-7644KQ3T.js +1 -0
- package/dist/split/chunks/{chunk-Z3EEGBYA.js → chunk-G2ZO6SXV.js} +1 -1
- package/dist/split/chunks/chunk-HSOCDTWX.js +1 -0
- package/dist/split/chunks/chunk-ROX5KEJX.js +1 -0
- package/dist/split/chunks/chunk-SEPY6OHJ.js +1 -0
- package/dist/split/chunks/chunk-Z7B3ZZE4.js +1 -0
- package/dist/split/chunks/chunk-ZOINIOIM.js +1 -0
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/diagnostics.d.ts +3 -3
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/formats.d.ts +4 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/list-keys.js +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/dist/wcs-manifest.json +15 -15
- package/package.json +1 -1
- package/dist/split/chunks/chunk-2PWEFKRB.js +0 -1
- package/dist/split/chunks/chunk-5PWMZ75N.js +0 -1
- package/dist/split/chunks/chunk-FED2DM4X.js +0 -1
- package/dist/split/chunks/chunk-HYEQWIFX.js +0 -1
- package/dist/split/chunks/chunk-NPPWJBGJ.js +0 -1
- package/dist/split/chunks/chunk-WPSUT5QQ.js +0 -1
- package/dist/split/chunks/chunk-YPD4YBJO.js +0 -1
- package/dist/split/chunks/chunk-YZUTVCIH.js +0 -1
package/dist/auto.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class{constructor(e,n,l){this.h=[],this.getter=null,this.oe=null,this.de=!1,this.G=[],this.$e=[],this.ct=null,this.F=-1,this.J=t,this.Fe=null,this.Pt=null,this.Tt=null,this.q=null,this.At=new Set,this.t=e,this.d=l,this.s=n;let i=null===l?[null]:l.f.slice(),r="*"===n;r&&i.push(l),this.n=i.length-1,this.U=r?[]:null===l?[n]:[...l.U,n],this.f=i}jn(e){this.At.has(e)||(this.At.add(e),this.G.push(e),e.$e.push(this))}Po(){this.getter=null,this.oe=null,this.F=-1,this.J=t,this.G.length=0,this.At.clear(),this.$e.length=0,this.ct=null,this.Fe=null,this.Pt=null,this.Tt=null,this.q=null}Q(e){let t=this;for(;null!==t;){if(t===e)return!0;t=t.d}return!1}},t=Symbol("unset"),n=Symbol("dirty"),l=Symbol("failed"),i=class{constructor(e=null){this.Ft=new Map,this.Ln=e}Ot(e){return this.Ft.get(e)}get(t){let n=this.Ft.get(t);if(void 0!==n)return n;let l=t.lastIndexOf("."),i=l<0?null:this.get(t.slice(0,l));return n=new e(t,t.slice(l+1),i),this.Ln?.(n),this.Ft.set(t,n),i&&i.h.push(n),n}all(){return this.Ft.values()}},r=new Map;function o(e){let t=r.get(e);if(void 0!==t)return t;let n=!0,l=e.split("."),i=[];for(let e=0;e<l.length;e++){let t=l[e],r=t.charCodeAt(0);e>0&&r>=48&&r<=57?(n=!1,i.push(Number(t)),l[e]="*"):"*"===t&&i.push(-1)}if(!n)return{o:l.join("."),indexes:i};let o={o:e,indexes:null};return r.set(e,o),o}var s=class{constructor(e,t,n){this.ut=null,this.$=null,this.fe=null,this.q=null,this.h=null,this.y=!0,this.l=e,this.b=t,this.T=n}},a=class{constructor(e,t){this.C=null,this.u=[],this.$=null,this.L=null,this.Z=!1,this.Ct=!1,this.dt=!1,this.o=e,this.re=t,this.n=e.n+1}},u=[],c={};function f(e,t){return null==e?t:(...n)=>{e(...n),t(...n)}}function h(e,t,n){return null==t?n:(...l)=>{let i=t(...l);return e(i)?i:n(...l)}}var d=e=>!0===e,p=e=>void 0!==e,m=e=>null!=e,g=new Set;function y(e){let t=e.$features;if(null!=c.jt&&Array.isArray(t)){let e=t.filter(e=>!g.has(e));if(e.length>0)return c.jt(e)}}function $(e,t){if(!g.has(e))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${t} needs the add-on @wcstack/state/features/${e}`)}function v(e,t,n){throw new Error(`[@wcstack/state] ${e}${c.Ao?.(e,t,n)??""}`)}var b=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],w=e=>{let t=b[e/100|0];return t?`[wcs/${t}] `:""};function k(e,t=[]){return c.Fo?.(e,t)??`${w(e)}#${e}${t.map(e=>` ${"string"==typeof e?JSON.stringify(e):String(e)}`).join("")}`}function S(e,t,n,l){v(k(e,t),n,l)}var x=class{constructor(e){this.ft=new Set,this.name=e}get size(){return this.ft.size}subscribe(e){return this.ft.add(e),()=>{this.ft.delete(e)}}unsubscribe(e){return this.ft.delete(e)}emit(...e){let t=[];for(let n of this.ft)try{t.push(n(...e))}catch(e){t.push(void 0),console.error(`[@wcstack/state] ${k(17,[this.name])}`,e)}return t}};function A(e,t,n){if(void 0===e)return[];Array.isArray(e)||S(18,[t]);let l=new Set;for(let i of e)("string"!=typeof i||""===i)&&S(19,[t]),i===n&&S(20,[t,i,n]),l.has(i)&&S(21,[t,i]),l.add(i);return e}var N=Symbol.for("wcstack.transition-runner");function j(e){let t=globalThis[N];return null==t||"wcs-transition-runner"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.run||"function"!=typeof t.accepts||!t.accepts(e)?null:t}function O(e,t,n){let l=j(e);if(null!==l)return l.run(t,{source:e,types:n});t()}var M="else",C="eventToken",T=/^\$[1-9]\d{0,2}$/,P=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function E(e){let t=[],n=[],l="",i=null,r=!1,o=-1,s=-1,a=e=>{let i=function(e,t,n){let l=-1===t?e.length:t,i=-1===n?0:n;return e.slice(l-e.slice(0,l).trimStart().length,i+e.slice(i).trimEnd().length)}(l,o,s);(!e||i||r)&&(t.push(i),n.push(function(e,t){return t?e:"true"===e||"false"!==e&&("null"===e?null:P.test(e)?Number(e):e)}(i,r))),l="",r=!1,o=-1,s=-1};for(let t=0;t<e.length;t++){let n=e[t];i?n===i?i=null:(-1===o&&(o=l.length),l+=n,s=l.length):'"'===n||"'"===n?(i=n,r=!0):","===n?a():l+=n}return null!==i&&S(107,[i,e]),a(!0),{args:t,literals:n}}var W=e=>e.trim();function R(e,t){let n=[],l=null;for(let i=0;i<e.length;i++){let r=e[i];null!==l?r===l&&(l=null):"'"===r||'"'===r?l=r:r===t&&n.push(i)}return n}var I=(e,t)=>R(e,t)[0]??-1;function L(e,t){let n=[],l=0;for(let i of R(e,t))n.push(e.slice(l,i)),l=i+1;return n.push(e.slice(l)),n}function q(e,t,n){let l=I(e,"|");if(-1===l)return[e.trim(),[]];let i=e.slice(l+1).trim(),r=n.get(i);return void 0===r&&(r=function(e,t,n){let l=n??e.join("|");return e.map(e=>{let n=I(e,"("),i=(e=>R(e,")").pop()??-1)(e);if(-1===i&&(i=e.lastIndexOf(")")),-1!==n&&-1===i&&S(108,[e]),-1!==i&&-1===n&&S(109,[e]),-1!==i&&i<n&&S(110,[e]),-1!==i&&e.slice(i+1).trim().length>0){let t=e.slice(i+1).trim();S(111,[e,t])}let r=(-1===n?e:e.substring(0,n)).trim();if(0===r.length&&S(112,[l]),r.includes("#")){let[,e]=r.split("#");S("input"===t?113:114,[r,e])}return-1===n?{Bn:r,args:[],literals:[]}:{Bn:r,...E(e.substring(n+1,i))}})}(L(i,"|").map(W),t,e),n.set(i,r)),[e.slice(0,l).trim(),r]}var D=new Map;function z(e){S(1101,[e])}function U(e){let[t,n]=q(e,"output",D);t.includes("@")&&S(32,[t]);let l=t,i=l.startsWith("."),r=i?l.slice(1):l;return(r.length>0&&r.split(".").some(e=>0===e.length)||!i&&0===r.length)&&S(119,[e]),function(e){e.includes("**")&&z(e);let t=e.split(".").length;t>512&&S(117,[e,t])}(l),{Je:l,Qe:n}}var _=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],F=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],B=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function H(e){return e.includes("**")&&z(e),e}var K=0;function V(e,t,n){let l=e.get(t);return void 0===l&&e.set(t,l=n()),l}var J=()=>new Set,X=()=>[];function G(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}function Y(e,t){return e===t||e!=e&&t!=t}function Q(e,t,n){let l=e.q?.get(t);void 0!==l&&l.delete(n)&&0===l.size&&e.q.delete(t)}function Z(e,t){for(let n=0;n<t.length;n++){if(null==e)return;e=e[t[n]]}return e}function ee(e,t){for(;null!==e&&e.l.n>t;)e=e.l.re;return null!==e&&e.l.n===t?e:null}function te(e,t,n){let l=ee(e,n);return null!==l&&l.l.o===t.f[n]?l:null}var ne=class{constructor(e,t){this.Oe=0,this.c=null,this.Ce=0,this.pt=new Set,this.Ze=new Map,this.Dn=Symbol("wcs.block"),this.element=null,this.mt=[],this.Ie=null,this.Mn=[],this.Mt=0,this.K=null,this.ee=new Map,this.ie=new Map,this.je=[],this.Le=[],this.Be=[],this.ht=!1,this.dn=!1,this.Wt=new WeakMap,this.M=0,this._t=0,this.fn=!1,this.Ht=!1,this.Vt=!1,this.xe=0,this.Wn=()=>{this.M=0,this.fn=!1},this._n=()=>{this.xe--},this.rp=null,this.rr=null,this.Oo=()=>this.Ut(),this.Co=(e,t)=>e(this.proxy,...t),this.Hn=[],this.Io={$untracked:e=>{let t=this.K;if(null===t)return e();t.pe++;try{return e()}finally{t.pe--}},$eqIndex:(e,t=1)=>{let n=ee(this.c,t);null===n&&S(7,[e]);let l=this.o(e);if(null!==l.getter||l.de)return this.watchIndex(t),n.b===this.read(l,null);let i=this.K;if(null!==i){let e=i.getter,n=l.Fe??(l.Fe=[]);if(!n.some(n=>n.getter===e&&n.Vn===t)){n.push({getter:e,Vn:t});let i=e.f[t];(i.Pt??(i.Pt=[])).push({source:l,getter:e})}}return n.b===this.v(l,null)},$eq:(e,t)=>this.eq(e,t),$eqPath:(e,t)=>{let n=this.o(t);return this.eq(e,this.v(n,ee(this.c,n.n)))},$dependOn:e=>{this.resolve(H(e),this.c),null!==this.K&&0===this.K.pe&&this.Un(this.rp,this.rr,this.K)},$getAll:(e,t)=>this.getAll(e,t),$setAll:(e,t,n,l)=>this.pn(e,t,n,l),$resolve:(...e)=>{let t=H(e[0]),n=e[1]??[],l=this.o(t);this.mn("$resolve",t,l,n,!0);let i=this.qn(l,n,null);if(e.length<3)return this.read(l,i);this.P(l,i,e[2])},$postUpdate:e=>{this.resolve(H(e),this.c);let t=this.rp,n=this.rr;"*"===t.s&&null!==n&&(n.T=n.l.C[n.b],this.R.qt(n)),this.hn(t,n),null!==n&&this.Kn(n,t,void 0,n.T,!1),0===t.n&&this.zn(t,void 0,void 0,!0),this.Kt(t,n,void 0,void 0,!1)}},this.R=t,this.B=new i(e=>this.et(e)),this.Xn(e);let n=this,l={getOwnPropertyDescriptor(e,t){let l=Reflect.getOwnPropertyDescriptor(n.target,t);return l&&(l.configurable=!0),l},get(e,t,l){let i=n.target;if("symbol"==typeof t)return Reflect.get(i,t);if(36===t.charCodeAt(0))return n.zt(t);if(t.indexOf(".")<0){let e=n.B.Ot(t);if(void 0===e||null===e.getter){let e=i[t];if("function"==typeof e)return l===n.proxy&&n.W?.(e)||e}if(void 0!==e&&0===e.n)return n.read(e,null)}return n.resolve(t,n.c),n.read(n.rp,n.rr)},set:(e,t,l)=>"symbol"==typeof t?Reflect.set(n.target,t,l):(n.resolve(H(t),n.c),n.P(n.rp,n.rr,l),!0)};for(let e of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])l[e]=(t,...l)=>Reflect[e](n.target,...l);this.proxy=new Proxy({},l)}o(e){return this.B.get(e)}Yn(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n)){if(t.has(e))continue;t.add(e);let l=Object.getOwnPropertyDescriptor(n,e);if(void 0===l.get&&void 0===l.set)continue;let i=this.o(e);i.getter=l.get??null,i.oe=l.set??null,null!==i.getter&&i.n>0&&(i.F=this.Oe++)}for(let e of this.B.all())this.et(e)}et(e){e.t.includes("**")&&z(e.t),("__proto__"===e.s||"prototype"===e.s)&&S(120,[e.t]);let t=e.d;e.de=null!==t&&"*"!==e.s&&t.n===e.n&&(null!==t.getter||t.de),null===e.getter&&this.jo(e)}jo(e){let t=e.t,n=e.s;if(T.test(n))e.getter=function(){return this[n]};else{let l=t.split("."),i=l.findIndex((e,t)=>t>0&&e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57);if(i<0||l.indexOf("*",i)>=0)return;e.getter=()=>(this.resolve(t,this.c),this.rp!==e?this.read(this.rp,this.rr):this.read(e.d,this.c)?.[n]),e.oe=l=>{if(this.resolve(t,this.c),this.rp!==e)return this.P(this.rp,this.rr,l);let i=this.read(e.d,this.c);null==i&&S(4,[t,i]),i[n]=l}}e.n>0&&(e.F=this.Oe++)}De(e,t){let n=null===e?this.ee:e.h??=new Map,l=n.get(t);return void 0===l&&n.set(t,l=new a(t,e)),this.z(l),l}Gn(e){try{this.z(e)}catch(t){this.Xt(t,e.o.t,e.$?.S??null,"for")}}z(e){let t=this.v(e.o,e.re);if(t===e.C)return;this.Jn(e);let n=function(e,t,n){let l=Array.isArray(t)?t:u;if(l===e.C)return null;let i=e.u,r=l.length,o=i.length,a=new Array(r),c=0;for(;c<r&&c<o&&i[c].T===l[c];)a[c]=i[c],c++;let f=o-1,h=r-1;for(;f>=c&&h>=c&&i[f].T===l[h];)a[h]=i[f],f--,h--;if(c>f)for(let t=c;t<=h;t++)a[t]=new s(e,t,l[t]);else if(c>h)for(let e=c;e<=f;e++)n.It(i[e]);else{let t=new Map;for(let e=c;e<=f;e++){let n=i[e],l=t.get(n.T);void 0===l?t.set(n.T,n):Array.isArray(l)?l.push(n):t.set(n.T,[l,n])}for(let n=c;n<=h;n++){let i,r=l[n],o=t.get(r);void 0!==o&&(Array.isArray(o)?(i=o.shift(),0===o.length&&t.delete(r)):(i=o,t.delete(r))),a[n]=i??new s(e,n,r)}for(let e of t.values())if(Array.isArray(e))for(let t of e)n.It(t);else n.It(e)}for(let e=c;e<r;e++){let t=a[e];t.b!==e&&(t.b=e,n.To(t))}return e.u=a,e.C=l,i}(e,t,this);if(null===n)return;if(e.C===t){let n=V(this.Wt,t,X);if(n.push(e),n.length>1)for(let e of n)e.dt=!0}c.Yt?.(this,e,n),(null!==e.$||null!==e.L)&&!e.Z&&(e.Z=!0,this.Le.push(e),this.Re());let l=e.o.Pt;if(null!==l)for(let{source:t,getter:i}of l){let l=this.v(t,null),r=n[l],o=e.u[l];r!==o&&(void 0!==r&&r.y&&this.gn(i,r),void 0!==o&&this.gn(i,o))}}To(e){this.R.Lo(this,e)}It(e){e.y=!1;let t=e.q;if(null!==t){for(let e of t)Q(e.source,e.key,e.sub);e.q=null}if(null!==e.h)for(let t of e.h.values()){this.Jn(t);for(let e of t.u)this.It(e)}}Jn(e){let t=this.Wt.get(e.C);void 0!==t&&(t.splice(t.indexOf(e)>>>0,1),e.dt=!1,1===t.length&&(t[0].dt=!1))}resolve(e,t){let n=o(e),l=this.rp=this.o(n.o),i=n.indexes;this.rr=0===l.n?null:null===i?te(t,l,l.n):this.qn(l,i,t,e)}qn(e,t,n,l){let i=null;for(let r,o=1,s=0;o<=e.n;o++){let a=e.f[o],c=this.De(i,a),f=t[s++];if(f<0)f=te(n,e,o)?.b??-1;else if(l&&c.C===u&&Object(r=this.v(a,i))===r){let t=e.t.split("."),n=a.t.split(".").length;t[n]=l.split(".")[n],e=this.o(t.join(".")),o--;continue}if(i=c.u[f]??null,null===i)break}return this.rp=e,i}yt(e,t){return 0===e.n?Z(this.target,e.U):null===t?void 0:Z(t.T,e.U)}read(e,t){let n=this.K;if(null!==n&&0===n.pe&&this.Un(e,t,n),null!==e.getter)return this.R.Bo(this,e,t);if(e.de){let n=this.read(e.d,t);return n?.[e.s]}return null===e.d&&!(e.s in this.target)&&!this.pt.has(e.s)&&"then"!==e.s&&"toJSON"!==e.s&&S(301,[e.t],e.s,Object.keys(this.target)),this.yt(e,t)}v(e,t){let n=this.K;if(null===n)return this.read(e,t);n.pe++;try{return this.read(e,t)}finally{n.pe--}}Un(e,t,n){let l=n.getter;e.jn(l),e.n>0&&l.n>0&&ee(t,Math.min(e.n,l.n))!==ee(n.r,Math.min(e.n,l.n))&&(l.ct??(l.ct=new Set)).add(e)}Do(e,t){for(let n=0;n<this.Mt;n++){let l=this.Mn[n];l.getter===e&&l.r===t&&S(701,[e.t])}this.Mt>=128&&S(801,[e.t]);let n=this.Mt++;this.Ce++;let l=this.Mn[n]??={getter:e,r:t,pe:0,Me:0};l.getter=e,l.r=t,l.pe=0,l.Me=++K;let i=this.K;this.K=l;let r=this.c;this.c=t;try{return e.getter.call(this.proxy)}finally{this.Ce--,this.Mt--,this.K=i,this.c=r,l.r=null}}watchIndex(e){let t=this.K;if(null!==t&&0===t.pe){let n=t.getter,l=n.f[e];if(l){let e=l.Tt??(l.Tt=[]);e.includes(n)||e.push(n)}}}zt(e){let t=e.charCodeAt(1);if(t>=48&&t<=57){let n=2===e.length?t-48:T.test(e)?+e.slice(1):0;return(n<1||n>128)&&S(1001,[e]),this.watchIndex(n),ee(this.c,n)?.b}let n=this.Io[e];if(void 0!==n)return n;switch(e){case"$trackDependency":return S(1701,[e,"$dependOn"]);case"$untrackDependency":return S(1701,[e,"$untracked"]);case"$stateElement":return this.element;case"$command":return this.commands}return c.zt?.(this,e)}eq(e,t){this.resolve(e,this.c);let n=this.rp,l=this.rr;if(null!==n.getter||n.de||n.n>0)return Y(this.read(n,l),t);let i=this.K;return null!==i&&0===i.pe&&this.Mo(n,t,i),Y(this.v(n,null),t)}Mo(e,t,n){let l=n.getter,i=n.r,r=null===i?this.Hn:i.q??(i.q=[]);for(let i=0;i<r.length;i++){let o=r[i];if(o.sub.getter===l&&o.source===e){if(Y(o.key,t))return void(o.Me=n.Me);o.Me!==n.Me&&(Q(e,o.key,o.sub),r.splice(i--,1))}}let o={getter:l,r:i};V(e.q??=new Map,t,J).add(o),r.push({source:e,key:t,sub:o,Me:n.Me})}zn(e,t,n,l){this.Gt(e,i=>{let r=i.q;if(null===r&&null===i.Fe)return;let o=i===e?[]:i.t.slice(e.t.length+1).split("."),s=Z(t,o),a=Z(n,o);if(null!==i.Fe&&this.Wo(i,s,a,l),null!==r)for(let e of l?r.keys():[s,a]){let t=r.get(e);if(void 0!==t)for(let n of t)null===n.r||n.r.y?this.R.me(this,n.getter,n.r):Q(i,e,n)}})}P(e,t,n,l=!1,i=!1){if(this.Ce>0&&S(8),i||this.xe>0?this.Ht=!0:this.Vt=!0,c.Pe?.(this,e,t,n,i))return;if(null!==e.oe){try{this.yn(e.oe,t,[n])}finally{this.Kt(e,t,void 0,void 0,!1)}return}null!==e.getter&&S(2,[e.t]),e.n>0&&null===t&&S(3,[e.t]);let r=e.de?this.v(e,t):this.yt(e,t);if(l||!this.Bt||!Object.is(r,n)||Object(n)===n){if("*"===e.s){let e=t;e.l.C[e.b]=n,e.T=n,this.R.qt(e)}else{let l=1===e.U.length?0===e.n?this.target:t.T:this.v(e.d,t);null==l&&S(4,[e.t,l]),l[e.s]=n}this.wn(e,t),null!==t&&this.Kn(t,e,r,n),0===e.n&&this.zn(e,r,n),this.Kt(e,t,r,n,!0)}}Qn(e){return(this.Wt.get(e.C)??[]).filter(t=>t.C===e.C&&(null===t.re||t.re.y))}Kn(e,t,l,i,r=!0){let o=e.l;if(!o.dt&&null===o.o.getter&&!o.o.G.length)return;let s=e.T,a=t.t.slice(o.o.t.length+2),u=(t,n)=>{if(void 0===n||n===e)return;let o=this.o(`${t.o.t}.*${a}`);""===a&&(n.T=i,this.R.qt(n)),r?this.wn(o,n):this.hn(o,n),this.Kt(o,n,l,i,r)};for(let t of this.Qn(o))u(t,t.u[e.b]);if(""===a)return;let c=new Set([o.C]),f=e=>Array.isArray(e)&&e.includes(s),h=(e,t)=>{if(!c.has(e)&&c.add(e))for(let t of this.Wt.get(e)??[])for(let e of t.u)e.T===s&&u(t,e);for(let l of t){let t=l.J,i=t===n;i&&(t=this.ee.get(l)?.C),(i||f(t))&&!c.has(l.G)&&c.add(l.G)&&(!i&&t!==e&&this.R.me(this,l,null),h(t,l.G))}},d=e=>{for(let t of e.$e)if(!c.has(t)&&c.add(t))if(null!==t.getter)d(t);else if(!t.de){let e=this.yt(t,null);f(e)&&h(e,t.G)}};null!==o.o.getter?d(o.o):h(o.C,o.o.G)}hn(e,t){this._o(e,t,e=>{this.z(e);for(let t of e.dt?this.Qn(e):[e]){let e=this.o(`${t.o.t}.*`);for(let n of t.u)this.wt(e,n),this.hn(e,n)}})}wn(e,t){let n=null===t?this.ee:t.h;if(null!==n)for(let t of n.values())t.o.Q(e)&&this.z(t)}_o(e,t,n){let l=null===t?this.ee:t.h;if(null!==l)for(let t of l.values())t.o.Q(e)&&n(t)}Wo(e,t,n,l){for(let{getter:i,Vn:r}of e.Fe)this.Zn(i.f[r],e=>{for(let r of l?e.u.keys():[t,n]){let t="number"==typeof r?e.u[r]:void 0;void 0!==t&&this.gn(i,t)}})}gn(e,t){t.l.n===e.n?this.R.me(this,e,t):this.Jt(t,e,t=>this.R.me(this,e,t))}Kt(e,t,n,l,i){c.he?.(this,e,t,n,l,i),this.We(e,t)}We(e,t){this.R.Ho(this,e,t),this.Re()}eo(e){let t=this.Ze.get(e);if(void 0!==t)return t;let n=Symbol(`wcs.on${e}`);this.Ze.set(e,n);let l=this.root,i=this.Dn;return l.addEventListener(e,t=>{for(let r=t.target;null!==r&&r!==l;r=r.parentNode){let l=r[n];if(void 0!==l&&(l(t),t.cancelBubble))return;let o=r[i];if(void 0!==o&&o.y&&o.Vo(e,t))return}}),n}reset(e){let t=this.target,n=this.pt;for(let e of this.B.all())null===e.d&&null!==e.getter&&n.add(e.s);this.Xn(e);for(let e in t)"$"!==e[0]&&n.add(e);for(let t of n)t in e&&n.delete(t);for(let e of this.ie.values())for(let t of e)this.Qt(t);for(let e of this.ee.values())this.to(e);this.Ie=null;try{this.Ut()}finally{this.bn()}c.element?.(this,"reset")}Xn(e){for(let[t,n]of F)void 0!==e[t]&&$(n,t);void 0!==e.$scan&&S(1);for(let[t,n]of _)void 0!==e[t]&&S(1601,[t,n]);let t=e.$features;if(void 0!==t){Array.isArray(t)||S(46);for(let e of t)$(e,"$features")}let n=void 0===e.$behavior?{}:e.$behavior;("object"!=typeof n||!n||Array.isArray(n))&&S(44,["state","$behavior"]);for(let e in n)(!B.includes(e)||"boolean"!=typeof n[e])&&S(44,["$behavior",e]);let[l,i,r]=B.map(e=>n[e]??!0);void 0!==this.target&&(l!==this.Lt||i!==this.Bt||r!==this.Dt)&&S(45);let o=function(e,t){let n={};for(let l of A(e.$commandTokens,"$commandTokens","$command"))n[l]=t?.[l]??new x(l);return Object.freeze(n)}(e,this.commands),s=function(e,t){let n=new Map;for(let t of A(e.$eventTokens,"$eventTokens"))n.set(t,new x(t));let l=e.$on;if(void 0===l)return n;(null===l||"object"!=typeof l)&&S(22);for(let[e,i]of Object.entries(l)){let l=n.get(e);void 0===l&&S(23,[e]),"function"!=typeof i&&S(24,[e]),l.subscribe((...e)=>t(i,e))}return n}(e,this.Co);this.Lt=l,this.Bt=i,this.Dt=r,c.se?.(this,e),this.target=e,this.Oe=0;for(let e of this.B.all())e.Po();this.Hn.length=0,this.Yn(e),this.commands=o,this.Ne=s}to(e){this.Gn(e);let t=this.o(`${e.o.t}.*`);for(let n of e.u)if(n.ut=null,n.q=null,this.wt(t,n),null!==n.h)for(let e of n.h.values())this.to(e)}_(e){let t=[];for(let n=e;null!==n;n=n.l.re)t.unshift(n.b);return t}Uo(e,t,n){let l=this.Ne.get(e);void 0===l&&S(1301,[e],e,this.Ne.keys()),l.emit(t,...this._(n))}command(e){let t=this.commands[e];return void 0===t&&S(1302,[e],e,Object.keys(this.commands)),t}qo(e,t,n){this.command(e).emit(t,...this._(n))}Ko(e,t,n){let l=e.includes(".")?this.v(this.o(e),null):this.target[e];return"function"!=typeof l&&S(5,[e]),this.yn(l,n,[t,...this._(n)])}yn(e,t,n){let l=this.c;this.c=t;try{return e.apply(this.proxy,n)}finally{this.c=l}}wt(e,t){if(null!==e.getter){let n=null===t?this.ee:t.h;if(null!==n)for(let t of n.values())!t.Ct&&t.o.Q(e)&&(t.Ct=!0,this.Be.push(t))}if(null===t)return void this.Gt(e,e=>{let t=this.ie.get(e);if(void 0!==t)for(let e of t)this.Qt(e)});let n=t.fe;if(null!==n)for(let t=0;t<n.length;t++)n[t].o.Q(e)&&this.Qt(n[t]);let l=t.$;null!==l&&null!==l.ae&&l.no(this,e);let i=t.l.L;if(null!==i)for(let n of i){let l=n.map.get(t);void 0!==l&&null!==l.ae&&l.no(this,e)}}vn(e,t,n){this.Gt(e,e=>{let l=e.G;for(let i=0;i<l.length;i++){let r=l[i];if(0===r.n)this.tt(r,null,n);else if(null===t||0===e.n||r.f[1]!==e.f[1]||null!==r.ct&&r.ct.has(e))this.Zt(r.f[r.n],e=>this.tt(r,e,n));else if(r.n<=e.n){let e=ee(t,r.n);null!==e&&this.tt(r,e,n)}else this.Jt(t,r,e=>this.tt(r,e,n))}})}tt(e,t,n){n(e,t)&&(c.ye?.(this,e,t),this.wt(e,t),this.vn(e,t,n))}Gt(e,t){t(e);let n=e.h;for(let e=0;e<n.length;e++)this.Gt(n[e],t)}Zt(e,t){this.Zn(e,e=>{for(let n of e.u)t(n)})}Zn(e,t){if(0===e.n){let n=this.ee.get(e);return void(void 0!==n&&t(n))}this.Zt(e.f[e.n],n=>{let l=n.h?.get(e);void 0!==l&&t(l)})}Jt(e,t,n){if(e.l.n===t.n)return n(e);let l=e.h?.get(t.f[e.l.n+1]);if(void 0!==l)for(let e of l.u)this.Jt(e,t,n)}zo(e){let t=e.r;null===t?V(this.ie,e.o,J).add(e):(t.fe??(t.fe=[])).push(e)}kn(e){let t=e.r;if(null===t)return void this.ie.get(e.o)?.delete(e);let n=t.fe;t.y&&null!==n&&n.splice(n.indexOf(e)>>>0,1)}Qt(e){e.Z||(e.Z=!0,this.je.push(e),this.Re())}Re(){this.ht||(this.ht=!0,queueMicrotask(this.Oo))}Sn(){for(let e of this.je)e.Z=!1;for(let e of this.Le)e.Z=!1;for(let e of this.Be)e.Ct=!1;this.je=[],this.Le=[],this.Be=[],this.R.pt(this)}oo(e,t){let n=[...new Set([...this.je,...this.Le,...this.Be].map(e=>e.o.t))];console.error(`[@wcstack/state] ${k(e)}`,n),c.nt?.(this,{type:"state:render-chain-limit",maxDepth:t,paths:n}),this.Sn()}Ut(){this.ht=!1;let e=this._t;this._t=0;let t=0;if(!this.Ht||this.Vt?this.Wn():e>0?t=e:1===(t=++this.M)&&setTimeout(this.Wn,0),this.Ht=this.Vt=!1,t>100)101===t?this.oo(41,100):this.Sn();else{this.dn=!0;try{for(let e=0;this.je.length>0||this.Le.length>0||this.Be.length>0;e++){if(e>=32){this.fn?this.Sn():this.oo(11,32),this.fn=!0;break}let n=this.Be;if(n.length>0){this.Be=[];for(let e of n)e.Ct=!1,this.Gn(e)}let l=this.Le,i=this.je;this.Le=[],this.je=[];let r=O("state",()=>{for(let e of l){e.Z=!1;for(let t of[e.$,...e.L??[]])if(null!==t&&t.y)try{t.bt()}catch(n){this.Xt(n,e.o.t,t.S,"for")}}for(let e=0;e<i.length;e++){let t=i[e];t.Z&&(t.Z=!1,(null===t.En||t.En.y)&&this._e(t))}this.dn||(this.He(),this.ht&&(this._t=t+1))});void 0!==r&&r.then(void 0,e=>console.error(e))}}finally{this.dn=!1}this.Ht=this.Vt=!1,this.He(),c.Te?.(this),e>0&&this.ht&&(this._t=t+1)}}vt(e,t){this.mt.push([e,t])}Xt(e,t,n,l){this.vt(e,{o:{t},a:n,en:()=>l})}_e(e){try{e.apply()}catch(t){return void this.mt.push([t,e])}null!==this.Ie&&this.io(e.o,e.r)}io(e,t){let n=V(this.Ie,e.t,X);null!==t&&n.push(this._(t))}bn(){this.Ie="function"==typeof this.target.$renderedCallback?new Map:null}He(){let e=this.Ie;if(null!==e&&e.size>0){this.Ie=new Map;let t,n=[...e.keys()],l={};for(let[t,n]of e)n.length>0&&(l[t]=n);this.xe++;try{t=this.we("$renderedCallback",[n,l])}catch(e){console.error(e)}G(t)?t.then(this._n,e=>{this._n(),console.error(e)}):this.xe--}if(0===this.mt.length)return;let t=this.mt;this.mt=[];let n=this.target.$errorCallback;for(let[e,l]of t){c.Ve?.(this,e,l);let t=l.o.t,i=l.en();if("function"==typeof n)try{let n=this.we("$errorCallback",[e,{path:t,bindingType:i,node:l.a}]);G(n)&&n.then(void 0,e=>console.error(e))}catch(e){console.error(e)}else console.error(`[@wcstack/state] ${k(12,[i,t])}`,e)}}we(e,t=[]){let n=this.target[e];return"function"==typeof n?this.yn(n,null,t):void 0}so(e,t,n){if(0===e.n)return void n(null,[]);let l=[],i=(r,o)=>{let s=e.f[r];this.read(s,o);let a=this.De(o,s),u=t=>{l.push(t.b),r===e.n?n(t,l):i(r+1,t),l.pop()};for(let e of r-1<t.length?[a.u[t[r-1]]]:a.u)void 0!==e&&u(e)};i(1,null)}getAll(e,t){let n=this.o(e);void 0!==t&&this.mn("$getAll",e,n,t,!1);let l=t;if(void 0===l){l=[];let t=this.c;if(null!==t&&n.n>0){for(let e=1;e<=n.n;e++){let i=te(t,n,e);if(null===i)break;l.push(i.b)}0===l.length&&S(6,[e])}}let i=[];return this.so(n,l,e=>i.push(this.read(n,e))),i}pn(e,t,n,l){Array.isArray(t)||S(9,[e]),this.Ce>0&&S(8);let i=this.o(e);this.mn("$setAll",e,i,t,!1);let r=[];this.so(i,t,(e,t)=>r.push([e,t.slice()]));let o=!0===l?.spread;o&&(!Array.isArray(n)||n.length!==r.length)&&S(10,[e,r.length]);let s=0;for(let e=0;e<r.length;e++){let[t,l]=r[e],a="function"==typeof n?n(this.v(i,t),...l):o?n[e]:n;void 0!==a&&(this.P(i,t,a),s++)}return s}mn(e,t,n,l,i){let r=l.length;(r>n.n||i&&r<n.n)&&S(i?901:902,[e,t,n.n,r])}},le={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1},ie=new Map,re=new Set(["if","elseif","else","for"]),oe=new Set([M,"if","elseif","for","..."]),se=new Set(["class","attr","style","command",C,"state"]);function ae(e){let t=function(e){return L(e,";")}(e).map(W).filter(e=>e.length>0).map(e=>{let t=I(e,":");-1===t&&S(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if(oe.has(i)){let t;return i!==n&&S(102,[e,i]),i===M?(l.length>0&&S(103,[e]),t={Je:"#else",Qe:[]}):"..."===i?(0===l.length&&S(104,[e]),t=U(l),t.Qe.length>0&&S(105,[e])):(t=U(l),"for"===i&&t.Qe.length>0&&S(121,[e])),{be:i,ve:[i],tn:[],I:[],...t,w:"..."===i?"spread":i}}let r=U(l),o=function(e){let[t,n]=q(e,"input",ie),l=t.split("#").map(W);l.length>2&&S(115,[t]);let[i,r]=l,o=i.split(".").map(W);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&S(116,[e]),{be:i,ve:o,tn:r?r.split(",").map(W):[],I:n}}(n),[s]=o.ve;if(""===s&&o.ve.length>1){let e=o.ve.slice(1);return(e.includes("")||se.has(e[0]))&&S(106,[n]),{...o,be:e.join("."),ve:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===C||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>re.has(e.w))&&S(201,[e]),t}var ue=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms"],ce=new Map,fe=new Map;function he(e){for(let t of Object.keys(e))ce.set(t,{...e[t]});fe.clear()}function de(e){return ce.has(e)}function pe(e){S(26,[e])}function me(e){S(27,[e])}function ge(e){S(28,[e])}function ye(e){S(29,[e])}function $e(e){return!(!e||isNaN(Number(e)))}function ve(e,t){return $e(e)||me(t),Number(e)}function be(e,t,n){return ve(e?.[t]??pe(n),n)}function we(e,t){return void 0!==t&&t.length>0?t[0]:e}var ke=(e,t)=>({factory:n=>{let l=be(n,0,e);return n=>("number"!=typeof n&&ge(e),t(n,l))},arity:[1,1]}),Se={eq:{factory:(e,t)=>{let n=e?.[0]??pe("eq"),l=we(n,t);return e=>"number"==typeof e?"string"!=typeof l?e===l:($e(n)||me("eq"),e===Number(n)):"string"==typeof e?e===n:e===l},arity:[1,1]},ne:{factory:(e,t)=>{let n=e?.[0]??pe("ne"),l=we(n,t);return e=>"number"==typeof e?"string"!=typeof l?e!==l:($e(n)||me("ne"),e!==Number(n)):"string"==typeof e?e!==n:e!==l},arity:[1,1]},not:{factory:()=>e=>!e,arity:[0,0]},lt:ke("lt",(e,t)=>e<t),le:ke("le",(e,t)=>e<=t),gt:ke("gt",(e,t)=>e>t),ge:ke("ge",(e,t)=>e>=t),add:ke("add",(e,t)=>e+t),sub:ke("sub",(e,t)=>e-t),mul:ke("mul",(e,t)=>e*t),div:ke("div",(e,t)=>e/t),mod:ke("mod",(e,t)=>e%t),abs:{factory:()=>e=>("number"!=typeof e&&ge("abs"),Math.abs(e)),arity:[0,0]},clamp:{factory:e=>{let t=be(e,0,"clamp"),n=be(e,1,"clamp");return e=>("number"!=typeof e&&ge("clamp"),Math.min(Math.max(e,t),n))},arity:[2,2]},int:{factory:()=>e=>parseInt(String(e),10),arity:[0,0]},float:{factory:()=>e=>parseFloat(String(e)),arity:[0,0]},falsy:{factory:()=>e=>!e,arity:[0,0]},truthy:{factory:()=>e=>!!e,arity:[0,0]},defaults:{factory:(e,t)=>{let n=we(e?.[0]??pe("defaults"),t);return e=>e||n},arity:[1,1]},coalesce:{factory:(e,t)=>{let n=we(e?.[0]??pe("coalesce"),t);return e=>e??n},arity:[1,1]},boolean:{factory:()=>e=>!!e,arity:[0,0]},number:{factory:()=>e=>Number(e),arity:[0,0]},string:{factory:()=>e=>String(e),arity:[0,0]},nullIfEmpty:{factory:()=>e=>""===e?null:e,arity:[0,0]}},xe=!1;function Ae(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function Ne(e){return 0===e.length?null:(xe||(xe=!0,he(Se)),e.map(e=>function(e,t,n){let l=`${e}${function(e,t){return`${JSON.stringify(e)}${JSON.stringify(t)}`}(t,n)}`,i=fe.get(l);if(typeof i<"u")return i;let r=ce.get(e);void 0===r&&function(e,t){ue.includes(e)&&v(`[wcs/filter-unknown] filter not found: ${e}. "${e}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,e,t),S(501,[e],e,t)}(e,ce.keys());let[o,s]=r.arity;t.length<o&&S(601,[e,o,t.length]),t.length>s&&S(602,[e,s,t.length]);let a=r.factory(t,n);return fe.set(l,a),a}(e.Bn,e.args,e.literals)))}var je=Symbol.for("wcstack.trustedTypes.policy");function Oe(){let e=globalThis[je];return null!==e&&"object"==typeof e?e:null}function Me(e){return"innerHTML"===e||"outerHTML"===e||"srcdoc"===e}function Ce(e){if(globalThis.trustedTypes?.isHTML(e))return e;let t=null==e?"":String(e),n=Oe(),l=n?.createHTML;return"function"==typeof l?l.call(n,t):t}var Te=Symbol.for("wcstack.state.view-transition-naming"),Pe=new WeakSet;function Ee(){let e=j("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var We=new WeakMap,Re=e=>e.customElementRegistry??customElements;function Ie(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=Re(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>Ie(e,t,n,l,i,!0));let a=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(We.has(e))return We.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new Map,commands:new Set};for(let e of t.properties??[])n.properties.set(e.name,{event:e.event,getter:"function"==typeof e.getter?e.getter:null,lo:"event"===e.semantics});for(let e of t.inputs??[])n.inputs.set(e.name,{attribute:"string"==typeof e.attribute?e.attribute:null});for(let e of t.commands??[])null!==e&&"object"==typeof e&&"string"==typeof e.name&&n.commands.add(e.name)}return We.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return a();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.kt??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{a()}catch(l){_e(e,l,t,n)}e.Re()})}function Le(e,t,n,l,i=t.o,r,o,s){let a=s.properties.get(l)??null,u=s.inputs.get(l),f=e.Dt;f&&null===a&&void 0===u&&S(38,[l]);let h=t.H;(null===a?"element"===h||"auto"===h:void 0===u&&("state"===h||"auto"===h))&&S(39,[h,l]),"connect"===t.z&&null===a&&S(40,[l]);let d=f&&null!==a&&void 0===u,p=new He(e,ze,n,l,i,r,o,t.N,void 0);p.I=t.I,p.attribute=u?.attribute??null,Ze(e,p,!d),null!==a&&!t.ro&&n.addEventListener(a.event,t=>{let i;null!==a.getter?i=a.getter(t):(i=t.detail,a.lo||c.detail?.(n,l,i)),(!p.$n||!Object.is(i,p.value))&&(i=Ae(p.I,i),null===p.N&&(p.value=i),e.P(p.o,p.r,i,a.lo,!0))});let m=h??(d?"element":"state");if("state"===m)d||e._e(p);else if("element"===m||"auto"===m){let i=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==e.v(p.o,p.r))return void(d||e._e(p));let t=n[l];null===p.N&&(p.value=t),e.P(p.o,p.r,t,!1,!0)};"connect"!==t.z||n.isConnected?i():Promise.resolve().then(i)}return p}function qe(e,t,n){S(e,[t.localName,n])}var De=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),ze=11,Ue=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],_e=(e,t,n,l)=>e.Xt(t,n.o?.t??n.St,l,Ue[n.i]),Fe=Symbol();function Be(e,t,n){let l=t.H;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.V:Fe}var He=class{constructor(e,t,n,l,i,r,o,s,a,u=null){this.Z=!1,this.I=null,this.attribute=null,this.$n=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.En=o,this.N=s,this.value=a,this.M=u}en(){return Ue[this.i]}apply(){if(null!==this.M)return void this.M.bt();let e=Ae(this.N,this.engine.read(this.o,this.r));if(e===this.value&&("object"!=typeof e||null===e||this.i===ze||8===this.i||Me(this.name)))return;if(this.value===Fe)return void(this.value=e);let t=this.a;if(this.i!==ze)9===this.i?t.checked=void 0!==e&&this.nn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.nn()):Ve(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.$n=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.$n=!1}null!==this.attribute&&function(e,t,n){try{if(null==n)e.removeAttribute(t);else{let l=n;if("object"==typeof n)try{l=JSON.stringify(n)}catch{}e.setAttribute(t,String(l))}}catch{}}(t,this.attribute,e)}}nn(){return Ae(this.I,this.a.value)}Xo(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.nn()}else if(10===this.i){let l=this.nn(),i=n.v(this.o,this.r),r=Array.isArray(i)?i:[],o=r.includes(l);if(t.checked?o:!o)return;e=o?r.filter(e=>e!==l):[...r,l]}else e=Ae(this.I,t[this.name]);n.P(this.o,this.r,e,!1,!0)}},Ke=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Ve(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(Ke(n)?t[n]="innerHTML"===n?Ce(l):null==l?"":String(l):Me(n)?null==l&&"srcdoc"===n?t.removeAttribute(n):void 0!==l&&(t[n]=Ce(l)):void 0!==l&&(t[n]!==l&&!("value"===n&&t.value===String(l))&&(t[n]=l),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[Je]=[n,l])));case 8:return void(t.innerHTML=Ce(l));case 2:return null!=l&&"boolean"!=typeof l&&S(401,[n,typeof l]),void t.classList.toggle(n,!0===l);case 3:return void(null==l?t.removeAttribute(n):t.setAttribute(n,String(l)));case 4:return void(null==l?t.style.removeProperty(n):t.style.setProperty(n,String(l)))}}var Je=Symbol();function Xe(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[Je];void 0!==n&&(t[n[0]]=n[1])}var Ge=class{constructor(e,t,n,l){this.y=!0,this.fe=null,this.h=null,this.kt=null,this.xn=null,this.r=e,this.Ue=t,this.j=n,this.A=l}Vo(e,t){let n=t.target,l=this.A,i=[],r=null;for(let t of l.Ne){if(t.name!==e)continue;let o=l.Rn[t.a],s=at(null===this.j?this.Ue:this.j[o[0]],o,1);s.contains(n)&&(s!==r&&i.unshift([]),i[0].push(t),r=s)}for(let e of i){for(let n of e)n.Nn(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.j?this.Ue:this.j[this.j.length-1]}qe(){let e=this.xn;return(null===e?null:e.Pn(this.Ue))??this.Ue}insertBefore(e,t){let n=this.s;for(let l=this.qe();;){let i=l.nextSibling;if(e.insertBefore(l,t),l===n)return;l=i}}uo(){null===this.j?this.Ue.remove():ut(this.qe(),this.s)}Se(e){if(this.y=!1,null!==this.kt)for(let e of this.kt)e();let t=this.fe;if(null!==t)for(let n=0;n<t.length;n++)e.kn(t[n]);if(null!==this.h)for(let e of this.h)e.Se()}},Ye=class extends Ge{constructor(e,t,n,l){super(e,t,n,l),this.fo=0,this.W=null,this.ae=0===l.Ke.length?null:new Array(2*l.Ke.length)}po(e,t){let n=this.W??=new Array(this.A.Ke.length),l=n[t];if(void 0===l){let i=this.A.Ke[t],r=this.ae;l=n[t]=new He(e,i.i,r[2*t],i.name,i.o,this.r,this,i.N,r[2*t+1])}return l}no(e,t){let n=this.A.Ke;for(let l=0;l<n.length;l++)n[l].o.Q(t)&&e.Qt(this.po(e,l))}Se(e){let t=this.r;t.$===this&&(t.$=null),super.Se(e)}};function Qe(e,t,n,l){let i=ee(n,t.n);try{return e.De(i,t)}catch(n){return e.Xt(n,t.t,l,"for"),null===i?e.ee.get(t):i.h.get(t)}}function Ze(e,t,n){n&&e.zo(t);let l=t.En;null!==l&&(l.fe??=[]).push(t)}var et=null;function tt(){let e=et;return et=null,e}var nt=-1;function lt(e,t,n,l,i=null){let r,o=t.Rn,s=t.build,a=t.mo,u=null,f=c.Ae?.(t,null===l?i:l.S,null!==l),h=!f&&t.Tn,d=f?document.createDocumentFragment():(h?t.root:t.on).cloneNode(!0);if(!f)for(let e=0;e<s.length;e++){let t=s[e];a[t]=at(d,o[t],h?1:0)}h?r=d:(u=f||[...d.childNodes],r=u[0]);let p,m=null;if(null!==l?(p=m=new Ye(n,r,u,t),null===l.map?n.$=m:l.map.set(n,m)):p=new Ge(n,r,u,t),nt>=0&&function(e,t,n,l){let i=null;if(null===t)i=1===e.nodeType?e:null;else for(let e=0;e<t.length&&null===i;e++)1===t[e].nodeType&&(i=t[e]);let r=i?.style;if(null===i||void 0===r||Pe.has(i))return;let o=globalThis[Te]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${k(25,[l])}`)):(Pe.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,u,null!==l?"row":"branch",nt),t.Ne.length>0){let t=e.Dn;if(null===u)r[t]=p;else for(let e of u)1===e.nodeType&&(e[t]=p)}let g=t.Yo,y=e.Ie,$=t.Go?a.slice(0,o.length):a,v=null===m?null:m.ae;if(null!==v){let e=t.Ke;for(let t=0;t<e.length;t++)v[2*t]=$[e[t].a],v[2*t+1]=e[t].V}for(let t=0;t<g.length;t++){let l=g[t],i=$[l.a],o=l.F;if(o>=0&&null!==v){let t=m.W?.[o];if(void 0!==t){t.Z=!1,e._e(t);continue}try{let t=Ae(l.N,e.read(l.o,n));t!==l.V&&(Ve(l.i,i,l.name,t),v[2*o+1]=t),null!==y&&e.io(l.o,n)}catch(t){e.vt(t,m.po(e,o))}continue}switch(l.i){case 6:{let t=new st(e,l.A,Qe(e,l.o,n,i),i);(p.h??=[]).push(t),i===r&&(p.xn=t),t.bt();break}case 7:{let t=rt(e,l.X.map(e=>({A:e.A,o:e.o,N:e.N,S:$[e.a]})),n,p);(p.h??=[]).push(t),i===r&&(p.xn=t);break}default:try{it(e,l,i,n,p)}catch(t){_e(e,t,l,i)}}}return et=p,d}function it(e,t,n,l,i){let r=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.Nn,o=e=>r(e,l);if(n.Ze){let l=e.eo(n.name),i=t[l];t[l]=void 0===i?o:e=>{i(e),o(e)},n.ke&&t.addEventListener(n.name,e=>e.bubbles||o(e))}else t.addEventListener(n.name,o),n.co&&null!==i&&(i.kt??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,l,i);case 12:return void Ie(e,t,r,i,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.St.slice(9));null===i&&qe(1202,n,`command.${r}`),i.commands.has(r)||S(1203,[n.localName,r]);let s=new WeakRef(n),a=o.subscribe((...e)=>{let t=s.deref();if(void 0!==t)return t.isConnected?t[r](...e):void 0;a()});null!==l&&(l.kt??=[]).push(a)}(e,t,r,i,n));case 13:return void Ie(e,t,r,i,n=>function(e,t,n,l,i){let r=t.name;null===i&&qe(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&S(1204,[n.localName,r]);let s=t.St;n.addEventListener(o.event,n=>{t.Et&&n.preventDefault(),t.$t&&n.stopPropagation();try{e.Uo(s,n,l)}catch(e){console.error(e)}})}(e,t,r,l,n))}let o=t.o,s=ee(l,o.n);if(14===t.i)return void Ie(e,t,r,i,n=>function(e,t,n,l,i,r){null===r&&qe(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs.keys()]);for(let s of o){if(t.ao?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),a=0===o.n?null:l;Le(e,{...t,H:null,z:null},n,s,o,a,i,r)}}(e,t,r,s,i,n));if(t.ke&&1===t.i)return void Ie(e,t,r,i,n=>function(e,t,n,l,i,r){if(null!==r)return void Le(e,t,n,t.name,t.o,l,i,r);let o=new He(e,1,n,t.name,t.o,l,i,t.N,Be(e,t,l));o.I=t.I,!c.Jo?.(o,t.ro)&&(Ze(e,o,!0),e._e(o))}(e,t,r,s,i,n));let a=new He(e,t.i,n,t.name,o,s,i,t.N,Be(e,t,s));a.I=t.I,Ze(e,a,!0),e._e(a),null!==t.Nt&&n.addEventListener(t.Nt,()=>a.Xo())}function rt(e,t,n,l){let i=new ot(e,t,n),r=null;for(let o of t){if(null===o.o)continue;let t=o.o,s=new He(e,7,o.S,"if",t,ee(n,t.n),l,null,void 0,i);Ze(e,s,!0),null===l&&i.ie.push(s),r??=s}return e._e(r),i}var ot=class{constructor(e,t,n){this.y=!0,this.O=null,this.b=-1,this.ie=[],this.engine=e,this.X=t,this.r=n}Pn(e){return null!==this.O&&this.X[this.b].S===e?this.O.qe():null}bt(){let e=this.engine,t=-1;for(let n=0;n<this.X.length;n++){let l=this.X[n];if(null===l.o||Ae(l.N,e.read(l.o,ee(this.r,l.o.n)))){t=n;break}}if(t!==this.b&&(nt=Ee(),null!==this.O&&(this.O.uo(),this.O.Se(e),this.O=null),this.b=t,t>=0)){let n=this.X[t],l=lt(e,n.A,this.r,null,n.S);this.O=tt();let i=n.S.parentNode;i.insertBefore(l,n.S),Xe(i)}}Se(){this.y=!1;for(let e of this.ie)this.engine.kn(e);null!==this.O&&this.O.Se(this.engine)}},st=class{constructor(e,t,n,l){this.y=!0,this.Ee=[],this.engine=e,this.A=t,this.l=n,this.S=l,null===n.$?(n.$=this,this.map=null):((n.L??=[]).push(this),this.map=new Map)}Pn(e){return 0===this.Ee.length?null:this.Ee[0].qe()}xt(e){return null===this.map?e.$:this.map.get(e)??null}ho(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.Se(this.engine)}bt(){let e=this.engine,t=this.l.u,n=this.Ee;nt=Ee();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){ut(n[0].qe(),n[i-1].s);for(let e=0;e<i;e++)this.ho(n[e])}return void(this.Ee=[])}let s=new Array(l),a=0;for(;a<l&&a<i&&this.xt(t[a])===n[a];)s[a]=n[a],a++;let u=i-1,c=l-1;for(;u>=a&&c>=a&&this.xt(t[c])===n[u];)s[c]=n[u],u--,c--;for(let e=a;e<=u;e++){let t=n[e],l=t.r;l.y&&this.xt(l)===t?t.fo=e:(t.uo(),this.ho(t))}if(a<=c){let n=c-a+1,u=new Int32Array(n),f=!1;if(i>0)for(let e=0;e<n;e++){let n=this.xt(t[a+e]);null!==n&&n.y?(u[e]=n.fo,f=!0):u[e]=-1}let h=c+1<l?s[c+1].qe():r;if(f){let l=function(e){let t=e.length,n=new Uint8Array(t),l=new Int32Array(t).fill(-1),i=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let r=0,o=i.length;for(;r<o;){let n=r+o>>1;e[i[n]]<t?r=n+1:o=n}r>0&&(l[n]=i[r-1]),i[r]=n}let r=i.length>0?i[i.length-1]:-1;for(;r>=0;)n[r]=1,r=l[r];return n}(u),i=h;for(let r=n-1;r>=0;r--){let n=t[a+r],u=this.xt(n);null!==u&&u.y?0===l[r]&&u.insertBefore(o,i):(o.insertBefore(lt(e,this.A,n,this),i),u=tt()),s[a+r]=u,i=u.qe()}}else{let n=document.createDocumentFragment();for(let l=a;l<=c;l++)n.appendChild(lt(e,this.A,t[l],this)),s[l]=tt();o.insertBefore(n,h)}}this.Ee=s,Xe(o)}Se(){this.y=!1;let e=this.l;if(e.$===this)e.$=null;else if(null!==e.L){let t=e.L.indexOf(this);t>=0&&e.L.splice(t,1),0===e.L.length&&(e.L=null)}for(let e of this.Ee)e.Se(this.engine);this.map?.clear()}};function at(e,t,n){for(;n<t.length;n++){e=e.firstChild;for(let l=t[n];l>0;l--)e=e.nextSibling}return e}function ut(e,t){let n=document.createRange();n.setStartBefore(e),n.setEndAfter(t),n.deleteContents()}var ct=()=>le.bindAttributeName;function ft(){return{a:0,i:1,name:"",o:null,N:null,V:t,Nn:null,A:null,X:null,I:null,Nt:null,ke:!1,H:null,z:null,ro:!1,Et:!1,$t:!1,St:null,ao:null,F:-1,Ze:!1,co:!1}}var ht=["state","element","auto","none"],dt=["call","connect"],pt="$command.";function mt(e,t,n){T.test(t)&&(null===n&&S(1401,[t,Number(t.slice(1))]),t=`${n.t}.*.${t}`);let l=e.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&S(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&S(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.f[e];l.f[e]!==t&&S(1403,[l.t,l.f[e].t,t.t])}return c.go?.(e,l),l}var gt=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),yt=e=>8===e.i||gt(e)||1===e.i&&Ke(e.name);function $t(e){S(202,[e])}function vt(e,t,n,l,i){let r=ae(t).map(t=>function(e,t,n,l,i){let r=function(e,t){let n=t.find(e=>e.startsWith("on")),l=null,i=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e.Dt||S(31);let r=n.slice(0,t).trim(),o=n.slice(t+1).trim(),s="init"===r;!s&&"sync"!==r&&S(33,[r,n]),null!==(s?l:i)&&S(34,[r]),(s?ht:dt).includes(o)||S(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),Et:t.includes("prevent"),$t:t.includes("stop"),event:n?n.slice(2):null,H:l,z:i}}(e,t.tn),o=l.localName.includes("-"),s=t.ve,a=t.Je;if("event"===t.w){if(null!==r.H&&"none"!==r.H&&S(36),"eventToken"===s[0])return{...ft(),a:i,i:13,name:s.slice(1).join("."),St:a,ke:o,Et:r.Et,$t:r.$t};let n=a.startsWith(pt)?a.slice(9):null,{Et:l,$t:u}=r,c=t.be.slice(2),f=t.tn.includes("direct"),h=!f&&De.has(c);return h&&e.eo(c),{...ft(),a:i,i:5,name:c,Ze:h,ke:o,co:f,Nn(t,i){l&&t.preventDefault(),u&&t.stopPropagation();try{if(null!==n)e.qo(n,t,i);else{let n=e.Ko(a,t,i);G(n)&&n.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...ft(),a:i,i:14,o:mt(e,a,n),ke:o};if("command"===s[0]&&s.length>1)return a.startsWith(pt)||S(1201,[t.be,a]),{...ft(),a:i,i:12,name:s.slice(1).join("."),St:a,ke:o};let u=mt(e,a,n),c={...ft(),a:i,i:1,name:t.be,o:u,N:Ne(t.Qe),I:Ne(t.I),ro:r.ro,H:r.H,z:r.z};if("radio"===t.w||"checkbox"===t.w)return("element"===r.H||"auto"===r.H)&&S(37,[t.w,r.H]),c.i="radio"===t.w?9:10,r.ro||(c.Nt=r.event??"input"),c;if(s.length>1){let e=s.slice(1).join("."),t=s[0];if("class"===t||"attr"===t||"style"===t)return c.H=null,c.name=e,"class"===t?(c.i=2,c.V=l.classList.contains(e)):c.i="attr"===t?"srcdoc"===e&&"iframe"===l.localName?1:3:4,c}return"html"===t.be?(c.i=8,c):(c.name="text"===t.be?"textContent":t.be,c.ke=o&&!Me(c.name),!o&&!r.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(l,c.name)&&(c.Nt=r.event??("select"===l.localName?"change":"input")),c)}(e,t,n,l,i));for(let e=0;e<r.length;e++)14===r[e].i&&(r[e].ao=r.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return r}var bt=/\{\{([\s\S]+?)\}\}/g;function wt(e){let t=e.data,n=[],l=0;bt.lastIndex=0;for(let i=bt.exec(t);null!==i;i=bt.exec(t)){let r=bt.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,Qo:i[1].trim()}),l=bt.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function kt(e,t,n,l){let i=function(e){return{be:"textContent",ve:["textContent"],tn:[],I:[],...U(e),w:"text"}}(t);return{...ft(),a:l,i:0,o:mt(e,i.Je,n),N:Ne(i.Qe),V:""}}function St(e){let t=e.getAttribute(ct());if(null===t)return null;let n=ae(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var xt=(e,t)=>0===e?le.commentIfPrefix:null===t.o?le.commentElsePrefix:le.commentElseIfPrefix;function At(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:mt(e,l.Je,n),N:"else"===l.w?null:Ne(l.Qe)}),i=[l(t,St(t))];for(let e=t.nextSibling;null!==e;e=e.nextSibling){if(3===e.nodeType&&""===e.data.trim()||8===e.nodeType)continue;if(1!==e.nodeType||"template"!==e.localName)break;let t=St(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var Nt=new WeakSet;function jt(e,t,n,l,i,r,o,s){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&c.An?.(e,i,t),i},u=t=>{for(let f=0;f<t.length;f++){let h=t[f];if(null!==h.parentNode)if(1===h.nodeType){let t=h,s=t.localName;if(l){if("script"===s||"style"===s||Nt.has(t))continue;if(Nt.add(t),s===le.tagNames.state){u([...t.childNodes]);continue}}let f="template"===s?St(t):null;if(null!==f){if("for"===f.w){let l=mt(e,f.Je,n),r=Ct(e,t,l,!0);i(a(t,le.commentForPrefix),l,r)}else"if"===f.w?r(At(e,t,n).map((t,l)=>({A:Ct(e,t.el,n,!1),o:t.o,N:t.N,S:a(t.el,xt(l,t))}))):$t(f.w);continue}let d=t.getAttribute(ct()),p=null===d?null:vt(e,d,n,t,0),m="noscript"!==s&&"iframe"!==s&&!p?.some(yt)&&!c.yo?.(t);try{l&&m&&u([...t.childNodes])}finally{null!==p&&o(t,p)}!l&&m&&u([...t.childNodes])}else if(3===h.nodeType&&e.Lt&&h.data.includes("{{")&&!Nt.has(h))for(let{a:e,Qo:t}of wt(h))s(e,t);else if(8===h.nodeType){let e=Ot.exec(h.data),t=e&&h.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");h.replaceWith(t),s(t,e[1])}}}};u(t)}var Ot=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Mt=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Ct(e,t,n,l){let i=document.importNode(Mt(t),!0),r=[],o=[],s=e=>r.push(e)-1;jt(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...ft(),a:s(e),i:6,o:t,A:n})},e=>{let t=e.map(e=>({a:s(e.S),A:e.A,o:e.o,N:e.N}));o.push({...ft(),a:t[0].a,i:7,X:t})},(e,t)=>{let n=s(e);for(let e of t)gt(e)&&S(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(ct())},(t,l)=>{o.push(kt(e,l,n,s(t)))}),Wt(i,new Set(r),!0);let a=r.map(e=>function(e,t){let n=[];for(let l=t;l!==e;l=l.parentNode){let e=0;for(let t=l.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(i,e)),u=1===i.childNodes.length&&8!==i.firstChild.nodeType,c=o.some(e=>6===e.i||7===e.i),f=[],h=new Set,d=[],p=[],m=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.Ze&&!e.ke&&!Tt(r[e.a],i)){d.push(e);continue}p.push(e);let t=e.o;if(null!==t&&t.n===m&&t.f[m]===n&&Pt(e)&&(e.F=f.push(e)-1),7===e.i)for(let t of e.X)h.add(t.a);else h.add(e.a)}let g=[...h].sort((e,t)=>e-t);return{on:i,root:u?i.firstChild:null,Rn:a,build:g,Ne:d,Yo:p,Tn:u,Go:c,mo:[],Ke:f}}function Tt(e,t){for(;e.parentNode!==t;e=e.parentNode){if(e.parentNode.localName.includes("-"))return!0;for(let t=e.previousSibling;t;t=t.previousSibling)if(8===t.nodeType)return!0}return!1}function Pt(e){if(null!==e.H)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.ke&&null===e.Nt;default:return!1}}var Et=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Wt(e,t,n){for(let l=e.firstChild;null!==l;){let e=l.nextSibling;3===l.nodeType?n&&!t.has(l)&&""===l.data.trim()&&l.remove():1===l.nodeType&&Wt(l,t,Et.has(l.localName)),l=e}}var Rt=new WeakMap;function It(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Rt.set(t,e),qt(e,[...n.childNodes]),e.He()}function Lt(e,t,n){try{let l="template"===t.localName?St(t):null;null!==l&&!n&&S(204,[l.w]),qt(e,[t])}catch(e){console.error(e)}e.He()}function qt(e,t){jt(e,t,null,!0,(t,n,l)=>{new st(e,l,Qe(e,n,null,t),t).bt()},t=>{rt(e,t,null,null)},(t,n)=>{c.An?.(e,t,n);for(let l of n)it(e,l,t,null,null)},(t,n)=>{c.An?.(e,t,n),it(e,kt(e,n,null,0),t,null,null)})}var Dt=Symbol.for("wcstack.binder"),zt=Symbol.for("wcstack.binder.pending"),Ut=Symbol.for("wcstack.binder.taken");var _t=new Map;function Ft(e,t){if(1!==e.nodeType||!e.isConnected)return;let n=Rt.get(e.getRootNode());void 0===n||!1===n.element?.isConnected?_t.set(e,t):Lt(n,e,t?.range)}function Bt(){let e=[..._t];_t.clear();for(let[t,n]of e)Ft(t,n);!function(){let e=function(){let e=globalThis[Dt];return null==e||"wcs-binder"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.bind?null:e}();if(null===e)return;let t=function(){let e=globalThis,t=e[zt];return void 0===t&&(t=[],e[zt]=t),t}();if(0===t.length)return;let n=t.splice(0,t.length),l=function(){let e=globalThis,t=e[Ut];return void 0===t&&(t=new WeakSet,e[Ut]=t),t}();for(let t of n)l.add(t),e.bind(t)}()}var Ht=class{constructor(){this.name="dirty",this.ot=(e,l)=>{if(0===e.n){let l=e.J;return l!==t&&l!==n&&(e.J=n,!0)}let i=null===l?null:l.ut;if(null===i)return!1;let r=i[e.F];return r!==t&&r!==n&&(i[e.F]=n,!0)}}Ho(e,t,n){null!==t.getter&&this.ot(t,n),e.wt(t,n),e.vn(t,n,this.ot)}Lo(e,t){let n=t.l.o.Tt;if(null!==n)for(let l of n)l.n===t.l.n?e.tt(l,t,this.ot):e.Jt(t,l,t=>e.tt(l,t,this.ot))}me(e,t,n){this.ot(t,n),c.ye?.(e,t,n),e.wt(t,n),e.vn(t,n,this.ot)}Bo(e,i,r){let o=0===i.n;if(!o&&null===r)return;let s=o?null:r.ut??=new Array(e.Oe).fill(t),a=null===s?i.J:s[i.F];if(a!==t&&a!==n&&a!==l&&(null===s||i.F in s))return a;a=l;try{return a=e.Do(i,null===s?null:r)}finally{null===s?i.J=a:s[i.F]=a}}qt(e){e.ut=null}pt(e){for(let t of e.B.all())null!==t.getter&&(0===t.n?t.J===n&&(t.J=l):e.Zt(t.f[t.n],e=>{let i=e.ut;null!==i&&i[t.F]===n&&(i[t.F]=l)}))}},Kt=0,Vt=new WeakMap;function Jt(e,t=e.getRootNode()){Vt.set(t,[...Vt.get(t)??[],e].filter((e,t,n)=>e.isConnected&&n.lastIndexOf(e)===t))}function Xt(e){let t=Vt.get(e)??[],n=t.filter(t=>t.getRootNode()===e);return Promise.any(n.map(e=>e.initializePromise.then(()=>e.W||e.connectedCallbackPromise))).then(()=>{},l=>n.length?Vt.get(e)!==t?Xt(e):Promise.reject(l.errors[0]):void 0)}var Gt=typeof HTMLElement>"u"?class{}:HTMLElement,Yt=class extends Gt{constructor(){super(),this.engine=null,this.Fn=!1,this.Ve=!1,this.V=null,this.ze=null,this.loaded=!1,this.ln=null,this.connectedCallbackPromise=new Promise((e,t)=>{this.sn=e,this.wo=t}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(e=>{this.rn=e})}static{this.getBindingsReady=Xt}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Fn){if(null!==this.ze)return void this.ze.Xe();Jt(this);let e=this.engine;if(null!==e){let t=e.root;t===this.getRootNode()&&!Rt.has(t)&&Rt.set(t,e),Bt(),c.element?.(e,"back"),this.bo("$connectedCallback",50,()=>{this.isConnected&&c.element?.(e,"connected")})}return}this.Fn=!0;let e=this.getRootNode(),t=c.rt?.(this,e);if(t)return this.ze=t,!t.vo&&this.parentNode instanceof ShadowRoot&&Jt(this),void(void 0===t.jt?this.ko():t.jt()).then(e=>(this.loaded=!0,t.start(e,()=>this.So()))).then(()=>{this.rn(),this.sn()},e=>this.vt(e,t.vo));this.start(e),Jt(this)}disconnectedCallback(){if(null!==this.ze)return void this.ze.On();let e=this.engine;if(null===e)return;let t=e.root;Rt.get(t)===e&&Rt.delete(t),Jt(this,t),this.bo("$disconnectedCallback",51),c.element?.(e,"disconnected")}setInitialState(e){if(this.Ve&&S(14),this.loaded)this.ze.reset(e);else if(null===this.engine)if(null!==this.ln){let t=this.ln;this.ln=null,t(e)}else this.V=e;else this.engine.reset(e)}createState(e,t){let n=this.engine;null===n&&S(15),"readonly"===e&&n.Ce++;try{t(n.proxy)}finally{"readonly"===e&&n.Ce--}}async createStateAsync(e,t){let n=this.engine;null===n&&S(15),await t("writable"===e?n.proxy:new Proxy(n.proxy,{get(e,t,n){let l=Reflect.get(e,t,n);return"$setAll"===t||"$resolve"===t?(...e)=>(e.length>2&&S(8),l(...e)):l},set(){S(8)}}))}async ko(){await 0;let e=this.getAttribute("state");if(null!==e){let t=t=>[...t.querySelectorAll('script[type="application/json"]')].find(t=>t.id===e),n=t(this.getRootNode())??t(document);return void 0===n?Promise.reject(new Error(`[@wcstack/state] ${k(16,[e])}`)):Promise.resolve(JSON.parse(n.textContent||"{}"))}let t=this.getAttribute("src");if(null!==t)return async function(e){let t=new URL(e,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(t)){let n=await fetch(t);return n.ok||S(13,[e,n.status]),await n.json()}return(await(import(t))).default??{}}(t);let n=this.getAttribute("json");if(null!==n)return Promise.resolve(JSON.parse(n));let l=this.querySelector('script[type="module"]');return null!==l?async function(e){let t=!1,n=e=>{e.effectiveDirective.startsWith("script-src")&&(t=!0)};document.addEventListener("securitypolicyviolation",n);let l="function"==typeof URL.createObjectURL,i=l?URL.createObjectURL(new Blob([e.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${e.text}\n//${++Kt}`);try{return(await(import(i))).default??{}}catch(e){throw await new Promise(e=>setTimeout(e)),new Error(`[@wcstack/state] ${t?k(42):k(43,[e instanceof Error?e.message:String(e)])}`,{cause:e})}finally{document.removeEventListener("securitypolicyviolation",n),l&&URL.revokeObjectURL(i)}}(l):null!==this.V?Promise.resolve(this.V):new Promise(e=>{this.ln=e})}async start(e){try{let t=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||t?.hasAttribute("data-wc-definition"))&&$("scopes","<wcs-state>");let n=await this.ko(),l=y(n);if(l&&await l,this.getRootNode()!==e)return this.V=n,this.Fn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&$("ssr","enable-ssr");let i=Rt.get(e)?.element;i?.isConnected&&(i.W||i.ze)&&S(47);let r=new ne(n,new Ht);r.element=this,this.engine=r,c.element?.(r,"mounting"),It(r,e),Bt(),r.bn(),this.So(),await r.we("$connectedCallback"),this.isConnected&&c.element?.(r,"connected"),this.sn()}catch(e){this.Ve=!this.W,this.vt(e)}}So(){this.W=!0,this.rn()}vt(e,t){this.He(this.W?50:49,e),this.rn(),t?this.sn():this.wo(e)}He(e,t){let n=["mount","bind-component","state","src"].flatMap(e=>this.hasAttribute(e)?[e,this.getAttribute(e)]:[]);console.error(`[@wcstack/state] ${k(e,[this.localName,...n])}`,t)}bo(e,t,n){(async()=>this.engine.we(e))().then(n,e=>this.He(t,e))}},Qt=[];function Zt(){return(Qt=Qt.filter(e=>e.deref())).map(e=>e.deref())}var en,tn=e=>t=>{let n=e(t);return e=>null==e?e:n(e)},nn="en";function ln(){if(le.locale!==en){en=le.locale;try{nn=Intl.getCanonicalLocales(en)[0]}catch{console.warn(`[@wcstack/state] ${k(48,[en])}`),nn="en"}}return nn}var rn={toFixed:{factory:e=>{let t=ve(e?.[0]??"0","toFixed");return e=>("number"!=typeof e&&ge("toFixed"),e.toFixed(t))},arity:[0,1]},locale:{factory:e=>{let t=e?.[0];return e=>("number"!=typeof e&&ge("locale"),e.toLocaleString(t??ln()))},arity:[0,1]},upper:{factory:tn(()=>e=>String(e).toUpperCase()),arity:[0,0]},lower:{factory:tn(()=>e=>String(e).toLowerCase()),arity:[0,0]},capitalize:{factory:tn(()=>e=>{let t=String(e);return 0===t.length?t:1===t.length?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}),arity:[0,0]},trim:{factory:tn(()=>e=>String(e).trim()),arity:[0,0]},slice:{factory:tn(e=>{let t=[be(e,0,"slice")],n=e?.[1];return typeof n<"u"&&t.push(ve(n,"slice")),e=>String(e).slice(...t)}),arity:[1,2]},padStart:{factory:tn(e=>{let t=be(e,0,"padStart"),n=e?.[1]??"0";return e=>String(e).padStart(t,n)}),arity:[1,2]},padEnd:{factory:tn(e=>{let t=be(e,0,"padEnd"),n=e?.[1]??" ";return e=>String(e).padEnd(t,n)}),arity:[1,2]},repeat:{factory:tn(e=>{let t=be(e,0,"repeat");return e=>String(e).repeat(t)}),arity:[1,1]},reverse:{factory:tn(()=>e=>String(e).split("").reverse().join("")),arity:[0,0]},truncate:{factory:tn(e=>{let t=be(e,0,"truncate"),n=e?.[1]??"…";return e=>{let l=String(e);return l.length<=t?l:l.slice(0,t)+n}}),arity:[1,2]},join:{factory:e=>{let t=e?.[0]??", ";return e=>(Array.isArray(e)||S(30,["join"]),e.join(t))},arity:[0,1]},round:{factory:e=>{let t=Math.pow(10,ve(e?.[0]??"0","round"));return e=>("number"!=typeof e&&ge("round"),Math.round(e*t)/t)},arity:[0,1]},floor:{factory:e=>{let t=Math.pow(10,ve(e?.[0]??"0","floor"));return e=>("number"!=typeof e&&ge("floor"),Math.floor(e*t)/t)},arity:[0,1]},ceil:{factory:e=>{let t=Math.pow(10,ve(e?.[0]??"0","ceil"));return e=>("number"!=typeof e&&ge("ceil"),Math.ceil(e*t)/t)},arity:[0,1]},percent:{factory:e=>{let t=ve(e?.[0]??"0","percent");return e=>("number"!=typeof e&&ge("percent"),`${(100*e).toFixed(t)}%`)},arity:[0,1]},unit:{factory:tn(e=>{let t=e?.[0]??pe("unit");return e=>String(e)+t}),arity:[1,1]},date:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ye("date"),e.toLocaleDateString(t??ln()))},arity:[0,1]},time:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ye("time"),e.toLocaleTimeString(t??ln()))},arity:[0,1]},datetime:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||ye("datetime"),e.toLocaleString(t??ln()))},arity:[0,1]},ymd:{factory:e=>{let t=e?.[0]??"-";return e=>{e instanceof Date||ye("ymd");let n=e.getFullYear().toString(),l=(e.getMonth()+1).toString().padStart(2,"0"),i=e.getDate().toString().padStart(2,"0");return`${n}${t}${l}${t}${i}`}},arity:[0,1]},hms:{factory:e=>{let t=e?.[0]??":";return e=>{e instanceof Date||ye("hms");let n=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0"),i=e.getSeconds().toString().padStart(2,"0");return`${n}${t}${l}${t}${i}`}},arity:[0,1]}},on=!1,sn={name:"formats",install:function(){on||(on=!0,he(rn))}};function an(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let l=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)l[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let r=1;r<=t.length;r++){let o=e[n-1]===t[r-1]?0:1;i[r]=Math.min(l[r]+1,i[r-1]+1,l[r-1]+o)}for(let e=0;e<=t.length;e++)l[e]=i[e]}return l[t.length]}function un(e,t){if(0===e.length)return"";let n=e.toLowerCase(),l=null,i=3;for(let e of t){let t=an(n,e.toLowerCase(),2);t<i&&(l=e,i=t)}return null!==l?` Did you mean "${l}"?`:""}var cn=" Validate statically: npx @wcstack/lint <file>.",fn=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],hn=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,dn="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",pn={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>"updates did not settle after 32 passes",41:()=>"render chain depth limit exceeded (100 drains that rendering itself started); bindings for this batch were not applied.",12:(e,t)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${dn}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${dn}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&fn.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${hn(e,t)} failed to initialize.`,50:(e,...t)=>`${hn(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${hn(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,119:e=>`"${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,l)=>`${e}("${t}") takes ${n} index(es), got ${l}.`,902:(e,t,n,l)=>`${e}("${t}") takes at most ${n} index(es), got ${l}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function mn(e,t){let n=pn[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var gn=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),yn=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],$n={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function vn(e,t,n){let l=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn($n,e)?$n[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?un(t,n):"");for(let[t,n]of yn){let i=t.exec(e);null!==i&&(l+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(l+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?l+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':ue.some(de)||(l+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let r=/\[wcs\/([\w-]+)\]/.exec(e);return null!==r&&gn.has(r[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(l+=cn),l}var bn=new WeakMap,wn=new WeakMap,kn=new WeakSet,Sn=new WeakSet;function xn(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function An(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function Nn(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let l=e.target,i=t=>null===t?null:function(e,t){let n=t.t.split("."),l=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return l<0||n.indexOf("*",l)>=0||void 0!==xn(e.target,t.t)?.get?t:e.B.Ot(o(t.t).o)}(e,t);for(let t of n){if(null!=i(t)?.getter||null===l||"object"!=typeof l)return null;if("*"===t.s){if(!Array.isArray(l)||0===l.length)return null;l=l[0];continue}if(Array.isArray(l)&&/^\d+$/.test(t.s)){if(Number(t.s)>=l.length)return null;l=l[Number(t.s)];continue}let n=xn(l,t.s);if(void 0===n&&null===t.d&&e.pt.has(t.s))return null;if(void 0===n){let n=An(l),r=i(t.d);for(let t of e.B.all())t.d===r&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;l=n.value}return null}function jn(e){kn.has(e)||(kn.add(e),setTimeout(()=>function(e){kn.delete(e);let t=bn.get(e);if(void 0===t)return;let n=wn.get(e);void 0===n&&wn.set(e,n=new Set);for(let[l,i]of t){if(n.has(l))continue;n.add(l);let t=Nn(e,l);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${le.tagNames.state}[mount]`)??[]].find(e=>!Sn.has(e)&&(l.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(l),r.initializePromise.then(()=>{Sn.add(r),jn(e)});continue}let[s,a]=i?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];c.nt?.(e,{type:"state:path-unresolved",source:i?"watch":"binding",path:l.t,missingSegment:t.seg});let u=e.B.Ot(o(l.t).o),f="";if(void 0!==u&&u!==l&&null!==u.getter){let e=u.f.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(u.f[t].t.length+2)}`);f=` The getter "${u.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${s}] ${a} "${l.t}" does not resolve on the state tree: "${t.seg}" is not declared.${un(t.seg,t.names)}${f} Updates to this path will be silently dropped.${cn}`)}}(e),0))}function On(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let l=bn.get(e);void 0===l&&bn.set(e,l=new Map),l.has(t)||l.set(t,n),jn(e)}var Mn=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Cn=!1;function Tn(e,t,n){let l="html"===n.name?"innerHTML":n.name;if(Cn||!(t instanceof TypeError)||!Me(l)||!("trustedTypes"in globalThis))return;Cn=!0;let i="function"==typeof Oe()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${l}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${i}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:n.a,property:l})}var Pn=new WeakMap;function En(e,t,n){let l=e[t],i=void 0===n?void 0===l?null:`the event carried no detail (undefined) while element.${t} is ${typeof l}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==l&&"object"==typeof l?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof l}`;if(null===i)return;let r=Pn.get(e);void 0===r&&Pn.set(e,r=new Set),!r.has(t)&&(r.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var Wn={name:"diagnostics",install(){c.Ao=vn,c.Fo=mn,c.go=On,c.detail=En,c.Ve=f(c.Ve,Tn),c.se=f(c.se,(e,t)=>{(function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[l,i]=n[0];if(!l.endsWith(".*")||!i.endsWith(".*"))return;let r=l.slice(0,-2),o=i.slice(0,-2),s=`.${i}`,a=`${r}.**`,u=An(e),c=u.filter(e=>e.startsWith(a)).map(e=>e.slice(a.length)),f=e=>v(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${o}`||e.startsWith(`.${o}.`))&&f(`"${a}${e}" names the recursion structure itself (the "${o}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${Mn(s)})+$`).test(t.slice(0,t.length-e.length))&&f(`"${a}${e}" and "${a}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${i}"). Rename one of them.`);let t=new RegExp(`^${Mn(l)}(?:${Mn(s)})*${Mn(e)}$`);for(let n of u)!n.includes("**")&&t.test(n)&&f(`"${n}" is already defined on the state, so the recursive getter "${a}${e}" cannot expand to it.`)}})(t),function(e){wn.delete(e),bn.has(e)&&jn(e)}(e)})}},Rn={},In=/\.\d/,Ln=new Set(Object.getOwnPropertyNames(Object.prototype)),qn=0,Dn=!1,zn=null,Un=()=>{Dn=!1,qn++};function _n(){if(null===zn)if("function"==typeof MessageChannel){let e=new MessageChannel;e.port1.onmessage=Un,e.port1.unref?.(),zn=()=>e.port2.postMessage(0)}else zn=()=>setTimeout(Un,0);return Dn||(Dn=!0,zn()),qn}function Fn(e,t){let n=new Set,l=[e];for(;l.length>0;){let e=l.pop();if(!n.has(e)){n.add(e);for(let n of e.$e){for(let l of t)if(n.Q(l)&&(n.n===l.n||!(l.n<e.n&&e.f[l.n+1].Q(l))))return!0;null!==n.getter&&l.push(n)}}}return!1}var Bn=class{constructor(e,t){this.active=!1,this.Ye=new Map,this.n=0,this.$o=-1,this.Cn=new Set,this.We=null,this.engine=e,this.it=t}Zo(){let e=this.engine;this.Ye.clear();for(let t of this.it)t.getter=null!==t.p.getter||t.p.de,t.s=new WeakMap,this.prime(t,()=>{0===t.p.n?t.getter&&t.s.set(Rn,e.v(t.p,null)):this.In(t.p,1,null,n=>{t.getter&&this.prime(t,()=>t.s.set(n,e.v(t.p,n)))})});this.active=!0}prime(e,t){try{t()}catch(t){console.error(`[@wcstack/state] $watch initial evaluation of "${e.t}" threw.`,t),c.nt?.(this.engine,{type:"state:watch-error",phase:"prime",path:e.t,error:t})}}No(){this.active=!1,this.Ye.clear()}In(e,t,n,l){let i=this.engine.De(n,e.f[t]);for(let n of i.u)t===e.n?l(n):this.In(e,t+1,n,l)}an(e,t,n,l){let i=this.Ye.get(e);void 0===i&&this.Ye.set(e,i=new Map);let r=i.get(t);void 0===r?i.set(t,[n,this.n,l]):(r[1]<this.n&&(r[1]=this.n),r[2]||=l)}he(e,t,n,l,i){if(this.active){(this.We??=new Set).add(e);for(let r of this.it){let o=r.p;o.n!==e.n||!o.Q(e)||this.an(r,t,r.getter?r.s.get(t??Rn):o===e&&i&&this.engine.Bt&&(null===l||"object"!=typeof l&&"function"!=typeof l)?n:void 0,!0)}}}ye(e,t){if(this.active)for(let n of this.it)(n.getter||=null!==n.p.getter||n.p.de)&&n.p.n===e.n&&n.p.Q(e)&&this.an(n,t,n.s.get(t??Rn),!1)}Yt(e,t){if(!this.active)return;let n=null;for(let l of this.it){let i=l.p;if(!(i.n<e.n||i.f[e.n]!==e.o)){n??=new Set(t);for(let t of e.u)n.has(t)||(i.n===e.n?this.an(l,t,void 0,!0):this.In(i,e.n+1,t,e=>this.an(l,e,void 0,!0)))}}}Te(){let e=this.We;if(this.We=null,!this.active||0===this.Ye.size)return;let t=this.Ye;this.Ye=new Map;let n=this.engine,l=[];for(let i of this.it){let r=t.get(i);if(void 0===r)continue;let o,s=[...r].filter(([e])=>null===e||e.y);s.length>1&&s.sort((e,t)=>Kn(e[0],t[0]));for(let[t,[r,a,u]]of s){let s,f="evaluate",h=n.c;this.n=a+1,n.xe++;try{if(s=n.v(i.p,t),i.getter&&(i.s.set(t??Rn,s),Object.is(s,r)&&(In.test(i.t)||null!==t&&!u&&!(o??=null!==e&&Fn(Hn(i.p),e)))))continue;if(a>32){l.includes(i.t)||l.push(i.t);continue}n.c=t,c.nt?.(n,{type:"state:watch-fired",path:i.t}),f="handler",i.handler.call(n.proxy,s,r,...n._(t))}catch(e){console.error(`[@wcstack/state] $watch "${i.t}" failed; the other watches still run.`,e),c.nt?.(n,{type:"state:watch-error",phase:f,path:i.t,error:e})}finally{n.c=h,this.n=0,n.xe--}}}l.length>0&&this.xo(l)}xo(e){let t=_n();t!==this.$o&&(this.$o=t,this.Cn.clear());let n=e.filter(e=>!this.Cn.has(e));if(0!==n.length){for(let e of n)this.Cn.add(e);console.error("[@wcstack/state] $watch handlers / $stream restarts kept writing for 32 batches; the chain is cut (nothing is rolled back)."),c.nt?.(this.engine,{type:"state:watch-chain-limit",maxDepth:32,paths:n})}}};function Hn(e){for(;null===e.getter&&null!==e.d;)e=e.d;return e}function Kn(e,t){let n=[],l=[];for(let t=e;null!==t;t=t.l.re)n.unshift(t.b);for(let e=t;null!==e;e=e.l.re)l.unshift(e.b);for(let e=0;e<n.length&&e<l.length;e++)if(n[e]!==l[e])return n[e]-l[e];return n.length-l.length}var Vn="$streamStatus",Jn="$streamError",Xn=new Set(Object.getOwnPropertyNames(Object.prototype)),Gn=!1;function Yn(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return void 0!==e.get||void 0!==e.set||"function"==typeof e.value}return!1}var Qn=class{constructor(e,t,n){this.engine=e,this.entries=t,this.D=n}set(e,t,n){Gn=!0;try{this.engine.P(this.engine.o(`${e}.${t}`),null,n)}finally{Gn=!1}}er(){for(let e of this.entries)this.start(e,!0)}tr(){for(let e of this.entries)e.st=!1,e.Y?.abort(),e.Y=null}nr(){for(let e of this.entries)e.st=!1,null!==e.Y&&(e.Y.abort(),e.Y=null),this.set(Vn,e.name,"idle")}ye(e){let t=this.D.n;for(let n of this.entries)n.g===e&&(n.n=n.st?Math.max(n.n,t):t,n.st=!0)}Te(){let e=this.engine,t=this.D,n=[];for(let i of this.entries){if(!i.st)continue;let r=i.n;if(i.st=!1,r>32)n.push(i.name),i.g.J=l;else{t.n=r+1,e.xe++;try{this.start(i,!1)}finally{e.xe--,t.n=0}}}n.length>0&&t.xo(n)}start(e,t){let n,i=this.engine;if(null!==e.Y&&e.Y.abort(),e.Y=null,null!==e.g){let r=e.g;r.getter=e.args;let o=r.$e.slice();Zn(r);try{n=i.read(r,null),function(e,t,n){null!==n&&"function"==typeof n?.then&&v(`$stream "${e}": args must be synchronous (it returned a Promise).`);for(let n of t.$e)n.n>0&&v(`$stream "${e}": args must not read a wildcard path ("${n.t}").`),(n.t===e||n.t===`${Vn}.${e}`||n.t===`${Jn}.${e}`)&&v(`$stream "${e}": args must not read the stream itself ("${n.t}").`)}(e.name,r,n)}catch(n){Zn(r);for(let e of o)e.jn(r);if(r.J=l,t)throw n;return this.set(Jn,e.name,n),void this.set(Vn,e.name,"error")}}let r=new AbortController;e.Y=r,i.P(i.o(e.name),null,e.V),this.set(Jn,e.name,null),this.set(Vn,e.name,"active"),this.or(e,r,n)}async or(e,t,n){let l=this.engine,i=t.signal,r=()=>!i.aborted&&e.Y===t,o=l.o(e.name),s=this.D.n,a=_n(),u=e=>{_n()===a&&(this.D.n=s);try{e()}finally{this.D.n=0}},c=e.V;try{let t=await e.source(n,i);if(!r())return;let s=t=>{c=void 0!==e.Ro?e.Ro(c,t):t,u(()=>l.P(o,null,c))};if(null!==t&&"function"==typeof t?.getReader){let e=t.getReader();for(i.addEventListener("abort",()=>{e.cancel().catch(()=>{})});;){let t=await e.read();if(!r())return;if(t.done)break;s(t.value)}}else{if(null===t||"function"!=typeof t?.[Symbol.asyncIterator])throw new TypeError(`$stream "${e.name}": source must return an async iterable or a ReadableStream`);{let e=t[Symbol.asyncIterator]();for(i.addEventListener("abort",()=>{e.return?.()});;){let t=await e.next();if(!r())return;if(t.done)break;s(t.value)}}}if(!r())return;e.Y=null,u(()=>this.set(Vn,e.name,"done"))}catch(n){if(!r())return;e.Y=null,t.abort(),u(()=>{this.set(Jn,e.name,n),this.set(Vn,e.name,"error")})}}};function Zn(e){for(let t of e.$e){let n=t.G.indexOf(e);n>=0&&t.G.splice(n,1),t.At.delete(e)}e.$e.length=0,e.J=t}var el=new WeakMap;function tl(e){let t=el.get(e);return t?.target===e.target?t:void 0}function nl(e,t){let n=new Bn(e,function(e,t){if(void 0===t)return[];(null===t||"object"!=typeof t)&&v("$watch must be an object mapping paths to handler functions.");let n=[];for(let l of Object.keys(t)){let i=t[l];(""===l||"$"===l[0]||l.includes("@")||Ln.has(l))&&v(`$watch path "${l}" is not a path of the state tree.`),"function"!=typeof i&&v(`$watch entry "${l}" must be a function.`);let r=e.o(l);c.go?.(e,r,!0),n.push({t:l,p:r,handler:i,getter:!1,s:new WeakMap})}return n}(e,t.$watch)),l=new Qn(e,function(e,t){let n=t.$stream;if(void 0===n)return[];(null===n||"object"!=typeof n)&&v("$stream must be an object mapping stream names to definitions.");let l=[],i={},r={};for(let o of Object.keys(n)){let s=n[o];(""===o||"$"===o[0]||/[.*]/.test(o)||Xn.has(o))&&v(`$stream entry "${o}" must be a flat property name.`),(null===s||"object"!=typeof s)&&v(`$stream entry "${o}" must be an object.`);let a=s.source,u=s.fold,c=s.args,f=s.initial;"function"!=typeof a&&v(`$stream entry "${o}" needs a source function.`),void 0!==u&&"function"!=typeof u&&v(`$stream entry "${o}": fold must be a function.`),void 0!==u&&!("initial"in s)&&v(`$stream entry "${o}": fold needs an initial value.`),void 0!==c&&"function"!=typeof c&&v(`$stream entry "${o}": args must be a function.`),Yn(t,o)&&v(`$stream entry "${o}" collides with a getter, setter or method of the state.`),void 0===t[o]&&(t[o]=f),i[o]="idle",r[o]=null,l.push({name:o,source:a,Ro:u,V:f,Y:null,st:!1,n:0,g:void 0===c?null:e.o(`$streamArgs.${o}`),args:void 0===c?null:function(){return c(this)}})}return t[Vn]=i,t[Jn]=r,l}(e,t),n),i=el.get(e);void 0!==i&&(i.D.No(),i.Rt.tr()),el.set(e,{D:n,Rt:l,Xe:i?.Xe??!1,target:t})}function ll(e,t){let n=el.get(e);if(void 0!==n&&"mounting"!==t&&!document.documentElement?.hasAttribute("data-wcs-server")&&("reset"!==t&&(n.Xe="connected"===t),n.target===e.target)){if("disconnected"===t)return n.D.No(),void n.Rt.nr();n.Xe&&(n.D.Zo(),n.Rt.er())}}var il=["$streamStatus","$streamError"],rl={name:"temporal",install(){c.se=f(c.se,nl),c.element=f(c.element,ll),c.he=f(c.he,(e,t,n,l,i,r)=>tl(e)?.D.he(t,n,l,i,r)),c.ye=f(c.ye,(e,t,n)=>{let l=tl(e);void 0!==l&&(l.D.ye(t,n),l.Rt.ye(t))}),c.Yt=f(c.Yt,(e,t,n)=>tl(e)?.D.Yt(t,n)),c.Te=f(c.Te,e=>{let t=tl(e);void 0!==t&&(t.D.Te(),t.Rt.Te())}),c.zt=h(p,c.zt,(e,t)=>{let n=t.split(".",1)[0];if(il.includes(n))return n===t?e.target[t]:e.read(e.o(t),null)}),c.Pe=h(d,c.Pe,(e,t)=>(!Gn&&36===t.t.charCodeAt(0)&&il.includes(t.t.split(".",1)[0])&&v(`"${t.t}" is read-only (the stream runtime owns it).`),!1))}},ol=new WeakMap,sl=!1,al=/^(?!prototype$)[^\d.*$][^.*]*$/;function ul(e,t){let n=t.$listKeys,l=new Map;if(void 0!==n){(null===n||"object"!=typeof n)&&v("$listKeys must be an object mapping list paths to a key field or function.");for(let t of Object.keys(n)){let i=n[t];"string"==typeof i?l.set(e.o(t),e=>e[i]):"function"==typeof i?l.set(e.o(t),i):v(`$listKeys "${t}" must be a field name or a function.`)}}ol.set(t,l)}function cl(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function fl(e,t,n){let l=new Map;for(let i of t){cl(i)||v(`$listKeys "${e}": rows must be plain objects.`);let t=n(i);null==t&&v(`$listKeys "${e}": a row has no key.`),l.has(t)&&v(`$listKeys "${e}": duplicate key ${JSON.stringify(t)}.`),l.set(t,i)}return l}function hl(e,t,n,l){if(sl||!Array.isArray(l))return!1;let i=ol.get(e.target)?.get(t);if(void 0===i)return!1;let r=e.yt(t,n);if(!Array.isArray(r)||r===l)return!1;let o=fl(t.t,r,i);fl(t.t,l,i);let s=[],a=[],u=r.length===l.length;for(let e=0;e<l.length;e++){let t=l[e],n=o.get(i(t));s.push(n??t),void 0!==n&&a.push([e,n,t]),s[e]!==r[e]&&(u=!1)}let c=[];for(let[e,t,n]of a){for(let l of Object.keys(n))Object.is(t[l],n[l])||c.push([e,l,n[l]]);for(let l of Object.keys(t))!(l in n)&&null!==t[l]&&c.push([e,l,null])}if(u&&0===c.length)return!0;if(!u){sl=!0;try{e.P(t,n,s)}finally{sl=!1}}if(c.length>0){let l=e.De(0===t.n?null:n,t);for(let[n,i,r]of c){if("__proto__"===i)continue;let o=l.u[n],s=al.test(i)?e.o(`${t.t}.*.${i}`):null;null===s?.getter?e.P(s,o,r):(o.T[i]=r,e.P(e.o(`${t.t}.*`),o,o.T,!0))}}return!0}var dl={name:"list-keys",install(){c.se=f(c.se,ul),c.Pe=h(d,c.Pe,hl)}},pl=new WeakMap,ml=new WeakMap,gl="will not graft: the root state failed to initialize.",yl=new WeakSet,$l=new WeakMap,vl=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],bl=["$commandTokens","$eventTokens","$on","$errorCallback"],wl=e=>`[@wcstack/state] <${le.tagNames.state} mount="${e}">`,kl=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),Sl=e=>e?.element?.isConnected?e:void 0;function xl(e){let t=ml.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function Al(e,t){let n=ml.get(t);if(ml.delete(t),Array.isArray(n))for(let t of n)Ml(t,e)}function Nl(e){let t=pl.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function jl(e,t){console.error(`${wl(e.t)} ${t}`),Nl(e),e.Ge?.(),e.Ge=null}function Ol(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,e=>console.error(e))}catch(e){console.error(e)}}function Ml(e,t){if(yl.has(t))return jl(e,"will not graft: its component is wired to its host.");let n=e.state,l=t.target,i=e.t.split("."),r=l;for(let e of i)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return jl(e,`will not graft: the root state already has "${e.t}".`);let o=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,l){if("symbol"==typeof l)return;if(36!==l.charCodeAt(0))return e.proxy[n(l)];let i=e.proxy[l];return"$eqPath"===l?(e,t)=>i(n(e),n(t)):kl.has(l)&&"function"==typeof i?(e,...t)=>i(n(e),...t):i},set:(t,l,i)=>"symbol"!=typeof l&&(e.proxy[n(l)]=i,!0)})}(t,e.t);e.chroot=o;let s={},a={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:l,set:i,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==l||void 0!==i)a[`${e.t}.${n}`]={get:l&&function(){return l.call(o)},set:i&&function(e){i.call(o,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(o);a[`${e.t}.${n}`]={get:()=>t}}else s[n]=r}}if(void 0===r){for(let e=1;e<i.length;e++){let n=t.o(i.slice(0,e).join("."));null==t.yt(n,null)&&t.P(n,null,{})}t.P(t.o(e.t),null,s)}t.Yn(Object.defineProperties({},a));for(let e in a)t.We(t.o(e),null);e.engine=t;let c=$l.get(t);void 0===c&&$l.set(t,c=[]),c.push(e),e.el.isConnected&&Ol(e,"$connectedCallback"),e.Ge?.(),e.Ge=null}function Cl(e,t){let n=ml.get(e);if(Array.isArray(n))for(let e of n)jl(e,gl);ml.set(e,t)}var Tl=new WeakMap;function Pl(e,t){let n=e.getAttribute("mount");if(null===n)return null;let l={el:e,root:t,t:n,state:null,engine:null,chroot:null,Ge:null},i=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(le.bindAttributeName))i='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=pl.get(t);void 0===e&&pl.set(t,e=new Map);let r=e.get(n);if(void 0!==r&&r!==l&&(null===r.engine?r.el.isConnected:Sl(r.engine)))i=`will not graft: another volume already holds "${n}".`;else{if(null===r?.engine){let e=ml.get(t);Array.isArray(e)&&ml.set(t,e.filter(e=>e!==r)),r.Ge?.(),r.Ge=null}e.set(n,l)}}else i='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{vo:!0,start(e){if(null!==i)return jl(l,i);if(pl.get(t).get(n)===l){for(let t of vl)if(void 0!==e[t])return jl(l,`${t} is not run in a volume — declare it on the root state.`);for(let t of bl)void 0!==e[t]&&console.warn(`${wl(n)} ${t} is not run in a volume (it belongs to the root).`);return l.state=e,new Promise(e=>{l.Ge=e;let n=Sl(Rt.get(t)),i=ml.get(t);void 0!==n?Ml(l,n):xl(t)?jl(l,gl):ml.set(t,[...Array.isArray(i)?i:[],l])})}},Xe(){null!==l.engine&&Ol(l,"$connectedCallback")},On(){null!==l.engine&&Ol(l,"$disconnectedCallback")},reset(){v(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var El=new WeakMap,Wl=new WeakMap;function Rl(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||v(`${t} must be an array of state member names.`);let l=new Set;for(let e of n)("string"!=typeof e||""===e)&&v(`${t} entries must be non-empty strings.`),"$"===e[0]&&v(`${t} entry "${e}": internal ($) members are never exposed.`),l.has(e)&&v(`${t} entry "${e}" is duplicated.`),l.add(e);return n}function Il(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let l=document.createDocumentFragment();for(let e of[...t.childNodes])l.appendChild(e.cloneNode(!0));let i=t.mode;return{start(t){e.hasAttribute("bind-component")&&v("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,l){e.includes("-")||v(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&v(`DCC: <${e}> is already defined.`);let i=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(l),r=Rl(l,"$bindables"),o=Rl(l,"$commands");for(let e of r){let t=i.get(e);void 0===t&&v(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&v(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of o){let t=i.get(e);void 0===t&&v(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&v(`$commands entry "${e}" is not a method: list it in $bindables.`)}let s={tag:e,bindables:r},a=new WeakMap,u=new WeakMap,c=l=>{if(a.has(l))return a.get(l);if(l.hasAttribute("data-wc-definition"))return null;let i=l.attachShadow({mode:n});i.appendChild(t.cloneNode(!0));let o=i.querySelector(le.tagNames.state);return a.set(l,o),El.set(l,s),null===o&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${le.tagNames.state}>: no change events.`),o},f=e=>c(e)?.engine??null,h=e=>Promise.resolve(c(e)?.initializePromise).then(()=>{let t=u.get(e);u.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,l]of t)n.proxy[e]=l});class d extends HTMLElement{static{this.wcBindable=0===r.length&&0===o.length?null:{protocol:"wc-bindable",version:1,properties:r.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:r.map(e=>({name:e})),...0===o.length?{}:{commands:o.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==c(this)&&h(this)}get stateElement(){return c(this)}}for(let[e,t]of i)"function"==typeof t.value?Object.defineProperty(d.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(d.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=u.get(this);void 0===n&&u.set(this,n=[]),n.push([e,t])}}});customElements.define(e,d)}(n.localName,l,i,t)},Xe(){},On(){},reset(){v("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var Ll=new WeakMap,ql=new WeakSet,Dl=new WeakMap,zl=new WeakMap,Ul="data-wcs-wired",_l=new WeakMap,Fl=new WeakMap,Bl=new WeakMap,Hl=0,Kl=new Set,Vl={},Jl=["$watch","$stream","$renderedCallback"],Xl=e=>e.split(".",1)[0];function Gl(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function Yl(e,t){let n=e.a,l=Xl(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(Ul);else if(!Zl(n,l)){let e=n.getAttribute(Ul)?.split(" ")??[];e.includes(l)||n.setAttribute(Ul,[...e,l].join(" "))}_l.get(n)?.ce===l&&v(`<${n.localName}>.${l} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let i=Ll.get(n);void 0===i&&Ll.set(n,i=[]),i.push(e),t&&ql.add(e);let r=Dl.get(n);return void 0===r&&Dl.set(n,r=new Map),r.has(l)||r.set(l,n[l]),zl.get(n)?.(),!1}function Ql(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${le.tagNames.state}[bind-component]`)}function Zl(e,t){let n=e.getAttribute(le.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function ei(e){let t=e.parentElement;for(;null!==t&&!Ql(t);)t=t.parentElement;let n=Rt.get(t??e.getRootNode()),l=n?.element;(l?.isConnected?l.W:null===t)&&(null===t?Ft(e):Lt(n,e))}var ti=new Set;function ni(e,t){ti.has(e)||(ti.add(e),console.warn(`[@wcstack/state] ${t}`))}var li=(e,t)=>t in e.state;function ii(e,t){let n=ri(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function ri(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function oi(e,t,n){if(null!==n.getter)return;let l,i=e.host,r=i.engine,o=Xl(n.t),s=i.entries.find(e=>e.E===n.t);if(void 0===s&&null!==n.d)return function(e,t){let n,l=t.d;for(;null!==l&&void 0===(n=e.at.get(l));)l=l.d;if(null===l||void 0===n)return;let i=e.x,r=e.host.engine,o=r.o(n.p.t+t.t.slice(l.t.length));if(null===o.getter)return;let s=n,a=()=>{let n=si(e,s.r);return 0===t.n?n:(r.resolve(Gl(o.t,[...r._(n),...i._(ee(i.c,t.n))]),null),r.rr)};t.getter=()=>{let e=a();return o.n>0&&null===e?void 0:r.v(o,e)},null!==o.oe&&(t.oe=n=>{let l=a();ai(e,s.e,()=>r.P(o,l,n)),e.cn=t}),t.n>0&&(t.F=i.Oe++),e.at.set(t,{e:s.e,p:o,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.E!==o?li(i,o):ii(i,o))return;l=s.ue}else{if(null===t||null!==n.d||"$"===o[0]||li(i,o))return;s=t,l=r.o(`${t.ue.t}.${o}`)}let a=s.r,u=s;n.getter=()=>r.v(l,si(e,a)),n.oe=t=>{ai(e,u,()=>r.P(l,a,t)),e.cn=n},e.at.set(n,{e:s,p:l,r:a})}function si(e,t){return null!==t&&!t.y&&v(`The host row of <${e.host.el.localName}> was removed.`),t}function ai(e,t,n){let l=Kl.has(e.x);Kl.add(e.x),e.from=t;try{n()}finally{l||Kl.delete(e.x),e.from=null}}var ui=(e,t)=>t||!Kl.has(e.m.x)||null!==e.m.from&&e.m.from!==e.e;function ci(e,t){if(e.un===t||null===e.host.engine)return;e.un=t,Hl+=t?1:-1;let n=e.host.engine,l=Bl.get(n);void 0===l&&Bl.set(n,l=new Map);for(let n of e.ae){let e=l.get(n.e.ue);void 0===e&&l.set(n.e.ue,e=new Map);let i=e.get(n.e.r);void 0===i&&e.set(n.e.r,i=new Set),t?i.add(n):(i.delete(n),0===i.size&&e.delete(n.e.r))}let i=e.host.entries.find(e=>""===e.E);if(void 0!==i){null===e.te&&function(e,t){let n=e.host,l=n.engine;e.te=new Map;let i=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let o of Object.getOwnPropertyNames(r)){if(i.has(o))continue;i.add(o);let s=Object.getOwnPropertyDescriptor(r,o);if(void 0===s.get&&void 0===s.set||"$"===o[0]||o.includes("*"))continue;let a=Xl(o);if(o!==a&&!li(n,a))continue;let u=l.o(`${t.ue.t}.${o}`);if(null===u.getter)di(l,u,t.ue);else if(!fi.has(u.getter))continue;e.te.set(u,e.x.o(o))}}(e,i);for(let l of e.te.keys())t&&null===l.getter&&di(n,l,i.ue),n.R.me(n,l,i.r);e.te.size>0&&n.Re(),t&&function(e,t){let n=e.host.engine;for(let[l,i]of e.te){let r=n.v(l.d,t.r);if(null===r||"object"!=typeof r||!(l.s in r))continue;let o=e.host.el.localName;ni(`${o}|${l.t}`,`[wcs/mount-export-shadowed] <${o}>.${e.host.ce}.${i.t} is exported at "${l.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,i)}}var fi=new WeakSet;function hi(e,t,n,l){let i=Bl.get(e)?.get(t)?.get(n);if(void 0===i)return null;let r=null;for(let e of i)""!==e.e.E||!0!==e.m.te?.has(l)||e.m===r||(null!==r&&v(`[wcs/mount-export-ambiguous] "${l.t}" is exported by two mounted components on the same instance: <${r.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),r=e.m);return r}function di(e,t,n){let l=t.d,i=t.s,r=()=>{let t=e.read(l,e.c);return null!==t&&"object"==typeof t&&i in t?t:null};t.getter=()=>{let l=r();if(null!==l)return l[i];let o=hi(e,n,e.c,t);return null===o?void 0:o.x.read(o.te.get(t),null)},fi.add(t.getter),t.oe=o=>{let s=null===r()?hi(e,n,e.c,t):null;if(null===s){let t=e.read(l,e.c);return void(null!==t&&"object"==typeof t&&(t[i]=o))}let a=s.te.get(t);void 0===ri(s.host.state,a.t)?.set&&v(`Cannot write to "${a.t}" on mounted <${s.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),s.x.P(a,null,o)},t.n>0&&(t.F=e.Oe++)}function pi(e,t,n,l,i,r){if(null!==t.getter)return e.R.me(e,t,n),void e.Re();if("*"===t.s){if(null===n)return;if(n.T=n.l.C[n.b],e.R.qt(n),null!==n.h)for(let t of n.h.values())e.z(t)}else e.wn(t,n);c.he?.(e,t,n,l,i,r),e.We(t,n)}function mi(e){let t=e.m.x;for(let[n,l]of e.m.at)l.e===e.e&&(0===n.n?t.R.me(t,n,null):t.Zt(n.f[n.n],e=>t.R.me(t,n,e)));t.Re()}function gi(e,t,n,l,i,r,o){let s=n.t.slice(t.t.length);if(""===s)return mi(e);let a,u=e.m,c=u.x;if(""===e.e.E){a=s.slice(1);let e=Xl(a);if("$"===e[0]||li(u.host,e)||u.host.entries.some(e=>""!==e.E&&(a===e.E||a.startsWith(`${e.E}.`))))return}else a=e.e.E+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(ee(l,e).b);c.resolve(Gl(a,f),null);let h=c.rp,d=c.rr;h.n>0&&null===d||pi(c,h,d,i,r,o)}function yi(e,t,n,l,i,r,o){if(0===Hl)return;let s=Kl.has(e);Kl.add(e);try{let s=Fl.get(e);!o&&void 0!==s&&s.un&&!Kl.has(s.host.engine)&&function(e,t,n,l,i,r){let o,s=t;for(;null!==s&&void 0===(o=e.at.get(s));)s=s.d;if(null===s||void 0===o)return;let a=e.host.engine;if(s===t&&e.cn===t)return void(e.cn=null);if(null!==o.r&&!o.r.y)return;let u=[...a._(o.r),...e.x._(n)];a.resolve(Gl(o.p.t+t.t.slice(s.t.length),u),null);let c=a.rp,f=a.rr;c.n>0&&null===f||ai(e,o.e,()=>pi(a,c,f,l,i,r))}(s,t,n,l,i,r),o&&void 0!==s&&s.un&&null!==s.te&&function(e,t){let n=e.host.entries.find(e=>""===e.E),l=e.host.engine;for(let[i,r]of e.te)r===t&&(l.R.me(l,i,n.r),l.Re())}(s,t);let a=Bl.get(e);if(void 0===a)return;for(let[e,s]of a)if(t.Q(e)){let a=s.get(0===e.n?null:ee(n,e.n));if(void 0!==a)for(let s of[...a])ui(s,o)&&gi(s,e,t,n,l,i,r)}else if(e.Q(t))for(let[e,l]of[...s])if(0===t.n||ee(e,t.n)===n)for(let e of[...l])ui(e,o)&&mi(e)}finally{s||Kl.delete(e)}}async function $i(e,t,n,l,i){if(l===Vl)return;let r=y(l);r&&await r;let o=_l.get(t);o.engine&&l.$recursion&&v(`[wcs/mount-dollar-declaration] <${t.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let s=o.O;if(null!==s&&s.el!==e&&s.el.isConnected&&v(`<${t.localName}> already has a connected <${le.tagNames.state} bind-component="${o.ce}">.`),null!==s&&ci(s,!1),null!==s&&function(e,t,n){let l=e.x,i=`[${le.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(i)||null!==e.querySelector(i)),o=new Set,s=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&o.add(e)},a=(e,t)=>{for(let n=e.Pn(t);null!==n&&n!==t;n=n.nextSibling)s(n);s(t)};for(let e of l.ie.values())for(let t of e)if(null===t.M)s(t.a);else for(let e of t.M.X)a(t.M,e.S);for(let e of l.ee.values())for(let t of[e.$,...e.L??[]])null!==t&&a(t,t.S);for(let t of e.j)t.parentNode===n&&r(t)&&o.add(t);if(0===o.size)return!1;let u=[...n.childNodes].filter(n=>n!==t&&!o.has(n)&&!e.j.includes(n)&&(r(n)||l.Lt&&n.textContent.includes("{{")));return u.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${u.length} node(s) added beside the content taken over are not bound.`),!0}(s,e,n))return async function(e,t,n,l){e.el.engine=null,e.el=t,e.x.element=t,t.engine=e.x,e.j=e.j.filter(e=>e.parentNode===n),t.isConnected?await vi(e,l):l()}(s,e,n,i);let a=new ne(l,new Ht);a.element=e,e.engine=a,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let l=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof l&&"constructor"!==t&&n.set(l,null)}let l=(t,n,l)=>Reflect.apply(t,e.proxy,l);e.W=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:l})),t}}(a,l);let u={el:e,j:[],x:a,host:o,ae:[],at:new Map,un:!1,cn:null,from:null,te:null};for(let e of o.entries)u.ae.push({m:u,e});o.O=u,Fl.set(a,u);let f=null===o.engine;f?c.element?.(a,"mounting"):(function(e){let t=e.x,n=e.host,l=n.engine,i=n.el.localName,r=n.entries.find(e=>""===e.E)??null;for(let e of n.entries){if(""===e.E)continue;let t=Xl(e.E);li(n,t)&&(e.E!==t||ii(n,t))&&ni(`${i}.${e.E}`,`[wcs/mount-own-key-shadow] <${i}>: "${n.ce}.${e.E}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=l.v(r.ue,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.E===t)&&ni(`${i}.${t}`,`[wcs/mount-own-key-shadow] <${i}>: its own "${t}" hides "${r.ue.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let o=Jl.filter(e=>void 0!==n.state[e]);o.length>0&&ni(`${i}.${n.ce}$`,`[wcs/mount-dollar-declaration] <${i}>: ${o.join(", ")} ${1===o.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let s=t.et;t.et=n=>{oi(e,r,n),s.call(t,n)};let a=[...t.B.all()];for(let t of a)oi(e,r,t);for(let e of a)s.call(t,e);let u=n.entries.filter(e=>null!==e.r);if(u.length>0){let e=t.Ut;t.Ut=()=>{u.every(e=>e.r.y)&&e.call(t)}}}(u),ci(u,!0),yl.add(a),Al(a,n));let h=c.ir?.(n);It(a,n),h?.(),u.j=[...n.childNodes],Bt(),f&&a.bn(),Object.defineProperty(t,o.ce,{configurable:!0,enumerable:!0,get:()=>a.proxy});let d=t.$stateReadyCallback;if("function"==typeof d)try{let e=d.call(t,o.ce);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}i(),e.isConnected?(await a.we("$connectedCallback"),f&&e.isConnected&&c.element?.(a,"connected")):ci(u,!1)}async function vi(e,t){ci(e,!0);for(let t of e.ae)mi(t);t?.(),!e.broken&&(await e.x.we("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.x,"connected"))}function bi(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=Rt.get(t)?.element;if(!(e.W||void 0!==n&&n!==e&&n.isConnected)){Cl(t,e);for(let e of Tl.get(t)??[])e()}}),null}(e,t);let l=e.parentNode,i=l instanceof ShadowRoot,r=i?l.host:l instanceof Element?l:null,o=()=>{let t=null===r?void 0:_l.get(r)?.O;return t?.el===e?t:null},s=t=>{throw i&&Cl(l,e),t},a=!1;return{jt:()=>(null!==r&&r.localName.includes("-")?async function(e,t,n,l){let i=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&v(`<${le.tagNames.state} bind-component> takes its state from <${i}>.${t}: it cannot also load one (state / src / json / an inline script).`),await Re(n).whenDefined(i);let r=_l.get(n);if(void 0!==r)return r.ce!==t&&v(`<${i}> already has a <${le.tagNames.state} bind-component="${r.ce}">.`),r.state;let o=()=>(Ll.get(n)??[]).filter(e=>Xl(e.name)===t),s=Zl(n,t);if(s&&0===o().length&&ei(n),0===o().length&&(s||((e,t)=>!0===e.getAttribute(Ul)?.split(" ").includes(t))(n,t))){let e;await new Promise((l,r)=>{zl.set(n,l),e=function(e,t){xl(e)&&t();let n=Tl.get(e)??new Set;return Tl.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>r(new Error(`[@wcstack/state] <${i}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}zl.delete(n);let a=o(),u=Dl.get(n),c=void 0!==u&&u.has(t)?u.get(t):n[t];if((null===c||"object"!=typeof c)&&v(`"bind-component": <${i}>.${t} must be an object (the component's state), got ${null===c?"null":typeof c}.`),0===a.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${i}>, or mount it from the host (${le.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),Vl}let f=[];for(let e of a){let l=e.name===t?"":e.name.slice(t.length+1);f.some(e=>e.E===l)&&v(`<${i}> maps "${e.name}" twice.`);let r=l.split(".").indexOf("*");if(r>=0){let n=l.split(".").slice(0,r).join(".");v(`<${i}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}f.push({E:l,ue:e.o,r:e.r,ro:ql.has(e)}),e.engine.kn(e),""!==l&&delete n[e.name]}let h=0===a.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(c):c;return _l.set(n,r={el:n,ce:t,state:h,engine:0===a.length?null:a[0].engine,entries:f,O:null}),h}(e,n,r,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${le.tagNames.state}> to be a direct child of a custom element.`))).catch(s),async start(t,n){await $i(e,r,i?l:r,t,()=>{a=!0,n()}).catch(e=>{let t=o();return!a&&null!==t&&(t.broken=!0),s(e)})},Xe(){let t=o();null!==t?vi(t).catch(e=>console.error(e)):a?Promise.resolve().then(()=>{if(e.parentNode===l)return $i(e,r,i?l:r,_l.get(r).state,()=>{})}).catch(e=>console.error(e)):zl.has(r)&&ei(r)},On(){let e=o();null!==e&&(ci(e,!1),!e.broken&&(e.x.we("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.x,"disconnected")))},reset(){v(`re-setting a component's state is not supported: write <${r?.localName}>.${n} instead.`)}}}var wi={name:"scopes",install(){c.rt=h(m,c.rt,Pl),c.rt=h(m,c.rt,Il),c.rt=h(m,c.rt,bi),c.Jo=Yl,c.yo=Ql,c.element=f(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=$l.get(e)??[];if("disconnected"===t)for(let e of n)Nl(e);else if("reset"!==t&&Sl(Rt.get(e.root))===e){Al(e,e.root);for(let e of n)pl.get(e.root).has(e.t)||pl.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();Al(e,n),function(e,t){let n=t.host,l=void 0===n?void 0:El.get(n);void 0!==l&&Wl.set(e,{host:n,def:l})}(e,n)}),c.he=f(c.he,(e,t,n,l,i,r)=>{(function(e,t,n,l){let i=Wl.get(e);if(void 0===i)return;let r=t.t.split(".",1)[0];if(!i.def.bindables.includes(r))return;let o=l&&t.t===r;i.host.dispatchEvent(new CustomEvent(`${i.def.tag}:${r}-changed`,{detail:o?n:void 0,bubbles:!0}))})(e,t,i,r),yi(e,t,n,l,i,r,!1)}),c.ye=f(c.ye,(e,t,n)=>yi(e,t,n,void 0,void 0,!1,!0)),c.Pe=h(d,c.Pe,(e,t,n,l,i)=>(function(e,t){let n=$l.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&v(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let l,i=Fl.get(e);if(void 0===i)return!1;for(let e=t;null!==e&&void 0===l;e=e.d)l=i.at.get(e);if(void 0===l)return!1;let r=l.e;return!((null===r.r||r.r.y)&&!r.ro)&&(!!n||(si(i,r.r),void v(`[wcs/mount-readonly] <${i.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${i.host.ce}${""===r.E?"":`.${r.E}`}#ro: ${r.ue.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,i)));let e=c.se;c.se=(t,n)=>{let l=$l.get(t);void 0!==l&&l.length>0&&v(`re-setting a root state with grafted volumes (${l.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=Bl.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&v("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},ki="$recursion",Si=new WeakMap,xi=new WeakSet,Ai=new WeakSet,Ni=0,ji=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Oi=e=>`[wcs/recursion-${e}]`;function Mi(e,t){let n=n=>v(`${Oi("declaration-invalid")} ${ki} ${e} "${String(t)}" ${n}`);("string"!=typeof t||""===t)&&v(`${Oi("declaration-invalid")} ${ki} ${e} must be a non-empty string.`);let l=t.split(".");(l.length<2||"*"!==l[l.length-1])&&n('must end with ".*" (a list element).');for(let e=0;e<l.length-1;e++){let t=l[e];""===t&&n("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&n('must have exactly one "*", at the end.'),t.includes("#")&&n('must not contain "#".')}return"$"===t[0]&&n('must not start with "$".'),t}var Ci=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function Ti(e,t){let n=`${e.l}.**`,l=t.slice(n.length);return(!t.startsWith(n)||""!==l&&"."!==l[0]||l.includes("**"))&&v(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),l}function Pi(e,t,n){let l=Ti(e,t),i=function(e,t){for(let n=t;null!==n;n=n.l.re){let t=e.nodeList.exec(n.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r:n}}return null}(e,n);return null===i&&v(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),Ci(e,i.k)+l}function Ei(e,t,n){let l=new Set,i=new Set,r=(e,n,r)=>!(!Array.isArray(e)||0===e.length||(l.has(e)&&v(`${Oi("cycle")} "${n}" is reachable from itself: the data under "${t.l}" must be a tree.`),i.has(e)&&v(`${Oi("shared-list")} "${n}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),r+1>128&&v(`${Oi("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${r+1} (the limit is 128).`),i.add(e),0)),o=(i,s)=>{for(let a of i){n(s,a);let i=e.o(`${Ci(t,s)}.${t.key}`),u=e.read(i,a);r(u,i.t,s+1)&&(l.add(u),o(e.De(a,i).u,s+1),l.delete(u))}},s=e.o(t.l),a=e.read(s,null);r(a,t.l,0)&&(l.add(a),o(e.De(null,s).u,0))}function Wi(e,t){let n=function(e){let t=e[ki],n=[],l=new Set;for(let t=e;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let e of Object.getOwnPropertyNames(t))!l.has(e)&&e.includes("**")&&n.push([e,Object.getOwnPropertyDescriptor(t,e)]),l.add(e);if(void 0===t)return n.length>0&&z(n[0][0]),null;(null===t||"object"!=typeof t||Array.isArray(t))&&v(`${Oi("declaration-invalid")} ${ki} must be an object mapping one anchor path to its repeating sub-path.`);let i=Object.entries(t);1!==i.length&&v(`${Oi("declaration-invalid")} ${ki} must declare exactly one anchor (it declares ${i.length}).`);let r=Mi("anchor",i[0][0]),o=Mi("repeat",i[0][1]),s=r.slice(0,-2),a=o.slice(0,-2),u=`.${o}`,c=new Map,f=[],h=`${s}.**`;for(let[e,t]of n){let n=e.slice(h.length);(!e.startsWith(h)||""!==n&&"."!==n[0]||n.includes("**"))&&v(`[wcs/recursion-anchor] "${e}": a recursive key is "${h}" followed by a path (the anchor is "${r}").`),(""===n||n.split(".").slice(1).some(e=>""===e))&&v(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&v(`${Oi("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),c.set(n,t.get),f.push([new RegExp(`^${ji(r)}((?:${ji(u)})*)${ji(n)}$`),n])}return{l:s,step:u,key:a,families:c,matchers:f,owners:new Map,nodeList:new RegExp(`^${ji(s)}((?:${ji(`.*.${a}`)})*)$`)}}(t),l=Si.has(e);null!==n?(l||Ni++,Si.set(e,n),Ai.add(e),xi.has(e)||function(e){xi.add(e);let t=e,n=t.et;t.et=l=>{let i=Si.get(e);if(l.t.includes("**")){let t=e.B.Ot(l.t)===l;return void(Ai.has(e)||void 0===i&&t?l.getter=()=>z(l.t):t||n.call(e,l))}if(void 0!==i&&null===l.getter)for(let[e,n]of i.matchers)if(e.test(l.t)){l.getter=i.families.get(n),l.n>0&&(l.F=t.Oe++),i.owners.set(l,i.l+".**"+n);break}n.call(e,l)};let l=t.resolve;t.resolve=(t,n)=>{let i=Si.get(e);return l.call(e,void 0!==i&&t.includes("**")?Pi(i,t,n):t,n)};let i=t.getAll;t.getAll=(n,l)=>{let r=Si.get(e);if(void 0===r||!n.includes("**"))return i.call(e,n,l);if(void 0===l)return i.call(e,Pi(r,n,t.c));(!Array.isArray(l)||l.length>0)&&v(`${Oi("getall-form")} $getAll("${n}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let o=Ti(r,n),s=[];return Ei(e,r,(t,n)=>{for(let l of i.call(e,Ci(r,t)+o,e._(n)))s.push(l)}),s};let r=t.pn;t.pn=(n,l,i,o)=>{let s=Si.get(e);if(void 0===s||!n.includes("**"))return r.call(e,n,l,i,o);Array.isArray(l)||S(9,[n]),l.length>0&&v(`${Oi("setall-form")} $setAll("${n}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof i||!0===o?.spread)&&v(`${Oi("setall-form")} $setAll("${n}", [], value) with "**" takes a plain value (no mapper, no spread).`),t.Ce>0&&S(8);let a=Ti(s,n),u=a.replace(/\.\d+(?=\.|$)/g,".*");for(;u.startsWith(s.step);)u=u.slice(s.step.length);let c=s.key.split(".");(""===u||u===`.${s.key}.length`||c.some((e,t)=>u===`.${c.slice(0,t+1).join(".")}`))&&v(`${Oi("structural-write")} "${n}" writes the recursion structure itself (a node, its "${s.key}" list or that list's length, or an object on the way to it).`);for(let e of s.families.keys()){let t=e;for(;t.startsWith(s.step);)t=t.slice(s.step.length);(u===t||u.startsWith(`${t}.`))&&v(`${Oi("readonly")} "${n}" writes into the recursive getter "${s.l}.**${e}".`)}let f=[];Ei(e,s,(e,t)=>f.push([e,t]));let h=0;for(let[t,n]of f)h+=r.call(e,Ci(s,t)+a,e._(n),i);return h}}(e)):l&&(Si.delete(e),Ni--)}function Ri(e,t){if(0===Ni)return!1;let n=Si.get(e);if(void 0===n)return!1;for(let e=t;null!==e;e=e.d){let l=n.owners.get(e);void 0!==l&&v(`${Oi("readonly")} "${t.t}" writes into the recursive getter "${l}".`)}return!1}var Ii={name:"recursion",install(){c.se=f(c.se,Wi),c.element=f(c.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){Ai.delete(e)}(e)}),c.Pe=h(d,c.Pe,Ri)}},Li="4.0.0-rc.3",qi=e=>e.split(".").slice(0,2).join("."),Di=class extends Gt{static find(e){return e.querySelector?.(le.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return qi(this.version)===qi(Li)}};function zi(e){let t=le.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends Di{})}var Ui=()=>le.tagNames.ssr,_i=Symbol.for("wcstack.ssr.snapshotBuilder"),Fi=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),Bi=e=>document.createComment(e),Hi=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,Ki=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),Vi=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,Gi=new WeakSet,Yi=new WeakMap;function Qi(e,t){let n=[];for(let l=e;null!==l&&(n.push(l),l!==t);l=l.nextSibling);return n}function Zi(e,t,...n){for(let n of Array.from(e.attributes))t.setAttribute(n.name,n.value);return(t.content??t).append(...n),t}var er=e=>null===e.j?e.Ue:e.j[e.j.length-1];function tr(e,t,n){let l=[Bi(null===n?"wcs-[":`wcs-[:${n}`)];for(let e of t)null===n&&l.push(Bi("wcs-|")),l.push(...Qi(e.Ue,er(e)));l.push(Bi("wcs-]")),e.after(...l);for(let e of l)Gi.add(e)}function nr(e){if(e instanceof st){tr(e.S,e.Ee,null);for(let t of e.Ee)lr(t);return}let t=e.O;null!==t&&(tr(e.X[e.X.length-1].S,[t],e.b),lr(t))}function lr(e){if(null!==e.h)for(let t of e.h)nr(t)}var ir=new Set(["script","style","template","textarea","title"]),rr="data-wcs-raw",or=e=>ir.has(e.localName)||e.localName===Ui();function sr(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(Bi("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(Bi("wcs-s")):1===t.nodeType&&!or(t)&&sr(t)}var ar=0;function ur(e,t){let n=e.getRootNode(),l=[t];for(let e of Ji.get(n)??[])e!==t&&!0===e.element?.hasAttribute("bind-component")&&l.push(e);let i=new Map;for(let e of l){let t=Vi.get(e);if(void 0===t)continue;let n=new Map;for(let t of e.ee.values())if(null!==t.$&&n.set(t.$.S,t.$),null!==t.L)for(let e of t.L)n.set(e.S,e);for(let t of e.ie.values())for(let e of t)if(null!==e.M)for(let t of e.M.X)n.set(t.S,e.M);let l=new Set;for(let[e,r]of t){i.set(e,r);let t=n.get(e);void 0!==t&&!l.has(t)&&e.isConnected&&(l.add(t),nr(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=Xi.get(e);if(void 0!==t){let n=document.createTreeWalker(e,133,{acceptNode:e=>Gi.has(e)||1===e.nodeType&&t.has(e)&&pr(e)?2:1}),l=[];for(let e=n.nextNode();null!==e;e=n.nextNode()){let n=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(or(e.parentNode)?Yi.has(e):t.has(n)&&Ki(n,"wcs-t:"))&&(Yi.has(e)||t.get(e)!==e.data):!t.has(e))&&l.push(e)}for(let e of l)e.remove()}let n=Array.from(e.childNodes);or(e)&&n.some(e=>Yi.has(e))&&e.setAttribute(rr,n.map(e=>Yi.has(e)?`{{ ${Yi.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}sr(9===n.nodeType?n.body:n);let r=document.createElement(Ui());r.setAttribute("version",Li);let o=document.createElement("script");o.type="application/json",o.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let n of Object.keys(e)){if("$"===n[0])continue;let l=Object.getOwnPropertyDescriptor(e,n);void 0!==l.get||void 0!==l.set||"function"==typeof l.value||(t[n]=l.value)}return t}(t.target)),r.append(o);for(let[e,t]of i){if(!e.isConnected)continue;let n=e.parentNode;for(;null!==n&&"svg"!==n.localName&&"foreignObject"!==n.localName;)n=n.parentElement;let l="svg"===n?.localName,i=`wcs-${l?"s":"t"}${ar++}`;e.replaceWith(Bi(`wcs-p:${i}`));let o=document.importNode(Mt(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(Zi(e,document.createElement("template"),...e.childNodes));if(l){let e=document.createElementNS(n.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=i,r.append(Zi(t,s,o))}e.before(r)}function cr(e){!function(e){if(null!==e.querySelector(le.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>Yi.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${le.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===Ui())continue;let e=t.engine;null!=e&&ur(t,e)}}var fr=Symbol.for("wcstack.state.ssr.impl"),hr=new Map,dr=new WeakMap,pr=e=>!0===c.yo?.(e),mr=e=>1===e.nodeType&&!or(e)&&!pr(e),gr=e=>e.u.flat().concat(e.U??[]),yr=e=>{for(let t of gr(e))t.remove()};function $r(e,t,n){let l=/^wcs-\[(?::(\d+))?/.exec(e.data),i=e.previousSibling,r=e.parentNode,o=[],s=e.nextSibling;for(e.remove();null!==s&&!Hi(s,"wcs-]");){let e=s.nextSibling;if(Hi(s,"wcs-|"))o.push([]),s.remove();else{0===o.length&&o.push([]);let n=o[o.length-1];Ki(s,"wcs-[")?e=$r(s,t,n):(n.push(s),mr(s)&&vr(s,t))}s=e}let a={branch:void 0===l[1]?null:Number(l[1]),u:o,U:s??r.appendChild(Bi("wcs-]"))},u=gr(a);s=a.U.nextSibling;for(let e of u)n?.push(e),t&&Nt.add(e);return t&&null!==i?hr.set(i,a):yr(a),s}function vr(e,t){for(let n=e.firstChild;null!==n;)Ki(n,"wcs-[")?n=$r(n,t):(mr(n)&&vr(n,t),n=n.nextSibling)}function br(e,t,n){let l=e=>{for(let i of Array.from(e.childNodes))if(i.parentNode===e)if(8===i.nodeType){let e=i.data;try{if("wcs-s"===e)i.remove();else if("wcs-e"===e)i.replaceWith("");else if(e.startsWith("wcs-t:")){let t=Bi(`@@:${decodeURIComponent(e.slice(6))}`),n=i.nextSibling;for(;null!==n&&!Hi(n,"wcs-/t");){let e=n.nextSibling;n.remove(),n=e}n?.remove(),i.replaceWith(t)}else if(e.startsWith("wcs-p:")){let n=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==n){let t=i.parentNode,l="s"===e[10]?Zi(n,document.createElementNS(t.namespaceURI,"template"),...document.importNode(n.content.firstChild,!0).childNodes):document.importNode(n,!0);l.removeAttribute("id"),t.replaceChild(l,i)}}}catch{}}else 1===i.nodeType&&!or(i)&&(pr(i)?dr.set(i,{ssr:t,Ae:n}):l(i))};l(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let n=t.previousSibling;null!==n&&(8===n.nodeType||jr(n)||"template"===n.localName);n=n.previousSibling)e.unshift(n);let n=0,l=0;if(e.forEach((e,t)=>{Ki(e,"wcs-[")?l++:Hi(e,"wcs-]")&&--l<0&&(l=0,n=t+1)}),0===l)continue;let i=0;for(let l=t.firstChild;null!==l;l=l.nextSibling)if(Ki(l,"wcs-["))i++;else if(Hi(l,"wcs-]")&&0===i--){t.prepend(...e.slice(n));break}}}(e),vr(e,n)}function wr(e){let t=dr.get(e);if(void 0===t||(dr.delete(e),br(e,t.ssr,t.Ae),!t.Ae))return null;let n=c.Ae;return c.Ae=Cr,()=>{c.Ae=n,kr()}}function kr(){for(let e of hr.values())yr(e);hr.clear()}function Sr(e){let t=[];for(let n=document.createTreeWalker(e,128);n.nextNode();)t.push(n.currentNode);return t}function xr(e,t,n,l){let i=null;for(let l of e){let e=l[n];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===i||e.length>i[n].length)&&(i=l)}let r=i?.[l];if(null==r)return null;let o=i[n],s=""===o?t:t.slice(o.length+1);return""===r?s:""===s?r:`${r}.${s}`}function Ar(e,t,n){if(Fi()){if(n instanceof Array){for(let e=n.length;e-- >0;)gt(n[e])&&n.splice(e,1);let e=t;if(n.some(yt))Gi.add(e);else if(e.localName.includes("-")&&!pr(e)){let t=new Map;for(let n=document.createTreeWalker(e,133);n.nextNode();)t.set(n.currentNode,n.currentNode.data);Xi.set(e,t)}return}if("string"==typeof n){if(Yi.set(t,n),or(t.parentNode))return;let e=Bi(`wcs-t:${encodeURIComponent(n)}`),l=Bi("wcs-/t");return t.before(e),void t.after(l)}let l=Vi.get(e);void 0===l&&Vi.set(e,l=new Map),l.set(t,n);let i=t.getRootNode(),r=Ji.get(i);return void 0===r&&Ji.set(i,r=new Set),void r.add(e)}if("string"!=typeof n&&hr.size>0){let e=hr.get(n);void 0!==e&&(hr.delete(n),hr.set(t,e))}}var Nr=e=>null!==e&&8===e.nodeType&&[le.commentIfPrefix,le.commentElseIfPrefix,le.commentElsePrefix].includes(e.data),jr=e=>3===e.nodeType&&""===e.data.trim(),Or=e=>(hr.get(e)?.U??e).nextSibling;function Mr(e,t){if(t.length!==e.on.childNodes.length)return!1;let n=e.Rn;for(let l=0;l<n.length;l++){let i=n[l],r=e.on,o=t[i[0]];for(let e=0;;){if(r=r.childNodes[i[e]],o?.nodeName!==r.nodeName)return!1;if(++e===i.length)break;o=o.firstChild;for(let t=i[e];t>0&&null!==o;t--)o=Or(o)}e.mo[l]=o}return!0}function Cr(e,t,n){if(0===hr.size)return null;let l=t,i=0;if(!n){let e=le.commentIfPrefix;if(!Hi(t,e))for(let n=t.previousSibling;null!==n&&1!==n.nodeType&&(Nr(n)&&i++,!Hi(n,e));n=n.previousSibling);for(let n=t.nextSibling;!hr.has(l)&&null!==n&&!Hi(n,e)&&1!==n.nodeType;n=n.nextSibling)Nr(n)&&(l=n)}let r=hr.get(l);if(void 0===r)return null;if(!n&&r.branch!==i)return hr.delete(l),yr(r),null;let o=r.u.shift();if(0===r.u.length&&hr.delete(l),r.U?.replaceWith(...Qi(t,l)),r.U=null,void 0===o)return null;let s=[];for(let e=0;e<o.length;e++){let t=hr.get(o[e]);if(s.push(o[e]),void 0!==t)for(;e<o.length&&o[e]!==t.U;)e++}if(!Mr(e,s)){let n=(e.Tn?e.root:e.on).cloneNode(!0);s=e.Tn?[n]:[...n.childNodes],Mr(e,s),(o[0]??r.u.find(e=>e.length>0)?.[0]??t).before(n);for(let e of o)e.remove()}return s}var Tr={name:"ssr",install(){c.An=Ar,c.ir=wr;let e=c.element;c.element=(t,n)=>{"mounting"===n&&function(e){let t=e.element;if(!t.hasAttribute("enable-ssr")||Fi())return;let n=t.previousElementSibling,l=n?.localName===Ui(),i=l?n.getAttribute("version"):null,r=null===i||qi(i)===qi(Li);if(r){let t=e,n=t.we;t.we=(t,l)=>"$connectedCallback"===t?void 0:n.call(e,t,l)}if(!l)return;let o=!r&&parseInt(i)<4,s=/^3\.(\d+)\.(\d+)$/.exec(i),a=null!==s&&(+s[1]-5||+s[2]-3)>=0;r||console.warn(`[@wcstack/state] <${Ui()} version="${i}"> does not match ${Li}: its snapshot is discarded, and the page renders on the client from its own state.${o&&!a?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let u=r?n.querySelector('script[type="application/json"]'):null;if(null!==u){let t=JSON.parse(u.textContent||"{}"),n=e.target;for(let e of Object.keys(t)){let l=Object.getOwnPropertyDescriptor(n,e);void 0!==l&&(void 0!==l.get||void 0!==l.set||"function"==typeof l.value)||(n[e]=t[e])}e.hydrated=!0}let f=t.getRootNode();for(let e of Array.from(f.querySelectorAll(`[${rr}]`)))e.textContent=e.getAttribute(rr),e.removeAttribute(rr);let h=9===f.nodeType?f.body:f;o?function(e,t,n){let l=new Map,i=e=>{let t=e.parentElement;for(;null!==t&&!pr(t);)t=t.parentElement;if(null===t)return null;let n=l.get(t);if(void 0===n){let e=i(t),r=t.querySelector(`:scope > ${le.tagNames.state}[bind-component]`).getAttribute("bind-component");l.set(t,n=[]);for(let l of ae(t.getAttribute(le.bindAttributeName)??"")){let t=l.Je;l.ve[0]===r&&n.push([e?xr(e,t,1,0):t,l.ve.slice(1).join("."),e&&t])}}return n},r=(e,t,n)=>{let l=i(e);if(null===l)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return n?t:xr(l,t,0,1)??t;let o=r[1].replace(/#m\d+\./g,"").slice(0,-1);return l.some(e=>""===e[1]&&(e[0]===o||e[2]===o))?r[2]:xr(l,r[2],2,1)??r[2]};for(let t of Sr(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let l=t.nextSibling;for(;null!==l&&!Hi(l,`@@wcs-${e[1]}-end:${e[2]}`);)l=l.nextSibling;if(null!==l){for(;t.nextSibling!==l;)t.nextSibling.remove();l.remove(),t.replaceWith(..."text"===e[1]?[Bi(`@@:${r(t,e[2],n)}`)]:[])}}let o=(e,n)=>{for(let l of Sr(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(l.data)?.[1],i=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===i)continue;let s=document.importNode(i,!0),a=le.bindAttributeName;s.removeAttribute("id"),s.setAttribute(a,s.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,i)=>t+r(n??l,i))),o(s.content,n??l);let u=s.content.firstChild;l.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?s.content.childNodes:[s])}};o(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(h,n,a):br(h,n,r),n.remove(),r&&(c.Ae=Cr,queueMicrotask(()=>{kr(),c.Ae=null}))}(t),e?.(t,n)},function(){let e=globalThis;e[fr]={build:cr,reset(){ar=0}},void 0===e[_i]&&(e[_i]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[fr].build(t),reset:()=>e[fr].reset()})}(),c.Eo=f(c.Eo,zi);for(let e of Zt())zi(e)}},Pr="__WCSTACK_DEVTOOLS_HOOK__",Er=null,Wr=new Set,Rr=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e._(n)}}),Ir=new WeakMap,Lr=0;var qr=new WeakMap;function Dr(e){if(null===Er)return;let t=qr.get(e),n=Wr.has(e)?function(e,t){let n=new Map,l=new Set,i=(l,i,r,o,s,a)=>{if(5===l)return;let u=function(e,t){return 0===e?"textContent":2===e?`class.${t}`:3===e?`attr.${t}`:4===e?`style.${t}`:t}(l,i),c=0===o.n?null:s,f=`${(e=>{let t=Ir.get(e);return void 0===t&&Ir.set(e,t=++Lr),t})(r)}|${u}|${o.t}|${null===c?"":e._(c).join(",")}`;if(n.has(f))return;let h=t?.get(f);n.set(f,h??{binding:{propName:u,statePathName:o.t,bindingType:a,node:r,replaceNode:r},absoluteAddress:Rr(e,o,c)})},r=e=>i(e.i,e.name,e.a,e.o,e.r,e.en()),o=e=>{if(!l.has(e)){if(l.add(e),null!==e.fe)for(let t of e.fe)r(t);if(e instanceof Ye&&null!==e.ae){let t=e.A.Ke;for(let n=0;n<t.length;n++){let l=e.W?.[n];void 0!==l?r(l):i(t[n].i,t[n].name,e.ae[2*n],t[n].o,e.r,0===t[n].i?"text":"prop")}}if(null!==e.h)for(let t of e.h)s(t)}},s=e=>{if(!l.has(e))if(l.add(e),e instanceof st){i(-1,"for",e.S,e.l.o,e.l.re,"for");for(let t of e.Ee)o(t)}else null!==e.O&&o(e.O)};for(let t of e.ie.values())for(let e of t)r(e),null!==e.M&&s(e.M);for(let t of e.ee.values())if(null!==t.$&&s(t.$),null!==t.L)for(let e of t.L)s(e);return n}(e,t):new Map;if(void 0!==t)for(let[e,l]of t)n.has(e)||Er({type:"state:binding-removed",...l});for(let[e,l]of n)(void 0===t||!t.has(e))&&Er({type:"state:binding-added",...l});qr.set(e,n)}function zr(e){let t=Rt.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function Ur(e){let t=new Set,n=new Set,l=new Set,i=new Set;for(let r of e.B.all()){for(let e=1;e<=r.n;e++)t.add(r.f[e].t);"*"===r.s&&n.add(r.t),null!==r.getter&&l.add(r.t),null!==r.oe&&i.add(r.t)}let r=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:i},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Ne.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==r.$watch&&"object"==typeof r.$watch?new Set(Object.keys(r.$watch)):null,keyedListPaths:null!==r.$listKeys&&"object"==typeof r.$listKeys?new Set(Object.keys(r.$listKeys)):null}}var _r=new WeakSet,Fr=new WeakMap;function Br(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(_r.has(t))return;_r.add(t);let l=t.emit;t.emit=(...i)=>(null!==Er&&Er({type:"state:token-emit",kind:n,tokenName:t.name,args:i,subscriberCount:t.size,stateElement:e.element}),l.apply(t,i))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Ne.values())t(n,"event")}(e),"connected"===t){if(Wr.has(e))return;Wr.add(e),Er?.({type:"state:element-registered",rootNode:e.root,element:e.element}),Dr(e)}else"disconnected"===t&&(Wr.delete(e),Dr(e),Er?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function Hr(e,t,n,l,i,r){if(null===Er)return;let o=Rr(e,t,0===t.n?null:n),s=Fr.get(e);void 0===s&&Fr.set(e,s=new Set),s.add(o),r&&Er({type:"state:write",absoluteAddress:o,value:i,oldValue:l,hasOldValue:!0})}function Kr(e){if(null===Er)return;let t=Fr.get(e);Fr.delete(e),void 0!==t&&Er({type:"state:update-batch",addresses:t}),Dr(e)}function Vr(e,t,n){Er?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.en(),error:t})}!function(e){for(let t of e)g.has(t.name)||(g.add(t.name),t.install())}([sn,Wn,rl,dl,wi,Ii,Tr,{name:"devtools",install(){c.element=f(c.element,Br),c.he=f(c.he,Hr),c.Te=f(c.Te,Kr),c.Ve=f(c.Ve,Vr),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let e=globalThis,t=e[Pr]??(e[Pr]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))for(let t of e.values())n(t)}}}}());2!==t.version&&console.warn(`[@wcstack/state] devtools hook registry version ${t.version}, expected 2: keeping the existing one.`),t.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:Li,getStateElements:()=>[...Wr].map(Ur),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.B.all()){let l=n.q,i=n.Fe?.length??0;if((null===l||0===l.size)&&0===i)continue;let r,o=0;if(null!==l)for(let e of l.values())o+=e.size;try{r=0===n.n?e.v(n,null):void 0}catch{r=void 0}t.push({path:n.t,tracked:!1,rows:o,keys:null===l?0:l.size,lists:i,lastValue:r})}return t}(zr(e)),keys(e){let t=zr(e).target;return Object.keys(t).filter(e=>{if(e.includes("*")||"$"===e[0])return!1;let n=Object.getOwnPropertyDescriptor(t,e);return void 0!==n.get||"function"!=typeof n.value})},read(e,t,n){let l;return zr(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){zr(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===Er&&null!==e;Er=e,null===e&&(qr=new WeakMap),c.nt=e&&((e,t)=>Er?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of Wr)Dr(e)})}})}()}}]),function(e=customElements){(function(){let e=globalThis;void 0===e[Dt]&&(e[Dt]={protocol:"wcs-binder",version:1,bind:Ft})})(),Zt().includes(e)||Qt.push(new WeakRef(e));let t=le.tagNames.state;void 0===e.get(t)&&e.define(t,class extends Yt{}),c.Eo?.(e)}();
|
|
1
|
+
var e=class{constructor(e,n,l){this.h=[],this.getter=null,this.oe=null,this.de=!1,this.G=[],this.$e=[],this.ut=null,this.F=-1,this.J=t,this.Fe=null,this.Tt=null,this.At=null,this.q=null,this.Ft=new Set,this.t=e,this.d=l,this.s=n;let i=null===l?[null]:l.f.slice(),r="*"===n;r&&i.push(l),this.n=i.length-1,this.U=r?[]:null===l?[n]:[...l.U,n],this.f=i}jn(e){this.Ft.has(e)||(this.Ft.add(e),this.G.push(e),e.$e.push(this))}Po(){this.getter=null,this.oe=null,this.F=-1,this.J=t,this.G.length=0,this.Ft.clear(),this.$e.length=0,this.ut=null,this.Fe=null,this.Tt=null,this.At=null,this.q=null}Q(e){let t=this;for(;null!==t;){if(t===e)return!0;t=t.d}return!1}},t=Symbol("unset"),n=Symbol("dirty"),l=Symbol("failed"),i=class{constructor(e=null){this.Ot=new Map,this.Ln=e}Ct(e){return this.Ot.get(e)}get(t){let n=this.Ot.get(t);if(void 0!==n)return n;let l=t.lastIndexOf("."),i=l<0?null:this.get(t.slice(0,l));return n=new e(t,t.slice(l+1),i),this.Ln?.(n),this.Ot.set(t,n),i&&i.h.push(n),n}all(){return this.Ot.values()}},r=new Map;function o(e){let t=r.get(e);if(void 0!==t)return t;let n=!0,l=e.split("."),i=[];for(let e=0;e<l.length;e++){let t=l[e],r=t.charCodeAt(0);e>0&&r>=48&&r<=57?(n=!1,i.push(Number(t)),l[e]="*"):"*"===t&&i.push(-1)}if(!n)return{o:l.join("."),indexes:i};let o={o:e,indexes:null};return r.set(e,o),o}var s=class{constructor(e,t,n){this.dt=null,this.$=null,this.fe=null,this.q=null,this.h=null,this.y=!0,this.l=e,this.b=t,this.T=n}},a=class{constructor(e,t){this.C=null,this.u=[],this.$=null,this.L=null,this.Z=!1,this.It=!1,this.ft=!1,this.o=e,this.re=t,this.n=e.n+1}},u=[],c={};function f(e,t){return null==e?t:(...n)=>{e(...n),t(...n)}}function h(e,t,n){return null==t?n:(...l)=>{let i=t(...l);return e(i)?i:n(...l)}}var d=e=>!0===e,p=e=>void 0!==e,m=e=>null!=e,g=new Set;function y(e){let t=e.$features;if(null!=c.Lt&&Array.isArray(t)){let e=t.filter(e=>!g.has(e));if(e.length>0)return c.Lt(e)}}function $(e,t){if(!g.has(e))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${t} needs the add-on @wcstack/state/features/${e}`)}function v(e,t,n){throw new Error(`[@wcstack/state] ${e}${c.Ao?.(e,t,n)??""}`)}function b(e,t=[]){return c.Fo?.(e,t)??`#${e}${t.map(e=>` ${"string"==typeof e?JSON.stringify(e):String(e)}`).join("")}`}function w(e,t,n,l){v(b(e,t),n,l)}var k=class{constructor(e){this.pt=new Set,this.name=e}get size(){return this.pt.size}subscribe(e){return this.pt.add(e),()=>{this.pt.delete(e)}}unsubscribe(e){return this.pt.delete(e)}emit(...e){let t=[];for(let n of this.pt)try{t.push(n(...e))}catch(e){t.push(void 0),console.error(`[@wcstack/state] ${b(17,[this.name])}`,e)}return t}};function S(e,t,n){if(void 0===e)return[];Array.isArray(e)||w(18,[t]);let l=new Set;for(let i of e)("string"!=typeof i||""===i)&&w(19,[t]),i===n&&w(20,[t,i,n]),l.has(i)&&w(21,[t,i]),l.add(i);return e}var x=Symbol.for("wcstack.transition-runner");function A(e){let t=globalThis[x];return null==t||"wcs-transition-runner"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.run||"function"!=typeof t.accepts||!t.accepts(e)?null:t}function N(e,t,n){let l=A(e);if(null!==l)return l.run(t,{source:e,types:n});t()}var j="else",O="eventToken",C=/^\$[1-9]\d{0,2}$/,M=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function T(e){let t=[],n=[],l="",i=null,r=!1,o=-1,s=-1,a=e=>{let i=function(e,t,n){let l=-1===t?e.length:t,i=-1===n?0:n;return e.slice(l-e.slice(0,l).trimStart().length,i+e.slice(i).trimEnd().length)}(l,o,s);(!e||i||r)&&(t.push(i),n.push(function(e,t){return t?e:"true"===e||"false"!==e&&("null"===e?null:M.test(e)?Number(e):e)}(i,r))),l="",r=!1,o=-1,s=-1};for(let t=0;t<e.length;t++){let n=e[t];i?n===i?i=null:(-1===o&&(o=l.length),l+=n,s=l.length):'"'===n||"'"===n?(i=n,r=!0):","===n?a():l+=n}return null!==i&&w(107,[i,e]),a(!0),{args:t,literals:n}}var P=e=>e.trim();function E(e,t){let n=[],l=null;for(let i=0;i<e.length;i++){let r=e[i];null!==l?r===l&&(l=null):"'"===r||'"'===r?l=r:r===t&&n.push(i)}return n}var W=(e,t)=>E(e,t)[0]??-1;function I(e,t){let n=[],l=0;for(let i of E(e,t))n.push(e.slice(l,i)),l=i+1;return n.push(e.slice(l)),n}function R(e,t,n){let l=W(e,"|");if(-1===l)return[e.trim(),[]];let i=e.slice(l+1).trim(),r=n.get(i);return void 0===r&&(r=function(e,t,n){let l=n??e.join("|");return e.map(e=>{let n=W(e,"("),i=(e=>E(e,")").pop()??-1)(e);if(-1===i&&(i=e.lastIndexOf(")")),-1!==n&&-1===i&&w(108,[e]),-1!==i&&-1===n&&w(109,[e]),-1!==i&&i<n&&w(110,[e]),-1!==i&&e.slice(i+1).trim().length>0){let t=e.slice(i+1).trim();w(111,[e,t])}let r=(-1===n?e:e.substring(0,n)).trim();if(0===r.length&&w(112,[l]),r.includes("#")){let[,e]=r.split("#");w("input"===t?113:114,[r,e])}return-1===n?{Bn:r,args:[],literals:[]}:{Bn:r,...T(e.substring(n+1,i))}})}(I(i,"|").map(P),t,e),n.set(i,r)),[e.slice(0,l).trim(),r]}var L=new Map;function q(e){w(1101,[e])}function D(e){let[t,n]=R(e,"output",L);t.includes("@")&&w(32,[t]);let l=t,i=l.startsWith("."),r=i?l.slice(1):l;return(r.length>0&&r.split(".").some(e=>0===e.length)||!i&&0===r.length)&&w(119,[e]),function(e){e.includes("**")&&q(e);let t=e.split(".").length;t>512&&w(117,[e,t])}(l),{Je:l,Qe:n}}var z=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],U=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function F(e){return e.includes("**")&&q(e),e}var _=0;function B(e,t,n){let l=e.get(t);return void 0===l&&e.set(t,l=n()),l}var H=()=>new Set,K=()=>[];function V(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}function J(e,t){return e===t||e!=e&&t!=t}function X(e,t,n){let l=e.q?.get(t);void 0!==l&&l.delete(n)&&0===l.size&&e.q.delete(t)}function G(e,t){for(let n=0;n<t.length;n++){if(null==e)return;e=e[t[n]]}return e}function Y(e,t){for(;null!==e&&e.l.n>t;)e=e.l.re;return null!==e&&e.l.n===t?e:null}function Q(e,t,n){let l=Y(e,n);return null!==l&&l.l.o===t.f[n]?l:null}var Z=class{constructor(e,t){this.Oe=0,this.c=null,this.Ce=0,this.mt=new Set,this.Ze=new Map,this.Dn=Symbol("wcs.block"),this.element=null,this.ht=[],this.Ie=null,this.Mn=[],this._t=0,this.K=null,this.ee=new Map,this.ie=new Map,this.je=[],this.Le=[],this.Be=[],this.yt=!1,this.dn=!1,this.Wt=new WeakMap,this.M=0,this.Ht=0,this.fn=!1,this.Vt=!1,this.Ut=!1,this.xe=0,this._n=()=>{this.M=0,this.fn=!1},this.Wn=()=>{this.xe--},this.rp=null,this.rr=null,this.Oo=()=>this.qt(),this.Co=(e,t)=>e(this.proxy,...t),this.Hn=[],this.Io={$untracked:e=>{let t=this.K;if(null===t)return e();t.pe++;try{return e()}finally{t.pe--}},$eqIndex:(e,t=1)=>{let n=Y(this.c,t);null===n&&w(7,[e]);let l=this.o(e);if(null!==l.getter||l.de)return this.watchIndex(t),n.b===this.read(l,null);let i=this.K;if(null!==i){let e=i.getter,n=l.Fe??(l.Fe=[]);if(!n.some(n=>n.getter===e&&n.Vn===t)){n.push({getter:e,Vn:t});let i=e.f[t];(i.Tt??(i.Tt=[])).push({source:l,getter:e})}}return n.b===this.v(l,null)},$eq:(e,t)=>this.eq(e,t),$eqPath:(e,t)=>{let n=this.o(t);return this.eq(e,this.v(n,Y(this.c,n.n)))},$dependOn:e=>{this.resolve(F(e),this.c),null!==this.K&&0===this.K.pe&&this.Un(this.rp,this.rr,this.K)},$getAll:(e,t)=>this.getAll(e,t),$setAll:(e,t,n,l)=>this.pn(e,t,n,l),$resolve:(...e)=>{let t=F(e[0]),n=e[1]??[],l=this.o(t);this.mn("$resolve",t,l,n,!0);let i=this.qn(l,n,null);if(e.length<3)return this.read(l,i);this.P(l,i,e[2])},$postUpdate:e=>{this.resolve(F(e),this.c);let t=this.rp,n=this.rr;"*"===t.s&&null!==n&&(n.T=n.l.C[n.b],this.R.Kt(n)),this.hn(t,n),null!==n&&this.Kn(n,t,void 0,n.T,!1),0===t.n&&this.zn(t,void 0,void 0,!0),this.zt(t,n,void 0,void 0,!1)}},this.R=t,this.B=new i(e=>this.et(e)),this.Xn(e);let n=this,l={getOwnPropertyDescriptor(e,t){let l=Reflect.getOwnPropertyDescriptor(n.target,t);return l&&(l.configurable=!0),l},get(e,t,l){let i=n.target;if("symbol"==typeof t)return Reflect.get(i,t);if(36===t.charCodeAt(0))return n.tt(t);if(t.indexOf(".")<0){let e=n.B.Ct(t);if(void 0===e||null===e.getter){let e=i[t];if("function"==typeof e)return l===n.proxy&&n._?.(e)||e}if(void 0!==e&&0===e.n)return n.read(e,null)}return n.resolve(t,n.c),n.read(n.rp,n.rr)},set:(e,t,l)=>"symbol"==typeof t?Reflect.set(n.target,t,l):(n.resolve(F(t),n.c),n.P(n.rp,n.rr,l),!0)};for(let e of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])l[e]=(t,...l)=>Reflect[e](n.target,...l);this.proxy=new Proxy({},l)}o(e){return this.B.get(e)}Yn(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n)){if(t.has(e))continue;t.add(e);let l=Object.getOwnPropertyDescriptor(n,e);if(void 0===l.get&&void 0===l.set)continue;let i=this.o(e);i.getter=l.get??null,i.oe=l.set??null,null!==i.getter&&i.n>0&&(i.F=this.Oe++)}for(let e of this.B.all())this.et(e)}et(e){e.t.includes("**")&&q(e.t),("__proto__"===e.s||"prototype"===e.s)&&w(120,[e.t]);let t=e.d;e.de=null!==t&&"*"!==e.s&&t.n===e.n&&(null!==t.getter||t.de),null===e.getter&&this.jo(e)}jo(e){let t=e.t,n=e.s;if(C.test(n))e.getter=function(){return this[n]};else{let l=t.split("."),i=l.findIndex((e,t)=>t>0&&e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57);if(i<0||l.indexOf("*",i)>=0)return;e.getter=()=>(this.resolve(t,this.c),this.rp!==e?this.read(this.rp,this.rr):this.read(e.d,this.c)?.[n]),e.oe=l=>{if(this.resolve(t,this.c),this.rp!==e)return this.P(this.rp,this.rr,l);let i=this.read(e.d,this.c);null==i&&w(4,[t,i]),i[n]=l}}e.n>0&&(e.F=this.Oe++)}De(e,t){let n=null===e?this.ee:e.h??=new Map,l=n.get(t);return void 0===l&&n.set(t,l=new a(t,e)),this.z(l),l}Gn(e){try{this.z(e)}catch(t){this.Xt(t,e.o.t,e.$?.S??null,"for")}}z(e){let t=this.v(e.o,e.re);if(t===e.C)return;this.Jn(e);let n=function(e,t,n){let l=Array.isArray(t)?t:u;if(l===e.C)return null;let i=e.u,r=l.length,o=i.length,a=new Array(r),c=0;for(;c<r&&c<o&&i[c].T===l[c];)a[c]=i[c],c++;let f=o-1,h=r-1;for(;f>=c&&h>=c&&i[f].T===l[h];)a[h]=i[f],f--,h--;if(c>f)for(let t=c;t<=h;t++)a[t]=new s(e,t,l[t]);else if(c>h)for(let e=c;e<=f;e++)n.jt(i[e]);else{let t=new Map;for(let e=c;e<=f;e++){let n=i[e],l=t.get(n.T);void 0===l?t.set(n.T,n):Array.isArray(l)?l.push(n):t.set(n.T,[l,n])}for(let n=c;n<=h;n++){let i,r=l[n],o=t.get(r);void 0!==o&&(Array.isArray(o)?(i=o.shift(),0===o.length&&t.delete(r)):(i=o,t.delete(r))),a[n]=i??new s(e,n,r)}for(let e of t.values())if(Array.isArray(e))for(let t of e)n.jt(t);else n.jt(e)}for(let e=c;e<r;e++){let t=a[e];t.b!==e&&(t.b=e,n.To(t))}return e.u=a,e.C=l,i}(e,t,this);if(null===n)return;if(e.C===t){let n=B(this.Wt,t,K);if(n.push(e),n.length>1)for(let e of n)e.ft=!0}c.Yt?.(this,e,n),(null!==e.$||null!==e.L)&&!e.Z&&(e.Z=!0,this.Le.push(e),this.Re());let l=e.o.Tt;if(null!==l)for(let{source:t,getter:i}of l){let l=this.v(t,null),r=n[l],o=e.u[l];r!==o&&(void 0!==r&&r.y&&this.gn(i,r),void 0!==o&&this.gn(i,o))}}To(e){this.R.Lo(this,e)}jt(e){e.y=!1;let t=e.q;if(null!==t){for(let e of t)X(e.source,e.key,e.sub);e.q=null}if(null!==e.h)for(let t of e.h.values()){this.Jn(t);for(let e of t.u)this.jt(e)}}Jn(e){let t=this.Wt.get(e.C);void 0!==t&&(t.splice(t.indexOf(e)>>>0,1),e.ft=!1,1===t.length&&(t[0].ft=!1))}resolve(e,t){let n=o(e),l=this.rp=this.o(n.o),i=n.indexes;this.rr=0===l.n?null:null===i?Q(t,l,l.n):this.qn(l,i,t,e)}qn(e,t,n,l){let i=null;for(let r,o=1,s=0;o<=e.n;o++){let a=e.f[o],c=this.De(i,a),f=t[s++];if(f<0)f=Q(n,e,o)?.b??-1;else if(l&&c.C===u&&Object(r=this.v(a,i))===r){let t=e.t.split("."),n=a.t.split(".").length;t[n]=l.split(".")[n],e=this.o(t.join(".")),o--;continue}if(i=c.u[f]??null,null===i)break}return this.rp=e,i}wt(e,t){return 0===e.n?G(this.target,e.U):null===t?void 0:G(t.T,e.U)}read(e,t){let n=this.K;if(null!==n&&0===n.pe&&this.Un(e,t,n),null!==e.getter)return this.R.Bo(this,e,t);if(e.de){let n=this.read(e.d,t);return n?.[e.s]}return null===e.d&&!(e.s in this.target)&&!this.mt.has(e.s)&&"then"!==e.s&&"toJSON"!==e.s&&w(301,[e.t],e.s,Object.keys(this.target)),this.wt(e,t)}v(e,t){let n=this.K;if(null===n)return this.read(e,t);n.pe++;try{return this.read(e,t)}finally{n.pe--}}Un(e,t,n){let l=n.getter;e.jn(l),e.n>0&&l.n>0&&Y(t,Math.min(e.n,l.n))!==Y(n.r,Math.min(e.n,l.n))&&(l.ut??(l.ut=new Set)).add(e)}Do(e,t){for(let n=0;n<this._t;n++){let l=this.Mn[n];l.getter===e&&l.r===t&&w(701,[e.t])}this._t>=128&&w(801,[e.t]);let n=this._t++;this.Ce++;let l=this.Mn[n]??={getter:e,r:t,pe:0,Me:0};l.getter=e,l.r=t,l.pe=0,l.Me=++_;let i=this.K;this.K=l;let r=this.c;this.c=t;try{return e.getter.call(this.proxy)}finally{this.Ce--,this._t--,this.K=i,this.c=r,l.r=null}}watchIndex(e){let t=this.K;if(null!==t&&0===t.pe){let n=t.getter,l=n.f[e];if(l){let e=l.At??(l.At=[]);e.includes(n)||e.push(n)}}}tt(e){let t=e.charCodeAt(1);if(t>=48&&t<=57){let n=2===e.length?t-48:C.test(e)?+e.slice(1):0;return(n<1||n>128)&&w(1001,[e]),this.watchIndex(n),Y(this.c,n)?.b}let n=this.Io[e];if(void 0!==n)return n;switch(e){case"$stateElement":return this.element;case"$command":return this.commands}return c.tt?.(this,e)}eq(e,t){this.resolve(e,this.c);let n=this.rp,l=this.rr;if(null!==n.getter||n.de||n.n>0)return J(this.read(n,l),t);let i=this.K;return null!==i&&0===i.pe&&this.Mo(n,t,i),J(this.v(n,null),t)}Mo(e,t,n){let l=n.getter,i=n.r,r=null===i?this.Hn:i.q??(i.q=[]);for(let i=0;i<r.length;i++){let o=r[i];if(o.sub.getter===l&&o.source===e){if(J(o.key,t))return void(o.Me=n.Me);o.Me!==n.Me&&(X(e,o.key,o.sub),r.splice(i--,1))}}let o={getter:l,r:i};B(e.q??=new Map,t,H).add(o),r.push({source:e,key:t,sub:o,Me:n.Me})}zn(e,t,n,l){this.Gt(e,i=>{let r=i.q;if(null===r&&null===i.Fe)return;let o=i===e?[]:i.t.slice(e.t.length+1).split("."),s=G(t,o),a=G(n,o);if(null!==i.Fe&&this._o(i,s,a,l),null!==r)for(let e of l?r.keys():[s,a]){let t=r.get(e);if(void 0!==t)for(let n of t)null===n.r||n.r.y?this.R.me(this,n.getter,n.r):X(i,e,n)}})}P(e,t,n,l=!1,i=!1){if(this.Ce>0&&w(8),i||this.xe>0?this.Vt=!0:this.Ut=!0,c.Pe?.(this,e,t,n,i))return;if(null!==e.oe){try{this.yn(e.oe,t,[n])}finally{this.zt(e,t,void 0,void 0,!1)}return}null!==e.getter&&w(2,[e.t]),e.n>0&&null===t&&w(3,[e.t]);let r=e.de?this.v(e,t):this.wt(e,t);if(l||!this.Dt||!Object.is(r,n)||Object(n)===n){if("*"===e.s){let e=t;e.l.C[e.b]=n,e.T=n,this.R.Kt(e)}else{let l=1===e.U.length?0===e.n?this.target:t.T:this.v(e.d,t);null==l&&w(4,[e.t,l]),l[e.s]=n}this.wn(e,t),null!==t&&this.Kn(t,e,r,n),0===e.n&&this.zn(e,r,n),this.zt(e,t,r,n,!0)}}Qn(e){return(this.Wt.get(e.C)??[]).filter(t=>t.C===e.C&&(null===t.re||t.re.y))}Kn(e,t,l,i,r=!0){let o=e.l;if(!o.ft&&null===o.o.getter&&!o.o.G.length)return;let s=e.T,a=t.t.slice(o.o.t.length+2),u=(t,n)=>{if(void 0===n||n===e)return;let o=this.o(`${t.o.t}.*${a}`);""===a&&(n.T=i,this.R.Kt(n)),r?this.wn(o,n):this.hn(o,n),this.zt(o,n,l,i,r)};for(let t of this.Qn(o))u(t,t.u[e.b]);if(""===a)return;let c=new Set([o.C]),f=e=>Array.isArray(e)&&e.includes(s),h=(e,t)=>{if(!c.has(e)&&c.add(e))for(let t of this.Wt.get(e)??[])for(let e of t.u)e.T===s&&u(t,e);for(let l of t){let t=l.J,i=t===n;i&&(t=this.ee.get(l)?.C),(i||f(t))&&!c.has(l.G)&&c.add(l.G)&&(!i&&t!==e&&this.R.me(this,l,null),h(t,l.G))}},d=e=>{for(let t of e.$e)if(!c.has(t)&&c.add(t))if(null!==t.getter)d(t);else if(!t.de){let e=this.wt(t,null);f(e)&&h(e,t.G)}};null!==o.o.getter?d(o.o):h(o.C,o.o.G)}hn(e,t){this.Wo(e,t,e=>{this.z(e);for(let t of e.ft?this.Qn(e):[e]){let e=this.o(`${t.o.t}.*`);for(let n of t.u)this.bt(e,n),this.hn(e,n)}})}wn(e,t){let n=null===t?this.ee:t.h;if(null!==n)for(let t of n.values())t.o.Q(e)&&this.z(t)}Wo(e,t,n){let l=null===t?this.ee:t.h;if(null!==l)for(let t of l.values())t.o.Q(e)&&n(t)}_o(e,t,n,l){for(let{getter:i,Vn:r}of e.Fe)this.Zn(i.f[r],e=>{for(let r of l?e.u.keys():[t,n]){let t="number"==typeof r?e.u[r]:void 0;void 0!==t&&this.gn(i,t)}})}gn(e,t){t.l.n===e.n?this.R.me(this,e,t):this.Jt(t,e,t=>this.R.me(this,e,t))}zt(e,t,n,l,i){c.he?.(this,e,t,n,l,i),this._e(e,t)}_e(e,t){this.R.Ho(this,e,t),this.Re()}eo(e){let t=this.Ze.get(e);if(void 0!==t)return t;let n=Symbol(`wcs.on${e}`);this.Ze.set(e,n);let l=this.root,i=this.Dn;return l.addEventListener(e,t=>{for(let r=t.target;null!==r&&r!==l;r=r.parentNode){let l=r[n];if(void 0!==l&&(l(t),t.cancelBubble))return;let o=r[i];if(void 0!==o&&o.y&&o.Vo(e,t))return}}),n}reset(e){let t=this.target,n=this.mt;for(let e of this.B.all())null===e.d&&null!==e.getter&&n.add(e.s);this.Xn(e);for(let e in t)"$"!==e[0]&&n.add(e);for(let t of n)t in e&&n.delete(t);for(let e of this.ie.values())for(let t of e)this.Qt(t);for(let e of this.ee.values())this.to(e);this.Ie=null;try{this.qt()}finally{this.bn()}c.element?.(this,"reset")}Xn(e){for(let[t,n]of z)void 0!==e[t]&&$(n,t);let t=e.$features;if(void 0!==t){Array.isArray(t)||w(46);for(let e of t)$(e,"$features")}let n=void 0===e.$behavior?{}:e.$behavior;("object"!=typeof n||!n||Array.isArray(n))&&w(44,["state","$behavior"]);for(let e in n)(!U.includes(e)||"boolean"!=typeof n[e])&&w(44,["$behavior",e]);let[l,i,r]=U.map(e=>n[e]??!0);void 0!==this.target&&(l!==this.Bt||i!==this.Dt||r!==this.Mt)&&w(45);let o=function(e,t){let n={};for(let l of S(e.$commandTokens,"$commandTokens","$command"))n[l]=t?.[l]??new k(l);return Object.freeze(n)}(e,this.commands),s=function(e,t){let n=new Map;for(let t of S(e.$eventTokens,"$eventTokens"))n.set(t,new k(t));let l=e.$on;if(void 0===l)return n;(null===l||"object"!=typeof l)&&w(22);for(let[e,i]of Object.entries(l)){let l=n.get(e);void 0===l&&w(23,[e]),"function"!=typeof i&&w(24,[e]),l.subscribe((...e)=>t(i,e))}return n}(e,this.Co);this.Bt=l,this.Dt=i,this.Mt=r,c.se?.(this,e),this.target=e,this.Oe=0;for(let e of this.B.all())e.Po();this.Hn.length=0,this.Yn(e),this.commands=o,this.Ne=s}to(e){this.Gn(e);let t=this.o(`${e.o.t}.*`);for(let n of e.u)if(n.dt=null,n.q=null,this.bt(t,n),null!==n.h)for(let e of n.h.values())this.to(e)}W(e){let t=[];for(let n=e;null!==n;n=n.l.re)t.unshift(n.b);return t}Uo(e,t,n){let l=this.Ne.get(e);void 0===l&&w(1301,[e],e,this.Ne.keys()),l.emit(t,...this.W(n))}command(e){let t=this.commands[e];return void 0===t&&w(1302,[e],e,Object.keys(this.commands)),t}qo(e,t,n){this.command(e).emit(t,...this.W(n))}Ko(e,t,n){let l=e.includes(".")?this.v(this.o(e),null):this.target[e];return"function"!=typeof l&&w(5,[e]),this.yn(l,n,[t,...this.W(n)])}yn(e,t,n){let l=this.c;this.c=t;try{return e.apply(this.proxy,n)}finally{this.c=l}}bt(e,t){if(null!==e.getter){let n=null===t?this.ee:t.h;if(null!==n)for(let t of n.values())!t.It&&t.o.Q(e)&&(t.It=!0,this.Be.push(t))}if(null===t)return void this.Gt(e,e=>{let t=this.ie.get(e);if(void 0!==t)for(let e of t)this.Qt(e)});let n=t.fe;if(null!==n)for(let t=0;t<n.length;t++)n[t].o.Q(e)&&this.Qt(n[t]);let l=t.$;null!==l&&null!==l.ae&&l.no(this,e);let i=t.l.L;if(null!==i)for(let n of i){let l=n.map.get(t);void 0!==l&&null!==l.ae&&l.no(this,e)}}vn(e,t,n){this.Gt(e,e=>{let l=e.G;for(let i=0;i<l.length;i++){let r=l[i];if(0===r.n)this.nt(r,null,n);else if(null===t||0===e.n||r.f[1]!==e.f[1]||null!==r.ut&&r.ut.has(e))this.Zt(r.f[r.n],e=>this.nt(r,e,n));else if(r.n<=e.n){let e=Y(t,r.n);null!==e&&this.nt(r,e,n)}else this.Jt(t,r,e=>this.nt(r,e,n))}})}nt(e,t,n){n(e,t)&&(c.ye?.(this,e,t),this.bt(e,t),this.vn(e,t,n))}Gt(e,t){t(e);let n=e.h;for(let e=0;e<n.length;e++)this.Gt(n[e],t)}Zt(e,t){this.Zn(e,e=>{for(let n of e.u)t(n)})}Zn(e,t){if(0===e.n){let n=this.ee.get(e);return void(void 0!==n&&t(n))}this.Zt(e.f[e.n],n=>{let l=n.h?.get(e);void 0!==l&&t(l)})}Jt(e,t,n){if(e.l.n===t.n)return n(e);let l=e.h?.get(t.f[e.l.n+1]);if(void 0!==l)for(let e of l.u)this.Jt(e,t,n)}zo(e){let t=e.r;null===t?B(this.ie,e.o,H).add(e):(t.fe??(t.fe=[])).push(e)}kn(e){let t=e.r;if(null===t)return void this.ie.get(e.o)?.delete(e);let n=t.fe;t.y&&null!==n&&n.splice(n.indexOf(e)>>>0,1)}Qt(e){e.Z||(e.Z=!0,this.je.push(e),this.Re())}Re(){this.yt||(this.yt=!0,queueMicrotask(this.Oo))}Sn(){for(let e of this.je)e.Z=!1;for(let e of this.Le)e.Z=!1;for(let e of this.Be)e.It=!1;this.je=[],this.Le=[],this.Be=[],this.R.mt(this)}oo(e,t){let n=[...new Set([...this.je,...this.Le,...this.Be].map(e=>e.o.t))];console.error(`[@wcstack/state] ${b(e)}`,n),c.ot?.(this,{type:"state:render-chain-limit",maxDepth:t,paths:n}),this.Sn()}qt(){this.yt=!1;let e=this.Ht;this.Ht=0;let t=0;if(!this.Vt||this.Ut?this._n():e>0?t=e:1===(t=++this.M)&&setTimeout(this._n,0),this.Vt=this.Ut=!1,t>100)101===t?this.oo(41,100):this.Sn();else{this.dn=!0;try{for(let e=0;this.je.length>0||this.Le.length>0||this.Be.length>0;e++){if(e>=32){this.fn?this.Sn():this.oo(11,32),this.fn=!0;break}let n=this.Be;if(n.length>0){this.Be=[];for(let e of n)e.It=!1,this.Gn(e)}let l=this.Le,i=this.je;this.Le=[],this.je=[];let r=N("state",()=>{for(let e of l){e.Z=!1;for(let t of[e.$,...e.L??[]])if(null!==t&&t.y)try{t.vt()}catch(n){this.Xt(n,e.o.t,t.S,"for")}}for(let e=0;e<i.length;e++){let t=i[e];t.Z&&(t.Z=!1,(null===t.En||t.En.y)&&this.We(t))}this.dn||(this.He(),this.yt&&(this.Ht=t+1))});void 0!==r&&r.then(void 0,e=>console.error(e))}}finally{this.dn=!1}this.Vt=this.Ut=!1,this.He(),c.Te?.(this),e>0&&this.yt&&(this.Ht=t+1)}}kt(e,t){this.ht.push([e,t])}Xt(e,t,n,l){this.kt(e,{o:{t},a:n,en:()=>l})}We(e){try{e.apply()}catch(t){return void this.ht.push([t,e])}null!==this.Ie&&this.io(e.o,e.r)}io(e,t){let n=B(this.Ie,e.t,K);null!==t&&n.push(this.W(t))}bn(){this.Ie="function"==typeof this.target.$renderedCallback?new Map:null}He(){let e=this.Ie;if(null!==e&&e.size>0){this.Ie=new Map;let t,n=[...e.keys()],l={};for(let[t,n]of e)n.length>0&&(l[t]=n);this.xe++;try{t=this.we("$renderedCallback",[n,l])}catch(e){console.error(e)}V(t)?t.then(this.Wn,e=>{this.Wn(),console.error(e)}):this.xe--}if(0===this.ht.length)return;let t=this.ht;this.ht=[];let n=this.target.$errorCallback;for(let[e,l]of t){c.Ve?.(this,e,l);let t=l.o.t,i=l.en();if("function"==typeof n)try{let n=this.we("$errorCallback",[e,{path:t,bindingType:i,node:l.a}]);V(n)&&n.then(void 0,e=>console.error(e))}catch(e){console.error(e)}else console.error(`[@wcstack/state] ${b(12,[i,t])}`,e)}}we(e,t=[]){let n=this.target[e];return"function"==typeof n?this.yn(n,null,t):void 0}so(e,t,n){if(0===e.n)return void n(null,[]);let l=[],i=(r,o)=>{let s=e.f[r];this.read(s,o);let a=this.De(o,s),u=t=>{l.push(t.b),r===e.n?n(t,l):i(r+1,t),l.pop()};for(let e of r-1<t.length?[a.u[t[r-1]]]:a.u)void 0!==e&&u(e)};i(1,null)}getAll(e,t){let n=this.o(e);void 0!==t&&this.mn("$getAll",e,n,t,!1);let l=t;if(void 0===l){l=[];let t=this.c;if(null!==t&&n.n>0){for(let e=1;e<=n.n;e++){let i=Q(t,n,e);if(null===i)break;l.push(i.b)}0===l.length&&w(6,[e])}}let i=[];return this.so(n,l,e=>i.push(this.read(n,e))),i}pn(e,t,n,l){Array.isArray(t)||w(9,[e]),this.Ce>0&&w(8);let i=this.o(e);this.mn("$setAll",e,i,t,!1);let r=[];this.so(i,t,(e,t)=>r.push([e,t.slice()]));let o=!0===l?.spread;o&&(!Array.isArray(n)||n.length!==r.length)&&w(10,[e,r.length]);let s=0;for(let e=0;e<r.length;e++){let[t,l]=r[e],a="function"==typeof n?n(this.v(i,t),...l):o?n[e]:n;void 0!==a&&(this.P(i,t,a),s++)}return s}mn(e,t,n,l,i){let r=l.length;(r>n.n||i&&r<n.n)&&w(i?901:902,[e,t,n.n,r])}},ee={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1},te=new Map,ne=new Set(["if","elseif","else","for"]),le=new Set([j,"if","elseif","for","..."]),ie=new Set(["class","attr","style","command",O,"state"]);function re(e){let t=function(e){return I(e,";")}(e).map(P).filter(e=>e.length>0).map(e=>{let t=W(e,":");-1===t&&w(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if(le.has(i)){let t;return i!==n&&w(102,[e,i]),i===j?(l.length>0&&w(103,[e]),t={Je:"#else",Qe:[]}):"..."===i?(0===l.length&&w(104,[e]),t=D(l),t.Qe.length>0&&w(105,[e])):(t=D(l),"for"===i&&t.Qe.length>0&&w(121,[e])),{be:i,ve:[i],tn:[],I:[],...t,w:"..."===i?"spread":i}}let r=D(l),o=function(e){let[t,n]=R(e,"input",te),l=t.split("#").map(P);l.length>2&&w(115,[t]);let[i,r]=l,o=i.split(".").map(P);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&w(116,[e]),{be:i,ve:o,tn:r?r.split(",").map(P):[],I:n}}(n),[s]=o.ve;if(""===s&&o.ve.length>1){let e=o.ve.slice(1);return(e.includes("")||ie.has(e[0]))&&w(106,[n]),{...o,be:e.join("."),ve:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===O||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>ne.has(e.w))&&w(201,[e]),t}var oe=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],se=new Map,ae=new Map;function ue(e){for(let t of Object.keys(e))se.set(t,{...e[t]});ae.clear()}function ce(e){return se.has(e)}function fe(e){w(26,[e])}function he(e){w(27,[e])}function de(e){w(28,[e])}function pe(e){w(29,[e])}function me(e){return!(!e||isNaN(Number(e)))}function ge(e,t){return me(e)||he(t),Number(e)}function ye(e,t,n){return ge(e?.[t]??fe(n),n)}function $e(e,t){return void 0!==t&&t.length>0?t[0]:e}var ve=(e,t)=>({factory:n=>{let l=ye(n,0,e);return n=>("number"!=typeof n&&de(e),t(n,l))},arity:[1,1]}),be={eq:{factory:(e,t)=>{let n=e?.[0]??fe("eq"),l=$e(n,t);return e=>"number"==typeof e?"string"!=typeof l?e===l:(me(n)||he("eq"),e===Number(n)):"string"==typeof e?e===n:e===l},arity:[1,1]},ne:{factory:(e,t)=>{let n=e?.[0]??fe("ne"),l=$e(n,t);return e=>"number"==typeof e?"string"!=typeof l?e!==l:(me(n)||he("ne"),e!==Number(n)):"string"==typeof e?e!==n:e!==l},arity:[1,1]},not:{factory:()=>e=>!e,arity:[0,0]},lt:ve("lt",(e,t)=>e<t),le:ve("le",(e,t)=>e<=t),gt:ve("gt",(e,t)=>e>t),ge:ve("ge",(e,t)=>e>=t),falsy:{factory:()=>e=>!e,arity:[0,0]},truthy:{factory:()=>e=>!!e,arity:[0,0]},boolean:{factory:()=>e=>!!e,arity:[0,0]}},we=!1;function ke(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function Se(e){return 0===e.length?null:(we||(we=!0,ue(be)),e.map(e=>function(e,t,n){let l=`${e}${function(e,t){return`${JSON.stringify(e)}${JSON.stringify(t)}`}(t,n)}`,i=ae.get(l);if(typeof i<"u")return i;let r=se.get(e);void 0===r&&function(e,t){oe.includes(e)&&v(`[wcs/filter-unknown] filter not found: ${e}. "${e}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,e,t),w(501,[e],e,t)}(e,se.keys());let[o,s]=r.arity;t.length<o&&w(601,[e,o,t.length]),t.length>s&&w(602,[e,s,t.length]);let a=r.factory(t,n);return ae.set(l,a),a}(e.Bn,e.args,e.literals)))}var xe=Symbol.for("wcstack.trustedTypes.policy");function Ae(){let e=globalThis[xe];return null!==e&&"object"==typeof e?e:null}function Ne(e){return"innerHTML"===e||"outerHTML"===e||"srcdoc"===e}function je(e){if(globalThis.trustedTypes?.isHTML(e))return e;let t=null==e?"":String(e),n=Ae(),l=n?.createHTML;return"function"==typeof l?l.call(n,t):t}var Oe=Symbol.for("wcstack.state.view-transition-naming"),Ce=new WeakSet;function Me(){let e=A("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var Te=new WeakMap,Pe=e=>e.customElementRegistry??customElements;function Ee(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=Pe(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>Ee(e,t,n,l,i,!0));let a=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(Te.has(e))return Te.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new Map,commands:new Set};for(let e of t.properties??[])n.properties.set(e.name,{event:e.event,getter:"function"==typeof e.getter?e.getter:null,lo:"event"===e.semantics});for(let e of t.inputs??[])n.inputs.set(e.name,{attribute:"string"==typeof e.attribute?e.attribute:null});for(let e of t.commands??[])null!==e&&"object"==typeof e&&"string"==typeof e.name&&n.commands.add(e.name)}return Te.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return a();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.St??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{a()}catch(l){De(e,l,t,n)}e.Re()})}function We(e,t,n,l,i=t.o,r,o,s){let a=s.properties.get(l)??null,u=s.inputs.get(l),f=e.Mt;f&&null===a&&void 0===u&&w(38,[l]);let h=t.H;(null===a?"element"===h||"auto"===h:void 0===u&&("state"===h||"auto"===h))&&w(39,[h,l]),"connect"===t.z&&null===a&&w(40,[l]);let d=f&&null!==a&&void 0===u,p=new Fe(e,Le,n,l,i,r,o,t.N,void 0);p.I=t.I,p.attribute=u?.attribute??null,Ge(e,p,!d),null!==a&&!t.ro&&n.addEventListener(a.event,t=>{let i;null!==a.getter?i=a.getter(t):(i=t.detail,a.lo||c.detail?.(n,l,i)),(!p.$n||!Object.is(i,p.value))&&(i=ke(p.I,i),null===p.N&&(p.value=i),e.P(p.o,p.r,i,a.lo,!0))});let m=h??(d?"element":"state");if("state"===m)d||e.We(p);else if("element"===m||"auto"===m){let i=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==e.v(p.o,p.r))return void(d||e.We(p));let t=n[l];null===p.N&&(p.value=t),e.P(p.o,p.r,t,!1,!0)};"connect"!==t.z||n.isConnected?i():Promise.resolve().then(i)}return p}function Ie(e,t,n){w(e,[t.localName,n])}var Re=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),Le=11,qe=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],De=(e,t,n,l)=>e.Xt(t,n.o?.t??n.Et,l,qe[n.i]),ze=Symbol();function Ue(e,t,n){let l=t.H;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.V:ze}var Fe=class{constructor(e,t,n,l,i,r,o,s,a,u=null){this.Z=!1,this.I=null,this.attribute=null,this.$n=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.En=o,this.N=s,this.value=a,this.M=u}en(){return qe[this.i]}apply(){if(null!==this.M)return void this.M.vt();let e=ke(this.N,this.engine.read(this.o,this.r));if(e===this.value&&("object"!=typeof e||null===e||this.i===Le||8===this.i||Ne(this.name)))return;if(this.value===ze)return void(this.value=e);let t=this.a;if(this.i!==Le)9===this.i?t.checked=void 0!==e&&this.nn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.nn()):Be(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.$n=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.$n=!1}null!==this.attribute&&function(e,t,n){try{if(null==n)e.removeAttribute(t);else{let l=n;if("object"==typeof n)try{l=JSON.stringify(n)}catch{}e.setAttribute(t,String(l))}}catch{}}(t,this.attribute,e)}}nn(){return ke(this.I,this.a.value)}Xo(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.nn()}else if(10===this.i){let l=this.nn(),i=n.v(this.o,this.r),r=Array.isArray(i)?i:[],o=r.includes(l);if(t.checked?o:!o)return;e=o?r.filter(e=>e!==l):[...r,l]}else e=ke(this.I,t[this.name]);n.P(this.o,this.r,e,!1,!0)}},_e=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Be(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(_e(n)?t[n]="innerHTML"===n?je(l):null==l?"":String(l):Ne(n)?null==l&&"srcdoc"===n?t.removeAttribute(n):void 0!==l&&(t[n]=je(l)):void 0!==l&&(t[n]!==l&&!("value"===n&&t.value===String(l))&&(t[n]=l),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[He]=[n,l])));case 8:return void(t.innerHTML=je(l));case 2:return null!=l&&"boolean"!=typeof l&&w(401,[n,typeof l]),void t.classList.toggle(n,!0===l);case 3:return void(null==l?t.removeAttribute(n):t.setAttribute(n,String(l)));case 4:return void(null==l?t.style.removeProperty(n):t.style.setProperty(n,String(l)))}}var He=Symbol();function Ke(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[He];void 0!==n&&(t[n[0]]=n[1])}var Ve=class{constructor(e,t,n,l){this.y=!0,this.fe=null,this.h=null,this.St=null,this.xn=null,this.r=e,this.Ue=t,this.j=n,this.A=l}Vo(e,t){let n=t.target,l=this.A,i=[],r=null;for(let t of l.Ne){if(t.name!==e)continue;let o=l.Rn[t.a],s=rt(null===this.j?this.Ue:this.j[o[0]],o,1);s.contains(n)&&(s!==r&&i.unshift([]),i[0].push(t),r=s)}for(let e of i){for(let n of e)n.Nn(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.j?this.Ue:this.j[this.j.length-1]}qe(){let e=this.xn;return(null===e?null:e.Pn(this.Ue))??this.Ue}insertBefore(e,t){let n=this.s;for(let l=this.qe();;){let i=l.nextSibling;if(e.insertBefore(l,t),l===n)return;l=i}}uo(){null===this.j?this.Ue.remove():ot(this.qe(),this.s)}Se(e){if(this.y=!1,null!==this.St)for(let e of this.St)e();let t=this.fe;if(null!==t)for(let n=0;n<t.length;n++)e.kn(t[n]);if(null!==this.h)for(let e of this.h)e.Se()}},Je=class extends Ve{constructor(e,t,n,l){super(e,t,n,l),this.fo=0,this._=null,this.ae=0===l.Ke.length?null:new Array(2*l.Ke.length)}po(e,t){let n=this._??=new Array(this.A.Ke.length),l=n[t];if(void 0===l){let i=this.A.Ke[t],r=this.ae;l=n[t]=new Fe(e,i.i,r[2*t],i.name,i.o,this.r,this,i.N,r[2*t+1])}return l}no(e,t){let n=this.A.Ke;for(let l=0;l<n.length;l++)n[l].o.Q(t)&&e.Qt(this.po(e,l))}Se(e){let t=this.r;t.$===this&&(t.$=null),super.Se(e)}};function Xe(e,t,n,l){let i=Y(n,t.n);try{return e.De(i,t)}catch(n){return e.Xt(n,t.t,l,"for"),null===i?e.ee.get(t):i.h.get(t)}}function Ge(e,t,n){n&&e.zo(t);let l=t.En;null!==l&&(l.fe??=[]).push(t)}var Ye=null;function Qe(){let e=Ye;return Ye=null,e}var Ze=-1;function et(e,t,n,l,i=null){let r,o=t.Rn,s=t.build,a=t.mo,u=null,f=c.Ae?.(t,null===l?i:l.S,null!==l),h=!f&&t.Tn,d=f?document.createDocumentFragment():(h?t.root:t.on).cloneNode(!0);if(!f)for(let e=0;e<s.length;e++){let t=s[e];a[t]=rt(d,o[t],h?1:0)}h?r=d:(u=f||[...d.childNodes],r=u[0]);let p,m=null;if(null!==l?(p=m=new Je(n,r,u,t),null===l.map?n.$=m:l.map.set(n,m)):p=new Ve(n,r,u,t),Ze>=0&&function(e,t,n,l){let i=null;if(null===t)i=1===e.nodeType?e:null;else for(let e=0;e<t.length&&null===i;e++)1===t[e].nodeType&&(i=t[e]);let r=i?.style;if(null===i||void 0===r||Ce.has(i))return;let o=globalThis[Oe]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${b(25,[l])}`)):(Ce.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,u,null!==l?"row":"branch",Ze),t.Ne.length>0){let t=e.Dn;if(null===u)r[t]=p;else for(let e of u)1===e.nodeType&&(e[t]=p)}let g=t.Yo,y=e.Ie,$=t.Go?a.slice(0,o.length):a,v=null===m?null:m.ae;if(null!==v){let e=t.Ke;for(let t=0;t<e.length;t++)v[2*t]=$[e[t].a],v[2*t+1]=e[t].V}for(let t=0;t<g.length;t++){let l=g[t],i=$[l.a],o=l.F;if(o>=0&&null!==v){let t=m._?.[o];if(void 0!==t){t.Z=!1,e.We(t);continue}try{let t=ke(l.N,e.read(l.o,n));t!==l.V&&(Be(l.i,i,l.name,t),v[2*o+1]=t),null!==y&&e.io(l.o,n)}catch(t){e.kt(t,m.po(e,o))}continue}switch(l.i){case 6:{let t=new it(e,l.A,Xe(e,l.o,n,i),i);(p.h??=[]).push(t),i===r&&(p.xn=t),t.vt();break}case 7:{let t=nt(e,l.X.map(e=>({A:e.A,o:e.o,N:e.N,S:$[e.a]})),n,p);(p.h??=[]).push(t),i===r&&(p.xn=t);break}default:try{tt(e,l,i,n,p)}catch(t){De(e,t,l,i)}}}return Ye=p,d}function tt(e,t,n,l,i){let r=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.Nn,o=e=>r(e,l);if(n.Ze){let l=e.eo(n.name),i=t[l];t[l]=void 0===i?o:e=>{i(e),o(e)},n.ke&&t.addEventListener(n.name,e=>e.bubbles||o(e))}else t.addEventListener(n.name,o),n.co&&null!==i&&(i.St??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,l,i);case 12:return void Ee(e,t,r,i,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.Et.slice(9));null===i&&Ie(1202,n,`command.${r}`),i.commands.has(r)||w(1203,[n.localName,r]);let s=new WeakRef(n),a=o.subscribe((...e)=>{let t=s.deref();if(void 0!==t)return t.isConnected?t[r](...e):void 0;a()});null!==l&&(l.St??=[]).push(a)}(e,t,r,i,n));case 13:return void Ee(e,t,r,i,n=>function(e,t,n,l,i){let r=t.name;null===i&&Ie(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&w(1204,[n.localName,r]);let s=t.Et;n.addEventListener(o.event,n=>{t.$t&&n.preventDefault(),t.Nt&&n.stopPropagation();try{e.Uo(s,n,l)}catch(e){console.error(e)}})}(e,t,r,l,n))}let o=t.o,s=Y(l,o.n);if(14===t.i)return void Ee(e,t,r,i,n=>function(e,t,n,l,i,r){null===r&&Ie(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs.keys()]);for(let s of o){if(t.ao?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),a=0===o.n?null:l;We(e,{...t,H:null,z:null},n,s,o,a,i,r)}}(e,t,r,s,i,n));if(t.ke&&1===t.i)return void Ee(e,t,r,i,n=>function(e,t,n,l,i,r){if(null!==r)return void We(e,t,n,t.name,t.o,l,i,r);let o=new Fe(e,1,n,t.name,t.o,l,i,t.N,Ue(e,t,l));o.I=t.I,!c.Jo?.(o,t.ro)&&(Ge(e,o,!0),e.We(o))}(e,t,r,s,i,n));let a=new Fe(e,t.i,n,t.name,o,s,i,t.N,Ue(e,t,s));a.I=t.I,Ge(e,a,!0),e.We(a),null!==t.xt&&n.addEventListener(t.xt,()=>a.Xo())}function nt(e,t,n,l){let i=new lt(e,t,n),r=null;for(let o of t){if(null===o.o)continue;let t=o.o,s=new Fe(e,7,o.S,"if",t,Y(n,t.n),l,null,void 0,i);Ge(e,s,!0),null===l&&i.ie.push(s),r??=s}return e.We(r),i}var lt=class{constructor(e,t,n){this.y=!0,this.O=null,this.b=-1,this.ie=[],this.engine=e,this.X=t,this.r=n}Pn(e){return null!==this.O&&this.X[this.b].S===e?this.O.qe():null}vt(){let e=this.engine,t=-1;for(let n=0;n<this.X.length;n++){let l=this.X[n];if(null===l.o||ke(l.N,e.read(l.o,Y(this.r,l.o.n)))){t=n;break}}if(t!==this.b&&(Ze=Me(),null!==this.O&&(this.O.uo(),this.O.Se(e),this.O=null),this.b=t,t>=0)){let n=this.X[t],l=et(e,n.A,this.r,null,n.S);this.O=Qe();let i=n.S.parentNode;i.insertBefore(l,n.S),Ke(i)}}Se(){this.y=!1;for(let e of this.ie)this.engine.kn(e);null!==this.O&&this.O.Se(this.engine)}},it=class{constructor(e,t,n,l){this.y=!0,this.Ee=[],this.engine=e,this.A=t,this.l=n,this.S=l,null===n.$?(n.$=this,this.map=null):((n.L??=[]).push(this),this.map=new Map)}Pn(e){return 0===this.Ee.length?null:this.Ee[0].qe()}Rt(e){return null===this.map?e.$:this.map.get(e)??null}ho(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.Se(this.engine)}vt(){let e=this.engine,t=this.l.u,n=this.Ee;Ze=Me();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){ot(n[0].qe(),n[i-1].s);for(let e=0;e<i;e++)this.ho(n[e])}return void(this.Ee=[])}let s=new Array(l),a=0;for(;a<l&&a<i&&this.Rt(t[a])===n[a];)s[a]=n[a],a++;let u=i-1,c=l-1;for(;u>=a&&c>=a&&this.Rt(t[c])===n[u];)s[c]=n[u],u--,c--;for(let e=a;e<=u;e++){let t=n[e],l=t.r;l.y&&this.Rt(l)===t?t.fo=e:(t.uo(),this.ho(t))}if(a<=c){let n=c-a+1,u=new Int32Array(n),f=!1;if(i>0)for(let e=0;e<n;e++){let n=this.Rt(t[a+e]);null!==n&&n.y?(u[e]=n.fo,f=!0):u[e]=-1}let h=c+1<l?s[c+1].qe():r;if(f){let l=function(e){let t=e.length,n=new Uint8Array(t),l=new Int32Array(t).fill(-1),i=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let r=0,o=i.length;for(;r<o;){let n=r+o>>1;e[i[n]]<t?r=n+1:o=n}r>0&&(l[n]=i[r-1]),i[r]=n}let r=i.length>0?i[i.length-1]:-1;for(;r>=0;)n[r]=1,r=l[r];return n}(u),i=h;for(let r=n-1;r>=0;r--){let n=t[a+r],u=this.Rt(n);null!==u&&u.y?0===l[r]&&u.insertBefore(o,i):(o.insertBefore(et(e,this.A,n,this),i),u=Qe()),s[a+r]=u,i=u.qe()}}else{let n=document.createDocumentFragment();for(let l=a;l<=c;l++)n.appendChild(et(e,this.A,t[l],this)),s[l]=Qe();o.insertBefore(n,h)}}this.Ee=s,Ke(o)}Se(){this.y=!1;let e=this.l;if(e.$===this)e.$=null;else if(null!==e.L){let t=e.L.indexOf(this);t>=0&&e.L.splice(t,1),0===e.L.length&&(e.L=null)}for(let e of this.Ee)e.Se(this.engine);this.map?.clear()}};function rt(e,t,n){for(;n<t.length;n++){e=e.firstChild;for(let l=t[n];l>0;l--)e=e.nextSibling}return e}function ot(e,t){let n=document.createRange();n.setStartBefore(e),n.setEndAfter(t),n.deleteContents()}var st=()=>ee.bindAttributeName;function at(){return{a:0,i:1,name:"",o:null,N:null,V:t,Nn:null,A:null,X:null,I:null,xt:null,ke:!1,H:null,z:null,ro:!1,$t:!1,Nt:!1,Et:null,ao:null,F:-1,Ze:!1,co:!1}}var ut=["state","element","auto","none"],ct=["call","connect"],ft="$command.";function ht(e,t,n){C.test(t)&&(null===n&&w(1401,[t,Number(t.slice(1))]),t=`${n.t}.*.${t}`);let l=e.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&w(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&w(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.f[e];l.f[e]!==t&&w(1403,[l.t,l.f[e].t,t.t])}return c.go?.(e,l),l}var dt=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),pt=e=>8===e.i||dt(e)||1===e.i&&_e(e.name);function mt(e){w(202,[e])}function gt(e,t,n,l,i){let r=re(t).map(t=>function(e,t,n,l,i){let r=function(e,t){let n=t.find(e=>e.startsWith("on")),l=null,i=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e.Mt||w(31);let r=n.slice(0,t).trim(),o=n.slice(t+1).trim(),s="init"===r;!s&&"sync"!==r&&w(33,[r,n]),null!==(s?l:i)&&w(34,[r]),(s?ut:ct).includes(o)||w(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),$t:t.includes("prevent"),Nt:t.includes("stop"),event:n?n.slice(2):null,H:l,z:i}}(e,t.tn),o=l.localName.includes("-"),s=t.ve,a=t.Je;if("event"===t.w){if(null!==r.H&&"none"!==r.H&&w(36),"eventToken"===s[0])return{...at(),a:i,i:13,name:s.slice(1).join("."),Et:a,ke:o,$t:r.$t,Nt:r.Nt};let n=a.startsWith(ft)?a.slice(9):null,{$t:l,Nt:u}=r,c=t.be.slice(2),f=t.tn.includes("direct"),h=!f&&Re.has(c);return h&&e.eo(c),{...at(),a:i,i:5,name:c,Ze:h,ke:o,co:f,Nn(t,i){l&&t.preventDefault(),u&&t.stopPropagation();try{if(null!==n)e.qo(n,t,i);else{let n=e.Ko(a,t,i);V(n)&&n.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...at(),a:i,i:14,o:ht(e,a,n),ke:o};if("command"===s[0]&&s.length>1)return a.startsWith(ft)||w(1201,[t.be,a]),{...at(),a:i,i:12,name:s.slice(1).join("."),Et:a,ke:o};let u=ht(e,a,n),c={...at(),a:i,i:1,name:t.be,o:u,N:Se(t.Qe),I:Se(t.I),ro:r.ro,H:r.H,z:r.z};if("radio"===t.w||"checkbox"===t.w)return("element"===r.H||"auto"===r.H)&&w(37,[t.w,r.H]),c.i="radio"===t.w?9:10,r.ro||(c.xt=r.event??"input"),c;if(s.length>1){let e=s.slice(1).join("."),t=s[0];if("class"===t||"attr"===t||"style"===t)return c.H=null,c.name=e,"class"===t?(c.i=2,c.V=l.classList.contains(e)):c.i="attr"===t?"srcdoc"===e&&"iframe"===l.localName?1:3:4,c}return"html"===t.be?(c.i=8,c):(c.name="text"===t.be?"textContent":t.be,c.ke=o&&!Ne(c.name),!o&&!r.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(l,c.name)&&(c.xt=r.event??("select"===l.localName?"change":"input")),c)}(e,t,n,l,i));for(let e=0;e<r.length;e++)14===r[e].i&&(r[e].ao=r.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return r}var yt=/\{\{([\s\S]+?)\}\}/g;function $t(e){let t=e.data,n=[],l=0;yt.lastIndex=0;for(let i=yt.exec(t);null!==i;i=yt.exec(t)){let r=yt.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,Qo:i[1].trim()}),l=yt.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function vt(e,t,n,l){let i=function(e){return{be:"textContent",ve:["textContent"],tn:[],I:[],...D(e),w:"text"}}(t);return{...at(),a:l,i:0,o:ht(e,i.Je,n),N:Se(i.Qe),V:""}}function bt(e){let t=e.getAttribute(st());if(null===t)return null;let n=re(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var wt=(e,t)=>0===e?ee.commentIfPrefix:null===t.o?ee.commentElsePrefix:ee.commentElseIfPrefix;function kt(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:ht(e,l.Je,n),N:"else"===l.w?null:Se(l.Qe)}),i=[l(t,bt(t))];for(let e=t.nextSibling;null!==e;e=e.nextSibling){if(3===e.nodeType&&""===e.data.trim()||8===e.nodeType)continue;if(1!==e.nodeType||"template"!==e.localName)break;let t=bt(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var St=new WeakSet;function xt(e,t,n,l,i,r,o,s){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&c.An?.(e,i,t),i},u=t=>{for(let f=0;f<t.length;f++){let h=t[f];if(null!==h.parentNode)if(1===h.nodeType){let t=h,s=t.localName;if(l){if("script"===s||"style"===s||St.has(t))continue;if(St.add(t),s===ee.tagNames.state){u([...t.childNodes]);continue}}let f="template"===s?bt(t):null;if(null!==f){if("for"===f.w){let l=ht(e,f.Je,n),r=jt(e,t,l,!0);i(a(t,ee.commentForPrefix),l,r)}else"if"===f.w?r(kt(e,t,n).map((t,l)=>({A:jt(e,t.el,n,!1),o:t.o,N:t.N,S:a(t.el,wt(l,t))}))):mt(f.w);continue}let d=t.getAttribute(st()),p=null===d?null:gt(e,d,n,t,0),m="noscript"!==s&&"iframe"!==s&&!p?.some(pt)&&!c.yo?.(t);try{l&&m&&u([...t.childNodes])}finally{null!==p&&o(t,p)}!l&&m&&u([...t.childNodes])}else if(3===h.nodeType&&e.Bt&&h.data.includes("{{")&&!St.has(h))for(let{a:e,Qo:t}of $t(h))s(e,t);else if(8===h.nodeType){let e=At.exec(h.data),t=e&&h.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");h.replaceWith(t),s(t,e[1])}}}};u(t)}var At=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Nt=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function jt(e,t,n,l){let i=document.importNode(Nt(t),!0),r=[],o=[],s=e=>r.push(e)-1;xt(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...at(),a:s(e),i:6,o:t,A:n})},e=>{let t=e.map(e=>({a:s(e.S),A:e.A,o:e.o,N:e.N}));o.push({...at(),a:t[0].a,i:7,X:t})},(e,t)=>{let n=s(e);for(let e of t)dt(e)&&w(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(st())},(t,l)=>{o.push(vt(e,l,n,s(t)))}),Tt(i,new Set(r),!0);let a=r.map(e=>function(e,t){let n=[];for(let l=t;l!==e;l=l.parentNode){let e=0;for(let t=l.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(i,e)),u=1===i.childNodes.length&&8!==i.firstChild.nodeType,c=o.some(e=>6===e.i||7===e.i),f=[],h=new Set,d=[],p=[],m=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.Ze&&!e.ke&&!Ot(r[e.a],i)){d.push(e);continue}p.push(e);let t=e.o;if(null!==t&&t.n===m&&t.f[m]===n&&Ct(e)&&(e.F=f.push(e)-1),7===e.i)for(let t of e.X)h.add(t.a);else h.add(e.a)}let g=[...h].sort((e,t)=>e-t);return{on:i,root:u?i.firstChild:null,Rn:a,build:g,Ne:d,Yo:p,Tn:u,Go:c,mo:[],Ke:f}}function Ot(e,t){for(;e.parentNode!==t;e=e.parentNode){if(e.parentNode.localName.includes("-"))return!0;for(let t=e.previousSibling;t;t=t.previousSibling)if(8===t.nodeType)return!0}return!1}function Ct(e){if(null!==e.H)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.ke&&null===e.xt;default:return!1}}var Mt=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Tt(e,t,n){for(let l=e.firstChild;null!==l;){let e=l.nextSibling;3===l.nodeType?n&&!t.has(l)&&""===l.data.trim()&&l.remove():1===l.nodeType&&Tt(l,t,Mt.has(l.localName)),l=e}}var Pt=new WeakMap;function Et(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Pt.set(t,e),It(e,[...n.childNodes]),e.He()}function Wt(e,t,n){try{let l="template"===t.localName?bt(t):null;null!==l&&!n&&w(204,[l.w]),It(e,[t])}catch(e){console.error(e)}e.He()}function It(e,t){xt(e,t,null,!0,(t,n,l)=>{new it(e,l,Xe(e,n,null,t),t).vt()},t=>{nt(e,t,null,null)},(t,n)=>{c.An?.(e,t,n);for(let l of n)tt(e,l,t,null,null)},(t,n)=>{c.An?.(e,t,n),tt(e,vt(e,n,null,0),t,null,null)})}var Rt=Symbol.for("wcstack.binder"),Lt=Symbol.for("wcstack.binder.pending"),qt=Symbol.for("wcstack.binder.taken");var Dt=new Map;function zt(e,t){if(1!==e.nodeType||!e.isConnected)return;let n=Pt.get(e.getRootNode());void 0===n||!1===n.element?.isConnected?Dt.set(e,t):Wt(n,e,t?.range)}function Ut(){let e=[...Dt];Dt.clear();for(let[t,n]of e)zt(t,n);!function(){let e=function(){let e=globalThis[Rt];return null==e||"wcs-binder"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.bind?null:e}();if(null===e)return;let t=function(){let e=globalThis,t=e[Lt];return void 0===t&&(t=[],e[Lt]=t),t}();if(0===t.length)return;let n=t.splice(0,t.length),l=function(){let e=globalThis,t=e[qt];return void 0===t&&(t=new WeakSet,e[qt]=t),t}();for(let t of n)l.add(t),e.bind(t)}()}var Ft=class{constructor(){this.name="dirty",this.rt=(e,l)=>{if(0===e.n){let l=e.J;return l!==t&&l!==n&&(e.J=n,!0)}let i=null===l?null:l.dt;if(null===i)return!1;let r=i[e.F];return r!==t&&r!==n&&(i[e.F]=n,!0)}}Ho(e,t,n){null!==t.getter&&this.rt(t,n),e.bt(t,n),e.vn(t,n,this.rt)}Lo(e,t){let n=t.l.o.At;if(null!==n)for(let l of n)l.n===t.l.n?e.nt(l,t,this.rt):e.Jt(t,l,t=>e.nt(l,t,this.rt))}me(e,t,n){this.rt(t,n),c.ye?.(e,t,n),e.bt(t,n),e.vn(t,n,this.rt)}Bo(e,i,r){let o=0===i.n;if(!o&&null===r)return;let s=o?null:r.dt??=new Array(e.Oe).fill(t),a=null===s?i.J:s[i.F];if(a!==t&&a!==n&&a!==l&&(null===s||i.F in s))return a;a=l;try{return a=e.Do(i,null===s?null:r)}finally{null===s?i.J=a:s[i.F]=a}}Kt(e){e.dt=null}mt(e){for(let t of e.B.all())null!==t.getter&&(0===t.n?t.J===n&&(t.J=l):e.Zt(t.f[t.n],e=>{let i=e.dt;null!==i&&i[t.F]===n&&(i[t.F]=l)}))}},_t=0,Bt=new WeakMap;function Ht(e,t=e.getRootNode()){Bt.set(t,[...Bt.get(t)??[],e].filter((e,t,n)=>e.isConnected&&n.lastIndexOf(e)===t))}function Kt(e){let t=Bt.get(e)??[],n=t.filter(t=>t.getRootNode()===e);return Promise.any(n.map(e=>e.initializePromise.then(()=>e._||e.connectedCallbackPromise))).then(()=>{},l=>n.length?Bt.get(e)!==t?Kt(e):Promise.reject(l.errors[0]):void 0)}var Vt=typeof HTMLElement>"u"?class{}:HTMLElement,Jt=class extends Vt{constructor(){super(),this.engine=null,this.Fn=!1,this.Ve=!1,this.V=null,this.ze=null,this.loaded=!1,this.ln=null,this.connectedCallbackPromise=new Promise((e,t)=>{this.sn=e,this.wo=t}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(e=>{this.rn=e})}static{this.getBindingsReady=Kt}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Fn){if(null!==this.ze)return void this.ze.Xe();Ht(this);let e=this.engine;if(null!==e){let t=e.root;t===this.getRootNode()&&!Pt.has(t)&&Pt.set(t,e),Ut(),c.element?.(e,"back"),this.bo("$connectedCallback",50,()=>{this.isConnected&&c.element?.(e,"connected")})}return}this.Fn=!0;let e=this.getRootNode(),t=c.it?.(this,e);if(t)return this.ze=t,!t.vo&&this.parentNode instanceof ShadowRoot&&Ht(this),void(void 0===t.Lt?this.ko():t.Lt()).then(e=>(this.loaded=!0,t.start(e,()=>this.So()))).then(()=>{this.rn(),this.sn()},e=>this.kt(e,t.vo));this.start(e),Ht(this)}disconnectedCallback(){if(null!==this.ze)return void this.ze.On();let e=this.engine;if(null===e)return;let t=e.root;Pt.get(t)===e&&Pt.delete(t),Ht(this,t),this.bo("$disconnectedCallback",51),c.element?.(e,"disconnected")}setInitialState(e){if(this.Ve&&w(14),this.loaded)this.ze.reset(e);else if(null===this.engine)if(null!==this.ln){let t=this.ln;this.ln=null,t(e)}else this.V=e;else this.engine.reset(e)}createState(e,t){let n=this.engine;null===n&&w(15),"readonly"===e&&n.Ce++;try{t(n.proxy)}finally{"readonly"===e&&n.Ce--}}async createStateAsync(e,t){let n=this.engine;null===n&&w(15),await t("writable"===e?n.proxy:new Proxy(n.proxy,{get(e,t,n){let l=Reflect.get(e,t,n);return"$setAll"===t||"$resolve"===t?(...e)=>(e.length>2&&w(8),l(...e)):l},set(){w(8)}}))}async ko(){await 0;let e=this.getAttribute("state");if(null!==e){let t=t=>[...t.querySelectorAll('script[type="application/json"]')].find(t=>t.id===e),n=t(this.getRootNode())??t(document);return void 0===n?Promise.reject(new Error(`[@wcstack/state] ${b(16,[e])}`)):Promise.resolve(JSON.parse(n.textContent||"{}"))}let t=this.getAttribute("src");if(null!==t)return async function(e){let t=new URL(e,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(t)){let n=await fetch(t);return n.ok||w(13,[e,n.status]),await n.json()}return(await(import(t))).default??{}}(t);let n=this.getAttribute("json");if(null!==n)return Promise.resolve(JSON.parse(n));let l=this.querySelector('script[type="module"]');return null!==l?async function(e){let t=!1,n=e=>{e.effectiveDirective.startsWith("script-src")&&(t=!0)};document.addEventListener("securitypolicyviolation",n);let l="function"==typeof URL.createObjectURL,i=l?URL.createObjectURL(new Blob([e.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${e.text}\n//${++_t}`);try{return(await(import(i))).default??{}}catch(e){throw await new Promise(e=>setTimeout(e)),new Error(`[@wcstack/state] ${t?b(42):b(43,[e instanceof Error?e.message:String(e)])}`,{cause:e})}finally{document.removeEventListener("securitypolicyviolation",n),l&&URL.revokeObjectURL(i)}}(l):null!==this.V?Promise.resolve(this.V):new Promise(e=>{this.ln=e})}async start(e){try{let t=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||t?.hasAttribute("data-wc-definition"))&&$("scopes","<wcs-state>");let n=await this.ko(),l=y(n);if(l&&await l,this.getRootNode()!==e)return this.V=n,this.Fn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&$("ssr","enable-ssr");let i=Pt.get(e)?.element;i?.isConnected&&(i._||i.ze)&&w(47);let r=new Z(n,new Ft);r.element=this,this.engine=r,c.element?.(r,"mounting"),Et(r,e),Ut(),r.bn(),this.So(),await r.we("$connectedCallback"),this.isConnected&&c.element?.(r,"connected"),this.sn()}catch(e){this.Ve=!this._,this.kt(e)}}So(){this._=!0,this.rn()}kt(e,t){this.He(this._?50:49,e),this.rn(),t?this.sn():this.wo(e)}He(e,t){let n=["mount","bind-component","state","src"].flatMap(e=>this.hasAttribute(e)?[e,this.getAttribute(e)]:[]);console.error(`[@wcstack/state] ${b(e,[this.localName,...n])}`,t)}bo(e,t,n){(async()=>this.engine.we(e))().then(n,e=>this.He(t,e))}},Xt=[];function Gt(){return(Xt=Xt.filter(e=>e.deref())).map(e=>e.deref())}var Yt,Qt=e=>t=>{let n=e(t);return e=>null==e?e:n(e)},Zt="en";function en(){if(ee.locale!==Yt){Yt=ee.locale;try{Zt=Intl.getCanonicalLocales(Yt)[0]}catch{console.warn(`[@wcstack/state] ${b(48,[Yt])}`),Zt="en"}}return Zt}var{eq:tn,ne:nn,not:ln,lt:rn,le:on,gt:sn,ge:an,falsy:un,truthy:cn,boolean:fn}=be,hn={toFixed:{factory:e=>{let t=ge(e?.[0]??"0","toFixed");return e=>("number"!=typeof e&&de("toFixed"),e.toFixed(t))},arity:[0,1]},locale:{factory:e=>{let t=e?.[0];return e=>("number"!=typeof e&&de("locale"),e.toLocaleString(t??en()))},arity:[0,1]},upper:{factory:Qt(()=>e=>String(e).toUpperCase()),arity:[0,0]},lower:{factory:Qt(()=>e=>String(e).toLowerCase()),arity:[0,0]},capitalize:{factory:Qt(()=>e=>{let t=String(e);return 0===t.length?t:1===t.length?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}),arity:[0,0]},trim:{factory:Qt(()=>e=>String(e).trim()),arity:[0,0]},slice:{factory:Qt(e=>{let t=[ye(e,0,"slice")],n=e?.[1];return typeof n<"u"&&t.push(ge(n,"slice")),e=>String(e).slice(...t)}),arity:[1,2]},padStart:{factory:Qt(e=>{let t=ye(e,0,"padStart"),n=e?.[1]??"0";return e=>String(e).padStart(t,n)}),arity:[1,2]},padEnd:{factory:Qt(e=>{let t=ye(e,0,"padEnd"),n=e?.[1]??" ";return e=>String(e).padEnd(t,n)}),arity:[1,2]},repeat:{factory:Qt(e=>{let t=ye(e,0,"repeat");return e=>String(e).repeat(t)}),arity:[1,1]},reverse:{factory:Qt(()=>e=>String(e).split("").reverse().join("")),arity:[0,0]},truncate:{factory:Qt(e=>{let t=ye(e,0,"truncate"),n=e?.[1]??"…";return e=>{let l=String(e);return l.length<=t?l:l.slice(0,t)+n}}),arity:[1,2]},join:{factory:e=>{let t=e?.[0]??", ";return e=>(Array.isArray(e)||w(30,["join"]),e.join(t))},arity:[0,1]},round:{factory:e=>{let t=Math.pow(10,ge(e?.[0]??"0","round"));return e=>("number"!=typeof e&&de("round"),Math.round(e*t)/t)},arity:[0,1]},floor:{factory:e=>{let t=Math.pow(10,ge(e?.[0]??"0","floor"));return e=>("number"!=typeof e&&de("floor"),Math.floor(e*t)/t)},arity:[0,1]},ceil:{factory:e=>{let t=Math.pow(10,ge(e?.[0]??"0","ceil"));return e=>("number"!=typeof e&&de("ceil"),Math.ceil(e*t)/t)},arity:[0,1]},percent:{factory:e=>{let t=ge(e?.[0]??"0","percent");return e=>("number"!=typeof e&&de("percent"),`${(100*e).toFixed(t)}%`)},arity:[0,1]},unit:{factory:Qt(e=>{let t=e?.[0]??fe("unit");return e=>String(e)+t}),arity:[1,1]},date:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||pe("date"),e.toLocaleDateString(t??en()))},arity:[0,1]},time:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||pe("time"),e.toLocaleTimeString(t??en()))},arity:[0,1]},datetime:{factory:e=>{let t=e?.[0];return e=>(e instanceof Date||pe("datetime"),e.toLocaleString(t??en()))},arity:[0,1]},ymd:{factory:e=>{let t=e?.[0]??"-";return e=>{e instanceof Date||pe("ymd");let n=e.getFullYear().toString(),l=(e.getMonth()+1).toString().padStart(2,"0"),i=e.getDate().toString().padStart(2,"0");return`${n}${t}${l}${t}${i}`}},arity:[0,1]},hms:{factory:e=>{let t=e?.[0]??":";return e=>{e instanceof Date||pe("hms");let n=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0"),i=e.getSeconds().toString().padStart(2,"0");return`${n}${t}${l}${t}${i}`}},arity:[0,1]},eq:tn,ne:nn,not:ln,lt:rn,le:on,gt:sn,ge:an,add:ve("add",(e,t)=>e+t),sub:ve("sub",(e,t)=>e-t),mul:ve("mul",(e,t)=>e*t),div:ve("div",(e,t)=>e/t),mod:ve("mod",(e,t)=>e%t),abs:{factory:()=>e=>("number"!=typeof e&&de("abs"),Math.abs(e)),arity:[0,0]},clamp:{factory:e=>{let t=ye(e,0,"clamp"),n=ye(e,1,"clamp");return e=>("number"!=typeof e&&de("clamp"),Math.min(Math.max(e,t),n))},arity:[2,2]},int:{factory:()=>e=>parseInt(String(e),10),arity:[0,0]},float:{factory:()=>e=>parseFloat(String(e)),arity:[0,0]},falsy:un,truthy:cn,defaults:{factory:(e,t)=>{let n=$e(e?.[0]??fe("defaults"),t);return e=>e||n},arity:[1,1]},coalesce:{factory:(e,t)=>{let n=$e(e?.[0]??fe("coalesce"),t);return e=>e??n},arity:[1,1]},boolean:fn,number:{factory:()=>e=>Number(e),arity:[0,0]},string:{factory:()=>e=>String(e),arity:[0,0]},nullIfEmpty:{factory:()=>e=>""===e?null:e,arity:[0,0]}},dn=!1,pn={name:"formats",install:function(){dn||(dn=!0,ue(hn))}};function mn(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let l=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)l[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let r=1;r<=t.length;r++){let o=e[n-1]===t[r-1]?0:1;i[r]=Math.min(l[r]+1,i[r-1]+1,l[r-1]+o)}for(let e=0;e<=t.length;e++)l[e]=i[e]}return l[t.length]}function gn(e,t){if(0===e.length)return"";let n=e.toLowerCase(),l=null,i=3;for(let e of t){let t=mn(n,e.toLowerCase(),2);t<i&&(l=e,i=t)}return null!==l?` Did you mean "${l}"?`:""}var yn=" Validate statically: npx @wcstack/lint <file>.",$n=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],vn=e=>{let t=$n[e/100|0];return t?`[wcs/${t}] `:""},bn=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],wn=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,kn="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",Sn={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>"updates did not settle after 32 passes",41:()=>"render chain depth limit exceeded (100 drains that rendering itself started); bindings for this batch were not applied.",12:(e,t)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${kn}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${kn}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&bn.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${wn(e,t)} failed to initialize.`,50:(e,...t)=>`${wn(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${wn(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,119:e=>`"${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,l)=>`${e}("${t}") takes ${n} index(es), got ${l}.`,902:(e,t,n,l)=>`${e}("${t}") takes at most ${n} index(es), got ${l}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function xn(e,t){let n=Sn[e];return void 0===n?`${vn(e)}#${e} ${t.join(" ")}`:vn(e)+n(...t)}var An=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),Nn=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],jn={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function On(e,t,n){let l=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(jn,e)?jn[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?gn(t,n):"");for(let[t,n]of Nn){let i=t.exec(e);null!==i&&(l+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(l+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?l+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':oe.some(ce)||(l+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let r=/\[wcs\/([\w-]+)\]/.exec(e);return null!==r&&An.has(r[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(l+=yn),l}var Cn=new WeakMap,Mn=new WeakMap,Tn=new WeakSet,Pn=new WeakSet;function En(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function Wn(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function In(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let l=e.target,i=t=>null===t?null:function(e,t){let n=t.t.split("."),l=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return l<0||n.indexOf("*",l)>=0||void 0!==En(e.target,t.t)?.get?t:e.B.Ct(o(t.t).o)}(e,t);for(let t of n){if(null!=i(t)?.getter||null===l||"object"!=typeof l)return null;if("*"===t.s){if(!Array.isArray(l)||0===l.length)return null;l=l[0];continue}if(Array.isArray(l)&&/^\d+$/.test(t.s)){if(Number(t.s)>=l.length)return null;l=l[Number(t.s)];continue}let n=En(l,t.s);if(void 0===n&&null===t.d&&e.mt.has(t.s))return null;if(void 0===n){let n=Wn(l),r=i(t.d);for(let t of e.B.all())t.d===r&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;l=n.value}return null}function Rn(e){Tn.has(e)||(Tn.add(e),setTimeout(()=>function(e){Tn.delete(e);let t=Cn.get(e);if(void 0===t)return;let n=Mn.get(e);void 0===n&&Mn.set(e,n=new Set);for(let[l,i]of t){if(n.has(l))continue;n.add(l);let t=In(e,l);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${ee.tagNames.state}[mount]`)??[]].find(e=>!Pn.has(e)&&(l.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(l),r.initializePromise.then(()=>{Pn.add(r),Rn(e)});continue}let[s,a]=i?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];c.ot?.(e,{type:"state:path-unresolved",source:i?"watch":"binding",path:l.t,missingSegment:t.seg});let u=e.B.Ct(o(l.t).o),f="";if(void 0!==u&&u!==l&&null!==u.getter){let e=u.f.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(u.f[t].t.length+2)}`);f=` The getter "${u.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${s}] ${a} "${l.t}" does not resolve on the state tree: "${t.seg}" is not declared.${gn(t.seg,t.names)}${f} Updates to this path will be silently dropped.${yn}`)}}(e),0))}function Ln(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let l=Cn.get(e);void 0===l&&Cn.set(e,l=new Map),l.has(t)||l.set(t,n),Rn(e)}var qn=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Dn=!1;function zn(e,t,n){let l="html"===n.name?"innerHTML":n.name;if(Dn||!(t instanceof TypeError)||!Ne(l)||!("trustedTypes"in globalThis))return;Dn=!0;let i="function"==typeof Ae()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${l}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${i}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:n.a,property:l})}var Un=new WeakMap;function Fn(e,t,n){let l=e[t],i=void 0===n?void 0===l?null:`the event carried no detail (undefined) while element.${t} is ${typeof l}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==l&&"object"==typeof l?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof l}`;if(null===i)return;let r=Un.get(e);void 0===r&&Un.set(e,r=new Set),!r.has(t)&&(r.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var _n=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],Bn={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},Hn={name:"diagnostics",install(){c.Ao=On,c.Fo=xn,c.go=Ln,c.detail=Fn,c.Ve=f(c.Ve,zn);let e=c.se;c.se=(t,n)=>{(function(e){void 0!==e.$scan&&w(1);for(let[t,n]of _n)void 0!==e[t]&&w(1601,[t,n])})(n),e?.(t,n),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[l,i]=n[0];if(!l.endsWith(".*")||!i.endsWith(".*"))return;let r=l.slice(0,-2),o=i.slice(0,-2),s=`.${i}`,a=`${r}.**`,u=Wn(e),c=u.filter(e=>e.startsWith(a)).map(e=>e.slice(a.length)),f=e=>v(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${o}`||e.startsWith(`.${o}.`))&&f(`"${a}${e}" names the recursion structure itself (the "${o}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${qn(s)})+$`).test(t.slice(0,t.length-e.length))&&f(`"${a}${e}" and "${a}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${i}"). Rename one of them.`);let t=new RegExp(`^${qn(l)}(?:${qn(s)})*${qn(e)}$`);for(let n of u)!n.includes("**")&&t.test(n)&&f(`"${n}" is already defined on the state, so the recursive getter "${a}${e}" cannot expand to it.`)}}(n),function(e){Mn.delete(e),Cn.has(e)&&Rn(e)}(t)},c.tt=h(p,c.tt,(e,t)=>Object.hasOwn(Bn,t)?w(1701,[t,Bn[t]]):void 0)}},Kn={},Vn=/\.\d/,Jn=new Set(Object.getOwnPropertyNames(Object.prototype)),Xn=0,Gn=!1,Yn=null,Qn=()=>{Gn=!1,Xn++};function Zn(){if(null===Yn)if("function"==typeof MessageChannel){let e=new MessageChannel;e.port1.onmessage=Qn,e.port1.unref?.(),Yn=()=>e.port2.postMessage(0)}else Yn=()=>setTimeout(Qn,0);return Gn||(Gn=!0,Yn()),Xn}function el(e,t){let n=new Set,l=[e];for(;l.length>0;){let e=l.pop();if(!n.has(e)){n.add(e);for(let n of e.$e){for(let l of t)if(n.Q(l)&&(n.n===l.n||!(l.n<e.n&&e.f[l.n+1].Q(l))))return!0;null!==n.getter&&l.push(n)}}}return!1}var tl=class{constructor(e,t){this.active=!1,this.Ye=new Map,this.n=0,this.$o=-1,this.Cn=new Set,this._e=null,this.engine=e,this.st=t}Zo(){let e=this.engine;this.Ye.clear();for(let t of this.st)t.getter=null!==t.p.getter||t.p.de,t.s=new WeakMap,this.prime(t,()=>{0===t.p.n?t.getter&&t.s.set(Kn,e.v(t.p,null)):this.In(t.p,1,null,n=>{t.getter&&this.prime(t,()=>t.s.set(n,e.v(t.p,n)))})});this.active=!0}prime(e,t){try{t()}catch(t){console.error(`[@wcstack/state] $watch initial evaluation of "${e.t}" threw.`,t),c.ot?.(this.engine,{type:"state:watch-error",phase:"prime",path:e.t,error:t})}}No(){this.active=!1,this.Ye.clear()}In(e,t,n,l){let i=this.engine.De(n,e.f[t]);for(let n of i.u)t===e.n?l(n):this.In(e,t+1,n,l)}an(e,t,n,l){let i=this.Ye.get(e);void 0===i&&this.Ye.set(e,i=new Map);let r=i.get(t);void 0===r?i.set(t,[n,this.n,l]):(r[1]<this.n&&(r[1]=this.n),r[2]||=l)}he(e,t,n,l,i){if(this.active){(this._e??=new Set).add(e);for(let r of this.st){let o=r.p;o.n!==e.n||!o.Q(e)||this.an(r,t,r.getter?r.s.get(t??Kn):o===e&&i&&this.engine.Dt&&(null===l||"object"!=typeof l&&"function"!=typeof l)?n:void 0,!0)}}}ye(e,t){if(this.active)for(let n of this.st)(n.getter||=null!==n.p.getter||n.p.de)&&n.p.n===e.n&&n.p.Q(e)&&this.an(n,t,n.s.get(t??Kn),!1)}Yt(e,t){if(!this.active)return;let n=null;for(let l of this.st){let i=l.p;if(!(i.n<e.n||i.f[e.n]!==e.o)){n??=new Set(t);for(let t of e.u)n.has(t)||(i.n===e.n?this.an(l,t,void 0,!0):this.In(i,e.n+1,t,e=>this.an(l,e,void 0,!0)))}}}Te(){let e=this._e;if(this._e=null,!this.active||0===this.Ye.size)return;let t=this.Ye;this.Ye=new Map;let n=this.engine,l=[];for(let i of this.st){let r=t.get(i);if(void 0===r)continue;let o,s=[...r].filter(([e])=>null===e||e.y);s.length>1&&s.sort((e,t)=>ll(e[0],t[0]));for(let[t,[r,a,u]]of s){let s,f="evaluate",h=n.c;this.n=a+1,n.xe++;try{if(s=n.v(i.p,t),i.getter&&(i.s.set(t??Kn,s),Object.is(s,r)&&(Vn.test(i.t)||null!==t&&!u&&!(o??=null!==e&&el(nl(i.p),e)))))continue;if(a>32){l.includes(i.t)||l.push(i.t);continue}n.c=t,c.ot?.(n,{type:"state:watch-fired",path:i.t}),f="handler",i.handler.call(n.proxy,s,r,...n.W(t))}catch(e){console.error(`[@wcstack/state] $watch "${i.t}" failed; the other watches still run.`,e),c.ot?.(n,{type:"state:watch-error",phase:f,path:i.t,error:e})}finally{n.c=h,this.n=0,n.xe--}}}l.length>0&&this.xo(l)}xo(e){let t=Zn();t!==this.$o&&(this.$o=t,this.Cn.clear());let n=e.filter(e=>!this.Cn.has(e));if(0!==n.length){for(let e of n)this.Cn.add(e);console.error("[@wcstack/state] $watch handlers / $stream restarts kept writing for 32 batches; the chain is cut (nothing is rolled back)."),c.ot?.(this.engine,{type:"state:watch-chain-limit",maxDepth:32,paths:n})}}};function nl(e){for(;null===e.getter&&null!==e.d;)e=e.d;return e}function ll(e,t){let n=[],l=[];for(let t=e;null!==t;t=t.l.re)n.unshift(t.b);for(let e=t;null!==e;e=e.l.re)l.unshift(e.b);for(let e=0;e<n.length&&e<l.length;e++)if(n[e]!==l[e])return n[e]-l[e];return n.length-l.length}var il="$streamStatus",rl="$streamError",ol=new Set(Object.getOwnPropertyNames(Object.prototype)),sl=!1;function al(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return void 0!==e.get||void 0!==e.set||"function"==typeof e.value}return!1}var ul=class{constructor(e,t,n){this.engine=e,this.entries=t,this.D=n}set(e,t,n){sl=!0;try{this.engine.P(this.engine.o(`${e}.${t}`),null,n)}finally{sl=!1}}er(){for(let e of this.entries)this.start(e,!0)}tr(){for(let e of this.entries)e.at=!1,e.Y?.abort(),e.Y=null}nr(){for(let e of this.entries)e.at=!1,null!==e.Y&&(e.Y.abort(),e.Y=null),this.set(il,e.name,"idle")}ye(e){let t=this.D.n;for(let n of this.entries)n.g===e&&(n.n=n.at?Math.max(n.n,t):t,n.at=!0)}Te(){let e=this.engine,t=this.D,n=[];for(let i of this.entries){if(!i.at)continue;let r=i.n;if(i.at=!1,r>32)n.push(i.name),i.g.J=l;else{t.n=r+1,e.xe++;try{this.start(i,!1)}finally{e.xe--,t.n=0}}}n.length>0&&t.xo(n)}start(e,t){let n,i=this.engine;if(null!==e.Y&&e.Y.abort(),e.Y=null,null!==e.g){let r=e.g;r.getter=e.args;let o=r.$e.slice();cl(r);try{n=i.read(r,null),function(e,t,n){null!==n&&"function"==typeof n?.then&&v(`$stream "${e}": args must be synchronous (it returned a Promise).`);for(let n of t.$e)n.n>0&&v(`$stream "${e}": args must not read a wildcard path ("${n.t}").`),(n.t===e||n.t===`${il}.${e}`||n.t===`${rl}.${e}`)&&v(`$stream "${e}": args must not read the stream itself ("${n.t}").`)}(e.name,r,n)}catch(n){cl(r);for(let e of o)e.jn(r);if(r.J=l,t)throw n;return this.set(rl,e.name,n),void this.set(il,e.name,"error")}}let r=new AbortController;e.Y=r,i.P(i.o(e.name),null,e.V),this.set(rl,e.name,null),this.set(il,e.name,"active"),this.or(e,r,n)}async or(e,t,n){let l=this.engine,i=t.signal,r=()=>!i.aborted&&e.Y===t,o=l.o(e.name),s=this.D.n,a=Zn(),u=e=>{Zn()===a&&(this.D.n=s);try{e()}finally{this.D.n=0}},c=e.V;try{let t=await e.source(n,i);if(!r())return;let s=t=>{c=void 0!==e.Ro?e.Ro(c,t):t,u(()=>l.P(o,null,c))};if(null!==t&&"function"==typeof t?.getReader){let e=t.getReader();for(i.addEventListener("abort",()=>{e.cancel().catch(()=>{})});;){let t=await e.read();if(!r())return;if(t.done)break;s(t.value)}}else{if(null===t||"function"!=typeof t?.[Symbol.asyncIterator])throw new TypeError(`$stream "${e.name}": source must return an async iterable or a ReadableStream`);{let e=t[Symbol.asyncIterator]();for(i.addEventListener("abort",()=>{e.return?.()});;){let t=await e.next();if(!r())return;if(t.done)break;s(t.value)}}}if(!r())return;e.Y=null,u(()=>this.set(il,e.name,"done"))}catch(n){if(!r())return;e.Y=null,t.abort(),u(()=>{this.set(rl,e.name,n),this.set(il,e.name,"error")})}}};function cl(e){for(let t of e.$e){let n=t.G.indexOf(e);n>=0&&t.G.splice(n,1),t.Ft.delete(e)}e.$e.length=0,e.J=t}var fl=new WeakMap;function hl(e){let t=fl.get(e);return t?.target===e.target?t:void 0}function dl(e,t){let n=new tl(e,function(e,t){if(void 0===t)return[];(null===t||"object"!=typeof t)&&v("$watch must be an object mapping paths to handler functions.");let n=[];for(let l of Object.keys(t)){let i=t[l];(""===l||"$"===l[0]||l.includes("@")||Jn.has(l))&&v(`$watch path "${l}" is not a path of the state tree.`),"function"!=typeof i&&v(`$watch entry "${l}" must be a function.`);let r=e.o(l);c.go?.(e,r,!0),n.push({t:l,p:r,handler:i,getter:!1,s:new WeakMap})}return n}(e,t.$watch)),l=new ul(e,function(e,t){let n=t.$stream;if(void 0===n)return[];(null===n||"object"!=typeof n)&&v("$stream must be an object mapping stream names to definitions.");let l=[],i={},r={};for(let o of Object.keys(n)){let s=n[o];(""===o||"$"===o[0]||/[.*]/.test(o)||ol.has(o))&&v(`$stream entry "${o}" must be a flat property name.`),(null===s||"object"!=typeof s)&&v(`$stream entry "${o}" must be an object.`);let a=s.source,u=s.fold,c=s.args,f=s.initial;"function"!=typeof a&&v(`$stream entry "${o}" needs a source function.`),void 0!==u&&"function"!=typeof u&&v(`$stream entry "${o}": fold must be a function.`),void 0!==u&&!("initial"in s)&&v(`$stream entry "${o}": fold needs an initial value.`),void 0!==c&&"function"!=typeof c&&v(`$stream entry "${o}": args must be a function.`),al(t,o)&&v(`$stream entry "${o}" collides with a getter, setter or method of the state.`),void 0===t[o]&&(t[o]=f),i[o]="idle",r[o]=null,l.push({name:o,source:a,Ro:u,V:f,Y:null,at:!1,n:0,g:void 0===c?null:e.o(`$streamArgs.${o}`),args:void 0===c?null:function(){return c(this)}})}return t[il]=i,t[rl]=r,l}(e,t),n),i=fl.get(e);void 0!==i&&(i.D.No(),i.Pt.tr()),fl.set(e,{D:n,Pt:l,Xe:i?.Xe??!1,target:t})}function pl(e,t){let n=fl.get(e);if(void 0!==n&&"mounting"!==t&&!document.documentElement?.hasAttribute("data-wcs-server")&&("reset"!==t&&(n.Xe="connected"===t),n.target===e.target)){if("disconnected"===t)return n.D.No(),void n.Pt.nr();n.Xe&&(n.D.Zo(),n.Pt.er())}}var ml=["$streamStatus","$streamError"],gl={name:"temporal",install(){c.se=f(c.se,dl),c.element=f(c.element,pl),c.he=f(c.he,(e,t,n,l,i,r)=>hl(e)?.D.he(t,n,l,i,r)),c.ye=f(c.ye,(e,t,n)=>{let l=hl(e);void 0!==l&&(l.D.ye(t,n),l.Pt.ye(t))}),c.Yt=f(c.Yt,(e,t,n)=>hl(e)?.D.Yt(t,n)),c.Te=f(c.Te,e=>{let t=hl(e);void 0!==t&&(t.D.Te(),t.Pt.Te())}),c.tt=h(p,c.tt,(e,t)=>{let n=t.split(".",1)[0];if(ml.includes(n))return n===t?e.target[t]:e.read(e.o(t),null)}),c.Pe=h(d,c.Pe,(e,t)=>(!sl&&36===t.t.charCodeAt(0)&&ml.includes(t.t.split(".",1)[0])&&v(`"${t.t}" is read-only (the stream runtime owns it).`),!1))}},yl=new WeakMap,$l=!1,vl=/^(?!prototype$)[^\d.*$][^.*]*$/;function bl(e,t){let n=t.$listKeys,l=new Map;if(void 0!==n){(null===n||"object"!=typeof n)&&v("$listKeys must be an object mapping list paths to a key field or function.");for(let t of Object.keys(n)){let i=n[t];"string"==typeof i?l.set(e.o(t),e=>e[i]):"function"==typeof i?l.set(e.o(t),i):v(`$listKeys "${t}" must be a field name or a function.`)}}yl.set(t,l)}function wl(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function kl(e,t,n){let l=new Map;for(let i of t){wl(i)||v(`$listKeys "${e}": rows must be plain objects.`);let t=n(i);null==t&&v(`$listKeys "${e}": a row has no key.`),l.has(t)&&v(`$listKeys "${e}": duplicate key ${JSON.stringify(t)}.`),l.set(t,i)}return l}function Sl(e,t,n,l){if($l||!Array.isArray(l))return!1;let i=yl.get(e.target)?.get(t);if(void 0===i)return!1;let r=e.wt(t,n);if(!Array.isArray(r)||r===l)return!1;let o=kl(t.t,r,i);kl(t.t,l,i);let s=[],a=[],u=r.length===l.length;for(let e=0;e<l.length;e++){let t=l[e],n=o.get(i(t));s.push(n??t),void 0!==n&&a.push([e,n,t]),s[e]!==r[e]&&(u=!1)}let c=[];for(let[e,t,n]of a){for(let l of Object.keys(n))Object.is(t[l],n[l])||c.push([e,l,n[l]]);for(let l of Object.keys(t))!(l in n)&&null!==t[l]&&c.push([e,l,null])}if(u&&0===c.length)return!0;if(!u){$l=!0;try{e.P(t,n,s)}finally{$l=!1}}if(c.length>0){let l=e.De(0===t.n?null:n,t);for(let[n,i,r]of c){if("__proto__"===i)continue;let o=l.u[n],s=vl.test(i)?e.o(`${t.t}.*.${i}`):null;null===s?.getter?e.P(s,o,r):(o.T[i]=r,e.P(e.o(`${t.t}.*`),o,o.T,!0))}}return!0}var xl={name:"list-keys",install(){c.se=f(c.se,bl),c.Pe=h(d,c.Pe,Sl)}},Al=new WeakMap,Nl=new WeakMap,jl="will not graft: the root state failed to initialize.",Ol=new WeakSet,Cl=new WeakMap,Ml=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],Tl=["$commandTokens","$eventTokens","$on","$errorCallback"],Pl=e=>`[@wcstack/state] <${ee.tagNames.state} mount="${e}">`,El=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),Wl=e=>e?.element?.isConnected?e:void 0;function Il(e){let t=Nl.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function Rl(e,t){let n=Nl.get(t);if(Nl.delete(t),Array.isArray(n))for(let t of n)zl(t,e)}function Ll(e){let t=Al.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function ql(e,t){console.error(`${Pl(e.t)} ${t}`),Ll(e),e.Ge?.(),e.Ge=null}function Dl(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,e=>console.error(e))}catch(e){console.error(e)}}function zl(e,t){if(Ol.has(t))return ql(e,"will not graft: its component is wired to its host.");let n=e.state,l=t.target,i=e.t.split("."),r=l;for(let e of i)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return ql(e,`will not graft: the root state already has "${e.t}".`);let o=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,l){if("symbol"==typeof l)return;if(36!==l.charCodeAt(0))return e.proxy[n(l)];let i=e.proxy[l];return"$eqPath"===l?(e,t)=>i(n(e),n(t)):El.has(l)&&"function"==typeof i?(e,...t)=>i(n(e),...t):i},set:(t,l,i)=>"symbol"!=typeof l&&(e.proxy[n(l)]=i,!0)})}(t,e.t);e.chroot=o;let s={},a={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:l,set:i,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==l||void 0!==i)a[`${e.t}.${n}`]={get:l&&function(){return l.call(o)},set:i&&function(e){i.call(o,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(o);a[`${e.t}.${n}`]={get:()=>t}}else s[n]=r}}if(void 0===r){for(let e=1;e<i.length;e++){let n=t.o(i.slice(0,e).join("."));null==t.wt(n,null)&&t.P(n,null,{})}t.P(t.o(e.t),null,s)}t.Yn(Object.defineProperties({},a));for(let e in a)t._e(t.o(e),null);e.engine=t;let c=Cl.get(t);void 0===c&&Cl.set(t,c=[]),c.push(e),e.el.isConnected&&Dl(e,"$connectedCallback"),e.Ge?.(),e.Ge=null}function Ul(e,t){let n=Nl.get(e);if(Array.isArray(n))for(let e of n)ql(e,jl);Nl.set(e,t)}var Fl=new WeakMap;function _l(e,t){let n=e.getAttribute("mount");if(null===n)return null;let l={el:e,root:t,t:n,state:null,engine:null,chroot:null,Ge:null},i=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(ee.bindAttributeName))i='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=Al.get(t);void 0===e&&Al.set(t,e=new Map);let r=e.get(n);if(void 0!==r&&r!==l&&(null===r.engine?r.el.isConnected:Wl(r.engine)))i=`will not graft: another volume already holds "${n}".`;else{if(null===r?.engine){let e=Nl.get(t);Array.isArray(e)&&Nl.set(t,e.filter(e=>e!==r)),r.Ge?.(),r.Ge=null}e.set(n,l)}}else i='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{vo:!0,start(e){if(null!==i)return ql(l,i);if(Al.get(t).get(n)===l){for(let t of Ml)if(void 0!==e[t])return ql(l,`${t} is not run in a volume — declare it on the root state.`);for(let t of Tl)void 0!==e[t]&&console.warn(`${Pl(n)} ${t} is not run in a volume (it belongs to the root).`);return l.state=e,new Promise(e=>{l.Ge=e;let n=Wl(Pt.get(t)),i=Nl.get(t);void 0!==n?zl(l,n):Il(t)?ql(l,jl):Nl.set(t,[...Array.isArray(i)?i:[],l])})}},Xe(){null!==l.engine&&Dl(l,"$connectedCallback")},On(){null!==l.engine&&Dl(l,"$disconnectedCallback")},reset(){v(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var Bl=new WeakMap,Hl=new WeakMap;function Kl(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||v(`${t} must be an array of state member names.`);let l=new Set;for(let e of n)("string"!=typeof e||""===e)&&v(`${t} entries must be non-empty strings.`),"$"===e[0]&&v(`${t} entry "${e}": internal ($) members are never exposed.`),l.has(e)&&v(`${t} entry "${e}" is duplicated.`),l.add(e);return n}function Vl(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let l=document.createDocumentFragment();for(let e of[...t.childNodes])l.appendChild(e.cloneNode(!0));let i=t.mode;return{start(t){e.hasAttribute("bind-component")&&v("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,l){e.includes("-")||v(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&v(`DCC: <${e}> is already defined.`);let i=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(l),r=Kl(l,"$bindables"),o=Kl(l,"$commands");for(let e of r){let t=i.get(e);void 0===t&&v(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&v(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of o){let t=i.get(e);void 0===t&&v(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&v(`$commands entry "${e}" is not a method: list it in $bindables.`)}let s={tag:e,bindables:r},a=new WeakMap,u=new WeakMap,c=l=>{if(a.has(l))return a.get(l);if(l.hasAttribute("data-wc-definition"))return null;let i=l.attachShadow({mode:n});i.appendChild(t.cloneNode(!0));let o=i.querySelector(ee.tagNames.state);return a.set(l,o),Bl.set(l,s),null===o&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${ee.tagNames.state}>: no change events.`),o},f=e=>c(e)?.engine??null,h=e=>Promise.resolve(c(e)?.initializePromise).then(()=>{let t=u.get(e);u.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,l]of t)n.proxy[e]=l});class d extends HTMLElement{static{this.wcBindable=0===r.length&&0===o.length?null:{protocol:"wc-bindable",version:1,properties:r.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:r.map(e=>({name:e})),...0===o.length?{}:{commands:o.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==c(this)&&h(this)}get stateElement(){return c(this)}}for(let[e,t]of i)"function"==typeof t.value?Object.defineProperty(d.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(d.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=u.get(this);void 0===n&&u.set(this,n=[]),n.push([e,t])}}});customElements.define(e,d)}(n.localName,l,i,t)},Xe(){},On(){},reset(){v("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var Jl=new WeakMap,Xl=new WeakSet,Gl=new WeakMap,Yl=new WeakMap,Ql="data-wcs-wired",Zl=new WeakMap,ei=new WeakMap,ti=new WeakMap,ni=0,li=new Set,ii={},ri=["$watch","$stream","$renderedCallback"],oi=e=>e.split(".",1)[0];function si(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function ai(e,t){let n=e.a,l=oi(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(Ql);else if(!ci(n,l)){let e=n.getAttribute(Ql)?.split(" ")??[];e.includes(l)||n.setAttribute(Ql,[...e,l].join(" "))}Zl.get(n)?.ce===l&&v(`<${n.localName}>.${l} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let i=Jl.get(n);void 0===i&&Jl.set(n,i=[]),i.push(e),t&&Xl.add(e);let r=Gl.get(n);return void 0===r&&Gl.set(n,r=new Map),r.has(l)||r.set(l,n[l]),Yl.get(n)?.(),!1}function ui(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${ee.tagNames.state}[bind-component]`)}function ci(e,t){let n=e.getAttribute(ee.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function fi(e){let t=e.parentElement;for(;null!==t&&!ui(t);)t=t.parentElement;let n=Pt.get(t??e.getRootNode()),l=n?.element;(l?.isConnected?l._:null===t)&&(null===t?zt(e):Wt(n,e))}var hi=new Set;function di(e,t){hi.has(e)||(hi.add(e),console.warn(`[@wcstack/state] ${t}`))}var pi=(e,t)=>t in e.state;function mi(e,t){let n=gi(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function gi(e,t){for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return e}}function yi(e,t,n){if(null!==n.getter)return;let l,i=e.host,r=i.engine,o=oi(n.t),s=i.entries.find(e=>e.E===n.t);if(void 0===s&&null!==n.d)return function(e,t){let n,l=t.d;for(;null!==l&&void 0===(n=e.ct.get(l));)l=l.d;if(null===l||void 0===n)return;let i=e.x,r=e.host.engine,o=r.o(n.p.t+t.t.slice(l.t.length));if(null===o.getter)return;let s=n,a=()=>{let n=$i(e,s.r);return 0===t.n?n:(r.resolve(si(o.t,[...r.W(n),...i.W(Y(i.c,t.n))]),null),r.rr)};t.getter=()=>{let e=a();return o.n>0&&null===e?void 0:r.v(o,e)},null!==o.oe&&(t.oe=n=>{let l=a();vi(e,s.e,()=>r.P(o,l,n)),e.cn=t}),t.n>0&&(t.F=i.Oe++),e.ct.set(t,{e:s.e,p:o,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.E!==o?pi(i,o):mi(i,o))return;l=s.ue}else{if(null===t||null!==n.d||"$"===o[0]||pi(i,o))return;s=t,l=r.o(`${t.ue.t}.${o}`)}let a=s.r,u=s;n.getter=()=>r.v(l,$i(e,a)),n.oe=t=>{vi(e,u,()=>r.P(l,a,t)),e.cn=n},e.ct.set(n,{e:s,p:l,r:a})}function $i(e,t){return null!==t&&!t.y&&v(`The host row of <${e.host.el.localName}> was removed.`),t}function vi(e,t,n){let l=li.has(e.x);li.add(e.x),e.from=t;try{n()}finally{l||li.delete(e.x),e.from=null}}var bi=(e,t)=>t||!li.has(e.m.x)||null!==e.m.from&&e.m.from!==e.e;function wi(e,t){if(e.un===t||null===e.host.engine)return;e.un=t,ni+=t?1:-1;let n=e.host.engine,l=ti.get(n);void 0===l&&ti.set(n,l=new Map);for(let n of e.ae){let e=l.get(n.e.ue);void 0===e&&l.set(n.e.ue,e=new Map);let i=e.get(n.e.r);void 0===i&&e.set(n.e.r,i=new Set),t?i.add(n):(i.delete(n),0===i.size&&e.delete(n.e.r))}let i=e.host.entries.find(e=>""===e.E);if(void 0!==i){null===e.te&&function(e,t){let n=e.host,l=n.engine;e.te=new Map;let i=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let o of Object.getOwnPropertyNames(r)){if(i.has(o))continue;i.add(o);let s=Object.getOwnPropertyDescriptor(r,o);if(void 0===s.get&&void 0===s.set||"$"===o[0]||o.includes("*"))continue;let a=oi(o);if(o!==a&&!pi(n,a))continue;let u=l.o(`${t.ue.t}.${o}`);if(null===u.getter)xi(l,u,t.ue);else if(!ki.has(u.getter))continue;e.te.set(u,e.x.o(o))}}(e,i);for(let l of e.te.keys())t&&null===l.getter&&xi(n,l,i.ue),n.R.me(n,l,i.r);e.te.size>0&&n.Re(),t&&function(e,t){let n=e.host.engine;for(let[l,i]of e.te){let r=n.v(l.d,t.r);if(null===r||"object"!=typeof r||!(l.s in r))continue;let o=e.host.el.localName;di(`${o}|${l.t}`,`[wcs/mount-export-shadowed] <${o}>.${e.host.ce}.${i.t} is exported at "${l.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,i)}}var ki=new WeakSet;function Si(e,t,n,l){let i=ti.get(e)?.get(t)?.get(n);if(void 0===i)return null;let r=null;for(let e of i)""!==e.e.E||!0!==e.m.te?.has(l)||e.m===r||(null!==r&&v(`[wcs/mount-export-ambiguous] "${l.t}" is exported by two mounted components on the same instance: <${r.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),r=e.m);return r}function xi(e,t,n){let l=t.d,i=t.s,r=()=>{let t=e.read(l,e.c);return null!==t&&"object"==typeof t&&i in t?t:null};t.getter=()=>{let l=r();if(null!==l)return l[i];let o=Si(e,n,e.c,t);return null===o?void 0:o.x.read(o.te.get(t),null)},ki.add(t.getter),t.oe=o=>{let s=null===r()?Si(e,n,e.c,t):null;if(null===s){let t=e.read(l,e.c);return void(null!==t&&"object"==typeof t&&(t[i]=o))}let a=s.te.get(t);void 0===gi(s.host.state,a.t)?.set&&v(`Cannot write to "${a.t}" on mounted <${s.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),s.x.P(a,null,o)},t.n>0&&(t.F=e.Oe++)}function Ai(e,t,n,l,i,r){if(null!==t.getter)return e.R.me(e,t,n),void e.Re();if("*"===t.s){if(null===n)return;if(n.T=n.l.C[n.b],e.R.Kt(n),null!==n.h)for(let t of n.h.values())e.z(t)}else e.wn(t,n);c.he?.(e,t,n,l,i,r),e._e(t,n)}function Ni(e){let t=e.m.x;for(let[n,l]of e.m.ct)l.e===e.e&&(0===n.n?t.R.me(t,n,null):t.Zt(n.f[n.n],e=>t.R.me(t,n,e)));t.Re()}function ji(e,t,n,l,i,r,o){let s=n.t.slice(t.t.length);if(""===s)return Ni(e);let a,u=e.m,c=u.x;if(""===e.e.E){a=s.slice(1);let e=oi(a);if("$"===e[0]||pi(u.host,e)||u.host.entries.some(e=>""!==e.E&&(a===e.E||a.startsWith(`${e.E}.`))))return}else a=e.e.E+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(Y(l,e).b);c.resolve(si(a,f),null);let h=c.rp,d=c.rr;h.n>0&&null===d||Ai(c,h,d,i,r,o)}function Oi(e,t,n,l,i,r,o){if(0===ni)return;let s=li.has(e);li.add(e);try{let s=ei.get(e);!o&&void 0!==s&&s.un&&!li.has(s.host.engine)&&function(e,t,n,l,i,r){let o,s=t;for(;null!==s&&void 0===(o=e.ct.get(s));)s=s.d;if(null===s||void 0===o)return;let a=e.host.engine;if(s===t&&e.cn===t)return void(e.cn=null);if(null!==o.r&&!o.r.y)return;let u=[...a.W(o.r),...e.x.W(n)];a.resolve(si(o.p.t+t.t.slice(s.t.length),u),null);let c=a.rp,f=a.rr;c.n>0&&null===f||vi(e,o.e,()=>Ai(a,c,f,l,i,r))}(s,t,n,l,i,r),o&&void 0!==s&&s.un&&null!==s.te&&function(e,t){let n=e.host.entries.find(e=>""===e.E),l=e.host.engine;for(let[i,r]of e.te)r===t&&(l.R.me(l,i,n.r),l.Re())}(s,t);let a=ti.get(e);if(void 0===a)return;for(let[e,s]of a)if(t.Q(e)){let a=s.get(0===e.n?null:Y(n,e.n));if(void 0!==a)for(let s of[...a])bi(s,o)&&ji(s,e,t,n,l,i,r)}else if(e.Q(t))for(let[e,l]of[...s])if(0===t.n||Y(e,t.n)===n)for(let e of[...l])bi(e,o)&&Ni(e)}finally{s||li.delete(e)}}async function Ci(e,t,n,l,i){if(l===ii)return;let r=y(l);r&&await r;let o=Zl.get(t);o.engine&&l.$recursion&&v(`[wcs/mount-dollar-declaration] <${t.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let s=o.O;if(null!==s&&s.el!==e&&s.el.isConnected&&v(`<${t.localName}> already has a connected <${ee.tagNames.state} bind-component="${o.ce}">.`),null!==s&&wi(s,!1),null!==s&&function(e,t,n){let l=e.x,i=`[${ee.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(i)||null!==e.querySelector(i)),o=new Set,s=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&o.add(e)},a=(e,t)=>{for(let n=e.Pn(t);null!==n&&n!==t;n=n.nextSibling)s(n);s(t)};for(let e of l.ie.values())for(let t of e)if(null===t.M)s(t.a);else for(let e of t.M.X)a(t.M,e.S);for(let e of l.ee.values())for(let t of[e.$,...e.L??[]])null!==t&&a(t,t.S);for(let t of e.j)t.parentNode===n&&r(t)&&o.add(t);if(0===o.size)return!1;let u=[...n.childNodes].filter(n=>n!==t&&!o.has(n)&&!e.j.includes(n)&&(r(n)||l.Bt&&n.textContent.includes("{{")));return u.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${u.length} node(s) added beside the content taken over are not bound.`),!0}(s,e,n))return async function(e,t,n,l){e.el.engine=null,e.el=t,e.x.element=t,t.engine=e.x,e.j=e.j.filter(e=>e.parentNode===n),t.isConnected?await Mi(e,l):l()}(s,e,n,i);let a=new Z(l,new Ft);a.element=e,e.engine=a,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let l=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof l&&"constructor"!==t&&n.set(l,null)}let l=(t,n,l)=>Reflect.apply(t,e.proxy,l);e._=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:l})),t}}(a,l);let u={el:e,j:[],x:a,host:o,ae:[],ct:new Map,un:!1,cn:null,from:null,te:null};for(let e of o.entries)u.ae.push({m:u,e});o.O=u,ei.set(a,u);let f=null===o.engine;f?c.element?.(a,"mounting"):(function(e){let t=e.x,n=e.host,l=n.engine,i=n.el.localName,r=n.entries.find(e=>""===e.E)??null;for(let e of n.entries){if(""===e.E)continue;let t=oi(e.E);pi(n,t)&&(e.E!==t||mi(n,t))&&di(`${i}.${e.E}`,`[wcs/mount-own-key-shadow] <${i}>: "${n.ce}.${e.E}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=l.v(r.ue,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.E===t)&&di(`${i}.${t}`,`[wcs/mount-own-key-shadow] <${i}>: its own "${t}" hides "${r.ue.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let o=ri.filter(e=>void 0!==n.state[e]);o.length>0&&di(`${i}.${n.ce}$`,`[wcs/mount-dollar-declaration] <${i}>: ${o.join(", ")} ${1===o.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let s=t.et;t.et=n=>{yi(e,r,n),s.call(t,n)};let a=[...t.B.all()];for(let t of a)yi(e,r,t);for(let e of a)s.call(t,e);let u=n.entries.filter(e=>null!==e.r);if(u.length>0){let e=t.qt;t.qt=()=>{u.every(e=>e.r.y)&&e.call(t)}}}(u),wi(u,!0),Ol.add(a),Rl(a,n));let h=c.ir?.(n);Et(a,n),h?.(),u.j=[...n.childNodes],Ut(),f&&a.bn(),Object.defineProperty(t,o.ce,{configurable:!0,enumerable:!0,get:()=>a.proxy});let d=t.$stateReadyCallback;if("function"==typeof d)try{let e=d.call(t,o.ce);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}i(),e.isConnected?(await a.we("$connectedCallback"),f&&e.isConnected&&c.element?.(a,"connected")):wi(u,!1)}async function Mi(e,t){wi(e,!0);for(let t of e.ae)Ni(t);t?.(),!e.broken&&(await e.x.we("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.x,"connected"))}function Ti(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=Pt.get(t)?.element;if(!(e._||void 0!==n&&n!==e&&n.isConnected)){Ul(t,e);for(let e of Fl.get(t)??[])e()}}),null}(e,t);let l=e.parentNode,i=l instanceof ShadowRoot,r=i?l.host:l instanceof Element?l:null,o=()=>{let t=null===r?void 0:Zl.get(r)?.O;return t?.el===e?t:null},s=t=>{throw i&&Ul(l,e),t},a=!1;return{Lt:()=>(null!==r&&r.localName.includes("-")?async function(e,t,n,l){let i=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&v(`<${ee.tagNames.state} bind-component> takes its state from <${i}>.${t}: it cannot also load one (state / src / json / an inline script).`),await Pe(n).whenDefined(i);let r=Zl.get(n);if(void 0!==r)return r.ce!==t&&v(`<${i}> already has a <${ee.tagNames.state} bind-component="${r.ce}">.`),r.state;let o=()=>(Jl.get(n)??[]).filter(e=>oi(e.name)===t),s=ci(n,t);if(s&&0===o().length&&fi(n),0===o().length&&(s||((e,t)=>!0===e.getAttribute(Ql)?.split(" ").includes(t))(n,t))){let e;await new Promise((l,r)=>{Yl.set(n,l),e=function(e,t){Il(e)&&t();let n=Fl.get(e)??new Set;return Fl.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>r(new Error(`[@wcstack/state] <${i}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}Yl.delete(n);let a=o(),u=Gl.get(n),c=void 0!==u&&u.has(t)?u.get(t):n[t];if((null===c||"object"!=typeof c)&&v(`"bind-component": <${i}>.${t} must be an object (the component's state), got ${null===c?"null":typeof c}.`),0===a.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${i}>, or mount it from the host (${ee.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),ii}let f=[];for(let e of a){let l=e.name===t?"":e.name.slice(t.length+1);f.some(e=>e.E===l)&&v(`<${i}> maps "${e.name}" twice.`);let r=l.split(".").indexOf("*");if(r>=0){let n=l.split(".").slice(0,r).join(".");v(`<${i}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}f.push({E:l,ue:e.o,r:e.r,ro:Xl.has(e)}),e.engine.kn(e),""!==l&&delete n[e.name]}let h=0===a.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(c):c;return Zl.set(n,r={el:n,ce:t,state:h,engine:0===a.length?null:a[0].engine,entries:f,O:null}),h}(e,n,r,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${ee.tagNames.state}> to be a direct child of a custom element.`))).catch(s),async start(t,n){await Ci(e,r,i?l:r,t,()=>{a=!0,n()}).catch(e=>{let t=o();return!a&&null!==t&&(t.broken=!0),s(e)})},Xe(){let t=o();null!==t?Mi(t).catch(e=>console.error(e)):a?Promise.resolve().then(()=>{if(e.parentNode===l)return Ci(e,r,i?l:r,Zl.get(r).state,()=>{})}).catch(e=>console.error(e)):Yl.has(r)&&fi(r)},On(){let e=o();null!==e&&(wi(e,!1),!e.broken&&(e.x.we("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.x,"disconnected")))},reset(){v(`re-setting a component's state is not supported: write <${r?.localName}>.${n} instead.`)}}}var Pi={name:"scopes",install(){c.it=h(m,c.it,_l),c.it=h(m,c.it,Vl),c.it=h(m,c.it,Ti),c.Jo=ai,c.yo=ui,c.element=f(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=Cl.get(e)??[];if("disconnected"===t)for(let e of n)Ll(e);else if("reset"!==t&&Wl(Pt.get(e.root))===e){Rl(e,e.root);for(let e of n)Al.get(e.root).has(e.t)||Al.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();Rl(e,n),function(e,t){let n=t.host,l=void 0===n?void 0:Bl.get(n);void 0!==l&&Hl.set(e,{host:n,def:l})}(e,n)}),c.he=f(c.he,(e,t,n,l,i,r)=>{(function(e,t,n,l){let i=Hl.get(e);if(void 0===i)return;let r=t.t.split(".",1)[0];if(!i.def.bindables.includes(r))return;let o=l&&t.t===r;i.host.dispatchEvent(new CustomEvent(`${i.def.tag}:${r}-changed`,{detail:o?n:void 0,bubbles:!0}))})(e,t,i,r),Oi(e,t,n,l,i,r,!1)}),c.ye=f(c.ye,(e,t,n)=>Oi(e,t,n,void 0,void 0,!1,!0)),c.Pe=h(d,c.Pe,(e,t,n,l,i)=>(function(e,t){let n=Cl.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&v(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let l,i=ei.get(e);if(void 0===i)return!1;for(let e=t;null!==e&&void 0===l;e=e.d)l=i.ct.get(e);if(void 0===l)return!1;let r=l.e;return!((null===r.r||r.r.y)&&!r.ro)&&(!!n||($i(i,r.r),void v(`[wcs/mount-readonly] <${i.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${i.host.ce}${""===r.E?"":`.${r.E}`}#ro: ${r.ue.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,i)));let e=c.se;c.se=(t,n)=>{let l=Cl.get(t);void 0!==l&&l.length>0&&v(`re-setting a root state with grafted volumes (${l.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=ti.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&v("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},Ei="$recursion",Wi=new WeakMap,Ii=new WeakSet,Ri=new WeakSet,Li=0,qi=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Di=e=>`[wcs/recursion-${e}]`;function zi(e,t){let n=n=>v(`${Di("declaration-invalid")} ${Ei} ${e} "${String(t)}" ${n}`);("string"!=typeof t||""===t)&&v(`${Di("declaration-invalid")} ${Ei} ${e} must be a non-empty string.`);let l=t.split(".");(l.length<2||"*"!==l[l.length-1])&&n('must end with ".*" (a list element).');for(let e=0;e<l.length-1;e++){let t=l[e];""===t&&n("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&n('must have exactly one "*", at the end.'),t.includes("#")&&n('must not contain "#".')}return"$"===t[0]&&n('must not start with "$".'),t}var Ui=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function Fi(e,t){let n=`${e.l}.**`,l=t.slice(n.length);return(!t.startsWith(n)||""!==l&&"."!==l[0]||l.includes("**"))&&v(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),l}function _i(e,t,n){let l=Fi(e,t),i=function(e,t){for(let n=t;null!==n;n=n.l.re){let t=e.nodeList.exec(n.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r:n}}return null}(e,n);return null===i&&v(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),Ui(e,i.k)+l}function Bi(e,t,n){let l=new Set,i=new Set,r=(e,n,r)=>!(!Array.isArray(e)||0===e.length||(l.has(e)&&v(`${Di("cycle")} "${n}" is reachable from itself: the data under "${t.l}" must be a tree.`),i.has(e)&&v(`${Di("shared-list")} "${n}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),r+1>128&&v(`${Di("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${r+1} (the limit is 128).`),i.add(e),0)),o=(i,s)=>{for(let a of i){n(s,a);let i=e.o(`${Ui(t,s)}.${t.key}`),u=e.read(i,a);r(u,i.t,s+1)&&(l.add(u),o(e.De(a,i).u,s+1),l.delete(u))}},s=e.o(t.l),a=e.read(s,null);r(a,t.l,0)&&(l.add(a),o(e.De(null,s).u,0))}function Hi(e,t){let n=function(e){let t=e[Ei],n=[],l=new Set;for(let t=e;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let e of Object.getOwnPropertyNames(t))!l.has(e)&&e.includes("**")&&n.push([e,Object.getOwnPropertyDescriptor(t,e)]),l.add(e);if(void 0===t)return n.length>0&&q(n[0][0]),null;(null===t||"object"!=typeof t||Array.isArray(t))&&v(`${Di("declaration-invalid")} ${Ei} must be an object mapping one anchor path to its repeating sub-path.`);let i=Object.entries(t);1!==i.length&&v(`${Di("declaration-invalid")} ${Ei} must declare exactly one anchor (it declares ${i.length}).`);let r=zi("anchor",i[0][0]),o=zi("repeat",i[0][1]),s=r.slice(0,-2),a=o.slice(0,-2),u=`.${o}`,c=new Map,f=[],h=`${s}.**`;for(let[e,t]of n){let n=e.slice(h.length);(!e.startsWith(h)||""!==n&&"."!==n[0]||n.includes("**"))&&v(`[wcs/recursion-anchor] "${e}": a recursive key is "${h}" followed by a path (the anchor is "${r}").`),(""===n||n.split(".").slice(1).some(e=>""===e))&&v(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&v(`${Di("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),c.set(n,t.get),f.push([new RegExp(`^${qi(r)}((?:${qi(u)})*)${qi(n)}$`),n])}return{l:s,step:u,key:a,families:c,matchers:f,owners:new Map,nodeList:new RegExp(`^${qi(s)}((?:${qi(`.*.${a}`)})*)$`)}}(t),l=Wi.has(e);null!==n?(l||Li++,Wi.set(e,n),Ri.add(e),Ii.has(e)||function(e){Ii.add(e);let t=e,n=t.et;t.et=l=>{let i=Wi.get(e);if(l.t.includes("**")){let t=e.B.Ct(l.t)===l;return void(Ri.has(e)||void 0===i&&t?l.getter=()=>q(l.t):t||n.call(e,l))}if(void 0!==i&&null===l.getter)for(let[e,n]of i.matchers)if(e.test(l.t)){l.getter=i.families.get(n),l.n>0&&(l.F=t.Oe++),i.owners.set(l,i.l+".**"+n);break}n.call(e,l)};let l=t.resolve;t.resolve=(t,n)=>{let i=Wi.get(e);return l.call(e,void 0!==i&&t.includes("**")?_i(i,t,n):t,n)};let i=t.getAll;t.getAll=(n,l)=>{let r=Wi.get(e);if(void 0===r||!n.includes("**"))return i.call(e,n,l);if(void 0===l)return i.call(e,_i(r,n,t.c));(!Array.isArray(l)||l.length>0)&&v(`${Di("getall-form")} $getAll("${n}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let o=Fi(r,n),s=[];return Bi(e,r,(t,n)=>{for(let l of i.call(e,Ui(r,t)+o,e.W(n)))s.push(l)}),s};let r=t.pn;t.pn=(n,l,i,o)=>{let s=Wi.get(e);if(void 0===s||!n.includes("**"))return r.call(e,n,l,i,o);Array.isArray(l)||w(9,[n]),l.length>0&&v(`${Di("setall-form")} $setAll("${n}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof i||!0===o?.spread)&&v(`${Di("setall-form")} $setAll("${n}", [], value) with "**" takes a plain value (no mapper, no spread).`),t.Ce>0&&w(8);let a=Fi(s,n),u=a.replace(/\.\d+(?=\.|$)/g,".*");for(;u.startsWith(s.step);)u=u.slice(s.step.length);let c=s.key.split(".");(""===u||u===`.${s.key}.length`||c.some((e,t)=>u===`.${c.slice(0,t+1).join(".")}`))&&v(`${Di("structural-write")} "${n}" writes the recursion structure itself (a node, its "${s.key}" list or that list's length, or an object on the way to it).`);for(let e of s.families.keys()){let t=e;for(;t.startsWith(s.step);)t=t.slice(s.step.length);(u===t||u.startsWith(`${t}.`))&&v(`${Di("readonly")} "${n}" writes into the recursive getter "${s.l}.**${e}".`)}let f=[];Bi(e,s,(e,t)=>f.push([e,t]));let h=0;for(let[t,n]of f)h+=r.call(e,Ui(s,t)+a,e.W(n),i);return h}}(e)):l&&(Wi.delete(e),Li--)}function Ki(e,t){if(0===Li)return!1;let n=Wi.get(e);if(void 0===n)return!1;for(let e=t;null!==e;e=e.d){let l=n.owners.get(e);void 0!==l&&v(`${Di("readonly")} "${t.t}" writes into the recursive getter "${l}".`)}return!1}var Vi={name:"recursion",install(){c.se=f(c.se,Hi),c.element=f(c.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){Ri.delete(e)}(e)}),c.Pe=h(d,c.Pe,Ki)}},Ji="4.0.0-rc.4",Xi=e=>e.split(".").slice(0,2).join("."),Gi=class extends Vt{static find(e){return e.querySelector?.(ee.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return Xi(this.version)===Xi(Ji)}};function Yi(e){let t=ee.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends Gi{})}var Qi=()=>ee.tagNames.ssr,Zi=Symbol.for("wcstack.ssr.snapshotBuilder"),er=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),tr=e=>document.createComment(e),nr=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,lr=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),ir=new WeakMap,rr=new WeakMap,or=new WeakMap,sr=new WeakSet,ar=new WeakMap;function ur(e,t){let n=[];for(let l=e;null!==l&&(n.push(l),l!==t);l=l.nextSibling);return n}function cr(e,t,...n){for(let n of Array.from(e.attributes))t.setAttribute(n.name,n.value);return(t.content??t).append(...n),t}var fr=e=>null===e.j?e.Ue:e.j[e.j.length-1];function hr(e,t,n){let l=[tr(null===n?"wcs-[":`wcs-[:${n}`)];for(let e of t)null===n&&l.push(tr("wcs-|")),l.push(...ur(e.Ue,fr(e)));l.push(tr("wcs-]")),e.after(...l);for(let e of l)sr.add(e)}function dr(e){if(e instanceof it){hr(e.S,e.Ee,null);for(let t of e.Ee)pr(t);return}let t=e.O;null!==t&&(hr(e.X[e.X.length-1].S,[t],e.b),pr(t))}function pr(e){if(null!==e.h)for(let t of e.h)dr(t)}var mr=new Set(["script","style","template","textarea","title"]),gr="data-wcs-raw",yr=e=>mr.has(e.localName)||e.localName===Qi();function $r(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(tr("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(tr("wcs-s")):1===t.nodeType&&!yr(t)&&$r(t)}var vr=0;function br(e,t){let n=e.getRootNode(),l=[t];for(let e of rr.get(n)??[])e!==t&&!0===e.element?.hasAttribute("bind-component")&&l.push(e);let i=new Map;for(let e of l){let t=ir.get(e);if(void 0===t)continue;let n=new Map;for(let t of e.ee.values())if(null!==t.$&&n.set(t.$.S,t.$),null!==t.L)for(let e of t.L)n.set(e.S,e);for(let t of e.ie.values())for(let e of t)if(null!==e.M)for(let t of e.M.X)n.set(t.S,e.M);let l=new Set;for(let[e,r]of t){i.set(e,r);let t=n.get(e);void 0!==t&&!l.has(t)&&e.isConnected&&(l.add(t),dr(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=or.get(e);if(void 0!==t){let n=document.createTreeWalker(e,133,{acceptNode:e=>sr.has(e)||1===e.nodeType&&t.has(e)&&Ar(e)?2:1}),l=[];for(let e=n.nextNode();null!==e;e=n.nextNode()){let n=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(yr(e.parentNode)?ar.has(e):t.has(n)&&lr(n,"wcs-t:"))&&(ar.has(e)||t.get(e)!==e.data):!t.has(e))&&l.push(e)}for(let e of l)e.remove()}let n=Array.from(e.childNodes);yr(e)&&n.some(e=>ar.has(e))&&e.setAttribute(gr,n.map(e=>ar.has(e)?`{{ ${ar.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}$r(9===n.nodeType?n.body:n);let r=document.createElement(Qi());r.setAttribute("version",Ji);let o=document.createElement("script");o.type="application/json",o.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let n of Object.keys(e)){if("$"===n[0])continue;let l=Object.getOwnPropertyDescriptor(e,n);void 0!==l.get||void 0!==l.set||"function"==typeof l.value||(t[n]=l.value)}return t}(t.target)),r.append(o);for(let[e,t]of i){if(!e.isConnected)continue;let n=e.parentNode;for(;null!==n&&"svg"!==n.localName&&"foreignObject"!==n.localName;)n=n.parentElement;let l="svg"===n?.localName,i=`wcs-${l?"s":"t"}${vr++}`;e.replaceWith(tr(`wcs-p:${i}`));let o=document.importNode(Nt(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(cr(e,document.createElement("template"),...e.childNodes));if(l){let e=document.createElementNS(n.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=i,r.append(cr(t,s,o))}e.before(r)}function wr(e){!function(e){if(null!==e.querySelector(ee.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>ar.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${ee.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===Qi())continue;let e=t.engine;null!=e&&br(t,e)}}var kr=Symbol.for("wcstack.state.ssr.impl"),Sr=new Map,xr=new WeakMap,Ar=e=>!0===c.yo?.(e),Nr=e=>1===e.nodeType&&!yr(e)&&!Ar(e),jr=e=>e.u.flat().concat(e.U??[]),Or=e=>{for(let t of jr(e))t.remove()};function Cr(e,t,n){let l=/^wcs-\[(?::(\d+))?/.exec(e.data),i=e.previousSibling,r=e.parentNode,o=[],s=e.nextSibling;for(e.remove();null!==s&&!nr(s,"wcs-]");){let e=s.nextSibling;if(nr(s,"wcs-|"))o.push([]),s.remove();else{0===o.length&&o.push([]);let n=o[o.length-1];lr(s,"wcs-[")?e=Cr(s,t,n):(n.push(s),Nr(s)&&Mr(s,t))}s=e}let a={branch:void 0===l[1]?null:Number(l[1]),u:o,U:s??r.appendChild(tr("wcs-]"))},u=jr(a);s=a.U.nextSibling;for(let e of u)n?.push(e),t&&St.add(e);return t&&null!==i?Sr.set(i,a):Or(a),s}function Mr(e,t){for(let n=e.firstChild;null!==n;)lr(n,"wcs-[")?n=Cr(n,t):(Nr(n)&&Mr(n,t),n=n.nextSibling)}function Tr(e,t,n){let l=e=>{for(let i of Array.from(e.childNodes))if(i.parentNode===e)if(8===i.nodeType){let e=i.data;try{if("wcs-s"===e)i.remove();else if("wcs-e"===e)i.replaceWith("");else if(e.startsWith("wcs-t:")){let t=tr(`@@:${decodeURIComponent(e.slice(6))}`),n=i.nextSibling;for(;null!==n&&!nr(n,"wcs-/t");){let e=n.nextSibling;n.remove(),n=e}n?.remove(),i.replaceWith(t)}else if(e.startsWith("wcs-p:")){let n=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==n){let t=i.parentNode,l="s"===e[10]?cr(n,document.createElementNS(t.namespaceURI,"template"),...document.importNode(n.content.firstChild,!0).childNodes):document.importNode(n,!0);l.removeAttribute("id"),t.replaceChild(l,i)}}}catch{}}else 1===i.nodeType&&!yr(i)&&(Ar(i)?xr.set(i,{ssr:t,Ae:n}):l(i))};l(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let n=t.previousSibling;null!==n&&(8===n.nodeType||qr(n)||"template"===n.localName);n=n.previousSibling)e.unshift(n);let n=0,l=0;if(e.forEach((e,t)=>{lr(e,"wcs-[")?l++:nr(e,"wcs-]")&&--l<0&&(l=0,n=t+1)}),0===l)continue;let i=0;for(let l=t.firstChild;null!==l;l=l.nextSibling)if(lr(l,"wcs-["))i++;else if(nr(l,"wcs-]")&&0===i--){t.prepend(...e.slice(n));break}}}(e),Mr(e,n)}function Pr(e){let t=xr.get(e);if(void 0===t||(xr.delete(e),Tr(e,t.ssr,t.Ae),!t.Ae))return null;let n=c.Ae;return c.Ae=Ur,()=>{c.Ae=n,Er()}}function Er(){for(let e of Sr.values())Or(e);Sr.clear()}function Wr(e){let t=[];for(let n=document.createTreeWalker(e,128);n.nextNode();)t.push(n.currentNode);return t}function Ir(e,t,n,l){let i=null;for(let l of e){let e=l[n];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===i||e.length>i[n].length)&&(i=l)}let r=i?.[l];if(null==r)return null;let o=i[n],s=""===o?t:t.slice(o.length+1);return""===r?s:""===s?r:`${r}.${s}`}function Rr(e,t,n){if(er()){if(n instanceof Array){for(let e=n.length;e-- >0;)dt(n[e])&&n.splice(e,1);let e=t;if(n.some(pt))sr.add(e);else if(e.localName.includes("-")&&!Ar(e)){let t=new Map;for(let n=document.createTreeWalker(e,133);n.nextNode();)t.set(n.currentNode,n.currentNode.data);or.set(e,t)}return}if("string"==typeof n){if(ar.set(t,n),yr(t.parentNode))return;let e=tr(`wcs-t:${encodeURIComponent(n)}`),l=tr("wcs-/t");return t.before(e),void t.after(l)}let l=ir.get(e);void 0===l&&ir.set(e,l=new Map),l.set(t,n);let i=t.getRootNode(),r=rr.get(i);return void 0===r&&rr.set(i,r=new Set),void r.add(e)}if("string"!=typeof n&&Sr.size>0){let e=Sr.get(n);void 0!==e&&(Sr.delete(n),Sr.set(t,e))}}var Lr=e=>null!==e&&8===e.nodeType&&[ee.commentIfPrefix,ee.commentElseIfPrefix,ee.commentElsePrefix].includes(e.data),qr=e=>3===e.nodeType&&""===e.data.trim(),Dr=e=>(Sr.get(e)?.U??e).nextSibling;function zr(e,t){if(t.length!==e.on.childNodes.length)return!1;let n=e.Rn;for(let l=0;l<n.length;l++){let i=n[l],r=e.on,o=t[i[0]];for(let e=0;;){if(r=r.childNodes[i[e]],o?.nodeName!==r.nodeName)return!1;if(++e===i.length)break;o=o.firstChild;for(let t=i[e];t>0&&null!==o;t--)o=Dr(o)}e.mo[l]=o}return!0}function Ur(e,t,n){if(0===Sr.size)return null;let l=t,i=0;if(!n){let e=ee.commentIfPrefix;if(!nr(t,e))for(let n=t.previousSibling;null!==n&&1!==n.nodeType&&(Lr(n)&&i++,!nr(n,e));n=n.previousSibling);for(let n=t.nextSibling;!Sr.has(l)&&null!==n&&!nr(n,e)&&1!==n.nodeType;n=n.nextSibling)Lr(n)&&(l=n)}let r=Sr.get(l);if(void 0===r)return null;if(!n&&r.branch!==i)return Sr.delete(l),Or(r),null;let o=r.u.shift();if(0===r.u.length&&Sr.delete(l),r.U?.replaceWith(...ur(t,l)),r.U=null,void 0===o)return null;let s=[];for(let e=0;e<o.length;e++){let t=Sr.get(o[e]);if(s.push(o[e]),void 0!==t)for(;e<o.length&&o[e]!==t.U;)e++}if(!zr(e,s)){let n=(e.Tn?e.root:e.on).cloneNode(!0);s=e.Tn?[n]:[...n.childNodes],zr(e,s),(o[0]??r.u.find(e=>e.length>0)?.[0]??t).before(n);for(let e of o)e.remove()}return s}var Fr={name:"ssr",install(){c.An=Rr,c.ir=Pr;let e=c.element;c.element=(t,n)=>{"mounting"===n&&function(e){let t=e.element;if(!t.hasAttribute("enable-ssr")||er())return;let n=t.previousElementSibling,l=n?.localName===Qi(),i=l?n.getAttribute("version"):null,r=null===i||Xi(i)===Xi(Ji);if(r){let t=e,n=t.we;t.we=(t,l)=>"$connectedCallback"===t?void 0:n.call(e,t,l)}if(!l)return;let o=!r&&parseInt(i)<4,s=/^3\.(\d+)\.(\d+)$/.exec(i),a=null!==s&&(+s[1]-5||+s[2]-3)>=0;r||console.warn(`[@wcstack/state] <${Qi()} version="${i}"> does not match ${Ji}: its snapshot is discarded, and the page renders on the client from its own state.${o&&!a?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let u=r?n.querySelector('script[type="application/json"]'):null;if(null!==u){let t=JSON.parse(u.textContent||"{}"),n=e.target;for(let e of Object.keys(t)){let l=Object.getOwnPropertyDescriptor(n,e);void 0!==l&&(void 0!==l.get||void 0!==l.set||"function"==typeof l.value)||(n[e]=t[e])}e.hydrated=!0}let f=t.getRootNode();for(let e of Array.from(f.querySelectorAll(`[${gr}]`)))e.textContent=e.getAttribute(gr),e.removeAttribute(gr);let h=9===f.nodeType?f.body:f;o?function(e,t,n){let l=new Map,i=e=>{let t=e.parentElement;for(;null!==t&&!Ar(t);)t=t.parentElement;if(null===t)return null;let n=l.get(t);if(void 0===n){let e=i(t),r=t.querySelector(`:scope > ${ee.tagNames.state}[bind-component]`).getAttribute("bind-component");l.set(t,n=[]);for(let l of re(t.getAttribute(ee.bindAttributeName)??"")){let t=l.Je;l.ve[0]===r&&n.push([e?Ir(e,t,1,0):t,l.ve.slice(1).join("."),e&&t])}}return n},r=(e,t,n)=>{let l=i(e);if(null===l)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return n?t:Ir(l,t,0,1)??t;let o=r[1].replace(/#m\d+\./g,"").slice(0,-1);return l.some(e=>""===e[1]&&(e[0]===o||e[2]===o))?r[2]:Ir(l,r[2],2,1)??r[2]};for(let t of Wr(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let l=t.nextSibling;for(;null!==l&&!nr(l,`@@wcs-${e[1]}-end:${e[2]}`);)l=l.nextSibling;if(null!==l){for(;t.nextSibling!==l;)t.nextSibling.remove();l.remove(),t.replaceWith(..."text"===e[1]?[tr(`@@:${r(t,e[2],n)}`)]:[])}}let o=(e,n)=>{for(let l of Wr(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(l.data)?.[1],i=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===i)continue;let s=document.importNode(i,!0),a=ee.bindAttributeName;s.removeAttribute("id"),s.setAttribute(a,s.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,i)=>t+r(n??l,i))),o(s.content,n??l);let u=s.content.firstChild;l.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?s.content.childNodes:[s])}};o(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(h,n,a):Tr(h,n,r),n.remove(),r&&(c.Ae=Ur,queueMicrotask(()=>{Er(),c.Ae=null}))}(t),e?.(t,n)},function(){let e=globalThis;e[kr]={build:wr,reset(){vr=0}},void 0===e[Zi]&&(e[Zi]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[kr].build(t),reset:()=>e[kr].reset()})}(),c.Eo=f(c.Eo,Yi);for(let e of Gt())Yi(e)}},_r="__WCSTACK_DEVTOOLS_HOOK__",Br=null,Hr=new Set,Kr=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.W(n)}}),Vr=new WeakMap,Jr=0;var Xr=new WeakMap;function Gr(e){if(null===Br)return;let t=Xr.get(e),n=Hr.has(e)?function(e,t){let n=new Map,l=new Set,i=(l,i,r,o,s,a)=>{if(5===l)return;let u=function(e,t){return 0===e?"textContent":2===e?`class.${t}`:3===e?`attr.${t}`:4===e?`style.${t}`:t}(l,i),c=0===o.n?null:s,f=`${(e=>{let t=Vr.get(e);return void 0===t&&Vr.set(e,t=++Jr),t})(r)}|${u}|${o.t}|${null===c?"":e.W(c).join(",")}`;if(n.has(f))return;let h=t?.get(f);n.set(f,h??{binding:{propName:u,statePathName:o.t,bindingType:a,node:r,replaceNode:r},absoluteAddress:Kr(e,o,c)})},r=e=>i(e.i,e.name,e.a,e.o,e.r,e.en()),o=e=>{if(!l.has(e)){if(l.add(e),null!==e.fe)for(let t of e.fe)r(t);if(e instanceof Je&&null!==e.ae){let t=e.A.Ke;for(let n=0;n<t.length;n++){let l=e._?.[n];void 0!==l?r(l):i(t[n].i,t[n].name,e.ae[2*n],t[n].o,e.r,0===t[n].i?"text":"prop")}}if(null!==e.h)for(let t of e.h)s(t)}},s=e=>{if(!l.has(e))if(l.add(e),e instanceof it){i(-1,"for",e.S,e.l.o,e.l.re,"for");for(let t of e.Ee)o(t)}else null!==e.O&&o(e.O)};for(let t of e.ie.values())for(let e of t)r(e),null!==e.M&&s(e.M);for(let t of e.ee.values())if(null!==t.$&&s(t.$),null!==t.L)for(let e of t.L)s(e);return n}(e,t):new Map;if(void 0!==t)for(let[e,l]of t)n.has(e)||Br({type:"state:binding-removed",...l});for(let[e,l]of n)(void 0===t||!t.has(e))&&Br({type:"state:binding-added",...l});Xr.set(e,n)}function Yr(e){let t=Pt.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function Qr(e){let t=new Set,n=new Set,l=new Set,i=new Set;for(let r of e.B.all()){for(let e=1;e<=r.n;e++)t.add(r.f[e].t);"*"===r.s&&n.add(r.t),null!==r.getter&&l.add(r.t),null!==r.oe&&i.add(r.t)}let r=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:i},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Ne.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==r.$watch&&"object"==typeof r.$watch?new Set(Object.keys(r.$watch)):null,keyedListPaths:null!==r.$listKeys&&"object"==typeof r.$listKeys?new Set(Object.keys(r.$listKeys)):null}}var Zr=new WeakSet,eo=new WeakMap;function to(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(Zr.has(t))return;Zr.add(t);let l=t.emit;t.emit=(...i)=>(null!==Br&&Br({type:"state:token-emit",kind:n,tokenName:t.name,args:i,subscriberCount:t.size,stateElement:e.element}),l.apply(t,i))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Ne.values())t(n,"event")}(e),"connected"===t){if(Hr.has(e))return;Hr.add(e),Br?.({type:"state:element-registered",rootNode:e.root,element:e.element}),Gr(e)}else"disconnected"===t&&(Hr.delete(e),Gr(e),Br?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function no(e,t,n,l,i,r){if(null===Br)return;let o=Kr(e,t,0===t.n?null:n),s=eo.get(e);void 0===s&&eo.set(e,s=new Set),s.add(o),r&&Br({type:"state:write",absoluteAddress:o,value:i,oldValue:l,hasOldValue:!0})}function lo(e){if(null===Br)return;let t=eo.get(e);eo.delete(e),void 0!==t&&Br({type:"state:update-batch",addresses:t}),Gr(e)}function io(e,t,n){Br?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.en(),error:t})}!function(e){for(let t of e)g.has(t.name)||(g.add(t.name),t.install())}([pn,Hn,gl,xl,Pi,Vi,Fr,{name:"devtools",install(){c.element=f(c.element,to),c.he=f(c.he,no),c.Te=f(c.Te,lo),c.Ve=f(c.Ve,io),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let e=globalThis,t=e[_r]??(e[_r]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))for(let t of e.values())n(t)}}}}());2!==t.version&&console.warn(`[@wcstack/state] devtools hook registry version ${t.version}, expected 2: keeping the existing one.`),t.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:Ji,getStateElements:()=>[...Hr].map(Qr),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.B.all()){let l=n.q,i=n.Fe?.length??0;if((null===l||0===l.size)&&0===i)continue;let r,o=0;if(null!==l)for(let e of l.values())o+=e.size;try{r=0===n.n?e.v(n,null):void 0}catch{r=void 0}t.push({path:n.t,tracked:!1,rows:o,keys:null===l?0:l.size,lists:i,lastValue:r})}return t}(Yr(e)),keys(e){let t=Yr(e).target;return Object.keys(t).filter(e=>{if(e.includes("*")||"$"===e[0])return!1;let n=Object.getOwnPropertyDescriptor(t,e);return void 0!==n.get||"function"!=typeof n.value})},read(e,t,n){let l;return Yr(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){Yr(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===Br&&null!==e;Br=e,null===e&&(Xr=new WeakMap),c.ot=e&&((e,t)=>Br?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of Hr)Gr(e)})}})}()}}]),function(e=customElements){(function(){let e=globalThis;void 0===e[Rt]&&(e[Rt]={protocol:"wcs-binder",version:1,bind:zt})})(),Gt().includes(e)||Xt.push(new WeakRef(e));let t=ee.tagNames.state;void 0===e.get(t)&&e.define(t,class extends Jt{}),c.Eo?.(e)}();
|