@wcstack/state 4.0.0-rc.4 → 4.0.0-rc.5

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 (34) hide show
  1. package/README.ja.md +68 -9
  2. package/README.md +69 -10
  3. package/dist/auto.min.js +1 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.esm.js +1 -1
  6. package/dist/manifest.d.ts +2 -0
  7. package/dist/manifest.esm.js +15 -2
  8. package/dist/parser.esm.js +3 -1
  9. package/dist/split/auto.js +1 -1
  10. package/dist/split/chunks/{chunk-SEPY6OHJ.js → chunk-5MLEMVL3.js} +1 -1
  11. package/dist/split/chunks/{chunk-5LIOXC7W.js → chunk-ACYOJ3NW.js} +1 -1
  12. package/dist/split/chunks/{chunk-HSOCDTWX.js → chunk-C3UYMJRT.js} +1 -1
  13. package/dist/split/chunks/{chunk-372Y2FIC.js → chunk-COJU24UI.js} +1 -1
  14. package/dist/split/chunks/{chunk-7644KQ3T.js → chunk-FVHQWDF4.js} +1 -1
  15. package/dist/split/chunks/{chunk-ROX5KEJX.js → chunk-FZJY4CF3.js} +1 -1
  16. package/dist/split/chunks/chunk-HSMALJSW.js +1 -0
  17. package/dist/split/chunks/{chunk-6GES2BK3.js → chunk-L2BZD5DU.js} +1 -1
  18. package/dist/split/chunks/chunk-VY2XLPFM.js +1 -0
  19. package/dist/split/core.js +1 -1
  20. package/dist/split/features/devtools.js +1 -1
  21. package/dist/split/features/diagnostics.js +1 -1
  22. package/dist/split/features/formats.js +1 -1
  23. package/dist/split/features/list-keys.js +1 -1
  24. package/dist/split/features/native-commands.d.ts +31 -0
  25. package/dist/split/features/native-commands.js +1 -0
  26. package/dist/split/features/recursion.js +1 -1
  27. package/dist/split/features/scopes.js +1 -1
  28. package/dist/split/features/ssr.js +1 -1
  29. package/dist/split/features/temporal.js +1 -1
  30. package/dist/wcs-manifest.json +56 -2
  31. package/package.json +1 -1
  32. package/dist/split/chunks/chunk-Z7B3ZZE4.js +0 -1
  33. package/dist/split/chunks/chunk-ZOINIOIM.js +0 -1
  34. /package/dist/split/chunks/{chunk-G2ZO6SXV.js → chunk-SA2LYPN7.js} +0 -0
@@ -96,6 +96,8 @@ interface IWcsManifest {
96
96
  }>>;
97
97
  /** The add-on names `$features` and the root `<wcs-state features>` take (4.0). */
98
98
  features: readonly string[];
99
+ /** What a native element's `command.<method>:` may call, by tag; `*` is every element's (4.0, the native-commands add-on). */
100
+ nativeCommands: Readonly<Record<string, readonly string[]>>;
99
101
  }
100
102
  declare function getWcsManifest(): IWcsManifest;
101
103
 
@@ -27,7 +27,19 @@ var config = {
27
27
  };
28
28
 
29
29
  // src/load.ts
30
- var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools"];
30
+ var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands"];
31
+
32
+ // src/native/commands.ts
33
+ var NATIVE_COMMANDS = {
34
+ "*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
35
+ "dialog": ["show", "showModal", "close", "requestClose"],
36
+ "form": ["requestSubmit", "checkValidity", "reportValidity"],
37
+ "input": ["select", "setSelectionRange", "showPicker", "setCustomValidity", "checkValidity", "reportValidity"],
38
+ "textarea": ["select", "setSelectionRange", "setCustomValidity", "checkValidity", "reportValidity"],
39
+ "select": ["showPicker", "setCustomValidity", "checkValidity", "reportValidity"],
40
+ "audio": ["play", "pause", "load"],
41
+ "video": ["play", "pause", "load"]
42
+ };
31
43
 
32
44
  // src/pattern.ts
33
45
  var WILDCARD = "*";
@@ -557,7 +569,8 @@ function getWcsManifest() {
557
569
  ],
558
570
  // every option is a boolean, true when left out (engine.ts `loadTarget`: `typeof … === "boolean"`, `?? true`)
559
571
  behaviorOptions: Object.fromEntries(BEHAVIOR_OPTION_KEYS.map((key) => [key, { type: "boolean", default: true }])),
560
- features: [...FEATURE_NAMES]
572
+ features: [...FEATURE_NAMES],
573
+ nativeCommands: Object.fromEntries(Object.entries(NATIVE_COMMANDS).map(([tag, methods]) => [tag, [...methods]]))
561
574
  };
562
575
  }
