@wcstack/state 4.9.0 → 4.10.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.
- package/README.ja.md +33 -12
- package/README.md +33 -12
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.esm.js +29 -31
- package/dist/parser.esm.js +4 -1
- package/dist/split/auto.js +1 -1
- package/dist/split/chunks/chunk-65B2K2XD.js +2 -0
- package/dist/split/chunks/{chunk-J3PTKUWV.js.map → chunk-65B2K2XD.js.map} +1 -1
- package/dist/split/chunks/{chunk-ISBASPV2.js → chunk-FFXJVUTT.js} +2 -2
- package/dist/split/chunks/{chunk-LWRYFYOC.js → chunk-FT7OW7CG.js} +2 -2
- package/dist/split/chunks/chunk-GU7IAIWW.js +2 -0
- package/dist/split/chunks/chunk-GU7IAIWW.js.map +1 -0
- package/dist/split/chunks/chunk-IWY3I2DG.js +2 -0
- package/dist/split/chunks/{chunk-47I6RYV3.js.map → chunk-IWY3I2DG.js.map} +1 -1
- package/dist/split/chunks/{chunk-FQUDP3XK.js → chunk-JCQTA35B.js} +2 -2
- package/dist/split/chunks/chunk-MZVF2WEY.js +2 -0
- package/dist/split/chunks/{chunk-P3JKSHRN.js → chunk-PTFWXISY.js} +2 -2
- package/dist/split/chunks/{chunk-BCL75PFH.js → chunk-SJRJALR4.js} +2 -2
- package/dist/split/chunks/chunk-TB52U4QV.js +2 -0
- package/dist/split/chunks/chunk-TB52U4QV.js.map +1 -0
- package/dist/split/chunks/chunk-UE6JK2ZA.js +2 -0
- package/dist/split/chunks/chunk-UE6JK2ZA.js.map +1 -0
- package/dist/split/core.js +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/list-keys.js +1 -1
- package/dist/split/features/native-commands.js +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/dist/wcs-manifest.json +9 -6
- package/package.json +1 -1
- package/dist/split/chunks/chunk-47I6RYV3.js +0 -2
- package/dist/split/chunks/chunk-EBIQH2HE.js +0 -2
- package/dist/split/chunks/chunk-EBIQH2HE.js.map +0 -1
- package/dist/split/chunks/chunk-J3PTKUWV.js +0 -2
- package/dist/split/chunks/chunk-SOFOV2OG.js +0 -2
- package/dist/split/chunks/chunk-SOFOV2OG.js.map +0 -1
- package/dist/split/chunks/chunk-TS2HEHBQ.js +0 -2
- package/dist/split/chunks/chunk-YIDHPXYQ.js +0 -2
- package/dist/split/chunks/chunk-YIDHPXYQ.js.map +0 -1
- /package/dist/split/chunks/{chunk-ISBASPV2.js.map → chunk-FFXJVUTT.js.map} +0 -0
- /package/dist/split/chunks/{chunk-LWRYFYOC.js.map → chunk-FT7OW7CG.js.map} +0 -0
- /package/dist/split/chunks/{chunk-FQUDP3XK.js.map → chunk-JCQTA35B.js.map} +0 -0
- /package/dist/split/chunks/{chunk-TS2HEHBQ.js.map → chunk-MZVF2WEY.js.map} +0 -0
- /package/dist/split/chunks/{chunk-P3JKSHRN.js.map → chunk-PTFWXISY.js.map} +0 -0
- /package/dist/split/chunks/{chunk-BCL75PFH.js.map → chunk-SJRJALR4.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{m as e}from"../chunks/chunk-
|
|
1
|
+
import{m as e}from"../chunks/chunk-PTFWXISY.js";import{b as t}from"../chunks/chunk-UE6JK2ZA.js";import{a as r,b as l,c as n,d as s,j as a}from"../chunks/chunk-SJRJALR4.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.ce){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.Ke(o,n).f,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.Ke(null,o).f,0))}function v(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.rt;l.rt=t=>{let s=o.get(r);if(t.t.includes("**")){let l=r.O.bt(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.Le++),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.d));(!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.H(t)))c.push(l)}),c};let h=l.vn;l.vn=(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.Be>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 v=0;for(let[e,t]of m)v+=h.call(r,p(c,e)+u,r.H(t),s);return v}}(r)):s&&(o.delete(r),h--)}function w(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.a){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",hooks:r,install(){r.fe=l(r.fe,v),r.element=l(r.element,(e,t)=>{("mounting"===t||"reset"===t)&&function(e){u.delete(e)}(e)}),r.Ie=n(s,r.Ie,w)}},b=k;export{b as default,k as recursion};
|
|
2
2
|
//# sourceMappingURL=recursion.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,b as t,d as n}from"../chunks/chunk-J3PTKUWV.js";import{b as o,p as l,q as r,r as i}from"../chunks/chunk-47I6RYV3.js";import"../chunks/chunk-ISBASPV2.js";import{e as a,f as s}from"../chunks/chunk-SOFOV2OG.js";import{a as u}from"../chunks/chunk-FQUDP3XK.js";import"../chunks/chunk-TS2HEHBQ.js";import"../chunks/chunk-P3JKSHRN.js";import"../chunks/chunk-EBIQH2HE.js";import{a as c,b as d,c as f,d as h,f as p,h as m,j as g,k as $}from"../chunks/chunk-BCL75PFH.js";var y=new WeakMap,b=new WeakMap,w="will not graft: the root state failed to initialize.",v=new WeakSet,k=new WeakMap,j=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],O=["$commandTokens","$eventTokens","$on","$errorCallback"],N=e=>`[@wcstack/state] <${u.tagNames.state} mount="${e}">`,A=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),C=e=>e?.element?.isConnected?e:void 0;function P(e){let t=b.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function R(e,t){let n=b.get(t);if(b.delete(t),Array.isArray(n))for(let t of n)W(t,e)}function S(e){let t=y.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function x(e,t){$(`${N(e.t)} ${t}`),S(e),e.Qe?.(),e.Qe=null}function M(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,$)}catch(e){$(e)}}function W(e,t){if(v.has(t))return x(e,"will not graft: its component is wired to its host.");let n=e.state,o=t.target,l=e.t.split("."),r=o;for(let e of l)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return x(e,`will not graft: the root state already has "${e.t}".`);let i=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,o){if("symbol"==typeof o)return;if(36!==o.charCodeAt(0))return e.proxy[n(o)];let l=e.proxy[o];return"$eqPath"===o?(e,t)=>l(n(e),n(t)):A.has(o)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,o,l)=>"symbol"!=typeof o&&(e.proxy[n(o)]=l,!0)})}(t,e.t);e.chroot=i;let a={},s={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:o,set:l,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o||void 0!==l)s[`${e.t}.${n}`]={get:o&&function(){return o.call(i)},set:l&&function(e){l.call(i,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(i);s[`${e.t}.${n}`]={get:()=>t}}else a[n]=r}}if(void 0===r){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.it(n,null)&&t.A(n,null,{})}t.A(t.o(e.t),null,a)}t.no(Object.defineProperties({},s));for(let e in s)t.Ke(t.o(e),null);e.engine=t;let c=k.get(t);void 0===c&&k.set(t,c=[]),c.push(e),e.el.isConnected&&M(e,"$connectedCallback"),e.Qe?.(),e.Qe=null}function E(e,t){let n=b.get(e);if(Array.isArray(n))for(let e of n)x(e,w);b.set(e,t)}var D=new WeakMap;function T(e,t){let n=e.getAttribute("mount");if(null===n)return null;let o={el:e,root:t,t:n,state:null,engine:null,chroot:null,Qe:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(u.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=y.get(t);void 0===e&&y.set(t,e=new Map);let l=e.get(n);if(void 0!==l&&l!==o&&(null===l.engine?l.el.isConnected:C(l.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===l?.engine){let e=b.get(t);Array.isArray(e)&&b.set(t,e.filter(e=>e!==l)),l.Qe?.(),l.Qe=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{Ro:!0,start(e){if(null!==r)return x(o,r);if(y.get(t).get(n)===o){for(let t of j)if(void 0!==e[t])return x(o,`${t} is not run in a volume — declare it on the root state.`);for(let t of O)void 0!==e[t]&&console.warn(`${N(n)} ${t} is not run in a volume (it belongs to the root).`);return o.state=e,new Promise(e=>{o.Qe=e;let n=C(l.get(t)),r=b.get(t);void 0!==n?W(o,n):P(t)?x(o,w):b.set(t,[...Array.isArray(r)?r:[],o])})}},Je(){null!==o.engine&&M(o,"$connectedCallback")},Bn(){null!==o.engine&&M(o,"$disconnectedCallback")},reset(){g(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var q=new WeakMap,H=new WeakMap;function I(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||g(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&g(`${t} entries must be non-empty strings.`),"$"===e[0]&&g(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&g(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function L(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let o=document.createDocumentFragment();for(let e of[...t.childNodes])o.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&g("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||g(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&g(`DCC: <${e}> is already defined.`);let l=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(o),r=I(o,"$bindables"),i=I(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&g(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&g(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&g(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&g(`$commands entry "${e}" is not a method: list it in $bindables.`)}let a={tag:e,bindables:r},s=new WeakMap,c=new WeakMap,d=o=>{if(s.has(o))return s.get(o);if(o.hasAttribute("data-wc-definition"))return null;let l=o.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let i=l.querySelector(u.tagNames.state);return s.set(o,i),q.set(o,a),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${u.tagNames.state}>: no change events.`),i},f=e=>d(e)?.engine??null,h=e=>Promise.resolve(d(e)?.initializePromise).then(()=>{let t=c.get(e);c.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,o]of t)n.proxy[e]=o});class p extends HTMLElement{static{this.wcBindable=0===r.length&&0===i.length?null:{protocol:"wc-bindable",version:1,properties:r.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:r.map(e=>({name:e})),...0===i.length?{}:{commands:i.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==d(this)&&h(this)}get stateElement(){return d(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(p.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(p.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=c.get(this);void 0===n&&c.set(this,n=[]),n.push([e,t])}}});customElements.define(e,p)}(n.localName,o,l,t)},Je(){},Bn(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var Q=new WeakMap,z=new WeakSet,B=new WeakMap,F=new WeakMap,V="data-wcs-wired",K=new WeakMap,J=new WeakMap,X=new WeakMap,U=0,Y=new Set,G={},Z=["$watch","$stream","$renderedCallback"],_=e=>e.split(".",1)[0];function ee(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function te(e,t){let n=e.a,o=_(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(V);else if(!oe(n,o)){let e=n.getAttribute(V)?.split(" ")??[];e.includes(o)||n.setAttribute(V,[...e,o].join(" "))}K.get(n)?.he===o&&g(`<${n.localName}>.${o} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=Q.get(n);void 0===l&&Q.set(n,l=[]),l.push(e),t&&z.add(e);let r=B.get(n);return void 0===r&&B.set(n,r=new Map),r.has(o)||r.set(o,n[o]),F.get(n)?.(),!1}function ne(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${u.tagNames.state}[bind-component]`)}function oe(e,t){let n=e.getAttribute(u.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function le(t){let n=t.parentElement;for(;null!==n&&!ne(n);)n=n.parentElement;let o=l.get(n??t.getRootNode()),r=o?.element;(r?.isConnected?r.V:null===n)&&(null===n?e(t):i(o,t))}var re=new Set;function ie(e,t){re.has(e)||(re.add(e),console.warn(`[@wcstack/state] ${t}`))}var ae=(e,t)=>t in e.state;function se(e,t){let n=ue(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function ue(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 ce(e,t,n){if(null!==n.getter)return;let o,l=e.host,r=l.engine,i=_(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.c)return function(e,t){let n,o=t.c;for(;null!==o&&void 0===(n=e.pt.get(o));)o=o.c;if(null===o||void 0===n)return;let l=e.R,r=e.host.engine,i=r.o(n.p.t+t.t.slice(o.t.length));if(null===i.getter)return;let s=n,u=()=>{let n=de(e,s.r);return 0===t.n?n:(r.resolve(ee(i.t,[...r.H(n),...l.H(a(l.d,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.se&&(t.se=n=>{let o=u();fe(e,s.e,()=>r.A(i,o,n)),e.dn=t}),t.n>0&&(t.F=l.Le++),e.pt.set(t,{e:s.e,p:i,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==i?ae(l,i):se(l,i))return;o=s.ye}else{if(null===t||null!==n.c||"$"===i[0]||ae(l,i))return;s=t,o=r.o(`${t.ye.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,de(e,u)),n.se=t=>{fe(e,c,()=>r.A(o,u,t)),e.dn=n},e.pt.set(n,{e:s,p:o,r:u})}function de(e,t){return null!==t&&!t.w&&g(`The host row of <${e.host.el.localName}> was removed.`),t}function fe(e,t,n){let o=Y.has(e.R);Y.add(e.R),e.from=t;try{n()}finally{o||Y.delete(e.R),e.from=null}}var he=(e,t)=>t||!Y.has(e.m.R)||null!==e.m.from&&e.m.from!==e.e;function pe(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,U+=t?1:-1;let n=e.host.engine,o=X.get(n);void 0===o&&X.set(n,o=new Map);for(let n of e.pe){let e=o.get(n.e.ye);void 0===e&&o.set(n.e.ye,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.$);if(void 0!==l){null===e.ie&&function(e,t){let n=e.host,o=n.engine;e.ie=new Map;let l=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let i of Object.getOwnPropertyNames(r)){if(l.has(i))continue;l.add(i);let a=Object.getOwnPropertyDescriptor(r,i);if(void 0===a.get&&void 0===a.set||"$"===i[0]||i.includes("*"))continue;let s=_(i);if(i!==s&&!ae(n,s))continue;let u=o.o(`${t.ye.t}.${i}`);if(null===u.getter)$e(o,u,t.ye);else if(!me.has(u.getter))continue;e.ie.set(u,e.R.o(i))}}(e,l);for(let o of e.ie.keys())t&&null===o.getter&&$e(n,o,l.ye),n.T.ke(n,o,l.r);e.ie.size>0&&n.ve(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.ie){let r=n.v(o.c,t.r);if(null===r||"object"!=typeof r||!(o.s in r))continue;let i=e.host.el.localName;ie(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.he}.${l.t} is exported at "${o.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,l)}}var me=new WeakSet;function ge(e,t,n,o){let l=X.get(e)?.get(t)?.get(n);if(void 0===l)return null;let r=null;for(let e of l)""!==e.e.$||!0!==e.m.ie?.has(o)||e.m===r||(null!==r&&g(`[wcs/mount-export-ambiguous] "${o.t}" is exported by two mounted components on the same instance: <${r.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),r=e.m);return r}function $e(e,t,n){let o=t.c,l=t.s,r=()=>{let t=e.read(o,e.d);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=ge(e,n,e.d,t);return null===i?void 0:i.R.read(i.ie.get(t),null)},me.add(t.getter),t.se=i=>{let a=null===r()?ge(e,n,e.d,t):null;if(null===a){let t=e.read(o,e.d);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.ie.get(t);void 0===ue(a.host.state,s.t)?.set&&g(`Cannot write to "${s.t}" on mounted <${a.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),a.R.A(s,null,i)},t.n>0&&(t.F=e.Le++)}function ye(e,t,n,o,l,r){if(null!==t.getter)return e.T.ke(e,t,n),void e.ve();if("*"===t.s){if(null===n)return;if(n.E=n.l.P[n.y],e.T.Gt(n),null!==n.u)for(let t of n.u.values())e.X(t)}else e.En(t,n);c.re?.(e,t,n,o,l,r),e.Ke(t,n)}function be(e){let t=e.m.R;for(let[n,o]of e.m.pt)o.e===e.e&&(0===n.n?t.T.ke(t,n,null):t.nn(n.h[n.n],e=>t.T.ke(t,n,e)));t.ve()}function we(e,t,n,o,l,r,i){let s=n.t.slice(t.t.length);if(""===s)return be(e);let u,c=e.m,d=c.R;if(""===e.e.$){u=s.slice(1);let e=_(u);if("$"===e[0]||ae(c.host,e)||c.host.entries.some(e=>""!==e.$&&(u===e.$||u.startsWith(`${e.$}.`))))return}else u=e.e.$+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(a(o,e).y);d.resolve(ee(u,f),null);let h=d.rp,p=d.rr;h.n>0&&null===p||ye(d,h,p,l,r,i)}function ve(e,t,n,o,l,r,i){if(0===U)return;let s=Y.has(e);Y.add(e);try{let s=J.get(e);!i&&void 0!==s&&s.fn&&!Y.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.pt.get(a));)a=a.c;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.dn===t)return void(e.dn=null);if(null!==i.r&&!i.r.w)return;let u=[...s.H(i.r),...e.R.H(n)];s.resolve(ee(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||fe(e,i.e,()=>ye(s,c,d,o,l,r))}(s,t,n,o,l,r),i&&void 0!==s&&s.fn&&null!==s.ie&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.ie)r===t&&(o.T.ke(o,l,n.r),o.ve())}(s,t);let u=X.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.ee(e)){let u=s.get(0===e.n?null:a(n,e.n));if(void 0!==u)for(let a of[...u])he(a,i)&&we(a,e,t,n,o,l,r)}else if(e.ee(t))for(let[e,o]of[...s])if(0===t.n||a(e,t.n)===n)for(let e of[...o])he(e,i)&&be(e)}finally{s||Y.delete(e)}}async function ke(e,o,l,i,a){if(i===G)return;let d=m(i);d&&await d;let f=K.get(o);f.engine&&i.$recursion&&g(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let h=f.I;if(null!==h&&h.el!==e&&h.el.isConnected&&g(`<${o.localName}> already has a connected <${u.tagNames.state} bind-component="${f.he}">.`),null!==h&&pe(h,!1),null!==h&&function(e,t,n){let o=e.R,l=`[${u.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,a=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},s=(e,t)=>{for(let n=e.In(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ue.values())for(let t of e)if(null===t.j)a(t.a);else for(let e of t.j.q)s(t.j,e.S);for(let e of o.oe.values())for(let t of[e.N,...e.W??[]])null!==t&&s(t,t.S);for(let t of e.L)t.parentNode===n&&r(t)&&i.add(t);if(0===i.size)return!1;let c=[...n.childNodes].filter(n=>n!==t&&!i.has(n)&&!e.L.includes(n)&&(r(n)||o.Mt&&n.textContent.includes("{{")));return c.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${c.length} node(s) added beside the content taken over are not bound.`),!0}(h,e,l))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.R.element=t,t.engine=e.R,e.L=e.L.filter(e=>e.parentNode===n),t.isConnected?await je(e,o):o()}(h,e,l,a);let p=new s(i,new n);p.element=e,e.engine=p,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let o=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof o&&"constructor"!==t&&n.set(o,null)}let o=(t,n,o)=>Reflect.apply(t,e.proxy,o);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(p,i);let y={el:e,L:[],R:p,host:f,pe:[],pt:new Map,fn:!1,dn:null,from:null,ie:null};for(let e of f.entries)y.pe.push({m:y,e});f.I=y,J.set(p,y);let b=null===f.engine;b?c.element?.(p,"mounting"):(function(e){let t=e.R,n=e.host,o=n.engine,l=n.el.localName,r=n.entries.find(e=>""===e.$)??null;for(let e of n.entries){if(""===e.$)continue;let t=_(e.$);ae(n,t)&&(e.$!==t||se(n,t))&&ie(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.he}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.ye,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.$===t)&&ie(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.ye.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=Z.filter(e=>void 0!==n.state[e]);i.length>0&&ie(`${l}.${n.he}$`,`[wcs/mount-dollar-declaration] <${l}>: ${i.join(", ")} ${1===i.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let a=t.ot;t.ot=n=>{ce(e,r,n),a.call(t,n)};let s=[...t.O.all()];for(let t of s)ce(e,r,t);for(let e of s)a.call(t,e);let u=t.Yt;t.Yt=()=>{(function(e){for(;void 0!==e;e=J.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.w))return!1;return!0})(e)&&u.call(t)}}(y),pe(y,!0),v.add(p),R(p,l));let w=c.hr?.(l,p);r(p,l),w?.(),y.L=[...l.childNodes],t(),b&&p.Nn(),Object.defineProperty(o,f.he,{configurable:!0,enumerable:!0,get:()=>p.proxy});let k=o.$stateReadyCallback;if("function"==typeof k)try{let e=k.call(o,f.he);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,$)}catch(e){$(e)}a(),e.isConnected?(await p.$e("$connectedCallback"),b&&e.isConnected&&c.element?.(p,"connected")):pe(y,!1)}async function je(e,t){pe(e,!0);for(let t of e.pe)be(t);t?.(),!e.broken&&(await e.R.$e("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.R,"connected"))}function Oe(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=l.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){E(t,e);for(let e of D.get(t)??[])e()}}),null}(e,t);let r=e.parentNode,i=r instanceof ShadowRoot,a=i?r.host:r instanceof Element?r:null,s=()=>{let t=null===a?void 0:K.get(a)?.I;return t?.el===e?t:null},d=t=>{throw i&&E(r,e),t},f=!1;return{kt:()=>(null!==a&&a.localName.includes("-")?async function(e,t,n,l){let r=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&g(`<${u.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await o(n).whenDefined(r);let i=K.get(n);if(void 0!==i)return i.he!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.he}">.`),i.state;let a=()=>(Q.get(n)??[]).filter(e=>_(e.name)===t),s=oe(n,t);if(s&&0===a().length&&le(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(V)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{F.set(n,o),e=function(e,t){P(e)&&t();let n=D.get(e)??new Set;return D.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}F.delete(n);let c=a(),d=B.get(n),f=void 0!==d&&d.has(t)?d.get(t):n[t];if((null===f||"object"!=typeof f)&&g(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===f?"null":typeof f}.`),0===c.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${r}>, or mount it from the host (${u.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),G}let h=[];for(let e of c){let o=e.name===t?"":e.name.slice(t.length+1);h.some(e=>e.$===o)&&g(`<${r}> maps "${e.name}" twice.`);let l=o.split(".").indexOf("*");if(l>=0){let n=o.split(".").slice(0,l).join(".");g(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}h.push({$:o,ye:e.o,r:e.r,ro:z.has(e)}),e.engine.Rn(e),""!==o&&delete n[e.name]}let p=0===c.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(f):f;return K.set(n,i={el:n,he:t,state:p,engine:0===c.length?null:c[0].engine,entries:h,I:null}),p}(e,n,a,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${u.tagNames.state}> to be a direct child of a custom element.`))).catch(d),async start(t,n){await ke(e,a,i?r:a,t,()=>{f=!0,n()}).catch(e=>{let t=s();return!f&&null!==t&&(t.broken=!0),d(e)})},Je(){let t=s();null!==t?je(t).catch($):f?Promise.resolve().then(()=>{if(e.parentNode===r)return ke(e,a,i?r:a,K.get(a).state,()=>{})}).catch($):F.has(a)&&le(a)},Bn(){let e=s();null!==e&&(pe(e,!1),!e.broken&&(e.R.$e("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.R,"disconnected")))},reset(){g(`re-setting a component's state is not supported: write <${a?.localName}>.${n} instead.`)}}}var Ne={name:"scopes",hooks:c,install(){c.ut=f(p,c.ut,T),c.ut=f(p,c.ut,L),c.ut=f(p,c.ut,Oe),c.ar=te,c.Eo=ne,c.element=d(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=k.get(e)??[];if("disconnected"===t)for(let e of n)S(e);else if("reset"!==t&&C(l.get(e.root))===e){R(e,e.root);for(let e of n)y.get(e.root).has(e.t)||y.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();R(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:q.get(n);void 0!==o&&H.set(e,{host:n,def:o})}(e,n)}),c.re=d(c.re,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=H.get(e);if(void 0===l)return;let r=t.t.split(".",1)[0];if(!l.def.bindables.includes(r))return;let i=o&&t.t===r;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${r}-changed`,{detail:i?n:void 0,bubbles:!0}))})(e,t,l,r),ve(e,t,n,o,l,r,!1)}),c.Se=d(c.Se,(e,t,n)=>ve(e,t,n,void 0,void 0,!1,!0)),c.Ie=f(h,c.Ie,(e,t,n,o,l)=>(function(e,t){let n=k.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&g(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let o,l=J.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.c)o=l.pt.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.w)&&!r.ro)&&(!!n||(de(l,r.r),void g(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.he}${""===r.$?"":`.${r.$}`}#ro: ${r.ye.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.fe;c.fe=(t,n)=>{let o=k.get(t);void 0!==o&&o.length>0&&g(`re-setting a root state with grafted volumes (${o.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=X.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&g("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},Ae=Ne;export{Ae as default,Ne as scopes};
|
|
1
|
+
import{a as e,b as t,d as n}from"../chunks/chunk-65B2K2XD.js";import{b as o,p as l,q as r,r as i}from"../chunks/chunk-IWY3I2DG.js";import"../chunks/chunk-FFXJVUTT.js";import{e as a,f as s}from"../chunks/chunk-GU7IAIWW.js";import{a as u}from"../chunks/chunk-JCQTA35B.js";import"../chunks/chunk-MZVF2WEY.js";import"../chunks/chunk-PTFWXISY.js";import"../chunks/chunk-UE6JK2ZA.js";import{a as c,b as d,c as f,d as h,f as m,h as p,j as g,k as $}from"../chunks/chunk-SJRJALR4.js";var y=new WeakMap,w=new WeakMap,b="will not graft: the root state failed to initialize.",v=new WeakSet,k=new WeakMap,j=["$stream","$streams","$scan","$recursion","$watch","$listKeys","$renderedCallback","$updatedCallback","$behavior","$features"],P=["$commandTokens","$eventTokens","$on","$errorCallback"],O=e=>`[@wcstack/state] <${u.tagNames.state} mount="${e}">`,N=new Set(["$getAll","$setAll","$resolve","$postUpdate","$dependOn","$eq","$eqIndex"]),A=e=>e?.element?.isConnected?e:void 0;function C(e){let t=w.get(e);return void 0!==t&&!Array.isArray(t)&&t.isConnected}function M(e,t){let n=w.get(t);if(w.delete(t),Array.isArray(n))for(let t of n)D(t,e)}function x(e){let t=y.get(e.root);t?.get(e.t)===e&&t.delete(e.t)}function S(e,t){$(`${O(e.t)} ${t}`),x(e),e.Ze?.(),e.Ze=null}function W(e,t){let n=e.state?.[t];if("function"==typeof n)try{let t=n.call(e.chroot);null!==t&&"object"==typeof t&&"function"==typeof t.then&&t.then(void 0,$)}catch(e){$(e)}}function D(e,t){if(v.has(t))return S(e,"will not graft: its component is wired to its host.");let n=e.state,o=t.target,l=e.t.split("."),r=o;for(let e of l)r=r?.[e];if(void 0!==r&&!0!==t.hydrated)return S(e,`will not graft: the root state already has "${e.t}".`);let i=function(e,t){let n=e=>`${t}.${e}`;return new Proxy({},{get(t,o){if("symbol"==typeof o)return;if(36!==o.charCodeAt(0))return e.proxy[n(o)];let l=e.proxy[o];return"$eqPath"===o?(e,t)=>l(n(e),n(t)):N.has(o)&&"function"==typeof l?(e,...t)=>l(n(e),...t):l},set:(t,o,l)=>"symbol"!=typeof o&&(e.proxy[n(o)]=l,!0)})}(t,e.t);e.chroot=i;let a={},s={},u=new Set;for(let t=n;null!==t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t)){if(u.has(n)||"constructor"===n)continue;u.add(n);let{get:o,set:l,value:r}=Object.getOwnPropertyDescriptor(t,n);if(void 0!==o||void 0!==l)s[`${e.t}.${n}`]={get:o&&function(){return o.call(i)},set:l&&function(e){l.call(i,e)}};else{if("$"===n[0])continue;if("function"==typeof r){let t=r.bind(i);s[`${e.t}.${n}`]={get:()=>t}}else a[n]=r}}if(void 0===r){for(let e=1;e<l.length;e++){let n=t.o(l.slice(0,e).join("."));null==t.st(n,null)&&t.A(n,null,{})}t.A(t.o(e.t),null,a)}t.io(Object.defineProperties({},s));for(let e in s)t.qe(t.o(e),null);e.engine=t;let c=k.get(t);void 0===c&&k.set(t,c=[]),c.push(e),e.el.isConnected&&W(e,"$connectedCallback"),e.Ze?.(),e.Ze=null}function E(e,t){let n=w.get(e);if(Array.isArray(n))for(let e of n)S(e,b);w.set(e,t)}var T=new WeakMap;function q(e,t){let n=e.getAttribute("mount");if(null===n)return null;let o={el:e,root:t,t:n,state:null,engine:null,chroot:null,Ze:null},r=null;if(function(e){return""!==e&&e.split(".").every(e=>""!==e&&!/[*$#@\s]/.test(e))}(n))if(e.hasAttribute(u.bindAttributeName))r='injections (data-wcs="state.<key>: …") are not supported — read the root path in a root getter.';else{let e=y.get(t);void 0===e&&y.set(t,e=new Map);let l=e.get(n);if(void 0!==l&&l!==o&&(null===l.engine?l.el.isConnected:A(l.engine)))r=`will not graft: another volume already holds "${n}".`;else{if(null===l?.engine){let e=w.get(t);Array.isArray(e)&&w.set(t,e.filter(e=>e!==l)),l.Ze?.(),l.Ze=null}e.set(n,o)}}else r='has an invalid mount path: it must be a static path (no "*", "$", "#", "@").';return{Ao:!0,start(e){if(null!==r)return S(o,r);if(y.get(t).get(n)===o){for(let t of j)if(void 0!==e[t])return S(o,`${t} is not run in a volume — declare it on the root state.`);for(let t of P)void 0!==e[t]&&console.warn(`${O(n)} ${t} is not run in a volume (it belongs to the root).`);return o.state=e,new Promise(e=>{o.Ze=e;let n=A(l.get(t)),r=w.get(t);void 0!==n?D(o,n):C(t)?S(o,b):w.set(t,[...Array.isArray(r)?r:[],o])})}},Qe(){null!==o.engine&&W(o,"$connectedCallback")},Mn(){null!==o.engine&&W(o,"$disconnectedCallback")},reset(){g(`re-setting a volume is not supported: its data was copied into the root tree at "${n}" — write the paths under it on the root instead.`)}}}var I=new WeakMap,L=new WeakMap;function R(e,t){let n=e[t];if(void 0===n)return[];Array.isArray(n)||g(`${t} must be an array of state member names.`);let o=new Set;for(let e of n)("string"!=typeof e||""===e)&&g(`${t} entries must be non-empty strings.`),"$"===e[0]&&g(`${t} entry "${e}": internal ($) members are never exposed.`),o.has(e)&&g(`${t} entry "${e}" is duplicated.`),o.add(e);return n}function Z(e,t){let n=t.host;if(void 0===n||!n.hasAttribute("data-wc-definition"))return null;let o=document.createDocumentFragment();for(let e of[...t.childNodes])o.appendChild(e.cloneNode(!0));let l=t.mode;return{start(t){e.hasAttribute("bind-component")&&g("DCC: a <wcs-state bind-component> cannot define a component (use one mechanism)."),function(e,t,n,o){e.includes("-")||g(`DCC: <${e} data-wc-definition> is not a valid custom element name.`),void 0!==customElements.get(e)&&g(`DCC: <${e}> is already defined.`);let l=function(e){let t=new Map;for(let n=e;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let e of Object.getOwnPropertyNames(n))"constructor"===e||"$"===e[0]||t.has(e)||t.set(e,Object.getOwnPropertyDescriptor(n,e));let n=e.$stream;if(null!==n&&"object"==typeof n)for(let e of Object.keys(n))t.has(e)||t.set(e,{value:void 0});return t}(o),r=R(o,"$bindables"),i=R(o,"$commands");for(let e of r){let t=l.get(e);void 0===t&&g(`$bindables entry "${e}" does not exist on the state.`),"function"==typeof t.value&&g(`$bindables entry "${e}" is a method: list it in $commands.`)}for(let e of i){let t=l.get(e);void 0===t&&g(`$commands entry "${e}" does not exist on the state.`),"function"!=typeof t.value&&g(`$commands entry "${e}" is not a method: list it in $bindables.`)}let a={tag:e,bindables:r},s=new WeakMap,c=new WeakMap,d=o=>{if(s.has(o))return s.get(o);if(o.hasAttribute("data-wc-definition"))return null;let l=o.attachShadow({mode:n});l.appendChild(t.cloneNode(!0));let i=l.querySelector(u.tagNames.state);return s.set(o,i),I.set(o,a),null===i&&r.length>0&&console.warn(`[@wcstack/state] DCC: <${e}> declares $bindables but its content has no <${u.tagNames.state}>: no change events.`),i},f=e=>d(e)?.engine??null,h=e=>Promise.resolve(d(e)?.initializePromise).then(()=>{let t=c.get(e);c.delete(e);let n=f(e);if(void 0!==t&&null!==n)for(let[e,o]of t)n.proxy[e]=o});class m extends HTMLElement{static{this.wcBindable=0===r.length&&0===i.length?null:{protocol:"wc-bindable",version:1,properties:r.map(t=>({name:t,event:`${e}:${t}-changed`,getter:e=>e.target[t]})),inputs:r.map(e=>({name:e})),...0===i.length?{}:{commands:i.map(e=>({name:e,async:!0}))}}}connectedCallback(){null!==d(this)&&h(this)}get stateElement(){return d(this)}}for(let[e,t]of l)"function"==typeof t.value?Object.defineProperty(m.prototype,e,{configurable:!0,value(...t){return h(this).then(()=>{let n=f(this);return null===n?void 0:n.proxy[e].apply(n.proxy,t)})}}):Object.defineProperty(m.prototype,e,{configurable:!0,get(){return f(this)?.proxy[e]},set(t){let n=f(this);if(null!==n)n.proxy[e]=t;else{let n=c.get(this);void 0===n&&c.set(this,n=[]),n.push([e,t])}}});customElements.define(e,m)}(n.localName,o,l,t)},Qe(){},Mn(){},reset(){g("re-setting a DCC definition is not supported: each instance loads its own state.")}}}var z=new WeakMap,F=new WeakSet,X=new WeakMap,H=new WeakMap,J="data-wcs-wired",V=new WeakMap,Q=new WeakMap,U=new WeakMap,B=0,G=new Set,K={},Y=["$watch","$stream","$renderedCallback"],_=e=>e.split(".",1)[0];function ee(e,t){let n=0;return e.split(".").map(e=>"*"===e?String(t[n++]):e).join(".")}function te(e,t){let n=e.c,o=_(e.name);if(!0!==document.documentElement?.hasAttribute("data-wcs-server"))n.removeAttribute(J);else if(!oe(n,o)){let e=n.getAttribute(J)?.split(" ")??[];e.includes(o)||n.setAttribute(J,[...e,o].join(" "))}V.get(n)?.he===o&&g(`<${n.localName}>.${o} has loaded its state: the wiring "${e.name}" added afterwards cannot reach it — bind the host's wiring before the component loads.`);let l=z.get(n);void 0===l&&z.set(n,l=[]),l.push(e),t&&F.add(e);let r=X.get(n);return void 0===r&&X.set(n,r=new Map),r.has(o)||r.set(o,n[o]),H.get(n)?.(),!1}function ne(e){return e.localName.includes("-")&&null!==e.querySelector(`:scope > ${u.tagNames.state}[bind-component]`)}function oe(e,t){let n=e.getAttribute(u.bindAttributeName);return null!==n&&new RegExp(`(^|;)\\s*${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*[.#:]`).test(n)}function le(t){let n=t.parentElement;for(;null!==n&&!ne(n);)n=n.parentElement;let o=l.get(n??t.getRootNode()),r=o?.element;(r?.isConnected?r.V:null===n)&&(null===n?e(t):i(o,t))}var re=new Set;function ie(e,t){re.has(e)||(re.add(e),console.warn(`[@wcstack/state] ${t}`))}var ae=(e,t)=>t in e.state;function se(e,t){let n=ue(e.state,t);return void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)}function ue(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 ce(e,t,n){if(null!==n.getter)return;let o,l=e.host,r=l.engine,i=_(n.t),s=l.entries.find(e=>e.$===n.t);if(void 0===s&&null!==n.a)return function(e,t){let n,o=t.a;for(;null!==o&&void 0===(n=e.mt.get(o));)o=o.a;if(null===o||void 0===n)return;let l=e.P,r=e.host.engine,i=r.o(n.p.t+t.t.slice(o.t.length));if(null===i.getter)return;let s=n,u=()=>{let n=de(e,s.r);return 0===t.n?n:(r.resolve(ee(i.t,[...r.H(n),...l.H(a(l.d,t.n))]),null),r.rr)};t.getter=()=>{let e=u();return i.n>0&&null===e?void 0:r.v(i,e)},null!==i.se&&(t.se=n=>{let o=u();fe(e,s.e,()=>r.A(i,o,n)),e.dn=t}),t.n>0&&(t.F=l.Le++),e.mt.set(t,{e:s.e,p:i,r:s.r})}(e,n);if(0!==n.n)return;if(void 0!==s){if(s.$!==i?ae(l,i):se(l,i))return;o=s.ye}else{if(null===t||null!==n.a||"$"===i[0]||ae(l,i))return;s=t,o=r.o(`${t.ye.t}.${i}`)}let u=s.r,c=s;n.getter=()=>r.v(o,de(e,u)),n.se=t=>{fe(e,c,()=>r.A(o,u,t)),e.dn=n},e.mt.set(n,{e:s,p:o,r:u})}function de(e,t){return null!==t&&!t.w&&g(`The host row of <${e.host.el.localName}> was removed.`),t}function fe(e,t,n){let o=G.has(e.P);G.add(e.P),e.from=t;try{n()}finally{o||G.delete(e.P),e.from=null}}var he=(e,t)=>t||!G.has(e.m.P)||null!==e.m.from&&e.m.from!==e.e;function me(e,t){if(e.fn===t||null===e.host.engine)return;e.fn=t,B+=t?1:-1;let n=e.host.engine,o=U.get(n);void 0===o&&U.set(n,o=new Map);for(let n of e.pe){let e=o.get(n.e.ye);void 0===e&&o.set(n.e.ye,e=new Map);let l=e.get(n.e.r);void 0===l&&e.set(n.e.r,l=new Set),t?l.add(n):(l.delete(n),0===l.size&&e.delete(n.e.r))}let l=e.host.entries.find(e=>""===e.$);if(void 0!==l){null===e.ie&&function(e,t){let n=e.host,o=n.engine;e.ie=new Map;let l=new Set;for(let r=n.state;null!==r&&r!==Object.prototype;r=Object.getPrototypeOf(r))for(let i of Object.getOwnPropertyNames(r)){if(l.has(i))continue;l.add(i);let a=Object.getOwnPropertyDescriptor(r,i);if(void 0===a.get&&void 0===a.set||"$"===i[0]||i.includes("*"))continue;let s=_(i);if(i!==s&&!ae(n,s))continue;let u=o.o(`${t.ye.t}.${i}`);if(null===u.getter)$e(o,u,t.ye);else if(!pe.has(u.getter))continue;e.ie.set(u,e.P.o(i))}}(e,l);for(let o of e.ie.keys())t&&null===o.getter&&$e(n,o,l.ye),n.T.ke(n,o,l.r);e.ie.size>0&&n.ve(),t&&function(e,t){let n=e.host.engine;for(let[o,l]of e.ie){let r=n.v(o.a,t.r);if(null===r||"object"!=typeof r||!(o.s in r))continue;let i=e.host.el.localName;ie(`${i}|${o.t}`,`[wcs/mount-export-shadowed] <${i}>.${e.host.he}.${l.t} is exported at "${o.t}" but the tree already has that key, so readers outside the component get the tree value. Remove the tree key or rename the accessor. See docs/state-overlay-export-design.md X1.`)}}(e,l)}}var pe=new WeakSet;function ge(e,t,n,o){let l=U.get(e)?.get(t)?.get(n);if(void 0===l)return null;let r=null;for(let e of l)""!==e.e.$||!0!==e.m.ie?.has(o)||e.m===r||(null!==r&&g(`[wcs/mount-export-ambiguous] "${o.t}" is exported by two mounted components on the same instance: <${r.host.el.localName}> and <${e.m.host.el.localName}>. Mount only one of them there, or rename one accessor. See docs/state-overlay-export-design.md X4.`),r=e.m);return r}function $e(e,t,n){let o=t.a,l=t.s,r=()=>{let t=e.read(o,e.d);return null!==t&&"object"==typeof t&&l in t?t:null};t.getter=()=>{let o=r();if(null!==o)return o[l];let i=ge(e,n,e.d,t);return null===i?void 0:i.P.read(i.ie.get(t),null)},pe.add(t.getter),t.se=i=>{let a=null===r()?ge(e,n,e.d,t):null;if(null===a){let t=e.read(o,e.d);return void(null!==t&&"object"==typeof t&&(t[l]=i))}let s=a.ie.get(t);void 0===ue(a.host.state,s.t)?.set&&g(`Cannot write to "${s.t}" on mounted <${a.host.el.localName}>: the accessor has no setter. Add a setter or write to the underlying state paths instead.`),a.P.A(s,null,i)},t.n>0&&(t.F=e.Le++)}function ye(e,t,n,o,l,r){if(null!==t.getter)return e.T.ke(e,t,n),void e.ve();if("*"===t.s){if(null===n)return;if(n.E=n.l.R[n.y],e.T.Gt(n),null!==n.u)for(let t of n.u.values())e.X(t)}else e.xn(t,n);c.re?.(e,t,n,o,l,r),e.qe(t,n)}function we(e){let t=e.m.P;for(let[n,o]of e.m.mt)o.e===e.e&&(0===n.n?t.T.ke(t,n,null):t.nn(n.h[n.n],e=>t.T.ke(t,n,e)));t.ve()}function be(e,t,n,o,l,r,i){let s=n.t.slice(t.t.length);if(""===s)return we(e);let u,c=e.m,d=c.P;if(""===e.e.$){u=s.slice(1);let e=_(u);if("$"===e[0]||ae(c.host,e)||c.host.entries.some(e=>""!==e.$&&(u===e.$||u.startsWith(`${e.$}.`))))return}else u=e.e.$+s;let f=[];for(let e=t.n+1;e<=n.n;e++)f.push(a(o,e).y);d.resolve(ee(u,f),null);let h=d.rp,m=d.rr;h.n>0&&null===m||ye(d,h,m,l,r,i)}function ve(e,t,n,o,l,r,i){if(0===B)return;let s=G.has(e);G.add(e);try{let s=Q.get(e);!i&&void 0!==s&&s.fn&&!G.has(s.host.engine)&&function(e,t,n,o,l,r){let i,a=t;for(;null!==a&&void 0===(i=e.mt.get(a));)a=a.a;if(null===a||void 0===i)return;let s=e.host.engine;if(a===t&&e.dn===t)return void(e.dn=null);if(null!==i.r&&!i.r.w)return;let u=[...s.H(i.r),...e.P.H(n)];s.resolve(ee(i.p.t+t.t.slice(a.t.length),u),null);let c=s.rp,d=s.rr;c.n>0&&null===d||fe(e,i.e,()=>ye(s,c,d,o,l,r))}(s,t,n,o,l,r),i&&void 0!==s&&s.fn&&null!==s.ie&&function(e,t){let n=e.host.entries.find(e=>""===e.$),o=e.host.engine;for(let[l,r]of e.ie)r===t&&(o.T.ke(o,l,n.r),o.ve())}(s,t);let u=U.get(e);if(void 0===u)return;for(let[e,s]of u)if(t.ee(e)){let u=s.get(0===e.n?null:a(n,e.n));if(void 0!==u)for(let a of[...u])he(a,i)&&be(a,e,t,n,o,l,r)}else if(e.ee(t))for(let[e,o]of[...s])if(0===t.n||a(e,t.n)===n)for(let e of[...o])he(e,i)&&we(e)}finally{s||G.delete(e)}}async function ke(e,o,l,i,a){if(i===K)return;let d=p(i);d&&await d;let f=V.get(o);f.engine&&i.$recursion&&g(`[wcs/mount-dollar-declaration] <${o.localName}>: $recursion is not run in a mounted component — declare it on the root state.`);let h=f.I;if(null!==h&&h.el!==e&&h.el.isConnected&&g(`<${o.localName}> already has a connected <${u.tagNames.state} bind-component="${f.he}">.`),null!==h&&me(h,!1),null!==h&&function(e,t,n){let o=e.P,l=`[${u.bindAttributeName}]`,r=e=>1===e.nodeType&&(e.matches(l)||null!==e.querySelector(l)),i=new Set,a=e=>{for(;null!==e&&e.parentNode!==n;)e=e.parentNode;null!==e&&i.add(e)},s=(e,t)=>{for(let n=e.jn(t);null!==n&&n!==t;n=n.nextSibling)a(n);a(t)};for(let e of o.ue.values())for(let t of e)if(null===t.D)a(t.c);else for(let e of t.D.q)s(t.D,e.S);for(let e of o.oe.values())for(let t of[e.N,...e.W??[]])null!==t&&s(t,t.S);for(let t of e.L)t.parentNode===n&&r(t)&&i.add(t);if(0===i.size)return!1;let c=[...n.childNodes].filter(n=>n!==t&&!i.has(n)&&!e.L.includes(n)&&(r(n)||o._t&&n.textContent.includes("{{")));return c.length>0&&console.warn(`[@wcstack/state] <${e.host.el.localName}>: ${c.length} node(s) added beside the content taken over are not bound.`),!0}(h,e,l))return async function(e,t,n,o){e.el.engine=null,e.el=t,e.P.element=t,t.engine=e.P,e.L=e.L.filter(e=>e.parentNode===n),t.isConnected?await je(e,o):o()}(h,e,l,a);let m=new s(i,new n);m.element=e,e.engine=m,function(e,t){let n=new Map;for(let e=t;null!==e&&e!==Object.prototype;e=Object.getPrototypeOf(e))for(let t of Object.getOwnPropertyNames(e)){let o=Object.getOwnPropertyDescriptor(e,t).value;"function"==typeof o&&"constructor"!==t&&n.set(o,null)}let o=(t,n,o)=>Reflect.apply(t,e.proxy,o);e.V=e=>{let t=n.get(e);return null===t&&n.set(e,t=new Proxy(e,{apply:o})),t}}(m,i);let y={el:e,L:[],P:m,host:f,pe:[],mt:new Map,fn:!1,dn:null,from:null,ie:null};for(let e of f.entries)y.pe.push({m:y,e});f.I=y,Q.set(m,y);let w=null===f.engine;w?c.element?.(m,"mounting"):(function(e){let t=e.P,n=e.host,o=n.engine,l=n.el.localName,r=n.entries.find(e=>""===e.$)??null;for(let e of n.entries){if(""===e.$)continue;let t=_(e.$);ae(n,t)&&(e.$!==t||se(n,t))&&ie(`${l}.${e.$}`,`[wcs/mount-own-key-shadow] <${l}>: "${n.he}.${e.$}" is hidden by the component's own "${t}"; rename one side.`)}if(null!==r){let e=o.v(r.ye,r.r);if(null!==e&&"object"==typeof e)for(let t of Object.keys(n.state))"$"!==t[0]&&t in e&&!n.entries.some(e=>e.$===t)&&ie(`${l}.${t}`,`[wcs/mount-own-key-shadow] <${l}>: its own "${t}" hides "${r.ye.t}.${t}" — remove the default to read the tree, or rename it to keep it private.`)}let i=Y.filter(e=>void 0!==n.state[e]);i.length>0&&ie(`${l}.${n.he}$`,`[wcs/mount-dollar-declaration] <${l}>: ${i.join(", ")} ${1===i.length?"is":"are"} not run in a mounted component — declare it on the root state.`);let a=t.rt;t.rt=n=>{ce(e,r,n),a.call(t,n)};let s=[...t.O.all()];for(let t of s)ce(e,r,t);for(let e of s)a.call(t,e);let u=t.Nt;t.Nt=()=>{(function(e){for(;void 0!==e;e=Q.get(e.host.engine))if(e.host.entries.some(e=>null!==e.r&&!e.r.w))return!1;return!0})(e)&&u.call(t)}}(y),me(y,!0),v.add(m),M(m,l));let b=c.wr?.(l,m);r(m,l),b?.(),y.L=[...l.childNodes],t(),w&&m.Pn(),Object.defineProperty(o,f.he,{configurable:!0,enumerable:!0,get:()=>m.proxy});let k=o.$stateReadyCallback;if("function"==typeof k)try{let e=k.call(o,f.he);null!==e&&"object"==typeof e&&"function"==typeof e.then&&e.then(void 0,$)}catch(e){$(e)}a(),e.isConnected?(await m.$e("$connectedCallback"),w&&e.isConnected&&c.element?.(m,"connected")):me(y,!1)}async function je(e,t){me(e,!0);for(let t of e.pe)we(t);t?.(),!e.broken&&(await e.P.$e("$connectedCallback"),null===e.host.engine&&e.el.isConnected&&c.element?.(e.P,"connected"))}function Pe(e,t){let n=e.getAttribute("bind-component");if(null===n)return function(e,t){return e.connectedCallbackPromise.catch(()=>{let n=l.get(t)?.element;if(!(e.V||void 0!==n&&n!==e&&n.isConnected)){E(t,e);for(let e of T.get(t)??[])e()}}),null}(e,t);let r=e.parentNode,i=r instanceof ShadowRoot,a=i?r.host:r instanceof Element?r:null,s=()=>{let t=null===a?void 0:V.get(a)?.I;return t?.el===e?t:null},d=t=>{throw i&&E(r,e),t},f=!1;return{St:()=>(null!==a&&a.localName.includes("-")?async function(e,t,n,l){let r=n.localName;(["state","src","json"].some(t=>e.hasAttribute(t))||null!==e.querySelector('script[type="module"]'))&&g(`<${u.tagNames.state} bind-component> takes its state from <${r}>.${t}: it cannot also load one (state / src / json / an inline script).`),await o(n).whenDefined(r);let i=V.get(n);if(void 0!==i)return i.he!==t&&g(`<${r}> already has a <${u.tagNames.state} bind-component="${i.he}">.`),i.state;let a=()=>(z.get(n)??[]).filter(e=>_(e.name)===t),s=oe(n,t);if(s&&0===a().length&&le(n),0===a().length&&(s||((e,t)=>!0===e.getAttribute(J)?.split(" ").includes(t))(n,t))){let e;await new Promise((o,l)=>{H.set(n,o),e=function(e,t){C(e)&&t();let n=T.get(e)??new Set;return T.set(e,n.add(t)),()=>n.delete(t)}(n.getRootNode(),()=>l(new Error(`[@wcstack/state] <${r}>.${t} will not mount: the root state failed to initialize.`)))}).finally(()=>e())}H.delete(n);let c=a(),d=X.get(n),f=void 0!==d&&d.has(t)?d.get(t):n[t];if((null===f||"object"!=typeof f)&&g(`"bind-component": <${r}>.${t} must be an object (the component's state), got ${null===f?"null":typeof f}.`),0===c.length&&l){let e=new Error(`[@wcstack/state] A plain (unwired) Light DOM "bind-component" is not supported. Attach a shadow root to <${r}>, or mount it from the host (${u.bindAttributeName}="${t}: path").`);return queueMicrotask(()=>{throw e}),K}let h=[];for(let e of c){let o=e.name===t?"":e.name.slice(t.length+1);h.some(e=>e.$===o)&&g(`<${r}> maps "${e.name}" twice.`);let l=o.split(".").indexOf("*");if(l>=0){let n=o.split(".").slice(0,l).join(".");g(`<${r}> maps "${e.name}": the component-side path of a mount cannot contain "*"${""===n?"":` — map the list itself ("${t}.${n}: <the host's list>")`}.`)}h.push({$:o,ye:e.o,r:e.r,ro:F.has(e)}),e.engine.Tn(e),""!==o&&delete n[e.name]}let m=0===c.length?function(e){let t=Object.getOwnPropertyDescriptors(e),n=Object.isFrozen(e);for(let e of Object.values(t))"value"in e&&!1===e.writable&&(e.writable=!0,n=!0);return n?Object.create(Object.getPrototypeOf(e),t):e}(f):f;return V.set(n,i={el:n,he:t,state:m,engine:0===c.length?null:c[0].engine,entries:h,I:null}),m}(e,n,a,!i):Promise.reject(new Error(`[@wcstack/state] "bind-component" requires <${u.tagNames.state}> to be a direct child of a custom element.`))).catch(d),async start(t,n){await ke(e,a,i?r:a,t,()=>{f=!0,n()}).catch(e=>{let t=s();return!f&&null!==t&&(t.broken=!0),d(e)})},Qe(){let t=s();null!==t?je(t).catch($):f?Promise.resolve().then(()=>{if(e.parentNode===r)return ke(e,a,i?r:a,V.get(a).state,()=>{})}).catch($):H.has(a)&&le(a)},Mn(){let e=s();null!==e&&(me(e,!1),!e.broken&&(e.P.$e("$disconnectedCallback"),null===e.host.engine&&c.element?.(e.P,"disconnected")))},reset(){g(`re-setting a component's state is not supported: write <${a?.localName}>.${n} instead.`)}}}var Oe={name:"scopes",hooks:c,install(){c.dt=f(m,c.dt,q),c.dt=f(m,c.dt,Z),c.dt=f(m,c.dt,Pe),c.dr=te,c.Po=ne,c.element=d(c.element,(e,t)=>{if("mounting"!==t)return function(e,t){let n=k.get(e)??[];if("disconnected"===t)for(let e of n)x(e);else if("reset"!==t&&A(l.get(e.root))===e){M(e,e.root);for(let e of n)y.get(e.root).has(e.t)||y.get(e.root).set(e.t,e)}}(e,t);let n=e.element.getRootNode();M(e,n),function(e,t){let n=t.host,o=void 0===n?void 0:I.get(n);void 0!==o&&L.set(e,{host:n,def:o})}(e,n)}),c.re=d(c.re,(e,t,n,o,l,r)=>{(function(e,t,n,o){let l=L.get(e);if(void 0===l)return;let r=t.t.split(".",1)[0];if(!l.def.bindables.includes(r))return;let i=o&&t.t===r;l.host.dispatchEvent(new CustomEvent(`${l.def.tag}:${r}-changed`,{detail:i?n:void 0,bubbles:!0}))})(e,t,l,r),ve(e,t,n,o,l,r,!1)}),c.Se=d(c.Se,(e,t,n)=>ve(e,t,n,void 0,void 0,!1,!0)),c.Ie=f(h,c.Ie,(e,t,n,o,l)=>(function(e,t){let n=k.get(e);if(void 0!==n&&0===t.n)for(let{t:e}of n)e.startsWith(`${t.t}.`)&&g(`writing "${t.t}" would replace the volume grafted at "${e}"; write the paths under it instead.`)}(e,t),function(e,t,n){let o,l=Q.get(e);if(void 0===l)return!1;for(let e=t;null!==e&&void 0===o;e=e.a)o=l.mt.get(e);if(void 0===o)return!1;let r=o.e;return!((null===r.r||r.r.w)&&!r.ro)&&(!!n||(de(l,r.r),void g(`[wcs/mount-readonly] <${l.host.el.localName}> cannot write "${t.t}": it is mounted read-only ("${l.host.he}${""===r.$?"":`.${r.$}`}#ro: ${r.ye.t}"). Write it on the host, or drop #ro from the mount.`)))}(e,t,l)));let e=c.fe;c.fe=(t,n)=>{let o=k.get(t);void 0!==o&&o.length>0&&g(`re-setting a root state with grafted volumes (${o.map(e=>e.t).join(", ")}) is not supported: their data is part of the tree.`),function(e){let t=U.get(e);if(void 0===t)return!1;for(let e of t.values())if(e.size>0)return!0;return!1}(t)&&g("re-setting a root state with mounted components is not supported: they read its data."),e?.(t,n)}}},Ne=Oe;export{Ne as default,Oe as scopes};
|
|
2
2
|
//# sourceMappingURL=scopes.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"../chunks/chunk-YIDHPXYQ.js";import{b as t,c as l}from"../chunks/chunk-LWRYFYOC.js";import"../chunks/chunk-J3PTKUWV.js";import{a as n,i as o,j as r,k as i,l as s,m as a,n as c,o as u}from"../chunks/chunk-47I6RYV3.js";import"../chunks/chunk-ISBASPV2.js";import"../chunks/chunk-SOFOV2OG.js";import{a as f}from"../chunks/chunk-FQUDP3XK.js";import"../chunks/chunk-TS2HEHBQ.js";import"../chunks/chunk-P3JKSHRN.js";import"../chunks/chunk-EBIQH2HE.js";import{a as d,b as p}from"../chunks/chunk-BCL75PFH.js";var m=e=>e.split(".").slice(0,2).join("."),h=class extends t{static find(e){return e.querySelector?.(f.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return m(this.version)===m(e)}};function g(e){let t=f.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends h{})}var b=()=>f.tagNames.ssr,v=Symbol.for("wcstack.ssr.snapshotBuilder"),y=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),w=e=>document.createComment(e),N=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,S=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),A=new WeakMap,x=new WeakMap,k=new WeakMap,T=new WeakSet,$=new WeakMap;function j(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function C(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var E=e=>{let t=e.nextSibling;return 1!==e.nodeType||"a"!==t?.localName||!t.hasAttribute("data-wcs-ssr-link")&&e.anchorElement!==t?null:t};function W(e,t,l,n){let o=w(null===n?"wcs-[":`wcs-[:${n}`),r=w("wcs-]");l.length>0&&l[0].Re().before(...j(e,t)),t.after(o);for(let e of l)null===n&&e.Re().before(w("wcs-|"));let i=l.length>0?(e=>null===e.L?e.ct:e.L[e.L.length-1])(l[l.length-1]):o;(E(i)??i).after(r);for(let e of j(o,r))T.add(e)}function q(e){if(e instanceof o){W(e.S,e.S,e.Ae,null);for(let t of e.Ae)I(t);return}let t=e.I;null!==t&&(W(e.q[e.y].S,e.q[e.q.length-1].S,[t],e.y),I(t))}function I(e){if(null!==e.u)for(let t of e.u)q(t)}var O=new Set(["script","style","template","textarea","title"]),M="data-wcs-raw",P=e=>O.has(e.localName)||e.localName===b();function R(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(w("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(w("wcs-s")):1===t.nodeType&&!P(t)&&R(t)}var z=0;function V(t,l){let n=t.getRootNode(),o=[l];for(let e of x.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&o.push(e);let r=new Map;for(let e of o){let t=A.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.N&&l.set(t.N.S,t.N),null!==t.W)for(let e of t.W)l.set(e.S,e);for(let t of e.ue.values())for(let e of t)if(null!==e.j)for(let t of e.j.q)l.set(t.S,e.j);let n=new Set;for(let[e,o]of t){r.set(e,o);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),q(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=k.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>T.has(e)||1===e.nodeType&&t.has(e)&&J(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(P(e.parentNode)?$.has(e):t.has(l)&&S(l,"wcs-t:"))&&($.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);P(e)&&l.some(e=>$.has(e))&&e.setAttribute(M,l.map(e=>$.has(e)?`{{ ${$.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}R(9===n.nodeType?n.body:n);let i=document.createElement(b());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of r){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,o=`wcs-${n?"s":"t"}${z++}`;e.replaceWith(w(`wcs-p:${o}`));let r=document.importNode(u(t),!0);for(let e of Array.from(r.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(C(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(r),r=e}let s=document.createElement("template");s.id=o,i.append(C(t,s,r))}t.before(i)}function D(e){!function(e){if(null!==e.querySelector(f.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>$.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${f.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===b())continue;let e=t.engine;null!=e&&V(t,e)}}var H=Symbol.for("wcstack.state.ssr.impl"),U=new Map,B=new WeakMap,J=e=>!0===d.Eo?.(e),L=e=>1===e.nodeType&&!P(e)&&!J(e),Y=e=>e.f.flat().concat(e.z??[]),F=e=>{for(let t of Y(e))t.remove()};function Q(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),o=e.previousSibling,r=e.parentNode,i=[],s=e.nextSibling;for(e.remove();null!==s&&!N(s,"wcs-]");){let e=s.nextSibling;if(N(s,"wcs-|"))i.push([]),s.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];S(s,"wcs-[")?e=Q(s,t,l):(l.push(s),L(s)&&K(s,t))}s=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,z:s??r.appendChild(w("wcs-]"))},u=Y(c);s=c.z.nextSibling;for(let e of u)l?.push(e),t&&a.add(e);return t&&null!==o?U.set(o,c):F(c),s}function K(e,t){for(let l=e.firstChild;null!==l;)S(l,"wcs-[")?l=Q(l,t):(L(l)&&K(l,t),l=l.nextSibling)}function X(e,t,l){let n=e=>{for(let o of Array.from(e.childNodes))if(o.parentNode===e)if(8===o.nodeType){let e=o.data;try{if("wcs-s"===e)o.remove();else if("wcs-e"===e)o.replaceWith("");else if(e.startsWith("wcs-t:")){let t=w(`@@:${decodeURIComponent(e.slice(6))}`),l=o.nextSibling;for(;null!==l&&!N(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),o.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=o.parentNode,n="s"===e[10]?C(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,o)}}}catch{}}else 1===o.nodeType&&!P(o)&&(J(o)?B.set(o,{ssr:t,Te:l}):n(o))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||oe(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{S(e,"wcs-[")?n++:N(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let o=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(S(n,"wcs-["))o++;else if(N(n,"wcs-]")&&0===o--){t.prepend(...e.slice(l));break}}}(e),K(e,l)}function G(e,t){let l=B.get(e);if(void 0===l)return null;B.delete(e);let n=e=>X(e,l.ssr,l.Te);if(l.Te||te(t,e,e,n),n(e),!l.Te)return null;let o=d.Te;return d.Te=se,()=>{d.Te=o,Z()}}function Z(){for(let e of U.values())F(e);U.clear()}function _(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function ee(e,t,l,n){let o=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===o||e.length>o[l].length)&&(o=n)}let r=o?.[n];if(null==r)return null;let i=o[l],s=""===i?t:t.slice(i.length+1);return""===r?s:""===s?r:`${r}.${s}`}function te(e,t,l,n){let o=document.createElement("template").content;for(let e of l.childNodes)o.appendChild(o.ownerDocument.importNode(e,!0));n(o),e.root=t;let r=()=>{};c(e,[...o.childNodes],null,!0,r,r,r,(t,l)=>s(e,l,null,0))}function le(e,t,l){if(y()){if(l instanceof Array){for(let e=l.length;e-- >0;)r(l[e])&&l.splice(e,1);let e=t;if(l.some(i))T.add(e);else if(e.localName.includes("-")&&!J(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);k.set(e,t)}return}if("string"==typeof l){if($.set(t,l),P(t.parentNode))return;let e=w(`wcs-t:${encodeURIComponent(l)}`),n=w("wcs-/t");return t.before(e),void t.after(n)}let n=A.get(e);void 0===n&&A.set(e,n=new Map),n.set(t,l);let o=t.getRootNode(),s=x.get(o);return void 0===s&&x.set(o,s=new Set),void s.add(e)}if("string"!=typeof l&&U.size>0){let e=U.get(l);void 0!==e&&(U.delete(l),U.set(t,e))}}var ne=e=>null!==e&&8===e.nodeType&&[f.commentIfPrefix,f.commentElseIfPrefix,f.commentElsePrefix].includes(e.data),oe=e=>3===e.nodeType&&""===e.data.trim(),re=e=>{let t=U.get(e)?.z??e;return(E(t)??t).nextSibling};function ie(e,t){if(t.length!==e.ln.childNodes.length)return!1;let l=e.Cn;for(let n=0;n<l.length;n++){let o=l[n],r=e.ln,i=t[o[0]];for(let e=0;;){if(r=r.childNodes[o[e]],i?.nodeName!==r.nodeName)return!1;if(++e===o.length)break;i=(E(i)??i).firstChild;for(let t=o[e];t>0&&null!==i;t--)i=re(i)}e.So[n]=i}return!0}function se(e,t,l){if(0===U.size)return null;let n=t,o=0;if(!l){let e=f.commentIfPrefix;if(!N(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ne(l)&&o++,!N(l,e));l=l.previousSibling);for(let l=t.nextSibling;!U.has(n)&&null!==l&&!N(l,e)&&1!==l.nodeType;l=l.nextSibling)ne(l)&&(n=l)}let r=U.get(n);if(void 0===r)return null;if(!l&&r.branch!==o)return U.delete(n),F(r),null;let i=r.f.shift();if(0===r.f.length&&U.delete(n),r.z?.replaceWith(...j(t,n)),r.z=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=U.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.z;)e++;else E(i[e])===i[e+1]&&e++}if(!ie(e,s)){let l=(e.jn?e.root:e.ln).cloneNode(!0);s=e.jn?[l]:[...l.childNodes],ie(e,s),(i[0]??r.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var ae={name:"ssr",hooks:d,install(){d.Dn=le,d.hr=G;let t=d.element;d.element=(l,o)=>{"mounting"===o&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||y())return;let o=l.previousElementSibling,r=o?.localName===b(),i=r?o.getAttribute("version"):null,s=null===i||m(i)===m(e);if(s){let e=t,l=e.$e;e.$e=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!r)return;let a=!s&&parseInt(i)<4,c=/^3\.(\d+)\.(\d+)$/.exec(i),u=null!==c&&(+c[1]-5||+c[2]-3)>=0;s||console.warn(`[@wcstack/state] <${b()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!u?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let p=s?o.querySelector('script[type="application/json"]'):null;if(null!==p){let e=JSON.parse(p.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let h=l.getRootNode();for(let e of Array.from(h.querySelectorAll(`[${M}]`)))e.textContent=e.getAttribute(M),e.removeAttribute(M);let g=9===h.nodeType?h.body:h;o.remove();let v=e=>a?function(e,t,l){let o=new Map,r=e=>{let t=e.parentElement;for(;null!==t&&!J(t);)t=t.parentElement;if(null===t)return null;let l=o.get(t);if(void 0===l){let e=r(t),i=t.querySelector(`:scope > ${f.tagNames.state}[bind-component]`).getAttribute("bind-component");o.set(t,l=[]);for(let o of n(t.getAttribute(f.bindAttributeName)??"")){let t=o.Ze;o.Ne[0]===i&&l.push([e?ee(e,t,1,0):t,o.Ne.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=r(e);if(null===n)return t;let o=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===o)return l?t:ee(n,t,0,1)??t;let i=o[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?o[2]:ee(n,o[2],2,1)??o[2]};for(let t of _(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!N(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[w(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of _(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],o=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===o)continue;let r=document.importNode(o,!0),a=f.bindAttributeName;r.removeAttribute("id"),r.setAttribute(a,r.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,o)=>t+i(l??n,o))),s(r.content,l??n);let c=r.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(c?.getAttribute?.(a)??"")?r.content.childNodes:[r])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(e,o,u):X(e,o,s);s||te(t,h,g,v),queueMicrotask(function(e){let t=[];for(let l of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===l.localName){let e=Array.from(l.options),n=e.map(e=>e.selected),o=e.map(e=>e.hasAttribute("selected")),r=o.lastIndexOf(!0);r<0&&(r=e.findIndex(e=>!e.disabled)),(l.multiple?e.some((e,t)=>n[t]!==o[t]):l.selectedIndex!==r)&&t.push([l,()=>e.forEach((e,t)=>e.selected=n[t])])}else if("checkbox"===l.type||"radio"===l.type){let e=l.checked;e!==l.defaultChecked&&(e||"checkbox"===l.type)&&t.push([l,()=>l.checked=e])}else if("file"!==l.type&&l.value!==l.defaultValue){let e=l.value;t.push([l,()=>l.value=e])}return()=>{for(let[e,l]of t)e.isConnected&&(l(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))}}(g)),v(g),s&&(d.Te=se,queueMicrotask(()=>{Z(),d.Te=null}))}(l),t?.(l,o)},function(){let e=globalThis;e[H]={build:D,reset(){z=0}},void 0===e[v]&&(e[v]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[H].build(t),reset:()=>e[H].reset()})}(),d.Ao=p(d.Ao,g);for(let e of l())g(e)}},ce=ae;export{ce as default,ae as ssr};
|
|
1
|
+
import{a as e}from"../chunks/chunk-TB52U4QV.js";import{b as t,c as l}from"../chunks/chunk-FT7OW7CG.js";import"../chunks/chunk-65B2K2XD.js";import{a as n,i as o,j as r,k as i,l as s,m as a,n as c,o as u}from"../chunks/chunk-IWY3I2DG.js";import"../chunks/chunk-FFXJVUTT.js";import"../chunks/chunk-GU7IAIWW.js";import{a as f}from"../chunks/chunk-JCQTA35B.js";import"../chunks/chunk-MZVF2WEY.js";import"../chunks/chunk-PTFWXISY.js";import"../chunks/chunk-UE6JK2ZA.js";import{a as d,b as p}from"../chunks/chunk-SJRJALR4.js";var m=e=>e.split(".").slice(0,2).join("."),h=class extends t{static find(e){return e.querySelector?.(f.tagNames.ssr)??null}get version(){return this.getAttribute("version")??""}get stateData(){let e=this.querySelector('script[type="application/json"]');return null===e?{}:JSON.parse(e.textContent||"{}")}get templates(){let e=new Map;for(let t of Array.from(this.children))"template"===t.localName&&e.set(t.id,t);return e}get hydrateProps(){return{}}getTemplate(e){return this.templates.get(e)??null}verifyVersion(){return m(this.version)===m(e)}};function g(e){let t=f.tagNames.ssr;void 0===e.get(t)&&e.define(t,class extends h{})}var b=()=>f.tagNames.ssr,v=Symbol.for("wcstack.ssr.snapshotBuilder"),y=()=>!0===document.documentElement?.hasAttribute("data-wcs-server"),w=e=>document.createComment(e),N=(e,t)=>null!==e&&8===e.nodeType&&e.data===t,S=(e,t)=>null!==e&&8===e.nodeType&&e.data.startsWith(t),A=new WeakMap,x=new WeakMap,k=new WeakMap,T=new WeakSet,$=new WeakMap;function W(e,t){let l=[];for(let n=e;null!==n&&(l.push(n),n!==t);n=n.nextSibling);return l}function C(e,t,...l){for(let l of Array.from(e.attributes))t.setAttribute(l.name,l.value);return(t.content??t).append(...l),t}var E=e=>{let t=e.nextSibling;return 1!==e.nodeType||"a"!==t?.localName||!t.hasAttribute("data-wcs-ssr-link")&&e.anchorElement!==t?null:t};function j(e,t,l,n){let o=w(null===n?"wcs-[":`wcs-[:${n}`),r=w("wcs-]");l.length>0&&l[0].Pe().before(...W(e,t)),t.after(o);for(let e of l)null===n&&e.Pe().before(w("wcs-|"));let i=l.length>0?(e=>null===e.L?e.ut:e.L[e.L.length-1])(l[l.length-1]):o;(E(i)??i).after(r);for(let e of W(o,r))T.add(e)}function q(e){if(e instanceof o){j(e.S,e.S,e.Ae,null);for(let t of e.Ae)I(t);return}let t=e.I;null!==t&&(j(e.q[e.y].S,e.q[e.q.length-1].S,[t],e.y),I(t))}function I(e){if(null!==e.u)for(let t of e.u)q(t)}var M=new Set(["script","style","template","textarea","title"]),O="data-wcs-raw",P=e=>M.has(e.localName)||e.localName===b();function D(e){for(let t of Array.from(e.childNodes))3===t.nodeType?""===t.data?t.replaceWith(w("wcs-e")):null!==t.nextSibling&&3===t.nextSibling.nodeType&&t.after(w("wcs-s")):1===t.nodeType&&!P(t)&&D(t)}var R=0;function z(t,l){let n=t.getRootNode(),o=[l];for(let e of x.get(n)??[])e!==l&&!0===e.element?.hasAttribute("bind-component")&&o.push(e);let r=new Map;for(let e of o){let t=A.get(e);if(void 0===t)continue;let l=new Map;for(let t of e.oe.values())if(null!==t.N&&l.set(t.N.S,t.N),null!==t.W)for(let e of t.W)l.set(e.S,e);for(let t of e.ue.values())for(let e of t)if(null!==e.D)for(let t of e.D.q)l.set(t.S,e.D);let n=new Set;for(let[e,o]of t){r.set(e,o);let t=l.get(e);void 0!==t&&!n.has(t)&&e.isConnected&&(n.add(t),q(t))}}for(let e of Array.from(n.querySelectorAll("*"))){let t=k.get(e);if(void 0!==t){let l=document.createTreeWalker(e,133,{acceptNode:e=>T.has(e)||1===e.nodeType&&t.has(e)&&B(e)?2:1}),n=[];for(let e=l.nextNode();null!==e;e=l.nextNode()){let l=e.previousSibling;(3===e.nodeType?e.data.includes("{{")&&!(P(e.parentNode)?$.has(e):t.has(l)&&S(l,"wcs-t:"))&&($.has(e)||t.get(e)!==e.data):!t.has(e))&&n.push(e)}for(let e of n)e.remove()}let l=Array.from(e.childNodes);P(e)&&l.some(e=>$.has(e))&&e.setAttribute(O,l.map(e=>$.has(e)?`{{ ${$.get(e)} }}`:8===e.nodeType?`\x3c!--${e.data}--\x3e`:e.textContent).join(""))}D(9===n.nodeType?n.body:n);let i=document.createElement(b());i.setAttribute("version",e);let s=document.createElement("script");s.type="application/json",s.textContent=function(e){return JSON.stringify(e).replace(/[<>&\u2028\u2029]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}(function(e){let t={};for(let l of Object.keys(e)){if("$"===l[0])continue;let n=Object.getOwnPropertyDescriptor(e,l);void 0!==n.get||void 0!==n.set||"function"==typeof n.value||(t[l]=n.value)}return t}(l.target)),i.append(s);for(let[e,t]of r){if(!e.isConnected)continue;let l=e.parentNode;for(;null!==l&&"svg"!==l.localName&&"foreignObject"!==l.localName;)l=l.parentElement;let n="svg"===l?.localName,o=`wcs-${n?"s":"t"}${R++}`;e.replaceWith(w(`wcs-p:${o}`));let r=document.importNode(u(t),!0);for(let e of Array.from(r.querySelectorAll("template")))"http://www.w3.org/2000/svg"===e.namespaceURI&&e.replaceWith(C(e,document.createElement("template"),...e.childNodes));if(n){let e=document.createElementNS(l.namespaceURI,"svg");e.append(r),r=e}let s=document.createElement("template");s.id=o,i.append(C(t,s,r))}t.before(i)}function U(e){!function(e){if(null!==e.querySelector(f.tagNames.state))for(let t of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===t.localName){let e=Array.from(t.options);if(t.multiple||e.some(e=>e.hasAttribute("selected"))||e[t.selectedIndex]!==e.find(e=>!e.disabled))for(let t of e)t.toggleAttribute("selected",t.selected)}else"textarea"===t.localName?t.value!==t.defaultValue&&!t.value.includes("{{")&&!Array.from(t.childNodes).some(e=>$.has(e))&&(t.textContent=t.value):"checkbox"===t.type||"radio"===t.type?t.toggleAttribute("checked",t.checked):"password"!==t.type&&t.value!==t.defaultValue&&t.setAttribute("value",t.value)}(e);for(let t of Array.from(e.querySelectorAll(`${f.tagNames.state}[enable-ssr]`))){if(t.hasAttribute("mount")||t.hasAttribute("bind-component")||t.previousElementSibling?.localName===b())continue;let e=t.engine;null!=e&&z(t,e)}}var J=Symbol.for("wcstack.state.ssr.impl"),V=new Map,L=new WeakMap,B=e=>!0===d.Po?.(e),F=e=>1===e.nodeType&&!P(e)&&!B(e),G=e=>e.f.flat().concat(e.z??[]),X=e=>{for(let t of G(e))t.remove()};function Y(e,t,l){let n=/^wcs-\[(?::(\d+))?/.exec(e.data),o=e.previousSibling,r=e.parentNode,i=[],s=e.nextSibling;for(e.remove();null!==s&&!N(s,"wcs-]");){let e=s.nextSibling;if(N(s,"wcs-|"))i.push([]),s.remove();else{0===i.length&&i.push([]);let l=i[i.length-1];S(s,"wcs-[")?e=Y(s,t,l):(l.push(s),F(s)&&K(s,t))}s=e}let c={branch:void 0===n[1]?null:Number(n[1]),f:i,z:s??r.appendChild(w("wcs-]"))},u=G(c);s=c.z.nextSibling;for(let e of u)l?.push(e),t&&a.add(e);return t&&null!==o?V.set(o,c):X(c),s}function K(e,t){for(let l=e.firstChild;null!==l;)S(l,"wcs-[")?l=Y(l,t):(F(l)&&K(l,t),l=l.nextSibling)}function Q(e,t,l){let n=e=>{for(let o of Array.from(e.childNodes))if(o.parentNode===e)if(8===o.nodeType){let e=o.data;try{if("wcs-s"===e)o.remove();else if("wcs-e"===e)o.replaceWith("");else if(e.startsWith("wcs-t:")){let t=w(`@@:${decodeURIComponent(e.slice(6))}`),l=o.nextSibling;for(;null!==l&&!N(l,"wcs-/t");){let e=l.nextSibling;l.remove(),l=e}l?.remove(),o.replaceWith(t)}else if(e.startsWith("wcs-p:")){let l=t.querySelector(`template[id="${e.slice(6)}"]`);if(null!==l){let t=o.parentNode,n="s"===e[10]?C(l,document.createElementNS(t.namespaceURI,"template"),...document.importNode(l.content.firstChild,!0).childNodes):document.importNode(l,!0);n.removeAttribute("id"),t.replaceChild(n,o)}}}catch{}}else 1===o.nodeType&&!P(o)&&(B(o)?L.set(o,{ssr:t,Te:l}):n(o))};n(e),function(e){for(let t of Array.from(e.querySelectorAll("table > tbody"))){let e=[];for(let l=t.previousSibling;null!==l&&(8===l.nodeType||oe(l)||"template"===l.localName);l=l.previousSibling)e.unshift(l);let l=0,n=0;if(e.forEach((e,t)=>{S(e,"wcs-[")?n++:N(e,"wcs-]")&&--n<0&&(n=0,l=t+1)}),0===n)continue;let o=0;for(let n=t.firstChild;null!==n;n=n.nextSibling)if(S(n,"wcs-["))o++;else if(N(n,"wcs-]")&&0===o--){t.prepend(...e.slice(l));break}}}(e),K(e,l)}function Z(e,t){let l=L.get(e);if(void 0===l)return null;L.delete(e);let n=e=>Q(e,l.ssr,l.Te);if(l.Te||te(t,e,e,n),n(e),!l.Te)return null;let o=d.Te;return d.Te=se,()=>{d.Te=o,H()}}function H(){for(let e of V.values())X(e);V.clear()}function _(e){let t=[];for(let l=document.createTreeWalker(e,128);l.nextNode();)t.push(l.currentNode);return t}function ee(e,t,l,n){let o=null;for(let n of e){let e=n[l];null!==e&&(""===e||t===e||t.startsWith(`${e}.`))&&(null===o||e.length>o[l].length)&&(o=n)}let r=o?.[n];if(null==r)return null;let i=o[l],s=""===i?t:t.slice(i.length+1);return""===r?s:""===s?r:`${r}.${s}`}function te(e,t,l,n){let o=document.createElement("template").content;for(let e of l.childNodes)o.appendChild(o.ownerDocument.importNode(e,!0));n(o),e.root=t;let r=()=>{};c(e,[...o.childNodes],null,!0,r,r,r,(t,l)=>s(e,l,null,0))}function le(e,t,l){if(y()){if(l instanceof Array){for(let e=l.length;e-- >0;)r(l[e])&&l.splice(e,1);let e=t;if(l.some(i))T.add(e);else if(e.localName.includes("-")&&!B(e)){let t=new Map;for(let l=document.createTreeWalker(e,133);l.nextNode();)t.set(l.currentNode,l.currentNode.data);k.set(e,t)}return}if("string"==typeof l){if($.set(t,l),P(t.parentNode))return;let e=w(`wcs-t:${encodeURIComponent(l)}`),n=w("wcs-/t");return t.before(e),void t.after(n)}let n=A.get(e);void 0===n&&A.set(e,n=new Map),n.set(t,l);let o=t.getRootNode(),s=x.get(o);return void 0===s&&x.set(o,s=new Set),void s.add(e)}if("string"!=typeof l&&V.size>0){let e=V.get(l);void 0!==e&&(V.delete(l),V.set(t,e))}}var ne=e=>null!==e&&8===e.nodeType&&[f.commentIfPrefix,f.commentElseIfPrefix,f.commentElsePrefix].includes(e.data),oe=e=>3===e.nodeType&&""===e.data.trim(),re=e=>{let t=V.get(e)?.z??e;return(E(t)??t).nextSibling};function ie(e,t){if(t.length!==e.ln.childNodes.length)return!1;let l=e.Dn;for(let n=0;n<l.length;n++){let o=l[n],r=e.ln,i=t[o[0]];for(let e=0;;){if(r=r.childNodes[o[e]],i?.nodeName!==r.nodeName)return!1;if(++e===o.length)break;i=(E(i)??i).firstChild;for(let t=o[e];t>0&&null!==i;t--)i=re(i)}e.No[n]=i}return!0}function se(e,t,l){if(0===V.size)return null;let n=t,o=0;if(!l){let e=f.commentIfPrefix;if(!N(t,e))for(let l=t.previousSibling;null!==l&&1!==l.nodeType&&(ne(l)&&o++,!N(l,e));l=l.previousSibling);for(let l=t.nextSibling;!V.has(n)&&null!==l&&!N(l,e)&&1!==l.nodeType;l=l.nextSibling)ne(l)&&(n=l)}let r=V.get(n);if(void 0===r)return null;if(!l&&r.branch!==o)return V.delete(n),X(r),null;let i=r.f.shift();if(0===r.f.length&&V.delete(n),r.z?.replaceWith(...W(t,n)),r.z=null,void 0===i)return null;let s=[];for(let e=0;e<i.length;e++){let t=V.get(i[e]);if(s.push(i[e]),void 0!==t)for(;e<i.length&&i[e]!==t.z;)e++;else E(i[e])===i[e+1]&&e++}if(!ie(e,s)){let l=(e.Ln?e.root:e.ln).cloneNode(!0);s=e.Ln?[l]:[...l.childNodes],ie(e,s),(i[0]??r.f.find(e=>e.length>0)?.[0]??t).before(l);for(let e of i)e.remove()}return s}var ae={name:"ssr",hooks:d,install(){d.Bn=le,d.wr=Z;let t=d.element;d.element=(l,o)=>{"mounting"===o&&function(t){let l=t.element;if(!l.hasAttribute("enable-ssr")||y())return;let o=l.previousElementSibling,r=o?.localName===b(),i=r?o.getAttribute("version"):null,s=null===i||m(i)===m(e);if(s){let e=t,l=e.$e;e.$e=(e,n)=>"$connectedCallback"===e?void 0:l.call(t,e,n)}if(!r)return;let a=!s&&parseInt(i)<4,c=/^3\.(\d+)\.(\d+)$/.exec(i),u=null!==c&&(+c[1]-5||+c[2]-3)>=0;s||console.warn(`[@wcstack/state] <${b()} version="${i}"> does not match ${e}: its snapshot is discarded, and the page renders on the client from its own state.${a&&!u?" 3.x output keeps only the path of a text binding outside a template, so such a binding loses its filters: deploy @wcstack/server 4.0 with this client.":""}`);let p=s?o.querySelector('script[type="application/json"]'):null;if(null!==p){let e=JSON.parse(p.textContent||"{}"),l=t.target;for(let t of Object.keys(e)){let n=Object.getOwnPropertyDescriptor(l,t);void 0!==n&&(void 0!==n.get||void 0!==n.set||"function"==typeof n.value)||(l[t]=e[t])}t.hydrated=!0}let h=l.getRootNode();for(let e of Array.from(h.querySelectorAll(`[${O}]`)))e.textContent=e.getAttribute(O),e.removeAttribute(O);let g=9===h.nodeType?h.body:h;o.remove();let v=e=>a?function(e,t,l){let o=new Map,r=e=>{let t=e.parentElement;for(;null!==t&&!B(t);)t=t.parentElement;if(null===t)return null;let l=o.get(t);if(void 0===l){let e=r(t),i=t.querySelector(`:scope > ${f.tagNames.state}[bind-component]`).getAttribute("bind-component");o.set(t,l=[]);for(let o of n(t.getAttribute(f.bindAttributeName)??"")){let t=o.et;o.Ne[0]===i&&l.push([e?ee(e,t,1,0):t,o.Ne.slice(1).join("."),e&&t])}}return l},i=(e,t,l)=>{let n=r(e);if(null===n)return t;let o=/^([^|]*)#m\d+\.([^|]*)$/.exec(t);if(null===o)return l?t:ee(n,t,0,1)??t;let i=o[1].replace(/#m\d+\./g,"").slice(0,-1);return n.some(e=>""===e[1]&&(e[0]===i||e[2]===i))?o[2]:ee(n,o[2],2,1)??o[2]};for(let t of _(e).reverse()){let e=/^@@wcs-(\w+)-start:([\s\S]*)/.exec(t.data);if(null===e)continue;let n=t.nextSibling;for(;null!==n&&!N(n,`@@wcs-${e[1]}-end:${e[2]}`);)n=n.nextSibling;if(null!==n){for(;t.nextSibling!==n;)t.nextSibling.remove();n.remove(),t.replaceWith(..."text"===e[1]?[w(`@@:${i(t,e[2],l)}`)]:[])}}let s=(e,l)=>{for(let n of _(e)){let e=/^@@wcs-(?:for|if|elseif|else):(\S+)$/.exec(n.data)?.[1],o=Array.from(t.querySelectorAll("template")).find(t=>t.id===e);if(void 0===o)continue;let r=document.importNode(o,!0),a=f.bindAttributeName;r.removeAttribute("id"),r.setAttribute(a,r.getAttribute(a).replace(/^(\s*\w+\s*:\s*)([^\s|]+)/,(e,t,o)=>t+i(l??n,o))),s(r.content,l??n);let c=r.content.firstChild;n.replaceWith(.../^\s*elseif\s*:/.test(c?.getAttribute?.(a)??"")?r.content.childNodes:[r])}};s(e);for(let t of Array.from(e.querySelectorAll("[data-wcs-ssr-id]")))t.removeAttribute("data-wcs-ssr-id")}(e,o,u):Q(e,o,s);s||te(t,h,g,v),queueMicrotask(function(e){let t=[];for(let l of Array.from(e.querySelectorAll("input,textarea,select")))if("select"===l.localName){let e=Array.from(l.options),n=e.map(e=>e.selected),o=e.map(e=>e.hasAttribute("selected")),r=o.lastIndexOf(!0);r<0&&(r=e.findIndex(e=>!e.disabled)),(l.multiple?e.some((e,t)=>n[t]!==o[t]):l.selectedIndex!==r)&&t.push([l,()=>e.forEach((e,t)=>e.selected=n[t])])}else if("checkbox"===l.type||"radio"===l.type){let e=l.checked;e!==l.defaultChecked&&(e||"checkbox"===l.type)&&t.push([l,()=>l.checked=e])}else if("file"!==l.type&&l.value!==l.defaultValue){let e=l.value;t.push([l,()=>l.value=e])}return()=>{for(let[e,l]of t)e.isConnected&&(l(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))}}(g)),v(g),s&&(d.Te=se,queueMicrotask(()=>{H(),d.Te=null}))}(l),t?.(l,o)},function(){let e=globalThis;e[J]={build:U,reset(){R=0}},void 0===e[v]&&(e[v]={protocol:"wcs-ssr-snapshot",version:1,build:t=>e[J].build(t),reset:()=>e[J].reset()})}(),d.Co=p(d.Co,g);for(let e of l())g(e)}},ce=ae;export{ce as default,ae as ssr};
|
|
2
2
|
//# sourceMappingURL=ssr.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as t,c as e}from"../chunks/chunk-
|
|
1
|
+
import{a as t,c as e}from"../chunks/chunk-MZVF2WEY.js";import{a as n,b as r,c as i,d as s,e as l,j as a,k as o}from"../chunks/chunk-SJRJALR4.js";var h={},f=/\.\d/,u=new Set(Object.getOwnPropertyNames(Object.prototype)),c=0,p=!1,d=null,m=()=>{p=!1,c++};function g(){if(null===d)if("function"==typeof MessageChannel){let t=new MessageChannel;t.port1.onmessage=m,t.port1.unref?.(),d=()=>t.port2.postMessage(0)}else d=()=>setTimeout(m,0);return p||(p=!0,d()),c}function y(t,e){let n=new Set,r=[t];for(;r.length>0;){let t=r.pop();if(!n.has(t)){n.add(t);for(let n of t.Q){for(let r of e)if(n.ee(r)&&(n.n===r.n||!(r.n<t.n&&t.h[r.n+1].ee(r))))return!0;null!==n.getter&&r.push(n)}}}return!1}var v=class{constructor(t,e){this.active=!1,this.Fe=new Map,this.early=[],this.n=0,this.Io=-1,this._n=new Set,this.qe=null,this.engine=t,this.De=e}pr(){let t=this.engine;this.Fe.clear();let e=this.early;this.early=[];for(let e of this.De)e.getter=null!==e.p.getter||e.p.ae,e.s=new WeakMap,this.prime(e,()=>{0===e.p.n?e.getter&&e.s.set(h,t.v(e.p,null)):this.Vn(e.p,1,null,n=>{e.getter&&this.prime(e,()=>e.s.set(n,t.v(e.p,n)))})});this.active=!0;let n=new Set;for(let[r,i,s,l]of e)if((null===i||i.w)&&Object.is(t.v(r,i),l)){n.add(r);for(let t of this.De)t.p===r&&this.ft(t,i,s,!0)}for(let t of this.De)t.getter&&0===t.p.n&&!this.Fe.has(t)&&y($(t.p),n)&&this.ft(t,null,void 0,!0);this.Fe.size>0&&t.ve()}prime(t,e){try{e()}catch(e){o(e,`[@wcstack/state] $watch initial evaluation of "${t.t}" threw.`),n.ct?.(this.engine,{type:"state:watch-error",phase:"prime",path:t.t,error:e})}}Do(){this.active=!1,this.Fe.clear(),this.early=[]}Vn(t,e,n,r){let i=this.engine.Ke(n,t.h[e]);for(let n of i.f)e===t.n?r(n):this.Vn(t,e+1,n,r)}ft(t,e,n,r){let i=this.Fe.get(t);void 0===i&&this.Fe.set(t,i=new Map);let s=i.get(e);void 0===s?i.set(e,[n,this.n,r]):(s[1]<this.n&&(s[1]=this.n),s[2]||=r)}re(t,e,n,r,i,s){if(this.active){(this.qe??=new Set).add(t);for(let s of this.De){let l=s.p;l.n!==t.n||!l.ee(t)||this.ft(s,e,s.getter?s.s.get(e??h):l===t&&i&&this.engine.Vt&&(null===r||"object"!=typeof r&&"function"!=typeof r)?n:void 0,!0)}}else s&&this.early.push([t,e,n,r])}Se(t,e){if(this.active)for(let n of this.De)(n.getter||=null!==n.p.getter||n.p.ae)&&n.p.n===t.n&&n.p.ee(t)&&this.ft(n,e,n.s.get(e??h),!1)}Qt(t,e){if(!this.active)return;let n=null;for(let r of this.De){let i=r.p;if(!(i.n<t.n||i.h[t.n]!==t.o)){n??=new Set(e);for(let e of t.f)n.has(e)||(i.n===t.n?this.ft(r,e,void 0,!0):this.Vn(i,t.n+1,e,t=>this.ft(r,t,void 0,!0)))}}}me(){let t=this.qe;if(this.qe=null,!this.active||0===this.Fe.size)return;let e=this.Fe;this.Fe=new Map;let r=this.engine,i=[];for(let s of this.De){let l=e.get(s);if(void 0===l)continue;let a,u=[...l].filter(([t])=>null===t||t.w);u.length>1&&u.sort((t,e)=>w(t[0],e[0]));for(let[e,[l,c,p]]of u){let u,d="evaluate",m=r.d;this.n=c+1,r.Ce++;try{if(u=r.v(s.p,e),s.getter&&(s.s.set(e??h,u),Object.is(u,l)&&(f.test(s.t)||null!==e&&!p&&!(a??=null!==t&&y($(s.p),t)))))continue;if(c>32){i.includes(s.t)||i.push(s.t);continue}r.d=e,n.ct?.(r,{type:"state:watch-fired",path:s.t}),d="handler",s.handler.call(r.proxy,u,l,...r.H(e))}catch(t){o(t,`[@wcstack/state] $watch "${s.t}" failed; the other watches still run.`),n.ct?.(r,{type:"state:watch-error",phase:d,path:s.t,error:t})}finally{r.d=m,this.n=0,r.Ce--}}}i.length>0&&this.jo(i)}jo(t){let e=g();e!==this.Io&&(this.Io=e,this._n.clear());let r=t.filter(t=>!this._n.has(t));if(0!==r.length){for(let t of r)this._n.add(t);o("[@wcstack/state] $watch handlers / $stream restarts kept writing for 32 batches; the chain is cut (nothing is rolled back)."),n.ct?.(this.engine,{type:"state:watch-chain-limit",maxDepth:32,paths:r})}}};function $(t){for(;null===t.getter&&null!==t.a;)t=t.a;return t}function w(t,e){let n=[],r=[];for(let e=t;null!==e;e=e.l.ce)n.unshift(e.y);for(let t=e;null!==t;t=t.l.ce)r.unshift(t.y);for(let t=0;t<n.length&&t<r.length;t++)if(n[t]!==r[t])return n[t]-r[t];return n.length-r.length}var b="$streamStatus",M="$streamError",j=new Set(Object.getOwnPropertyNames(Object.prototype)),D=!1;function S(t,e){for(let n=t;null!==n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){let t=Object.getOwnPropertyDescriptor(n,e);if(void 0!==t)return void 0!==t.get||void 0!==t.set||"function"==typeof t.value}return!1}var k=class{constructor(t,e,n){this.engine=t,this.entries=e,this.M=n}set(t,e,n){D=!0;try{this.engine.A(this.engine.o(`${t}.${e}`),null,n)}finally{D=!1}}mr(){for(let t of this.entries)this.start(t,!0)}hr(){for(let t of this.entries)t.pt=!1,t.J?.abort(),t.J=null}gr(){for(let t of this.entries)t.pt=!1,null!==t.J&&(t.J.abort(),t.J=null),this.set(b,t.name,"idle")}Se(t){let e=this.M.n;for(let n of this.entries)n.g===t&&(n.n=n.pt?Math.max(n.n,e):e,n.pt=!0)}me(){let t=this.engine,n=this.M,r=[];for(let i of this.entries){if(!i.pt)continue;let s=i.n;if(i.pt=!1,s>32)r.push(i.name),i.g.Y=e;else{n.n=s+1,t.Ce++;try{this.start(i,!1)}finally{t.Ce--,n.n=0}}}r.length>0&&n.jo(r)}start(t,n){let r,i=this.engine;if(null!==t.J&&t.J.abort(),t.J=null,null!==t.g){let s=t.g;s.getter=t.args;let l=s.Q.slice();O(s);try{r=i.read(s,null),function(t,e,n){null!==n&&"function"==typeof n?.then&&a(`$stream "${t}": args must be synchronous (it returned a Promise).`);for(let n of e.Q)n.n>0&&a(`$stream "${t}": args must not read a wildcard path ("${n.t}").`),(n.t===t||n.t===`${b}.${t}`||n.t===`${M}.${t}`)&&a(`$stream "${t}": args must not read the stream itself ("${n.t}").`)}(t.name,s,r)}catch(r){O(s);for(let t of l)t.Hn(s);if(s.Y=e,n)throw r;return this.set(M,t.name,r),void this.set(b,t.name,"error")}}let s=new AbortController;t.J=s,i.A(i.o(t.name),null,t.K),this.set(M,t.name,null),this.set(b,t.name,"active"),this.yr(t,s,r)}async yr(t,e,n){let r=this.engine,i=e.signal,s=()=>!i.aborted&&t.J===e,l=r.o(t.name),a=this.M.n,o=g(),h=t=>{g()===o&&(this.M.n=a);try{t()}finally{this.M.n=0}},f=t.K;try{let e=await t.source(n,i);if(!s())return;let a=e=>{f=void 0!==t.Lo?t.Lo(f,e):e,h(()=>r.A(l,null,f))};if(null!==e&&"function"==typeof e?.getReader){let t=e.getReader();for(i.addEventListener("abort",()=>{t.cancel().catch(()=>{})});;){let e=await t.read();if(!s())return;if(e.done)break;a(e.value)}}else{if(null===e||"function"!=typeof e?.[Symbol.asyncIterator])throw new TypeError(`$stream "${t.name}": source must return an async iterable or a ReadableStream`);{let t=e[Symbol.asyncIterator]();for(i.addEventListener("abort",()=>{t.return?.()});;){let e=await t.next();if(!s())return;if(e.done)break;a(e.value)}}}if(!s())return;t.J=null,h(()=>this.set(b,t.name,"done"))}catch(n){if(!s())return;t.J=null,e.abort(),h(()=>{this.set(M,t.name,n),this.set(b,t.name,"error")})}}};function O(e){for(let t of e.Q){let n=t.B.indexOf(e);n>=0&&t.B.splice(n,1),t.yt.delete(e)}e.Q.length=0,e.Y=t}var J=new WeakMap;function Q(t){let e=J.get(t);return e?.target===t.target?e:void 0}function F(t,e){let r=new v(t,function(t,e){if(void 0===e)return[];(null===e||"object"!=typeof e)&&a("$watch must be an object mapping paths to handler functions.");let r=[];for(let i of Object.keys(e)){let s=e[i];(""===i||"$"===i[0]||i.includes("@")||u.has(i))&&a(`$watch path "${i}" is not a path of the state tree.`),"function"!=typeof s&&a(`$watch entry "${i}" must be a function.`);let l=t.o(i);n.xo?.(t,l,!0),r.push({t:i,p:l,handler:s,getter:!1,s:new WeakMap})}return r}(t,e.$watch)),i=new k(t,function(t,e){let n=e.$stream;if(void 0===n)return[];(null===n||"object"!=typeof n)&&a("$stream must be an object mapping stream names to definitions.");let r=[],i={},s={};for(let l of Object.keys(n)){let o=n[l];(""===l||"$"===l[0]||/[.*]/.test(l)||j.has(l))&&a(`$stream entry "${l}" must be a flat property name.`),(null===o||"object"!=typeof o)&&a(`$stream entry "${l}" must be an object.`);let h=o.source,f=o.fold,u=o.args,c=o.initial;"function"!=typeof h&&a(`$stream entry "${l}" needs a source function.`),void 0!==f&&"function"!=typeof f&&a(`$stream entry "${l}": fold must be a function.`),void 0!==f&&!("initial"in o)&&a(`$stream entry "${l}": fold needs an initial value.`),void 0!==u&&"function"!=typeof u&&a(`$stream entry "${l}": args must be a function.`),S(e,l)&&a(`$stream entry "${l}" collides with a getter, setter or method of the state.`),void 0===e[l]&&(e[l]=c),i[l]="idle",s[l]=null,r.push({name:l,source:h,Lo:f,K:c,J:null,pt:!1,n:0,g:void 0===u?null:t.o(`$streamArgs.${l}`),args:void 0===u?null:function(){return u(this)}})}return e[b]=i,e[M]=s,r}(t,e),r),s=J.get(t);void 0!==s&&(s.M.Do(),s.Dt.hr()),J.set(t,{M:r,Dt:i,Qe:s?.Qe??!1,target:e})}function A(t,e){let n=J.get(t);if(void 0!==n&&"mounting"!==e&&!document.documentElement?.hasAttribute("data-wcs-server")&&("reset"!==e&&(n.Qe="connected"===e),n.target===t.target)){if("disconnected"===e)return n.M.Do(),void n.Dt.gr();n.Qe&&(n.M.pr(),n.Dt.mr())}}var C=["$streamStatus","$streamError"],x={name:"temporal",hooks:n,install(){n.fe=r(n.fe,F),n.element=r(n.element,A),n.re=r(n.re,(t,e,n,r,i,s,l)=>Q(t)?.M.re(e,n,r,i,s,l)),n.Se=r(n.Se,(t,e,n)=>{let r=Q(t);void 0!==r&&(r.M.Se(e,n),r.Dt.Se(e))}),n.Qt=r(n.Qt,(t,e,n)=>Q(t)?.M.Qt(e,n)),n.me=r(n.me,t=>{let e=Q(t);void 0!==e&&(e.M.me(),e.Dt.me())}),n.it=i(l,n.it,(t,e)=>{let n=e.split(".",1)[0];if(C.includes(n))return n===e?t.target[e]:t.read(t.o(e),null)}),n.Ie=i(s,n.Ie,(t,e)=>(!D&&36===e.t.charCodeAt(0)&&C.includes(e.t.split(".",1)[0])&&a(`"${e.t}" is read-only (the stream runtime owns it).`),!1))}},E=x;export{E as default,x as temporal};
|
|
2
2
|
//# sourceMappingURL=temporal.js.map
|
package/dist/wcs-manifest.json
CHANGED
|
@@ -517,37 +517,40 @@
|
|
|
517
517
|
]
|
|
518
518
|
},
|
|
519
519
|
"date": {
|
|
520
|
-
"description": "ロケール形式の日付 ([locale][, style]。style は full / long / medium / short
|
|
520
|
+
"description": "ロケール形式の日付 ([locale][, style][, zone]。style は full / long / medium / short、zone は IANA のタイムゾーン(Asia/Tokyo — 無ければ読み手のゾーン)、空の引数は既定、既定のロケールは config.locale)",
|
|
521
521
|
"hasArgs": true,
|
|
522
522
|
"resultType": "string",
|
|
523
523
|
"acceptTypes": "any",
|
|
524
524
|
"minArgs": 0,
|
|
525
|
-
"maxArgs":
|
|
525
|
+
"maxArgs": 3,
|
|
526
526
|
"argTypes": [
|
|
527
|
+
"string",
|
|
527
528
|
"string",
|
|
528
529
|
"string"
|
|
529
530
|
]
|
|
530
531
|
},
|
|
531
532
|
"time": {
|
|
532
|
-
"description": "ロケール形式の時刻 ([locale][, style]。style は full / long / medium / short
|
|
533
|
+
"description": "ロケール形式の時刻 ([locale][, style][, zone]。style は full / long / medium / short、zone は IANA のタイムゾーン(Asia/Tokyo — 無ければ読み手のゾーン)、空の引数は既定、既定のロケールは config.locale)",
|
|
533
534
|
"hasArgs": true,
|
|
534
535
|
"resultType": "string",
|
|
535
536
|
"acceptTypes": "any",
|
|
536
537
|
"minArgs": 0,
|
|
537
|
-
"maxArgs":
|
|
538
|
+
"maxArgs": 3,
|
|
538
539
|
"argTypes": [
|
|
540
|
+
"string",
|
|
539
541
|
"string",
|
|
540
542
|
"string"
|
|
541
543
|
]
|
|
542
544
|
},
|
|
543
545
|
"datetime": {
|
|
544
|
-
"description": "ロケール形式の日時 ([locale][, style]。style は full / long / medium / short
|
|
546
|
+
"description": "ロケール形式の日時 ([locale][, style][, zone]。style は full / long / medium / short、zone は IANA のタイムゾーン(Asia/Tokyo — 無ければ読み手のゾーン)、空の引数は既定、既定のロケールは config.locale)",
|
|
545
547
|
"hasArgs": true,
|
|
546
548
|
"resultType": "string",
|
|
547
549
|
"acceptTypes": "any",
|
|
548
550
|
"minArgs": 0,
|
|
549
|
-
"maxArgs":
|
|
551
|
+
"maxArgs": 3,
|
|
550
552
|
"argTypes": [
|
|
553
|
+
"string",
|
|
551
554
|
"string",
|
|
552
555
|
"string"
|
|
553
556
|
]
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{l as e}from"./chunk-ISBASPV2.js";import{a as t,d as n,e as l,j as i,k as r}from"./chunk-SOFOV2OG.js";import{a as s,g as o}from"./chunk-FQUDP3XK.js";import{a as u}from"./chunk-TS2HEHBQ.js";import{a,b as h,c,d as f,e as d,f as m,g as p,h as g,i as v,j as b,k as w,l as x,n as y}from"./chunk-P3JKSHRN.js";import{a as N,b as S}from"./chunk-EBIQH2HE.js";import{a as C,k}from"./chunk-BCL75PFH.js";var A=new Map,T=new Set(["if","elseif","else","for"]),P=new Set([a,"if","elseif","for","..."]),D=new Set([d,m,p,f,h,c]);function E(e){let t=function(e){return w(e,";")}(e).map(v).filter(e=>e.length>0).map(e=>{let t=b(e,":");-1===t&&S(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if(P.has(i)){let t;return i!==n&&S(102,[e,i]),i===a?(l.length>0&&S(103,[e]),t={Ze:"#else",et:[]}):"..."===i?(0===l.length&&S(104,[e]),t=y(l),t.et.length>0&&S(105,[e])):(t=y(l),"for"===i&&t.et.length>0&&S(121,[e])),{Ee:i,Ne:[i],rn:[],D:[],...t,b:"..."===i?"spread":i}}(i===d||i===m)&&S(122,[e,i]);let r=y(l),s=function(e){let[t,n]=x(e,"input",A),l=t.split("#").map(v);l.length>2&&S(115,[t]);let[i,r]=l,s=i.split(".").map(v);return!(s.length>1&&""===s[0])&&(0===i.length||s.some(e=>0===e.length))&&S(116,[e]),{Ee:i,Ne:s,rn:r?r.split(",").map(v):[],D:n}}(n),[o]=s.Ne;if(""===o&&s.Ne.length>1){let e=s.Ne.slice(1);return(e.includes("")||D.has(e[0]))&&S(106,[n]),{...s,Ee:e.join("."),Ne:e,...r,b:"prop"}}return{...s,...r,b:"radio"===i||"checkbox"===i?i:o===h||o.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>T.has(e.b))&&S(201,[e]),t}function L(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function I(t){return 0===t.length?null:(e(),t.map(e=>o(e.Hn,e.args,e.literals)))}var j=Symbol.for("wcstack.state.view-transition-naming"),F=new WeakSet;function O(){let e=t("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var U=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),W=0,q=2,$=3,R=4,B=5,H=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],M=(e,t,n,l)=>e.Jt(t,n.o?.t??n.Tt,l,H[n.i]),G=Symbol();function K(e,t,n){let l=t.U;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.K:G}var X=class{constructor(e,t,n,l,i,r,s,o,u,a=null){this.te=!1,this.D=null,this.An=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.Tn=s,this.x=o,this.value=u,this.j=a}on(){return H[this.i]}apply(){if(null!==this.j)return void this.j.xt();let e=L(this.x,this.engine.read(this.o,this.r));if(e===this.value&&9!==this.i&&("object"!=typeof e||null===e||11===this.i||8===this.i||i(this.name)))return;if(this.value===G)return void(this.value=e);let t=this.a;if(11!==this.i)9===this.i?t.checked=void 0!==e&&this.sn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.sn()):Z(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.An=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.An=!1}}}sn(){return L(this.D,this.a.value)}ir(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.sn()}else if(10===this.i){let l=this.sn(),i=n.v(this.o,this.r),r=Array.isArray(i)?i:[],s=r.includes(l);if(t.checked?s:!s)return;e=s?r.filter(e=>e!==l):[...r,l]}else e=L(this.D,t[this.name]),this.value=NaN;n.A(this.o,this.r,e,!1,!0)}},V=e=>"textContent"===e||"innerText"===e||"innerHTML"===e;function Z(e,t,n,l){switch(e){case 0:return void(t.data=null==l?"":String(l));case 1:return void(V(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[Q]=[n,l])));case 8:return void(t.innerHTML=r(l));case 2:return null!=l&&"boolean"!=typeof l&&S(401,[n,typeof l]),void t.classList.toggle(n,!0===l);case 3:return void(null==l?t.removeAttribute(n):t.setAttribute(n,String(l)));case 4:return void(n.includes("-")?null==l?t.style.removeProperty(n):t.style.setProperty(n,String(l)):t.style[n]=null==l?"":String(l))}}var Q=Symbol();function J(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[Q];void 0!==n&&(t[n[0]]=n[1])}var z=class{constructor(e,t,n,l){this.w=!0,this.we=null,this.u=null,this.Pt=null,this.On=null,this.r=e,this.ct=t,this.L=n,this.C=l}Qo(e,t){let n=t.target,l=this.C,i=[],r=null;for(let t of l.Oe){if(t.name!==e)continue;let s=l.Cn[t.a],o=ae(null===this.L?this.ct:this.L[s[0]],s,1);o.contains(n)&&(o!==r&&i.unshift([]),i[0].push(t),r=o)}for(let e of i){for(let n of e)n.Fn(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.L?this.ct:this.L[this.L.length-1]}Re(){let e=this.On;return(null===e?null:e.In(this.ct))??this.ct}insertBefore(e,t){let n=this.s;for(let l=this.Re();;){let i=l.nextSibling;if(e.insertBefore(l,t),l===n)return;l=i}}bo(){null===this.L?this.ct.remove():he(this.Re(),this.s)}Pe(e){if(this.w=!1,null!==this.Pt)for(let e of this.Pt)e();let t=this.we;if(null!==t)for(let n=0;n<t.length;n++)e.Rn(t[n]);if(null!==this.u)for(let e of this.u)e.Pe()}},Y=class extends z{constructor(e,t,n,l){super(e,t,n,l),this.vo=0,this.V=null,this.pe=0===l.Ge.length?null:new Array(2*l.Ge.length)}ko(e,t){let n=this.V??=new Array(this.C.Ge.length),l=n[t];if(void 0===l){let i=this.C.Ge[t],r=this.pe;l=n[t]=new X(e,i.i,r[2*t],i.name,i.o,this.r,this,i.x,r[2*t+1])}return l}fo(e,t){let n=this.C.Ge;for(let l=0;l<n.length;l++)n[l].o.ee(t)&&e.tn(this.ko(e,l))}Pe(e){let t=this.r;t.N===this&&(t.N=null),super.Pe(e)}};function _(e,t,n,i){let r=l(n,t.n);try{return e.Ue(r,t)}catch(n){return e.Jt(n,t.t,i,"for"),null===r?e.oe.get(t):r.u.get(t)}}function ee(e,t,n){n&&e.nr(t);let l=t.Tn;null!==l&&(l.we??=[]).push(t)}var te=null;function ne(){let e=te;return te=null,e}var le=-1;function ie(e,t,n,l,i=null){let r,s=t.Cn,o=t.build,u=t.So,a=null,h=C.Te?.(t,null===l?i:l.S,null!==l),c=!h&&t.jn,f=h?document.createDocumentFragment():(c?t.root:t.ln).cloneNode(!0);if(!h)for(let e=0;e<o.length;e++){let t=o[e];u[t]=ae(f,s[t],c?1:0)}c?r=f:(a=h||[...f.childNodes],r=a[0]);let d,m=null;if(null!==l?(d=m=new Y(n,r,a,t),null===l.map?n.N=m:l.map.set(n,m)):d=new z(n,r,a,t),le>=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||F.has(i))return;let s=globalThis[j]??={counter:0,assigned:0,warned:!1};s.assigned>=l?s.warned||(s.warned=!0,console.warn(`[@wcstack/state] ${N(25,[l])}`)):(F.add(i),s.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++s.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,a,null!==l?"row":"branch",le),t.Oe.length>0){let t=e.Un;if(null===a)r[t]=d;else for(let e of a)1===e.nodeType&&(e[t]=d)}let p=t.sr,g=e.We,v=t.lr?u.slice(0,s.length):u,b=null===m?null:m.pe;if(null!==b){let e=t.Ge;for(let t=0;t<e.length;t++)b[2*t]=v[e[t].a],b[2*t+1]=e[t].K}for(let t=0;t<p.length;t++){let l=p[t],i=v[l.a],s=l.F;if(s>=0&&null!==b){let t=m.V?.[s];if(void 0!==t){t.te=!1,e.qe(t);continue}try{let t=L(l.x,e.read(l.o,n));t!==l.K&&(Z(l.i,i,l.name,t),b[2*s+1]=t),null!==g&&e.mo(l.o,n)}catch(t){e.Rt(t,m.ko(e,s))}continue}switch(l.i){case 6:{let t=new ue(e,l.C,_(e,l.o,n,i),i);(d.u??=[]).push(t),i===r&&(d.On=t),t.xt();break}case 7:{let t=se(e,l.q.map(e=>({C:e.C,o:e.o,x:e.x,S:v[e.a]})),n,d);(d.u??=[]).push(t),i===r&&(d.On=t);break}default:try{re(e,l,i,n,d)}catch(t){M(e,t,l,i)}}}return te=d,f}function re(e,t,n,i,r){let s=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.Fn,s=e=>r(e,l);if(n.nt){let l=e.co(n.name),i=t[l];t[l]=void 0===i?s:e=>{i(e),s(e)},n.xe&&t.addEventListener(n.name,e=>e.bubbles||s(e))}else t.addEventListener(n.name,s),n.wo&&null!==i&&(i.Pt??=[]).push(()=>t.removeEventListener(n.name,s))}(e,n,t,i,r);case 12:return void de(e,t,s,r,n=>function(e,t,n,l,i){let r=t.name,s=e.command(t.Tt.slice(9)),o=null===i?C.or?.(n,r):null;o||(null===i&&pe(1202,n,`command.${r}`),i.commands.has(r)||S(1203,[n.localName,r]));let u=new WeakRef(n),a=s.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?o?o(t,e):t[r](...e):void 0;a()});null!==l&&(l.Pt??=[]).push(a)}(e,t,s,r,n));case 13:return void de(e,t,s,r,n=>function(e,t,n,l,i){let r=t.name;null===i&&pe(1202,n,`eventToken.${r}`);let s=i.properties.get(r);void 0===s&&S(1204,[n.localName,r]);let o=t.Tt;n.addEventListener(s.event,n=>{t.At&&n.preventDefault(),t.Ft&&n.stopPropagation();try{e.Zo(o,n,l)}catch(e){k(e)}})}(e,t,s,i,n))}let o=t.o,u=l(i,o.n);if(14===t.i)return void de(e,t,s,r,n=>function(e,t,n,l,i,r){null===r&&pe(1501,n,`"...: ${t.o.t}"`);let s=new Set([...r.properties.keys(),...r.inputs]);for(let o of s){if(t.yo?.includes(o))continue;let s=e.o(`${t.o.t}.${o}`),u=0===s.n?null:l;me(e,{...t,U:null,X:null},n,o,s,u,i,r)}}(e,t,s,u,r,n));if(t.xe&&1===t.i)return void de(e,t,s,r,n=>function(e,t,n,l,i,r){if(null!==r)return void me(e,t,n,t.name,t.o,l,i,r);let s=new X(e,1,n,t.name,t.o,l,i,t.x,K(e,t,l));s.D=t.D,!C.ar?.(s,t.ro)&&(ee(e,s,!0),e.qe(s))}(e,t,s,u,r,n));let a=new X(e,t.i,n,t.name,o,u,r,t.x,K(e,t,u));a.D=t.D,ee(e,a,!0),e.qe(a),null!==t.Ot&&n.addEventListener(t.Ot,()=>a.ir())}function se(e,t,n,i){let r=new oe(e,t,n),s=null;for(let o of t){if(null===o.o)continue;let t=o.o,u=new X(e,7,o.S,"if",t,l(n,t.n),i,null,void 0,r);ee(e,u,!0),null===i&&r.ue.push(u),s??=u}return e.qe(s),r}var oe=class{constructor(e,t,n){this.w=!0,this.I=null,this.y=-1,this.ue=[],this.engine=e,this.q=t,this.r=n}In(e){return null!==this.I&&this.q[this.y].S===e?this.I.Re():null}xt(){let e=this.engine,t=-1;for(let n=0;n<this.q.length;n++){let i=this.q[n];if(null===i.o||L(i.x,e.read(i.o,l(this.r,i.o.n)))){t=n;break}}if(t!==this.y&&(le=O(),null!==this.I&&(this.I.bo(),this.I.Pe(e),this.I=null),this.y=t,t>=0)){let n=this.q[t],l=ie(e,n.C,this.r,null,n.S);this.I=ne();let i=n.S.parentNode;i.insertBefore(l,n.S),J(i)}}Pe(){this.w=!1;for(let e of this.ue)this.engine.Rn(e);null!==this.I&&this.I.Pe(this.engine)}},ue=class{constructor(e,t,n,l){this.w=!0,this.Ae=[],this.engine=e,this.C=t,this.l=n,this.S=l,null===n.N?(n.N=this,this.map=null):((n.W??=[]).push(this),this.map=new Map)}In(e){return 0===this.Ae.length?null:this.Ae[0].Re()}Ct(e){return null===this.map?e.N:this.map.get(e)??null}Lt(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.Pe(this.engine)}xt(){let e=this.engine,t=this.l.f,n=this.Ae;le=O();let l=t.length,i=n.length,r=this.S,s=r.parentNode;if(0===l){if(i>0){let e=n[0].Re(),t=n[i-1].s,l=[];for(let n=s.firstChild;null!==n;n=n===e?t.nextSibling:n.nextSibling)if(n!==e){if(n!==r&&3!==n.nodeType){l=null;break}l.push(n)}null!==l?s.replaceChildren(...l):he(e,t);for(let e=0;e<i;e++)this.Lt(n[e])}return void(this.Ae=[])}let o=new Array(l),u=0;for(;u<l&&u<i&&this.Ct(t[u])===n[u];)o[u]=n[u],u++;let a=i-1,h=l-1;for(;a>=u&&h>=u&&this.Ct(t[h])===n[a];)o[h]=n[a],a--,h--;for(let e=u;e<=a;e++){let t=n[e],l=t.r;l.w&&this.Ct(l)===t?t.vo=e:(t.bo(),this.Lt(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.Ct(t[u+e]);null!==n&&n.w?(a[e]=n.vo,c=!0):a[e]=-1}let f=h+1<l?o[h+1].Re():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,s=i.length;for(;r<s;){let n=r+s>>1;e[i[n]]<t?r=n+1:s=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.Ct(n);null!==a&&a.w?0===l[r]&&a.insertBefore(s,i):(s.insertBefore(ie(e,this.C,n,this),i),a=ne()),o[u+r]=a,i=a.Re()}}else{let n=document.createDocumentFragment();for(let l=u;l<=h;l++)n.appendChild(ie(e,this.C,t[l],this)),o[l]=ne();s.insertBefore(n,f)}}this.Ae=o,J(s)}Pe(){this.w=!1;let e=this.l;if(e.N===this)e.N=null;else if(null!==e.W){let t=e.W.indexOf(this);t>=0&&e.W.splice(t,1),0===e.W.length&&(e.W=null)}for(let e of this.Ae)e.Pe(this.engine);this.map?.clear()}};function ae(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 he(e,t){for(let n,l=e;l!==t;l=n)n=l.nextSibling,l.remove();t.remove()}var ce=new WeakMap,fe=e=>e.customElementRegistry??customElements;function de(e,t,n,l,i,r=!1){let s=n.localName;if(!s.includes("-"))return i(null);let o=fe(n);if(!r&&!n.isConnected&&void 0===o.get(s)&&"customElementRegistry"in n)return void queueMicrotask(()=>de(e,t,n,l,i,!0));let u=()=>{let e=o.get(s);o.upgrade(n),i(e?function(e){if(ce.has(e))return ce.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 Set,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,go:"event"===e.semantics});for(let e of t.inputs??[])n.inputs.add(e.name);for(let e of t.commands??[])null!==e&&"object"==typeof e&&"string"==typeof e.name&&n.commands.add(e.name)}return ce.set(e,n),n}(e):null)};if(!r&&void 0!==o.get(s))return u();null!==l&&!l.w||function(e,t,n){let l=n;null!==t&&(t.Pt??=[]).push(()=>{l=null}),e.then(()=>l?.())}(o.whenDefined(s),l,()=>{try{u()}catch(l){M(e,l,t,n)}e.ve()})}function me(e,t,n,l,i=t.o,r,s,o){let u=o.properties.get(l)??null,a=o.inputs.has(l),h=e.Vt;h&&null===u&&!a&&S(38,[l]);let c=t.U;(null===u?"element"===c||"auto"===c:!a&&("state"===c||"auto"===c))&&S(39,[c,l]),"connect"===t.X&&null===u&&S(40,[l]);let f=h&&null!==u&&!a,d=new X(e,11,n,l,i,r,s,t.x,void 0);d.D=t.D,ee(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.go||C.detail?.(n,l,i)),(!d.An||!Object.is(i,d.value))&&(i=L(d.D,i),null===d.x&&(d.value=i),e.A(d.o,d.r,i,u.go,!0))});let m=c??(f?"element":"state");if("state"===m)f||e.qe(d);else if("element"===m||"auto"===m){let i=()=>{if(null!==s&&!s.w)return;if("auto"===m&&void 0!==e.v(d.o,d.r))return void(f||e.qe(d));let t=n[l];null===d.x&&(d.value=t),e.A(d.o,d.r,t,!1,!0)};"connect"!==t.X||n.isConnected?i():Promise.resolve().then(i)}return d}function pe(e,t,n){S(e,[t.localName,n])}var ge=()=>s.bindAttributeName;function ve(){return{a:0,i:1,name:"",o:null,x:null,K:u,Fn:null,C:null,q:null,D:null,Ot:null,xe:!1,U:null,X:null,ro:!1,At:!1,Ft:!1,Tt:null,yo:null,F:-1,nt:!1,wo:!1}}var be=["state","element","auto","none"],we=["call","connect"],xe="$command.";function ye(e,t,n){g.test(t)&&(null===n&&S(1401,[t,Number(t.slice(1))]),t=`${n.t}.*.${t}`);let l=e.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&S(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&S(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.h[e];l.h[e]!==t&&S(1403,[l.t,l.h[e].t,t.t])}return C.$o?.(e,l),l}var Ne=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),Se=e=>8===e.i||Ne(e)||1===e.i&&V(e.name);function Ce(e){S(202,[e])}function ke(e,t,l,r,s){let o=E(t).map(t=>function(e,t,l,r,s){let o=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.Vt||S(31);let r=n.slice(0,t).trim(),s=n.slice(t+1).trim(),o="init"===r;!o&&"sync"!==r&&S(33,[r,n]),null!==(o?l:i)&&S(34,[r]),(o?be:we).includes(s)||S(35,[r,s]),o?l=s:i=s}return{ro:t.includes("ro"),At:t.includes("prevent"),Ft:t.includes("stop"),event:n?n.slice(2):null,U:l,X:i}}(e,t.rn),u=r.localName.includes("-"),a=t.Ne,h=t.Ze;if("event"===t.b){if(null!==o.U&&"none"!==o.U&&S(36),"eventToken"===a[0])return{...ve(),a:s,i:13,name:a.slice(1).join("."),Tt:h,xe:u,At:o.At,Ft:o.Ft};let l=h.startsWith(xe)?h.slice(9):null,{At:i,Ft:r}=o,c=t.Ee.slice(2),f=t.rn.includes("direct"),d=!f&&U.has(c);d&&e.co(c);let m=t=>{k(t),d&&C.handlerThrew?.(e,h,c)};return{...ve(),a:s,i:5,name:c,nt:d,xe:u,wo:f,Fn(t,s){i&&t.preventDefault(),r&&t.stopPropagation();try{if(null!==l)e.er(l,t,s);else{let l=e.tr(h,t,s);n(l)&&l.then(void 0,m)}}catch(e){m(e)}}}}if("spread"===t.b)return{...ve(),a:s,i:14,o:ye(e,h,l),xe:u};if("command"===a[0]&&a.length>1)return h.startsWith(xe)||S(1201,[t.Ee,h]),{...ve(),a:s,i:12,name:a.slice(1).join("."),Tt:h,xe:u};let c=ye(e,h,l),f={...ve(),a:s,i:1,name:t.Ee,o:c,x:I(t.et),D:I(t.D),ro:o.ro,U:o.U,X:o.X};if("radio"===t.b||"checkbox"===t.b)return("element"===o.U||"auto"===o.U)&&S(37,[t.b,o.U]),f.i="radio"===t.b?9:10,o.ro||(f.Ot=o.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.U=null,f.name=e,"class"===t?(f.i=2,f.K=r.classList.contains(e)):f.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,f}return"html"===t.Ee?(f.i=8,f):(f.name="text"===t.Ee?"textContent":t.Ee,f.xe=u&&!i(f.name),!u&&!o.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.Ot=o.event??("select"===r.localName?"change":"input")),f)}(e,t,l,r,s));for(let e=0;e<o.length;e++)14===o[e].i&&(o[e].yo=o.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return o}var Ae=/\{\{([\s\S]+?)\}\}/g;function Te(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 s=e.ownerDocument.createTextNode("");e.before(s),n.push({a:s,cr:i[1].trim()}),l=Ae.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function Pe(e,t,n,l){let i=function(e){return{Ee:"textContent",Ne:["textContent"],rn:[],D:[],...y(e),b:"text"}}(t);return{...ve(),a:l,i:0,o:ye(e,i.Ze,n),x:I(i.et),K:""}}function De(e){let t=e.getAttribute(ge());if(null===t)return null;let n=E(t)[0];return void 0===n||"for"!==n.b&&"if"!==n.b&&"elseif"!==n.b&&"else"!==n.b?null:n}var Ee=(e,t)=>0===e?s.commentIfPrefix:null===t.o?s.commentElsePrefix:s.commentElseIfPrefix;function Le(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.b?null:ye(e,l.Ze,n),x:"else"===l.b?null:I(l.et)}),i=[l(t,De(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=De(e);if(null===t||"elseif"!==t.b&&"else"!==t.b||(i.push(l(e,t)),"else"===t.b))break}return i}var Ie=new WeakSet;function je(e,t,n,l,i,r,o,u){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&C.Dn?.(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(t.hasAttribute(ge()+"-ignore"))continue;if(l){if("script"===u||"style"===u||Ie.has(t))continue;if(Ie.add(t),u===s.tagNames.state){h([...t.childNodes]);continue}}let c="template"===u?De(t):null;if(null!==c){if("for"===c.b){let l=ye(e,c.Ze,n),r=Ue(e,t,l,!0);i(a(t,s.commentForPrefix),l,r)}else"if"===c.b?r(Le(e,t,n).map((t,l)=>({C:Ue(e,t.el,n,!1),o:t.o,x:t.x,S:a(t.el,Ee(l,t))}))):Ce(c.b);continue}let d=t.getAttribute(ge()),m=null===d?null:ke(e,d,n,t,0),p="noscript"!==u&&"iframe"!==u&&!m?.some(Se)&&!C.Eo?.(t);try{l&&p&&h([...t.childNodes])}finally{null!==m&&o(t,m)}!l&&p&&h([...t.childNodes])}else if(3===f.nodeType&&e.Mt&&f.data.includes("{{")&&!Ie.has(f))for(let{a:e,cr:t}of Te(f))u(e,t);else if(8===f.nodeType){let e=Fe.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 Fe=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Oe=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function Ue(e,t,n,l){let i=document.importNode(Oe(t),!0),r=[],s=[],o=e=>r.push(e)-1;je(e,[...i.childNodes],n,!1,(e,t,n)=>{s.push({...ve(),a:o(e),i:6,o:t,C:n})},e=>{let t=e.map(e=>({a:o(e.S),C:e.C,o:e.o,x:e.x}));s.push({...ve(),a:t[0].a,i:7,q:t})},(e,t)=>{let n=o(e);for(let e of t)Ne(e)&&S(203,[e.name]),e.a=n;s.push(...t),e.removeAttribute(ge())},(t,l)=>{s.push(Pe(e,l,n,o(t)))}),Re(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=s.some(e=>6===e.i||7===e.i),c=[],f=new Set,d=[],m=[],p=l?n.n+1:-1;for(let e of s){if(5===e.i&&e.nt&&!e.xe&&!We(r[e.a],i)){d.push(e);continue}m.push(e);let t=e.o;if(null!==t&&t.n===p&&t.h[p]===n&&qe(e)&&(e.F=c.push(e)-1),7===e.i)for(let t of e.q)f.add(t.a);else f.add(e.a)}let g=[...f].sort((e,t)=>e-t);return{ln:i,root:a?i.firstChild:null,Cn:u,build:g,Oe:d,sr:m,jn:a,lr:h,So:[],Ge:c}}function We(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 qe(e){if(null!==e.U)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.xe&&null===e.Ot;default:return!1}}var $e=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Re(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&&Re(l,t,$e.has(l.localName)),l=e}}var Be=new WeakMap;function He(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Be.set(t,e),Ge(e,[...n.childNodes]),e.ze()}function Me(e,t,n){try{let l="template"===t.localName?De(t):null;null!==l&&!n&&S(204,[l.b]),Ge(e,[t])}catch(e){k(e)}e.ze()}function Ge(e,t){je(e,t,null,!0,(t,n,l)=>{new ue(e,l,_(e,n,null,t),t).xt()},t=>{se(e,t,null,null)},(t,n)=>{C.Dn?.(e,t,n);for(let l of n)re(e,l,t,null,null)},(t,n)=>{C.Dn?.(e,t,n),re(e,Pe(e,n,null,0),t,null,null)})}export{E as a,fe as b,W as c,q as d,$ as e,R as f,B as g,Y as h,ue as i,Ne as j,Se as k,Pe as l,Ie as m,je as n,Oe as o,Be as p,He as q,Me as r};
|
|
2
|
-
//# sourceMappingURL=chunk-47I6RYV3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["text","id","args","hooks","render","map","a","JSON","stringify","String","join","raise","subject","candidates","raiseError","s"],"sources":["../../../src/messages.ts"],"sourcesContent":["/**\n * The core's messages, by number. The prose lives in the diagnostics add-on\n * (`src/diagnostics/messages.ts`); without it a message reads `[@wcstack/state] #108 \"a|b(\"` —\n * the message number and the values it would have shown. With it (the full `auto` bundle installs\n * it) the message is the code shared with lint and the VS Code extension and the full sentence\n * (`[wcs/binding-syntax] Invalid filter format: …`), followed by the guidance.\n *\n * The hundreds of a number name its code (the diagnostics add-on's `CODES`, in the core up to\n * 4.0.0-rc.3): 1xx binding-syntax, 2xx template-syntax, …; 1–99 carry no code. Numbers are only\n * ever added, so a number read on a page keeps its meaning across versions. `M` is a const enum:\n * the build inlines the numbers.\n *\n * Kept as full text in the core, not numbered: the barriers a page without add-ons meets on\n * purpose (`[wcs/feature-not-installed]`, a formatting filter without the formats add-on).\n */\nimport { hooks } from \"./hooks\";\nimport { raiseError } from \"./parser/raiseError\";\n\nexport const enum M {\n // no code\n ScanRemoved = 1,\n GetterWithoutSetter = 2,\n NoRow = 3,\n ParentNotObject = 4,\n NotAMethod = 5,\n GetAllNoCommonLevel = 6,\n EqIndexNoRow = 7,\n Readonly = 8,\n SetAllNeedsIndexes = 9,\n SetAllSpreadLength = 10,\n DrainNotSettled = 11,\n BindingFailed = 12,\n LoadFailed = 13,\n ElementFailed = 14,\n NotInitialized = 15,\n NoScript = 16,\n TokenSubscriberThrew = 17,\n TokenListNotArray = 18,\n TokenEntryEmpty = 19,\n TokenEntryReserved = 20,\n TokenEntryDuplicated = 21,\n OnNotObject = 22,\n OnEntryUndeclared = 23,\n OnEntryNotFunction = 24,\n NamingLimit = 25,\n FilterOptionsRequired = 26,\n FilterOptionNotNumber = 27,\n FilterValueNotNumber = 28,\n FilterValueNotDate = 29,\n FilterValueNotArray = 30,\n DirectionalSyncDisabled = 31,\n SelectorRemoved = 32,\n ModifierUnknown = 33,\n ModifierTwice = 34,\n ModifierValue = 35,\n EventInitNone = 36,\n InitUnsupported = 37,\n MemberUndeclared = 38,\n InitIncompatible = 39,\n SyncConnectNeedsOutput = 40,\n RenderChain = 41,\n InlineBlocked = 42,\n InlineFailed = 43,\n OptionInvalid = 44,\n BehaviorChanged = 45,\n FeaturesNotArray = 46,\n SecondRoot = 47,\n LocaleInvalid = 48,\n InitFailed = 49,\n ConnectedFailed = 50,\n DisconnectedFailed = 51,\n FilterStyleInvalid = 52,\n FilterCurrencyInvalid = 53,\n // [wcs/binding-syntax]\n BindTextNoColon = 101,\n StructuralTakesNoModifiers = 102,\n ElseTakesNoValue = 103,\n SpreadNoPath = 104,\n SpreadNoFilters = 105,\n LeadingDotNamespace = 106,\n UnterminatedQuote = 107,\n FilterUnclosed = 108,\n FilterUnopened = 109,\n FilterParenOrder = 110,\n FilterTrailing = 111,\n FilterEmpty = 112,\n FilterNameHasModifiersInput = 113,\n FilterNameHasModifiersOutput = 114,\n OneModifierList = 115,\n NoPropertyName = 116,\n TooManySegments = 117,\n EmptySegment = 119,\n UnsafeSegment = 120,\n ForNoFilters = 121,\n NamespaceNeedsName = 122,\n // [wcs/template-syntax]\n StructuralNotSingle = 201,\n ElseWithoutIf = 202,\n OuterInTemplate = 203,\n TemplateHandedOver = 204,\n // [wcs/binding-path-missing]\n PathMissing = 301,\n // [wcs/binding-type-expectation]\n ClassNeedsBoolean = 401,\n // [wcs/filter-unknown]\n FilterUnknown = 501,\n // [wcs/filter-arity]\n FilterTooFewArgs = 601,\n FilterTooManyArgs = 602,\n // [wcs/getter-cycle]\n GetterCycle = 701,\n // [wcs/getter-depth-exceeded]\n GetterDepth = 801,\n // [wcs/index-arity]\n IndexArityExact = 901,\n IndexArityAtMost = 902,\n // [wcs/index-param-range]\n IndexParamRange = 1001,\n // [wcs/recursion-unsupported]\n RecursionUnsupported = 1101,\n // [wcs/token-misconfigured]\n CommandRightSide = 1201,\n NoBindable = 1202,\n NoCommand = 1203,\n NoProperty = 1204,\n NativeNoCommand = 1205,\n // [wcs/token-undeclared]\n EventTokenUndeclared = 1301,\n CommandTokenUndeclared = 1302,\n // [wcs/wildcard-rank]\n WildcardNoLoop = 1401,\n WildcardRelative = 1402,\n WildcardOtherList = 1403,\n // [wcs/spread-no-bindable]\n SpreadNoBindable = 1501,\n // [wcs/declaration-alias]\n DeclarationRemoved = 1601,\n // [wcs/name-alias]\n ApiRemoved = 1701,\n}\n\n/** A message without the `[@wcstack/state]` prefix: the code and the full sentence with diagnostics, else the number and the values. */\nexport function text(id: M, args: readonly unknown[] = []): string {\n return hooks.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === \"string\" ? JSON.stringify(a) : String(a)}`).join(\"\")}`;\n}\n\n/** Throws message `id` (`subject` / `candidates` feed the diagnostics add-on's did-you-mean). */\nexport function raise(id: M, args?: readonly unknown[], subject?: string, candidates?: Iterable<string>): never {\n raiseError(text(id, args), subject, candidates);\n}\n"],"mappings":"+CA8IO,SAASA,EAAKC,EAAOC,EAA2B,IACrD,OAAOC,EAAMC,KAASH,EAAIC,IAAS,IAAID,IAAKC,EAAKG,IAAKC,GAAM,IAAiB,iBAANA,EAAiBC,KAAKC,UAAUF,GAAKG,OAAOH,MAAMI,KAAK,KAChI,CAGO,SAASC,EAAMV,EAAOC,EAA2BU,EAAkBC,GACxEC,EAAWd,EAAKC,EAAIC,GAAOU,EAASC,EACtC,QAAAP,OAAAS","ignoreList":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as n,r as t}from"./chunk-47I6RYV3.js";import{a as l,b as e,c as r}from"./chunk-TS2HEHBQ.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.Dt;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)}Uo(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.Ko(t,null===u?null:o)}finally{null===u?t.Y=s:u[t.F]=s}}Gt(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-J3PTKUWV.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as t,d as e,e as i}from"./chunk-TS2HEHBQ.js";import{h as l,m as s}from"./chunk-P3JKSHRN.js";import{a as n,b as r}from"./chunk-EBIQH2HE.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.P=null,this.f=[],this.N=null,this.W=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"]],O=["enableMustache","sameValueGuard","enableDirectionalInitialSync"];function P(t){return t.includes("**")&&s(t),t}var S=0,j=32,M=100;function T(t,e,i){let l=t.get(e);return void 0===l&&t.set(e,l=i()),l}var E=()=>new Set,_=()=>[],H=new WeakMap;function B(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}function x(t,e){return t===e||t!=t&&e!=e}function z(t,e,i){let l=t._?.get(e);void 0!==l&&l.delete(i)&&0===l.size&&t._.delete(e)}function G(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 W(t,e,i){let l=q(t,i);return null!==l&&l.l.o===e.h[i]?l:null}var N=class{constructor(t,i){this.Le=0,this.d=null,this.Be=0,this.tt=new Set,this.nt=new Map,this.Un=Symbol("wcs.block"),this.element=null,this.$t=[],this.We=null,this.Kn=[],this.Ht=0,this.G=null,this.oe=new Map,this.ue=new Map,this.Me=[],this._e=[],this.Ve=[],this.Et=!1,this.gn=!1,this.Ut=new WeakMap,this.j=0,this.Kt=0,this.yn=!1,this.qt=!1,this.zt=!1,this.Ce=0,this.qn=()=>{this.j=0,this.yn=!1},this.zn=()=>{this.Ce--},this.rp=null,this.rr=null,this.Mo=()=>this.Yt(),this._o=(t,e)=>t(this.proxy,...e),this.Yn=[],this.He=[],this.Gn={$untracked:t=>{let e=this.G;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.G;if(null!==s){let t=s.getter,i=l.De??(l.De=[]);if(!i.some(i=>i.getter===t&&i.Xn===e)){i.push({getter:t,Xn:e});let s=t.h[e];(s.jt??(s.jt=[])).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(P(t),this.d),null!==this.G&&0===this.G.be&&this.Jn(this.rp,this.rr,this.G)},$getAll:(t,e)=>this.getAll(t,e),$setAll:(t,e,i,l)=>this.wn(t,e,i,l),$resolve:(...t)=>{let e=P(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(P(t),this.d);let e=this.rp,i=this.rr;"*"===e.s&&null!==i&&(i.E=i.l.P[i.y],H.delete(i.l.P),this.T.Gt(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.Xt(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(P(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++)}Ue(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.X(l),l}oo(t){try{this.X(t)}catch(e){this.Jt(e,t.o.t,t.N?.S??null,"for")}}X(t){let e=this.v(t.o,t.ce);if(e===t.P)return;this.io(t);let i=function(t,e,i){let l=Array.isArray(e)?e:v;if(l===t.P)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.Wt(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.Wt(e);else i.Wt(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.P=l,s}(t,e,this);if(null===i)return;if(t.P===e){let i=T(this.Ut,e,_);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.W)&&!t.te&&(t.te=!0,this._e.push(t),this.ve());let l=t.o.jt;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)}Wt(t){t.w=!1;let e=t._;if(null!==e){for(let t of e)z(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.Wt(t)}}io(t){let e=this.Ut.get(t.P);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?W(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.Ue(s,o),f=e[h++];if(f<0)f=W(i,t,r)?.y??-1;else if(l&&u.P===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?G(this.target,t.z):null===e?void 0:G(e.E,t.z)}read(t,e){let i=this.G;if(null!==i&&0===i.be&&this.Jn(t,e,i),null!==t.getter)return this.T.Uo(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.G;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)}Ko(t,e){for(let i=0;i<this.Ht;i++){let l=this.Kn[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.Kn[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.G;this.G=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.G=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.jo(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.G;if(null!==e&&0===e.be){let i=e.getter,l=i.h[t];if(l){let t=l.Dt??(l.Dt=[]);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.Gn[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 x(this.read(i,l),e);let s=this.G;return null!==s&&0===s.be&&this.Yo(i,e,s),x(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(x(r.key,e))return void(r.de=i.de);r.de!==i.de&&(z(t,r.key,r.sub),n.splice(s--,1))}}let r={getter:l,r:s};T(t._??=new Map,e,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.De)return;let r=s===t?[]:s.t.slice(t.t.length+1).split("."),h=G(e,r),o=G(i,r);if(null!==s.De&&this.Go(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):z(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.Xt(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.P[t.y]=i,H.delete(t.l.P),t.E=i,this.T.Gt(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.Xt(t,e,n,i,!0,s)}}lo(t){return(this.Ut.get(t.P)??[]).filter(e=>e.P===t.P&&(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.P);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.Gt(i)),n?this.En(r,i):this.vn(r,i),this.Xt(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.P]),d=t=>Array.isArray(t)&&t.includes(u),c=(e,i)=>{if(!a.has(e)&&a.add(e))for(let t of this.Ut.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)?.P),(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.P,r.o.B)}vn(t,e){this.Xo(t,e,t=>{this.X(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.X(e)}Xo(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)}Go(t,e,i,l){for(let{getter:s,Xn:n}of t.De)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))}Xt(t,e,i,l,s,n){h.re?.(this,t,e,i,l,s,n),this.Ke(t,e)}Ke(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.Un;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.We=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)(!O.includes(t)||"boolean"!=typeof i[t])&&r(44,["$behavior",t]);let[l,s,n]=O.map(t=>i[t]??!0);void 0!==this.target&&(l!==this.Mt||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.Mt=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.Do();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.W;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?T(this.ue,t.o,E).add(t):(e.we??(e.we=[])).push(t)}Rn(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.Me.push(t),this.ve())}ve(){this.Et||(this.Et=!0,queueMicrotask(this.Mo))}Pn(){for(let t of this.Me)t.te=!1;for(let t of this._e)t.te=!1;for(let t of this.Ve)t.Bt=!1;this.Me=[],this._e=[],this.Ve=[],this.T.tt(this)}po(t,e){let i=[...new Set([...this.Me,...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.Pn()}Yt(){this.Et=!1;let t=this.Kt;this.Kt=0;let e=0;if(!this.qt||this.zt?this.qn():t>0?e=t:1===(e=++this.j)&&setTimeout(this.qn,0),this.qt=this.zt=!1,e>100)101===e?this.po(41,100):this.Pn();else{this.gn=!0;try{for(let t=0;this.Me.length>0||this._e.length>0||this.Ve.length>0;t++){if(t>=32){this.yn?this.Pn():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.Me;this._e=[],this.Me=[];let n=()=>{for(let t of l){t.te=!1;for(let e of[t.N,...t.W??[]])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.j==(0===t)||(i.te=!1,(null===i.Tn||i.Tn.w)&&this.qe(i))}this.gn||(this.ze(),this.Et&&(this.Kt=e+1))},r=l.length>0||s.some(t=>null!==t.j)?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.Kt=e+1)}}Rt(t,e){this.$t.push([t,e])}Jt(t,e,i,l){this.Rt(t,{o:{t:e},a:i,on:()=>l})}qe(t){try{t.apply()}catch(e){return void this.$t.push([e,t])}null!==this.We&&this.mo(t.o,t.r)}mo(t,e){let i=T(this.We,t.t,_);null!==e&&i.push(this.H(e))}Nn(){this.We="function"==typeof this.target.$renderedCallback?new Map:null}ze(){let t=this.We;if(null!==t&&t.size>0){this.We=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)}B(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}]);B(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.Ue(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=W(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,j as b,M as c,B as d,q as e,N as f,f as g,a as h,d as i,c as j,p as k};
|
|
2
|
-
//# sourceMappingURL=chunk-SOFOV2OG.js.map
|