@wcstack/state 4.6.1 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.ja.md +39 -12
  2. package/README.md +41 -12
  3. package/dist/auto.min.js +1 -1
  4. package/dist/auto.min.js.map +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/manifest.esm.js +5 -5
  8. package/dist/split/auto.js +1 -1
  9. package/dist/split/chunks/chunk-BCL75PFH.js +2 -0
  10. package/dist/split/chunks/chunk-BCL75PFH.js.map +1 -0
  11. package/dist/split/chunks/{chunk-JWRQLKOQ.js → chunk-DRSAQE4E.js} +2 -2
  12. package/dist/split/chunks/{chunk-GBBBRPZR.js → chunk-GQTEYSRZ.js} +2 -2
  13. package/dist/split/chunks/{chunk-FBBHQU7S.js → chunk-IBGHHABS.js} +2 -2
  14. package/dist/split/chunks/{chunk-T3FN37DU.js → chunk-P3EXTBXC.js} +2 -2
  15. package/dist/split/chunks/{chunk-CBMAVRYG.js → chunk-PKEAYPFR.js} +2 -2
  16. package/dist/split/chunks/chunk-QMOIMPIJ.js +2 -0
  17. package/dist/split/chunks/chunk-QMOIMPIJ.js.map +1 -0
  18. package/dist/split/chunks/chunk-T3KW5DZD.js +2 -0
  19. package/dist/split/chunks/chunk-T3KW5DZD.js.map +1 -0
  20. package/dist/split/chunks/chunk-UN6ADZKP.js +2 -0
  21. package/dist/split/chunks/{chunk-RIZH2AQE.js.map → chunk-UN6ADZKP.js.map} +1 -1
  22. package/dist/split/chunks/chunk-XXVJ6J2N.js +2 -0
  23. package/dist/split/chunks/chunk-XXVJ6J2N.js.map +1 -0
  24. package/dist/split/core.d.ts +2 -0
  25. package/dist/split/core.js +1 -1
  26. package/dist/split/features/devtools.d.ts +2 -0
  27. package/dist/split/features/devtools.js +1 -1
  28. package/dist/split/features/devtools.js.map +1 -1
  29. package/dist/split/features/diagnostics.d.ts +2 -0
  30. package/dist/split/features/diagnostics.js +1 -1
  31. package/dist/split/features/diagnostics.js.map +1 -1
  32. package/dist/split/features/formats.d.ts +2 -0
  33. package/dist/split/features/formats.js +1 -1
  34. package/dist/split/features/formats.js.map +1 -1
  35. package/dist/split/features/list-keys.d.ts +2 -0
  36. package/dist/split/features/list-keys.js +1 -1
  37. package/dist/split/features/list-keys.js.map +1 -1
  38. package/dist/split/features/native-commands.d.ts +2 -0
  39. package/dist/split/features/native-commands.js +1 -1
  40. package/dist/split/features/native-commands.js.map +1 -1
  41. package/dist/split/features/recursion.d.ts +2 -0
  42. package/dist/split/features/recursion.js +1 -1
  43. package/dist/split/features/recursion.js.map +1 -1
  44. package/dist/split/features/scopes.d.ts +2 -0
  45. package/dist/split/features/scopes.js +1 -1
  46. package/dist/split/features/scopes.js.map +1 -1
  47. package/dist/split/features/ssr.d.ts +2 -0
  48. package/dist/split/features/ssr.js +1 -1
  49. package/dist/split/features/ssr.js.map +1 -1
  50. package/dist/split/features/temporal.d.ts +2 -0
  51. package/dist/split/features/temporal.js +1 -1
  52. package/dist/split/features/temporal.js.map +1 -1
  53. package/package.json +1 -1
  54. package/dist/split/chunks/chunk-467LYA2V.js +0 -2
  55. package/dist/split/chunks/chunk-467LYA2V.js.map +0 -1
  56. package/dist/split/chunks/chunk-RIZH2AQE.js +0 -2
  57. package/dist/split/chunks/chunk-TNYNJXEC.js +0 -2
  58. package/dist/split/chunks/chunk-TNYNJXEC.js.map +0 -1
  59. package/dist/split/chunks/chunk-ULMHOGJ2.js +0 -2
  60. package/dist/split/chunks/chunk-ULMHOGJ2.js.map +0 -1
  61. package/dist/split/chunks/chunk-ZJYPRSTO.js +0 -2
  62. package/dist/split/chunks/chunk-ZJYPRSTO.js.map +0 -1
  63. /package/dist/split/chunks/{chunk-JWRQLKOQ.js.map → chunk-DRSAQE4E.js.map} +0 -0
  64. /package/dist/split/chunks/{chunk-GBBBRPZR.js.map → chunk-GQTEYSRZ.js.map} +0 -0
  65. /package/dist/split/chunks/{chunk-FBBHQU7S.js.map → chunk-IBGHHABS.js.map} +0 -0
  66. /package/dist/split/chunks/{chunk-T3FN37DU.js.map → chunk-P3EXTBXC.js.map} +0 -0
  67. /package/dist/split/chunks/{chunk-CBMAVRYG.js.map → chunk-PKEAYPFR.js.map} +0 -0
