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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.ja.md +29 -34
  2. package/README.md +29 -34
  3. package/dist/auto.min.js +2 -1
  4. package/dist/auto.min.js.map +1 -0
  5. package/dist/index.esm.js +2 -1
  6. package/dist/index.esm.js.map +1 -0
  7. package/dist/split/auto.js +2 -1
  8. package/dist/split/auto.js.map +1 -0
  9. package/dist/split/chunks/{chunk-V34ZHCK5.js → chunk-4NJBYXIT.js} +2 -1
  10. package/dist/split/chunks/chunk-4NJBYXIT.js.map +1 -0
  11. package/dist/split/chunks/{chunk-JMPQHCIT.js → chunk-55J45X6H.js} +2 -1
  12. package/dist/split/chunks/chunk-55J45X6H.js.map +1 -0
  13. package/dist/split/chunks/{chunk-LTBR3OV5.js → chunk-7AYOQHZH.js} +2 -1
  14. package/dist/split/chunks/chunk-7AYOQHZH.js.map +1 -0
  15. package/dist/split/chunks/chunk-EIMTT5I3.js +2 -0
  16. package/dist/split/chunks/chunk-EIMTT5I3.js.map +1 -0
  17. package/dist/split/chunks/chunk-L3PFEJP7.js +2 -0
  18. package/dist/split/chunks/chunk-L3PFEJP7.js.map +1 -0
  19. package/dist/split/chunks/{chunk-W5KT4PQ3.js → chunk-M5SODAAE.js} +2 -1
  20. package/dist/split/chunks/chunk-M5SODAAE.js.map +1 -0
  21. package/dist/split/chunks/{chunk-SPWZUBQS.js → chunk-NOPTR2L3.js} +2 -1
  22. package/dist/split/chunks/chunk-NOPTR2L3.js.map +1 -0
  23. package/dist/split/chunks/chunk-SAUVGHSB.js +2 -0
  24. package/dist/split/chunks/chunk-SAUVGHSB.js.map +1 -0
  25. package/dist/split/chunks/{chunk-ARPZVNKL.js → chunk-UD3AYVP2.js} +2 -1
  26. package/dist/split/chunks/chunk-UD3AYVP2.js.map +1 -0
  27. package/dist/split/chunks/{chunk-XF6V6DWR.js → chunk-W4KOY6GT.js} +2 -1
  28. package/dist/split/chunks/chunk-W4KOY6GT.js.map +1 -0
  29. package/dist/split/chunks/{chunk-2EGTC36Y.js → chunk-ZN52NEIB.js} +2 -1
  30. package/dist/split/chunks/chunk-ZN52NEIB.js.map +1 -0
  31. package/dist/split/core.js +2 -1
  32. package/dist/split/core.js.map +1 -0
  33. package/dist/split/features/devtools.js +2 -1
  34. package/dist/split/features/devtools.js.map +1 -0
  35. package/dist/split/features/diagnostics.js +2 -1
  36. package/dist/split/features/diagnostics.js.map +1 -0
  37. package/dist/split/features/formats.js +2 -1
  38. package/dist/split/features/formats.js.map +1 -0
  39. package/dist/split/features/list-keys.js +2 -1
  40. package/dist/split/features/list-keys.js.map +1 -0
  41. package/dist/split/features/native-commands.js +2 -1
  42. package/dist/split/features/native-commands.js.map +1 -0
  43. package/dist/split/features/recursion.js +2 -1
  44. package/dist/split/features/recursion.js.map +1 -0
  45. package/dist/split/features/scopes.js +2 -1
  46. package/dist/split/features/scopes.js.map +1 -0
  47. package/dist/split/features/ssr.js +2 -1
  48. package/dist/split/features/ssr.js.map +1 -0
  49. package/dist/split/features/temporal.js +2 -1
  50. package/dist/split/features/temporal.js.map +1 -0
  51. package/package.json +1 -1
  52. package/dist/split/chunks/chunk-27N3IPIZ.js +0 -1
  53. package/dist/split/chunks/chunk-7EWPQMA6.js +0 -1
  54. package/dist/split/chunks/chunk-ALVA5TQM.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{j as e}from"./chunk-W4KOY6GT.js";import{a as t,d as n,e as l,j as i,k as r}from"./chunk-7AYOQHZH.js";import{a as o,g as s}from"./chunk-M5SODAAE.js";import{a as u}from"./chunk-ZN52NEIB.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 w,k as y,l as b,n as x}from"./chunk-NOPTR2L3.js";import{a as N,b as S}from"./chunk-EIMTT5I3.js";import{a as T}from"./chunk-4NJBYXIT.js";var k=new Map,j=new Set(["if","elseif","else","for"]),A=new Set([a,"if","elseif","for","..."]),E=new Set([d,m,p,f,h,c]);function F(e){let t=function(e){return y(e,";")}(e).map(v).filter(e=>e.length>0).map(e=>{let t=w(e,":");-1===t&&S(101,[e]);let n=e.slice(0,t).trim(),l=e.slice(t+1).trim(),i=n.split("#")[0].split("|")[0].trim();if(A.has(i)){let t;return i!==n&&S(102,[e,i]),i===a?(l.length>0&&S(103,[e]),t={Je:"#else",Ze:[]}):"..."===i?(0===l.length&&S(104,[e]),t=x(l),t.Ze.length>0&&S(105,[e])):(t=x(l),"for"===i&&t.Ze.length>0&&S(121,[e])),{Se:i,$e:[i],on:[],j:[],...t,w:"..."===i?"spread":i}}let r=x(l),o=function(e){let[t,n]=b(e,"input",k),l=t.split("#").map(v);l.length>2&&S(115,[t]);let[i,r]=l,o=i.split(".").map(v);return!(o.length>1&&""===o[0])&&(0===i.length||o.some(e=>0===e.length))&&S(116,[e]),{Se:i,$e:o,on:r?r.split(",").map(v):[],j:n}}(n),[s]=o.$e;if(""===s&&o.$e.length>1){let e=o.$e.slice(1);return(e.includes("")||E.has(e[0]))&&S(106,[n]),{...o,Se:e.join("."),$e:e,...r,w:"prop"}}return{...o,...r,w:"radio"===i||"checkbox"===i?i:s===h||s.startsWith("on")?"event":"prop"}});return t.length>1&&t.some(e=>j.has(e.w))&&S(201,[e]),t}function $(e,t){if(null!==e)for(let n=0;n<e.length;n++)t=e[n](t);return t}function C(t){return 0===t.length?null:(e(),t.map(e=>s(e.Hn,e.args,e.literals)))}var L=Symbol.for("wcstack.state.view-transition-naming"),O=new WeakSet;function P(){let e=t("state");return null!==e&&"auto"===e.naming?e.namingLimit:-1}var D=new Set(["click","dblclick","input","change","submit","keydown","keyup","mousedown","mouseup","pointerdown","pointerup"]),K=0,I=2,R=3,M=4,U=5,W=["text","prop","prop","prop","prop","event","for","if","prop","radio","checkbox","prop","prop","event","spread"],G=(e,t,n,l)=>e.Gt(t,n.o?.t??n.Rt,l,W[n.i]),B=Symbol();function q(e,t,n){let l=t.K;return null===l||"state"===l||"auto"===l&&void 0!==e.v(t.o,n)?t.U:B}var H=class{constructor(e,t,n,l,i,r,o,s,u,a=null){this.te=!1,this.j=null,this.Tn=!1,this.engine=e,this.i=t,this.a=n,this.name=l,this.o=i,this.r=r,this.Pn=o,this.x=s,this.value=u,this._=a}nn(){return W[this.i]}apply(){if(null!==this._)return void this._.Et();let e=$(this.x,this.engine.read(this.o,this.r));if(e===this.value&&9!==this.i&&("object"!=typeof e||null===e||11===this.i||8===this.i||i(this.name)))return;if(this.value===B)return void(this.value=e);let t=this.a;if(11!==this.i)9===this.i?t.checked=void 0!==e&&this.rn()===e:10===this.i?t.checked=Array.isArray(e)&&e.includes(this.rn()):Z(this.i,t,this.name,e),this.value=e;else{if(void 0===e)return void(this.value=e);this.value=e,this.Tn=!0;try{t[this.name]!==e&&(t[this.name]=e)}finally{this.Tn=!1}}}rn(){return $(this.j,this.a.value)}ir(){let e,t=this.a,n=this.engine;if(9===this.i){if(!t.checked)return;e=this.rn()}else if(10===this.i){let l=this.rn(),i=n.v(this.o,this.r),r=Array.isArray(i)?i:[],o=r.includes(l);if(t.checked?o:!o)return;e=o?r.filter(e=>e!==l):[...r,l]}else e=$(this.j,t[this.name]),this.value=NaN;n.T(this.o,this.r,e,!1,!0)}},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[X]=[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 X=Symbol();function z(e){let t="optgroup"===e.localName?e.parentNode:e,n=t?.[X];void 0!==n&&(t[n[0]]=n[1])}var J=class{constructor(e,t,n,l){this.y=!0,this.he=null,this.c=null,this.Nt=null,this.Fn=null,this.r=e,this.Ue=t,this.D=n,this.F=l}Jo(e,t){let n=t.target,l=this.F,i=[],r=null;for(let t of l.Re){if(t.name!==e)continue;let o=l.On[t.a],s=ue(null===this.D?this.Ue:this.D[o[0]],o,1);s.contains(n)&&(s!==r&&i.unshift([]),i[0].push(t),r=s)}for(let e of i){for(let n of e)n.An(t,this.r);if(t.cancelBubble)return!0}return!1}get s(){return null===this.D?this.Ue:this.D[this.D.length-1]}qe(){let e=this.Fn;return(null===e?null:e.Cn(this.Ue))??this.Ue}insertBefore(e,t){let n=this.s;for(let l=this.qe();;){let i=l.nextSibling;if(e.insertBefore(l,t),l===n)return;l=i}}wo(){null===this.D?this.Ue.remove():ae(this.qe(),this.s)}xe(e){if(this.y=!1,null!==this.Nt)for(let e of this.Nt)e();let t=this.he;if(null!==t)for(let n=0;n<t.length;n++)e.Nn(t[n]);if(null!==this.c)for(let e of this.c)e.xe()}},_=class extends J{constructor(e,t,n,l){super(e,t,n,l),this.bo=0,this.V=null,this.fe=0===l.ze.length?null:new Array(2*l.ze.length)}vo(e,t){let n=this.V??=new Array(this.F.ze.length),l=n[t];if(void 0===l){let i=this.F.ze[t],r=this.fe;l=n[t]=new H(e,i.i,r[2*t],i.name,i.o,this.r,this,i.x,r[2*t+1])}return l}uo(e,t){let n=this.F.ze;for(let l=0;l<n.length;l++)n[l].o.ee(t)&&e.en(this.vo(e,l))}xe(e){let t=this.r;t.E===this&&(t.E=null),super.xe(e)}};function Y(e,t,n,i){let r=l(n,t.n);try{return e.We(r,t)}catch(n){return e.Gt(n,t.t,i,"for"),null===r?e.oe.get(t):r.c.get(t)}}function Q(e,t,n){n&&e.nr(t);let l=t.Pn;null!==l&&(l.he??=[]).push(t)}var ee=null;function te(){let e=ee;return ee=null,e}var ne=-1;function le(e,t,n,l,i=null){let r,o=t.On,s=t.build,u=t.ko,a=null,h=T.Oe?.(t,null===l?i:l.S,null!==l),c=!h&&t.In,f=h?document.createDocumentFragment():(c?t.root:t.sn).cloneNode(!0);if(!h)for(let e=0;e<s.length;e++){let t=s[e];u[t]=ue(f,o[t],c?1:0)}c?r=f:(a=h||[...f.childNodes],r=a[0]);let d,m=null;if(null!==l?(d=m=new _(n,r,a,t),null===l.map?n.E=m:l.map.set(n,m)):d=new J(n,r,a,t),ne>=0&&function(e,t,n,l){let i=null;if(null===t)i=1===e.nodeType?e:null;else for(let e=0;e<t.length&&null===i;e++)1===t[e].nodeType&&(i=t[e]);let r=i?.style;if(null===i||void 0===r||O.has(i))return;let o=globalThis[L]??={counter:0,assigned:0,warned:!1};o.assigned>=l?o.warned||(o.warned=!0,console.warn(`[@wcstack/state] ${N(25,[l])}`)):(O.add(i),o.assigned++,r.setProperty("view-transition-name",`wcs-${n}-${++o.counter}`),r.setProperty("view-transition-class",`wcs-${n}`))}(r,a,null!==l?"row":"branch",ne),t.Re.length>0){let t=e.Kn;if(null===a)r[t]=d;else for(let e of a)1===e.nodeType&&(e[t]=d)}let p=t.sr,g=e.De,v=t.lr?u.slice(0,o.length):u,w=null===m?null:m.fe;if(null!==w){let e=t.ze;for(let t=0;t<e.length;t++)w[2*t]=v[e[t].a],w[2*t+1]=e[t].U}for(let t=0;t<p.length;t++){let l=p[t],i=v[l.a],o=l.A;if(o>=0&&null!==w){let t=m.V?.[o];if(void 0!==t){t.te=!1,e.Ve(t);continue}try{let t=$(l.x,e.read(l.o,n));t!==l.U&&(Z(l.i,i,l.name,t),w[2*o+1]=t),null!==g&&e.po(l.o,n)}catch(t){e.xt(t,m.vo(e,o))}continue}switch(l.i){case 6:{let t=new se(e,l.F,Y(e,l.o,n,i),i);(d.c??=[]).push(t),i===r&&(d.Fn=t),t.Et();break}case 7:{let t=re(e,l.G.map(e=>({F:e.F,o:e.o,x:e.x,S:v[e.a]})),n,d);(d.c??=[]).push(t),i===r&&(d.Fn=t);break}default:try{ie(e,l,i,n,d)}catch(t){G(e,t,l,i)}}}return ee=d,f}function ie(e,t,n,i,r){let o=n;switch(t.i){case 5:return void function(e,t,n,l,i){let r=n.An,o=e=>r(e,l);if(n.et){let l=e.ao(n.name),i=t[l];t[l]=void 0===i?o:e=>{i(e),o(e)},n.Ee&&t.addEventListener(n.name,e=>e.bubbles||o(e))}else t.addEventListener(n.name,o),n.yo&&null!==i&&(i.Nt??=[]).push(()=>t.removeEventListener(n.name,o))}(e,n,t,i,r);case 12:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name,o=e.command(t.Rt.slice(9)),s=null===i?T.or?.(n,r):null;s||(null===i&&me(1202,n,`command.${r}`),i.commands.has(r)||S(1203,[n.localName,r]));let u=new WeakRef(n),a=o.subscribe((...e)=>{let t=u.deref();if(void 0!==t)return t.isConnected?s?s(t,e):t[r](...e):void 0;a()});null!==l&&(l.Nt??=[]).push(a)}(e,t,o,r,n));case 13:return void fe(e,t,o,r,n=>function(e,t,n,l,i){let r=t.name;null===i&&me(1202,n,`eventToken.${r}`);let o=i.properties.get(r);void 0===o&&S(1204,[n.localName,r]);let s=t.Rt;n.addEventListener(o.event,n=>{t.Pt&&n.preventDefault(),t.Tt&&n.stopPropagation();try{e.Zo(s,n,l)}catch(e){console.error(e)}})}(e,t,o,i,n))}let s=t.o,u=l(i,s.n);if(14===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){null===r&&me(1501,n,`"...: ${t.o.t}"`);let o=new Set([...r.properties.keys(),...r.inputs]);for(let s of o){if(t.go?.includes(s))continue;let o=e.o(`${t.o.t}.${s}`),u=0===o.n?null:l;de(e,{...t,K:null,X:null},n,s,o,u,i,r)}}(e,t,o,u,r,n));if(t.Ee&&1===t.i)return void fe(e,t,o,r,n=>function(e,t,n,l,i,r){if(null!==r)return void de(e,t,n,t.name,t.o,l,i,r);let o=new H(e,1,n,t.name,t.o,l,i,t.x,q(e,t,l));o.j=t.j,!T.ar?.(o,t.ro)&&(Q(e,o,!0),e.Ve(o))}(e,t,o,u,r,n));let a=new H(e,t.i,n,t.name,s,u,r,t.x,q(e,t,u));a.j=t.j,Q(e,a,!0),e.Ve(a),null!==t.At&&n.addEventListener(t.At,()=>a.ir())}function re(e,t,n,i){let r=new oe(e,t,n),o=null;for(let s of t){if(null===s.o)continue;let t=s.o,u=new H(e,7,s.S,"if",t,l(n,t.n),i,null,void 0,r);Q(e,u,!0),null===i&&r.ce.push(u),o??=u}return e.Ve(o),r}var oe=class{constructor(e,t,n){this.y=!0,this.O=null,this.b=-1,this.ce=[],this.engine=e,this.G=t,this.r=n}Cn(e){return null!==this.O&&this.G[this.b].S===e?this.O.qe():null}Et(){let e=this.engine,t=-1;for(let n=0;n<this.G.length;n++){let i=this.G[n];if(null===i.o||$(i.x,e.read(i.o,l(this.r,i.o.n)))){t=n;break}}if(t!==this.b&&(ne=P(),null!==this.O&&(this.O.wo(),this.O.xe(e),this.O=null),this.b=t,t>=0)){let n=this.G[t],l=le(e,n.F,this.r,null,n.S);this.O=te();let i=n.S.parentNode;i.insertBefore(l,n.S),z(i)}}xe(){this.y=!1;for(let e of this.ce)this.engine.Nn(e);null!==this.O&&this.O.xe(this.engine)}},se=class{constructor(e,t,n,l){this.y=!0,this.Ne=[],this.engine=e,this.F=t,this.l=n,this.S=l,null===n.E?(n.E=this,this.map=null):((n.L??=[]).push(this),this.map=new Map)}Cn(e){return 0===this.Ne.length?null:this.Ne[0].qe()}Ft(e){return null===this.map?e.E:this.map.get(e)??null}Dt(e){let t=this.map;null!==t&&t.get(e.r)===e&&t.delete(e.r),e.xe(this.engine)}Et(){let e=this.engine,t=this.l.f,n=this.Ne;ne=P();let l=t.length,i=n.length,r=this.S,o=r.parentNode;if(0===l){if(i>0){let e=n[0].qe(),t=n[i-1].s,l=[];for(let n=o.firstChild;null!==n;n=n===e?t.nextSibling:n.nextSibling)if(n!==e){if(n!==r&&3!==n.nodeType){l=null;break}l.push(n)}null!==l?o.replaceChildren(...l):ae(e,t);for(let e=0;e<i;e++)this.Dt(n[e])}return void(this.Ne=[])}let s=new Array(l),u=0;for(;u<l&&u<i&&this.Ft(t[u])===n[u];)s[u]=n[u],u++;let a=i-1,h=l-1;for(;a>=u&&h>=u&&this.Ft(t[h])===n[a];)s[h]=n[a],a--,h--;for(let e=u;e<=a;e++){let t=n[e],l=t.r;l.y&&this.Ft(l)===t?t.bo=e:(t.wo(),this.Dt(t))}if(u<=h){let n=h-u+1,a=new Int32Array(n),c=!1;if(i>0)for(let e=0;e<n;e++){let n=this.Ft(t[u+e]);null!==n&&n.y?(a[e]=n.bo,c=!0):a[e]=-1}let f=h+1<l?s[h+1].qe():r;if(c){let l=function(e){let t=e.length,n=new Uint8Array(t),l=new Int32Array(t).fill(-1),i=[];for(let n=0;n<t;n++){let t=e[n];if(t<0)continue;let r=0,o=i.length;for(;r<o;){let n=r+o>>1;e[i[n]]<t?r=n+1:o=n}r>0&&(l[n]=i[r-1]),i[r]=n}let r=i.length>0?i[i.length-1]:-1;for(;r>=0;)n[r]=1,r=l[r];return n}(a),i=f;for(let r=n-1;r>=0;r--){let n=t[u+r],a=this.Ft(n);null!==a&&a.y?0===l[r]&&a.insertBefore(o,i):(o.insertBefore(le(e,this.F,n,this),i),a=te()),s[u+r]=a,i=a.qe()}}else{let n=document.createDocumentFragment();for(let l=u;l<=h;l++)n.appendChild(le(e,this.F,t[l],this)),s[l]=te();o.insertBefore(n,f)}}this.Ne=s,z(o)}xe(){this.y=!1;let e=this.l;if(e.E===this)e.E=null;else if(null!==e.L){let t=e.L.indexOf(this);t>=0&&e.L.splice(t,1),0===e.L.length&&(e.L=null)}for(let e of this.Ne)e.xe(this.engine);this.map?.clear()}};function ue(e,t,n){for(;n<t.length;n++){e=e.firstChild;for(let l=t[n];l>0;l--)e=e.nextSibling}return e}function ae(e,t){for(let n,l=e;l!==t;l=n)n=l.nextSibling,l.remove();t.remove()}var he=new WeakMap,ce=e=>e.customElementRegistry??customElements;function fe(e,t,n,l,i,r=!1){let o=n.localName;if(!o.includes("-"))return i(null);let s=ce(n);if(!r&&!n.isConnected&&void 0===s.get(o)&&"customElementRegistry"in n)return void queueMicrotask(()=>fe(e,t,n,l,i,!0));let u=()=>{let e=s.get(o);s.upgrade(n),i(e?function(e){if(he.has(e))return he.get(e);let t=e.wcBindable,n=null;if(null!==t&&"object"==typeof t&&"wc-bindable"===t.protocol&&Number.isInteger(t.version)&&t.version>=1){n={properties:new Map,inputs:new 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,ho:"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 he.set(e,n),n}(e):null)};if(!r&&void 0!==s.get(o))return u();null!==l&&!l.y||function(e,t,n){let l=n;null!==t&&(t.Nt??=[]).push(()=>{l=null}),e.then(()=>l?.())}(s.whenDefined(o),l,()=>{try{u()}catch(l){G(e,l,t,n)}e.Te()})}function de(e,t,n,l,i=t.o,r,o,s){let u=s.properties.get(l)??null,a=s.inputs.has(l),h=e._t;h&&null===u&&!a&&S(38,[l]);let c=t.K;(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 H(e,11,n,l,i,r,o,t.x,void 0);d.j=t.j,Q(e,d,!f),null!==u&&!t.ro&&n.addEventListener(u.event,t=>{let i;null!==u.getter?i=u.getter(t):(i=t.detail,u.ho||T.detail?.(n,l,i)),(!d.Tn||!Object.is(i,d.value))&&(i=$(d.j,i),null===d.x&&(d.value=i),e.T(d.o,d.r,i,u.ho,!0))});let m=c??(f?"element":"state");if("state"===m)f||e.Ve(d);else if("element"===m||"auto"===m){let i=()=>{if(null!==o&&!o.y)return;if("auto"===m&&void 0!==e.v(d.o,d.r))return void(f||e.Ve(d));let t=n[l];null===d.x&&(d.value=t),e.T(d.o,d.r,t,!1,!0)};"connect"!==t.X||n.isConnected?i():Promise.resolve().then(i)}return d}function me(e,t,n){S(e,[t.localName,n])}var pe=()=>o.bindAttributeName;function ge(){return{a:0,i:1,name:"",o:null,x:null,U:u,An:null,F:null,G:null,j:null,At:null,Ee:!1,K:null,X:null,ro:!1,Pt:!1,Tt:!1,Rt:null,go:null,A:-1,et:!1,yo:!1}}var ve=["state","element","auto","none"],we=["call","connect"],ye="$command.";function be(e,t,n){g.test(t)&&(null===n&&S(1401,[t,Number(t.slice(1))]),t=`${n.t}.*.${t}`);let l=e.o(function(e,t){return 46!==e.charCodeAt(0)?e:(null===t&&S(1402,[e]),"."===e?`${t.t}.*`:`${t.t}.*${e}`)}(t,n)),i=null===n?0:n.n+1;l.n>i&&S(1401,[l.t,l.n,i]);for(let e=1;e<=l.n;e++){let t=e===i?n:n.h[e];l.h[e]!==t&&S(1403,[l.t,l.h[e].t,t.t])}return T.So?.(e,l),l}var xe=e=>1===e.i&&("outerHTML"===e.name||"outerText"===e.name),Ne=e=>8===e.i||xe(e)||1===e.i&&V(e.name);function Se(e){S(202,[e])}function Te(e,t,l,r,o){let s=F(t).map(t=>function(e,t,l,r,o){let s=function(e,t){let n=t.find(e=>e.startsWith("on")),l=null,i=null;for(let n of t){let t=n.indexOf("=");if(t<0)continue;e._t||S(31);let r=n.slice(0,t).trim(),o=n.slice(t+1).trim(),s="init"===r;!s&&"sync"!==r&&S(33,[r,n]),null!==(s?l:i)&&S(34,[r]),(s?ve:we).includes(o)||S(35,[r,o]),s?l=o:i=o}return{ro:t.includes("ro"),Pt:t.includes("prevent"),Tt:t.includes("stop"),event:n?n.slice(2):null,K:l,X:i}}(e,t.on),u=r.localName.includes("-"),a=t.$e,h=t.Je;if("event"===t.w){if(null!==s.K&&"none"!==s.K&&S(36),"eventToken"===a[0])return{...ge(),a:o,i:13,name:a.slice(1).join("."),Rt:h,Ee:u,Pt:s.Pt,Tt:s.Tt};let l=h.startsWith(ye)?h.slice(9):null,{Pt:i,Tt:r}=s,c=t.Se.slice(2),f=t.on.includes("direct"),d=!f&&D.has(c);return d&&e.ao(c),{...ge(),a:o,i:5,name:c,et:d,Ee:u,yo:f,An(t,o){i&&t.preventDefault(),r&&t.stopPropagation();try{if(null!==l)e.er(l,t,o);else{let l=e.tr(h,t,o);n(l)&&l.then(void 0,e=>console.error(e))}}catch(e){console.error(e)}}}}if("spread"===t.w)return{...ge(),a:o,i:14,o:be(e,h,l),Ee:u};if("command"===a[0]&&a.length>1)return h.startsWith(ye)||S(1201,[t.Se,h]),{...ge(),a:o,i:12,name:a.slice(1).join("."),Rt:h,Ee:u};let c=be(e,h,l),f={...ge(),a:o,i:1,name:t.Se,o:c,x:C(t.Ze),j:C(t.j),ro:s.ro,K:s.K,X:s.X};if("radio"===t.w||"checkbox"===t.w)return("element"===s.K||"auto"===s.K)&&S(37,[t.w,s.K]),f.i="radio"===t.w?9:10,s.ro||(f.At=s.event??"input"),f;if(a.length>1){let e=a.slice(1).join("."),t=a[0];if("class"===t||"attr"===t||"style"===t)return f.K=null,f.name=e,"class"===t?(f.i=2,f.U=r.classList.contains(e)):f.i="attr"===t?"srcdoc"===e&&"iframe"===r.localName?1:3:4,f}return"html"===t.Se?(f.i=8,f):(f.name="text"===t.Se?"textContent":t.Se,f.Ee=u&&!i(f.name),!u&&!s.ro&&function(e,t){let n=e.localName;if("input"===n){let n=(e.getAttribute("type")||"text").toLowerCase();return"button"!==n&&(("radio"===n||"checkbox"===n)&&"checked"===t||"value"===t||"valueAsNumber"===t||"valueAsDate"===t)}return("select"===n||"textarea"===n)&&"value"===t}(r,f.name)&&(f.At=s.event??("select"===r.localName?"change":"input")),f)}(e,t,l,r,o));for(let e=0;e<s.length;e++)14===s[e].i&&(s[e].go=s.slice(e+1).filter(e=>1===e.i).map(e=>e.name));return s}var ke=/\{\{([\s\S]+?)\}\}/g;function je(e){let t=e.data,n=[],l=0;ke.lastIndex=0;for(let i=ke.exec(t);null!==i;i=ke.exec(t)){let r=ke.lastIndex-i[0].length;r>l&&e.before(t.slice(l,r));let o=e.ownerDocument.createTextNode("");e.before(o),n.push({a:o,cr:i[1].trim()}),l=ke.lastIndex}return 0===n.length||(l<t.length&&e.before(t.slice(l)),e.remove()),n}function Ae(e,t,n,l){let i=function(e){return{Se:"textContent",$e:["textContent"],on:[],j:[],...x(e),w:"text"}}(t);return{...ge(),a:l,i:0,o:be(e,i.Je,n),x:C(i.Ze),U:""}}function Ee(e){let t=e.getAttribute(pe());if(null===t)return null;let n=F(t)[0];return void 0===n||"for"!==n.w&&"if"!==n.w&&"elseif"!==n.w&&"else"!==n.w?null:n}var Fe=(e,t)=>0===e?o.commentIfPrefix:null===t.o?o.commentElsePrefix:o.commentElseIfPrefix;function $e(e,t,n){let l=(t,l)=>({el:t,o:"else"===l.w?null:be(e,l.Je,n),x:"else"===l.w?null:C(l.Ze)}),i=[l(t,Ee(t))];for(let e=t.nextSibling;null!==e;e=e.nextSibling){if(3===e.nodeType&&""===e.data.trim()||8===e.nodeType)continue;if(1!==e.nodeType||"template"!==e.localName)break;let t=Ee(e);if(null===t||"elseif"!==t.w&&"else"!==t.w||(i.push(l(e,t)),"else"===t.w))break}return i}var Ce=new WeakSet;function Le(e,t,n,l,i,r,s,u){let a=(t,n)=>{let i=document.createComment(n);return t.replaceWith(i),l&&T.jn?.(e,i,t),i},h=t=>{for(let c=0;c<t.length;c++){let f=t[c];if(null!==f.parentNode)if(1===f.nodeType){let t=f,u=t.localName;if(l){if("script"===u||"style"===u||Ce.has(t))continue;if(Ce.add(t),u===o.tagNames.state){h([...t.childNodes]);continue}}let c="template"===u?Ee(t):null;if(null!==c){if("for"===c.w){let l=be(e,c.Je,n),r=De(e,t,l,!0);i(a(t,o.commentForPrefix),l,r)}else"if"===c.w?r($e(e,t,n).map((t,l)=>({F:De(e,t.el,n,!1),o:t.o,x:t.x,S:a(t.el,Fe(l,t))}))):Se(c.w);continue}let d=t.getAttribute(pe()),m=null===d?null:Te(e,d,n,t,0),p="noscript"!==u&&"iframe"!==u&&!m?.some(Ne)&&!T.$o?.(t);try{l&&p&&h([...t.childNodes])}finally{null!==m&&s(t,m)}!l&&p&&h([...t.childNodes])}else if(3===f.nodeType&&e.Mt&&f.data.includes("{{")&&!Ce.has(f))for(let{a:e,cr:t}of je(f))u(e,t);else if(8===f.nodeType){let e=Oe.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 Oe=/^\s*@@\s*(?:wcs-text)?\s*:\s*([\s\S]+?)\s*$/,Pe=e=>{let t=document.createRange();return t.selectNodeContents(e),e.content??t.cloneContents()};function De(e,t,n,l){let i=document.importNode(Pe(t),!0),r=[],o=[],s=e=>r.push(e)-1;Le(e,[...i.childNodes],n,!1,(e,t,n)=>{o.push({...ge(),a:s(e),i:6,o:t,F:n})},e=>{let t=e.map(e=>({a:s(e.S),F:e.F,o:e.o,x:e.x}));o.push({...ge(),a:t[0].a,i:7,G:t})},(e,t)=>{let n=s(e);for(let e of t)xe(e)&&S(203,[e.name]),e.a=n;o.push(...t),e.removeAttribute(pe())},(t,l)=>{o.push(Ae(e,l,n,s(t)))}),Me(i,new Set(r),!0);let u=r.map(e=>function(e,t){let n=[];for(let l=t;l!==e;l=l.parentNode){let e=0;for(let t=l.previousSibling;null!==t;t=t.previousSibling)e++;n.unshift(e)}return n}(i,e)),a=1===i.childNodes.length&&8!==i.firstChild.nodeType,h=o.some(e=>6===e.i||7===e.i),c=[],f=new Set,d=[],m=[],p=l?n.n+1:-1;for(let e of o){if(5===e.i&&e.et&&!e.Ee&&!Ke(r[e.a],i)){d.push(e);continue}m.push(e);let t=e.o;if(null!==t&&t.n===p&&t.h[p]===n&&Ie(e)&&(e.A=c.push(e)-1),7===e.i)for(let t of e.G)f.add(t.a);else f.add(e.a)}let g=[...f].sort((e,t)=>e-t);return{sn:i,root:a?i.firstChild:null,On:u,build:g,Re:d,sr:m,In:a,lr:h,ko:[],ze:c}}function Ke(e,t){for(;e.parentNode!==t;e=e.parentNode){if(e.parentNode.localName.includes("-"))return!0;for(let t=e.previousSibling;t;t=t.previousSibling)if(8===t.nodeType)return!0}return!1}function Ie(e){if(null!==e.K)return!1;switch(e.i){case 0:case 2:case 3:case 4:case 8:return!0;case 1:return!e.Ee&&null===e.At;default:return!1}}var Re=new Set(["table","thead","tbody","tfoot","tr","colgroup","select","optgroup","datalist"]);function Me(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&&Me(l,t,Re.has(l.localName)),l=e}}var Ue=new WeakMap;function We(e,t){let n=9===t.nodeType?t.body:t;e.root=t,Ue.set(t,e),Be(e,[...n.childNodes]),e.He()}function Ge(e,t,n){try{let l="template"===t.localName?Ee(t):null;null!==l&&!n&&S(204,[l.w]),Be(e,[t])}catch(e){console.error(e)}e.He()}function Be(e,t){Le(e,t,null,!0,(t,n,l)=>{new se(e,l,Y(e,n,null,t),t).Et()},t=>{re(e,t,null,null)},(t,n)=>{T.jn?.(e,t,n);for(let l of n)ie(e,l,t,null,null)},(t,n)=>{T.jn?.(e,t,n),ie(e,Ae(e,n,null,0),t,null,null)})}export{F as a,ce as b,K as c,I as d,R as e,M as f,U as g,_ as h,se as i,xe as j,Ne as k,Ce as l,Pe as m,Ue as n,We as o,Ge as p};
