@wcstack/state 4.0.0-rc.2 → 4.0.0-rc.3

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.
Files changed (33) hide show
  1. package/README.ja.md +16 -14
  2. package/README.md +16 -14
  3. package/dist/auto.min.js +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/parser.esm.js +1 -0
  6. package/dist/split/auto.js +1 -1
  7. package/dist/split/chunks/{chunk-HFKGUDDJ.js → chunk-2PWEFKRB.js} +1 -1
  8. package/dist/split/chunks/chunk-5PWMZ75N.js +1 -0
  9. package/dist/split/chunks/chunk-FED2DM4X.js +1 -0
  10. package/dist/split/chunks/chunk-HYEQWIFX.js +1 -0
  11. package/dist/split/chunks/chunk-I2V4DGEI.js +1 -0
  12. package/dist/split/chunks/{chunk-WWJNAZVP.js → chunk-NPPWJBGJ.js} +1 -1
  13. package/dist/split/chunks/chunk-WPSUT5QQ.js +1 -0
  14. package/dist/split/chunks/chunk-YPD4YBJO.js +1 -0
  15. package/dist/split/chunks/{chunk-QQH6N5CJ.js → chunk-YZ4LWPXN.js} +1 -1
  16. package/dist/split/chunks/{chunk-732CB4QN.js → chunk-YZUTVCIH.js} +1 -1
  17. package/dist/split/chunks/{chunk-YOPPVWPQ.js → chunk-Z3EEGBYA.js} +1 -1
  18. package/dist/split/core.js +1 -1
  19. package/dist/split/features/devtools.js +1 -1
  20. package/dist/split/features/diagnostics.js +1 -1
  21. package/dist/split/features/formats.js +1 -1
  22. package/dist/split/features/list-keys.js +1 -1
  23. package/dist/split/features/recursion.js +1 -1
  24. package/dist/split/features/scopes.js +1 -1
  25. package/dist/split/features/ssr.js +1 -1
  26. package/dist/split/features/temporal.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/split/chunks/chunk-7PN5YNZZ.js +0 -1
  29. package/dist/split/chunks/chunk-FF6KHTYS.js +0 -1
  30. package/dist/split/chunks/chunk-PKDBVBAP.js +0 -1
  31. package/dist/split/chunks/chunk-QI7P7YPP.js +0 -1
  32. package/dist/split/chunks/chunk-UM3O6QXD.js +0 -1
  33. package/dist/split/chunks/chunk-WEL3YSG7.js +0 -1
