@wcstack/state 4.0.0-rc.6 → 4.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{d as t}from"./chunks/chunk-RGG2TYRK.js";import"./chunks/chunk-GI7MH75B.js";import"./chunks/chunk-2BGNNXNX.js";import"./chunks/chunk-XF6V6DWR.js";import"./chunks/chunk-LTBR3OV5.js";import{a as n}from"./chunks/chunk-W5KT4PQ3.js";import"./chunks/chunk-2EGTC36Y.js";import"./chunks/chunk-SPWZUBQS.js";import"./chunks/chunk-ALVA5TQM.js";import{a as s,g as o}from"./chunks/chunk-V34ZHCK5.js";var e,r=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools","native-commands"],a=(e=import.meta.url,t=>Promise.all(t.map(async t=>{if(!r.includes(t))throw new Error(`[@wcstack/state] [wcs/feature-unknown] "${t}" is not an add-on (${r.join(", ")}).`);return(await(import(new URL(`./features/${t}.js`,e).href))).default})));s.wt=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var c=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(c?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
1
+ import{d as t}from"./chunks/chunk-ARPZVNKL.js";import"./chunks/chunk-JMPQHCIT.js";import"./chunks/chunk-7EWPQMA6.js";import"./chunks/chunk-XF6V6DWR.js";import"./chunks/chunk-LTBR3OV5.js";import{a as n}from"./chunks/chunk-W5KT4PQ3.js";import"./chunks/chunk-2EGTC36Y.js";import"./chunks/chunk-SPWZUBQS.js";import"./chunks/chunk-ALVA5TQM.js";import{a as s,g as o}from"./chunks/chunk-V34ZHCK5.js";var e,r=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools","native-commands"],a=(e=import.meta.url,t=>Promise.all(t.map(async t=>{if(!r.includes(t))throw new Error(`[@wcstack/state] [wcs/feature-unknown] "${t}" is not an add-on (${r.join(", ")}).`);return(await(import(new URL(`./features/${t}.js`,e).href))).default})));s.wt=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var c=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(c?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
@@ -0,0 +1 @@
1
+ var a="4.0.0-rc.7";export{a};
@@ -0,0 +1 @@
1
+ import{j as e}from"./chunk-XF6V6DWR.js";import{a as t,d as n,e as l,j as i,k as r}from"./chunk-LTBR3OV5.js";import{a as o,g as s}from"./chunk-W5KT4PQ3.js";import{a as u}from"./chunk-2EGTC36Y.js";import{a,b as h,c,d as f,e as d,f as m,g as p,h as g,i as v,j as b,k as w,l as y,n as x}from"./chunk-SPWZUBQS.js";import{a as N,b as S}from"./chunk-ALVA5TQM.js";import{a as T}from"./chunk-V34ZHCK5.js";var k=new Map,j=new Set(["if","elseif","else","for"]),A=new Set([a,"if","elseif","for","..."]),E=new Set([d,m,p,f,h,c]);function F(e){let t=function(e){return w(e,";")}(e).map(v).filter(e=>e.length>0).map(e=>{let t=b(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(A.has(i)){let t;return i!==n&&S(102,[e,i]),i===a?(l.length>0&&S(103,[e]),t={Qe:"#else",Ze:[]}):"..."===i?(0===l.length&&S(104,[e]),t=x(l),t.Ze.length>0&&S(105,[e])):(t=x(l),"for"===i&&t.Ze.length>0&&S(121,[e])),{Se:i,$e:[i],on:[],j:[],...t,w:"..."===i?"spread":i}}let r=x(l),o=function(e){let[t,n]=y(e,"input",k),l=t.split("#").map(v);l.length>2&&S(115,[t]);let[i,r]=l,o=i.split(".").map(v);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&S(116,[e]),{Se:i,$e:o,on:r?r.split(",").map(v):[],j:n}}(n),[s]=o.$e;if(""===s&&o.$e.length>1){let e=o.$e.slice(1);return(e.includes("")||E.has(e[0]))&&S(106,[n]),{...o,Se:e.join("."),$e:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===h||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>j.has(e.w))&&S(201,[e]),t}function $(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function C(t){return 0===t.length?null:(e(),t.map(e=>s(e.Hn,e.args,e.literals)))}var L=Symbol.for("wcstack.state.view-transition-naming"),P=new WeakSet;function D(){let e=t("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var O=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),K=0,R=2,W=3,U=4,M=5,V=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],G=(e,t,n,l)=>e.Gt(t,n.o?.t??n.Rt,l,V[n.i]),I=Symbol();function B(e,t,n){let l=t.K;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.U:I}var q=class{constructor(e,t,n,l,i,r,o,s,u,a=null){this.te=!1,this.j=null,this.attribute=null,this.Tn=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.Pn=o,this.x=s,this.value=u,this._=a}nn(){return V[this.i]}apply(){if(null!==this._)return void this._.Et();let e=$(this.x,this.engine.read(this.o,this.r));if(e===this.value&&9!==this.i&&("object"!=typeof e||null===e||11===this.i||8===this.i||i(this.name)))return;if(this.value===I)return void(this.value=e);let t=this.a;if(11!==this.i)9===this.i?t.checked=void 0!==e&&this.rn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.rn()):Z(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.Tn=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.Tn=!1}null!==this.attribute&&function(e,t,n){try{if(null==n||!1===n)e.removeAttribute(t);else if(!0===n)e.setAttribute(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)}}rn(){return $(this.j,this.a.value)}ir(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.rn()}else if(10===this.i){let l=this.rn(),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=$(this.j,t[this.name]),this.value=NaN;n.T(this.o,this.r,e,!1,!0)}},Q=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Z(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(Q(n)?t[n]="innerHTML"===n?r(l):null==l?"":String(l):i(n)?null==l&&"srcdoc"===n?t.removeAttribute(n):void 0!==l&&(t[n]=r(l)):void 0!==l&&(t[n]!==l&&!("value"===n&&t.value===String(l))&&(t[n]=l),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[H]=[n,l])));case 8:return void(t.innerHTML=r(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(n.includes("-")?null==l?t.style.removeProperty(n):t.style.setProperty(n,String(l)):t.style[n]=null==l?"":String(l))}}var H=Symbol();function X(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[H];void 0!==n&&(t[n[0]]=n[1])}var z=class{constructor(e,t,n,l){this.y=!0,this.he=null,this.c=null,this.Nt=null,this.Fn=null,this.r=e,this.Ue=t,this.D=n,this.F=l}Qo(e,t){let n=t.target,l=this.F,i=[],r=null;for(let t of l.Re){if(t.name!==e)continue;let o=l.On[t.a],s=ue(null===this.D?this.Ue:this.D[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.An(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.D?this.Ue:this.D[this.D.length-1]}qe(){let e=this.Fn;return(null===e?null:e.Cn(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}}wo(){null===this.D?this.Ue.remove():ae(this.qe(),this.s)}xe(e){if(this.y=!1,null!==this.Nt)for(let e of this.Nt)e();let t=this.he;if(null!==t)for(let n=0;n<t.length;n++)e.Nn(t[n]);if(null!==this.c)for(let e of this.c)e.xe()}},_=class extends z{constructor(e,t,n,l){super(e,t,n,l),this.bo=0,this.V=null,this.fe=0===l.ze.length?null:new Array(2*l.ze.length)}vo(e,t){let n=this.V??=new Array(this.F.ze.length),l=n[t];if(void 0===l){let i=this.F.ze[t],r=this.fe;l=n[t]=new q(e,i.i,r[2*t],i.name,i.o,this.r,this,i.x,r[2*t+1])}return l}uo(e,t){let n=this.F.ze;for(let l=0;l<n.length;l++)n[l].o.ee(t)&&e.en(this.vo(e,l))}xe(e){let t=this.r;t.E===this&&(t.E=null),super.xe(e)}};function J(e,t,n,i){let r=l(n,t.n);try{return e.We(r,t)}catch(n){return e.Gt(n,t.t,i,"for"),null===r?e.oe.get(t):r.c.get(t)}}function Y(e,t,n){n&&e.nr(t);let l=t.Pn;null!==l&&(l.he??=[]).push(t)}var ee=null;function te(){let e=ee;return ee=null,e}var ne=-1;function le(e,t,n,l,i=null){let r,o=t.On,s=t.build,u=t.ko,a=null,h=T.Oe?.(t,null===l?i:l.S,null!==l),c=!h&&t.In,f=h?document.createDocumentFragment():(c?t.root:t.sn).cloneNode(!0);if(!h)for(let e=0;e<s.length;e++){let t=s[e];u[t]=ue(f,o[t],c?1:0)}c?r=f:(a=h||[...f.childNodes],r=a[0]);let d,m=null;if(null!==l?(d=m=new _(n,r,a,t),null===l.map?n.E=m:l.map.set(n,m)):d=new z(n,r,a,t),ne>=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||P.has(i))return;let o=globalThis[L]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${N(25,[l])}`)):(P.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,a,null!==l?"row":"branch",ne),t.Re.length>0){let t=e.Kn;if(null===a)r[t]=d;else for(let e of a)1===e.nodeType&&(e[t]=d)}let p=t.sr,g=e.De,v=t.lr?u.slice(0,o.length):u,b=null===m?null:m.fe;if(null!==b){let e=t.ze;for(let t=0;t<e.length;t++)b[2*t]=v[e[t].a],b[2*t+1]=e[t].U}for(let t=0;t<p.length;t++){let l=p[t],i=v[l.a],o=l.A;if(o>=0&&null!==b){let t=m.V?.[o];if(void 0!==t){t.te=!1,e.Ve(t);continue}try{let t=$(l.x,e.read(l.o,n));t!==l.U&&(Z(l.i,i,l.name,t),b[2*o+1]=t),null!==g&&e.po(l.o,n)}catch(t){e.xt(t,m.vo(e,o))}continue}switch(l.i){case 6:{let t=new se(e,l.F,J(e,l.o,n,i),i);(d.c??=[]).push(t),i===r&&(d.Fn=t),t.Et();break}case 7:{let t=re(e,l.G.map(e=>({F:e.F,o:e.o,x:e.x,S:v[e.a]})),n,d);(d.c??=[]).push(t),i===r&&(d.Fn=t);break}default:try{ie(e,l,i,n,d)}catch(t){G(e,t,l,i)}}}return ee=d,f}function ie(e,t,n,i,r){let o=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.An,o=e=>r(e,l);if(n.et){let l=e.ao(n.name),i=t[l];t[l]=void 0===i?o:e=>{i(e),o(e)},n.Ee&&t.addEventListener(n.name,e=>e.bubbles||o(e))}else t.addEventListener(n.name,o),n.yo&&null!==i&&(i.Nt??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,i,r);case 12:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.Rt.slice(9)),s=null===i?T.or?.(n,r):null;s||(null===i&&me(1202,n,`command.${r}`),i.commands.has(r)||S(1203,[n.localName,r]));let u=new WeakRef(n),a=o.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?s?s(t,e):t[r](...e):void 0;a()});null!==l&&(l.Nt??=[]).push(a)}(e,t,o,r,n));case 13:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name;null===i&&me(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&S(1204,[n.localName,r]);let s=t.Rt;n.addEventListener(o.event,n=>{t.Pt&&n.preventDefault(),t.Tt&&n.stopPropagation();try{e.Zo(s,n,l)}catch(e){console.error(e)}})}(e,t,o,i,n))}let s=t.o,u=l(i,s.n);if(14===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){null===r&&me(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs.keys()]);for(let s of o){if(t.go?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),u=0===o.n?null:l;de(e,{...t,K:null,X:null},n,s,o,u,i,r)}}(e,t,o,u,r,n));if(t.Ee&&1===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){if(null!==r)return void de(e,t,n,t.name,t.o,l,i,r);let o=new q(e,1,n,t.name,t.o,l,i,t.x,B(e,t,l));o.j=t.j,!T.ar?.(o,t.ro)&&(Y(e,o,!0),e.Ve(o))}(e,t,o,u,r,n));let a=new q(e,t.i,n,t.name,s,u,r,t.x,B(e,t,u));a.j=t.j,Y(e,a,!0),e.Ve(a),null!==t.At&&n.addEventListener(t.At,()=>a.ir())}function re(e,t,n,i){let r=new oe(e,t,n),o=null;for(let s of t){if(null===s.o)continue;let t=s.o,u=new q(e,7,s.S,"if",t,l(n,t.n),i,null,void 0,r);Y(e,u,!0),null===i&&r.ce.push(u),o??=u}return e.Ve(o),r}var oe=class{constructor(e,t,n){this.y=!0,this.O=null,this.b=-1,this.ce=[],this.engine=e,this.G=t,this.r=n}Cn(e){return null!==this.O&&this.G[this.b].S===e?this.O.qe():null}Et(){let e=this.engine,t=-1;for(let n=0;n<this.G.length;n++){let i=this.G[n];if(null===i.o||$(i.x,e.read(i.o,l(this.r,i.o.n)))){t=n;break}}if(t!==this.b&&(ne=D(),null!==this.O&&(this.O.wo(),this.O.xe(e),this.O=null),this.b=t,t>=0)){let n=this.G[t],l=le(e,n.F,this.r,null,n.S);this.O=te();let i=n.S.parentNode;i.insertBefore(l,n.S),X(i)}}xe(){this.y=!1;for(let e of this.ce)this.engine.Nn(e);null!==this.O&&this.O.xe(this.engine)}},se=class{constructor(e,t,n,l){this.y=!0,this.Ne=[],this.engine=e,this.F=t,this.l=n,this.S=l,null===n.E?(n.E=this,this.map=null):((n.L??=[]).push(this),this.map=new Map)}Cn(e){return 0===this.Ne.length?null:this.Ne[0].qe()}Ft(e){return null===this.map?e.E:this.map.get(e)??null}Dt(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.xe(this.engine)}Et(){let e=this.engine,t=this.l.f,n=this.Ne;ne=D();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){let e=n[0].qe(),t=n[i-1].s,l=[];for(let n=o.firstChild;null!==n;n=n===e?t.nextSibling:n.nextSibling)if(n!==e){if(n!==r&&3!==n.nodeType){l=null;break}l.push(n)}null!==l?o.replaceChildren(...l):ae(e,t);for(let e=0;e<i;e++)this.Dt(n[e])}return void(this.Ne=[])}let s=new Array(l),u=0;for(;u<l&&u<i&&this.Ft(t[u])===n[u];)s[u]=n[u],u++;let a=i-1,h=l-1;for(;a>=u&&h>=u&&this.Ft(t[h])===n[a];)s[h]=n[a],a--,h--;for(let e=u;e<=a;e++){let t=n[e],l=t.r;l.y&&this.Ft(l)===t?t.bo=e:(t.wo(),this.Dt(t))}if(u<=h){let n=h-u+1,a=new Int32Array(n),c=!1;if(i>0)for(let e=0;e<n;e++){let n=this.Ft(t[u+e]);null!==n&&n.y?(a[e]=n.bo,c=!0):a[e]=-1}let f=h+1<l?s[h+1].qe():r;if(c){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}(a),i=f;for(let r=n-1;r>=0;r--){let n=t[u+r],a=this.Ft(n);null!==a&&a.y?0===l[r]&&a.insertBefore(o,i):(o.insertBefore(le(e,this.F,n,this),i),a=te()),s[u+r]=a,i=a.qe()}}else{let n=document.createDocumentFragment();for(let l=u;l<=h;l++)n.appendChild(le(e,this.F,t[l],this)),s[l]=te();o.insertBefore(n,f)}}this.Ne=s,X(o)}xe(){this.y=!1;let e=this.l;if(e.E===this)e.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.Ne)e.xe(this.engine);this.map?.clear()}};function ue(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 ae(e,t){for(let n,l=e;l!==t;l=n)n=l.nextSibling,l.remove();t.remove()}var he=new WeakMap,ce=e=>e.customElementRegistry??customElements;function fe(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=ce(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>fe(e,t,n,l,i,!0));let u=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(he.has(e))return he.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,ho:"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 he.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return u();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.Nt??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{u()}catch(l){G(e,l,t,n)}e.Te()})}function de(e,t,n,l,i=t.o,r,o,s){let u=s.properties.get(l)??null,a=s.inputs.get(l),h=e._t;h&&null===u&&void 0===a&&S(38,[l]);let c=t.K;(null===u?"element"===c||"auto"===c:void 0===a&&("state"===c||"auto"===c))&&S(39,[c,l]),"connect"===t.X&&null===u&&S(40,[l]);let f=h&&null!==u&&void 0===a,d=new q(e,11,n,l,i,r,o,t.x,void 0);d.j=t.j,d.attribute=a?.attribute??null,Y(e,d,!f),null!==u&&!t.ro&&n.addEventListener(u.event,t=>{let i;null!==u.getter?i=u.getter(t):(i=t.detail,u.ho||T.detail?.(n,l,i)),(!d.Tn||!Object.is(i,d.value))&&(i=$(d.j,i),null===d.x&&(d.value=i),e.T(d.o,d.r,i,u.ho,!0))});let m=c??(f?"element":"state");if("state"===m)f||e.Ve(d);else if("element"===m||"auto"===m){let i=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==e.v(d.o,d.r))return void(f||e.Ve(d));let t=n[l];null===d.x&&(d.value=t),e.T(d.o,d.r,t,!1,!0)};"connect"!==t.X||n.isConnected?i():Promise.resolve().then(i)}return d}function me(e,t,n){S(e,[t.localName,n])}var pe=()=>o.bindAttributeName;function ge(){return{a:0,i:1,name:"",o:null,x:null,U:u,An:null,F:null,G:null,j:null,At:null,Ee:!1,K:null,X:null,ro:!1,Pt:!1,Tt:!1,Rt:null,go:null,A:-1,et:!1,yo:!1}}var ve=["state","element","auto","none"],be=["call","connect"],we="$command.";function ye(e,t,n){g.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.h[e];l.h[e]!==t&&S(1403,[l.t,l.h[e].t,t.t])}return T.So?.(e,l),l}var xe=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),Ne=e=>8===e.i||xe(e)||1===e.i&&Q(e.name);function Se(e){S(202,[e])}function Te(e,t,l,r,o){let s=F(t).map(t=>function(e,t,l,r,o){let s=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._t||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?ve:be).includes(o)||S(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),Pt:t.includes("prevent"),Tt:t.includes("stop"),event:n?n.slice(2):null,K:l,X:i}}(e,t.on),u=r.localName.includes("-"),a=t.$e,h=t.Qe;if("event"===t.w){if(null!==s.K&&"none"!==s.K&&S(36),"eventToken"===a[0])return{...ge(),a:o,i:13,name:a.slice(1).join("."),Rt:h,Ee:u,Pt:s.Pt,Tt:s.Tt};let l=h.startsWith(we)?h.slice(9):null,{Pt:i,Tt:r}=s,c=t.Se.slice(2),f=t.on.includes("direct"),d=!f&&O.has(c);return d&&e.ao(c),{...ge(),a:o,i:5,name:c,et:d,Ee:u,yo:f,An(t,o){i&&t.preventDefault(),r&&t.stopPropagation();try{if(null!==l)e.er(l,t,o);else{let l=e.tr(h,t,o);n(l)&&l.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...ge(),a:o,i:14,o:ye(e,h,l),Ee:u};if("command"===a[0]&&a.length>1)return h.startsWith(we)||S(1201,[t.Se,h]),{...ge(),a:o,i:12,name:a.slice(1).join("."),Rt:h,Ee:u};let c=ye(e,h,l),f={...ge(),a:o,i:1,name:t.Se,o:c,x:C(t.Ze),j:C(t.j),ro:s.ro,K:s.K,X:s.X};if("radio"===t.w||"checkbox"===t.w)return("element"===s.K||"auto"===s.K)&&S(37,[t.w,s.K]),f.i="radio"===t.w?9:10,s.ro||(f.At=s.event??"input"),f;if(a.length>1){let e=a.slice(1).join("."),t=a[0];if("class"===t||"attr"===t||"style"===t)return f.K=null,f.name=e,"class"===t?(f.i=2,f.U=r.classList.contains(e)):f.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,f}return"html"===t.Se?(f.i=8,f):(f.name="text"===t.Se?"textContent":t.Se,f.Ee=u&&!i(f.name),!u&&!s.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}(r,f.name)&&(f.At=s.event??("select"===r.localName?"change":"input")),f)}(e,t,l,r,o));for(let e=0;e<s.length;e++)14===s[e].i&&(s[e].go=s.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return s}var ke=/\{\{([\s\S]+?)\}\}/g;function je(e){let t=e.data,n=[],l=0;ke.lastIndex=0;for(let i=ke.exec(t);null!==i;i=ke.exec(t)){let r=ke.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,cr:i[1].trim()}),l=ke.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function Ae(e,t,n,l){let i=function(e){return{Se:"textContent",$e:["textContent"],on:[],j:[],...x(e),w:"text"}}(t);return{...ge(),a:l,i:0,o:ye(e,i.Qe,n),x:C(i.Ze),U:""}}function Ee(e){let t=e.getAttribute(pe());if(null===t)return null;let n=F(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var Fe=(e,t)=>0===e?o.commentIfPrefix:null===t.o?o.commentElsePrefix:o.commentElseIfPrefix;function $e(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:ye(e,l.Qe,n),x:"else"===l.w?null:C(l.Ze)}),i=[l(t,Ee(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=Ee(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var Ce=new WeakSet;function Le(e,t,n,l,i,r,s,u){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&T.jn?.(e,i,t),i},h=t=>{for(let c=0;c<t.length;c++){let f=t[c];if(null!==f.parentNode)if(1===f.nodeType){let t=f,u=t.localName;if(l){if("script"===u||"style"===u||Ce.has(t))continue;if(Ce.add(t),u===o.tagNames.state){h([...t.childNodes]);continue}}let c="template"===u?Ee(t):null;if(null!==c){if("for"===c.w){let l=ye(e,c.Qe,n),r=Oe(e,t,l,!0);i(a(t,o.commentForPrefix),l,r)}else"if"===c.w?r($e(e,t,n).map((t,l)=>({F:Oe(e,t.el,n,!1),o:t.o,x:t.x,S:a(t.el,Fe(l,t))}))):Se(c.w);continue}let d=t.getAttribute(pe()),m=null===d?null:Te(e,d,n,t,0),p="noscript"!==u&&"iframe"!==u&&!m?.some(Ne)&&!T.$o?.(t);try{l&&p&&h([...t.childNodes])}finally{null!==m&&s(t,m)}!l&&p&&h([...t.childNodes])}else if(3===f.nodeType&&e.Mt&&f.data.includes("{{")&&!Ce.has(f))for(let{a:e,cr:t}of je(f))u(e,t);else if(8===f.nodeType){let e=Pe.exec(f.data),t=e&&f.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");f.replaceWith(t),u(t,e[1])}}}};h(t)}var Pe=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,De=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Oe(e,t,n,l){let i=document.importNode(De(t),!0),r=[],o=[],s=e=>r.push(e)-1;Le(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...ge(),a:s(e),i:6,o:t,F:n})},e=>{let t=e.map(e=>({a:s(e.S),F:e.F,o:e.o,x:e.x}));o.push({...ge(),a:t[0].a,i:7,G:t})},(e,t)=>{let n=s(e);for(let e of t)xe(e)&&S(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(pe())},(t,l)=>{o.push(Ae(e,l,n,s(t)))}),Ue(i,new Set(r),!0);let u=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)),a=1===i.childNodes.length&&8!==i.firstChild.nodeType,h=o.some(e=>6===e.i||7===e.i),c=[],f=new Set,d=[],m=[],p=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.et&&!e.Ee&&!Ke(r[e.a],i)){d.push(e);continue}m.push(e);let t=e.o;if(null!==t&&t.n===p&&t.h[p]===n&&Re(e)&&(e.A=c.push(e)-1),7===e.i)for(let t of e.G)f.add(t.a);else f.add(e.a)}let g=[...f].sort((e,t)=>e-t);return{sn:i,root:a?i.firstChild:null,On:u,build:g,Re:d,sr:m,In:a,lr:h,ko:[],ze:c}}function Ke(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 Re(e){if(null!==e.K)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.Ee&&null===e.At;default:return!1}}var We=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Ue(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&&Ue(l,t,We.has(l.localName)),l=e}}var Me=new WeakMap;function Ve(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Me.set(t,e),Ie(e,[...n.childNodes]),e.He()}function Ge(e,t,n){try{let l="template"===t.localName?Ee(t):null;null!==l&&!n&&S(204,[l.w]),Ie(e,[t])}catch(e){console.error(e)}e.He()}function Ie(e,t){Le(e,t,null,!0,(t,n,l)=>{new se(e,l,J(e,n,null,t),t).Et()},t=>{re(e,t,null,null)},(t,n)=>{T.jn?.(e,t,n);for(let l of n)ie(e,l,t,null,null)},(t,n)=>{T.jn?.(e,t,n),ie(e,Ae(e,n,null,0),t,null,null)})}export{F as a,ce as b,K as c,R as d,W as e,U as f,M as g,_ as h,se as i,xe as j,Ne as k,Ce as l,De as m,Me as n,Ve as o,Ge as p};
@@ -1 +1 @@
1
- import{b as t,c as e,d as s}from"./chunk-GI7MH75B.js";import{n as i,o as n}from"./chunk-2BGNNXNX.js";import{f as o}from"./chunk-LTBR3OV5.js";import{a,b as r}from"./chunk-W5KT4PQ3.js";import{a as l,b as c}from"./chunk-ALVA5TQM.js";import{a as h,h as u,i as d}from"./chunk-V34ZHCK5.js";var m=0,f=new WeakMap;function p(t,e=t.getRootNode()){f.set(e,[...f.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function g(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?g(t):Promise.reject(i.errors[0]):void 0)}var b=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends b{constructor(){super(),this.engine=null,this.Dn=!1,this.Ke=!1,this.U=null,this.Ye=null,this.loaded=!1,this.cn=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.an=t,this.Eo=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.ln=t})}static{this.getBindingsReady=g}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Dn){if(null!==this.Ye)return void this.Ye.Xe();p(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Dn=!0;let e=this.getRootNode(),s=h.at?.(this,e);if(s)return this.Ye=s,!s.No&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.wt?this.Ro():s.wt()).then(t=>(this.loaded=!0,s.start(t,()=>this.Po()))).then(()=>{this.ln(),this.an()},t=>this.xt(t,s.No));this.start(e),p(this)}disconnectedCallback(){if(null!==this.Ye)return void this.Ye.Ln();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.xo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ke&&c(14),this.loaded)this.Ye.reset(t);else if(null===this.engine)if(null!==this.cn){let e=this.cn;this.cn=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.je++;try{e(s.proxy)}finally{"readonly"===t&&s.je--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++m}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.cn=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.Dn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Ye)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.En(),this.Po(),await f.ke("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.an()}catch(t){this.Ke=!this.V,this.xt(t)}}Po(){this.V=!0,this.ln()}xt(t,e){this.He(this.V?50:49,t),this.ln(),e?this.an():this.Eo(t)}He(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);console.error(`[@wcstack/state] ${l(t,[this.localName,...s])}`,e)}xo(t,e,s){(async()=>this.engine.ke(t))().then(s,t=>this.He(e,t))}},y=[];function k(){return(y=y.filter(t=>t.deref())).map(t=>t.deref())}function v(t,s){t&&r(t),function(t=customElements){e(),k().includes(t)||y.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends w{}),h.To?.(t)}(s)}var R=t=>g(t);export{g as a,b,k as c,v as d,R as e};
1
+ import{b as t,c as e,d as s}from"./chunk-JMPQHCIT.js";import{n as i,o as n}from"./chunk-7EWPQMA6.js";import{f as o}from"./chunk-LTBR3OV5.js";import{a,b as r}from"./chunk-W5KT4PQ3.js";import{a as l,b as c}from"./chunk-ALVA5TQM.js";import{a as h,h as u,i as d}from"./chunk-V34ZHCK5.js";var m=0,f=new WeakMap;function p(t,e=t.getRootNode()){f.set(e,[...f.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function g(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?g(t):Promise.reject(i.errors[0]):void 0)}var b=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends b{constructor(){super(),this.engine=null,this.Dn=!1,this.Ke=!1,this.U=null,this.Ye=null,this.loaded=!1,this.cn=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.an=t,this.Eo=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.ln=t})}static{this.getBindingsReady=g}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Dn){if(null!==this.Ye)return void this.Ye.Xe();p(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Dn=!0;let e=this.getRootNode(),s=h.at?.(this,e);if(s)return this.Ye=s,!s.No&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.wt?this.Ro():s.wt()).then(t=>(this.loaded=!0,s.start(t,()=>this.Po()))).then(()=>{this.ln(),this.an()},t=>this.xt(t,s.No));this.start(e),p(this)}disconnectedCallback(){if(null!==this.Ye)return void this.Ye.Ln();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.xo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ke&&c(14),this.loaded)this.Ye.reset(t);else if(null===this.engine)if(null!==this.cn){let e=this.cn;this.cn=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.je++;try{e(s.proxy)}finally{"readonly"===t&&s.je--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++m}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.cn=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.Dn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Ye)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.En(),this.Po(),await f.ke("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.an()}catch(t){this.Ke=!this.V,this.xt(t)}}Po(){this.V=!0,this.ln()}xt(t,e){this.He(this.V?50:49,t),this.ln(),e?this.an():this.Eo(t)}He(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);console.error(`[@wcstack/state] ${l(t,[this.localName,...s])}`,e)}xo(t,e,s){(async()=>this.engine.ke(t))().then(s,t=>this.He(e,t))}},y=[];function k(){return(y=y.filter(t=>t.deref())).map(t=>t.deref())}function v(t,s){t&&r(t),function(t=customElements){e(),k().includes(t)||y.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends w{}),h.To?.(t)}(s)}var P=t=>g(t);export{g as a,b,k as c,v as d,P as e};
@@ -1 +1 @@
1
- import{n as t,p as n}from"./chunk-2BGNNXNX.js";import{a as l,b as e,c as r}from"./chunk-2EGTC36Y.js";import{a as o}from"./chunk-V34ZHCK5.js";var i=Symbol.for("wcstack.binder"),u=Symbol.for("wcstack.binder.pending"),s=Symbol.for("wcstack.binder.taken");var a=new Map;function f(l,e){if(1!==l.nodeType||!l.isConnected)return;let r=t.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?a.set(l,e):n(r,l,e?.range)}function c(){let t=[...a];a.clear();for(let[n,l]of t)f(n,l);!function(){let t=function(){let t=globalThis[i];return null==t||"wcs-binder"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.bind?null:t}();if(null===t)return;let n=function(){let t=globalThis,n=t[u];return void 0===n&&(n=[],t[u]=n),n}();if(0===n.length)return;let l=n.splice(0,n.length),e=function(){let t=globalThis,n=t[s];return void 0===n&&(n=new WeakSet,t[s]=n),n}();for(let n of l)e.add(n),t.bind(n)}()}function h(){let t=globalThis;void 0===t[i]&&(t[i]={protocol:"wcs-binder",version:1,bind:f})}var d=class{constructor(){this.name="dirty",this.Z=(t,n)=>{if(0===t.n){let n=t.z;return n!==l&&n!==e&&(t.z=e,!0)}let r=null===n?null:n.ht;if(null===r)return!1;let o=r[t.A];return o!==l&&o!==e&&(r[t.A]=e,!0)}}Jo(t,n,l){null!==n.getter&&this.Z(n,l),t.$t(n,l),t.xn(n,l,this.Z)}Ho(t,n){let l=n.l.o.It;if(null!==l)for(let e of l)e.n===n.l.n?t.it(e,n,this.Z):t.Zt(n,e,n=>t.it(e,n,this.Z))}we(t,n,l){this.Z(n,l),o.ve?.(t,n,l),t.$t(n,l),t.xn(n,l,this.Z)}Ko(t,n,o){let i=0===n.n;if(!i&&null===o)return;let u=i?null:o.ht??=new Array(t.Ie).fill(l),s=null===u?n.z:u[n.A];if(s!==l&&s!==e&&s!==r&&(null===u||n.A in u))return s;s=r;try{return s=t.Uo(n,null===u?null:o)}finally{null===u?n.z=s:u[n.A]=s}}Yt(t){t.ht=null}vt(t){for(let n of t.I.all())null!==n.getter&&(0===n.n?n.z===e&&(n.z=r):t.tn(n.h[n.n],t=>{let l=t.ht;null!==l&&l[n.A]===e&&(l[n.A]=r)}))}};export{f as a,c as b,h as c,d};
1
+ import{n as t,p as n}from"./chunk-7EWPQMA6.js";import{a as l,b as e,c as r}from"./chunk-2EGTC36Y.js";import{a as o}from"./chunk-V34ZHCK5.js";var i=Symbol.for("wcstack.binder"),u=Symbol.for("wcstack.binder.pending"),s=Symbol.for("wcstack.binder.taken");var a=new Map;function f(l,e){if(1!==l.nodeType||!l.isConnected)return;let r=t.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?a.set(l,e):n(r,l,e?.range)}function c(){let t=[...a];a.clear();for(let[n,l]of t)f(n,l);!function(){let t=function(){let t=globalThis[i];return null==t||"wcs-binder"!==t.protocol||"number"!=typeof t.version||t.version<1||"function"!=typeof t.bind?null:t}();if(null===t)return;let n=function(){let t=globalThis,n=t[u];return void 0===n&&(n=[],t[u]=n),n}();if(0===n.length)return;let l=n.splice(0,n.length),e=function(){let t=globalThis,n=t[s];return void 0===n&&(n=new WeakSet,t[s]=n),n}();for(let n of l)e.add(n),t.bind(n)}()}function h(){let t=globalThis;void 0===t[i]&&(t[i]={protocol:"wcs-binder",version:1,bind:f})}var d=class{constructor(){this.name="dirty",this.Z=(t,n)=>{if(0===t.n){let n=t.z;return n!==l&&n!==e&&(t.z=e,!0)}let r=null===n?null:n.ht;if(null===r)return!1;let o=r[t.A];return o!==l&&o!==e&&(r[t.A]=e,!0)}}Jo(t,n,l){null!==n.getter&&this.Z(n,l),t.$t(n,l),t.xn(n,l,this.Z)}Ho(t,n){let l=n.l.o.It;if(null!==l)for(let e of l)e.n===n.l.n?t.it(e,n,this.Z):t.Zt(n,e,n=>t.it(e,n,this.Z))}we(t,n,l){this.Z(n,l),o.ve?.(t,n,l),t.$t(n,l),t.xn(n,l,this.Z)}Ko(t,n,o){let i=0===n.n;if(!i&&null===o)return;let u=i?null:o.ht??=new Array(t.Ie).fill(l),s=null===u?n.z:u[n.A];if(s!==l&&s!==e&&s!==r&&(null===u||n.A in u))return s;s=r;try{return s=t.Uo(n,null===u?null:o)}finally{null===u?n.z=s:u[n.A]=s}}Yt(t){t.ht=null}vt(t){for(let n of t.I.all())null!==n.getter&&(0===n.n?n.z===e&&(n.z=r):t.tn(n.h[n.n],t=>{let l=t.ht;null!==l&&l[n.A]===e&&(l[n.A]=r)}))}};export{f as a,c as b,h as c,d};
@@ -1 +1 @@
1
- import{a as s}from"./chunks/chunk-7EPYU3C5.js";import{a as n,d as t,e as u}from"./chunks/chunk-RGG2TYRK.js";import"./chunks/chunk-GI7MH75B.js";import"./chunks/chunk-2BGNNXNX.js";import"./chunks/chunk-XF6V6DWR.js";import{g as a,h as c,i as h}from"./chunks/chunk-LTBR3OV5.js";import{c as i}from"./chunks/chunk-W5KT4PQ3.js";import"./chunks/chunk-2EGTC36Y.js";import"./chunks/chunk-SPWZUBQS.js";import"./chunks/chunk-ALVA5TQM.js";import{g as o}from"./chunks/chunk-V34ZHCK5.js";function r(s){return s}export{a as TRUSTED_TYPES_POLICY_SLOT,s as VERSION,t as bootstrapState,u as buildBindings,r as defineState,n as getBindingsReady,i as getConfig,c as getTrustedTypesPolicy,o as installFeatures,h as setTrustedTypesPolicy};
1
+ import{a as s}from"./chunks/chunk-27N3IPIZ.js";import{a as n,d as t,e as u}from"./chunks/chunk-ARPZVNKL.js";import"./chunks/chunk-JMPQHCIT.js";import"./chunks/chunk-7EWPQMA6.js";import"./chunks/chunk-XF6V6DWR.js";import{g as a,h as c,i as h}from"./chunks/chunk-LTBR3OV5.js";import{c as i}from"./chunks/chunk-W5KT4PQ3.js";import"./chunks/chunk-2EGTC36Y.js";import"./chunks/chunk-SPWZUBQS.js";import"./chunks/chunk-ALVA5TQM.js";import{g as o}from"./chunks/chunk-V34ZHCK5.js";function r(s){return s}export{a as TRUSTED_TYPES_POLICY_SLOT,s as VERSION,t as bootstrapState,u as buildBindings,r as defineState,n as getBindingsReady,i as getConfig,c as getTrustedTypesPolicy,o as installFeatures,h as setTrustedTypesPolicy};
@@ -1 +1 @@
1
- import{a as e}from"../chunks/chunk-7EPYU3C5.js";import{c as t,d as n,e as l,f as o,g as s,h as r,i as a,n as i}from"../chunks/chunk-2BGNNXNX.js";import"../chunks/chunk-XF6V6DWR.js";import"../chunks/chunk-LTBR3OV5.js";import"../chunks/chunk-W5KT4PQ3.js";import"../chunks/chunk-2EGTC36Y.js";import"../chunks/chunk-SPWZUBQS.js";import"../chunks/chunk-ALVA5TQM.js";import{a as u,b as d}from"../chunks/chunk-V34ZHCK5.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,p=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),h=new WeakMap,k=0;var v=new WeakMap;function g(e){if(null===c)return;let i=v.get(e),u=m.has(e)?function(e,i){let u=new Map,d=new Set,f=(r,a,d,f,c,m)=>{if(r===s)return;let v=function(e,s){return e===t?"textContent":e===n?`class.${s}`:e===l?`attr.${s}`:e===o?`style.${s}`:s}(r,a),g=0===f.n?null:c,w=`${(e=>{let t=h.get(e);return void 0===t&&h.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e.H(g).join(",")}`;if(u.has(w))return;let y=i?.get(w);u.set(w,y??{binding:{propName:v,statePathName:f.t,bindingType:m,node:d,replaceNode:d},absoluteAddress:p(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.nn()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.he)for(let t of e.he)c(t);if(e instanceof r&&null!==e.fe){let n=e.F.ze;for(let l=0;l<n.length;l++){let o=e.V?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.fe[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.c)for(let t of e.c)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.l.o,e.l.ae,"for");for(let t of e.Ne)m(t)}else null!==e.O&&m(e.O)};for(let t of e.ce.values())for(let e of t)c(e),null!==e._&&v(e._);for(let t of e.oe.values())if(null!==t.E&&v(t.E),null!==t.L)for(let e of t.L)v(e);return u}(e,i):new Map;if(void 0!==i)for(let[e,t]of i)u.has(e)||c({type:"state:binding-removed",...t});for(let[e,t]of u)(void 0===i||!i.has(e))&&c({type:"state:binding-added",...t});v.set(e,u)}function w(e){let t=i.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function y(e){let t=new Set,n=new Set,l=new Set,o=new Set;for(let s of e.I.all()){for(let e=1;e<=s.n;e++)t.add(s.h[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.ie&&o.add(s.t)}let s=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:o},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Re.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==s.$watch&&"object"==typeof s.$watch?new Set(Object.keys(s.$watch)):null,keyedListPaths:null!==s.$listKeys&&"object"==typeof s.$listKeys?new Set(Object.keys(s.$listKeys)):null}}var S=new WeakSet,b=new WeakMap;function j(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(S.has(t))return;S.add(t);let l=t.emit;t.emit=(...o)=>(null!==c&&c({type:"state:token-emit",kind:n,tokenName:t.name,args:o,subscriberCount:t.size,stateElement:e.element}),l.apply(t,o))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Re.values())t(n,"event")}(e),"connected"===t){if(m.has(e))return;m.add(e),c?.({type:"state:element-registered",rootNode:e.root,element:e.element}),g(e)}else"disconnected"===t&&(m.delete(e),g(e),c?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function $(e,t,n,l,o,s){if(null===c)return;let r=p(e,t,0===t.n?null:n),a=b.get(e);void 0===a&&b.set(e,a=new Set),a.add(r),s&&c({type:"state:write",absoluteAddress:r,value:o,oldValue:l,hasOldValue:!0})}function O(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function N(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.nn(),error:t})}var E={name:"devtools",install(){u.element=d(u.element,j),u.be=d(u.be,$),u.Fe=d(u.Fe,O),u.Ke=d(u.Ke,N),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=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!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.I.all()){let l=n.W,o=n.Ce?.length??0;if((null===l||0===l.size)&&0===o)continue;let s,r=0;if(null!==l)for(let e of l.values())r+=e.size;try{s=0===n.n?e.v(n,null):void 0}catch{s=void 0}t.push({path:n.t,tracked:!1,rows:r,keys:null===l?0:l.size,lists:o,lastValue:s})}return t}(w(e)),keys(e){let t=w(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 w(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){w(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===c&&null!==e;c=e,null===e&&(v=new WeakMap),u.st=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},M=E;export{M as default,E as devtools};
1
+ import{a as e}from"../chunks/chunk-27N3IPIZ.js";import{c as t,d as n,e as l,f as o,g as s,h as r,i as a,n as i}from"../chunks/chunk-7EWPQMA6.js";import"../chunks/chunk-XF6V6DWR.js";import"../chunks/chunk-LTBR3OV5.js";import"../chunks/chunk-W5KT4PQ3.js";import"../chunks/chunk-2EGTC36Y.js";import"../chunks/chunk-SPWZUBQS.js";import"../chunks/chunk-ALVA5TQM.js";import{a as u,b as d}from"../chunks/chunk-V34ZHCK5.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,p=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e.H(n)}}),h=new WeakMap,k=0;var v=new WeakMap;function g(e){if(null===c)return;let i=v.get(e),u=m.has(e)?function(e,i){let u=new Map,d=new Set,f=(r,a,d,f,c,m)=>{if(r===s)return;let v=function(e,s){return e===t?"textContent":e===n?`class.${s}`:e===l?`attr.${s}`:e===o?`style.${s}`:s}(r,a),g=0===f.n?null:c,w=`${(e=>{let t=h.get(e);return void 0===t&&h.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e.H(g).join(",")}`;if(u.has(w))return;let y=i?.get(w);u.set(w,y??{binding:{propName:v,statePathName:f.t,bindingType:m,node:d,replaceNode:d},absoluteAddress:p(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.nn()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.he)for(let t of e.he)c(t);if(e instanceof r&&null!==e.fe){let n=e.F.ze;for(let l=0;l<n.length;l++){let o=e.V?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.fe[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.c)for(let t of e.c)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.l.o,e.l.ae,"for");for(let t of e.Ne)m(t)}else null!==e.O&&m(e.O)};for(let t of e.ce.values())for(let e of t)c(e),null!==e._&&v(e._);for(let t of e.oe.values())if(null!==t.E&&v(t.E),null!==t.L)for(let e of t.L)v(e);return u}(e,i):new Map;if(void 0!==i)for(let[e,t]of i)u.has(e)||c({type:"state:binding-removed",...t});for(let[e,t]of u)(void 0===i||!i.has(e))&&c({type:"state:binding-added",...t});v.set(e,u)}function w(e){let t=i.get(e);if(void 0===t)throw new Error("[@wcstack/state] devtools: no state tree on this root");return t}function y(e){let t=new Set,n=new Set,l=new Set,o=new Set;for(let s of e.I.all()){for(let e=1;e<=s.n;e++)t.add(s.h[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.ie&&o.add(s.t)}let s=e.target;return{rootNode:e.root,element:e.element,paths:{list:t,element:n,getter:l,setter:o},commandTokenNames:new Set(Object.keys(e.commands)),eventTokenNames:new Set(e.Re.keys()),staticDependency:new Map,dynamicDependency:new Map,watchPaths:null!==s.$watch&&"object"==typeof s.$watch?new Set(Object.keys(s.$watch)):null,keyedListPaths:null!==s.$listKeys&&"object"==typeof s.$listKeys?new Set(Object.keys(s.$listKeys)):null}}var S=new WeakSet,b=new WeakMap;function j(e,t){if(("mounting"===t||"reset"===t)&&function(e){let t=(t,n)=>{if(S.has(t))return;S.add(t);let l=t.emit;t.emit=(...o)=>(null!==c&&c({type:"state:token-emit",kind:n,tokenName:t.name,args:o,subscriberCount:t.size,stateElement:e.element}),l.apply(t,o))};for(let n of Object.values(e.commands))t(n,"command");for(let n of e.Re.values())t(n,"event")}(e),"connected"===t){if(m.has(e))return;m.add(e),c?.({type:"state:element-registered",rootNode:e.root,element:e.element}),g(e)}else"disconnected"===t&&(m.delete(e),g(e),c?.({type:"state:element-unregistered",rootNode:e.root,element:e.element}))}function $(e,t,n,l,o,s){if(null===c)return;let r=p(e,t,0===t.n?null:n),a=b.get(e);void 0===a&&b.set(e,a=new Set),a.add(r),s&&c({type:"state:write",absoluteAddress:r,value:o,oldValue:l,hasOldValue:!0})}function O(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function M(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.nn(),error:t})}var E={name:"devtools",install(){u.element=d(u.element,j),u.be=d(u.be,$),u.Fe=d(u.Fe,O),u.Ke=d(u.Ke,M),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=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!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.I.all()){let l=n.W,o=n.Ce?.length??0;if((null===l||0===l.size)&&0===o)continue;let s,r=0;if(null!==l)for(let e of l.values())r+=e.size;try{s=0===n.n?e.v(n,null):void 0}catch{s=void 0}t.push({path:n.t,tracked:!1,rows:r,keys:null===l?0:l.size,lists:o,lastValue:s})}return t}(w(e)),keys(e){let t=w(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 w(e).element.createState("readonly",e=>{l=e.$resolve(t,n??[])}),l},write(e,t,n,l){w(e).element.createState("writable",e=>{e.$resolve(t,l??[],n)})},_setSink(e){let t=null===c&&null!==e;c=e,null===e&&(v=new WeakMap),u.st=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},_=E;export{_ as default,E as devtools};
@@ -1 +1 @@
1
- import{a as e,b as t,d as n}from"../chunks/chunk-GI7MH75B.js";import{b as o,n as l,o as r,p as i}from"../chunks/chunk-2BGNNXNX.js";import"../chunks/chunk-XF6V6DWR.js";import{e as a,f as s}from"../chunks/chunk-LTBR3OV5.js";import{a as u}from"../chunks/chunk-W5KT4PQ3.js";import"../chunks/chunk-2EGTC36Y.js";import"../chunks/chunk-SPWZUBQS.js";import"../chunks/chunk-ALVA5TQM.js";import{a as c,b as d,c as f,d as p,f as h,h as m,j as g}from"../chunks/chunk-V34ZHCK5.js";var $=new WeakMap,b=new WeakMap,w="will not graft: the root state failed to initialize.",y=new WeakSet,v=new WeakMap,k=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],N=["$commandTokens","$eventTokens","$on","$errorCallback"],j=e=>`[@wcstack/state] <${u.tagNames.state} mount="${e}">`,O=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),C=e=>e?.element?.isConnected?e:void 0;function A(e){let t=b.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function P(e,t){let n=b.get(t);if(b.delete(t),Array.isArray(n))for(let t of n)W(t,e)}function M(e){let t=$.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function x(e,t){console.error(`${j(e.t)} ${t}`),M(e),e.Je?.(),e.Je=null}function S(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 W(e,t){if(y.has(t))return x(e,"will not graft: its component is wired to its host.");let n=e.state,o=t.target,l=e.t.split("."),r=o;for(let e of l)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return x(e,`will not graft: the root state already has "${e.t}".`);let i=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,o){if("symbol"==typeof o)return;if(36!==o.charCodeAt(0))return e.proxy[n(o)];let l=e.proxy[o];return"$eqPath"===o?(e,t)=>l(n(e),n(t)):O.has(o)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,o,l)=>"symbol"!=typeof o&&(e.proxy[n(o)]=l,!0)})}(t,e.t);e.chroot=i;let a={},s={},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:o,set:l,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o||void 0!==l)s[`${e.t}.${n}`]={get:o&&function(){return o.call(i)},set:l&&function(e){l.call(i,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(i);s[`${e.t}.${n}`]={get:()=>t}}else a[n]=r}}if(void 0===r){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.rt(n,null)&&t.T(n,null,{})}t.T(t.o(e.t),null,a)}t.to(Object.defineProperties({},s));for(let e in s)t._e(t.o(e),null);e.engine=t;let c=v.get(t);void 0===c&&v.set(t,c=[]),c.push(e),e.el.isConnected&&S(e,"$connectedCallback"),e.Je?.(),e.Je=null}function D(e,t){let n=b.get(e);if(Array.isArray(n))for(let e of n)x(e,w);b.set(e,t)}var T=new WeakMap;function E(e,t){let n=e.getAttribute("mount");if(null===n)return null;let o={el:e,root:t,t:n,state:null,engine:null,chroot:null,Je:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(u.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=$.get(t);void 0===e&&$.set(t,e=new Map);let l=e.get(n);if(void 0!==l&&l!==o&&(null===l.engine?l.el.isConnected:C(l.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===l?.engine){let e=b.get(t);Array.isArray(e)&&b.set(t,e.filter(e=>e!==l)),l.Je?.(),l.Je=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{No:!0,start(e){if(null!==r)return x(o,r);if($.get(t).get(n)===o){for(let t of k)if(void 0!==e[t])return x(o,`${t} is not run in a volume — declare it on the root state.`);for(let t of N)void 0!==e[t]&&console.warn(`${j(n)} ${t} is not run in a volume (it belongs to the root).`);return o.state=e,new Promise(e=>{o.Je=e;let n=C(l.get(t)),r=b.get(t);void 0!==n?W(o,n):A(t)?x(o,w):b.set(t,[...Array.isArray(r)?r:[],o])})}},Xe(){null!==o.engine&&S(o,"$connectedCallback")},Ln(){null!==o.engine&&S(o,"$disconnectedCallback")},reset(){g(`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 R=new WeakMap,z=new WeakMap;function q(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||g(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&g(`${t} entries must be non-empty strings.`),"$"===e[0]&&g(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&g(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function X(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let o=document.createDocumentFragment();for(let e of[...t.childNodes])o.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&g("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||g(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&g(`DCC: <${e}> is already defined.`);let l=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}(o),r=q(o,"$bindables"),i=q(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&g(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&g(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&g(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&g(`$commands entry "${e}" is not a method: list it in $bindables.`)}let a={tag:e,bindables:r},s=new WeakMap,c=new WeakMap,d=o=>{if(s.has(o))return s.get(o);if(o.hasAttribute("data-wc-definition"))return null;let l=o.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let i=l.querySelector(u.tagNames.state);return s.set(o,i),R.set(o,a),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${u.tagNames.state}>: no change events.`),i},f=e=>d(e)?.engine??null,p=e=>Promise.resolve(d(e)?.initializePromise).then(()=>{let t=c.get(e);c.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,o]of t)n.proxy[e]=o});class h extends HTMLElement{static{this.wcBindable=0===r.length&&0===i.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===i.length?{}:{commands:i.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==d(this)&&p(this)}get stateElement(){return d(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(h.prototype,e,{configurable:!0,value(...t){return p(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(h.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=c.get(this);void 0===n&&c.set(this,n=[]),n.push([e,t])}}});customElements.define(e,h)}(n.localName,o,l,t)},Xe(){},Ln(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var J=new WeakMap,L=new WeakSet,H=new WeakMap,V=new WeakMap,B="data-wcs-wired",I=new WeakMap,_=new WeakMap,G=new WeakMap,F=0,K=new Set,Q={},U=["$watch","$stream","$renderedCallback"],Y=e=>e.split(".",1)[0];function Z(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function ee(e,t){let n=e.a,o=Y(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(B);else if(!ne(n,o)){let e=n.getAttribute(B)?.split(" ")??[];e.includes(o)||n.setAttribute(B,[...e,o].join(" "))}I.get(n)?.pe===o&&g(`<${n.localName}>.${o} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=J.get(n);void 0===l&&J.set(n,l=[]),l.push(e),t&&L.add(e);let r=H.get(n);return void 0===r&&H.set(n,r=new Map),r.has(o)||r.set(o,n[o]),V.get(n)?.(),!1}function te(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${u.tagNames.state}[bind-component]`)}function ne(e,t){let n=e.getAttribute(u.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function oe(t){let n=t.parentElement;for(;null!==n&&!te(n);)n=n.parentElement;let o=l.get(n??t.getRootNode()),r=o?.element;(r?.isConnected?r.V:null===n)&&(null===n?e(t):i(o,t))}var le=new Set;function re(e,t){le.has(e)||(le.add(e),console.warn(`[@wcstack/state] ${t}`))}var ie=(e,t)=>t in e.state;function ae(e,t){let n=se(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function se(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 ue(e,t,n){if(null!==n.getter)return;let o,l=e.host,r=l.engine,i=Y(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.d)return function(e,t){let n,o=t.d;for(;null!==o&&void 0===(n=e.dt.get(o));)o=o.d;if(null===o||void 0===n)return;let l=e.N,r=e.host.engine,i=r.o(n.p.t+t.t.slice(o.t.length));if(null===i.getter)return;let s=n,u=()=>{let n=ce(e,s.r);return 0===t.n?n:(r.resolve(Z(i.t,[...r.H(n),...l.H(a(l.u,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.ie&&(t.ie=n=>{let o=u();de(e,s.e,()=>r.T(i,o,n)),e.dn=t}),t.n>0&&(t.A=l.Ie++),e.dt.set(t,{e:s.e,p:i,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==i?ie(l,i):ae(l,i))return;o=s.me}else{if(null===t||null!==n.d||"$"===i[0]||ie(l,i))return;s=t,o=r.o(`${t.me.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,ce(e,u)),n.ie=t=>{de(e,c,()=>r.T(o,u,t)),e.dn=n},e.dt.set(n,{e:s,p:o,r:u})}function ce(e,t){return null!==t&&!t.y&&g(`The host row of <${e.host.el.localName}> was removed.`),t}function de(e,t,n){let o=K.has(e.N);K.add(e.N),e.from=t;try{n()}finally{o||K.delete(e.N),e.from=null}}var fe=(e,t)=>t||!K.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function pe(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,F+=t?1:-1;let n=e.host.engine,o=G.get(n);void 0===o&&G.set(n,o=new Map);for(let n of e.fe){let e=o.get(n.e.me);void 0===e&&o.set(n.e.me,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.$);if(void 0!==l){null===e.re&&function(e,t){let n=e.host,o=n.engine;e.re=new Map;let l=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let i of Object.getOwnPropertyNames(r)){if(l.has(i))continue;l.add(i);let a=Object.getOwnPropertyDescriptor(r,i);if(void 0===a.get&&void 0===a.set||"$"===i[0]||i.includes("*"))continue;let s=Y(i);if(i!==s&&!ie(n,s))continue;let u=o.o(`${t.me.t}.${i}`);if(null===u.getter)ge(o,u,t.me);else if(!he.has(u.getter))continue;e.re.set(u,e.N.o(i))}}(e,l);for(let o of e.re.keys())t&&null===o.getter&&ge(n,o,l.me),n.P.we(n,o,l.r);e.re.size>0&&n.Te(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.re){let r=n.v(o.d,t.r);if(null===r||"object"!=typeof r||!(o.s in r))continue;let i=e.host.el.localName;re(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.pe}.${l.t} is exported at "${o.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,l)}}var he=new WeakSet;function me(e,t,n,o){let l=G.get(e)?.get(t)?.get(n);if(void 0===l)return null;let r=null;for(let e of l)""!==e.e.$||!0!==e.m.re?.has(o)||e.m===r||(null!==r&&g(`[wcs/mount-export-ambiguous] "${o.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 ge(e,t,n){let o=t.d,l=t.s,r=()=>{let t=e.read(o,e.u);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=me(e,n,e.u,t);return null===i?void 0:i.N.read(i.re.get(t),null)},he.add(t.getter),t.ie=i=>{let a=null===r()?me(e,n,e.u,t):null;if(null===a){let t=e.read(o,e.u);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.re.get(t);void 0===se(a.host.state,s.t)?.set&&g(`Cannot write to "${s.t}" on mounted <${a.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),a.N.T(s,null,i)},t.n>0&&(t.A=e.Ie++)}function $e(e,t,n,o,l,r){if(null!==t.getter)return e.P.we(e,t,n),void e.Te();if("*"===t.s){if(null===n)return;if(n.R=n.l.C[n.b],e.P.Yt(n),null!==n.c)for(let t of n.c.values())e.X(t)}else e.$n(t,n);c.be?.(e,t,n,o,l,r),e._e(t,n)}function be(e){let t=e.m.N;for(let[n,o]of e.m.dt)o.e===e.e&&(0===n.n?t.P.we(t,n,null):t.tn(n.h[n.n],e=>t.P.we(t,n,e)));t.Te()}function we(e,t,n,o,l,r,i){let s=n.t.slice(t.t.length);if(""===s)return be(e);let u,c=e.m,d=c.N;if(""===e.e.$){u=s.slice(1);let e=Y(u);if("$"===e[0]||ie(c.host,e)||c.host.entries.some(e=>""!==e.$&&(u===e.$||u.startsWith(`${e.$}.`))))return}else u=e.e.$+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(a(o,e).b);d.resolve(Z(u,f),null);let p=d.rp,h=d.rr;p.n>0&&null===h||$e(d,p,h,l,r,i)}function ye(e,t,n,o,l,r,i){if(0===F)return;let s=K.has(e);K.add(e);try{let s=_.get(e);!i&&void 0!==s&&s.fn&&!K.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.dt.get(a));)a=a.d;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.dn===t)return void(e.dn=null);if(null!==i.r&&!i.r.y)return;let u=[...s.H(i.r),...e.N.H(n)];s.resolve(Z(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||de(e,i.e,()=>$e(s,c,d,o,l,r))}(s,t,n,o,l,r),i&&void 0!==s&&s.fn&&null!==s.re&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.re)r===t&&(o.P.we(o,l,n.r),o.Te())}(s,t);let u=G.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.ee(e)){let u=s.get(0===e.n?null:a(n,e.n));if(void 0!==u)for(let a of[...u])fe(a,i)&&we(a,e,t,n,o,l,r)}else if(e.ee(t))for(let[e,o]of[...s])if(0===t.n||a(e,t.n)===n)for(let e of[...o])fe(e,i)&&be(e)}finally{s||K.delete(e)}}async function ve(e,o,l,i,a){if(i===Q)return;let d=m(i);d&&await d;let f=I.get(o);f.engine&&i.$recursion&&g(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let p=f.O;if(null!==p&&p.el!==e&&p.el.isConnected&&g(`<${o.localName}> already has a connected <${u.tagNames.state} bind-component="${f.pe}">.`),null!==p&&pe(p,!1),null!==p&&function(e,t,n){let o=e.N,l=`[${u.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,a=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},s=(e,t)=>{for(let n=e.Cn(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ce.values())for(let t of e)if(null===t._)a(t.a);else for(let e of t._.G)s(t._,e.S);for(let e of o.oe.values())for(let t of[e.E,...e.L??[]])null!==t&&s(t,t.S);for(let t of e.D)t.parentNode===n&&r(t)&&i.add(t);if(0===i.size)return!1;let c=[...n.childNodes].filter(n=>n!==t&&!i.has(n)&&!e.D.includes(n)&&(r(n)||o.Mt&&n.textContent.includes("{{")));return c.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${c.length} node(s) added beside the content taken over are not bound.`),!0}(p,e,l))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.N.element=t,t.engine=e.N,e.D=e.D.filter(e=>e.parentNode===n),t.isConnected?await ke(e,o):o()}(p,e,l,a);let h=new s(i,new n);h.element=e,e.engine=h,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 o=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof o&&"constructor"!==t&&n.set(o,null)}let o=(t,n,o)=>Reflect.apply(t,e.proxy,o);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(h,i);let $={el:e,D:[],N:h,host:f,fe:[],dt:new Map,fn:!1,dn:null,from:null,re:null};for(let e of f.entries)$.fe.push({m:$,e});f.O=$,_.set(h,$);let b=null===f.engine;b?c.element?.(h,"mounting"):(function(e){let t=e.N,n=e.host,o=n.engine,l=n.el.localName,r=n.entries.find(e=>""===e.$)??null;for(let e of n.entries){if(""===e.$)continue;let t=Y(e.$);ie(n,t)&&(e.$!==t||ae(n,t))&&re(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.pe}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.me,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.$===t)&&re(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.me.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=U.filter(e=>void 0!==n.state[e]);i.length>0&&re(`${l}.${n.pe}$`,`[wcs/mount-dollar-declaration] <${l}>: ${i.join(", ")} ${1===i.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let a=t.nt;t.nt=n=>{ue(e,r,n),a.call(t,n)};let s=[...t.I.all()];for(let t of s)ue(e,r,t);for(let e of s)a.call(t,e);let u=n.entries.filter(e=>null!==e.r);if(u.length>0){let e=t.zt;t.zt=()=>{u.every(e=>e.r.y)&&e.call(t)}}}($),pe($,!0),y.add(h),P(h,l));let w=c.hr?.(l);r(h,l),w?.(),$.D=[...l.childNodes],t(),b&&h.En(),Object.defineProperty(o,f.pe,{configurable:!0,enumerable:!0,get:()=>h.proxy});let v=o.$stateReadyCallback;if("function"==typeof v)try{let e=v.call(o,f.pe);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}a(),e.isConnected?(await h.ke("$connectedCallback"),b&&e.isConnected&&c.element?.(h,"connected")):pe($,!1)}async function ke(e,t){pe(e,!0);for(let t of e.fe)be(t);t?.(),!e.broken&&(await e.N.ke("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.N,"connected"))}function Ne(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=l.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){D(t,e);for(let e of T.get(t)??[])e()}}),null}(e,t);let r=e.parentNode,i=r instanceof ShadowRoot,a=i?r.host:r instanceof Element?r:null,s=()=>{let t=null===a?void 0:I.get(a)?.O;return t?.el===e?t:null},d=t=>{throw i&&D(r,e),t},f=!1;return{wt:()=>(null!==a&&a.localName.includes("-")?async function(e,t,n,l){let r=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&g(`<${u.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await o(n).whenDefined(r);let i=I.get(n);if(void 0!==i)return i.pe!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.pe}">.`),i.state;let a=()=>(J.get(n)??[]).filter(e=>Y(e.name)===t),s=ne(n,t);if(s&&0===a().length&&oe(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(B)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{V.set(n,o),e=function(e,t){A(e)&&t();let n=T.get(e)??new Set;return T.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}V.delete(n);let c=a(),d=H.get(n),f=void 0!==d&&d.has(t)?d.get(t):n[t];if((null===f||"object"!=typeof f)&&g(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===f?"null":typeof f}.`),0===c.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${r}>, or mount it from the host (${u.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),Q}let p=[];for(let e of c){let o=e.name===t?"":e.name.slice(t.length+1);p.some(e=>e.$===o)&&g(`<${r}> maps "${e.name}" twice.`);let l=o.split(".").indexOf("*");if(l>=0){let n=o.split(".").slice(0,l).join(".");g(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}p.push({$:o,me:e.o,r:e.r,ro:L.has(e)}),e.engine.Nn(e),""!==o&&delete n[e.name]}let h=0===c.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}(f):f;return I.set(n,i={el:n,pe:t,state:h,engine:0===c.length?null:c[0].engine,entries:p,O:null}),h}(e,n,a,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${u.tagNames.state}> to be a direct child of a custom element.`))).catch(d),async start(t,n){await ve(e,a,i?r:a,t,()=>{f=!0,n()}).catch(e=>{let t=s();return!f&&null!==t&&(t.broken=!0),d(e)})},Xe(){let t=s();null!==t?ke(t).catch(e=>console.error(e)):f?Promise.resolve().then(()=>{if(e.parentNode===r)return ve(e,a,i?r:a,I.get(a).state,()=>{})}).catch(e=>console.error(e)):V.has(a)&&oe(a)},Ln(){let e=s();null!==e&&(pe(e,!1),!e.broken&&(e.N.ke("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.N,"disconnected")))},reset(){g(`re-setting a component's state is not supported: write <${a?.localName}>.${n} instead.`)}}}var je={name:"scopes",install(){c.at=f(h,c.at,E),c.at=f(h,c.at,X),c.at=f(h,c.at,Ne),c.ar=ee,c.$o=te,c.element=d(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=v.get(e)??[];if("disconnected"===t)for(let e of n)M(e);else if("reset"!==t&&C(l.get(e.root))===e){P(e,e.root);for(let e of n)$.get(e.root).has(e.t)||$.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();P(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:R.get(n);void 0!==o&&z.set(e,{host:n,def:o})}(e,n)}),c.be=d(c.be,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=z.get(e);if(void 0===l)return;let r=t.t.split(".",1)[0];if(!l.def.bindables.includes(r))return;let i=o&&t.t===r;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${r}-changed`,{detail:i?n:void 0,bubbles:!0}))})(e,t,l,r),ye(e,t,n,o,l,r,!1)}),c.ve=d(c.ve,(e,t,n)=>ye(e,t,n,void 0,void 0,!1,!0)),c.Ae=f(p,c.Ae,(e,t,n,o,l)=>(function(e,t){let n=v.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&g(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let o,l=_.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.d)o=l.dt.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.y)&&!r.ro)&&(!!n||(ce(l,r.r),void g(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.pe}${""===r.$?"":`.${r.$}`}#ro: ${r.me.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.de;c.de=(t,n)=>{let o=v.get(t);void 0!==o&&o.length>0&&g(`re-setting a root state with grafted volumes (${o.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=G.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&g("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},Oe=je;export{Oe as default,je as scopes};
1
+ import{a as e,b as t,d as n}from"../chunks/chunk-JMPQHCIT.js";import{b as o,n as l,o as r,p as i}from"../chunks/chunk-7EWPQMA6.js";import"../chunks/chunk-XF6V6DWR.js";import{e as a,f as s}from"../chunks/chunk-LTBR3OV5.js";import{a as u}from"../chunks/chunk-W5KT4PQ3.js";import"../chunks/chunk-2EGTC36Y.js";import"../chunks/chunk-SPWZUBQS.js";import"../chunks/chunk-ALVA5TQM.js";import{a as c,b as d,c as f,d as h,f as p,h as m,j as g}from"../chunks/chunk-V34ZHCK5.js";var $=new WeakMap,b=new WeakMap,w="will not graft: the root state failed to initialize.",y=new WeakSet,v=new WeakMap,k=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],N=["$commandTokens","$eventTokens","$on","$errorCallback"],j=e=>`[@wcstack/state] <${u.tagNames.state} mount="${e}">`,O=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),C=e=>e?.element?.isConnected?e:void 0;function A(e){let t=b.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function P(e,t){let n=b.get(t);if(b.delete(t),Array.isArray(n))for(let t of n)W(t,e)}function M(e){let t=$.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function x(e,t){console.error(`${j(e.t)} ${t}`),M(e),e.Je?.(),e.Je=null}function S(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 W(e,t){if(y.has(t))return x(e,"will not graft: its component is wired to its host.");let n=e.state,o=t.target,l=e.t.split("."),r=o;for(let e of l)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return x(e,`will not graft: the root state already has "${e.t}".`);let i=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,o){if("symbol"==typeof o)return;if(36!==o.charCodeAt(0))return e.proxy[n(o)];let l=e.proxy[o];return"$eqPath"===o?(e,t)=>l(n(e),n(t)):O.has(o)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,o,l)=>"symbol"!=typeof o&&(e.proxy[n(o)]=l,!0)})}(t,e.t);e.chroot=i;let a={},s={},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:o,set:l,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o||void 0!==l)s[`${e.t}.${n}`]={get:o&&function(){return o.call(i)},set:l&&function(e){l.call(i,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(i);s[`${e.t}.${n}`]={get:()=>t}}else a[n]=r}}if(void 0===r){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.rt(n,null)&&t.T(n,null,{})}t.T(t.o(e.t),null,a)}t.to(Object.defineProperties({},s));for(let e in s)t._e(t.o(e),null);e.engine=t;let c=v.get(t);void 0===c&&v.set(t,c=[]),c.push(e),e.el.isConnected&&S(e,"$connectedCallback"),e.Je?.(),e.Je=null}function D(e,t){let n=b.get(e);if(Array.isArray(n))for(let e of n)x(e,w);b.set(e,t)}var T=new WeakMap;function E(e,t){let n=e.getAttribute("mount");if(null===n)return null;let o={el:e,root:t,t:n,state:null,engine:null,chroot:null,Je:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(u.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=$.get(t);void 0===e&&$.set(t,e=new Map);let l=e.get(n);if(void 0!==l&&l!==o&&(null===l.engine?l.el.isConnected:C(l.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===l?.engine){let e=b.get(t);Array.isArray(e)&&b.set(t,e.filter(e=>e!==l)),l.Je?.(),l.Je=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{No:!0,start(e){if(null!==r)return x(o,r);if($.get(t).get(n)===o){for(let t of k)if(void 0!==e[t])return x(o,`${t} is not run in a volume — declare it on the root state.`);for(let t of N)void 0!==e[t]&&console.warn(`${j(n)} ${t} is not run in a volume (it belongs to the root).`);return o.state=e,new Promise(e=>{o.Je=e;let n=C(l.get(t)),r=b.get(t);void 0!==n?W(o,n):A(t)?x(o,w):b.set(t,[...Array.isArray(r)?r:[],o])})}},Xe(){null!==o.engine&&S(o,"$connectedCallback")},Ln(){null!==o.engine&&S(o,"$disconnectedCallback")},reset(){g(`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 R=new WeakMap,z=new WeakMap;function q(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||g(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&g(`${t} entries must be non-empty strings.`),"$"===e[0]&&g(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&g(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function J(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let o=document.createDocumentFragment();for(let e of[...t.childNodes])o.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&g("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||g(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&g(`DCC: <${e}> is already defined.`);let l=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}(o),r=q(o,"$bindables"),i=q(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&g(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&g(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&g(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&g(`$commands entry "${e}" is not a method: list it in $bindables.`)}let a={tag:e,bindables:r},s=new WeakMap,c=new WeakMap,d=o=>{if(s.has(o))return s.get(o);if(o.hasAttribute("data-wc-definition"))return null;let l=o.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let i=l.querySelector(u.tagNames.state);return s.set(o,i),R.set(o,a),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${u.tagNames.state}>: no change events.`),i},f=e=>d(e)?.engine??null,h=e=>Promise.resolve(d(e)?.initializePromise).then(()=>{let t=c.get(e);c.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,o]of t)n.proxy[e]=o});class p extends HTMLElement{static{this.wcBindable=0===r.length&&0===i.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===i.length?{}:{commands:i.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==d(this)&&h(this)}get stateElement(){return d(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(p.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(p.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=c.get(this);void 0===n&&c.set(this,n=[]),n.push([e,t])}}});customElements.define(e,p)}(n.localName,o,l,t)},Xe(){},Ln(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var L=new WeakMap,H=new WeakSet,V=new WeakMap,X=new WeakMap,I="data-wcs-wired",Q=new WeakMap,_=new WeakMap,B=new WeakMap,F=0,K=new Set,G={},U=["$watch","$stream","$renderedCallback"],Y=e=>e.split(".",1)[0];function Z(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function ee(e,t){let n=e.a,o=Y(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(I);else if(!ne(n,o)){let e=n.getAttribute(I)?.split(" ")??[];e.includes(o)||n.setAttribute(I,[...e,o].join(" "))}Q.get(n)?.pe===o&&g(`<${n.localName}>.${o} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=L.get(n);void 0===l&&L.set(n,l=[]),l.push(e),t&&H.add(e);let r=V.get(n);return void 0===r&&V.set(n,r=new Map),r.has(o)||r.set(o,n[o]),X.get(n)?.(),!1}function te(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${u.tagNames.state}[bind-component]`)}function ne(e,t){let n=e.getAttribute(u.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function oe(t){let n=t.parentElement;for(;null!==n&&!te(n);)n=n.parentElement;let o=l.get(n??t.getRootNode()),r=o?.element;(r?.isConnected?r.V:null===n)&&(null===n?e(t):i(o,t))}var le=new Set;function re(e,t){le.has(e)||(le.add(e),console.warn(`[@wcstack/state] ${t}`))}var ie=(e,t)=>t in e.state;function ae(e,t){let n=se(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function se(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 ue(e,t,n){if(null!==n.getter)return;let o,l=e.host,r=l.engine,i=Y(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.d)return function(e,t){let n,o=t.d;for(;null!==o&&void 0===(n=e.dt.get(o));)o=o.d;if(null===o||void 0===n)return;let l=e.N,r=e.host.engine,i=r.o(n.p.t+t.t.slice(o.t.length));if(null===i.getter)return;let s=n,u=()=>{let n=ce(e,s.r);return 0===t.n?n:(r.resolve(Z(i.t,[...r.H(n),...l.H(a(l.u,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.ie&&(t.ie=n=>{let o=u();de(e,s.e,()=>r.T(i,o,n)),e.dn=t}),t.n>0&&(t.A=l.Ie++),e.dt.set(t,{e:s.e,p:i,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==i?ie(l,i):ae(l,i))return;o=s.me}else{if(null===t||null!==n.d||"$"===i[0]||ie(l,i))return;s=t,o=r.o(`${t.me.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,ce(e,u)),n.ie=t=>{de(e,c,()=>r.T(o,u,t)),e.dn=n},e.dt.set(n,{e:s,p:o,r:u})}function ce(e,t){return null!==t&&!t.y&&g(`The host row of <${e.host.el.localName}> was removed.`),t}function de(e,t,n){let o=K.has(e.N);K.add(e.N),e.from=t;try{n()}finally{o||K.delete(e.N),e.from=null}}var fe=(e,t)=>t||!K.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function he(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,F+=t?1:-1;let n=e.host.engine,o=B.get(n);void 0===o&&B.set(n,o=new Map);for(let n of e.fe){let e=o.get(n.e.me);void 0===e&&o.set(n.e.me,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.$);if(void 0!==l){null===e.re&&function(e,t){let n=e.host,o=n.engine;e.re=new Map;let l=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let i of Object.getOwnPropertyNames(r)){if(l.has(i))continue;l.add(i);let a=Object.getOwnPropertyDescriptor(r,i);if(void 0===a.get&&void 0===a.set||"$"===i[0]||i.includes("*"))continue;let s=Y(i);if(i!==s&&!ie(n,s))continue;let u=o.o(`${t.me.t}.${i}`);if(null===u.getter)ge(o,u,t.me);else if(!pe.has(u.getter))continue;e.re.set(u,e.N.o(i))}}(e,l);for(let o of e.re.keys())t&&null===o.getter&&ge(n,o,l.me),n.P.we(n,o,l.r);e.re.size>0&&n.Te(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.re){let r=n.v(o.d,t.r);if(null===r||"object"!=typeof r||!(o.s in r))continue;let i=e.host.el.localName;re(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.pe}.${l.t} is exported at "${o.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,l)}}var pe=new WeakSet;function me(e,t,n,o){let l=B.get(e)?.get(t)?.get(n);if(void 0===l)return null;let r=null;for(let e of l)""!==e.e.$||!0!==e.m.re?.has(o)||e.m===r||(null!==r&&g(`[wcs/mount-export-ambiguous] "${o.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 ge(e,t,n){let o=t.d,l=t.s,r=()=>{let t=e.read(o,e.u);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=me(e,n,e.u,t);return null===i?void 0:i.N.read(i.re.get(t),null)},pe.add(t.getter),t.ie=i=>{let a=null===r()?me(e,n,e.u,t):null;if(null===a){let t=e.read(o,e.u);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.re.get(t);void 0===se(a.host.state,s.t)?.set&&g(`Cannot write to "${s.t}" on mounted <${a.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),a.N.T(s,null,i)},t.n>0&&(t.A=e.Ie++)}function $e(e,t,n,o,l,r){if(null!==t.getter)return e.P.we(e,t,n),void e.Te();if("*"===t.s){if(null===n)return;if(n.R=n.l.C[n.b],e.P.Yt(n),null!==n.c)for(let t of n.c.values())e.X(t)}else e.$n(t,n);c.be?.(e,t,n,o,l,r),e._e(t,n)}function be(e){let t=e.m.N;for(let[n,o]of e.m.dt)o.e===e.e&&(0===n.n?t.P.we(t,n,null):t.tn(n.h[n.n],e=>t.P.we(t,n,e)));t.Te()}function we(e,t,n,o,l,r,i){let s=n.t.slice(t.t.length);if(""===s)return be(e);let u,c=e.m,d=c.N;if(""===e.e.$){u=s.slice(1);let e=Y(u);if("$"===e[0]||ie(c.host,e)||c.host.entries.some(e=>""!==e.$&&(u===e.$||u.startsWith(`${e.$}.`))))return}else u=e.e.$+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(a(o,e).b);d.resolve(Z(u,f),null);let h=d.rp,p=d.rr;h.n>0&&null===p||$e(d,h,p,l,r,i)}function ye(e,t,n,o,l,r,i){if(0===F)return;let s=K.has(e);K.add(e);try{let s=_.get(e);!i&&void 0!==s&&s.fn&&!K.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.dt.get(a));)a=a.d;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.dn===t)return void(e.dn=null);if(null!==i.r&&!i.r.y)return;let u=[...s.H(i.r),...e.N.H(n)];s.resolve(Z(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||de(e,i.e,()=>$e(s,c,d,o,l,r))}(s,t,n,o,l,r),i&&void 0!==s&&s.fn&&null!==s.re&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.re)r===t&&(o.P.we(o,l,n.r),o.Te())}(s,t);let u=B.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.ee(e)){let u=s.get(0===e.n?null:a(n,e.n));if(void 0!==u)for(let a of[...u])fe(a,i)&&we(a,e,t,n,o,l,r)}else if(e.ee(t))for(let[e,o]of[...s])if(0===t.n||a(e,t.n)===n)for(let e of[...o])fe(e,i)&&be(e)}finally{s||K.delete(e)}}async function ve(e,o,l,i,a){if(i===G)return;let d=m(i);d&&await d;let f=Q.get(o);f.engine&&i.$recursion&&g(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let h=f.O;if(null!==h&&h.el!==e&&h.el.isConnected&&g(`<${o.localName}> already has a connected <${u.tagNames.state} bind-component="${f.pe}">.`),null!==h&&he(h,!1),null!==h&&function(e,t,n){let o=e.N,l=`[${u.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,a=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},s=(e,t)=>{for(let n=e.Cn(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ce.values())for(let t of e)if(null===t._)a(t.a);else for(let e of t._.G)s(t._,e.S);for(let e of o.oe.values())for(let t of[e.E,...e.L??[]])null!==t&&s(t,t.S);for(let t of e.D)t.parentNode===n&&r(t)&&i.add(t);if(0===i.size)return!1;let c=[...n.childNodes].filter(n=>n!==t&&!i.has(n)&&!e.D.includes(n)&&(r(n)||o.Mt&&n.textContent.includes("{{")));return c.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${c.length} node(s) added beside the content taken over are not bound.`),!0}(h,e,l))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.N.element=t,t.engine=e.N,e.D=e.D.filter(e=>e.parentNode===n),t.isConnected?await ke(e,o):o()}(h,e,l,a);let p=new s(i,new n);p.element=e,e.engine=p,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 o=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof o&&"constructor"!==t&&n.set(o,null)}let o=(t,n,o)=>Reflect.apply(t,e.proxy,o);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(p,i);let $={el:e,D:[],N:p,host:f,fe:[],dt:new Map,fn:!1,dn:null,from:null,re:null};for(let e of f.entries)$.fe.push({m:$,e});f.O=$,_.set(p,$);let b=null===f.engine;b?c.element?.(p,"mounting"):(function(e){let t=e.N,n=e.host,o=n.engine,l=n.el.localName,r=n.entries.find(e=>""===e.$)??null;for(let e of n.entries){if(""===e.$)continue;let t=Y(e.$);ie(n,t)&&(e.$!==t||ae(n,t))&&re(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.pe}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.me,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.$===t)&&re(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.me.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=U.filter(e=>void 0!==n.state[e]);i.length>0&&re(`${l}.${n.pe}$`,`[wcs/mount-dollar-declaration] <${l}>: ${i.join(", ")} ${1===i.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let a=t.nt;t.nt=n=>{ue(e,r,n),a.call(t,n)};let s=[...t.I.all()];for(let t of s)ue(e,r,t);for(let e of s)a.call(t,e);let u=t.zt;t.zt=()=>{(function(e){for(;void 0!==e;e=_.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.y))return!1;return!0})(e)&&u.call(t)}}($),he($,!0),y.add(p),P(p,l));let w=c.hr?.(l);r(p,l),w?.(),$.D=[...l.childNodes],t(),b&&p.En(),Object.defineProperty(o,f.pe,{configurable:!0,enumerable:!0,get:()=>p.proxy});let v=o.$stateReadyCallback;if("function"==typeof v)try{let e=v.call(o,f.pe);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}a(),e.isConnected?(await p.ke("$connectedCallback"),b&&e.isConnected&&c.element?.(p,"connected")):he($,!1)}async function ke(e,t){he(e,!0);for(let t of e.fe)be(t);t?.(),!e.broken&&(await e.N.ke("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.N,"connected"))}function Ne(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=l.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){D(t,e);for(let e of T.get(t)??[])e()}}),null}(e,t);let r=e.parentNode,i=r instanceof ShadowRoot,a=i?r.host:r instanceof Element?r:null,s=()=>{let t=null===a?void 0:Q.get(a)?.O;return t?.el===e?t:null},d=t=>{throw i&&D(r,e),t},f=!1;return{wt:()=>(null!==a&&a.localName.includes("-")?async function(e,t,n,l){let r=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&g(`<${u.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await o(n).whenDefined(r);let i=Q.get(n);if(void 0!==i)return i.pe!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.pe}">.`),i.state;let a=()=>(L.get(n)??[]).filter(e=>Y(e.name)===t),s=ne(n,t);if(s&&0===a().length&&oe(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(I)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{X.set(n,o),e=function(e,t){A(e)&&t();let n=T.get(e)??new Set;return T.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}X.delete(n);let c=a(),d=V.get(n),f=void 0!==d&&d.has(t)?d.get(t):n[t];if((null===f||"object"!=typeof f)&&g(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===f?"null":typeof f}.`),0===c.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${r}>, or mount it from the host (${u.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),G}let h=[];for(let e of c){let o=e.name===t?"":e.name.slice(t.length+1);h.some(e=>e.$===o)&&g(`<${r}> maps "${e.name}" twice.`);let l=o.split(".").indexOf("*");if(l>=0){let n=o.split(".").slice(0,l).join(".");g(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}h.push({$:o,me:e.o,r:e.r,ro:H.has(e)}),e.engine.Nn(e),""!==o&&delete n[e.name]}let p=0===c.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}(f):f;return Q.set(n,i={el:n,pe:t,state:p,engine:0===c.length?null:c[0].engine,entries:h,O:null}),p}(e,n,a,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${u.tagNames.state}> to be a direct child of a custom element.`))).catch(d),async start(t,n){await ve(e,a,i?r:a,t,()=>{f=!0,n()}).catch(e=>{let t=s();return!f&&null!==t&&(t.broken=!0),d(e)})},Xe(){let t=s();null!==t?ke(t).catch(e=>console.error(e)):f?Promise.resolve().then(()=>{if(e.parentNode===r)return ve(e,a,i?r:a,Q.get(a).state,()=>{})}).catch(e=>console.error(e)):X.has(a)&&oe(a)},Ln(){let e=s();null!==e&&(he(e,!1),!e.broken&&(e.N.ke("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.N,"disconnected")))},reset(){g(`re-setting a component's state is not supported: write <${a?.localName}>.${n} instead.`)}}}var je={name:"scopes",install(){c.at=f(p,c.at,E),c.at=f(p,c.at,J),c.at=f(p,c.at,Ne),c.ar=ee,c.$o=te,c.element=d(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=v.get(e)??[];if("disconnected"===t)for(let e of n)M(e);else if("reset"!==t&&C(l.get(e.root))===e){P(e,e.root);for(let e of n)$.get(e.root).has(e.t)||$.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();P(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:R.get(n);void 0!==o&&z.set(e,{host:n,def:o})}(e,n)}),c.be=d(c.be,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=z.get(e);if(void 0===l)return;let r=t.t.split(".",1)[0];if(!l.def.bindables.includes(r))return;let i=o&&t.t===r;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${r}-changed`,{detail:i?n:void 0,bubbles:!0}))})(e,t,l,r),ye(e,t,n,o,l,r,!1)}),c.ve=d(c.ve,(e,t,n)=>ye(e,t,n,void 0,void 0,!1,!0)),c.Ae=f(h,c.Ae,(e,t,n,o,l)=>(function(e,t){let n=v.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&g(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let o,l=_.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.d)o=l.dt.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.y)&&!r.ro)&&(!!n||(ce(l,r.r),void g(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.pe}${""===r.$?"":`.${r.$}`}#ro: ${r.me.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.de;c.de=(t,n)=>{let o=v.get(t);void 0!==o&&o.length>0&&g(`re-setting a root state with grafted volumes (${o.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=B.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&g("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},Oe=je;export{Oe as default,je as scopes};
@@ -1 +1 @@
1
- import{a as e}from"../chunks/chunk-7EPYU3C5.js";import{b as t,c as l}from"../chunks/chunk-RGG2TYRK.js";import"../chunks/chunk-GI7MH75B.js";import{a as n,i as r,j as o,k as i,l as s,m as a}from"../chunks/chunk-2BGNNXNX.js";import"../chunks/chunk-XF6V6DWR.js";import"../chunks/chunk-LTBR3OV5.js";import{a as c}from"../chunks/chunk-W5KT4PQ3.js";import"../chunks/chunk-2EGTC36Y.js";import"../chunks/chunk-SPWZUBQS.js";import"../chunks/chunk-ALVA5TQM.js";import{a as u,b as f}from"../chunks/chunk-V34ZHCK5.js";var d=e=>e.split(".").slice(0,2).join("."),p=class extends t{static find(e){return e.querySelector?.(c.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 d(this.version)===d(e)}};function m(e){let t=c.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends p{})}var h=()=>c.tagNames.ssr,g=Symbol.for("wcstack.ssr.snapshotBuilder"),b=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),v=e=>document.createComment(e),y=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,w=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),N=new WeakMap,S=new WeakMap,A=new WeakMap,k=new WeakSet,x=new WeakMap;function $(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function T(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var j=e=>null===e.D?e.Ue:e.D[e.D.length-1];function W(e,t,l){let n=[v(null===l?"wcs-[":`wcs-[:${l}`)];for(let e of t)null===l&&n.push(v("wcs-|")),n.push(...$(e.Ue,j(e)));n.push(v("wcs-]")),e.after(...n);for(let e of n)k.add(e)}function C(e){if(e instanceof r){W(e.S,e.Ne,null);for(let t of e.Ne)q(t);return}let t=e.O;null!==t&&(W(e.G[e.G.length-1].S,[t],e.b),q(t))}function q(e){if(null!==e.c)for(let t of e.c)C(t)}var O=new Set(["script","style","template","textarea","title"]),E="data-wcs-raw",M=e=>O.has(e.localName)||e.localName===h();function I(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(v("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(v("wcs-s")):1===t.nodeType&&!M(t)&&I(t)}var R=0;function P(t,l){let n=t.getRootNode(),r=[l];for(let e of S.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let o=new Map;for(let e of r){let t=N.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.E&&l.set(t.E.S,t.E),null!==t.L)for(let e of t.L)l.set(e.S,e);for(let t of e.ce.values())for(let e of t)if(null!==e._)for(let t of e._.G)l.set(t.S,e._);let n=new Set;for(let[e,r]of t){o.set(e,r);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),C(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=A.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>k.has(e)||1===e.nodeType&&t.has(e)&&B(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(M(e.parentNode)?x.has(e):t.has(l)&&w(l,"wcs-t:"))&&(x.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);M(e)&&l.some(e=>x.has(e))&&e.setAttribute(E,l.map(e=>x.has(e)?`{{ ${x.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}I(9===n.nodeType?n.body:n);let i=document.createElement(h());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.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 l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of o){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,r=`wcs-${n?"s":"t"}${R++}`;e.replaceWith(v(`wcs-p:${r}`));let o=document.importNode(a(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(T(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=r,i.append(T(t,s,o))}t.before(i)}function U(e){!function(e){if(null!==e.querySelector(c.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=>x.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(`${c.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===h())continue;let e=t.engine;null!=e&&P(t,e)}}var G=Symbol.for("wcstack.state.ssr.impl"),D=new Map,V=new WeakMap,B=e=>!0===u.$o?.(e),L=e=>1===e.nodeType&&!M(e)&&!B(e),Q=e=>e.f.flat().concat(e.q??[]),J=e=>{for(let t of Q(e))t.remove()};function K(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),r=e.previousSibling,o=e.parentNode,i=[],a=e.nextSibling;for(e.remove();null!==a&&!y(a,"wcs-]");){let e=a.nextSibling;if(y(a,"wcs-|"))i.push([]),a.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];w(a,"wcs-[")?e=K(a,t,l):(l.push(a),L(a)&&X(a,t))}a=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,q:a??o.appendChild(v("wcs-]"))},u=Q(c);a=c.q.nextSibling;for(let e of u)l?.push(e),t&&s.add(e);return t&&null!==r?D.set(r,c):J(c),a}function X(e,t){for(let l=e.firstChild;null!==l;)w(l,"wcs-[")?l=K(l,t):(L(l)&&X(l,t),l=l.nextSibling)}function Y(e,t,l){let n=e=>{for(let r of Array.from(e.childNodes))if(r.parentNode===e)if(8===r.nodeType){let e=r.data;try{if("wcs-s"===e)r.remove();else if("wcs-e"===e)r.replaceWith("");else if(e.startsWith("wcs-t:")){let t=v(`@@:${decodeURIComponent(e.slice(6))}`),l=r.nextSibling;for(;null!==l&&!y(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),r.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=r.parentNode,n="s"===e[10]?T(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,r)}}}catch{}}else 1===r.nodeType&&!M(r)&&(B(r)?V.set(r,{ssr:t,Oe:l}):n(r))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||te(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{w(e,"wcs-[")?n++:y(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let r=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(w(n,"wcs-["))r++;else if(y(n,"wcs-]")&&0===r--){t.prepend(...e.slice(l));break}}}(e),X(e,l)}function _(e){let t=V.get(e);if(void 0===t||(V.delete(e),Y(e,t.ssr,t.Oe),!t.Oe))return null;let l=u.Oe;return u.Oe=re,()=>{u.Oe=l,z()}}function z(){for(let e of D.values())J(e);D.clear()}function H(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function Z(e,t,l,n){let r=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===r||e.length>r[l].length)&&(r=n)}let o=r?.[n];if(null==o)return null;let i=r[l],s=""===i?t:t.slice(i.length+1);return""===o?s:""===s?o:`${o}.${s}`}function F(e,t,l){if(b()){if(l instanceof Array){for(let e=l.length;e-- >0;)o(l[e])&&l.splice(e,1);let e=t;if(l.some(i))k.add(e);else if(e.localName.includes("-")&&!B(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);A.set(e,t)}return}if("string"==typeof l){if(x.set(t,l),M(t.parentNode))return;let e=v(`wcs-t:${encodeURIComponent(l)}`),n=v("wcs-/t");return t.before(e),void t.after(n)}let n=N.get(e);void 0===n&&N.set(e,n=new Map),n.set(t,l);let r=t.getRootNode(),s=S.get(r);return void 0===s&&S.set(r,s=new Set),void s.add(e)}if("string"!=typeof l&&D.size>0){let e=D.get(l);void 0!==e&&(D.delete(l),D.set(t,e))}}var ee=e=>null!==e&&8===e.nodeType&&[c.commentIfPrefix,c.commentElseIfPrefix,c.commentElsePrefix].includes(e.data),te=e=>3===e.nodeType&&""===e.data.trim(),le=e=>(D.get(e)?.q??e).nextSibling;function ne(e,t){if(t.length!==e.sn.childNodes.length)return!1;let l=e.On;for(let n=0;n<l.length;n++){let r=l[n],o=e.sn,i=t[r[0]];for(let e=0;;){if(o=o.childNodes[r[e]],i?.nodeName!==o.nodeName)return!1;if(++e===r.length)break;i=i.firstChild;for(let t=r[e];t>0&&null!==i;t--)i=le(i)}e.ko[n]=i}return!0}function re(e,t,l){if(0===D.size)return null;let n=t,r=0;if(!l){let e=c.commentIfPrefix;if(!y(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ee(l)&&r++,!y(l,e));l=l.previousSibling);for(let l=t.nextSibling;!D.has(n)&&null!==l&&!y(l,e)&&1!==l.nodeType;l=l.nextSibling)ee(l)&&(n=l)}let o=D.get(n);if(void 0===o)return null;if(!l&&o.branch!==r)return D.delete(n),J(o),null;let i=o.f.shift();if(0===o.f.length&&D.delete(n),o.q?.replaceWith(...$(t,n)),o.q=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=D.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.q;)e++}if(!ne(e,s)){let l=(e.In?e.root:e.sn).cloneNode(!0);s=e.In?[l]:[...l.childNodes],ne(e,s),(i[0]??o.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var oe={name:"ssr",install(){u.jn=F,u.hr=_;let t=u.element;u.element=(l,r)=>{"mounting"===r&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||b())return;let r=l.previousElementSibling,o=r?.localName===h(),i=o?r.getAttribute("version"):null,s=null===i||d(i)===d(e);if(s){let e=t,l=e.ke;e.ke=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!o)return;let a=!s&&parseInt(i)<4,f=/^3\.(\d+)\.(\d+)$/.exec(i),p=null!==f&&(+f[1]-5||+f[2]-3)>=0;s||console.warn(`[@wcstack/state] <${h()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!p?" 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 m=s?r.querySelector('script[type="application/json"]'):null;if(null!==m){let e=JSON.parse(m.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let g=l.getRootNode();for(let e of Array.from(g.querySelectorAll(`[${E}]`)))e.textContent=e.getAttribute(E),e.removeAttribute(E);let w=9===g.nodeType?g.body:g;a?function(e,t,l){let r=new Map,o=e=>{let t=e.parentElement;for(;null!==t&&!B(t);)t=t.parentElement;if(null===t)return null;let l=r.get(t);if(void 0===l){let e=o(t),i=t.querySelector(`:scope > ${c.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,l=[]);for(let r of n(t.getAttribute(c.bindAttributeName)??"")){let t=r.Qe;r.$e[0]===i&&l.push([e?Z(e,t,1,0):t,r.$e.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=o(e);if(null===n)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return l?t:Z(n,t,0,1)??t;let i=r[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?r[2]:Z(n,r[2],2,1)??r[2]};for(let t of H(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!y(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[v(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of H(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],r=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===r)continue;let o=document.importNode(r,!0),a=c.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,r)=>t+i(l??n,r))),s(o.content,l??n);let u=o.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(w,r,p):Y(w,r,s),r.remove(),s&&(u.Oe=re,queueMicrotask(()=>{z(),u.Oe=null}))}(l),t?.(l,r)},function(){let e=globalThis;e[G]={build:U,reset(){R=0}},void 0===e[g]&&(e[g]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[G].build(t),reset:()=>e[G].reset()})}(),u.To=f(u.To,m);for(let e of l())m(e)}},ie=oe;export{ie as default,oe as ssr};
1
+ import{a as e}from"../chunks/chunk-27N3IPIZ.js";import{b as t,c as l}from"../chunks/chunk-ARPZVNKL.js";import"../chunks/chunk-JMPQHCIT.js";import{a as n,i as r,j as o,k as i,l as s,m as a}from"../chunks/chunk-7EWPQMA6.js";import"../chunks/chunk-XF6V6DWR.js";import"../chunks/chunk-LTBR3OV5.js";import{a as c}from"../chunks/chunk-W5KT4PQ3.js";import"../chunks/chunk-2EGTC36Y.js";import"../chunks/chunk-SPWZUBQS.js";import"../chunks/chunk-ALVA5TQM.js";import{a as u,b as f}from"../chunks/chunk-V34ZHCK5.js";var d=e=>e.split(".").slice(0,2).join("."),p=class extends t{static find(e){return e.querySelector?.(c.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 d(this.version)===d(e)}};function m(e){let t=c.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends p{})}var h=()=>c.tagNames.ssr,g=Symbol.for("wcstack.ssr.snapshotBuilder"),b=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),v=e=>document.createComment(e),y=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,w=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),N=new WeakMap,S=new WeakMap,A=new WeakMap,k=new WeakSet,x=new WeakMap;function $(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function T(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var W=e=>null===e.D?e.Ue:e.D[e.D.length-1];function j(e,t,l){let n=[v(null===l?"wcs-[":`wcs-[:${l}`)];for(let e of t)null===l&&n.push(v("wcs-|")),n.push(...$(e.Ue,W(e)));n.push(v("wcs-]")),e.after(...n);for(let e of n)k.add(e)}function C(e){if(e instanceof r){j(e.S,e.Ne,null);for(let t of e.Ne)q(t);return}let t=e.O;null!==t&&(j(e.G[e.G.length-1].S,[t],e.b),q(t))}function q(e){if(null!==e.c)for(let t of e.c)C(t)}var O=new Set(["script","style","template","textarea","title"]),E="data-wcs-raw",M=e=>O.has(e.localName)||e.localName===h();function I(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(v("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(v("wcs-s")):1===t.nodeType&&!M(t)&&I(t)}var P=0;function R(t,l){let n=t.getRootNode(),r=[l];for(let e of S.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&r.push(e);let o=new Map;for(let e of r){let t=N.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.E&&l.set(t.E.S,t.E),null!==t.L)for(let e of t.L)l.set(e.S,e);for(let t of e.ce.values())for(let e of t)if(null!==e._)for(let t of e._.G)l.set(t.S,e._);let n=new Set;for(let[e,r]of t){o.set(e,r);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),C(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=A.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>k.has(e)||1===e.nodeType&&t.has(e)&&L(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(M(e.parentNode)?x.has(e):t.has(l)&&w(l,"wcs-t:"))&&(x.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);M(e)&&l.some(e=>x.has(e))&&e.setAttribute(E,l.map(e=>x.has(e)?`{{ ${x.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}I(9===n.nodeType?n.body:n);let i=document.createElement(h());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.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 l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of o){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,r=`wcs-${n?"s":"t"}${P++}`;e.replaceWith(v(`wcs-p:${r}`));let o=document.importNode(a(t),!0);for(let e of Array.from(o.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(T(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(o),o=e}let s=document.createElement("template");s.id=r,i.append(T(t,s,o))}t.before(i)}function U(e){!function(e){if(null!==e.querySelector(c.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=>x.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(`${c.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===h())continue;let e=t.engine;null!=e&&R(t,e)}}var V=Symbol.for("wcstack.state.ssr.impl"),D=new Map,Q=new WeakMap,L=e=>!0===u.$o?.(e),G=e=>1===e.nodeType&&!M(e)&&!L(e),J=e=>e.f.flat().concat(e.q??[]),Z=e=>{for(let t of J(e))t.remove()};function B(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),r=e.previousSibling,o=e.parentNode,i=[],a=e.nextSibling;for(e.remove();null!==a&&!y(a,"wcs-]");){let e=a.nextSibling;if(y(a,"wcs-|"))i.push([]),a.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];w(a,"wcs-[")?e=B(a,t,l):(l.push(a),G(a)&&K(a,t))}a=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,q:a??o.appendChild(v("wcs-]"))},u=J(c);a=c.q.nextSibling;for(let e of u)l?.push(e),t&&s.add(e);return t&&null!==r?D.set(r,c):Z(c),a}function K(e,t){for(let l=e.firstChild;null!==l;)w(l,"wcs-[")?l=B(l,t):(G(l)&&K(l,t),l=l.nextSibling)}function _(e,t,l){let n=e=>{for(let r of Array.from(e.childNodes))if(r.parentNode===e)if(8===r.nodeType){let e=r.data;try{if("wcs-s"===e)r.remove();else if("wcs-e"===e)r.replaceWith("");else if(e.startsWith("wcs-t:")){let t=v(`@@:${decodeURIComponent(e.slice(6))}`),l=r.nextSibling;for(;null!==l&&!y(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),r.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=r.parentNode,n="s"===e[10]?T(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,r)}}}catch{}}else 1===r.nodeType&&!M(r)&&(L(r)?Q.set(r,{ssr:t,Oe:l}):n(r))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||te(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{w(e,"wcs-[")?n++:y(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let r=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(w(n,"wcs-["))r++;else if(y(n,"wcs-]")&&0===r--){t.prepend(...e.slice(l));break}}}(e),K(e,l)}function z(e){let t=Q.get(e);if(void 0===t||(Q.delete(e),_(e,t.ssr,t.Oe),!t.Oe))return null;let l=u.Oe;return u.Oe=re,()=>{u.Oe=l,H()}}function H(){for(let e of D.values())Z(e);D.clear()}function F(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function X(e,t,l,n){let r=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===r||e.length>r[l].length)&&(r=n)}let o=r?.[n];if(null==o)return null;let i=r[l],s=""===i?t:t.slice(i.length+1);return""===o?s:""===s?o:`${o}.${s}`}function Y(e,t,l){if(b()){if(l instanceof Array){for(let e=l.length;e-- >0;)o(l[e])&&l.splice(e,1);let e=t;if(l.some(i))k.add(e);else if(e.localName.includes("-")&&!L(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);A.set(e,t)}return}if("string"==typeof l){if(x.set(t,l),M(t.parentNode))return;let e=v(`wcs-t:${encodeURIComponent(l)}`),n=v("wcs-/t");return t.before(e),void t.after(n)}let n=N.get(e);void 0===n&&N.set(e,n=new Map),n.set(t,l);let r=t.getRootNode(),s=S.get(r);return void 0===s&&S.set(r,s=new Set),void s.add(e)}if("string"!=typeof l&&D.size>0){let e=D.get(l);void 0!==e&&(D.delete(l),D.set(t,e))}}var ee=e=>null!==e&&8===e.nodeType&&[c.commentIfPrefix,c.commentElseIfPrefix,c.commentElsePrefix].includes(e.data),te=e=>3===e.nodeType&&""===e.data.trim(),le=e=>(D.get(e)?.q??e).nextSibling;function ne(e,t){if(t.length!==e.sn.childNodes.length)return!1;let l=e.On;for(let n=0;n<l.length;n++){let r=l[n],o=e.sn,i=t[r[0]];for(let e=0;;){if(o=o.childNodes[r[e]],i?.nodeName!==o.nodeName)return!1;if(++e===r.length)break;i=i.firstChild;for(let t=r[e];t>0&&null!==i;t--)i=le(i)}e.ko[n]=i}return!0}function re(e,t,l){if(0===D.size)return null;let n=t,r=0;if(!l){let e=c.commentIfPrefix;if(!y(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ee(l)&&r++,!y(l,e));l=l.previousSibling);for(let l=t.nextSibling;!D.has(n)&&null!==l&&!y(l,e)&&1!==l.nodeType;l=l.nextSibling)ee(l)&&(n=l)}let o=D.get(n);if(void 0===o)return null;if(!l&&o.branch!==r)return D.delete(n),Z(o),null;let i=o.f.shift();if(0===o.f.length&&D.delete(n),o.q?.replaceWith(...$(t,n)),o.q=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=D.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.q;)e++}if(!ne(e,s)){let l=(e.In?e.root:e.sn).cloneNode(!0);s=e.In?[l]:[...l.childNodes],ne(e,s),(i[0]??o.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var oe={name:"ssr",install(){u.jn=Y,u.hr=z;let t=u.element;u.element=(l,r)=>{"mounting"===r&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||b())return;let r=l.previousElementSibling,o=r?.localName===h(),i=o?r.getAttribute("version"):null,s=null===i||d(i)===d(e);if(s){let e=t,l=e.ke;e.ke=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!o)return;let a=!s&&parseInt(i)<4,f=/^3\.(\d+)\.(\d+)$/.exec(i),p=null!==f&&(+f[1]-5||+f[2]-3)>=0;s||console.warn(`[@wcstack/state] <${h()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!p?" 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 m=s?r.querySelector('script[type="application/json"]'):null;if(null!==m){let e=JSON.parse(m.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let g=l.getRootNode();for(let e of Array.from(g.querySelectorAll(`[${E}]`)))e.textContent=e.getAttribute(E),e.removeAttribute(E);let w=9===g.nodeType?g.body:g;a?function(e,t,l){let r=new Map,o=e=>{let t=e.parentElement;for(;null!==t&&!L(t);)t=t.parentElement;if(null===t)return null;let l=r.get(t);if(void 0===l){let e=o(t),i=t.querySelector(`:scope > ${c.tagNames.state}[bind-component]`).getAttribute("bind-component");r.set(t,l=[]);for(let r of n(t.getAttribute(c.bindAttributeName)??"")){let t=r.Qe;r.$e[0]===i&&l.push([e?X(e,t,1,0):t,r.$e.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=o(e);if(null===n)return t;let r=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===r)return l?t:X(n,t,0,1)??t;let i=r[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?r[2]:X(n,r[2],2,1)??r[2]};for(let t of F(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!y(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[v(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of F(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],r=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===r)continue;let o=document.importNode(r,!0),a=c.bindAttributeName;o.removeAttribute("id"),o.setAttribute(a,o.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,r)=>t+i(l??n,r))),s(o.content,l??n);let u=o.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(u?.getAttribute?.(a)??"")?o.content.childNodes:[o])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(w,r,p):_(w,r,s),r.remove(),s&&(u.Oe=re,queueMicrotask(()=>{H(),u.Oe=null}))}(l),t?.(l,r)},function(){let e=globalThis;e[V]={build:U,reset(){P=0}},void 0===e[g]&&(e[g]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[V].build(t),reset:()=>e[V].reset()})}(),u.To=f(u.To,m);for(let e of l())m(e)}},ie=oe;export{ie as default,oe as ssr};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/state",
3
- "version": "4.0.0-rc.6",
3
+ "version": "4.0.0-rc.7",
4
4
  "description": "Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",
@@ -1 +0,0 @@
1
- import{j as e}from"./chunk-XF6V6DWR.js";import{a as t,d as n,e as l,j as i,k as r}from"./chunk-LTBR3OV5.js";import{a as o,g as s}from"./chunk-W5KT4PQ3.js";import{a as u}from"./chunk-2EGTC36Y.js";import{a,b as h,c,d as f,e as d,f as m,g as p,h as g,i as v,j as b,k as w,l as y,n as x}from"./chunk-SPWZUBQS.js";import{a as S,b as N}from"./chunk-ALVA5TQM.js";import{a as T}from"./chunk-V34ZHCK5.js";var k=new Map,j=new Set(["if","elseif","else","for"]),A=new Set([a,"if","elseif","for","..."]),E=new Set([d,m,p,f,h,c]);function F(e){let t=function(e){return w(e,";")}(e).map(v).filter(e=>e.length>0).map(e=>{let t=b(e,":");-1===t&&N(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if(A.has(i)){let t;return i!==n&&N(102,[e,i]),i===a?(l.length>0&&N(103,[e]),t={Qe:"#else",Ze:[]}):"..."===i?(0===l.length&&N(104,[e]),t=x(l),t.Ze.length>0&&N(105,[e])):(t=x(l),"for"===i&&t.Ze.length>0&&N(121,[e])),{Se:i,$e:[i],on:[],j:[],...t,w:"..."===i?"spread":i}}let r=x(l),o=function(e){let[t,n]=y(e,"input",k),l=t.split("#").map(v);l.length>2&&N(115,[t]);let[i,r]=l,o=i.split(".").map(v);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&N(116,[e]),{Se:i,$e:o,on:r?r.split(",").map(v):[],j:n}}(n),[s]=o.$e;if(""===s&&o.$e.length>1){let e=o.$e.slice(1);return(e.includes("")||E.has(e[0]))&&N(106,[n]),{...o,Se:e.join("."),$e:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===h||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>j.has(e.w))&&N(201,[e]),t}function $(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function C(t){return 0===t.length?null:(e(),t.map(e=>s(e.Hn,e.args,e.literals)))}var L=Symbol.for("wcstack.state.view-transition-naming"),P=new WeakSet;function D(){let e=t("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var O=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),K=0,R=2,W=3,U=4,M=5,V=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],G=(e,t,n,l)=>e.Gt(t,n.o?.t??n.Rt,l,V[n.i]),I=Symbol();function B(e,t,n){let l=t.K;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.U:I}var q=class{constructor(e,t,n,l,i,r,o,s,u,a=null){this.te=!1,this.j=null,this.attribute=null,this.Tn=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.Pn=o,this.x=s,this.value=u,this._=a}nn(){return V[this.i]}apply(){if(null!==this._)return void this._.Et();let e=$(this.x,this.engine.read(this.o,this.r));if(e===this.value&&("object"!=typeof e||null===e||11===this.i||8===this.i||i(this.name)))return;if(this.value===I)return void(this.value=e);let t=this.a;if(11!==this.i)9===this.i?t.checked=void 0!==e&&this.rn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.rn()):Z(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.Tn=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.Tn=!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)}}rn(){return $(this.j,this.a.value)}ir(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.rn()}else if(10===this.i){let l=this.rn(),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=$(this.j,t[this.name]);n.T(this.o,this.r,e,!1,!0)}},Q=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Z(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(Q(n)?t[n]="innerHTML"===n?r(l):null==l?"":String(l):i(n)?null==l&&"srcdoc"===n?t.removeAttribute(n):void 0!==l&&(t[n]=r(l)):void 0!==l&&(t[n]!==l&&!("value"===n&&t.value===String(l))&&(t[n]=l),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[H]=[n,l])));case 8:return void(t.innerHTML=r(l));case 2:return null!=l&&"boolean"!=typeof l&&N(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 H=Symbol();function X(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[H];void 0!==n&&(t[n[0]]=n[1])}var z=class{constructor(e,t,n,l){this.y=!0,this.he=null,this.c=null,this.Nt=null,this.Fn=null,this.r=e,this.Ue=t,this.D=n,this.F=l}Qo(e,t){let n=t.target,l=this.F,i=[],r=null;for(let t of l.Re){if(t.name!==e)continue;let o=l.On[t.a],s=ue(null===this.D?this.Ue:this.D[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.An(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.D?this.Ue:this.D[this.D.length-1]}qe(){let e=this.Fn;return(null===e?null:e.Cn(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}}wo(){null===this.D?this.Ue.remove():ae(this.qe(),this.s)}xe(e){if(this.y=!1,null!==this.Nt)for(let e of this.Nt)e();let t=this.he;if(null!==t)for(let n=0;n<t.length;n++)e.Nn(t[n]);if(null!==this.c)for(let e of this.c)e.xe()}},_=class extends z{constructor(e,t,n,l){super(e,t,n,l),this.bo=0,this.V=null,this.fe=0===l.ze.length?null:new Array(2*l.ze.length)}vo(e,t){let n=this.V??=new Array(this.F.ze.length),l=n[t];if(void 0===l){let i=this.F.ze[t],r=this.fe;l=n[t]=new q(e,i.i,r[2*t],i.name,i.o,this.r,this,i.x,r[2*t+1])}return l}uo(e,t){let n=this.F.ze;for(let l=0;l<n.length;l++)n[l].o.ee(t)&&e.en(this.vo(e,l))}xe(e){let t=this.r;t.E===this&&(t.E=null),super.xe(e)}};function J(e,t,n,i){let r=l(n,t.n);try{return e.We(r,t)}catch(n){return e.Gt(n,t.t,i,"for"),null===r?e.oe.get(t):r.c.get(t)}}function Y(e,t,n){n&&e.nr(t);let l=t.Pn;null!==l&&(l.he??=[]).push(t)}var ee=null;function te(){let e=ee;return ee=null,e}var ne=-1;function le(e,t,n,l,i=null){let r,o=t.On,s=t.build,u=t.ko,a=null,h=T.Oe?.(t,null===l?i:l.S,null!==l),c=!h&&t.In,f=h?document.createDocumentFragment():(c?t.root:t.sn).cloneNode(!0);if(!h)for(let e=0;e<s.length;e++){let t=s[e];u[t]=ue(f,o[t],c?1:0)}c?r=f:(a=h||[...f.childNodes],r=a[0]);let d,m=null;if(null!==l?(d=m=new _(n,r,a,t),null===l.map?n.E=m:l.map.set(n,m)):d=new z(n,r,a,t),ne>=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||P.has(i))return;let o=globalThis[L]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${S(25,[l])}`)):(P.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,a,null!==l?"row":"branch",ne),t.Re.length>0){let t=e.Kn;if(null===a)r[t]=d;else for(let e of a)1===e.nodeType&&(e[t]=d)}let p=t.sr,g=e.De,v=t.lr?u.slice(0,o.length):u,b=null===m?null:m.fe;if(null!==b){let e=t.ze;for(let t=0;t<e.length;t++)b[2*t]=v[e[t].a],b[2*t+1]=e[t].U}for(let t=0;t<p.length;t++){let l=p[t],i=v[l.a],o=l.A;if(o>=0&&null!==b){let t=m.V?.[o];if(void 0!==t){t.te=!1,e.Ve(t);continue}try{let t=$(l.x,e.read(l.o,n));t!==l.U&&(Z(l.i,i,l.name,t),b[2*o+1]=t),null!==g&&e.po(l.o,n)}catch(t){e.xt(t,m.vo(e,o))}continue}switch(l.i){case 6:{let t=new se(e,l.F,J(e,l.o,n,i),i);(d.c??=[]).push(t),i===r&&(d.Fn=t),t.Et();break}case 7:{let t=re(e,l.G.map(e=>({F:e.F,o:e.o,x:e.x,S:v[e.a]})),n,d);(d.c??=[]).push(t),i===r&&(d.Fn=t);break}default:try{ie(e,l,i,n,d)}catch(t){G(e,t,l,i)}}}return ee=d,f}function ie(e,t,n,i,r){let o=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.An,o=e=>r(e,l);if(n.et){let l=e.ao(n.name),i=t[l];t[l]=void 0===i?o:e=>{i(e),o(e)},n.Ee&&t.addEventListener(n.name,e=>e.bubbles||o(e))}else t.addEventListener(n.name,o),n.yo&&null!==i&&(i.Nt??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,i,r);case 12:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.Rt.slice(9)),s=null===i?T.or?.(n,r):null;s||(null===i&&me(1202,n,`command.${r}`),i.commands.has(r)||N(1203,[n.localName,r]));let u=new WeakRef(n),a=o.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?s?s(t,e):t[r](...e):void 0;a()});null!==l&&(l.Nt??=[]).push(a)}(e,t,o,r,n));case 13:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name;null===i&&me(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&N(1204,[n.localName,r]);let s=t.Rt;n.addEventListener(o.event,n=>{t.Pt&&n.preventDefault(),t.Tt&&n.stopPropagation();try{e.Zo(s,n,l)}catch(e){console.error(e)}})}(e,t,o,i,n))}let s=t.o,u=l(i,s.n);if(14===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){null===r&&me(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs.keys()]);for(let s of o){if(t.go?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),u=0===o.n?null:l;de(e,{...t,K:null,X:null},n,s,o,u,i,r)}}(e,t,o,u,r,n));if(t.Ee&&1===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){if(null!==r)return void de(e,t,n,t.name,t.o,l,i,r);let o=new q(e,1,n,t.name,t.o,l,i,t.x,B(e,t,l));o.j=t.j,!T.ar?.(o,t.ro)&&(Y(e,o,!0),e.Ve(o))}(e,t,o,u,r,n));let a=new q(e,t.i,n,t.name,s,u,r,t.x,B(e,t,u));a.j=t.j,Y(e,a,!0),e.Ve(a),null!==t.At&&n.addEventListener(t.At,()=>a.ir())}function re(e,t,n,i){let r=new oe(e,t,n),o=null;for(let s of t){if(null===s.o)continue;let t=s.o,u=new q(e,7,s.S,"if",t,l(n,t.n),i,null,void 0,r);Y(e,u,!0),null===i&&r.ce.push(u),o??=u}return e.Ve(o),r}var oe=class{constructor(e,t,n){this.y=!0,this.O=null,this.b=-1,this.ce=[],this.engine=e,this.G=t,this.r=n}Cn(e){return null!==this.O&&this.G[this.b].S===e?this.O.qe():null}Et(){let e=this.engine,t=-1;for(let n=0;n<this.G.length;n++){let i=this.G[n];if(null===i.o||$(i.x,e.read(i.o,l(this.r,i.o.n)))){t=n;break}}if(t!==this.b&&(ne=D(),null!==this.O&&(this.O.wo(),this.O.xe(e),this.O=null),this.b=t,t>=0)){let n=this.G[t],l=le(e,n.F,this.r,null,n.S);this.O=te();let i=n.S.parentNode;i.insertBefore(l,n.S),X(i)}}xe(){this.y=!1;for(let e of this.ce)this.engine.Nn(e);null!==this.O&&this.O.xe(this.engine)}},se=class{constructor(e,t,n,l){this.y=!0,this.Ne=[],this.engine=e,this.F=t,this.l=n,this.S=l,null===n.E?(n.E=this,this.map=null):((n.L??=[]).push(this),this.map=new Map)}Cn(e){return 0===this.Ne.length?null:this.Ne[0].qe()}Ft(e){return null===this.map?e.E:this.map.get(e)??null}Dt(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.xe(this.engine)}Et(){let e=this.engine,t=this.l.f,n=this.Ne;ne=D();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){let e=n[0].qe(),t=n[i-1].s,l=[];for(let n=o.firstChild;null!==n;n=n===e?t.nextSibling:n.nextSibling)if(n!==e){if(n!==r&&3!==n.nodeType){l=null;break}l.push(n)}null!==l?o.replaceChildren(...l):ae(e,t);for(let e=0;e<i;e++)this.Dt(n[e])}return void(this.Ne=[])}let s=new Array(l),u=0;for(;u<l&&u<i&&this.Ft(t[u])===n[u];)s[u]=n[u],u++;let a=i-1,h=l-1;for(;a>=u&&h>=u&&this.Ft(t[h])===n[a];)s[h]=n[a],a--,h--;for(let e=u;e<=a;e++){let t=n[e],l=t.r;l.y&&this.Ft(l)===t?t.bo=e:(t.wo(),this.Dt(t))}if(u<=h){let n=h-u+1,a=new Int32Array(n),c=!1;if(i>0)for(let e=0;e<n;e++){let n=this.Ft(t[u+e]);null!==n&&n.y?(a[e]=n.bo,c=!0):a[e]=-1}let f=h+1<l?s[h+1].qe():r;if(c){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}(a),i=f;for(let r=n-1;r>=0;r--){let n=t[u+r],a=this.Ft(n);null!==a&&a.y?0===l[r]&&a.insertBefore(o,i):(o.insertBefore(le(e,this.F,n,this),i),a=te()),s[u+r]=a,i=a.qe()}}else{let n=document.createDocumentFragment();for(let l=u;l<=h;l++)n.appendChild(le(e,this.F,t[l],this)),s[l]=te();o.insertBefore(n,f)}}this.Ne=s,X(o)}xe(){this.y=!1;let e=this.l;if(e.E===this)e.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.Ne)e.xe(this.engine);this.map?.clear()}};function ue(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 ae(e,t){for(let n,l=e;l!==t;l=n)n=l.nextSibling,l.remove();t.remove()}var he=new WeakMap,ce=e=>e.customElementRegistry??customElements;function fe(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=ce(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>fe(e,t,n,l,i,!0));let u=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(he.has(e))return he.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,ho:"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 he.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return u();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.Nt??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{u()}catch(l){G(e,l,t,n)}e.Te()})}function de(e,t,n,l,i=t.o,r,o,s){let u=s.properties.get(l)??null,a=s.inputs.get(l),h=e._t;h&&null===u&&void 0===a&&N(38,[l]);let c=t.K;(null===u?"element"===c||"auto"===c:void 0===a&&("state"===c||"auto"===c))&&N(39,[c,l]),"connect"===t.X&&null===u&&N(40,[l]);let f=h&&null!==u&&void 0===a,d=new q(e,11,n,l,i,r,o,t.x,void 0);d.j=t.j,d.attribute=a?.attribute??null,Y(e,d,!f),null!==u&&!t.ro&&n.addEventListener(u.event,t=>{let i;null!==u.getter?i=u.getter(t):(i=t.detail,u.ho||T.detail?.(n,l,i)),(!d.Tn||!Object.is(i,d.value))&&(i=$(d.j,i),null===d.x&&(d.value=i),e.T(d.o,d.r,i,u.ho,!0))});let m=c??(f?"element":"state");if("state"===m)f||e.Ve(d);else if("element"===m||"auto"===m){let i=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==e.v(d.o,d.r))return void(f||e.Ve(d));let t=n[l];null===d.x&&(d.value=t),e.T(d.o,d.r,t,!1,!0)};"connect"!==t.X||n.isConnected?i():Promise.resolve().then(i)}return d}function me(e,t,n){N(e,[t.localName,n])}var pe=()=>o.bindAttributeName;function ge(){return{a:0,i:1,name:"",o:null,x:null,U:u,An:null,F:null,G:null,j:null,At:null,Ee:!1,K:null,X:null,ro:!1,Pt:!1,Tt:!1,Rt:null,go:null,A:-1,et:!1,yo:!1}}var ve=["state","element","auto","none"],be=["call","connect"],we="$command.";function ye(e,t,n){g.test(t)&&(null===n&&N(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&&N(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&N(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.h[e];l.h[e]!==t&&N(1403,[l.t,l.h[e].t,t.t])}return T.So?.(e,l),l}var xe=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),Se=e=>8===e.i||xe(e)||1===e.i&&Q(e.name);function Ne(e){N(202,[e])}function Te(e,t,l,r,o){let s=F(t).map(t=>function(e,t,l,r,o){let s=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._t||N(31);let r=n.slice(0,t).trim(),o=n.slice(t+1).trim(),s="init"===r;!s&&"sync"!==r&&N(33,[r,n]),null!==(s?l:i)&&N(34,[r]),(s?ve:be).includes(o)||N(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),Pt:t.includes("prevent"),Tt:t.includes("stop"),event:n?n.slice(2):null,K:l,X:i}}(e,t.on),u=r.localName.includes("-"),a=t.$e,h=t.Qe;if("event"===t.w){if(null!==s.K&&"none"!==s.K&&N(36),"eventToken"===a[0])return{...ge(),a:o,i:13,name:a.slice(1).join("."),Rt:h,Ee:u,Pt:s.Pt,Tt:s.Tt};let l=h.startsWith(we)?h.slice(9):null,{Pt:i,Tt:r}=s,c=t.Se.slice(2),f=t.on.includes("direct"),d=!f&&O.has(c);return d&&e.ao(c),{...ge(),a:o,i:5,name:c,et:d,Ee:u,yo:f,An(t,o){i&&t.preventDefault(),r&&t.stopPropagation();try{if(null!==l)e.er(l,t,o);else{let l=e.tr(h,t,o);n(l)&&l.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...ge(),a:o,i:14,o:ye(e,h,l),Ee:u};if("command"===a[0]&&a.length>1)return h.startsWith(we)||N(1201,[t.Se,h]),{...ge(),a:o,i:12,name:a.slice(1).join("."),Rt:h,Ee:u};let c=ye(e,h,l),f={...ge(),a:o,i:1,name:t.Se,o:c,x:C(t.Ze),j:C(t.j),ro:s.ro,K:s.K,X:s.X};if("radio"===t.w||"checkbox"===t.w)return("element"===s.K||"auto"===s.K)&&N(37,[t.w,s.K]),f.i="radio"===t.w?9:10,s.ro||(f.At=s.event??"input"),f;if(a.length>1){let e=a.slice(1).join("."),t=a[0];if("class"===t||"attr"===t||"style"===t)return f.K=null,f.name=e,"class"===t?(f.i=2,f.U=r.classList.contains(e)):f.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,f}return"html"===t.Se?(f.i=8,f):(f.name="text"===t.Se?"textContent":t.Se,f.Ee=u&&!i(f.name),!u&&!s.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}(r,f.name)&&(f.At=s.event??("select"===r.localName?"change":"input")),f)}(e,t,l,r,o));for(let e=0;e<s.length;e++)14===s[e].i&&(s[e].go=s.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return s}var ke=/\{\{([\s\S]+?)\}\}/g;function je(e){let t=e.data,n=[],l=0;ke.lastIndex=0;for(let i=ke.exec(t);null!==i;i=ke.exec(t)){let r=ke.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,cr:i[1].trim()}),l=ke.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function Ae(e,t,n,l){let i=function(e){return{Se:"textContent",$e:["textContent"],on:[],j:[],...x(e),w:"text"}}(t);return{...ge(),a:l,i:0,o:ye(e,i.Qe,n),x:C(i.Ze),U:""}}function Ee(e){let t=e.getAttribute(pe());if(null===t)return null;let n=F(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var Fe=(e,t)=>0===e?o.commentIfPrefix:null===t.o?o.commentElsePrefix:o.commentElseIfPrefix;function $e(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:ye(e,l.Qe,n),x:"else"===l.w?null:C(l.Ze)}),i=[l(t,Ee(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=Ee(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var Ce=new WeakSet;function Le(e,t,n,l,i,r,s,u){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&T.jn?.(e,i,t),i},h=t=>{for(let c=0;c<t.length;c++){let f=t[c];if(null!==f.parentNode)if(1===f.nodeType){let t=f,u=t.localName;if(l){if("script"===u||"style"===u||Ce.has(t))continue;if(Ce.add(t),u===o.tagNames.state){h([...t.childNodes]);continue}}let c="template"===u?Ee(t):null;if(null!==c){if("for"===c.w){let l=ye(e,c.Qe,n),r=Oe(e,t,l,!0);i(a(t,o.commentForPrefix),l,r)}else"if"===c.w?r($e(e,t,n).map((t,l)=>({F:Oe(e,t.el,n,!1),o:t.o,x:t.x,S:a(t.el,Fe(l,t))}))):Ne(c.w);continue}let d=t.getAttribute(pe()),m=null===d?null:Te(e,d,n,t,0),p="noscript"!==u&&"iframe"!==u&&!m?.some(Se)&&!T.$o?.(t);try{l&&p&&h([...t.childNodes])}finally{null!==m&&s(t,m)}!l&&p&&h([...t.childNodes])}else if(3===f.nodeType&&e.Mt&&f.data.includes("{{")&&!Ce.has(f))for(let{a:e,cr:t}of je(f))u(e,t);else if(8===f.nodeType){let e=Pe.exec(f.data),t=e&&f.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");f.replaceWith(t),u(t,e[1])}}}};h(t)}var Pe=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,De=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Oe(e,t,n,l){let i=document.importNode(De(t),!0),r=[],o=[],s=e=>r.push(e)-1;Le(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...ge(),a:s(e),i:6,o:t,F:n})},e=>{let t=e.map(e=>({a:s(e.S),F:e.F,o:e.o,x:e.x}));o.push({...ge(),a:t[0].a,i:7,G:t})},(e,t)=>{let n=s(e);for(let e of t)xe(e)&&N(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(pe())},(t,l)=>{o.push(Ae(e,l,n,s(t)))}),Ue(i,new Set(r),!0);let u=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)),a=1===i.childNodes.length&&8!==i.firstChild.nodeType,h=o.some(e=>6===e.i||7===e.i),c=[],f=new Set,d=[],m=[],p=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.et&&!e.Ee&&!Ke(r[e.a],i)){d.push(e);continue}m.push(e);let t=e.o;if(null!==t&&t.n===p&&t.h[p]===n&&Re(e)&&(e.A=c.push(e)-1),7===e.i)for(let t of e.G)f.add(t.a);else f.add(e.a)}let g=[...f].sort((e,t)=>e-t);return{sn:i,root:a?i.firstChild:null,On:u,build:g,Re:d,sr:m,In:a,lr:h,ko:[],ze:c}}function Ke(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 Re(e){if(null!==e.K)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.Ee&&null===e.At;default:return!1}}var We=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Ue(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&&Ue(l,t,We.has(l.localName)),l=e}}var Me=new WeakMap;function Ve(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Me.set(t,e),Ie(e,[...n.childNodes]),e.He()}function Ge(e,t,n){try{let l="template"===t.localName?Ee(t):null;null!==l&&!n&&N(204,[l.w]),Ie(e,[t])}catch(e){console.error(e)}e.He()}function Ie(e,t){Le(e,t,null,!0,(t,n,l)=>{new se(e,l,J(e,n,null,t),t).Et()},t=>{re(e,t,null,null)},(t,n)=>{T.jn?.(e,t,n);for(let l of n)ie(e,l,t,null,null)},(t,n)=>{T.jn?.(e,t,n),ie(e,Ae(e,n,null,0),t,null,null)})}export{F as a,ce as b,K as c,R as d,W as e,U as f,M as g,_ as h,se as i,xe as j,Se as k,Ce as l,De as m,Me as n,Ve as o,Ge as p};
@@ -1 +0,0 @@
1
- var a="4.0.0-rc.6";export{a};