2
+ //# sourceMappingURL=chunk-L3PFEJP7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["cacheFilterInfos","Map","STRUCTURAL_BINDING_TYPE_SET","Set","KEYWORDS_WITHOUT_MODIFIERS","ELSE_KEYWORD","EXPLICIT_PROPERTY_REJECTED_HEADS","CLASS_NAMESPACE","ATTR_NAMESPACE","STYLE_NAMESPACE","COMMAND_NAMESPACE","EVENT_TOKEN_NAMESPACE","VOLUME_INJECTION_PROP","parseBindTextsForElement","bindText","results","splitOutsideQuotes","splitBindTexts","map","trimFn","filter","s","length","separatorIndex","indexOfOutsideQuotes","raise","propPart","slice","trim","statePart","keyword","split","has","stateResult","statePathName","outFilters","parseStatePart","propName","propSegments","propModifiers","inFilters","bindingType","propResult","propText","filters","splitFilters","modifierParts","propModifiersText","some","segment","parsePropPart","head","includes","join","startsWith","r","pipe","fs","v","i","buildFilters","parsed","installCoreFilters","f","resolveFilter","filterName","args","literals","LEDGER_KEY","Symbol","for","named","WeakSet","autoNaming","runner","getTransitionRunner","naming","namingLimit","BUBBLING","K_TEXT","K_CLASS","K_ATTR","K_STYLE","K_EVENT","TYPE_NAMES","failSpec","engine","error","node","failAt","pattern","path","token","kind","HOLD","initialOf","row","init","readUntracked","initial","Binding","constructor","name","owner","chain","this","queued","applying","value","typeName","apply","update","read","isHtmlSink","n","checked","elementValue","Array","isArray","applyTo","writeBack","e","cur","arr","x","NaN","write","isContent","data","String","trustHtml","removeAttribute","localName","SELECTED","innerHTML","classList","toggle","setAttribute","style","removeProperty","setProperty","reselect","parent","sel","parentNode","Block","first","nodes","plan","alive","bindings","children","cleanups","lead","dispatch","type","target","hits","last","events","nodePaths","nodeAt","contains","unshift","push","own","listener","cancelBubble","headAt","insertBefore","ref","next","nextSibling","removeNodes","remove","removeContiguous","dispose","c","bs","unregister","RowView","super","pos","bound","slots","lazy","slotBinding","k","b","enqueueSlots","p","isUnder","enqueue","view","listFor","anchor","rowAt","depth","childList","rootLists","get","adopt","register","lastBlock","takeBlock","buildBlock","fv","at","paths","build","scratch","all","adopted","hooks","single","top","document","createDocumentFragment","root","fragment","cloneNode","childNodes","block","rv","set","limit","el","nodeType","ledger","globalThis","counter","assigned","warned","console","warn","text","add","nameBlock","key","blockKey","specs","rendered","nested","slot","applyBinding","noteRendered","fail","ForView","iv","attachChain","branches","br","attachSpec","fn","h","delegated","delegate","prev","custom","addEventListener","bubbles","direct","removeEventListener","attachEvent","whenDefined","bd","spec","method","command","call","nativeCommand","noBindable","commands","WeakRef","unsubscribe","subscribe","deref","isConnected","attachCommand","prop","decl","properties","event","prevent","preventDefault","stop","stopPropagation","fireEventToken","attachEventToken","brow","names","keys","inputs","exclude","attachProperty","sync","attachSpread","hostBinding","ro","attachCustomOrPlain","twoWay","IfView","rootBindings","current","index","list","rowViews","extra","_n","viewOf","drop","delete","rows","old","o","keep","firstChild","replaceChildren","views","oe","ne","m","src","Int32Array","anyKept","next0","Uint8Array","fill","tails","lo","hi","mid","lisKeep","frag","appendChild","indexOf","splice","clear","j","bindableByClass","WeakMap","registryOf","customElementRegistry","customElements","attach","later","tag","queueMicrotask","run","cls","upgrade","wcBindable","out","protocol","Number","isInteger","version","getter","occurrence","semantics","readBindable","then","pending","schedule","input","directional","outputOnly","detail","Object","is","authority","seed","snapshot","Promise","resolve","id","what","bindAttr","config","bindAttributeName","blank","UNSET","INITS","SYNCS","COMMAND_PREFIX","boundPattern","INDEX_PARAM","test","charCodeAt","expandPath","d","loop","lists","declared","isOuter","setsContent","notAfterIf","elementSpecs","mods","on","find","isInit","flags","segs","emitCommand","invoke","isThenable","getAttribute","toLowerCase","isTwoWay","specFor","MUSTACHE","splitMustache","t","lastIndex","exec","before","ownerDocument","createTextNode","expr","textSpec","parseBindTextForEmbeddedNode","directive","chainAnchorText","part","commentIfPrefix","commentElsePrefix","commentElseIfPrefix","readChain","parts","walked","walkBindings","page","onFor","onIf","onElement","onText","anchorFor","createComment","replaceWith","ssrMark","walk","child","tagNames","state","compilePlan","commentForPrefix","into","componentScope","mustache","COMMENT_BINDING","templateContent","createRange","selectNodeContents","content","cloneContents","template","asRow","importNode","targets","stripInsignificantWhitespace","previousSibling","pathOf","used","shifts","isSlotKind","sort","a","NO_TEXT","strip","engines","mount","container","body","report","mountSubtree","subtree","range","Rt","Z","ee","te","pe","H","dt","Mt","Ce","Wt","Gt","Gn","jn"],"sources":["../../../src/parser/parsePropPart.ts","../../../src/parser/types.ts","../../../src/parser/parseBindTextsForElement.ts","../../../src/dom/filters.ts","../../../src/dom/naming.ts","../../../src/dom/view.ts","../../../src/dom/wc.ts","../../../src/dom/plan.ts","../../../src/parser/parseBindTextForEmbeddedNode.ts","../../../src/dom/mount.ts"],"sourcesContent":["import { DELIMITER, MODIFIER_SEPARATOR } from \"./define\";\nimport { splitFilters } from \"./parseFilters\";\nimport { raise, M } from \"../messages\";\nimport { ParsedBinding, ParsedFilter } from \"./types\";\nimport { trimFn } from \"./utils\";\n\n// 解析の段の形(フィルタは名前と引数だけ — 実関数はエンジンが引く。要件 D16)\nexport type PropPartParseResult = Pick<ParsedBinding, 'propName' | 'propSegments' | 'propModifiers' | 'inFilters'>;\n\n/**\n * 入力フィルタ列の解析結果のキャッシュ(鍵は `|` より後ろの原文)。同じ原文は**同じ配列**を返す —\n * 消費側は返された `inFilters` を変更しないこと。落ちた解析は載らない。\n * (`@wcstack/state` の tooling 専用の解放口 `clearPropPartCacheForTooling` は移植しない)\n */\nconst cacheFilterInfos = new Map<string, ParsedFilter[]>();\n/** Tooling (`clearParserCaches`): a long-running process drops what it parsed. */\nexport const clearPropPartCache = (): void => cacheFilterInfos.clear();\n\n// format: propName#moodifier1,modifier2\n// propName-format: path.to.property (e.g., textContent, style.color, not include :)\n// special path:\n// 'attr.attributeName' for attributes (e.g., attr.href, attr.data-id)\n// 'style.propertyName' for style properties (e.g., style.backgroundColor, style.fontSize)\n// 'class.className' for class names (e.g., class.active, class.hidden)\n// 'onclick', 'onchange' etc. for event listeners\n\n/** Port of `@wcstack/state` `src/bindTextParser/parsePropPart.ts` (behaviour unchanged). */\nexport function parsePropPart(propPart: string): PropPartParseResult {\n const [propText, filters] = splitFilters(propPart, \"input\", cacheFilterInfos);\n\n // **不変条件**: ここから下の `split` は素で走らせてよい。`propText` は「引用符外の最初の `|`\n // より前」のスライスであり、引用符を含みうるのは入力フィルタの引数(`|` の後ろ)だけなので、\n // `#` も `,` も `.` も引用符の中に現れない。**修飾子の値に引用符を許す拡張(例\n // `value#fmt('a,b'): x`)を入れるなら、この 3 つも `splitOutsideQuotes` に替えること**。\n const modifierParts = propText.split(MODIFIER_SEPARATOR).map(trimFn);\n if (modifierParts.length > 2) {\n // 修飾子の並びは 1 つだけ(要件 B2)。`value#ro#wo` は以前 `ro` だけを残して黙って捨てていた\n raise(M.OneModifierList, [propText]);\n }\n const [propName, propModifiersText] = modifierParts;\n const propSegments = propName.split(DELIMITER).map(trimFn);\n // 明示のプロパティ形(`.name:` — 要件 B5 / D34)だけは先頭の空セグメントが正しい形。\n // それ以外で空のセグメントが残るのは書き間違い: 左辺が空(`\": x\"` / `\"#ro: x\"` / `\"|trim: x\"`)だと\n // `element[\"\"] = value` の expando ができて完全に沈黙し、末尾が空(`\"foo.: x\"`)だと適用の段で\n // 素の TypeError になる。どちらも解析の段で名指しで落とす(`.: x` 等は D34 の検査が受け持つ)\n const isExplicitProperty = propSegments.length > 1 && propSegments[0] === '';\n if (!isExplicitProperty && (propName.length === 0 || propSegments.some((segment) => segment.length === 0))) {\n raise(M.NoPropertyName, [propPart]);\n }\n const propModifiers = propModifiersText\n ? propModifiersText.split(',').map(trimFn)\n : [];\n return {\n propName,\n propSegments,\n propModifiers,\n inFilters: filters,\n };\n}\n","export type BindingType = 'text' | 'prop' | 'event' | 'for' | 'if' | 'elseif' | 'else' | 'radio' | 'checkbox' | 'spread';\n\n/** Left side (input) or right side (output) of a binding — only used to pick the diagnostic wording. */\nexport type FilterIOType = 'input' | 'output';\n\n/**\n * A filter as the grammar reads it: name and arguments only. The filter function is resolved\n * later by the engine (the parser never looks names up, so unknown names pass here).\n *\n * Field names are the ones of `@wcstack/state`'s `IParsedFilter`:\n * - `filterName` — the name as written (no alias resolution).\n * - `args` — the raw argument texts, quotes removed (format filters read these).\n * - `literals` — the typed value of each argument (requirement B9): unquoted `true` / `false` /\n * `null` / numbers are typed, everything else (and every quoted argument) is the string.\n * Always the same length and order as `args`.\n */\nexport interface ParsedFilter {\n filterName: string;\n args: string[];\n literals: unknown[];\n}\n\n/** Parse result of one binding (DOM independent). */\nexport interface ParsedBinding {\n propName: string;\n propSegments: string[];\n propModifiers: string[];\n statePathName: string;\n inFilters: ParsedFilter[];\n outFilters: ParsedFilter[];\n bindingType: BindingType;\n}\n\n/** Bindings that must be the only binding of their attribute value. */\nexport const STRUCTURAL_BINDING_TYPE_SET: ReadonlySet<BindingType> = new Set<BindingType>([\n 'if',\n 'elseif',\n 'else',\n 'for',\n]);\n","import {\n ATTR_NAMESPACE,\n BINDING_SEPARATOR,\n CLASS_NAMESPACE,\n COMMAND_NAMESPACE,\n DELIMITER,\n ELSE_KEYWORD,\n EVENT_PROP_PREFIX,\n EVENT_TOKEN_NAMESPACE,\n FILTER_SEPARATOR,\n MODIFIER_SEPARATOR,\n PROP_VALUE_SEPARATOR,\n SPREAD_PROP,\n STYLE_NAMESPACE,\n VOLUME_INJECTION_PROP,\n} from \"./define\";\nimport { parsePropPart } from \"./parsePropPart\";\nimport { parseStatePart, type StatePartParseResult } from \"./parseStatePart\";\nimport { raise, M } from \"../messages\";\nimport { ParsedBinding, STRUCTURAL_BINDING_TYPE_SET } from \"./types\";\nimport { indexOfOutsideQuotes, splitOutsideQuotes, trimFn } from \"./utils\";\n\n// format: propPart:statePart; propPart:statePart; ...\n// special-propPart:\n// if: statePart (single binding for conditional rendering)\n// else: (single binding for conditional rendering, and statePart is ignored)\n// elseif: statePart only (single binding for conditional rendering)\n// for: statePart only (single binding for loop rendering)\n// onclick: statePart, onchange: statePart etc. (event listeners)\n// ...: statePart (spread — the engine expands it into the target's wcBindable properties)\n\n/** 左辺に修飾子も入力フィルタも取らない束縛(構造ディレクティブと spread)— 付いていれば拒否する(要件 B4) */\nconst KEYWORDS_WITHOUT_MODIFIERS = new Set<string>([ELSE_KEYWORD, 'if', 'elseif', 'for', SPREAD_PROP]);\n\n/**\n * 明示のプロパティ形(`.name:`)の先頭に置けない語 — 名前空間として読まれる語(要件 B5)。\n * `state`(`VOLUME_INJECTION_PROP`)も含む: `<wcs-state mount>` 上の左辺 `state.<key>:` は\n * 注入の宣言(要件 B14③)なので、`.state.taxRate:` はプロパティか注入か曖昧になる。\n */\nconst EXPLICIT_PROPERTY_REJECTED_HEADS = new Set<string>([\n CLASS_NAMESPACE, ATTR_NAMESPACE, STYLE_NAMESPACE, COMMAND_NAMESPACE, EVENT_TOKEN_NAMESPACE,\n VOLUME_INJECTION_PROP,\n]);\n\n/**\n * `data-wcs` の値をバインディングごとに区切る(前後の空白は残す — tooling が位置を数えられるように)。\n * 引用符の中の `;` は区切りではない(要件 B1 — `join(';')`)。\n */\nexport function splitBindTexts(bindText: string): string[] {\n return splitOutsideQuotes(bindText, BINDING_SEPARATOR);\n}\n\n/**\n * `data-wcs` 属性値 1 つを解析する。Port of `@wcstack/state`\n * `src/bindTextParser/parseBindTextsForElement.ts` — same signature (text only: no decision\n * here needs the element), same results minus `statePathInfo`, same diagnostics.\n *\n * The parser does NOT: expand the loop-relative shorthand (`.name` / `.`), expand `...:`\n * spread into the target's properties, resolve filter names/functions, or check the\n * `if`/`elseif`/`else` sibling order — the engine does those.\n */\nexport function parseBindTextsForElement(bindText: string): ParsedBinding[] {\n const bindTexts = splitBindTexts(bindText).map(trimFn).filter(s => s.length > 0);\n const results = bindTexts.map((bindText): ParsedBinding => {\n // 左辺と右辺の区切りも引用符の外だけで探す(要件 B1)。`value|defaults(':'): path` の\n // 引数の中の `:` を区切りとして拾っていた\n const separatorIndex = indexOfOutsideQuotes(bindText, PROP_VALUE_SEPARATOR);\n if (separatorIndex === -1) {\n raise(M.BindTextNoColon, [bindText]);\n }\n const propPart = bindText.slice(0, separatorIndex).trim();\n const statePart = bindText.slice(separatorIndex + 1).trim();\n // 種別は修飾子・入力フィルタより前の名前で決める(要件 B4)。以前は左辺全体との完全一致で\n // 判定していたので、`radio#ro:` が汎用プロパティに落ちていた。\n // **不変条件**: ここは素の `split` でよい — 取り出すのは最初の区切りより前の**先頭**片で、\n // 引用符を含みうるのは入力フィルタの引数(引用符外の最初の `|` より後ろ)だけなので、\n // `#` も `|` も引用符の中では出会わない。**修飾子の値に引用符を許す拡張を入れるなら\n // `indexOfOutsideQuotes` に替えること**(`parsePropPart.ts` の同じ注記と対)。\n const keyword = propPart.split(MODIFIER_SEPARATOR)[0].split(FILTER_SEPARATOR)[0].trim();\n if (KEYWORDS_WITHOUT_MODIFIERS.has(keyword)) {\n if (keyword !== propPart) {\n raise(M.StructuralTakesNoModifiers, [bindText, keyword]);\n }\n let stateResult: StatePartParseResult;\n if (keyword === ELSE_KEYWORD) {\n if (statePart.length > 0) {\n // else は値を取らない(要件 B2)。以前は右辺を黙って捨てていた\n raise(M.ElseTakesNoValue, [bindText]);\n }\n stateResult = { statePathName: '#else', outFilters: [] };\n } else if (keyword === SPREAD_PROP) {\n // 空の右辺は spread 専用の語彙で先に落とす。`parseStatePart` の一般の空パス診断\n // (「the right side of a binding must name a state path」)より、ここでは\n // 「spread target path is required」のほうが直し方を指している\n if (statePart.length === 0) {\n raise(M.SpreadNoPath, [bindText]);\n }\n stateResult = parseStatePart(statePart);\n if (stateResult.outFilters.length > 0) {\n raise(M.SpreadNoFilters, [bindText]);\n }\n } else {\n stateResult = parseStatePart(statePart);\n // a row of `for: p` is `p.<index>`: the rows of a filtered list would name other elements (#370)\n if (keyword === 'for' && stateResult.outFilters.length > 0) {\n raise(M.ForNoFilters, [bindText]);\n }\n }\n return {\n propName: keyword,\n propSegments: [keyword],\n propModifiers: [],\n inFilters: [],\n ...stateResult,\n bindingType: keyword === SPREAD_PROP ? 'spread' : keyword as ParsedBinding['bindingType'],\n };\n }\n const stateResult = parseStatePart(statePart);\n const propResult = parsePropPart(propPart);\n const [head] = propResult.propSegments;\n // 左辺の先頭ドット(`.online:`)は明示のプロパティ形(要件 B5・3.x 計画 D34)。ドットの無い形と\n // 同じ束縛だが、`on` で始まってもイベントにはならない(`online:` は \"line\" イベントを待つ)。\n // 名前空間の語(`.class.x` / `.command.x` …)はプロパティか名前空間か曖昧なので受けない\n if (head === '' && propResult.propSegments.length > 1) {\n const propSegments = propResult.propSegments.slice(1);\n if (propSegments.includes('') || EXPLICIT_PROPERTY_REJECTED_HEADS.has(propSegments[0])) {\n raise(M.LeadingDotNamespace, [propPart]);\n }\n return {\n ...propResult,\n propName: propSegments.join(DELIMITER),\n propSegments,\n ...stateResult,\n bindingType: 'prop',\n };\n }\n return {\n ...propResult,\n ...stateResult,\n // 修飾子(`#ro`・`#onchange` …)と入力フィルタは radio / checkbox のハンドラが読む(要件 B4)。\n // eventToken.<prop>: <name> は要素 dispatch を state へ流す pub/sub 配線。\n // 値適用ではないため bindingType 'event' として listener attach 経路に乗せる。\n bindingType: keyword === 'radio' || keyword === 'checkbox' ? keyword\n : head === EVENT_TOKEN_NAMESPACE || head.startsWith(EVENT_PROP_PREFIX) ? 'event' : 'prop',\n };\n });\n // check for sigle binding for 'if', 'elseif', 'else', 'for'\n if (results.length > 1) {\n const isIncludeSingleBinding = results.some(r => STRUCTURAL_BINDING_TYPE_SET.has(r.bindingType));\n if (isIncludeSingleBinding) {\n // lint 側の単独バインディング検査(bindingValidator の structuralMustBeSingle)が\n // 同じケースを検出するため誘導を付ける(三面同語彙)。\n raise(M.StructuralNotSingle, [bindText]);\n }\n }\n return results;\n}\n","import type { ParsedFilter } from \"../parser/index\";\nimport { resolveFilter, type FilterFn } from \"../filters/registry\";\nimport { installCoreFilters } from \"../filters/core\";\n\nexport type { FilterFn };\n\n/** `v` through the filters `fs` (none when null). */\nexport function pipe(fs: FilterFn[] | null, v: unknown): unknown {\n if (fs !== null) for (let i = 0; i < fs.length; i++) v = fs[i](v);\n return v;\n}\n\n/**\n * Resolves a binding's parsed filters to functions (at plan time, once per binding spec).\n * The core filters (the conditions) are always available; the others come with the formats add-on\n * (`installFeatures([formats])`; the full build installs it).\n */\nexport function buildFilters(parsed: readonly ParsedFilter[]): FilterFn[] | null {\n if (parsed.length === 0) return null;\n installCoreFilters(); // idempotent\n return parsed.map((f) => resolveFilter(f.filterName, f.args, f.literals));\n}\n","import { getTransitionRunner } from \"../protocol/transitionRunner\";\nimport { M, text } from \"../messages\";\n\n/**\n * Automatic `view-transition-name` (docs/view-transition-design.md §6), as @wcstack/state\n * does it: when the page's arbiter declares `naming=\"auto\"`, the first element of every\n * row and `if` branch built gets a unique name. A name must be on the element before the\n * browser snapshots the old state, so it is given when the block is built, never renamed,\n * and capped (each named element is a snapshot group of its own).\n *\n * The ledger is per document (a `Symbol.for` slot shared with @wcstack/state), so two\n * bundles on one page never mint the same name.\n */\ninterface Ledger {\n counter: number;\n assigned: number;\n warned: boolean;\n}\n\nconst LEDGER_KEY = Symbol.for(\"wcstack.state.view-transition-naming\");\nconst named = new WeakSet<Element>();\n\n/** The naming cap when the arbiter names automatically, or -1 (the author names). */\nexport function autoNaming(): number {\n const runner = getTransitionRunner(\"state\");\n return runner !== null && runner.naming === \"auto\" ? runner.namingLimit : -1;\n}\n\n/** Names the first element of `nodes` (`wcs-row-3`, `wcs-branch-7`), within the cap. */\nexport function nameBlock(first: ChildNode, nodes: ChildNode[] | null, kind: \"row\" | \"branch\", limit: number): void {\n let el: Element | null = null;\n if (nodes === null) el = first.nodeType === 1 ? (first as Element) : null;\n else for (let i = 0; i < nodes.length && el === null; i++) if (nodes[i].nodeType === 1) el = nodes[i] as Element;\n const style = (el as HTMLElement | null)?.style;\n if (el === null || style === undefined || named.has(el)) return;\n const ledger = ((globalThis as any)[LEDGER_KEY] ??= { counter: 0, assigned: 0, warned: false }) as Ledger;\n if (ledger.assigned >= limit) {\n if (!ledger.warned) {\n ledger.warned = true;\n console.warn(`[@wcstack/state] ${text(M.NamingLimit, [limit])}`);\n }\n return;\n }\n named.add(el);\n ledger.assigned++;\n style.setProperty(\"view-transition-name\", `wcs-${kind}-${++ledger.counter}`);\n style.setProperty(\"view-transition-class\", `wcs-${kind}`);\n}\n","import { rowAt, type Engine } from \"../engine\";\nimport type { Pattern } from \"../pattern\";\nimport type { StateList, StateRow } from \"../list\";\nimport { pipe, type FilterFn } from \"./filters\";\nimport { isHtmlSink, trustHtml } from \"../trustedTypes\";\nimport { autoNaming, nameBlock } from \"./naming\";\nimport { raise, M } from \"../messages\";\nimport { hooks } from \"../hooks\";\n\n/**\n * `on*:` bindings of bubbling events are delegated: one listener per event type on the root\n * (so `event.currentTarget` is the root — decided 2026-09-25), which runs the handlers of the\n * elements the event passed, innermost first. Inside a block the handler is not attached to the\n * element at all: the block's top node carries the block, which finds its handlers from its plan\n * when an event passes (Block.dispatch). Outside any block (a root-level element), where a\n * block's content can shift before the element (see compilePlan), and on a custom element, the\n * handler is stored on the element. A custom element may dispatch such an event without bubbling\n * (the root never hears it): that one is heard on the element. A non-bubbling event type gets a\n * listener on the element itself.\n *\n * `on*#direct:` is not delegated: a listener on the element itself, as 3.x (`currentTarget` is the\n * element) — `#stop` stops the page's own listeners on its ancestors, an ancestor's\n * `stopPropagation()` does not keep it from running, and an element moved under another root still\n * runs it. In a block (a row, a branch) it is attached with the block and removed when the block\n * goes. It runs where the DOM puts it: an outer `#direct` runs before the delegated handlers inside\n * it (they run at the root), so an inner `#stop` stops it only if the inner one is `#direct` too.\n */\nexport function attachEvent(engine: Engine, node: Node, s: Spec, row: StateRow | null, block: Block | null): void {\n const fn = s.listener!;\n const h = (e: Event): void => fn(e, row);\n if (s.delegated) {\n const key = engine.delegate(s.name);\n const prev = (node as any)[key];\n // two of one type on one element (`onclick: a; onclick: b`): both run\n (node as any)[key] = prev === undefined ? h : (e: Event): void => {\n prev(e);\n h(e);\n };\n if (s.custom) node.addEventListener(s.name, (e) => e.bubbles || h(e));\n } else {\n node.addEventListener(s.name, h);\n if (s.direct && block !== null) (block.cleanups ??= []).push(() => node.removeEventListener(s.name, h));\n }\n}\n\n/** Events that bubble: the only ones a delegated listener can see. */\nexport const BUBBLING = new Set([\"click\", \"dblclick\", \"input\", \"change\", \"submit\", \"keydown\", \"keyup\", \"mousedown\", \"mouseup\", \"pointerdown\", \"pointerup\"]);\n\nimport { attachCommand, attachEventToken, attachProperty, attachSpread, whenDefined, type Bindable } from \"./wc\";\n\nexport const K_TEXT = 0;\nexport const K_PROP = 1;\nexport const K_CLASS = 2;\nexport const K_ATTR = 3;\nexport const K_STYLE = 4;\nexport const K_EVENT = 5;\nexport const K_FOR = 6;\nexport const K_IF = 7;\nexport const K_HTML = 8;\nexport const K_RADIO = 9;\nexport const K_CHECKBOX = 10;\n/** A property of a custom element (direction and authority from its wc-bindable declaration). */\nexport const K_CUSTOM = 11;\nexport const K_COMMAND = 12;\nexport const K_EVTTOKEN = 13;\nexport const K_SPREAD = 14;\n\n\nexport interface BranchSpec {\n /** Index into the plan's node paths: the anchor this branch renders before. */\n node: number;\n plan: RowPlan;\n /** null for `else:`. */\n pattern: Pattern | null;\n filters: FilterFn[] | null;\n}\n\nexport interface Spec {\n /** Index into the plan's node paths (unused at the root). */\n node: number;\n kind: number;\n /** Property / class / attribute / style name, or the event type. */\n name: string;\n pattern: Pattern | null;\n filters: FilterFn[] | null;\n /** What the DOM already shows, so the first apply can skip a no-op write. */\n initial: unknown;\n /** Event handler, run for the row of the block the element is in (null outside rows). */\n listener: ((e: Event, row: StateRow | null) => void) | null;\n /** An event binding whose type bubbles: dispatched from the root listener. */\n delegated: boolean;\n /** `on*#direct:`: a listener on the element itself (see attachEvent). */\n direct: boolean;\n /** The row plan of a nested `for`. */\n plan: RowPlan | null;\n /** The branches of an `if` / `elseif` / `else` chain. */\n branches: BranchSpec[] | null;\n /** Input filters (left side), applied to what the element writes back. */\n inFilters: FilterFn[] | null;\n /** The event that writes the element's value back to state (two-way, radio, checkbox), or null. */\n twoWay: string | null;\n /** On a custom element: the binding is resolved when the element's class is defined. */\n custom: boolean;\n /** `#init=` / `#sync=` (binding authority on wc-bindable members). */\n init: string | null;\n sync: string | null;\n /** `#ro`: the element never writes back. */\n ro: boolean;\n prevent: boolean;\n stop: boolean;\n /** The path a command / event token binding names: `$command.<token>` / the event token's name. */\n token: string | null;\n /** Spread: members bound explicitly after it on the same element (last wins). */\n exclude: string[] | null;\n /**\n * In a row plan: the index of this binding among the row's slots (-1 = a Binding object is\n * built with the row). A slot binding reads its own row and needs nothing from the element,\n * so the row keeps only its node and value until a change reaches it.\n */\n slot: number;\n}\n\nexport interface RowPlan {\n fragment: DocumentFragment;\n /** The single top-level node (when `single`), cloned directly instead of the fragment. */\n root: Node | null;\n /** Reused per block creation (nodes are handed to bindings before the next block). */\n scratch: Node[];\n /** The child-index path of every bound node (from the fragment). */\n nodePaths: number[][];\n /** The node paths a block resolves when it is built (the others serve only delegated events). */\n build: number[];\n /** The delegated event specs found through the block (by their node paths) when an event passes. */\n events: Spec[];\n /** The specs bound as a block is built (all but `events`). */\n specs: Spec[];\n /** The block renders exactly one top-level node. */\n single: boolean;\n /** Some spec builds a nested view (for / if): the scratch nodes must be copied first. */\n nested: boolean;\n /** The slot specs of a row plan, by slot index (empty for a branch plan). */\n lazy: Spec[];\n}\n\n/**\n * A binding's type as the parser classifies it (@wcstack/state 3.x reports the same in\n * `$errorCallback`'s info, the console and DevTools): `class.` / `attr.` / `style.` / `command.`\n * and HTML are properties, `eventToken.` is an event.\n */\nconst TYPE_NAMES = [\"text\", \"prop\", \"prop\", \"prop\", \"prop\", \"event\", \"for\", \"if\", \"prop\", \"radio\", \"checkbox\", \"prop\", \"prop\", \"event\", \"spread\"];\n\n/** A binding refused as it is attached fails alone (reported as its own failure). */\nexport const failSpec = (engine: Engine, error: unknown, s: Spec, node: Node): void =>\n engine.failAt(error, s.pattern?.path ?? s.token!, node, TYPE_NAMES[s.kind]);\n\n/** A binding's first value when #init= leaves the element as it is: its first apply only records the value. */\nconst HOLD: unique symbol = Symbol() as never;\n\n/**\n * The first value of a binding on an element with no wc-bindable declaration. `#init=none` and\n * `element`, and `auto` over an undefined state value, leave the element as it is (3.3): the\n * value is still read (a getter must be, for a change to reach it) and applied from the next change.\n */\nexport function initialOf(engine: Engine, s: Spec, row: StateRow | null): unknown {\n const init = s.init;\n return init === null || init === \"state\" || (init === \"auto\" && engine.readUntracked(s.pattern!, row) !== undefined) ? s.initial : HOLD;\n}\n\nexport class Binding {\n queued = false;\n declare readonly engine: Engine;\n declare readonly kind: number;\n declare readonly node: Node;\n declare readonly name: string;\n declare readonly pattern: Pattern;\n /** Row at pattern.depth (null for a root-level pattern). */\n declare readonly row: StateRow | null;\n /** The block that renders this binding (null at the root). */\n declare readonly owner: Block | null;\n declare readonly filters: FilterFn[] | null;\n /** Input filters for the value the element writes back. */\n inFilters: FilterFn[] | null = null;\n /** The `if` chain an `if`/`elseif` condition drives. */\n declare readonly chain: IfView | null;\n declare value: unknown;\n /** Set while state writes the element (an event it fires synchronously is our own echo). */\n applying = false;\n\n constructor(engine: Engine, kind: number, node: Node, name: string, pattern: Pattern,\n row: StateRow | null, owner: Block | null, filters: FilterFn[] | null, initial: unknown, chain: IfView | null = null) {\n this.engine = engine;\n this.kind = kind;\n this.node = node;\n this.name = name;\n this.pattern = pattern;\n this.row = row;\n this.owner = owner;\n this.filters = filters;\n this.value = initial;\n this.chain = chain;\n }\n\n typeName(): string {\n return TYPE_NAMES[this.kind];\n }\n\n apply(): void {\n if (this.chain !== null) {\n this.chain.update();\n return;\n }\n const v = pipe(this.filters, this.engine.read(this.pattern, this.row));\n // the same object may have changed in place ($postUpdate, an array assigned again): shown\n // again — but an element input keeps the object it already has, and an HTML sink the markup it\n // parsed (a TrustedHTML does not change: parsing it again would rebuild the nodes). A radio is\n // set again: checking another one of its group unchecked it.\n if (v === this.value && this.kind !== K_RADIO && (typeof v !== \"object\" || v === null || this.kind === K_CUSTOM || this.kind === K_HTML || isHtmlSink(this.name))) return;\n if (this.value === HOLD) {\n this.value = v;\n return;\n }\n const n = this.node as any;\n if (this.kind === K_CUSTOM) {\n if (v === undefined) {\n // an element input keeps its own value when state has no opinion (B8)\n this.value = v;\n return;\n }\n this.value = v;\n this.applying = true;\n try {\n if (n[this.name] !== v) n[this.name] = v;\n } finally {\n this.applying = false;\n }\n return;\n }\n if (this.kind === K_RADIO) n.checked = v !== undefined && this.elementValue() === v;\n else if (this.kind === K_CHECKBOX) n.checked = Array.isArray(v) && v.includes(this.elementValue());\n else applyTo(this.kind, n, this.name, v);\n this.value = v;\n }\n\n /** The element's own value (radio / checkbox), through the input filters. */\n elementValue(): unknown {\n return pipe(this.inFilters, (this.node as any).value);\n }\n\n /** Writes the element's value back to state (two-way, radio, checkbox). */\n writeBack(): void {\n const n = this.node as any;\n const engine = this.engine;\n let v: unknown;\n if (this.kind === K_RADIO) {\n if (!n.checked) return;\n v = this.elementValue();\n } else if (this.kind === K_CHECKBOX) {\n const e = this.elementValue();\n const cur = engine.readUntracked(this.pattern, this.row);\n const arr = Array.isArray(cur) ? cur : [];\n const has = arr.includes(e);\n // checked and listed, or neither: nothing to write\n if (n.checked ? has : !has) return;\n v = has ? arr.filter((x) => x !== e) : [...arr, e];\n } else {\n v = pipe(this.inFilters, n[this.name]);\n // the element shows its own value now, not the last applied one: the next apply runs (NaN\n // equals nothing) — a write in the same drain may put that value back (a reset, a validation)\n this.value = NaN;\n }\n engine.write(this.pattern, this.row, v, false, true);\n }\n}\n\n/** A property that is the element's content (its children are a value). */\nexport const isContent = (name: string): boolean => name === \"textContent\" || name === \"innerText\" || name === \"innerHTML\";\n\n/**\n * Writes `v` to the element: the kinds that need nothing but the node and the name (the\n * ones a row slot can hold).\n */\nexport function applyTo(kind: number, n: any, name: string, v: unknown): void {\n switch (kind) {\n case K_TEXT:\n n.data = v == null ? \"\" : String(v);\n return;\n case K_PROP:\n // display surfaces: undefined and null both mean \"no value\" (B8); other properties are element inputs\n if (isContent(name)) {\n // a string, as a browser's setter makes it (happy-dom — the server's DOM — writes 0 as \"\", and\n // throws on a number for innerText); innerHTML keeps a TrustedHTML as it is\n n[name] = name === \"innerHTML\" ? trustHtml(v) : v == null ? \"\" : String(v);\n } else if (isHtmlSink(name)) {\n // srcdoc without a value: the attribute goes (the frame shows its src again, as attr.srcdoc:\n // did); outerHTML: undefined writes nothing (\"\" would take the element itself out)\n if (v == null && name === \"srcdoc\") n.removeAttribute(name);\n else if (v !== undefined) n[name] = trustHtml(v);\n } else if (v !== undefined) {\n // undefined: an element input keeps its own value when state has no opinion (B8);\n // never re-write what the element already shows (keeps the caret while typing)\n if (n[name] !== v && !(name === \"value\" && n.value === String(v))) n[name] = v;\n // a select's value may name an option not rendered yet: kept for reselect\n if ((name === \"value\" || name === \"selectedIndex\") && n.localName === \"select\") n[SELECTED] = [name, v];\n }\n return;\n case K_HTML:\n n.innerHTML = trustHtml(v);\n return;\n case K_CLASS:\n if (v != null && typeof v !== \"boolean\") {\n raise(M.ClassNeedsBoolean, [name, typeof v]);\n }\n n.classList.toggle(name, v === true);\n return;\n case K_ATTR:\n if (v == null) n.removeAttribute(name);\n else n.setAttribute(name, String(v));\n return;\n case K_STYLE:\n // the property as CSS writes it (background-color, --gap), or as the DOM does\n // (backgroundColor, which setProperty ignores; 3.x wrote style[name])\n if (!name.includes(\"-\")) n.style[name] = v == null ? \"\" : String(v);\n else if (v == null) n.style.removeProperty(name);\n else n.style.setProperty(name, String(v));\n return;\n }\n}\n\n/** A select's last bound `value` / `selectedIndex`: [name, value]. */\nconst SELECTED: unique symbol = Symbol() as never;\n\n/**\n * A view rendered options into `parent`: the select's bound value is applied again. A block binds\n * its plan in document order, so a select's value there comes before the options a `for` inside\n * it renders, and names none of them; so does a value applied before a later change renders more\n * options (3.3 applies it after the options). (On the page a select's children are bound first.)\n */\nfunction reselect(parent: Node): void {\n const sel: any = (parent as Element).localName === \"optgroup\" ? parent.parentNode : parent;\n const r = sel?.[SELECTED];\n if (r !== undefined) sel[r[0]] = r[1];\n}\n\n/**\n * One rendering of a plan: a list row (RowView) or the content of an `if` branch.\n * It owns its nodes, its bindings and the structural views nested in it.\n */\nexport class Block {\n alive = true;\n /** The row this block renders in (its own row for a RowView; the enclosing row, or null, for an if branch). */\n declare readonly row: StateRow | null;\n declare readonly first: ChildNode;\n /** All top-level nodes when the plan renders more than one. */\n declare readonly nodes: ChildNode[] | null;\n /** The Binding objects built with this block, unregistered when it goes (allocated on first use). */\n bindings: Binding[] | null = null;\n children: (ForView | IfView)[] | null = null;\n /** Run when the block goes away (token unsubscriptions); allocated on first use. */\n cleanups: (() => void)[] | null = null;\n /** The view anchored at the block's first top-level node: it renders before the block's first node. */\n lead: ForView | IfView | null = null;\n declare readonly plan: RowPlan;\n\n constructor(row: StateRow | null, first: ChildNode, nodes: ChildNode[] | null, plan: RowPlan) {\n this.row = row;\n this.first = first;\n this.nodes = nodes;\n this.plan = plan;\n }\n\n /**\n * An event of `type` reached this block's top node: runs the handlers of the block's\n * elements it passed, innermost first. Returns true when one of them stopped it.\n */\n dispatch(type: string, e: Event): boolean {\n const target = e.target as Node;\n const plan = this.plan;\n // the specs are in document order (an element's own together): the elements the event passed\n // are met outermost first, so each one's handlers go in front — innermost first\n const hits: Spec[][] = [];\n let last: Node | null = null;\n for (const s of plan.events) {\n if (s.name !== type) continue;\n const path = plan.nodePaths[s.node];\n const n = nodeAt(this.nodes === null ? this.first : this.nodes[path[0]], path, 1);\n if (!n.contains(target)) continue;\n if (n !== last) hits.unshift([]);\n hits[0].push(s);\n last = n;\n }\n // stopPropagation stops the elements further out, not the rest of the same element's (as the DOM)\n for (const own of hits) {\n for (const s of own) s.listener!(e, this.row);\n if (e.cancelBubble) return true;\n }\n return false;\n }\n\n get last(): ChildNode {\n return this.nodes === null ? this.first : this.nodes[this.nodes.length - 1];\n }\n\n /**\n * The block's first node. A view nested at the block's top level renders before its anchor, so\n * the block spans from here to its last top-level node, the rows and branches of those views\n * included.\n */\n head(): ChildNode {\n const v = this.lead;\n return (v === null ? null : v.headAt(this.first)) ?? this.first;\n }\n\n insertBefore(parent: Node, ref: Node | null): void {\n const last = this.last;\n for (let n = this.head(); ; ) {\n const next = n.nextSibling!;\n parent.insertBefore(n, ref);\n if (n === last) return;\n n = next;\n }\n }\n\n removeNodes(): void {\n if (this.nodes === null) this.first.remove();\n else removeContiguous(this.head(), this.last);\n }\n\n /** Stops the block: runs its cleanups, unregisters its bindings, disposes the views nested in it. */\n dispose(engine: Engine): void {\n this.alive = false;\n if (this.cleanups !== null) for (const c of this.cleanups) c();\n const bs = this.bindings;\n if (bs !== null) for (let i = 0; i < bs.length; i++) engine.unregister(bs[i]);\n if (this.children !== null) for (const c of this.children) c.dispose();\n }\n}\n\n/**\n * The rendering of one row by one for view. Its slot bindings (plan.lazy) are kept as\n * node / value pairs and become Binding objects only when a change first reaches them:\n * creating a row allocates no Binding for them and registers nothing — a change of the\n * row finds them through the row's views (Engine.enqueueBound).\n */\nexport class RowView extends Block {\n /** Position in the view's previous order (set during an update). */\n pos = 0;\n /** [node0, value0, node1, value1, …] by slot; the value is the last one applied. */\n declare readonly slots: unknown[] | null;\n /** The Binding objects the slots became (sparse, allocated on first use). */\n bound: (Binding | undefined)[] | null = null;\n\n constructor(row: StateRow, first: ChildNode, nodes: ChildNode[] | null, plan: RowPlan) {\n super(row, first, nodes, plan);\n this.slots = plan.lazy.length === 0 ? null : new Array(plan.lazy.length * 2);\n }\n\n /** The Binding object of slot k (built on first use; from then on it holds the value). */\n slotBinding(engine: Engine, k: number): Binding {\n const bound = (this.bound ??= new Array(this.plan.lazy.length));\n let b = bound[k];\n if (b === undefined) {\n const s = this.plan.lazy[k];\n const slots = this.slots!;\n b = bound[k] = new Binding(engine, s.kind, slots[2 * k] as Node, s.name, s.pattern!, this.row, this, s.filters, slots[2 * k + 1]);\n }\n return b;\n }\n\n /** Queues the slot bindings on `p` or under it. */\n enqueueSlots(engine: Engine, p: Pattern): void {\n const lazy = this.plan.lazy;\n for (let k = 0; k < lazy.length; k++) if (lazy[k].pattern!.isUnder(p)) engine.enqueue(this.slotBinding(engine, k));\n }\n\n override dispose(engine: Engine): void {\n const row = this.row!;\n if (row.view === this) row.view = null;\n super.dispose(engine);\n }\n}\n\n/**\n * The list whose rows `p` ranges over, in the context of `row`. A path that fails to read\n * (a missing top-level key) is reported as the `for` binding's failure and the list starts\n * empty: it was created before the read, so a later write of the path fills it.\n */\nexport function listFor(engine: Engine, p: Pattern, row: StateRow | null, anchor: Node): StateList {\n const parent = rowAt(row, p.depth);\n try {\n return engine.childList(parent, p);\n } catch (error) {\n engine.failAt(error, p.path, anchor, \"for\");\n return parent === null ? engine.rootLists.get(p)! : parent.children!.get(p)!;\n }\n}\n\n/**\n * Records `b` in its block (unregistered when the block goes) and, unless it only carries\n * element → state, registers it where a change of its location finds it.\n */\nexport function adopt(engine: Engine, b: Binding, register: boolean): void {\n if (register) engine.register(b);\n const owner = b.owner;\n if (owner !== null) (owner.bindings ??= []).push(b);\n}\n\n/** The block built by the last buildBlock call (taken right after it; saves an allocation per row). */\nlet lastBlock: Block | null = null;\n\n/** The block the last buildBlock call built; released here so a removed tree is not kept alive. */\nfunction takeBlock(): Block {\n const b = lastBlock!;\n lastBlock = null;\n return b;\n}\n\n/** The auto-naming cap for the blocks being built (-1: none), read once per view update. */\nlet naming = -1;\n\n/**\n * Clones the plan in the context of `row`, binds it and applies the initial values\n * (off-document). `fv`: the for view the block is a row of (null for an if branch).\n * Returns the node to insert: the block's element, or a fragment of its nodes.\n */\nexport function buildBlock(engine: Engine, plan: RowPlan, row: StateRow | null, fv: ForView | null, at: Node | null = null): Node {\n const paths = plan.nodePaths;\n const build = plan.build;\n const nodes = plan.scratch;\n let first: ChildNode;\n let all: ChildNode[] | null = null;\n // SSR hydration: the server's nodes, where they are (the add-on put the plan's nodes in them in\n // `nodes`); the view then inserts an empty fragment\n const adopted = hooks.adopt?.(plan, fv === null ? at! : fv.anchor, fv !== null);\n const single = !adopted && plan.single;\n // a single plan clones the block's element itself; paths start at the fragment, so skip their first step\n const top = adopted ? document.createDocumentFragment() : (single ? plan.root! : plan.fragment).cloneNode(true);\n if (!adopted) for (let b = 0; b < build.length; b++) {\n const i = build[b];\n nodes[i] = nodeAt(top, paths[i], single ? 1 : 0);\n }\n if (single) {\n first = top as ChildNode;\n } else {\n all = adopted || [...top.childNodes] as ChildNode[];\n first = all[0];\n }\n let block: Block;\n let rv: RowView | null = null;\n if (fv !== null) {\n block = rv = new RowView(row!, first, all, plan);\n if (fv.map === null) row!.view = rv;\n else fv.map.set(row!, rv);\n } else {\n block = new Block(row, first, all, plan);\n }\n if (naming >= 0) nameBlock(first, all, fv !== null ? \"row\" : \"branch\", naming);\n if (plan.events.length > 0) {\n // delegated events find the block through its top node(s)\n const key = engine.blockKey;\n if (all === null) (first as any)[key] = block;\n else for (const n of all) if (n.nodeType === 1) (n as any)[key] = block;\n }\n const specs = plan.specs;\n const rendered = engine.rendered;\n // the scratch array is ours until a nested view builds a block of another plan: take\n // every node we need before that can happen\n const own = plan.nested ? nodes.slice(0, paths.length) : nodes;\n const slots = rv === null ? null : rv.slots;\n if (slots !== null) {\n // every slot has its node before anything runs: an element bound earlier in the row can\n // write state (wc-bindable seeding) and so reach a slot further on\n const lazy = plan.lazy;\n for (let k = 0; k < lazy.length; k++) {\n slots[2 * k] = own[lazy[k].node];\n slots[2 * k + 1] = lazy[k].initial;\n }\n }\n for (let i = 0; i < specs.length; i++) {\n const s = specs[i];\n const node = own[s.node];\n const k = s.slot;\n if (k >= 0 && slots !== null) {\n // a slot: the node and the value are all the row keeps\n const b = rv!.bound?.[k];\n if (b !== undefined) {\n // already reached by a change during this build: it is a Binding now, applied here (and\n // so no longer queued: the drain skips it)\n b.queued = false;\n engine.applyBinding(b);\n continue;\n }\n try {\n const v = pipe(s.filters, engine.read(s.pattern!, row));\n if (v !== s.initial) {\n applyTo(s.kind, node, s.name, v);\n slots[2 * k + 1] = v;\n }\n if (rendered !== null) engine.noteRendered(s.pattern!, row);\n } catch (error) {\n engine.fail(error, rv!.slotBinding(engine, k));\n }\n continue;\n }\n switch (s.kind) {\n case K_FOR: {\n const view = new ForView(engine, s.plan!, listFor(engine, s.pattern!, row, node), node as Comment);\n (block.children ??= []).push(view);\n if (node === first) block.lead = view;\n view.update();\n break;\n }\n case K_IF: {\n const iv = attachChain(engine, s.branches!.map((br) => ({ plan: br.plan, pattern: br.pattern, filters: br.filters, anchor: own[br.node] })), row, block);\n (block.children ??= []).push(iv);\n if (node === first) block.lead = iv;\n break;\n }\n default:\n // (the delegated events found through the block are not among the specs: nothing per row)\n // A binding refused as it is attached (an undeclared token or member, a failing `#init=auto`\n // read) fails alone: the row is still built whole, so its view's records stay right\n try {\n attachSpec(engine, s, node, row, block);\n } catch (error) {\n failSpec(engine, error, s, node);\n }\n }\n }\n lastBlock = block;\n return top;\n}\n\n/**\n * Binds a spec that builds no view to `node`, in `block` (null: a root-level element). A\n * delegated event that reaches here is stored on the element (attachEvent).\n */\nexport function attachSpec(engine: Engine, s: Spec, node: Node, row: StateRow | null, block: Block | null): void {\n const el = node as Element;\n switch (s.kind) {\n case K_EVENT:\n attachEvent(engine, node, s, row, block);\n return;\n case K_COMMAND:\n whenDefined(engine, s, el, block, (bd) => attachCommand(engine, s, el, block, bd));\n return;\n case K_EVTTOKEN:\n whenDefined(engine, s, el, block, (bd) => attachEventToken(engine, s, el, row, bd));\n return;\n }\n const p = s.pattern!;\n const brow = rowAt(row, p.depth);\n if (s.kind === K_SPREAD) {\n whenDefined(engine, s, el, block, (bd) => attachSpread(engine, s, el, brow, block, bd));\n return;\n }\n if (s.custom && s.kind === K_PROP) {\n whenDefined(engine, s, el, block, (bd) => attachCustomOrPlain(engine, s, el, brow, block, bd));\n return;\n }\n const b = new Binding(engine, s.kind, node, s.name, p, brow, block, s.filters, initialOf(engine, s, brow));\n b.inFilters = s.inFilters;\n adopt(engine, b, true);\n engine.applyBinding(b);\n if (s.twoWay !== null) node.addEventListener(s.twoWay, () => b.writeBack());\n}\n\n/** A property binding on a custom element: wc-bindable members get direction and authority, others are plain. */\nexport function attachCustomOrPlain(engine: Engine, s: Spec, el: Element, row: StateRow | null, owner: Block | null, bd: Bindable | null): void {\n if (bd !== null) {\n attachProperty(engine, s, el, s.name, s.pattern!, row, owner, bd);\n return;\n }\n const b = new Binding(engine, K_PROP, el, s.name, s.pattern!, row, owner, s.filters, initialOf(engine, s, row));\n b.inFilters = s.inFilters;\n if (hooks.hostBinding?.(b, s.ro)) return;\n adopt(engine, b, true);\n engine.applyBinding(b);\n}\n\nexport interface Branch {\n plan: RowPlan;\n pattern: Pattern | null;\n filters: FilterFn[] | null;\n anchor: Node;\n}\n\n/**\n * Builds an `if` chain: one condition binding per `if`/`elseif` (each drives the whole\n * chain) and the initial render. `owner` is the enclosing block (null at the root).\n */\nexport function attachChain(engine: Engine, branches: Branch[], row: StateRow | null, owner: Block | null): IfView {\n const iv = new IfView(engine, branches, row);\n let first: Binding | null = null;\n for (const br of branches) {\n if (br.pattern === null) continue;\n const p = br.pattern;\n const b = new Binding(engine, K_IF, br.anchor, \"if\", p, rowAt(row, p.depth), owner, null, undefined, iv);\n adopt(engine, b, true);\n if (owner === null) iv.rootBindings.push(b);\n first ??= b;\n }\n // the first branch is the `if:`: it always has a condition\n engine.applyBinding(first!);\n return iv;\n}\n\nexport class IfView {\n alive = true;\n current: Block | null = null;\n index = -1;\n /** Condition bindings of a root-level chain (a nested chain's belong to its block). */\n readonly rootBindings: Binding[] = [];\n declare readonly engine: Engine;\n declare readonly branches: Branch[];\n declare readonly row: StateRow | null;\n\n constructor(engine: Engine, branches: Branch[], row: StateRow | null) {\n this.engine = engine;\n this.branches = branches;\n this.row = row;\n }\n\n /** The first node this chain renders before anchor `n` (the shown branch's, if `n` is its anchor). */\n headAt(n: Node): ChildNode | null {\n return this.current !== null && this.branches[this.index].anchor === n ? this.current.head() : null;\n }\n\n /** Renders the first branch whose condition holds (JavaScript truthiness), or nothing. */\n update(): void {\n const engine = this.engine;\n let index = -1;\n for (let i = 0; i < this.branches.length; i++) {\n const br = this.branches[i];\n // `else:` (no condition) always holds\n if (br.pattern === null || pipe(br.filters, engine.read(br.pattern, rowAt(this.row, br.pattern.depth)))) {\n index = i;\n break;\n }\n }\n if (index === this.index) return;\n naming = autoNaming();\n if (this.current !== null) {\n this.current.removeNodes();\n this.current.dispose(engine);\n this.current = null;\n }\n this.index = index;\n if (index >= 0) {\n const br = this.branches[index];\n const top = buildBlock(engine, br.plan, this.row, null, br.anchor);\n this.current = takeBlock();\n const parent = br.anchor.parentNode!;\n parent.insertBefore(top, br.anchor);\n reselect(parent);\n }\n }\n\n dispose(): void {\n this.alive = false;\n for (const b of this.rootBindings) this.engine.unregister(b);\n if (this.current !== null) this.current.dispose(this.engine);\n }\n}\n\nexport class ForView {\n alive = true;\n rowViews: RowView[] = [];\n declare readonly engine: Engine;\n declare readonly plan: RowPlan;\n declare readonly list: StateList;\n declare readonly anchor: Comment;\n /**\n * The row views by row when another for view already renders this list (the list's first\n * view keeps them on row.view instead).\n */\n declare readonly map: Map<StateRow, RowView> | null;\n\n constructor(engine: Engine, plan: RowPlan, list: StateList, anchor: Comment) {\n this.engine = engine;\n this.plan = plan;\n this.list = list;\n this.anchor = anchor;\n if (list.view === null) {\n list.view = this;\n this.map = null;\n } else {\n (list.extra ??= []).push(this);\n this.map = new Map();\n }\n }\n\n /** The first node this view renders (before its anchor), or null with no rows. */\n headAt(_n: Node): ChildNode | null {\n return this.rowViews.length === 0 ? null : this.rowViews[0].head();\n }\n\n /** This view's rendering of `row`, or null. */\n viewOf(row: StateRow): RowView | null {\n return this.map === null ? row.view : this.map.get(row) ?? null;\n }\n\n private drop(rv: RowView): void {\n const map = this.map;\n if (map !== null && map.get(rv.row!) === rv) map.delete(rv.row!);\n rv.dispose(this.engine);\n }\n\n /** Brings the DOM in line with list.rows, moving kept rows as little as possible. */\n update(): void {\n const engine = this.engine;\n const rows = this.list.rows;\n const old = this.rowViews;\n naming = autoNaming();\n const n = rows.length;\n const o = old.length;\n const anchor = this.anchor;\n const parent = anchor.parentNode!;\n\n if (n === 0) {\n if (o > 0) {\n const first = old[0].head();\n const last = old[o - 1].last;\n // the rows are all the parent holds but the anchor and text (a <tbody> of rows, its whitespace):\n // one call empties it and puts those back — faster than a Range in Chromium (10,000 rows: 14 %; node\n // by node is 5 % slower than one) and linear in happy-dom. An element beside them would be put back\n // too (a custom element reconnected, an iframe reloaded): then node by node\n let keep: Node[] | null = [];\n for (let x = parent.firstChild; x !== null; x = x === first ? last.nextSibling : x.nextSibling) {\n if (x === first) continue;\n if (x !== anchor && x.nodeType !== 3) {\n keep = null;\n break;\n }\n keep.push(x);\n }\n if (keep !== null) parent.replaceChildren(...keep);\n else removeContiguous(first, last);\n for (let i = 0; i < o; i++) this.drop(old[i]);\n }\n this.rowViews = [];\n return;\n }\n\n const views: RowView[] = new Array(n);\n let s = 0;\n while (s < n && s < o && this.viewOf(rows[s]) === old[s]) {\n views[s] = old[s];\n s++;\n }\n let oe = o - 1;\n let ne = n - 1;\n while (oe >= s && ne >= s && this.viewOf(rows[ne]) === old[oe]) {\n views[ne] = old[oe];\n oe--;\n ne--;\n }\n for (let i = s; i <= oe; i++) {\n const rv = old[i];\n const row = rv.row!;\n if (!row.alive || this.viewOf(row) !== rv) {\n rv.removeNodes();\n this.drop(rv);\n } else {\n rv.pos = i;\n }\n }\n if (s <= ne) {\n const m = ne - s + 1;\n const src = new Int32Array(m);\n let anyKept = false;\n // no rows before: none kept (the first render builds every row)\n if (o > 0) for (let i = 0; i < m; i++) {\n const rv = this.viewOf(rows[s + i]);\n if (rv !== null && rv.alive) {\n src[i] = rv.pos;\n anyKept = true;\n } else {\n src[i] = -1;\n }\n }\n const next0: Node = ne + 1 < n ? views[ne + 1].head() : anchor;\n if (!anyKept) {\n const frag = document.createDocumentFragment();\n for (let i = s; i <= ne; i++) {\n frag.appendChild(buildBlock(engine, this.plan, rows[i], this));\n views[i] = takeBlock() as RowView;\n }\n parent.insertBefore(frag, next0);\n } else {\n const keep = lisKeep(src);\n let next: Node = next0;\n for (let i = m - 1; i >= 0; i--) {\n const row = rows[s + i];\n let rv = this.viewOf(row);\n if (rv === null || !rv.alive) {\n parent.insertBefore(buildBlock(engine, this.plan, row, this), next);\n rv = takeBlock() as RowView;\n } else if (keep[i] === 0) {\n rv.insertBefore(parent, next);\n }\n views[s + i] = rv;\n next = rv.head();\n }\n }\n }\n this.rowViews = views;\n reselect(parent);\n }\n\n dispose(): void {\n this.alive = false;\n const list = this.list;\n if (list.view === this) {\n list.view = null;\n } else if (list.extra !== null) {\n const i = list.extra.indexOf(this);\n if (i >= 0) list.extra.splice(i, 1);\n if (list.extra.length === 0) list.extra = null;\n }\n for (const rv of this.rowViews) rv.dispose(this.engine);\n this.map?.clear();\n }\n}\n\n/** The node `path` leads to from `n`, following its steps from `j` on. */\nfunction nodeAt(n: Node, path: number[], j: number): Node {\n for (; j < path.length; j++) {\n n = n.firstChild!;\n for (let k = path[j]; k > 0; k--) n = n.nextSibling!;\n }\n return n;\n}\n\nfunction removeContiguous(first: ChildNode, last: ChildNode): void {\n // node by node, not a Range's deleteContents(): happy-dom's (the DOM of @wcstack/testing and of SSR)\n // is quadratic — a list of 1,000 rows took 13 s to empty\n for (let n = first, next; n !== last; n = next) {\n next = n.nextSibling!;\n n.remove();\n }\n last.remove();\n}\n\n/** Marks the entries (>= 0) that form a longest increasing subsequence of `src`. */\nexport function lisKeep(src: Int32Array): Uint8Array {\n const n = src.length;\n const keep = new Uint8Array(n);\n const prev = new Int32Array(n).fill(-1);\n const tails: number[] = [];\n for (let i = 0; i < n; i++) {\n const v = src[i];\n if (v < 0) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (src[tails[mid]] < v) lo = mid + 1;\n else hi = mid;\n }\n if (lo > 0) prev[i] = tails[lo - 1];\n tails[lo] = i;\n }\n let k = tails.length > 0 ? tails[tails.length - 1] : -1;\n while (k >= 0) {\n keep[k] = 1;\n k = prev[k];\n }\n return keep;\n}\n","/**\n * Wiring to custom elements that declare the wc-bindable protocol:\n * static wcBindable = { protocol: \"wc-bindable\", version: 1,\n * properties: [{ name, event, getter?, semantics? }], // element → state\n * inputs: [{ name, attribute? }], // state → element\n * commands: [{ name, async? }] } // state invokes\n * Property bindings take their direction and initial authority from the declaration;\n * `command.<m>:` subscribes a method to a command token; `eventToken.<p>:` fires an event\n * token when the element dispatches that property's event; `...:` spreads a state object\n * over every declared property and input.\n */\nimport type { Engine } from \"../engine\";\nimport { raise, M } from \"../messages\";\nimport { hooks } from \"../hooks\";\nimport type { StateRow } from \"../list\";\nimport { adopt, Binding, failSpec, K_CUSTOM, type Block, type Spec } from \"./view\";\nimport { pipe } from \"./filters\";\n// (view.ts imports this module too: the cycle is fine, everything here is used at call time)\n\ninterface PropertyDecl {\n event: string;\n getter: ((e: Event) => unknown) | null;\n /** `semantics: \"event\"`: an occurrence, written even when equal to the current value. */\n occurrence: boolean;\n}\n\nexport interface Bindable {\n properties: Map<string, PropertyDecl>;\n /** The settable members. Their `attribute` hint is not used: the element reflects its own attributes. */\n inputs: Set<string>;\n commands: Set<string>;\n}\n\nconst bindableByClass = new WeakMap<CustomElementConstructor, Bindable | null>();\n\n/** The element's wc-bindable declaration (null when it has none), cached per class. */\nexport function readBindable(cls: CustomElementConstructor): Bindable | null {\n if (bindableByClass.has(cls)) return bindableByClass.get(cls)!;\n const decl = (cls as any).wcBindable;\n let out: Bindable | null = null;\n if (decl !== null && typeof decl === \"object\" && decl.protocol === \"wc-bindable\" && Number.isInteger(decl.version) && decl.version >= 1) {\n out = { properties: new Map(), inputs: new Set(), commands: new Set() };\n for (const p of decl.properties ?? []) {\n out.properties.set(p.name, { event: p.event, getter: typeof p.getter === \"function\" ? p.getter : null, occurrence: p.semantics === \"event\" });\n }\n for (const i of decl.inputs ?? []) out.inputs.add(i.name);\n for (const c of decl.commands ?? []) if (c !== null && typeof c === \"object\" && typeof c.name === \"string\") out.commands.add(c.name);\n }\n bindableByClass.set(cls, out);\n return out;\n}\n\n/** The registry that defines `el`: a scoped one (`attachShadow({ customElementRegistry })`) or the global one. */\nexport const registryOf = (el: Element): CustomElementRegistry =>\n ((el as any).customElementRegistry as CustomElementRegistry | null | undefined) ?? customElements;\n\n/**\n * Runs `attach` (for spec `s`) once the element's class is defined (at once when it already is) and\n * upgraded, unless its block went away in the meantime (`pending`). A native element has no definition to wait\n * for: it is attached at once (and refused there, as a custom element with no declaration is).\n */\nexport function whenDefined(engine: Engine, s: Spec, el: Element, owner: Block | null, attach: (bindable: Bindable | null) => void, later = false): void {\n const tag = el.localName;\n if (!tag.includes(\"-\")) return attach(null);\n const r = registryOf(el);\n // a row built in a fragment takes the registry of the shadow root it goes into (a scoped one)\n // when it is placed, in this drain: wait for that before waiting for a definition\n if (!later && !el.isConnected && r.get(tag) === undefined && \"customElementRegistry\" in el) {\n queueMicrotask(() => whenDefined(engine, s, el, owner, attach, true));\n return;\n }\n const run = (): void => {\n const cls = r.get(tag);\n r.upgrade(el);\n attach(cls ? readBindable(cls) : null);\n };\n if (!later && r.get(tag) !== undefined) return run();\n // a row gone while it waited for its registry waits for nothing (its block's cleanups have run)\n if (owner !== null && !owner.alive) return;\n // later, outside any drain: a failure is the binding's; it and what was applied are reported by\n // a drain (one for every element the definition upgrades: one `$renderedCallback`)\n pending(r.whenDefined(tag), owner, () => {\n try {\n run();\n } catch (error) {\n failSpec(engine, error, s, el);\n }\n engine.schedule();\n });\n}\n\n/**\n * Runs `fn` once `p` settles, unless `owner` went away first. Its own scope: the reaction holds\n * only `f`, so a removed row of a tag never defined keeps nothing alive.\n */\nfunction pending(p: Promise<unknown>, owner: Block | null, fn: () => void): void {\n let f: (() => void) | null = fn;\n if (owner !== null) (owner.cleanups ??= []).push(() => {\n f = null;\n });\n void p.then(() => f?.());\n}\n\n/** A property binding on a member of a custom element's wc-bindable declaration. */\nexport function attachProperty(engine: Engine, spec: Spec, el: Element, name: string, pattern = spec.pattern!,\n row: StateRow | null, owner: Block | null, bd: Bindable): Binding {\n const out = bd.properties.get(name) ?? null;\n const input = bd.inputs.has(name);\n // enableDirectionalInitialSync off (3.x opt-out): no member checks (and no init= / sync=, see\n // plan.ts); state wins every initial sync, output-only included\n const directional = engine.directional;\n if (directional && out === null && !input) raise(M.MemberUndeclared, [name]);\n // what the member's shape allows: output-only takes element / none, input-only state / none, two-way any\n const init = spec.init;\n const refused = out === null ? init === \"element\" || init === \"auto\" : !input && (init === \"state\" || init === \"auto\");\n if (refused) raise(M.InitIncompatible, [init, name]);\n if (spec.sync === \"connect\" && out === null) raise(M.SyncConnectNeedsOutput, [name]);\n const outputOnly = directional && out !== null && !input;\n const b = new Binding(engine, K_CUSTOM, el, name, pattern, row, owner, spec.filters, undefined);\n b.inFilters = spec.inFilters;\n // state → element (every member but an output-only one)\n adopt(engine, b, !outputOnly);\n // element → state (a declared property)\n if (out !== null && !spec.ro) {\n el.addEventListener(out.event, (e) => {\n let v: unknown;\n if (out.getter !== null) v = out.getter(e);\n else {\n v = (e as CustomEvent).detail;\n // the protocol's default getter: diagnostics tells the two shapes it can see are wrong\n if (!out.occurrence) hooks.detail?.(el, name, v);\n }\n if (b.applying && Object.is(v, b.value)) return; // our own write echoing back\n v = pipe(b.inFilters, v);\n // the element already shows this value: the apply this write causes must not echo it\n // back to the element it came from\n if (b.filters === null) b.value = v;\n engine.write(b.pattern, b.row, v, out.occurrence, true);\n });\n }\n // initial authority: output-only members seed state from the element, others the other way\n const authority = init ?? (outputOnly ? \"element\" : \"state\");\n if (authority === \"state\") {\n if (!outputOnly) engine.applyBinding(b);\n } else if (authority === \"element\" || authority === \"auto\") {\n const seed = (): void => {\n if (owner !== null && !owner.alive) return;\n if (authority === \"auto\" && engine.readUntracked(b.pattern, b.row) !== undefined) {\n if (!outputOnly) engine.applyBinding(b);\n return;\n }\n const snapshot = (el as any)[name];\n if (b.filters === null) b.value = snapshot; // seeded from the element: nothing to write back\n engine.write(b.pattern, b.row, snapshot, false, true);\n };\n if (spec.sync === \"connect\" && !el.isConnected) void Promise.resolve().then(seed);\n else seed();\n }\n return b;\n}\n\nfunction noBindable(id: M, el: Element, what: string): never {\n raise(id, [el.localName, what]);\n}\n\n/**\n * `command.<method>: $command.<token>` — the element's method subscribes to the token. A native\n * element (no declaration) is called the way the native-commands add-on says, when installed.\n */\nexport function attachCommand(engine: Engine, spec: Spec, el: Element, owner: Block | null, bd: Bindable | null): void {\n const method = spec.name;\n // (the path, \"$command.<token>\")\n const token = engine.command(spec.token!.slice(9));\n const call = bd === null ? hooks.nativeCommand?.(el, method) : null;\n if (!call) {\n if (bd === null) noBindable(M.NoBindable, el, `command.${method}`);\n if (!bd.commands.has(method)) raise(M.NoCommand, [el.localName, method]);\n }\n const ref = new WeakRef(el);\n const fn = (...args: unknown[]): unknown => {\n const target = ref.deref() as any;\n if (target === undefined) {\n unsubscribe();\n return undefined;\n }\n // detached for now (a route hidden with its nodes kept): not called, still subscribed\n return target.isConnected ? (call ? call(target, args) : target[method](...args)) : undefined;\n };\n const unsubscribe = token.subscribe(fn);\n if (owner !== null) (owner.cleanups ??= []).push(unsubscribe);\n}\n\n/** `eventToken.<property>: <token>` — the property's event fires the event token. */\nexport function attachEventToken(engine: Engine, spec: Spec, el: Element, row: StateRow | null, bd: Bindable | null): void {\n const prop = spec.name;\n if (bd === null) noBindable(M.NoBindable, el, `eventToken.${prop}`);\n const decl = bd.properties.get(prop);\n if (decl === undefined) raise(M.NoProperty, [el.localName, prop]);\n const name = spec.token!;\n el.addEventListener(decl.event, (e) => {\n if (spec.prevent) e.preventDefault();\n if (spec.stop) e.stopPropagation();\n try {\n engine.fireEventToken(name, e, row);\n } catch (error) {\n console.error(error);\n }\n });\n}\n\n/** `...: path` — one property binding per declared property and input (explicit bindings win). */\nexport function attachSpread(engine: Engine, spec: Spec, el: Element, row: StateRow | null, owner: Block | null, bd: Bindable | null): void {\n if (bd === null) noBindable(M.SpreadNoBindable, el, `\"...: ${spec.pattern!.path}\"`);\n const names = new Set([...bd.properties.keys(), ...bd.inputs]);\n for (const name of names) {\n if (spec.exclude?.includes(name)) continue;\n const p = engine.pattern(`${spec.pattern!.path}.${name}`);\n const r = p.depth === 0 ? null : row;\n attachProperty(engine, { ...spec, init: null, sync: null }, el, name, p, r, owner, bd);\n }\n}\n","import { INDEX_PARAM, isThenable, type Engine } from \"../engine\";\nimport type { StateRow } from \"../list\";\nimport { UNSET, type Pattern } from \"../pattern\";\nimport { config } from \"../config\";\nimport { parseBindTextForEmbeddedNode, parseBindTextsForElement, type ParsedBinding } from \"../parser/index\";\nimport { buildFilters, type FilterFn } from \"./filters\";\nimport { raise, M } from \"../messages\";\nimport { hooks } from \"../hooks\";\nimport { isHtmlSink } from \"../trustedTypes\";\nimport {\n K_ATTR, K_CHECKBOX, K_CLASS, K_COMMAND, K_EVENT, K_EVTTOKEN, K_FOR, K_HTML, K_IF, K_PROP, K_RADIO, K_SPREAD, K_STYLE, K_TEXT, BUBBLING,\n isContent, type Branch, type BranchSpec, type RowPlan, type Spec,\n} from \"./view\";\n\n/** The binding attribute (`bindAttributeName`, default data-wcs). */\nexport const bindAttr = (): string => config.bindAttributeName;\n\n/** `.label` / `.` inside a `for: data` template → `data.*.label` / `data.*`. */\nexport function expandPath(path: string, list: Pattern | null): string {\n if (path.charCodeAt(0) !== 46 /* . */) return path;\n if (list === null) raise(M.WildcardRelative, [path]);\n return path === \".\" ? `${list.path}.*` : `${list.path}.*${path}`;\n}\n\nfunction blank(): Spec {\n return {\n node: 0, kind: K_PROP, name: \"\", pattern: null, filters: null, initial: UNSET, listener: null, plan: null, branches: null,\n inFilters: null, twoWay: null, custom: false, init: null, sync: null, ro: false, prevent: false, stop: false, token: null, exclude: null,\n slot: -1, delegated: false, direct: false,\n };\n}\n\n/** Native elements whose property flows back to state (custom elements come with wc-bindable). */\nfunction isTwoWay(el: Element, prop: string): boolean {\n const tag = el.localName;\n if (tag === \"input\") {\n const type = (el.getAttribute(\"type\") || \"text\").toLowerCase();\n if (type === \"button\") return false;\n if ((type === \"radio\" || type === \"checkbox\") && prop === \"checked\") return true;\n return prop === \"value\" || prop === \"valueAsNumber\" || prop === \"valueAsDate\";\n }\n return (tag === \"select\" || tag === \"textarea\") && prop === \"value\";\n}\n\ninterface Flags {\n ro: boolean;\n prevent: boolean;\n stop: boolean;\n /** `#onchange` → \"change\": the event that writes back instead of the default. */\n event: string | null;\n init: string | null;\n sync: string | null;\n}\n\nconst INITS = [\"state\", \"element\", \"auto\", \"none\"];\nconst SYNCS = [\"call\", \"connect\"];\n\n/** `#ro`, `#prevent`, `#stop`, `#onchange`, `#init=…`, `#sync=…` (`#direct`: specFor). */\nfunction flags(engine: Engine, mods: string[]): Flags {\n const on = mods.find((m) => m.startsWith(\"on\"));\n // (the keys are compared, never used as property names: the build renames `init` / `sync`)\n let init: string | null = null;\n let sync: string | null = null;\n for (const m of mods) {\n const i = m.indexOf(\"=\");\n if (i < 0) continue;\n if (!engine.directional) raise(M.DirectionalSyncDisabled);\n const key = m.slice(0, i).trim();\n const value = m.slice(i + 1).trim();\n const isInit = key === \"init\";\n if (!isInit && key !== \"sync\") raise(M.ModifierUnknown, [key, m]);\n if ((isInit ? init : sync) !== null) raise(M.ModifierTwice, [key]);\n if (!(isInit ? INITS : SYNCS).includes(value)) raise(M.ModifierValue, [key, value]);\n if (isInit) init = value;\n else sync = value;\n }\n return {\n ro: mods.includes(\"ro\"), prevent: mods.includes(\"prevent\"), stop: mods.includes(\"stop\"),\n event: on ? on.slice(2) : null, init, sync,\n };\n}\n\nconst COMMAND_PREFIX = \"$command.\";\n\n/** The pattern of a path a binding names (shown to the diagnostics add-on). */\nexport function boundPattern(engine: Engine, path: string, list: Pattern | null): Pattern {\n // `$1` is the loop index: a row pattern of the innermost loop answers it (Engine.markupAccessor)\n if (INDEX_PARAM.test(path)) {\n if (list === null) raise(M.WildcardNoLoop, [path, Number(path.slice(1))]);\n path = `${list.path}.*.${path}`;\n }\n const p = engine.pattern(expandPath(path, list));\n // each \"*\" is the row of the enclosing loop at its level, never a row of another list (F32)\n const d = list === null ? 0 : list.depth + 1;\n if (p.depth > d) raise(M.WildcardNoLoop, [p.path, p.depth, d]);\n for (let k = 1; k <= p.depth; k++) {\n const loop = k === d ? list! : list!.lists[k]!;\n if (p.lists[k] !== loop) raise(M.WildcardOtherList, [p.path, p.lists[k]!.path, loop.path]);\n }\n hooks.declared?.(engine, p);\n return p;\n}\n\n/**\n * A binding that replaces its element with the value (`outerHTML:` / `outerText:`, the properties —\n * not `class.outerHTML:`, `attr.outerText:` or an `on…:` event of that name).\n */\nexport const isOuter = (s: Spec): boolean => s.kind === K_PROP && (s.name === \"outerHTML\" || s.name === \"outerText\");\n\n/**\n * A binding after which the element's children are not markup to bind: it sets the element's content\n * (they are a value), or replaces the element (they are out of the page).\n */\nexport const setsContent = (s: Spec): boolean =>\n s.kind === K_HTML || isOuter(s) || (s.kind === K_PROP && isContent(s.name));\n\n/** An `elseif:` / `else:` template with no `if:` before it. */\nexport function notAfterIf(type: string): never {\n raise(M.ElseWithoutIf, [type]);\n}\n\nexport function specFor(engine: Engine, b: ParsedBinding, list: Pattern | null, el: Element, node: number): Spec {\n const f = flags(engine, b.propModifiers);\n const custom = el.localName.includes(\"-\");\n const segs = b.propSegments;\n const path = b.statePathName;\n\n if (b.bindingType === \"event\") {\n if (f.init !== null && f.init !== \"none\") raise(M.EventInitNone);\n if (segs[0] === \"eventToken\") {\n return { ...blank(), node, kind: K_EVTTOKEN, name: segs.slice(1).join(\".\"), token: path, custom, prevent: f.prevent, stop: f.stop };\n }\n // `onclick: $command.x` emits a command token; `onclick: method` calls a state method\n const command = path.startsWith(COMMAND_PREFIX) ? path.slice(COMMAND_PREFIX.length) : null;\n const { prevent, stop } = f;\n const type = b.propName.slice(2);\n // `#direct`: a listener on the element itself, as 3.x (see attachEvent). (A custom element's\n // `change` / `click` may be dispatched without bubbling: see attachEvent too)\n const direct = b.propModifiers.includes(\"direct\");\n const delegated = !direct && BUBBLING.has(type);\n if (delegated) engine.delegate(type);\n return {\n ...blank(), node, kind: K_EVENT, name: type, delegated, custom, direct,\n listener(e: Event, row: StateRow | null) {\n if (prevent) e.preventDefault();\n if (stop) e.stopPropagation();\n try {\n if (command !== null) engine.emitCommand(command, e, row);\n else {\n // an async handler's failure is reported like a sync one's (not left unhandled)\n const r = engine.invoke(path, e, row) as any;\n if (isThenable(r)) r.then(undefined, (error: unknown) => console.error(error));\n }\n } catch (error) {\n console.error(error);\n }\n },\n };\n }\n if (b.bindingType === \"spread\") {\n return { ...blank(), node, kind: K_SPREAD, pattern: boundPattern(engine, path, list), custom };\n }\n if (segs[0] === \"command\" && segs.length > 1) {\n if (!path.startsWith(COMMAND_PREFIX)) raise(M.CommandRightSide, [b.propName, path]);\n return { ...blank(), node, kind: K_COMMAND, name: segs.slice(1).join(\".\"), token: path, custom };\n }\n\n const pattern = boundPattern(engine, path, list);\n const spec: Spec = {\n ...blank(), node, kind: K_PROP, name: b.propName, pattern,\n filters: buildFilters(b.outFilters), inFilters: buildFilters(b.inFilters), ro: f.ro, init: f.init, sync: f.sync,\n };\n if (b.bindingType === \"radio\" || b.bindingType === \"checkbox\") {\n if (f.init === \"element\" || f.init === \"auto\") raise(M.InitUnsupported, [b.bindingType, f.init]);\n spec.kind = b.bindingType === \"radio\" ? K_RADIO : K_CHECKBOX;\n if (!f.ro) spec.twoWay = f.event ?? \"input\";\n return spec;\n }\n if (segs.length > 1) {\n const name = segs.slice(1).join(\".\");\n const head = segs[0];\n if (head === \"class\" || head === \"attr\" || head === \"style\") {\n // a namespace takes no initial authority: #init= is ignored (as in 3.3)\n spec.init = null;\n spec.name = name;\n if (head === \"class\") {\n spec.kind = K_CLASS;\n spec.initial = el.classList.contains(name);\n } else {\n // (an iframe's srcdoc attribute is an HTML sink: written as the property, through the policy)\n spec.kind = head === \"attr\" ? (name === \"srcdoc\" && el.localName === \"iframe\" ? K_PROP : K_ATTR) : K_STYLE;\n }\n return spec;\n }\n }\n if (b.propName === \"html\") {\n spec.kind = K_HTML;\n return spec;\n }\n spec.name = b.propName === \"text\" ? \"textContent\" : b.propName;\n // an HTML sink is never a wc-bindable member: written at once, through the policy\n spec.custom = custom && !isHtmlSink(spec.name);\n if (!custom && !f.ro && isTwoWay(el, spec.name)) spec.twoWay = f.event ?? (el.localName === \"select\" ? \"change\" : \"input\");\n return spec;\n}\n\n/**\n * The specs of one element's data-wcs, in order. A spread is told which members are bound\n * explicitly after it (last wins).\n */\nexport function elementSpecs(engine: Engine, text: string, list: Pattern | null, el: Element, node: number): Spec[] {\n const specs = parseBindTextsForElement(text).map((b) => specFor(engine, b, list, el, node));\n for (let i = 0; i < specs.length; i++) {\n if (specs[i].kind !== K_SPREAD) continue;\n specs[i].exclude = specs.slice(i + 1).filter((s) => s.kind === K_PROP).map((s) => s.name);\n }\n return specs;\n}\n\nconst MUSTACHE = /\\{\\{([\\s\\S]+?)\\}\\}/g;\n\n/** Replaces a text node holding `{{ … }}` with static text nodes and empty bound ones. */\nexport function splitMustache(t: Text): { node: Text; expr: string }[] {\n const s = t.data;\n const out: { node: Text; expr: string }[] = [];\n let last = 0;\n MUSTACHE.lastIndex = 0;\n for (let m = MUSTACHE.exec(s); m !== null; m = MUSTACHE.exec(s)) {\n // where the match starts (not `m.index`: `index` is a name the build shortens)\n const at = MUSTACHE.lastIndex - m[0].length;\n // (a string is inserted as a text node of t's document)\n if (at > last) t.before(s.slice(last, at));\n const bound = t.ownerDocument.createTextNode(\"\");\n t.before(bound);\n out.push({ node: bound, expr: m[1].trim() });\n last = MUSTACHE.lastIndex;\n }\n if (out.length === 0) return out;\n if (last < s.length) t.before(s.slice(last));\n t.remove();\n return out;\n}\n\nexport function textSpec(engine: Engine, expr: string, list: Pattern | null, node: number): Spec {\n const b = parseBindTextForEmbeddedNode(expr);\n return { ...blank(), node, kind: K_TEXT, pattern: boundPattern(engine, b.statePathName, list), filters: buildFilters(b.outFilters), initial: \"\" };\n}\n\n/** The structural directive on a template (`for` / `if` / `elseif` / `else`), or null. */\nexport function directive(el: Element): ParsedBinding | null {\n const text = el.getAttribute(bindAttr());\n if (text === null) return null;\n const b = parseBindTextsForElement(text)[0];\n return b !== undefined && (b.bindingType === \"for\" || b.bindingType === \"if\" || b.bindingType === \"elseif\" || b.bindingType === \"else\") ? b : null;\n}\n\nexport interface ChainPart {\n el: HTMLTemplateElement;\n pattern: Pattern | null;\n filters: FilterFn[] | null;\n}\n\n/** The anchor text of a chain's `k`-th template: `if`, then `elseif`, and `else` (no path). */\nexport const chainAnchorText = (k: number, part: ChainPart): string =>\n k === 0 ? config.commentIfPrefix : part.pattern === null ? config.commentElsePrefix : config.commentElseIfPrefix;\n\n/**\n * Reads an `if` chain starting at `first` (an `if:` template): the `elseif:` / `else:` templates\n * that follow it in the tree, across whitespace and comments. The walker skips the ones taken (each\n * is out of the tree, its anchor in its place).\n */\nexport function readChain(engine: Engine, first: Element, list: Pattern | null): ChainPart[] {\n const part = (el: Element, b: ParsedBinding): ChainPart => ({\n el: el as HTMLTemplateElement,\n pattern: b.bindingType === \"else\" ? null : boundPattern(engine, b.statePathName, list),\n filters: b.bindingType === \"else\" ? null : buildFilters(b.outFilters),\n });\n const parts = [part(first, directive(first)!)];\n for (let c = first.nextSibling; c !== null; c = c.nextSibling) {\n if ((c.nodeType === 3 && (c as Text).data.trim() === \"\") || c.nodeType === 8) continue;\n if (c.nodeType !== 1 || (c as Element).localName !== \"template\") break;\n const b = directive(c as Element);\n if (b === null || (b.bindingType !== \"elseif\" && b.bindingType !== \"else\")) break;\n parts.push(part(c as Element, b));\n if (b.bindingType === \"else\") break;\n }\n return parts;\n}\n\n/**\n * The elements a page walk has visited: each is bound once, however often it is handed over. SSR\n * hydration adds the top-level nodes of the server's rows and branches (a text's too): their blocks\n * bind them where they are, and the walk passes them by.\n */\nexport const walked = new WeakSet<Node>();\n\n/**\n * Walks `children` and what they contain for bindings, by the same markup rules for the page\n * (`page`: the mount — it skips script / style, enters `<wcs-state>`, and marks anchors for SSR)\n * and for a template's content (a plan). Structural templates are compiled and replaced by\n * their anchors; the rest is handed to the callbacks.\n */\nexport function walkBindings(engine: Engine, children: ChildNode[], list: Pattern | null, page: boolean,\n onFor: (anchor: Comment, p: Pattern, plan: RowPlan) => void,\n onIf: (branches: Branch[]) => void,\n onElement: (el: Element, specs: Spec[]) => void,\n onText: (node: Text, expr: string) => void): void {\n // a structural template leaves the tree: its anchor takes its place\n const anchorFor = (el: Element, type: string): Comment => {\n const anchor = document.createComment(type);\n el.replaceWith(anchor);\n if (page) hooks.ssrMark?.(engine, anchor, el);\n return anchor;\n };\n const walk = (children: ChildNode[]): void => {\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n // (out of the tree: an `elseif:` / `else:` template its chain's anchor replaced)\n if (child.parentNode === null) continue;\n if (child.nodeType === 1) {\n const el = child as Element;\n const tag = el.localName;\n if (page) {\n // walked before (a subtree handed over again): left alone — its text and rows show\n // values now, which are not markup\n if (tag === \"script\" || tag === \"style\" || walked.has(el)) continue;\n walked.add(el);\n // markup written inside a <wcs-state> is part of the page (its own attributes are not bindings)\n if (tag === config.tagNames.state) {\n walk([...el.childNodes]);\n continue;\n }\n }\n // a template with no structural directive binds like any element (its content stays inert)\n const d = tag === \"template\" ? directive(el) : null;\n if (d !== null) {\n if (d.bindingType === \"for\") {\n const p = boundPattern(engine, d.statePathName, list);\n const plan = compilePlan(engine, el as HTMLTemplateElement, p, true);\n onFor(anchorFor(el, config.commentForPrefix), p, plan);\n } else if (d.bindingType === \"if\") {\n onIf(readChain(engine, el, list).map((part, k) => {\n const plan = compilePlan(engine, part.el, list, false);\n return { plan, pattern: part.pattern, filters: part.filters, anchor: anchorFor(part.el, chainAnchorText(k, part)) };\n }));\n } else {\n notAfterIf(d.bindingType);\n }\n continue;\n }\n const text = el.getAttribute(bindAttr());\n const specs = text === null ? null : elementSpecs(engine, text, list, el, 0);\n // What a binding puts in an element is a value, not markup. An element whose content a\n // binding sets (`textContent:` / `innerHTML:` / `html:`) is not walked at all — whenever the\n // value lands (a custom element's waits for its definition), and if it fails — nor one a\n // binding replaces (`outerHTML:` / `outerText:`: its children leave the page). Nor is the\n // content of a <noscript> or an <iframe>: raw text to a page that runs scripts (a server may\n // have rendered a value there). A Light DOM component's content is bound by its own engine\n const into = tag !== \"noscript\" && tag !== \"iframe\" && !specs?.some(setsContent) && !hooks.componentScope?.(el);\n // On the page an element's children are bound before it: what its bindings then put anywhere\n // in it (a custom element rendering a value into a child of its own) is never walked — nor\n // after an error in them, which leaves the walk with the element bound (it is before the\n // error in document order). A plan keeps document order (Block.dispatch relies on it): its\n // bindings change nothing in it\n try {\n if (page && into) walk([...el.childNodes]);\n } finally {\n if (specs !== null) onElement(el, specs);\n }\n if (!page && into) walk([...el.childNodes]);\n } else if (child.nodeType === 3 && engine.mustache && (child as Text).data.includes(\"{{\") && !walked.has(child)) {\n for (const { node, expr } of splitMustache(child as Text)) onText(node, expr);\n } else if (child.nodeType === 8) {\n // a comment binding, as 3.x (`$behavior.enableMustache` aside): a text binding in its place —\n // not in a <textarea> / <title>, where a browser's parser makes it text (a server's DOM may not)\n const m = COMMENT_BINDING.exec((child as Comment).data);\n const p = m && (child.parentNode as Element).localName;\n if (p !== null && p !== \"textarea\" && p !== \"title\") {\n const t = document.createTextNode(\"\");\n child.replaceWith(t);\n onText(t, m![1]);\n }\n }\n }\n };\n walk(children);\n}\n\n/**\n * `<!--@@: expr-->` / `<!--@@wcs-text: expr-->` (3.x's comment binding: a text binding that renders\n * nothing before it is bound — no FOUC, no element added); no other keyword (a router's `@@route:`,\n * 3.x's SSR marks). `expr` is a `{{ }}` expression (across lines, as a mustache's: SSR restores both\n * as this).\n */\nconst COMMENT_BINDING = /^\\s*@@\\s*(?:wcs-text)?\\s*:\\s*([\\s\\S]+?)\\s*$/;\n\n/**\n * A template's content. A `<template>` inside `<svg>` is an SVG element (the HTML parser makes it\n * so) and has no `.content`: its children are its content (a copy of them: the template keeps them).\n */\nexport const templateContent = (t: HTMLTemplateElement): DocumentFragment => {\n const r = document.createRange();\n r.selectNodeContents(t);\n return t.content ?? r.cloneContents();\n};\n\n/**\n * Compiles a template into a plan: the fragment to clone, the child-index path of every\n * bound node, and one spec per binding. Paths are resolved to patterns here, once —\n * blocks never parse or resolve anything. `list` is the enclosing `for` (for `.` paths).\n */\nexport function compilePlan(engine: Engine, template: HTMLTemplateElement, list: Pattern | null, asRow: boolean): RowPlan {\n const frag = document.importNode(templateContent(template), true);\n const targets: Node[] = [];\n const specs: Spec[] = [];\n const target = (node: Node): number => targets.push(node) - 1;\n\n walkBindings(engine, [...frag.childNodes], list, false,\n (anchor, p, plan) => {\n specs.push({ ...blank(), node: target(anchor), kind: K_FOR, pattern: p, plan });\n },\n (chain) => {\n const branches: BranchSpec[] = chain.map((br) => ({ node: target(br.anchor), plan: br.plan, pattern: br.pattern, filters: br.filters }));\n specs.push({ ...blank(), node: branches[0].node, kind: K_IF, branches });\n },\n (el, own) => {\n const n = target(el);\n for (const s of own) {\n // a row or a branch keeps its nodes by position: a binding that replaces its element (once —\n // the element is out of the page after) has no place in one\n if (isOuter(s)) raise(M.OuterInTemplate, [s.name]);\n s.node = n;\n }\n specs.push(...own);\n // the plan holds the bindings: blocks cloned from it carry nothing left to bind\n el.removeAttribute(bindAttr());\n },\n (node, expr) => {\n specs.push(textSpec(engine, expr, list, target(node)));\n });\n\n // Whitespace that never renders is not part of a block: at the top level, and inside\n // elements whose content model has no text (table parts, select). Bound text nodes start\n // empty: keep them.\n stripInsignificantWhitespace(frag, new Set(targets), true);\n\n const nodePaths = targets.map((t) => pathOf(frag, t));\n // one node cloned alone — not a structural anchor, whose view inserts before it (it needs a parent)\n const single = frag.childNodes.length === 1 && frag.firstChild!.nodeType !== 8;\n const nested = specs.some((s) => s.kind === K_FOR || s.kind === K_IF);\n const lazy: Spec[] = [];\n const used = new Set<number>();\n const events: Spec[] = [];\n // what a block binds as it is built (the delegated events it finds by path are not among them)\n const own: Spec[] = [];\n // in a row plan, the row's own locations bound by kinds that need only the node are slots (see RowView)\n const d = asRow ? list!.depth + 1 : -1;\n for (const s of specs) {\n // a node used only by delegated events is never resolved when a block is built (a custom\n // element's are attached: it may dispatch them without bubbling)\n if (s.kind === K_EVENT && s.delegated && !s.custom && !shifts(targets[s.node], frag)) {\n events.push(s);\n continue;\n }\n own.push(s);\n const p = s.pattern;\n if (p !== null && p.depth === d && p.lists[d] === list && isSlotKind(s)) s.slot = lazy.push(s) - 1;\n if (s.kind === K_IF) for (const br of s.branches!) used.add(br.node);\n else used.add(s.node);\n }\n const build = [...used].sort((a, b) => a - b);\n return { fragment: frag, root: single ? frag.firstChild : null, nodePaths, build, events, specs: own, single, nested, scratch: [], lazy };\n}\n\n/**\n * Whether the path to `n` from its block's top node can change once the block renders: a\n * structural anchor before it on the way (its view renders before the anchor) or a custom element\n * above it (a Light DOM component may add children). Such an element's delegated events are not\n * found by path: they are stored on the element as its block is built.\n */\nfunction shifts(n: Node, top: Node): boolean {\n for (; n.parentNode !== top; n = n.parentNode!) {\n if ((n.parentNode as Element).localName.includes(\"-\")) return true;\n for (let s = n.previousSibling; s; s = s.previousSibling) if (s.nodeType === 8) return true;\n }\n return false;\n}\n\nfunction isSlotKind(s: Spec): boolean {\n // a slot applies its first value as it is built: #init= needs a Binding (HOLD)\n if (s.init !== null) return false;\n switch (s.kind) {\n case K_TEXT:\n case K_CLASS:\n case K_ATTR:\n case K_STYLE:\n case K_HTML:\n return true;\n case K_PROP:\n return !s.custom && s.twoWay === null;\n default:\n return false;\n }\n}\n\n/** Elements whose children never render as text: whitespace between their children is noise. */\nconst NO_TEXT = new Set([\"table\", \"thead\", \"tbody\", \"tfoot\", \"tr\", \"colgroup\", \"select\", \"optgroup\", \"datalist\"]);\n\nfunction stripInsignificantWhitespace(parent: Node, keep: Set<Node>, strip: boolean): void {\n for (let n = parent.firstChild; n !== null;) {\n const next = n.nextSibling;\n if (n.nodeType === 3) {\n if (strip && !keep.has(n) && (n as Text).data.trim() === \"\") n.remove();\n } else if (n.nodeType === 1) {\n stripInsignificantWhitespace(n, keep, NO_TEXT.has((n as Element).localName));\n }\n n = next;\n }\n}\n\nfunction pathOf(root: Node, node: Node): number[] {\n const path: number[] = [];\n for (let n: Node = node; n !== root; n = n.parentNode!) {\n let i = 0;\n for (let s = n.previousSibling; s !== null; s = s.previousSibling) i++;\n path.unshift(i);\n }\n return path;\n}\n","import { parseStatePart } from \"./parseStatePart\";\nimport { ParsedBinding } from \"./types\";\n\n/**\n * テキストバインディング(mustache `{{ expr }}` / コメント `<!--@@: expr-->`・`<!--@@wcs-text: expr-->`)の式を解析する。\n * 式全体が `path[|filters]` — `;` は**分割しない**(属性経路との規定差)。\n * Port of `@wcstack/state` `src/bindTextParser/parseBindTextForEmbeddedNode.ts`.\n */\nexport function parseBindTextForEmbeddedNode(bindText: string): ParsedBinding {\n const stateResult = parseStatePart(bindText);\n return {\n propName: 'textContent',\n propSegments: ['textContent'],\n propModifiers: [],\n inFilters: [],\n ...stateResult,\n bindingType: 'text',\n };\n}\n","import type { Engine } from \"../engine\";\nimport { hooks } from \"../hooks\";\nimport { directive, textSpec, walkBindings } from \"./plan\";\nimport { raise, M } from \"../messages\";\nimport { attachChain, attachSpec, ForView, listFor } from \"./view\";\n\n/**\n * The engine mounted on each root (document, shadow root): the binder's lookup. A root's while its\n * `<wcs-state>` is in the page (src/element.ts): the root node outlives the content it bound.\n */\nexport const engines = new WeakMap<Node, Engine>();\n\n/**\n * Binds everything under `root` to `engine` and renders it. An element walked once is left\n * alone after (walkBindings): the binder protocol hands route content over on every insertion.\n */\nexport function mount(engine: Engine, root: Document | ShadowRoot | Element): void {\n const container: Node = root.nodeType === 9 ? (root as Document).body : root;\n engine.root = root;\n engines.set(root, engine);\n walk(engine, [...container.childNodes]);\n engine.report();\n}\n\n/**\n * Binds a subtree that entered the document after the mount (the binder protocol). It never throws\n * for markup reasons (the protocol): an error in the markup is reported, and what is before it in\n * document order (the elements it is in too) stays bound. A structural template handed over itself (a\n * route's top-level node) is rendered only when the caller carries its range (`range`: the router\n * takes everything up to its end mark along, the rows rendered beside the template included);\n * otherwise it is refused (#204): what it renders would sit beside it, where whoever inserted it\n * does not reach (an older router removes only its own nodes, `<wcs-head>` its one element). An\n * `if:` template handed over reads its `elseif:` / `else:` siblings into one chain (readChain), and\n * those, handed over next, are out of the document by then (their anchors took their place).\n */\nexport function mountSubtree(engine: Engine, subtree: Element, range?: boolean): void {\n try {\n const d = subtree.localName === \"template\" ? directive(subtree) : null;\n if (d !== null && !range) raise(M.TemplateHandedOver, [d.bindingType]);\n walk(engine, [subtree]);\n } catch (e) {\n console.error(e);\n }\n engine.report();\n}\n\nfunction walk(engine: Engine, children: ChildNode[]): void {\n walkBindings(engine, children, null, true,\n (anchor, p, plan) => {\n new ForView(engine, plan, listFor(engine, p, null, anchor), anchor).update();\n },\n (branches) => {\n attachChain(engine, branches, null, null);\n },\n (el, specs) => {\n hooks.ssrMark?.(engine, el, specs);\n for (const spec of specs) attachSpec(engine, spec, el, null, null);\n },\n (node, expr) => {\n hooks.ssrMark?.(engine, node, expr);\n attachSpec(engine, textSpec(engine, expr, null, 0), node, null, null);\n });\n}\n"],"mappings":"4YAcA,IAAMA,EAAmB,IAAIC,ICoBhBC,EAAwD,IAAIC,IAAiB,CACxF,KACA,SACA,OACA,QCNIC,EAA6B,IAAID,IAAY,CAACE,EAAc,KAAM,SAAU,MAAO,QAOnFC,EAAmC,IAAIH,IAAY,CACvDI,EAAiBC,EAAgBC,EAAiBC,EAAmBC,EACrEC,IAoBK,SAASC,EAAyBC,GAEvC,IAAMC,EAfD,SAAwBD,GAC7B,OAAOE,EAAmBF,EAAU,IACtC,CAYoBG,CAAeH,GAAUI,IAAIC,GAAQC,OAAOC,GAAKA,EAAEC,OAAS,GACpDJ,IAAKJ,IAG7B,IAAMS,EAAiBC,EAAqBV,EAAU,MAC/B,IAAnBS,GACFE,MAAyB,CAACX,IAE5B,IAAMY,EAAWZ,EAASa,MAAM,EAAGJ,GAAgBK,OAC7CC,EAAYf,EAASa,MAAMJ,EAAiB,GAAGK,OAO/CE,EAAUJ,EAASK,MAAM,KAAoB,GAAGA,MAAM,KAAkB,GAAGH,OACjF,GAAIxB,EAA2B4B,IAAIF,GAAU,CAI3C,IAAIG,EACJ,OAJIH,IAAYJ,GACdD,MAAoC,CAACX,EAAUgB,IAG7CA,IAAYzB,GACVwB,EAAUP,OAAS,GAErBG,MAA0B,CAACX,IAE7BmB,EAAc,C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AAazV,EAAQiE,EAAU,MAAM,EACnC,CAAC4C,EAAQL,EAAG1C,KACV,IAAImG,GAAQjK,EAAQ8D,EAAM8C,EAAQ5G,EAAQwG,EAAG,KAAMK,GAASA,GAAQpF,MAErE2I,IACCD,GAAYnK,EAAQoK,EAAU,KAAM,OAEtC,CAACxB,EAAIc,KACH3B,EAAMmO,KAAUlW,EAAQ4I,EAAIc,GAC5B,QAAW0B,KAAQ1B,EAAOY,GAAWtK,EAAQoL,EAAMxC,EAAI,KAAM,OAE/D,CAAC1I,EAAM2U,KACL9M,EAAMmO,KAAUlW,EAAQE,EAAM2U,GAC9BvK,GAAWtK,EAAQ8U,GAAS9U,EAAQ6U,EAAM,KAAM,GAAI3U,EAAM,KAAM,OAEtE,QAAA0P,OAAA4I,QAAAC,OAAAC,OAAAC,OAAAjK,OAAAD,OAAAmK,OAAAC,QAAAC,QAAAC,QAAAC,QAAAC,QAAAC,QAAAC,QAAAC","ignoreList":[]}
@@ -1 +1,2 @@
1
- import{b as t}from"./chunk-ALVA5TQM.js";import{j as e}from"./chunk-V34ZHCK5.js";var a={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1};function r(e){let r=a,s=a.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,a]of n){let s=r[e];(!Object.hasOwn(r,e)||null===a||typeof a!=typeof s||Array.isArray(a)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,a]of o)(!Object.hasOwn(s,e)||"string"!=typeof a)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(r[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>a,n=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],o=new Map,i=new Map;function f(t){for(let e of Object.keys(t))o.set(e,{...t[e]});i.clear()}function l(t){return o.has(t)}function c(a,r,s){let f=`${a}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(r,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(a);void 0===c&&function(a,r){n.includes(a)&&e(`[wcs/filter-unknown] filter not found: ${a}. "${a}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,a,r),t(501,[a],a,r)}(a,o.keys());let[m,u]=c.arity;r.length<m&&t(601,[a,m,r.length]),r.length>u&&t(602,[a,u,r.length]);let d=c.factory(r,s);return i.set(f,d),d}export{a,r as b,s as c,n as d,f as e,l as f,c as g};
1
+ import{b as t}from"./chunk-EIMTT5I3.js";import{j as e}from"./chunk-4NJBYXIT.js";var a={bindAttributeName:"data-wcs",commentForPrefix:"wcs-for",commentIfPrefix:"wcs-if",commentElseIfPrefix:"wcs-elseif",commentElsePrefix:"wcs-else",tagNames:{state:"wcs-state",ssr:"wcs-ssr"},locale:typeof document<"u"&&document.documentElement?.lang||"en",enableContractAnalyzer:!1};function r(e){let r=a,s=a.tagNames,n=Object.entries(e).filter(([,t])=>void 0!==t),o=Object.entries(e.tagNames??{}).filter(([,t])=>void 0!==t);for(let[e,a]of n){let s=r[e];(!Object.hasOwn(r,e)||null===a||typeof a!=typeof s||Array.isArray(a)!==Array.isArray(s))&&t(44,["bootstrapState",e])}for(let[e,a]of o)(!Object.hasOwn(s,e)||"string"!=typeof a)&&t(44,["bootstrapState",`tagNames.${e}`]);for(let[t,e]of n)"tagNames"!==t&&(r[t]=e);for(let[t,e]of o)s[t]=e}var s=()=>a,n=["toFixed","locale","upper","lower","capitalize","trim","slice","padStart","padEnd","repeat","reverse","truncate","join","round","floor","ceil","percent","unit","date","time","datetime","ymd","hms","add","sub","mul","div","mod","abs","clamp","int","float","defaults","coalesce","number","string","nullIfEmpty"],o=new Map,i=new Map;function f(t){for(let e of Object.keys(t))o.set(e,{...t[e]});i.clear()}function l(t){return o.has(t)}function c(a,r,s){let f=`${a}${function(t,e){return`${JSON.stringify(t)}${JSON.stringify(e)}`}(r,s)}`,l=i.get(f);if(typeof l<"u")return l;let c=o.get(a);void 0===c&&function(a,r){n.includes(a)&&e(`[wcs/filter-unknown] filter not found: ${a}. "${a}" is in the formats add-on — install it with installFeatures([formats]) from "@wcstack/state/features/formats".`,a,r),t(501,[a],a,r)}(a,o.keys());let[m,u]=c.arity;r.length<m&&t(601,[a,m,r.length]),r.length>u&&t(602,[a,u,r.length]);let d=c.factory(r,s);return i.set(f,d),d}export{a,r as b,s as c,n as d,f as e,l as f,c as g};
2
+ //# sourceMappingURL=chunk-M5SODAAE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["config","bindAttributeName","commentForPrefix","commentIfPrefix","commentElseIfPrefix","commentElsePrefix","tagNames","state","ssr","locale","document","documentElement","lang","enableContractAnalyzer","setConfig","partial","options","tags","given","Object","entries","filter","value","givenTags","tag","key","current","hasOwn","Array","isArray","raise","name","getConfig","FORMATS_FILTER_NAMES","definitions","Map","resolvedByKey","registerFilters","map","keys","set","clear","hasFilter","has","resolveFilter","literals","args","JSON","stringify","filterArgsKey","resolved","get","definition","known","includes","raiseError","unknownFilter","min","max","arity","length","filterFn","factory","c","x","b","y","A","O","h"],"sources":["../../../src/config.ts","../../../src/filters/registry.ts"],"sourcesContent":["import { raise, M } from \"./messages\";\n\n/**\n * Page-wide configuration (`bootstrapState(config)`): how this page spells wcstack markup (the tag\n * names, the binding attribute, the anchor comments — fixed before the first definition, the same\n * on the server) and the locale default. How a state tree behaves is its own `$behavior` (engine.ts).\n */\nexport interface Config {\n bindAttributeName: string;\n /** The text of a `for` template's anchor comment. */\n commentForPrefix: string;\n /** The texts of an `if` / `elseif` / `else` chain's anchor comments. */\n commentIfPrefix: string;\n commentElseIfPrefix: string;\n commentElsePrefix: string;\n tagNames: { state: string; ssr: string };\n locale: string;\n /** Opt-in `analyzeContract()` (dev time); off, it returns at once. */\n enableContractAnalyzer: boolean;\n}\n\nexport const config: Config = {\n bindAttributeName: \"data-wcs\",\n commentForPrefix: \"wcs-for\",\n commentIfPrefix: \"wcs-if\",\n commentElseIfPrefix: \"wcs-elseif\",\n commentElsePrefix: \"wcs-else\",\n tagNames: { state: \"wcs-state\", ssr: \"wcs-ssr\" },\n locale: typeof document !== \"undefined\" ? document.documentElement?.lang || \"en\" : \"en\",\n enableContractAnalyzer: false,\n};\n\nexport type PartialConfig = Partial<Omit<Config, \"tagNames\">> & { tagNames?: Partial<Config[\"tagNames\"]> };\n\n/**\n * Applies the options given; an undefined value is left out. An option `bootstrapState` does not\n * have (a key 4.0 moved to the state's `$behavior` or removed included), a value of another type\n * than its default (null, or an array for an object, included) or a tag name it does not define\n * throws, and then nothing is applied — the same rule as every package's bootstrap.\n */\nexport function setConfig(partial: PartialConfig): void {\n const options = config as unknown as Record<string, unknown>;\n const tags = config.tagNames as Record<string, string>;\n const given = Object.entries(partial).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partial.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n raise(M.OptionInvalid, [\"bootstrapState\", key]);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") raise(M.OptionInvalid, [\"bootstrapState\", `tagNames.${name}`]);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n}\n\n/** The current configuration (read-only view). */\nexport const getConfig = (): Readonly<Config> => config;\n","/**\n * filters/registry.ts — the filter registry, ported from `@wcstack/state` (`core/filterRegistry.ts`).\n *\n * The grammar (`path|filter(args)`) only produces names and arguments; the functions are looked up\n * here when the bindings are planned. The core set (`./core`) and the formats add-on (`./formats`)\n * each put their filters in with an install call; this module knows neither implementation, so a\n * page that skips the add-on does not carry its code.\n *\n * Differences from the source, all decided:\n * - one registry, not an input / output pair (the source registered the same table in both);\n * - no aliases (`inc dec fix uc lc cap pad rep rev null` are not carried over);\n * - every registered filter has arity bounds (the source allowed them to be absent);\n * - the core set is registered like any other (the source hard-wired `not` into the registry).\n */\nimport { raiseError } from \"../parser/raiseError\";\nimport { raise, M } from \"../messages\";\n\nexport type FilterFn = (value: unknown) => unknown;\n\n/**\n * Builds the function for one use of a filter. `options` are the argument texts (unquoted),\n * `literals` their typed values (requirement B9 — only filters that compare or return an argument\n * read them).\n */\nexport type FilterFactory = (options: string[], literals: readonly unknown[]) => FilterFn;\n\n/** A filter as an install call hands it to the registry: the factory and its [min, max] argument count (B3). */\nexport interface FilterDefinition {\n factory: FilterFactory;\n arity: readonly [number, number];\n}\n\n/**\n * The formats add-on's filters (37: up to 4.0.0-rc.3 the 23 display ones, then the core's\n * arithmetic, conversion and missing-value 14). Only the names live here (not the code), so that a\n * page without the add-on can still say where one of them comes from instead of calling it a typo.\n * A test keeps this list equal to the add-on's table.\n */\nexport const FORMATS_FILTER_NAMES: readonly string[] = [\n \"toFixed\", \"locale\",\n \"upper\", \"lower\", \"capitalize\", \"trim\", \"slice\", \"padStart\", \"padEnd\", \"repeat\", \"reverse\", \"truncate\", \"join\",\n \"round\", \"floor\", \"ceil\", \"percent\", \"unit\",\n \"date\", \"time\", \"datetime\", \"ymd\", \"hms\",\n \"add\", \"sub\", \"mul\", \"div\", \"mod\", \"abs\", \"clamp\", \"int\", \"float\", \"defaults\", \"coalesce\", \"number\", \"string\", \"nullIfEmpty\",\n];\n\n/**\n * A `Map`, not a plain object: bracket access on an object lets the `Object.prototype` members\n * through as filters (`|toString` / `|constructor` / `|valueOf`), which then fail with a\n * meaningless TypeError instead of `[wcs/filter-unknown]`.\n */\nconst definitions = new Map<string, FilterDefinition>();\n\n/** Name + arguments → the function already built for them (each is built once). */\nconst resolvedByKey = new Map<string, FilterFn>();\n\n/**\n * The key of one argument list: **both the raw texts and the typed values** (B3 / B9).\n * - Raw texts alone would make `defaults(0)` and `defaults('0')` the same `[\"0\"]`, sharing one\n * function between two filters of different types.\n * - Typed values alone would fold `1` / `1.0` / `01` / `+1` into the same number, although the\n * factories that read the raw text (`truncate` / `unit` / `join` / `ymd` / `padStart` …) answer\n * them differently.\n * - A structural key, never `args.join(\",\")`: `['a,b']` and `['a', 'b']` are different arguments.\n */\nexport function filterArgsKey(args: readonly string[], literals: readonly unknown[]): string {\n return `${JSON.stringify(args)}${JSON.stringify(literals)}`;\n}\n\n/** Called by the install functions. Idempotent — a name registered again replaces the previous one. */\nexport function registerFilters(map: Record<string, FilterDefinition>): void {\n for (const name of Object.keys(map)) {\n // a copy: the registry keeps what was registered\n definitions.set(name, { ...map[name] });\n }\n // A new registration can change the answers already built (a page installs once; tests and\n // tooling swap registrations)\n resolvedByKey.clear();\n}\n\nexport function hasFilter(name: string): boolean {\n return definitions.has(name);\n}\n\n/** The registered names, which the did-you-mean suggestion reads. */\nexport function knownFilterNames(): string[] {\n return [...definitions.keys()];\n}\n\n/** Drops the functions already built (tooling that clears its parser caches). */\nexport function clearFilterResolutionCache(): void {\n resolvedByKey.clear();\n}\n\n/**\n * `[wcs/filter-unknown]`. A formatting filter on a page without the formats add-on is not a typo:\n * that barrier is kept as full text, since it is met on pages without add-ons (the diagnostics\n * add-on adds the nearest name to either).\n */\nfunction unknownFilter(name: string, known: Iterable<string>): never {\n if (FORMATS_FILTER_NAMES.includes(name)) {\n raiseError(`[wcs/filter-unknown] filter not found: ${name}. \"${name}\" is in the formats add-on — install it with installFeatures([formats]) from \"@wcstack/state/features/formats\".`, name, known);\n }\n raise(M.FilterUnknown, [name], name, known);\n}\n\n/**\n * The function for one use of a filter (binding planning). An unknown name or a wrong argument count\n * fails here, by name — the parser never rejects a filter.\n */\nexport function resolveFilter(name: string, options: string[], literals: readonly unknown[]): FilterFn {\n const key = `${name}${filterArgsKey(options, literals)}`;\n const resolved = resolvedByKey.get(key);\n if (typeof resolved !== \"undefined\") {\n return resolved;\n }\n const definition = definitions.get(name);\n if (definition === undefined) {\n unknownFilter(name, definitions.keys());\n }\n // Same vocabulary as lint's wcs/filter-arity\n const [min, max] = definition.arity;\n if (options.length < min) raise(M.FilterTooFewArgs, [name, min, options.length]);\n if (options.length > max) raise(M.FilterTooManyArgs, [name, max, options.length]);\n const filterFn = definition.factory(options, literals);\n resolvedByKey.set(key, filterFn);\n return filterFn;\n}\n"],"mappings":"gFAqBO,IAAMA,EAAiB,CAC5BC,kBAAmB,WACnBC,iBAAkB,UAClBC,gBAAiB,SACjBC,oBAAqB,aACrBC,kBAAmB,WACnBC,SAAU,CAAEC,MAAO,YAAaC,IAAK,WACrCC,cAAeC,SAAa,KAAcA,SAASC,iBAAiBC,MAAQ,KAC5EC,wBAAwB,GAWnB,SAASC,EAAUC,GACxB,IAAMC,EAAUhB,EACViB,EAAOjB,EAAOM,SACdY,EAAQC,OAAOC,QAAQL,GAASM,OAAO,EAAE,CAAEC,UAAqB,IAAVA,GACtDC,EAAYJ,OAAOC,QAAQL,EAAQT,UAAY,CAAC,GAAGe,OAAO,EAAE,CAAEG,UAAiB,IAARA,GAC7E,QAAYC,EAAKH,KAAUJ,EAAO,CAChC,IAAMQ,EAAUV,EAAQS,KACnBN,OAAOQ,OAAOX,EAASS,IAAkB,OAAVH,UAAyBA,UAAiBI,GAAWE,MAAMC,QAAQP,KAAWM,MAAMC,QAAQH,KAC9HI,KAAuB,CAAC,iBAAkBL,GAE9C,CACA,QAAYM,EAAMP,KAAQD,IACnBJ,OAAOQ,OAAOV,EAAMc,IAAwB,iBAARP,IAAkBM,KAAuB,CAAC,iBAAkB,YAAYC,MAEnH,QAAYN,EAAKH,KAAUJ,EACb,aAARO,IACFT,EAAQ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T,EAAWU,QAAQ9C,EAAS6B,GAC7C,OAAAT,EAAcI,IAAIf,EAAKoC,GAChBA,CACT,QAAAE,EAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC","ignoreList":[]}
@@ -1 +1,2 @@
1
- import{b as t}from"./chunk-ALVA5TQM.js";var e="else",l="eventToken",n="state",s="command",r="class",i="attr",u="style",a=/^\$[1-9]\d{0,2}$/,c=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function o(e){let l=[],n=[],s="",r=null,i=!1,u=-1,a=-1,o=t=>{let e=function(t,e,l){let n=-1===e?t.length:e,s=-1===l?0:l;return t.slice(n-t.slice(0,n).trimStart().length,s+t.slice(s).trimEnd().length)}(s,u,a);(!t||e||i)&&(l.push(e),n.push(function(t,e){return e?t:"true"===t||"false"!==t&&("null"===t?null:c.test(t)?Number(t):t)}(e,i))),s="",i=!1,u=-1,a=-1};for(let t=0;t<e.length;t++){let l=e[t];r?l===r?r=null:(-1===u&&(u=s.length),s+=l,a=s.length):'"'===l||"'"===l?(r=l,i=!0):","===l?o():s+=l}return null!==r&&t(107,[r,e]),o(!0),{args:l,literals:n}}var f=t=>t.trim();function h(t,e){let l=[],n=null;for(let s=0;s<t.length;s++){let r=t[s];null!==n?r===n&&(n=null):"'"===r||'"'===r?n=r:r===e&&l.push(s)}return l}var g=(t,e)=>h(t,e)[0]??-1;function m(t,e){let l=[],n=0;for(let s of h(t,e))l.push(t.slice(n,s)),n=s+1;return l.push(t.slice(n)),l}function p(e,l,n){let s=g(e,"|");if(-1===s)return[e.trim(),[]];let r=e.slice(s+1).trim(),i=n.get(r);return void 0===i&&(i=function(e,l,n){let s=n??e.join("|");return e.map(e=>{let n=g(e,"("),r=(t=>h(t,")").pop()??-1)(e);if(-1===r&&(r=e.lastIndexOf(")")),-1!==n&&-1===r&&t(108,[e]),-1!==r&&-1===n&&t(109,[e]),-1!==r&&r<n&&t(110,[e]),-1!==r&&e.slice(r+1).trim().length>0){let l=e.slice(r+1).trim();t(111,[e,l])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&t(112,[s]),i.includes("#")){let[,e]=i.split("#");t("input"===l?113:114,[i,e])}return-1===n?{Hn:i,args:[],literals:[]}:{Hn:i,...o(e.substring(n+1,r))}})}(m(r,"|").map(f),l,e),n.set(r,i)),[e.slice(0,s).trim(),i]}var d=new Map;function v(e){t(1101,[e])}function b(e){let[l,n]=p(e,"output",d);l.includes("@")&&t(32,[l]);let s=l,r=s.startsWith("."),i=r?s.slice(1):s;return(i.length>0&&i.split(".").some(t=>0===t.length)||!r&&0===i.length)&&t(119,[e]),function(e){e.includes("**")&&v(e);let l=e.split(".").length;l>512&&t(117,[e,l])}(s),{Qe:s,Ze:n}}export{e as a,l as b,n as c,s as d,r as e,i as f,u as g,a as h,f as i,g as j,m as k,p as l,v as m,b as n};
1
+ import{b as t}from"./chunk-EIMTT5I3.js";var e="else",l="eventToken",n="state",s="command",r="class",i="attr",u="style",a=/^\$[1-9]\d{0,2}$/,c=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function o(e){let l=[],n=[],s="",r=null,i=!1,u=-1,a=-1,o=t=>{let e=function(t,e,l){let n=-1===e?t.length:e,s=-1===l?0:l;return t.slice(n-t.slice(0,n).trimStart().length,s+t.slice(s).trimEnd().length)}(s,u,a);(!t||e||i)&&(l.push(e),n.push(function(t,e){return e?t:"true"===t||"false"!==t&&("null"===t?null:c.test(t)?Number(t):t)}(e,i))),s="",i=!1,u=-1,a=-1};for(let t=0;t<e.length;t++){let l=e[t];r?l===r?r=null:(-1===u&&(u=s.length),s+=l,a=s.length):'"'===l||"'"===l?(r=l,i=!0):","===l?o():s+=l}return null!==r&&t(107,[r,e]),o(!0),{args:l,literals:n}}var f=t=>t.trim();function h(t,e){let l=[],n=null;for(let s=0;s<t.length;s++){let r=t[s];null!==n?r===n&&(n=null):"'"===r||'"'===r?n=r:r===e&&l.push(s)}return l}var g=(t,e)=>h(t,e)[0]??-1;function m(t,e){let l=[],n=0;for(let s of h(t,e))l.push(t.slice(n,s)),n=s+1;return l.push(t.slice(n)),l}function p(e,l,n){let s=g(e,"|");if(-1===s)return[e.trim(),[]];let r=e.slice(s+1).trim(),i=n.get(r);return void 0===i&&(i=function(e,l,n){let s=n??e.join("|");return e.map(e=>{let n=g(e,"("),r=(t=>h(t,")").pop()??-1)(e);if(-1===r&&(r=e.lastIndexOf(")")),-1!==n&&-1===r&&t(108,[e]),-1!==r&&-1===n&&t(109,[e]),-1!==r&&r<n&&t(110,[e]),-1!==r&&e.slice(r+1).trim().length>0){let l=e.slice(r+1).trim();t(111,[e,l])}let i=(-1===n?e:e.substring(0,n)).trim();if(0===i.length&&t(112,[s]),i.includes("#")){let[,e]=i.split("#");t("input"===l?113:114,[i,e])}return-1===n?{Hn:i,args:[],literals:[]}:{Hn:i,...o(e.substring(n+1,r))}})}(m(r,"|").map(f),l,e),n.set(r,i)),[e.slice(0,s).trim(),i]}var d=new Map;function v(e){t(1101,[e])}function b(e){let[l,n]=p(e,"output",d);l.includes("@")&&t(32,[l]);let s=l,r=s.startsWith("."),i=r?s.slice(1):s;return(i.length>0&&i.split(".").some(t=>0===t.length)||!r&&0===i.length)&&t(119,[e]),function(e){e.includes("**")&&v(e);let l=e.split(".").length;l>512&&t(117,[e,l])}(s),{Je:s,Ze:n}}export{e as a,l as b,n as c,s as d,r as e,i as f,u as g,a as h,f as i,g as j,m as k,p as l,v as m,b as n};
2
+ //# sourceMappingURL=chunk-NOPTR2L3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ELSE_KEYWORD","EVENT_TOKEN_NAMESPACE","VOLUME_INJECTION_PROP","COMMAND_NAMESPACE","CLASS_NAMESPACE","ATTR_NAMESPACE","STYLE_NAMESPACE","INDEX_PARAM","NUMBER_LITERAL","parseFilterArgsWithLiterals","argsText","args","literals","current","inQuote","hasQuote","firstQuoteStart","lastQuoteEnd","flush","last","arg","text","startLimit","length","endLimit","slice","trimStart","trimEnd","finalizeArg","push","quoted","test","Number","toLiteral","i","char","raise","trimFn","s","trim","outsideQuotes","found","quote","c","indexOfOutsideQuotes","splitOutsideQuotes","separator","parts","start","splitFilters","part","filterIOType","cache","pos","filtersText","filters","get","filterTextList","sourceText","source","join","map","filterText","openParenIndex","closeParenIndex","pop","lastIndexOfOutsideQuotes","lastIndexOf","trailing","filterName","substring","includes","modifiers","split","parseFilters","set","cacheFilterInfos","Map","recursionUnsupported","path","parseStatePart","statePart","stateAndPath","statePathName","isLoopRelative","startsWith","body","some","segment","segmentCount","checkPathLikeGetPathInfo","outFilters","b","x","y","Q","U","k","v","W","P","m","R","S","D","J"],"sources":["../../../src/parser/define.ts","../../../src/parser/parseFilterArgs.ts","../../../src/parser/utils.ts","../../../src/parser/parseFilters.ts","../../../src/parser/parseStatePart.ts"],"sourcesContent":["/**\n * Constants of the `data-wcs` binding grammar, copied from `@wcstack/state`\n * (`src/define.ts` / `src/errorGuidance.ts`). The values are the syntax contract\n * (`[prop][#mod]: [path][|filter...]`) and must stay identical to the current engine.\n */\n\n/** Path segment delimiter. */\nexport const DELIMITER = '.';\n/** Separator between the bindings of one attribute value. */\nexport const BINDING_SEPARATOR = ';';\n/** Separator between the left side (property) and the right side (path). */\nexport const PROP_VALUE_SEPARATOR = ':';\n/** Separator between the property and its modifier list. */\nexport const MODIFIER_SEPARATOR = '#';\n/** Separator of the filter pipeline. */\nexport const FILTER_SEPARATOR = '|';\n\nexport const ELSE_KEYWORD = 'else';\nexport const SPREAD_PROP = '...';\nexport const EVENT_PROP_PREFIX = 'on';\nexport const EVENT_TOKEN_NAMESPACE = 'eventToken';\n/** `<wcs-state mount>` left side `state.<key>: path` (volume injection). */\nexport const VOLUME_INJECTION_PROP = 'state';\nexport const COMMAND_NAMESPACE = 'command';\nexport const CLASS_NAMESPACE = 'class';\nexport const ATTR_NAMESPACE = 'attr';\nexport const STYLE_NAMESPACE = 'style';\n\n/**\n * Segment-count ceiling of one path. The current engine enforces it in `getPathInfo`\n * (first intern only) with a `[wcs/binding-syntax]` diagnostic; the parser port keeps the\n * same check inline on the string.\n */\nexport const MAX_PATH_SEGMENTS = 512;\n\n/** `$1` … `$128`, no leading zero: a loop index parameter (anything else after the `$` is not one). */\nexport const INDEX_PARAM = /^\\$[1-9]\\d{0,2}$/;\nexport const MAX_INDEX_PARAM = 128;\n\n/** Recursive wildcard — only meaningful in `$recursion` declarations, never in a binding path. */\nexport const RECURSION_WILDCARD = '**';\n","/**\n * フィルタ引数リストのパース。`filter(a, b)` の `a, b` 部分を受け取る。\n *\n * トリムの規則は「**クォートの外側だけ**」。`fix( 2 )` のような書き癖を吸収するために\n * 素の引数は前後をトリムするが、クォートは「ここは literal」という宣言なので中身の\n * 空白は残す。両方まとめてトリムしていたため `pad(5, ' ')` が空文字パディング\n * (=無変化)に化けており、空白区切りの `join(' / ')` も指定できなかった。\n *\n * Port of `@wcstack/state` `src/bindTextParser/parseFilterArgs.ts` (behaviour unchanged).\n */\nimport { raise, M } from \"../messages\";\n\n/** 引数 1 つを確定する。クォート由来の文字が入った範囲より外側だけをトリムする。 */\nfunction finalizeArg(text: string, firstQuoteStart: number, lastQuoteEnd: number): string {\n // 先頭側: 最初のクォート文字より前だけが削れる(クォートが無ければ全体が対象)\n const startLimit = firstQuoteStart === -1 ? text.length : firstQuoteStart;\n // 末尾側: 最後のクォート文字より後ろだけが削れる(クォートが無ければ全体が対象)\n const endLimit = lastQuoteEnd === -1 ? 0 : lastQuoteEnd;\n // (`trim` removes what `\\s` matches: WhiteSpace and LineTerminator)\n return text.slice(startLimit - text.slice(0, startLimit).trimStart().length, endLimit + text.slice(endLimit).trimEnd().length);\n}\n\n/** 引用符の無い引数の型(要件 B9): true / false / null / 数値は型付き、それ以外は文字列 */\nconst NUMBER_LITERAL = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/;\nfunction toLiteral(text: string, quoted: boolean): unknown {\n if (quoted) return text;\n if (text === \"true\") return true;\n if (text === \"false\") return false;\n if (text === \"null\") return null;\n return NUMBER_LITERAL.test(text) ? Number(text) : text;\n}\n\n/**\n * 引数の原文と、その型付きの値(要件 B9)を一緒に返す。原文は引用符を外したもの。\n *\n * 末尾の空引数だけが落ちる(`\"a,\"` → 1 個、`\",a\"` → 2 個、`\",\"` → 1 個)。`filter()` を\n * 「引数 0 個」と読むための規則で、先頭・中間の空引数は位置を保つために残す。\n */\nexport function parseFilterArgsWithLiterals(argsText: string): { args: string[]; literals: unknown[] } {\n const args: string[] = [];\n const literals: unknown[] = [];\n let current = '';\n let inQuote: string | null = null;\n let hasQuote = false;\n let firstQuoteStart = -1;\n let lastQuoteEnd = -1;\n\n /** Ends an argument; only the last one is dropped when empty (and not quoted). */\n const flush = (last?: boolean): void => {\n const arg = finalizeArg(current, firstQuoteStart, lastQuoteEnd);\n if (!last || arg || hasQuote) {\n args.push(arg);\n literals.push(toLiteral(arg, hasQuote));\n }\n current = '';\n hasQuote = false;\n firstQuoteStart = -1;\n lastQuoteEnd = -1;\n };\n\n for (let i = 0; i < argsText.length; i++) {\n const char = argsText[i];\n\n if (inQuote) {\n if (char === inQuote) {\n inQuote = null;\n } else {\n if (firstQuoteStart === -1) {\n firstQuoteStart = current.length;\n }\n current += char;\n lastQuoteEnd = current.length;\n }\n } else if (char === '\"' || char === \"'\") {\n inQuote = char;\n hasQuote = true;\n } else if (char === ',') {\n flush();\n } else {\n current += char;\n }\n }\n\n if (inQuote !== null) {\n // 閉じていない引用符は受理しない(要件 B2)。以前は黙って閉じたことにしていた\n raise(M.UnterminatedQuote, [inQuote, argsText]);\n }\n flush(true);\n\n return { args, literals };\n}\n","export const trimFn = (s: string): string => s.trim();\n\n/**\n * The positions of `char` in `text` that are outside quotes (`'` / `\"`), in order (要件 B1).\n * 閉じていない引用符はそのまま末尾まで続く扱い — 不正な引用符はフィルタ引数の段で名指しで落ちる。\n */\nfunction outsideQuotes(text: string, char: string): number[] {\n const found: number[] = [];\n let quote: string | null = null;\n for (let i = 0; i < text.length; i++) {\n const c = text[i];\n if (quote !== null) {\n if (c === quote) quote = null;\n } else if (c === \"'\" || c === '\"') {\n quote = c;\n } else if (c === char) {\n found.push(i);\n }\n }\n return found;\n}\n\n/** `text` の中で、引用符(`'` / `\"`)の外にある最初の `char` の位置。無ければ -1(要件 B1)。 */\nexport const indexOfOutsideQuotes = (text: string, char: string): number => outsideQuotes(text, char)[0] ?? -1;\n\n/**\n * `text` の中で、引用符の外にある**最後の** `char` の位置。無ければ -1(要件 B1)。\n * フィルタの閉じ括弧を探す用(`a|foo(')')` の引用符内の `)` を終端と誤認しないため)。\n */\nexport const lastIndexOfOutsideQuotes = (text: string, char: string): number => outsideQuotes(text, char).pop() ?? -1;\n\n/**\n * `separator` で区切る。ただし引用符の中は区切らない(要件 B1): `join(';')` や `join('|')` の\n * 区切り文字は引数であって、バインディングやフィルタの区切りではない。\n */\nexport function splitOutsideQuotes(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n for (const i of outsideQuotes(text, separator)) {\n parts.push(text.slice(start, i));\n start = i + 1;\n }\n parts.push(text.slice(start));\n return parts;\n}\n","import { FILTER_SEPARATOR, MODIFIER_SEPARATOR } from \"./define\";\nimport { parseFilterArgsWithLiterals } from \"./parseFilterArgs\";\nimport { raise, M } from \"../messages\";\nimport { FilterIOType, ParsedFilter } from \"./types\";\nimport { indexOfOutsideQuotes, lastIndexOfOutsideQuotes, splitOutsideQuotes, trimFn } from \"./utils\";\n\n// format: filterName(arg1,arg2) or filterName\n\n/**\n * 文法の段(要件 D16): 名前と引数だけを読む。**実関数は引かない** — フィルタ名の解決\n * (別名も含む)はエンジン側の仕事。未知のフィルタもここでは落とさない。\n *\n * Port of `@wcstack/state` `src/bindTextParser/parseFilters.ts` (behaviour unchanged; the\n * tooling-only `clearFilterFnCacheForTooling` is dropped).\n *\n * @param filterTextList 個々のフィルタの原文(`|` で切った後)\n * @param filterIOType 入力(左辺)/ 出力(右辺)。実関数は引かないが、助言の出し分けに使う\n * @param sourceText 診断に埋める原文。呼び出し側は**その辺の全文**(`propPart` / `statePart`)を\n * 渡すこと。`|` より後ろだけを渡すと、`textContent: a|` のように末尾が空の形で\n * 空文字になり、つなぎ直し(`filterTextList.join(\"|\")`)と同じで文脈が消える。\n * 省略時のつなぎ直しは、原文を持たない直接の呼び出し用のフォールバック\n */\nexport function parseFilters(filterTextList: string[], filterIOType: FilterIOType, sourceText?: string): ParsedFilter[] {\n const source = sourceText ?? filterTextList.join(\"|\");\n return filterTextList.map((filterText) => {\n // 括弧も引用符の外だけで探す(要件 B1)。素の `indexOf` / `lastIndexOf` だと\n // `foo(')')` の引用符内の `)` を終端に取り、「閉じ括弧が無い」ではなく\n // 「引用符が閉じていない」という見当違いの診断になっていた\n const openParenIndex = indexOfOutsideQuotes(filterText, '(');\n let closeParenIndex = lastIndexOfOutsideQuotes(filterText, ')');\n if (closeParenIndex === -1) {\n // 引用符の外に閉じ括弧が無い = 引用符が閉じていない形(`join('x)`)か、本当に無いか。\n // 前者で「閉じ括弧が無い」と言うのは見当違いなので素の探索へ落とし、引数の段の\n // `[wcs/binding-syntax] unterminated ' quote` に診断させる\n closeParenIndex = filterText.lastIndexOf(')');\n }\n // check parentheses\n if (openParenIndex !== -1 && closeParenIndex === -1) {\n raise(M.FilterUnclosed, [filterText]);\n }\n if (closeParenIndex !== -1 && openParenIndex === -1) {\n raise(M.FilterUnopened, [filterText]);\n }\n if (closeParenIndex !== -1 && closeParenIndex < openParenIndex) {\n // `foo)1(` — 以前は `substring` が start > end で引数を入れ替えるため、フィルタ名\n // `foo)1` として受理されていた\n raise(M.FilterParenOrder, [filterText]);\n }\n if (closeParenIndex !== -1 && filterText.slice(closeParenIndex + 1).trim().length > 0) {\n // 閉じ括弧の後ろの残余を**黙って捨てていた**。`n|fix(2)uc` は `uc` が消えて診断ゼロで\n // 通っていた。実害は「`|` の打ち忘れでフィルタが 1 本消えても無診断」\n const trailing = filterText.slice(closeParenIndex + 1).trim();\n raise(M.FilterTrailing, [filterText, trailing]);\n }\n const filterName = (openParenIndex === -1 ? filterText : filterText.substring(0, openParenIndex)).trim();\n if (filterName.length === 0) {\n // 空のフィルタ(`x|`・`x||y`・`x|(1)`)は文法の誤り。解析の段で名指しで落とす — 未知の\n // フィルタとは別物で、実関数の解決まで持ち越すと tooling の解析が素通りする\n raise(M.FilterEmpty, [source]);\n }\n if (filterName.includes(MODIFIER_SEPARATOR)) {\n // フィルタ名に `#` が飲まれた形。`[wcs/filter-unknown] filter not found: trim#ro` だと\n // 診断が指す先が実際の誤りと違う(要件 B4 の並び)。\n // 助言は辺で分ける — **修飾子は左辺にしか存在しない**ので、右辺で「修飾子をフィルタより\n // 前に書け」と言うと成立しない直し方(`textContent#ro|trim: x`)を勧めることになる\n const [, modifiers] = filterName.split(MODIFIER_SEPARATOR);\n raise(filterIOType === \"input\" ? M.FilterNameHasModifiersInput : M.FilterNameHasModifiersOutput, [filterName, modifiers]);\n }\n if (openParenIndex === -1) {\n // no arguments\n return { filterName, args: [], literals: [] };\n }\n const argsText = filterText.substring(openParenIndex + 1, closeParenIndex);\n return { filterName, ...parseFilterArgsWithLiterals(argsText) };\n });\n}\n\n/**\n * One side of a binding split at its first `|` outside quotes: the text before it (trimmed) and its\n * parsed filters. `cache` is keyed by the text after the `|`: the same text gives **the same array**\n * (callers must not change it); a failed parse is not cached. The diagnostics quote the whole side\n * (`part`): the text after the `|` alone is empty for `a|`.\n */\nexport function splitFilters(part: string, filterIOType: FilterIOType, cache: Map<string, ParsedFilter[]>): [string, ParsedFilter[]] {\n // 引用符の中の `|` はフィルタの区切りではない(要件 B1 — `join('|')`)\n const pos = indexOfOutsideQuotes(part, FILTER_SEPARATOR);\n if (pos === -1) return [part.trim(), []];\n const filtersText = part.slice(pos + 1).trim();\n let filters = cache.get(filtersText);\n if (filters === undefined) {\n filters = parseFilters(splitOutsideQuotes(filtersText, FILTER_SEPARATOR).map(trimFn), filterIOType, part);\n cache.set(filtersText, filters);\n }\n return [part.slice(0, pos).trim(), filters];\n}\n","import { DELIMITER, MAX_PATH_SEGMENTS, RECURSION_WILDCARD } from \"./define\";\nimport { splitFilters } from \"./parseFilters\";\nimport { raise, M } from \"../messages\";\nimport { ParsedBinding, ParsedFilter } from \"./types\";\n\n// 解析の段の形(フィルタは名前と引数だけ — 実関数はエンジンが引く。要件 D16)。\n// `@wcstack/state` はここで `statePathInfo`(`getPathInfo` の intern 結果)も返していたが、\n// 新エンジンはパスを自分で解決するので文字列だけを返す。\nexport type StatePartParseResult = Pick<ParsedBinding, 'statePathName' | 'outFilters'>;\n\n/**\n * 出力フィルタ列の解析結果のキャッシュ(鍵は `|` より後ろの原文)。同じ原文は**同じ配列**を返す —\n * 消費側は返された `outFilters` を変更しないこと。落ちた解析は載らない。\n * (`@wcstack/state` の tooling 専用の解放口 `clearStatePartCacheForTooling` は移植しない)\n */\nconst cacheFilterInfos = new Map<string, ParsedFilter[]>();\n/** Tooling (`clearParserCaches`): a long-running process drops what it parsed. */\nexport const clearStatePartCache = (): void => cacheFilterInfos.clear();\n\n/**\n * `getPathInfo` が初回 intern で行っていた文字列だけで決まる検査の移植(順序も同じ:\n * `**` → セグメント数)。`getPathInfo` は `**` のパスを intern しないので毎回落ち、\n * 上限超えのパスも intern されないので毎回落ちる — 状態を持たない検査と同値。\n */\nfunction checkPathLikeGetPathInfo(path: string): void {\n if (path.includes(RECURSION_WILDCARD)) {\n recursionUnsupported(path);\n }\n const segmentCount = path.split(DELIMITER).length;\n if (segmentCount > MAX_PATH_SEGMENTS) {\n raise(M.TooManySegments, [path, segmentCount]);\n }\n}\n\n// format: statePath|filter|filter\n// statePath-format: path.to.property (e.g., user.name.first, users.*.name, users.0.name, not include @)\n// filters-format: filterName or filterName(arg1,arg2)\n\n/** Port of `@wcstack/state` `src/bindTextParser/parseStatePart.ts` (no `statePathInfo`). */\n/** `**` outside the places a `$recursion` declaration gives it meaning. */\nexport function recursionUnsupported(path: string): never {\n raise(M.RecursionUnsupported, [path]);\n}\n\nexport function parseStatePart(statePart: string): StatePartParseResult {\n const [stateAndPath, filters] = splitFilters(statePart, \"output\", cacheFilterInfos);\n if (stateAndPath.includes(\"@\")) {\n // 名前次元は v2 で撤去(docs/state-mount-design.md D16 / §9)。パスは 1 本のツリー。\n raise(M.SelectorRemoved, [stateAndPath]);\n }\n const statePathName = stateAndPath;\n // 右辺も左辺(`parsePropPart`)と同じ規準で空セグメントを弾く(要件 B1)。\n //\n // **判定の前にループ相対の短縮形を正規化する。** `.` で始まる右辺は `for` 行の相対パスで\n // (展開はエンジンの仕事 — パーサは展開前の原文をそのまま返す)、先頭の空セグメント 1 つは正当。\n // とくに **`.` 単独は「行そのもの」を指す正規の書き方**(`state: .`)— 「先頭は許すが末尾は拒否」と\n // 素朴に書くと `\".\"` は `[\"\", \"\"]` = 先頭かつ末尾なので落ちる。取り除いた残りが空でも通すこと\n const isLoopRelative = statePathName.startsWith(DELIMITER);\n const body = isLoopRelative ? statePathName.slice(DELIMITER.length) : statePathName;\n const hasEmptySegment = body.length > 0 && body.split(DELIMITER).some((segment) => segment.length === 0);\n if (hasEmptySegment || (!isLoopRelative && body.length === 0)) {\n raise(M.EmptySegment, [statePart]);\n }\n checkPathLikeGetPathInfo(statePathName);\n return {\n statePathName,\n outFilters: filters,\n };\n}\n"],"mappings":"wCAiBO,IAAMA,EAAe,OAGfC,EAAwB,aAExBC,EAAwB,QACxBC,EAAoB,UACpBC,EAAkB,QAClBC,EAAiB,OACjBC,EAAkB,QAUlBC,EAAc,mBCbrBC,EAAiB,0CAehB,SAASC,EAA4BC,GAC1C,IAAMC,EAAiB,GACjBC,EAAsB,GACxBC,EAAU,GACVC,EAAyB,KACzBC,GAAW,EACXC,GAAkB,EAClBC,GAAe,EAGbC,EAASC,IACb,IAAMC,EApCV,SAAqBC,EAAcL,EAAyBC,GAE1D,IAAMK,GAAiC,IAApBN,EAAyBK,EAAKE,OAASP,EAEpDQ,GAA4B,IAAjBP,EAAsB,EAAIA,EAE3C,OAAOI,EAAKI,MAAMH,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,QAA0E,CAACkB,EAAYG,GAChH,CACA,OAAuB,IAAnBT,EAEK,CAAEM,KAAY1D,KAAM,GAAIC,SAAU,IAGpC,CAAEyD,QAAe5D,EADPqD,EAAWQ,UAAUP,EAAiB,EAAGC,MAG9D,CAecU,CAAa7B,EAAmBS,EAAa,KAAkBO,IAAIxB,GAASc,EAAcD,GACpGE,EAAMuB,IAAIrB,EAAaC,IAElB,CAACL,EAAKzB,MAAM,EAAG4B,GAAKd,OAAQgB,EACrC,CC/EA,IAAMqB,EAAmB,IAAIC,IAyBtB,SAASC,EAAqBC,GACnC3C,OAA8B,CAAC2C,GACjC,CAEO,SAASC,EAAeC,GAC7B,IAAOC,EAAc3B,GAAWN,EAAagC,EAAW,SAAUL,GAC9DM,EAAaX,SAAS,MAExBnC,KAAyB,CAAC8C,IAE5B,IAAMC,EAAgBD,EAOhBE,EAAiBD,EAAcE,WAAW,KAC1CC,EAAOF,EAAiBD,EAAc1D,MAAM,GAAoB0D,EAEtE,OADwBG,EAAK/D,OAAS,GAAK+D,EAAKb,MAAM,KAAWc,KAAMC,GAA+B,IAAnBA,EAAQjE,UAClE6D,GAAkC,IAAhBE,EAAK/D,SAC9Ca,MAAsB,CAAC6C,IArC3B,SAAkCF,GAC5BA,EAAKR,SAAS,OAChBO,EAAqBC,GAEvB,IAAMU,EAAeV,EAAKN,MAAM,KAAWlD,OACvCkE,EAAe,KACjBrD,MAAyB,CAAC2C,EAAMU,GAEpC,CA+BEC,CAAyBP,GAClB,CACLA,KACAQ,GAAYpC,EAEhB,QAAAqC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC,OAAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ var a="4.0.0-rc.9";export{a};
2
+ //# sourceMappingURL=chunk-SAUVGHSB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["VERSION","r"],"sources":["../../../package.json","../../../src/version.ts"],"sourcesContent":["{\n \"name\": \"@wcstack/state\",\n \"version\": \"4.0.0-rc.9\",\n \"description\": \"Reactive state management with declarative data binding for Web Components. Zero dependencies, buildless.\",\n \"type\": \"module\",\n \"main\": \"./dist/index.esm.js\",\n \"module\": \"./dist/index.esm.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.esm.js\"\n },\n \"./auto\": \"./dist/auto.min.js\",\n \"./core\": {\n \"types\": \"./dist/split/core.d.ts\",\n \"import\": \"./dist/split/core.js\"\n },\n \"./features/*\": {\n \"types\": \"./dist/split/features/*.d.ts\",\n \"import\": \"./dist/split/features/*.js\"\n },\n \"./define\": {\n \"types\": \"./dist/define.d.ts\",\n \"import\": \"./dist/define.js\"\n },\n \"./manifest\": {\n \"types\": \"./dist/manifest.d.ts\",\n \"import\": \"./dist/manifest.esm.js\"\n },\n \"./parser\": {\n \"types\": \"./dist/parser.d.ts\",\n \"import\": \"./dist/parser.esm.js\"\n },\n \"./wcs-manifest.json\": \"./dist/wcs-manifest.json\"\n },\n \"files\": [\n \"dist\",\n \"!dist/core.min.js\"\n ],\n \"scripts\": {\n \"clean\": \"node -e \\\"require('node:fs').rmSync('dist', { recursive: true, force: true })\\\"\",\n \"build\": \"node build.mjs\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"lint\": \"eslint src\",\n \"typecheck\": \"tsc --noEmit\",\n \"golden\": \"node scripts/golden.mjs\",\n \"version:patch\": \"npm version patch\",\n \"version:minor\": \"npm version minor\",\n \"version:major\": \"npm version major\",\n \"prepublishOnly\": \"npm run build && npm run test:coverage\"\n },\n \"keywords\": [\n \"web-components\",\n \"state-management\",\n \"reactive\",\n \"data-binding\",\n \"proxy\",\n \"custom-elements\",\n \"shadow-dom\",\n \"buildless\",\n \"zero-dependencies\",\n \"declarative\"\n ],\n \"author\": \"mogera551\",\n \"homepage\": \"https://wcstack.github.io\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/wcstack/wcstack.git\",\n \"directory\": \"packages/state\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/wcstack/wcstack/issues\"\n },\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.5\",\n \"@vitest/coverage-v8\": \"^4.1.11\",\n \"esbuild\": \"0.27.2\",\n \"eslint\": \"^9.39.5\",\n \"globals\": \"^16.5.0\",\n \"happy-dom\": \"^20.0.11\",\n \"rollup\": \"^4.63.5\",\n \"rollup-plugin-dts\": \"^6.5.1\",\n \"terser\": \"^5.51.2\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.70.1\",\n \"vitest\": \"^4.0.15\"\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\n\n/** The package version: stamped into `<wcs-ssr>`, compared on hydration (major.minor), shown by DevTools. */\nexport const VERSION: string = pkg.version;\n"],"mappings":"AAAA,ICGaA,EDDA,oBCCsBC","ignoreList":[]}
@@ -1 +1,2 @@
1
- import{b as t,c as e,d as s}from"./chunk-JMPQHCIT.js";import{n as i,o as n}from"./chunk-7EWPQMA6.js";import{f as o}from"./chunk-LTBR3OV5.js";import{a,b as r}from"./chunk-W5KT4PQ3.js";import{a as l,b as c}from"./chunk-ALVA5TQM.js";import{a as h,h as u,i as d}from"./chunk-V34ZHCK5.js";var m=0,f=new WeakMap;function p(t,e=t.getRootNode()){f.set(e,[...f.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function g(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?g(t):Promise.reject(i.errors[0]):void 0)}var b=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends b{constructor(){super(),this.engine=null,this.Dn=!1,this.Ke=!1,this.U=null,this.Ye=null,this.loaded=!1,this.cn=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.an=t,this.Eo=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.ln=t})}static{this.getBindingsReady=g}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Dn){if(null!==this.Ye)return void this.Ye.Xe();p(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Dn=!0;let e=this.getRootNode(),s=h.at?.(this,e);if(s)return this.Ye=s,!s.No&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.wt?this.Ro():s.wt()).then(t=>(this.loaded=!0,s.start(t,()=>this.Po()))).then(()=>{this.ln(),this.an()},t=>this.xt(t,s.No));this.start(e),p(this)}disconnectedCallback(){if(null!==this.Ye)return void this.Ye.Ln();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.xo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ke&&c(14),this.loaded)this.Ye.reset(t);else if(null===this.engine)if(null!==this.cn){let e=this.cn;this.cn=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.je++;try{e(s.proxy)}finally{"readonly"===t&&s.je--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++m}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.cn=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.Dn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Ye)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.En(),this.Po(),await f.ke("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.an()}catch(t){this.Ke=!this.V,this.xt(t)}}Po(){this.V=!0,this.ln()}xt(t,e){this.He(this.V?50:49,t),this.ln(),e?this.an():this.Eo(t)}He(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);console.error(`[@wcstack/state] ${l(t,[this.localName,...s])}`,e)}xo(t,e,s){(async()=>this.engine.ke(t))().then(s,t=>this.He(e,t))}},y=[];function k(){return(y=y.filter(t=>t.deref())).map(t=>t.deref())}function v(t,s){t&&r(t),function(t=customElements){e(),k().includes(t)||y.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends w{}),h.To?.(t)}(s)}var P=t=>g(t);export{g as a,b,k as c,v as d,P as e};
1
+ import{b as t,c as e,d as s}from"./chunk-55J45X6H.js";import{n as i,o as n}from"./chunk-L3PFEJP7.js";import{f as o}from"./chunk-7AYOQHZH.js";import{a,b as r}from"./chunk-M5SODAAE.js";import{a as l,b as c}from"./chunk-EIMTT5I3.js";import{a as h,h as u,i as d}from"./chunk-4NJBYXIT.js";var m=0,f=new WeakMap;function p(t,e=t.getRootNode()){f.set(e,[...f.get(e)??[],t].filter((t,e,s)=>t.isConnected&&s.lastIndexOf(t)===e))}function g(t){let e=f.get(t)??[],s=e.filter(e=>e.getRootNode()===t);return Promise.any(s.map(t=>t.initializePromise.then(()=>t.V||t.connectedCallbackPromise))).then(()=>{},i=>s.length?f.get(t)!==e?g(t):Promise.reject(i.errors[0]):void 0)}var b=typeof HTMLElement>"u"?class{}:HTMLElement,w=class extends b{constructor(){super(),this.engine=null,this.Dn=!1,this.Ke=!1,this.U=null,this.Ye=null,this.loaded=!1,this.cn=null,this.connectedCallbackPromise=new Promise((t,e)=>{this.an=t,this.Eo=e}),this.connectedCallbackPromise.catch(()=>{}),this.initializePromise=new Promise(t=>{this.ln=t})}static{this.getBindingsReady=g}static{this.hasConnectedCallbackPromise=!0}connectedCallback(){if(this.Dn){if(null!==this.Ye)return void this.Ye.Xe();p(this);let e=this.engine;if(null!==e){let s=e.root;s===this.getRootNode()&&!i.has(s)&&i.set(s,e),t(),h.element?.(e,"back"),this.xo("$connectedCallback",50,()=>{this.isConnected&&h.element?.(e,"connected")})}return}this.Dn=!0;let e=this.getRootNode(),s=h.at?.(this,e);if(s)return this.Ye=s,!s.No&&this.parentNode instanceof ShadowRoot&&p(this),void(void 0===s.wt?this.Ro():s.wt()).then(t=>(this.loaded=!0,s.start(t,()=>this.Po()))).then(()=>{this.ln(),this.an()},t=>this.xt(t,s.No));this.start(e),p(this)}disconnectedCallback(){if(null!==this.Ye)return void this.Ye.Ln();let t=this.engine;if(null===t)return;let e=t.root;i.get(e)===t&&i.delete(e),p(this,e),this.xo("$disconnectedCallback",51),h.element?.(t,"disconnected")}setInitialState(t){if(this.Ke&&c(14),this.loaded)this.Ye.reset(t);else if(null===this.engine)if(null!==this.cn){let e=this.cn;this.cn=null,e(t)}else this.U=t;else this.engine.reset(t)}createState(t,e){let s=this.engine;null===s&&c(15),"readonly"===t&&s.je++;try{e(s.proxy)}finally{"readonly"===t&&s.je--}}async createStateAsync(t,e){let s=this.engine;null===s&&c(15),await e("writable"===t?s.proxy:new Proxy(s.proxy,{get(t,e,s){let i=Reflect.get(t,e,s);return"$setAll"===e||"$resolve"===e?(...t)=>(t.length>2&&c(8),i(...t)):i},set(){c(8)}}))}async Ro(){await 0;let t=this.getAttribute("state");if(null!==t){let e=e=>[...e.querySelectorAll('script[type="application/json"]')].find(e=>e.id===t),s=e(this.getRootNode())??e(document);return void 0===s?Promise.reject(new Error(`[@wcstack/state] ${l(16,[t])}`)):Promise.resolve(JSON.parse(s.textContent||"{}"))}let e=this.getAttribute("src");if(null!==e)return async function(t){let e=new URL(t,document.baseURI).href;if(/\.json(?:[?#]|$)/.test(e)){let s=await fetch(e);return s.ok||c(13,[t,s.status]),await s.json()}return(await(import(e))).default??{}}(e);let s=this.getAttribute("json");if(null!==s)return Promise.resolve(JSON.parse(s));let i=this.querySelector('script[type="module"]');return null!==i?async function(t){let e=!1,s=t=>{t.effectiveDirective.startsWith("script-src")&&(e=!0)};document.addEventListener("securitypolicyviolation",s);let i="function"==typeof URL.createObjectURL,n=i?URL.createObjectURL(new Blob([t.text],{type:"application/javascript"})):"data:text/javascript;charset=utf-8,"+encodeURIComponent(`${t.text}\n//${++m}`);try{return(await(import(n))).default??{}}catch(t){throw await new Promise(t=>setTimeout(t)),new Error(`[@wcstack/state] ${e?l(42):l(43,[t instanceof Error?t.message:String(t)])}`,{cause:t})}finally{document.removeEventListener("securitypolicyviolation",s),i&&URL.revokeObjectURL(n)}}(i):null!==this.U?Promise.resolve(this.U):new Promise(t=>{this.cn=t})}async start(e){try{let a=e.host;(this.hasAttribute("mount")||this.hasAttribute("bind-component")||a?.hasAttribute("data-wc-definition"))&&d("scopes","<wcs-state>");let r=await this.Ro(),l=u(r);if(l&&await l,this.getRootNode()!==e)return this.U=r,this.Dn=!1,void(this.isConnected&&this.connectedCallback());this.hasAttribute("enable-ssr")&&d("ssr","enable-ssr");let m=i.get(e)?.element;m?.isConnected&&(m.V||m.Ye)&&c(47);let f=new o(r,new s);f.element=this,this.engine=f,h.element?.(f,"mounting"),n(f,e),t(),f.En(),this.Po(),await f.ke("$connectedCallback"),this.isConnected&&h.element?.(f,"connected"),this.an()}catch(t){this.Ke=!this.V,this.xt(t)}}Po(){this.V=!0,this.ln()}xt(t,e){this.He(this.V?50:49,t),this.ln(),e?this.an():this.Eo(t)}He(t,e){let s=["mount","bind-component","state","src"].flatMap(t=>this.hasAttribute(t)?[t,this.getAttribute(t)]:[]);console.error(`[@wcstack/state] ${l(t,[this.localName,...s])}`,e)}xo(t,e,s){(async()=>this.engine.ke(t))().then(s,t=>this.He(e,t))}},y=[];function k(){return(y=y.filter(t=>t.deref())).map(t=>t.deref())}function v(t,s){t&&r(t),function(t=customElements){e(),k().includes(t)||y.push(new WeakRef(t));let s=a.tagNames.state;void 0===t.get(s)&&t.define(s,class extends w{}),h.To?.(t)}(s)}var P=t=>g(t);export{g as a,b,k as c,v as d,P as e};
2
+ //# sourceMappingURL=chunk-UD3AYVP2.js.map