@@ -363,6 +363,7 @@ var SENTENCES = {
363
363
  [46 /* FeaturesNotArray */]: () => '$features must be an array of add-on names (["temporal", "formats"]).',
364
364
  [49 /* InitFailed */]: (tag, ...at) => `${element(tag, at)} failed to initialize.`,
365
365
  [50 /* ConnectedFailed */]: (tag, ...at) => `${element(tag, at)} $connectedCallback failed.`,
366
+ [51 /* DisconnectedFailed */]: (tag, ...at) => `${element(tag, at)} $disconnectedCallback failed.`,
366
367
  [101 /* BindTextNoColon */]: (t) => `Invalid bindText: "${t}". Missing ':' separator between propPart and statePart.`,
367
368
  [102 /* StructuralTakesNoModifiers */]: (t, keyword) => `"${t}": "${keyword}" takes no modifiers or filters on its left side \u2014 write "${keyword}:".`,
368
369
  [103 /* ElseTakesNoValue */]: (t) => `"${t}": "else" takes no value \u2014 write "else:".`,
@@ -1 +1 @@
1
- import{d as t}from"./chunks/chunk-FF6KHTYS.js";import"./chunks/chunk-PKDBVBAP.js";import"./chunks/chunk-7PN5YNZZ.js";import"./chunks/chunk-HFKGUDDJ.js";import"./chunks/chunk-UM3O6QXD.js";import{a as n}from"./chunks/chunk-732CB4QN.js";import"./chunks/chunk-QI7P7YPP.js";import"./chunks/chunk-QQH6N5CJ.js";import"./chunks/chunk-WWJNAZVP.js";import{a as s,g as o}from"./chunks/chunk-YOPPVWPQ.js";var e,r=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools"],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.dt=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var u=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(u?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
1
+ import{d as t}from"./chunks/chunk-HYEQWIFX.js";import"./chunks/chunk-FED2DM4X.js";import"./chunks/chunk-5PWMZ75N.js";import"./chunks/chunk-2PWEFKRB.js";import"./chunks/chunk-WPSUT5QQ.js";import{a as n}from"./chunks/chunk-YZUTVCIH.js";import"./chunks/chunk-I2V4DGEI.js";import"./chunks/chunk-YZ4LWPXN.js";import"./chunks/chunk-NPPWJBGJ.js";import{a as s,g as o}from"./chunks/chunk-Z3EEGBYA.js";var e,r=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools"],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.ft=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var u=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(u?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
@@ -1 +1 @@
1
- import{c as n}from"./chunk-WWJNAZVP.js";function t(t){n(26,[t])}function u(t){n(27,[t])}function i(t){n(28,[t])}function o(t){n(29,[t])}function r(t){n(30,[t])}function a(n){return!(!n||isNaN(Number(n)))}function c(n,t){return a(n)||u(t),Number(n)}function s(n,u,i){return c(n?.[u]??t(i),i)}function f(n,t){return void 0!==t&&t.length>0?t[0]:n}export{t as a,u as b,i as c,o as d,r as e,a as f,c as g,s as h,f as i};
1
+ import{c as n}from"./chunk-NPPWJBGJ.js";function t(t){n(26,[t])}function u(t){n(27,[t])}function i(t){n(28,[t])}function o(t){n(29,[t])}function r(t){n(30,[t])}function a(n){return!(!n||isNaN(Number(n)))}function c(n,t){return a(n)||u(t),Number(n)}function s(n,u,i){return c(n?.[u]??t(i),i)}function f(n,t){return void 0!==t&&t.length>0?t[0]:n}export{t as a,u as b,i as c,o as d,r as e,a as f,c as g,s as h,f as i};
@@ -0,0 +1 @@
1
+ import{a as e,b as t,c as n,f as l,h as i,i as r}from"./chunk-2PWEFKRB.js";import{a as o,d as s,e as a,j as u,k as c}from"./chunk-WPSUT5QQ.js";import{a as f,e as h,g as d}from"./chunk-YZUTVCIH.js";import{a as m}from"./chunk-I2V4DGEI.js";import{a as p,b as v,c as g,d as y,e as b,f as w,g as x,h as S,i as N,j as k,k as A,l as E,n as I}from"./chunk-YZ4LWPXN.js";import{b as $,c as T}from"./chunk-NPPWJBGJ.js";import{a as j}from"./chunk-Z3EEGBYA.js";var L=new Map,P=new Set(["if","elseif","else","for"]),C=new Set([p,"if","elseif","for","..."]),V=new Set([b,w,x,y,v,g]);function W(e){let t=function(e){return A(e,";")}(e).map(N).filter(e=>e.length>0).map(e=>{let t=k(e,":");-1===t&&T(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if(C.has(i)){let t;return i!==n&&T(102,[e,i]),i===p?(l.length>0&&T(103,[e]),t={Je:"#else",Qe:[]}):"..."===i?(0===l.length&&T(104,[e]),t=I(l),t.Qe.length>0&&T(105,[e])):(t=I(l),"for"===i&&t.Qe.length>0&&T(121,[e])),{be:i,ve:[i],tn:[],I:[],...t,w:"..."===i?"spread":i}}let r=I(l),o=function(e){let[t,n]=E(e,"input",L),l=t.split("#").map(N);l.length>2&&T(115,[t]);let[i,r]=l,o=i.split(".").map(N);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&T(116,[e]),{be:i,ve:o,tn:r?r.split(",").map(N):[],I:n}}(n),[s]=o.ve;if(""===s&&o.ve.length>1){let e=o.ve.slice(1);return(e.includes("")||V.has(e[0]))&&T(106,[n]),{...o,be:e.join("."),ve:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===v||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>P.has(e.w))&&T(201,[e]),t}var M=(e,t)=>({factory:l=>{let r=i(l,0,e);return l=>("number"!=typeof l&&n(e),t(l,r))},arity:[1,1]}),B={eq:{factory:(n,i)=>{let o=n?.[0]??e("eq"),s=r(o,i);return e=>"number"==typeof e?"string"!=typeof s?e===s:(l(o)||t("eq"),e===Number(o)):"string"==typeof e?e===o:e===s},arity:[1,1]},ne:{factory:(n,i)=>{let o=n?.[0]??e("ne"),s=r(o,i);return e=>"number"==typeof e?"string"!=typeof s?e!==s:(l(o)||t("ne"),e!==Number(o)):"string"==typeof e?e!==o:e!==s},arity:[1,1]},not:{factory:()=>e=>!e,arity:[0,0]},lt:M("lt",(e,t)=>e<t),le:M("le",(e,t)=>e<=t),gt:M("gt",(e,t)=>e>t),ge:M("ge",(e,t)=>e>=t),add:M("add",(e,t)=>e+t),sub:M("sub",(e,t)=>e-t),mul:M("mul",(e,t)=>e*t),div:M("div",(e,t)=>e/t),mod:M("mod",(e,t)=>e%t),abs:{factory:()=>e=>("number"!=typeof e&&n("abs"),Math.abs(e)),arity:[0,0]},clamp:{factory:e=>{let t=i(e,0,"clamp"),l=i(e,1,"clamp");return e=>("number"!=typeof e&&n("clamp"),Math.min(Math.max(e,t),l))},arity:[2,2]},int:{factory:()=>e=>parseInt(String(e),10),arity:[0,0]},float:{factory:()=>e=>parseFloat(String(e)),arity:[0,0]},falsy:{factory:()=>e=>!e,arity:[0,0]},truthy:{factory:()=>e=>!!e,arity:[0,0]},defaults:{factory:(t,n)=>{let l=t?.[0]??e("defaults"),i=r(l,n);return e=>e||i},arity:[1,1]},coalesce:{factory:(t,n)=>{let l=t?.[0]??e("coalesce"),i=r(l,n);return e=>e??i},arity:[1,1]},boolean:{factory:()=>e=>!!e,arity:[0,0]},number:{factory:()=>e=>Number(e),arity:[0,0]},string:{factory:()=>e=>String(e),arity:[0,0]},nullIfEmpty:{factory:()=>e=>""===e?null:e,arity:[0,0]}},R=!1;function Y(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function O(e){return 0===e.length?null:(R||(R=!0,h(B)),e.map(e=>d(e.Dn,e.args,e.literals)))}var q=Symbol.for("wcstack.state.view-transition-naming"),H=new WeakSet;function Q(){let e=o("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var U=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),D=0,J=2,Z=3,z=4,F=5,K=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],_=(e,t,n,l)=>e.Yt(t,n.o?.t??n.$t,l,K[n.i]),G=Symbol();function X(e,t,n){let l=t.V;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.H:G}var ee=class{constructor(e,t,n,l,i,r,o,s,a,u=null){this.Z=!1,this.I=null,this.attribute=null,this.En=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.$n=o,this.x=s,this.value=a,this.M=u}en(){return K[this.i]}apply(){if(null!==this.M)return void this.M.vt();let e=Y(this.x,this.engine.read(this.o,this.r));if(e===this.value&&("object"!=typeof e||null===e||11===this.i||8===this.i||u(this.name)))return;if(this.value===G)return void(this.value=e);let t=this.a;if(11!==this.i)9===this.i?t.checked=void 0!==e&&this.nn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.nn()):ne(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.En=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.En=!1}null!==this.attribute&&function(e,t,n){try{if(null==n)e.removeAttribute(t);else{let l=n;if("object"==typeof n)try{l=JSON.stringify(n)}catch{}e.setAttribute(t,String(l))}}catch{}}(t,this.attribute,e)}}nn(){return Y(this.I,this.a.value)}Yo(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.nn()}else if(10===this.i){let l=this.nn(),i=n.v(this.o,this.r),r=Array.isArray(i)?i:[],o=r.includes(l);if(t.checked?o:!o)return;e=o?r.filter(e=>e!==l):[...r,l]}else e=Y(this.I,t[this.name]);n.P(this.o,this.r,e,!1,!0)}},te=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function ne(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(te(n)?t[n]="innerHTML"===n?c(l):null==l?"":String(l):u(n)?null==l&&"srcdoc"===n?t.removeAttribute(n):void 0!==l&&(t[n]=c(l)):void 0!==l&&(t[n]!==l&&!("value"===n&&t.value===String(l))&&(t[n]=l),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[le]=[n,l])));case 8:return void(t.innerHTML=c(l));case 2:return null!=l&&"boolean"!=typeof l&&T(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 le=Symbol();function ie(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[le];void 0!==n&&(t[n[0]]=n[1])}var re=class{constructor(e,t,n,l){this.y=!0,this.fe=null,this.h=null,this.St=null,this.Nn=null,this.r=e,this.Ke=t,this.j=n,this.A=l}Ho(e,t){let n=t.target,l=this.A,i=[],r=null;for(let t of l.xe){if(t.name!==e)continue;let o=l.Rn[t.a],s=ge(null===this.j?this.Ke:this.j[o[0]],o,1);s.contains(n)&&(s!==r&&i.unshift([]),i[0].push(t),r=s)}for(let e of i){for(let n of e)n.xn(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.j?this.Ke:this.j[this.j.length-1]}Ue(){let e=this.Nn;return(null===e?null:e.Pn(this.Ke))??this.Ke}insertBefore(e,t){let n=this.s;for(let l=this.Ue();;){let i=l.nextSibling;if(e.insertBefore(l,t),l===n)return;l=i}}uo(){null===this.j?this.Ke.remove():ye(this.Ue(),this.s)}Se(e){if(this.y=!1,null!==this.St)for(let e of this.St)e();let t=this.fe;if(null!==t)for(let n=0;n<t.length;n++)e.kn(t[n]);if(null!==this.h)for(let e of this.h)e.Se()}},oe=class extends re{constructor(e,t,n,l){super(e,t,n,l),this.fo=0,this.W=null,this.ae=0===l.qe.length?null:new Array(2*l.qe.length)}po(e,t){let n=this.W??=new Array(this.A.qe.length),l=n[t];if(void 0===l){let i=this.A.qe[t],r=this.ae;l=n[t]=new ee(e,i.i,r[2*t],i.name,i.o,this.r,this,i.x,r[2*t+1])}return l}no(e,t){let n=this.A.qe;for(let l=0;l<n.length;l++)n[l].o.Q(t)&&e.Qt(this.po(e,l))}Se(e){let t=this.r;t.E===this&&(t.E=null),super.Se(e)}};function se(e,t,n,l){let i=a(n,t.n);try{return e.Be(i,t)}catch(n){return e.Yt(n,t.t,l,"for"),null===i?e.ee.get(t):i.h.get(t)}}function ae(e,t,n){n&&e.zo(t);let l=t.$n;null!==l&&(l.fe??=[]).push(t)}var ue=null;function ce(){let e=ue;return ue=null,e}var fe=-1;function he(e,t,n,l,i=null){let r,o=t.Rn,s=t.build,a=t.mo,u=null,c=j.Ae?.(t,null===l?i:l.S,null!==l),f=!c&&t.Tn,h=c?document.createDocumentFragment():(f?t.root:t.on).cloneNode(!0);if(!c)for(let e=0;e<s.length;e++){let t=s[e];a[t]=ge(h,o[t],f?1:0)}f?r=h:(u=c||[...h.childNodes],r=u[0]);let d,m=null;if(null!==l?(d=m=new oe(n,r,u,t),null===l.map?n.E=m:l.map.set(n,m)):d=new re(n,r,u,t),fe>=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||H.has(i))return;let o=globalThis[q]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${$(25,[l])}`)):(H.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,u,null!==l?"row":"branch",fe),t.xe.length>0){let t=e.Bn;if(null===u)r[t]=d;else for(let e of u)1===e.nodeType&&(e[t]=d)}let p=t.Xo,v=e.Ie,g=t.Go?a.slice(0,o.length):a,y=null===m?null:m.ae;if(null!==y){let e=t.qe;for(let t=0;t<e.length;t++)y[2*t]=g[e[t].a],y[2*t+1]=e[t].H}for(let t=0;t<p.length;t++){let l=p[t],i=g[l.a],o=l.F;if(o>=0&&null!==y){let t=m.W?.[o];if(void 0!==t){t.Z=!1,e._e(t);continue}try{let t=Y(l.x,e.read(l.o,n));t!==l.H&&(ne(l.i,i,l.name,t),y[2*o+1]=t),null!==v&&e.io(l.o,n)}catch(t){e.kt(t,m.po(e,o))}continue}switch(l.i){case 6:{let t=new ve(e,l.A,se(e,l.o,n,i),i);(d.h??=[]).push(t),i===r&&(d.Nn=t),t.vt();break}case 7:{let t=me(e,l.Y.map(e=>({A:e.A,o:e.o,x:e.x,S:g[e.a]})),n,d);(d.h??=[]).push(t),i===r&&(d.Nn=t);break}default:try{de(e,l,i,n,d)}catch(t){_(e,t,l,i)}}}return ue=d,h}function de(e,t,n,l,i){let r=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.xn,o=e=>r(e,l);if(n.Ze){let l=e.eo(n.name),i=t[l];t[l]=void 0===i?o:e=>{i(e),o(e)},n.ke&&t.addEventListener(n.name,e=>e.bubbles||o(e))}else t.addEventListener(n.name,o),n.co&&null!==i&&(i.St??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,l,i);case 12:return void xe(e,t,r,i,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.$t.slice(9));null===i&&Ne(1202,n,`command.${r}`),i.commands.has(r)||T(1203,[n.localName,r]);let s=new WeakRef(n),a=o.subscribe((...e)=>{let t=s.deref();if(void 0!==t)return t.isConnected?t[r](...e):void 0;a()});null!==l&&(l.St??=[]).push(a)}(e,t,r,i,n));case 13:return void xe(e,t,r,i,n=>function(e,t,n,l,i){let r=t.name;null===i&&Ne(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&T(1204,[n.localName,r]);let s=t.$t;n.addEventListener(o.event,n=>{t.Et&&n.preventDefault(),t.xt&&n.stopPropagation();try{e.Ko(s,n,l)}catch(e){console.error(e)}})}(e,t,r,l,n))}let o=t.o,s=a(l,o.n);if(14===t.i)return void xe(e,t,r,i,n=>function(e,t,n,l,i,r){null===r&&Ne(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs.keys()]);for(let s of o){if(t.ao?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),a=0===o.n?null:l;Se(e,{...t,V:null,z:null},n,s,o,a,i,r)}}(e,t,r,s,i,n));if(t.ke&&1===t.i)return void xe(e,t,r,i,n=>function(e,t,n,l,i,r){if(null!==r)return void Se(e,t,n,t.name,t.o,l,i,r);let o=new ee(e,1,n,t.name,t.o,l,i,t.x,X(e,t,l));o.I=t.I,!j.Jo?.(o,t.ro)&&(ae(e,o,!0),e._e(o))}(e,t,r,s,i,n));let u=new ee(e,t.i,n,t.name,o,s,i,t.x,X(e,t,s));u.I=t.I,ae(e,u,!0),e._e(u),null!==t.Nt&&n.addEventListener(t.Nt,()=>u.Yo())}function me(e,t,n,l){let i=new pe(e,t,n),r=null;for(let o of t){if(null===o.o)continue;let t=o.o,s=new ee(e,7,o.S,"if",t,a(n,t.n),l,null,void 0,i);ae(e,s,!0),null===l&&i.ie.push(s),r??=s}return e._e(r),i}var pe=class{constructor(e,t,n){this.y=!0,this.O=null,this.b=-1,this.ie=[],this.engine=e,this.Y=t,this.r=n}Pn(e){return null!==this.O&&this.Y[this.b].S===e?this.O.Ue():null}vt(){let e=this.engine,t=-1;for(let n=0;n<this.Y.length;n++){let l=this.Y[n];if(null===l.o||Y(l.x,e.read(l.o,a(this.r,l.o.n)))){t=n;break}}if(t!==this.b&&(fe=Q(),null!==this.O&&(this.O.uo(),this.O.Se(e),this.O=null),this.b=t,t>=0)){let n=this.Y[t],l=he(e,n.A,this.r,null,n.S);this.O=ce();let i=n.S.parentNode;i.insertBefore(l,n.S),ie(i)}}Se(){this.y=!1;for(let e of this.ie)this.engine.kn(e);null!==this.O&&this.O.Se(this.engine)}},ve=class{constructor(e,t,n,l){this.y=!0,this.$e=[],this.engine=e,this.A=t,this.l=n,this.S=l,null===n.E?(n.E=this,this.map=null):((n.L??=[]).push(this),this.map=new Map)}Pn(e){return 0===this.$e.length?null:this.$e[0].Ue()}Rt(e){return null===this.map?e.E:this.map.get(e)??null}ho(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.Se(this.engine)}vt(){let e=this.engine,t=this.l.u,n=this.$e;fe=Q();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){ye(n[0].Ue(),n[i-1].s);for(let e=0;e<i;e++)this.ho(n[e])}return void(this.$e=[])}let s=new Array(l),a=0;for(;a<l&&a<i&&this.Rt(t[a])===n[a];)s[a]=n[a],a++;let u=i-1,c=l-1;for(;u>=a&&c>=a&&this.Rt(t[c])===n[u];)s[c]=n[u],u--,c--;for(let e=a;e<=u;e++){let t=n[e],l=t.r;l.y&&this.Rt(l)===t?t.fo=e:(t.uo(),this.ho(t))}if(a<=c){let n=c-a+1,u=new Int32Array(n),f=!1;if(i>0)for(let e=0;e<n;e++){let n=this.Rt(t[a+e]);null!==n&&n.y?(u[e]=n.fo,f=!0):u[e]=-1}let h=c+1<l?s[c+1].Ue():r;if(f){let l=function(e){let t=e.length,n=new Uint8Array(t),l=new Int32Array(t).fill(-1),i=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let r=0,o=i.length;for(;r<o;){let n=r+o>>1;e[i[n]]<t?r=n+1:o=n}r>0&&(l[n]=i[r-1]),i[r]=n}let r=i.length>0?i[i.length-1]:-1;for(;r>=0;)n[r]=1,r=l[r];return n}(u),i=h;for(let r=n-1;r>=0;r--){let n=t[a+r],u=this.Rt(n);null!==u&&u.y?0===l[r]&&u.insertBefore(o,i):(o.insertBefore(he(e,this.A,n,this),i),u=ce()),s[a+r]=u,i=u.Ue()}}else{let n=document.createDocumentFragment();for(let l=a;l<=c;l++)n.appendChild(he(e,this.A,t[l],this)),s[l]=ce();o.insertBefore(n,h)}}this.$e=s,ie(o)}Se(){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.$e)e.Se(this.engine);this.map?.clear()}};function ge(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 ye(e,t){let n=document.createRange();n.setStartBefore(e),n.setEndAfter(t),n.deleteContents()}var be=new WeakMap,we=e=>e.customElementRegistry??customElements;function xe(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=we(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>xe(e,t,n,l,i,!0));let a=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(be.has(e))return be.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new Map,commands:new Set};for(let e of t.properties??[])n.properties.set(e.name,{event:e.event,getter:"function"==typeof e.getter?e.getter:null,lo:"event"===e.semantics});for(let e of t.inputs??[])n.inputs.set(e.name,{attribute:"string"==typeof e.attribute?e.attribute:null});for(let e of t.commands??[])null!==e&&"object"==typeof e&&"string"==typeof e.name&&n.commands.add(e.name)}return be.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return a();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.St??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{a()}catch(l){_(e,l,t,n)}e.Re()})}function Se(e,t,n,l,i=t.o,r,o,s){let a=s.properties.get(l)??null,u=s.inputs.get(l),c=e.Bt;c&&null===a&&void 0===u&&T(38,[l]);let f=t.V;(null===a?"element"===f||"auto"===f:void 0===u&&("state"===f||"auto"===f))&&T(39,[f,l]),"connect"===t.z&&null===a&&T(40,[l]);let h=c&&null!==a&&void 0===u,d=new ee(e,11,n,l,i,r,o,t.x,void 0);d.I=t.I,d.attribute=u?.attribute??null,ae(e,d,!h),null!==a&&!t.ro&&n.addEventListener(a.event,t=>{let i;null!==a.getter?i=a.getter(t):(i=t.detail,a.lo||j.detail?.(n,l,i)),(!d.En||!Object.is(i,d.value))&&(i=Y(d.I,i),null===d.x&&(d.value=i),e.P(d.o,d.r,i,a.lo,!0))});let m=f??(h?"element":"state");if("state"===m)h||e._e(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(h||e._e(d));let t=n[l];null===d.x&&(d.value=t),e.P(d.o,d.r,t,!1,!0)};"connect"!==t.z||n.isConnected?i():Promise.resolve().then(i)}return d}function Ne(e,t,n){T(e,[t.localName,n])}var ke=()=>f.bindAttributeName;function Ae(){return{a:0,i:1,name:"",o:null,x:null,H:m,xn:null,A:null,Y:null,I:null,Nt:null,ke:!1,V:null,z:null,ro:!1,Et:!1,xt:!1,$t:null,ao:null,F:-1,Ze:!1,co:!1}}var Ee=["state","element","auto","none"],Ie=["call","connect"],$e="$command.";function Te(e,t,n){S.test(t)&&(null===n&&T(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&&T(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&T(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.f[e];l.f[e]!==t&&T(1403,[l.t,l.f[e].t,t.t])}return j.go?.(e,l),l}var je=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),Le=e=>8===e.i||je(e)||1===e.i&&te(e.name);function Pe(e){T(202,[e])}function Ce(e,t,n,l,i){let r=W(t).map(t=>function(e,t,n,l,i){let r=function(e,t){let n=t.find(e=>e.startsWith("on")),l=null,i=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e.Bt||T(31);let r=n.slice(0,t).trim(),o=n.slice(t+1).trim(),s="init"===r;!s&&"sync"!==r&&T(33,[r,n]),null!==(s?l:i)&&T(34,[r]),(s?Ee:Ie).includes(o)||T(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),Et:t.includes("prevent"),xt:t.includes("stop"),event:n?n.slice(2):null,V:l,z:i}}(e,t.tn),o=l.localName.includes("-"),a=t.ve,c=t.Je;if("event"===t.w){if(null!==r.V&&"none"!==r.V&&T(36),"eventToken"===a[0])return{...Ae(),a:i,i:13,name:a.slice(1).join("."),$t:c,ke:o,Et:r.Et,xt:r.xt};let n=c.startsWith($e)?c.slice(9):null,{Et:l,xt:u}=r,f=t.be.slice(2),h=t.tn.includes("direct"),d=!h&&U.has(f);return d&&e.eo(f),{...Ae(),a:i,i:5,name:f,Ze:d,ke:o,co:h,xn(t,i){l&&t.preventDefault(),u&&t.stopPropagation();try{if(null!==n)e.Uo(n,t,i);else{let n=e.qo(c,t,i);s(n)&&n.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...Ae(),a:i,i:14,o:Te(e,c,n),ke:o};if("command"===a[0]&&a.length>1)return c.startsWith($e)||T(1201,[t.be,c]),{...Ae(),a:i,i:12,name:a.slice(1).join("."),$t:c,ke:o};let f=Te(e,c,n),h={...Ae(),a:i,i:1,name:t.be,o:f,x:O(t.Qe),I:O(t.I),ro:r.ro,V:r.V,z:r.z};if("radio"===t.w||"checkbox"===t.w)return("element"===r.V||"auto"===r.V)&&T(37,[t.w,r.V]),h.i="radio"===t.w?9:10,r.ro||(h.Nt=r.event??"input"),h;if(a.length>1){let e=a.slice(1).join("."),t=a[0];if("class"===t||"attr"===t||"style"===t)return h.V=null,h.name=e,"class"===t?(h.i=2,h.H=l.classList.contains(e)):h.i="attr"===t?"srcdoc"===e&&"iframe"===l.localName?1:3:4,h}return"html"===t.be?(h.i=8,h):(h.name="text"===t.be?"textContent":t.be,h.ke=o&&!u(h.name),!o&&!r.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(l,h.name)&&(h.Nt=r.event??("select"===l.localName?"change":"input")),h)}(e,t,n,l,i));for(let e=0;e<r.length;e++)14===r[e].i&&(r[e].ao=r.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return r}var Ve=/\{\{([\s\S]+?)\}\}/g;function We(e){let t=e.data,n=[],l=0;Ve.lastIndex=0;for(let i=Ve.exec(t);null!==i;i=Ve.exec(t)){let r=Ve.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,Qo:i[1].trim()}),l=Ve.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function Me(e,t,n,l){let i=function(e){return{be:"textContent",ve:["textContent"],tn:[],I:[],...I(e),w:"text"}}(t);return{...Ae(),a:l,i:0,o:Te(e,i.Je,n),x:O(i.Qe),H:""}}function Be(e){let t=e.getAttribute(ke());if(null===t)return null;let n=W(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var Re=(e,t)=>0===e?f.commentIfPrefix:null===t.o?f.commentElsePrefix:f.commentElseIfPrefix;function Ye(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:Te(e,l.Je,n),x:"else"===l.w?null:O(l.Qe)}),i=[l(t,Be(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=Be(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var Oe=new WeakSet;function qe(e,t,n,l,i,r,o,s){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&j.An?.(e,i,t),i},u=t=>{for(let c=0;c<t.length;c++){let h=t[c];if(null!==h.parentNode)if(1===h.nodeType){let t=h,s=t.localName;if(l){if("script"===s||"style"===s||Oe.has(t))continue;if(Oe.add(t),s===f.tagNames.state){u([...t.childNodes]);continue}}let c="template"===s?Be(t):null;if(null!==c){if("for"===c.w){let l=Te(e,c.Je,n),r=Ue(e,t,l,!0);i(a(t,f.commentForPrefix),l,r)}else"if"===c.w?r(Ye(e,t,n).map((t,l)=>({A:Ue(e,t.el,n,!1),o:t.o,x:t.x,S:a(t.el,Re(l,t))}))):Pe(c.w);continue}let d=t.getAttribute(ke()),m=null===d?null:Ce(e,d,n,t,0),p="noscript"!==s&&"iframe"!==s&&!m?.some(Le)&&!j.yo?.(t);try{l&&p&&u([...t.childNodes])}finally{null!==m&&o(t,m)}!l&&p&&u([...t.childNodes])}else if(3===h.nodeType&&e.Lt&&h.data.includes("{{")&&!Oe.has(h))for(let{a:e,Qo:t}of We(h))s(e,t);else if(8===h.nodeType){let e=He.exec(h.data),t=e&&h.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");h.replaceWith(t),s(t,e[1])}}}};u(t)}var He=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Qe=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Ue(e,t,n,l){let i=document.importNode(Qe(t),!0),r=[],o=[],s=e=>r.push(e)-1;qe(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...Ae(),a:s(e),i:6,o:t,A:n})},e=>{let t=e.map(e=>({a:s(e.S),A:e.A,o:e.o,x:e.x}));o.push({...Ae(),a:t[0].a,i:7,Y:t})},(e,t)=>{let n=s(e);for(let e of t)je(e)&&T(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(ke())},(t,l)=>{o.push(Me(e,l,n,s(t)))}),ze(i,new Set(r),!0);let a=r.map(e=>function(e,t){let n=[];for(let l=t;l!==e;l=l.parentNode){let e=0;for(let t=l.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(i,e)),u=1===i.childNodes.length&&8!==i.firstChild.nodeType,c=o.some(e=>6===e.i||7===e.i),f=[],h=new Set,d=[],m=[],p=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.Ze&&!e.ke&&!De(r[e.a],i)){d.push(e);continue}m.push(e);let t=e.o;if(null!==t&&t.n===p&&t.f[p]===n&&Je(e)&&(e.F=f.push(e)-1),7===e.i)for(let t of e.Y)h.add(t.a);else h.add(e.a)}let v=[...h].sort((e,t)=>e-t);return{on:i,root:u?i.firstChild:null,Rn:a,build:v,xe:d,Xo:m,Tn:u,Go:c,mo:[],qe:f}}function De(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 Je(e){if(null!==e.V)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.ke&&null===e.Nt;default:return!1}}var Ze=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function ze(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&&ze(l,t,Ze.has(l.localName)),l=e}}var Fe=new WeakMap;function Ke(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Fe.set(t,e),Ge(e,[...n.childNodes]),e.Ve()}function _e(e,t,n){try{let l="template"===t.localName?Be(t):null;null!==l&&!n&&T(204,[l.w]),Ge(e,[t])}catch(e){console.error(e)}e.Ve()}function Ge(e,t){qe(e,t,null,!0,(t,n,l)=>{new ve(e,l,se(e,n,null,t),t).vt()},t=>{me(e,t,null,null)},(t,n)=>{j.An?.(e,t,n);for(let l of n)de(e,l,t,null,null)},(t,n)=>{j.An?.(e,t,n),de(e,Me(e,n,null,0),t,null,null)})}export{W as a,we as b,D as c,J as d,Z as e,z as f,F as g,oe as h,ve as i,je as j,Le as k,Oe as l,Qe as m,Fe as n,Ke as o,_e as p};
@@ -0,0 +1 @@
1
+ import{n as t,p as n}from"./chunk-5PWMZ75N.js";import{a as l,b as e,c as o}from"./chunk-I2V4DGEI.js";import{a as r}from"./chunk-Z3EEGBYA.js";var i=Symbol.for("wcstack.binder"),u=Symbol.for("wcstack.binder.pending"),s=Symbol.for("wcstack.binder.taken");var f=new Map;function a(l,e){if(1!==l.nodeType||!l.isConnected)return;let o=t.get(l.getRootNode());void 0===o||!1===o.element?.isConnected?f.set(l,e):n(o,l,e?.range)}function c(){let t=[...f];f.clear();for(let[n,l]of t)a(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 d(){let t=globalThis;void 0===t[i]&&(t[i]={protocol:"wcs-binder",version:1,bind:a})}var b=class{constructor(){this.name="dirty",this.ot=(t,n)=>{if(0===t.n){let n=t.J;return n!==l&&n!==e&&(t.J=e,!0)}let o=null===n?null:n.ut;if(null===o)return!1;let r=o[t.F];return r!==l&&r!==e&&(o[t.F]=e,!0)}}Vo(t,n,l){null!==n.getter&&this.ot(n,l),t.bt(n,l),t.vn(n,l,this.ot)}Lo(t,n){let l=n.l.o.At;if(null!==l)for(let e of l)e.n===n.l.n?t.tt(e,n,this.ot):t.Jt(n,e,n=>t.tt(e,n,this.ot))}me(t,n,l){this.ot(n,l),r.ye?.(t,n,l),t.bt(n,l),t.vn(n,l,this.ot)}Do(t,n,r){let i=0===n.n;if(!i&&null===r)return;let u=i?null:r.ut??=new Array(t.Oe).fill(l),s=null===u?n.J:u[n.F];if(s!==l&&s!==e&&s!==o&&(null===u||n.F in u))return s;s=o;try{return s=t.Bo(n,null===u?null:r)}finally{null===u?n.J=s:u[n.F]=s}}Ut(t){t.ut=null}mt(t){for(let n of t.D.all())null!==n.getter&&(0===n.n?n.J===e&&(n.J=o):t.Zt(n.f[n.n],t=>{let l=t.ut;null!==l&&l[n.F]===e&&(l[n.F]=o)}))}};export{a,c as b,d as c,b as d};
@@ -0,0 +1 @@
1
+ import{b as t,c as e,d as s}from"./chunk-FED2DM4X.js";import{n as i,o as n}from"./chunk-5PWMZ75N.js";import{f as o}from"./chunk-WPSUT5QQ.js";import{a,b as r}from"./chunk-YZUTVCIH.js";import{b as l,c}from"./chunk-NPPWJBGJ.js";import{a as h,h as u,i as d}from"./chunk-Z3EEGBYA.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 b(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.W||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?b(t):Promise.reject(i.errors[0]):void 0)}var g=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends g{constructor(){super(),this.engine=null,this.Fn=!1,this.He=!1,this.H=null,this.ze=null,this.loaded=!1,this.ln=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.sn=t,this.wo=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.rn=t})}static{this.getBindingsReady=b}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Fn){if(null!==this.ze)return void this.ze.Ye();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.bo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Fn=!0;let e=this.getRootNode(),s=h.rt?.(this,e);if(s)return this.ze=s,!s.vo&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.ft?this.ko():s.ft()).then(t=>(this.loaded=!0,s.start(t,()=>this.So()))).then(()=>{this.rn(),this.sn()},t=>this.kt(t,s.vo));this.start(e),p(this)}disconnectedCallback(){if(null!==this.ze)return void this.ze.On();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.bo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.He&&c(14),this.loaded)this.ze.reset(t);else if(null===this.engine)if(null!==this.ln){let e=this.ln;this.ln=null,e(t)}else this.H=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.Ce++;try{e(s.proxy)}finally{"readonly"===t&&s.Ce--}}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 ko(){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.H?Promise.resolve(this.H):new Promise(t=>{this.ln=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.ko(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.H=r,this.Fn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.W||m.ze)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.bn(),this.So(),await f.we("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.sn()}catch(t){this.He=!this.W,this.kt(t)}}So(){this.W=!0,this.rn()}kt(t,e){this.Ve(this.W?50:49,t),this.rn(),e?this.sn():this.wo(t)}Ve(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)}bo(t,e,s){(async()=>this.engine.we(t))().then(s,t=>this.Ve(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.$o?.(t)}(s)}var C=t=>b(t);export{b as a,g as b,k as c,v as d,C as e};
@@ -0,0 +1 @@
1
+ var t=class{constructor(t,l,e){this.h=[],this.getter=null,this.oe=null,this.de=!1,this.G=[],this.Ee=[],this.ct=null,this.F=-1,this.J=s,this.Fe=null,this.Tt=null,this.At=null,this.U=null,this.Ft=new Set,this.t=t,this.d=e,this.s=l;let i=null===e?[null]:e.f.slice(),h="*"===l;h&&i.push(e),this.n=i.length-1,this.K=h?[]:null===e?[l]:[...e.K,l],this.f=i}jn(t){this.Ft.has(t)||(this.Ft.add(t),this.G.push(t),t.Ee.push(this))}Po(){this.getter=null,this.oe=null,this.F=-1,this.J=s,this.G.length=0,this.Ft.clear(),this.Ee.length=0,this.ct=null,this.Fe=null,this.Tt=null,this.At=null,this.U=null}Q(t){let s=this;for(;null!==s;){if(s===t)return!0;s=s.d}return!1}},s=Symbol("unset"),l=Symbol("dirty"),e=Symbol("failed"),i=class{constructor(t=null){this.Ot=new Map,this.Ln=t}Ct(t){return this.Ot.get(t)}get(s){let l=this.Ot.get(s);if(void 0!==l)return l;let e=s.lastIndexOf("."),i=e<0?null:this.get(s.slice(0,e));return l=new t(s,s.slice(e+1),i),this.Ln?.(l),this.Ot.set(s,l),i&&i.h.push(l),l}all(){return this.Ot.values()}},h=new Map;function n(t){let s=h.get(t);if(void 0!==s)return s;let l=!0,e=t.split("."),i=[];for(let t=0;t<e.length;t++){let s=e[t],h=s.charCodeAt(0);t>0&&h>=48&&h<=57?(l=!1,i.push(Number(s)),e[t]="*"):"*"===s&&i.push(-1)}if(!l)return{o:e.join("."),indexes:i};let n={o:t,indexes:null};return h.set(t,n),n}export{s as a,l as b,e as c,i as d,n as e};
@@ -1 +1 @@
1
- import{a as n,j as e}from"./chunk-YOPPVWPQ.js";var t=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],a=n=>{let e=t[n/100|0];return e?`[wcs/${e}] `:""};function i(e,t=[]){return n.Fo?.(e,t)??`${a(e)}#${e}${t.map(n=>` ${"string"==typeof n?JSON.stringify(n):String(n)}`).join("")}`}function r(n,t,a,r){e(i(n,t),a,r)}export{a,i as b,r as c};
1
+ import{a as n,j as e}from"./chunk-Z3EEGBYA.js";var t=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],a=n=>{let e=t[n/100|0];return e?`[wcs/${e}] `:""};function i(e,t=[]){return n.Fo?.(e,t)??`${a(e)}#${e}${t.map(n=>` ${"string"==typeof n?JSON.stringify(n):String(n)}`).join("")}`}function r(n,t,a,r){e(i(n,t),a,r)}export{a,i as b,r as c};
@@ -0,0 +1 @@
1
+ import{b as t,d as e,e as i}from"./chunk-I2V4DGEI.js";import{h as s,m as l}from"./chunk-YZ4LWPXN.js";import{b as n,c as r}from"./chunk-NPPWJBGJ.js";import{a as h,i as o}from"./chunk-Z3EEGBYA.js";var u=Symbol.for("wcstack.trustedTypes.policy");function f(){let t=globalThis[u];return null!==t&&"object"==typeof t?t:null}function a(t){globalThis[u]=t}function c(t){return"innerHTML"===t||"outerHTML"===t||"srcdoc"===t}function d(t){if(globalThis.trustedTypes?.isHTML(t))return t;let e=null==t?"":String(t),i=f(),s=i?.createHTML;return"function"==typeof s?s.call(i,e):e}var p=class{constructor(t,e,i){this.ut=null,this.E=null,this.fe=null,this.U=null,this.h=null,this.y=!0,this.l=t,this.b=e,this.T=i}},g=class{constructor(t,e){this.C=null,this.u=[],this.E=null,this.L=null,this.Z=!1,this.It=!1,this.dt=!1,this.o=t,this.re=e,this.n=t.n+1}},y=[],v=class{constructor(t){this.pt=new Set,this.name=t}get size(){return this.pt.size}subscribe(t){return this.pt.add(t),()=>{this.pt.delete(t)}}unsubscribe(t){return this.pt.delete(t)}emit(...t){let e=[];for(let i of this.pt)try{e.push(i(...t))}catch(t){e.push(void 0),console.error(`[@wcstack/state] ${n(17,[this.name])}`,t)}return e}};function b(t,e,i){if(void 0===t)return[];Array.isArray(t)||r(18,[e]);let s=new Set;for(let l of t)("string"!=typeof l||""===l)&&r(19,[e]),l===i&&r(20,[e,l,i]),s.has(l)&&r(21,[e,l]),s.add(l);return t}var m=Symbol.for("wcstack.transition-runner");function w(t){let e=globalThis[m];return null==e||"wcs-transition-runner"!==e.protocol||"number"!=typeof e.version||e.version<1||"function"!=typeof e.run||"function"!=typeof e.accepts||!e.accepts(t)?null:e}function $(t,e,i){let s=w(t);if(null!==s)return s.run(e,{source:t,types:i});e()}var k=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],M=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],j=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function T(t){return t.includes("**")&&l(t),t}var A=0,C=32,O=100;function q(t,e,i){let s=t.get(e);return void 0===s&&t.set(e,s=i()),s}var D=()=>new Set,I=()=>[];function x(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function L(t,e){return t===e||t!=t&&e!=e}function S(t,e,i){let s=t.U?.get(e);void 0!==s&&s.delete(i)&&0===s.size&&t.U.delete(e)}function Z(t,e){for(let i=0;i<e.length;i++){if(null==t)return;t=t[e[i]]}return t}function _(t,e){for(;null!==t&&t.l.n>e;)t=t.l.re;return null!==t&&t.l.n===e?t:null}function P(t,e,i){let s=_(t,i);return null!==s&&s.l.o===e.f[i]?s:null}var R=class{constructor(t,i){this.Oe=0,this.c=null,this.Ce=0,this.mt=new Set,this.Ze=new Map,this.Bn=Symbol("wcs.block"),this.element=null,this.ht=[],this.Ie=null,this.Mn=[],this.Mt=0,this.q=null,this.ee=new Map,this.ie=new Map,this.je=[],this.Le=[],this.De=[],this.yt=!1,this.dn=!1,this.Wt=new WeakMap,this.M=0,this._t=0,this.fn=!1,this.Vt=!1,this.Ht=!1,this.Ne=0,this.Wn=()=>{this.M=0,this.fn=!1},this._n=()=>{this.Ne--},this.rp=null,this.rr=null,this.Oo=()=>this.Kt(),this.Co=(t,e)=>t(this.proxy,...e),this.Vn=[],this.Io={$untracked:t=>{let e=this.q;if(null===e)return t();e.pe++;try{return t()}finally{e.pe--}},$eqIndex:(t,e=1)=>{let i=_(this.c,e);null===i&&r(7,[t]);let s=this.o(t);if(null!==s.getter||s.de)return this.watchIndex(e),i.b===this.read(s,null);let l=this.q;if(null!==l){let t=l.getter,i=s.Fe??(s.Fe=[]);if(!i.some(i=>i.getter===t&&i.Hn===e)){i.push({getter:t,Hn:e});let l=t.f[e];(l.Tt??(l.Tt=[])).push({source:s,getter:t})}}return i.b===this.v(s,null)},$eq:(t,e)=>this.eq(t,e),$eqPath:(t,e)=>{let i=this.o(e);return this.eq(t,this.v(i,_(this.c,i.n)))},$dependOn:t=>{this.resolve(T(t),this.c),null!==this.q&&0===this.q.pe&&this.Kn(this.rp,this.rr,this.q)},$getAll:(t,e)=>this.getAll(t,e),$setAll:(t,e,i,s)=>this.pn(t,e,i,s),$resolve:(...t)=>{let e=T(t[0]),i=t[1]??[],s=this.o(e);this.mn("$resolve",e,s,i,!0);let l=this.Un(s,i,null);if(t.length<3)return this.read(s,l);this.P(s,l,t[2])},$postUpdate:t=>{this.resolve(T(t),this.c);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.T=i.l.C[i.b],this.R.Ut(i)),this.hn(e,i),null!==i&&this.qn(i,e,void 0,i.T,!1),0===e.n&&this.zn(e,void 0,void 0,!0),this.qt(e,i,void 0,void 0,!1)}},this.R=i,this.D=new e(t=>this.et(t)),this.Yn(t);let s=this,l={getOwnPropertyDescriptor(t,e){let i=Reflect.getOwnPropertyDescriptor(s.target,e);return i&&(i.configurable=!0),i},get(t,e,i){let l=s.target;if("symbol"==typeof e)return Reflect.get(l,e);if(36===e.charCodeAt(0))return s.zt(e);if(e.indexOf(".")<0){let t=s.D.Ct(e);if(void 0===t||null===t.getter){let t=l[e];if("function"==typeof t)return i===s.proxy&&s.W?.(t)||t}if(void 0!==t&&0===t.n)return s.read(t,null)}return s.resolve(e,s.c),s.read(s.rp,s.rr)},set:(t,e,i)=>"symbol"==typeof e?Reflect.set(s.target,e,i):(s.resolve(T(e),s.c),s.P(s.rp,s.rr,i),!0)};for(let t of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])l[t]=(e,...i)=>Reflect[t](s.target,...i);this.proxy=new Proxy({},l)}o(t){return this.D.get(t)}Xn(t){let e=new Set;for(let i=t;null!==i&&i!==Object.prototype;i=Object.getPrototypeOf(i))for(let t of Object.getOwnPropertyNames(i)){if(e.has(t))continue;e.add(t);let s=Object.getOwnPropertyDescriptor(i,t);if(void 0===s.get&&void 0===s.set)continue;let l=this.o(t);l.getter=s.get??null,l.oe=s.set??null,null!==l.getter&&l.n>0&&(l.F=this.Oe++)}for(let t of this.D.all())this.et(t)}et(t){t.t.includes("**")&&l(t.t),("__proto__"===t.s||"prototype"===t.s)&&r(120,[t.t]);let e=t.d;t.de=null!==e&&"*"!==t.s&&e.n===t.n&&(null!==e.getter||e.de),null===t.getter&&this.jo(t)}jo(t){let e=t.t,i=t.s;if(s.test(i))t.getter=function(){return this[i]};else{let s=e.split("."),l=s.findIndex((t,e)=>e>0&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57);if(l<0||s.indexOf("*",l)>=0)return;t.getter=()=>(this.resolve(e,this.c),this.rp!==t?this.read(this.rp,this.rr):this.read(t.d,this.c)?.[i]),t.oe=s=>{if(this.resolve(e,this.c),this.rp!==t)return this.P(this.rp,this.rr,s);let l=this.read(t.d,this.c);null==l&&r(4,[e,l]),l[i]=s}}t.n>0&&(t.F=this.Oe++)}Be(t,e){let i=null===t?this.ee:t.h??=new Map,s=i.get(e);return void 0===s&&i.set(e,s=new g(e,t)),this.z(s),s}Gn(t){try{this.z(t)}catch(e){this.Yt(e,t.o.t,t.E?.S??null,"for")}}z(t){let e=this.v(t.o,t.re);if(e===t.C)return;this.Jn(t);let i=function(t,e,i){let s=Array.isArray(e)?e:y;if(s===t.C)return null;let l=t.u,n=s.length,r=l.length,h=new Array(n),o=0;for(;o<n&&o<r&&l[o].T===s[o];)h[o]=l[o],o++;let u=r-1,f=n-1;for(;u>=o&&f>=o&&l[u].T===s[f];)h[f]=l[u],u--,f--;if(o>u)for(let e=o;e<=f;e++)h[e]=new p(t,e,s[e]);else if(o>f)for(let t=o;t<=u;t++)i.jt(l[t]);else{let e=new Map;for(let t=o;t<=u;t++){let i=l[t],s=e.get(i.T);void 0===s?e.set(i.T,i):Array.isArray(s)?s.push(i):e.set(i.T,[s,i])}for(let i=o;i<=f;i++){let l,n=s[i],r=e.get(n);void 0!==r&&(Array.isArray(r)?(l=r.shift(),0===r.length&&e.delete(n)):(l=r,e.delete(n))),h[i]=l??new p(t,i,n)}for(let t of e.values())if(Array.isArray(t))for(let e of t)i.jt(e);else i.jt(t)}for(let t=o;t<n;t++){let e=h[t];e.b!==t&&(e.b=t,i.To(e))}return t.u=h,t.C=s,l}(t,e,this);if(null===i)return;if(t.C===e){let i=q(this.Wt,e,I);if(i.push(t),i.length>1)for(let t of i)t.dt=!0}h.Xt?.(this,t,i),(null!==t.E||null!==t.L)&&!t.Z&&(t.Z=!0,this.Le.push(t),this.Re());let s=t.o.Tt;if(null!==s)for(let{source:e,getter:l}of s){let s=this.v(e,null),n=i[s],r=t.u[s];n!==r&&(void 0!==n&&n.y&&this.gn(l,n),void 0!==r&&this.gn(l,r))}}To(t){this.R.Lo(this,t)}jt(t){t.y=!1;let e=t.U;if(null!==e){for(let t of e)S(t.source,t.key,t.sub);t.U=null}if(null!==t.h)for(let e of t.h.values()){this.Jn(e);for(let t of e.u)this.jt(t)}}Jn(t){let e=this.Wt.get(t.C);void 0!==e&&(e.splice(e.indexOf(t)>>>0,1),t.dt=!1,1===e.length&&(e[0].dt=!1))}resolve(t,e){let s=i(t),l=this.rp=this.o(s.o),n=s.indexes;this.rr=0===l.n?null:null===n?P(e,l,l.n):this.Un(l,n,e,t)}Un(t,e,i,s){let l=null;for(let n,r=1,h=0;r<=t.n;r++){let o=t.f[r],u=this.Be(l,o),f=e[h++];if(f<0)f=P(i,t,r)?.b??-1;else if(s&&u.C===y&&Object(n=this.v(o,l))===n){let e=t.t.split("."),i=o.t.split(".").length;e[i]=s.split(".")[i],t=this.o(e.join(".")),r--;continue}if(l=u.u[f]??null,null===l)break}return this.rp=t,l}wt(t,e){return 0===t.n?Z(this.target,t.K):null===e?void 0:Z(e.T,t.K)}read(t,e){let i=this.q;if(null!==i&&0===i.pe&&this.Kn(t,e,i),null!==t.getter)return this.R.Do(this,t,e);if(t.de){let i=this.read(t.d,e);return i?.[t.s]}return null===t.d&&!(t.s in this.target)&&!this.mt.has(t.s)&&"then"!==t.s&&"toJSON"!==t.s&&r(301,[t.t],t.s,Object.keys(this.target)),this.wt(t,e)}v(t,e){let i=this.q;if(null===i)return this.read(t,e);i.pe++;try{return this.read(t,e)}finally{i.pe--}}Kn(t,e,i){let s=i.getter;t.jn(s),t.n>0&&s.n>0&&_(e,Math.min(t.n,s.n))!==_(i.r,Math.min(t.n,s.n))&&(s.ct??(s.ct=new Set)).add(t)}Bo(t,e){for(let i=0;i<this.Mt;i++){let s=this.Mn[i];s.getter===t&&s.r===e&&r(701,[t.t])}this.Mt>=128&&r(801,[t.t]);let i=this.Mt++;this.Ce++;let s=this.Mn[i]??={getter:t,r:e,pe:0,Me:0};s.getter=t,s.r=e,s.pe=0,s.Me=++A;let l=this.q;this.q=s;let n=this.c;this.c=e;try{return t.getter.call(this.proxy)}finally{this.Ce--,this.Mt--,this.q=l,this.c=n,s.r=null}}watchIndex(t){let e=this.q;if(null!==e&&0===e.pe){let i=e.getter,s=i.f[t];if(s){let t=s.At??(s.At=[]);t.includes(i)||t.push(i)}}}zt(t){let e=t.charCodeAt(1);if(e>=48&&e<=57){let i=2===t.length?e-48:s.test(t)?+t.slice(1):0;return(i<1||i>128)&&r(1001,[t]),this.watchIndex(i),_(this.c,i)?.b}let i=this.Io[t];if(void 0!==i)return i;switch(t){case"$trackDependency":return r(1701,[t,"$dependOn"]);case"$untrackDependency":return r(1701,[t,"$untracked"]);case"$stateElement":return this.element;case"$command":return this.commands}return h.zt?.(this,t)}eq(t,e){this.resolve(t,this.c);let i=this.rp,s=this.rr;if(null!==i.getter||i.de||i.n>0)return L(this.read(i,s),e);let l=this.q;return null!==l&&0===l.pe&&this.Mo(i,e,l),L(this.v(i,null),e)}Mo(t,e,i){let s=i.getter,l=i.r,n=null===l?this.Vn:l.U??(l.U=[]);for(let l=0;l<n.length;l++){let r=n[l];if(r.sub.getter===s&&r.source===t){if(L(r.key,e))return void(r.Me=i.Me);r.Me!==i.Me&&(S(t,r.key,r.sub),n.splice(l--,1))}}let r={getter:s,r:l};q(t.U??=new Map,e,D).add(r),n.push({source:t,key:e,sub:r,Me:i.Me})}zn(t,e,i,s){this.Gt(t,l=>{let n=l.U;if(null===n&&null===l.Fe)return;let r=l===t?[]:l.t.slice(t.t.length+1).split("."),h=Z(e,r),o=Z(i,r);if(null!==l.Fe&&this.Wo(l,h,o,s),null!==n)for(let t of s?n.keys():[h,o]){let e=n.get(t);if(void 0!==e)for(let i of e)null===i.r||i.r.y?this.R.me(this,i.getter,i.r):S(l,t,i)}})}P(t,e,i,s=!1,l=!1){if(this.Ce>0&&r(8),l||this.Ne>0?this.Vt=!0:this.Ht=!0,h.Pe?.(this,t,e,i,l))return;if(null!==t.oe){try{this.yn(t.oe,e,[i])}finally{this.qt(t,e,void 0,void 0,!1)}return}null!==t.getter&&r(2,[t.t]),t.n>0&&null===e&&r(3,[t.t]);let n=t.de?this.v(t,e):this.wt(t,e);if(s||!this.Dt||!Object.is(n,i)||Object(i)===i){if("*"===t.s){let t=e;t.l.C[t.b]=i,t.T=i,this.R.Ut(t)}else{let s=1===t.K.length?0===t.n?this.target:e.T:this.v(t.d,e);null==s&&r(4,[t.t,s]),s[t.s]=i}this.wn(t,e),null!==e&&this.qn(e,t,n,i),0===t.n&&this.zn(t,n,i),this.qt(t,e,n,i,!0)}}Qn(t){return(this.Wt.get(t.C)??[]).filter(e=>e.C===t.C&&(null===e.re||e.re.y))}qn(e,i,s,l,n=!0){let r=e.l;if(!r.dt&&null===r.o.getter&&!r.o.G.length)return;let h=e.T,o=i.t.slice(r.o.t.length+2),u=(t,i)=>{if(void 0===i||i===e)return;let r=this.o(`${t.o.t}.*${o}`);""===o&&(i.T=l,this.R.Ut(i)),n?this.wn(r,i):this.hn(r,i),this.qt(r,i,s,l,n)};for(let t of this.Qn(r))u(t,t.u[e.b]);if(""===o)return;let f=new Set([r.C]),a=t=>Array.isArray(t)&&t.includes(h),c=(e,i)=>{if(!f.has(e)&&f.add(e))for(let t of this.Wt.get(e)??[])for(let e of t.u)e.T===h&&u(t,e);for(let s of i){let i=s.J,l=i===t;l&&(i=this.ee.get(s)?.C),(l||a(i))&&!f.has(s.G)&&f.add(s.G)&&(!l&&i!==e&&this.R.me(this,s,null),c(i,s.G))}},d=t=>{for(let e of t.Ee)if(!f.has(e)&&f.add(e))if(null!==e.getter)d(e);else if(!e.de){let t=this.wt(e,null);a(t)&&c(t,e.G)}};null!==r.o.getter?d(r.o):c(r.C,r.o.G)}hn(t,e){this._o(t,e,t=>{this.z(t);for(let e of t.dt?this.Qn(t):[t]){let t=this.o(`${e.o.t}.*`);for(let i of e.u)this.bt(t,i),this.hn(t,i)}})}wn(t,e){let i=null===e?this.ee:e.h;if(null!==i)for(let e of i.values())e.o.Q(t)&&this.z(e)}_o(t,e,i){let s=null===e?this.ee:e.h;if(null!==s)for(let e of s.values())e.o.Q(t)&&i(e)}Wo(t,e,i,s){for(let{getter:l,Hn:n}of t.Fe)this.Zn(l.f[n],t=>{for(let n of s?t.u.keys():[e,i]){let e="number"==typeof n?t.u[n]:void 0;void 0!==e&&this.gn(l,e)}})}gn(t,e){e.l.n===t.n?this.R.me(this,t,e):this.Jt(e,t,e=>this.R.me(this,t,e))}qt(t,e,i,s,l){h.he?.(this,t,e,i,s,l),this.We(t,e)}We(t,e){this.R.Vo(this,t,e),this.Re()}eo(t){let e=this.Ze.get(t);if(void 0!==e)return e;let i=Symbol(`wcs.on${t}`);this.Ze.set(t,i);let s=this.root,l=this.Bn;return s.addEventListener(t,e=>{for(let n=e.target;null!==n&&n!==s;n=n.parentNode){let s=n[i];if(void 0!==s&&(s(e),e.cancelBubble))return;let r=n[l];if(void 0!==r&&r.y&&r.Ho(t,e))return}}),i}reset(t){let e=this.target,i=this.mt;for(let t of this.D.all())null===t.d&&null!==t.getter&&i.add(t.s);this.Yn(t);for(let t in e)"$"!==t[0]&&i.add(t);for(let e of i)e in t&&i.delete(e);for(let t of this.ie.values())for(let e of t)this.Qt(e);for(let t of this.ee.values())this.to(t);this.Ie=null;try{this.Kt()}finally{this.bn()}h.element?.(this,"reset")}Yn(t){for(let[e,i]of M)void 0!==t[e]&&o(i,e);void 0!==t.$scan&&r(1);for(let[e,i]of k)void 0!==t[e]&&r(1601,[e,i]);let e=t.$features;if(void 0!==e){Array.isArray(e)||r(46);for(let t of e)o(t,"$features")}let i=void 0===t.$behavior?{}:t.$behavior;("object"!=typeof i||!i||Array.isArray(i))&&r(44,["state","$behavior"]);for(let t in i)(!j.includes(t)||"boolean"!=typeof i[t])&&r(44,["$behavior",t]);let[s,l,n]=j.map(t=>i[t]??!0);void 0!==this.target&&(s!==this.Lt||l!==this.Dt||n!==this.Bt)&&r(45);let u=function(t,e){let i={};for(let s of b(t.$commandTokens,"$commandTokens","$command"))i[s]=e?.[s]??new v(s);return Object.freeze(i)}(t,this.commands),f=function(t,e){let i=new Map;for(let e of b(t.$eventTokens,"$eventTokens"))i.set(e,new v(e));let s=t.$on;if(void 0===s)return i;(null===s||"object"!=typeof s)&&r(22);for(let[t,l]of Object.entries(s)){let s=i.get(t);void 0===s&&r(23,[t]),"function"!=typeof l&&r(24,[t]),s.subscribe((...t)=>e(l,t))}return i}(t,this.Co);this.Lt=s,this.Dt=l,this.Bt=n,h.se?.(this,t),this.target=t,this.Oe=0;for(let t of this.D.all())t.Po();this.Vn.length=0,this.Xn(t),this.commands=u,this.xe=f}to(t){this.Gn(t);let e=this.o(`${t.o.t}.*`);for(let i of t.u)if(i.ut=null,i.U=null,this.bt(e,i),null!==i.h)for(let t of i.h.values())this.to(t)}_(t){let e=[];for(let i=t;null!==i;i=i.l.re)e.unshift(i.b);return e}Ko(t,e,i){let s=this.xe.get(t);void 0===s&&r(1301,[t],t,this.xe.keys()),s.emit(e,...this._(i))}command(t){let e=this.commands[t];return void 0===e&&r(1302,[t],t,Object.keys(this.commands)),e}Uo(t,e,i){this.command(t).emit(e,...this._(i))}qo(t,e,i){let s=t.includes(".")?this.v(this.o(t),null):this.target[t];return"function"!=typeof s&&r(5,[t]),this.yn(s,i,[e,...this._(i)])}yn(t,e,i){let s=this.c;this.c=e;try{return t.apply(this.proxy,i)}finally{this.c=s}}bt(t,e){if(null!==t.getter){let i=null===e?this.ee:e.h;if(null!==i)for(let e of i.values())!e.It&&e.o.Q(t)&&(e.It=!0,this.De.push(e))}if(null===e)return void this.Gt(t,t=>{let e=this.ie.get(t);if(void 0!==e)for(let t of e)this.Qt(t)});let i=e.fe;if(null!==i)for(let e=0;e<i.length;e++)i[e].o.Q(t)&&this.Qt(i[e]);let s=e.E;null!==s&&null!==s.ae&&s.no(this,t);let l=e.l.L;if(null!==l)for(let i of l){let s=i.map.get(e);void 0!==s&&null!==s.ae&&s.no(this,t)}}vn(t,e,i){this.Gt(t,t=>{let s=t.G;for(let l=0;l<s.length;l++){let n=s[l];if(0===n.n)this.tt(n,null,i);else if(null===e||0===t.n||n.f[1]!==t.f[1]||null!==n.ct&&n.ct.has(t))this.Zt(n.f[n.n],t=>this.tt(n,t,i));else if(n.n<=t.n){let t=_(e,n.n);null!==t&&this.tt(n,t,i)}else this.Jt(e,n,t=>this.tt(n,t,i))}})}tt(t,e,i){i(t,e)&&(h.ye?.(this,t,e),this.bt(t,e),this.vn(t,e,i))}Gt(t,e){e(t);let i=t.h;for(let t=0;t<i.length;t++)this.Gt(i[t],e)}Zt(t,e){this.Zn(t,t=>{for(let i of t.u)e(i)})}Zn(t,e){if(0===t.n){let i=this.ee.get(t);return void(void 0!==i&&e(i))}this.Zt(t.f[t.n],i=>{let s=i.h?.get(t);void 0!==s&&e(s)})}Jt(t,e,i){if(t.l.n===e.n)return i(t);let s=t.h?.get(e.f[t.l.n+1]);if(void 0!==s)for(let t of s.u)this.Jt(t,e,i)}zo(t){let e=t.r;null===e?q(this.ie,t.o,D).add(t):(e.fe??(e.fe=[])).push(t)}kn(t){let e=t.r;if(null===e)return void this.ie.get(t.o)?.delete(t);let i=e.fe;e.y&&null!==i&&i.splice(i.indexOf(t)>>>0,1)}Qt(t){t.Z||(t.Z=!0,this.je.push(t),this.Re())}Re(){this.yt||(this.yt=!0,queueMicrotask(this.Oo))}Sn(){for(let t of this.je)t.Z=!1;for(let t of this.Le)t.Z=!1;for(let t of this.De)t.It=!1;this.je=[],this.Le=[],this.De=[],this.R.mt(this)}oo(t,e){let i=[...new Set([...this.je,...this.Le,...this.De].map(t=>t.o.t))];console.error(`[@wcstack/state] ${n(t)}`,i),h.nt?.(this,{type:"state:render-chain-limit",maxDepth:e,paths:i}),this.Sn()}Kt(){this.yt=!1;let t=this._t;this._t=0;let e=0;if(!this.Vt||this.Ht?this.Wn():t>0?e=t:1===(e=++this.M)&&setTimeout(this.Wn,0),this.Vt=this.Ht=!1,e>100)101===e?this.oo(41,100):this.Sn();else{this.dn=!0;try{for(let t=0;this.je.length>0||this.Le.length>0||this.De.length>0;t++){if(t>=32){this.fn?this.Sn():this.oo(11,32),this.fn=!0;break}let i=this.De;if(i.length>0){this.De=[];for(let t of i)t.It=!1,this.Gn(t)}let s=this.Le,l=this.je;this.Le=[],this.je=[];let n=$("state",()=>{for(let t of s){t.Z=!1;for(let e of[t.E,...t.L??[]])if(null!==e&&e.y)try{e.vt()}catch(i){this.Yt(i,t.o.t,e.S,"for")}}for(let t=0;t<l.length;t++){let e=l[t];e.Z&&(e.Z=!1,(null===e.$n||e.$n.y)&&this._e(e))}this.dn||(this.Ve(),this.yt&&(this._t=e+1))});void 0!==n&&n.then(void 0,t=>console.error(t))}}finally{this.dn=!1}this.Vt=this.Ht=!1,this.Ve(),h.Te?.(this),t>0&&this.yt&&(this._t=e+1)}}kt(t,e){this.ht.push([t,e])}Yt(t,e,i,s){this.kt(t,{o:{t:e},a:i,en:()=>s})}_e(t){try{t.apply()}catch(e){return void this.ht.push([e,t])}null!==this.Ie&&this.io(t.o,t.r)}io(t,e){let i=q(this.Ie,t.t,I);null!==e&&i.push(this._(e))}bn(){this.Ie="function"==typeof this.target.$renderedCallback?new Map:null}Ve(){let t=this.Ie;if(null!==t&&t.size>0){this.Ie=new Map;let e,i=[...t.keys()],s={};for(let[e,i]of t)i.length>0&&(s[e]=i);this.Ne++;try{e=this.we("$renderedCallback",[i,s])}catch(t){console.error(t)}x(e)?e.then(this._n,t=>{this._n(),console.error(t)}):this.Ne--}if(0===this.ht.length)return;let e=this.ht;this.ht=[];let i=this.target.$errorCallback;for(let[t,s]of e){h.He?.(this,t,s);let e=s.o.t,l=s.en();if("function"==typeof i)try{let i=this.we("$errorCallback",[t,{path:e,bindingType:l,node:s.a}]);x(i)&&i.then(void 0,t=>console.error(t))}catch(t){console.error(t)}else console.error(`[@wcstack/state] ${n(12,[l,e])}`,t)}}we(t,e=[]){let i=this.target[t];return"function"==typeof i?this.yn(i,null,e):void 0}so(t,e,i){if(0===t.n)return void i(null,[]);let s=[],l=(n,r)=>{let h=t.f[n];this.read(h,r);let o=this.Be(r,h),u=e=>{s.push(e.b),n===t.n?i(e,s):l(n+1,e),s.pop()};for(let t of n-1<e.length?[o.u[e[n-1]]]:o.u)void 0!==t&&u(t)};l(1,null)}getAll(t,e){let i=this.o(t);void 0!==e&&this.mn("$getAll",t,i,e,!1);let s=e;if(void 0===s){s=[];let e=this.c;if(null!==e&&i.n>0){for(let t=1;t<=i.n;t++){let l=P(e,i,t);if(null===l)break;s.push(l.b)}0===s.length&&r(6,[t])}}let l=[];return this.so(i,s,t=>l.push(this.read(i,t))),l}pn(t,e,i,s){Array.isArray(e)||r(9,[t]),this.Ce>0&&r(8);let l=this.o(t);this.mn("$setAll",t,l,e,!1);let n=[];this.so(l,e,(t,e)=>n.push([t,e.slice()]));let h=!0===s?.spread;h&&(!Array.isArray(i)||i.length!==n.length)&&r(10,[t,n.length]);let o=0;for(let t=0;t<n.length;t++){let[e,s]=n[t],r="function"==typeof i?i(this.v(l,e),...s):h?i[t]:i;void 0!==r&&(this.P(l,e,r),o++)}return o}mn(t,e,i,s,l){let n=s.length;(n>i.n||l&&n<i.n)&&r(l?901:902,[t,e,i.n,n])}};export{w as a,C as b,O as c,x as d,_ as e,R as f,u as g,f as h,a as i,c as j,d as k};
@@ -0,0 +1 @@
1
+ var a="4.0.0-rc.3";export{a};
@@ -1 +1 @@
1
- import{c as t}from"./chunk-WWJNAZVP.js";var e="else",l="eventToken",n="state",s="command",r="class",i="attr",u="style",a=/^\$[1-9]\d{0,2}$/,c=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function o(e){let l=[],n=[],s="",r=null,i=!1,u=-1,a=-1,o=t=>{let e=function(t,e,l){let n=-1===e?t.length:e,s=-1===l?0:l;return t.slice(n-t.slice(0,n).trimStart().length,s+t.slice(s).trimEnd().length)}(s,u,a);(!t||e||i)&&(l.push(e),n.push(function(t,e){return e?t:"true"===t||"false"!==t&&("null"===t?null:c.test(t)?Number(t):t)}(e,i))),s="",i=!1,u=-1,a=-1};for(let t=0;t<e.length;t++){let l=e[t];r?l===r?r=null:(-1===u&&(u=s.length),s+=l,a=s.length):'"'===l||"'"===l?(r=l,i=!0):","===l?o():s+=l}return null!==r&&t(107,[r,e]),o(!0),{args:l,literals:n}}var f=t=>t.trim();function h(t,e){let l=[],n=null;for(let s=0;s<t.length;s++){let r=t[s];null!==n?r===n&&(n=null):"'"===r||'"'===r?n=r:r===e&&l.push(s)}return l}var g=(t,e)=>h(t,e)[0]??-1;function m(t,e){let l=[],n=0;for(let s of h(t,e))l.push(t.slice(n,s)),n=s+1;return l.push(t.slice(n)),l}function p(e,l,n){let s=g(e,"|");if(-1===s)return[e.trim(),[]];let r=e.slice(s+1).trim(),i=n.get(r);return void 0===i&&(i=function(e,l,n){let s=n??e.join("|");return e.map(e=>{let n=g(e,"("),r=(t=>h(t,")").pop()??-1)(e);if(-1===r&&(r=e.lastIndexOf(")")),-1!==n&&-1===r&&t(108,[e]),-1!==r&&-1===n&&t(109,[e]),-1!==r&&r<n&&t(110,[e]),-1!==r&&e.slice(r+1).trim().length>0){let l=e.slice(r+1).trim();t(111,[e,l])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&t(112,[s]),i.includes("#")){let[,e]=i.split("#");t("input"===l?113:114,[i,e])}return-1===n?{Dn:i,args:[],literals:[]}:{Dn:i,...o(e.substring(n+1,r))}})}(m(r,"|").map(f),l,e),n.set(r,i)),[e.slice(0,s).trim(),i]}var d=new Map;function v(e){t(1101,[e])}function b(e){let[l,n]=p(e,"output",d);l.includes("@")&&t(32,[l]);let s=l,r=s.startsWith("."),i=r?s.slice(1):s;return(i.length>0&&i.split(".").some(t=>0===t.length)||!r&&0===i.length)&&t(119,[e]),function(e){e.includes("**")&&v(e);let l=e.split(".").length;l>512&&t(117,[e,l])}(s),{Ge:s,Je:n}}export{e as a,l as b,n as c,s as d,r as e,i as f,u as g,a as h,f as i,g as j,m as k,p as l,v as m,b as n};
1
+ import{c as t}from"./chunk-NPPWJBGJ.js";var e="else",l="eventToken",n="state",s="command",r="class",i="attr",u="style",a=/^\$[1-9]\d{0,2}$/,c=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function o(e){let l=[],n=[],s="",r=null,i=!1,u=-1,a=-1,o=t=>{let e=function(t,e,l){let n=-1===e?t.length:e,s=-1===l?0:l;return t.slice(n-t.slice(0,n).trimStart().length,s+t.slice(s).trimEnd().length)}(s,u,a);(!t||e||i)&&(l.push(e),n.push(function(t,e){return e?t:"true"===t||"false"!==t&&("null"===t?null:c.test(t)?Number(t):t)}(e,i))),s="",i=!1,u=-1,a=-1};for(let t=0;t<e.length;t++){let l=e[t];r?l===r?r=null:(-1===u&&(u=s.length),s+=l,a=s.length):'"'===l||"'"===l?(r=l,i=!0):","===l?o():s+=l}return null!==r&&t(107,[r,e]),o(!0),{args:l,literals:n}}var f=t=>t.trim();function h(t,e){let l=[],n=null;for(let s=0;s<t.length;s++){let r=t[s];null!==n?r===n&&(n=null):"'"===r||'"'===r?n=r:r===e&&l.push(s)}return l}var g=(t,e)=>h(t,e)[0]??-1;function m(t,e){let l=[],n=0;for(let s of h(t,e))l.push(t.slice(n,s)),n=s+1;return l.push(t.slice(n)),l}function p(e,l,n){let s=g(e,"|");if(-1===s)return[e.trim(),[]];let r=e.slice(s+1).trim(),i=n.get(r);return void 0===i&&(i=function(e,l,n){let s=n??e.join("|");return e.map(e=>{let n=g(e,"("),r=(t=>h(t,")").pop()??-1)(e);if(-1===r&&(r=e.lastIndexOf(")")),-1!==n&&-1===r&&t(108,[e]),-1!==r&&-1===n&&t(109,[e]),-1!==r&&r<n&&t(110,[e]),-1!==r&&e.slice(r+1).trim().length>0){let l=e.slice(r+1).trim();t(111,[e,l])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&t(112,[s]),i.includes("#")){let[,e]=i.split("#");t("input"===l?113:114,[i,e])}return-1===n?{Dn:i,args:[],literals:[]}:{Dn:i,...o(e.substring(n+1,r))}})}(m(r,"|").map(f),l,e),n.set(r,i)),[e.slice(0,s).trim(),i]}var d=new Map;function v(e){t(1101,[e])}function b(e){let[l,n]=p(e,"output",d);l.includes("@")&&t(32,[l]);let s=l,r=s.startsWith("."),i=r?s.slice(1):s;return(i.length>0&&i.split(".").some(t=>0===t.length)||!r&&0===i.length)&&t(119,[e]),function(e){e.includes("**")&&v(e);let l=e.split(".").length;l>512&&t(117,[e,l])}(s),{Je:s,Qe:n}}export{e as a,l as b,n as c,s as d,r as e,i as f,u as g,a as h,f as i,g as j,m as k,p as l,v as m,b as n};
@@ -1 +1 @@
1
- import{c as t}from"./chunk-WWJNAZVP.js";import{j as e}from"./chunk-YOPPVWPQ.js";var r={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1};function a(e){let a=r,s=r.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,r]of n){let s=a[e];(!Object.hasOwn(a,e)||null===r||typeof r!=typeof s||Array.isArray(r)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,r]of o)(!Object.hasOwn(s,e)||"string"!=typeof r)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(a[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>r,n=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms"],o=new Map,i=new Map;function f(t){for(let e of Object.keys(t))o.set(e,{...t[e]});i.clear()}function l(t){return o.has(t)}function c(r,a,s){let f=`${r}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(a,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(r);void 0===c&&function(r,a){n.includes(r)&&e(`[wcs/filter-unknown] filter not found: ${r}. "${r}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,r,a),t(501,[r],r,a)}(r,o.keys());let[m,u]=c.arity;a.length<m&&t(601,[r,m,a.length]),a.length>u&&t(602,[r,u,a.length]);let d=c.factory(a,s);return i.set(f,d),d}export{r as a,a as b,s as c,n as d,f as e,l as f,c as g};
1
+ import{c as t}from"./chunk-NPPWJBGJ.js";import{j as e}from"./chunk-Z3EEGBYA.js";var r={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1};function a(e){let a=r,s=r.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,r]of n){let s=a[e];(!Object.hasOwn(a,e)||null===r||typeof r!=typeof s||Array.isArray(r)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,r]of o)(!Object.hasOwn(s,e)||"string"!=typeof r)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(a[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>r,n=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms"],o=new Map,i=new Map;function f(t){for(let e of Object.keys(t))o.set(e,{...t[e]});i.clear()}function l(t){return o.has(t)}function c(r,a,s){let f=`${r}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(a,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(r);void 0===c&&function(r,a){n.includes(r)&&e(`[wcs/filter-unknown] filter not found: ${r}. "${r}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,r,a),t(501,[r],r,a)}(r,o.keys());let[m,u]=c.arity;a.length<m&&t(601,[r,m,a.length]),a.length>u&&t(602,[r,u,a.length]);let d=c.factory(a,s);return i.set(f,d),d}export{r as a,a as b,s as c,n as d,f as e,l as f,c as g};
@@ -1 +1 @@
1
- var t={};function a(t,a){return null==t?a:(...e)=>{t(...e),a(...e)}}function e(t,a,e){return null==a?e:(...n)=>{let r=a(...n);return t(r)?r:e(...n)}}var n=t=>!0===t,r=t=>void 0!==t,s=t=>null!=t,l=new Set;function o(t){for(let a of t)l.has(a.name)||(l.add(a.name),a.install())}function u(a){let e=a.$features;if(null!=t.dt&&Array.isArray(e)){let a=e.filter(t=>!l.has(t));if(a.length>0)return t.dt(a)}}function f(t,a){if(!l.has(t))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${a} needs the add-on @wcstack/state/features/${t}`)}function i(a,e,n){throw new Error(`[@wcstack/state] ${a}${t.Ao?.(a,e,n)??""}`)}export{t as a,a as b,e as c,n as d,r as e,s as f,o as g,u as h,f as i,i as j};
1
+ var t={};function a(t,a){return null==t?a:(...e)=>{t(...e),a(...e)}}function e(t,a,e){return null==a?e:(...n)=>{let r=a(...n);return t(r)?r:e(...n)}}var n=t=>!0===t,r=t=>void 0!==t,s=t=>null!=t,f=new Set;function l(t){for(let a of t)f.has(a.name)||(f.add(a.name),a.install())}function o(a){let e=a.$features;if(null!=t.ft&&Array.isArray(e)){let a=e.filter(t=>!f.has(t));if(a.length>0)return t.ft(a)}}function u(t,a){if(!f.has(t))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${a} needs the add-on @wcstack/state/features/${t}`)}function i(a,e,n){throw new Error(`[@wcstack/state] ${a}${t.Ao?.(a,e,n)??""}`)}export{t as a,a as b,e as c,n as d,r as e,s as f,l as g,o as h,u as i,i as j};
@@ -1 +1 @@
1
- import{a as s}from"./chunks/chunk-WEL3YSG7.js";import{a as n,d as t,e as u}from"./chunks/chunk-FF6KHTYS.js";import"./chunks/chunk-PKDBVBAP.js";import"./chunks/chunk-7PN5YNZZ.js";import"./chunks/chunk-HFKGUDDJ.js";import{g as a,h as c,i as h}from"./chunks/chunk-UM3O6QXD.js";import{c as i}from"./chunks/chunk-732CB4QN.js";import"./chunks/chunk-QI7P7YPP.js";import"./chunks/chunk-QQH6N5CJ.js";import"./chunks/chunk-WWJNAZVP.js";import{g as o}from"./chunks/chunk-YOPPVWPQ.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-YPD4YBJO.js";import{a as n,d as t,e as u}from"./chunks/chunk-HYEQWIFX.js";import"./chunks/chunk-FED2DM4X.js";import"./chunks/chunk-5PWMZ75N.js";import"./chunks/chunk-2PWEFKRB.js";import{g as a,h as c,i as h}from"./chunks/chunk-WPSUT5QQ.js";import{c as i}from"./chunks/chunk-YZUTVCIH.js";import"./chunks/chunk-I2V4DGEI.js";import"./chunks/chunk-YZ4LWPXN.js";import"./chunks/chunk-NPPWJBGJ.js";import{g as o}from"./chunks/chunk-Z3EEGBYA.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-WEL3YSG7.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-7PN5YNZZ.js";import"../chunks/chunk-HFKGUDDJ.js";import"../chunks/chunk-UM3O6QXD.js";import"../chunks/chunk-732CB4QN.js";import"../chunks/chunk-QI7P7YPP.js";import"../chunks/chunk-QQH6N5CJ.js";import"../chunks/chunk-WWJNAZVP.js";import{a as u,b as d}from"../chunks/chunk-YOPPVWPQ.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.D(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.D(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.Zt()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.de)for(let t of e.de)c(t);if(e instanceof r&&null!==e.se){let n=e.T.Ke;for(let l=0;l<n.length;l++){let o=e.K?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.se[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.u)for(let t of e.u)v(t)}},v=e=>{if(!d.has(e))if(d.add(e),e instanceof a){f(-1,"for",e.S,e.s.o,e.s.te,"for");for(let t of e.ve)m(t)}else null!==e.F&&m(e.F)};for(let t of e.re.values())for(let e of t)c(e),null!==e.B&&v(e.B);for(let t of e.oe.values())if(null!==t.E&&v(t.E),null!==t.j)for(let e of t.j)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.L.all()){for(let e=1;e<=s.n;e++)t.add(s.c[e].t);"*"===s.l&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.Z&&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.Se.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.Se.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 P(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.Zt(),error:t})}var O={name:"devtools",install(){u.element=d(u.element,j),u.pe=d(u.pe,$),u.Pe=d(u.Pe,P),u._e=d(u._e,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.L.all()){let l=n.V,o=n.Fe?.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.tt=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},M=O;export{M as default,O as devtools};
1
+ import{a as e}from"../chunks/chunk-YPD4YBJO.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-5PWMZ75N.js";import"../chunks/chunk-2PWEFKRB.js";import"../chunks/chunk-WPSUT5QQ.js";import"../chunks/chunk-YZUTVCIH.js";import"../chunks/chunk-I2V4DGEI.js";import"../chunks/chunk-YZ4LWPXN.js";import"../chunks/chunk-NPPWJBGJ.js";import{a as u,b as d}from"../chunks/chunk-Z3EEGBYA.js";var f="__WCSTACK_DEVTOOLS_HOOK__",c=null,m=new Set,h=(e,t,n)=>({absolutePathInfo:{pathInfo:{path:t.t},stateElement:e.element},listIndex:null===n?null:{indexes:e._(n)}}),p=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=p.get(e);return void 0===t&&p.set(e,t=++k),t})(d)}|${v}|${f.t}|${null===g?"":e._(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:h(e,f,g)})},c=e=>f(e.i,e.name,e.a,e.o,e.r,e.en()),m=e=>{if(!d.has(e)){if(d.add(e),null!==e.fe)for(let t of e.fe)c(t);if(e instanceof r&&null!==e.ae){let n=e.A.qe;for(let l=0;l<n.length;l++){let o=e.W?.[l];void 0!==o?c(o):f(n[l].i,n[l].name,e.ae[2*l],n[l].o,e.r,n[l].i===t?"text":"prop")}}if(null!==e.h)for(let t of e.h)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.re,"for");for(let t of e.$e)m(t)}else null!==e.O&&m(e.O)};for(let t of e.ie.values())for(let e of t)c(e),null!==e.M&&v(e.M);for(let t of e.ee.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.D.all()){for(let e=1;e<=s.n;e++)t.add(s.f[e].t);"*"===s.s&&n.add(s.t),null!==s.getter&&l.add(s.t),null!==s.oe&&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.xe.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 $(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.xe.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 j(e,t,n,l,o,s){if(null===c)return;let r=h(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 E(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.en(),error:t})}var M={name:"devtools",install(){u.element=d(u.element,$),u.he=d(u.he,j),u.Te=d(u.Te,O),u.He=d(u.He,E),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.D.all()){let l=n.U,o=n.Fe?.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.nt=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},N=M;export{N as default,M as devtools};
@@ -1 +1 @@
1
- import{b as e,c as t,h as n,j as i}from"../chunks/chunk-UM3O6QXD.js";import{a,d as s,f as r}from"../chunks/chunk-732CB4QN.js";import{e as o}from"../chunks/chunk-QI7P7YPP.js";import"../chunks/chunk-QQH6N5CJ.js";import{a as l}from"../chunks/chunk-WWJNAZVP.js";import{a as d,b as c,j as f}from"../chunks/chunk-YOPPVWPQ.js";function u(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let i=new Array(t.length+1),a=new Array(t.length+1);for(let e=0;e<=t.length;e++)i[e]=e;for(let n=1;n<=e.length;n++){a[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;a[s]=Math.min(i[s]+1,a[s-1]+1,i[s-1]+r)}for(let e=0;e<=t.length;e++)i[e]=a[e]}return i[t.length]}function h(e,t){if(0===e.length)return"";let n=e.toLowerCase(),i=null,a=3;for(let e of t){let t=u(n,e.toLowerCase(),2);t<a&&(i=e,a=t)}return null!==i?` Did you mean "${i}"?`:""}var p=" Validate statically: npx @wcstack/lint <file>.",$=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],m=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,g="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",w={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>`updates did not settle after ${e} passes`,41:()=>`render chain depth limit exceeded (${t} drains that rendering itself started); bindings for this batch were not applied.`,12:(e,t)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${g}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${g}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&$.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${m(e,t)} failed to initialize.`,50:(e,...t)=>`${m(e,t)} $connectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,119:e=>`"${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,i)=>`${e}("${t}") takes ${n} index(es), got ${i}.`,902:(e,t,n,i)=>`${e}("${t}") takes at most ${n} index(es), got ${i}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function b(e,t){let n=w[e];return void 0===n?`${l(e)}#${e} ${t.join(" ")}`:l(e)+n(...t)}var y=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),v=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],k={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function x(e,t,n){let i=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(k,e)?k[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?h(t,n):"");for(let[t,n]of v){let a=t.exec(e);null!==a&&(i+=n.replace(/\$(\d)/g,(e,t)=>a[Number(t)]))}let a=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==a&&(i+=` — write "${a[1]}#${a[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?i+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(i+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let o=/\[wcs\/([\w-]+)\]/.exec(e);return null!==o&&y.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(i+=p),i}var j=new WeakMap,T=new WeakMap,P=new WeakSet,O=new WeakSet;function S(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 I(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function M(e,t){let n=[];for(let e=t;null!==e;e=e.w)n.unshift(e);let i=e.target,a=t=>null===t?null:function(e,t){let n=t.t.split("."),i=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return i<0||n.indexOf("*",i)>=0||void 0!==S(e.target,t.t)?.get?t:e.L.Ft(o(t.t).o)}(e,t);for(let t of n){if(null!=a(t)?.getter||null===i||"object"!=typeof i)return null;if("*"===t.l){if(!Array.isArray(i)||0===i.length)return null;i=i[0];continue}if(Array.isArray(i)&&/^\d+$/.test(t.l)){if(Number(t.l)>=i.length)return null;i=i[Number(t.l)];continue}let n=S(i,t.l);if(void 0===n&&null===t.w&&e.pt.has(t.l))return null;if(void 0===n){let n=I(i),s=a(t.w);for(let t of e.L.all())t.w===s&&null!==t.getter&&n.push(t.l);return{seg:t.l,names:n}}if(void 0!==n.get||void 0!==n.set)return null;i=n.value}return null}function A(e){P.has(e)||(P.add(e),setTimeout(()=>function(e){P.delete(e);let t=j.get(e);if(void 0===t)return;let n=T.get(e);void 0===n&&T.set(e,n=new Set);for(let[i,s]of t){if(n.has(i))continue;n.add(i);let t=M(e,i);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${a.tagNames.state}[mount]`)??[]].find(e=>!O.has(e)&&(i.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(i),r.initializePromise.then(()=>{O.add(r),A(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.tt?.(e,{type:"state:path-unresolved",source:s?"watch":"binding",path:i.t,missingSegment:t.seg});let f=e.L.Ft(o(i.t).o),u="";if(void 0!==f&&f!==i&&null!==f.getter){let e=f.c.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(f.c[t].t.length+2)}`);u=` The getter "${f.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${l}] ${c} "${i.t}" does not resolve on the state tree: "${t.seg}" is not declared.${h(t.seg,t.names)}${u} Updates to this path will be silently dropped.${p}`)}}(e),0))}function W(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.w)return;let i=j.get(e);void 0===i&&j.set(e,i=new Map),i.has(t)||i.set(t,n),A(e)}var q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=!1;function N(e,t,a){let s="html"===a.name?"innerHTML":a.name;if(L||!(t instanceof TypeError)||!i(s)||!("trustedTypes"in globalThis))return;L=!0;let r="function"==typeof n()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${s}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${r}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:a.a,property:s})}var B=new WeakMap;function C(e,t,n){let i=e[t],a=void 0===n?void 0===i?null:`the event carried no detail (undefined) while element.${t} is ${typeof i}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==i&&"object"==typeof i?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof i}`;if(null===a)return;let s=B.get(e);void 0===s&&B.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${a}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var z={name:"diagnostics",install(){d.Ao=x,d.Fo=b,d.yo=W,d.detail=C,d._e=c(d._e,N),d.ie=c(d.ie,(e,t)=>{(function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[i,a]=n[0];if(!i.endsWith(".*")||!a.endsWith(".*"))return;let s=i.slice(0,-2),r=a.slice(0,-2),o=`.${a}`,l=`${s}.**`,d=I(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>f(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${r}`||e.startsWith(`.${r}.`))&&u(`"${l}${e}" names the recursion structure itself (the "${r}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${q(o)})+$`).test(t.slice(0,t.length-e.length))&&u(`"${l}${e}" and "${l}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${a}"). Rename one of them.`);let t=new RegExp(`^${q(i)}(?:${q(o)})*${q(e)}$`);for(let n of d)!n.includes("**")&&t.test(n)&&u(`"${n}" is already defined on the state, so the recursive getter "${l}${e}" cannot expand to it.`)}})(t),function(e){T.delete(e),j.has(e)&&A(e)}(e)})}},D=z;export{D as default,z as diagnostics};
1
+ import{b as e,c as t,h as n,j as i}from"../chunks/chunk-WPSUT5QQ.js";import{a,d as s,f as r}from"../chunks/chunk-YZUTVCIH.js";import{e as o}from"../chunks/chunk-I2V4DGEI.js";import"../chunks/chunk-YZ4LWPXN.js";import{a as l}from"../chunks/chunk-NPPWJBGJ.js";import{a as d,b as c,j as f}from"../chunks/chunk-Z3EEGBYA.js";function u(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let i=new Array(t.length+1),a=new Array(t.length+1);for(let e=0;e<=t.length;e++)i[e]=e;for(let n=1;n<=e.length;n++){a[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;a[s]=Math.min(i[s]+1,a[s-1]+1,i[s-1]+r)}for(let e=0;e<=t.length;e++)i[e]=a[e]}return i[t.length]}function h(e,t){if(0===e.length)return"";let n=e.toLowerCase(),i=null,a=3;for(let e of t){let t=u(n,e.toLowerCase(),2);t<a&&(i=e,a=t)}return null!==i?` Did you mean "${i}"?`:""}var $=" Validate statically: npx @wcstack/lint <file>.",p=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],m=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,g="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",w={1:()=>"$scan was removed (use $watch or $on)",2:e=>`"${e}" is a getter without a setter`,3:e=>`no row for "${e}"`,4:(e,t)=>`cannot write "${e}": its parent is ${t}`,5:e=>`"${e}" is not a method`,6:e=>`$getAll("${e}"): no loop level in common with the context`,7:e=>`$eqIndex("${e}") needs a list row scope.`,8:()=>"This state is readonly.",9:e=>`$setAll("${e}") needs indexes ([] for every match)`,10:(e,t)=>`$setAll("${e}", …, { spread: true }) needs an array of ${t} values`,11:()=>`updates did not settle after ${e} passes`,41:()=>`render chain depth limit exceeded (${t} drains that rendering itself started); bindings for this batch were not applied.`,12:(e,t)=>`binding "${e}: ${t}" failed to apply.`,13:(e,t)=>`failed to load "${e}": ${t}`,14:()=>"this <wcs-state> failed to initialize; create a new one",15:()=>"state is not initialized",16:e=>`no <script> with id "${e}"`,42:()=>`The inline <script> of <wcs-state> was blocked by Content-Security-Policy. Inline state is evaluated through a blob: URL: give the page's nonce to the <script> that loads @wcstack/state, or allow blob: in script-src. Moving the state into an external file (src="./state.js") needs neither. See ${g}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${g}`,17:e=>`a subscriber of token "${e}" threw.`,18:e=>`${e} must be an array of strings.`,19:e=>`${e} entries must be non-empty strings.`,20:(e,t,n)=>`${e} entry "${t}" conflicts with the reserved namespace name "${n}".`,21:(e,t)=>`${e} entry "${t}" is duplicated.`,22:()=>"$on must be an object of handlers.",23:e=>`$on entry "${e}" is not declared in $eventTokens.`,24:e=>`$on entry "${e}" must be a function.`,25:e=>`view-transition naming-limit (${e}) reached.`,26:e=>`filter ${e} requires at least one option`,27:e=>`filter ${e} requires a number as option`,28:e=>`filter ${e} requires a number value`,29:e=>`filter ${e} requires a date value`,30:e=>`filter ${e} requires an array value`,31:()=>"init=/sync= modifiers require enableDirectionalInitialSync.",33:(e,t)=>`Unknown binding modifier "${e}" in "${t}".`,34:e=>`Binding modifier "${e}" may only be specified once.`,35:(e,t)=>`Invalid ${e} modifier value "${t}".`,36:()=>"Event bindings only allow init=none.",37:(e,t)=>`Binding type "${e}" does not support init=${t}.`,38:e=>`Property "${e}" is not declared by wcBindable.`,39:(e,t)=>`init=${e} is incompatible with wcBindable member "${t}".`,40:e=>`sync=connect requires observable property "${e}".`,44:(e,t)=>`${e}: "${t}" is not one of its options, or not of the option's type.${"bootstrapState"===e&&p.includes(t)?" 4.0 moved it to the state's $behavior.":""}`,45:()=>"a re-set state may not change $behavior: create the element again.",47:()=>'a second <wcs-state> on the same root: there is one state tree per root — graft a subtree with <wcs-state mount="path"> (v1\'s name="…" is gone: read the mounted state by its path).',48:e=>`the locale "${e}" (<html lang> or bootstrapState's locale) is not a language tag Intl takes (en-US, not en_US): the locale filters use "en".`,46:()=>'$features must be an array of add-on names (["temporal", "formats"]).',49:(e,...t)=>`${m(e,t)} failed to initialize.`,50:(e,...t)=>`${m(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${m(e,t)} $disconnectedCallback failed.`,101:e=>`Invalid bindText: "${e}". Missing ':' separator between propPart and statePart.`,102:(e,t)=>`"${e}": "${t}" takes no modifiers or filters on its left side — write "${t}:".`,103:e=>`"${e}": "else" takes no value — write "else:".`,104:e=>`Invalid spread binding "${e}": spread target path is required.`,105:e=>`Invalid spread binding "${e}": filters are not allowed on spread targets.`,106:e=>`"${e}": a leading "." binds an element property by name — write a non-empty property that is not a namespace (class, attr, style, command, eventToken, state).`,107:(e,t)=>`unterminated ${e} quote in the filter arguments "(${t})". Close the quote.`,108:e=>`Invalid filter format: missing closing parenthesis in "${e}".`,109:e=>`Invalid filter format: missing opening parenthesis in "${e}".`,110:e=>`Invalid filter format: ")" comes before "(" in "${e}".`,111:(e,t)=>`"${e}": unexpected "${t}" after the filter's closing ")" — separate filters with "|" (write "${e.slice(0,e.lastIndexOf(")")+1)}|${t}").`,112:e=>`an empty filter in "${e}" — remove the extra "|" or name the filter.`,113:(e,t)=>`"${e}" is not a filter name: a modifier list "#${t}" comes before the input filters, not inside one`,114:e=>`"${e}" is not a filter name: "#" cannot appear in one.`,115:e=>`"${e}": a binding takes one modifier list after a single "#"`,116:e=>`"${e}": the left side of a binding must name a property — write "<property>: <path>" (modifiers and input filters come after the name).`,117:(e,t)=>`"${e}" has ${t} path segments — the limit is 512.`,32:e=>`"${e}": the "@name" selector was removed in v2 — there is a single state tree. Mount the named state onto the tree (<wcs-state mount="...">) and read it by its path prefix instead.`,120:e=>`"${e}": a state path cannot go through "__proto__" or "prototype" (it would reach every object's prototype).`,121:e=>`"${e}": "for:" takes no filters — a row is "<path>.<index>", so the rows of a filtered list would name other elements. Declare a getter that returns the filtered list and loop over it ("for: <getter>").`,119:e=>`"${e}": the right side of a binding must name a state path — write "<property>: <path>" (a path segment cannot be empty; "." alone and a leading "." are the loop-relative shorthand).`,201:e=>`Invalid bindText: "${e}". 'if', 'elseif', 'else', and 'for' bindings must be single binding.`,202:e=>`"${e}:" must follow an "if:" template`,204:e=>`a "${e}:" template at the top of inserted content was not rendered, as it would render beside itself out of the inserter's reach: wrap it in an element.`,203:e=>`"${e}:" replaces its element, so it cannot be used inside a "for" / "if" template (a row or branch keeps its nodes by position): bind innerHTML: on a wrapper element instead.`,301:e=>`Path "${e}" does not exist on the state tree.`,401:(e,t)=>`class.${e} needs a boolean, got ${t}.`,501:e=>`filter not found: ${e}.`,601:(e,t,n)=>`filter "${e}" requires at least ${t} argument(s) (${n} given).`,602:(e,t,n)=>`filter "${e}" accepts at most ${t} argument(s) (${n} given).`,701:e=>`"${e}" depends on itself`,801:e=>`"${e}"`,901:(e,t,n,i)=>`${e}("${t}") takes ${n} index(es), got ${i}.`,902:(e,t,n,i)=>`${e}("${t}") takes at most ${n} index(es), got ${i}.`,1001:e=>`"${e}": list index parameters run from $1 to $128.`,1101:e=>`"${e}" uses "**", which is not accepted here.`,1201:(e,t)=>`"${e}: ${t}": the right-hand side must be $command.<name>`,1202:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1301:e=>`eventToken "${e}" is not declared in $eventTokens.`,1302:e=>`"$command.${e}" is not declared in $commandTokens.`,1401:(e,t,n=0)=>`"${e}" needs ${t} enclosing loop level(s); the scope provides ${n}.`,1402:e=>`"${e}" is relative: it needs an enclosing "for" template`,1403:(e,t,n)=>`"${e}" ranges over the rows of "${t}", but the enclosing "for" template at that level renders "${n}".`,1501:(e,t)=>`<${e}> declares no static wcBindable (${t}).`,1601:(e,t)=>`${e} was removed: write ${t}.`,1701:(e,t)=>`${e} was removed: write ${t}.`};function b(e,t){let n=w[e];return void 0===n?`${l(e)}#${e} ${t.join(" ")}`:l(e)+n(...t)}var y=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),v=[[/no loop level in common with the context/,"; pass indexes ([] for all)."],[/"([^"#]+)#([^"]*)" is not a filter name: a modifier list .* comes before the input filters/,' — write "<property>#$2|$1".'],[/\[wcs\/recursion-unsupported\]/," It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path argument of $getAll / $setAll — and only when the state declares a $recursion anchor."],[/must be single binding/,' Put the structural binding alone in its own data-wcs (e.g. <template data-wcs="for: items">).'],[/\[wcs\/wildcard-rank\] .* needs \d+ enclosing/,' Wrap it in that many "for" templates, or use $resolve(path, indexes) to name the row explicitly.'],[/\[wcs\/wildcard-rank\] .* ranges over the rows of/,' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/,' Write "class.$1: path|truthy" to toggle on truthiness.'],[/path segments — the limit/," Every prefix of a path is interned, so the cost grows with the square of the depth."],[/\[wcs\/index-arity\] \$resolve/,' $resolve takes one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/,' Modifiers belong on the left side of the binding, before the ":" — write "$1" here.']],k={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function x(e,t,n){let i=(void 0!==t&&e.includes("[wcs/filter-unknown]")?function(e){if("substr"===e)return' "substr" was removed in 4.0 — write slice(start, start + length): slice takes the end index, not a length.';let t=Object.hasOwn(k,e)?k[e]:null;return null===t?null:` "${e}" was renamed "${t}" in 3.2 and removed in 4.0 — write "${t}".`}(t):null)??(void 0!==t&&void 0!==n?h(t,n):"");for(let[t,n]of v){let a=t.exec(e);null!==a&&(i+=n.replace(/\$(\d)/g,(e,t)=>a[Number(t)]))}let a=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==a&&(i+=` — write "${a[1]}#${a[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?i+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(i+=' No formatting filters are installed — add the formats add-on: installFeatures([formats]) from "@wcstack/state/features/formats" (a split auto page: features="formats", or "$features").'));let o=/\[wcs\/([\w-]+)\]/.exec(e);return null!==o&&y.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(i+=$),i}var j=new WeakMap,T=new WeakMap,I=new WeakSet,S=new WeakSet;function O(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 P(e){let t=new Set;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"$"!==e[0]&&"constructor"!==e&&t.add(e);return[...t]}function M(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let i=e.target,a=t=>null===t?null:function(e,t){let n=t.t.split("."),i=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return i<0||n.indexOf("*",i)>=0||void 0!==O(e.target,t.t)?.get?t:e.D.Ct(o(t.t).o)}(e,t);for(let t of n){if(null!=a(t)?.getter||null===i||"object"!=typeof i)return null;if("*"===t.s){if(!Array.isArray(i)||0===i.length)return null;i=i[0];continue}if(Array.isArray(i)&&/^\d+$/.test(t.s)){if(Number(t.s)>=i.length)return null;i=i[Number(t.s)];continue}let n=O(i,t.s);if(void 0===n&&null===t.d&&e.mt.has(t.s))return null;if(void 0===n){let n=P(i),s=a(t.d);for(let t of e.D.all())t.d===s&&null!==t.getter&&n.push(t.s);return{seg:t.s,names:n}}if(void 0!==n.get||void 0!==n.set)return null;i=n.value}return null}function A(e){I.has(e)||(I.add(e),setTimeout(()=>function(e){I.delete(e);let t=j.get(e);if(void 0===t)return;let n=T.get(e);void 0===n&&T.set(e,n=new Set);for(let[i,s]of t){if(n.has(i))continue;n.add(i);let t=M(e,i);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${a.tagNames.state}[mount]`)??[]].find(e=>!S.has(e)&&(i.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(i),r.initializePromise.then(()=>{S.add(r),A(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.nt?.(e,{type:"state:path-unresolved",source:s?"watch":"binding",path:i.t,missingSegment:t.seg});let f=e.D.Ct(o(i.t).o),u="";if(void 0!==f&&f!==i&&null!==f.getter){let e=f.f.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(f.f[t].t.length+2)}`);u=` The getter "${f.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${l}] ${c} "${i.t}" does not resolve on the state tree: "${t.seg}" is not declared.${h(t.seg,t.names)}${u} Updates to this path will be silently dropped.${$}`)}}(e),0))}function W(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let i=j.get(e);void 0===i&&j.set(e,i=new Map),i.has(t)||i.set(t,n),A(e)}var q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),C=!1;function D(e,t,a){let s="html"===a.name?"innerHTML":a.name;if(C||!(t instanceof TypeError)||!i(s)||!("trustedTypes"in globalThis))return;C=!0;let r="function"==typeof n()?.createHTML?"The injected policy's createHTML() did not return a TrustedHTML.":"No sanitizing policy is installed, and @wcstack/state deliberately does not pass state values through an identity policy — that would defeat the CSP.";console.error(`[@wcstack/state] Writing to "${s}" was blocked by Trusted Types (require-trusted-types-for 'script'). ${r}\nInstall a sanitizing policy before the first binding is applied:\n globalThis[Symbol.for("wcstack.trustedTypes.policy")] =\n trustedTypes.createPolicy("my-app", { createHTML: (s) => DOMPurify.sanitize(s) });\nOr bind the value as text instead of HTML. See docs/csp.md section 7.`,{element:a.a,property:s})}var L=new WeakMap;function B(e,t,n){let i=e[t],a=void 0===n?void 0===i?null:`the event carried no detail (undefined) while element.${t} is ${typeof i}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==i&&"object"==typeof i?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof i}`;if(null===a)return;let s=L.get(e);void 0===s&&L.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${a}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var H={name:"diagnostics",install(){d.Ao=x,d.Fo=b,d.go=W,d.detail=B,d.He=c(d.He,D),d.se=c(d.se,(e,t)=>{(function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[i,a]=n[0];if(!i.endsWith(".*")||!a.endsWith(".*"))return;let s=i.slice(0,-2),r=a.slice(0,-2),o=`.${a}`,l=`${s}.**`,d=P(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>f(`[wcs/recursion-declaration-invalid] ${e}`);for(let e of c){(e===`.${r}`||e.startsWith(`.${r}.`))&&u(`"${l}${e}" names the recursion structure itself (the "${r}" lists): recursive getters compute values over the nodes.`);for(let t of c)t.length>e.length&&t.endsWith(e)&&new RegExp(`^(?:${q(o)})+$`).test(t.slice(0,t.length-e.length))&&u(`"${l}${e}" and "${l}${t}" expand to the same concrete path at different depths (they differ by whole repetitions of "${a}"). Rename one of them.`);let t=new RegExp(`^${q(i)}(?:${q(o)})*${q(e)}$`);for(let n of d)!n.includes("**")&&t.test(n)&&u(`"${n}" is already defined on the state, so the recursive getter "${l}${e}" cannot expand to it.`)}})(t),function(e){T.delete(e),j.has(e)&&A(e)}(e)})}},N=H;export{N as default,H as diagnostics};
@@ -1 +1 @@
1
- import{a as t,c as r,d as e,e as a,g as n,h as o}from"../chunks/chunk-HFKGUDDJ.js";import{a as i,e as c}from"../chunks/chunk-732CB4QN.js";import{b as l}from"../chunks/chunk-WWJNAZVP.js";import"../chunks/chunk-YOPPVWPQ.js";var y,u=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},s="en";function f(){if(i.locale!==y){y=i.locale;try{s=Intl.getCanonicalLocales(y)[0]}catch{console.warn(`[@wcstack/state] ${l(48,[y])}`),s="en"}}return s}var p={toFixed:{factory:t=>{let e=n(t?.[0]??"0","toFixed");return t=>("number"!=typeof t&&r("toFixed"),t.toFixed(e))},arity:[0,1]},locale:{factory:t=>{let e=t?.[0];return t=>("number"!=typeof t&&r("locale"),t.toLocaleString(e??f()))},arity:[0,1]},upper:{factory:u(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:u(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:u(()=>t=>{let r=String(t);return 0===r.length?r:1===r.length?r.toUpperCase():r.charAt(0).toUpperCase()+r.slice(1)}),arity:[0,0]},trim:{factory:u(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:u(t=>{let r=[o(t,0,"slice")],e=t?.[1];return typeof e<"u"&&r.push(n(e,"slice")),t=>String(t).slice(...r)}),arity:[1,2]},padStart:{factory:u(t=>{let r=o(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:u(t=>{let r=o(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:u(t=>{let r=o(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:u(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:u(t=>{let r=o(t,0,"truncate"),e=t?.[1]??"…";return t=>{let a=String(t);return a.length<=r?a:a.slice(0,r)+e}}),arity:[1,2]},join:{factory:t=>{let r=t?.[0]??", ";return t=>(Array.isArray(t)||a("join"),t.join(r))},arity:[0,1]},round:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","round"));return t=>("number"!=typeof t&&r("round"),Math.round(t*e)/e)},arity:[0,1]},floor:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","floor"));return t=>("number"!=typeof t&&r("floor"),Math.floor(t*e)/e)},arity:[0,1]},ceil:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","ceil"));return t=>("number"!=typeof t&&r("ceil"),Math.ceil(t*e)/e)},arity:[0,1]},percent:{factory:t=>{let e=n(t?.[0]??"0","percent");return t=>("number"!=typeof t&&r("percent"),`${(100*t).toFixed(e)}%`)},arity:[0,1]},unit:{factory:u(r=>{let e=r?.[0]??t("unit");return t=>String(t)+e}),arity:[1,1]},date:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("date"),t.toLocaleDateString(r??f()))},arity:[0,1]},time:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("time"),t.toLocaleTimeString(r??f()))},arity:[0,1]},datetime:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("datetime"),t.toLocaleString(r??f()))},arity:[0,1]},ymd:{factory:t=>{let r=t?.[0]??"-";return t=>{t instanceof Date||e("ymd");let a=t.getFullYear().toString(),n=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0");return`${a}${r}${n}${r}${o}`}},arity:[0,1]},hms:{factory:t=>{let r=t?.[0]??":";return t=>{t instanceof Date||e("hms");let a=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getSeconds().toString().padStart(2,"0");return`${a}${r}${n}${r}${o}`}},arity:[0,1]}},d=!1,g={name:"formats",install:function(){d||(d=!0,c(p))}},S=g;export{S as default,g as formats};
1
+ import{a as t,c as r,d as e,e as a,g as n,h as o}from"../chunks/chunk-2PWEFKRB.js";import{a as i,e as c}from"../chunks/chunk-YZUTVCIH.js";import{b as l}from"../chunks/chunk-NPPWJBGJ.js";import"../chunks/chunk-Z3EEGBYA.js";var y,u=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},s="en";function f(){if(i.locale!==y){y=i.locale;try{s=Intl.getCanonicalLocales(y)[0]}catch{console.warn(`[@wcstack/state] ${l(48,[y])}`),s="en"}}return s}var p={toFixed:{factory:t=>{let e=n(t?.[0]??"0","toFixed");return t=>("number"!=typeof t&&r("toFixed"),t.toFixed(e))},arity:[0,1]},locale:{factory:t=>{let e=t?.[0];return t=>("number"!=typeof t&&r("locale"),t.toLocaleString(e??f()))},arity:[0,1]},upper:{factory:u(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:u(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:u(()=>t=>{let r=String(t);return 0===r.length?r:1===r.length?r.toUpperCase():r.charAt(0).toUpperCase()+r.slice(1)}),arity:[0,0]},trim:{factory:u(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:u(t=>{let r=[o(t,0,"slice")],e=t?.[1];return typeof e<"u"&&r.push(n(e,"slice")),t=>String(t).slice(...r)}),arity:[1,2]},padStart:{factory:u(t=>{let r=o(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:u(t=>{let r=o(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:u(t=>{let r=o(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:u(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:u(t=>{let r=o(t,0,"truncate"),e=t?.[1]??"…";return t=>{let a=String(t);return a.length<=r?a:a.slice(0,r)+e}}),arity:[1,2]},join:{factory:t=>{let r=t?.[0]??", ";return t=>(Array.isArray(t)||a("join"),t.join(r))},arity:[0,1]},round:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","round"));return t=>("number"!=typeof t&&r("round"),Math.round(t*e)/e)},arity:[0,1]},floor:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","floor"));return t=>("number"!=typeof t&&r("floor"),Math.floor(t*e)/e)},arity:[0,1]},ceil:{factory:t=>{let e=Math.pow(10,n(t?.[0]??"0","ceil"));return t=>("number"!=typeof t&&r("ceil"),Math.ceil(t*e)/e)},arity:[0,1]},percent:{factory:t=>{let e=n(t?.[0]??"0","percent");return t=>("number"!=typeof t&&r("percent"),`${(100*t).toFixed(e)}%`)},arity:[0,1]},unit:{factory:u(r=>{let e=r?.[0]??t("unit");return t=>String(t)+e}),arity:[1,1]},date:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("date"),t.toLocaleDateString(r??f()))},arity:[0,1]},time:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("time"),t.toLocaleTimeString(r??f()))},arity:[0,1]},datetime:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("datetime"),t.toLocaleString(r??f()))},arity:[0,1]},ymd:{factory:t=>{let r=t?.[0]??"-";return t=>{t instanceof Date||e("ymd");let a=t.getFullYear().toString(),n=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0");return`${a}${r}${n}${r}${o}`}},arity:[0,1]},hms:{factory:t=>{let r=t?.[0]??":";return t=>{t instanceof Date||e("hms");let a=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),o=t.getSeconds().toString().padStart(2,"0");return`${a}${r}${n}${r}${o}`}},arity:[0,1]}},d=!1,g={name:"formats",install:function(){d||(d=!0,c(p))}},S=g;export{S as default,g as formats};
@@ -1 +1 @@
1
- import{a as t,b as e,c as l,d as n,j as o}from"../chunks/chunk-YOPPVWPQ.js";var s=new WeakMap,r=!1,i=/^(?!prototype$)[^\d.*$][^.*]*$/;function f(t,e){let l=e.$listKeys,n=new Map;if(void 0!==l){(null===l||"object"!=typeof l)&&o("$listKeys must be an object mapping list paths to a key field or function.");for(let e of Object.keys(l)){let s=l[e];"string"==typeof s?n.set(t.o(e),t=>t[s]):"function"==typeof s?n.set(t.o(e),s):o(`$listKeys "${e}" must be a field name or a function.`)}}s.set(e,n)}function u(t){if(null===t||"object"!=typeof t)return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function a(t,e,l){let n=new Map;for(let s of e){u(s)||o(`$listKeys "${t}": rows must be plain objects.`);let e=l(s);null==e&&o(`$listKeys "${t}": a row has no key.`),n.has(e)&&o(`$listKeys "${t}": duplicate key ${JSON.stringify(e)}.`),n.set(e,s)}return n}function y(t,e,l,n){if(r||!Array.isArray(n))return!1;let o=s.get(t.target)?.get(e);if(void 0===o)return!1;let f=t.zt(e,l);if(!Array.isArray(f)||f===n)return!1;let u=a(e.t,f,o);a(e.t,n,o);let y=[],p=[],c=f.length===n.length;for(let t=0;t<n.length;t++){let e=n[t],l=u.get(o(e));y.push(l??e),void 0!==l&&p.push([t,l,e]),y[t]!==f[t]&&(c=!1)}let $=[];for(let[t,e,l]of p){for(let n of Object.keys(l))Object.is(e[n],l[n])||$.push([t,n,l[n]]);for(let n of Object.keys(e))!(n in l)&&null!==e[n]&&$.push([t,n,null])}if(c&&0===$.length)return!0;if(!c){r=!0;try{t.P(e,l,y)}finally{r=!1}}if($.length>0){let n=t.De(0===e.n?null:l,e);for(let[l,o,s]of $){if("__proto__"===o)continue;let r=n.f[l],f=i.test(o)?t.o(`${e.t}.*.${o}`):null;null===f?.getter?t.P(f,r,s):(r.O[o]=s,t.P(t.o(`${e.t}.*`),r,r.O,!0))}}return!0}var p={name:"list-keys",install(){t.ie=e(t.ie,f),t.Re=l(n,t.Re,y)}},c=p;export{c as default,p as listKeys};
1
+ import{a as t,b as e,c as l,d as n,j as s}from"../chunks/chunk-Z3EEGBYA.js";var o=new WeakMap,r=!1,i=/^(?!prototype$)[^\d.*$][^.*]*$/;function f(t,e){let l=e.$listKeys,n=new Map;if(void 0!==l){(null===l||"object"!=typeof l)&&s("$listKeys must be an object mapping list paths to a key field or function.");for(let e of Object.keys(l)){let o=l[e];"string"==typeof o?n.set(t.o(e),t=>t[o]):"function"==typeof o?n.set(t.o(e),o):s(`$listKeys "${e}" must be a field name or a function.`)}}o.set(e,n)}function u(t){if(null===t||"object"!=typeof t)return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function a(t,e,l){let n=new Map;for(let o of e){u(o)||s(`$listKeys "${t}": rows must be plain objects.`);let e=l(o);null==e&&s(`$listKeys "${t}": a row has no key.`),n.has(e)&&s(`$listKeys "${t}": duplicate key ${JSON.stringify(e)}.`),n.set(e,o)}return n}function y(t,e,l,n){if(r||!Array.isArray(n))return!1;let s=o.get(t.target)?.get(e);if(void 0===s)return!1;let f=t.wt(e,l);if(!Array.isArray(f)||f===n)return!1;let u=a(e.t,f,s);a(e.t,n,s);let y=[],p=[],c=f.length===n.length;for(let t=0;t<n.length;t++){let e=n[t],l=u.get(s(e));y.push(l??e),void 0!==l&&p.push([t,l,e]),y[t]!==f[t]&&(c=!1)}let $=[];for(let[t,e,l]of p){for(let n of Object.keys(l))Object.is(e[n],l[n])||$.push([t,n,l[n]]);for(let n of Object.keys(e))!(n in l)&&null!==e[n]&&$.push([t,n,null])}if(c&&0===$.length)return!0;if(!c){r=!0;try{t.P(e,l,y)}finally{r=!1}}if($.length>0){let n=t.Be(0===e.n?null:l,e);for(let[l,s,o]of $){if("__proto__"===s)continue;let r=n.u[l],f=i.test(s)?t.o(`${e.t}.*.${s}`):null;null===f?.getter?t.P(f,r,o):(r.T[s]=o,t.P(t.o(`${e.t}.*`),r,r.T,!0))}}return!0}var p={name:"list-keys",install(){t.se=e(t.se,f),t.Pe=l(n,t.Pe,y)}},c=p;export{c as default,p as listKeys};
@@ -1 +1 @@
1
- import{m as e}from"../chunks/chunk-QQH6N5CJ.js";import{c as t}from"../chunks/chunk-WWJNAZVP.js";import{a as r,b as s,c as n,d as l,j as i}from"../chunks/chunk-YOPPVWPQ.js";var a="$recursion",o=new WeakMap,c=new WeakSet,u=new WeakSet,h=0,d=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=e=>`[wcs/recursion-${e}]`;function f(e,t){let r=r=>i(`${$("declaration-invalid")} ${a} ${e} "${String(t)}" ${r}`);("string"!=typeof t||""===t)&&i(`${$("declaration-invalid")} ${a} ${e} must be a non-empty string.`);let s=t.split(".");(s.length<2||"*"!==s[s.length-1])&&r('must end with ".*" (a list element).');for(let e=0;e<s.length-1;e++){let t=s[e];""===t&&r("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&r('must have exactly one "*", at the end.'),t.includes("#")&&r('must not contain "#".')}return"$"===t[0]&&r('must not start with "$".'),t}var p=(e,t)=>`${e.s}.*${e.step.repeat(t)}`;function g(e,t){let r=`${e.s}.**`,s=t.slice(r.length);return(!t.startsWith(r)||""!==s&&"."!==s[0]||s.includes("**"))&&i(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.s}.*".`),s}function m(e,t,r){let s=g(e,t),n=function(e,t){for(let r=t;null!==r;r=r.s.te){let t=e.nodeList.exec(r.s.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r}}return null}(e,r);return null===n&&i(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),p(e,n.k)+s}function y(e,t,r){let s=new Set,n=new Set,l=(e,r,l)=>!(!Array.isArray(e)||0===e.length||(s.has(e)&&i(`${$("cycle")} "${r}" is reachable from itself: the data under "${t.s}" must be a tree.`),n.has(e)&&i(`${$("shared-list")} "${r}" is the same array instance as a list reached before: the data under "${t.s}" must be a tree.`),l+1>128&&i(`${$("depth-exceeded")} Recursion on "${t.s}.*" reached depth ${l+1} (the limit is 128).`),n.add(e),0)),a=(n,i)=>{for(let o of n){r(i,o);let n=e.o(`${p(t,i)}.${t.key}`),c=e.read(n,o);l(c,n.t,i+1)&&(s.add(c),a(e.De(o,n).f,i+1),s.delete(c))}},o=e.o(t.s),c=e.read(o,null);l(c,t.s,0)&&(s.add(c),a(e.De(null,o).f,0))}function w(r,s){let n=function(t){let r=t[a],s=[],n=new Set;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e))!n.has(t)&&t.includes("**")&&s.push([t,Object.getOwnPropertyDescriptor(e,t)]),n.add(t);if(void 0===r)return s.length>0&&e(s[0][0]),null;(null===r||"object"!=typeof r||Array.isArray(r))&&i(`${$("declaration-invalid")} ${a} must be an object mapping one anchor path to its repeating sub-path.`);let l=Object.entries(r);1!==l.length&&i(`${$("declaration-invalid")} ${a} must declare exactly one anchor (it declares ${l.length}).`);let o=f("anchor",l[0][0]),c=f("repeat",l[0][1]),u=o.slice(0,-2),h=c.slice(0,-2),p=`.${c}`,g=new Map,m=[],y=`${u}.**`;for(let[e,t]of s){let r=e.slice(y.length);(!e.startsWith(y)||""!==r&&"."!==r[0]||r.includes("**"))&&i(`[wcs/recursion-anchor] "${e}": a recursive key is "${y}" followed by a path (the anchor is "${o}").`),(""===r||r.split(".").slice(1).some(e=>""===e))&&i(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&i(`${$("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),g.set(r,t.get),m.push([new RegExp(`^${d(o)}((?:${d(p)})*)${d(r)}$`),r])}return{s:u,step:p,key:h,families:g,matchers:m,owners:new Map,nodeList:new RegExp(`^${d(u)}((?:${d(`.*.${h}`)})*)$`)}}(s),l=o.has(r);null!==n?(l||h++,o.set(r,n),u.add(r),c.has(r)||function(r){c.add(r);let s=r,n=s.Ze;s.Ze=t=>{let l=o.get(r);if(t.t.includes("**")){let s=r.L.Ft(t.t)===t;return void(u.has(r)||void 0===l&&s?t.getter=()=>e(t.t):s||n.call(r,t))}if(void 0!==l&&null===t.getter)for(let[e,r]of l.matchers)if(e.test(t.t)){t.getter=l.families.get(r),t.n>0&&(t.A=s.Oe++),l.owners.set(t,l.s+".**"+r);break}n.call(r,t)};let l=s.resolve;s.resolve=(e,t)=>{let s=o.get(r);return l.call(r,void 0!==s&&e.includes("**")?m(s,e,t):e,t)};let a=s.getAll;s.getAll=(e,t)=>{let n=o.get(r);if(void 0===n||!e.includes("**"))return a.call(r,e,t);if(void 0===t)return a.call(r,m(n,e,s.h));(!Array.isArray(t)||t.length>0)&&i(`${$("getall-form")} $getAll("${e}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let l=g(n,e),c=[];return y(r,n,(e,t)=>{for(let s of a.call(r,p(n,e)+l,r.D(t)))c.push(s)}),c};let h=s.pn;s.pn=(e,n,l,a)=>{let c=o.get(r);if(void 0===c||!e.includes("**"))return h.call(r,e,n,l,a);Array.isArray(n)||t(9,[e]),n.length>0&&i(`${$("setall-form")} $setAll("${e}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof l||!0===a?.spread)&&i(`${$("setall-form")} $setAll("${e}", [], value) with "**" takes a plain value (no mapper, no spread).`),s.Ce>0&&t(8);let u=g(c,e),d=u.replace(/\.\d+(?=\.|$)/g,".*");for(;d.startsWith(c.step);)d=d.slice(c.step.length);let f=c.key.split(".");(""===d||d===`.${c.key}.length`||f.some((e,t)=>d===`.${f.slice(0,t+1).join(".")}`))&&i(`${$("structural-write")} "${e}" writes the recursion structure itself (a node, its "${c.key}" list or that list's length, or an object on the way to it).`);for(let t of c.families.keys()){let r=t;for(;r.startsWith(c.step);)r=r.slice(c.step.length);(d===r||d.startsWith(`${r}.`))&&i(`${$("readonly")} "${e}" writes into the recursive getter "${c.s}.**${t}".`)}let m=[];y(r,c,(e,t)=>m.push([e,t]));let w=0;for(let[e,t]of m)w+=h.call(r,p(c,e)+u,r.D(t),l);return w}}(r)):l&&(o.delete(r),h--)}function v(e,t){if(0===h)return!1;let r=o.get(e);if(void 0===r)return!1;for(let e=t;null!==e;e=e.w){let s=r.owners.get(e);void 0!==s&&i(`${$("readonly")} "${t.t}" writes into the recursive getter "${s}".`)}return!1}var k={name:"recursion",install(){r.ie=s(r.ie,w),r.element=s(r.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){u.delete(e)}(e)}),r.Re=n(l,r.Re,v)}},b=k;export{b as default,k as recursion};
1
+ import{m as e}from"../chunks/chunk-YZ4LWPXN.js";import{c as t}from"../chunks/chunk-NPPWJBGJ.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-Z3EEGBYA.js";var i="$recursion",o=new WeakMap,c=new WeakSet,u=new WeakSet,h=0,d=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=e=>`[wcs/recursion-${e}]`;function f(e,t){let r=r=>a(`${$("declaration-invalid")} ${i} ${e} "${String(t)}" ${r}`);("string"!=typeof t||""===t)&&a(`${$("declaration-invalid")} ${i} ${e} must be a non-empty string.`);let l=t.split(".");(l.length<2||"*"!==l[l.length-1])&&r('must end with ".*" (a list element).');for(let e=0;e<l.length-1;e++){let t=l[e];""===t&&r("must not contain empty path segments."),("*"===t||"**"===t||/^\d/.test(t))&&r('must have exactly one "*", at the end.'),t.includes("#")&&r('must not contain "#".')}return"$"===t[0]&&r('must not start with "$".'),t}var p=(e,t)=>`${e.l}.*${e.step.repeat(t)}`;function g(e,t){let r=`${e.l}.**`,l=t.slice(r.length);return(!t.startsWith(r)||""!==l&&"."!==l[0]||l.includes("**"))&&a(`[wcs/recursion-anchor] "${t}" does not start at the recursion anchor "${e.l}.*".`),l}function m(e,t,r){let l=g(e,t),n=function(e,t){for(let r=t;null!==r;r=r.l.re){let t=e.nodeList.exec(r.l.o.t);if(null!==t)return{k:t[1].length/(e.key.length+3),r}}return null}(e,r);return null===n&&a(`[wcs/recursion-context] "${t}" uses "**", which is bound to the depth of the row it is evaluated in; there is none here — use $getAll("${t}", []) for every depth.`),p(e,n.k)+l}function y(e,t,r){let l=new Set,n=new Set,s=(e,r,s)=>!(!Array.isArray(e)||0===e.length||(l.has(e)&&a(`${$("cycle")} "${r}" is reachable from itself: the data under "${t.l}" must be a tree.`),n.has(e)&&a(`${$("shared-list")} "${r}" is the same array instance as a list reached before: the data under "${t.l}" must be a tree.`),s+1>128&&a(`${$("depth-exceeded")} Recursion on "${t.l}.*" reached depth ${s+1} (the limit is 128).`),n.add(e),0)),i=(n,a)=>{for(let o of n){r(a,o);let n=e.o(`${p(t,a)}.${t.key}`),c=e.read(n,o);s(c,n.t,a+1)&&(l.add(c),i(e.Be(o,n).u,a+1),l.delete(c))}},o=e.o(t.l),c=e.read(o,null);s(c,t.l,0)&&(l.add(c),i(e.Be(null,o).u,0))}function w(r,l){let n=function(t){let r=t[i],l=[],n=new Set;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e))!n.has(t)&&t.includes("**")&&l.push([t,Object.getOwnPropertyDescriptor(e,t)]),n.add(t);if(void 0===r)return l.length>0&&e(l[0][0]),null;(null===r||"object"!=typeof r||Array.isArray(r))&&a(`${$("declaration-invalid")} ${i} must be an object mapping one anchor path to its repeating sub-path.`);let s=Object.entries(r);1!==s.length&&a(`${$("declaration-invalid")} ${i} must declare exactly one anchor (it declares ${s.length}).`);let o=f("anchor",s[0][0]),c=f("repeat",s[0][1]),u=o.slice(0,-2),h=c.slice(0,-2),p=`.${c}`,g=new Map,m=[],y=`${u}.**`;for(let[e,t]of l){let r=e.slice(y.length);(!e.startsWith(y)||""!==r&&"."!==r[0]||r.includes("**"))&&a(`[wcs/recursion-anchor] "${e}": a recursive key is "${y}" followed by a path (the anchor is "${o}").`),(""===r||r.split(".").slice(1).some(e=>""===e))&&a(`[wcs/recursion-anchor] "${e}" needs a path after "**".`),(void 0===t.get||void 0!==t.set)&&a(`${$("declaration-invalid")} "${e}": a recursive key is a getter without a setter.`),g.set(r,t.get),m.push([new RegExp(`^${d(o)}((?:${d(p)})*)${d(r)}$`),r])}return{l:u,step:p,key:h,families:g,matchers:m,owners:new Map,nodeList:new RegExp(`^${d(u)}((?:${d(`.*.${h}`)})*)$`)}}(l),s=o.has(r);null!==n?(s||h++,o.set(r,n),u.add(r),c.has(r)||function(r){c.add(r);let l=r,n=l.et;l.et=t=>{let s=o.get(r);if(t.t.includes("**")){let l=r.D.Ct(t.t)===t;return void(u.has(r)||void 0===s&&l?t.getter=()=>e(t.t):l||n.call(r,t))}if(void 0!==s&&null===t.getter)for(let[e,r]of s.matchers)if(e.test(t.t)){t.getter=s.families.get(r),t.n>0&&(t.F=l.Oe++),s.owners.set(t,s.l+".**"+r);break}n.call(r,t)};let s=l.resolve;l.resolve=(e,t)=>{let l=o.get(r);return s.call(r,void 0!==l&&e.includes("**")?m(l,e,t):e,t)};let i=l.getAll;l.getAll=(e,t)=>{let n=o.get(r);if(void 0===n||!e.includes("**"))return i.call(r,e,t);if(void 0===t)return i.call(r,m(n,e,l.c));(!Array.isArray(t)||t.length>0)&&a(`${$("getall-form")} $getAll("${e}", indexes) with "**" takes either no indexes (this depth) or [] (every depth).`);let s=g(n,e),c=[];return y(r,n,(e,t)=>{for(let l of i.call(r,p(n,e)+s,r._(t)))c.push(l)}),c};let h=l.pn;l.pn=(e,n,s,i)=>{let c=o.get(r);if(void 0===c||!e.includes("**"))return h.call(r,e,n,s,i);Array.isArray(n)||t(9,[e]),n.length>0&&a(`${$("setall-form")} $setAll("${e}", indexes, …) with "**" takes no partial prefix: pass [] to write every node.`),("function"==typeof s||!0===i?.spread)&&a(`${$("setall-form")} $setAll("${e}", [], value) with "**" takes a plain value (no mapper, no spread).`),l.Ce>0&&t(8);let u=g(c,e),d=u.replace(/\.\d+(?=\.|$)/g,".*");for(;d.startsWith(c.step);)d=d.slice(c.step.length);let f=c.key.split(".");(""===d||d===`.${c.key}.length`||f.some((e,t)=>d===`.${f.slice(0,t+1).join(".")}`))&&a(`${$("structural-write")} "${e}" writes the recursion structure itself (a node, its "${c.key}" list or that list's length, or an object on the way to it).`);for(let t of c.families.keys()){let r=t;for(;r.startsWith(c.step);)r=r.slice(c.step.length);(d===r||d.startsWith(`${r}.`))&&a(`${$("readonly")} "${e}" writes into the recursive getter "${c.l}.**${t}".`)}let m=[];y(r,c,(e,t)=>m.push([e,t]));let w=0;for(let[e,t]of m)w+=h.call(r,p(c,e)+u,r._(t),s);return w}}(r)):s&&(o.delete(r),h--)}function v(e,t){if(0===h)return!1;let r=o.get(e);if(void 0===r)return!1;for(let e=t;null!==e;e=e.d){let l=r.owners.get(e);void 0!==l&&a(`${$("readonly")} "${t.t}" writes into the recursive getter "${l}".`)}return!1}var k={name:"recursion",install(){r.se=l(r.se,w),r.element=l(r.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){u.delete(e)}(e)}),r.Pe=n(s,r.Pe,v)}},b=k;export{b as default,k as recursion};
@@ -1 +1 @@
1
- import{a as e,c as t}from"../chunks/chunk-PKDBVBAP.js";import{b as n,n as o,o as l}from"../chunks/chunk-7PN5YNZZ.js";import"../chunks/chunk-HFKGUDDJ.js";import{e as r,f as i}from"../chunks/chunk-UM3O6QXD.js";import{a}from"../chunks/chunk-732CB4QN.js";import"../chunks/chunk-QI7P7YPP.js";import"../chunks/chunk-QQH6N5CJ.js";import"../chunks/chunk-WWJNAZVP.js";import{a as s,b as u,c,d,f,h,j as p}from"../chunks/chunk-YOPPVWPQ.js";var m=new WeakMap,g=new WeakMap,$=new WeakMap,w="will not graft: the root state failed to initialize.",b=new WeakSet,y=new WeakMap,v=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],k=["$commandTokens","$eventTokens","$on","$errorCallback"],N=e=>`[@wcstack/state] <${a.tagNames.state} mount="${e}">`,j=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),O=e=>e?.element?.isConnected?e:void 0;function P(e){let t=$.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function C(e,t){m.set(t,e);let n=$.get(t);if($.delete(t),Array.isArray(n))for(let t of n)M(t,e)}function A(e,t){console.error(`${N(e.t)} ${t}`),function(e){let t=g.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}(e),e.Xe?.(),e.Xe=null}function x(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 M(e,t){if(b.has(t))return A(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 A(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)):j.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.zt(n,null)&&t.P(n,null,{})}t.P(t.o(e.t),null,a)}t.Gn(Object.defineProperties({},s));for(let e in s)t.Ee(t.o(e),null);e.engine=t;let c=y.get(t);void 0===c&&y.set(t,c=[]),c.push(e.t),e.el.isConnected&&x(e,"$connectedCallback"),e.Xe?.(),e.Xe=null}function S(e,t){let n=$.get(e);if(Array.isArray(n))for(let e of n)A(e,w);$.set(e,t)}var W=new WeakMap;function D(e,t){let n=e.getAttribute("mount");if(null===n)return null;let l={el:e,root:t,t:n,state:null,engine:null,chroot:null,Xe:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(a.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=g.get(t);void 0===e&&g.set(t,e=new Map);let o=e.get(n);if(void 0!==o&&o!==l&&(null===o.engine?o.el.isConnected:O(o.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===o?.engine){let e=$.get(t);Array.isArray(e)&&$.set(t,e.filter(e=>e!==o)),o.Xe?.(),o.Xe=null}e.set(n,l)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{vo:!0,start(e){if(null!==r)return A(l,r);if(g.get(t).get(n)===l){for(let t of v)if(void 0!==e[t])return A(l,`${t} is not run in a volume — declare it on the root state.`);for(let t of k)void 0!==e[t]&&console.warn(`${N(n)} ${t} is not run in a volume (it belongs to the root).`);return l.state=e,new Promise(e=>{l.Xe=e;let n=O(m.get(t))??O(o.get(t)),r=$.get(t);void 0!==n?M(l,n):P(t)?A(l,w):$.set(t,[...Array.isArray(r)?r:[],l])})}},qe(){null!==l.engine&&x(l,"$connectedCallback")},On(){null!==l.engine&&x(l,"$disconnectedCallback")},reset(){p(`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 Q=new WeakMap,E=new WeakMap;function R(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||p(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&p(`${t} entries must be non-empty strings.`),"$"===e[0]&&p(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&p(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function q(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")&&p("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||p(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&p(`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=R(o,"$bindables"),i=R(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&p(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&p(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&p(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&p(`$commands entry "${e}" is not a method: list it in $bindables.`)}let s={tag:e,bindables:r},u=new WeakMap,c=new WeakMap,d=o=>{if(u.has(o))return u.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(a.tagNames.state);return u.set(o,i),Q.set(o,s),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${a.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 m 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(m.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(m.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,m)}(n.localName,o,l,t)},qe(){},On(){},reset(){p("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var X=new WeakMap,z=new WeakSet,I=new WeakMap,Z=new WeakMap,B="data-wcs-wired",F=new WeakMap,J=new WeakMap,K=new WeakMap,T=0,Y=new Set,U={},V=["$watch","$stream","$renderedCallback"],G=e=>e.split(".",1)[0];function H(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function L(e,t){let n=e.a,o=G(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(B);else if(!ee(n,o)){let e=n.getAttribute(B)?.split(" ")??[];e.includes(o)||n.setAttribute(B,[...e,o].join(" "))}F.get(n)?.ce===o&&p(`<${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=X.get(n);void 0===l&&X.set(n,l=[]),l.push(e),t&&z.add(e);let r=I.get(n);return void 0===r&&I.set(n,r=new Map),r.has(o)||r.set(o,n[o]),Z.get(n)?.(),!1}function _(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${a.tagNames.state}[bind-component]`)}function ee(e,t){let n=e.getAttribute(a.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}var te=new Set;function ne(e,t){te.has(e)||(te.add(e),console.warn(`[@wcstack/state] ${t}`))}var oe=(e,t)=>t in e.state;function le(e,t){let n=re(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function re(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 ie(e,t,n){if(null!==n.getter)return;let o,l=e.host,i=l.engine,a=G(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.w)return function(e,t){let n,o=t.w;for(;null!==o&&void 0===(n=e.st.get(o));)o=o.w;if(null===o||void 0===n)return;let l=e.N,i=e.host.engine,a=i.o(n.p.t+t.t.slice(o.t.length));if(null===a.getter)return;let s=n,u=()=>{let n=ae(e,s.r);return 0===t.n?n:(i.resolve(H(a.t,[...i.D(n),...l.D(r(l.h,t.n))]),null),i.rr)};t.getter=()=>{let e=u();return a.n>0&&null===e?void 0:i.v(a,e)},null!==a.Z&&(t.Z=n=>{let o=u();se(e,s.e,()=>i.P(a,o,n)),e.an=t}),t.n>0&&(t.A=l.Oe++),e.st.set(t,{e:s.e,p:a,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==a?oe(l,a):le(l,a))return;o=s.ue}else{if(null===t||null!==n.w||"$"===a[0]||oe(l,a))return;s=t,o=i.o(`${t.ue.t}.${a}`)}let u=s.r,c=s;n.getter=()=>i.v(o,ae(e,u)),n.Z=t=>{se(e,c,()=>i.P(o,u,t)),e.an=n},e.st.set(n,{e:s,p:o,r:u})}function ae(e,t){return null!==t&&!t.d&&p(`The host row of <${e.host.el.localName}> was removed.`),t}function se(e,t,n){let o=Y.has(e.N);Y.add(e.N),e.from=t;try{n()}finally{o||Y.delete(e.N),e.from=null}}var ue=(e,t)=>t||!Y.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function ce(e,t){if(e.cn===t||null===e.host.engine)return;e.cn=t,T+=t?1:-1;let n=e.host.engine,o=K.get(n);void 0===o&&K.set(n,o=new Map);for(let n of e.se){let e=o.get(n.e.ue);void 0===e&&o.set(n.e.ue,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.Q&&function(e,t){let n=e.host,o=n.engine;e.Q=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=G(i);if(i!==s&&!oe(n,s))continue;let u=o.o(`${t.ue.t}.${i}`);if(null===u.getter)he(o,u,t.ue);else if(!de.has(u.getter))continue;e.Q.set(u,e.N.o(i))}}(e,l);for(let o of e.Q.keys())t&&null===o.getter&&he(n,o,l.ue),n.R.Ne(n,o,l.r);e.Q.size>0&&n.xe(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.Q){let r=n.v(o.w,t.r);if(null===r||"object"!=typeof r||!(o.l in r))continue;let i=e.host.el.localName;ne(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.ce}.${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 de=new WeakSet;function fe(e,t,n,o){let l=K.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.Q?.has(o)||e.m===r||(null!==r&&p(`[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 he(e,t,n){let o=t.w,l=t.l,r=()=>{let t=e.read(o,e.h);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=fe(e,n,e.h,t);return null===i?void 0:i.N.read(i.Q.get(t),null)},de.add(t.getter),t.Z=i=>{let a=null===r()?fe(e,n,e.h,t):null;if(null===a){let t=e.read(o,e.h);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.Q.get(t);void 0===re(a.host.state,s.t)?.set&&p(`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.P(s,null,i)},t.n>0&&(t.A=e.Oe++)}function pe(e,t,n,o,l,r){if(null!==t.getter)return e.R.Ne(e,t,n),void e.xe();if("*"===t.l){if(null===n)return;if(n.O=n.s.G[n.b],e.R.Vt(n),null!==n.u)for(let t of n.u.values())e.U(t)}else e.wn(t,n);s.pe?.(e,t,n,o,l,r),e.Ee(t,n)}function me(e){let t=e.m.N;for(let[n,o]of e.m.st)o.e===e.e&&(0===n.n?t.R.Ne(t,n,null):t.Jt(n.c[n.n],e=>t.R.Ne(t,n,e)));t.xe()}function ge(e,t,n,o,l,i,a){let s=n.t.slice(t.t.length);if(""===s)return me(e);let u,c=e.m,d=c.N;if(""===e.e.$){u=s.slice(1);let e=G(u);if("$"===e[0]||oe(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(r(o,e).b);d.resolve(H(u,f),null);let h=d.rp,p=d.rr;h.n>0&&null===p||pe(d,h,p,l,i,a)}function $e(e,t,n,o,l,i,a){if(0===T)return;let s=Y.has(e);Y.add(e);try{let s=J.get(e);!a&&void 0!==s&&s.cn&&!Y.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.st.get(a));)a=a.w;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.an===t)return void(e.an=null);if(null!==i.r&&!i.r.d)return;let u=[...s.D(i.r),...e.N.D(n)];s.resolve(H(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||se(e,i.e,()=>pe(s,c,d,o,l,r))}(s,t,n,o,l,i),a&&void 0!==s&&s.cn&&null!==s.Q&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.Q)r===t&&(o.R.Ne(o,l,n.r),o.xe())}(s,t);let u=K.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.Y(e)){let u=s.get(0===e.n?null:r(n,e.n));if(void 0!==u)for(let r of[...u])ue(r,a)&&ge(r,e,t,n,o,l,i)}else if(e.Y(t))for(let[e,o]of[...s])if(0===t.n||r(e,t.n)===n)for(let e of[...o])ue(e,a)&&me(e)}finally{s||Y.delete(e)}}async function we(e,t){ce(e,!0);for(let t of e.se)me(t);t?.(),!e.broken&&(await e.N.ae("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&s.element?.(e.N,"connected"))}function be(r,u){let c=r.getAttribute("bind-component");if(null===c)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=o.get(t)?.element;if(!(e.K||void 0!==n&&n!==e&&n.isConnected)){S(t,e);for(let e of W.get(t)??[])e()}}),null}(r,u);let d=r.parentNode,f=d instanceof ShadowRoot,m=f?d.host:d instanceof Element?d:null,g=()=>{let e=null===m?void 0:F.get(m)?.F;return e?.el===r?e:null},$=e=>{throw f&&S(d,r),e};return{dt:()=>(null!==m&&m.localName.includes("-")?async function(e,t,o,l){let r=o.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&p(`<${a.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await n(o).whenDefined(r);let i=F.get(o);if(void 0!==i)return i.ce!==t&&p(`<${r}> already has a <${a.tagNames.state} bind-component="${i.ce}">.`),i.state;let s=()=>(X.get(o)??[]).filter(e=>G(e.name)===t);if(0===s().length&&(ee(o,t)||((e,t)=>!0===e.getAttribute(B)?.split(" ").includes(t))(o,t))){let e;await new Promise((n,l)=>{Z.set(o,n),e=function(e,t){P(e)&&t();let n=W.get(e)??new Set;return W.set(e,n.add(t)),()=>n.delete(t)}(o.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}Z.delete(o);let u=s(),c=I.get(o),d=void 0!==c&&c.has(t)?c.get(t):o[t];if((null===d||"object"!=typeof d)&&p(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===d?"null":typeof d}.`),0===u.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 (${a.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),U}let f=[];for(let e of u){let n=e.name===t?"":e.name.slice(t.length+1);f.some(e=>e.$===n)&&p(`<${r}> maps "${e.name}" twice.`);let l=n.split(".").indexOf("*");if(l>=0){let o=n.split(".").slice(0,l).join(".");p(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===o?"":` — map the list itself ("${t}.${o}: <the host's list>")`}.`)}f.push({$:n,ue:e.o,r:e.r,ro:z.has(e)}),e.engine.kn(e),""!==n&&delete o[e.name]}let h=0===u.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}(d):d;return F.set(o,i={el:o,ce:t,state:h,engine:0===u.length?null:u[0].engine,entries:f,F:null}),h}(r,c,m,!f):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${a.tagNames.state}> to be a direct child of a custom element.`))).catch($),async start(n,o){let u=!1;await async function(n,o,r,u,c){if(u===U)return;let d=h(u);d&&await d;let f=F.get(o);f.engine&&u.$recursion&&p(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let m=f.F;if(null!==m&&m.el!==n&&m.el.isConnected&&p(`<${o.localName}> already has a connected <${a.tagNames.state} bind-component="${f.ce}">.`),null!==m&&ce(m,!1),null!==m&&function(e,t,n){let o=e.N,l=`[${a.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,s=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},u=(e,t)=>{for(let n=e.Pn(t);null!==n&&n!==t;n=n.nextSibling)s(n);s(t)};for(let e of o.re.values())for(let t of e)if(null===t.B)s(t.a);else for(let e of t.B.q)u(t.B,e.S);for(let e of o.oe.values())for(let t of[e.E,...e.j??[]])null!==t&&u(t,t.S);for(let t of e.I)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.I.includes(n)&&(r(n)||o.It&&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}(m,n,r))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.N.element=t,t.engine=e.N,e.I=e.I.filter(e=>e.parentNode===n),t.isConnected?await we(e,o):o()}(m,n,r,c);let g=new i(u,new t);g.element=n,n.engine=g,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.K=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(g,u);let $={el:n,I:[],N:g,host:f,se:[],st:new Map,cn:!1,an:null,from:null,Q:null};for(let e of f.entries)$.se.push({m:$,e});f.F=$,J.set(g,$);let w=null===f.engine;w?s.element?.(g,"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=G(e.$);oe(n,t)&&(e.$!==t||le(n,t))&&ne(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.ce}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.ue,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.$===t)&&ne(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.ue.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=V.filter(e=>void 0!==n.state[e]);i.length>0&&ne(`${l}.${n.ce}$`,`[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.Ze;t.Ze=n=>{ie(e,r,n),a.call(t,n)};let s=[...t.L.all()];for(let t of s)ie(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._t;t._t=()=>{u.every(e=>e.r.d)&&e.call(t)}}}($),ce($,!0),b.add(g),C(g,r));let y=s.ir?.(r);l(g,r),y?.(),$.I=[...r.childNodes],e(),w&&g.bn(),Object.defineProperty(o,f.ce,{configurable:!0,enumerable:!0,get:()=>g.proxy});let v=o.$stateReadyCallback;if("function"==typeof v)try{let e=v.call(o,f.ce);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,e=>console.error(e))}catch(e){console.error(e)}c(),n.isConnected?(await g.ae("$connectedCallback"),w&&n.isConnected&&s.element?.(g,"connected")):ce($,!1)}(r,m,f?d:m,n,()=>{u=!0,o()}).catch(e=>{let t=g();return!u&&null!==t&&(t.broken=!0),$(e)})},qe(){let e=g();null!==e&&we(e).catch(e=>console.error(e))},On(){let e=g();null!==e&&(ce(e,!1),!e.broken&&(e.N.ae("$disconnectedCallback"),null===e.host.engine&&s.element?.(e.N,"disconnected")))},reset(){p(`re-setting a component's state is not supported: write <${m?.localName}>.${c} instead.`)}}}var ye={name:"scopes",install(){s.ot=c(f,s.ot,D),s.ot=c(f,s.ot,q),s.ot=c(f,s.ot,be),s.Jo=L,s.wo=_,s.element=u(s.element,(e,t)=>{if("mounting"!==t)return;let n=e.element.getRootNode();C(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:Q.get(n);void 0!==o&&E.set(e,{host:n,def:o})}(e,n)}),s.pe=u(s.pe,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=E.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),$e(e,t,n,o,l,r,!1)}),s.me=u(s.me,(e,t,n)=>$e(e,t,n,void 0,void 0,!1,!0)),s.Re=c(d,s.Re,(e,t,n,o,l)=>(function(e,t){let n=y.get(e);if(void 0!==n&&0===t.n)for(let e of n)e.startsWith(`${t.t}.`)&&p(`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=J.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.w)o=l.st.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.d)&&!r.ro)&&(!!n||(ae(l,r.r),void p(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.ce}${""===r.$?"":`.${r.$}`}#ro: ${r.ue.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=s.ie;s.ie=(t,n)=>{let o=y.get(t);void 0!==o&&o.length>0&&p(`re-setting a root state with grafted volumes (${o.join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=K.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&p("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},ve=ye;export{ve as default,ye as scopes};
1
+ import{a as e,b as t,d as n}from"../chunks/chunk-FED2DM4X.js";import{b as o,n as l,o as r,p as i}from"../chunks/chunk-5PWMZ75N.js";import"../chunks/chunk-2PWEFKRB.js";import{e as a,f as s}from"../chunks/chunk-WPSUT5QQ.js";import{a as u}from"../chunks/chunk-YZUTVCIH.js";import"../chunks/chunk-I2V4DGEI.js";import"../chunks/chunk-YZ4LWPXN.js";import"../chunks/chunk-NPPWJBGJ.js";import{a as c,b as d,c as f,d as h,f as m,h as p,j as g}from"../chunks/chunk-Z3EEGBYA.js";var $=new WeakMap,b=new WeakMap,y="will not graft: the root state failed to initialize.",w=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"]),P=e=>e?.element?.isConnected?e:void 0;function C(e){let t=b.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function A(e,t){let n=b.get(t);if(b.delete(t),Array.isArray(n))for(let t of n)S(t,e)}function M(e){let t=$.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function W(e,t){console.error(`${j(e.t)} ${t}`),M(e),e.Ge?.(),e.Ge=null}function x(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 S(e,t){if(w.has(t))return W(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 W(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.wt(n,null)&&t.P(n,null,{})}t.P(t.o(e.t),null,a)}t.Xn(Object.defineProperties({},s));for(let e in s)t.We(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&&x(e,"$connectedCallback"),e.Ge?.(),e.Ge=null}function E(e,t){let n=b.get(e);if(Array.isArray(n))for(let e of n)W(e,y);b.set(e,t)}var R=new WeakMap;function D(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,Ge: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:P(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.Ge?.(),l.Ge=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{vo:!0,start(e){if(null!==r)return W(o,r);if($.get(t).get(n)===o){for(let t of k)if(void 0!==e[t])return W(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.Ge=e;let n=P(l.get(t)),r=b.get(t);void 0!==n?S(o,n):C(t)?W(o,y):b.set(t,[...Array.isArray(r)?r:[],o])})}},Ye(){null!==o.engine&&x(o,"$connectedCallback")},On(){null!==o.engine&&x(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 G=new WeakMap,q=new WeakMap;function z(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 T(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=z(o,"$bindables"),i=z(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),G.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 m 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(m.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(m.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,m)}(n.localName,o,l,t)},Ye(){},On(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var Y=new WeakMap,F=new WeakSet,L=new WeakMap,X=new WeakMap,Z="data-wcs-wired",B=new WeakMap,I=new WeakMap,K=new WeakMap,Q=0,U=new Set,_={},J=["$watch","$stream","$renderedCallback"],H=e=>e.split(".",1)[0];function V(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=H(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(Z);else if(!ne(n,o)){let e=n.getAttribute(Z)?.split(" ")??[];e.includes(o)||n.setAttribute(Z,[...e,o].join(" "))}B.get(n)?.ce===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=Y.get(n);void 0===l&&Y.set(n,l=[]),l.push(e),t&&F.add(e);let r=L.get(n);return void 0===r&&L.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.W: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=H(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.at.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(V(i.t,[...r._(n),...l._(a(l.c,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.oe&&(t.oe=n=>{let o=u();de(e,s.e,()=>r.P(i,o,n)),e.cn=t}),t.n>0&&(t.F=l.Oe++),e.at.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.ue}else{if(null===t||null!==n.d||"$"===i[0]||ie(l,i))return;s=t,o=r.o(`${t.ue.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,ce(e,u)),n.oe=t=>{de(e,c,()=>r.P(o,u,t)),e.cn=n},e.at.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=U.has(e.N);U.add(e.N),e.from=t;try{n()}finally{o||U.delete(e.N),e.from=null}}var fe=(e,t)=>t||!U.has(e.m.N)||null!==e.m.from&&e.m.from!==e.e;function he(e,t){if(e.un===t||null===e.host.engine)return;e.un=t,Q+=t?1:-1;let n=e.host.engine,o=K.get(n);void 0===o&&K.set(n,o=new Map);for(let n of e.ae){let e=o.get(n.e.ue);void 0===e&&o.set(n.e.ue,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.te&&function(e,t){let n=e.host,o=n.engine;e.te=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=H(i);if(i!==s&&!ie(n,s))continue;let u=o.o(`${t.ue.t}.${i}`);if(null===u.getter)ge(o,u,t.ue);else if(!me.has(u.getter))continue;e.te.set(u,e.N.o(i))}}(e,l);for(let o of e.te.keys())t&&null===o.getter&&ge(n,o,l.ue),n.R.me(n,o,l.r);e.te.size>0&&n.Re(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.te){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.ce}.${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 me=new WeakSet;function pe(e,t,n,o){let l=K.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.te?.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.c);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=pe(e,n,e.c,t);return null===i?void 0:i.N.read(i.te.get(t),null)},me.add(t.getter),t.oe=i=>{let a=null===r()?pe(e,n,e.c,t):null;if(null===a){let t=e.read(o,e.c);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.te.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.P(s,null,i)},t.n>0&&(t.F=e.Oe++)}function $e(e,t,n,o,l,r){if(null!==t.getter)return e.R.me(e,t,n),void e.Re();if("*"===t.s){if(null===n)return;if(n.T=n.l.C[n.b],e.R.Ut(n),null!==n.h)for(let t of n.h.values())e.z(t)}else e.wn(t,n);c.he?.(e,t,n,o,l,r),e.We(t,n)}function be(e){let t=e.m.N;for(let[n,o]of e.m.at)o.e===e.e&&(0===n.n?t.R.me(t,n,null):t.Zt(n.f[n.n],e=>t.R.me(t,n,e)));t.Re()}function ye(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=H(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(V(u,f),null);let h=d.rp,m=d.rr;h.n>0&&null===m||$e(d,h,m,l,r,i)}function we(e,t,n,o,l,r,i){if(0===Q)return;let s=U.has(e);U.add(e);try{let s=I.get(e);!i&&void 0!==s&&s.un&&!U.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.at.get(a));)a=a.d;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.cn===t)return void(e.cn=null);if(null!==i.r&&!i.r.y)return;let u=[...s._(i.r),...e.N._(n)];s.resolve(V(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.un&&null!==s.te&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.te)r===t&&(o.R.me(o,l,n.r),o.Re())}(s,t);let u=K.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.Q(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)&&ye(a,e,t,n,o,l,r)}else if(e.Q(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||U.delete(e)}}async function ve(e,o,l,i,a){if(i===_)return;let d=p(i);d&&await d;let f=B.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.ce}">.`),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.Pn(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ie.values())for(let t of e)if(null===t.M)a(t.a);else for(let e of t.M.Y)s(t.M,e.S);for(let e of o.ee.values())for(let t of[e.E,...e.L??[]])null!==t&&s(t,t.S);for(let t of e.j)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.j.includes(n)&&(r(n)||o.Lt&&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.j=e.j.filter(e=>e.parentNode===n),t.isConnected?await ke(e,o):o()}(h,e,l,a);let m=new s(i,new n);m.element=e,e.engine=m,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.W=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(m,i);let $={el:e,j:[],N:m,host:f,ae:[],at:new Map,un:!1,cn:null,from:null,te:null};for(let e of f.entries)$.ae.push({m:$,e});f.O=$,I.set(m,$);let b=null===f.engine;b?c.element?.(m,"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=H(e.$);ie(n,t)&&(e.$!==t||ae(n,t))&&re(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.ce}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.ue,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.$===t)&&re(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.ue.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=J.filter(e=>void 0!==n.state[e]);i.length>0&&re(`${l}.${n.ce}$`,`[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.et;t.et=n=>{ue(e,r,n),a.call(t,n)};let s=[...t.D.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.Kt;t.Kt=()=>{u.every(e=>e.r.y)&&e.call(t)}}}($),he($,!0),w.add(m),A(m,l));let y=c.ir?.(l);r(m,l),y?.(),$.j=[...l.childNodes],t(),b&&m.bn(),Object.defineProperty(o,f.ce,{configurable:!0,enumerable:!0,get:()=>m.proxy});let v=o.$stateReadyCallback;if("function"==typeof v)try{let e=v.call(o,f.ce);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 m.we("$connectedCallback"),b&&e.isConnected&&c.element?.(m,"connected")):he($,!1)}async function ke(e,t){he(e,!0);for(let t of e.ae)be(t);t?.(),!e.broken&&(await e.N.we("$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.W||void 0!==n&&n!==e&&n.isConnected)){E(t,e);for(let e of R.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:B.get(a)?.O;return t?.el===e?t:null},d=t=>{throw i&&E(r,e),t},f=!1;return{ft:()=>(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=B.get(n);if(void 0!==i)return i.ce!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.ce}">.`),i.state;let a=()=>(Y.get(n)??[]).filter(e=>H(e.name)===t),s=ne(n,t);if(s&&0===a().length&&oe(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(Z)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{X.set(n,o),e=function(e,t){C(e)&&t();let n=R.get(e)??new Set;return R.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=L.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}),_}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,ue:e.o,r:e.r,ro:F.has(e)}),e.engine.kn(e),""!==o&&delete n[e.name]}let m=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 B.set(n,i={el:n,ce:t,state:m,engine:0===c.length?null:c[0].engine,entries:h,O:null}),m}(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)})},Ye(){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,B.get(a).state,()=>{})}).catch(e=>console.error(e)):X.has(a)&&oe(a)},On(){let e=s();null!==e&&(he(e,!1),!e.broken&&(e.N.we("$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.rt=f(m,c.rt,D),c.rt=f(m,c.rt,T),c.rt=f(m,c.rt,Ne),c.Jo=ee,c.yo=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&&P(l.get(e.root))===e){A(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();A(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:G.get(n);void 0!==o&&q.set(e,{host:n,def:o})}(e,n)}),c.he=d(c.he,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=q.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),we(e,t,n,o,l,r,!1)}),c.ye=d(c.ye,(e,t,n)=>we(e,t,n,void 0,void 0,!1,!0)),c.Pe=f(h,c.Pe,(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=I.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.d)o=l.at.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.ce}${""===r.$?"":`.${r.$}`}#ro: ${r.ue.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.se;c.se=(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=K.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};