@@ -426,11 +426,11 @@ var registered = {
426
426
  percent: { factory: percent, arity: [0, 1] },
427
427
  unit: { factory: nullishPassthrough(unit), arity: [1, 1] },
428
428
  // The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), and a style (`date(ja-JP,long)`)
429
- date: { factory: date, arity: [0, 2] },
430
- time: { factory: time, arity: [0, 2] },
431
- datetime: { factory: datetime, arity: [0, 2] },
432
- ymd: { factory: ymd, arity: [0, 1] },
433
- hms: { factory: hms, arity: [0, 1] },
429
+ date: { factory: nullishPassthrough(date), arity: [0, 2] },
430
+ time: { factory: nullishPassthrough(time), arity: [0, 2] },
431
+ datetime: { factory: nullishPassthrough(datetime), arity: [0, 2] },
432
+ ymd: { factory: nullishPassthrough(ymd), arity: [0, 1] },
433
+ hms: { factory: nullishPassthrough(hms), arity: [0, 1] },
434
434
  // the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
435
435
  eq: eq2,
436
436
  ne: ne2,
@@ -1,2 +1,2 @@
1
- import{d as t}from"./chunks/chunk-ULMHOGJ2.js";import"./chunks/chunk-GBBBRPZR.js";import"./chunks/chunk-467LYA2V.js";import"./chunks/chunk-FBBHQU7S.js";import"./chunks/chunk-ZJYPRSTO.js";import{a as n}from"./chunks/chunk-T3FN37DU.js";import"./chunks/chunk-NITPUCPA.js";import"./chunks/chunk-CBMAVRYG.js";import"./chunks/chunk-JWRQLKOQ.js";import{a as s,g as o}from"./chunks/chunk-TNYNJXEC.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.kt=t=>a(t).then(o),"loading"===document.readyState&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0}));var c=document.querySelector(`${n.tagNames.state}:not([mount]):not([bind-component])`);o(await a(c?.getAttribute("features")?.split(/\s+/).filter(Boolean)??[])),t();
1
+ import{d as t}from"./chunks/chunk-QMOIMPIJ.js";import"./chunks/chunk-GQTEYSRZ.js";import"./chunks/chunk-XXVJ6J2N.js";import"./chunks/chunk-IBGHHABS.js";import"./chunks/chunk-T3KW5DZD.js";import{a as n}from"./chunks/chunk-P3EXTBXC.js";import"./chunks/chunk-NITPUCPA.js";import"./chunks/chunk-PKEAYPFR.js";import"./chunks/chunk-DRSAQE4E.js";import{a as s,g as o}from"./chunks/chunk-BCL75PFH.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.kt=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();
2
2
  //# sourceMappingURL=auto.js.map
@@ -0,0 +1,2 @@
1
+ var r={};function t(r,t){return null==r?t:(...e)=>{r(...e),t(...e)}}function e(r,t,e){return null==t?e:(...o)=>{let a=t(...o);return r(a)?a:e(...o)}}var o=r=>!0===r,a=r=>void 0!==r,n=r=>null!=r,s=new Set;function f(t){for(let e of t)if(!s.has(e.name)){if(e.hooks!==r)throw new Error(`[@wcstack/state] [wcs/feature-foreign] The add-on "${e.name}" is from another copy of @wcstack/state (another version, or another URL): load the core and its add-ons from one build`);s.add(e.name),e.install()}}function i(t){let e=t.$features;if(null!=r.kt&&Array.isArray(e)){let t=e.filter(r=>!s.has(r));if(t.length>0)return r.kt(t)}}function c(r,t){if(!s.has(r))throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${t} needs the add-on @wcstack/state/features/${r}`)}function u(t,e,o){throw new Error(`[@wcstack/state] ${t}${r.Bo?.(t,e,o)??""}`)}function l(r,t,...e){"function"!=typeof reportError?console.error(...void 0===t?[r]:[t,r],...e):reportError(void 0===t?r:new Error(`${t} ${r}`,{cause:r}))}export{r as a,t as b,e as c,o as d,a as e,n as f,f as g,i as h,c as i,u as j,l as k};
2
+ //# sourceMappingURL=chunk-BCL75PFH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hooks","chain","prev","fn","a","first","answered","r","handled","known","taken","installed","Set","installFeatures","features","f","has","name","Error","add","install","loadFeatures","state","names","$features","load","Array","isArray","missing","filter","n","length","requireFeature","feature","what","raiseError","message","subject","candidates","explain","report","error","rest","reportError","console","cause","t","d","s","u","g","c","w","p","k","v"],"sources":["../../../src/hooks.ts","../../../src/parser/raiseError.ts"],"sourcesContent":["/**\n * The places the core calls into add-ons (docs/state-engine-rewrite/addons-plan.ja.md §1.2).\n *\n * Add-ons ship as separate entries of the same build as the core (`features/*`): they reach\n * the core's internals directly, and the core only calls out through these slots. A slot is\n * empty until an installed feature fills it (the object starts with none: a list of null slots\n * would be the core's bytes), so a page without the feature pays one `?.` check. A feature\n * restoring a slot may set it to null.\n * Slots are added with the first feature that needs them; several features share one through\n * chain / first. The slots `element` and `detail` keep their names (a DevTools-facing field and a DOM\n * name share them); the others are shortened by the build. An empty slot is read through\n * Object.prototype: a page that polluted it (a value under `element`, say) breaks the core loudly\n * there, as it does wherever the core reads a plain object's keys (`$behavior`); not defended.\n */\nimport type { Engine } from \"./engine\";\nimport type { Pattern } from \"./pattern\";\nimport type { StateList, StateRow } from \"./list\";\nimport type { Binding, RowPlan, Spec } from \"./dom/view\";\n\nexport interface Hooks {\n /** Diagnostics: extra text for an error message (did-you-mean, lint pointer, how to fix). */\n explain?: ((message: string, subject?: string, candidates?: Iterable<string>) => string) | null;\n /** Diagnostics: the full sentence of a numbered core message (`src/messages.ts`). */\n render?: ((id: number, args: readonly unknown[]) => string) | null;\n /**\n * A write before it is applied (`element`: an element wrote it back, not code); true = the\n * add-on handled it ($listKeys, a read-only mount dropping an element's write).\n */\n beforeWrite?: ((engine: Engine, p: Pattern, row: StateRow | null, value: unknown, element: boolean) => boolean) | null;\n /** A write landed: `direct` for a data write (then `old` is the value before, `value` the new one). */\n /** `element`: an element wrote it (a binding's write-back or its initial value), not code. */\n written?: ((engine: Engine, p: Pattern, row: StateRow | null, old: unknown, value: unknown, direct: boolean, element?: boolean) => void) | null;\n /** A change reached a getter occurrence whose cached value was current (it may now differ). */\n getterReached?: ((engine: Engine, g: Pattern, row: StateRow | null) => void) | null;\n /** A list was reconciled with a new value; `old` are its rows before. */\n listSynced?: ((engine: Engine, list: StateList, old: StateRow[]) => void) | null;\n /** A drain ended (after its report and `$renderedCallback`). */\n drained?: ((engine: Engine) => void) | null;\n /** A state object was received (construction, or a re-set before it replaces the old one). */\n declare?: ((engine: Engine, target: Record<string, any>) => void) | null;\n /**\n * A root engine's lifecycle: \"mounting\" (created, its page not bound yet), \"back\" (its `<wcs-state>`\n * connected again, before `$connectedCallback` runs again: it holds its root again, unless another\n * one bound it meanwhile), \"connected\" (after `$connectedCallback`, and on reconnect), \"disconnected\",\n * \"reset\" (after a re-set).\n */\n element?: ((engine: Engine, phase: \"mounting\" | \"back\" | \"connected\" | \"disconnected\" | \"reset\") => void) | null;\n /**\n * A `<wcs-state>` an add-on takes over instead of it becoming a root (a volume, a DCC\n * definition): asked when it connects; the core then only loads its state.\n */\n claim?: ((el: HTMLElement, root: Node) => Claimed | null) | null;\n /** A `$` name the core does not know. */\n dollar?: ((engine: Engine, key: string) => unknown) | null;\n /** A binding failed to apply (reported after the drain, before `$errorCallback` / the console). */\n failed?: ((engine: Engine, error: unknown, binding: Binding) => void) | null;\n /**\n * A plain property binding on a custom element, made and not yet registered or applied (a\n * component mount's wiring, `state.x: path`); true = an add-on took it over.\n */\n hostBinding?: ((binding: Binding, ro: boolean) => boolean) | null;\n /** An element whose content an add-on binds (a Light DOM component): the walker leaves it. */\n componentScope?: ((el: Element) => boolean) | null;\n /**\n * The page walker replaced a structural template with its anchor (`source` is the template),\n * bound a mustache text node (`source` is its expression), or is about to bind an element\n * (`source` is its specs, which the hook may take some out of): SSR records the first two, and\n * on the server leaves `outerHTML:` to the client.\n */\n ssrMark?: ((engine: Engine, node: Node, source: Element | string | Spec[]) => void) | null;\n /**\n * A block is about to be cloned from `plan` for the view anchored at `anchor`: an add-on may\n * hand over existing nodes instead (SSR hydration) — the block's top-level nodes, already where\n * the block renders (the view inserts nothing), with the plan's nodes in them in `plan.scratch`.\n */\n adopt?: ((plan: RowPlan, anchor: Node, isFor: boolean) => ChildNode[] | null) | null;\n /**\n * A Light DOM component's engine is about to bind `root` (its host): SSR hands over the server's\n * nodes there too; the function returned is called when the walk is done.\n */\n adoptScope?: ((root: Node, engine: Engine) => (() => void) | null) | null;\n /** A path a binding (or, with `watch`, a `$watch` key) names: diagnostics checks it exists. */\n declared?: ((engine: Engine, p: Pattern, watch?: boolean) => void) | null;\n /** `<wcs-state>` was defined in `registry`: an add-on defines its own tags there (`<wcs-ssr>`). */\n tags?: ((registry: CustomElementRegistry) => void) | null;\n /** A wc-bindable property's event read with the default getter (`e.detail`): diagnostics checks its shape. */\n detail?: ((el: Element, name: string, detail: unknown) => void) | null;\n /** The handler `path` of a delegated `on<type>:` threw (reported already): diagnostics says when `currentTarget` is why. */\n handlerThrew?: ((engine: Engine, path: string, type: string) => void) | null;\n /**\n * `command.<method>:` on an element with no wc-bindable declaration: how a native element's\n * method is called (native-commands), or null for a custom element. The add-on throws for a\n * method a native element may not be commanded to run.\n */\n nativeCommand?: ((el: Element, method: string) => NativeCall | null) | null;\n /** The split auto entry: loads and installs add-ons of its build by name (a state's `$features`). */\n load?: ((names: string[]) => Promise<void>) | null;\n /**\n * An event an add-on (or the core) reports for the DevTools protocol (a `$watch` handler fired or\n * threw, a `$watch` chain or an update loop cut, a path that does not resolve): `event` is the\n * protocol's payload, its keys quoted (`{ \"type\": \"state:watch-fired\", \"path\": … }`). Called as\n * `hooks.noticed?.(engine, {…})`, the payload is built only while the slot is filled.\n */\n noticed?: ((engine: Engine, event: Record<string, unknown>) => void) | null;\n}\n\n/** Calls a native element's command method with what the token was emitted with. */\nexport type NativeCall = (target: Element, args: unknown[]) => unknown;\n\n/** What an add-on does with a `<wcs-state>` it claimed. */\nexport interface Claimed {\n /** Where the state comes from, when not from the element's own sources. */\n load?(): Promise<Record<string, any>>;\n /**\n * The loaded state; `connectedCallbackPromise` resolves when this is done, and `built` is called\n * once its bindings are built (before `$connectedCallback`: getBindingsReady resolves then, as for a\n * root). When it (or the load) throws, the core reports the failure and rejects the promise with\n * it — a DCC definition, a component mount: 3.x's README promises it for their configuration\n * errors, and 4.0 also rejects where 3.x did not (a component whose root failed: 3.x left it\n * unsettled; a second mount in one scope: 3.x resolved it) — or resolves it, for a lenient claim.\n */\n start(state: Record<string, any>, built: () => void): Promise<void> | void;\n /** A failure resolves `connectedCallbackPromise` instead (a volume settles without grafting, as 3.x). */\n lenient?: boolean;\n connected(): void;\n disconnected(): void;\n /** `setInitialState` after the start. */\n reset(state: Record<string, any>): void;\n}\n\nexport const hooks: Hooks = {};\n\ntype HookFn = (...args: any[]) => any;\n\n/*\n * A feature fills a slot by assigning it (`hooks.written = chain(hooks.written, fn)`), never by\n * its name as a string: the slot names are shortened by the build (mangle.mjs) like any internal\n * property.\n */\n\n/** A slot several features share: `fn` runs after whatever is there. */\nexport function chain<F extends HookFn>(prev: F | null | undefined, fn: F): F {\n return prev == null ? fn : ((...a: unknown[]) => { prev(...a); fn(...a); }) as F;\n}\n\n/** A slot whose first answer wins (`answered` tells one): `fn` is asked when what is there does not answer. */\nexport function first<F extends HookFn>(answered: (r: unknown) => boolean, prev: F | null | undefined, fn: F): F {\n return prev == null ? fn : ((...a: unknown[]) => { const r = prev(...a); return answered(r) ? r : fn(...a); }) as F;\n}\n\n/** `beforeWrite`: the first feature that handles the write. */\nexport const handled = (r: unknown): boolean => r === true;\n/** `dollar`: the first feature that knows the `$` name (a value, possibly null or false). */\nexport const known = (r: unknown): boolean => r !== undefined;\n/** `claim`: the first feature that takes the `<wcs-state>`. */\nexport const taken = (r: unknown): boolean => r != null;\n\n/** An add-on entry: `installFeatures([temporal, diagnostics])` before the state is defined. */\nexport interface Feature {\n readonly name: string;\n /** The slots of the build it comes from: it fills only those (the core checks they are its own). */\n readonly hooks: object;\n install(): void;\n}\n\nconst installed = new Set<string>();\n\nexport function installFeatures(features: readonly Feature[]): void {\n for (const f of features) {\n if (installed.has(f.name)) continue;\n // An add-on of another copy of the engine — another version (a vendor directory replaced in place),\n // or the same files under another URL (esm.run) — fills that copy's slots: its name would pass\n // requireFeature, and a `$watch` would never run, without a word (docs/seam-apps.md, prod-booking)\n if (f.hooks !== hooks) {\n throw new Error(`[@wcstack/state] [wcs/feature-foreign] The add-on \"${f.name}\" is from another copy of @wcstack/state (another version, or another URL): load the core and its add-ons from one build`);\n }\n installed.add(f.name);\n f.install();\n }\n}\n\n/**\n * A state's `$features` before its engine is made: the missing add-ons, loaded where an entry can\n * load them (`hooks.load`); undefined when there is nothing to wait for. The engine then checks\n * every name (a bundle or the full build only checks).\n */\nexport function loadFeatures(state: Record<string, any>): Promise<void> | undefined {\n const names = state.$features;\n if (hooks.load != null && Array.isArray(names)) {\n const missing = names.filter((n) => !installed.has(n));\n if (missing.length > 0) return hooks.load(missing);\n }\n}\n\n/** The barrier: a declaration that needs a feature the page did not install. */\nexport function requireFeature(feature: string, what: string): void {\n if (!installed.has(feature)) {\n throw new Error(`[@wcstack/state] [wcs/feature-not-installed] ${what} needs the add-on @wcstack/state/features/${feature}`);\n }\n}\n","import { hooks } from \"../hooks\";\n\n/**\n * Throws `[@wcstack/state] <message>`. The core's messages state the fact (a number and values); the\n * diagnostics add-on, when installed, appends the guidance (the nearest of `candidates` to\n * `subject`, how to fix it, the lint pointer).\n */\nexport function raiseError(message: string, subject?: string, candidates?: Iterable<string>): never {\n throw new Error(`[@wcstack/state] ${message}${hooks.explain?.(message, subject, candidates) ?? \"\"}`);\n}\n\n/**\n * Reports an error the engine caught or found — a getter, a filter, a handler or a callback of the\n * page that threw, a `<wcs-state>` that failed to initialize, an update loop cut — through the\n * platform's `reportError()`, so the page's error handlers (`window.onerror`, an `error` listener)\n * see it as an uncaught error, and the console shows it. A production error reporter heard none of\n * them when they went to `console.error` (docs/seam-apps.md, prod-booking). `message` says where\n * (the element, the binding): the reported Error carries both, with the original as its `cause`.\n * Where there is no `reportError()` (happy-dom, Node) it is `console.error` with the arguments as\n * before.\n */\nexport function report(error: unknown, message?: string, ...rest: unknown[]): void {\n if (typeof reportError !== \"function\") console.error(...(message === undefined ? [error] : [message, error]), ...rest);\n else reportError(message === undefined ? error : new Error(`${message} ${error}`, { cause: error }));\n}\n"],"mappings":"AAkIO,IAAMA,EAAe,CAAC,EAWtB,SAASC,EAAwBC,EAA4BC,GAClE,OAAe,MAARD,EAAeC,MAAUC,KAAmBF,KAAQE,GAAID,KAAMC,EAAI,CAC3E,CAGO,SAASC,EAAwBC,EAAmCJ,EAA4BC,GACrG,OAAe,MAARD,EAAeC,MAAUC,KAAmB,IAAMG,EAAIL,KAAQE,GAAI,OAAOE,EAASC,GAAKA,EAAIJ,KAAMC,EAAI,CAC9G,CAGO,IAAMI,EAAWD,IAA8B,IAANA,EAEnCE,EAASF,QAA8B,IAANA,EAEjCG,EAASH,GAA6B,MAALA,EAUxCI,EAAY,IAAIC,IAEf,SAASC,EAAgBC,GAC9B,QAAWC,KAAKD,EACd,IAAIH,EAAUK,IAAID,EAAEE,MAIpB,IAAIF,EAAEf,QAAUA,EACd,MAAM,IAAIkB,MAAM,sDAAsDH,EAAEE,gIAE1EN,EAAUQ,IAAIJ,EAAEE,MAChBF,EAAEK,SAAQ,CAEd,CAOO,SAASC,EAAaC,GAC3B,IAAMC,EAAQD,EAAME,UACpB,GAAkB,MAAdxB,EAAMyB,IAAgBC,MAAMC,QAAQJ,GAAQ,CAC9C,IAAMK,EAAUL,EAAMM,OAAQC,IAAOnB,EAAUK,IAAIc,IACnD,GAAIF,EAAQG,OAAS,EAAG,OAAO/B,EAAMyB,GAAKG,EAC5C,CACF,CAGO,SAASI,EAAeC,EAAiBC,GAC9C,IAAKvB,EAAUK,IAAIiB,GACjB,MAAM,IAAIf,MAAM,gDAAgDgB,8CAAiDD,IAErH,CChMO,SAASE,EAAWC,EAAiBC,EAAkBC,GAC5D,MAAM,IAAIpB,MAAM,oBAAoBkB,IAAUpC,EAAMuC,KAAUH,EAASC,EAASC,IAAe,KACjG,CAYO,SAASE,EAAOC,EAAgBL,KAAqBM,GAC/B,mBAAhBC,YAA4BC,QAAQH,cAAsB,IAAZL,EAAwB,CAACK,GAAS,CAACL,EAASK,MAAYC,GAC5GC,iBAAwB,IAAZP,EAAwBK,EAAQ,IAAIvB,MAAM,GAAGkB,KAAWK,IAAS,CAAEI,MAAOJ,IAC7F,QAAAK,OAAA1C,OAAA2C,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{a as n,j as t}from"./chunk-TNYNJXEC.js";function i(t,i=[]){return n.Mo?.(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};
2
- //# sourceMappingURL=chunk-JWRQLKOQ.js.map
1
+ import{a as n,j as t}from"./chunk-BCL75PFH.js";function i(t,i=[]){return n.Mo?.(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};
2
+ //# sourceMappingURL=chunk-DRSAQE4E.js.map
@@ -1,2 +1,2 @@
1
- import{p as n,r as t}from"./chunk-467LYA2V.js";import{a as l,b as e,c as r}from"./chunk-NITPUCPA.js";import{a as o}from"./chunk-TNYNJXEC.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=n.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?f.set(l,e):t(r,l,e?.range)}function c(){let n=[...f];f.clear();for(let[t,l]of n)a(t,l);!function(){let n=function(){let n=globalThis[i];return null==n||"wcs-binder"!==n.protocol||"number"!=typeof n.version||n.version<1||"function"!=typeof n.bind?null:n}();if(null===n)return;let t=function(){let n=globalThis,t=n[u];return void 0===t&&(t=[],n[u]=t),t}();if(0===t.length)return;let l=t.splice(0,t.length),e=function(){let n=globalThis,t=n[s];return void 0===t&&(t=new WeakSet,n[s]=t),t}();for(let t of l)e.add(t),n.bind(t)}()}function b(){let n=globalThis;void 0===n[i]&&(n[i]={protocol:"wcs-binder",version:1,bind:a})}var d=class{constructor(){this.name="dirty",this.Z=(n,t)=>{if(0===n.n){let t=n.Y;return t!==l&&t!==e&&(n.Y=e,!0)}let r=null===t?null:t.bt;if(null===r)return!1;let o=r[n.F];return o!==l&&o!==e&&(r[n.F]=e,!0)}}Jo(n,t,l){null!==t.getter&&this.Z(t,l),n.Nt(t,l),n.xn(t,l,this.Z)}Ho(n,t){let l=t.l.o.jt;if(null!==l)for(let e of l)e.n===t.l.n?n.st(e,t,this.Z):n.en(t,e,t=>n.st(e,t,this.Z))}ke(n,t,l){this.Z(t,l),o.Se?.(n,t,l),n.Nt(t,l),n.xn(t,l,this.Z)}Ko(n,t,o){let i=0===t.n;if(!i&&null===o)return;let u=i?null:o.bt??=new Array(n.Le).fill(l),s=null===u?t.Y:u[t.F];if(s!==l&&s!==e&&s!==r&&(null===u||t.F in u))return s;s=r;try{return s=n.Uo(t,null===u?null:o)}finally{null===u?t.Y=s:u[t.F]=s}}Xt(n){n.bt=null}tt(n){for(let t of n.O.all())null!==t.getter&&(0===t.n?t.Y===e&&(t.Y=r):n.nn(t.h[t.n],n=>{let l=n.bt;null!==l&&l[t.F]===e&&(l[t.F]=r)}))}};export{a,c as b,b as c,d};
2
- //# sourceMappingURL=chunk-GBBBRPZR.js.map
1
+ import{p as n,r as t}from"./chunk-XXVJ6J2N.js";import{a as l,b as e,c as r}from"./chunk-NITPUCPA.js";import{a as o}from"./chunk-BCL75PFH.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=n.get(l.getRootNode());void 0===r||!1===r.element?.isConnected?f.set(l,e):t(r,l,e?.range)}function c(){let n=[...f];f.clear();for(let[t,l]of n)a(t,l);!function(){let n=function(){let n=globalThis[i];return null==n||"wcs-binder"!==n.protocol||"number"!=typeof n.version||n.version<1||"function"!=typeof n.bind?null:n}();if(null===n)return;let t=function(){let n=globalThis,t=n[u];return void 0===t&&(t=[],n[u]=t),t}();if(0===t.length)return;let l=t.splice(0,t.length),e=function(){let n=globalThis,t=n[s];return void 0===t&&(t=new WeakSet,n[s]=t),t}();for(let t of l)e.add(t),n.bind(t)}()}function b(){let n=globalThis;void 0===n[i]&&(n[i]={protocol:"wcs-binder",version:1,bind:a})}var d=class{constructor(){this.name="dirty",this.Z=(n,t)=>{if(0===n.n){let t=n.Y;return t!==l&&t!==e&&(n.Y=e,!0)}let r=null===t?null:t.bt;if(null===r)return!1;let o=r[n.F];return o!==l&&o!==e&&(r[n.F]=e,!0)}}Jo(n,t,l){null!==t.getter&&this.Z(t,l),n.Nt(t,l),n.xn(t,l,this.Z)}Ho(n,t){let l=t.l.o.jt;if(null!==l)for(let e of l)e.n===t.l.n?n.st(e,t,this.Z):n.en(t,e,t=>n.st(e,t,this.Z))}ke(n,t,l){this.Z(t,l),o.Se?.(n,t,l),n.Nt(t,l),n.xn(t,l,this.Z)}Ko(n,t,o){let i=0===t.n;if(!i&&null===o)return;let u=i?null:o.bt??=new Array(n.Le).fill(l),s=null===u?t.Y:u[t.F];if(s!==l&&s!==e&&s!==r&&(null===u||t.F in u))return s;s=r;try{return s=n.Uo(t,null===u?null:o)}finally{null===u?t.Y=s:u[t.F]=s}}Xt(n){n.bt=null}tt(n){for(let t of n.O.all())null!==t.getter&&(0===t.n?t.Y===e&&(t.Y=r):n.nn(t.h[t.n],n=>{let l=n.bt;null!==l&&l[t.F]===e&&(l[t.F]=r)}))}};export{a,c as b,b as c,d};
2
+ //# sourceMappingURL=chunk-GQTEYSRZ.js.map
@@ -1,2 +1,2 @@
1
- import{e as t}from"./chunk-T3FN37DU.js";import{b as n}from"./chunk-JWRQLKOQ.js";function r(t){n(26,[t])}function e(t){n(27,[t])}function o(t,r){n(52,[t,r])}function a(t){n(53,[t])}function f(t,r){n(28,[t,r])}function u(t,r){n(29,[t,r])}function i(t){n(30,[t])}function y(t){return!(!t||isNaN(Number(t)))}function c(t,n){return y(t)||e(n),Number(t)}function s(t,n,e){return c(t?.[n]??r(e),e)}function l(t,n){return void 0!==n&&n.length>0?n[0]:t}var m=(t,n)=>({factory:r=>{let e=s(r,0,t);return r=>("number"!=typeof r&&f(t,r),n(r,e))},arity:[1,1]}),b={eq:{factory:(t,n)=>{let o=t?.[0]??r("eq"),a=l(o,n);return t=>"number"==typeof t?"string"!=typeof a?t===a:(y(o)||e("eq"),t===Number(o)):"string"==typeof t?t===o:t===a},arity:[1,1]},ne:{factory:(t,n)=>{let o=t?.[0]??r("ne"),a=l(o,n);return t=>"number"==typeof t?"string"!=typeof a?t!==a:(y(o)||e("ne"),t!==Number(o)):"string"==typeof t?t!==o:t!==a},arity:[1,1]},not:{factory:()=>t=>!t,arity:[0,0]},lt:m("lt",(t,n)=>t<n),le:m("le",(t,n)=>t<=n),gt:m("gt",(t,n)=>t>n),ge:m("ge",(t,n)=>t>=n),falsy:{factory:()=>t=>!t,arity:[0,0]},truthy:{factory:()=>t=>!!t,arity:[0,0]},boolean:{factory:()=>t=>!!t,arity:[0,0]}},g=!1;function p(){g||(g=!0,t(b))}export{r as a,o as b,a as c,f as d,u as e,i as f,c as g,s as h,l as i,m as j,b as k,p as l};
2
- //# sourceMappingURL=chunk-FBBHQU7S.js.map
1
+ import{e as t}from"./chunk-P3EXTBXC.js";import{b as n}from"./chunk-DRSAQE4E.js";function r(t){n(26,[t])}function e(t){n(27,[t])}function o(t,r){n(52,[t,r])}function a(t){n(53,[t])}function f(t,r){n(28,[t,r])}function u(t,r){n(29,[t,r])}function i(t){n(30,[t])}function y(t){return!(!t||isNaN(Number(t)))}function c(t,n){return y(t)||e(n),Number(t)}function s(t,n,e){return c(t?.[n]??r(e),e)}function l(t,n){return void 0!==n&&n.length>0?n[0]:t}var m=(t,n)=>({factory:r=>{let e=s(r,0,t);return r=>("number"!=typeof r&&f(t,r),n(r,e))},arity:[1,1]}),b={eq:{factory:(t,n)=>{let o=t?.[0]??r("eq"),a=l(o,n);return t=>"number"==typeof t?"string"!=typeof a?t===a:(y(o)||e("eq"),t===Number(o)):"string"==typeof t?t===o:t===a},arity:[1,1]},ne:{factory:(t,n)=>{let o=t?.[0]??r("ne"),a=l(o,n);return t=>"number"==typeof t?"string"!=typeof a?t!==a:(y(o)||e("ne"),t!==Number(o)):"string"==typeof t?t!==o:t!==a},arity:[1,1]},not:{factory:()=>t=>!t,arity:[0,0]},lt:m("lt",(t,n)=>t<n),le:m("le",(t,n)=>t<=n),gt:m("gt",(t,n)=>t>n),ge:m("ge",(t,n)=>t>=n),falsy:{factory:()=>t=>!t,arity:[0,0]},truthy:{factory:()=>t=>!!t,arity:[0,0]},boolean:{factory:()=>t=>!!t,arity:[0,0]}},g=!1;function p(){g||(g=!0,t(b))}export{r as a,o as b,a as c,f as d,u as e,i as f,c as g,s as h,l as i,m as j,b as k,p as l};
2
+ //# sourceMappingURL=chunk-IBGHHABS.js.map
@@ -1,2 +1,2 @@
1
- import{b as t}from"./chunk-JWRQLKOQ.js";import{j as e}from"./chunk-TNYNJXEC.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","currency"],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};
2
- //# sourceMappingURL=chunk-T3FN37DU.js.map
1
+ import{b as t}from"./chunk-DRSAQE4E.js";import{j as e}from"./chunk-BCL75PFH.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","currency"],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};
2
+ //# sourceMappingURL=chunk-P3EXTBXC.js.map
@@ -1,2 +1,2 @@
1
- import{b as t}from"./chunk-JWRQLKOQ.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?{Hn:i,args:[],literals:[]}:{Hn: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),{Ze:s,et: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};
2
- //# sourceMappingURL=chunk-CBMAVRYG.js.map
1
+ import{b as t}from"./chunk-DRSAQE4E.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?{Hn:i,args:[],literals:[]}:{Hn: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),{Ze:s,et: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};
2
+ //# sourceMappingURL=chunk-PKEAYPFR.js.map
@@ -0,0 +1,2 @@
1
+ import{b as t,c as e,d as s}from"./chunk-GQTEYSRZ.js";import{p as i,q as n}from"./chunk-XXVJ6J2N.js";import{f as o}from"./chunk-T3KW5DZD.js";import{a,b as r}from"./chunk-P3EXTBXC.js";import{a as l,b as c}from"./chunk-DRSAQE4E.js";import{a as h,h as u,i as d,k as m}from"./chunk-BCL75PFH.js";var f=0,p=new WeakMap;function b(t,e=t.getRootNode()){p.set(e,[...p.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function g(t){let e=p.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?p.get(t)!==e?g(t):Promise.reject(i.errors[0]):void 0)}var w=typeof HTMLElement>"u"?class{}:HTMLElement,y=class extends w{constructor(){super(),this.engine=null,this.Ln=!1,this.Ye=!1,this.U=null,this.Ge=null,this.loaded=!1,this.un=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.cn=t,this.No=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.an=t})}static{this.getBindingsReady=g}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Ln){if(null!==this.Ge)return void this.Ge.Je();b(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Ln=!0;let e=this.getRootNode(),s=h.ut?.(this,e);if(s)return this.Ge=s,!s.Po&&this.parentNode instanceof ShadowRoot&&b(this),void(void 0===s.kt?this.Ro():s.kt()).then(t=>(this.loaded=!0,s.start(t,()=>this.To()))).then(()=>{this.an(),this.cn()},t=>this.Pt(t,s.Po));this.start(e),b(this)}disconnectedCallback(){if(null!==this.Ge)return void this.Ge.Bn();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),b(this,e),this.xo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ye&&c(14),this.loaded)this.Ge.reset(t);else if(null===this.engine)if(null!==this.un){let e=this.un;this.un=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.Be++;try{e(s.proxy)}finally{"readonly"===t&&s.Be--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(globalThis[Symbol.for("wcstack.ssr.resolveModule")]?.(e)??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//${++f}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.un=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.Ln=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Ge)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.Nn(),this.To(),await f.$e("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.cn()}catch(t){this.Ye=!this.V,this.Pt(t)}}To(){this.V=!0,this.an()}Pt(t,e){this.ze(this.V?50:49,t),this.an(),e?this.cn():this.No(t)}ze(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);m(e,`[@wcstack/state] ${l(t,[this.localName,...s])}`)}xo(t,e,s){(async()=>this.engine.$e(t))().then(s,t=>this.ze(e,t))}},k=[];function v(){return(k=k.filter(t=>t.deref())).map(t=>t.deref())}function P(t,s){t&&r(t),function(t=customElements){e(),v().includes(t)||k.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends y{}),h.Ao?.(t)}(s)}var R=t=>g(t);export{g as a,w as b,v as c,P as d,R as e};
2
+ //# sourceMappingURL=chunk-QMOIMPIJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["loads","readyByRoot","WeakMap","enroll","el","root","getRootNode","set","get","filter","e","i","a","isConnected","lastIndexOf","getBindingsReady","list","els","Promise","any","map","initializePromise","then","bound","connectedCallbackPromise","length","reject","errors","HTMLElementBase","HTMLElement","WcsState","constructor","super","this","engine","started","failed","initial","claimed","loaded","receiveInitial","resolve","resolveConnected","rejectConnected","catch","resolveInitialize","hasConnectedCallbackPromise","connectedCallback","connected","engines","has","drainBinds","hooks","element","rerun","claim","lenient","parentNode","ShadowRoot","load","loadState","state","start","built","fail","disconnectedCallback","disconnected","delete","setInitialState","raise","reset","receive","createState","mutability","callback","readonlyDepth","proxy","createStateAsync","Proxy","t","k","receiver","v","Reflect","id","getAttribute","find","r","querySelectorAll","x","script","document","Error","text","JSON","parse","textContent","src","async","url","URL","baseURI","href","test","res","fetch","ok","status","json","globalThis","Symbol","for","default","loadSrc","querySelector","blocked","seen","effectiveDirective","startsWith","addEventListener","blob","createObjectURL","Blob","type","encodeURIComponent","setTimeout","message","String","cause","removeEventListener","revokeObjectURL","loadInnerScript","host","hasAttribute","requireFeature","loading","loadFeatures","other","Engine","DirtyStrategy","mount","watchRendered","callHook","report","at","flatMap","n","localName","name","refs","registries","deref","bootstrapState","partial","registry","setConfig","customElements","installBinder","includes","push","WeakRef","tag","config","tagNames","define","tags","buildBindings","R","I","$","J","V"],"sources":["../../../src/element.ts"],"sourcesContent":["import type { IWritableConfig } from \"./public/types\";\nimport { Engine } from \"./engine\";\nimport { engines, mount } from \"./dom/mount\";\nimport { drainBinds, installBinder } from \"./dom/binder\";\nimport { DirtyStrategy } from \"./strategy/dirty\";\nimport { config, setConfig } from \"./config\";\nimport type { Strategy } from \"./strategy/types\";\nimport { raise, M, text } from \"./messages\";\nimport { hooks, loadFeatures, requireFeature, type Claimed } from \"./hooks\";\nimport { report } from \"./parser/raiseError\";\n\nlet makeStrategy: () => Strategy = () => new DirtyStrategy();\n\n/** Chooses the invalidation strategy of every engine created from now on. */\nexport function configure(factory: () => Strategy): void {\n makeStrategy = factory;\n}\n\nlet loads = 0;\n\nasync function loadInnerScript(script: HTMLScriptElement): Promise<Record<string, any>> {\n // an import a Content-Security-Policy blocked rejects without saying why: the violation event\n // is the only witness (docs/csp.md §9)\n let blocked = false;\n const seen = (e: SecurityPolicyViolationEvent): void => {\n if (e.effectiveDirective.startsWith(\"script-src\")) blocked = true;\n };\n document.addEventListener(\"securitypolicyviolation\", seen);\n // a server (@wcstack/server) removes createObjectURL: a data: URL, unique so no load is cached\n const blob = typeof URL.createObjectURL === \"function\";\n const url = blob\n ? URL.createObjectURL(new Blob([script.text], { type: \"application/javascript\" }))\n : \"data:text/javascript;charset=utf-8,\" + encodeURIComponent(`${script.text}\\n//${++loads}`);\n try {\n const mod = await import(/* @vite-ignore */ url);\n return (mod.default ?? {}) as Record<string, any>;\n } catch (e) {\n // Firefox fires the violation a task after the rejection (Chromium and WebKit before it)\n await new Promise((r) => setTimeout(r));\n throw new Error(`[@wcstack/state] ${blocked ? text(M.InlineBlocked) : text(M.InlineFailed, [e instanceof Error ? e.message : String(e)])}`, { cause: e });\n } finally {\n document.removeEventListener(\"securitypolicyviolation\", seen);\n if (blob) URL.revokeObjectURL(url);\n }\n}\n\nasync function loadSrc(src: string): Promise<Record<string, any>> {\n const url = new URL(src, document.baseURI).href;\n if (/\\.json(?:[?#]|$)/.test(url)) {\n const res = await fetch(url);\n if (!res.ok) raise(M.LoadFailed, [src, res.status]);\n return (await res.json()) as Record<string, any>;\n }\n // on the server, the renderer's local module for the URL (protocol/ssr-snapshot.ts, resolveModule):\n // Node's loader reads no http: URL\n const mod = await import(/* @vite-ignore */ (globalThis as any)[Symbol.for(\"wcstack.ssr.resolveModule\")]?.(url) ?? url);\n return (mod.default ?? {}) as Record<string, any>;\n}\n\n/**\n * The root `<wcs-state>` elements of each root node (and the one a component mount or a DCC definition\n * has in its shadow root): a new list whenever one connects, without the ones no longer in the page.\n */\nconst readyByRoot = new WeakMap<Node, WcsState[]>();\n\n/**\n * Puts `el` among the `<wcs-state>` elements of `root` (a new list, without the ones that left) — or,\n * taken out of it, takes it off: the list holds nothing of a page that went.\n */\nfunction enroll(el: WcsState, root: Node = el.getRootNode()): void {\n readyByRoot.set(root, [...(readyByRoot.get(root) ?? []), el].filter((e, i, a) => e.isConnected && a.lastIndexOf(e) === i));\n}\n\n/**\n * Resolves when the bindings of `root` are built — by any `<wcs-state>` in it now, whatever its\n * `$connectedCallback` does then, as 3.x — and rejects, with the first failure, only when every one\n * failed before building them. A stray one (a second root, #47; one that fails to load) changes\n * nothing while another binds the root; one taken out of the page (or moved to another root) counts\n * no more (a root replaced: the new one decides). With none in it — none ever, or only ones that left —\n * it resolves at once: there is nothing to wait for (a page without state).\n */\nexport function getBindingsReady(root: Node): Promise<void> {\n const list = readyByRoot.get(root) ?? [];\n const els = list.filter((e) => e.getRootNode() === root);\n return Promise.any(els.map((el) => el.initializePromise.then((): unknown => el.bound || el.connectedCallbackPromise))).then(\n () => {},\n // none, or every one failed: one connected since (the list is a new one) may still bind the root\n // (quoted: `errors` is a name the build shortens, an AggregateError's is not)\n (e: AggregateError) => (els.length ? readyByRoot.get(root) !== list ? getBindingsReady(root) : Promise.reject(e[\"errors\"][0]) : undefined),\n );\n}\n\n/**\n * The base of the package's elements: HTMLElement, or — where there is none (Node without a DOM)\n * — an inert class, so the entries can be imported headless (a tool reading the manifest, a\n * server framework importing at the top level), as 3.x. Making an element stays a browser's.\n */\nexport const HTMLElementBase = (typeof HTMLElement === \"undefined\" ? class {} : HTMLElement) as typeof HTMLElement;\n\n/**\n * `<wcs-state>` — one engine per element, bound to the element's root node.\n * State resolution order: `state` (id of a JSON script) → `src` → `json` → inner\n * `<script type=\"module\">` → wait for `setInitialState()`.\n */\nexport class WcsState extends HTMLElementBase {\n static getBindingsReady = getBindingsReady;\n /** Servers (@wcstack/server) wait on connectedCallbackPromise when this is set. */\n static hasConnectedCallbackPromise = true;\n\n engine: Engine | null = null;\n readonly connectedCallbackPromise: Promise<void>;\n /**\n * Resolves once the state is loaded and bound (before `$connectedCallback`) — and also when\n * initialization fails: the failure is delivered on connectedCallbackPromise.\n */\n readonly initializePromise: Promise<void>;\n private resolveInitialize!: () => void;\n private resolveConnected!: () => void;\n private rejectConnected!: (e: unknown) => void;\n private started = false;\n /** Initialization failed before the page was bound: `setInitialState` refuses (#14). */\n private failed = false;\n private initial: Record<string, any> | null = null;\n /** Taken over by an add-on (a volume, a DCC definition): it never becomes a root. */\n private claimed: Claimed | null = null;\n /** A claimed element's state is loaded: `setInitialState` from now on is the add-on's re-set. */\n private loaded = false;\n /** The root's bindings are built (getBindingsReady resolves, whatever `$connectedCallback` does). */\n bound?: boolean;\n private receiveInitial: ((state: Record<string, any>) => void) | null = null;\n\n constructor() {\n super();\n this.connectedCallbackPromise = new Promise<void>((resolve, reject) => {\n this.resolveConnected = resolve;\n this.rejectConnected = reject;\n });\n this.connectedCallbackPromise.catch(() => {});\n this.initializePromise = new Promise<void>((resolve) => {\n this.resolveInitialize = resolve;\n });\n }\n\n connectedCallback(): void {\n if (this.started) {\n if (this.claimed !== null) {\n this.claimed.connected();\n return;\n }\n enroll(this);\n const engine = this.engine;\n if (engine !== null) {\n // back in the page: it holds its root again (unless another <wcs-state> bound it meanwhile),\n // binds what was handed over while it was out, and the add-ons hear of it (the volumes that\n // connected meanwhile graft) — then $connectedCallback runs again\n const root = engine.root;\n if (root === this.getRootNode() && !engines.has(root)) engines.set(root, engine);\n drainBinds();\n hooks.element?.(engine, \"back\");\n this.rerun(\"$connectedCallback\", M.ConnectedFailed, () => {\n if (this.isConnected) hooks.element?.(engine, \"connected\");\n });\n }\n return;\n }\n this.started = true;\n const root = this.getRootNode();\n const claimed = hooks.claim?.(this, root);\n if (claimed) {\n this.claimed = claimed;\n // the `<wcs-state>` of the shadow root it binds (a component's, a DCC definition's) is that\n // root's, as 3.x: getBindingsReady there waits for it — until its bindings are built, as a\n // root's — and fails with it (a volume never fails)\n if (!claimed.lenient && this.parentNode instanceof ShadowRoot) enroll(this);\n void (claimed.load === undefined ? this.loadState() : claimed.load()).then((state) => {\n this.loaded = true;\n return claimed.start(state, () => this.built());\n }).then(() => {\n this.resolveInitialize();\n this.resolveConnected();\n }, (e) => this.fail(e, claimed.lenient));\n return;\n }\n void this.start(root);\n enroll(this);\n }\n\n disconnectedCallback(): void {\n if (this.claimed !== null) {\n this.claimed.disconnected();\n return;\n }\n const engine = this.engine;\n if (engine === null) return;\n // out of the page, it lets go of its root (it holds it again when it is back): what outlives the\n // page's content — its root node, the document — does not keep its state and the DOM it bound\n // (a root that failed before its mount has none: enroll takes the root it is in now)\n const root = engine.root;\n if (engines.get(root!) === engine) engines.delete(root!);\n enroll(this, root);\n this.rerun(\"$disconnectedCallback\", M.DisconnectedFailed);\n hooks.element?.(engine, \"disconnected\");\n }\n\n /**\n * Supplies the initial state; on an initialized element, replaces the whole state and\n * re-applies every binding to it before returning (not a write: no `$renderedCallback`).\n */\n setInitialState(state: Record<string, any>): void {\n if (this.failed) raise(M.ElementFailed);\n // (until a claimed element's state is loaded, this supplies it like a root's)\n if (this.loaded) {\n this.claimed!.reset(state);\n return;\n }\n if (this.engine !== null) {\n this.engine.reset(state);\n return;\n }\n if (this.receiveInitial !== null) {\n const receive = this.receiveInitial;\n this.receiveInitial = null;\n receive(state);\n } else {\n this.initial = state;\n }\n }\n\n /** Runs `callback` with a state proxy; its writes are applied in the next drain. */\n createState(mutability: \"readonly\" | \"writable\", callback: (state: Record<string, any>) => void): void {\n const engine = this.engine;\n if (engine === null) raise(M.NotInitialized);\n if (mutability === \"readonly\") engine.readonlyDepth++;\n try {\n callback(engine.proxy);\n } finally {\n if (mutability === \"readonly\") engine.readonlyDepth--;\n }\n }\n\n /** `createState` whose callback may await; a readonly proxy stays readonly across its awaits. */\n async createStateAsync(mutability: \"readonly\" | \"writable\", callback: (state: Record<string, any>) => Promise<void>): Promise<void> {\n const engine = this.engine;\n if (engine === null) raise(M.NotInitialized);\n await callback(mutability === \"writable\" ? engine.proxy : new Proxy(engine.proxy, {\n // as in createState(\"readonly\"), the writes of $setAll and $resolve (path, indexes, value) refuse;\n // read with this view as the receiver, a method comes as it is and runs on this view\n get(t, k, receiver) {\n const v = Reflect.get(t, k, receiver);\n return k === \"$setAll\" || k === \"$resolve\" ? (...a: unknown[]) => (a.length > 2 && raise(M.Readonly), v(...a)) : v;\n },\n set() {\n raise(M.Readonly);\n },\n }));\n }\n\n private async loadState(): Promise<Record<string, any>> {\n // a parser that inserts the element before its children (a server render) has added them by now\n await 0;\n const id = this.getAttribute(\"state\");\n if (id !== null) {\n // a JSON script of that id (an element of user content with the same id, earlier, is not it)\n const find = (r: Node): HTMLScriptElement | undefined =>\n [...(r as Document).querySelectorAll<HTMLScriptElement>('script[type=\"application/json\"]')].find((x) => x.id === id);\n const script = find(this.getRootNode()) ?? find(document);\n if (script === undefined) return Promise.reject(new Error(`[@wcstack/state] ${text(M.NoScript, [id])}`));\n return Promise.resolve(JSON.parse(script.textContent || \"{}\"));\n }\n const src = this.getAttribute(\"src\");\n if (src !== null) return loadSrc(src);\n const json = this.getAttribute(\"json\");\n if (json !== null) return Promise.resolve(JSON.parse(json));\n const script = this.querySelector('script[type=\"module\"]') as HTMLScriptElement | null;\n if (script !== null) return loadInnerScript(script);\n if (this.initial !== null) return Promise.resolve(this.initial);\n return new Promise((resolve) => {\n this.receiveInitial = resolve;\n });\n }\n\n private async start(root: Node): Promise<void> {\n try {\n // what an add-on serves: a volume, a component mount, a DCC definition, server rendering\n const host = (root as ShadowRoot).host;\n if (this.hasAttribute(\"mount\") || this.hasAttribute(\"bind-component\") || host?.hasAttribute(\"data-wc-definition\")) {\n requireFeature(\"scopes\", \"<wcs-state>\");\n }\n const state = await this.loadState();\n const loading = loadFeatures(state);\n if (loading) await loading;\n // taken out of its root while it loaded (the page's content replaced, or moved to another root):\n // nothing is mounted on the root it left. It starts again where it is now, or when it connects\n // again. A state given by setInitialState() is kept for that; a state= / src= / json= / inline\n // script source is read again (a fetch runs again, an inline module is evaluated again)\n if (this.getRootNode() !== root) {\n this.initial = state;\n this.started = false;\n if (this.isConnected) this.connectedCallback();\n return;\n }\n if (this.hasAttribute(\"enable-ssr\")) requireFeature(\"ssr\", \"enable-ssr\");\n // one state tree per root: another <wcs-state> already bound this root (and still does —\n // whatever its $connectedCallback did then), or a component's took it\n const other = engines.get(root)?.element as WcsState | undefined;\n if (other?.isConnected && (other.bound || other.claimed)) raise(M.SecondRoot);\n const engine = new Engine(state, makeStrategy());\n engine.element = this;\n this.engine = engine;\n hooks.element?.(engine, \"mounting\");\n mount(engine, root as Document | ShadowRoot);\n drainBinds();\n engine.watchRendered();\n this.built();\n await engine.callHook(\"$connectedCallback\");\n if (this.isConnected) hooks.element?.(engine, \"connected\");\n this.resolveConnected();\n } catch (e) {\n // (a root that bound its page and whose $connectedCallback then failed has not: re-set stays open)\n this.failed = !this.bound;\n this.fail(e);\n }\n }\n\n /** The bindings are built (before `$connectedCallback`): getBindingsReady resolves, initializePromise too. */\n private built(): void {\n this.bound = true;\n this.resolveInitialize();\n }\n\n /**\n * Initialization failed: reported once, the element (and where its state comes from) before what\n * was thrown, as 3.5 — `<wcs-state src=\"./state.js\"> failed to initialize.`, or, once its\n * bindings were built, `… $connectedCallback failed.` — and connectedCallbackPromise rejects with\n * it, or resolves for a claim that is `lenient` (a volume).\n */\n private fail(e: unknown, lenient?: boolean): void {\n this.report(this.bound ? M.ConnectedFailed : M.InitFailed, e);\n this.resolveInitialize();\n if (lenient) this.resolveConnected();\n else this.rejectConnected(e);\n }\n\n /** Reports a failure once: the element (and where its state comes from), then what was thrown. */\n private report(id: M, e: unknown): void {\n const at = [\"mount\", \"bind-component\", \"state\", \"src\"].flatMap((n) => (this.hasAttribute(n) ? [n, this.getAttribute(n)] : []));\n report(e, `[@wcstack/state] ${text(id, [this.localName, ...at])}`);\n }\n\n /**\n * Runs a lifecycle callback of a root that connected before (on reconnect, on disconnect) at once: a\n * failure — thrown or rejected — is reported as a first connection's is, never thrown out of the\n * element's callback.\n */\n private rerun(name: string, id: M, then?: () => void): void {\n void (async () => this.engine!.callHook(name))().then(then, (e) => this.report(id, e));\n }\n}\n\n/**\n * The registries `<wcs-state>` was defined in: an add-on installed later defines its tags there\n * too. Weak: a server creates a registry per render, and holding them would keep every render's\n * registry (and every constructor defined in it) alive.\n */\nlet refs: WeakRef<CustomElementRegistry>[] = [];\n\n/**\n * The registries still alive (dead references are dropped). A registry deref() returned stays\n * alive until the end of this job, so the second deref() of each kept reference finds it.\n */\nexport function registries(): CustomElementRegistry[] {\n refs = refs.filter((r) => r.deref());\n return refs.map((r) => r.deref()!);\n}\n\n/**\n * Registers `<wcs-state>` (and the installed add-ons' tags) in `registry` — a scoped registry\n * does not inherit the global one, so a tree using one needs its own definitions.\n */\nexport function define(registry: CustomElementRegistry = customElements): void {\n installBinder();\n if (!registries().includes(registry)) refs.push(new WeakRef(registry));\n const tag = config.tagNames.state;\n if (registry.get(tag) === undefined) registry.define(tag, class extends WcsState {});\n hooks.tags?.(registry);\n}\n\n/** Applies `config` and registers `<wcs-state>`. The core only: install the add-ons first. */\nexport function bootstrapState(partial?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (partial) setConfig(partial);\n define(registry);\n}\n\n/**\n * Waits for the bindings under `root` (3.x built them here; the new engine builds them when the\n * root's `<wcs-state>` loads its state, so this only waits — the same as getBindingsReady).\n */\nexport const buildBindings = (root: Document | ShadowRoot): Promise<void> => getBindingsReady(root);\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{b as t,d as e,e as i}from"./chunk-NITPUCPA.js";import{h as l,m as s}from"./chunk-PKEAYPFR.js";import{a as n,b as r}from"./chunk-DRSAQE4E.js";import{a as h,i as o,k as u}from"./chunk-BCL75PFH.js";var f=Symbol.for("wcstack.trustedTypes.policy");function a(){let t=globalThis[f];return null!==t&&"object"==typeof t?t:null}function d(t){globalThis[f]=t}function c(t){return"innerHTML"===t||"outerHTML"===t||"srcdoc"===t}function p(t){if(globalThis.trustedTypes?.isHTML(t))return t;let e=null==t?"":String(t),i=a(),l=i?.createHTML;return"function"==typeof l?l.call(i,e):e}var g=class{constructor(t,e,i){this.bt=null,this.N=null,this.we=null,this._=null,this.u=null,this.w=!0,this.l=t,this.y=e,this.E=i}},y=class{constructor(t,e){this.R=null,this.f=[],this.N=null,this.M=null,this.te=!1,this.Bt=!1,this.vt=!1,this.o=t,this.ce=e,this.n=t.n+1}},v=[],b=class{constructor(t){this.St=new Set,this.name=t}get size(){return this.St.size}subscribe(t){return this.St.add(t),()=>{this.St.delete(t)}}unsubscribe(t){return this.St.delete(t)}emit(...t){let e=[];for(let i of this.St)try{e.push(i(...t))}catch(t){e.push(void 0),u(t,`[@wcstack/state] ${n(17,[this.name])}`)}return e}};function m(t,e,i){if(void 0===t)return[];Array.isArray(t)||r(18,[e]);let l=new Set;for(let s of t)("string"!=typeof s||""===s)&&r(19,[e]),s===i&&r(20,[e,s,i]),l.has(s)&&r(21,[e,s]),l.add(s);return t}var w=Symbol.for("wcstack.transition-runner");function $(t){let e=globalThis[w];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 k(t,e,i){let l=$(t);if(null!==l)return l.run(e,{source:t,types:i});e()}var A=[["$watch","temporal"],["$stream","temporal"],["$listKeys","list-keys"],["$recursion","recursion"]],M=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function O(t){return t.includes("**")&&s(t),t}var S=0,T=32,j=100;function E(t,e,i){let l=t.get(e);return void 0===l&&t.set(e,l=i()),l}var _=()=>new Set,R=()=>[],H=new WeakMap;function x(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function z(t,e){return t===e||t!=t&&e!=e}function B(t,e,i){let l=t._?.get(e);void 0!==l&&l.delete(i)&&0===l.size&&t._.delete(e)}function X(t,e){for(let i=0;i<e.length;i++){if(null==t)return;t=t[e[i]]}return t}function q(t,e){for(;null!==t&&t.l.n>e;)t=t.l.ce;return null!==t&&t.l.n===e?t:null}function P(t,e,i){let l=q(t,i);return null!==l&&l.l.o===e.h[i]?l:null}var G=class{constructor(t,i){this.Le=0,this.d=null,this.Be=0,this.tt=new Set,this.nt=new Map,this.Kn=Symbol("wcs.block"),this.element=null,this.$t=[],this.Me=null,this.Un=[],this.Ht=0,this.X=null,this.oe=new Map,this.ue=new Map,this.We=[],this._e=[],this.Ve=[],this.Et=!1,this.gn=!1,this.Kt=new WeakMap,this.D=0,this.Ut=0,this.yn=!1,this.qt=!1,this.zt=!1,this.Ce=0,this.qn=()=>{this.D=0,this.yn=!1},this.zn=()=>{this.Ce--},this.rp=null,this.rr=null,this.Wo=()=>this.Yt(),this._o=(t,e)=>t(this.proxy,...e),this.Yn=[],this.He=[],this.Xn={$untracked:t=>{let e=this.X;if(null===e)return t();e.be++;try{return t()}finally{e.be--}},$eqIndex:(t,e=1)=>{let i=q(this.d,e);null===i&&r(7,[t]);let l=this.o(t);if(null!==l.getter||l.ae)return this.watchIndex(e),i.y===this.read(l,null);let s=this.X;if(null!==s){let t=s.getter,i=l.je??(l.je=[]);if(!i.some(i=>i.getter===t&&i.Gn===e)){i.push({getter:t,Gn:e});let s=t.h[e];(s.Dt??(s.Dt=[])).push({source:l,getter:t})}}return i.y===this.v(l,null)},$eq:(t,e)=>this.eq(t,e),$eqPath:(t,e)=>{let i=this.o(e);return this.eq(t,this.v(i,q(this.d,i.n)))},$dependOn:t=>{this.resolve(O(t),this.d),null!==this.X&&0===this.X.be&&this.Jn(this.rp,this.rr,this.X)},$getAll:(t,e)=>this.getAll(t,e),$setAll:(t,e,i,l)=>this.wn(t,e,i,l),$resolve:(...t)=>{let e=O(t[0]),i=t[1]??[],l=this.o(e,!0);this.bn("$resolve",e,l,i,!0);let s=this.Qn(l,i,null);if(t.length<3)return this.read(l,s);this.A(l,s,t[2])},$postUpdate:t=>{this.resolve(O(t),this.d);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.E=i.l.R[i.y],H.delete(i.l.R),this.T.Xt(i)),this.vn(e,i),null!==i&&this.Zn(i,e,void 0,i.E,!1),0===e.n&&this.eo(e,void 0,void 0,!0),this.Gt(e,i,void 0,void 0,!1)}},this.T=i,this.O=new e(t=>{this.He.push(t),this.ot(t)}),this.to(t);let l=this,s={getOwnPropertyDescriptor(t,e){let i=Reflect.getOwnPropertyDescriptor(l.target,e);return i&&(i.configurable=!0),i},get(t,e,i){let s=l.target;if("symbol"==typeof e)return Reflect.get(s,e);if(36===e.charCodeAt(0))return l.rt(e);if(e.indexOf(".")<0){let t=l.O.wt(e);if(void 0===t||null===t.getter){let t=s[e];if("function"==typeof t)return i===l.proxy&&l.V?.(t)||t}if(void 0!==t&&0===t.n)return l.read(t,null)}return l.resolve(e,l.d),l.read(l.rp,l.rr)},set:(t,e,i)=>"symbol"==typeof e?Reflect.set(l.target,e,i):(l.resolve(O(e),l.d),l.A(l.rp,l.rr,i),!0)};for(let t of["has","ownKeys","deleteProperty","defineProperty","getPrototypeOf"])s[t]=(e,...i)=>Reflect[t](l.target,...i);this.proxy=new Proxy({},s)}o(t,e){let i=this.O.get(t);return e||(i.pn=!0),i}no(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 l=Object.getOwnPropertyDescriptor(i,t);if(void 0===l.get&&void 0===l.set)continue;let s=this.o(t);s.getter=l.get??null,s.se=l.set??null,null!==s.getter&&s.n>0&&(s.F=this.Le++)}for(let t of this.O.all())this.ot(t)}ot(t){t.t.includes("**")&&s(t.t),("__proto__"===t.s||"prototype"===t.s)&&r(120,[t.t]);let e=t.c;t.ae=null!==e&&"*"!==t.s&&e.n===t.n&&(null!==e.getter||e.ae),null===t.getter&&this.Vo(t)}Vo(t){let e=t.t,i=t.s;if(l.test(i))t.getter=function(){return this[i]};else{let l=e.split("."),s=l.findIndex((t,e)=>e>0&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57);if(s<0||l.indexOf("*",s)>=0)return;t.getter=()=>(this.resolve(e,this.d),this.rp!==t?this.read(this.rp,this.rr):this.read(t.c,this.d)?.[i]),t.se=l=>{if(this.resolve(e,this.d),this.rp!==t)return this.A(this.rp,this.rr,l);let s=this.read(t.c,this.d);null==s&&r(4,[e,s]),s[i]=l}}t.hn=!0,t.n>0&&(t.F=this.Le++)}Ke(t,e){let i=null===t?this.oe:t.u??=new Map,l=i.get(e);return void 0===l&&i.set(e,l=new y(e,t)),e.pn=!0,this.G(l),l}oo(t){try{this.G(t)}catch(e){this.Jt(e,t.o.t,t.N?.S??null,"for")}}G(t){let e=this.v(t.o,t.ce);if(e===t.R)return;this.io(t);let i=function(t,e,i){let l=Array.isArray(e)?e:v;if(l===t.R)return null;let s=t.f,n=l.length,r=s.length,h=new Array(n),o=0;for(;o<n&&o<r&&s[o].E===l[o];)h[o]=s[o],o++;let u=r-1,f=n-1;for(;u>=o&&f>=o&&s[u].E===l[f];)h[f]=s[u],u--,f--;if(o>u)for(let e=o;e<=f;e++)h[e]=new g(t,e,l[e]);else if(o>f)for(let t=o;t<=u;t++)i.Mt(s[t]);else{let e=u<f?u:f;for(let t=o;t<=e;t++)s[t].E===l[t]&&(h[t]=s[t]);let n=new Map;for(let t=u;t>=o;t--){let i=s[t];if(t<=e&&h[t]===i)continue;let l=n.get(i.E);void 0===l?n.set(i.E,i):Array.isArray(l)?l.push(i):n.set(i.E,[l,i])}for(let e=o;e<=f;e++){if(void 0!==h[e])continue;let i,s=l[e],r=n.get(s);void 0!==r&&(Array.isArray(r)?(i=r.pop(),0===r.length&&n.delete(s)):(i=r,n.delete(s))),h[e]=i??new g(t,e,s)}for(let t of n.values())if(Array.isArray(t))for(let e of t)i.Mt(e);else i.Mt(t)}for(let t=o;t<n;t++){let e=h[t];e.y!==t&&(e.y=t,i.Lo(e))}return t.f=h,t.R=l,s}(t,e,this);if(null===i)return;if(t.R===e){let i=E(this.Kt,e,R);if(i.push(t),i.length>1)for(let t of i)t.vt=!0}h.Qt?.(this,t,i),(null!==t.N||null!==t.M)&&!t.te&&(t.te=!0,this._e.push(t),this.ve());let l=t.o.Dt;if(null!==l)for(let{source:e,getter:s}of l){let l=this.v(e,null),n=i[l],r=t.f[l];n!==r&&(void 0!==n&&n.w&&this.kn(s,n),void 0!==r&&this.kn(s,r))}}Lo(t){this.T.Ho(this,t)}Mt(t){t.w=!1;let e=t._;if(null!==e){for(let t of e)B(t.source,t.key,t.sub);t._=null}if(null!==t.u)for(let e of t.u.values()){this.io(e);for(let t of e.f)this.Mt(t)}}io(t){let e=this.Kt.get(t.R);void 0!==e&&(e.splice(e.indexOf(t)>>>0,1),t.vt=!1,1===e.length&&(e[0].vt=!1))}resolve(t,e){let l=i(t),s=this.rp=this.o(l.o,!0),n=l.indexes;this.rr=0===s.n?null:null===n?P(e,s,s.n):this.Qn(s,n,e,t)}Qn(t,e,i,l){let s=null;for(let n,r=1,h=0;r<=t.n;r++){let o=t.h[r],u=this.Ke(s,o),f=e[h++];if(f<0)f=P(i,t,r)?.y??-1;else if(l&&u.R===v&&Object(n=this.v(o,s))===n){let e=t.t.split("."),i=o.t.split(".").length;e[i]=l.split(".")[i],t=this.o(e.join("."),!0),r--;continue}if(s=u.f[f]??null,null===s)break}return this.rp=t,s}it(t,e){return 0===t.n?X(this.target,t.z):null===e?void 0:X(e.E,t.z)}read(t,e){let i=this.X;if(null!==i&&0===i.be&&this.Jn(t,e,i),null!==t.getter)return this.T.Ko(this,t,e);if(t.ae){let i=this.read(t.c,e);return i?.[t.s]}return null===t.c&&!(t.s in this.target)&&!this.tt.has(t.s)&&"then"!==t.s&&"toJSON"!==t.s&&r(301,[t.t],t.s,Object.keys(this.target)),this.it(t,e)}v(t,e){let i=this.X;if(null===i)return this.read(t,e);i.be++;try{return this.read(t,e)}finally{i.be--}}Jn(t,e,i){let l=i.getter;t._n(l),0===l.n?t.Z!==i.de&&(t.Z=i.de,i.Sn.push(t)):t.n>0&&q(e,Math.min(t.n,l.n))!==q(i.r,Math.min(t.n,l.n))&&(l.mt??(l.mt=new Set)).add(t)}Uo(t,e){for(let i=0;i<this.Ht;i++){let l=this.Un[i];l.getter===t&&l.r===e&&r(701,[t.t])}this.Ht>=128&&r(801,[t.t]);let i=this.Ht++;this.Be++;let l=this.Un[i]??={getter:t,r:e,be:0,de:0,Sn:[]};l.getter=t,l.r=e,l.be=0,l.de=++S,l.Sn.length=0;let s=this.X;this.X=l;let n=this.d;this.d=e;try{let e=t.getter.call(this.proxy);return 0===t.n&&this.qo(t,l),e}finally{this.Be--,this.Ht--,this.X=s,this.d=n,l.r=null}}qo(t,e){let i=e.de;for(let t of e.Sn)t.Z=i;t.Q=t.Q.filter(e=>e.Z===i||e.n>0||!e.ae&&Array.isArray(null!==e.getter?e.Y:this.it(e,null))||this.so(e,t))}so(t,e){return t.Do(e),this.He.push(t),!1}zo(){for(let t=this.He;t.length>0;t=this.He){this.He=[];let e=new Set;for(let i of t)if(!(i.pn||i.mn||null===i.c||i.u.length>0||i.B.length>0)&&(null===i.getter||i.hn&&i.F<0)&&null===i._){i.mn=!0,this.O.Lt(i),e.add(i.c);for(let t of i.Q)this.so(t,i)}for(let t of e)(t.u=t.u.filter(t=>!t.mn)).length||this.He.push(t)}}watchIndex(t){let e=this.X;if(null!==e&&0===e.be){let i=e.getter,l=i.h[t];if(l){let t=l.jt??(l.jt=[]);t.includes(i)||t.push(i)}}}rt(t){let e=t.charCodeAt(1);if(e>=48&&e<=57){let i=2===t.length?e-48:l.test(t)?+t.slice(1):0;return(i<1||i>128)&&r(1001,[t]),this.watchIndex(i),q(this.d,i)?.y}let i=this.Xn[t];if(void 0!==i)return i;switch(t){case"$stateElement":return this.element;case"$command":return this.commands}return h.rt?.(this,t)}eq(t,e){this.resolve(t,this.d);let i=this.rp,l=this.rr;if(null!==i.getter||i.ae||i.n>0)return z(this.read(i,l),e);let s=this.X;return null!==s&&0===s.be&&this.Yo(i,e,s),z(this.v(i,null),e)}Yo(t,e,i){let l=i.getter,s=i.r,n=null===s?this.Yn:s._??(s._=[]);for(let s=0;s<n.length;s++){let r=n[s];if(r.sub.getter===l&&r.source===t){if(z(r.key,e))return void(r.de=i.de);r.de!==i.de&&(B(t,r.key,r.sub),n.splice(s--,1))}}let r={getter:l,r:s};E(t._??=new Map,e,_).add(r),n.push({source:t,key:e,sub:r,de:i.de})}eo(t,e,i,l){this.Zt(t,s=>{let n=s._;if(null===n&&null===s.je)return;let r=s===t?[]:s.t.slice(t.t.length+1).split("."),h=X(e,r),o=X(i,r);if(null!==s.je&&this.Xo(s,h,o,l),null!==n)for(let t of l?n.keys():[h,o]){let e=n.get(t);if(void 0!==e)for(let i of e)null===i.r||i.r.w?this.T.ke(this,i.getter,i.r):B(s,t,i)}})}A(t,e,i,l=!1,s=!1){if(this.Be>0&&r(8),s||this.Ce>0?this.qt=!0:this.zt=!0,h.Ie?.(this,t,e,i,s))return;if(null!==t.se){try{this.$n(t.se,e,[i])}finally{this.Gt(t,e,void 0,void 0,!1,s)}return}null!==t.getter&&r(2,[t.t]),t.n>0&&null===e&&r(3,[t.t]);let n=t.ae?this.v(t,e):this.it(t,e);if(l||!this._t||!Object.is(n,i)||Object(i)===i){if("*"===t.s){let t=e;t.l.R[t.y]=i,H.delete(t.l.R),t.E=i,this.T.Xt(t)}else{let l=1===t.z.length?0===t.n?this.target:e.E:this.v(t.c,e);null==l&&r(4,[t.t,l]),l[t.s]=i}this.En(t,e),null!==e&&this.Zn(e,t,n,i),0===t.n&&this.eo(t,n,i),this.Gt(t,e,n,i,!0,s)}}lo(t){return(this.Kt.get(t.R)??[]).filter(e=>e.R===t.R&&(null===e.ce||e.ce.w))}Zn(e,i,l,s,n=!0){let r=e.l,h=i.t.slice(r.o.t.length+2),o=""!==h&&function(t){let e=H.get(t);if(void 0===e){let i=new Set;H.set(t,e=t.some(t=>Object(t)===t&&(i.has(t)||!i.add(t))))}return e}(r.R);if(!o&&!r.vt&&null===r.o.getter&&!r.o.B.length)return;let u=e.E,f=(t,i)=>{if(void 0===i||i===e)return;let r=this.o(`${t.o.t}.*${h}`,!0);""===h&&(i.E=s,this.T.Xt(i)),n?this.En(r,i):this.vn(r,i),this.Gt(r,i,l,s,n)};for(let t of this.lo(r))if(f(t,t.f[e.y]),o)for(let i of t.f)i.E===u&&i.y!==e.y&&f(t,i);if(""===h)return;let a=new Set([r.R]),d=t=>Array.isArray(t)&&t.includes(u),c=(e,i)=>{if(!a.has(e)&&a.add(e))for(let t of this.Kt.get(e)??[])for(let e of t.f)e.E===u&&f(t,e);for(let l of i){let i=l.Y,s=i===t;s&&(i=this.oe.get(l)?.R),(s||d(i))&&!a.has(l.B)&&a.add(l.B)&&(!s&&i!==e&&this.T.ke(this,l,null),c(i,l.B))}},p=t=>{for(let e of t.Q)if(!a.has(e)&&a.add(e))if(null!==e.getter)p(e);else if(!e.ae){let t=this.it(e,null);d(t)&&c(t,e.B)}};null!==r.o.getter?p(r.o):c(r.R,r.o.B)}vn(t,e){this.Go(t,e,t=>{this.G(t);for(let e of t.vt?this.lo(t):[t]){let t=this.o(`${e.o.t}.*`);for(let i of e.f)this.Nt(t,i),this.vn(t,i)}})}En(t,e){let i=null===e?this.oe:e.u;if(null!==i)for(let e of i.values())e.o.ee(t)&&this.G(e)}Go(t,e,i){let l=null===e?this.oe:e.u;if(null!==l)for(let e of l.values())e.o.ee(t)&&i(e)}Xo(t,e,i,l){for(let{getter:s,Gn:n}of t.je)this.ao(s.h[n],t=>{for(let n of l?t.f.keys():[e,i]){let e="number"==typeof n?t.f[n]:void 0;void 0!==e&&this.kn(s,e)}})}kn(t,e){e.l.n===t.n?this.T.ke(this,t,e):this.en(e,t,e=>this.T.ke(this,t,e))}Gt(t,e,i,l,s,n){h.re?.(this,t,e,i,l,s,n),this.Ue(t,e)}Ue(t,e){this.T.Jo(this,t,e),this.ve()}co(t){let e=this.nt.get(t);if(void 0!==e)return e;let i=Symbol(`wcs.on${t}`);this.nt.set(t,i);let l=this.root,s=this.Kn;return l.addEventListener(t,e=>{for(let n=e.target;null!==n&&n!==l;n=n.parentNode){let l=n[i];if(void 0!==l&&(l(e),e.cancelBubble))return;let r=n[s];if(void 0!==r&&r.w&&r.Qo(t,e))return}}),i}reset(t){let e=this.target,i=this.tt;for(let t of this.O.all())null===t.c&&null!==t.getter&&i.add(t.s);this.to(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.ue.values())for(let e of t)this.tn(e);for(let t of this.oe.values())this.uo(t);this.Me=null;try{this.Yt()}finally{this.Nn()}h.element?.(this,"reset")}to(t){for(let[e,i]of A)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)(!M.includes(t)||"boolean"!=typeof i[t])&&r(44,["$behavior",t]);let[l,s,n]=M.map(t=>i[t]??!0);void 0!==this.target&&(l!==this.Wt||s!==this._t||n!==this.Vt)&&r(45);let u=function(t,e){let i={};for(let l of m(t.$commandTokens,"$commandTokens","$command"))i[l]=e?.[l]??new b(l);return Object.freeze(i)}(t,this.commands),f=function(t,e){let i=new Map;for(let e of m(t.$eventTokens,"$eventTokens"))i.set(e,new b(e));let l=t.$on;if(void 0===l)return i;(null===l||"object"!=typeof l)&&r(22);for(let[t,s]of Object.entries(l)){let l=i.get(t);void 0===l&&r(23,[t]),"function"!=typeof s&&r(24,[t]),l.subscribe((...t)=>e(s,t))}return i}(t,this._o);this.Wt=l,this._t=s,this.Vt=n,h.fe?.(this,t),this.target=t,this.Le=0;for(let t of this.O.all())t.jo();this.Yn.length=0,this.no(t),this.commands=u,this.Oe=f}uo(t){this.oo(t);let e=this.o(`${t.o.t}.*`);for(let i of t.f)if(i.bt=null,i._=null,this.Nt(e,i),null!==i.u)for(let t of i.u.values())this.uo(t)}H(t){let e=[];for(let i=t;null!==i;i=i.l.ce)e.unshift(i.y);return e}Zo(t,e,i){let l=this.Oe.get(t);void 0===l&&r(1301,[t],t,this.Oe.keys()),l.emit(e,...this.H(i))}command(t){let e=this.commands[t];return void 0===e&&r(1302,[t],t,Object.keys(this.commands)),e}er(t,e,i){this.command(t).emit(e,...this.H(i))}tr(t,e,i){let l=t.includes(".")?this.v(this.o(t),null):this.target[t];return"function"!=typeof l&&r(5,[t]),this.$n(l,i,[e,...this.H(i)])}$n(t,e,i){let l=this.d;this.d=e;try{return t.apply(this.proxy,i)}finally{this.d=l}}Nt(t,e){if(null!==t.getter){let i=null===e?this.oe:e.u;if(null!==i)for(let e of i.values())!e.Bt&&e.o.ee(t)&&(e.Bt=!0,this.Ve.push(e))}if(null===e)return void this.Zt(t,t=>{let e=this.ue.get(t);if(void 0!==e)for(let t of e)this.tn(t)});let i=e.we;if(null!==i)for(let e=0;e<i.length;e++)i[e].o.ee(t)&&this.tn(i[e]);let l=e.N;null!==l&&null!==l.pe&&l.fo(this,t);let s=e.l.M;if(null!==s)for(let i of s){let l=i.map.get(e);void 0!==l&&null!==l.pe&&l.fo(this,t)}}xn(t,e,i){this.Zt(t,t=>{let l=t.B;for(let s=0;s<l.length;s++){let n=l[s];if(0===n.n)this.st(n,null,i);else if(null===e||0===t.n||n.h[1]!==t.h[1]||null!==n.mt&&n.mt.has(t))this.nn(n.h[n.n],t=>this.st(n,t,i));else if(n.n<=t.n){let t=q(e,n.n);null!==t&&this.st(n,t,i)}else this.en(e,n,t=>this.st(n,t,i))}})}st(t,e,i){i(t,e)&&(h.Se?.(this,t,e),this.Nt(t,e),this.xn(t,e,i))}Zt(t,e){e(t);let i=t.u;for(let t=0;t<i.length;t++)this.Zt(i[t],e)}nn(t,e){this.ao(t,t=>{for(let i of t.f)e(i)})}ao(t,e){if(0===t.n){let i=this.oe.get(t);return void(void 0!==i&&e(i))}this.nn(t.h[t.n],i=>{let l=i.u?.get(t);void 0!==l&&e(l)})}en(t,e,i){if(t.l.n===e.n)return i(t);let l=t.u?.get(e.h[t.l.n+1]);if(void 0!==l)for(let t of l.f)this.en(t,e,i)}nr(t){let e=t.r;null===e?E(this.ue,t.o,_).add(t):(e.we??(e.we=[])).push(t)}Pn(t){let e=t.r;if(null===e)return void this.ue.get(t.o)?.delete(t);let i=e.we;e.w&&null!==i&&i.splice(i.indexOf(t)>>>0,1)}tn(t){t.te||(t.te=!0,this.We.push(t),this.ve())}ve(){this.Et||(this.Et=!0,queueMicrotask(this.Wo))}Rn(){for(let t of this.We)t.te=!1;for(let t of this._e)t.te=!1;for(let t of this.Ve)t.Bt=!1;this.We=[],this._e=[],this.Ve=[],this.T.tt(this)}po(t,e){let i=[...new Set([...this.We,...this._e,...this.Ve].map(t=>t.o.t))];u(i,`[@wcstack/state] ${n(t)}`),h.at?.(this,{type:"state:render-chain-limit",maxDepth:e,paths:i}),this.Rn()}Yt(){this.Et=!1;let t=this.Ut;this.Ut=0;let e=0;if(!this.qt||this.zt?this.qn():t>0?e=t:1===(e=++this.D)&&setTimeout(this.qn,0),this.qt=this.zt=!1,e>100)101===e?this.po(41,100):this.Rn();else{this.gn=!0;try{for(let t=0;this.We.length>0||this._e.length>0||this.Ve.length>0;t++){if(t>=32){this.yn?this.Rn():this.po(11,32),this.yn=!0;break}let i=this.Ve;if(i.length>0){this.Ve=[];for(let t of i)t.Bt=!1,this.oo(t)}let l=this._e,s=this.We;this._e=[],this.We=[];let n=()=>{for(let t of l){t.te=!1;for(let e of[t.N,...t.M??[]])if(null!==e&&e.w)try{e.xt()}catch(i){this.Jt(i,t.o.t,e.S,"for")}}for(let t=0;t<2;t++)for(let e=0;e<s.length;e++){let i=s[e];!i.te||null===i.D==(0===t)||(i.te=!1,(null===i.Tn||i.Tn.w)&&this.qe(i))}this.gn||(this.ze(),this.Et&&(this.Ut=e+1))},r=l.length>0||s.some(t=>null!==t.D)?k("state",n):n();void 0!==r&&r.then(void 0,u)}}finally{this.gn=!1}this.qt=this.zt=!1,this.ze(),h.me?.(this),this.zo(),t>0&&this.Et&&(this.Ut=e+1)}}Pt(t,e){this.$t.push([t,e])}Jt(t,e,i,l){this.Pt(t,{o:{t:e},a:i,on:()=>l})}qe(t){try{t.apply()}catch(e){return void this.$t.push([e,t])}null!==this.Me&&this.mo(t.o,t.r)}mo(t,e){let i=E(this.Me,t.t,R);null!==e&&i.push(this.H(e))}Nn(){this.Me="function"==typeof this.target.$renderedCallback?new Map:null}ze(){let t=this.Me;if(null!==t&&t.size>0){this.Me=new Map;let e,i=[...t.keys()],l={};for(let[e,i]of t)i.length>0&&(l[e]=i);this.Ce++;try{e=this.$e("$renderedCallback",[i,l])}catch(t){u(t)}x(e)?e.then(this.zn,t=>{this.zn(),u(t)}):this.Ce--}if(0===this.$t.length)return;let e=this.$t;this.$t=[];let i=this.target.$errorCallback;for(let[t,l]of e){h.Ye?.(this,t,l);let e=l.o.t,s=l.on();if("function"==typeof i)try{let i=this.$e("$errorCallback",[t,{path:e,bindingType:s,node:l.a}]);x(i)&&i.then(void 0,u)}catch(t){u(t)}else u(t,`[@wcstack/state] ${n(12,l.name?[s,e,l.name,l.i]:[s,e])}`,l.a)}}$e(t,e=[]){let i=this.target[t];return"function"==typeof i?this.$n(i,null,e):void 0}ho(t,e,i){if(0===t.n)return void i(null,[]);let l=[],s=(n,r)=>{let h=t.h[n];this.read(h,r);let o=this.Ke(r,h),u=e=>{l.push(e.y),n===t.n?i(e,l):s(n+1,e),l.pop()};for(let t of n-1<e.length?[o.f[e[n-1]]]:o.f)void 0!==t&&u(t)};s(1,null)}getAll(t,e){let i=this.o(t,!0);void 0!==e&&this.bn("$getAll",t,i,e,!1);let l=e;if(void 0===l){l=[];let e=this.d;if(null!==e&&i.n>0){for(let t=1;t<=i.n;t++){let s=P(e,i,t);if(null===s)break;l.push(s.y)}0===l.length&&r(6,[t])}}let s=[];return this.ho(i,l,t=>s.push(this.read(i,t))),s}wn(t,e,i,l){Array.isArray(e)||r(9,[t]),this.Be>0&&r(8);let s=this.o(t,!0);this.bn("$setAll",t,s,e,!1);let n=[];this.ho(s,e,(t,e)=>n.push([t,e.slice()]));let h=!0===l?.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,l]=n[t],r="function"==typeof i?i(this.v(s,e),...l):h?i[t]:i;void 0!==r&&(this.A(s,e,r),o++)}return o}bn(t,e,i,l,s){let n=l.length;(n>i.n||s&&n<i.n)&&r(s?901:902,[t,e,i.n,n])}};export{$ as a,T as b,j as c,x as d,q as e,G as f,f as g,a as h,d as i,c as j,p as k};
2
+ //# sourceMappingURL=chunk-T3KW5DZD.js.map