563
576
  export {
@@ -415,9 +415,11 @@ var SENTENCES = {
415
415
  [1001 /* IndexParamRange */]: (key) => `"${key}": list index parameters run from $1 to $${MAX_INDEX_PARAM}.`,
416
416
  [1101 /* RecursionUnsupported */]: (p) => `"${p}" uses "${RECURSION_WILDCARD}", which is not accepted here.`,
417
417
  [1201 /* CommandRightSide */]: (prop, p) => `"${prop}: ${p}": the right-hand side must be $command.<name>`,
418
- [1202 /* NoBindable */]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).`,
418
+ // a native element's command (no hyphen: never a custom element) is the native-commands add-on's
419
+ [1202 /* NoBindable */]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${!tag.includes("-") && what.startsWith("command.") ? " A native element's command needs the add-on @wcstack/state/features/native-commands." : ""}`,
419
420
  [1203 /* NoCommand */]: (tag, method) => `<${tag}> declares no command "${method}".`,
420
421
  [1204 /* NoProperty */]: (tag, prop) => `<${tag}> declares no property "${prop}".`,
422
+ [1205 /* NativeNoCommand */]: (tag, method, allowed) => `<${tag}> has no command "${method}" (a native <${tag}>'s commands: ${allowed}).`,
421
423
  [1301 /* EventTokenUndeclared */]: (name) => `eventToken "${name}" is not declared in $eventTokens.`,
422
424
  [1302 /* CommandTokenUndeclared */]: (name) => `"$command.${name}" is not declared in $commandTokens.`,
423
425
  [1401 /* WildcardNoLoop */]: (p, depth, n = 0) => `"${p}" needs ${depth} enclosing loop level(s); the scope provides ${n}.`,
@@ -1 +1 @@
1
- import{d as t}from"./chunks/chunk-7644KQ3T.js";import"./chunks/chunk-6GES2BK3.js";import"./chunks/chunk-Z7B3ZZE4.js";import"./chunks/chunk-SEPY6OHJ.js";import"./chunks/chunk-372Y2FIC.js";import{a as n}from"./chunks/chunk-HSOCDTWX.js";import"./chunks/chunk-5D34CGCF.js";import"./chunks/chunk-5LIOXC7W.js";import"./chunks/chunk-ROX5KEJX.js";import{a as s,g as o}from"./chunks/chunk-G2ZO6SXV.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.pt=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-FVHQWDF4.js";import"./chunks/chunk-L2BZD5DU.js";import"./chunks/chunk-HSMALJSW.js";import"./chunks/chunk-5MLEMVL3.js";import"./chunks/chunk-COJU24UI.js";import{a as n}from"./chunks/chunk-C3UYMJRT.js";import"./chunks/chunk-5D34CGCF.js";import"./chunks/chunk-ACYOJ3NW.js";import"./chunks/chunk-FZJY4CF3.js";import{a as s,g as o}from"./chunks/chunk-SA2LYPN7.js";var e,r=["formats","diagnostics","temporal","list-keys","scopes","recursion","ssr","devtools","native-commands"],a=(e=import.meta.url,t=>Promise.all(t.map(async t=>{if(!r.includes(t))throw new Error(`[@wcstack/state] [wcs/feature-unknown] "${t}" is not an add-on (${r.join(", ")}).`);return(await(import(new URL(`./features/${t}.js`,e).href))).default})));s.pt=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var c=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(c?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
@@ -1 +1 @@
1
- import{e as t}from"./chunk-HSOCDTWX.js";import{b as r}from"./chunk-ROX5KEJX.js";function n(t){r(26,[t])}function e(t){r(27,[t])}function o(t){r(28,[t])}function a(t){r(29,[t])}function f(t){r(30,[t])}function u(t){return!(!t||isNaN(Number(t)))}function i(t,r){return u(t)||e(r),Number(t)}function y(t,r,e){return i(t?.[r]??n(e),e)}function c(t,r){return void 0!==r&&r.length>0?r[0]:t}var s=(t,r)=>({factory:n=>{let e=y(n,0,t);return n=>("number"!=typeof n&&o(t),r(n,e))},arity:[1,1]}),m={eq:{factory:(t,r)=>{let o=t?.[0]??n("eq"),a=c(o,r);return t=>"number"==typeof t?"string"!=typeof a?t===a:(u(o)||e("eq"),t===Number(o)):"string"==typeof t?t===o:t===a},arity:[1,1]},ne:{factory:(t,r)=>{let o=t?.[0]??n("ne"),a=c(o,r);return t=>"number"==typeof t?"string"!=typeof a?t!==a:(u(o)||e("ne"),t!==Number(o)):"string"==typeof t?t!==o:t!==a},arity:[1,1]},not:{factory:()=>t=>!t,arity:[0,0]},lt:s("lt",(t,r)=>t<r),le:s("le",(t,r)=>t<=r),gt:s("gt",(t,r)=>t>r),ge:s("ge",(t,r)=>t>=r),falsy:{factory:()=>t=>!t,arity:[0,0]},truthy:{factory:()=>t=>!!t,arity:[0,0]},boolean:{factory:()=>t=>!!t,arity:[0,0]}},b=!1;function g(){b||(b=!0,t(m))}export{n as a,o as b,a as c,f as d,i as e,y as f,c as g,s as h,m as i,g as j};
1
+ import{e as t}from"./chunk-C3UYMJRT.js";import{b as r}from"./chunk-FZJY4CF3.js";function n(t){r(26,[t])}function e(t){r(27,[t])}function o(t){r(28,[t])}function a(t){r(29,[t])}function f(t){r(30,[t])}function u(t){return!(!t||isNaN(Number(t)))}function i(t,r){return u(t)||e(r),Number(t)}function y(t,r,e){return i(t?.[r]??n(e),e)}function c(t,r){return void 0!==r&&r.length>0?r[0]:t}var s=(t,r)=>({factory:n=>{let e=y(n,0,t);return n=>("number"!=typeof n&&o(t),r(n,e))},arity:[1,1]}),m={eq:{factory:(t,r)=>{let o=t?.[0]??n("eq"),a=c(o,r);return t=>"number"==typeof t?"string"!=typeof a?t===a:(u(o)||e("eq"),t===Number(o)):"string"==typeof t?t===o:t===a},arity:[1,1]},ne:{factory:(t,r)=>{let o=t?.[0]??n("ne"),a=c(o,r);return t=>"number"==typeof t?"string"!=typeof a?t!==a:(u(o)||e("ne"),t!==Number(o)):"string"==typeof t?t!==o:t!==a},arity:[1,1]},not:{factory:()=>t=>!t,arity:[0,0]},lt:s("lt",(t,r)=>t<r),le:s("le",(t,r)=>t<=r),gt:s("gt",(t,r)=>t>r),ge:s("ge",(t,r)=>t>=r),falsy:{factory:()=>t=>!t,arity:[0,0]},truthy:{factory:()=>t=>!!t,arity:[0,0]},boolean:{factory:()=>t=>!!t,arity:[0,0]}},b=!1;function g(){b||(b=!0,t(m))}export{n as a,o as b,a as c,f as d,i as e,y as f,c as g,s as h,m as i,g as j};
@@ -1 +1 @@
1
- import{b as t}from"./chunk-ROX5KEJX.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?{Ln:i,args:[],literals:[]}:{Ln: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
+ import{b as t}from"./chunk-FZJY4CF3.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?{Ln:i,args:[],literals:[]}:{Ln: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{b as t}from"./chunk-ROX5KEJX.js";import{j as e}from"./chunk-G2ZO6SXV.js";var a={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 r(e){let r=a,s=a.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,a]of n){let s=r[e];(!Object.hasOwn(r,e)||null===a||typeof a!=typeof s||Array.isArray(a)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,a]of o)(!Object.hasOwn(s,e)||"string"!=typeof a)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(r[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>a,n=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],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(a,r,s){let f=`${a}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(r,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(a);void 0===c&&function(a,r){n.includes(a)&&e(`[wcs/filter-unknown] filter not found: ${a}. "${a}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,a,r),t(501,[a],a,r)}(a,o.keys());let[m,u]=c.arity;r.length<m&&t(601,[a,m,r.length]),r.length>u&&t(602,[a,u,r.length]);let d=c.factory(r,s);return i.set(f,d),d}export{a,r as b,s as c,n as d,f as e,l as f,c as g};
1
+ import{b as t}from"./chunk-FZJY4CF3.js";import{j as e}from"./chunk-SA2LYPN7.js";var a={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 r(e){let r=a,s=a.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,a]of n){let s=r[e];(!Object.hasOwn(r,e)||null===a||typeof a!=typeof s||Array.isArray(a)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,a]of o)(!Object.hasOwn(s,e)||"string"!=typeof a)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(r[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>a,n=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],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(a,r,s){let f=`${a}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(r,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(a);void 0===c&&function(a,r){n.includes(a)&&e(`[wcs/filter-unknown] filter not found: ${a}. "${a}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,a,r),t(501,[a],a,r)}(a,o.keys());let[m,u]=c.arity;r.length<m&&t(601,[a,m,r.length]),r.length>u&&t(602,[a,u,r.length]);let d=c.factory(r,s);return i.set(f,d),d}export{a,r as b,s as c,n as d,f as e,l as f,c as g};
@@ -1 +1 @@
1
- import{b as t,d as e,e as i}from"./chunk-5D34CGCF.js";import{h as s,m as l}from"./chunk-5LIOXC7W.js";import{a as n,b as r}from"./chunk-ROX5KEJX.js";import{a as h,i as o}from"./chunk-G2ZO6SXV.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.dt=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.D=null,this.Z=!1,this.jt=!1,this.ft=!1,this.o=t,this.re=e,this.n=t.n+1}},y=[],v=class{constructor(t){this.mt=new Set,this.name=t}get size(){return this.mt.size}subscribe(t){return this.mt.add(t),()=>{this.mt.delete(t)}}unsubscribe(t){return this.mt.delete(t)}emit(...t){let e=[];for(let i of this.mt)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=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],j=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function M(t){return t.includes("**")&&l(t),t}var A=0,C=32,T=100;function O(t,e,i){let s=t.get(e);return void 0===s&&t.set(e,s=i()),s}var q=()=>new Set,D=()=>[];function S(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function L(t,e){return t===e||t!=t&&e!=e}function x(t,e,i){let s=t.U?.get(e);void 0!==s&&s.delete(i)&&0===s.size&&t.U.delete(e)}function R(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 Z(t,e,i){let s=_(t,i);return null!==s&&s.l.o===e.f[i]?s:null}var z=class{constructor(t,i){this.Oe=0,this.c=null,this.Ce=0,this.ht=new Set,this.Ze=new Map,this.Bn=Symbol("wcs.block"),this.element=null,this.yt=[],this.Ie=null,this.Mn=[],this.Wt=0,this.q=null,this.ee=new Map,this.ie=new Map,this.je=[],this.De=[],this.Le=[],this.wt=!1,this.dn=!1,this._t=new WeakMap,this.M=0,this.Vt=0,this.fn=!1,this.Ht=!1,this.Kt=!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.Ut(),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.At??(l.At=[])).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(M(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=M(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(M(t),this.c);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.T=i.l.C[i.b],this.R.qt(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.zt(e,i,void 0,void 0,!1)}},this.R=i,this.L=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.tt(e);if(e.indexOf(".")<0){let t=s.L.It(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(M(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.L.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.L.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.Dt(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.Dt(e);else i.Dt(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=O(this._t,e,D);if(i.push(t),i.length>1)for(let t of i)t.ft=!0}h.Xt?.(this,t,i),(null!==t.E||null!==t.D)&&!t.Z&&(t.Z=!0,this.De.push(t),this.Re());let s=t.o.At;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.Do(this,t)}Dt(t){t.y=!1;let e=t.U;if(null!==e){for(let t of e)x(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.Dt(t)}}Jn(t){let e=this._t.get(t.C);void 0!==e&&(e.splice(e.indexOf(t)>>>0,1),t.ft=!1,1===e.length&&(e[0].ft=!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?Z(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=Z(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}bt(t,e){return 0===t.n?R(this.target,t.K):null===e?void 0:R(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.Lo(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.ht.has(t.s)&&"then"!==t.s&&"toJSON"!==t.s&&r(301,[t.t],t.s,Object.keys(this.target)),this.bt(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.ut??(s.ut=new Set)).add(t)}Bo(t,e){for(let i=0;i<this.Wt;i++){let s=this.Mn[i];s.getter===t&&s.r===e&&r(701,[t.t])}this.Wt>=128&&r(801,[t.t]);let i=this.Wt++;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.Wt--,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.Ft??(s.Ft=[]);t.includes(i)||t.push(i)}}}tt(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"$stateElement":return this.element;case"$command":return this.commands}return h.tt?.(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&&(x(t,r.key,r.sub),n.splice(l--,1))}}let r={getter:s,r:l};O(t.U??=new Map,e,q).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=R(e,r),o=R(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):x(l,t,i)}})}P(t,e,i,s=!1,l=!1){if(this.Ce>0&&r(8),l||this.Ne>0?this.Ht=!0:this.Kt=!0,h.Pe?.(this,t,e,i,l))return;if(null!==t.oe){try{this.yn(t.oe,e,[i])}finally{this.zt(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.bt(t,e);if(s||!this.Bt||!Object.is(n,i)||Object(i)===i){if("*"===t.s){let t=e;t.l.C[t.b]=i,t.T=i,this.R.qt(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.zt(t,e,n,i,!0)}}Qn(t){return(this._t.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.ft&&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.qt(i)),n?this.wn(r,i):this.hn(r,i),this.zt(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._t.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.bt(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.ft?this.Qn(t):[t]){let t=this.o(`${e.o.t}.*`);for(let i of e.u)this.vt(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))}zt(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.ht;for(let t of this.L.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.Ut()}finally{this.bn()}h.element?.(this,"reset")}Yn(t){for(let[e,i]of k)void 0!==t[e]&&o(i,e);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.Bt||n!==this.Mt)&&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.Bt=l,this.Mt=n,h.se?.(this,t),this.target=t,this.Oe=0;for(let t of this.L.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.dt=null,i.U=null,this.vt(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}}vt(t,e){if(null!==t.getter){let i=null===e?this.ee:e.h;if(null!==i)for(let e of i.values())!e.jt&&e.o.Q(t)&&(e.jt=!0,this.Le.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.D;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.nt(n,null,i);else if(null===e||0===t.n||n.f[1]!==t.f[1]||null!==n.ut&&n.ut.has(t))this.Zt(n.f[n.n],t=>this.nt(n,t,i));else if(n.n<=t.n){let t=_(e,n.n);null!==t&&this.nt(n,t,i)}else this.Jt(e,n,t=>this.nt(n,t,i))}})}nt(t,e,i){i(t,e)&&(h.ye?.(this,t,e),this.vt(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?O(this.ie,t.o,q).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.wt||(this.wt=!0,queueMicrotask(this.Oo))}Sn(){for(let t of this.je)t.Z=!1;for(let t of this.De)t.Z=!1;for(let t of this.Le)t.jt=!1;this.je=[],this.De=[],this.Le=[],this.R.ht(this)}oo(t,e){let i=[...new Set([...this.je,...this.De,...this.Le].map(t=>t.o.t))];console.error(`[@wcstack/state] ${n(t)}`,i),h.ot?.(this,{type:"state:render-chain-limit",maxDepth:e,paths:i}),this.Sn()}Ut(){this.wt=!1;let t=this.Vt;this.Vt=0;let e=0;if(!this.Ht||this.Kt?this.Wn():t>0?e=t:1===(e=++this.M)&&setTimeout(this.Wn,0),this.Ht=this.Kt=!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.De.length>0||this.Le.length>0;t++){if(t>=32){this.fn?this.Sn():this.oo(11,32),this.fn=!0;break}let i=this.Le;if(i.length>0){this.Le=[];for(let t of i)t.jt=!1,this.Gn(t)}let s=this.De,l=this.je;this.De=[],this.je=[];let n=$("state",()=>{for(let t of s){t.Z=!1;for(let e of[t.E,...t.D??[]])if(null!==e&&e.y)try{e.kt()}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.wt&&(this.Vt=e+1))});void 0!==n&&n.then(void 0,t=>console.error(t))}}finally{this.dn=!1}this.Ht=this.Kt=!1,this.Ve(),h.Te?.(this),t>0&&this.wt&&(this.Vt=e+1)}}St(t,e){this.yt.push([t,e])}Yt(t,e,i,s){this.St(t,{o:{t:e},a:i,en:()=>s})}_e(t){try{t.apply()}catch(e){return void this.yt.push([e,t])}null!==this.Ie&&this.io(t.o,t.r)}io(t,e){let i=O(this.Ie,t.t,D);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)}S(e)?e.then(this._n,t=>{this._n(),console.error(t)}):this.Ne--}if(0===this.yt.length)return;let e=this.yt;this.yt=[];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}]);S(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=Z(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,T as c,S as d,_ as e,z as f,u as g,f as h,a as i,c as j,d as k};
1
+ import{b as t,d as e,e as i}from"./chunk-5D34CGCF.js";import{h as s,m as l}from"./chunk-ACYOJ3NW.js";import{a as n,b as r}from"./chunk-FZJY4CF3.js";import{a as h,i as o}from"./chunk-SA2LYPN7.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.dt=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.D=null,this.Z=!1,this.jt=!1,this.ft=!1,this.o=t,this.re=e,this.n=t.n+1}},y=[],v=class{constructor(t){this.mt=new Set,this.name=t}get size(){return this.mt.size}subscribe(t){return this.mt.add(t),()=>{this.mt.delete(t)}}unsubscribe(t){return this.mt.delete(t)}emit(...t){let e=[];for(let i of this.mt)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=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],j=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function A(t){return t.includes("**")&&l(t),t}var M=0,C=32,T=100;function O(t,e,i){let s=t.get(e);return void 0===s&&t.set(e,s=i()),s}var q=()=>new Set,D=()=>[];function S(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function L(t,e){return t===e||t!=t&&e!=e}function x(t,e,i){let s=t.U?.get(e);void 0!==s&&s.delete(i)&&0===s.size&&t.U.delete(e)}function _(t,e){for(let i=0;i<e.length;i++){if(null==t)return;t=t[e[i]]}return t}function R(t,e){for(;null!==t&&t.l.n>e;)t=t.l.re;return null!==t&&t.l.n===e?t:null}function Z(t,e,i){let s=R(t,i);return null!==s&&s.l.o===e.f[i]?s:null}var z=class{constructor(t,i){this.Oe=0,this.c=null,this.Ce=0,this.ht=new Set,this.Ze=new Map,this.Bn=Symbol("wcs.block"),this.element=null,this.yt=[],this.Ie=null,this.Mn=[],this.Wt=0,this.q=null,this.ee=new Map,this.ie=new Map,this.je=[],this.De=[],this.Le=[],this.wt=!1,this.dn=!1,this._t=new WeakMap,this.M=0,this.Vt=0,this.fn=!1,this.Ht=!1,this.Kt=!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.Ut(),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=R(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.At??(l.At=[])).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,R(this.c,i.n)))},$dependOn:t=>{this.resolve(A(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=A(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(A(t),this.c);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.T=i.l.C[i.b],this.R.qt(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.zt(e,i,void 0,void 0,!1)}},this.R=i,this.L=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.tt(e);if(e.indexOf(".")<0){let t=s.L.It(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(A(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.L.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.L.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.Dt(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.Dt(e);else i.Dt(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=O(this._t,e,D);if(i.push(t),i.length>1)for(let t of i)t.ft=!0}h.Xt?.(this,t,i),(null!==t.E||null!==t.D)&&!t.Z&&(t.Z=!0,this.De.push(t),this.Re());let s=t.o.At;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.Do(this,t)}Dt(t){t.y=!1;let e=t.U;if(null!==e){for(let t of e)x(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.Dt(t)}}Jn(t){let e=this._t.get(t.C);void 0!==e&&(e.splice(e.indexOf(t)>>>0,1),t.ft=!1,1===e.length&&(e[0].ft=!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?Z(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=Z(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}bt(t,e){return 0===t.n?_(this.target,t.K):null===e?void 0:_(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.Lo(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.ht.has(t.s)&&"then"!==t.s&&"toJSON"!==t.s&&r(301,[t.t],t.s,Object.keys(this.target)),this.bt(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&&R(e,Math.min(t.n,s.n))!==R(i.r,Math.min(t.n,s.n))&&(s.ut??(s.ut=new Set)).add(t)}Bo(t,e){for(let i=0;i<this.Wt;i++){let s=this.Mn[i];s.getter===t&&s.r===e&&r(701,[t.t])}this.Wt>=128&&r(801,[t.t]);let i=this.Wt++;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=++M;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.Wt--,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.Ft??(s.Ft=[]);t.includes(i)||t.push(i)}}}tt(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),R(this.c,i)?.b}let i=this.Io[t];if(void 0!==i)return i;switch(t){case"$stateElement":return this.element;case"$command":return this.commands}return h.tt?.(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&&(x(t,r.key,r.sub),n.splice(l--,1))}}let r={getter:s,r:l};O(t.U??=new Map,e,q).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=_(e,r),o=_(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):x(l,t,i)}})}P(t,e,i,s=!1,l=!1){if(this.Ce>0&&r(8),l||this.Ne>0?this.Ht=!0:this.Kt=!0,h.Pe?.(this,t,e,i,l))return;if(null!==t.oe){try{this.yn(t.oe,e,[i])}finally{this.zt(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.bt(t,e);if(s||!this.Bt||!Object.is(n,i)||Object(i)===i){if("*"===t.s){let t=e;t.l.C[t.b]=i,t.T=i,this.R.qt(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.zt(t,e,n,i,!0)}}Qn(t){return(this._t.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.ft&&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.qt(i)),n?this.wn(r,i):this.hn(r,i),this.zt(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._t.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.bt(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.ft?this.Qn(t):[t]){let t=this.o(`${e.o.t}.*`);for(let i of e.u)this.vt(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))}zt(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.ht;for(let t of this.L.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.Ut()}finally{this.bn()}h.element?.(this,"reset")}Yn(t){for(let[e,i]of k)void 0!==t[e]&&o(i,e);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.Bt||n!==this.Mt)&&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.Bt=l,this.Mt=n,h.se?.(this,t),this.target=t,this.Oe=0;for(let t of this.L.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.dt=null,i.U=null,this.vt(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}}vt(t,e){if(null!==t.getter){let i=null===e?this.ee:e.h;if(null!==i)for(let e of i.values())!e.jt&&e.o.Q(t)&&(e.jt=!0,this.Le.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.D;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.nt(n,null,i);else if(null===e||0===t.n||n.f[1]!==t.f[1]||null!==n.ut&&n.ut.has(t))this.Zt(n.f[n.n],t=>this.nt(n,t,i));else if(n.n<=t.n){let t=R(e,n.n);null!==t&&this.nt(n,t,i)}else this.Jt(e,n,t=>this.nt(n,t,i))}})}nt(t,e,i){i(t,e)&&(h.ye?.(this,t,e),this.vt(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?O(this.ie,t.o,q).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.wt||(this.wt=!0,queueMicrotask(this.Oo))}Sn(){for(let t of this.je)t.Z=!1;for(let t of this.De)t.Z=!1;for(let t of this.Le)t.jt=!1;this.je=[],this.De=[],this.Le=[],this.R.ht(this)}oo(t,e){let i=[...new Set([...this.je,...this.De,...this.Le].map(t=>t.o.t))];console.error(`[@wcstack/state] ${n(t)}`,i),h.ot?.(this,{type:"state:render-chain-limit",maxDepth:e,paths:i}),this.Sn()}Ut(){this.wt=!1;let t=this.Vt;this.Vt=0;let e=0;if(!this.Ht||this.Kt?this.Wn():t>0?e=t:1===(e=++this.M)&&setTimeout(this.Wn,0),this.Ht=this.Kt=!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.De.length>0||this.Le.length>0;t++){if(t>=32){this.fn?this.Sn():this.oo(11,32),this.fn=!0;break}let i=this.Le;if(i.length>0){this.Le=[];for(let t of i)t.jt=!1,this.Gn(t)}let s=this.De,l=this.je;this.De=[],this.je=[];let n=$("state",()=>{for(let t of s){t.Z=!1;for(let e of[t.E,...t.D??[]])if(null!==e&&e.y)try{e.kt()}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.wt&&(this.Vt=e+1))});void 0!==n&&n.then(void 0,t=>console.error(t))}}finally{this.dn=!1}this.Ht=this.Kt=!1,this.Ve(),h.Te?.(this),t>0&&this.wt&&(this.Vt=e+1)}}St(t,e){this.yt.push([t,e])}Yt(t,e,i,s){this.St(t,{o:{t:e},a:i,en:()=>s})}_e(t){try{t.apply()}catch(e){return void this.yt.push([e,t])}null!==this.Ie&&this.io(t.o,t.r)}io(t,e){let i=O(this.Ie,t.t,D);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)}S(e)?e.then(this._n,t=>{this._n(),console.error(t)}):this.Ne--}if(0===this.yt.length)return;let e=this.yt;this.yt=[];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}]);S(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=Z(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,T as c,S as d,R as e,z as f,u as g,f as h,a as i,c as j,d as k};
@@ -1 +1 @@
1
- import{b as t,c as e,d as s}from"./chunk-6GES2BK3.js";import{n as i,o as n}from"./chunk-Z7B3ZZE4.js";import{f as o}from"./chunk-372Y2FIC.js";import{a,b as r}from"./chunk-HSOCDTWX.js";import{a as l,b as c}from"./chunk-ROX5KEJX.js";import{a as h,h as u,i as d}from"./chunk-G2ZO6SXV.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.it?.(this,e);if(s)return this.ze=s,!s.vo&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.pt?this.ko():s.pt()).then(t=>(this.loaded=!0,s.start(t,()=>this.So()))).then(()=>{this.rn(),this.sn()},t=>this.St(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.St(t)}}So(){this.W=!0,this.rn()}St(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};
1
+ import{b as t,c as e,d as s}from"./chunk-L2BZD5DU.js";import{n as i,o as n}from"./chunk-HSMALJSW.js";import{f as o}from"./chunk-COJU24UI.js";import{a,b as r}from"./chunk-C3UYMJRT.js";import{a as l,b as c}from"./chunk-FZJY4CF3.js";import{a as h,h as u,i as d}from"./chunk-SA2LYPN7.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.it?.(this,e);if(s)return this.ze=s,!s.vo&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.pt?this.ko():s.pt()).then(t=>(this.loaded=!0,s.start(t,()=>this.So()))).then(()=>{this.rn(),this.sn()},t=>this.St(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.St(t)}}So(){this.W=!0,this.rn()}St(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};
@@ -1 +1 @@
1
- import{a as n,j as t}from"./chunk-G2ZO6SXV.js";function i(t,i=[]){return n.Fo?.(t,i)??`#${t}${i.map(n=>` ${"string"==typeof n?JSON.stringify(n):String(n)}`).join("")}`}function o(n,o,r,s){t(i(n,o),r,s)}export{i as a,o as b};
1
+ import{a as n,j as t}from"./chunk-SA2LYPN7.js";function i(t,i=[]){return n.Fo?.(t,i)??`#${t}${i.map(n=>` ${"string"==typeof n?JSON.stringify(n):String(n)}`).join("")}`}function o(n,o,r,s){t(i(n,o),r,s)}export{i as a,o as b};
@@ -0,0 +1 @@
1
+ import{j as e}from"./chunk-5MLEMVL3.js";import{a as t,d as n,e as l,j as i,k as r}from"./chunk-COJU24UI.js";import{a as o,g as s}from"./chunk-C3UYMJRT.js";import{a as u}from"./chunk-5D34CGCF.js";import{a,b as h,c,d as f,e as d,f as m,g as p,h as v,i as g,j as b,k as w,l as y,n as x}from"./chunk-ACYOJ3NW.js";import{a as k,b as S}from"./chunk-FZJY4CF3.js";import{a as N}from"./chunk-SA2LYPN7.js";var A=new Map,E=new Set(["if","elseif","else","for"]),$=new Set([a,"if","elseif","for","..."]),T=new Set([d,m,p,f,h,c]);function j(e){let t=function(e){return w(e,";")}(e).map(g).filter(e=>e.length>0).map(e=>{let t=b(e,":");-1===t&&S(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if($.has(i)){let t;return i!==n&&S(102,[e,i]),i===a?(l.length>0&&S(103,[e]),t={Je:"#else",Qe:[]}):"..."===i?(0===l.length&&S(104,[e]),t=x(l),t.Qe.length>0&&S(105,[e])):(t=x(l),"for"===i&&t.Qe.length>0&&S(121,[e])),{be:i,ve:[i],tn:[],I:[],...t,w:"..."===i?"spread":i}}let r=x(l),o=function(e){let[t,n]=y(e,"input",A),l=t.split("#").map(g);l.length>2&&S(115,[t]);let[i,r]=l,o=i.split(".").map(g);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&S(116,[e]),{be:i,ve:o,tn:r?r.split(",").map(g):[],I:n}}(n),[s]=o.ve;if(""===s&&o.ve.length>1){let e=o.ve.slice(1);return(e.includes("")||T.has(e[0]))&&S(106,[n]),{...o,be:e.join("."),ve:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===h||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>E.has(e.w))&&S(201,[e]),t}function I(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function C(t){return 0===t.length?null:(e(),t.map(e=>s(e.Ln,e.args,e.literals)))}var P=Symbol.for("wcstack.state.view-transition-naming"),L=new WeakSet;function M(){let e=t("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var V=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),O=0,R=2,Y=3,W=4,D=5,U=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],J=(e,t,n,l)=>e.Yt(t,n.o?.t??n.Et,l,U[n.i]),B=Symbol();function H(e,t,n){let l=t.V;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.H:B}var q=class{constructor(e,t,n,l,i,r,o,s,u,a=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=u,this.M=a}en(){return U[this.i]}apply(){if(null!==this.M)return void this.M.kt();let e=I(this.x,this.engine.read(this.o,this.r));if(e===this.value&&("object"!=typeof e||null===e||11===this.i||8===this.i||i(this.name)))return;if(this.value===B)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()):Q(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 I(this.I,this.a.value)}Xo(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.nn()}else if(10===this.i){let l=this.nn(),i=n.v(this.o,this.r),r=Array.isArray(i)?i:[],o=r.includes(l);if(t.checked?o:!o)return;e=o?r.filter(e=>e!==l):[...r,l]}else e=I(this.I,t[this.name]);n.P(this.o,this.r,e,!1,!0)}},F=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Q(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(F(n)?t[n]="innerHTML"===n?r(l):null==l?"":String(l):i(n)?null==l&&"srcdoc"===n?t.removeAttribute(n):void 0!==l&&(t[n]=r(l)):void 0!==l&&(t[n]!==l&&!("value"===n&&t.value===String(l))&&(t[n]=l),("value"===n||"selectedIndex"===n)&&"select"===t.localName&&(t[Z]=[n,l])));case 8:return void(t.innerHTML=r(l));case 2:return null!=l&&"boolean"!=typeof l&&S(401,[n,typeof l]),void t.classList.toggle(n,!0===l);case 3:return void(null==l?t.removeAttribute(n):t.setAttribute(n,String(l)));case 4:return void(null==l?t.style.removeProperty(n):t.style.setProperty(n,String(l)))}}var Z=Symbol();function z(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[Z];void 0!==n&&(t[n[0]]=n[1])}var K=class{constructor(e,t,n,l){this.y=!0,this.fe=null,this.h=null,this.$t=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=ue(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():ae(this.Ue(),this.s)}Se(e){if(this.y=!1,null!==this.$t)for(let e of this.$t)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()}},_=class extends K{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 q(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 G(e,t,n,i){let r=l(n,t.n);try{return e.Be(r,t)}catch(n){return e.Yt(n,t.t,i,"for"),null===r?e.ee.get(t):r.h.get(t)}}function X(e,t,n){n&&e.zo(t);let l=t.$n;null!==l&&(l.fe??=[]).push(t)}var ee=null;function te(){let e=ee;return ee=null,e}var ne=-1;function le(e,t,n,l,i=null){let r,o=t.Rn,s=t.build,u=t.mo,a=null,h=N.Ae?.(t,null===l?i:l.S,null!==l),c=!h&&t.Tn,f=h?document.createDocumentFragment():(c?t.root:t.on).cloneNode(!0);if(!h)for(let e=0;e<s.length;e++){let t=s[e];u[t]=ue(f,o[t],c?1:0)}c?r=f:(a=h||[...f.childNodes],r=a[0]);let d,m=null;if(null!==l?(d=m=new _(n,r,a,t),null===l.map?n.E=m:l.map.set(n,m)):d=new K(n,r,a,t),ne>=0&&function(e,t,n,l){let i=null;if(null===t)i=1===e.nodeType?e:null;else for(let e=0;e<t.length&&null===i;e++)1===t[e].nodeType&&(i=t[e]);let r=i?.style;if(null===i||void 0===r||L.has(i))return;let o=globalThis[P]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${k(25,[l])}`)):(L.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,a,null!==l?"row":"branch",ne),t.xe.length>0){let t=e.Bn;if(null===a)r[t]=d;else for(let e of a)1===e.nodeType&&(e[t]=d)}let p=t.Go,v=e.Ie,g=t.Jo?u.slice(0,o.length):u,b=null===m?null:m.ae;if(null!==b){let e=t.qe;for(let t=0;t<e.length;t++)b[2*t]=g[e[t].a],b[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!==b){let t=m.W?.[o];if(void 0!==t){t.Z=!1,e._e(t);continue}try{let t=I(l.x,e.read(l.o,n));t!==l.H&&(Q(l.i,i,l.name,t),b[2*o+1]=t),null!==v&&e.io(l.o,n)}catch(t){e.St(t,m.po(e,o))}continue}switch(l.i){case 6:{let t=new se(e,l.A,G(e,l.o,n,i),i);(d.h??=[]).push(t),i===r&&(d.Nn=t),t.kt();break}case 7:{let t=re(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{ie(e,l,i,n,d)}catch(t){J(e,t,l,i)}}}return ee=d,f}function ie(e,t,n,i,r){let o=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.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.$t??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,i,r);case 12:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.Et.slice(9)),s=null===i?N.Yo?.(n,r):null;s||(null===i&&me(1202,n,`command.${r}`),i.commands.has(r)||S(1203,[n.localName,r]));let u=new WeakRef(n),a=o.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?s?s(t,e):t[r](...e):void 0;a()});null!==l&&(l.$t??=[]).push(a)}(e,t,o,r,n));case 13:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name;null===i&&me(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&S(1204,[n.localName,r]);let s=t.Et;n.addEventListener(o.event,n=>{t.xt&&n.preventDefault(),t.Nt&&n.stopPropagation();try{e.Ko(s,n,l)}catch(e){console.error(e)}})}(e,t,o,i,n))}let s=t.o,u=l(i,s.n);if(14===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){null===r&&me(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs.keys()]);for(let s of o){if(t.ao?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),u=0===o.n?null:l;de(e,{...t,V:null,z:null},n,s,o,u,i,r)}}(e,t,o,u,r,n));if(t.ke&&1===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){if(null!==r)return void de(e,t,n,t.name,t.o,l,i,r);let o=new q(e,1,n,t.name,t.o,l,i,t.x,H(e,t,l));o.I=t.I,!N.Qo?.(o,t.ro)&&(X(e,o,!0),e._e(o))}(e,t,o,u,r,n));let a=new q(e,t.i,n,t.name,s,u,r,t.x,H(e,t,u));a.I=t.I,X(e,a,!0),e._e(a),null!==t.Rt&&n.addEventListener(t.Rt,()=>a.Xo())}function re(e,t,n,i){let r=new oe(e,t,n),o=null;for(let s of t){if(null===s.o)continue;let t=s.o,u=new q(e,7,s.S,"if",t,l(n,t.n),i,null,void 0,r);X(e,u,!0),null===i&&r.ie.push(u),o??=u}return e._e(o),r}var oe=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}kt(){let e=this.engine,t=-1;for(let n=0;n<this.Y.length;n++){let i=this.Y[n];if(null===i.o||I(i.x,e.read(i.o,l(this.r,i.o.n)))){t=n;break}}if(t!==this.b&&(ne=M(),null!==this.O&&(this.O.uo(),this.O.Se(e),this.O=null),this.b=t,t>=0)){let n=this.Y[t],l=le(e,n.A,this.r,null,n.S);this.O=te();let i=n.S.parentNode;i.insertBefore(l,n.S),z(i)}}Se(){this.y=!1;for(let e of this.ie)this.engine.kn(e);null!==this.O&&this.O.Se(this.engine)}},se=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.D??=[]).push(this),this.map=new Map)}Pn(e){return 0===this.$e.length?null:this.$e[0].Ue()}Pt(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)}kt(){let e=this.engine,t=this.l.u,n=this.$e;ne=M();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){ae(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),u=0;for(;u<l&&u<i&&this.Pt(t[u])===n[u];)s[u]=n[u],u++;let a=i-1,h=l-1;for(;a>=u&&h>=u&&this.Pt(t[h])===n[a];)s[h]=n[a],a--,h--;for(let e=u;e<=a;e++){let t=n[e],l=t.r;l.y&&this.Pt(l)===t?t.fo=e:(t.uo(),this.ho(t))}if(u<=h){let n=h-u+1,a=new Int32Array(n),c=!1;if(i>0)for(let e=0;e<n;e++){let n=this.Pt(t[u+e]);null!==n&&n.y?(a[e]=n.fo,c=!0):a[e]=-1}let f=h+1<l?s[h+1].Ue():r;if(c){let l=function(e){let t=e.length,n=new Uint8Array(t),l=new Int32Array(t).fill(-1),i=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let r=0,o=i.length;for(;r<o;){let n=r+o>>1;e[i[n]]<t?r=n+1:o=n}r>0&&(l[n]=i[r-1]),i[r]=n}let r=i.length>0?i[i.length-1]:-1;for(;r>=0;)n[r]=1,r=l[r];return n}(a),i=f;for(let r=n-1;r>=0;r--){let n=t[u+r],a=this.Pt(n);null!==a&&a.y?0===l[r]&&a.insertBefore(o,i):(o.insertBefore(le(e,this.A,n,this),i),a=te()),s[u+r]=a,i=a.Ue()}}else{let n=document.createDocumentFragment();for(let l=u;l<=h;l++)n.appendChild(le(e,this.A,t[l],this)),s[l]=te();o.insertBefore(n,f)}}this.$e=s,z(o)}Se(){this.y=!1;let e=this.l;if(e.E===this)e.E=null;else if(null!==e.D){let t=e.D.indexOf(this);t>=0&&e.D.splice(t,1),0===e.D.length&&(e.D=null)}for(let e of this.$e)e.Se(this.engine);this.map?.clear()}};function ue(e,t,n){for(;n<t.length;n++){e=e.firstChild;for(let l=t[n];l>0;l--)e=e.nextSibling}return e}function ae(e,t){let n=document.createRange();n.setStartBefore(e),n.setEndAfter(t),n.deleteContents()}var he=new WeakMap,ce=e=>e.customElementRegistry??customElements;function fe(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=ce(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>fe(e,t,n,l,i,!0));let u=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(he.has(e))return he.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new Map,commands:new Set};for(let e of t.properties??[])n.properties.set(e.name,{event:e.event,getter:"function"==typeof e.getter?e.getter:null,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 he.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return u();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.$t??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{u()}catch(l){J(e,l,t,n)}e.Re()})}function de(e,t,n,l,i=t.o,r,o,s){let u=s.properties.get(l)??null,a=s.inputs.get(l),h=e.Mt;h&&null===u&&void 0===a&&S(38,[l]);let c=t.V;(null===u?"element"===c||"auto"===c:void 0===a&&("state"===c||"auto"===c))&&S(39,[c,l]),"connect"===t.z&&null===u&&S(40,[l]);let f=h&&null!==u&&void 0===a,d=new q(e,11,n,l,i,r,o,t.x,void 0);d.I=t.I,d.attribute=a?.attribute??null,X(e,d,!f),null!==u&&!t.ro&&n.addEventListener(u.event,t=>{let i;null!==u.getter?i=u.getter(t):(i=t.detail,u.lo||N.detail?.(n,l,i)),(!d.En||!Object.is(i,d.value))&&(i=I(d.I,i),null===d.x&&(d.value=i),e.P(d.o,d.r,i,u.lo,!0))});let m=c??(f?"element":"state");if("state"===m)f||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(f||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 me(e,t,n){S(e,[t.localName,n])}var pe=()=>o.bindAttributeName;function ve(){return{a:0,i:1,name:"",o:null,x:null,H:u,xn:null,A:null,Y:null,I:null,Rt:null,ke:!1,V:null,z:null,ro:!1,xt:!1,Nt:!1,Et:null,ao:null,F:-1,Ze:!1,co:!1}}var ge=["state","element","auto","none"],be=["call","connect"],we="$command.";function ye(e,t,n){v.test(t)&&(null===n&&S(1401,[t,Number(t.slice(1))]),t=`${n.t}.*.${t}`);let l=e.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&S(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&S(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.f[e];l.f[e]!==t&&S(1403,[l.t,l.f[e].t,t.t])}return N.go?.(e,l),l}var xe=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),ke=e=>8===e.i||xe(e)||1===e.i&&F(e.name);function Se(e){S(202,[e])}function Ne(e,t,l,r,o){let s=j(t).map(t=>function(e,t,l,r,o){let s=function(e,t){let n=t.find(e=>e.startsWith("on")),l=null,i=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e.Mt||S(31);let r=n.slice(0,t).trim(),o=n.slice(t+1).trim(),s="init"===r;!s&&"sync"!==r&&S(33,[r,n]),null!==(s?l:i)&&S(34,[r]),(s?ge:be).includes(o)||S(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),xt:t.includes("prevent"),Nt:t.includes("stop"),event:n?n.slice(2):null,V:l,z:i}}(e,t.tn),u=r.localName.includes("-"),a=t.ve,h=t.Je;if("event"===t.w){if(null!==s.V&&"none"!==s.V&&S(36),"eventToken"===a[0])return{...ve(),a:o,i:13,name:a.slice(1).join("."),Et:h,ke:u,xt:s.xt,Nt:s.Nt};let l=h.startsWith(we)?h.slice(9):null,{xt:i,Nt:r}=s,c=t.be.slice(2),f=t.tn.includes("direct"),d=!f&&V.has(c);return d&&e.eo(c),{...ve(),a:o,i:5,name:c,Ze:d,ke:u,co:f,xn(t,o){i&&t.preventDefault(),r&&t.stopPropagation();try{if(null!==l)e.Uo(l,t,o);else{let l=e.qo(h,t,o);n(l)&&l.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...ve(),a:o,i:14,o:ye(e,h,l),ke:u};if("command"===a[0]&&a.length>1)return h.startsWith(we)||S(1201,[t.be,h]),{...ve(),a:o,i:12,name:a.slice(1).join("."),Et:h,ke:u};let c=ye(e,h,l),f={...ve(),a:o,i:1,name:t.be,o:c,x:C(t.Qe),I:C(t.I),ro:s.ro,V:s.V,z:s.z};if("radio"===t.w||"checkbox"===t.w)return("element"===s.V||"auto"===s.V)&&S(37,[t.w,s.V]),f.i="radio"===t.w?9:10,s.ro||(f.Rt=s.event??"input"),f;if(a.length>1){let e=a.slice(1).join("."),t=a[0];if("class"===t||"attr"===t||"style"===t)return f.V=null,f.name=e,"class"===t?(f.i=2,f.H=r.classList.contains(e)):f.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,f}return"html"===t.be?(f.i=8,f):(f.name="text"===t.be?"textContent":t.be,f.ke=u&&!i(f.name),!u&&!s.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(r,f.name)&&(f.Rt=s.event??("select"===r.localName?"change":"input")),f)}(e,t,l,r,o));for(let e=0;e<s.length;e++)14===s[e].i&&(s[e].ao=s.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return s}var Ae=/\{\{([\s\S]+?)\}\}/g;function Ee(e){let t=e.data,n=[],l=0;Ae.lastIndex=0;for(let i=Ae.exec(t);null!==i;i=Ae.exec(t)){let r=Ae.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,Zo:i[1].trim()}),l=Ae.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function $e(e,t,n,l){let i=function(e){return{be:"textContent",ve:["textContent"],tn:[],I:[],...x(e),w:"text"}}(t);return{...ve(),a:l,i:0,o:ye(e,i.Je,n),x:C(i.Qe),H:""}}function Te(e){let t=e.getAttribute(pe());if(null===t)return null;let n=j(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var je=(e,t)=>0===e?o.commentIfPrefix:null===t.o?o.commentElsePrefix:o.commentElseIfPrefix;function Ie(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:ye(e,l.Je,n),x:"else"===l.w?null:C(l.Qe)}),i=[l(t,Te(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=Te(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var Ce=new WeakSet;function Pe(e,t,n,l,i,r,s,u){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&N.An?.(e,i,t),i},h=t=>{for(let c=0;c<t.length;c++){let f=t[c];if(null!==f.parentNode)if(1===f.nodeType){let t=f,u=t.localName;if(l){if("script"===u||"style"===u||Ce.has(t))continue;if(Ce.add(t),u===o.tagNames.state){h([...t.childNodes]);continue}}let c="template"===u?Te(t):null;if(null!==c){if("for"===c.w){let l=ye(e,c.Je,n),r=Ve(e,t,l,!0);i(a(t,o.commentForPrefix),l,r)}else"if"===c.w?r(Ie(e,t,n).map((t,l)=>({A:Ve(e,t.el,n,!1),o:t.o,x:t.x,S:a(t.el,je(l,t))}))):Se(c.w);continue}let d=t.getAttribute(pe()),m=null===d?null:Ne(e,d,n,t,0),p="noscript"!==u&&"iframe"!==u&&!m?.some(ke)&&!N.yo?.(t);try{l&&p&&h([...t.childNodes])}finally{null!==m&&s(t,m)}!l&&p&&h([...t.childNodes])}else if(3===f.nodeType&&e.Lt&&f.data.includes("{{")&&!Ce.has(f))for(let{a:e,Zo:t}of Ee(f))u(e,t);else if(8===f.nodeType){let e=Le.exec(f.data),t=e&&f.parentNode.localName;if(null!==t&&"textarea"!==t&&"title"!==t){let t=document.createTextNode("");f.replaceWith(t),u(t,e[1])}}}};h(t)}var Le=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Me=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Ve(e,t,n,l){let i=document.importNode(Me(t),!0),r=[],o=[],s=e=>r.push(e)-1;Pe(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...ve(),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({...ve(),a:t[0].a,i:7,Y:t})},(e,t)=>{let n=s(e);for(let e of t)xe(e)&&S(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(pe())},(t,l)=>{o.push($e(e,l,n,s(t)))}),We(i,new Set(r),!0);let u=r.map(e=>function(e,t){let n=[];for(let l=t;l!==e;l=l.parentNode){let e=0;for(let t=l.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(i,e)),a=1===i.childNodes.length&&8!==i.firstChild.nodeType,h=o.some(e=>6===e.i||7===e.i),c=[],f=new Set,d=[],m=[],p=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.Ze&&!e.ke&&!Oe(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&&Re(e)&&(e.F=c.push(e)-1),7===e.i)for(let t of e.Y)f.add(t.a);else f.add(e.a)}let v=[...f].sort((e,t)=>e-t);return{on:i,root:a?i.firstChild:null,Rn:u,build:v,xe:d,Go:m,Tn:a,Jo:h,mo:[],qe:c}}function Oe(e,t){for(;e.parentNode!==t;e=e.parentNode){if(e.parentNode.localName.includes("-"))return!0;for(let t=e.previousSibling;t;t=t.previousSibling)if(8===t.nodeType)return!0}return!1}function Re(e){if(null!==e.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.Rt;default:return!1}}var Ye=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function We(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&&We(l,t,Ye.has(l.localName)),l=e}}var De=new WeakMap;function Ue(e,t){let n=9===t.nodeType?t.body:t;e.root=t,De.set(t,e),Be(e,[...n.childNodes]),e.Ve()}function Je(e,t,n){try{let l="template"===t.localName?Te(t):null;null!==l&&!n&&S(204,[l.w]),Be(e,[t])}catch(e){console.error(e)}e.Ve()}function Be(e,t){Pe(e,t,null,!0,(t,n,l)=>{new se(e,l,G(e,n,null,t),t).kt()},t=>{re(e,t,null,null)},(t,n)=>{N.An?.(e,t,n);for(let l of n)ie(e,l,t,null,null)},(t,n)=>{N.An?.(e,t,n),ie(e,$e(e,n,null,0),t,null,null)})}export{j as a,ce as b,O as c,R as d,Y as e,W as f,D as g,_ as h,se as i,xe as j,ke as k,Ce as l,Me as m,De as n,Ue as o,Je as p};
@@ -1 +1 @@
1
- import{n as t,p as n}from"./chunk-Z7B3ZZE4.js";import{a as l,b as e,c as r}from"./chunk-5D34CGCF.js";import{a as o}from"./chunk-G2ZO6SXV.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 r=t.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?f.set(l,e):n(r,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.rt=(t,n)=>{if(0===t.n){let n=t.J;return n!==l&&n!==e&&(t.J=e,!0)}let r=null===n?null:n.dt;if(null===r)return!1;let o=r[t.F];return o!==l&&o!==e&&(r[t.F]=e,!0)}}Vo(t,n,l){null!==n.getter&&this.rt(n,l),t.vt(n,l),t.vn(n,l,this.rt)}Do(t,n){let l=n.l.o.Ft;if(null!==l)for(let e of l)e.n===n.l.n?t.nt(e,n,this.rt):t.Jt(n,e,n=>t.nt(e,n,this.rt))}me(t,n,l){this.rt(n,l),o.ye?.(t,n,l),t.vt(n,l),t.vn(n,l,this.rt)}Lo(t,n,o){let i=0===n.n;if(!i&&null===o)return;let u=i?null:o.dt??=new Array(t.Oe).fill(l),s=null===u?n.J:u[n.F];if(s!==l&&s!==e&&s!==r&&(null===u||n.F in u))return s;s=r;try{return s=t.Bo(n,null===u?null:o)}finally{null===u?n.J=s:u[n.F]=s}}qt(t){t.dt=null}ht(t){for(let n of t.L.all())null!==n.getter&&(0===n.n?n.J===e&&(n.J=r):t.Zt(n.f[n.n],t=>{let l=t.dt;null!==l&&l[n.F]===e&&(l[n.F]=r)}))}};export{a,c as b,d as c,b as d};
1
+ import{n as t,p as n}from"./chunk-HSMALJSW.js";import{a as l,b as e,c as r}from"./chunk-5D34CGCF.js";import{a as o}from"./chunk-SA2LYPN7.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 r=t.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?f.set(l,e):n(r,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.rt=(t,n)=>{if(0===t.n){let n=t.J;return n!==l&&n!==e&&(t.J=e,!0)}let r=null===n?null:n.dt;if(null===r)return!1;let o=r[t.F];return o!==l&&o!==e&&(r[t.F]=e,!0)}}Vo(t,n,l){null!==n.getter&&this.rt(n,l),t.vt(n,l),t.vn(n,l,this.rt)}Do(t,n){let l=n.l.o.Ft;if(null!==l)for(let e of l)e.n===n.l.n?t.nt(e,n,this.rt):t.Jt(n,e,n=>t.nt(e,n,this.rt))}me(t,n,l){this.rt(n,l),o.ye?.(t,n,l),t.vt(n,l),t.vn(n,l,this.rt)}Lo(t,n,o){let i=0===n.n;if(!i&&null===o)return;let u=i?null:o.dt??=new Array(t.Oe).fill(l),s=null===u?n.J:u[n.F];if(s!==l&&s!==e&&s!==r&&(null===u||n.F in u))return s;s=r;try{return s=t.Bo(n,null===u?null:o)}finally{null===u?n.J=s:u[n.F]=s}}qt(t){t.dt=null}ht(t){for(let n of t.L.all())null!==n.getter&&(0===n.n?n.J===e&&(n.J=r):t.Zt(n.f[n.n],t=>{let l=t.dt;null!==l&&l[n.F]===e&&(l[n.F]=r)}))}};export{a,c as b,d as c,b as d};
@@ -0,0 +1 @@
1
+ var a="4.0.0-rc.5";export{a};
@@ -1 +1 @@
1
- import{a as s}from"./chunks/chunk-ZOINIOIM.js";import{a as n,d as t,e as u}from"./chunks/chunk-7644KQ3T.js";import"./chunks/chunk-6GES2BK3.js";import"./chunks/chunk-Z7B3ZZE4.js";import"./chunks/chunk-SEPY6OHJ.js";import{g as a,h as c,i as h}from"./chunks/chunk-372Y2FIC.js";import{c as i}from"./chunks/chunk-HSOCDTWX.js";import"./chunks/chunk-5D34CGCF.js";import"./chunks/chunk-5LIOXC7W.js";import"./chunks/chunk-ROX5KEJX.js";import{g as o}from"./chunks/chunk-G2ZO6SXV.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-VY2XLPFM.js";import{a as n,d as t,e as u}from"./chunks/chunk-FVHQWDF4.js";import"./chunks/chunk-L2BZD5DU.js";import"./chunks/chunk-HSMALJSW.js";import"./chunks/chunk-5MLEMVL3.js";import{g as a,h as c,i as h}from"./chunks/chunk-COJU24UI.js";import{c as i}from"./chunks/chunk-C3UYMJRT.js";import"./chunks/chunk-5D34CGCF.js";import"./chunks/chunk-ACYOJ3NW.js";import"./chunks/chunk-FZJY4CF3.js";import{g as o}from"./chunks/chunk-SA2LYPN7.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-ZOINIOIM.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-Z7B3ZZE4.js";import"../chunks/chunk-SEPY6OHJ.js";import"../chunks/chunk-372Y2FIC.js";import"../chunks/chunk-HSOCDTWX.js";import"../chunks/chunk-5D34CGCF.js";import"../chunks/chunk-5LIOXC7W.js";import"../chunks/chunk-ROX5KEJX.js";import{a as u,b as d}from"../chunks/chunk-G2ZO6SXV.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.D)for(let e of t.D)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.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 O(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 $(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 j(e){if(null===c)return;let t=b.get(e);b.delete(e),void 0!==t&&c({type:"state:update-batch",addresses:t}),g(e)}function M(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.en(),error:t})}var E={name:"devtools",install(){u.element=d(u.element,O),u.he=d(u.he,$),u.Te=d(u.Te,j),u.He=d(u.He,M),function(){if(typeof document>"u"||document.documentElement?.hasAttribute("data-wcs-server"))return;let t=globalThis,n=t[f]??(t[f]=function(){let e=new Map,t=new Set,n=e=>{0===t.size?e._setSink(null):e._setSink(n=>{for(let l of t)l.onEvent?.(e.id,n)})};return{version:2,sources:e,register(l){if(!e.has(l.id)){e.set(l.id,l),n(l);for(let e of t)e.onSourceRegistered?.(l)}},unregister(n){let l=e.get(n);if(void 0!==l){l._setSink(null),e.delete(n);for(let e of t)e.onSourceUnregistered?.(n)}},addListener(l){t.add(l);for(let t of e.values())n(t),l.onSourceRegistered?.(t);return()=>{if(t.delete(l))for(let t of e.values())n(t)}}}}());2!==n.version&&console.warn(`[@wcstack/state] devtools hook registry version ${n.version}, expected 2: keeping the existing one.`),n.register({id:`state:${Math.random().toString(36).slice(2,10)}`,kind:"state",packageVersion:e,getStateElements:()=>[...m].map(y),overlays:()=>[],keyedSubscriptions:e=>function(e){let t=[];for(let n of e.L.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.ot=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},_=E;export{_ as default,E as devtools};
1
+ import{a as e}from"../chunks/chunk-VY2XLPFM.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-HSMALJSW.js";import"../chunks/chunk-5MLEMVL3.js";import"../chunks/chunk-COJU24UI.js";import"../chunks/chunk-C3UYMJRT.js";import"../chunks/chunk-5D34CGCF.js";import"../chunks/chunk-ACYOJ3NW.js";import"../chunks/chunk-FZJY4CF3.js";import{a as u,b as d}from"../chunks/chunk-SA2LYPN7.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.D)for(let e of t.D)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.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 M(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 O(e,t,n){c?.({type:"state:binding-apply-error",path:n.o.t,bindingType:n.en(),error:t})}var _={name:"devtools",install(){u.element=d(u.element,$),u.he=d(u.he,j),u.Te=d(u.Te,M),u.He=d(u.He,O),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.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.ot=e&&((e,t)=>c?.({...t,stateElement:e.element})),t&&queueMicrotask(()=>{for(let e of m)g(e)})}})}()}},E=_;export{E as default,_ as devtools};
@@ -1 +1 @@
1
- import{b as e,c as t,h as n,j as a}from"../chunks/chunk-372Y2FIC.js";import{a as i,d as s,f as r}from"../chunks/chunk-HSOCDTWX.js";import{e as o}from"../chunks/chunk-5D34CGCF.js";import"../chunks/chunk-5LIOXC7W.js";import{b as l}from"../chunks/chunk-ROX5KEJX.js";import{a as d,b as c,c as u,e as f,j as h}from"../chunks/chunk-G2ZO6SXV.js";function p(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let a=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)a[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;i[s]=Math.min(a[s]+1,i[s-1]+1,a[s-1]+r)}for(let e=0;e<=t.length;e++)a[e]=i[e]}return a[t.length]}function $(e,t){if(0===e.length)return"";let n=e.toLowerCase(),a=null,i=3;for(let e of t){let t=p(n,e.toLowerCase(),2);t<i&&(a=e,i=t)}return null!==a?` Did you mean "${a}"?`:""}var m=" Validate statically: npx @wcstack/lint <file>.",g=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],w=e=>{let t=g[e/100|0];return t?`[wcs/${t}] `:""},b=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],y=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,v="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",k={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 ${v}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${v}`,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&&b.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)=>`${y(e,t)} failed to initialize.`,50:(e,...t)=>`${y(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${y(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,a)=>`${e}("${t}") takes ${n} index(es), got ${a}.`,902:(e,t,n,a)=>`${e}("${t}") takes at most ${n} index(es), got ${a}.`,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 x(e,t){let n=k[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var j=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),T=[[/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.']],O={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function I(e,t,n){let a=(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(O,e)?O[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?$(t,n):"");for(let[t,n]of T){let i=t.exec(e);null!==i&&(a+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(a+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?a+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(a+=' 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&&j.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var S=new WeakMap,M=new WeakMap,A=new WeakSet,W=new WeakSet;function P(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 q(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 C(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let a=e.target,i=t=>null===t?null:function(e,t){let n=t.t.split("."),a=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return a<0||n.indexOf("*",a)>=0||void 0!==P(e.target,t.t)?.get?t:e.L.It(o(t.t).o)}(e,t);for(let t of n){if(null!=i(t)?.getter||null===a||"object"!=typeof a)return null;if("*"===t.s){if(!Array.isArray(a)||0===a.length)return null;a=a[0];continue}if(Array.isArray(a)&&/^\d+$/.test(t.s)){if(Number(t.s)>=a.length)return null;a=a[Number(t.s)];continue}let n=P(a,t.s);if(void 0===n&&null===t.d&&e.ht.has(t.s))return null;if(void 0===n){let n=q(a),s=i(t.d);for(let t of e.L.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;a=n.value}return null}function L(e){A.has(e)||(A.add(e),setTimeout(()=>function(e){A.delete(e);let t=S.get(e);if(void 0===t)return;let n=M.get(e);void 0===n&&M.set(e,n=new Set);for(let[a,s]of t){if(n.has(a))continue;n.add(a);let t=C(e,a);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!W.has(e)&&(a.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(a),r.initializePromise.then(()=>{W.add(r),L(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.ot?.(e,{type:"state:path-unresolved",source:s?"watch":"binding",path:a.t,missingSegment:t.seg});let u=e.L.It(o(a.t).o),f="";if(void 0!==u&&u!==a&&null!==u.getter){let e=u.f.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(u.f[t].t.length+2)}`);f=` The getter "${u.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${l}] ${c} "${a.t}" does not resolve on the state tree: "${t.seg}" is not declared.${$(t.seg,t.names)}${f} Updates to this path will be silently dropped.${m}`)}}(e),0))}function D(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let a=S.get(e);void 0===a&&S.set(e,a=new Map),a.has(t)||a.set(t,n),L(e)}var H=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=!1;function B(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(z||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;z=!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:i.a,property:s})}var N=new WeakMap;function E(e,t,n){let a=e[t],i=void 0===n?void 0===a?null:`the event carried no detail (undefined) while element.${t} is ${typeof a}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==a&&"object"==typeof a?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof a}`;if(null===i)return;let s=N.get(e);void 0===s&&N.set(e,s=new Set),!s.has(t)&&(s.add(t),console.warn(`[@wcstack/state] [wcs/default-getter-mismatch] <${e.localName}> "${t}": ${i}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var F=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],R={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},U={name:"diagnostics",install(){d.Ao=I,d.Fo=x,d.go=D,d.detail=E,d.He=c(d.He,B);let e=d.se;d.se=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of F)void 0!==e[t]&&l(1601,[t,n])})(n),e?.(t,n),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[a,i]=n[0];if(!a.endsWith(".*")||!i.endsWith(".*"))return;let s=a.slice(0,-2),r=i.slice(0,-2),o=`.${i}`,l=`${s}.**`,d=q(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>h(`[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(`^(?:${H(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 "${i}"). Rename one of them.`);let t=new RegExp(`^${H(a)}(?:${H(o)})*${H(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.`)}}(n),function(e){M.delete(e),S.has(e)&&L(e)}(t)},d.tt=u(f,d.tt,(e,t)=>Object.hasOwn(R,t)?l(1701,[t,R[t]]):void 0)}},X=U;export{X as default,U as diagnostics};
1
+ import{b as e,c as t,h as n,j as a}from"../chunks/chunk-COJU24UI.js";import{a as i,d as s,f as r}from"../chunks/chunk-C3UYMJRT.js";import{e as o}from"../chunks/chunk-5D34CGCF.js";import"../chunks/chunk-ACYOJ3NW.js";import{b as l}from"../chunks/chunk-FZJY4CF3.js";import{a as d,b as c,c as u,e as f,j as h}from"../chunks/chunk-SA2LYPN7.js";function $(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let a=new Array(t.length+1),i=new Array(t.length+1);for(let e=0;e<=t.length;e++)a[e]=e;for(let n=1;n<=e.length;n++){i[0]=n;for(let s=1;s<=t.length;s++){let r=e[n-1]===t[s-1]?0:1;i[s]=Math.min(a[s]+1,i[s-1]+1,a[s-1]+r)}for(let e=0;e<=t.length;e++)a[e]=i[e]}return a[t.length]}function p(e,t){if(0===e.length)return"";let n=e.toLowerCase(),a=null,i=3;for(let e of t){let t=$(n,e.toLowerCase(),2);t<i&&(a=e,i=t)}return null!==a?` Did you mean "${a}"?`:""}var m=" Validate statically: npx @wcstack/lint <file>.",g=["","binding-syntax","template-syntax","binding-path-missing","binding-type-expectation","filter-unknown","filter-arity","getter-cycle","getter-depth-exceeded","index-arity","index-param-range","recursion-unsupported","token-misconfigured","token-undeclared","wildcard-rank","spread-no-bindable","declaration-alias","name-alias"],w=e=>{let t=g[e/100|0];return t?`[wcs/${t}] `:""},b=["enableMustache","sameValueGuard","enableDirectionalInitialSync"],y=(e,t)=>`<${e}${t.map((e,t)=>t%2?`="${e}"`:` ${e}`).join("")}>`,v="https://github.com/wcstack/wcstack/blob/main/docs/csp.md",k={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 ${v}`,43:e=>`Failed to evaluate the inline <script> of <wcs-state>: ${e}. If this page sets a Content-Security-Policy, see ${v}`,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&&b.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)=>`${y(e,t)} failed to initialize.`,50:(e,...t)=>`${y(e,t)} $connectedCallback failed.`,51:(e,...t)=>`${y(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,a)=>`${e}("${t}") takes ${n} index(es), got ${a}.`,902:(e,t,n,a)=>`${e}("${t}") takes at most ${n} index(es), got ${a}.`,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}).${!e.includes("-")&&t.startsWith("command.")?" A native element's command needs the add-on @wcstack/state/features/native-commands.":""}`,1203:(e,t)=>`<${e}> declares no command "${t}".`,1204:(e,t)=>`<${e}> declares no property "${t}".`,1205:(e,t,n)=>`<${e}> has no command "${t}" (a native <${e}>'s commands: ${n}).`,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 x(e,t){let n=k[e];return void 0===n?`${w(e)}#${e} ${t.join(" ")}`:w(e)+n(...t)}var j=new Set(["binding-syntax","template-syntax","filter-unknown","filter-arity","index-arity","wildcard-rank","token-undeclared","binding-path-missing","index-param-range"]),T=[[/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.']],O={inc:"add",dec:"sub",fix:"toFixed",uc:"upper",lc:"lower",cap:"capitalize",rep:"repeat",rev:"reverse",pad:"padStart",null:"nullIfEmpty"};function I(e,t,n){let a=(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(O,e)?O[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?p(t,n):"");for(let[t,n]of T){let i=t.exec(e);null!==i&&(a+=n.replace(/\$(\d)/g,(e,t)=>i[Number(t)]))}let i=/"([^"#]+)#([^"]+)": a binding takes one modifier list/.exec(e);null!==i&&(a+=` — write "${i[1]}#${i[2].split("#").join(",")}".`),e.includes("[wcs/filter-unknown]")&&(e.includes("formats add-on")?a+=' On a split auto page: features="formats" on the root, or "$features": ["formats"].':s.some(r)||(a+=' 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&&j.has(o[1])&&!/ path segments — the limit is |inserted content was not rendered|formats add-on/.test(e)&&(a+=m),a}var S=new WeakMap,A=new WeakMap,M=new WeakSet,P=new WeakSet;function W(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 C(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 q(e,t){let n=[];for(let e=t;null!==e;e=e.d)n.unshift(e);let a=e.target,i=t=>null===t?null:function(e,t){let n=t.t.split("."),a=n.findIndex((e,t)=>t>0&&/^\d/.test(e));return a<0||n.indexOf("*",a)>=0||void 0!==W(e.target,t.t)?.get?t:e.L.It(o(t.t).o)}(e,t);for(let t of n){if(null!=i(t)?.getter||null===a||"object"!=typeof a)return null;if("*"===t.s){if(!Array.isArray(a)||0===a.length)return null;a=a[0];continue}if(Array.isArray(a)&&/^\d+$/.test(t.s)){if(Number(t.s)>=a.length)return null;a=a[Number(t.s)];continue}let n=W(a,t.s);if(void 0===n&&null===t.d&&e.ht.has(t.s))return null;if(void 0===n){let n=C(a),s=i(t.d);for(let t of e.L.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;a=n.value}return null}function L(e){M.has(e)||(M.add(e),setTimeout(()=>function(e){M.delete(e);let t=S.get(e);if(void 0===t)return;let n=A.get(e);void 0===n&&A.set(e,n=new Set);for(let[a,s]of t){if(n.has(a))continue;n.add(a);let t=q(e,a);if(null===t)continue;let r=[...e.root?.querySelectorAll(`${i.tagNames.state}[mount]`)??[]].find(e=>!P.has(e)&&(a.t+".").startsWith(e.getAttribute("mount")+"."));if(void 0!==r){n.delete(a),r.initializePromise.then(()=>{P.add(r),L(e)});continue}let[l,c]=s?["watch-path-missing","$watch path"]:["binding-path-missing","Bound path"];d.ot?.(e,{type:"state:path-unresolved",source:s?"watch":"binding",path:a.t,missingSegment:t.seg});let u=e.L.It(o(a.t).o),f="";if(void 0!==u&&u!==a&&null!==u.getter){let e=u.f.slice(1).map((e,t)=>`for: ${0===t?e.t:e.t.slice(u.f[t].t.length+2)}`);f=` The getter "${u.t}" is declared for the rows of ${e.join(" → ")}; a list named by an index has rows of its own.`}console.warn(`[@wcstack/state] [wcs/${l}] ${c} "${a.t}" does not resolve on the state tree: "${t.seg}" is not declared.${p(t.seg,t.names)}${f} Updates to this path will be silently dropped.${m}`)}}(e),0))}function D(e,t,n=!1){if("$"===t.t[0]||t.t.includes("#")||!n&&null===t.d)return;let a=S.get(e);void 0===a&&S.set(e,a=new Map),a.has(t)||a.set(t,n),L(e)}var N=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=!1;function z(e,t,i){let s="html"===i.name?"innerHTML":i.name;if(H||!(t instanceof TypeError)||!a(s)||!("trustedTypes"in globalThis))return;H=!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:i.a,property:s})}var B=new WeakMap;function U(e,t,n){let a=e[t],i=void 0===n?void 0===a?null:`the event carried no detail (undefined) while element.${t} is ${typeof a}`:null===n||"object"!=typeof n||!Object.prototype.hasOwnProperty.call(n,t)||null!==a&&"object"==typeof a?null:`the event's detail is an object with a "${t}" key while element.${t} is ${typeof a}`;if(null===i)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}": ${i}. With no getter, state receives e.detail as-is. Dispatch the value itself as detail, or declare getter (e.g. (e) => e.detail.${t}, or (e) => e.target.${t}) on that wcBindable property.`))}var F=[["$streams","$stream"],["$updatedCallback","$renderedCallback"]],E={$trackDependency:"$dependOn",$untrackDependency:"$untracked"},R={name:"diagnostics",install(){d.Ao=I,d.Fo=x,d.go=D,d.detail=U,d.He=c(d.He,z);let e=d.se;d.se=(t,n)=>{(function(e){void 0!==e.$scan&&l(1);for(let[t,n]of F)void 0!==e[t]&&l(1601,[t,n])})(n),e?.(t,n),function(e){let t=e.$recursion;if(null===t||"object"!=typeof t)return;let n=Object.entries(t);if(1!==n.length||"string"!=typeof n[0][1])return;let[a,i]=n[0];if(!a.endsWith(".*")||!i.endsWith(".*"))return;let s=a.slice(0,-2),r=i.slice(0,-2),o=`.${i}`,l=`${s}.**`,d=C(e),c=d.filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),u=e=>h(`[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(`^(?:${N(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 "${i}"). Rename one of them.`);let t=new RegExp(`^${N(a)}(?:${N(o)})*${N(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.`)}}(n),function(e){A.delete(e),S.has(e)&&L(e)}(t)},d.tt=u(f,d.tt,(e,t)=>Object.hasOwn(E,t)?l(1701,[t,E[t]]):void 0)}},_=R;export{_ as default,R as diagnostics};
@@ -1 +1 @@
1
- import{a as t,b as r,c as e,d as a,e as n,f as o,g as i,h as l,i as c}from"../chunks/chunk-SEPY6OHJ.js";import{a as y,e as u}from"../chunks/chunk-HSOCDTWX.js";import{a as s}from"../chunks/chunk-ROX5KEJX.js";import"../chunks/chunk-G2ZO6SXV.js";var f,p=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},d="en";function m(){if(y.locale!==f){f=y.locale;try{d=Intl.getCanonicalLocales(f)[0]}catch{console.warn(`[@wcstack/state] ${s(48,[f])}`),d="en"}}return d}var{eq:g,ne:S,not:h,lt:b,le:$,gt:M,ge:k,falsy:j,truthy:D,boolean:w}=c,x={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??m()))},arity:[0,1]},upper:{factory:p(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:p(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:p(()=>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:p(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:p(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:p(t=>{let r=o(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:p(t=>{let r=o(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:p(t=>{let r=o(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:p(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:p(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:p(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??m()))},arity:[0,1]},time:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("time"),t.toLocaleTimeString(r??m()))},arity:[0,1]},datetime:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("datetime"),t.toLocaleString(r??m()))},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]},eq:g,ne:S,not:h,lt:b,le:$,gt:M,ge:k,add:l("add",(t,r)=>t+r),sub:l("sub",(t,r)=>t-r),mul:l("mul",(t,r)=>t*r),div:l("div",(t,r)=>t/r),mod:l("mod",(t,r)=>t%r),abs:{factory:()=>t=>("number"!=typeof t&&r("abs"),Math.abs(t)),arity:[0,0]},clamp:{factory:t=>{let e=o(t,0,"clamp"),a=o(t,1,"clamp");return t=>("number"!=typeof t&&r("clamp"),Math.min(Math.max(t,e),a))},arity:[2,2]},int:{factory:()=>t=>parseInt(String(t),10),arity:[0,0]},float:{factory:()=>t=>parseFloat(String(t)),arity:[0,0]},falsy:j,truthy:D,defaults:{factory:(r,e)=>{let a=r?.[0]??t("defaults"),n=i(a,e);return t=>t||n},arity:[1,1]},coalesce:{factory:(r,e)=>{let a=r?.[0]??t("coalesce"),n=i(a,e);return t=>t??n},arity:[1,1]},boolean:w,number:{factory:()=>t=>Number(t),arity:[0,0]},string:{factory:()=>t=>String(t),arity:[0,0]},nullIfEmpty:{factory:()=>t=>""===t?null:t,arity:[0,0]}},F=!1,v={name:"formats",install:function(){F||(F=!0,u(x))}},C=v;export{C as default,v as formats};
1
+ import{a as t,b as r,c as e,d as a,e as n,f as o,g as i,h as l,i as c}from"../chunks/chunk-5MLEMVL3.js";import{a as y,e as u}from"../chunks/chunk-C3UYMJRT.js";import{a as s}from"../chunks/chunk-FZJY4CF3.js";import"../chunks/chunk-SA2LYPN7.js";var f,p=t=>r=>{let e=t(r);return t=>null==t?t:e(t)},d="en";function m(){if(y.locale!==f){f=y.locale;try{d=Intl.getCanonicalLocales(f)[0]}catch{console.warn(`[@wcstack/state] ${s(48,[f])}`),d="en"}}return d}var{eq:g,ne:S,not:h,lt:b,le:M,gt:$,ge:k,falsy:F,truthy:L,boolean:j}=c,w={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??m()))},arity:[0,1]},upper:{factory:p(()=>t=>String(t).toUpperCase()),arity:[0,0]},lower:{factory:p(()=>t=>String(t).toLowerCase()),arity:[0,0]},capitalize:{factory:p(()=>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:p(()=>t=>String(t).trim()),arity:[0,0]},slice:{factory:p(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:p(t=>{let r=o(t,0,"padStart"),e=t?.[1]??"0";return t=>String(t).padStart(r,e)}),arity:[1,2]},padEnd:{factory:p(t=>{let r=o(t,0,"padEnd"),e=t?.[1]??" ";return t=>String(t).padEnd(r,e)}),arity:[1,2]},repeat:{factory:p(t=>{let r=o(t,0,"repeat");return t=>String(t).repeat(r)}),arity:[1,1]},reverse:{factory:p(()=>t=>String(t).split("").reverse().join("")),arity:[0,0]},truncate:{factory:p(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:p(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??m()))},arity:[0,1]},time:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("time"),t.toLocaleTimeString(r??m()))},arity:[0,1]},datetime:{factory:t=>{let r=t?.[0];return t=>(t instanceof Date||e("datetime"),t.toLocaleString(r??m()))},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]},eq:g,ne:S,not:h,lt:b,le:M,gt:$,ge:k,add:l("add",(t,r)=>t+r),sub:l("sub",(t,r)=>t-r),mul:l("mul",(t,r)=>t*r),div:l("div",(t,r)=>t/r),mod:l("mod",(t,r)=>t%r),abs:{factory:()=>t=>("number"!=typeof t&&r("abs"),Math.abs(t)),arity:[0,0]},clamp:{factory:t=>{let e=o(t,0,"clamp"),a=o(t,1,"clamp");return t=>("number"!=typeof t&&r("clamp"),Math.min(Math.max(t,e),a))},arity:[2,2]},int:{factory:()=>t=>parseInt(String(t),10),arity:[0,0]},float:{factory:()=>t=>parseFloat(String(t)),arity:[0,0]},falsy:F,truthy:L,defaults:{factory:(r,e)=>{let a=r?.[0]??t("defaults"),n=i(a,e);return t=>t||n},arity:[1,1]},coalesce:{factory:(r,e)=>{let a=r?.[0]??t("coalesce"),n=i(a,e);return t=>t??n},arity:[1,1]},boolean:j,number:{factory:()=>t=>Number(t),arity:[0,0]},string:{factory:()=>t=>String(t),arity:[0,0]},nullIfEmpty:{factory:()=>t=>""===t?null:t,arity:[0,0]}},x=!1,C={name:"formats",install:function(){x||(x=!0,u(w))}},D=C;export{D as default,C as formats};
@@ -1 +1 @@
1
- import{a as t,b as e,c as l,d as n,j as s}from"../chunks/chunk-G2ZO6SXV.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.bt(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
+ import{a as t,b as e,c as l,d as n,j as s}from"../chunks/chunk-SA2LYPN7.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.bt(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};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The places the core calls into add-ons (docs/state-engine-rewrite/addons-plan.ja.md §1.2).
3
+ *
4
+ * Add-ons ship as separate entries of the same build as the core (`features/*`): they reach
5
+ * the core's internals directly, and the core only calls out through these slots. A slot is
6
+ * empty until an installed feature fills it (the object starts with none: a list of null slots
7
+ * would be the core's bytes), so a page without the feature pays one `?.` check. A feature
8
+ * restoring a slot may set it to null.
9
+ * Slots are added with the first feature that needs them; several features share one through
10
+ * chain / first. The slots `element` and `detail` keep their names (a DevTools-facing field and a DOM
11
+ * name share them); the others are shortened by the build. An empty slot is read through
12
+ * Object.prototype: a page that polluted it (a value under `element`, say) breaks the core loudly
13
+ * there, as it does wherever the core reads a plain object's keys (`$behavior`); not defended.
14
+ */
15
+
16
+ /** An add-on entry: `installFeatures([temporal, diagnostics])` before the state is defined. */
17
+ interface Feature {
18
+ readonly name: string;
19
+ install(): void;
20
+ }
21
+
22
+ /**
23
+ * The native-commands add-on (@wcstack/state/features/native-commands): `command.<method>:` on a
24
+ * native element (README "Native element commands") — `showModal` / `close` on a `<dialog>`,
25
+ * `focus` on an `<input>`, `play` / `pause` on a `<video>`, from the table in native/commands.ts.
26
+ * Without it a native element's `command.` fails as before (`[wcs/token-misconfigured]`).
27
+ */
28
+
29
+ declare const nativeCommands: Feature;
30
+
31
+ export { nativeCommands as default, nativeCommands };
@@ -0,0 +1 @@
1
+ import{b as e}from"../chunks/chunk-FZJY4CF3.js";import{a as t}from"../chunks/chunk-SA2LYPN7.js";var i={"*":["focus","blur","click","scrollIntoView","showPopover","hidePopover","togglePopover"],dialog:["show","showModal","close","requestClose"],form:["requestSubmit","checkValidity","reportValidity"],input:["select","setSelectionRange","showPicker","setCustomValidity","checkValidity","reportValidity"],textarea:["select","setSelectionRange","setCustomValidity","checkValidity","reportValidity"],select:["showPicker","setCustomValidity","checkValidity","reportValidity"],audio:["play","pause","load"],video:["play","pause","load"]};function o(t,o){let a=t.localName;if(a.includes("-"))return null;let l=(e=>[...i["*"],...Object.hasOwn(i,e)?i[e]:[]])(a);return l.includes(o)||e(1205,[a,o,l.join(", ")],o,l),(e,t)=>e[o](...t[0]instanceof Event?[]:t)}var a={name:"native-commands",install(){t.Yo=o}},l=a;export{l as default,a as nativeCommands};
@@ -1 +1 @@
1
- import{m as e}from"../chunks/chunk-5LIOXC7W.js";import{b as t}from"../chunks/chunk-ROX5KEJX.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-G2ZO6SXV.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.L.It(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
+ import{m as e}from"../chunks/chunk-ACYOJ3NW.js";import{b as t}from"../chunks/chunk-FZJY4CF3.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-SA2LYPN7.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.L.It(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};