@jxsuite/compiler 8.4.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compiler.js CHANGED
@@ -1,78 +1,87 @@
1
- import{createRequire as hl}from"node:module";var ul=Object.create;var{getPrototypeOf:fl,defineProperty:wo,getOwnPropertyNames:pl}=Object;var Eo=Object.prototype.hasOwnProperty;function dl(e){return this[e]}var ml,gl,af=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?ml??=new WeakMap:gl??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?ul(fl(e)):{};let i=t||!e||!e.__esModule||!Eo.call(e,"default")?wo(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let c of pl(e))if(!Eo.call(i,c))wo(i,c,{get:dl.bind(e,c),enumerable:!0})}if(r)s.set(e,i);return i};var lf=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var j=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var uf=hl(import.meta.url);function b(e){return typeof e==="string"}function se(e){return typeof e==="number"}function me(e){return typeof e==="boolean"}function Se(e){return typeof e==="function"}function A(e){return typeof e==="object"&&e!==null}function D(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function H(e){return D(e)&&typeof e.$ref==="string"}function be(e){return D(e)&&e.$prototype==="Function"}function we(e){return D(e)&&D(e.$expression)}function xt(e){return we(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function st(e){return be(e)&&Array.isArray(e.body)}function ot(e){return D(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function He(e){return D(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function Jo(e){return D(e)&&!e.$prototype&&!e.$expression&&"default"in e}function it(e){if(!D(e))return!1;for(let t of Object.keys(e))if(!No.has(t))return!1;return!0}function ne(e){return D(e)&&e.$prototype==="Array"}function zr(e){return(Array.isArray(e)?e:[e]).some((n)=>ne(n))}function Ao(e){return D(e)&&e.$prototype==="Class"}function ln(e){return D(e)}function L(e){return typeof e==="string"&&e.includes("${")}function yt(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function xl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Be(e){if(!e)return[];return e.map((t)=>b(t)?t:t.name)}function yl(e){return typeof e==="string"}function Me(e){if(typeof e!=="object"||e===null||Array.isArray(e)||!D(e.$expression))return!1;let t=e.$expression;if(t.operator==="?:")return typeof t.value==="string"&&typeof t.initial==="string";if(t.operator==="switch")return D(t.cases)&&Object.values(t.cases).every((n)=>b(n))&&typeof t.default==="string";return!1}function jt(e){if(yl(e))return[e];if(!Me(e))return[];let t=e.$expression;if(t.operator==="?:")return[...new Set([t.value,t.initial])];return[...new Set([...Object.values(t.cases),t.default])]}var No;var z=j(()=>{No=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function ge(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function Oo(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let n=e.slice(2,-1).trim();return $l.has(n.toLowerCase())?n:e.slice(1)}return null}function cn(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function fn(e){return e.startsWith("@keyframes")}function Co(e,t){let n=[];for(let r of un(e))for(let s of un(t))n.push(Sl(r,s));return n.join(", ")}function Sl(e,t){let n=Vn(t,e);if(n!==null)return n;if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function Kr(e){let t=[],n=null,r=0;for(let s=0;s<e.length;s+=1){let o=e[s];if(n){if(o==="\\")s+=1;else if(o===n)n=null;continue}if(o==="\\")s+=1;else if(o==='"'||o==="'")n=o;else if(o==="[")r+=1;else if(o==="]")r=Math.max(0,r-1);else if(o==="&"&&r===0)t.push(s)}return t}function Vn(e,t){return Kr(e).length>0?bl(e,t):null}function bl(e,t){let n="",r=0;for(let s of Kr(e))n+=e.slice(r,s)+t,r=s+1;return n+e.slice(r)}function un(e){let t=[],n=0,r=null,s=0;for(let i=0;i<e.length;i+=1){let c=e[i];if(r){if(c==="\\")i+=1;else if(c===r)r=null;continue}if(c==='"'||c==="'")r=c;else if(c==="("||c==="[")n+=1;else if(c===")"||c==="]")n=Math.max(0,n-1);else if(c===","&&n===0)t.push(e.slice(s,i)),s=i+1}t.push(e.slice(s));let o=t.flatMap((i)=>{let c=i.trim();return c===""?[]:[c]});return o.length>0?o:[e]}function Ue(e){let t=/^\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)$/.exec(e.trim())?.[1];return t==="light"||t==="dark"?t:null}function Gr(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${Re}]))`,forced:`${e}:where([${Re}="${t}"])`};return{auto:`:where(:root:not([${Re}])) ${e}`,forced:`:where(:root[${Re}="${t}"]) ${e}`}}function at(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function Yr(e){return e.startsWith("--")?e:ge(e)}function Wn(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function jo(e,t,n){let r=n.map(([o,i])=>`${o}: ${i}`).join("; "),s=t===null?r:`${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function wl(e,t,n){let r=n.map(({selector:o,declarations:i})=>`${o} { ${i.map(([c,a])=>`${c}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function El(e){let t=Object.keys(e).filter((r)=>fn(r));if(t.length===0)return e;let n={...e};for(let r of t)delete n[r];return n}function Jl(e){let n=Kr(e).at(-1),r=n===void 0?e:e.slice(n+1);return r===""||r.startsWith(":")||r.startsWith(".")||r.startsWith("[")}function vt(e,t={}){let{scope:n=null,mediaQueries:r={},transposeValue:s=(m)=>m,transposeSelector:o=(m)=>m,resolveValue:i}=t,c=[],a=(m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)&&!H(m),l=(m,x)=>{if(a(x))return[x];if(!cn(m)||!Array.isArray(x)||x.length===0)return[];return x.every((E)=>a(E))?x:[]},u=(m,x,E,O)=>{if(x===void 0||x===null)return null;if(H(x))return E?i?.(m,x,O)??null:null;if(A(x))return null;let J=String(x);if(L(J))return E?i?.(m,J,O)??null:null;return s(J)},f=(m,x,E=!0,O="self")=>{let J=[];for(let[C,q]of Object.entries(m)){if(l(C,q).length>0)continue;if(x&&(C.startsWith("@")||at(C)))continue;if(C.startsWith("$"))continue;let S=u(C,q,E,O);if(S!==null)J.push([Yr(C),S])}return J},p=(m,x,E,O,J)=>{if(E.length===0)return;let C=x;if(C!==null){let y=o(C);if(y===null)return;C=y}let q=jo(m,C,E),S={text:q,conditions:[...m],selector:C,declarations:E,target:O,key:Wn(q)};if(b(J)&&J!=="")S.description=J;c.push(S)},d=(m,x,E)=>{let O=m.slice(10).trim();if(O==="")return;let J=[];for(let[q,S]of Object.entries(x)){if(!a(S))continue;let y=f(S,!0,!1,"unscoped");if(y.length>0)J.push({declarations:y,selector:q.trim()})}if(J.length===0)return;let C=wl(E,O,J);c.push({blocks:J,conditions:[...E],declarations:[],key:Wn(C),selector:null,target:"unscoped",text:C})},h=(m,x,E,O,J)=>{if(m==="@--")return;if(cn(m)){p([...O,m],null,f(x,!1,!0,"unscoped"),"unscoped",x.$description);return}if(fn(m)){d(m,x,O);return}let C=Oo(m,r),q=C===null?m:`@media ${C}`,S=C===null?null:Ue(C);if(S!==null&&E!==null){let{auto:y,forced:w}=Gr(E,S);g(x,y,[...O,q],J),g(El(x),w,O,J);return}g(x,E,[...O,q],J)};function g(m,x,E,O){p(E,x,f(m,!0,!0,O),O,m.$description);for(let[J,C]of Object.entries(m))for(let q of l(J,C))if(J.startsWith("@"))h(J,q,x,E,O);else if(x!==null)g(q,Co(x,J),E,Jl(J)?O:"descendant")}return g(e,n,[],"self"),c}var $l,Re="data-color-scheme",Hn="jx-color-scheme";var pn=j(()=>{z();$l=new Set(["all","print","screen","speech"])});function gf(){return`the Intl helpers ${Zr.join(", ")}`}var De="en-US",Xr="UTC",vo,Zr,To;var Ro=j(()=>{vo=[{api:"Intl.NumberFormat",params:["value","locale","options"],path:"Intl/formatNumber",summary:"Format a number for a locale — grouping, decimals, currency, percent, units."},{api:"Intl.DateTimeFormat",params:["value","locale","options"],path:"Intl/formatDate",summary:"Format a date or timestamp for a locale. Pass `timeZone` in options."},{api:"Intl.RelativeTimeFormat",params:["value","unit","locale","options"],path:"Intl/formatRelativeTime",summary:'Format a relative time — `-3, "day"` becomes "3 days ago".'},{api:"Intl.ListFormat",params:["values","locale","options"],path:"Intl/formatList",summary:'Join a list the way a locale does — "a, b, and c", not a hand-written comma join.'},{api:"Intl.PluralRules",params:["value","locale","options"],path:"Intl/plural",summary:'Which plural category a number falls in ("one", "few", "other") — many languages have '+"more than two, so a ternary on `n === 1` is wrong outside English."},{api:"Intl.Collator",params:["a","b","locale","options"],path:"Intl/compare",summary:'Compare two strings for sorting. `<` and `sort()` order by UTF-16 code unit, which puts "Zebra" before "apple" and sorts every accented word into the wrong place.'},{api:"Intl.DisplayNames",params:["code","type","locale","options"],path:"Intl/displayName",summary:'The name of a language, region, script or currency in a locale — "de" as "German" or '+'"Deutsch", from CLDR rather than a hand-kept table.'},{api:"Intl.Segmenter",params:["value","granularity","locale"],path:"Intl/segment",summary:"Split text into graphemes, words or sentences (UAX #29). `[...str]` splits code points, so it cuts an emoji with a skin-tone modifier in half."}],Zr=vo.map((e)=>e.path),To=Object.fromEntries(vo.map((e)=>[e.path,e.params.indexOf("locale")]))});function Nl(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function re(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function qe(e){if(e==="")return[];return e.split("/").map((t)=>Nl(t))}function oe(e,t){let n=e;for(let r of qe(t))n=n?.[r];return n}function k(e,t){let n=e;for(let r of qe(t))n+=Qr.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;return n}function _o(e,t){let n=e;for(let[r,s]of qe(t).entries()){let o=r===0?"":"?.";n+=Qr.test(s)?`${r===0?".":o}${s}`:`${o}[${JSON.stringify(s)}]`}return n}function ze(e){return Qr.test(e)?e:JSON.stringify(e)}function Po(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var Qr;var Tt=j(()=>{Qr=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function es(e){let t=e.$map;return A(t)?t:void 0}function Do(e){return A(e)&&!Array.isArray(e)&&"operator"in e}function dn(e){return A(e)&&!Array.isArray(e)&&"$ref"in e}function jl(e,t,n){let r=To[e];if(r===void 0||r<0||t[r]!=null)return t;let s=oe(n.$page,"locale");if(!b(s)||s==="")return t;let o=[...t];return o[r]=s,o}function Vo(e){return e.startsWith("window#/")&&Ol.has(e.slice(8))}function Ke(e){return Fo.has(e)}function G(e,t){if(!e)return;let n=(e.depth??0)+1;if(n>vl)return;return{depth:n,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function K(e,t,n,r,s){if(e===null||e===void 0)return e;if(Do(e))return Ee(e,t,n,r,s);if(dn(e)){let o=Bn(e.$ref,t,n,r);return s?.report(s.path??[],o),o}if(Array.isArray(e))return Ho(e,t,n,r,s);return s?.report(s.path??[],e),e}function Ho(e,t,n,r,s){return e.map((o,i)=>K(o,t,n,r,G(s,i)))}function Tl(e,t,n,r){let s=(o)=>{if(!e.slice(o.length).includes("/"))return t;return Bn(e.slice(0,e.lastIndexOf("/")),t,n,r)};if(e.startsWith("#/state/"))return s("#/state/");if(e.startsWith("parent#/"))return s("parent#/");if(e.startsWith("$map/")||e.startsWith("$args/"))return e.split("/").length>2?Bn(e.slice(0,e.lastIndexOf("/")),t,n,r):void 0;return}function Bn(e,t,n,r){if(e==="$reduce/acc")return r?.acc;if(e.startsWith("$reduce/"))return r?.acc;if(e.startsWith("$args/")){let s=e.slice(6).split("/"),o=r?.args?.[s[0]];return s.length>1?oe(o,s.slice(1).join("/")):o}if(e.startsWith("event#/")){let s=e.slice(7);return oe(n,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,c=es(t);if(o==="item")i=r?.item??c?.item??t["$map/item"];else if(o==="index")i=r?.index??c?.index??t["$map/index"];else i=c?.[o]??t[`$map/${o}`];return s.length>2?oe(i,s.slice(2).join("/")):i}if(e.startsWith("#/state/"))return oe(t,e.slice(8));if(e.startsWith("parent#/"))return oe(t,e.slice(8));if(e.startsWith("window#/"))return oe(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return oe(globalThis.document,e.slice(10));return oe(t,e)??null}function Rl(e,t,n,r){if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,c=es(t);if(o==="item")i=r?.item??c?.item??t["$map/item"];else if(o==="index")i=r?.index??c?.index??t["$map/index"];else i=c?.[o]??t[`$map/${o}`];if(s.length>2){let a=s.slice(2),l=a.pop(),u=a.length>0?oe(i,a.join("/")):i;return{key:l,obj:u}}return{key:o==="item"?"$map/item":"$map/index",obj:es(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let i=qe(s),c=i.pop(),a=t;for(let l of i)a=a[l];return{key:c,obj:a}}return{key:e,obj:t}}function Ee(e,t,n,r,s){let o=_l(e,t,n,r,s);return s?.report(s.path??[],o),o}function Io(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;case"<":return t<n;case"<=":return t<=n;case">":return t>n;default:return t>=n}}function _l(e,t,n,r,s){let{operator:o,target:i,value:c,initial:a}=e;if(!Al.has(o))throw Error(`$expression: unknown operator "${o}"`);if(ts.has(o)&&!("value"in e)){let l=K(i,t,n,r,G(s,"target"));if(o==="!")return!l;if(o==="-")return-l}if(o==="call"){let l=dn(i)?i.$ref:void 0;if(!b(l))throw TypeError("$expression: call target must be a $ref pointer");let u=(r?.callDepth??0)+1;if(u>ko)throw Error(`$expression: call depth exceeded (${ko})`);let f=Array.isArray(c)?c.map((d,h)=>K(d,t,n,r,G(s,["value",h]))):[];if(l.startsWith("window#/")){if(!Vo(l))throw Error(`$expression: "${l}" is not a blessed pure global`);let d=l.slice(8),h=Cl.get(d);if(h)return h(...jl(d,f,t));let g=oe(globalThis.window,d),m=d.lastIndexOf("/"),x=m===-1?globalThis.window:oe(globalThis.window,d.slice(0,m));return g.apply(x,f)}let p=Bn(l,t,n,r);if(Se(p))return p.apply(Tl(l,t,n,r),f);if(A(p)&&"$expression"in p){let d=p,h={};for(let[g,m]of(d.parameters??[]).entries()){let x=b(m)?m:m?.name??"";if(!x)continue;h[x]=f[g]===void 0&&A(m)&&"default"in m?m.default:f[g]}return Ee(d.$expression,t,n,{args:h,callDepth:u})}throw TypeError(`$expression: call target "${l}" is not callable`)}if(ss.has(o)){if(o==="?:"){let d=K(i,t,n,r,G(s,"target"));if(s){let h=K(c,t,n,r,G(s,"value")),g=K(a,t,n,r,G(s,"initial"));return d?h:g}return d?K(c,t,n,r):K(a,t,n,r)}let l=K(i,t,n,r,G(s,"target")),u=String(l),f=e.cases??{},p=Object.hasOwn(f,u);if(s){let d;for(let[g,m]of Object.entries(f)){let x=K(m,t,n,r,G(s,["cases",g]));if(g===u)d=x}let h=K(e.default,t,n,r,G(s,"default"));return p?d:h}return p?K(f[u],t,n,r):K(e.default,t,n,r)}if(ns.has(o)){let l=K(i,t,n,r,G(s,"target")),u=K(c,t,n,r,G(s,"value"));switch(o){case"===":return l===u;case"!==":return l!==u;case"&&":return l&&u;case"||":return l||u;case"??":return l??u;default:return Io(o,l,u)}}if(Lo.has(o)){let l=K(c,t,n,r,G(s,"value")),{obj:u,key:f}=Rl(i.$ref,t,n,r);u[f]=o==="="?l:Io(o.slice(0,-1),u[f],l);return}if(Wo.has(o)){let l=K(i,t,n,r,G(s,"target"));switch(o){case"push":return l.push(K(c,t,n,r,G(s,"value")));case"unshift":return l.unshift(K(c,t,n,r,G(s,"value")));case"pop":return l.pop();case"shift":return l.shift();case"splice":{let u=K(c,t,n,r,G(s,"value"));return l.splice(...u)}default:break}}if(os.has(o)){let l=K(i,t,n,r,G(s,"target")),u=c===void 0?[]:Array.isArray(c)?Ho(c,t,n,r,G(s,"value")):[K(c,t,n,r,G(s,"value"))],f=oe(l,o);if(!Se(f))return;return f.apply(l,u)}if(rs.has(o)){let l=K(i,t,n,r,G(s,"target")),u=c;if(o==="reduce"){let f=K(a,t,n,r,G(s,"initial"));for(let[p,d]of l.entries())f=Ee(u,t,n,{acc:f,index:p,item:d},p===0?G(s,"value"):void 0);return f}if(o==="map")return l.map((f,p)=>Ee(u,t,n,{...r,index:p,item:f},p===0?G(s,"value"):void 0));if(o==="filter")return l.filter((f,p)=>Ee(u,t,n,{...r,index:p,item:f},p===0?G(s,"value"):void 0))}return}function Y(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(Do(e))return pe(e,t);if(dn(e))return is(e.$ref,t);if(Array.isArray(e))return e.map((n)=>Y(n,t)).join(", ");return JSON.stringify(e)}function Pl(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function is(e,t){let n=t.statePrefix??"state",r=t.eventParam??"event";if(e==="$reduce/acc")return"_acc";if(e.startsWith("$reduce/"))return"_acc";if(e.startsWith("$args/"))return k("_args",e.slice(6));if(e.startsWith("event#/"))return k(r,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s;if(o==="item")return s.length>2?k("_item",s.slice(2).join("/")):"_item";if(o==="index")return"_index";return`_${o}`}if(e.startsWith("#/state/"))return k(n,e.slice(8));if(e.startsWith("parent#/"))return k(n,e.slice(8));if(e.startsWith("window#/"))return k("window",e.slice(8));if(e.startsWith("document#/"))return k("document",e.slice(10));return k(n,e)}function Mo(e,t){if(dn(e))return is(e.$ref,t);return Y(e,t)}function kl(e,t,n){let r=(i)=>t[i]??"undefined",s=`(${n.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(De)})`,o=JSON.stringify(Xr);switch(e){case"Intl/formatNumber":return`new Intl.NumberFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/formatDate":return`new Intl.DateTimeFormat(${r(1)} ?? ${s}, {timeZone: ${o}, ...${r(2)}}).format(new Date(${r(0)}))`;case"Intl/formatRelativeTime":return`new Intl.RelativeTimeFormat(${r(2)} ?? ${s}, ${r(3)}).format(${r(0)}, ${r(1)})`;case"Intl/formatList":return`new Intl.ListFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/plural":return`new Intl.PluralRules(${r(1)} ?? ${s}, ${r(2)}).select(${r(0)})`;case"Intl/compare":return`new Intl.Collator(${r(2)} ?? ${s}, ${r(3)}).compare(${r(0)}, ${r(1)})`;case"Intl/displayName":return`new Intl.DisplayNames(${r(2)} ?? ${s}, {...${r(3)}, type: ${r(1)} ?? 'language'}).of(${r(0)})`;case"Intl/segment":return`[...new Intl.Segmenter(${r(2)} ?? ${s}, {granularity: ${r(1)} ?? 'grapheme'}).segment(${r(0)})].map((p) => p.segment)`;default:return null}}function pe(e,t={}){let{operator:n,target:r,value:s,initial:o}=e;if(ts.has(n)&&!("value"in e)){let i=Y(r,t);if(n==="!")return`!(${i})`;if(n==="-")return`-(${i})`}if(n==="call"){let i=(dn(r)?r.$ref:void 0)??"",c=Array.isArray(s)?s.map((a)=>Y(a,t)):[];if(i.startsWith("window#/")){if(!Vo(i))throw Error(`$expression: "${i}" is not a blessed pure global`);let a=kl(i.slice(8),c,t);if(a)return a;return`window.${i.slice(8).replaceAll("/",".")}(${c.join(", ")})`}if(i.startsWith("#/state/")){let a=i.slice(8),l=t.formulaParams?.[a];if(l){let u=l.map((f,p)=>`${JSON.stringify(f)}: ${c[p]??"undefined"}`).join(", ");return`${Pl(a)}(${t.statePrefix??"state"}, { ${u} })`}}return`${is(i,t)}(${c.join(", ")})`}if(ss.has(n)){if(n==="?:"){let l=Y(r,t),u=Y(s,t),f=Y(o,t);return`(${l} ? ${u} : ${f})`}let i=Y(r,t),c=Object.entries(e.cases??{}).map(([l,u])=>`_d === ${JSON.stringify(l)} ? ${Y(u,t)} : `).join(""),a="default"in e?Y(e.default,t):"undefined";return`((_d) => ${c}${a})(String(${i}))`}if(ns.has(n)){let i=Y(r,t),c=Y(s,t);return`(${i} ${n} ${c})`}if(Lo.has(n)){let i=Mo(r,t),c=Y(s,t);return`${i} ${n} ${c}`}if(Wo.has(n)){let i=Mo(r,t);switch(n){case"push":return`${i}.push(${Y(s,t)})`;case"unshift":return`${i}.unshift(${Y(s,t)})`;case"pop":return`${i}.pop()`;case"shift":return`${i}.shift()`;case"splice":{let c=Array.isArray(s)?s.map((a)=>Y(a,t)).join(", "):Y(s,t);return`${i}.splice(${c})`}default:break}}if(os.has(n)){let i=Y(r,t),c=s===void 0?"":Array.isArray(s)?s.map((a)=>Y(a,t)).join(", "):Y(s,t);return`(${i})?.${n}?.(${c})`}if(rs.has(n)){let i=Y(r,t),c=pe(s,t);if(n==="reduce"){let a=Y(o,t);return`${i}.reduce((_acc, _item, _index) => ${c}, ${a})`}if(n==="map")return`${i}.map((_item, _index) => ${c})`;if(n==="filter")return`${i}.filter((_item, _index) => ${c})`}return"undefined"}function Rt(e,t,n,r){return K(e,t,n,r)}function Ge(e,t={}){return Y(e,t)}var Fo,ts,ns,Lo,Wo,rs,ss,os,Al,Ol,Cl,ko=64,vl=64;var mn=j(()=>{Ro();z();Tt();Fo=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),ts=new Set(["!","-"]),ns=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),Lo=new Set(["=","+=","-=","*=","/="]),Wo=new Set(["push","pop","shift","unshift","splice"]),rs=new Set(["reduce","map","filter"]),ss=new Set(["?:","switch"]),os=new Set(["includes","indexOf","lastIndexOf","join","slice","concat","at","flat","toSorted","toReversed","toSpliced","with","toUpperCase","toLowerCase","trim","trimStart","trimEnd","split","startsWith","endsWith","padStart","padEnd","replaceAll","repeat","charAt","normalize","toLocaleUpperCase","toLocaleLowerCase","toFixed","toPrecision","toLocaleString"]),Al=new Set([...Fo,...ts,...ns,...rs,...ss,...os,"call"]),Ol=new Set(["isNaN","isFinite","parseFloat","parseInt","encodeURIComponent","decodeURIComponent","structuredClone","Math/abs","Math/ceil","Math/floor","Math/round","Math/trunc","Math/sign","Math/sqrt","Math/cbrt","Math/pow","Math/exp","Math/log","Math/log2","Math/log10","Math/min","Math/max","Math/hypot","Number/isInteger","Number/isFinite","Number/isNaN","Number/parseFloat","Number/parseInt","JSON/parse","JSON/stringify","Object/keys","Object/values","Object/entries","Object/fromEntries","Array/from","Array/isArray","Array/of","String/fromCharCode","String/fromCodePoint",...Zr]),Cl=new Map([["Intl/compare",(e,t,n,r)=>new Intl.Collator(n??De,r).compare(e,t)],["Intl/displayName",(e,t,n,r)=>new Intl.DisplayNames(n??De,{...r,type:t??"language"}).of(e)],["Intl/formatDate",(e,t,n)=>new Intl.DateTimeFormat(t??De,{timeZone:Xr,...n}).format(new Date(e))],["Intl/formatList",(e,t,n)=>new Intl.ListFormat(t??De,n).format(e)],["Intl/formatNumber",(e,t,n)=>new Intl.NumberFormat(t??De,n).format(e)],["Intl/formatRelativeTime",(e,t,n,r)=>new Intl.RelativeTimeFormat(n??De,r).format(e,t)],["Intl/plural",(e,t,n)=>new Intl.PluralRules(t??De,n).select(e)],["Intl/segment",(e,t,n)=>[...new Intl.Segmenter(n??De,{granularity:t??"grapheme"}).segment(e)].map((r)=>r.segment)]])});function Il(e){return e.startsWith(Bo)}function Ef(e){let t=e;if(Il(t))t=t.slice(Bo.length);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`${as}${t}.js`}function Jf(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",n=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`${as}${n}`:`${as}${n}.${t}`}function Uo(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function qo(e){let t=Uo(e);return t.startsWith("/")?t:`/${t}`}function Ml(e,t){return[...e].toSorted((n,r)=>r[t].length-n[t].length)}function Nf(e,t){let n=t.split("#")[0].split("?")[0];if(!n.startsWith("/"))return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(/%2e|%2f/i.test(r))return null;for(let s of Ml(e,"urlPrefix")){let o=qo(s.urlPrefix);if(!r.startsWith(`${o}/`))continue;let c=r.slice(o.length+1).split("/");if(c.some((l)=>l===""||l==="."||l===".."))return null;let{filter:a}=s;if(a&&!a(c.join("/")))return null;return`${Uo(s.dir)}/${c.join("/")}`}return null}function Af(e,t){let n=new Set;for(let r of t){let s=qo(r.urlPrefix),o=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${Dl}]+`,"g");for(let i of e.matchAll(o)){let c=i[0].split("#")[0].split("?")[0];if(!c.endsWith("/"))n.add(c)}}return[...n].filter(Boolean)}function Fl(e){let t=[],n=0;while(n<e.length){while(n<e.length&&(/\s/.test(e[n])||e[n]===","))n+=1;if(n>=e.length)break;let r=n;while(n<e.length&&!/\s/.test(e[n]))n+=1;let s=e.slice(r,n);if(s.endsWith(",")){t.push({descriptor:"",url:s.replace(/,+$/,"")});continue}while(n<e.length&&/\s/.test(e[n]))n+=1;let o=n;while(n<e.length&&e[n]!==",")n+=1;let i=e.slice(o,n).trim();if(n+=1,s=s.replace(/,+$/,""),s!=="")t.push({descriptor:i,url:s})}return t}function Ll(e){return e.map(({url:t,descriptor:n})=>n?`${t} ${n}`:t).join(", ")}function Of(e){if(!b(e)||e==="")return"";let t;try{({pathname:t}=new URL(e))}catch{return""}let n=t.replace(/\/+$/,"");if(n===""||n==="/")return"";return n.startsWith("/")?n:`/${n}`}function zo(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function Cf(e,t){let n=new URL(t);if(!n.pathname.endsWith("/"))n.pathname+="/";return new URL(e.replace(/^\/+/,""),n).href}var Bo="npm:",as="/assets/",Dl;var ls=j(()=>{z();Dl=String.raw`"'\s<>()\\`});function Ko(e){if("operator"in e)return{kind:"expression",node:e};if("if"in e)return{kind:"if",node:e};if("$switch"in e)return{kind:"switch",node:e};if("stopPropagation"in e)return{kind:"stopPropagation"};if("preventDefault"in e)return{kind:"preventDefault"};return{kind:"dispatch",node:e}}function Wl(e){return(A(e)||Se(e))&&"then"in e&&Se(e.then)}async function _t(e,t,n,r={}){let s=r.args?{args:r.args}:void 0;for(let o of e){let i=Ko(o);switch(i.kind){case"expression":{let c=Ee(i.node,t,n,s);if(Wl(c))await c;break}case"if":{let c=i.node,a=Rt(c.if,t,n,s)?c.then:c.else;if(Array.isArray(a))await _t(a,t,n,r);break}case"switch":{let c=i.node,a=String(Rt(c.$switch,t,n,s)),l=c.cases??{},u=Object.hasOwn(l,a)?l[a]:c.default;if(Array.isArray(u))await _t(u,t,n,r);break}case"dispatch":{let c=i.node,a=Se(r.target)?r.target():r.target,l=n?.currentTarget??a;if(!l)break;let u={};if("detail"in c)u.detail=Rt(c.detail,t,n,s);if(c.bubbles!==void 0)u.bubbles=c.bubbles;if(c.composed!==void 0)u.composed=c.composed;l.dispatchEvent(new CustomEvent(c.dispatchEvent,u));break}case"stopPropagation":{n?.stopPropagation();break}case"preventDefault":{n?.preventDefault();break}default:break}}}function Ce(e,t={}){let n=t.indent??"",r=[];for(let s of e){let o=Ko(s);switch(o.kind){case"expression":{r.push(`${n}${pe(o.node,t)};`);break}case"if":{let i=o.node,c=Ge(i.if,t),a={...t,indent:`${n} `};if(r.push(`${n}if (${c}) {`,Ce(i.then??[],a)),i.else)r.push(`${n}} else {`,Ce(i.else,a));r.push(`${n}}`);break}case"switch":{let i=o.node,c=Ge(i.$switch,t),a={...t,indent:`${n} `};r.push(`${n}switch (String(${c})) {`);for(let[l,u]of Object.entries(i.cases??{}))r.push(`${n} case ${JSON.stringify(l)}: {`,Ce(u,a),`${n} break;`,`${n} }`);if(i.default)r.push(`${n} default: {`,Ce(i.default,a),`${n} }`);r.push(`${n}}`);break}case"dispatch":{let i=o.node,c=t.eventParam??"event",a=t.dispatchTarget??`(${c} && ${c}.currentTarget)`,l=[];if("detail"in i)l.push(`detail: ${Ge(i.detail,t)}`);if(i.bubbles!==void 0)l.push(`bubbles: ${JSON.stringify(i.bubbles)}`);if(i.composed!==void 0)l.push(`composed: ${JSON.stringify(i.composed)}`);let u=l.length>0?`, { ${l.join(", ")} }`:"";r.push(`${n}${a}?.dispatchEvent(new CustomEvent(${JSON.stringify(i.dispatchEvent)}${u}));`);break}case"stopPropagation":{r.push(`${n}${t.eventParam??"event"}?.stopPropagation();`);break}case"preventDefault":{r.push(`${n}${t.eventParam??"event"}?.preventDefault();`);break}default:break}}return r.join(`
2
- `)}var Un=j(()=>{z();mn()});function qn(e){if(!e.startsWith("${")||!e.endsWith("}"))return!1;let t=0;for(let n=1;n<e.length;n+=1){let r=e[n];if(r==="{")t+=1;else if(r==="}"){if(t-=1,t===0)return n===e.length-1}}return!1}function Yo(){return[...Go].toSorted()}function $t(e,t){let n=e.toLowerCase();if(n.startsWith("aria-")||Go.has(n))return String(t);return t?"":null}var Ye,Go,cs=32,zn,Kn="jx-slot",us="data-jx-slots",fs="jx.slot.group",Uf;var gn=j(()=>{pn();mn();Tt();z();ls();Un();pn();Ye=new Set(["$schema","$id","$defs","state","$ref","$props","$elements","$title","$description","$switch","$prototype","$src","$export","$media","$map","timing","default","description","body","parameters","arguments","name","tagName","children","style","attributes","items","map","filter","sort","cases","observedAttributes"]),Go=new Set(["contenteditable","draggable","spellcheck"]);zn=/^[\t\n\f\r ]+$/u,Uf=(()=>{let e=Symbol.for(fs),t=globalThis;return t[e]??=new WeakMap,t[e]})()});function Xo(e,t,n,r,s=Hl){let o=[],i=(f,p)=>{let d={mediaQueries:t,scope:p,transposeValue:n};if(r)d.resolveValue=(h,g)=>r(h,g,p);for(let h of vt(f,d))o.push(h.text)},c={},a={},l=[],u=[];for(let[f,p]of Object.entries(e)){if(A(p)&&!Array.isArray(p)){if(f.startsWith("@"))l.push([f,p]);else if(!f.startsWith("--"))u.push([f,p]);continue}if(at(f)||f.startsWith("@"))continue;if(f.startsWith("--")||f==="colorScheme"||f==="color-scheme")c[f]=p;else a[f]=p}i(c,s.root),i(a,s.body);for(let[f,p]of u)if(f.startsWith("&"))i({[f]:p},s.root);else i(p,f);for(let[f,p]of l){if(cn(f)||fn(f)){i({[f]:p},null);continue}let d={},h={},g=[];for(let[m,x]of Object.entries(p)){if(A(x)&&!Array.isArray(x)){if(!m.startsWith("@"))g.push([m,x]);continue}if(m.startsWith("--"))d[m]=x;else h[m]=x}i({[f]:d},s.root),i({[f]:h},s.body);for(let[m,x]of g)i({[f]:x},m)}if(Object.values(t).some((f)=>Ue(f)!==null)&&!("colorScheme"in e))o.push(`${s.root} { color-scheme: light dark }`,`${s.root}:where([${Re}="light"]) { color-scheme: light }`,`${s.root}:where([${Re}="dark"]) { color-scheme: dark }`);return o.join(`
3
- `)}var Hl;var Zo=j(()=>{pn();z();Hl={body:"body",root:":root"}});function Qo(e){return e===!1||e==="open"||e==="closed"}function Gn(e,t){let n=e?.$shadow;if(Qo(n))return n===!1?null:n;let r=t?.shadow;return Qo(r)&&r!==!1?r:null}function ei(e,t){return t===null?e:":host"}function xn(e,t){let n=[];for(let[r,s]of(e.parameters??[]).entries()){let o=ti(s);if(!o)continue;let i=ni(s)?`_a[${r}] === undefined ? ${JSON.stringify(s.default)} : _a[${r}]`:`_a[${r}]`;n.push(`${JSON.stringify(o)}: ${i}`)}return`(..._a) => { const _args = { ${n.join(", ")} }; return ${t}; }`}function ti(e){return b(e)?e:e?.name??""}function ni(e){return A(e)&&"default"in e}function Qn(e,t){let n=xs(e,t);return n===e?e:`${n} as ${e}`}function xs(e,t){let n=t?.$export;return b(n)&&n!==""?n:e}function er(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o}=n,{url:i}=t,c=L(i),a=t.method??"GET";if(t.manual)return`${s}// ${e}: manual Request — fetch triggered by user action`;let l=[`// ${e}: auto-fetch from ${c?"(dynamic URL)":i}`,o?`${o}.push(effect(() => {`:"effect(() => {"];if(c)l.push(` const url = \`${Ul(i,r)}\`;`,' if (!url || url === "undefined" || url.includes("undefined")) return;');else l.push(` const url = ${JSON.stringify(i)};`);let u=[];if(a!=="GET")u.push(`method: ${JSON.stringify(a)}`);if(t.headers)u.push(`headers: ${JSON.stringify(t.headers)}`);if(t.body){let p=A(t.body)?JSON.stringify(JSON.stringify(t.body)):JSON.stringify(t.body);u.push(`body: ${p}`)}let f=u.length>0?`, { ${u.join(", ")} }`:"";return l.push(` fetch(url${f})`," .then(r => r.ok ? r.json() : Promise.reject(r.statusText))",` .then(d => { ${r}.${e} = d; })`,` .catch(e => { ${r}.${e} = { error: String(e) }; });`,o?"}));":"});"),l.map((p)=>`${s}${p}`).join(`
4
- `)}function tr(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o,serverBaseUrl:i="/_jx/server"}=n,c=JSON.stringify(`${i}/${t.$export}`),a=Object.entries(t.arguments??{}),l=a.map(([g,m])=>{if(!H(m))return`${ze(g)}: ${JSON.stringify(m)}`;if(Bl.some((x)=>m.$ref.startsWith(x)))throw Error(`Server function "${e}": argument "${g}" references "${m.$ref}", which a state entry cannot read. Use a #/state/, parent#/, window#/ or document#/ reference.`);return`${ze(g)}: ${Ge({$ref:m.$ref},{statePrefix:r})}`}),u=a.some(([,g])=>H(g)),f=`${ci}(${c}, ${l.length>0?`{ ${l.join(", ")} }`:"{}"})`,p=k(r,re(e)),d=`console.error(${JSON.stringify(`Jx server function ${t.$export}:`)}, e)`;return(u?[`// ${e}: server function ${t.$export}, called again when an argument changes`,"{"," let _jxSeq = 0;",o?` ${o}.push(effect(() => {`:" effect(() => {"," const _seq = ++_jxSeq;",` ${f}`,` .then((d) => { if (_seq === _jxSeq) ${p} = d; })`,` .catch((e) => { if (_seq === _jxSeq) ${d}; });`,o?" }));":" });","}"]:[`// ${e}: server function ${t.$export}, called once`,f,` .then((d) => { ${p} = d; })`,` .catch((e) => { ${d}; });`]).map((g)=>`${s}${g}`).join(`
5
- `)}function Ul(e,t){if(t==="state")return e;return e.replaceAll(/\$\{([^}]*)\}/g,(n,r)=>`\${${r.replaceAll(/(?<!this\.)\bstate\./g,`${t}.`)}}`)}function sr(e){if(!A(e))return!1;if(e.state)for(let[t,n]of Object.entries(e.state)){if(t==="$site"||t==="$page")continue;if(!A(n)||Array.isArray(n))return!0;if(n.timing==="compiler")continue;if(n.$prototype)return!0;if("default"in n)return!0;if(it(n))continue;return!0}if(e.$switch)return!0;if(ne(e)||zr(e.children))return!0;if(Array.isArray(e.children)&&e.children.some((t)=>sr(t)))return!0;for(let[t,n]of Object.entries(e)){if(Ye.has(t))continue;if(H(n))return!0;if(L(n))return!0}if(A(e.style)){for(let t of Object.values(e.style))if(L(t))return!0}if(A(e.attributes)){for(let t of Object.values(e.attributes))if(L(t))return!0}return!1}function si(e){if(!A(e))return!1;if(e.$switch)return!0;if(ne(e)||zr(e.children))return!0;for(let[t,n]of Object.entries(e)){if(Ye.has(t))continue;if(H(n))return!0;if(L(n))return!0}if(A(e.style)){for(let t of Object.values(e.style))if(L(t))return!0}if(A(e.attributes)){for(let t of Object.values(e.attributes))if(L(t))return!0}return!1}function It(e,t=null,n={},r={}){let s=e?.state?gs(e.state,t):t??oi();return{media:r,scope:s,scopeDefs:n}}function oi(e=null){return Object.create(e)}function ii(e){return e[ri]}function ms(e,t){if(b(e)){for(let o of e.matchAll(ql))t.add(o[1]);for(let o of e.matchAll(zl))t.add(o[1]);return}if(Array.isArray(e)){for(let o of e)ms(o,t);return}if(!A(e))return;let n=e,{operator:r,target:s}=n;if(b(r)&&Ke(r)&&H(s)&&s.$ref.startsWith("#/state/"))t.add(s.$ref.slice(8).split("/")[0]);for(let o of Object.values(n))ms(o,t)}function gs(e={},t=null){let n=oi(t),r=t?ii(t):void 0,s=new Set(r);Object.defineProperty(n,ri,{configurable:!0,enumerable:!1,value:s,writable:!0});let o=new Set;for(let l of Object.values(e))if(be(l)||we(l))ms(l.body??l.$expression,o);for(let l of o)if(l in e)s.add(l);for(let[l,u]of Object.entries(e)){if(!A(u)||Array.isArray(u)){Xe(n,l,Yn(u));continue}if("default"in u){Xe(n,l,Yn(u.default));continue}if(He(u)){s.add(l);continue}if(!u.$prototype&&!("$expression"in u)&&!it(u))Xe(n,l,Yn(u))}let i=[],c=[];for(let[l,u]of Object.entries(e)){if(L(u)){i.push([l,u]);continue}if(!A(u))continue;if(we(u)){let f=u.$expression;if(xt(u)){let p=u.parameters;Xe(n,l,(...d)=>{let h={};for(let[g,m]of p.entries()){let x=ti(m);if(!x)continue;h[x]=d[g]===void 0&&ni(m)?m.default:d[g]}return Ee(f,n,null,{args:h})})}else if(Ke(f.operator))Xe(n,l,(p,d)=>Ee(f,p,d));else ps(n,l,()=>Ee(f,n,null));continue}if(be(u)){if(st(u)){let{body:f}=u;Xe(n,l,(p,d)=>{_t(f,p??n,d??null)})}else if(b(u.body)){let f=u.parameters?Be(u.parameters):u.arguments??[],{body:p}=u,d=f.includes("state")?f:["state",...f],h=Function(...d,p),g=(m,x)=>h(...d.map((E)=>E==="state"?m:x));if(yt(p))ps(n,l,()=>g(n)),c.push([l,p]);else Xe(n,l,g)}else Xe(n,l,()=>{}),s.add(l);continue}if(ot(u)&&(u.$prototype==="LocalStorage"||u.$prototype==="SessionStorage")){Xe(n,l,Yn(u.default??null));continue}if(ot(u)&&u.$prototype==="Request")s.add(l)}let a=!0;while(a){a=!1;for(let[l,u]of[...c,...i])if(!s.has(l)&&ai(u,n))s.add(l),a=!0}for(let[l,u]of i)ps(n,l,()=>ys(u,n));return n}function Xe(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function ps(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:n})}function B(e,t){if(H(e))return Kl(e.$ref,t);if(L(e))return ys(e,t);return e}function he(e){return H(e)}function Kl(e,t){if(!b(e))return e;if(e.startsWith("$map/")){let n=e.split("/"),r=n[1],o=t.$map?.[r]??t[`$map/${r}`];return n.length>2?ds(o,n.slice(2).join("/")):o}if(e.startsWith("#/state/"))return ds(t,e.slice(8));return ds(t,e)??null}function ai(e,t){if(!t)return!1;let n=ii(t);for(let r of e.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*(\()?/g)){if(r[2])continue;let s=r[1];if(n?.has(s))return!0;let o;try{o=t[s]}catch{continue}if(Se(o))return!0}return!1}function or(e){return qn(e)?`(${e.slice(2,-1)})`:`\`${e}\``}function ys(e,t){if(ai(e,t))return null;let n=["state","$map","$site","$page"],r=[t,t?.$map,t?.$site,t?.$page];try{let s=qn(e)?`return (${e.slice(2,-1)})`:`return \`${e}\``;return Function(...n,s)(...r)}catch{return null}}function ds(e,t){return oe(e,t)}function Yn(e){if(!A(e))return e;return structuredClone(e)}function Gl(e,t){if(!e||!t)return"";return Object.entries(e).filter(([n,r])=>!n.startsWith(":")&&!n.startsWith(".")&&!n.startsWith("&")&&!n.startsWith("[")&&!n.startsWith("@")&&L(r)).map(([n,r])=>{let s=B(r,t);return s==null?null:`${ge(n)}: ${s}`}).filter(Boolean).join("; ")}function St(e,t,n=""){let r="",s=B(e.id,t),o=B(e.className,t),i=B(e.hidden,t),c=B(e.tabIndex,t),a=B(e.title,t),l=B(e.lang,t),u=B(e.dir,t);if(s)r+=` id="${_(String(s))}"`;if(o)r+=` class="${_(String(o))}"`;if(i)r+=" hidden";if(c!==void 0&&c!==null)r+=` tabindex="${_(String(c))}"`;if(a)r+=` title="${_(String(a))}"`;if(l)r+=` lang="${_(String(l))}"`;if(u)r+=` dir="${_(String(u))}"`;let f=[Gl(e.style,t),n].filter(Boolean).join("; ");if(f)r+=` style="${_(f)}"`;if(e.attributes)for(let[p,d]of Object.entries(e.attributes)){let h=B(d,t);if(me(h)){let g=$t(p,h);if(g!==null)r+=g===""?` ${p}`:` ${p}="${_(g)}"`;continue}if(b(h)||se(h))r+=` ${p}="${_(String(h))}"`}if(e.$static)r+=" data-jx-static";else if(e.$prerendered)r+=" data-jx-prerendered";return r}function yn(e,t=" "){return e?"":`
6
- ${t}`}function ir(){let e=JSON.stringify(Hn),t=JSON.stringify(Re);return`(function(){try{var s=localStorage.getItem(${e});if(s==="light"||s==="dark"){document.documentElement.setAttribute(${t},s)}}catch(e){}})()`}function Xn(e,t,n,r){for(let s of vt(t,{mediaQueries:r,resolveValue:(o,i)=>li(o,i,n),scope:n}))e.push(s.text)}function li(e,t,n){let r=b(t)?t:t.$ref;return Yl.push({property:e,selector:n,source:r}),null}function ar(){return`const __jxEnumAttrs = new Set(${JSON.stringify(Yo())});
7
- function ${Mt}(n, v) {
1
+ import{createRequire as zl}from"node:module";var Wl=Object.create;var{getPrototypeOf:Vl,defineProperty:Wo,getOwnPropertyNames:Bl}=Object;var Vo=Object.prototype.hasOwnProperty;function Hl(e){return this[e]}var Ul,ql,ep=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?Ul??=new WeakMap:ql??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?Wl(Vl(e)):{};let i=t||!e||!e.__esModule||!Vo.call(e,"default")?Wo(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Bl(e))if(!Vo.call(i,a))Wo(i,a,{get:Hl.bind(e,a),enumerable:!0})}if(r)s.set(e,i);return i};var tp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var A=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var rp=zl(import.meta.url);function S(e){return typeof e==="string"}function re(e){return typeof e==="number"}function ge(e){return typeof e==="boolean"}function we(e){return typeof e==="function"}function J(e){return typeof e==="object"&&e!==null}function R(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function H(e){return R(e)&&typeof e.$ref==="string"}function se(e){return R(e)&&e.$prototype==="Function"}function Ee(e){return R(e)&&R(e.$expression)}function xt(e){return Ee(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function De(e){return se(e)&&Array.isArray(e.body)}function ot(e){return R(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function Ue(e){return R(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function Bo(e){return R(e)&&!e.$prototype&&!e.$expression&&"default"in e}function it(e){if(!R(e))return!1;for(let t of Object.keys(e))if(!Ho.has(t))return!1;return!0}function te(e){return R(e)&&e.$prototype==="Array"}function rs(e){return(Array.isArray(e)?e:[e]).some((n)=>te(n))}function Uo(e){return R(e)&&e.$prototype==="Class"}function fn(e){return R(e)}function W(e){return typeof e==="string"&&e.includes("${")}function qo(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(yt(e))}function ss(e){return e.$prototype==="Function"||S(e.role)&&e.role!=="field"}function yt(e){if(!/[/'"`]/u.test(e))return e;let t=zn.get(e);if(t!==void 0)return t;let n=Gl(e);if(zn.size>=Kl)zn.clear();return zn.set(e,n),n}function Gl(e){let t=e.split(""),n=(i)=>{if(t[i]!==void 0&&t[i]!==`
2
+ `)t[i]=" "},r=[],s=!1,o=0;while(o<e.length){let i=e.charAt(o);if(s)if(i==="\\")n(o),n(o+1),o+=2;else if(i==="`")s=!1,o+=1;else if(i==="$"&&e.charAt(o+1)==="{")r.push(0),s=!1,o+=2;else n(o),o+=1;else if(i==="/"&&e.charAt(o+1)==="/")while(o<e.length&&e.charAt(o)!==`
3
+ `)n(o),o+=1;else if(i==="/"&&e.charAt(o+1)==="*"){let a=e.indexOf("*/",o+2),l=a===-1?e.length:a+2;for(;o<l;o+=1)n(o)}else if(i==="'"||i==='"'){o+=1;while(o<e.length&&e.charAt(o)!==i&&e.charAt(o)!==`
4
+ `){if(e.charAt(o)==="\\")n(o),o+=1;n(o),o+=1}o+=1}else if(i==="`")s=!0,o+=1;else{let a=r.length-1;if(a>=0&&i==="{")r[a]=(r[a]??0)+1;else if(a>=0&&i==="}")if(r[a]===0)r.pop(),s=!0;else r[a]=(r[a]??1)-1;o+=1}}return t.join("")}function Yl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Kn(e){if(!e)return[];return e.map((t)=>S(t)?t:t.name)}function Xl(e){return typeof e==="string"}function Me(e){if(typeof e!=="object"||e===null||Array.isArray(e)||!R(e.$expression))return!1;let t=e.$expression;if(t.operator==="?:")return typeof t.value==="string"&&typeof t.initial==="string";if(t.operator==="switch")return R(t.cases)&&Object.values(t.cases).every((n)=>S(n))&&typeof t.default==="string";return!1}function Tt(e){if(Xl(e))return[e];if(!Me(e))return[];let t=e.$expression;if(t.operator==="?:")return[...new Set([t.value,t.initial])];return[...new Set([...Object.values(t.cases),t.default])]}var Ho,zn,Kl=2048;var U=A(()=>{Ho=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"]);zn=new Map});function Zl(e,t){let n=e.slice(0,t),r=n.split(`
5
+ `).length;return{column:t-n.lastIndexOf(`
6
+ `),line:r}}function os(e,t,n,r){return{...Zl(e,t),kind:n,message:r,offset:t}}function Ql(e,t){let n=t;while(n<e.length&&/\s/u.test(e.charAt(n)))n+=1;return n}function Go(e){for(let t of[e,`return async function () {
7
+ ${e}
8
+ }`])try{return Reflect.construct(Function,[t])!==null}catch{}return!1}function Yo(e){as=e,Gn=null}function tc(e,t){if(!Gn){if(!as)throw Error("@jxsuite/erase was imported without an entry that loads its stripper");Gn=as()}return Gn(e,t)}function nc(e){return yt(e).includes("<")||!Go(e)}function rc(e){let t=is.get(e);if(t)return t;if(!nc(e)){let i={code:e,problems:[]};return is.set(e,i),i}let n=[],r=tc(e,(i)=>{let a=Ql(e,i.pos),[l="this"]=/^[\w$]+/u.exec(e.slice(a))??[];n.push(os(e,a,"unsupported",`\`${l}\` is TypeScript that has to be compiled rather than erased. A function body may use only types that can be removed: no enum, value namespace or parameter property`))}),s=yt(r);for(let i of s.matchAll(ec)){let a=i.index+(i[1]?.length??0)+(i[2]?.length??0);n.push(os(e,a,"unsupported",`A function body cannot ${i[3]??"import"}. Move code that needs a module into one of its own, named by $src`))}if(r!==e&&n.length===0&&Go(e)){let i=[...e].findIndex((a,l)=>a!==r[l]);n.push(os(e,Math.max(i,0),"meaning","This was already JavaScript, and reading it as TypeScript changes it: `a < b > (c)` is a generic call in TypeScript and two comparisons in JavaScript. Add parentheses if a comparison is meant"))}let o={code:r,problems:n};return is.set(e,o),o}function sc(e){return String(e).replaceAll("~","~0").replaceAll("/","~1")}function zo(e,t,n){if(S(e))return Ko(e,t,n);if(Array.isArray(e)&&e.length>0&&e.every((r)=>S(r)))return Ko(e.join(`
9
+ `),t,n).split(`
10
+ `);return e}function Ko(e,t,n){let{code:r,problems:s}=rc(e),[o,...i]=s.filter((a)=>a.kind==="unsupported");if(o)throw new Xo(t,[o,...i]);for(let a of s)n.push({...t,problem:a});return r}function ls(e,t,n){if(Array.isArray(e))return e.map((i,a)=>ls(i,{...t,pointer:`${t.pointer}/${a}`},n));if(!R(e))return e;let r=ss(e),s=[],o={set:(i,a)=>{s.push([i,a])}};for(let[i,a]of Object.entries(e)){let l={...t,pointer:`${t.pointer}/${sc(i)}`};if(r&&i==="body")o.set(i,zo(a,l,n));else if(r&&(i==="getter"||i==="setter")&&R(a)){let c={...a};if(a.body!==void 0)c.body=zo(a.body,{...l,pointer:`${l.pointer}/body`},n);o.set(i,c)}else o.set(i,ls(a,l,n))}return Object.fromEntries(s)}function cs(e,t,n=[]){return ls(e,{path:t,pointer:""},n)}function Zo(e,t,n=[]){return cs(e,t,n)}var ec,is,Gn=null,as=null,Xo;var us=A(()=>{U();ec=/(^|[\n;{}])(\s*)(import|export)(?=[\s{*"'])/gu;is=new Map;Xo=class Xo extends Error{problems;site;constructor(e,t){let[n]=t;super(`${e.path}${e.pointer}: ${n.message} (line ${n.line}, column ${n.column})`);this.name="EraseError",this.problems=t,this.site=e}}});import{createRequire as oc}from"node:module";var Qo=A(()=>{us();us();Yo(()=>oc(import.meta.url)("ts-blank-space").default)});function ti(e){for(let{path:t,pointer:n,problem:r}of e){let s=`${t}${n} (line ${r.line}, column ${r.column}): ${r.message}`;if(!ei.has(s))ei.add(s),console.warn(`Warning: ${s}`)}}function pn(e,t){let n=[],r=cs(e,t,n);return ti(n),r}function ni(e,t){let n=[],r=Zo(e,t,n);return ti(n),r}var ei;var Yn=A(()=>{Qo();ei=new Set});function ac(e){let t=new Set,n=new Set,r=(o)=>{if(o.startsWith("#/state/"))t.add(o.slice(8).split("/")[0])},s=(o)=>{if(S(o)){for(let i of o.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*\(/gu))t.add(i[1]);return}if(Array.isArray(o)){if(!n.has(o)){n.add(o);for(let i of o)s(i)}return}if(!R(o)||n.has(o))return;if(n.add(o),o.operator==="call"&&H(o.target))r(o.target.$ref);for(let[i,a]of Object.entries(o)){if(i==="$defs")continue;if(i.startsWith("on")&&H(a))r(a.$ref);s(a)}};s(e);for(let o of ic)if(R(e.state)&&o in e.state)t.add(o);return t}function fs(e){return"body"in e&&"$src"in e}function dn(e){return Kn(e.parameters??e.arguments).length>0}function Fe(e){let t=["state"];for(let n of Kn(e.parameters??e.arguments))if(n!=="state")t.push(n);return t}function lc(e,t,n){if(De(t))return"callable";if(Kn(t.parameters??t.arguments).length>0)return"callable";if(S(t.body))return qo(t.body)?"computed":"callable";if(t.$src)return n().has(e)?"callable":"computed";return"callable"}function $t(e){let t=new Map,n=null,r=()=>n??=ac(e);for(let[s,o]of Object.entries(e.state??{}))if(se(o))t.set(s,lc(s,o,r));return t}var ic;var mn=A(()=>{U();ic=new Set(["onMount","onUnmount","onAdopted"])});function he(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function ri(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let n=e.slice(2,-1).trim();return cc.has(n.toLowerCase())?n:e.slice(1)}return null}function gn(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function xn(e){return e.startsWith("@keyframes")}function si(e,t){let n=[];for(let r of hn(e))for(let s of hn(t))n.push(uc(r,s));return n.join(", ")}function uc(e,t){let n=Zn(t,e);if(n!==null)return n;if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function ps(e){let t=[],n=null,r=0;for(let s=0;s<e.length;s+=1){let o=e[s];if(n){if(o==="\\")s+=1;else if(o===n)n=null;continue}if(o==="\\")s+=1;else if(o==='"'||o==="'")n=o;else if(o==="[")r+=1;else if(o==="]")r=Math.max(0,r-1);else if(o==="&"&&r===0)t.push(s)}return t}function Zn(e,t){return ps(e).length>0?fc(e,t):null}function fc(e,t){let n="",r=0;for(let s of ps(e))n+=e.slice(r,s)+t,r=s+1;return n+e.slice(r)}function hn(e){let t=[],n=0,r=null,s=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(r){if(a==="\\")i+=1;else if(a===r)r=null;continue}if(a==='"'||a==="'")r=a;else if(a==="("||a==="[")n+=1;else if(a===")"||a==="]")n=Math.max(0,n-1);else if(a===","&&n===0)t.push(e.slice(s,i)),s=i+1}t.push(e.slice(s));let o=t.flatMap((i)=>{let a=i.trim();return a===""?[]:[a]});return o.length>0?o:[e]}function qe(e){let t=/^\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)$/.exec(e.trim())?.[1];return t==="light"||t==="dark"?t:null}function ds(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${Re}]))`,forced:`${e}:where([${Re}="${t}"])`};return{auto:`:where(:root:not([${Re}])) ${e}`,forced:`:where(:root[${Re}="${t}"]) ${e}`}}function at(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function ms(e){return e.startsWith("--")?e:he(e)}function Xn(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function oi(e,t,n){let r=n.map(([o,i])=>`${o}: ${i}`).join("; "),s=t===null?r:`${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function pc(e,t,n){let r=n.map(({selector:o,declarations:i})=>`${o} { ${i.map(([a,l])=>`${a}: ${l}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function dc(e){let t=Object.keys(e).filter((r)=>xn(r));if(t.length===0)return e;let n={...e};for(let r of t)delete n[r];return n}function mc(e){let n=ps(e).at(-1),r=n===void 0?e:e.slice(n+1);return r===""||r.startsWith(":")||r.startsWith(".")||r.startsWith("[")}function Rt(e,t={}){let{scope:n=null,mediaQueries:r={},transposeValue:s=(m)=>m,transposeSelector:o=(m)=>m,resolveValue:i}=t,a=[],l=(m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)&&!H(m),c=(m,x)=>{if(l(x))return[x];if(!gn(m)||!Array.isArray(x)||x.length===0)return[];return x.every((w)=>l(w))?x:[]},u=(m,x,w,N)=>{if(x===void 0||x===null)return null;if(H(x))return w?i?.(m,x,N)??null:null;if(J(x))return null;let E=String(x);if(W(E))return w?i?.(m,E,N)??null:null;return s(E)},f=(m,x,w=!0,N="self")=>{let E=[];for(let[O,K]of Object.entries(m)){if(c(O,K).length>0)continue;if(x&&(O.startsWith("@")||at(O)))continue;if(O.startsWith("$"))continue;let b=u(O,K,w,N);if(b!==null)E.push([ms(O),b])}return E},p=(m,x,w,N,E)=>{if(w.length===0)return;let O=x;if(O!==null){let y=o(O);if(y===null)return;O=y}let K=oi(m,O,w),b={text:K,conditions:[...m],selector:O,declarations:w,target:N,key:Xn(K)};if(S(E)&&E!=="")b.description=E;a.push(b)},d=(m,x,w)=>{let N=m.slice(10).trim();if(N==="")return;let E=[];for(let[K,b]of Object.entries(x)){if(!l(b))continue;let y=f(b,!0,!1,"unscoped");if(y.length>0)E.push({declarations:y,selector:K.trim()})}if(E.length===0)return;let O=pc(w,N,E);a.push({blocks:E,conditions:[...w],declarations:[],key:Xn(O),selector:null,target:"unscoped",text:O})},h=(m,x,w,N,E)=>{if(m==="@--")return;if(gn(m)){p([...N,m],null,f(x,!1,!0,"unscoped"),"unscoped",x.$description);return}if(xn(m)){d(m,x,N);return}let O=ri(m,r),K=O===null?m:`@media ${O}`,b=O===null?null:qe(O);if(b!==null&&w!==null){let{auto:y,forced:j}=ds(w,b);g(x,y,[...N,K],E),g(dc(x),j,N,E);return}g(x,w,[...N,K],E)};function g(m,x,w,N){p(w,x,f(m,!0,!0,N),N,m.$description);for(let[E,O]of Object.entries(m))for(let K of c(E,O))if(E.startsWith("@"))h(E,K,x,w,N);else if(x!==null)g(K,si(x,E),w,mc(E)?N:"descendant")}return g(e,n,[],"self"),a}var cc,Re="data-color-scheme",Qn="jx-color-scheme";var yn=A(()=>{U();cc=new Set(["all","print","screen","speech"])});function yp(){return`the Intl helpers ${hs.join(", ")}`}var Le="en-US",gs="UTC",ii,hs,ai;var li=A(()=>{ii=[{api:"Intl.NumberFormat",params:["value","locale","options"],path:"Intl/formatNumber",summary:"Format a number for a locale — grouping, decimals, currency, percent, units."},{api:"Intl.DateTimeFormat",params:["value","locale","options"],path:"Intl/formatDate",summary:"Format a date or timestamp for a locale. Pass `timeZone` in options."},{api:"Intl.RelativeTimeFormat",params:["value","unit","locale","options"],path:"Intl/formatRelativeTime",summary:'Format a relative time — `-3, "day"` becomes "3 days ago".'},{api:"Intl.ListFormat",params:["values","locale","options"],path:"Intl/formatList",summary:'Join a list the way a locale does — "a, b, and c", not a hand-written comma join.'},{api:"Intl.PluralRules",params:["value","locale","options"],path:"Intl/plural",summary:'Which plural category a number falls in ("one", "few", "other") — many languages have '+"more than two, so a ternary on `n === 1` is wrong outside English."},{api:"Intl.Collator",params:["a","b","locale","options"],path:"Intl/compare",summary:'Compare two strings for sorting. `<` and `sort()` order by UTF-16 code unit, which puts "Zebra" before "apple" and sorts every accented word into the wrong place.'},{api:"Intl.DisplayNames",params:["code","type","locale","options"],path:"Intl/displayName",summary:'The name of a language, region, script or currency in a locale — "de" as "German" or '+'"Deutsch", from CLDR rather than a hand-kept table.'},{api:"Intl.Segmenter",params:["value","granularity","locale"],path:"Intl/segment",summary:"Split text into graphemes, words or sentences (UAX #29). `[...str]` splits code points, so it cuts an emoji with a skin-tone modifier in half."}],hs=ii.map((e)=>e.path),ai=Object.fromEntries(ii.map((e)=>[e.path,e.params.indexOf("locale")]))});function gc(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function pe(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function ze(e){if(e==="")return[];return e.split("/").map((t)=>gc(t))}function oe(e,t){let n=e;for(let r of ze(t))n=n?.[r];return n}function L(e,t){let n=e;for(let r of ze(t))n+=xs.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;return n}function ci(e,t){let n=e;for(let[r,s]of ze(t).entries()){let o=r===0?"":"?.";n+=xs.test(s)?`${r===0?".":o}${s}`:`${o}[${JSON.stringify(s)}]`}return n}function Ke(e){return xs.test(e)?e:JSON.stringify(e)}function ui(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var xs;var _t=A(()=>{xs=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function ys(e){let t=e.$map;return J(t)?t:void 0}function mi(e){return J(e)&&!Array.isArray(e)&&"operator"in e}function $n(e){return J(e)&&!Array.isArray(e)&&"$ref"in e}function $c(e,t,n){let r=ai[e];if(r===void 0||r<0||t[r]!=null)return t;let s=oe(n.$page,"locale");if(!S(s)||s==="")return t;let o=[...t];return o[r]=s,o}function yi(e){return e.startsWith("window#/")&&xc.has(e.slice(8))}function Ge(e){return gi.has(e)}function Y(e,t){if(!e)return;let n=(e.depth??0)+1;if(n>Sc)return;return{depth:n,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function G(e,t,n,r,s){if(e===null||e===void 0)return e;if(mi(e))return Je(e,t,n,r,s);if($n(e)){let o=er(e.$ref,t,n,r);return s?.report(s.path??[],o),o}if(Array.isArray(e))return $i(e,t,n,r,s);return s?.report(s.path??[],e),e}function $i(e,t,n,r,s){return e.map((o,i)=>G(o,t,n,r,Y(s,i)))}function bc(e,t,n,r){let s=(o)=>{if(!e.slice(o.length).includes("/"))return t;return er(e.slice(0,e.lastIndexOf("/")),t,n,r)};if(e.startsWith("#/state/"))return s("#/state/");if(e.startsWith("parent#/"))return s("parent#/");if(e.startsWith("$map/")||e.startsWith("$args/"))return e.split("/").length>2?er(e.slice(0,e.lastIndexOf("/")),t,n,r):void 0;return}function er(e,t,n,r){if(e==="$reduce/acc")return r?.acc;if(e.startsWith("$reduce/"))return r?.acc;if(e.startsWith("$args/")){let s=e.slice(6).split("/"),o=r?.args?.[s[0]];return s.length>1?oe(o,s.slice(1).join("/")):o}if(e.startsWith("event#/")){let s=e.slice(7);return oe(n,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,a=ys(t);if(o==="item")i=r?.item??a?.item??t["$map/item"];else if(o==="index")i=r?.index??a?.index??t["$map/index"];else i=a?.[o]??t[`$map/${o}`];return s.length>2?oe(i,s.slice(2).join("/")):i}if(e.startsWith("#/state/"))return oe(t,e.slice(8));if(e.startsWith("parent#/"))return oe(t,e.slice(8));if(e.startsWith("window#/"))return oe(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return oe(globalThis.document,e.slice(10));return oe(t,e)??null}function wc(e,t,n,r){if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,a=ys(t);if(o==="item")i=r?.item??a?.item??t["$map/item"];else if(o==="index")i=r?.index??a?.index??t["$map/index"];else i=a?.[o]??t[`$map/${o}`];if(s.length>2){let l=s.slice(2),c=l.pop(),u=l.length>0?oe(i,l.join("/")):i;return{key:c,obj:u}}return{key:o==="item"?"$map/item":"$map/index",obj:ys(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let i=ze(s),a=i.pop(),l=t;for(let c of i)l=l[c];return{key:a,obj:l}}return{key:e,obj:t}}function Je(e,t,n,r,s){let o=Ec(e,t,n,r,s);return s?.report(s.path??[],o),o}function pi(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;case"<":return t<n;case"<=":return t<=n;case">":return t>n;default:return t>=n}}function Ec(e,t,n,r,s){let{operator:o,target:i,value:a,initial:l}=e;if(!hc.has(o))throw Error(`$expression: unknown operator "${o}"`);if($s.has(o)&&!("value"in e)){let c=G(i,t,n,r,Y(s,"target"));if(o==="!")return!c;if(o==="-")return-c}if(o==="call"){let c=$n(i)?i.$ref:void 0;if(!S(c))throw TypeError("$expression: call target must be a $ref pointer");let u=(r?.callDepth??0)+1;if(u>fi)throw Error(`$expression: call depth exceeded (${fi})`);let f=Array.isArray(a)?a.map((d,h)=>G(d,t,n,r,Y(s,["value",h]))):[];if(c.startsWith("window#/")){if(!yi(c))throw Error(`$expression: "${c}" is not a blessed pure global`);let d=c.slice(8),h=yc.get(d);if(h)return h(...$c(d,f,t));let g=oe(globalThis.window,d),m=d.lastIndexOf("/"),x=m===-1?globalThis.window:oe(globalThis.window,d.slice(0,m));return g.apply(x,f)}let p=er(c,t,n,r);if(we(p))return p.apply(bc(c,t,n,r),f);if(J(p)&&"$expression"in p){let d=p,h={};for(let[g,m]of(d.parameters??[]).entries()){let x=S(m)?m:m?.name??"";if(!x)continue;h[x]=f[g]===void 0&&J(m)&&"default"in m?m.default:f[g]}return Je(d.$expression,t,n,{args:h,callDepth:u})}throw TypeError(`$expression: call target "${c}" is not callable`)}if(ws.has(o)){if(o==="?:"){let d=G(i,t,n,r,Y(s,"target"));if(s){let h=G(a,t,n,r,Y(s,"value")),g=G(l,t,n,r,Y(s,"initial"));return d?h:g}return d?G(a,t,n,r):G(l,t,n,r)}let c=G(i,t,n,r,Y(s,"target")),u=String(c),f=e.cases??{},p=Object.hasOwn(f,u);if(s){let d;for(let[g,m]of Object.entries(f)){let x=G(m,t,n,r,Y(s,["cases",g]));if(g===u)d=x}let h=G(e.default,t,n,r,Y(s,"default"));return p?d:h}return p?G(f[u],t,n,r):G(e.default,t,n,r)}if(Ss.has(o)){let c=G(i,t,n,r,Y(s,"target")),u=G(a,t,n,r,Y(s,"value"));switch(o){case"===":return c===u;case"!==":return c!==u;case"&&":return c&&u;case"||":return c||u;case"??":return c??u;default:return pi(o,c,u)}}if(hi.has(o)){let c=G(a,t,n,r,Y(s,"value")),{obj:u,key:f}=wc(i.$ref,t,n,r);u[f]=o==="="?c:pi(o.slice(0,-1),u[f],c);return}if(xi.has(o)){let c=G(i,t,n,r,Y(s,"target"));switch(o){case"push":return c.push(G(a,t,n,r,Y(s,"value")));case"unshift":return c.unshift(G(a,t,n,r,Y(s,"value")));case"pop":return c.pop();case"shift":return c.shift();case"splice":{let u=G(a,t,n,r,Y(s,"value"));return c.splice(...u)}default:break}}if(Es.has(o)){let c=G(i,t,n,r,Y(s,"target")),u=a===void 0?[]:Array.isArray(a)?$i(a,t,n,r,Y(s,"value")):[G(a,t,n,r,Y(s,"value"))],f=oe(c,o);if(!we(f))return;return f.apply(c,u)}if(bs.has(o)){let c=G(i,t,n,r,Y(s,"target")),u=a;if(o==="reduce"){let f=G(l,t,n,r,Y(s,"initial"));for(let[p,d]of c.entries())f=Je(u,t,n,{acc:f,index:p,item:d},p===0?Y(s,"value"):void 0);return f}if(o==="map")return c.map((f,p)=>Je(u,t,n,{...r,index:p,item:f},p===0?Y(s,"value"):void 0));if(o==="filter")return c.filter((f,p)=>Je(u,t,n,{...r,index:p,item:f},p===0?Y(s,"value"):void 0))}return}function X(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(mi(e))return de(e,t);if($n(e))return Js(e.$ref,t);if(Array.isArray(e))return e.map((n)=>X(n,t)).join(", ");return JSON.stringify(e)}function Jc(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function Js(e,t){let n=t.statePrefix??"state",r=t.eventParam??"event";if(e==="$reduce/acc")return"_acc";if(e.startsWith("$reduce/"))return"_acc";if(e.startsWith("$args/"))return L("_args",e.slice(6));if(e.startsWith("event#/"))return L(r,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s;if(o==="item")return s.length>2?L("_item",s.slice(2).join("/")):"_item";if(o==="index")return"_index";return`_${o}`}if(e.startsWith("#/state/"))return L(n,e.slice(8));if(e.startsWith("parent#/"))return L(n,e.slice(8));if(e.startsWith("window#/"))return L("window",e.slice(8));if(e.startsWith("document#/"))return L("document",e.slice(10));return L(n,e)}function di(e,t){if($n(e))return Js(e.$ref,t);return X(e,t)}function Nc(e,t,n){let r=(i)=>t[i]??"undefined",s=`(${n.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(Le)})`,o=JSON.stringify(gs);switch(e){case"Intl/formatNumber":return`new Intl.NumberFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/formatDate":return`new Intl.DateTimeFormat(${r(1)} ?? ${s}, {timeZone: ${o}, ...${r(2)}}).format(new Date(${r(0)}))`;case"Intl/formatRelativeTime":return`new Intl.RelativeTimeFormat(${r(2)} ?? ${s}, ${r(3)}).format(${r(0)}, ${r(1)})`;case"Intl/formatList":return`new Intl.ListFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/plural":return`new Intl.PluralRules(${r(1)} ?? ${s}, ${r(2)}).select(${r(0)})`;case"Intl/compare":return`new Intl.Collator(${r(2)} ?? ${s}, ${r(3)}).compare(${r(0)}, ${r(1)})`;case"Intl/displayName":return`new Intl.DisplayNames(${r(2)} ?? ${s}, {...${r(3)}, type: ${r(1)} ?? 'language'}).of(${r(0)})`;case"Intl/segment":return`[...new Intl.Segmenter(${r(2)} ?? ${s}, {granularity: ${r(1)} ?? 'grapheme'}).segment(${r(0)})].map((p) => p.segment)`;default:return null}}function de(e,t={}){let{operator:n,target:r,value:s,initial:o}=e;if($s.has(n)&&!("value"in e)){let i=X(r,t);if(n==="!")return`!(${i})`;if(n==="-")return`-(${i})`}if(n==="call"){let i=($n(r)?r.$ref:void 0)??"",a=Array.isArray(s)?s.map((l)=>X(l,t)):[];if(i.startsWith("window#/")){if(!yi(i))throw Error(`$expression: "${i}" is not a blessed pure global`);let l=Nc(i.slice(8),a,t);if(l)return l;return`window.${i.slice(8).replaceAll("/",".")}(${a.join(", ")})`}if(i.startsWith("#/state/")){let l=i.slice(8),c=t.formulaParams?.[l];if(c){let u=c.map((f,p)=>`${JSON.stringify(f)}: ${a[p]??"undefined"}`).join(", ");return`${Jc(l)}(${t.statePrefix??"state"}, { ${u} })`}}return`${Js(i,t)}(${a.join(", ")})`}if(ws.has(n)){if(n==="?:"){let c=X(r,t),u=X(s,t),f=X(o,t);return`(${c} ? ${u} : ${f})`}let i=X(r,t),a=Object.entries(e.cases??{}).map(([c,u])=>`_d === ${JSON.stringify(c)} ? ${X(u,t)} : `).join(""),l="default"in e?X(e.default,t):"undefined";return`((_d) => ${a}${l})(String(${i}))`}if(Ss.has(n)){let i=X(r,t),a=X(s,t);return`(${i} ${n} ${a})`}if(hi.has(n)){let i=di(r,t),a=X(s,t);return`${i} ${n} ${a}`}if(xi.has(n)){let i=di(r,t);switch(n){case"push":return`${i}.push(${X(s,t)})`;case"unshift":return`${i}.unshift(${X(s,t)})`;case"pop":return`${i}.pop()`;case"shift":return`${i}.shift()`;case"splice":{let a=Array.isArray(s)?s.map((l)=>X(l,t)).join(", "):X(s,t);return`${i}.splice(${a})`}default:break}}if(Es.has(n)){let i=X(r,t),a=s===void 0?"":Array.isArray(s)?s.map((l)=>X(l,t)).join(", "):X(s,t);return`(${i})?.${n}?.(${a})`}if(bs.has(n)){let i=X(r,t),a=de(s,t);if(n==="reduce"){let l=X(o,t);return`${i}.reduce((_acc, _item, _index) => ${a}, ${l})`}if(n==="map")return`${i}.map((_item, _index) => ${a})`;if(n==="filter")return`${i}.filter((_item, _index) => ${a})`}return"undefined"}function Pt(e,t,n,r){return G(e,t,n,r)}function Ye(e,t={}){return X(e,t)}var gi,$s,Ss,hi,xi,bs,ws,Es,hc,xc,yc,fi=64,Sc=64;var Sn=A(()=>{li();U();_t();gi=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),$s=new Set(["!","-"]),Ss=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),hi=new Set(["=","+=","-=","*=","/="]),xi=new Set(["push","pop","shift","unshift","splice"]),bs=new Set(["reduce","map","filter"]),ws=new Set(["?:","switch"]),Es=new Set(["includes","indexOf","lastIndexOf","join","slice","concat","at","flat","toSorted","toReversed","toSpliced","with","toUpperCase","toLowerCase","trim","trimStart","trimEnd","split","startsWith","endsWith","padStart","padEnd","replaceAll","repeat","charAt","normalize","toLocaleUpperCase","toLocaleLowerCase","toFixed","toPrecision","toLocaleString"]),hc=new Set([...gi,...$s,...Ss,...bs,...ws,...Es,"call"]),xc=new Set(["isNaN","isFinite","parseFloat","parseInt","encodeURIComponent","decodeURIComponent","structuredClone","Math/abs","Math/ceil","Math/floor","Math/round","Math/trunc","Math/sign","Math/sqrt","Math/cbrt","Math/pow","Math/exp","Math/log","Math/log2","Math/log10","Math/min","Math/max","Math/hypot","Number/isInteger","Number/isFinite","Number/isNaN","Number/parseFloat","Number/parseInt","JSON/parse","JSON/stringify","Object/keys","Object/values","Object/entries","Object/fromEntries","Array/from","Array/isArray","Array/of","String/fromCharCode","String/fromCodePoint",...hs]),yc=new Map([["Intl/compare",(e,t,n,r)=>new Intl.Collator(n??Le,r).compare(e,t)],["Intl/displayName",(e,t,n,r)=>new Intl.DisplayNames(n??Le,{...r,type:t??"language"}).of(e)],["Intl/formatDate",(e,t,n)=>new Intl.DateTimeFormat(t??Le,{timeZone:gs,...n}).format(new Date(e))],["Intl/formatList",(e,t,n)=>new Intl.ListFormat(t??Le,n).format(e)],["Intl/formatNumber",(e,t,n)=>new Intl.NumberFormat(t??Le,n).format(e)],["Intl/formatRelativeTime",(e,t,n,r)=>new Intl.RelativeTimeFormat(n??Le,r).format(e,t)],["Intl/plural",(e,t,n)=>new Intl.PluralRules(t??Le,n).select(e)],["Intl/segment",(e,t,n)=>[...new Intl.Segmenter(n??Le,{granularity:t??"grapheme"}).segment(e)].map((r)=>r.segment)]])});function Ac(e){return e.startsWith(Si)}function Ap(e){let t=e;if(Ac(t))t=t.slice(Si.length);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`${Ns}${t}.js`}function Op(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",n=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`${Ns}${n}`:`${Ns}${n}.${t}`}function bi(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function wi(e){let t=bi(e);return t.startsWith("/")?t:`/${t}`}function Oc(e,t){return[...e].toSorted((n,r)=>r[t].length-n[t].length)}function Cp(e,t){let n=t.split("#")[0].split("?")[0];if(!n.startsWith("/"))return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(/%2e|%2f/i.test(r))return null;for(let s of Oc(e,"urlPrefix")){let o=wi(s.urlPrefix);if(!r.startsWith(`${o}/`))continue;let a=r.slice(o.length+1).split("/");if(a.some((c)=>c===""||c==="."||c===".."))return null;let{filter:l}=s;if(l&&!l(a.join("/")))return null;return`${bi(s.dir)}/${a.join("/")}`}return null}function jp(e,t){let n=new Set;for(let r of t){let s=wi(r.urlPrefix),o=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${Cc}]+`,"g");for(let i of e.matchAll(o)){let a=i[0].split("#")[0].split("?")[0];if(!a.endsWith("/"))n.add(a)}}return[...n].filter(Boolean)}function jc(e){let t=[],n=0;while(n<e.length){while(n<e.length&&(/\s/.test(e[n])||e[n]===","))n+=1;if(n>=e.length)break;let r=n;while(n<e.length&&!/\s/.test(e[n]))n+=1;let s=e.slice(r,n);if(s.endsWith(",")){t.push({descriptor:"",url:s.replace(/,+$/,"")});continue}while(n<e.length&&/\s/.test(e[n]))n+=1;let o=n;while(n<e.length&&e[n]!==",")n+=1;let i=e.slice(o,n).trim();if(n+=1,s=s.replace(/,+$/,""),s!=="")t.push({descriptor:i,url:s})}return t}function vc(e){return e.map(({url:t,descriptor:n})=>n?`${t} ${n}`:t).join(", ")}function vp(e){if(!S(e)||e==="")return"";let t;try{({pathname:t}=new URL(e))}catch{return""}let n=t.replace(/\/+$/,"");if(n===""||n==="/")return"";return n.startsWith("/")?n:`/${n}`}function Ei(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function Tp(e,t){let n=new URL(t);if(!n.pathname.endsWith("/"))n.pathname+="/";return new URL(e.replace(/^\/+/,""),n).href}var Si="npm:",Ns="/assets/",Cc;var As=A(()=>{U();Cc=String.raw`"'\s<>()\\`});function Ji(e){if("operator"in e)return{kind:"expression",node:e};if("if"in e)return{kind:"if",node:e};if("$switch"in e)return{kind:"switch",node:e};if("stopPropagation"in e)return{kind:"stopPropagation"};if("preventDefault"in e)return{kind:"preventDefault"};return{kind:"dispatch",node:e}}function Tc(e){return(J(e)||we(e))&&"then"in e&&we(e.then)}async function kt(e,t,n,r={}){let s=r.args?{args:r.args}:void 0;for(let o of e){let i=Ji(o);switch(i.kind){case"expression":{let a=Je(i.node,t,n,s);if(Tc(a))await a;break}case"if":{let a=i.node,l=Pt(a.if,t,n,s)?a.then:a.else;if(Array.isArray(l))await kt(l,t,n,r);break}case"switch":{let a=i.node,l=String(Pt(a.$switch,t,n,s)),c=a.cases??{},u=Object.hasOwn(c,l)?c[l]:a.default;if(Array.isArray(u))await kt(u,t,n,r);break}case"dispatch":{let a=i.node,l=we(r.target)?r.target():r.target,c=n?.currentTarget??l;if(!c)break;let u={};if("detail"in a)u.detail=Pt(a.detail,t,n,s);if(a.bubbles!==void 0)u.bubbles=a.bubbles;if(a.composed!==void 0)u.composed=a.composed;c.dispatchEvent(new CustomEvent(a.dispatchEvent,u));break}case"stopPropagation":{n?.stopPropagation();break}case"preventDefault":{n?.preventDefault();break}default:break}}}function je(e,t={}){let n=t.indent??"",r=[];for(let s of e){let o=Ji(s);switch(o.kind){case"expression":{r.push(`${n}${de(o.node,t)};`);break}case"if":{let i=o.node,a=Ye(i.if,t),l={...t,indent:`${n} `};if(r.push(`${n}if (${a}) {`,je(i.then??[],l)),i.else)r.push(`${n}} else {`,je(i.else,l));r.push(`${n}}`);break}case"switch":{let i=o.node,a=Ye(i.$switch,t),l={...t,indent:`${n} `};r.push(`${n}switch (String(${a})) {`);for(let[c,u]of Object.entries(i.cases??{}))r.push(`${n} case ${JSON.stringify(c)}: {`,je(u,l),`${n} break;`,`${n} }`);if(i.default)r.push(`${n} default: {`,je(i.default,l),`${n} }`);r.push(`${n}}`);break}case"dispatch":{let i=o.node,a=t.eventParam??"event",l=t.dispatchTarget??`(${a} && ${a}.currentTarget)`,c=[];if("detail"in i)c.push(`detail: ${Ye(i.detail,t)}`);if(i.bubbles!==void 0)c.push(`bubbles: ${JSON.stringify(i.bubbles)}`);if(i.composed!==void 0)c.push(`composed: ${JSON.stringify(i.composed)}`);let u=c.length>0?`, { ${c.join(", ")} }`:"";r.push(`${n}${l}?.dispatchEvent(new CustomEvent(${JSON.stringify(i.dispatchEvent)}${u}));`);break}case"stopPropagation":{r.push(`${n}${t.eventParam??"event"}?.stopPropagation();`);break}case"preventDefault":{r.push(`${n}${t.eventParam??"event"}?.preventDefault();`);break}default:break}}return r.join(`
11
+ `)}var tr=A(()=>{U();Sn()});var Os=A(()=>{U()});function nr(e){if(!e.startsWith("${")||!e.endsWith("}"))return!1;let t=0;for(let n=1;n<e.length;n+=1){let r=e[n];if(r==="{")t+=1;else if(r==="}"){if(t-=1,t===0)return n===e.length-1}}return!1}function Ai(){return[...Ni].toSorted()}function St(e,t){let n=e.toLowerCase();if(n.startsWith("aria-")||Ni.has(n))return String(t);return t?"":null}var Xe,Ni,Cs=32,rr,sr="jx-slot",js="data-jx-slots",vs="jx.slot.group",nd;var bn=A(()=>{yn();Sn();_t();U();mn();As();tr();Os();Os();yn();Xe=new Set(["$schema","$id","$defs","state","$ref","$props","$elements","$title","$description","$switch","$prototype","$src","$export","$media","$map","timing","default","description","body","parameters","arguments","name","tagName","children","style","attributes","items","map","filter","sort","cases","observedAttributes"]),Ni=new Set(["contenteditable","draggable","spellcheck"]);rr=/^[\t\n\f\r ]+$/u,nd=(()=>{let e=Symbol.for(vs),t=globalThis;return t[e]??=new WeakMap,t[e]})()});function Oi(e,t,n,r,s=Pc){let o=[],i=(f,p)=>{let d={mediaQueries:t,scope:p,transposeValue:n};if(r)d.resolveValue=(h,g)=>r(h,g,p);for(let h of Rt(f,d))o.push(h.text)},a={},l={},c=[],u=[];for(let[f,p]of Object.entries(e)){if(J(p)&&!Array.isArray(p)){if(f.startsWith("@"))c.push([f,p]);else if(!f.startsWith("--"))u.push([f,p]);continue}if(at(f)||f.startsWith("@"))continue;if(f.startsWith("--")||f==="colorScheme"||f==="color-scheme")a[f]=p;else l[f]=p}i(a,s.root),i(l,s.body);for(let[f,p]of u)if(f.startsWith("&"))i({[f]:p},s.root);else i(p,f);for(let[f,p]of c){if(gn(f)||xn(f)){i({[f]:p},null);continue}let d={},h={},g=[];for(let[m,x]of Object.entries(p)){if(J(x)&&!Array.isArray(x)){if(!m.startsWith("@"))g.push([m,x]);continue}if(m.startsWith("--"))d[m]=x;else h[m]=x}i({[f]:d},s.root),i({[f]:h},s.body);for(let[m,x]of g)i({[f]:x},m)}if(Object.values(t).some((f)=>qe(f)!==null)&&!("colorScheme"in e))o.push(`${s.root} { color-scheme: light dark }`,`${s.root}:where([${Re}="light"]) { color-scheme: light }`,`${s.root}:where([${Re}="dark"]) { color-scheme: dark }`);return o.join(`
12
+ `)}var Pc;var Ci=A(()=>{yn();U();Pc={body:"body",root:":root"}});function ji(e){return e===!1||e==="open"||e==="closed"}function or(e,t){let n=e?.$shadow;if(ji(n))return n===!1?null:n;let r=t?.shadow;return ji(r)&&r!==!1?r:null}function vi(e,t){return t===null?e:":host"}function En(e,t){let n=[];for(let[r,s]of(e.parameters??[]).entries()){let o=Ti(s);if(!o)continue;let i=Ri(s)?`_a[${r}] === undefined ? ${JSON.stringify(s.default)} : _a[${r}]`:`_a[${r}]`;n.push(`${JSON.stringify(o)}: ${i}`)}return`(..._a) => { const _args = { ${n.join(", ")} }; return ${t}; }`}function Ti(e){return S(e)?e:e?.name??""}function Ri(e){return J(e)&&"default"in e}function cr(e,t){let n=Is(e,t);return n===e?e:`${n} as ${e}`}function Is(e,t){let n=t?.$export;return S(n)&&n!==""?n:e}function ur(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o}=n,{url:i}=t,a=W(i),l=t.method??"GET";if(t.manual)return`${s}// ${e}: manual Request — fetch triggered by user action`;let c=[`// ${e}: auto-fetch from ${a?"(dynamic URL)":i}`,o?`${o}.push(effect(() => {`:"effect(() => {"];if(a)c.push(` const url = \`${Ic(i,r)}\`;`,' if (!url || url === "undefined" || url.includes("undefined")) return;');else c.push(` const url = ${JSON.stringify(i)};`);let u=[];if(l!=="GET")u.push(`method: ${JSON.stringify(l)}`);if(t.headers)u.push(`headers: ${JSON.stringify(t.headers)}`);if(t.body){let p=J(t.body)?JSON.stringify(JSON.stringify(t.body)):JSON.stringify(t.body);u.push(`body: ${p}`)}let f=u.length>0?`, { ${u.join(", ")} }`:"";return c.push(` fetch(url${f})`," .then(r => r.ok ? r.json() : Promise.reject(r.statusText))",` .then(d => { ${r}.${e} = d; })`,` .catch(e => { ${r}.${e} = { error: String(e) }; });`,o?"}));":"});"),c.map((p)=>`${s}${p}`).join(`
13
+ `)}function fr(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o,serverBaseUrl:i="/_jx/server"}=n,a=JSON.stringify(`${i}/${t.$export}`),l=Object.entries(t.arguments??{}),c=l.map(([g,m])=>{if(!H(m))return`${Ke(g)}: ${JSON.stringify(m)}`;if(kc.some((x)=>m.$ref.startsWith(x)))throw Error(`Server function "${e}": argument "${g}" references "${m.$ref}", which a state entry cannot read. Use a #/state/, parent#/, window#/ or document#/ reference.`);return`${Ke(g)}: ${Ye({$ref:m.$ref},{statePrefix:r})}`}),u=l.some(([,g])=>H(g)),f=`${Fi}(${a}, ${c.length>0?`{ ${c.join(", ")} }`:"{}"})`,p=L(r,pe(e)),d=`console.error(${JSON.stringify(`Jx server function ${t.$export}:`)}, e)`;return(u?[`// ${e}: server function ${t.$export}, called again when an argument changes`,"{"," let _jxSeq = 0;",o?` ${o}.push(effect(() => {`:" effect(() => {"," const _seq = ++_jxSeq;",` ${f}`,` .then((d) => { if (_seq === _jxSeq) ${p} = d; })`,` .catch((e) => { if (_seq === _jxSeq) ${d}; });`,o?" }));":" });","}"]:[`// ${e}: server function ${t.$export}, called once`,f,` .then((d) => { ${p} = d; })`,` .catch((e) => { ${d}; });`]).map((g)=>`${s}${g}`).join(`
14
+ `)}function Ic(e,t){if(t==="state")return e;return e.replaceAll(/\$\{([^}]*)\}/g,(n,r)=>`\${${r.replaceAll(/(?<!this\.)\bstate\./g,`${t}.`)}}`)}function mr(e){if(!J(e))return!1;if(e.state)for(let[t,n]of Object.entries(e.state)){if(t==="$site"||t==="$page")continue;if(!J(n)||Array.isArray(n))return!0;if(n.timing==="compiler")continue;if(n.$prototype)return!0;if("default"in n)return!0;if(it(n))continue;return!0}if(e.$switch)return!0;if(te(e)||rs(e.children))return!0;if(Array.isArray(e.children)&&e.children.some((t)=>mr(t)))return!0;for(let[t,n]of Object.entries(e)){if(Xe.has(t))continue;if(H(n))return!0;if(W(n))return!0}if(J(e.style)){for(let t of Object.values(e.style))if(W(t))return!0}if(J(e.attributes)){for(let t of Object.values(e.attributes))if(W(t))return!0}return!1}function Pi(e){if(!J(e))return!1;if(e.$switch)return!0;if(te(e)||rs(e.children))return!0;for(let[t,n]of Object.entries(e)){if(Xe.has(t))continue;if(H(n))return!0;if(W(n))return!0}if(J(e.style)){for(let t of Object.values(e.style))if(W(t))return!0}if(J(e.attributes)){for(let t of Object.values(e.attributes))if(W(t))return!0}return!1}function Mt(e,t=null,n={},r={}){let s=e?.state?Ps(e.state,t):t??ki();return{media:r,scope:s,scopeDefs:n}}function ki(e=null){return Object.create(e)}function Ii(e){return e[_i]}function Wc(e,t,n){if(t>0&&Fc.test(e.charAt(t-1)))return!1;let r=t+5;if(n)return!Lc.test(e.charAt(r));while(/\s/u.test(e.charAt(r)))r+=1;return e.charAt(r)==="."}function Ft(e,t,n={}){if(!e.includes("state"))return e;let r=n.bare===!0,s=n.code===!1?e:yt(e),o="",i=0;for(let a=s.indexOf("state");a!==-1;a=s.indexOf("state",a+1))if(Wc(s,a,r))o+=e.slice(i,a)+t,i=a+5;return o+e.slice(i)}function _s(e,t){if(S(e)){if(!e.includes("state."))return;let o=yt(e);for(let i of o.matchAll(Dc))t.add(i[1]);for(let i of o.matchAll(Mc))t.add(i[1]);return}if(Array.isArray(e)){for(let o of e)_s(o,t);return}if(!J(e))return;let n=e,{operator:r,target:s}=n;if(S(r)&&Ge(r)&&H(s)&&s.$ref.startsWith("#/state/"))t.add(s.$ref.slice(8).split("/")[0]);for(let o of Object.values(n))_s(o,t)}function lt(e,t){if(se(t)&&fs(t))throw Error(`${e} declares both "body" and "$src"; they are mutually exclusive (spec.md §5.3 4d). Keep one.`)}function Ps(e={},t=null){let n=ki(t),r=t?Ii(t):void 0,s=new Set(r);Object.defineProperty(n,_i,{configurable:!0,enumerable:!1,value:s,writable:!0});let o=new Set;for(let u of Object.values(e))if(se(u)||Ee(u))_s(u.body??u.$expression,o);for(let u of o)if(u in e)s.add(u);let i=$t({state:e});for(let[u,f]of Object.entries(e)){if(!J(f)||Array.isArray(f)){Ze(n,u,ir(f));continue}if("default"in f){Ze(n,u,ir(f.default));continue}if(Ue(f)){s.add(u);continue}if(!f.$prototype&&!("$expression"in f)&&!it(f))Ze(n,u,ir(f))}let a=[],l=[];for(let[u,f]of Object.entries(e)){if(W(f)){a.push([u,f]);continue}if(!J(f))continue;if(Ee(f)){let p=f.$expression;if(xt(f)){let d=f.parameters;Ze(n,u,(...h)=>{let g={};for(let[m,x]of d.entries()){let w=Ti(x);if(!w)continue;g[w]=h[m]===void 0&&Ri(x)?x.default:h[m]}return Je(p,n,null,{args:g})})}else if(Ge(p.operator))Ze(n,u,(d,h)=>Je(p,d,h));else Ts(n,u,()=>Je(p,n,null));continue}if(se(f)){if(lt(`state entry "${u}"`,f),De(f)){let{body:p}=f;Ze(n,u,(d,h)=>{kt(p,d??n,h??null)})}else if(S(f.body)){let{body:p}=f,d=Function(...Fe(f),p);if(i.get(u)==="computed")Ts(n,u,()=>d(n)),l.push([u,p]);else Ze(n,u,d)}else Ze(n,u,()=>{}),s.add(u);continue}if(ot(f)&&(f.$prototype==="LocalStorage"||f.$prototype==="SessionStorage")){Ze(n,u,ir(f.default??null));continue}if(ot(f)&&f.$prototype==="Request")s.add(u)}let c=!0;while(c){c=!1;for(let[u,f]of[...l,...a])if(!s.has(u)&&Di(f,n))s.add(u),c=!0}for(let[u,f]of a)Ts(n,u,()=>Ds(f,n));return n}function Ze(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function Ts(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:n})}function q(e,t){if(H(e))return Vc(e.$ref,t);if(W(e))return Ds(e,t);return e}function xe(e){return H(e)}function Vc(e,t){if(!S(e))return e;if(e.startsWith("$map/")){let n=e.split("/"),r=n[1],o=t.$map?.[r]??t[`$map/${r}`];return n.length>2?Rs(o,n.slice(2).join("/")):o}if(e.startsWith("#/state/"))return Rs(t,e.slice(8));return Rs(t,e)??null}function Di(e,t){if(!t)return!1;let n=Ii(t);for(let r of e.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*(\()?/g)){if(r[2])continue;let s=r[1];if(n?.has(s))return!0;let o;try{o=t[s]}catch{continue}if(we(o))return!0}return!1}function gr(e){return nr(e)?`(${e.slice(2,-1)})`:`\`${e}\``}function Ds(e,t){if(Di(e,t))return null;let n=["state","$map","$site","$page"],r=[t,t?.$map,t?.$site,t?.$page];try{let s=nr(e)?`return (${e.slice(2,-1)})`:`return \`${e}\``;return Function(...n,s)(...r)}catch{return null}}function Rs(e,t){return oe(e,t)}function ir(e){if(!J(e))return e;return structuredClone(e)}function Bc(e,t){if(!e||!t)return"";return Object.entries(e).filter(([n,r])=>!n.startsWith(":")&&!n.startsWith(".")&&!n.startsWith("&")&&!n.startsWith("[")&&!n.startsWith("@")&&W(r)).map(([n,r])=>{let s=q(r,t);return s==null?null:`${he(n)}: ${s}`}).filter(Boolean).join("; ")}function bt(e,t,n=""){let r="",s=q(e.id,t),o=q(e.className,t),i=q(e.hidden,t),a=q(e.tabIndex,t),l=q(e.title,t),c=q(e.lang,t),u=q(e.dir,t);if(s)r+=` id="${k(String(s))}"`;if(o)r+=` class="${k(String(o))}"`;if(i)r+=" hidden";if(a!==void 0&&a!==null)r+=` tabindex="${k(String(a))}"`;if(l)r+=` title="${k(String(l))}"`;if(c)r+=` lang="${k(String(c))}"`;if(u)r+=` dir="${k(String(u))}"`;let f=[Bc(e.style,t),n].filter(Boolean).join("; ");if(f)r+=` style="${k(f)}"`;if(e.attributes)for(let[p,d]of Object.entries(e.attributes)){let h=q(d,t);if(ge(h)){let g=St(p,h);if(g!==null)r+=g===""?` ${p}`:` ${p}="${k(g)}"`;continue}if(S(h)||re(h))r+=` ${p}="${k(String(h))}"`}if(e.$static)r+=" data-jx-static";else if(e.$prerendered)r+=" data-jx-prerendered";return r}function Jn(e,t=" "){return e?"":`
15
+ ${t}`}function hr(){let e=JSON.stringify(Qn),t=JSON.stringify(Re);return`(function(){try{var s=localStorage.getItem(${e});if(s==="light"||s==="dark"){document.documentElement.setAttribute(${t},s)}}catch(e){}})()`}function ar(e,t,n,r){for(let s of Rt(t,{mediaQueries:r,resolveValue:(o,i)=>Mi(o,i,n),scope:n}))e.push(s.text)}function Mi(e,t,n){let r=S(t)?t:t.$ref;return Hc.push({property:e,selector:n,source:r}),null}function xr(){return`const __jxEnumAttrs = new Set(${JSON.stringify(Ai())});
16
+ function ${Lt}(n, v) {
8
17
  if (typeof v !== 'boolean') return v;
9
18
  const l = n.toLowerCase();
10
19
  if (l.startsWith('aria-') || __jxEnumAttrs.has(l)) return String(v);
11
20
  return v ? '' : null;
12
- }`}function lr(){return[`async function ${ci}(url, args) {`," const r = await fetch(url, {"," method: 'POST',"," headers: { 'Content-Type': 'application/json' },"," body: JSON.stringify(args),"," });"," const text = await r.text();"," let body = null;"," if (text !== '') {"," try { body = JSON.parse(text); } catch (e) { if (r.ok) throw e; }"," }"," if (!r.ok) throw new Error((body && body.error) || text || r.statusText);"," return body;","}"].join(`
13
- `)}function ui(){let e=`new RegExp(${JSON.stringify(zn.source)}, ${JSON.stringify(zn.flags)})`,t=`Symbol.for(${JSON.stringify(fs)})`,n=JSON.stringify(us),r=JSON.stringify(Kn);return[`const __jxSlotWs = ${e};`,`const __jxSlotRec = globalThis[${t}] || (globalThis[${t}] = new WeakMap());`,`function ${$s}(host) {`,` const id = host.getAttribute(${n});`," if (id === null) return Array.from(host.childNodes);",` host.removeAttribute(${n});`,` const open = ${r} + ' ' + id + ' ';`,` const close = '/' + ${r} + ' ' + id;`," const openers = [];"," const w = host.ownerDocument.createTreeWalker(host, 128);"," for (let n = w.nextNode(); n; n = w.nextNode()) if (n.data.startsWith(open)) openers.push(n);"," const out = [];"," for (const o of openers) {"," const name = decodeURIComponent(o.data.slice(open.length));"," for (let n = o.nextSibling; n; n = n.nextSibling) {"," if (n.nodeType === 8 && n.data === close) break;"," __jxSlotRec.set(n, name);"," out.push(n);"," }"," }"," return out;","}",`function ${Ss}(host, captured) {`," const slots = Array.from(host.querySelectorAll('slot'));"," if (slots.length === 0) return;"," const groups = new Map();"," for (const n of captured) {"," if (n.nodeType === 3 && __jxSlotWs.test(n.data)) continue;"," const r = __jxSlotRec.get(n);"," __jxSlotRec.delete(n);"," const name = r !== undefined ? r : n.nodeType === 1 ? n.getAttribute('slot') || '' : '';"," let g = groups.get(name);"," if (!g) { g = []; groups.set(name, g); }"," g.push(n);"," }"," const taken = new Set();"," for (const slot of slots) {"," const name = slot.getAttribute('name') || '';"," let g = [];"," if (!taken.has(name)) { taken.add(name); g = groups.get(name) || []; }"," const content = g.some((n) => n.nodeType === 1 || (n.nodeType === 3 && n.data !== ''));"," const placed = content ? g : g.concat(Array.from(slot.childNodes));"," const p = slot.parentElement;"," if (p && p !== host && p.localName.includes('-')) {"," const r = __jxSlotRec.get(slot);"," const f = r !== undefined ? r : slot.getAttribute('slot') || '';"," for (const n of placed) __jxSlotRec.set(n, f);"," }"," slot.replaceWith(...placed);"," }","}"].join(`
14
- `)}function Pt(e){for(let t of bs(e)){if(ne(t)){if(t.map&&Pt([t.map]))return!0;continue}if(!ln(t))continue;if(t.tagName==="slot")return!0;let n=Object.values(t.cases??{}).filter((r)=>ln(r)&&!he(r));if(Pt(n)||Pt(t.children))return!0}return!1}function bs(e){if(ne(e))return[e];if(!Array.isArray(e))return[];return e}function Ft(e,t={},n=null){let r=[],s=Xo(A(n)?n:{},t,(i)=>i,li);if(s!=="")r.push(s);if(kt(e,r,t,"",{n:0}),r.length===0)return"";return`<style>
15
- ${Xl(r.join(`
21
+ }`}function yr(){return[`async function ${Fi}(url, args) {`," const r = await fetch(url, {"," method: 'POST',"," headers: { 'Content-Type': 'application/json' },"," body: JSON.stringify(args),"," });"," const text = await r.text();"," let body = null;"," if (text !== '') {"," try { body = JSON.parse(text); } catch (e) { if (r.ok) throw e; }"," }"," if (!r.ok) throw new Error((body && body.error) || text || r.statusText);"," return body;","}"].join(`
22
+ `)}function Li(){let e=`new RegExp(${JSON.stringify(rr.source)}, ${JSON.stringify(rr.flags)})`,t=`Symbol.for(${JSON.stringify(vs)})`,n=JSON.stringify(js),r=JSON.stringify(sr);return[`const __jxSlotWs = ${e};`,`const __jxSlotRec = globalThis[${t}] || (globalThis[${t}] = new WeakMap());`,`function ${Ms}(host) {`,` const id = host.getAttribute(${n});`," if (id === null) return Array.from(host.childNodes);",` host.removeAttribute(${n});`,` const open = ${r} + ' ' + id + ' ';`,` const close = '/' + ${r} + ' ' + id;`," const openers = [];"," const w = host.ownerDocument.createTreeWalker(host, 128);"," for (let n = w.nextNode(); n; n = w.nextNode()) if (n.data.startsWith(open)) openers.push(n);"," const out = [];"," for (const o of openers) {"," const name = decodeURIComponent(o.data.slice(open.length));"," for (let n = o.nextSibling; n; n = n.nextSibling) {"," if (n.nodeType === 8 && n.data === close) break;"," __jxSlotRec.set(n, name);"," out.push(n);"," }"," }"," return out;","}",`function ${Fs}(host, captured) {`," const slots = Array.from(host.querySelectorAll('slot'));"," if (slots.length === 0) return;"," const groups = new Map();"," for (const n of captured) {"," if (n.nodeType === 3 && __jxSlotWs.test(n.data)) continue;"," const r = __jxSlotRec.get(n);"," __jxSlotRec.delete(n);"," const name = r !== undefined ? r : n.nodeType === 1 ? n.getAttribute('slot') || '' : '';"," let g = groups.get(name);"," if (!g) { g = []; groups.set(name, g); }"," g.push(n);"," }"," const taken = new Set();"," for (const slot of slots) {"," const name = slot.getAttribute('name') || '';"," let g = [];"," if (!taken.has(name)) { taken.add(name); g = groups.get(name) || []; }"," const content = g.some((n) => n.nodeType === 1 || (n.nodeType === 3 && n.data !== ''));"," const placed = content ? g : g.concat(Array.from(slot.childNodes));"," const p = slot.parentElement;"," if (p && p !== host && p.localName.includes('-')) {"," const r = __jxSlotRec.get(slot);"," const f = r !== undefined ? r : slot.getAttribute('slot') || '';"," for (const n of placed) __jxSlotRec.set(n, f);"," }"," slot.replaceWith(...placed);"," }","}"].join(`
23
+ `)}function It(e){for(let t of Ls(e)){if(te(t)){if(t.map&&It([t.map]))return!0;continue}if(!fn(t))continue;if(t.tagName==="slot")return!0;let n=Object.values(t.cases??{}).filter((r)=>fn(r)&&!xe(r));if(It(n)||It(t.children))return!0}return!1}function Ls(e){if(te(e))return[e];if(!Array.isArray(e))return[];return e}function Vt(e,t={},n=null){let r=[],s=Oi(J(n)?n:{},t,(i)=>i,Mi);if(s!=="")r.push(s);if(Dt(e,r,t,"",{n:0}),r.length===0)return"";return`<style>
24
+ ${Uc(r.join(`
16
25
  `))}
17
- </style>`}function Xl(e){return e.replaceAll(/<\/(?=style)/gi,String.raw`<\/`)}function kt(e,t,n,r="",s,o="jx"){let i=s??{n:0};if(!A(e))return;if(e.style&&!e.id&&!e.className)e.className=`${o}-${i.n}`,i.n+=1;let c=jt(e.tagName).join(", ")||"*",a=e.id?`#${e.id}`:e.className?`.${e.className.split(" ")[0]}`:c;if(e.style)Xn(t,e.style,a,n);if(Array.isArray(e.children))for(let l of e.children)kt(l,t,n,a,i,o);if(A(e.cases))for(let l of Object.values(e.cases))kt(l,t,n,a,i,o)}function _(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function cr(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function ap(e){let t=[];return fi(e,t),t}function fi(e,t){if(!A(e))return;if(e.state){for(let[n,r]of Object.entries(e.state))if(He(r))t.push({exportName:r.$export,key:n,src:r.$src})}if(Array.isArray(e.children))for(let n of e.children)fi(n,t)}function Es(e,t){if(b(e))return e;let n=jt(e);if(n.length===0)return"div";if(!Me(e))return n[0];let r=e.$expression,s=r.target;if(r.operator==="?:")return B(s,t)?r.value:r.initial;let o=B(s,t);return r.cases[String(o)]??r.default}function Zl(e){if(!e?.slotIds)return null;return e.slotIds.n+=1,e.slotIds.n}function Ql(e,t,n,r=null){let s=new Map;for(let o of bs(e)){let i="",c=!0,a;if(b(o)||se(o)||me(o)){if(a=n(o),zn.test(a))continue;c=a!==""}else if(ne(o))a="";else if(!ln(o))a=n(o),c=a!=="";else{let u=B(o.attributes?.slot,t),f=b(o.slot)?B(o.slot,t):null;if(b(u)&&u!=="")i=u,a=n(o);else if(b(f)&&f!==""){i=f;let{slot:p,...d}=o;a=n({...d,attributes:{...d.attributes,slot:f}})}else a=n(o)}let l=s.get(i);if(l)l.html=l.html===""?a:`${l.html}
18
- ${a}`,l.content||=c;else s.set(i,{content:c,html:a})}return{groups:s,id:r,taken:new Set}}function pi(e,t,n){for(let r of bs(e)){if(ne(r)||!ln(r))continue;if(r.tagName==="slot"){let s=B(r.attributes?.name,t);n.taken.add(b(s)?s:"")}pi(r.children,t,n)}}function ec(e){let t=null,n={};for(let[r,s]of Object.entries(e??{}))if(r.startsWith("props.")&&r.length>6)t??={},t[r.slice(6)]=s;else n[r]=s;return{lifted:t,rest:n}}function di(e,t){if(!t)return gs(e.state??{},null);let n={...e.state};for(let[r,s]of Object.entries(t)){let o=n[r];n[r]=A(o)&&!Array.isArray(o)&&"default"in o?{...o,default:s}:s}return gs(n,null)}function tc(e,t){return Object.fromEntries(Object.entries(e??{}).flatMap(([n,r])=>{if(!L(r))return[];let s=B(r,t);return s==null?[]:[[n,s]]}))}function hn(e,t,n,r){if(e.textContent!==void 0){let s=B(e.textContent,t);return s!=null?_(String(s)):""}if(e.innerHTML){let s=B(e.innerHTML,t);return s!=null?String(s):e.innerHTML}if(Array.isArray(e.children))return e.children.map((s)=>Zn(s,t,n,r)).join(`
19
- `);return""}function Zn(e,t,n=null,r=null){if(b(e)){if(L(e)&&t){let c=ys(e,t);return c!=null?_(String(c)):_(e)}return _(e)}if(se(e)||me(e))return _(String(e));if(Array.isArray(e))return e.map((c)=>Zn(c,t,n,r)).join(`
20
- `);if(!A(e))return"";if(e.$prototype==="Array")return"";if(e.$switch){let c=e.tagName??"div",a=St(e,t),l=B(e.$switch,t),u=l==null?void 0:e.cases?.[String(l)],f=u!==void 0&&!he(u)?Zn(u,t,n,r):"";return`<${c}${a}>${f}</${c}>`}let s=Es(e.tagName,t);if(s==="slot"&&n){let c=B(e.attributes?.name,t),a=b(c)?c:"",l;if(!n.taken.has(a))n.taken.add(a),l=n.groups.get(a);let u=l?.html??"";if(u!==""&&n.id!==null)u=`<!--${Kn} ${n.id} ${encodeURIComponent(a)}-->${u}<!--/${Kn} ${n.id}-->`;if(l?.content)return pi(e.children,t,n),u;let f=hn(e,t,n,r);return u===""?f:f===""?u:`${u}
21
- ${f}`}let o=r?.componentDefs.get(s);if(o&&r)return nc(e,o,t,n,r);let i=St(e,t);if(ws.has(s))return`<${s}${i}>`;return`<${s}${i}>${hn(e,t,n,r)}</${s}>`}function nc(e,t,n,r,s){let o=t.tagName,{lifted:i,rest:c}=ec(e.attributes),a={...i,...e.$props},l={};for(let[y,w]of Object.entries(a))l[y]=B(w,n)??w;let u=Object.keys(l).length>0,f=s.path??[],p={key:JSON.stringify(l),tag:o},d=[...f.map((y)=>y.tag),o].join(" → ");if(f.some((y)=>y.tag===p.tag&&y.key===p.key))throw Error(`Component <${o}> renders itself: ${d}. A component cannot appear inside its own `+"definition with the same props — the expansion would never end.");if(f.length>=cs)throw Error(`Component nesting exceeds ${cs} levels: ${d}. A component that renders itself with changing props needs a case that stops.`);let h={...s,path:[...f,p]},{children:g}=e,m=(y)=>Zn(y,n,r,s),x=Gn(t,s.defaults),E=rc(t),O=di(t,u?l:null),J,C=null;if(x){let y=Array.isArray(g)?g.map((w)=>m(w)).join(`
22
- `):"";J=`<template shadowrootmode="${x}"><link rel="stylesheet" href="/components/${o}.css">${hn(t,O,null,h)}</template>${y}`}else{C=!E&&Pt(t.children)?Zl(s):null;let y=Ql(g,n,m,C);J=hn(t,O,y,h)}let q=Object.entries(tc(t.style,O)).map(([y,w])=>`${ge(y)}: ${w}`).join("; "),S={...e};if(delete S.$props,delete S.children,S.attributes=!E&&u?{...c,"data-jx-props":JSON.stringify(l)}:c,C!==null)S.attributes={...S.attributes,[us]:String(C)};if(E)S.$static=!0;else S.$prerendered=!0;return`<${o}${St(S,n,q)}>${J}</${o}>`}function lp(e,t=null,n=null,r=null){return hn(e,di(e,t),n,r)}function rc(e){return hs(e)}function hs(e){if(!A(e))return!0;if(Array.isArray(e))return e.every((t)=>hs(t));if(e.$prototype)return!1;if(e.$ref)return!1;if(e.state)for(let t of Object.values(e.state)){if(!A(t)||Array.isArray(t))continue;if(t.$prototype)return!1;if(t.$ref)return!1}for(let t of Object.keys(e))if(t.startsWith("on")&&t!=="observedAttributes")return!1;if(Array.isArray(e.children))return e.children.every((t)=>hs(t));if(ne(e.children))return!1;return!0}function oc(e,t){return un(e).map((n)=>ic(n,t)).join(", ")}function ic(e,t){let n=Vn(e,t);if(n!==null)return n;if(e.startsWith(":host")){let r=/^:host\((.*)\)$/.exec(e)?.[1];if(t===":host")return e;return r===void 0?t:`${t}${r}`}if(t===":host"&&sc.test(e))return e;return`${t}${e}`}function cp(e,t,n=null,r={},s=null){let o=[],i=ei(e,s);if(A(t)){let c={},a=[];for(let[l,u]of Object.entries(t))if(H(u))c[l]=u;else if(A(u)&&!Array.isArray(u))a.push([l,u]);else if(!l.startsWith("@")&&!at(l))c[l]=u;Xn(o,c,i,r);for(let[l,u]of a)if(l.startsWith("@"))Xn(o,{[l]:u},i,r);else if(at(l))Xn(o,u,oc(l,i),r)}if(n&&Array.isArray(n.children)){let c={n:0};for(let a of n.children)kt(a,o,r,"",c,e)}return o.length>0?`${o.join(`
26
+ </style>`}function Uc(e){return e.replaceAll(/<\/(?=style)/gi,String.raw`<\/`)}function Dt(e,t,n,r="",s,o="jx"){let i=s??{n:0};if(!J(e))return;if(e.style&&!e.id&&!e.className)e.className=`${o}-${i.n}`,i.n+=1;let a=Tt(e.tagName).join(", ")||"*",l=e.id?`#${e.id}`:e.className?`.${e.className.split(" ")[0]}`:a;if(e.style)ar(t,e.style,l,n);if(Array.isArray(e.children))for(let c of e.children)Dt(c,t,n,l,i,o);if(J(e.cases))for(let c of Object.values(e.cases))Dt(c,t,n,l,i,o)}function k(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function $r(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function Sd(e){let t=[];return Wi(e,t),t}function Wi(e,t){if(!J(e))return;if(e.state){for(let[n,r]of Object.entries(e.state))if(Ue(r))t.push({exportName:r.$export,key:n,src:r.$src})}if(Array.isArray(e.children))for(let n of e.children)Wi(n,t)}function Vs(e,t){if(S(e))return e;let n=Tt(e);if(n.length===0)return"div";if(!Me(e))return n[0];let r=e.$expression,s=r.target;if(r.operator==="?:")return q(s,t)?r.value:r.initial;let o=q(s,t);return r.cases[String(o)]??r.default}function qc(e){if(!e?.slotIds)return null;return e.slotIds.n+=1,e.slotIds.n}function zc(e,t,n,r=null){let s=new Map;for(let o of Ls(e)){let i="",a=!0,l;if(S(o)||re(o)||ge(o)){if(l=n(o),rr.test(l))continue;a=l!==""}else if(te(o))l="";else if(!fn(o))l=n(o),a=l!=="";else{let u=q(o.attributes?.slot,t),f=S(o.slot)?q(o.slot,t):null;if(S(u)&&u!=="")i=u,l=n(o);else if(S(f)&&f!==""){i=f;let{slot:p,...d}=o;l=n({...d,attributes:{...d.attributes,slot:f}})}else l=n(o)}let c=s.get(i);if(c)c.html=c.html===""?l:`${c.html}
27
+ ${l}`,c.content||=a;else s.set(i,{content:a,html:l})}return{groups:s,id:r,taken:new Set}}function Vi(e,t,n){for(let r of Ls(e)){if(te(r)||!fn(r))continue;if(r.tagName==="slot"){let s=q(r.attributes?.name,t);n.taken.add(S(s)?s:"")}Vi(r.children,t,n)}}function Kc(e){let t=null,n={};for(let[r,s]of Object.entries(e??{}))if(r.startsWith("props.")&&r.length>6)t??={},t[r.slice(6)]=s;else n[r]=s;return{lifted:t,rest:n}}function Bi(e,t){if(!t)return Ps(e.state??{},null);let n={...e.state};for(let[r,s]of Object.entries(t)){let o=n[r];n[r]=J(o)&&!Array.isArray(o)&&"default"in o?{...o,default:s}:s}return Ps(n,null)}function Gc(e,t){return Object.fromEntries(Object.entries(e??{}).flatMap(([n,r])=>{if(!W(r))return[];let s=q(r,t);return s==null?[]:[[n,s]]}))}function wn(e,t,n,r){if(e.textContent!==void 0){let s=q(e.textContent,t);return s!=null?k(String(s)):""}if(e.innerHTML){let s=q(e.innerHTML,t);return s!=null?String(s):e.innerHTML}if(Array.isArray(e.children))return e.children.map((s)=>lr(s,t,n,r)).join(`
28
+ `);return""}function lr(e,t,n=null,r=null){if(S(e)){if(W(e)&&t){let a=Ds(e,t);return a!=null?k(String(a)):k(e)}return k(e)}if(re(e)||ge(e))return k(String(e));if(Array.isArray(e))return e.map((a)=>lr(a,t,n,r)).join(`
29
+ `);if(!J(e))return"";if(e.$prototype==="Array")return"";if(e.$switch){let a=e.tagName??"div",l=bt(e,t),c=q(e.$switch,t),u=c==null?void 0:e.cases?.[String(c)],f=u!==void 0&&!xe(u)?lr(u,t,n,r):"";return`<${a}${l}>${f}</${a}>`}let s=Vs(e.tagName,t);if(s==="slot"&&n){let a=q(e.attributes?.name,t),l=S(a)?a:"",c;if(!n.taken.has(l))n.taken.add(l),c=n.groups.get(l);let u=c?.html??"";if(u!==""&&n.id!==null)u=`<!--${sr} ${n.id} ${encodeURIComponent(l)}-->${u}<!--/${sr} ${n.id}-->`;if(c?.content)return Vi(e.children,t,n),u;let f=wn(e,t,n,r);return u===""?f:f===""?u:`${u}
30
+ ${f}`}let o=r?.componentDefs.get(s);if(o&&r)return Yc(e,o,t,n,r);let i=bt(e,t);if(Ws.has(s))return`<${s}${i}>`;return`<${s}${i}>${wn(e,t,n,r)}</${s}>`}function Yc(e,t,n,r,s){let o=t.tagName,{lifted:i,rest:a}=Kc(e.attributes),l={...i,...e.$props},c={};for(let[y,j]of Object.entries(l))c[y]=q(j,n)??j;let u=Object.keys(c).length>0,f=s.path??[],p={key:JSON.stringify(c),tag:o},d=[...f.map((y)=>y.tag),o].join(" → ");if(f.some((y)=>y.tag===p.tag&&y.key===p.key))throw Error(`Component <${o}> renders itself: ${d}. A component cannot appear inside its own `+"definition with the same props — the expansion would never end.");if(f.length>=Cs)throw Error(`Component nesting exceeds ${Cs} levels: ${d}. A component that renders itself with changing props needs a case that stops.`);let h={...s,path:[...f,p]},{children:g}=e,m=(y)=>lr(y,n,r,s),x=or(t,s.defaults),w=Xc(t),N=Bi(t,u?c:null),E,O=null;if(x){let y=Array.isArray(g)?g.map((j)=>m(j)).join(`
31
+ `):"";E=`<template shadowrootmode="${x}"><link rel="stylesheet" href="/components/${o}.css">${wn(t,N,null,h)}</template>${y}`}else{O=!w&&It(t.children)?qc(s):null;let y=zc(g,n,m,O);E=wn(t,N,y,h)}let K=Object.entries(Gc(t.style,N)).map(([y,j])=>`${he(y)}: ${j}`).join("; "),b={...e};if(delete b.$props,delete b.children,b.attributes=!w&&u?{...a,"data-jx-props":JSON.stringify(c)}:a,O!==null)b.attributes={...b.attributes,[js]:String(O)};if(w)b.$static=!0;else b.$prerendered=!0;return`<${o}${bt(b,n,K)}>${E}</${o}>`}function bd(e,t=null,n=null,r=null){return wn(e,Bi(e,t),n,r)}function Xc(e){return ks(e)}function ks(e){if(!J(e))return!0;if(Array.isArray(e))return e.every((t)=>ks(t));if(e.$prototype)return!1;if(e.$ref)return!1;if(e.state)for(let t of Object.values(e.state)){if(!J(t)||Array.isArray(t))continue;if(t.$prototype)return!1;if(t.$ref)return!1}for(let t of Object.keys(e))if(t.startsWith("on")&&t!=="observedAttributes")return!1;if(Array.isArray(e.children))return e.children.every((t)=>ks(t));if(te(e.children))return!1;return!0}function Qc(e,t){return hn(e).map((n)=>eu(n,t)).join(", ")}function eu(e,t){let n=Zn(e,t);if(n!==null)return n;if(e.startsWith(":host")){let r=/^:host\((.*)\)$/.exec(e)?.[1];if(t===":host")return e;return r===void 0?t:`${t}${r}`}if(t===":host"&&Zc.test(e))return e;return`${t}${e}`}function wd(e,t,n=null,r={},s=null){let o=[],i=vi(e,s);if(J(t)){let a={},l=[];for(let[c,u]of Object.entries(t))if(H(u))a[c]=u;else if(J(u)&&!Array.isArray(u))l.push([c,u]);else if(!c.startsWith("@")&&!at(c))a[c]=u;ar(o,a,i,r);for(let[c,u]of l)if(c.startsWith("@"))ar(o,{[c]:u},i,r);else if(at(c))ar(o,u,Qc(c,i),r)}if(n&&Array.isArray(n.children)){let a={n:0};for(let l of n.children)Dt(l,o,r,"",a,e)}return o.length>0?`${o.join(`
23
32
  `)}
24
- `:""}var Bl,ri,nr="https://esm.sh/@vue/reactivity@3.5.40",rr="https://esm.sh/lit-html@3.3.0",ql,zl,lt,Yl,Mt="__jxAttrText",ci="__jxServerCall",$s="__jxCaptureSlotted",Ss="__jxDistributeSlots",Dt="<!---->",ws,sc;var Lt=j(()=>{gn();pn();mn();Un();Zo();z();Tt();gn();mn();Un();z();Bl=["$map/","event#/","$args/","$reduce/"];ri=Symbol("jx.runtimeOnlyStateKeys");ql=/\bstate\.([A-Za-z_$][\w$]*)\s*(?:\+\+|--|(?:\*\*|\|\||&&|\?\?|<<|>>>|>>|[-+*/%&|^])?=(?!=))/g,zl=/\bstate\.([A-Za-z_$][\w$]*)\s*\.\s*(?:push|pop|shift|unshift|splice|sort|reverse|fill|copyWithin)\s*\(/g;lt=new Set(["pre","textarea","listing","plaintext","xmp"]);Yl=[];ws=new Set(["input","br","hr","img","meta","link","area","col","source"]);sc=/^(?:::slotted\(|::part\()/});class mi{index;text;constructor(e){this.text=e,this.index=e.codePointAt(0)===65279?1:0}get done(){return this.index>=this.text.length}startsWith(e){return this.text.startsWith(e,this.index)}skipLine(){let e=this.text.indexOf(`
33
+ `:""}var kc,_i,pr="https://esm.sh/@vue/reactivity@3.5.40",dr="https://esm.sh/lit-html@3.3.0",Dc,Mc,Fc,Lc,ct,Hc,Lt="__jxAttrText",Fi="__jxServerCall",Ms="__jxCaptureSlotted",Fs="__jxDistributeSlots",Wt="<!---->",Ws,Zc;var Bt=A(()=>{mn();bn();yn();Sn();tr();Ci();U();_t();bn();Sn();tr();U();kc=["$map/","event#/","$args/","$reduce/"];_i=Symbol("jx.runtimeOnlyStateKeys");Dc=/\bstate\.([A-Za-z_$][\w$]*)\s*(?:\+\+|--|(?:\*\*|\|\||&&|\?\?|<<|>>>|>>|[-+*/%&|^])?=(?!=))/g,Mc=/\bstate\.([A-Za-z_$][\w$]*)\s*\.\s*(?:push|pop|shift|unshift|splice|sort|reverse|fill|copyWithin)\s*\(/g,Fc=/[\w$.]/u,Lc=/[\w$]/u;ct=new Set(["pre","textarea","listing","plaintext","xmp"]);Hc=[];Ws=new Set(["input","br","hr","img","meta","link","area","col","source"]);Zc=/^(?:::slotted\(|::part\()/});class Hi{index;text;constructor(e){this.text=e,this.index=e.codePointAt(0)===65279?1:0}get done(){return this.index>=this.text.length}startsWith(e){return this.text.startsWith(e,this.index)}skipLine(){let e=this.text.indexOf(`
25
34
  `,this.index);this.index=e===-1?this.text.length:e}skipBlock(){let e=1;this.index+=2;while(!this.done&&e>0)if(this.startsWith("/*"))e+=1,this.index+=2;else if(this.startsWith("*/"))e-=1,this.index+=2;else this.index+=1}skipTrivia(){for(;;){while(!this.done&&/[\s;]/u.test(this.text.charAt(this.index)))this.index+=1;if(this.startsWith("//"))this.skipLine();else if(this.startsWith("/*"))this.skipBlock();else if(this.startsWith("/-"))this.index+=2,this.skipNode();else return}}skipString(){let e=0,t=this.index;while(this.text.charAt(t)==="#")e+=1,t+=1;let n=this.text.startsWith('"""',t),r=n?'"""':'"',s=r+"#".repeat(e);t+=r.length;while(t<this.text.length)if(e===0&&this.text.charAt(t)==="\\")t+=2;else if(this.text.startsWith(s,t))return this.index=t+s.length,!0;else if(!n&&this.text.charAt(t)===`
26
35
  `)return!1;else t+=1;return!1}skipNode(){let e=0;while(!this.done){let t=this.text.charAt(this.index);if(t==='"'||t==="#"&&/^#+"/u.test(this.text.slice(this.index,this.index+16))){if(!this.skipString())return!1}else if(this.startsWith("//"))this.skipLine();else if(this.startsWith("/*"))this.skipBlock();else if(t==="{")e+=1,this.index+=1;else if(t==="}"){if(e===0)return!1;e-=1,this.index+=1}else if((t===`
27
- `||t===";")&&e===0)return this.index+=1,!0;else this.index+=1}return e===0}}function Wt(e){if(ac.test(e))return"unreadable";let t=new mi(e);for(;;){if(t.skipTrivia(),t.done)return"document";if(t.startsWith("(")){let n=e.indexOf(")",t.index);if(n===-1)return"unreadable";t.index=n+1}else{let[n]=lc.exec(e.slice(t.index,t.index+256))??[];if(!n)return t.startsWith('"')||t.startsWith("#")?"document":"unreadable";if(!n.startsWith("$"))return n==="project"?"project":"document";if(t.index+=n.length,!t.skipNode())return"unreadable"}}}var ac,lc;var $n=j(()=>{ac=/\0/u,lc=/^[^\s\\/(){};[\]"#=]+/u});function hi(e){let t=[],n=[],r=null,s=0,o=()=>n.at(-1)?.path??"",i=()=>r===null?o():fc(o(),r),c=()=>{s+=1;let a="";while(s<e.length){let l=e[s];if(l==="\\"){let u=e[s+1]??"";if(u==="u")a+=String.fromCodePoint(Number.parseInt(e.slice(s+2,s+6),16)),s+=6;else a+=cc.get(u)??u,s+=2;continue}if(l==='"')return s+=1,a;a+=l,s+=1}return a};while(s<e.length){let a=e[s];if(gi.has(a)||a===","||a===":"){s+=1;continue}if(a==="{"||a==="["){n.push(a==="{"?{keys:new Set,kind:"object",path:i()}:{kind:"array",path:i()}),r=null,s+=1;continue}if(a==="}"||a==="]"){n.pop(),r=null,s+=1;continue}if(a==='"'){let u=c(),f=n.at(-1);if(f?.kind==="object"&&uc(e,s)===":"){if(f.keys.has(u))t.push({detail:u,kind:"duplicate-key",path:f.path});f.keys.add(u),r=u}else r=null;continue}if(a==="-"||a>="0"&&a<="9"){let u=s;while(s<e.length&&/[\d+.eE-]/.test(e[s]))s+=1;let f=e.slice(u,s);if(!pc(f))t.push({detail:f,kind:"unsafe-number",path:i()});r=null;continue}let l=s;while(s<e.length&&/[A-Za-z]/.test(e[s]))s+=1;if(s===l)s+=1;r=null}return t}function uc(e,t){let n=t;while(n<e.length&&gi.has(e[n]))n+=1;return e[n]??""}function fc(e,t){return e===""?t:`${e}.${t}`}function pc(e){if(/[.eE]/.test(e))return!0;let t=Number(e);if(!Number.isFinite(t))return!1;return String(t)===e.replace(/^\+/,"")}function xi(e){let t=e.path===""?"the document root":`"${e.path}"`;return e.kind==="duplicate-key"?`duplicate key "${e.detail}" in ${t} — JSON.parse keeps the last one and `+"silently discards the first (RFC 7493 §2.3)":`number ${e.detail} in ${t} cannot be represented exactly and will change when `+"the document is written back (RFC 7493 §2.2)"}var gi,cc;var yi=j(()=>{gi=new Set([" ","\t",`
28
- `,"\r"]);cc=new Map([["b","\b"],["f","\f"],["n",`
29
- `],["r","\r"],["t","\t"]])});function dc(e){return e instanceof Error?e.message:String(e)}function Si(e){if(b(e))return $i.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>Si(t));if(D(e))return Vt(e);return e}function Vt(e){let t={};for(let[n,r]of Object.entries(e))t[$i.test(n)?n.normalize("NFC"):n]=Si(r);return t}function Js(e,t,n){let r;try{r=JSON.parse(e)}catch(o){throw Error(`Failed to parse ${n} at ${t}: ${dc(o)}`,{cause:o})}if(!D(r))throw Error(`Invalid ${n} at ${t}: expected a JSON object`);let s=hi(e);if(s.length>0){let o=s.map((i)=>xi(i)).join("; ");throw Error(`Invalid ${n} at ${t}: ${o}`)}return Vt(r)}function bi(e,t){return Js(e,t,"Jx document")}function wi(e,t){return Js(e,t,"project config")}function $p(e,t){return Js(e,t,"class definition")}var $i;var Sn=j(()=>{z();yi();$i=/[^\p{ASCII}]/u});function En(e){switch(e){case 9:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:return!0}return!1}function pt(e){return e===13||e===10||e===133||e===11||e===12||e===8232||e===8233||!1}function Sr(e){return e<8||e>=14&&e<=25||e===127||e>=55296&&e<=57343||e>1114111||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function U(e){return!isNaN(e)&&!En(e)&&!pt(e)&&e!==61&&e!==92&&e!==47&&e!==40&&e!==41&&e!==123&&e!==125&&e!==59&&e!==91&&e!==93&&e!==34&&e!==35&&!0}function Ei(e){return e>=65&&e<91||e>=97&&e<123||!1}function Ns(e){return e>=48&&e<64||e>=65&&e<71||e>=97&&e<103||!1}function As(e){return Ns(e)||e===95}function Qe(e){return e>=48&&e<58}function Jt(e){return Qe(e)||e===95}function Os(e){return e>=48&&e<56}function Ji(e){return Os(e)||e===95}function Cs(e){return e===48||e===49}function Ni(e){return Cs(e)||e===95}function Ai(e){return e===45||e===43}var ct=1,Ht=2,bt=3,ur=4,fr=5,bn=6,pr=7,dr=8,wn=9,ut=10,le=11,Bt=12,Ut=13,mr=14,Ze=15,gr=16,hr=17,wt=18,ft=19,xr=20,yr=21,$r=22,qt=23,Et=24,Fe=28;function*gc(e){for(let t of(mc??=new Intl.Segmenter("en")).segment(e))yield t.segment}function hc(e){return e[Symbol.iterator]()}function Oi(e,{flags:t,graphemeLocations:n=!1}){let r=n?gc(e):hc(e),s=r.next();return{text:e,graphemeLocations:n,line:1,column:1,offset:0,length:e.length,iterator:r,currentIter:s,current:s.done?NaN:s.value.codePointAt(0),start:{line:1,column:1,offset:0},errorsInToken:null,flags:t}}function*Ci(e){if(P(e,65279))e.column=1,yield v(e,Ht);if(Sr(e.current))throw Le(e,`Invalid character \\u${e.current.toString(16)}`)}function Q(e){e.offset+=e.currentIter.value.length,e.column++;let t=e.currentIter=e.iterator.next(),n=e.current=t.done?NaN:t.value.codePointAt(0);if(Sr(n))if(n>=55296&&n<=57343||n>1114111)Jn(e,`Invalid character \\u${n.toString(16)}`);else Jn(e,`Invalid character \\u${n.toString(16)}, this character is not allowed but can be included in strings as \\u{${n.toString(16)}}`);return n}function _e(e,t){if(t(e.current)){let n=e.current;return Q(e),n}}function P(e,t){if(e.current===t)return Q(e),t}function zt(e){if(!pt(e.current))return!1;if(!e.graphemeLocations&&e.current===13&&e.text.codePointAt(e.offset+1)===10)e.iterator.next(),e.offset++;return Q(e),e.column=1,e.line++,!0}function js(e,t){while(e.current===t)Q(e)}function W(e,t){while(t(e.current))Q(e)}function v(e,t,n){let{line:r,column:s,offset:o}=e,i={line:r,column:s,offset:o},c=e.start;e.start=i;let a=e.errorsInToken;e.errorsInToken=null;let l={type:t,text:e.text.slice(c.offset,i.offset),start:c,end:i,errors:a};if(n){if(!l.errors)l.errors=[];l.errors.push(new M(n,{token:l}))}return l}function Le(e,t){if(t instanceof M)return t;let{line:n,column:r,offset:s}=e,o={line:n,column:r,offset:s},i;if(s<e.length)if(pt(e.current))i={line:n+1,column:1,offset:s+1};else i={line:n,column:r+1,offset:s+1};return new M(`${t}`,{start:o,end:i})}function Jn(e,t){(e.errorsInToken??=[]).push(Le(e,t))}var mc;var ji=j(()=>{Nt()});function At(e){return(t)=>(Q(t),v(t,e))}function Nn(e){return W(e,En),v(e,wt)}function Ot(e){return zt(e),v(e,ft)}function xc(e){Q(e);let t=!1,n=!1;if(P(e,34)){if(!P(e,34))return v(e,wn);if(n=!0,e.current===34)throw Le(e,"Multiline strings must start with exactly three quotes");while(!t&&e.offset<e.length)if(P(e,34)){if(P(e,34)&&P(e,34))t=!0}else P(e,92),zt(e)||Q(e)}else while(!t&&e.offset<e.length)if(P(e,34))t=!0;else P(e,92),zt(e)||Q(e);if(!t)throw Le(e,"Unexpected EOF inside string");return v(e,n?qt:wn)}function vi(e){if(Q(e),e.current===35||e.current===34){let t=1;while(P(e,35))t++;if(!P(e,34))throw Le(e,`Expected a quote after ${"#".repeat(t)}`);let n=!1;if(P(e,34))if(P(e,34)){if(e.current===34)throw Le(e,"Multiline strings must start with exactly three quotes");n=!0}else{let r=0;while(P(e,35))r++;if(r===t)return v(e,ut)}while(!0){if(e.offset>=e.length)throw Le(e,"Unexpected EOF while parsing raw string");if(P(e,34)){if(n){if(!P(e,34)||!P(e,34))continue}let r=0;while(r<t&&P(e,35))r++;if(r===t)return v(e,n?Et:ut)}else zt(e)||Q(e)}}else{let t;if(e.current<255){let n=T[e.current];t=n(e)}else if(En(e.current))t=Nn(e);else if(pt(e.current))t=Ot(e);else t=Ts(e);if(t.type!==le)(t.errors??=[]).push(new M("Expected a valid identifier",{token:t}));return t.type=Ut,t}}function yc(e){if(Q(e),_e(e,Qe))return W(e,U),v(e,le,"Invalid identifier, identifiers that start with a sign and a dot must be quoted if the next character is a digit to prevent confusion with decimal numbers");return W(e,U),v(e,le)}function $c(e){if(Q(e),P(e,45))return v(e,bt);else if(P(e,47)){while(e.offset<e.length&&!pt(e.current))Q(e);return v(e,yr)}else if(P(e,42)){let t=1;while(e.offset<e.length)if(P(e,42)){if(P(e,47)){if(t--,t===0)return v(e,$r)}}else if(P(e,47)){if(P(e,42))t++}else zt(e)||Q(e);throw Le(e,"Unexpected EOF in multiline comment")}else wr(e)}function Ti(e){return Q(e),Sc(e)}function Sc(e){if(Qe(e.current))return Pe(e);else if(P(e,46)){if(_e(e,Qe))return W(e,U),v(e,le,"Invalid identifier or number, surround with quotes to make it an identifier or add a zero between the sign and the decimal point");return W(e,U),v(e,le)}else return W(e,U),v(e,le)}function vs(e,t,n,r){return(s)=>{let o=Q(s);if(_e(s,n))return W(s,r),v(s,t);else if(!s.flags.experimentalSuffixedNumbers){if(P(s,95)){if(W(s,r),!U(s.current))return v(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(o)} cannot be an underscore`)}return W(s,U),v(s,le,`Invalid ${e} number`)}else if(P(s,95)){if(js(s,95),n(s.current)){if(W(s,r),!U(s.current))return v(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(o)} cannot be an underscore`)}return W(s,U),v(s,le,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else if(Qe(s.current))return v(s,le,"Invalid number with suffix, a suffix cannot start with a letter followed by a number");else return W(s,U),v(s,Fe)}}function Pe(e){if(P(e,48)){let t=br[e.current];if(t)return t(e)}if(W(e,Jt),P(e,46)){if(!_e(e,Qe))if(e.current===95)Jn(e,"Invalid decimal number, the part after the decimal point mustn't start on an underscore");else Jn(e,"Invalid decimal number, a decimal point must be followed by a digit");W(e,Jt)}if(P(e,101)||P(e,69))if(_e(e,Ai),_e(e,Qe)){if(W(e,Jt),U(e.current))return W(e,U),v(e,le,"Invalid number with suffix, a number with an exponent cannot have a suffix");return v(e,Ze)}else if(!e.flags.experimentalSuffixedNumbers)if(e.current===95)return W(e,Jt),v(e,Ze,"Invalid decimal number, the number after the exponent mustn't start on an underscore");else return W(e,U),v(e,Ze,"Invalid decimal number, missing a number after the exponent");else if(P(e,95)){if(js(e,95),Qe(e.current)){if(W(e,Jt),!U(e.current))return v(e,Ze,"Invalid decimal number, the number after the exponent mustn't start on an underscore")}return W(e,U),v(e,le,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else return W(e,U),v(e,Fe);else if(e.flags.experimentalSuffixedNumbers)if(e.current===88||e.current===120){Q(e);let t=null;if(_e(e,As))t="Invalid number with suffix, a suffix cannot start with an x followed by a hexidecimal number";return W(e,U),v(e,Fe,t)}else if(_e(e,Ei)){let t=null;if(_e(e,Jt))t="Invalid number with suffix, a suffix cannot start with a letter followed by a digit";return W(e,U),v(e,Fe,t)}else if(P(e,44))return W(e,U),v(e,Fe,"Invalid number with suffix, a suffix cannot start with a comma");else if(P(e,46))return W(e,U),v(e,Fe,"Invalid number with suffix, a suffix cannot start with a dot");else if(_e(e,U))return W(e,U),v(e,Fe);else return v(e,Ze);else return v(e,Ze)}function bc(e){if(Q(e),e.current!=35)return W(e,U),v(e,le);let t=vi(e);t.start.offset--,t.start.column--;let n;switch(t.type){case ut:case Et:n='Invalid raw string, the correct syntax is #" "#, not r#" "#';break;default:n="Invalid token, did you forget a whitespace after this r?"}return(t.errors??=[]).push(new M(n,{token:t})),t}function Ts(e){return Q(e),W(e,U),v(e,le)}function wr(e){throw Le(e,`Unexpected character ${JSON.stringify(String.fromCodePoint(e.current))}, did you forget to quote an identifier?`)}function*An(e,t){let n=Oi(e,t);yield*Ci(n);while(!n.currentIter.done){if(n.current<255){let r=T[n.current];yield r(n);continue}if(En(n.current)){yield Nn(n);continue}if(pt(n.current)){yield Ot(n);continue}yield Ts(n)}yield v(n,ct)}var br,T;var Ri=j(()=>{Nt();ji();br=Array(256).fill(null);br[98]=vs("binary",hr,Cs,Ni);br[111]=vs("octal",gr,Os,Ji);br[120]=vs("hexadecimal",mr,Ns,As);T=Array(255);T.fill(Ts);for(let e=0;e<32;e++)T[e]=wr;T[9]=Nn;T[10]=Ot;T[11]=Ot;T[12]=Ot;T[13]=Ot;T[32]=Nn;T[34]=xc;T[35]=vi;T[40]=At(ur);T[41]=At(bn);T[43]=Ti;T[45]=Ti;T[46]=yc;T[47]=$c;T[48]=Pe;T[49]=Pe;T[50]=Pe;T[51]=Pe;T[52]=Pe;T[53]=Pe;T[54]=Pe;T[55]=Pe;T[56]=Pe;T[57]=Pe;T[59]=At(dr);T[61]=At(Bt);T[91]=wr;T[92]=At(xr);T[93]=wr;T[114]=bc;T[123]=At(fr);T[125]=At(pr);T[133]=Ot;T[160]=Nn});var Kt=j(()=>{Ri()});var M;var Nt=j(()=>{Kt();M=class M extends Error{name="InvalidKdlError";start;end;token;errors;constructor(e,{token:t,start:n=t?.start,end:r=t?.end,errors:s,...o}={}){if(t?.type===ct)e=`${e} at end of input`;else if(n)e=`${e} at ${n.line}:${n.column}`;super(e,o);this.token=t,this.start=n,this.end=r,this.errors=s}*flat(){if(this.errors==null){yield this;return}for(let e of this.errors)yield*e.flat()}}});function Gt(e){return _i.get(e)}function Pi(e,{start:t},{end:n}){_i.set(e,{start:t,end:n})}var _i;var Rs=j(()=>{_i=new WeakMap});function ki({experimentalSuffixedNumbers:e=!1}={}){return{experimentalSuffixedNumbers:e}}class ke{type="identifier";static type="identifier";representation;constructor(e){this.name=e}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new ke(this.name);return e.representation=this.representation,e}}class We{type="tag";static type="tag";representation;leading;trailing;suffix;constructor(e){this.name,Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!1,value:e})}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new We(this.name);return e.representation=this.representation,e.leading=this.leading,e.trailing=this.trailing,e.suffix=this.suffix,e}}class Ie{type="value";static type="value";representation;tag=null;betweenTagAndValue;constructor(e){this.value=e}clone(){let e=new Ie(this.value);return e.tag=this.tag?.clone()??null,e.betweenTagAndValue=this.betweenTagAndValue,e.representation=this.representation,e}getValue(){return this.value}setValue(e){if(e!==this.value)this.value=e,this.representation=void 0}getTag(){return this.tag?this.tag.name:null}setTag(e){if(e==null)this.tag=null;else if(this.tag!=null)this.tag.setName(e);else this.tag=new We(e)}}var _s=()=>{};class Je{static createArgument(e){return new Je(new Ie(e),null)}static createProperty(e,t){return new Je(new Ie(t),new ke(e))}type="entry";static type="entry";name;value;leading;trailing;equals;constructor(e,t){this.value=e,this.name=t}clone(){let e=new Je(this.value.clone(),this.name?.clone()??null);return e.leading=this.leading,e.trailing=this.trailing,e.equals=this.equals,e}getTag(){return this.value.getTag()}setTag(e){this.value.setTag(e)}getName(){return this.name?this.name.name:null}setName(e){this.name=e!=null?new ke(e):null}getValue(){return this.value.value}setValue(e){this.value=new Ie(e)}isArgument(){return this.name==null}isProperty(){return this.name!=null}}var Ps=j(()=>{_s()});function*Yt(e){for(let t=e.length-1;t>=0;t--)yield e[t]}function ks(e){return e.children??(e.children=new dt)}class Xt{static create(e){return new Xt(new ke(e))}type="node";static type="node";name;tag=null;entries;children;leading;trailing;beforeChildren;betweenTagAndName;constructor(e,t=[],n=null){this.name=e,this.entries=t,this.children=n}clone({shallow:e=!1}={}){let t=new Xt(this.name.clone(),e?[]:this.entries.map((n)=>n.clone()),this.children?.clone({shallow:e}));if(this.tag)t.tag=this.tag.clone();return t.leading=this.leading,t.betweenTagAndName=this.betweenTagAndName,t.beforeChildren=this.beforeChildren,t.trailing=this.trailing,t}getTag(){return this.tag?this.tag.name:null}setTag(e){this.tag=e!=null?new We(e):null}getName(){return this.name.name}setName(e){this.name.setName(e)}hasArguments(){return this.entries.some((e)=>e.isArgument())}getArguments(){return this.getArgumentEntries().map((e)=>e.getValue())}getArgumentEntries(){return this.entries.filter((e)=>e.isArgument())}hasArgument(e){return this.getArgumentEntry(e)!=null}getArgument(e){return this.getArgumentEntry(e)?.getValue()}getArgumentEntry(e){for(let t of this.entries){if(!t.isArgument())continue;if(e===0)return t;e--}}addArgument(e,t,n){let r=Je.createArgument(e);if(r.value.setTag(t),n!=null)for(let[s,o]of this.entries.entries()){if(!o.isArgument())continue;if(n===0){this.entries.splice(s,0,o);return}n--}this.entries.push(r)}removeArgument(e){for(let[t,n]of this.entries.entries()){if(!n.isArgument())continue;if(e===0){this.entries.splice(t,1);return}e--}}hasProperties(){return this.entries.some((e)=>e.isProperty())}getProperties(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e.getValue()]))}getPropertyEntries(){return this.entries.filter((e)=>e.isProperty())}getPropertyEntryMap(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e]))}hasProperty(e){return this.getPropertyEntry(e)!=null}getProperty(e){return this.getPropertyEntry(e)?.getValue()}getPropertyEntry(e){for(let t of Yt(this.entries))if(t.getName()===e)return t;return}setProperty(e,t,n){for(let s of Yt(this.entries))if(s.getName()===e){s.setValue(t),s.value.setTag(n);return}let r=Je.createProperty(e,t);r.value.setTag(n),this.entries.push(r)}deleteProperty(e){this.entries=this.entries.filter((t)=>t.getName()!==e)}hasChildren(){return this.children!=null&&!this.children.isEmpty()}appendNode(e){ks(this).appendNode(e)}insertNodeBefore(e,t){ks(this).insertNodeBefore(e,t)}insertNodeAfter(e,t){ks(this).insertNodeAfter(e,t)}removeNode(e){if(this.children==null)throw Error("Node to remove is not in document");this.children.removeNode(e)}replaceNode(e,t){if(this.children==null)throw Error("Node to remove is not in document");this.children.replaceNode(e,t)}findNodesByName(e){return this.children!=null?this.children.findNodesByName(e):[]}findNodeByName(e){return this.children?.findNodeByName(e)}findParameterizedNode(e,t){return this.children?.findParameterizedNode(e,t)}removeNodesByName(e){this.children?.removeNodesByName(e)}}var Ii=j(()=>{Is();Ps()});function*Zt(e){if(e instanceof dt)yield*e.nodes;else yield e}class dt{type="document";static type="document";nodes;trailing;constructor(e=[]){this.nodes=e}clone({shallow:e}={}){let t=new dt(e?[]:this.nodes.map((n)=>n.clone()));return t.trailing=this.trailing,t}appendNode(e){this.nodes.push(...Zt(e))}insertNodeBefore(e,t){if(t==null){this.nodes.push(...Zt(e));return}let n=this.nodes.indexOf(t);if(n===-1)throw Error("Reference node is not in document");this.nodes.splice(n,0,...Zt(e))}insertNodeAfter(e,t){if(t==null){this.nodes.unshift(...Zt(e));return}let n=this.nodes.indexOf(t);if(n===-1)throw Error("Reference node is not in document");this.nodes.splice(n+1,0,...Zt(e))}removeNode(e){let t=this.nodes.indexOf(e);if(t===-1)throw Error("Node to remove is not in document");this.nodes.splice(t,1)}replaceNode(e,t){let n=this.nodes.indexOf(e);if(n===-1)throw Error("Node to replace is not in document");this.nodes.splice(n,1,...Zt(t))}findNodesByName(e){return this.nodes.filter((t)=>t.name.name===e)}findNodeByName(e){for(let t of Yt(this.nodes))if(t.name.name===e)return t;return}findParameterizedNode(e,t){for(let n of Yt(this.nodes)){if(n.name.name!==e)continue;let r=n.getArguments();if(r.length!==1||t!==void 0&&r[0]!==t)continue;return n}return}removeNodesByName(e){this.nodes=this.nodes.filter((t)=>t.name.name!==e)}isEmpty(){return this.nodes.length===0}}var Is=()=>{};var Mi=j(()=>{Is();Ps();Ii();_s()});function Di(e,t,n){let r;while(r=Ec.exec(t)){let s=On(n,t,r.index);e.push(new M("Raw strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:n,start:s,end:{offset:s.offset+r[0].length,line:s.line+1,column:1}}))}return t}function Fi(e,t,n){if(!Qt.test(t))return e.push(new M("Raw strings with three quotes must be multiline strings",{token:n})),t;if(!Qt.test(t[0]))return e.push(new M("Multi-line strings must start with a newline",{token:n})),t;let r=Ac.exec(t)?.[1];if(r==null)return e.push(new M("The final line in a multiline string may only contain whitespace",{token:n})),t;return t.replace(Cc,(s,o,i,c,a)=>{if(!c)return`
30
- `;if(!i.startsWith(r)){let l=On(n,t,a+o.length);return e.push(new M("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:n,start:l,end:{offset:l.offset+r.length,line:l.line,column:l.column+r.length}})),`
36
+ `||t===";")&&e===0)return this.index+=1,!0;else this.index+=1}return e===0}}function Ht(e){if(tu.test(e))return"unreadable";let t=new Hi(e);for(;;){if(t.skipTrivia(),t.done)return"document";if(t.startsWith("(")){let n=e.indexOf(")",t.index);if(n===-1)return"unreadable";t.index=n+1}else{let[n]=nu.exec(e.slice(t.index,t.index+256))??[];if(!n)return t.startsWith('"')||t.startsWith("#")?"document":"unreadable";if(!n.startsWith("$"))return n==="project"?"project":"document";if(t.index+=n.length,!t.skipNode())return"unreadable"}}}var tu,nu;var Nn=A(()=>{tu=/\0/u,nu=/^[^\s\\/(){};[\]"#=]+/u});function qi(e){let t=[],n=[],r=null,s=0,o=()=>n.at(-1)?.path??"",i=()=>r===null?o():ou(o(),r),a=()=>{s+=1;let l="";while(s<e.length){let c=e[s];if(c==="\\"){let u=e[s+1]??"";if(u==="u")l+=String.fromCodePoint(Number.parseInt(e.slice(s+2,s+6),16)),s+=6;else l+=ru.get(u)??u,s+=2;continue}if(c==='"')return s+=1,l;l+=c,s+=1}return l};while(s<e.length){let l=e[s];if(Ui.has(l)||l===","||l===":"){s+=1;continue}if(l==="{"||l==="["){n.push(l==="{"?{keys:new Set,kind:"object",path:i()}:{kind:"array",path:i()}),r=null,s+=1;continue}if(l==="}"||l==="]"){n.pop(),r=null,s+=1;continue}if(l==='"'){let u=a(),f=n.at(-1);if(f?.kind==="object"&&su(e,s)===":"){if(f.keys.has(u))t.push({detail:u,kind:"duplicate-key",path:f.path});f.keys.add(u),r=u}else r=null;continue}if(l==="-"||l>="0"&&l<="9"){let u=s;while(s<e.length&&/[\d+.eE-]/.test(e[s]))s+=1;let f=e.slice(u,s);if(!iu(f))t.push({detail:f,kind:"unsafe-number",path:i()});r=null;continue}let c=s;while(s<e.length&&/[A-Za-z]/.test(e[s]))s+=1;if(s===c)s+=1;r=null}return t}function su(e,t){let n=t;while(n<e.length&&Ui.has(e[n]))n+=1;return e[n]??""}function ou(e,t){return e===""?t:`${e}.${t}`}function iu(e){if(/[.eE]/.test(e))return!0;let t=Number(e);if(!Number.isFinite(t))return!1;return String(t)===e.replace(/^\+/,"")}function zi(e){let t=e.path===""?"the document root":`"${e.path}"`;return e.kind==="duplicate-key"?`duplicate key "${e.detail}" in ${t} — JSON.parse keeps the last one and `+"silently discards the first (RFC 7493 §2.3)":`number ${e.detail} in ${t} cannot be represented exactly and will change when `+"the document is written back (RFC 7493 §2.2)"}var Ui,ru;var Ki=A(()=>{Ui=new Set([" ","\t",`
37
+ `,"\r"]);ru=new Map([["b","\b"],["f","\f"],["n",`
38
+ `],["r","\r"],["t","\t"]])});function au(e){return e instanceof Error?e.message:String(e)}function Yi(e){if(S(e))return Gi.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>Yi(t));if(R(e))return Ut(e);return e}function Ut(e){let t={};for(let[n,r]of Object.entries(e))t[Gi.test(n)?n.normalize("NFC"):n]=Yi(r);return t}function Bs(e,t,n){let r;try{r=JSON.parse(e)}catch(o){throw Error(`Failed to parse ${n} at ${t}: ${au(o)}`,{cause:o})}if(!R(r))throw Error(`Invalid ${n} at ${t}: expected a JSON object`);let s=qi(e);if(s.length>0){let o=s.map((i)=>zi(i)).join("; ");throw Error(`Invalid ${n} at ${t}: ${o}`)}return Ut(r)}function Xi(e,t){return Bs(e,t,"Jx document")}function Zi(e,t){return Bs(e,t,"project config")}function Rd(e,t){return Bs(e,t,"class definition")}var Gi;var An=A(()=>{U();Ki();Gi=/[^\p{ASCII}]/u});function jn(e){switch(e){case 9:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:return!0}return!1}function dt(e){return e===13||e===10||e===133||e===11||e===12||e===8232||e===8233||!1}function vr(e){return e<8||e>=14&&e<=25||e===127||e>=55296&&e<=57343||e>1114111||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function z(e){return!isNaN(e)&&!jn(e)&&!dt(e)&&e!==61&&e!==92&&e!==47&&e!==40&&e!==41&&e!==123&&e!==125&&e!==59&&e!==91&&e!==93&&e!==34&&e!==35&&!0}function Qi(e){return e>=65&&e<91||e>=97&&e<123||!1}function Hs(e){return e>=48&&e<64||e>=65&&e<71||e>=97&&e<103||!1}function Us(e){return Hs(e)||e===95}function et(e){return e>=48&&e<58}function Nt(e){return et(e)||e===95}function qs(e){return e>=48&&e<56}function ea(e){return qs(e)||e===95}function zs(e){return e===48||e===49}function ta(e){return zs(e)||e===95}function na(e){return e===45||e===43}var ut=1,qt=2,wt=3,Sr=4,br=5,On=6,wr=7,Er=8,Cn=9,ft=10,le=11,zt=12,Kt=13,Jr=14,Qe=15,Nr=16,Ar=17,Et=18,pt=19,Or=20,Cr=21,jr=22,Gt=23,Jt=24,We=28;function*cu(e){for(let t of(lu??=new Intl.Segmenter("en")).segment(e))yield t.segment}function uu(e){return e[Symbol.iterator]()}function ra(e,{flags:t,graphemeLocations:n=!1}){let r=n?cu(e):uu(e),s=r.next();return{text:e,graphemeLocations:n,line:1,column:1,offset:0,length:e.length,iterator:r,currentIter:s,current:s.done?NaN:s.value.codePointAt(0),start:{line:1,column:1,offset:0},errorsInToken:null,flags:t}}function*sa(e){if(I(e,65279))e.column=1,yield T(e,qt);if(vr(e.current))throw Ve(e,`Invalid character \\u${e.current.toString(16)}`)}function Q(e){e.offset+=e.currentIter.value.length,e.column++;let t=e.currentIter=e.iterator.next(),n=e.current=t.done?NaN:t.value.codePointAt(0);if(vr(n))if(n>=55296&&n<=57343||n>1114111)vn(e,`Invalid character \\u${n.toString(16)}`);else vn(e,`Invalid character \\u${n.toString(16)}, this character is not allowed but can be included in strings as \\u{${n.toString(16)}}`);return n}function _e(e,t){if(t(e.current)){let n=e.current;return Q(e),n}}function I(e,t){if(e.current===t)return Q(e),t}function Yt(e){if(!dt(e.current))return!1;if(!e.graphemeLocations&&e.current===13&&e.text.codePointAt(e.offset+1)===10)e.iterator.next(),e.offset++;return Q(e),e.column=1,e.line++,!0}function Ks(e,t){while(e.current===t)Q(e)}function V(e,t){while(t(e.current))Q(e)}function T(e,t,n){let{line:r,column:s,offset:o}=e,i={line:r,column:s,offset:o},a=e.start;e.start=i;let l=e.errorsInToken;e.errorsInToken=null;let c={type:t,text:e.text.slice(a.offset,i.offset),start:a,end:i,errors:l};if(n){if(!c.errors)c.errors=[];c.errors.push(new M(n,{token:c}))}return c}function Ve(e,t){if(t instanceof M)return t;let{line:n,column:r,offset:s}=e,o={line:n,column:r,offset:s},i;if(s<e.length)if(dt(e.current))i={line:n+1,column:1,offset:s+1};else i={line:n,column:r+1,offset:s+1};return new M(`${t}`,{start:o,end:i})}function vn(e,t){(e.errorsInToken??=[]).push(Ve(e,t))}var lu;var oa=A(()=>{At()});function Ot(e){return(t)=>(Q(t),T(t,e))}function Tn(e){return V(e,jn),T(e,Et)}function Ct(e){return Yt(e),T(e,pt)}function fu(e){Q(e);let t=!1,n=!1;if(I(e,34)){if(!I(e,34))return T(e,Cn);if(n=!0,e.current===34)throw Ve(e,"Multiline strings must start with exactly three quotes");while(!t&&e.offset<e.length)if(I(e,34)){if(I(e,34)&&I(e,34))t=!0}else I(e,92),Yt(e)||Q(e)}else while(!t&&e.offset<e.length)if(I(e,34))t=!0;else I(e,92),Yt(e)||Q(e);if(!t)throw Ve(e,"Unexpected EOF inside string");return T(e,n?Gt:Cn)}function ia(e){if(Q(e),e.current===35||e.current===34){let t=1;while(I(e,35))t++;if(!I(e,34))throw Ve(e,`Expected a quote after ${"#".repeat(t)}`);let n=!1;if(I(e,34))if(I(e,34)){if(e.current===34)throw Ve(e,"Multiline strings must start with exactly three quotes");n=!0}else{let r=0;while(I(e,35))r++;if(r===t)return T(e,ft)}while(!0){if(e.offset>=e.length)throw Ve(e,"Unexpected EOF while parsing raw string");if(I(e,34)){if(n){if(!I(e,34)||!I(e,34))continue}let r=0;while(r<t&&I(e,35))r++;if(r===t)return T(e,n?Jt:ft)}else Yt(e)||Q(e)}}else{let t;if(e.current<255){let n=_[e.current];t=n(e)}else if(jn(e.current))t=Tn(e);else if(dt(e.current))t=Ct(e);else t=Ys(e);if(t.type!==le)(t.errors??=[]).push(new M("Expected a valid identifier",{token:t}));return t.type=Kt,t}}function pu(e){if(Q(e),_e(e,et))return V(e,z),T(e,le,"Invalid identifier, identifiers that start with a sign and a dot must be quoted if the next character is a digit to prevent confusion with decimal numbers");return V(e,z),T(e,le)}function du(e){if(Q(e),I(e,45))return T(e,wt);else if(I(e,47)){while(e.offset<e.length&&!dt(e.current))Q(e);return T(e,Cr)}else if(I(e,42)){let t=1;while(e.offset<e.length)if(I(e,42)){if(I(e,47)){if(t--,t===0)return T(e,jr)}}else if(I(e,47)){if(I(e,42))t++}else Yt(e)||Q(e);throw Ve(e,"Unexpected EOF in multiline comment")}else Rr(e)}function aa(e){return Q(e),mu(e)}function mu(e){if(et(e.current))return Pe(e);else if(I(e,46)){if(_e(e,et))return V(e,z),T(e,le,"Invalid identifier or number, surround with quotes to make it an identifier or add a zero between the sign and the decimal point");return V(e,z),T(e,le)}else return V(e,z),T(e,le)}function Gs(e,t,n,r){return(s)=>{let o=Q(s);if(_e(s,n))return V(s,r),T(s,t);else if(!s.flags.experimentalSuffixedNumbers){if(I(s,95)){if(V(s,r),!z(s.current))return T(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(o)} cannot be an underscore`)}return V(s,z),T(s,le,`Invalid ${e} number`)}else if(I(s,95)){if(Ks(s,95),n(s.current)){if(V(s,r),!z(s.current))return T(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(o)} cannot be an underscore`)}return V(s,z),T(s,le,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else if(et(s.current))return T(s,le,"Invalid number with suffix, a suffix cannot start with a letter followed by a number");else return V(s,z),T(s,We)}}function Pe(e){if(I(e,48)){let t=Tr[e.current];if(t)return t(e)}if(V(e,Nt),I(e,46)){if(!_e(e,et))if(e.current===95)vn(e,"Invalid decimal number, the part after the decimal point mustn't start on an underscore");else vn(e,"Invalid decimal number, a decimal point must be followed by a digit");V(e,Nt)}if(I(e,101)||I(e,69))if(_e(e,na),_e(e,et)){if(V(e,Nt),z(e.current))return V(e,z),T(e,le,"Invalid number with suffix, a number with an exponent cannot have a suffix");return T(e,Qe)}else if(!e.flags.experimentalSuffixedNumbers)if(e.current===95)return V(e,Nt),T(e,Qe,"Invalid decimal number, the number after the exponent mustn't start on an underscore");else return V(e,z),T(e,Qe,"Invalid decimal number, missing a number after the exponent");else if(I(e,95)){if(Ks(e,95),et(e.current)){if(V(e,Nt),!z(e.current))return T(e,Qe,"Invalid decimal number, the number after the exponent mustn't start on an underscore")}return V(e,z),T(e,le,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else return V(e,z),T(e,We);else if(e.flags.experimentalSuffixedNumbers)if(e.current===88||e.current===120){Q(e);let t=null;if(_e(e,Us))t="Invalid number with suffix, a suffix cannot start with an x followed by a hexidecimal number";return V(e,z),T(e,We,t)}else if(_e(e,Qi)){let t=null;if(_e(e,Nt))t="Invalid number with suffix, a suffix cannot start with a letter followed by a digit";return V(e,z),T(e,We,t)}else if(I(e,44))return V(e,z),T(e,We,"Invalid number with suffix, a suffix cannot start with a comma");else if(I(e,46))return V(e,z),T(e,We,"Invalid number with suffix, a suffix cannot start with a dot");else if(_e(e,z))return V(e,z),T(e,We);else return T(e,Qe);else return T(e,Qe)}function gu(e){if(Q(e),e.current!=35)return V(e,z),T(e,le);let t=ia(e);t.start.offset--,t.start.column--;let n;switch(t.type){case ft:case Jt:n='Invalid raw string, the correct syntax is #" "#, not r#" "#';break;default:n="Invalid token, did you forget a whitespace after this r?"}return(t.errors??=[]).push(new M(n,{token:t})),t}function Ys(e){return Q(e),V(e,z),T(e,le)}function Rr(e){throw Ve(e,`Unexpected character ${JSON.stringify(String.fromCodePoint(e.current))}, did you forget to quote an identifier?`)}function*Rn(e,t){let n=ra(e,t);yield*sa(n);while(!n.currentIter.done){if(n.current<255){let r=_[n.current];yield r(n);continue}if(jn(n.current)){yield Tn(n);continue}if(dt(n.current)){yield Ct(n);continue}yield Ys(n)}yield T(n,ut)}var Tr,_;var la=A(()=>{At();oa();Tr=Array(256).fill(null);Tr[98]=Gs("binary",Ar,zs,ta);Tr[111]=Gs("octal",Nr,qs,ea);Tr[120]=Gs("hexadecimal",Jr,Hs,Us);_=Array(255);_.fill(Ys);for(let e=0;e<32;e++)_[e]=Rr;_[9]=Tn;_[10]=Ct;_[11]=Ct;_[12]=Ct;_[13]=Ct;_[32]=Tn;_[34]=fu;_[35]=ia;_[40]=Ot(Sr);_[41]=Ot(On);_[43]=aa;_[45]=aa;_[46]=pu;_[47]=du;_[48]=Pe;_[49]=Pe;_[50]=Pe;_[51]=Pe;_[52]=Pe;_[53]=Pe;_[54]=Pe;_[55]=Pe;_[56]=Pe;_[57]=Pe;_[59]=Ot(Er);_[61]=Ot(zt);_[91]=Rr;_[92]=Ot(Or);_[93]=Rr;_[114]=gu;_[123]=Ot(br);_[125]=Ot(wr);_[133]=Ct;_[160]=Tn});var Xt=A(()=>{la()});var M;var At=A(()=>{Xt();M=class M extends Error{name="InvalidKdlError";start;end;token;errors;constructor(e,{token:t,start:n=t?.start,end:r=t?.end,errors:s,...o}={}){if(t?.type===ut)e=`${e} at end of input`;else if(n)e=`${e} at ${n.line}:${n.column}`;super(e,o);this.token=t,this.start=n,this.end=r,this.errors=s}*flat(){if(this.errors==null){yield this;return}for(let e of this.errors)yield*e.flat()}}});function Zt(e){return ca.get(e)}function ua(e,{start:t},{end:n}){ca.set(e,{start:t,end:n})}var ca;var Xs=A(()=>{ca=new WeakMap});function fa({experimentalSuffixedNumbers:e=!1}={}){return{experimentalSuffixedNumbers:e}}class ke{type="identifier";static type="identifier";representation;constructor(e){this.name=e}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new ke(this.name);return e.representation=this.representation,e}}class Be{type="tag";static type="tag";representation;leading;trailing;suffix;constructor(e){this.name,Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!1,value:e})}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new Be(this.name);return e.representation=this.representation,e.leading=this.leading,e.trailing=this.trailing,e.suffix=this.suffix,e}}class Ie{type="value";static type="value";representation;tag=null;betweenTagAndValue;constructor(e){this.value=e}clone(){let e=new Ie(this.value);return e.tag=this.tag?.clone()??null,e.betweenTagAndValue=this.betweenTagAndValue,e.representation=this.representation,e}getValue(){return this.value}setValue(e){if(e!==this.value)this.value=e,this.representation=void 0}getTag(){return this.tag?this.tag.name:null}setTag(e){if(e==null)this.tag=null;else if(this.tag!=null)this.tag.setName(e);else this.tag=new Be(e)}}var Zs=()=>{};class Ne{static createArgument(e){return new Ne(new Ie(e),null)}static createProperty(e,t){return new Ne(new Ie(t),new ke(e))}type="entry";static type="entry";name;value;leading;trailing;equals;constructor(e,t){this.value=e,this.name=t}clone(){let e=new Ne(this.value.clone(),this.name?.clone()??null);return e.leading=this.leading,e.trailing=this.trailing,e.equals=this.equals,e}getTag(){return this.value.getTag()}setTag(e){this.value.setTag(e)}getName(){return this.name?this.name.name:null}setName(e){this.name=e!=null?new ke(e):null}getValue(){return this.value.value}setValue(e){this.value=new Ie(e)}isArgument(){return this.name==null}isProperty(){return this.name!=null}}var Qs=A(()=>{Zs()});function*Qt(e){for(let t=e.length-1;t>=0;t--)yield e[t]}function eo(e){return e.children??(e.children=new mt)}class en{static create(e){return new en(new ke(e))}type="node";static type="node";name;tag=null;entries;children;leading;trailing;beforeChildren;betweenTagAndName;constructor(e,t=[],n=null){this.name=e,this.entries=t,this.children=n}clone({shallow:e=!1}={}){let t=new en(this.name.clone(),e?[]:this.entries.map((n)=>n.clone()),this.children?.clone({shallow:e}));if(this.tag)t.tag=this.tag.clone();return t.leading=this.leading,t.betweenTagAndName=this.betweenTagAndName,t.beforeChildren=this.beforeChildren,t.trailing=this.trailing,t}getTag(){return this.tag?this.tag.name:null}setTag(e){this.tag=e!=null?new Be(e):null}getName(){return this.name.name}setName(e){this.name.setName(e)}hasArguments(){return this.entries.some((e)=>e.isArgument())}getArguments(){return this.getArgumentEntries().map((e)=>e.getValue())}getArgumentEntries(){return this.entries.filter((e)=>e.isArgument())}hasArgument(e){return this.getArgumentEntry(e)!=null}getArgument(e){return this.getArgumentEntry(e)?.getValue()}getArgumentEntry(e){for(let t of this.entries){if(!t.isArgument())continue;if(e===0)return t;e--}}addArgument(e,t,n){let r=Ne.createArgument(e);if(r.value.setTag(t),n!=null)for(let[s,o]of this.entries.entries()){if(!o.isArgument())continue;if(n===0){this.entries.splice(s,0,o);return}n--}this.entries.push(r)}removeArgument(e){for(let[t,n]of this.entries.entries()){if(!n.isArgument())continue;if(e===0){this.entries.splice(t,1);return}e--}}hasProperties(){return this.entries.some((e)=>e.isProperty())}getProperties(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e.getValue()]))}getPropertyEntries(){return this.entries.filter((e)=>e.isProperty())}getPropertyEntryMap(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e]))}hasProperty(e){return this.getPropertyEntry(e)!=null}getProperty(e){return this.getPropertyEntry(e)?.getValue()}getPropertyEntry(e){for(let t of Qt(this.entries))if(t.getName()===e)return t;return}setProperty(e,t,n){for(let s of Qt(this.entries))if(s.getName()===e){s.setValue(t),s.value.setTag(n);return}let r=Ne.createProperty(e,t);r.value.setTag(n),this.entries.push(r)}deleteProperty(e){this.entries=this.entries.filter((t)=>t.getName()!==e)}hasChildren(){return this.children!=null&&!this.children.isEmpty()}appendNode(e){eo(this).appendNode(e)}insertNodeBefore(e,t){eo(this).insertNodeBefore(e,t)}insertNodeAfter(e,t){eo(this).insertNodeAfter(e,t)}removeNode(e){if(this.children==null)throw Error("Node to remove is not in document");this.children.removeNode(e)}replaceNode(e,t){if(this.children==null)throw Error("Node to remove is not in document");this.children.replaceNode(e,t)}findNodesByName(e){return this.children!=null?this.children.findNodesByName(e):[]}findNodeByName(e){return this.children?.findNodeByName(e)}findParameterizedNode(e,t){return this.children?.findParameterizedNode(e,t)}removeNodesByName(e){this.children?.removeNodesByName(e)}}var pa=A(()=>{to();Qs()});function*tn(e){if(e instanceof mt)yield*e.nodes;else yield e}class mt{type="document";static type="document";nodes;trailing;constructor(e=[]){this.nodes=e}clone({shallow:e}={}){let t=new mt(e?[]:this.nodes.map((n)=>n.clone()));return t.trailing=this.trailing,t}appendNode(e){this.nodes.push(...tn(e))}insertNodeBefore(e,t){if(t==null){this.nodes.push(...tn(e));return}let n=this.nodes.indexOf(t);if(n===-1)throw Error("Reference node is not in document");this.nodes.splice(n,0,...tn(e))}insertNodeAfter(e,t){if(t==null){this.nodes.unshift(...tn(e));return}let n=this.nodes.indexOf(t);if(n===-1)throw Error("Reference node is not in document");this.nodes.splice(n+1,0,...tn(e))}removeNode(e){let t=this.nodes.indexOf(e);if(t===-1)throw Error("Node to remove is not in document");this.nodes.splice(t,1)}replaceNode(e,t){let n=this.nodes.indexOf(e);if(n===-1)throw Error("Node to replace is not in document");this.nodes.splice(n,1,...tn(t))}findNodesByName(e){return this.nodes.filter((t)=>t.name.name===e)}findNodeByName(e){for(let t of Qt(this.nodes))if(t.name.name===e)return t;return}findParameterizedNode(e,t){for(let n of Qt(this.nodes)){if(n.name.name!==e)continue;let r=n.getArguments();if(r.length!==1||t!==void 0&&r[0]!==t)continue;return n}return}removeNodesByName(e){this.nodes=this.nodes.filter((t)=>t.name.name!==e)}isEmpty(){return this.nodes.length===0}}var to=()=>{};var da=A(()=>{to();Qs();pa();Zs()});function ma(e,t,n){let r;while(r=xu.exec(t)){let s=_n(n,t,r.index);e.push(new M("Raw strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:n,start:s,end:{offset:s.offset+r[0].length,line:s.line+1,column:1}}))}return t}function ga(e,t,n){if(!nn.test(t))return e.push(new M("Raw strings with three quotes must be multiline strings",{token:n})),t;if(!nn.test(t[0]))return e.push(new M("Multi-line strings must start with a newline",{token:n})),t;let r=Su.exec(t)?.[1];if(r==null)return e.push(new M("The final line in a multiline string may only contain whitespace",{token:n})),t;return t.replace(wu,(s,o,i,a,l)=>{if(!a)return`
39
+ `;if(!i.startsWith(r)){let c=_n(n,t,l+o.length);return e.push(new M("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:n,start:c,end:{offset:c.offset+r.length,line:c.line,column:c.column+r.length}})),`
31
40
  `}return`
32
- `+i.slice(r.length)+c}).slice(1,-1)}function Li(e,t,n){let r;while(r=Nc.exec(t)){let s=On(n,t,r.indices[1][0]);e.push(new M("Strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:n,start:s,end:{offset:s.offset+r[1].length,line:s.line+1,column:1}}))}return t.replace(vc,(s,o,i,c,a)=>Vi(e,t,n,s,o,i,c,a))}function Wi(e,t,n){if(!Jc.test(t))return e.push(new M("Strings with three quotes must be multiline strings",{token:n})),t;if(!Qt.test(t[0]))return e.push(new M("Multi-line strings must start with a newline",{token:n})),t;let r=Oc.exec(t)?.[1];if(r==null){let s=jc.exec(t),o=s?On(n,t,s.index):void 0,i="The final line in a multiline string may only contain whitespace";if(s?.[0][0]==="\\")i+=" after removing escaped whitespace";return e.push(new M(i,{token:n,start:o,end:o&&{offset:o.offset,line:o.line,column:o.column+1}})),t}return t.replace(Tc,(s,o,i,c,a,l,u)=>{if(!o)return Vi(e,t,n,s,c,a,l,u);let f=t[u+o.length+(i?i.length:0)];if(Qt.test(f))return`
33
- `;if(!i.startsWith(r)){let p=On(n,t,u+o.length);return e.push(new M("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:n,start:p,end:{offset:p.offset+r.length,line:p.line,column:p.column+r.length}})),`
41
+ `+i.slice(r.length)+a}).slice(1,-1)}function ha(e,t,n){let r;while(r=$u.exec(t)){let s=_n(n,t,r.indices[1][0]);e.push(new M("Strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:n,start:s,end:{offset:s.offset+r[1].length,line:s.line+1,column:1}}))}return t.replace(Ju,(s,o,i,a,l)=>ya(e,t,n,s,o,i,a,l))}function xa(e,t,n){if(!yu.test(t))return e.push(new M("Strings with three quotes must be multiline strings",{token:n})),t;if(!nn.test(t[0]))return e.push(new M("Multi-line strings must start with a newline",{token:n})),t;let r=bu.exec(t)?.[1];if(r==null){let s=Eu.exec(t),o=s?_n(n,t,s.index):void 0,i="The final line in a multiline string may only contain whitespace";if(s?.[0][0]==="\\")i+=" after removing escaped whitespace";return e.push(new M(i,{token:n,start:o,end:o&&{offset:o.offset,line:o.line,column:o.column+1}})),t}return t.replace(Nu,(s,o,i,a,l,c,u)=>{if(!o)return ya(e,t,n,s,a,l,c,u);let f=t[u+o.length+(i?i.length:0)];if(nn.test(f))return`
42
+ `;if(!i.startsWith(r)){let p=_n(n,t,u+o.length);return e.push(new M("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:n,start:p,end:{offset:p.offset+r.length,line:p.line,column:p.column+r.length}})),`
34
43
  `}return`
35
- `+i.slice(r.length)}).slice(1,-1)}function Vi(e,t,n,r,s,o,i,c){if(i)return"";if(o){let a=n.text.startsWith('"""'),l=t.slice(0,c).split(Qt),u={offset:n.start.offset+(a?3:1)+c,line:n.start.line+(l.length-1),column:l.length===1?n.start.column+(a?3:1)+c:l.at(-1).length},f={offset:u.offset+r.length,line:u.line,column:u.column+r.length};if(!o.startsWith("{"))e.push(new M(String.raw`Invalid unicode escape "\u${o}", did you forget to use {}? "\u{${o}}"`,{token:n,start:u,end:f}));else e.push(new M(String.raw`Invalid unicode escape "\u${o.endsWith("}")?o:`${o}...`}"`,{token:n,start:u,end:f}));return""}else if(s){let a=parseInt(s,16);if(a>=55296&&a<=57343)e.push(new M(String.raw`Invalid unicode escape "\u{${s}}, only scalar values can be added using an escape`,{token:n}));return String.fromCodePoint(a)}else{let a=wc.get(r);if(a==null)return e.push(new M(r.length<2?"Invalid whitespace escape at the end of a string":`Invalid escape "${r}"`,{token:n})),"";return a}}function On(e,t,n){let r=1;switch(e.type){case qt:r=3;break;case ut:r=e.text.indexOf('"')+1;break;case Et:r=e.text.indexOf('"')+3;break}let s=t.slice(0,n).split(Qt);return{offset:e.start.offset+r+n,line:e.start.line+(s.length-1),column:s.length===1?e.start.column+r+n:1+s[s.length-1].length}}var ad,wc,Qt,Ec,Jc,Nc,Ac,Oc,Cc,jc,vc,Tc;var Hi=j(()=>{Nt();Kt();ad=new Map([...Array.from({length:32},(e,t)=>[t,`\\u{${t.toString(16).padStart(2,"0")}}`]),[127,"\\u{7f}"],[8206,"\\u{200e}"],[8207,"\\u{200f}"],[8234,"\\u{202a}"],[8235,"\\u{202b}"],[8236,"\\u{202c}"],[8237,"\\u{202d}"],[8238,"\\u{202e}"],[8294,"\\u{2066}"],[8295,"\\u{2067}"],[8296,"\\u{2068}"],[8297,"\\u{2069}"],[65279,"\\u{feff}"],[34,"\\\""],[92,"\\\\"],[10,"\\n"],[11,"\\u{0b}"],[12,"\\f"],[13,"\\r"],[133,"\\u{85}"],[8232,"\\u{2028}"],[8233,"\\u{2029}"],[8,"\\b"],[9,"\\t"]]),wc=new Map([["\\n",`
36
- `],["\\r","\r"],["\\t","\t"],["\\\\","\\"],["\\\"",'"'],["\\b","\b"],["\\f","\f"],["\\s"," "]]),Qt=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/,Ec=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/g,Jc=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/s,Nc=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/dgs;Ac=/[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)$/,Oc=/(?:^|[^\\\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])(?:\\\\)*[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(?:\\[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)*$/,Cc=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]?)/g,jc=/([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*$/;vc=/\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g;Tc=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)|\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g});function et(e){if(!e.current.done)e.lastToken=e.current.value;e.current=e.tokens.next();let t=!e.current.done&&e.current.value.errors;if(t)e.errors.push(...t)}function V(e,t){if(!e.current.done&&e.current.value.type===t){let n=e.current.value;return et(e),n}}function R(e,t){let n="current"in e?e.current.value??e.lastToken:e;return new M(t,{token:n})}function xe(e,t,n,r=n){if(e.storeLocations)Pi(t,n,r)}function ce(e="",t="",n=""){return e+t+n||void 0}function Nr(e,t,{storeLocations:n=!1,flags:r}){let s={type:-1,text:"",start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1},errors:null},o={text:e,tokens:t[Symbol.iterator](),current:{done:!1,value:s},storeLocations:n,lastToken:s,errors:[],flags:r};return et(o),o}function Ds(e,t){if(!t&&!e.current.done&&e.current.value.type!==ct)t=R(e,`Unexpected token ${JSON.stringify(e.current.value.text)}, did you forget to quote an identifier?`);let n=e.errors??[];if(t!=null)if(t instanceof M)if(t.errors)n.push(...t.errors);else n.push(t);else n.push(new M(`An unexpected error occurred, ${String(t)}, this is likely a bug in the KDL parser`,{cause:t}));if(n.length)if(n.length===1)throw n[0];else throw new M("Encountered multiple errors",{errors:n})}function Er(e){switch(e){case"#null":return null;case"#true":return!0;case"#false":return!1;case"#inf":return 1/0;case"#-inf":return-1/0;case"#nan":return NaN}}function Bi(e){return e==="inf"||e==="-inf"||e==="nan"||e==="true"||e==="false"||e==="null"||!1}function Fs(e){let{value:t}=e.current,n,r,s,o,i,c=!1;if(t?.text[0]==="-"||t?.text[0]==="+")i=t.text[0];switch(t?.type){case Fe:{if(!e.flags.experimentalSuffixedNumbers)throw new M("Unreachable code: got a suffixed number from the tokenizer but the suffixed number flag is not set",{token:t});let u=i?t.text.slice(1):t.text,f=u.search(/[^0-9._]/);if(r=(i??"")+u.slice(0,f),n=Number.parseFloat(r.replaceAll("_","")),o=s=u.slice(f),Bi(s))e.errors.push(R(e,`Invalid suffix ${s}, values that look like keywords cannot be used as suffix`))}break;case hr:c=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),2);break;case gr:c=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),8);break;case Ze:c=!0,n=Number.parseFloat(t.text.replaceAll("_",""));break;case mr:c=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),16);break;case Ut:if(n=Er(t.text),n===void 0)if(n=null,Er(t.text.toLowerCase())!==void 0)e.errors.push(R(e,`Invalid keyword ${t.text}, keywords are case sensitive, write ${t.text.toLowerCase()} instead`));else switch(t.text.toLowerCase()){case"#nul":case"#nill":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #null?`));break;case"#fals":case"#fasle":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #false?`));break;case"#ture":case"#treu":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #true?`));break;case"#ifn":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #inf?`));break;case"#-ifn":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #-inf?`));break;default:e.errors.push(R(e,`Invalid keyword ${t.text}, surround it with quotes to use a string`))}break;default:return}et(e);let a=e.flags.experimentalSuffixedNumbers&&V(e,Ut);if(a)if(c){if(o=a.text,Er(o)!==void 0)e.errors.push(R(a,`Invalid number suffix ${o}, did you forget a space between the number and the keyword?`));s=o.slice(1)}else if(s)e.errors.push(R(a,"Unexpected hashed suffix, a number can only have one suffix"));else if(typeof n==="number")e.errors.push(R(a,"Unexpected hashed suffix, you cannot place suffixes on number keywords"));else e.errors.push(R(a,"Unexpected hashed suffix, you can only place suffixes on numbers"));let l=new Ie(n);if(l.representation=r??t.text,xe(e,l,t),s){let u=new We(s);u.representation=o,u.suffix=!0,xe(e,u,e.lastToken),l.tag=u}return l}function Cn(e){if(e.current.done)return;let{value:t}=e.current,n;switch(t.type){case le:if(et(e),Bi(t.text))e.errors.push(R(e,`Invalid keyword "${t.text}", add a leading # to use the keyword or surround with quotes to make it a string`));n=[t.text,t.text,t];break;case wn:et(e),n=[Li(e.errors,t.text.slice(1,-1),t),t.text,t];break;case qt:et(e),n=[Wi(e.errors,t.text.slice(3,-3),t),t.text,t];break;case ut:{et(e);let r=t.text,s=r.indexOf('"');n=[Di(e.errors,r.slice(s+1,-(s+1)),t),r,t];break}case Et:{et(e);let r=t.text,s=r.indexOf('"');n=[Fi(e.errors,r.slice(s+3,-(s+3)),t),r,t];break}default:return}if(V(e,Ut))e.errors.push(R(e.lastToken,Er(e.lastToken.text)===void 0?"Unexpected hashed suffix on a string, you can only place suffixes on numbers":"Unexpected keyword, did you forget to add whitespace?"));return n}function Ls(e){let t=Cn(e);if(!t)return;let n=new ke(t[0]);return n.representation=t[1],xe(e,n,t[2],e.lastToken),n}function Jr(e){let t=Fs(e);if(t)return t;let n=Cn(e);if(!n)return;let r=new Ie(n[0]);return r.representation=n[1],xe(e,r,n[2],e.lastToken),r}function jn(e){let t=V(e,yr);if(!t)return;let{value:n}=e.current;return et(e),t.text+(n?.text??"")}function Ar(e){return V(e,$r)?.text}function Ws(e){return V(e,wt)??Ar(e)}function Or(e){let t=V(e,xr);if(!t)return;while(Ws(e));if(!jn(e)&&!V(e,ft)&&!V(e,ct))e.errors.push(R(e,`Expected newline or single-line comment after backslash but got ${e.current.value?.text??"EOF"}`));return e.text.slice(t.start.offset,e.lastToken.end.offset)}function mt(e){let t=e.lastToken.end;while(V(e,ft)?.text??jn(e)??Ws(e)??Or(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function ee(e){let t=e.lastToken.end;while(Ws(e)??Or(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function Ms(e){let t=V(e,ur);if(!t)return;let n=ee(e),r=Cn(e);if(!r&&e.current.value){let c=e.current.value;if(mt(e))e.errors.push(R(c,"This type of whitespace is not allowed inside a tag"));r=Cn(e)}if(!r){if(Fs(e))e.errors.push(R(e,"Invalid tag, did you forget to quote a string?")),r=["error","error"]}if(!r)throw R(e,"Invalid tag, did you forget to quote a string?");let s=ee(e),o=V(e,bn);if(!o&&e.current.value){let c=e.current.value;if(mt(e))e.errors.push(R(c,"This type of whitespace is not allowed inside a tag"));o=V(e,bn)}if(!o)throw R(e,"Invalid tag, did you forget to quote a string?");let i=new We(r[0]);return i.representation=r[1],i.leading=n,i.trailing=s,xe(e,i,t,e.lastToken),i}function Cr(e){return jn(e)??V(e,ft)?.text??V(e,dr)?.text??V(e,ct)?.text}function Vs(e){if(!V(e,fr))return;let t=Ki(e);if(!V(e,pr))throw R(e,"Invalid node children");return t}function en(e){let t=e.current.value;{let f=Ms(e);if(f){let p=ee(e),d=Jr(e);if(!d)throw R(e,"Invalid argument");if(d.tag)e.errors.push(R(e.lastToken,"A number suffix cannot be combined with a regular tag"));d.tag=f,d.betweenTagAndValue=p;let h=new Je(d,null);xe(e,d,t,e.lastToken),xe(e,h,t,e.lastToken);let g=ee(e);if(V(e,Bt))e.errors.push(R(e.lastToken,typeof d.value==="string"?"Unexpected equals sign, properties are name=(tag)value not (tag)name=value":"Unexpected equals sign")),g=ce(g,ee(e))||" ";return[h,g]}}{let f=Fs(e);if(f){let p=new Je(f,null);xe(e,p,t,e.lastToken);let d=ee(e);if(V(e,Bt))e.errors.push(R(e.lastToken,"Unexpected equals sign, did you forget to quote the property name?")),d=ce(d,ee(e))||" ";return[p,d]}}let n=Cn(e);if(!n)return;let r=ee(e),s=V(e,Bt);if(!s){let f=new Ie(n[0]);f.representation=n[1],xe(e,f,n[2]);let p=new Je(f,null);return xe(e,p,t,e.lastToken),[p,r]}let o=new ke(n[0]);o.representation=n[1],xe(e,o,n[2]);let i=ee(e),c=Ms(e),a=c&&ee(e),l=Jr(e);if(!l)throw R(e,"Expected a value");if(c){if(l.tag)e.errors.push(R(e.lastToken,"A number suffix cannot be combined with a regular tag"));l.tag=c,l.betweenTagAndValue=a}let u=new Je(l,o);return xe(e,u,t,e.lastToken),u.equals=ce(r,s.text,i),[u,void 0]}function Ui(e){let t=ee(e)??"",n;while(n=Ct(e)){let i=e.lastToken.end,c=en(e);if(!c)throw R(e,"Expected a property or argument");if(!(c[1]??ee(e)))throw R(e,"Expected space after slashdashed property or argument");t=t+n+e.text.slice(i.offset,e.lastToken.end.offset)}let r=en(e);if(!r)return;let s=r[1]??ee(e)??"";while(n=Ct(e)){let i=e.lastToken.end,c=en(e);if(!c)throw R(e,"Expected a property or argument");if(!(c[1]??ee(e)))break;s=s+n+e.text.slice(i.offset,e.lastToken.end.offset)}let o=r[0];return o.leading=t,o.trailing=s,o}function Ct(e){let t=V(e,bt)?.text;if(!t)return;return ce(t,mt(e))}function jr(e){let t=e.current.value,n=Ms(e),r=n&&ee(e),s=Ls(e);if(!s)if(n)throw R(e,"Couldn't find node name");else return;let o=ee(e),i=o!=null,c=Ct(e),a=[];while(i||c){let p=e.lastToken.end,d=en(e);if(!d)break;if(c)i=(d[1]||ee(e))!=null,o=ce(o,c,e.text.slice(p.offset,e.lastToken.end.offset)),c=Ct(e);else{let h=d[0];h.leading=o,a.push(h),o=d[1]||ee(e),i=o!=null,c=Ct(e)}}let l,u;while(!0){c??=Ct(e);let p=e.lastToken.end,d=Vs(e);if(!d){if(c)throw R(e,"Unexpected slashdash");break}if(c)o=ce(o,c,e.text.slice(p.offset,e.lastToken.end.offset)),c=void 0;else{if(l)e.errors.push(R(e,"A node can only have one children block"));l=d,u=o??"",o=void 0}o=ce(o,ee(e))}let f=new Xt(s,a,l);return f.tag=n??null,f.betweenTagAndName=r,f.beforeChildren=u,f.trailing=o??"",xe(e,f,t,e.lastToken),f}function qi(e){let t=mt(e),n=jr(e);if(!n)return;let r=ce(Cr(e),mt(e));return n.leading=ce(t,n.leading),n.trailing=ce(n.trailing,r),n}function zi(e){let t=V(e,Ht)?.text,n=Ki(e);if(!t)return n;if(n.nodes[0])n.nodes[0].leading=ce(t,n.nodes[0].leading);else n.trailing=ce(t,n.trailing);return n}function Ki(e){let t=e.current.value,n=[],r=!0,s=mt(e);while(r){let i=e.lastToken.end,c=Ct(e),a=jr(e);if(!a){if(c)throw R(e,"Unexpected slashdash");break}let l=ee(e),u=Cr(e);if(c)s=ce(s,e.text.slice(i.offset,e.lastToken.end.offset),mt(e));else a.trailing=ce(a.trailing,l,u)??"",n.push(a),a.leading=s??"",s=mt(e);r=u!=null}let o=new dt(n);return xe(e,o,t,e.lastToken),o.trailing=s??"",o}var Hs=j(()=>{Nt();Rs();Mi();Hi();Kt()});function Gi(e,t){let n=[],r;while(r=t(e))n.push(r);return n.length>0?n:void 0}function Rc(e){{let t=V(e,Ht);if(t)return{type:"bom",text:t.text}}{let t=V(e,ft);if(t)return{type:"newline",text:t.text}}{let t=V(e,wt);if(t)return{type:"space",text:t.text}}{let t=jn(e);if(t)return{type:"singleline",text:t}}{let t=Ar(e);if(t)return{type:"multiline",text:t}}return}function vr(e){{let t=Or(e);if(t)return{type:"line-escape",text:t}}{let t=V(e,wt);if(t)return{type:"space",text:t.text}}{let t=Ar(e);if(t)return{type:"multiline",text:t}}return}function Yi(e){let t=[];while(!0){{let n=Rc(e);if(n){t.push(n);continue}}if(V(e,bt)?.text){let r,s=Gi(e,vr)??[],o=jr(e);if(!o)throw R(e,"Invalid slashdash, expected a commented node");o.trailing=ce(o.trailing,Gi(e,vr)?.map((i)=>i.text).join(""),Cr(e)),t.push({type:"slashdash",preface:s,value:o});continue}break}return t}function _c(e){let t=V(e,bt);if(t==null)return;let n,r=[];while(n=vr(e))r.push(n);let s,o,i="";if(o=en(e)){if(s=o[0],o[1])i=o[1]}else if(o=Vs(e))s=o;else throw R(t,"Couldn't find argument, property, or children that were commented by slashdash");return[{type:"slashdash",preface:r,value:s},i]}function Bs(e){let t=[];while(!0){let n=vr(e);if(!n)break;let r=!0;t.push(n);while(r){let s=_c(e);if(!s)break;if(t.push(s[0]),s[1][0])t.push(...Bs(Nr(s[1][0],An(s[1][0],{flags:e.flags}),{flags:e.flags})));r=!!s[1][0]}}return t}var Xi=j(()=>{Kt();Hs()});function gt(e,{as:t="document",flags:n,...r}={}){let s=Pc[t];if(s==null)throw TypeError(`Invalid "as" target passed: ${JSON.stringify(t)}`);if(typeof e!=="string"){if(typeof TextDecoder!=="function")throw TypeError("Uint8Array input is only supported on platforms that include TextDecoder");e=new TextDecoder("utf-8",{fatal:!0}).decode(e)}let o=ki(n),i=An(e,{...r,flags:o}),c=Nr(e,i,{...r,flags:o}),a;try{a=s(c)}catch(l){Ds(c,l)}if(Ds(c),!a)throw new M(`Expected ${/^[aeiouy]/.exec(t)?"an":"a"} ${t}`);return a}var Pc;var Zi=j(()=>{Nt();Kt();Hs();Xi();Pc={value:Jr,identifier:Ls,node:qi,entry:Ui,document:zi,"whitespace in document":Yi,"whitespace in node":Bs}});var Tr=j(()=>{Nt();Rs();Zi()});function tn(e,t){let n=e.slice(0,t),r=n.split(`
44
+ `+i.slice(r.length)}).slice(1,-1)}function ya(e,t,n,r,s,o,i,a){if(i)return"";if(o){let l=n.text.startsWith('"""'),c=t.slice(0,a).split(nn),u={offset:n.start.offset+(l?3:1)+a,line:n.start.line+(c.length-1),column:c.length===1?n.start.column+(l?3:1)+a:c.at(-1).length},f={offset:u.offset+r.length,line:u.line,column:u.column+r.length};if(!o.startsWith("{"))e.push(new M(String.raw`Invalid unicode escape "\u${o}", did you forget to use {}? "\u{${o}}"`,{token:n,start:u,end:f}));else e.push(new M(String.raw`Invalid unicode escape "\u${o.endsWith("}")?o:`${o}...`}"`,{token:n,start:u,end:f}));return""}else if(s){let l=parseInt(s,16);if(l>=55296&&l<=57343)e.push(new M(String.raw`Invalid unicode escape "\u{${s}}, only scalar values can be added using an escape`,{token:n}));return String.fromCodePoint(l)}else{let l=hu.get(r);if(l==null)return e.push(new M(r.length<2?"Invalid whitespace escape at the end of a string":`Invalid escape "${r}"`,{token:n})),"";return l}}function _n(e,t,n){let r=1;switch(e.type){case Gt:r=3;break;case ft:r=e.text.indexOf('"')+1;break;case Jt:r=e.text.indexOf('"')+3;break}let s=t.slice(0,n).split(nn);return{offset:e.start.offset+r+n,line:e.start.line+(s.length-1),column:s.length===1?e.start.column+r+n:1+s[s.length-1].length}}var Sm,hu,nn,xu,yu,$u,Su,bu,wu,Eu,Ju,Nu;var $a=A(()=>{At();Xt();Sm=new Map([...Array.from({length:32},(e,t)=>[t,`\\u{${t.toString(16).padStart(2,"0")}}`]),[127,"\\u{7f}"],[8206,"\\u{200e}"],[8207,"\\u{200f}"],[8234,"\\u{202a}"],[8235,"\\u{202b}"],[8236,"\\u{202c}"],[8237,"\\u{202d}"],[8238,"\\u{202e}"],[8294,"\\u{2066}"],[8295,"\\u{2067}"],[8296,"\\u{2068}"],[8297,"\\u{2069}"],[65279,"\\u{feff}"],[34,"\\\""],[92,"\\\\"],[10,"\\n"],[11,"\\u{0b}"],[12,"\\f"],[13,"\\r"],[133,"\\u{85}"],[8232,"\\u{2028}"],[8233,"\\u{2029}"],[8,"\\b"],[9,"\\t"]]),hu=new Map([["\\n",`
45
+ `],["\\r","\r"],["\\t","\t"],["\\\\","\\"],["\\\"",'"'],["\\b","\b"],["\\f","\f"],["\\s"," "]]),nn=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/,xu=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/g,yu=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/s,$u=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/dgs;Su=/[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)$/,bu=/(?:^|[^\\\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])(?:\\\\)*[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(?:\\[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)*$/,wu=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]?)/g,Eu=/([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*$/;Ju=/\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g;Nu=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)|\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g});function tt(e){if(!e.current.done)e.lastToken=e.current.value;e.current=e.tokens.next();let t=!e.current.done&&e.current.value.errors;if(t)e.errors.push(...t)}function B(e,t){if(!e.current.done&&e.current.value.type===t){let n=e.current.value;return tt(e),n}}function P(e,t){let n="current"in e?e.current.value??e.lastToken:e;return new M(t,{token:n})}function ye(e,t,n,r=n){if(e.storeLocations)ua(t,n,r)}function ce(e="",t="",n=""){return e+t+n||void 0}function kr(e,t,{storeLocations:n=!1,flags:r}){let s={type:-1,text:"",start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1},errors:null},o={text:e,tokens:t[Symbol.iterator](),current:{done:!1,value:s},storeLocations:n,lastToken:s,errors:[],flags:r};return tt(o),o}function ro(e,t){if(!t&&!e.current.done&&e.current.value.type!==ut)t=P(e,`Unexpected token ${JSON.stringify(e.current.value.text)}, did you forget to quote an identifier?`);let n=e.errors??[];if(t!=null)if(t instanceof M)if(t.errors)n.push(...t.errors);else n.push(t);else n.push(new M(`An unexpected error occurred, ${String(t)}, this is likely a bug in the KDL parser`,{cause:t}));if(n.length)if(n.length===1)throw n[0];else throw new M("Encountered multiple errors",{errors:n})}function _r(e){switch(e){case"#null":return null;case"#true":return!0;case"#false":return!1;case"#inf":return 1/0;case"#-inf":return-1/0;case"#nan":return NaN}}function Sa(e){return e==="inf"||e==="-inf"||e==="nan"||e==="true"||e==="false"||e==="null"||!1}function so(e){let{value:t}=e.current,n,r,s,o,i,a=!1;if(t?.text[0]==="-"||t?.text[0]==="+")i=t.text[0];switch(t?.type){case We:{if(!e.flags.experimentalSuffixedNumbers)throw new M("Unreachable code: got a suffixed number from the tokenizer but the suffixed number flag is not set",{token:t});let u=i?t.text.slice(1):t.text,f=u.search(/[^0-9._]/);if(r=(i??"")+u.slice(0,f),n=Number.parseFloat(r.replaceAll("_","")),o=s=u.slice(f),Sa(s))e.errors.push(P(e,`Invalid suffix ${s}, values that look like keywords cannot be used as suffix`))}break;case Ar:a=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),2);break;case Nr:a=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),8);break;case Qe:a=!0,n=Number.parseFloat(t.text.replaceAll("_",""));break;case Jr:a=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),16);break;case Kt:if(n=_r(t.text),n===void 0)if(n=null,_r(t.text.toLowerCase())!==void 0)e.errors.push(P(e,`Invalid keyword ${t.text}, keywords are case sensitive, write ${t.text.toLowerCase()} instead`));else switch(t.text.toLowerCase()){case"#nul":case"#nill":e.errors.push(P(e,`Invalid keyword ${t.text}, did you mean #null?`));break;case"#fals":case"#fasle":e.errors.push(P(e,`Invalid keyword ${t.text}, did you mean #false?`));break;case"#ture":case"#treu":e.errors.push(P(e,`Invalid keyword ${t.text}, did you mean #true?`));break;case"#ifn":e.errors.push(P(e,`Invalid keyword ${t.text}, did you mean #inf?`));break;case"#-ifn":e.errors.push(P(e,`Invalid keyword ${t.text}, did you mean #-inf?`));break;default:e.errors.push(P(e,`Invalid keyword ${t.text}, surround it with quotes to use a string`))}break;default:return}tt(e);let l=e.flags.experimentalSuffixedNumbers&&B(e,Kt);if(l)if(a){if(o=l.text,_r(o)!==void 0)e.errors.push(P(l,`Invalid number suffix ${o}, did you forget a space between the number and the keyword?`));s=o.slice(1)}else if(s)e.errors.push(P(l,"Unexpected hashed suffix, a number can only have one suffix"));else if(typeof n==="number")e.errors.push(P(l,"Unexpected hashed suffix, you cannot place suffixes on number keywords"));else e.errors.push(P(l,"Unexpected hashed suffix, you can only place suffixes on numbers"));let c=new Ie(n);if(c.representation=r??t.text,ye(e,c,t),s){let u=new Be(s);u.representation=o,u.suffix=!0,ye(e,u,e.lastToken),c.tag=u}return c}function Pn(e){if(e.current.done)return;let{value:t}=e.current,n;switch(t.type){case le:if(tt(e),Sa(t.text))e.errors.push(P(e,`Invalid keyword "${t.text}", add a leading # to use the keyword or surround with quotes to make it a string`));n=[t.text,t.text,t];break;case Cn:tt(e),n=[ha(e.errors,t.text.slice(1,-1),t),t.text,t];break;case Gt:tt(e),n=[xa(e.errors,t.text.slice(3,-3),t),t.text,t];break;case ft:{tt(e);let r=t.text,s=r.indexOf('"');n=[ma(e.errors,r.slice(s+1,-(s+1)),t),r,t];break}case Jt:{tt(e);let r=t.text,s=r.indexOf('"');n=[ga(e.errors,r.slice(s+3,-(s+3)),t),r,t];break}default:return}if(B(e,Kt))e.errors.push(P(e.lastToken,_r(e.lastToken.text)===void 0?"Unexpected hashed suffix on a string, you can only place suffixes on numbers":"Unexpected keyword, did you forget to add whitespace?"));return n}function oo(e){let t=Pn(e);if(!t)return;let n=new ke(t[0]);return n.representation=t[1],ye(e,n,t[2],e.lastToken),n}function Pr(e){let t=so(e);if(t)return t;let n=Pn(e);if(!n)return;let r=new Ie(n[0]);return r.representation=n[1],ye(e,r,n[2],e.lastToken),r}function kn(e){let t=B(e,Cr);if(!t)return;let{value:n}=e.current;return tt(e),t.text+(n?.text??"")}function Ir(e){return B(e,jr)?.text}function io(e){return B(e,Et)??Ir(e)}function Dr(e){let t=B(e,Or);if(!t)return;while(io(e));if(!kn(e)&&!B(e,pt)&&!B(e,ut))e.errors.push(P(e,`Expected newline or single-line comment after backslash but got ${e.current.value?.text??"EOF"}`));return e.text.slice(t.start.offset,e.lastToken.end.offset)}function gt(e){let t=e.lastToken.end;while(B(e,pt)?.text??kn(e)??io(e)??Dr(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function ee(e){let t=e.lastToken.end;while(io(e)??Dr(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function no(e){let t=B(e,Sr);if(!t)return;let n=ee(e),r=Pn(e);if(!r&&e.current.value){let a=e.current.value;if(gt(e))e.errors.push(P(a,"This type of whitespace is not allowed inside a tag"));r=Pn(e)}if(!r){if(so(e))e.errors.push(P(e,"Invalid tag, did you forget to quote a string?")),r=["error","error"]}if(!r)throw P(e,"Invalid tag, did you forget to quote a string?");let s=ee(e),o=B(e,On);if(!o&&e.current.value){let a=e.current.value;if(gt(e))e.errors.push(P(a,"This type of whitespace is not allowed inside a tag"));o=B(e,On)}if(!o)throw P(e,"Invalid tag, did you forget to quote a string?");let i=new Be(r[0]);return i.representation=r[1],i.leading=n,i.trailing=s,ye(e,i,t,e.lastToken),i}function Mr(e){return kn(e)??B(e,pt)?.text??B(e,Er)?.text??B(e,ut)?.text}function ao(e){if(!B(e,br))return;let t=Ja(e);if(!B(e,wr))throw P(e,"Invalid node children");return t}function rn(e){let t=e.current.value;{let f=no(e);if(f){let p=ee(e),d=Pr(e);if(!d)throw P(e,"Invalid argument");if(d.tag)e.errors.push(P(e.lastToken,"A number suffix cannot be combined with a regular tag"));d.tag=f,d.betweenTagAndValue=p;let h=new Ne(d,null);ye(e,d,t,e.lastToken),ye(e,h,t,e.lastToken);let g=ee(e);if(B(e,zt))e.errors.push(P(e.lastToken,typeof d.value==="string"?"Unexpected equals sign, properties are name=(tag)value not (tag)name=value":"Unexpected equals sign")),g=ce(g,ee(e))||" ";return[h,g]}}{let f=so(e);if(f){let p=new Ne(f,null);ye(e,p,t,e.lastToken);let d=ee(e);if(B(e,zt))e.errors.push(P(e.lastToken,"Unexpected equals sign, did you forget to quote the property name?")),d=ce(d,ee(e))||" ";return[p,d]}}let n=Pn(e);if(!n)return;let r=ee(e),s=B(e,zt);if(!s){let f=new Ie(n[0]);f.representation=n[1],ye(e,f,n[2]);let p=new Ne(f,null);return ye(e,p,t,e.lastToken),[p,r]}let o=new ke(n[0]);o.representation=n[1],ye(e,o,n[2]);let i=ee(e),a=no(e),l=a&&ee(e),c=Pr(e);if(!c)throw P(e,"Expected a value");if(a){if(c.tag)e.errors.push(P(e.lastToken,"A number suffix cannot be combined with a regular tag"));c.tag=a,c.betweenTagAndValue=l}let u=new Ne(c,o);return ye(e,u,t,e.lastToken),u.equals=ce(r,s.text,i),[u,void 0]}function ba(e){let t=ee(e)??"",n;while(n=jt(e)){let i=e.lastToken.end,a=rn(e);if(!a)throw P(e,"Expected a property or argument");if(!(a[1]??ee(e)))throw P(e,"Expected space after slashdashed property or argument");t=t+n+e.text.slice(i.offset,e.lastToken.end.offset)}let r=rn(e);if(!r)return;let s=r[1]??ee(e)??"";while(n=jt(e)){let i=e.lastToken.end,a=rn(e);if(!a)throw P(e,"Expected a property or argument");if(!(a[1]??ee(e)))break;s=s+n+e.text.slice(i.offset,e.lastToken.end.offset)}let o=r[0];return o.leading=t,o.trailing=s,o}function jt(e){let t=B(e,wt)?.text;if(!t)return;return ce(t,gt(e))}function Fr(e){let t=e.current.value,n=no(e),r=n&&ee(e),s=oo(e);if(!s)if(n)throw P(e,"Couldn't find node name");else return;let o=ee(e),i=o!=null,a=jt(e),l=[];while(i||a){let p=e.lastToken.end,d=rn(e);if(!d)break;if(a)i=(d[1]||ee(e))!=null,o=ce(o,a,e.text.slice(p.offset,e.lastToken.end.offset)),a=jt(e);else{let h=d[0];h.leading=o,l.push(h),o=d[1]||ee(e),i=o!=null,a=jt(e)}}let c,u;while(!0){a??=jt(e);let p=e.lastToken.end,d=ao(e);if(!d){if(a)throw P(e,"Unexpected slashdash");break}if(a)o=ce(o,a,e.text.slice(p.offset,e.lastToken.end.offset)),a=void 0;else{if(c)e.errors.push(P(e,"A node can only have one children block"));c=d,u=o??"",o=void 0}o=ce(o,ee(e))}let f=new en(s,l,c);return f.tag=n??null,f.betweenTagAndName=r,f.beforeChildren=u,f.trailing=o??"",ye(e,f,t,e.lastToken),f}function wa(e){let t=gt(e),n=Fr(e);if(!n)return;let r=ce(Mr(e),gt(e));return n.leading=ce(t,n.leading),n.trailing=ce(n.trailing,r),n}function Ea(e){let t=B(e,qt)?.text,n=Ja(e);if(!t)return n;if(n.nodes[0])n.nodes[0].leading=ce(t,n.nodes[0].leading);else n.trailing=ce(t,n.trailing);return n}function Ja(e){let t=e.current.value,n=[],r=!0,s=gt(e);while(r){let i=e.lastToken.end,a=jt(e),l=Fr(e);if(!l){if(a)throw P(e,"Unexpected slashdash");break}let c=ee(e),u=Mr(e);if(a)s=ce(s,e.text.slice(i.offset,e.lastToken.end.offset),gt(e));else l.trailing=ce(l.trailing,c,u)??"",n.push(l),l.leading=s??"",s=gt(e);r=u!=null}let o=new mt(n);return ye(e,o,t,e.lastToken),o.trailing=s??"",o}var lo=A(()=>{At();Xs();da();$a();Xt()});function Na(e,t){let n=[],r;while(r=t(e))n.push(r);return n.length>0?n:void 0}function Au(e){{let t=B(e,qt);if(t)return{type:"bom",text:t.text}}{let t=B(e,pt);if(t)return{type:"newline",text:t.text}}{let t=B(e,Et);if(t)return{type:"space",text:t.text}}{let t=kn(e);if(t)return{type:"singleline",text:t}}{let t=Ir(e);if(t)return{type:"multiline",text:t}}return}function Lr(e){{let t=Dr(e);if(t)return{type:"line-escape",text:t}}{let t=B(e,Et);if(t)return{type:"space",text:t.text}}{let t=Ir(e);if(t)return{type:"multiline",text:t}}return}function Aa(e){let t=[];while(!0){{let n=Au(e);if(n){t.push(n);continue}}if(B(e,wt)?.text){let r,s=Na(e,Lr)??[],o=Fr(e);if(!o)throw P(e,"Invalid slashdash, expected a commented node");o.trailing=ce(o.trailing,Na(e,Lr)?.map((i)=>i.text).join(""),Mr(e)),t.push({type:"slashdash",preface:s,value:o});continue}break}return t}function Ou(e){let t=B(e,wt);if(t==null)return;let n,r=[];while(n=Lr(e))r.push(n);let s,o,i="";if(o=rn(e)){if(s=o[0],o[1])i=o[1]}else if(o=ao(e))s=o;else throw P(t,"Couldn't find argument, property, or children that were commented by slashdash");return[{type:"slashdash",preface:r,value:s},i]}function co(e){let t=[];while(!0){let n=Lr(e);if(!n)break;let r=!0;t.push(n);while(r){let s=Ou(e);if(!s)break;if(t.push(s[0]),s[1][0])t.push(...co(kr(s[1][0],Rn(s[1][0],{flags:e.flags}),{flags:e.flags})));r=!!s[1][0]}}return t}var Oa=A(()=>{Xt();lo()});function ht(e,{as:t="document",flags:n,...r}={}){let s=Cu[t];if(s==null)throw TypeError(`Invalid "as" target passed: ${JSON.stringify(t)}`);if(typeof e!=="string"){if(typeof TextDecoder!=="function")throw TypeError("Uint8Array input is only supported on platforms that include TextDecoder");e=new TextDecoder("utf-8",{fatal:!0}).decode(e)}let o=fa(n),i=Rn(e,{...r,flags:o}),a=kr(e,i,{...r,flags:o}),l;try{l=s(a)}catch(c){ro(a,c)}if(ro(a),!l)throw new M(`Expected ${/^[aeiouy]/.exec(t)?"an":"a"} ${t}`);return l}var Cu;var Ca=A(()=>{At();Xt();lo();Oa();Cu={value:Pr,identifier:oo,node:wa,entry:ba,document:Ea,"whitespace in document":Aa,"whitespace in node":co}});var Wr=A(()=>{At();Xs();Ca()});function sn(e,t){let n=e.slice(0,t),r=n.split(`
37
46
  `).length;return{column:t-n.lastIndexOf(`
38
- `),line:r,offset:t}}var ie;var nn=j(()=>{ie=class ie extends Error{column;line;offset;reason;constructor(e,t=null){super(t?`${e} (line ${t.line}, column ${t.column})`:e);this.name="JxnError",this.column=t?.column??null,this.line=t?.line??null,this.offset=t?.offset??null,this.reason=e}inFile(e){let t=this.line!==null&&this.column!==null&&this.offset!==null?{column:this.column,line:this.line,offset:this.offset}:null;return new ie(`${e}: ${this.reason}`,t)}}});var Qi;var ea=j(()=>{Qi=new Set(["onabort","onactivate","onaddsourcebuffer","onaddtrack","onadvertisementreceived","onafterprint","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onappinstalled","onaudioend","onaudioprocess","onaudiostart","onauxclick","onavailabilitychanged","onbackgroundfetchabort","onbackgroundfetchclick","onbackgroundfetchfail","onbackgroundfetchsuccess","onbeforeinput","onbeforeinstallprompt","onbeforematch","onbeforeprint","onbeforetoggle","onbeforexrselect","onbegin","onblocked","onblur","onboundary","onbufferedamountlow","onbufferedchange","oncancel","oncanmakepayment","oncanplay","oncanplaythrough","oncaptureaction","oncapturedmousechange","oncapturehandlechange","onchange","oncharacterboundsupdate","oncharacteristicvaluechanged","onchargingchange","onchargingtimechange","onclick","onclose","onclosing","oncommand","oncomplete","oncompositionend","oncompositionstart","onconfigurationchange","onconnect","onconnecting","onconnectionavailable","onconnectionstatechange","oncontentdelete","oncontextlost","oncontextmenu","oncontextoverflow","oncontextrestored","oncontrollerchange","oncookiechange","oncopy","oncuechange","oncurrententrychange","oncurrentscreenchange","oncut","ondataavailable","ondatachannel","ondblclick","ondequeue","ondevicechange","ondevicemotion","ondeviceorientation","ondeviceorientationabsolute","ondischargingtimechange","ondisconnect","ondispose","ondownloadprogress","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onencrypted","onend","onended","onendstreaming","onenter","onenterpictureinpicture","onerror","onexit","onfencedtreeclick","onfetch","onfinish","onfocus","onformdata","onframeratechange","onfreeze","onfullscreenchange","onfullscreenerror","ongamepadconnected","ongamepaddisconnected","ongatheringstatechange","ongattserverdisconnected","ongeometrychange","ongotpointercapture","onhashchange","onicecandidate","onicecandidateerror","oniceconnectionstatechange","onicegatheringstatechange","oninput","oninputreport","oninputsourceschange","oninstall","oninstallresult","oninvalid","onisolationchange","onkeydown","onkeyframerequest","onkeypress","onkeystatuseschange","onkeyup","onlanguagechange","onlayoutchange","onleavepictureinpicture","onlevelchange","onload","onloadeddata","onloadedmetadata","onloadend","onloading","onloadingdone","onloadingerror","onloadstart","onlocation","onlostpointercapture","onmanagedconfigurationchange","onmark","onmessage","onmessageerror","onmidimessage","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmute","onnavigate","onnavigateerror","onnavigatesuccess","onnegotiationneeded","onnomatch","onnotificationclick","onnotificationclose","onoffline","ononline","onopen","onorientationchange","onpagehide","onpagereveal","onpageshow","onpageswap","onpaste","onpause","onpayerdetailchange","onpaymentmethodchange","onpaymentrequest","onperiodicsync","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointerlockchange","onpointerlockerror","onpointermove","onpointerout","onpointerover","onpointerrawupdate","onpointerup","onpopstate","onportalactivate","onprerenderingchange","onprioritychange","onprocessorerror","onprogress","onpromptaction","onpromptdismiss","onpush","onpushsubscriptionchange","onquotaoverflow","onratechange","onreading","onreadingerror","onreadystatechange","onredraw","onreflectionchange","onrejectionhandled","onrelease","onremove","onremovesourcebuffer","onremovetrack","onrepeat","onreset","onresize","onresourcetimingbufferfull","onresult","onresume","onrtctransform","onscreenschange","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectedcandidatepairchange","onselectend","onselectionchange","onselectstart","onserviceadded","onservicechanged","onserviceremoved","onshippingaddresschange","onshippingoptionchange","onshow","onsignalingstatechange","onsinkchange","onslotchange","onsnapchanged","onsnapchanging","onsoundend","onsoundstart","onsourceclose","onsourceended","onsourceopen","onspeechend","onspeechstart","onsqueeze","onsqueezeend","onsqueezestart","onstalled","onstart","onstartstreaming","onstatechange","onstop","onstorage","onstream","onsubmit","onsuccess","onsuspend","onsync","onterminate","ontextformatupdate","ontextupdate","ontimeout","ontimeupdate","ontoggle","ontonechange","ontoolactivated","ontoolcancel","ontoolchange","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontrack","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onuncapturederror","onunhandledrejection","onunload","onunmute","onupdate","onupdateend","onupdatefound","onupdatestart","onupgradeneeded","onvalidationstatuschange","onversionchange","onvisibilitychange","onvoiceschanged","onvolumechange","onwaiting","onwaitingforkey","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel","onzoomlevelchange"])});function I(e,t,n,r,s){let o=t.normalize("NFC");if(o==="__proto__")throw F(r,s,'"__proto__" cannot be a key: it would not be data');if(Object.hasOwn(e,o))throw F(r,s,`"${o}" is written twice, and one of them would be lost`);e[o]=n}function F(e,t,n){let r=ta(t)?.start;return new ie(n,r===void 0?null:tn(e.text,r))}function ta(e){let t=Gt(e);return t?{end:t.end.offset,start:t.start.offset}:null}function ae(e,t,n){let r=e.spans?ta(n):null;if(r)e.spans?.set(t,r)}function Ne(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function rn(e,t){let n=t.getTag();if(n!==null&&!Ic.has(n))throw F(e,t,`(${n}) is not an annotation Jx Notation has`);if(n==="ref")throw F(e,t,"(ref) annotates a value, and this is a name");return n}function sn(e,t){let n=t.getTag(),r=t.getValue();if(n!==null&&n!=="ref")throw F(e,t,`(${n}) cannot annotate a value here; only (ref) can`);if(se(r)){if(!Number.isFinite(r))throw F(e,t,"JSON has no way to hold #inf or #nan");if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw F(e,t,"This number is too large to survive being read as JSON")}if(n==="ref"){if(!b(r))throw F(e,t,"(ref) needs a string");return{$ref:r}}return r}function tt(e,t){return t.entries.filter((n)=>!n.name).map((n)=>sn(e,n))}function nt(e){return e.entries.filter((t)=>t.name)}function ye(e){return e.children?.nodes??[]}function vn(e){return e.getName()??""}function Dc(e,t,n){let r={$prototype:"Function"},s=tt(e,t),o=ye(t);for(let i of nt(t))I(r,vn(i),sn(e,i),e,i);if(o.length>0){if(s.length>0)I(r,"parameters",s,e,t);I(r,"body",Us(e,o,`${n}/body`),e,t)}else if(s.length>0){let i=s.at(-1)??null,c=s.slice(0,-1);if(c.length>0)I(r,"parameters",c,e,t);I(r,"body",i,e,t)}return ae(e,n,t),r}function Us(e,t,n){return t.map((r,s)=>{if(r.getName()!=="-")throw F(e,r,`A list holds only "-" items, and this is "${r.getName()}"`);return je(e,r,`${n}/${s}`)})}function je(e,t,n){let r=rn(e,t);if(ae(e,n,t),r==="fn")return Dc(e,t,n);let s=tt(e,t),o=nt(t),i=ye(t);if(r==="array"){if(o.length>0)throw F(e,t,"(array) holds items, and these are named");return[...s,...Us(e,i,n)]}if(r!=="object"){if(s.length>1){if(o.length>0||i.length>0)throw F(e,t,"A list of values cannot also have names or a block");return s}if(s.length===1){if(o.length>0||i.length>0)throw F(e,t,"A value cannot also have names or a block");return s[0]??null}if(i.length>0&&o.length===0&&i.every((a)=>a.getName()==="-"))return Us(e,i,n)}else if(s.length>0)throw F(e,t,"(object) holds names, and this is a value");let c={};for(let a of o){let l=vn(a);I(c,l,sn(e,a),e,a),ae(e,`${n}/${Ne(l)}`,a)}for(let a of i){let l=a.getName();I(c,l,je(e,a,`${n}/${Ne(l)}`),e,a)}return c}function _r(e,t,n){let r={};if(ae(e,n,t),tt(e,t).length>0)throw F(e,t,"A style block holds declarations, and this is a value");for(let s of nt(t)){let o=vn(s);I(r,o,sn(e,s),e,s),ae(e,`${n}/${Ne(o)}`,s)}for(let s of ye(t)){let o=s.getName(),i=`${n}/${Ne(o)}`,c=ye(s);if(s.getTag()==="array"||c.length>0&&c.every((l)=>l.getName()==="-")){I(r,o,je(e,s,i),e,s);continue}let a=tt(e,s);if(a.length>1)throw F(e,s,`"${o}" has more than one value. A selector with a space in it needs quotes`);if(a.length===1){if(nt(s).length>0||ye(s).length>0)throw F(e,s,`"${o}" has a value and names. A selector with a space in it needs quotes`);I(r,o,a[0]??null,e,s),ae(e,i,s)}else I(r,o,_r(e,s,i),e,s)}return r}function Rr(e,t,n){let r=ye(t);if(r.length!==1||!r[0])throw F(e,t,`"${t.getName()}" holds one element`);return ra(e,r[0],n)}function na(e,t,n){let r={$prototype:"Array"};if(ae(e,n,t),tt(e,t).length>0)throw F(e,t,"$array holds names and one element, and this is a value");for(let s of nt(t)){let o=vn(s);I(r,o.startsWith(".")?o.slice(1):o,sn(e,s),e,s)}if(ye(t).length>0)I(r,"map",Rr(e,t,`${n}/map`),e,t);return r}function ra(e,t,n){let r=t.getName();if(r==="-"){let s=tt(e,t);if(s.length!==1||nt(t).length>0||ye(t).length>0)throw F(e,t,'"-" is one piece of text or one (ref)');return ae(e,n,t),s[0]??null}if(r==="$array")return na(e,t,n);return qs(e,t,n)}function Fc(e,t,n,r){let s=rn(e,n);if(t==="map")return Rr(e,n,r);if(t==="cases"){let o={};for(let i of ye(n)){let c=i.getName();I(o,c,Rr(e,i,`${r}/${Ne(c)}`),e,i)}return o}if(t==="children"&&s!=="array"&&ye(n).length>0)return Rr(e,n,r);return je(e,n,r)}function qs(e,t,n){let r={},s=t.getName(),o=rn(e,t);if(ae(e,n,t),o!==null)throw F(e,t,`(${o}) cannot annotate an element`);let i=tt(e,t);if(s==="$element"){let[a,l,...u]=i;if(u.length>0)throw F(e,t,"$element takes at most a tag and a text value");if(a!==void 0)I(r,"tagName",a,e,t);if(l!==void 0)I(r,"textContent",l,e,t)}else{if(s.startsWith("$"))throw F(e,t,`"${s}" is not a kind of element`);if(I(r,"tagName",s,e,t),i.length>1)throw F(e,t,"An element has one text value. A list of them needs a block");if(i[0]!==void 0)I(r,"textContent",i[0],e,t),ae(e,`${n}/textContent`,t)}Lc(e,t,r,n);let c=[];for(let a of ye(t))Wc(e,a,r,c,n);if(c.length>0)I(r,"children",c,e,t);return r}function sa(e){let{attributes:t}=e;if(D(t))return t;let n={};return e.attributes=n,n}function Lc(e,t,n,r){for(let s of nt(t)){let o=vn(s),i=s.getTag();if(i==="fn")throw F(e,s,"A function has a block form: (fn)name, on a line of its own");let c=sn(e,s);if(o.startsWith(".")||o.startsWith("$")){let a=o.startsWith(".")?o.slice(1):o;I(n,a,c,e,s),ae(e,`${r}/${Ne(a)}`,s)}else if(o.startsWith("on")&&i==="ref")I(n,o,c,e,s),ae(e,`${r}/${Ne(o)}`,s);else if(o.startsWith("on")&&Qi.has(o))throw F(e,s,`${o} needs (ref)"pointer", or a function on a line of its own: (fn)${o} "…"`);else I(sa(n),o,c,e,s),ae(e,`${r}/attributes/${Ne(o)}`,s)}}function Wc(e,t,n,r,s){let o=t.getName(),i=rn(e,t),c=(a)=>`${s}/${Ne(a)}`;if(i==="fn"||i==="on"){if(!o.startsWith("on"))throw F(e,t,`(${i}) in an element marks a handler, and "${o}" is not one`);I(n,o,je(e,t,c(o)),e,t)}else if(o==="script")throw F(e,t,'"script" is reserved. A <script> element is $element "script"');else if(o==="state")I(n,"state",je(e,t,c("state")),e,t);else if(o==="style")I(n,"style",_r(e,t,c("style")),e,t);else if(o==="attributes"){let a=je(e,t,c("attributes"));if(D(a))for(let[l,u]of Object.entries(a))I(sa(n),l,u,e,t);else I(n,"attributes",a,e,t)}else if(o.startsWith(".")){let a=o.slice(1);I(n,a,Fc(e,a,t,c(a)),e,t)}else if(o.startsWith("$")&&o!=="$array"&&o!=="$element")I(n,o,je(e,t,c(o)),e,t);else{if(Mc.has(o))throw F(e,t,`"${o}" is reserved here`);r.push(ra(e,t,`${s}/children/${r.length}`))}}function zs(e,t){return ye(t).map((n,r)=>{let s=`/$head/${r}`;return n.getName()==="-"?je(e,n,s):qs(e,n,s)})}function Ks(e){let t=kc.exec(e);if(t)throw new ie(`A raw control character (U+${t[0].codePointAt(0)?.toString(16).toUpperCase().padStart(4,"0")}) cannot be in a Jx Notation file. Escape it, as \\u{1b}`,tn(e,t.index));try{return gt(e,{storeLocations:!0})}catch(n){let s=(n instanceof M?n.errors?.[0]??n:null)?.start,o=n instanceof Error?n.message:String(n);throw new ie(o.split(`
39
- `)[0]??o,s?tn(e,s.offset):null)}}function oa(e){if(Wt(e.text)==="project")throw new ie('This is a project file: its first node is "project". A document has an element there, and a <project> element is $element "project"');let n=Ks(e.text),r={},s=null;for(let o of n.nodes){let i=o.getName();if(i==="$head"&&o.getTag()===null)I(r,i,zs(e,o),e,o);else if(i.startsWith("$")&&i!=="$array"&&i!=="$element")I(r,i,je(e,o,`/${Ne(i)}`),e,o),ae(e,`/${Ne(i)}`,o);else if(s)throw F(e,o,"A document has one root element, and this is a second");else s=o}if(s){let o=s.getName()==="$array"?na(e,s,""):qs(e,s,"");for(let[i,c]of Object.entries(o))I(r,i,c,e,s)}return Vt(r)}function Tn(e,t){try{return oa({spans:null,text:e})}catch(n){throw t!==void 0&&n instanceof ie?n.inFile(t):n}}function Gs(e){let t=new Map;return{document:oa({spans:t,text:e}),spans:t}}var kc,Ic,Mc;var Rn=j(()=>{Tr();z();Sn();$n();nn();ea();kc=/(?![\t\n\v\f\r])\p{Cc}/u,Ic=new Set(["array","fn","object","on","ref"]),Mc=new Set(["attributes","script","state","style"])});function _n(e){return e.toLowerCase().endsWith(".jxn")}function Pn(e){return e.endsWith(".json")||_n(e)}function kn(e,t){return _n(t)?Tn(e,t):bi(e,t)}var Ys=j(()=>{Sn();Rn()});function Bc(e){let t={comments:0,escapes:[]},n=Hc.exec(e)?.[0].length??0;while(n<e.length)if(e.startsWith("//",n)){t.comments+=1;let r=e.indexOf(`
40
- `,n);n=r===-1?e.length:r}else if(e.startsWith("/*",n)){t.comments+=1;let r=e.indexOf("*/",n+2);n=r===-1?e.length:r+2}else if(e.startsWith("/-",n))t.comments+=1,n+=2;else if(e.charAt(n)==="#"&&/^#+"/u.test(e.slice(n,n+16))){let[r=""]=/^#+/u.exec(e.slice(n))??[],s=n+r.length,o=e.startsWith('"""',s)?'"""':'"',i=e.indexOf(o+r,s+o.length);n=i===-1?e.length:i+o.length+r.length}else if(e.charAt(n)==='"'){let r=e.startsWith('"""',n)?'"""':'"';n+=r.length;while(n<e.length&&!e.startsWith(r,n))if(e.charAt(n)==="\\")t.escapes.push(n),n+=2;else n+=1;n+=r.length}else n+=1;return t}function Uc(e){return Bc(e).escapes.flatMap((t)=>{let n=Vc.get(e.charAt(t+1));return n?[{...tn(e,t),message:n}]:[]})}var Vc,Hc;var ia=j(()=>{nn();Vc=new Map([["b",String.raw`\b in a quoted string is a backspace, not a word boundary. Use a raw string, like #"…"#, if this is a pattern.`],["s",String.raw`\s in a quoted string is a space, not whitespace. Use a raw string, like #"…"#, if this is a pattern.`]]),Hc=/^\uFEFF?\s*\/-[^\S\n]*kdl-version[^\S\n]+\d+[^\S\n]*(?:\n|$)/u});function on(e,t=!1){if(Array.isArray(e))return`[${e.map((s)=>on(s,t)).join(",")}]`;if(!D(e))return e===void 0?"null":JSON.stringify(e);return`{${(t?Object.keys(e):Object.keys(e).toSorted()).map((s)=>`${JSON.stringify(s)}:${on(e[s],t||s==="style")}`).join(",")}}`}function qc(e,t){let n=e;for(let r of t.split("/").slice(1)){let s=r.replaceAll("~1","/").replaceAll("~0","~");if(Array.isArray(n))n=n[Number(s)];else n=D(n)?n[s]:void 0}return n}function zc({spans:e}){let t=new Map;for(let[n,r]of e){let s=t.get(r.start);if(s===void 0||n.length<s.length)t.set(r.start,n)}return t}function aa(e,t){let n=zc(e),r=new Map;for(let[s,o]of n)r.set(s,on(qc(e.document,o)));return{meanings:r,pointers:n,text:t}}function rt(e){let t=Gt(e);return{end:t?.end.offset??0,start:t?.start.offset??0}}function kr(e,t){let{end:n,start:r}=rt(e);return t.slice(r,n).trimEnd()}function Pr(e,t){let{end:n,start:r}=rt(e);return`${e.leading??" "}${t.slice(r,n).trimEnd()}`}function eo(e){return e.children?.nodes??[]}function Xs(e){let t=e.entries.map((o)=>`${o.getName()??""}=(${o.getTag()??""})${JSON.stringify(o.getValue())}`),n=t.filter((o)=>!o.startsWith("=")).toSorted(),r=t.filter((o)=>o.startsWith("=")),s=eo(e).map((o)=>Xs(o));return`(${e.getTag()??""})${e.getName()} ${[...n,...r].join(" ")} {${s.join(";")}}`}function Zs(e,t,n){if(Xs(t)===Xs(n))return!0;let r=e.previous.meanings.get(rt(t).start);return r!==void 0&&r===e.next.meanings.get(rt(n).start)}function la(e){let n=e.entries.filter((r)=>["$id","key"].includes(r.getName()??"")).map((r)=>JSON.stringify(r.getValue()));return`(${e.getTag()??""})${e.getName()} ${n.join(" ")}`}function ca(e,t,n){let r=e.length+1,s=t.length+1,o=new Int32Array(r*s);for(let l=e.length-1;l>=0;l-=1)for(let u=t.length-1;u>=0;u-=1){let f=e[l],p=t[u];o[l*s+u]=f!==void 0&&p!==void 0&&n(f,p)?(o[(l+1)*s+u+1]??0)+1:Math.max(o[(l+1)*s+u]??0,o[l*s+u+1]??0)}let i=[],c=0,a=0;while(c<e.length&&a<t.length){let l=e[c],u=t[a];if(l!==void 0&&u!==void 0&&n(l,u))i.push([c,a]),c+=1,a+=1;else if((o[(c+1)*s+a]??0)>=(o[c*s+a+1]??0))c+=1;else a+=1}return i}function Kc(e,t,n){let r=new Map,s=new Set,o=(l,u)=>{let f=t[l];if(f)r.set(u,f),s.add(l)},i=ca(t,n,(l,u)=>Zs(e,l,u)),c=0,a=0;for(let[l,u]of[...i,[t.length,n.length]]){let f=ca(t.slice(c,l),n.slice(a,u),(p,d)=>la(p)===la(d));for(let[p,d]of f)o(c+p,a+d);if(l<t.length)o(l,u);c=l+1,a=u+1}for(let[l,u]of n.entries())if(!r.has(l)){let f=t.findIndex((p,d)=>!s.has(d)&&Zs(e,p,u));if(f!==-1)o(f,l)}return r}function to(e){let t=e.leading??"";return t.slice(t.lastIndexOf(`
41
- `)+1)}function Gc(e,t,n){return e.split(`
47
+ `),line:r,offset:t}}var ie;var on=A(()=>{ie=class ie extends Error{column;line;offset;reason;constructor(e,t=null){super(t?`${e} (line ${t.line}, column ${t.column})`:e);this.name="JxnError",this.column=t?.column??null,this.line=t?.line??null,this.offset=t?.offset??null,this.reason=e}inFile(e){let t=this.line!==null&&this.column!==null&&this.offset!==null?{column:this.column,line:this.line,offset:this.offset}:null;return new ie(`${e}: ${this.reason}`,t)}}});var ja;var va=A(()=>{ja=new Set(["onabort","onactivate","onaddsourcebuffer","onaddtrack","onadvertisementreceived","onafterprint","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onappinstalled","onaudioend","onaudioprocess","onaudiostart","onauxclick","onavailabilitychanged","onbackgroundfetchabort","onbackgroundfetchclick","onbackgroundfetchfail","onbackgroundfetchsuccess","onbeforeinput","onbeforeinstallprompt","onbeforematch","onbeforeprint","onbeforetoggle","onbeforexrselect","onbegin","onblocked","onblur","onboundary","onbufferedamountlow","onbufferedchange","oncancel","oncanmakepayment","oncanplay","oncanplaythrough","oncaptureaction","oncapturedmousechange","oncapturehandlechange","onchange","oncharacterboundsupdate","oncharacteristicvaluechanged","onchargingchange","onchargingtimechange","onclick","onclose","onclosing","oncommand","oncomplete","oncompositionend","oncompositionstart","onconfigurationchange","onconnect","onconnecting","onconnectionavailable","onconnectionstatechange","oncontentdelete","oncontextlost","oncontextmenu","oncontextoverflow","oncontextrestored","oncontrollerchange","oncookiechange","oncopy","oncuechange","oncurrententrychange","oncurrentscreenchange","oncut","ondataavailable","ondatachannel","ondblclick","ondequeue","ondevicechange","ondevicemotion","ondeviceorientation","ondeviceorientationabsolute","ondischargingtimechange","ondisconnect","ondispose","ondownloadprogress","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onencrypted","onend","onended","onendstreaming","onenter","onenterpictureinpicture","onerror","onexit","onfencedtreeclick","onfetch","onfinish","onfocus","onformdata","onframeratechange","onfreeze","onfullscreenchange","onfullscreenerror","ongamepadconnected","ongamepaddisconnected","ongatheringstatechange","ongattserverdisconnected","ongeometrychange","ongotpointercapture","onhashchange","onicecandidate","onicecandidateerror","oniceconnectionstatechange","onicegatheringstatechange","oninput","oninputreport","oninputsourceschange","oninstall","oninstallresult","oninvalid","onisolationchange","onkeydown","onkeyframerequest","onkeypress","onkeystatuseschange","onkeyup","onlanguagechange","onlayoutchange","onleavepictureinpicture","onlevelchange","onload","onloadeddata","onloadedmetadata","onloadend","onloading","onloadingdone","onloadingerror","onloadstart","onlocation","onlostpointercapture","onmanagedconfigurationchange","onmark","onmessage","onmessageerror","onmidimessage","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmute","onnavigate","onnavigateerror","onnavigatesuccess","onnegotiationneeded","onnomatch","onnotificationclick","onnotificationclose","onoffline","ononline","onopen","onorientationchange","onpagehide","onpagereveal","onpageshow","onpageswap","onpaste","onpause","onpayerdetailchange","onpaymentmethodchange","onpaymentrequest","onperiodicsync","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointerlockchange","onpointerlockerror","onpointermove","onpointerout","onpointerover","onpointerrawupdate","onpointerup","onpopstate","onportalactivate","onprerenderingchange","onprioritychange","onprocessorerror","onprogress","onpromptaction","onpromptdismiss","onpush","onpushsubscriptionchange","onquotaoverflow","onratechange","onreading","onreadingerror","onreadystatechange","onredraw","onreflectionchange","onrejectionhandled","onrelease","onremove","onremovesourcebuffer","onremovetrack","onrepeat","onreset","onresize","onresourcetimingbufferfull","onresult","onresume","onrtctransform","onscreenschange","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectedcandidatepairchange","onselectend","onselectionchange","onselectstart","onserviceadded","onservicechanged","onserviceremoved","onshippingaddresschange","onshippingoptionchange","onshow","onsignalingstatechange","onsinkchange","onslotchange","onsnapchanged","onsnapchanging","onsoundend","onsoundstart","onsourceclose","onsourceended","onsourceopen","onspeechend","onspeechstart","onsqueeze","onsqueezeend","onsqueezestart","onstalled","onstart","onstartstreaming","onstatechange","onstop","onstorage","onstream","onsubmit","onsuccess","onsuspend","onsync","onterminate","ontextformatupdate","ontextupdate","ontimeout","ontimeupdate","ontoggle","ontonechange","ontoolactivated","ontoolcancel","ontoolchange","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontrack","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onuncapturederror","onunhandledrejection","onunload","onunmute","onupdate","onupdateend","onupdatefound","onupdatestart","onupgradeneeded","onvalidationstatuschange","onversionchange","onvisibilitychange","onvoiceschanged","onvolumechange","onwaiting","onwaitingforkey","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel","onzoomlevelchange"])});function D(e,t,n,r,s){let o=t.normalize("NFC");if(o==="__proto__")throw F(r,s,'"__proto__" cannot be a key: it would not be data');if(Object.hasOwn(e,o))throw F(r,s,`"${o}" is written twice, and one of them would be lost`);e[o]=n}function F(e,t,n){let r=Ta(t)?.start;return new ie(n,r===void 0?null:sn(e.text,r))}function Ta(e){let t=Zt(e);return t?{end:t.end.offset,start:t.start.offset}:null}function ae(e,t,n){let r=e.spans?Ta(n):null;if(r)e.spans?.set(t,r)}function Ae(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function an(e,t){let n=t.getTag();if(n!==null&&!vu.has(n))throw F(e,t,`(${n}) is not an annotation Jx Notation has`);if(n==="ref")throw F(e,t,"(ref) annotates a value, and this is a name");return n}function ln(e,t){let n=t.getTag(),r=t.getValue();if(n!==null&&n!=="ref")throw F(e,t,`(${n}) cannot annotate a value here; only (ref) can`);if(re(r)){if(!Number.isFinite(r))throw F(e,t,"JSON has no way to hold #inf or #nan");if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw F(e,t,"This number is too large to survive being read as JSON")}if(n==="ref"){if(!S(r))throw F(e,t,"(ref) needs a string");return{$ref:r}}return r}function nt(e,t){return t.entries.filter((n)=>!n.name).map((n)=>ln(e,n))}function rt(e){return e.entries.filter((t)=>t.name)}function $e(e){return e.children?.nodes??[]}function In(e){return e.getName()??""}function Ru(e,t,n){let r={$prototype:"Function"},s=nt(e,t),o=$e(t);for(let i of rt(t))D(r,In(i),ln(e,i),e,i);if(o.length>0){if(s.length>0)D(r,"parameters",s,e,t);D(r,"body",uo(e,o,`${n}/body`),e,t)}else if(s.length>0){let i=s.at(-1)??null,a=s.slice(0,-1);if(a.length>0)D(r,"parameters",a,e,t);D(r,"body",i,e,t)}return ae(e,n,t),r}function uo(e,t,n){return t.map((r,s)=>{if(r.getName()!=="-")throw F(e,r,`A list holds only "-" items, and this is "${r.getName()}"`);return ve(e,r,`${n}/${s}`)})}function ve(e,t,n){let r=an(e,t);if(ae(e,n,t),r==="fn")return Ru(e,t,n);let s=nt(e,t),o=rt(t),i=$e(t);if(r==="array"){if(o.length>0)throw F(e,t,"(array) holds items, and these are named");return[...s,...uo(e,i,n)]}if(r!=="object"){if(s.length>1){if(o.length>0||i.length>0)throw F(e,t,"A list of values cannot also have names or a block");return s}if(s.length===1){if(o.length>0||i.length>0)throw F(e,t,"A value cannot also have names or a block");return s[0]??null}if(i.length>0&&o.length===0&&i.every((l)=>l.getName()==="-"))return uo(e,i,n)}else if(s.length>0)throw F(e,t,"(object) holds names, and this is a value");let a={};for(let l of o){let c=In(l);D(a,c,ln(e,l),e,l),ae(e,`${n}/${Ae(c)}`,l)}for(let l of i){let c=l.getName();D(a,c,ve(e,l,`${n}/${Ae(c)}`),e,l)}return a}function Br(e,t,n){let r={};if(ae(e,n,t),nt(e,t).length>0)throw F(e,t,"A style block holds declarations, and this is a value");for(let s of rt(t)){let o=In(s);D(r,o,ln(e,s),e,s),ae(e,`${n}/${Ae(o)}`,s)}for(let s of $e(t)){let o=s.getName(),i=`${n}/${Ae(o)}`,a=$e(s);if(s.getTag()==="array"||a.length>0&&a.every((c)=>c.getName()==="-")){D(r,o,ve(e,s,i),e,s);continue}let l=nt(e,s);if(l.length>1)throw F(e,s,`"${o}" has more than one value. A selector with a space in it needs quotes`);if(l.length===1){if(rt(s).length>0||$e(s).length>0)throw F(e,s,`"${o}" has a value and names. A selector with a space in it needs quotes`);D(r,o,l[0]??null,e,s),ae(e,i,s)}else D(r,o,Br(e,s,i),e,s)}return r}function Vr(e,t,n){let r=$e(t);if(r.length!==1||!r[0])throw F(e,t,`"${t.getName()}" holds one element`);return _a(e,r[0],n)}function Ra(e,t,n){let r={$prototype:"Array"};if(ae(e,n,t),nt(e,t).length>0)throw F(e,t,"$array holds names and one element, and this is a value");for(let s of rt(t)){let o=In(s);D(r,o.startsWith(".")?o.slice(1):o,ln(e,s),e,s)}if($e(t).length>0)D(r,"map",Vr(e,t,`${n}/map`),e,t);return r}function _a(e,t,n){let r=t.getName();if(r==="-"){let s=nt(e,t);if(s.length!==1||rt(t).length>0||$e(t).length>0)throw F(e,t,'"-" is one piece of text or one (ref)');return ae(e,n,t),s[0]??null}if(r==="$array")return Ra(e,t,n);return fo(e,t,n)}function _u(e,t,n,r){let s=an(e,n);if(t==="map")return Vr(e,n,r);if(t==="cases"){let o={};for(let i of $e(n)){let a=i.getName();D(o,a,Vr(e,i,`${r}/${Ae(a)}`),e,i)}return o}if(t==="children"&&s!=="array"&&$e(n).length>0)return Vr(e,n,r);return ve(e,n,r)}function fo(e,t,n){let r={},s=t.getName(),o=an(e,t);if(ae(e,n,t),o!==null)throw F(e,t,`(${o}) cannot annotate an element`);let i=nt(e,t);if(s==="$element"){let[l,c,...u]=i;if(u.length>0)throw F(e,t,"$element takes at most a tag and a text value");if(l!==void 0)D(r,"tagName",l,e,t);if(c!==void 0)D(r,"textContent",c,e,t)}else{if(s.startsWith("$"))throw F(e,t,`"${s}" is not a kind of element`);if(D(r,"tagName",s,e,t),i.length>1)throw F(e,t,"An element has one text value. A list of them needs a block");if(i[0]!==void 0)D(r,"textContent",i[0],e,t),ae(e,`${n}/textContent`,t)}Pu(e,t,r,n);let a=[];for(let l of $e(t))ku(e,l,r,a,n);if(a.length>0)D(r,"children",a,e,t);return r}function Pa(e){let{attributes:t}=e;if(R(t))return t;let n={};return e.attributes=n,n}function Pu(e,t,n,r){for(let s of rt(t)){let o=In(s),i=s.getTag();if(i==="fn")throw F(e,s,"A function has a block form: (fn)name, on a line of its own");let a=ln(e,s);if(o.startsWith(".")||o.startsWith("$")){let l=o.startsWith(".")?o.slice(1):o;D(n,l,a,e,s),ae(e,`${r}/${Ae(l)}`,s)}else if(o.startsWith("on")&&i==="ref")D(n,o,a,e,s),ae(e,`${r}/${Ae(o)}`,s);else if(o.startsWith("on")&&ja.has(o))throw F(e,s,`${o} needs (ref)"pointer", or a function on a line of its own: (fn)${o} "…"`);else D(Pa(n),o,a,e,s),ae(e,`${r}/attributes/${Ae(o)}`,s)}}function ku(e,t,n,r,s){let o=t.getName(),i=an(e,t),a=(l)=>`${s}/${Ae(l)}`;if(i==="fn"||i==="on"){if(!o.startsWith("on"))throw F(e,t,`(${i}) in an element marks a handler, and "${o}" is not one`);D(n,o,ve(e,t,a(o)),e,t)}else if(o==="script")throw F(e,t,'"script" is reserved. A <script> element is $element "script"');else if(o==="state")D(n,"state",ve(e,t,a("state")),e,t);else if(o==="style")D(n,"style",Br(e,t,a("style")),e,t);else if(o==="attributes"){let l=ve(e,t,a("attributes"));if(R(l))for(let[c,u]of Object.entries(l))D(Pa(n),c,u,e,t);else D(n,"attributes",l,e,t)}else if(o.startsWith(".")){let l=o.slice(1);D(n,l,_u(e,l,t,a(l)),e,t)}else if(o.startsWith("$")&&o!=="$array"&&o!=="$element")D(n,o,ve(e,t,a(o)),e,t);else{if(Tu.has(o))throw F(e,t,`"${o}" is reserved here`);r.push(_a(e,t,`${s}/children/${r.length}`))}}function po(e,t){return $e(t).map((n,r)=>{let s=`/$head/${r}`;return n.getName()==="-"?ve(e,n,s):fo(e,n,s)})}function mo(e){let t=ju.exec(e);if(t)throw new ie(`A raw control character (U+${t[0].codePointAt(0)?.toString(16).toUpperCase().padStart(4,"0")}) cannot be in a Jx Notation file. Escape it, as \\u{1b}`,sn(e,t.index));try{return ht(e,{storeLocations:!0})}catch(n){let s=(n instanceof M?n.errors?.[0]??n:null)?.start,o=n instanceof Error?n.message:String(n);throw new ie(o.split(`
48
+ `)[0]??o,s?sn(e,s.offset):null)}}function ka(e){if(Ht(e.text)==="project")throw new ie('This is a project file: its first node is "project". A document has an element there, and a <project> element is $element "project"');let n=mo(e.text),r={},s=null;for(let o of n.nodes){let i=o.getName();if(i==="$head"&&o.getTag()===null)D(r,i,po(e,o),e,o);else if(i.startsWith("$")&&i!=="$array"&&i!=="$element")D(r,i,ve(e,o,`/${Ae(i)}`),e,o),ae(e,`/${Ae(i)}`,o);else if(s)throw F(e,o,"A document has one root element, and this is a second");else s=o}if(s){let o=s.getName()==="$array"?Ra(e,s,""):fo(e,s,"");for(let[i,a]of Object.entries(o))D(r,i,a,e,s)}return Ut(r)}function Dn(e,t){try{return ka({spans:null,text:e})}catch(n){throw t!==void 0&&n instanceof ie?n.inFile(t):n}}function go(e){let t=new Map;return{document:ka({spans:t,text:e}),spans:t}}var ju,vu,Tu;var Mn=A(()=>{Wr();U();An();Nn();on();va();ju=/(?![\t\n\v\f\r])\p{Cc}/u,vu=new Set(["array","fn","object","on","ref"]),Tu=new Set(["attributes","script","state","style"])});function Fn(e){return e.toLowerCase().endsWith(".jxn")}function Ln(e){return e.endsWith(".json")||Fn(e)}function Wn(e,t){return Fn(t)?Dn(e,t):Xi(e,t)}var ho=A(()=>{An();Mn()});function Mu(e){let t={comments:0,escapes:[]},n=Du.exec(e)?.[0].length??0;while(n<e.length)if(e.startsWith("//",n)){t.comments+=1;let r=e.indexOf(`
49
+ `,n);n=r===-1?e.length:r}else if(e.startsWith("/*",n)){t.comments+=1;let r=e.indexOf("*/",n+2);n=r===-1?e.length:r+2}else if(e.startsWith("/-",n))t.comments+=1,n+=2;else if(e.charAt(n)==="#"&&/^#+"/u.test(e.slice(n,n+16))){let[r=""]=/^#+/u.exec(e.slice(n))??[],s=n+r.length,o=e.startsWith('"""',s)?'"""':'"',i=e.indexOf(o+r,s+o.length);n=i===-1?e.length:i+o.length+r.length}else if(e.charAt(n)==='"'){let r=e.startsWith('"""',n)?'"""':'"';n+=r.length;while(n<e.length&&!e.startsWith(r,n))if(e.charAt(n)==="\\")t.escapes.push(n),n+=2;else n+=1;n+=r.length}else n+=1;return t}function Fu(e){return Mu(e).escapes.flatMap((t)=>{let n=Iu.get(e.charAt(t+1));return n?[{...sn(e,t),message:n}]:[]})}var Iu,Du;var Ia=A(()=>{on();Iu=new Map([["b",String.raw`\b in a quoted string is a backspace, not a word boundary. Use a raw string, like #"…"#, if this is a pattern.`],["s",String.raw`\s in a quoted string is a space, not whitespace. Use a raw string, like #"…"#, if this is a pattern.`]]),Du=/^\uFEFF?\s*\/-[^\S\n]*kdl-version[^\S\n]+\d+[^\S\n]*(?:\n|$)/u});function cn(e,t=!1){if(Array.isArray(e))return`[${e.map((s)=>cn(s,t)).join(",")}]`;if(!R(e))return e===void 0?"null":JSON.stringify(e);return`{${(t?Object.keys(e):Object.keys(e).toSorted()).map((s)=>`${JSON.stringify(s)}:${cn(e[s],t||s==="style")}`).join(",")}}`}function Lu(e,t){let n=e;for(let r of t.split("/").slice(1)){let s=r.replaceAll("~1","/").replaceAll("~0","~");if(Array.isArray(n))n=n[Number(s)];else n=R(n)?n[s]:void 0}return n}function Wu({spans:e}){let t=new Map;for(let[n,r]of e){let s=t.get(r.start);if(s===void 0||n.length<s.length)t.set(r.start,n)}return t}function Da(e,t){let n=Wu(e),r=new Map;for(let[s,o]of n)r.set(s,cn(Lu(e.document,o)));return{meanings:r,pointers:n,text:t}}function st(e){let t=Zt(e);return{end:t?.end.offset??0,start:t?.start.offset??0}}function Ur(e,t){let{end:n,start:r}=st(e);return t.slice(r,n).trimEnd()}function Hr(e,t){let{end:n,start:r}=st(e);return`${e.leading??" "}${t.slice(r,n).trimEnd()}`}function So(e){return e.children?.nodes??[]}function xo(e){let t=e.entries.map((o)=>`${o.getName()??""}=(${o.getTag()??""})${JSON.stringify(o.getValue())}`),n=t.filter((o)=>!o.startsWith("=")).toSorted(),r=t.filter((o)=>o.startsWith("=")),s=So(e).map((o)=>xo(o));return`(${e.getTag()??""})${e.getName()} ${[...n,...r].join(" ")} {${s.join(";")}}`}function yo(e,t,n){if(xo(t)===xo(n))return!0;let r=e.previous.meanings.get(st(t).start);return r!==void 0&&r===e.next.meanings.get(st(n).start)}function Ma(e){let n=e.entries.filter((r)=>["$id","key"].includes(r.getName()??"")).map((r)=>JSON.stringify(r.getValue()));return`(${e.getTag()??""})${e.getName()} ${n.join(" ")}`}function Fa(e,t,n){let r=e.length+1,s=t.length+1,o=new Int32Array(r*s);for(let c=e.length-1;c>=0;c-=1)for(let u=t.length-1;u>=0;u-=1){let f=e[c],p=t[u];o[c*s+u]=f!==void 0&&p!==void 0&&n(f,p)?(o[(c+1)*s+u+1]??0)+1:Math.max(o[(c+1)*s+u]??0,o[c*s+u+1]??0)}let i=[],a=0,l=0;while(a<e.length&&l<t.length){let c=e[a],u=t[l];if(c!==void 0&&u!==void 0&&n(c,u))i.push([a,l]),a+=1,l+=1;else if((o[(a+1)*s+l]??0)>=(o[a*s+l+1]??0))a+=1;else l+=1}return i}function Vu(e,t,n){let r=new Map,s=new Set,o=(c,u)=>{let f=t[c];if(f)r.set(u,f),s.add(c)},i=Fa(t,n,(c,u)=>yo(e,c,u)),a=0,l=0;for(let[c,u]of[...i,[t.length,n.length]]){let f=Fa(t.slice(a,c),n.slice(l,u),(p,d)=>Ma(p)===Ma(d));for(let[p,d]of f)o(a+p,l+d);if(c<t.length)o(c,u);a=c+1,l=u+1}for(let[c,u]of n.entries())if(!r.has(c)){let f=t.findIndex((p,d)=>!s.has(d)&&yo(e,p,u));if(f!==-1)o(f,c)}return r}function bo(e){let t=e.leading??"";return t.slice(t.lastIndexOf(`
50
+ `)+1)}function Bu(e,t,n){return e.split(`
42
51
  `).map((r,s)=>s>0&&r.startsWith(t)?n+r.slice(t.length):r).join(`
43
- `)}function Yc(e,t,n){let r=[...n],s=(i)=>{let c=i.getName(),a=r.findIndex((l)=>l.getName()===c);return a===-1?void 0:r.splice(a,1)[0]},o="";for(let i of t.entries){let c=s(i);if(c){let a=c.getTag()===i.getTag()&&c.getValue()===i.getValue();o+=a?Pr(i,e.previous.text):`${i.leading??" "}${Pr(c,e.next.text).trimStart()}`}}for(let i of r)o+=` ${Pr(i,e.next.text).trimStart()}`;return o}function Xc(e,t,n){let r=new Map;for(let o of eo(t)){let i=e.previous.pointers.get(rt(o).start);if(i!==void 0)r.set(i,o)}let s=new Map;for(let o of n.entries){let i=e.next.pointers.get(rt(o).start),c=i===void 0?void 0:r.get(i);if(c&&o.getName()!==null)s.set(c,o)}return s}function Zc(e,t,n){let{text:r}=e.previous,s=Pr(n,e.next.text).trimStart().slice(`${n.getName()}=`.length),[o]=t.entries;if(o?.getName()===null&&t.entries.length===1&&!t.children){if(o.getValue()===n.getValue()&&o.getTag()===n.getTag())return kr(t,r);return`${Qs(t,r)}${o.leading??" "}${s}`}return`${Qs(t,r)} ${s}`}function Qs(e,t){let{start:n}=rt(e),[r]=e.entries;if(r)return t.slice(n,rt(r).start-(r.leading??"").length);let s=e.children&&Gt(e.children);if(s)return t.slice(n,s.start.offset-1).trimEnd();return kr(e,t)}function Qc(e,t,n,r){let s=Xc(e,t,n),o=new Set(s.values()),i=n.entries.filter((d)=>!o.has(d)),c=`${Qs(t,e.previous.text)}${Yc(e,t,i)}`,a=eo(n);if(a.length===0&&s.size===0)return c;let l=a[0]?to(a[0]):`${r} `,u=t.children,f=t.beforeChildren===""?" ":t.beforeChildren??" ";if(u&&u.nodes.length>0&&tu(u,e.previous.text,t)){let d=`${r}${eu(u,r)}`;return`${c}${f}{${fa(e,u,a,d,l,s)}}`}let p=a.map((d)=>ua(e,d,l,`${r} `));return`${c}${f}{
44
- ${p.join("")}${r}}`}function eu(e,t){let[n]=e.nodes,r=n?to(n):"";return r.startsWith(t)?r.slice(t.length):" "}function tu(e,t,n){let{end:r,start:s}=rt(n),[o]=e.nodes;return o!==void 0&&(o.leading??"").includes(`
52
+ `)}function Hu(e,t,n){let r=[...n],s=(i)=>{let a=i.getName(),l=r.findIndex((c)=>c.getName()===a);return l===-1?void 0:r.splice(l,1)[0]},o="";for(let i of t.entries){let a=s(i);if(a){let l=a.getTag()===i.getTag()&&a.getValue()===i.getValue();o+=l?Hr(i,e.previous.text):`${i.leading??" "}${Hr(a,e.next.text).trimStart()}`}}for(let i of r)o+=` ${Hr(i,e.next.text).trimStart()}`;return o}function Uu(e,t,n){let r=new Map;for(let o of So(t)){let i=e.previous.pointers.get(st(o).start);if(i!==void 0)r.set(i,o)}let s=new Map;for(let o of n.entries){let i=e.next.pointers.get(st(o).start),a=i===void 0?void 0:r.get(i);if(a&&o.getName()!==null)s.set(a,o)}return s}function qu(e,t,n){let{text:r}=e.previous,s=Hr(n,e.next.text).trimStart().slice(`${n.getName()}=`.length),[o]=t.entries;if(o?.getName()===null&&t.entries.length===1&&!t.children){if(o.getValue()===n.getValue()&&o.getTag()===n.getTag())return Ur(t,r);return`${$o(t,r)}${o.leading??" "}${s}`}return`${$o(t,r)} ${s}`}function $o(e,t){let{start:n}=st(e),[r]=e.entries;if(r)return t.slice(n,st(r).start-(r.leading??"").length);let s=e.children&&Zt(e.children);if(s)return t.slice(n,s.start.offset-1).trimEnd();return Ur(e,t)}function zu(e,t,n,r){let s=Uu(e,t,n),o=new Set(s.values()),i=n.entries.filter((d)=>!o.has(d)),a=`${$o(t,e.previous.text)}${Hu(e,t,i)}`,l=So(n);if(l.length===0&&s.size===0)return a;let c=l[0]?bo(l[0]):`${r} `,u=t.children,f=t.beforeChildren===""?" ":t.beforeChildren??" ";if(u&&u.nodes.length>0&&Gu(u,e.previous.text,t)){let d=`${r}${Ku(u,r)}`;return`${a}${f}{${Wa(e,u,l,d,c,s)}}`}let p=l.map((d)=>La(e,d,c,`${r} `));return`${a}${f}{
53
+ ${p.join("")}${r}}`}function Ku(e,t){let[n]=e.nodes,r=n?bo(n):"";return r.startsWith(t)?r.slice(t.length):" "}function Gu(e,t,n){let{end:r,start:s}=st(n),[o]=e.nodes;return o!==void 0&&(o.leading??"").includes(`
45
54
  `)&&t.slice(s,r).includes(`
46
- `)}function ua(e,t,n,r){return`${r}${Gc(kr(t,e.next.text),n,r)}
47
- `}function fa(e,t,n,r,s,o){let i=t.nodes.filter((m)=>!o.has(m)),c=Kc(e,i,n),a=t.nodes[0]?.leading??"",l=a.indexOf(`
48
- `),u=l===-1?"":a.slice(0,l+1),f=u,p=-1,d=()=>{if(f!==""&&!f.endsWith(`
55
+ `)}function La(e,t,n,r){return`${r}${Bu(Ur(t,e.next.text),n,r)}
56
+ `}function Wa(e,t,n,r,s,o){let i=t.nodes.filter((m)=>!o.has(m)),a=Vu(e,i,n),l=t.nodes[0]?.leading??"",c=l.indexOf(`
57
+ `),u=c===-1?"":l.slice(0,c+1),f=u,p=-1,d=()=>{if(f!==""&&!f.endsWith(`
49
58
  `)&&!f.endsWith(";"))f+=`
50
- `},h=(m,x)=>{let E=t.nodes.indexOf(m),O=E===p+1||E>p;p=Math.max(p,E);let J=m===t.nodes[0]?a.slice(u.length):m.leading??"";if(O&&(J.includes(`
51
- `)||f===u||f.endsWith(";"))){f+=`${J}${x}${m.trailing??""}`;return}if(!f.endsWith(`
59
+ `},h=(m,x)=>{let w=t.nodes.indexOf(m),N=w===p+1||w>p;p=Math.max(p,w);let E=m===t.nodes[0]?l.slice(u.length):m.leading??"";if(N&&(E.includes(`
60
+ `)||f===u||f.endsWith(";"))){f+=`${E}${x}${m.trailing??""}`;return}if(!f.endsWith(`
52
61
  `))f+=`
53
- `;let C=(m.trailing??"").replace(/^;/u,"");f+=`${J.includes(`
54
- `)?J:r}${x}${C}`},g=(m)=>{for(let[x,E]of t.nodes.entries()){let O=o.get(E);if(O&&x<m&&x>p)d(),h(E,Zc(e,E,O))}};for(let[m,x]of n.entries()){let E=c.get(m);if(E){g(t.nodes.indexOf(E)),d();let O=Zs(e,E,x)?kr(E,e.previous.text):Qc(e,E,x,to(E));h(E,O)}else d(),f+=ua(e,x,s,r)}return g(t.nodes.length),`${f}${t.trailing??""}`}function Ir(e,t,n){let r;try{r=n(e)}catch{return t}let s=n(t),o=on(s.document);if(on(r.document)===o)return e;let i={next:aa(s,t),previous:aa(r,e)},c=fa(i,gt(e,{storeLocations:!0}),gt(t,{storeLocations:!0}).nodes,"","",new Map);try{return on(n(c).document)===o?c:t}catch{return t}}var Mr=j(()=>{Tr();z()});function ga(e){return!/\p{Cs}/u.test(e)}function ha(e,t){try{return gt(`x ${e}`).nodes[0]?.entries[0]?.getValue()===t}catch{return!1}}function Dr(e){let t='"';for(let n of e)if(n==='"')t+=String.raw`\"`;else if(n==="\\")t+=String.raw`\\`;else if(n===`
55
- `)t+=String.raw`\n`;else if(n==="\t")t+=String.raw`\t`;else if(n==="\r")t+=String.raw`\r`;else if(ma.test(n))t+=`\\u{${n.codePointAt(0)?.toString(16)}}`;else t+=n;return`${t}"`}function xa(e,t){let n="#";while(e.includes(t+n))n+="#";return n}function su(e,t){if(nu.test(e))return null;let n=xa(e,'"""'),r=`${t}${ue}`,s=e.split(`
62
+ `;let O=(m.trailing??"").replace(/^;/u,"");f+=`${E.includes(`
63
+ `)?E:r}${x}${O}`},g=(m)=>{for(let[x,w]of t.nodes.entries()){let N=o.get(w);if(N&&x<m&&x>p)d(),h(w,qu(e,w,N))}};for(let[m,x]of n.entries()){let w=a.get(m);if(w){g(t.nodes.indexOf(w)),d();let N=yo(e,w,x)?Ur(w,e.previous.text):zu(e,w,x,bo(w));h(w,N)}else d(),f+=La(e,x,s,r)}return g(t.nodes.length),`${f}${t.trailing??""}`}function qr(e,t,n){let r;try{r=n(e)}catch{return t}let s=n(t),o=cn(s.document);if(cn(r.document)===o)return e;let i={next:Da(s,t),previous:Da(r,e)},a=Wa(i,ht(e,{storeLocations:!0}),ht(t,{storeLocations:!0}).nodes,"","",new Map);try{return cn(n(a).document)===o?a:t}catch{return t}}var zr=A(()=>{Wr();U()});function Ua(e){return!/\p{Cs}/u.test(e)}function qa(e,t){try{return ht(`x ${e}`).nodes[0]?.entries[0]?.getValue()===t}catch{return!1}}function Kr(e){let t='"';for(let n of e)if(n==='"')t+=String.raw`\"`;else if(n==="\\")t+=String.raw`\\`;else if(n===`
64
+ `)t+=String.raw`\n`;else if(n==="\t")t+=String.raw`\t`;else if(n==="\r")t+=String.raw`\r`;else if(Ha.test(n))t+=`\\u{${n.codePointAt(0)?.toString(16)}}`;else t+=n;return`${t}"`}function za(e,t){let n="#";while(e.includes(t+n))n+="#";return n}function Zu(e,t){if(Yu.test(e))return null;let n=za(e,'"""'),r=`${t}${ue}`,s=e.split(`
56
65
  `).map((i)=>i===""?"":r+i),o=`${n}"""
57
66
  ${s.join(`
58
67
  `)}
59
- ${r}"""${n}`;return ha(o,e)?o:null}function ro(e,t,n){if(!ga(e))throw new ie(`${n} holds a lone surrogate, which Jx Notation has no way to spell`);if(da.test(e))return e;if(e.includes(`
60
- `)){let r=su(e,t);if(r)return r}else if((e.includes("\\")||e.includes('"'))&&!ma.test(e)){let r=xa(e,'"'),s=`${r}"${e}"${r}`;if(ha(s,e))return s}return Dr(e)}function $e(e,t){if(!ga(e))throw new ie(`${t} is a key with a lone surrogate, which Jx Notation cannot spell`);return da.test(e)?e:Dr(e)}function fe(e,t,n){if(e===null)return"#null";if(e===!0)return"#true";if(e===!1)return"#false";if(se(e))return Object.is(e,-0)?"-0":String(e);if(b(e))return ro(e,t,n);return Mn(e)?`(ref)${Dr(e.$ref)}`:null}function ya(e){if(!ve(e)||e.$prototype!=="Function")return!1;let{$prototype:t,body:n,parameters:r,...s}=e,o=Object.values(s).every((l)=>fe(l,"","")!==null),i=r===void 0||Array.isArray(r)&&r.length>0&&r.every((l)=>b(l))&&n!==void 0,c=n===void 0||b(n)||Array.isArray(n),a=Array.isArray(n)&&n.length===0;return o&&i&&c&&!a}function $a(e,t,n,r){let{$prototype:s,body:o,parameters:i,...c}=t,a=[`${n}(fn)${$e(e,r)}`];for(let[l,u]of Object.entries(c))a.push(`${$e(l,r)}=${fe(u,n,X(r,l))}`);if(Array.isArray(i))for(let l of i)a.push(ro(String(l),n,X(r,"parameters")));if(b(o))a.push(ro(o,n,X(r,"body")));else if(Array.isArray(o))return[`${a.join(" ")} {`,...o.flatMap((l,u)=>Ae("-",l,n+ue,X(X(r,"body"),u))),`${n}}`];return[a.join(" ")]}function Ae(e,t,n,r){let s=$e(e,r),o=n+s,i=fe(t,n,r);if(i!==null)return[`${o} ${i}`];if(ya(t))return $a(e,t,n,r);if(Array.isArray(t)){if(t.length===0)return[`${n}(array)${s}`];let u=t.map((p,d)=>fe(p,n,X(r,d)));if(t.length>1&&u.every((p)=>p!==null&&!p.includes(`
61
- `))){let p=`${o} ${u.join(" ")}`;if(p.length<=no)return[p]}return[`${o} {`,...t.flatMap((p,d)=>Ae("-",p,n+ue,X(r,d))),`${n}}`]}let c=ve(t)?Object.entries(t):[];if(c.length===0)return[`${o} {}`];let a=c.every(([u])=>u==="-")?`${n}(object)${s}`:o,l=c.map(([u,f])=>{let p=fe(f,n,X(r,u));return p===null||p.includes(`
62
- `)?null:`${$e(u,r)}=${p}`});if(l.every((u)=>u!==null)){let u=`${a} ${l.join(" ")}`;if(u.length<=no)return[u]}return[`${a} {`,...c.flatMap(([u,f])=>Ae(u,f,n+ue,X(r,u))),`${n}}`]}function Sa(e,t,n,r){let s=Object.entries(t),o=n+$e(e,r);if(s.length===0)return[`${o} {}`];let i=[],c=0;for(let[p,d]of s){let h=fe(d,n,X(r,p));if(h===null||h.includes(`
63
- `))break;i.push(`${$e(p,r)}=${h}`),c+=1}let a=`${o} ${i.join(" ")}`,l=i.length>0&&a.length<=no,u=l?c:0,f=s.slice(u).flatMap(([p,d])=>{if(ve(d)&&!Mn(d))return Sa(p,d,n+ue,X(r,p));return Ae(p,d,n+ue,X(r,p))});if(l&&f.length===0)return[a];return[`${l?a:o} {`,...f,`${n}}`]}function ou(e){if(!ve(e)||e.$prototype!=="Array"||!ve(e.map))return!1;let{$prototype:t,map:n,...r}=e;return Object.values(r).every((s)=>{let o=fe(s,"","");return o!==null&&!o.includes(`
64
- `)})}function iu(e,t,n){let{$prototype:r,map:s,...o}=e,i=[`${t}$array`];for(let[c,a]of Object.entries(o))i.push(`${$e(c,n)}=${fe(a,t,X(n,c))}`);return[`${i.join(" ")} {`,...In(s??null,t+ue,X(n,"map")),`${t}}`]}function In(e,t,n){let r=fe(e,t,n);if(r!==null)return[`${t}- ${r}`];if(ou(e))return iu(e,t,n);if(ve(e))return so(e,t,n);throw new ie(`${n} is a list inside a list of children, which has no spelling`)}function au(e,t,n){let{tagName:r}=e;if(!b(r))return`${t}$element`;if(ru.has(r)||r.startsWith("$")||r.startsWith("."))return`${t}$element ${Dr(r)}`;return t+$e(r,n)}function lu(e,t){return t!==null&&!t.includes(`
65
- `)&&!e.startsWith("on")&&!e.startsWith("$")&&!e.startsWith(".")}function so(e,t,n){let r=[au(e,t,n)],s=t+ue,o=[],i={},c=null;for(let[a,l]of Object.entries(e)){let u=X(n,a);if(a==="tagName"&&b(l))continue;if(a==="children")continue;if(a==="textContent"){let f=fe(l,t,u);if(f===null||!b(e.tagName))pa(r,o,a,l,s,t,u);else c=f}else if(a==="attributes"&&ve(l))for(let[f,p]of Object.entries(l)){let d=fe(p,t,X(u,f));if(lu(f,d))r.push(`${$e(f,u)}=${d}`);else i[f]=p}else if(a==="state")o.push(...Ae("state",l,s,u));else if(a==="style"&&ve(l))o.push(...Sa("style",l,s,u));else if(a.startsWith("on")&&Mn(l))r.push(`${$e(a,u)}=${fe(l,t,u)}`);else if(a.startsWith("on"))o.push(...ya(l)?$a(a,l,s,u):Ae(a,l,s,u).map((f,p)=>p===0?f.replace(s,`${s}(on)`):f));else if(a.startsWith("$")){let f=fe(l,t,u);if(f===null||f.includes(`
66
- `))o.push(...Ae(a,l,s,u));else r.push(`${$e(a,u)}=${f}`)}else pa(r,o,a,l,s,t,u)}if(Object.keys(i).length>0)o.push(...Ae("attributes",i,s,X(n,"attributes")));if(o.push(...cu(e.children,s,X(n,"children"))),c!==null)r.push(c);return o.length===0?[r.join(" ")]:[`${r.join(" ")} {`,...o,`${t}}`]}function cu(e,t,n){if(e===void 0)return[];if(Array.isArray(e)){if(e.length===0)return[`${t}(array).children`];return e.flatMap((s,o)=>In(s,t,X(n,o)))}let r=fe(e,t,n);if(r!==null)return[`${t}.children ${r}`];return[`${t}.children {`,...In(e,t+ue,n),`${t}}`]}function pa(e,t,n,r,s,o,i){let c=$e(`.${n}`,i);if(n==="map"&&ve(r)){t.push(`${s}${c} {`,...In(r,s+ue,i),`${s}}`);return}if(n==="cases"&&ve(r)){t.push(`${s}${c} {`);for(let[l,u]of Object.entries(r))t.push(`${s}${ue}${$e(l,i)} {`,...In(u,s+ue+ue,X(i,l)),`${s}${ue}}`);t.push(`${s}}`);return}let a=fe(r,o,i);if(a===null||a.includes(`
67
- `))t.push(...Ae(`.${n}`,r,s,i));else e.push(`${c}=${a}`)}function ba(e,t){return["$head {",...e.flatMap((n,r)=>ve(n)&&!Mn(n)&&b(n.tagName)&&!n.$ref?so(n,t,`/$head/${r}`):Ae("-",n,t,`/$head/${r}`)),"}"]}function uu(e){let{document:t,spans:n}=Gs(e);return{document:D(t)?t:null,spans:n}}function oo(e,t){let n=fu(e);return t===void 0?n:Ir(t,n,uu)}function fu(e){if(!D(e))throw new ie("A document is an object");let t=e,n=["/- kdl-version 2"],r={};for(let[s,o]of Object.entries(t))if(s==="$head"&&Array.isArray(o))n.push(...ba(o,ue));else if(s==="$head")n.push(`(object)${Ae(s,o,"","/$head").join(`
68
- `)}`);else if(s.startsWith("$"))n.push(...Ae(s,o,"",X("",s)));else r[s]=o;if(Object.keys(r).length>0)n.push("",...so(r,"",""));return`${n.join(`
68
+ ${r}"""${n}`;return qa(o,e)?o:null}function Eo(e,t,n){if(!Ua(e))throw new ie(`${n} holds a lone surrogate, which Jx Notation has no way to spell`);if(Ba.test(e))return e;if(e.includes(`
69
+ `)){let r=Zu(e,t);if(r)return r}else if((e.includes("\\")||e.includes('"'))&&!Ha.test(e)){let r=za(e,'"'),s=`${r}"${e}"${r}`;if(qa(s,e))return s}return Kr(e)}function Se(e,t){if(!Ua(e))throw new ie(`${t} is a key with a lone surrogate, which Jx Notation cannot spell`);return Ba.test(e)?e:Kr(e)}function fe(e,t,n){if(e===null)return"#null";if(e===!0)return"#true";if(e===!1)return"#false";if(re(e))return Object.is(e,-0)?"-0":String(e);if(S(e))return Eo(e,t,n);return Bn(e)?`(ref)${Kr(e.$ref)}`:null}function Ka(e){if(!Te(e)||e.$prototype!=="Function")return!1;let{$prototype:t,body:n,parameters:r,...s}=e,o=Object.values(s).every((c)=>fe(c,"","")!==null),i=r===void 0||Array.isArray(r)&&r.length>0&&r.every((c)=>S(c))&&n!==void 0,a=n===void 0||S(n)||Array.isArray(n),l=Array.isArray(n)&&n.length===0;return o&&i&&a&&!l}function Ga(e,t,n,r){let{$prototype:s,body:o,parameters:i,...a}=t,l=[`${n}(fn)${Se(e,r)}`];for(let[c,u]of Object.entries(a))l.push(`${Se(c,r)}=${fe(u,n,Z(r,c))}`);if(Array.isArray(i))for(let c of i)l.push(Eo(String(c),n,Z(r,"parameters")));if(S(o))l.push(Eo(o,n,Z(r,"body")));else if(Array.isArray(o))return[`${l.join(" ")} {`,...o.flatMap((c,u)=>Oe("-",c,n+ue,Z(Z(r,"body"),u))),`${n}}`];return[l.join(" ")]}function Oe(e,t,n,r){let s=Se(e,r),o=n+s,i=fe(t,n,r);if(i!==null)return[`${o} ${i}`];if(Ka(t))return Ga(e,t,n,r);if(Array.isArray(t)){if(t.length===0)return[`${n}(array)${s}`];let u=t.map((p,d)=>fe(p,n,Z(r,d)));if(t.length>1&&u.every((p)=>p!==null&&!p.includes(`
70
+ `))){let p=`${o} ${u.join(" ")}`;if(p.length<=wo)return[p]}return[`${o} {`,...t.flatMap((p,d)=>Oe("-",p,n+ue,Z(r,d))),`${n}}`]}let a=Te(t)?Object.entries(t):[];if(a.length===0)return[`${o} {}`];let l=a.every(([u])=>u==="-")?`${n}(object)${s}`:o,c=a.map(([u,f])=>{let p=fe(f,n,Z(r,u));return p===null||p.includes(`
71
+ `)?null:`${Se(u,r)}=${p}`});if(c.every((u)=>u!==null)){let u=`${l} ${c.join(" ")}`;if(u.length<=wo)return[u]}return[`${l} {`,...a.flatMap(([u,f])=>Oe(u,f,n+ue,Z(r,u))),`${n}}`]}function Ya(e,t,n,r){let s=Object.entries(t),o=n+Se(e,r);if(s.length===0)return[`${o} {}`];let i=[],a=0;for(let[p,d]of s){let h=fe(d,n,Z(r,p));if(h===null||h.includes(`
72
+ `))break;i.push(`${Se(p,r)}=${h}`),a+=1}let l=`${o} ${i.join(" ")}`,c=i.length>0&&l.length<=wo,u=c?a:0,f=s.slice(u).flatMap(([p,d])=>{if(Te(d)&&!Bn(d))return Ya(p,d,n+ue,Z(r,p));return Oe(p,d,n+ue,Z(r,p))});if(c&&f.length===0)return[l];return[`${c?l:o} {`,...f,`${n}}`]}function Qu(e){if(!Te(e)||e.$prototype!=="Array"||!Te(e.map))return!1;let{$prototype:t,map:n,...r}=e;return Object.values(r).every((s)=>{let o=fe(s,"","");return o!==null&&!o.includes(`
73
+ `)})}function ef(e,t,n){let{$prototype:r,map:s,...o}=e,i=[`${t}$array`];for(let[a,l]of Object.entries(o))i.push(`${Se(a,n)}=${fe(l,t,Z(n,a))}`);return[`${i.join(" ")} {`,...Vn(s??null,t+ue,Z(n,"map")),`${t}}`]}function Vn(e,t,n){let r=fe(e,t,n);if(r!==null)return[`${t}- ${r}`];if(Qu(e))return ef(e,t,n);if(Te(e))return Jo(e,t,n);throw new ie(`${n} is a list inside a list of children, which has no spelling`)}function tf(e,t,n){let{tagName:r}=e;if(!S(r))return`${t}$element`;if(Xu.has(r)||r.startsWith("$")||r.startsWith("."))return`${t}$element ${Kr(r)}`;return t+Se(r,n)}function nf(e,t){return t!==null&&!t.includes(`
74
+ `)&&!e.startsWith("on")&&!e.startsWith("$")&&!e.startsWith(".")}function Jo(e,t,n){let r=[tf(e,t,n)],s=t+ue,o=[],i={},a=null;for(let[l,c]of Object.entries(e)){let u=Z(n,l);if(l==="tagName"&&S(c))continue;if(l==="children")continue;if(l==="textContent"){let f=fe(c,t,u);if(f===null||!S(e.tagName))Va(r,o,l,c,s,t,u);else a=f}else if(l==="attributes"&&Te(c))for(let[f,p]of Object.entries(c)){let d=fe(p,t,Z(u,f));if(nf(f,d))r.push(`${Se(f,u)}=${d}`);else i[f]=p}else if(l==="state")o.push(...Oe("state",c,s,u));else if(l==="style"&&Te(c))o.push(...Ya("style",c,s,u));else if(l.startsWith("on")&&Bn(c))r.push(`${Se(l,u)}=${fe(c,t,u)}`);else if(l.startsWith("on"))o.push(...Ka(c)?Ga(l,c,s,u):Oe(l,c,s,u).map((f,p)=>p===0?f.replace(s,`${s}(on)`):f));else if(l.startsWith("$")){let f=fe(c,t,u);if(f===null||f.includes(`
75
+ `))o.push(...Oe(l,c,s,u));else r.push(`${Se(l,u)}=${f}`)}else Va(r,o,l,c,s,t,u)}if(Object.keys(i).length>0)o.push(...Oe("attributes",i,s,Z(n,"attributes")));if(o.push(...rf(e.children,s,Z(n,"children"))),a!==null)r.push(a);return o.length===0?[r.join(" ")]:[`${r.join(" ")} {`,...o,`${t}}`]}function rf(e,t,n){if(e===void 0)return[];if(Array.isArray(e)){if(e.length===0)return[`${t}(array).children`];return e.flatMap((s,o)=>Vn(s,t,Z(n,o)))}let r=fe(e,t,n);if(r!==null)return[`${t}.children ${r}`];return[`${t}.children {`,...Vn(e,t+ue,n),`${t}}`]}function Va(e,t,n,r,s,o,i){let a=Se(`.${n}`,i);if(n==="map"&&Te(r)){t.push(`${s}${a} {`,...Vn(r,s+ue,i),`${s}}`);return}if(n==="cases"&&Te(r)){t.push(`${s}${a} {`);for(let[c,u]of Object.entries(r))t.push(`${s}${ue}${Se(c,i)} {`,...Vn(u,s+ue+ue,Z(i,c)),`${s}${ue}}`);t.push(`${s}}`);return}let l=fe(r,o,i);if(l===null||l.includes(`
76
+ `))t.push(...Oe(`.${n}`,r,s,i));else e.push(`${a}=${l}`)}function Xa(e,t){return["$head {",...e.flatMap((n,r)=>Te(n)&&!Bn(n)&&S(n.tagName)&&!n.$ref?Jo(n,t,`/$head/${r}`):Oe("-",n,t,`/$head/${r}`)),"}"]}function sf(e){let{document:t,spans:n}=go(e);return{document:R(t)?t:null,spans:n}}function No(e,t){let n=of(e);return t===void 0?n:qr(t,n,sf)}function of(e){if(!R(e))throw new ie("A document is an object");let t=e,n=["/- kdl-version 2"],r={};for(let[s,o]of Object.entries(t))if(s==="$head"&&Array.isArray(o))n.push(...Xa(o,ue));else if(s==="$head")n.push(`(object)${Oe(s,o,"","/$head").join(`
77
+ `)}`);else if(s.startsWith("$"))n.push(...Oe(s,o,"",Z("",s)));else r[s]=o;if(Object.keys(r).length>0)n.push("",...Jo(r,"",""));return`${n.join(`
69
78
  `)}
70
- `}var ue=" ",no=100,da,ma,nu,ru,ve=(e)=>D(e),Mn=(e)=>ve(e)&&b(e.$ref)&&Object.keys(e).length===1,X=(e,t)=>`${e}/${String(t).replaceAll("~","~0").replaceAll("/","~1")}`;var io=j(()=>{Tr();z();nn();Rn();Mr();da=/^(?![-+]?\.?\d)(?!(?:true|false|null|inf|-inf|nan)$)[^\s\\/(){};[\]"#=,\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+$/u,ma=/[\p{Cc}\p{Zl}\p{Zp}‎‏‪-‮⁦-⁩]/u,nu=/(?!\n)\p{Cc}|[\p{Zl}\p{Zp}‎‏‪-‮⁦-⁩]/u,ru=new Set(["-","attributes","script","state","style"])});function mu(e,t,n){if(rn(e,t)!==null)throw F(e,t,`"project" names the file's kind, and takes no annotation`);let r=tt(e,t);if(r.length>1||nt(t).length>0||ye(t).length>0)throw F(e,t,`"project" holds one value, the project's name, and nothing else`);if(r[0]!==void 0)I(n,"name",r[0],e,t),ae(e,"/name",t)}function gu(e,t,n){let r=t.getName(),s=`/${Ne(r)}`,o=t.getTag()===null,i;if(r==="$head"&&o)i=zs(e,t),ae(e,s,t);else if(du.has(r)&&o)i=_r(e,t,s);else i=je(e,t,s);I(n,r,i,e,t)}function hu(e){if(Wt(e.text)==="document")throw new ie('A project file declares itself: its first node, after any $ metadata, is project "<name>"');let t=Ks(e.text),n={},r=!1;for(let s of t.nodes)if(s.getName()===pu){if(r)throw F(e,s,'"project" is written twice, and a file declares one project');mu(e,s,n),r=!0}else gu(e,s,n);return Vt(n)}function ao(e,t){try{return hu({spans:null,text:e})}catch(n){throw t!==void 0&&n instanceof ie?n.inFile(t):n}}var pu="project",du;var lo=j(()=>{z();Sn();$n();nn();Rn();Mr();io();du=new Set(["$media","style"])});var Fr=j(()=>{$n();Ys();nn();ia();Rn();Mr();io();lo()});function Na(e){if(!b(e))return null;let[t,...n]=e.split(";"),r=(t??"").indexOf("/");if(r===-1)return null;let s=(t??"").slice(0,r).trim().toLowerCase(),o=(t??"").slice(r+1).trim().toLowerCase();if(!wa.test(s)||!wa.test(o))return null;let i=o.lastIndexOf("+"),c=i===-1?null:o.slice(i+1),a=i===-1?o:o.slice(0,i);if(c==="")return null;let l=a.indexOf("."),u=l===-1?null:a.slice(0,l),f=u!==null&&yu.has(u)?u:null,p=f===null?a:a.slice(f.length+1);if(p==="")return null;let d={};for(let h of n){let g=h.indexOf("=");if(g===-1)return null;let m=h.slice(0,g).trim().toLowerCase(),x=h.slice(g+1).trim();if(m==="")return null;if(x.startsWith('"')&&x.endsWith('"')&&x.length>=2)x=x.slice(1,-1);d[m]=x}return{parameters:d,subtype:p,suffix:c,tree:f,type:s}}function Aa(e){if(!b(e)||e.trim()==="")return"expected a media type string";if(!e.includes("/"))return`"${e}" has no "/" — a media type is type/subtype (RFC 6838 §4.2)`;if(Na(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function Oa(e){let t=Na(e);if(t===null)return null;let n=t.tree===null?"":`${t.tree}.`,r=t.suffix===null?"":`+${t.suffix}`;return`${t.type}/${n}${t.subtype}${r}`}var wa,yu,Ea="text/markdown; variant=GFM",Ja="application/yaml",jm;var Ca=j(()=>{z();wa=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,yu=new Set(["vnd","prs","x"]);jm={".jxn":"text/plain; charset=utf-8",".markdown":`${Ea}; charset=utf-8`,".md":`${Ea}; charset=utf-8`,".yaml":`${Ja}; charset=utf-8`,".yml":`${Ja}; charset=utf-8`}});function Ra(e){if(e===null)throw TypeError("A class descriptor cannot be null");return D(e)?e:{}}class Dn{name;classPath;classDef;extensions;mediaType;mediaTypeEssence;documentKinds;exportTarget;remote;studio;project;server;connector;capabilities;#t;#e=null;constructor(e,t,n,r){this.name=e,this.classPath=t,this.classDef=n,this.#t=r;let{format:s}=n;this.extensions=(s?.extensions??[]).map((o)=>o.toLowerCase()),this.mediaType=s?.mediaType??null,this.mediaTypeEssence=Oa(this.mediaType),this.documentKinds=s?.documentKinds??[],this.exportTarget=s?.exportTarget===!0,this.remote=s?.remote===!0,this.studio=n.$studio??null,this.project=n.project??null,this.server=n.server??null,this.connector=n.connector??null,this.capabilities=Su(n)}implementation(){if(!this.#e){let e=this.classDef.$implementation;if(!e)return Promise.reject(Error(`Format class "${this.name}" has no $implementation to import`));this.#e=this.#t.importModule(this.#t.resolvePath(this.classPath,e))}return this.#e}async implementationExport(){return this.#n(await this.implementation())}#n(e){let t=this.classDef.title??this.name;return e[t]??e.default?.[t]??e.default}async call(e,...t){let n=this.capabilities[e];if(!n)throw Error(`Format class "${this.name}" does not declare a "${e}" capability`);let r=this.#n(await this.implementation()),s=r?.[n.identifier];if(!Se(s)){let i=this.classDef.title??this.name;throw TypeError(`Format class "${this.name}": implementation export "${i}" has no static "${n.identifier}" method`)}return await s.call(r,...t)}async parseDocument(e,t){return await this.call("parse",e,t)}}class Lr{#t;get#e(){return[...this.#t,Ju]}constructor(e){this.#t=e;for(let t of e)if(t.extensions.includes(".jxn"))throw Error(`Format "${t.name}" claims ".jxn", which is built in`);for(let t of e){if(t.mediaType===null)continue;let n=Aa(t.mediaType);if(n!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${n}`)}for(let t of va){let n=new Map;for(let r of e){if(!r.capabilities[t])continue;for(let s of r.extensions){let o=n.get(s);if(o)throw Error(`Format conflict: "${o.name}" and "${r.name}" both claim "${s}" with the "${t}" capability`);n.set(s,r)}}}}get entries(){return this.#t}byExtension(e,t){let n=ja(e);return this.#e.find((r)=>r.extensions.includes(n)&&(!t||r.capabilities[t]))}byName(e){return this.#t.find((t)=>t.name===e)}withCapability(e){return this.#e.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let n of this.#e){if(e&&!n.documentKinds.includes(e))continue;for(let r of n.extensions)t.add(r)}return t.delete(".json"),[...t]}has(e){let t=ja(e);return this.#e.some((n)=>n.extensions.includes(t))}}function Su(e){let t={},n=e.$defs?.methods??{};for(let[r,s]of Object.entries(n)){let{role:o}=s;if(!wu(o))continue;let i={identifier:s.identifier??r,timing:s.timing??$u};if(b(s.discriminator))i.discriminator=s.discriminator;t[o]=i}return t}function wu(e){return e!==void 0&&bu.has(e)}function ja(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var va,Ta,$u,bu,Eu,Ju;var co=j(()=>{z();Ca();va=["parse","serialize","rewrite","discover","load"],Ta=[...va,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"];$u=["compiler","server"];bu=new Set(Ta);Eu={importModule:async()=>{await Promise.resolve().then(() => Fr());return{JxNotation:{parse:(n)=>Tn(n),serialize:(n)=>oo(n)}}},loadJson:()=>Promise.reject(Error("Jx Notation reads no file of its own")),resolvePath:(e,t)=>t},Ju=new Dn("jxn","",{$defs:{methods:{parse:{role:"parse"},serialize:{role:"serialize"}}},$implementation:"jxn",format:{documentKinds:["page","component"],extensions:[".jxn"]},title:"JxNotation"},Eu)});class _a{#t;#e;#n;constructor(e){this.#t=e,this.#e=e.flatMap((s)=>s.classes);let t=new Map;for(let s of e)for(let o of s.classes){let i=t.get(o.name);if(i&&i!==s.specifier)throw Error(`Extension conflict: "${i}" and "${s.specifier}" both provide a class named "${o.name}"`);t.set(o.name,s.specifier)}let n=new Map;for(let s of this.#e){if(!s.project)continue;let o=n.get(s.project.key);if(o)throw Error(`Extension conflict: "${o.name}" and "${s.name}" both claim the project section "${s.project.key}"`);n.set(s.project.key,s)}let r=new Map;for(let s of this.#e){if(!s.server)continue;let{basePath:o}=s.server;if(!o.startsWith("/_jx/"))throw Error(`Extension "${s.name}": server basePath "${o}" must be under /_jx/`);let i=r.get(o);if(i)throw Error(`Extension conflict: "${i.name}" and "${s.name}" both mount "${o}"`);r.set(o,s)}this.#n=new Lr(this.#e.filter((s)=>s.extensions.length>0))}get extensions(){return this.#t}get classes(){return this.#e}get formats(){return this.#n}byName(e){return this.#e.find((t)=>t.name===e)}projectContributions(){return this.#e.filter((e)=>e.project!==null)}byProjectKey(e){return this.#e.find((t)=>t.project?.key===e)}byPathsDiscriminator(e){return this.#e.find((t)=>t.capabilities.resolvePaths?.discriminator===e)}emitters(){return this.#e.filter((e)=>e.capabilities.emit!==void 0)}headProviders(){return this.#e.filter((e)=>e.capabilities.head!==void 0)}assetProviders(){return this.#e.filter((e)=>e.capabilities.assets!==void 0)}serverMounts(){return this.#e.filter((e)=>e.server!==null).toSorted((e,t)=>(e.server?.order??100)-(t.server?.order??100)||e.name.localeCompare(t.name))}connectors(){return this.#e.filter((e)=>e.connector!==null)}schemaFragments(e){return this.#t.map((t)=>t.schemas[e]).filter((t)=>typeof t==="string")}}async function Pa(e,t,n){let r=[];for(let s of e??[])r.push(await Nu(s,t,n));return new _a(r)}async function Nu(e,t,n){let r;if(e.startsWith("./")||e.startsWith("../")){let a=t.resolvePath(n,e);r=t.resolvePath(`${a}/package.json`,`./${Fn}`)}else try{r=t.resolvePath(n,`${e}/${Fn}`)}catch(a){throw Error(`Extension "${e}" is not resolvable: it must export ${Fn} (is the package installed, and does its exports map include it?): ${uo(a)}`,{cause:a})}let s;try{s=await t.loadJson(r)}catch(a){throw Error(`Extension "${e}": cannot read manifest ${r}: ${uo(a)}`,{cause:a})}if(!D(s)||!b(s.name))throw Error(`Extension "${e}": ${Fn} must declare a "name"`);let o=s;if(!e.startsWith(".")&&o.name!==e)throw Error(`Extension "${e}": manifest name "${o.name}" does not match the specifier`);let i=[];for(let[a,l]of Object.entries(o.classes??{})){let u=t.resolvePath(r,l),f;try{f=await t.loadJson(u)}catch(p){throw Error(`Extension "${e}": cannot read class "${a}" at ${u}: ${uo(p)}`,{cause:p})}i.push(new Dn(a,u,Ra(f),t))}let c={};if(o.schemas?.project)c.project=t.resolvePath(r,o.schemas.project);if(o.schemas?.document)c.document=t.resolvePath(r,o.schemas.document);if(o.schemas?.fields)c.fields=t.resolvePath(r,o.schemas.fields);return{specifier:e,manifestPath:r,manifest:o,classes:i,schemas:c}}function uo(e){return e instanceof Error?e.message:String(e)}var Fn="jx-extension.json";var ka=j(()=>{co();z();co()});var Ia=j(()=>{z()});function Ou(e){return`${e} holds both project.jxn and project.json, and a project has one. Keep the one you edit and delete the other`}function Da(e){let t=Au.filter((n)=>e(n));if(t.length>1)return"conflict";return t[0]??null}function Km(e,t){return _n(t)?ao(e,t):wi(e,t)}var Au,Ma="project.json",fo;var Fa=j(()=>{z();Ia();$n();Ys();lo();Sn();Au=["project.jxn","project.json"];fo=class fo extends Error{constructor(e){super(Ou(e));this.name="ProjectFileConflictError"}}});import{accessSync as Qm,closeSync as eg,constants as tg,existsSync as Cu,fstatSync as ng,lstatSync as rg,openSync as sg,readFileSync as og,statSync as ig}from"node:fs";import{dirname as lg,join as La}from"node:path";function ju(e){return Da((t)=>Cu(La(e,t)))}function Wa(e){let t=ju(e);if(t==="conflict")throw new fo(e);return La(e,t??Ma)}var Va=j(()=>{Fa()});import{readFileSync as vu}from"node:fs";import{dirname as Tu,isAbsolute as Ru,resolve as Ha,sep as Wr}from"node:path";import{pathToFileURL as _u}from"node:url";import{createRequire as Pu}from"node:module";async function ku(e){let t=[e],n=`${Wr}src${Wr}`,r=`${Wr}dist${Wr}`;if(e.includes(n)){let o=e.replace(n,r);if(t.push(o),o.endsWith(".ts"))t.push(`${o.slice(0,-3)}.js`)}if(e.endsWith(".js"))t.push(`${e.slice(0,-3)}.ts`);let s;for(let o of t)try{return await import(_u(o).href)}catch(i){s=i}throw s instanceof Error?s:Error(String(s))}function Iu(e,t){return Pu(Ha(e,"package.json")).resolve(t)}function Mu(e){return{importModule:(t)=>ku(t),loadJson:async(t)=>JSON.parse(vu(t,"utf8")),resolvePath:(t,n)=>{if(n.startsWith("./")||n.startsWith("../"))return Ha(Tu(t),n);if(Ru(n))return n;return Iu(e,n)}}}async function yg(e,t){return Pa(t?.extensions,Mu(e),Wa(e))}function Vr(e,t){return Error(`No format class registered for "${t}" (${e}). Enable an extension providing this format in project.json "extensions", e.g. "@jxsuite/parser".`)}var po=j(()=>{ka();z();Va()});async function za(e,t={}){let{resolveElementPath:n,$media:r,formats:s}=t,o=[],i=new Set;async function c(a,l){let u,f;if(b(a)){let{readFileSync:J}=await import("node:fs"),{resolve:C}=await import("node:path");if(f=l?C(l,a):C(a),i.has(f))return;if(i.add(f),Pn(f))u=kn(J(f,"utf8"),f);else{let{extname:q}=await import("node:path"),S=q(f).toLowerCase(),y=s?.byExtension(S,"parse");if(!y){await Promise.resolve().then(() => po());throw Vr(f,S)}u=await y.parseDocument(J(f,"utf8"))}}else{if(u=a,f=null,u.tagName&&i.has(u.tagName))return;if(u.tagName)i.add(u.tagName)}let{tagName:p}=u;if(!p||!p.includes("-"))throw Error(`compileElement: tagName "${p}" must contain a hyphen`);let{dirname:d}=await import("node:path"),h=f?d(f):null,g=[];if(Array.isArray(u.$elements))for(let J of u.$elements){let C=H(J)?J.$ref:J;if(!b(C))continue;if(h)await c(C,h);let q=n?n(C,h):C.replace(/\.(?:json|jxn)$/i,".js");g.push(q)}let m=cr(p);if(r)u.$media={...r,...u.$media};let{rewriteSrc:x}=t,E=Ln(u,m,g,x?(J)=>x(J,h):void 0,Gn(u,t.defaults),t.serverBaseUrl),O=f?f.replace(/\.(?:json|jxn)$/i,".js"):`${p}.js`;o.push({content:E,path:O,tagName:p})}return await c(e,t.basePath??null),{files:o}}async function Du(e,t={}){let{title:n="Jx App",reactivitySrc:r="https://esm.sh/@vue/reactivity@3.5.13",litHtmlSrc:s="https://esm.sh/lit-html@3.3.0"}=t,o=await za(e,t),i=o.files.at(-1);if(!i)throw Error("compileElementPage: no element modules were produced");let{basename:c}=await import("node:path"),a=c(i.path),l=`<!DOCTYPE html>
79
+ `}var ue=" ",wo=100,Ba,Ha,Yu,Xu,Te=(e)=>R(e),Bn=(e)=>Te(e)&&S(e.$ref)&&Object.keys(e).length===1,Z=(e,t)=>`${e}/${String(t).replaceAll("~","~0").replaceAll("/","~1")}`;var Ao=A(()=>{Wr();U();on();Mn();zr();Ba=/^(?![-+]?\.?\d)(?!(?:true|false|null|inf|-inf|nan)$)[^\s\\/(){};[\]"#=,\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+$/u,Ha=/[\p{Cc}\p{Zl}\p{Zp}‎‏‪-‮⁦-⁩]/u,Yu=/(?!\n)\p{Cc}|[\p{Zl}\p{Zp}‎‏‪-‮⁦-⁩]/u,Xu=new Set(["-","attributes","script","state","style"])});function cf(e,t,n){if(an(e,t)!==null)throw F(e,t,`"project" names the file's kind, and takes no annotation`);let r=nt(e,t);if(r.length>1||rt(t).length>0||$e(t).length>0)throw F(e,t,`"project" holds one value, the project's name, and nothing else`);if(r[0]!==void 0)D(n,"name",r[0],e,t),ae(e,"/name",t)}function uf(e,t,n){let r=t.getName(),s=`/${Ae(r)}`,o=t.getTag()===null,i;if(r==="$head"&&o)i=po(e,t),ae(e,s,t);else if(lf.has(r)&&o)i=Br(e,t,s);else i=ve(e,t,s);D(n,r,i,e,t)}function ff(e){if(Ht(e.text)==="document")throw new ie('A project file declares itself: its first node, after any $ metadata, is project "<name>"');let t=mo(e.text),n={},r=!1;for(let s of t.nodes)if(s.getName()===af){if(r)throw F(e,s,'"project" is written twice, and a file declares one project');cf(e,s,n),r=!0}else uf(e,s,n);return Ut(n)}function Oo(e,t){try{return ff({spans:null,text:e})}catch(n){throw t!==void 0&&n instanceof ie?n.inFile(t):n}}var af="project",lf;var Co=A(()=>{U();An();Nn();on();Mn();zr();Ao();lf=new Set(["$media","style"])});var Gr=A(()=>{Nn();ho();on();Ia();Mn();zr();Ao();Co()});function tl(e){if(!S(e))return null;let[t,...n]=e.split(";"),r=(t??"").indexOf("/");if(r===-1)return null;let s=(t??"").slice(0,r).trim().toLowerCase(),o=(t??"").slice(r+1).trim().toLowerCase();if(!Za.test(s)||!Za.test(o))return null;let i=o.lastIndexOf("+"),a=i===-1?null:o.slice(i+1),l=i===-1?o:o.slice(0,i);if(a==="")return null;let c=l.indexOf("."),u=c===-1?null:l.slice(0,c),f=u!==null&&df.has(u)?u:null,p=f===null?l:l.slice(f.length+1);if(p==="")return null;let d={};for(let h of n){let g=h.indexOf("=");if(g===-1)return null;let m=h.slice(0,g).trim().toLowerCase(),x=h.slice(g+1).trim();if(m==="")return null;if(x.startsWith('"')&&x.endsWith('"')&&x.length>=2)x=x.slice(1,-1);d[m]=x}return{parameters:d,subtype:p,suffix:a,tree:f,type:s}}function nl(e){if(!S(e)||e.trim()==="")return"expected a media type string";if(!e.includes("/"))return`"${e}" has no "/" — a media type is type/subtype (RFC 6838 §4.2)`;if(tl(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function rl(e){let t=tl(e);if(t===null)return null;let n=t.tree===null?"":`${t.tree}.`,r=t.suffix===null?"":`+${t.suffix}`;return`${t.type}/${n}${t.subtype}${r}`}var Za,df,Qa="text/markdown; variant=GFM",el="application/yaml",Vg;var sl=A(()=>{U();Za=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,df=new Set(["vnd","prs","x"]);Vg={".jxn":"text/plain; charset=utf-8",".markdown":`${Qa}; charset=utf-8`,".md":`${Qa}; charset=utf-8`,".yaml":`${el}; charset=utf-8`,".yml":`${el}; charset=utf-8`}});function ll(e){if(e===null)throw TypeError("A class descriptor cannot be null");return R(e)?e:{}}class Hn{name;classPath;classDef;extensions;mediaType;mediaTypeEssence;documentKinds;exportTarget;remote;studio;project;server;connector;capabilities;#t;#e=null;constructor(e,t,n,r){this.name=e,this.classPath=t,this.classDef=n,this.#t=r;let{format:s}=n;this.extensions=(s?.extensions??[]).map((o)=>o.toLowerCase()),this.mediaType=s?.mediaType??null,this.mediaTypeEssence=rl(this.mediaType),this.documentKinds=s?.documentKinds??[],this.exportTarget=s?.exportTarget===!0,this.remote=s?.remote===!0,this.studio=n.$studio??null,this.project=n.project??null,this.server=n.server??null,this.connector=n.connector??null,this.capabilities=gf(n)}implementation(){if(!this.#e){let e=this.classDef.$implementation;if(!e)return Promise.reject(Error(`Format class "${this.name}" has no $implementation to import`));this.#e=this.#t.importModule(this.#t.resolvePath(this.classPath,e))}return this.#e}async implementationExport(){return this.#n(await this.implementation())}#n(e){let t=this.classDef.title??this.name;return e[t]??e.default?.[t]??e.default}async call(e,...t){let n=this.capabilities[e];if(!n)throw Error(`Format class "${this.name}" does not declare a "${e}" capability`);let r=this.#n(await this.implementation()),s=r?.[n.identifier];if(!we(s)){let i=this.classDef.title??this.name;throw TypeError(`Format class "${this.name}": implementation export "${i}" has no static "${n.identifier}" method`)}return await s.call(r,...t)}async parseDocument(e,t){return await this.call("parse",e,t)}}class Yr{#t;get#e(){return[...this.#t,$f]}constructor(e){this.#t=e;for(let t of e)if(t.extensions.includes(".jxn"))throw Error(`Format "${t.name}" claims ".jxn", which is built in`);for(let t of e){if(t.mediaType===null)continue;let n=nl(t.mediaType);if(n!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${n}`)}for(let t of il){let n=new Map;for(let r of e){if(!r.capabilities[t])continue;for(let s of r.extensions){let o=n.get(s);if(o)throw Error(`Format conflict: "${o.name}" and "${r.name}" both claim "${s}" with the "${t}" capability`);n.set(s,r)}}}}get entries(){return this.#t}byExtension(e,t){let n=ol(e);return this.#e.find((r)=>r.extensions.includes(n)&&(!t||r.capabilities[t]))}byName(e){return this.#t.find((t)=>t.name===e)}withCapability(e){return this.#e.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let n of this.#e){if(e&&!n.documentKinds.includes(e))continue;for(let r of n.extensions)t.add(r)}return t.delete(".json"),[...t]}has(e){let t=ol(e);return this.#e.some((n)=>n.extensions.includes(t))}}function gf(e){let t={},n=e.$defs?.methods??{};for(let[r,s]of Object.entries(n)){let{role:o}=s;if(!xf(o))continue;let i={identifier:s.identifier??r,timing:s.timing??mf};if(S(s.discriminator))i.discriminator=s.discriminator;t[o]=i}return t}function xf(e){return e!==void 0&&hf.has(e)}function ol(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var il,al,mf,hf,yf,$f;var jo=A(()=>{U();sl();il=["parse","serialize","rewrite","discover","load"],al=[...il,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"];mf=["compiler","server"];hf=new Set(al);yf={importModule:async()=>{await Promise.resolve().then(() => Gr());return{JxNotation:{parse:(n)=>Dn(n),serialize:(n)=>No(n)}}},loadJson:()=>Promise.reject(Error("Jx Notation reads no file of its own")),resolvePath:(e,t)=>t},$f=new Hn("jxn","",{$defs:{methods:{parse:{role:"parse"},serialize:{role:"serialize"}}},$implementation:"jxn",format:{documentKinds:["page","component"],extensions:[".jxn"]},title:"JxNotation"},yf)});class cl{#t;#e;#n;constructor(e){this.#t=e,this.#e=e.flatMap((s)=>s.classes);let t=new Map;for(let s of e)for(let o of s.classes){let i=t.get(o.name);if(i&&i!==s.specifier)throw Error(`Extension conflict: "${i}" and "${s.specifier}" both provide a class named "${o.name}"`);t.set(o.name,s.specifier)}let n=new Map;for(let s of this.#e){if(!s.project)continue;let o=n.get(s.project.key);if(o)throw Error(`Extension conflict: "${o.name}" and "${s.name}" both claim the project section "${s.project.key}"`);n.set(s.project.key,s)}let r=new Map;for(let s of this.#e){if(!s.server)continue;let{basePath:o}=s.server;if(!o.startsWith("/_jx/"))throw Error(`Extension "${s.name}": server basePath "${o}" must be under /_jx/`);let i=r.get(o);if(i)throw Error(`Extension conflict: "${i.name}" and "${s.name}" both mount "${o}"`);r.set(o,s)}this.#n=new Yr(this.#e.filter((s)=>s.extensions.length>0))}get extensions(){return this.#t}get classes(){return this.#e}get formats(){return this.#n}byName(e){return this.#e.find((t)=>t.name===e)}projectContributions(){return this.#e.filter((e)=>e.project!==null)}byProjectKey(e){return this.#e.find((t)=>t.project?.key===e)}byPathsDiscriminator(e){return this.#e.find((t)=>t.capabilities.resolvePaths?.discriminator===e)}emitters(){return this.#e.filter((e)=>e.capabilities.emit!==void 0)}headProviders(){return this.#e.filter((e)=>e.capabilities.head!==void 0)}assetProviders(){return this.#e.filter((e)=>e.capabilities.assets!==void 0)}serverMounts(){return this.#e.filter((e)=>e.server!==null).toSorted((e,t)=>(e.server?.order??100)-(t.server?.order??100)||e.name.localeCompare(t.name))}connectors(){return this.#e.filter((e)=>e.connector!==null)}schemaFragments(e){return this.#t.map((t)=>t.schemas[e]).filter((t)=>typeof t==="string")}}async function ul(e,t,n){let r=[];for(let s of e??[])r.push(await Sf(s,t,n));return new cl(r)}async function Sf(e,t,n){let r;if(e.startsWith("./")||e.startsWith("../")){let l=t.resolvePath(n,e);r=t.resolvePath(`${l}/package.json`,`./${Un}`)}else try{r=t.resolvePath(n,`${e}/${Un}`)}catch(l){throw Error(`Extension "${e}" is not resolvable: it must export ${Un} (is the package installed, and does its exports map include it?): ${vo(l)}`,{cause:l})}let s;try{s=await t.loadJson(r)}catch(l){throw Error(`Extension "${e}": cannot read manifest ${r}: ${vo(l)}`,{cause:l})}if(!R(s)||!S(s.name))throw Error(`Extension "${e}": ${Un} must declare a "name"`);let o=s;if(!e.startsWith(".")&&o.name!==e)throw Error(`Extension "${e}": manifest name "${o.name}" does not match the specifier`);let i=[];for(let[l,c]of Object.entries(o.classes??{})){let u=t.resolvePath(r,c),f;try{f=await t.loadJson(u)}catch(p){throw Error(`Extension "${e}": cannot read class "${l}" at ${u}: ${vo(p)}`,{cause:p})}i.push(new Hn(l,u,ll(f),t))}let a={};if(o.schemas?.project)a.project=t.resolvePath(r,o.schemas.project);if(o.schemas?.document)a.document=t.resolvePath(r,o.schemas.document);if(o.schemas?.fields)a.fields=t.resolvePath(r,o.schemas.fields);return{specifier:e,manifestPath:r,manifest:o,classes:i,schemas:a}}function vo(e){return e instanceof Error?e.message:String(e)}var Un="jx-extension.json";var fl=A(()=>{jo();U();jo()});var pl=A(()=>{U()});function wf(e){return`${e} holds both project.jxn and project.json, and a project has one. Keep the one you edit and delete the other`}function ml(e){let t=bf.filter((n)=>e(n));if(t.length>1)return"conflict";return t[0]??null}function ah(e,t){return Fn(t)?Oo(e,t):Zi(e,t)}var bf,dl="project.jxn",To;var gl=A(()=>{U();pl();Nn();ho();Co();An();bf=["project.jxn","project.json"];To=class To extends Error{constructor(e){super(wf(e));this.name="ProjectFileConflictError"}}});import{accessSync as ph,closeSync as dh,constants as mh,existsSync as Ef,fstatSync as gh,lstatSync as hh,openSync as xh,readFileSync as yh,statSync as $h}from"node:fs";import{dirname as bh,join as hl}from"node:path";function Jf(e){return ml((t)=>Ef(hl(e,t)))}function xl(e){let t=Jf(e);if(t==="conflict")throw new To(e);return hl(e,t??dl)}var yl=A(()=>{gl()});import{readFileSync as Nf}from"node:fs";import{dirname as Af,isAbsolute as Of,resolve as $l,sep as Xr}from"node:path";import{pathToFileURL as Cf}from"node:url";import{createRequire as jf}from"node:module";async function vf(e){let t=[e],n=`${Xr}src${Xr}`,r=`${Xr}dist${Xr}`;if(e.includes(n)){let o=e.replace(n,r);if(t.push(o),o.endsWith(".ts"))t.push(`${o.slice(0,-3)}.js`)}if(e.endsWith(".js"))t.push(`${e.slice(0,-3)}.ts`);let s;for(let o of t)try{return await import(Cf(o).href)}catch(i){s=i}throw s instanceof Error?s:Error(String(s))}function Tf(e,t){return jf($l(e,"package.json")).resolve(t)}function Rf(e){return{importModule:(t)=>vf(t),loadJson:async(t)=>JSON.parse(Nf(t,"utf8")),resolvePath:(t,n)=>{if(n.startsWith("./")||n.startsWith("../"))return $l(Af(t),n);if(Of(n))return n;return Tf(e,n)}}}async function Th(e,t){return ul(t?.extensions,Rf(e),xl(e))}function Zr(e,t){return Error(`No format class registered for "${t}" (${e}). Enable an extension providing this format in project.json "extensions", e.g. "@jxsuite/parser".`)}var Ro=A(()=>{fl();U();yl()});async function wl(e,t={}){let{resolveElementPath:n,$media:r,formats:s}=t,o=[],i=new Set;async function a(l,c){let u,f;if(S(l)){let{readFileSync:E}=await import("node:fs"),{resolve:O}=await import("node:path");if(f=c?O(c,l):O(l),i.has(f))return;if(i.add(f),Ln(f))u=Wn(E(f,"utf8"),f);else{let{extname:K}=await import("node:path"),b=K(f).toLowerCase(),y=s?.byExtension(b,"parse");if(!y){await Promise.resolve().then(() => Ro());throw Zr(f,b)}u=await y.parseDocument(E(f,"utf8"))}u=pn(u,f)}else{if(u=pn(l,l.tagName??"a component"),f=null,u.tagName&&i.has(u.tagName))return;if(u.tagName)i.add(u.tagName)}let{tagName:p}=u;if(!p||!p.includes("-"))throw Error(`compileElement: tagName "${p}" must contain a hyphen`);let{dirname:d}=await import("node:path"),h=f?d(f):null,g=[];if(Array.isArray(u.$elements))for(let E of u.$elements){let O=H(E)?E.$ref:E;if(!S(O))continue;if(h)await a(O,h);let K=n?n(O,h):O.replace(/\.(?:json|jxn)$/i,".js");g.push(K)}let m=$r(p);if(r)u.$media={...r,...u.$media};let{rewriteSrc:x}=t,w=qn(u,m,g,x?(E)=>x(E,h):void 0,or(u,t.defaults),t.serverBaseUrl),N=f?f.replace(/\.(?:json|jxn)$/i,".js"):`${p}.js`;o.push({content:w,path:N,tagName:p})}return await a(e,t.basePath??null),{files:o}}async function _f(e,t={}){let{title:n="Jx App",reactivitySrc:r="https://esm.sh/@vue/reactivity@3.5.13",litHtmlSrc:s="https://esm.sh/lit-html@3.3.0"}=t,o=await wl(e,t),i=o.files.at(-1);if(!i)throw Error("compileElementPage: no element modules were produced");let{basename:a}=await import("node:path"),l=a(i.path),c=`<!DOCTYPE html>
71
80
  <html lang="en">
72
81
  <head>
73
82
  <meta charset="utf-8">
74
83
  <meta name="viewport" content="width=device-width, initial-scale=1">
75
- <title>${_(n)}</title>
84
+ <title>${k(n)}</title>
76
85
  <script type="importmap">
77
86
  {
78
87
  "imports": {
@@ -84,99 +93,104 @@ ${r}"""${n}`;return ha(o,e)?o:null}function ro(e,t,n){if(!ga(e))throw new ie(`${
84
93
  </head>
85
94
  <body>
86
95
  <${i.tagName}></${i.tagName}>
87
- <script type="module" src="./${a}"></script>
96
+ <script type="module" src="./${l}"></script>
88
97
  </body>
89
- </html>`;return{files:o.files,html:l}}function Fu(e){if(!A(e)||Array.isArray(e))return JSON.stringify(e);if("default"in e)return JSON.stringify(e.default);if(it(e))return;if(e.$prototype==="LocalStorage"||e.$prototype==="SessionStorage")return JSON.stringify(e.default??null);if(e.$prototype==="Request")return"null";if(He(e))return"null";return JSON.stringify(e)}function Lu(e){let t=new Set,n=new Set,r=(o)=>{if(o.startsWith("#/state/"))t.add(o.slice(8).split("/")[0])},s=(o)=>{if(b(o)){for(let c of o.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*\(/g))t.add(c[1]);return}if(!A(o)||n.has(o))return;if(n.add(o),Array.isArray(o)){for(let c of o)s(c);return}let i=o;if(i.operator==="call"&&H(i.target))r(i.target.$ref);for(let[c,a]of Object.entries(i)){if(c.startsWith("on")&&c!=="observedAttributes"&&H(a))r(a.$ref);s(a)}};return s(e.children),s(e.state),t}function Ln(e,t,n,r,s=null,o="/_jx/server"){let i=["// Generated by @jxsuite/compiler — do not edit manually"];if(e.$id)i.push(`// Source: ${e.$id}`);for(let S of n)i.push(`import '${S}';`);let c=new Map,a=new Map,l=e.state??{},u=Lu(e);for(let[S,y]of Object.entries(l))if(be(y)&&y.$src){let w=y.$src;if(y.$lazy===!0){if(!u.has(S)&&!Ba.has(S))throw Error(`"${S}" declares "$lazy": true but is used as a computed value, not called. A lazily loaded function resolves to a promise; a computed must resolve now. Remove "$lazy", or call ${S}() from a handler instead of binding its value.`);let Z=a.get(w);if(!Z)Z=[],a.set(w,Z);Z.push({binding:S,exportName:xs(S,y)});continue}let N=c.get(w);if(!N)N=[],c.set(w,N);N.push(Qn(S,y))}for(let[S,y]of c){let w=r?r(S):S;i.push(`import { ${y.join(", ")} } from '${w}';`)}let f=Object.entries(l).flatMap(([S,y])=>ot(y)&&y.$prototype==="Request"?[[S,y]]:[]),p=Object.entries(l).flatMap(([S,y])=>He(y)?[[S,y]]:[]);if(i.push("import { reactive, computed, effect, stop } from '@vue/reactivity';","import { render, html, nothing } from 'lit-html';",ar()),p.length>0)i.push(lr());let d=s===null&&Pt(e.children);if(d)i.push(ui());let h=0;for(let[S,y]of a){let w=r?r(S):S,N=`_jxLazy${h}`;h+=1,i.push(`let ${N};`,`const ${N}Load = () => (${N} ??= import('${w}'));`,...y.map(({binding:Z,exportName:te})=>`const ${Z} = (...args) => ${N}Load().then((m) => m.${te}(...args));`))}i.push("",`class ${t} extends HTMLElement {`," #effects = [];",...s===null?[]:[" #root = null;"],""," constructor() {"," super();");let g=[],m=[],x=[],E=[],O=[];for(let[S,y]of Object.entries(l))if(we(y))if(xt(y))E.push([S,y]);else if(Ke(y.$expression.operator))x.push([S,y]);else m.push([S,y]);else if(be(y))if(y.$src&&!b(y.body))if(u.has(S)||Ba.has(S))x.push([S,y]);else m.push([S,y]);else if(b(y.body)&&yt(y.body))m.push([S,y]);else x.push([S,y]);else if(b(y)&&y.includes("${"))O.push([S,y]);else{let w=Fu(y);if(w!==void 0)g.push([S,w])}i.push(" this.state = reactive({");for(let[S,y]of g)i.push(` ${ze(S)}: ${y},`);i.push(" });");for(let[S,y]of x)if(i.push(""),we(y)){let w=pe(y.$expression,{eventParam:"e",statePrefix:"s"});i.push(` ${k("this.state",re(S))} = (s, e) => { ${w}; };`)}else if(st(y)){let w=Ce(y.body,{dispatchTarget:"this",eventParam:"e",indent:" ",statePrefix:"this.state"});i.push(` ${k("this.state",re(S))} = (s, e) => {`,w," };")}else{let w=y.parameters?Be(y.parameters):y.arguments??["state"],N=w.join(", "),Z=b(y.body)?y.body:"";if(w[0]==="state")if(y.$src)i.push(` ${k("this.state",re(S))} = (${N}) => ${S}(${N});`);else i.push(` ${k("this.state",re(S))} = (${N}) => {`,` ${Z}`," };");else{let te=w.map((Te)=>Te==="state"?"state":"e").join(", ");if(y.$src)i.push(` ${k("this.state",re(S))} = (state, e) => ${S}(${te});`);else i.push(` ${k("this.state",re(S))} = (state, e) => {`,` const _fn = (${N}) => {`,` ${Z}`," };",` return _fn(${te});`," };")}}for(let[S,y]of E){i.push("");let w=pe(y.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${k("this.state",re(S))} = ${xn(y,w)};`)}for(let[S,y]of O)i.push("",` ${k("this.state",re(S))} = computed(() => ${or(y.replaceAll("state.","this.state."))});`);for(let[S,y]of m)if(i.push(""),we(y)){let w=pe(y.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${k("this.state",re(S))} = computed(() => ${w});`)}else if(y.$src)i.push(` ${k("this.state",re(S))} = computed(() => ${S}(this.state));`);else{i.push(` ${k("this.state",re(S))} = computed(() => {`);let w=(b(y.body)?y.body:"").replaceAll("state.","this.state.");i.push(` ${w}`," });")}i.push(" }","");let J=[];if(Array.isArray(e.children)){let S={n:0};for(let y of e.children)kt(y,J,e.$media??{},"",S,e.tagName)}let C=Ka(),q=!Array.isArray(e.children)&&e.textContent!==void 0?` ${Ur(e.textContent)}`:Br(e.children,e.style," ",!1,!1,C);i.push(" template() {"," const s = this.state;",...C.decls," return html`",q," `;"," }","",...s===null?[]:[" #renderRoot() {"," if (this.#root) return this.#root;",s==="closed"?" this.#root = this.attachInternals().shadowRoot ?? this.attachShadow({ mode: 'closed' });":" this.#root = this.shadowRoot ?? this.attachShadow({ mode: 'open' });"," return this.#root;"," }",""]," connectedCallback() {"," const _pa = this.getAttribute('data-jx-props');"," if (_pa) {"," try {"," const _p = JSON.parse(_pa);"," for (const [k, v] of Object.entries(_p)) {"," if (k.startsWith('#')) continue;"," if (k in this.state) this.state[k] = v;"," }"," } catch {}"," this.removeAttribute('data-jx-props');"," }"," const _pn = this.getAttributeNames().filter(n => n.startsWith('props.') && n.length > 6);"," for (const _n of _pn) {"," const _k = _n.slice(6);"," if (_k.startsWith('#')) { this.removeAttribute(_n); continue; }"," if (_k in this.state) {"," this.state[_k] = this.getAttribute(_n);"," this.removeAttribute(_n);"," }"," }"," for (const key of Object.keys(this.state)) {"," if (key.startsWith('#')) continue;"," if (this.hasOwnProperty(key) && this[key] !== undefined) {"," this.state[key] = this[key];"," }"," }");for(let[S,y]of f)i.push(er(S,y,{collect:"this.#effects",indent:" ",statePrefix:"this.state"}));for(let[S,y]of p)i.push(tr(S,y,{collect:"this.#effects",indent:" ",serverBaseUrl:o,statePrefix:"this.state"}));if(A(e.style)){let S=[];for(let[y,w]of Object.entries(e.style)){if(y.startsWith(":")||y.startsWith(".")||y.startsWith("&")||y.startsWith("[")||y.startsWith("@"))continue;if(b(w)&&w.includes("${"))S.push([ge(y),w])}if(S.length>0){i.push(" this.#effects.push(effect(() => {");for(let[y,w]of S){let N=w.replaceAll(/\$\{([^}]+)\}/g,(Z,te)=>`\${${te.replaceAll("state.","this.state.")}}`);i.push(` this.style['${y}'] = \`${N}\`;`)}i.push(" }));")}}if(d)i.push(` const _slotted = ${$s}(this);`);if(i.push(" if (this.hasAttribute('data-jx-prerendered')) {"," this.removeAttribute('data-jx-prerendered');"," }"),s===null)i.push(" this.replaceChildren();"," this.#effects.push(effect(() => render(this.template(), this)));");else i.push(" const _root = this.#renderRoot();"," for (const _n of [..._root.childNodes]) {"," if (!(_n.nodeType === 1 && _n.tagName === 'LINK')) _n.remove();"," }"," this.#effects.push(effect(() => render(this.template(), _root)));");if(d)i.push(` ${Ss}(this, _slotted);`);return i.push(" if (typeof this.state.onMount === 'function') {"," queueMicrotask(() => this.state.onMount(this.state));"," }"," }",""," disconnectedCallback() {"," for (const _e of this.#effects) { stop(_e); }"," this.#effects.length = 0;"," if (typeof this.state.onUnmount === 'function') { this.state.onUnmount(this.state); }"," }","}","",`customElements.define('${e.tagName}', ${t});`,""),i.join(`
90
- `)}function Ka(){return{byText:new Map,decls:[]}}function Ga(e,t){let n=e.byText.get(t);if(n)return n;let r=`_c${e.decls.length}`;e.decls.push(` const ${r} = html\`
98
+ </html>`;return{files:o.files,html:c}}function Pf(e){if(!J(e)||Array.isArray(e))return JSON.stringify(e);if("default"in e)return JSON.stringify(e.default);if(it(e))return;if(e.$prototype==="LocalStorage"||e.$prototype==="SessionStorage")return JSON.stringify(e.default??null);if(e.$prototype==="Request")return"null";if(Ue(e))return"null";return JSON.stringify(e)}function qn(e,t,n,r,s=null,o="/_jx/server"){let i=["// Generated by @jxsuite/compiler — do not edit manually"];if(e.$id)i.push(`// Source: ${e.$id}`);for(let b of n)i.push(`import '${b}';`);let a=new Map,l=new Map,c=e.state??{},u=$t(e);for(let[b,y]of Object.entries(c))if(lt(`state entry "${b}"`,y),se(y)&&y.$src){let j=y.$src;if(y.$lazy===!0){if(u.get(b)==="computed")throw Error(`"${b}" declares "$lazy": true but is used as a computed value, not called. A lazily loaded function resolves to a promise; a computed must resolve now. Remove "$lazy", or call ${b}() from a handler instead of binding its value.`);let v=l.get(j);if(!v)v=[],l.set(j,v);v.push({binding:b,exportName:Is(b,y)});continue}let C=a.get(j);if(!C)C=[],a.set(j,C);C.push(cr(b,y))}for(let[b,y]of a){let j=r?r(b):b;i.push(`import { ${y.join(", ")} } from '${j}';`)}let f=Object.entries(c).flatMap(([b,y])=>ot(y)&&y.$prototype==="Request"?[[b,y]]:[]),p=Object.entries(c).flatMap(([b,y])=>Ue(y)?[[b,y]]:[]);if(i.push("import { reactive, computed, effect, stop } from '@vue/reactivity';","import { render, html, nothing } from 'lit-html';",xr()),p.length>0)i.push(yr());let d=s===null&&It(e.children);if(d)i.push(Li());let h=0;for(let[b,y]of l){let j=r?r(b):b,C=`_jxLazy${h}`;h+=1,i.push(`let ${C};`,`const ${C}Load = () => (${C} ??= import('${j}'));`,...y.map(({binding:v,exportName:ne})=>`const ${v} = (...args) => ${C}Load().then((m) => m.${ne}(...args));`))}i.push("",`class ${t} extends HTMLElement {`," #effects = [];",...s===null?[]:[" #root = null;"],""," constructor() {"," super();");let g=[],m=[],x=[],w=[],N=[];for(let[b,y]of Object.entries(c))if(Ee(y))if(xt(y))w.push([b,y]);else if(Ge(y.$expression.operator))x.push([b,y]);else m.push([b,y]);else if(se(y))(u.get(b)==="computed"?m:x).push([b,y]);else if(S(y)&&y.includes("${"))N.push([b,y]);else{let j=Pf(y);if(j!==void 0)g.push([b,j])}i.push(" this.state = reactive({");for(let[b,y]of g)i.push(` ${Ke(b)}: ${y},`);i.push(" });");for(let[b,y]of x)if(i.push(""),Ee(y)){let j=de(y.$expression,{eventParam:"e",statePrefix:"s"});i.push(` ${L("this.state",pe(b))} = (s, e) => { ${j}; };`)}else if(De(y)){let j=je(y.body,{dispatchTarget:"this",eventParam:"e",indent:" ",statePrefix:"this.state"});i.push(` ${L("this.state",pe(b))} = (s, e) => {`,j," };")}else{let j=L("this.state",pe(b));if(y.$src)i.push(` ${j} = ${b};`);else{let C=S(y.body)?y.body:"";i.push(` ${j} = (${Fe(y).join(", ")}) => {`,` ${C}`," };")}}for(let[b,y]of w){i.push("");let j=de(y.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${L("this.state",pe(b))} = ${En(y,j)};`)}for(let[b,y]of N)i.push("",` ${L("this.state",pe(b))} = computed(() => ${gr(Ft(y,"this.state",{code:!1}))});`);for(let[b,y]of m)if(i.push(""),Ee(y)){let j=de(y.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${L("this.state",pe(b))} = computed(() => ${j});`)}else if(y.$src)i.push(` ${L("this.state",pe(b))} = computed(() => ${b}(this.state));`);else{i.push(` ${L("this.state",pe(b))} = computed(() => {`);let j=Ft(S(y.body)?y.body:"","this.state");i.push(` ${j}`," });")}i.push(" }","");let E=[];if(Array.isArray(e.children)){let b={n:0};for(let y of e.children)Dt(y,E,e.$media??{},"",b,e.tagName)}let O=El(),K=!Array.isArray(e.children)&&e.textContent!==void 0?` ${ts(e.textContent)}`:es(e.children,e.style," ",!1,!1,O);i.push(" template() {"," const s = this.state;",...O.decls," return html`",K," `;"," }","",...s===null?[]:[" #renderRoot() {"," if (this.#root) return this.#root;",s==="closed"?" this.#root = this.attachInternals().shadowRoot ?? this.attachShadow({ mode: 'closed' });":" this.#root = this.shadowRoot ?? this.attachShadow({ mode: 'open' });"," return this.#root;"," }",""]," connectedCallback() {"," const _pa = this.getAttribute('data-jx-props');"," if (_pa) {"," try {"," const _p = JSON.parse(_pa);"," for (const [k, v] of Object.entries(_p)) {"," if (k.startsWith('#')) continue;"," if (k in this.state) this.state[k] = v;"," }"," } catch {}"," this.removeAttribute('data-jx-props');"," }"," const _pn = this.getAttributeNames().filter(n => n.startsWith('props.') && n.length > 6);"," for (const _n of _pn) {"," const _k = _n.slice(6);"," if (_k.startsWith('#')) { this.removeAttribute(_n); continue; }"," if (_k in this.state) {"," this.state[_k] = this.getAttribute(_n);"," this.removeAttribute(_n);"," }"," }"," for (const key of Object.keys(this.state)) {"," if (key.startsWith('#')) continue;"," if (this.hasOwnProperty(key) && this[key] !== undefined) {"," this.state[key] = this[key];"," }"," }");for(let[b,y]of f)i.push(ur(b,y,{collect:"this.#effects",indent:" ",statePrefix:"this.state"}));for(let[b,y]of p)i.push(fr(b,y,{collect:"this.#effects",indent:" ",serverBaseUrl:o,statePrefix:"this.state"}));if(J(e.style)){let b=[];for(let[y,j]of Object.entries(e.style)){if(y.startsWith(":")||y.startsWith(".")||y.startsWith("&")||y.startsWith("[")||y.startsWith("@"))continue;if(S(j)&&j.includes("${"))b.push([he(y),j])}if(b.length>0){i.push(" this.#effects.push(effect(() => {");for(let[y,j]of b){let C=j.replaceAll(/\$\{([^}]+)\}/g,(v,ne)=>`\${${Ft(ne,"this.state")}}`);i.push(` this.style['${y}'] = \`${C}\`;`)}i.push(" }));")}}if(d)i.push(` const _slotted = ${Ms}(this);`);if(i.push(" if (this.hasAttribute('data-jx-prerendered')) {"," this.removeAttribute('data-jx-prerendered');"," }"),s===null)i.push(" this.replaceChildren();"," this.#effects.push(effect(() => render(this.template(), this)));");else i.push(" const _root = this.#renderRoot();"," for (const _n of [..._root.childNodes]) {"," if (!(_n.nodeType === 1 && _n.tagName === 'LINK')) _n.remove();"," }"," this.#effects.push(effect(() => render(this.template(), _root)));");if(d)i.push(` ${Fs}(this, _slotted);`);return i.push(" if (typeof this.state.onMount === 'function') {"," queueMicrotask(() => this.state.onMount(this.state));"," }"," }",""," disconnectedCallback() {"," for (const _e of this.#effects) { stop(_e); }"," this.#effects.length = 0;"," if (typeof this.state.onUnmount === 'function') { this.state.onUnmount(this.state); }"," }","}","",`customElements.define('${e.tagName}', ${t});`,""),i.join(`
99
+ `)}function El(){return{byText:new Map,decls:[]}}function Jl(e,t){let n=e.byText.get(t);if(n)return n;let r=`_c${e.decls.length}`;e.decls.push(` const ${r} = html\`
91
100
  ${t}
92
- \`;`);let s=`\${${r}}`;return e.byText.set(t,s),s}function Br(e,t,n,r=!1,s=!1,o=null,i=!1){if(!e)return"";let c=i?Dt:"";if(ne(e))return`${qa(e,n)}${c}`;if(!Array.isArray(e))return"";return e.map((a)=>{if(ne(a))return`${qa(a,n)}${c}`;let l=go(a,r?"":n,r,s,o);return b(a)&&a.includes("${")||A(a)&&Me(a.tagName)?`${l}${c}`:l}).join(r?"":`
93
- `)}function go(e,t,n=!1,r=!1,s=null,o=null){if(b(e)){if(e.includes("${"))return`${t}${Ur(e)}`;return`${t}${_(e)}`}if(se(e)||me(e))return`${t}${_(String(e))}`;if(!A(e))return"";if(Me(e.tagName)){let g=e.tagName.$expression,m=Ge(g.target,{eventParam:"e",statePrefix:"s"}),x=g.operator==="?:"?[[!0,g.value],[!1,g.initial]]:[...Object.entries(g.cases),["__default__",g.default]],E=x.map(([,y])=>y),O=E.map((y)=>n||lt.has(y)),J=null;if(s&&O.every((y)=>y===O[0])){let y=Ua(e,`${t} `,O[0]===!0,r,s,E.some((w)=>w.includes("-")));if(y.trim()!=="")J=Ga(s,y)}let C=x.map(([y,w])=>{let N={...e,tagName:w};return[y,go(N,`${t} `,n,r,s,J)]});if(g.operator==="?:"){let[,y]=C[0],[,w]=C[1];return`${t}\${${m}
101
+ \`;`);let s=`\${${r}}`;return e.byText.set(t,s),s}function es(e,t,n,r=!1,s=!1,o=null,i=!1){if(!e)return"";let a=i?Wt:"";if(te(e))return`${bl(e,n)}${a}`;if(!Array.isArray(e))return"";return e.map((l)=>{if(te(l))return`${bl(l,n)}${a}`;let c=Po(l,r?"":n,r,s,o);return S(l)&&l.includes("${")||J(l)&&Me(l.tagName)?`${c}${a}`:c}).join(r?"":`
102
+ `)}function Po(e,t,n=!1,r=!1,s=null,o=null){if(S(e)){if(e.includes("${"))return`${t}${ts(e)}`;return`${t}${k(e)}`}if(re(e)||ge(e))return`${t}${k(String(e))}`;if(!J(e))return"";if(Me(e.tagName)){let g=e.tagName.$expression,m=Ye(g.target,{eventParam:"e",statePrefix:"s"}),x=g.operator==="?:"?[[!0,g.value],[!1,g.initial]]:[...Object.entries(g.cases),["__default__",g.default]],w=x.map(([,y])=>y),N=w.map((y)=>n||ct.has(y)),E=null;if(s&&N.every((y)=>y===N[0])){let y=Sl(e,`${t} `,N[0]===!0,r,s,w.some((j)=>j.includes("-")));if(y.trim()!=="")E=Jl(s,y)}let O=x.map(([y,j])=>{let C={...e,tagName:j};return[y,Po(C,`${t} `,n,r,s,E)]});if(g.operator==="?:"){let[,y]=O[0],[,j]=O[1];return`${t}\${${m}
94
103
  ? html\`
95
104
  ${y}
96
105
  \`
97
106
  : html\`
98
- ${w}
99
- \`}`}let q=C.flatMap(([y,w])=>y==="__default__"?[]:[` ${JSON.stringify(y)}: html\`
100
- ${w}
101
- \``]),[,S]=C.at(-1);return`${t}\${{
102
- ${q.join(`,
107
+ ${j}
108
+ \`}`}let K=O.flatMap(([y,j])=>y==="__default__"?[]:[` ${JSON.stringify(y)}: html\`
109
+ ${j}
110
+ \``]),[,b]=O.at(-1);return`${t}\${{
111
+ ${K.join(`,
103
112
  `)}
104
113
  }[String(${m})] ?? html\`
105
- ${S}
106
- \`}`}let i=e.tagName??"div",c=n||lt.has(i),a=[];if(e.attributes)for(let[g,m]of Object.entries(e.attributes))if(H(m))a.push(`${g}="\${${Mt}('${g}', ${Ve(m.$ref)}) ?? nothing}"`);else if(b(m)&&Wu(m))a.push(`${g}="\${${Mt}('${g}', ${Oe(m).slice(2,-1)}) ?? nothing}"`);else if(b(m)&&m.includes("${"))a.push(`${g}="${Oe(m)}"`);else if(me(m)){let x=$t(g,m);if(x!==null)a.push(x===""?g:`${g}="${x}"`)}else a.push(`${g}="${m}"`);if(e.id)a.push(`id="${Oe(String(e.id))}"`);if(e.className)a.push(`class="${Oe(String(e.className))}"`);for(let[g,m]of Object.entries(e)){if(Ye.has(g)||g.startsWith("$")||g.startsWith("on")||g==="tagName"||g==="id"||g==="className"||g==="style"||g==="children"||g==="textContent"||g==="innerHTML"||g==="attributes")continue;if(Hr(m))a.push(`.${g}="\${${Ve(m.$ref)}}"`);else if(b(m)&&m.includes("${"))a.push(`.${g}="${Oe(m)}"`);else a.push(`.${g}="\${${JSON.stringify(m)}}"`)}if(e.$props)for(let[g,m]of Object.entries(e.$props))if(Hr(m))a.push(`.${g}="\${${Ve(m.$ref)}}"`);else if(b(m)&&m.includes("${"))a.push(`.${g}="${Oe(m)}"`);else a.push(`.${g}="\${${JSON.stringify(m)}}"`);let l=r?"s.$map = $map; ":"";for(let[g,m]of Object.entries(e)){if(!g.startsWith("on")||g==="observedAttributes")continue;let x=g.slice(2).toLowerCase();if(Hr(m))a.push(l?`@${x}="\${(e) => { ${l}${Ve(m.$ref)}(s, e); }}"`:`@${x}="\${(e) => ${Ve(m.$ref)}(s, e)}"`);else if(A(m)&&"$expression"in m){let E=pe(m.$expression,{eventParam:"e",statePrefix:"s"});a.push(`@${x}="\${(e) => { ${l}${E}; }}"`)}else if(be(m))a.push(`@${x}="\${(e) => { ${l}${Vu(m)} }}"`)}let u=Xa(e.style);if(u)a.push(`style="${u}"`);let f=a.length>0?`
107
- ${t} ${a.join(`
114
+ ${b}
115
+ \`}`}let i=e.tagName??"div",a=n||ct.has(i),l=[];if(e.attributes)for(let[g,m]of Object.entries(e.attributes))if(H(m))l.push(`${g}="\${${Lt}('${g}', ${He(m.$ref)}) ?? nothing}"`);else if(S(m)&&kf(m))l.push(`${g}="\${${Lt}('${g}', ${Ce(m).slice(2,-1)}) ?? nothing}"`);else if(S(m)&&m.includes("${"))l.push(`${g}="${Ce(m)}"`);else if(ge(m)){let x=St(g,m);if(x!==null)l.push(x===""?g:`${g}="${x}"`)}else l.push(`${g}="${m}"`);if(e.id)l.push(`id="${Ce(String(e.id))}"`);if(e.className)l.push(`class="${Ce(String(e.className))}"`);for(let[g,m]of Object.entries(e)){if(Xe.has(g)||g.startsWith("$")||g.startsWith("on")||g==="tagName"||g==="id"||g==="className"||g==="style"||g==="children"||g==="textContent"||g==="innerHTML"||g==="attributes")continue;if(Qr(m))l.push(`.${g}="\${${He(m.$ref)}}"`);else if(S(m)&&m.includes("${"))l.push(`.${g}="${Ce(m)}"`);else l.push(`.${g}="\${${JSON.stringify(m)}}"`)}if(e.$props)for(let[g,m]of Object.entries(e.$props))if(Qr(m))l.push(`.${g}="\${${He(m.$ref)}}"`);else if(S(m)&&m.includes("${"))l.push(`.${g}="${Ce(m)}"`);else l.push(`.${g}="\${${JSON.stringify(m)}}"`);let c=r?"s.$map = $map; ":"";for(let[g,m]of Object.entries(e)){if(!g.startsWith("on")||g==="observedAttributes")continue;lt(`inline "${g}" handler`,m);let x=g.slice(2).toLowerCase();if(Qr(m))l.push(c?`@${x}="\${(e) => { ${c}${He(m.$ref)}(s, e); }}"`:`@${x}="\${(e) => ${He(m.$ref)}(s, e)}"`);else if(J(m)&&"$expression"in m){let w=de(m.$expression,{eventParam:"e",statePrefix:"s"});l.push(`@${x}="\${(e) => { ${c}${w}; }}"`)}else if(se(m))l.push(`@${x}="\${(e) => { ${c}${Al(m)} }}"`)}let u=Ol(e.style);if(u)l.push(`style="${u}"`);let f=l.length>0?`
116
+ ${t} ${l.join(`
108
117
  ${t} `)}`:"";if(new Set(["input","br","hr","img","meta","link"]).has(i))return`${t}<${i}${f}
109
- ${t}>`;let d=o??Ua(e,t,c,r,s,i.includes("-")),h=i==="slot"?Dt:"";return c?`${h}<${i}${f}>${d}${h}</${i}>`:`${t}${h}<${i}${f}
110
- ${t}>${d}${h}</${i}>`}function Ua(e,t,n,r,s,o=!1){if(e.$switch){let i=H(e.$switch)?e.$switch.$ref:e.$switch,c=Ve(i),a=[];for(let[p,d]of Object.entries(e.cases??{})){if(!d||H(d))continue;a.push([p,go(d,`${t} `,!1,r,s)])}let l=a.map(([,p])=>p),u=new Set(l.filter((p,d)=>l.indexOf(p)!==d&&p.trim()!==""));return`\${{
111
- ${a.map(([p,d])=>{let h=s&&u.has(d)?Ga(s,d):d;return` ${JSON.stringify(p)}: html\`
118
+ ${t}>`;let d=o??Sl(e,t,a,r,s,i.includes("-")),h=i==="slot"?Wt:"";return a?`${h}<${i}${f}>${d}${h}</${i}>`:`${t}${h}<${i}${f}
119
+ ${t}>${d}${h}</${i}>`}function Sl(e,t,n,r,s,o=!1){if(e.$switch){let i=H(e.$switch)?e.$switch.$ref:e.$switch,a=He(i),l=[];for(let[p,d]of Object.entries(e.cases??{})){if(!d||H(d))continue;l.push([p,Po(d,`${t} `,!1,r,s)])}let c=l.map(([,p])=>p),u=new Set(c.filter((p,d)=>c.indexOf(p)!==d&&p.trim()!==""));return`\${{
120
+ ${l.map(([p,d])=>{let h=s&&u.has(d)?Jl(s,d):d;return` ${JSON.stringify(p)}: html\`
112
121
  ${h}
113
122
  \``}).join(`,
114
123
  `)}
115
- }[${c}]}`}if(e.textContent!==void 0){let i=Ur(e.textContent),c=H(e.textContent)||b(e.textContent)&&e.textContent.includes("${");return o&&c?`${i}${Dt}`:i}if(e.innerHTML!==void 0)return e.innerHTML;if(e.children)return n?Br(e.children,e.style,"",!0,r,s,o):`
116
- ${Br(e.children,e.style,`${t} `,!1,r,s,o)}
117
- ${t}`;return""}function qa(e,t){let n=H(e.items)?Ve(e.items.$ref):"ITEMS",r=e.map;if(!r)return"";let s=r.tagName??"div",o=[];if(r.attributes)for(let[d,h]of Object.entries(r.attributes))if(H(h))o.push(`${d}="\${${mo(h.$ref)}}"`);else if(b(h)&&h.includes("${"))o.push(`${d}="${Oe(h)}"`);else o.push(`${d}="${h}"`);if(r.id)o.push(`id="${Oe(String(r.id))}"`);if(r.className)o.push(`class="${Oe(String(r.className))}"`);for(let[d,h]of Object.entries(r)){if(Ye.has(d)||d.startsWith("$")||d.startsWith("on")||d==="tagName"||d==="id"||d==="className"||d==="style"||d==="children"||d==="textContent"||d==="innerHTML"||d==="attributes")continue;if(Hr(h))o.push(`.${d}="\${${mo(h.$ref)}}"`);else if(b(h)&&h.includes("${"))o.push(`.${d}="${Oe(h)}"`);else o.push(`.${d}="\${${JSON.stringify(h)}}"`)}if(r.$props)for(let[d,h]of Object.entries(r.$props))if(H(h))o.push(`.${d}="\${${mo(h.$ref)}}"`);else if(b(h)&&h.includes("${"))o.push(`.${d}="${Oe(h)}"`);else o.push(`.${d}="\${${JSON.stringify(h)}}"`);let i=Xa(r.style);if(i)o.push(`style="${i}"`);for(let[d,h]of Object.entries(r)){if(!d.startsWith("on"))continue;let g=d.slice(2).toLowerCase();if(H(h))o.push(`@${g}="\${(e) => { s.$map = $map; ${Ve(h.$ref)}(s, e); }}"`);else if(we(h)){let m=pe(h.$expression,{eventParam:"e",statePrefix:"s"});o.push(`@${g}="\${(e) => { s.$map = $map; ${m}; }}"`)}}let c=o.length>0?`
124
+ }[${a}]}`}if(e.textContent!==void 0){let i=ts(e.textContent),a=H(e.textContent)||S(e.textContent)&&e.textContent.includes("${");return o&&a?`${i}${Wt}`:i}if(e.innerHTML!==void 0)return e.innerHTML;if(e.children)return n?es(e.children,e.style,"",!0,r,s,o):`
125
+ ${es(e.children,e.style,`${t} `,!1,r,s,o)}
126
+ ${t}`;return""}function bl(e,t){let n=H(e.items)?He(e.items.$ref):"ITEMS",r=e.map;if(!r)return"";let s=r.tagName??"div",o=[];if(r.attributes)for(let[d,h]of Object.entries(r.attributes))if(H(h))o.push(`${d}="\${${_o(h.$ref)}}"`);else if(S(h)&&h.includes("${"))o.push(`${d}="${Ce(h)}"`);else o.push(`${d}="${h}"`);if(r.id)o.push(`id="${Ce(String(r.id))}"`);if(r.className)o.push(`class="${Ce(String(r.className))}"`);for(let[d,h]of Object.entries(r)){if(Xe.has(d)||d.startsWith("$")||d.startsWith("on")||d==="tagName"||d==="id"||d==="className"||d==="style"||d==="children"||d==="textContent"||d==="innerHTML"||d==="attributes")continue;if(Qr(h))o.push(`.${d}="\${${_o(h.$ref)}}"`);else if(S(h)&&h.includes("${"))o.push(`.${d}="${Ce(h)}"`);else o.push(`.${d}="\${${JSON.stringify(h)}}"`)}if(r.$props)for(let[d,h]of Object.entries(r.$props))if(H(h))o.push(`.${d}="\${${_o(h.$ref)}}"`);else if(S(h)&&h.includes("${"))o.push(`.${d}="${Ce(h)}"`);else o.push(`.${d}="\${${JSON.stringify(h)}}"`);let i=Ol(r.style);if(i)o.push(`style="${i}"`);for(let[d,h]of Object.entries(r)){if(!d.startsWith("on"))continue;lt(`inline "${d}" handler`,h);let g=d.slice(2).toLowerCase();if(H(h))o.push(`@${g}="\${(e) => { s.$map = $map; ${He(h.$ref)}(s, e); }}"`);else if(Ee(h)){let m=de(h.$expression,{eventParam:"e",statePrefix:"s"});o.push(`@${g}="\${(e) => { s.$map = $map; ${m}; }}"`)}else if(se(h))o.push(`@${g}="\${(e) => { s.$map = $map; ${Al(h)} }}"`)}let a=o.length>0?`
118
127
  ${t} ${o.join(`
119
- ${t} `)}`:"",a=Ka(),l="";if(r.textContent!==void 0)l=Ur(r.textContent);else if(r.children)l=`
120
- ${Br(r.children,null,`${t} `,!1,!0,a)}
128
+ ${t} `)}`:"",l=El(),c="";if(r.textContent!==void 0)c=ts(r.textContent);else if(r.children)c=`
129
+ ${es(r.children,null,`${t} `,!1,!0,l)}
121
130
  ${t} `;let u=`html\`
122
- ${t} <${s}${c}
123
- ${t} >${l}</${s}>
124
- ${t}\``,f=(u.includes("$map")?"const $map = { item, index }; ":"")+a.decls.map((d)=>`${d.trim()} `).join(""),p=f?`(item, index) => { ${f}return ${u}; }`:`(item, index) => ${u}`;return`${t}\${${n}.map(${p})}`}function Hr(e){return H(e)&&e.$ref!==""}function Ve(e){if(e.startsWith("#/state/"))return k("s",e.slice(8));if(e.startsWith("$map/"))return Ya(e.slice(5));if(e.startsWith("parent#/"))return k("s",e.slice(8));if(e.startsWith("window#/"))return k("window",e.slice(8));if(e.startsWith("document#/"))return k("document",e.slice(10));return k("s",e)}function Ya(e){let[t,...n]=qe(e);return k(t??"",n.map((r)=>re(r)).join("/"))}function mo(e){if(e.startsWith("$map/"))return Ya(e.slice(5));return Ve(e)}function Oe(e){return e.replaceAll("state.","s.")}function Wu(e){return e.startsWith("${")&&e.endsWith("}")&&!e.slice(2).includes("${")}function Ur(e){if(H(e))return`\${${Ve(e.$ref)}}`;if(b(e)&&e.includes("${"))return Oe(e);return String(e)}function Vu(e){if(st(e))return Ce(e.body,{dispatchTarget:"e.currentTarget",eventParam:"e",statePrefix:"s"});let t=b(e.body)?e.body:"",n=e.parameters?Be(e.parameters):e.arguments??[];if(n.length>0){let r=n.map((s)=>s==="state"?"s":"e").join(", ");return`((${n.join(", ")}) => { ${t} })(${r});`}return t.replaceAll(/(?<!this\.)state\./g,"s.").replaceAll(/(?<!this\.)state(?!\.)/g,"s")}function Xa(e){if(!A(e))return"";let t=[];for(let[n,r]of Object.entries(e)){if(n.startsWith(":")||n.startsWith(".")||n.startsWith("&")||n.startsWith("[")||n.startsWith("@"))continue;if(b(r)&&r.includes("${")){let s=ge(n);t.push(`${s}: ${Oe(r)}`)}}return t.join("; ")}var Ba;var qr=j(()=>{gn();Lt();z();Fr();Tt();Ba=new Set(["onMount","onUnmount","onAdopted"])});function Za(e,t){let{title:n="Jx App",reactivitySrc:r,litHtmlSrc:s}=t,o=It(e,null,e.state??{},e.$media??{}),i=Ft(e,e.$media??{},t.projectStyle??null),c=[],a=Qa(e,!1,o,c),l=[],u="",f="";if(c.length>0){for(let h of c){let g=Ln(h.def,h.className,[],t.rewriteSrc);l.push({content:g,path:`_islands/${h.tagName}.js`,tagName:h.tagName})}u=`<script type="importmap">
131
+ ${t} <${s}${a}
132
+ ${t} >${c}</${s}>
133
+ ${t}\``,f=(u.includes("$map")?"const $map = { item, index }; ":"")+l.decls.map((d)=>`${d.trim()} `).join(""),p=f?`(item, index) => { ${f}return ${u}; }`:`(item, index) => ${u}`;return`${t}\${${n}.map(${p})}`}function Qr(e){return H(e)&&e.$ref!==""}function He(e){if(e.startsWith("#/state/"))return L("s",e.slice(8));if(e.startsWith("$map/"))return Nl(e.slice(5));if(e.startsWith("parent#/"))return L("s",e.slice(8));if(e.startsWith("window#/"))return L("window",e.slice(8));if(e.startsWith("document#/"))return L("document",e.slice(10));return L("s",e)}function Nl(e){let[t,...n]=ze(e);return L(t??"",n.map((r)=>pe(r)).join("/"))}function _o(e){if(e.startsWith("$map/"))return Nl(e.slice(5));return He(e)}function Ce(e){return Ft(e,"s",{code:!1})}function kf(e){return e.startsWith("${")&&e.endsWith("}")&&!e.slice(2).includes("${")}function ts(e){if(H(e))return`\${${He(e.$ref)}}`;if(S(e)&&e.includes("${"))return Ce(e);return String(e)}function Al(e){if(De(e))return je(e.body,{dispatchTarget:"e.currentTarget",eventParam:"e",statePrefix:"s"});let t=S(e.body)?e.body:"";if(dn(e))return`((${Fe(e).join(", ")}) => { ${t}
134
+ })(s, e);`;return`${Ft(t,"s",{bare:!0})}
135
+ `}function Ol(e){if(!J(e))return"";let t=[];for(let[n,r]of Object.entries(e)){if(n.startsWith(":")||n.startsWith(".")||n.startsWith("&")||n.startsWith("[")||n.startsWith("@"))continue;if(S(r)&&r.includes("${")){let s=he(n);t.push(`${s}: ${Ce(r)}`)}}return t.join("; ")}var ns=A(()=>{Yn();mn();bn();Bt();U();Gr();_t()});function Cl(e,t){let{title:n="Jx App",reactivitySrc:r,litHtmlSrc:s}=t,o=Mt(e,null,e.state??{},e.$media??{}),i=Vt(e,e.$media??{},t.projectStyle??null),a=[],l=jl(e,!1,o,a),c=[],u="",f="";if(a.length>0){for(let h of a){let g=qn(h.def,h.className,[],t.rewriteSrc);c.push({content:g,path:`_islands/${h.tagName}.js`,tagName:h.tagName})}u=`<script type="importmap">
125
136
  {
126
137
  "imports": {
127
138
  "@vue/reactivity": "${r}",
128
139
  "lit-html": "${s}"
129
140
  }
130
141
  }
131
- </script>`,f=l.map((h)=>`<script type="module" src="./${h.path}"></script>`).join(`
132
- `)}let p=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((h)=>Ue(String(h))!==null)?`<script>${ir()}</script>
142
+ </script>`,f=c.map((h)=>`<script type="module" src="./${h.path}"></script>`).join(`
143
+ `)}let p=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((h)=>qe(String(h))!==null)?`<script>${hr()}</script>
133
144
  `:"",d=`<!DOCTYPE html>
134
145
  <html lang="en">
135
146
  <head>
136
147
  <meta charset="utf-8">
137
148
  <meta name="viewport" content="width=device-width, initial-scale=1">
138
- <title>${_(n)}</title>
149
+ <title>${k(n)}</title>
139
150
  ${p}${u}
140
151
  ${i}
141
152
  </head>
142
153
  <body>
143
- ${a}
154
+ ${l}
144
155
  ${f}
145
156
  </body>
146
- </html>`;return{files:l,html:d}}function Qa(e,t,n,r){if(b(e))return _(e);if(se(e)||me(e))return _(String(e));if(!A(e))return"";let s=It(e,n.scope,e.state??n.scopeDefs,e.$media??n.media);if(t){let l=r.length,u=`jx-island-${l}`,f=`JxIsland${l}`,p={...e,tagName:u};return r.push({className:f,def:p,tagName:u}),`<${u}></${u}>`}let o=Es(e.tagName,s.scope),i=St(e,s.scope);if(ws.has(o))return`<${o}${i}>`;let c=n.preformatted===!0||lt.has(o),a=Hu(e,{...s,preformatted:c},r);return`<${o}${i}>${a}</${o}>`}function Hu(e,t,n){if(e.textContent!==void 0){let r=B(e.textContent,t.scope);return r==null?"":_(String(r))}if(e.innerHTML){let r=B(e.innerHTML,t.scope);return r==null?e.innerHTML:String(r)}if(Array.isArray(e.children))return e.children.map((r)=>Qa(r,si(r),t,n)).join(yn(t.preformatted));return""}var el=j(()=>{Lt();qr();z()});function $o(e,t){let{title:n="Jx App",reactivitySrc:r=nr,litHtmlSrc:s=rr,modulePath:o="app.js",serverBaseUrl:i="/_jx/server"}=t,c=It(e,null,e.state??{},e.$media??{}),a=Ft(e,e.$media??{},t.projectStyle??null),l={h:0,l:0,m:0,needsLit:!1,s:0,sw:0,t:0},u=new Map,f=new Map,p=[],d=[],h=[],g=[],m=[],x=[],E=new Map,O=e.state??{};for(let[w,N]of Object.entries(O)){if(!A(N)||Array.isArray(N)){if(L(N))d.push([w,`() => ${or(N)}`]);else p.push([w,N]);continue}if(we(N)){let Z=N.$expression,te=pe(Z,{eventParam:"e",statePrefix:"state"});if(xt(N))m.push(`state[${JSON.stringify(w)}] = ${xn(N,te)};`);else if(Ke(Z.operator))g.push([w,{args:["state","e"],body:te}]);else d.push([w,`() => ${te}`]);continue}if(be(N)){let Z=N.parameters?Be(N.parameters):N.arguments,{body:te}=N;if(Array.isArray(te)){let Te=Ce(te,{eventParam:"e",statePrefix:"state"});if(N.parameters&&N.parameters.length>0)m.push(`state[${JSON.stringify(w)}] = ${xn(N,`(() => {
147
- ${Te}
148
- })()`)};`);else g.push([w,{args:["state","e"],body:Te}])}else if(N.$src){let Te=E.get(N.$src);if(!Te)Te=new Set,E.set(N.$src,Te);Te.add(Qn(w,N)),d.push([w,`() => { return ${w}(state); }`])}else if(b(te)&&yt(te))d.push([w,`() => { ${te} }`]);else g.push([w,{args:Z??["state"],body:te}]);continue}if(it(N))continue;if(Jo(N)){p.push([w,N.default]);continue}if(ot(N)){if(N.$prototype==="LocalStorage"||N.$prototype==="SessionStorage"){let Z=N.$prototype==="LocalStorage"?"localStorage":"sessionStorage",te=N.key??w,Te=N.default??null;p.push([w,null]),m.push(Uu(w,Z,te,Te));continue}if(N.$prototype==="Request"){p.push([w,null]),m.push(er(w,N));continue}if(N.$prototype==="Cookie"){p.push([w,null]),m.push(qu(w,N.name??w,N.default??null));continue}}if(He(N)){p.push([w,null]),x.push(tr(w,N,{serverBaseUrl:i}));continue}p.push([w,N])}let J=tl(e,c,u,f,l);for(let[w,N]of u)if(!h.some(([Z])=>Z===w))h.push([w,N]);for(let[w,N]of f)if(!g.some(([Z])=>Z===w))g.push([w,N]);let C=Bu(p,d,h,g,m,x,E,l,r,t.rewriteSrc),q=[` "@vue/reactivity": "${r}"`,` "lit-html": "${s}"`],S=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((w)=>Ue(String(w))!==null)?`<script>${ir()}</script>
149
- `:"",y=`<!DOCTYPE html>
157
+ </html>`;return{files:c,html:d}}function jl(e,t,n,r){if(S(e))return k(e);if(re(e)||ge(e))return k(String(e));if(!J(e))return"";let s=Mt(e,n.scope,e.state??n.scopeDefs,e.$media??n.media);if(t){let c=r.length,u=`jx-island-${c}`,f=`JxIsland${c}`,p={...e,tagName:u};return r.push({className:f,def:p,tagName:u}),`<${u}></${u}>`}let o=Vs(e.tagName,s.scope),i=bt(e,s.scope);if(Ws.has(o))return`<${o}${i}>`;let a=n.preformatted===!0||ct.has(o),l=If(e,{...s,preformatted:a},r);return`<${o}${i}>${l}</${o}>`}function If(e,t,n){if(e.textContent!==void 0){let r=q(e.textContent,t.scope);return r==null?"":k(String(r))}if(e.innerHTML){let r=q(e.innerHTML,t.scope);return r==null?e.innerHTML:String(r)}if(Array.isArray(e.children))return e.children.map((r)=>jl(r,Pi(r),t,n)).join(Jn(t.preformatted));return""}var vl=A(()=>{Bt();ns();U()});function Mo(e,t){let{title:n="Jx App",reactivitySrc:r=pr,litHtmlSrc:s=dr,modulePath:o="app.js",serverBaseUrl:i="/_jx/server"}=t,a=Mt(e,null,e.state??{},e.$media??{}),l=$t(e),c=Vt(e,e.$media??{},t.projectStyle??null),u={h:0,l:0,m:0,needsLit:!1,s:0,sw:0,t:0},f=new Map,p=new Map,d=[],h=[],g=[],m=[],x=[],w=[],N=new Map,E=e.state??{};for(let[C,v]of Object.entries(E)){if(!J(v)||Array.isArray(v)){if(W(v))h.push([C,`() => ${gr(v)}`]);else d.push([C,v]);continue}if(Ee(v)){let ne=v.$expression,be=de(ne,{eventParam:"e",statePrefix:"state"});if(xt(v))x.push(`state[${JSON.stringify(C)}] = ${En(v,be)};`);else if(Ge(ne.operator))m.push([C,{args:["state","e"],body:be}]);else h.push([C,`() => ${be}`]);continue}if(se(v)){let{body:ne}=v;if(Array.isArray(ne)){let be=je(ne,{eventParam:"e",statePrefix:"state"});if(v.parameters&&v.parameters.length>0)x.push(`state[${JSON.stringify(C)}] = ${En(v,`(() => {
158
+ ${be}
159
+ })()`)};`);else m.push([C,{args:["state","e"],body:be}])}else if(v.$src){let be=N.get(v.$src);if(!be)be=new Set,N.set(v.$src,be);if(be.add(cr(C,v)),l.get(C)==="computed")h.push([C,`() => { return ${C}(state); }`]);else x.push(`state[${JSON.stringify(C)}] = ${C};`),m.push([C,{args:["state","event"],body:`return ${C}(state, event);`}])}else if(S(ne)&&l.get(C)==="computed")h.push([C,`() => { ${ne} }`]);else m.push([C,{args:Fe(v),body:ne}]);continue}if(it(v))continue;if(Bo(v)){d.push([C,v.default]);continue}if(ot(v)){if(v.$prototype==="LocalStorage"||v.$prototype==="SessionStorage"){let ne=v.$prototype==="LocalStorage"?"localStorage":"sessionStorage",be=v.key??C,Ll=v.default??null;d.push([C,null]),x.push(Ff(C,ne,be,Ll));continue}if(v.$prototype==="Request"){d.push([C,null]),x.push(ur(C,v));continue}if(v.$prototype==="Cookie"){d.push([C,null]),x.push(Lf(C,v.name??C,v.default??null));continue}}if(Ue(v)){d.push([C,null]),w.push(fr(C,v,{serverBaseUrl:i}));continue}d.push([C,v])}let O=Tl(e,a,f,p,u);for(let[C,v]of f)if(!g.some(([ne])=>ne===C))g.push([C,v]);for(let[C,v]of p)if(!m.some(([ne])=>ne===C))m.push([C,v]);let K=Mf(d,h,g,m,x,w,N,u,r,t.rewriteSrc),b=[` "@vue/reactivity": "${r}"`,` "lit-html": "${s}"`],y=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((C)=>qe(String(C))!==null)?`<script>${hr()}</script>
160
+ `:"",j=`<!DOCTYPE html>
150
161
  <html lang="en">
151
162
  <head>
152
163
  <meta charset="utf-8">
153
164
  <meta name="viewport" content="width=device-width, initial-scale=1">
154
- <title>${_(n)}</title>
155
- ${S}<script type="importmap">
165
+ <title>${k(n)}</title>
166
+ ${y}<script type="importmap">
156
167
  {
157
168
  "imports": {
158
- ${q.join(`,
169
+ ${b.join(`,
159
170
  `)}
160
171
  }
161
172
  }
162
173
  </script>
163
- ${a}
174
+ ${c}
164
175
  <script type="module" src="./${o}"></script>
165
176
  </head>
166
177
  <body>
167
- ${J}
178
+ ${O}
168
179
  </body>
169
- </html>`;return{files:[{content:C,path:o}],html:y}}function tl(e,t,n,r,s){if(b(e))return _(e);if(se(e)||me(e))return _(String(e));if(!A(e))return"";let o=It(e,t.scope,e.state??t.scopeDefs,e.$media??t.media);if(Me(e.tagName))throw Error(`A tag chosen at creation is not supported on a dynamic page yet (candidates: ${jt(e.tagName).join(", ")}). Move the element into a component, or give it a literal tagName.`);let i=e.tagName??"div";o.preformatted=t.preformatted===!0||lt.has(i);let c=[],a=!1;if(e.textContent!==void 0){let g=e.textContent;if(he(g)){let m=an(g.$ref);c.push(`:text-content="${m}"`),ho(n,m,g.$ref),a=!0}else if(L(g)){let m=`_t${s.t}`;s.t+=1,c.push(`:text-content="${m}"`),n.set(m,`() => \`${g}\``),a=!0}}for(let[g,m]of Object.entries(e)){if(!g.startsWith("on")||g==="observedAttributes")continue;let x=g.slice(2).toLowerCase();if(he(m)){let E=an(m.$ref);c.push(`@${x}="${E}"`),a=!0}else if(be(m)){let E=`_h${s.h}`;s.h+=1,c.push(`@${x}="${E}"`);let{body:O}=m;r.set(E,Array.isArray(O)?{args:["state","e"],body:Ce(O,{eventParam:"e",statePrefix:"state"})}:{args:m.parameters?Be(m.parameters):m.arguments??["state","event"],body:O}),a=!0}else if(we(m)){let E=`_h${s.h}`;s.h+=1,c.push(`@${x}="${E}"`);let O=pe(m.$expression,{eventParam:"e",statePrefix:"state"});r.set(E,{args:["state","e"],body:O}),a=!0}}if(A(e.style))for(let[g,m]of Object.entries(e.style)){if(g.startsWith(":")||g.startsWith(".")||g.startsWith("&")||g.startsWith("[")||g.startsWith("@"))continue;if(rl(m))continue;if(L(m)){let x=`_s${s.s}`;s.s+=1,c.push(`:style.${ge(g)}="${x}"`),n.set(x,`() => \`${m}\``),a=!0}}if(A(e.attributes)){for(let[g,m]of Object.entries(e.attributes))if(he(m)){let x=an(m.$ref);c.push(`:attr.${g}="${x}"`),ho(n,x,m.$ref),a=!0}else if(L(m)){let x=`_t${s.t}`;s.t+=1,c.push(`:attr.${g}="${x}"`),n.set(x,`() => \`${m}\``),a=!0}}for(let[g,m]of Object.entries(e)){if(Ye.has(g)||g.startsWith("on")||g.startsWith("$")||g==="tagName"||g==="id"||g==="className"||g==="style"||g==="children"||g==="textContent"||g==="innerHTML"||g==="attributes")continue;if(he(m)){let x=an(m.$ref);c.push(`:${ge(g)}="${x}"`),ho(n,x,m.$ref),a=!0}else if(L(m)){let x=`_t${s.t}`;s.t+=1,c.push(`:${ge(g)}="${x}"`),n.set(x,`() => \`${m}\``),a=!0}}let l=St(e,o.scope),u=a?" data-bind":"",f=c.length>0?` ${c.join(" ")}`:"",p="",d=e;if(d.$switch){s.needsLit=!0;let g=`_sw${s.sw}`;s.sw+=1;let m=he(d.$switch)?yo(d.$switch.$ref):`\`${String(d.$switch)}\``,x=d.cases??{},E=Object.entries(x).filter(([,J])=>J&&!he(J)).map(([J,C])=>`${JSON.stringify(J)}: html\`${xo(C,o.preformatted)}\``);n.set(g,`() => ({${E.join(", ")}})[String(${m})] ?? html\`\``),c.push(`:render="${g}"`);let O=` ${c.join(" ")}`;return`<${i}${l} data-bind${O}></${i}>`}if(d.textContent!==void 0&&!a){let g=B(d.textContent,o.scope);p=g==null?"":_(String(g))}else if(d.textContent!==void 0&&a){let g=B(d.textContent,o.scope);p=g==null?"":_(String(g))}else if(d.innerHTML){let g=B(d.innerHTML,o.scope);p=g==null?d.innerHTML:String(g)}else if(ne(d.children)){s.needsLit=!0;let g=`_list${s.l}`;s.l+=1;let m=d.children,x=he(m.items)?yo(m.items.$ref):JSON.stringify(m.items),E=So(m.map);n.set(g,`() => (${x} ?? []).map((item, index) => html\`${E}\`)`),c.push(`:render="${g}"`),a=!0;let O=" data-bind",J=` ${c.join(" ")}`;if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${l}${O}${J}>`;return`<${i}${l}${O}${J}></${i}>`}else if(Array.isArray(d.children)&&d.children.some((g)=>ne(g))){s.needsLit=!0;let g=`_children${s.l}`;s.l+=1;let m=d.children.map((E)=>xo(E,o.preformatted)).join(yn(o.preformatted," "));n.set(g,o.preformatted?`() => html\`${m}\``:`() => html\`
180
+ </html>`;return{files:[{content:K,path:o}],html:j}}function Tl(e,t,n,r,s){if(S(e))return k(e);if(re(e)||ge(e))return k(String(e));if(!J(e))return"";let o=Mt(e,t.scope,e.state??t.scopeDefs,e.$media??t.media);if(Me(e.tagName))throw Error(`A tag chosen at creation is not supported on a dynamic page yet (candidates: ${Tt(e.tagName).join(", ")}). Move the element into a component, or give it a literal tagName.`);let i=e.tagName??"div";o.preformatted=t.preformatted===!0||ct.has(i);let a=[],l=!1;if(e.textContent!==void 0){let g=e.textContent;if(xe(g)){let m=un(g.$ref);a.push(`:text-content="${m}"`),ko(n,m,g.$ref),l=!0}else if(W(g)){let m=`_t${s.t}`;s.t+=1,a.push(`:text-content="${m}"`),n.set(m,`() => \`${g}\``),l=!0}}for(let[g,m]of Object.entries(e)){if(!g.startsWith("on")||g==="observedAttributes")continue;lt(`inline "${g}" handler`,m);let x=g.slice(2).toLowerCase();if(xe(m)){let w=un(m.$ref);a.push(`@${x}="${w}"`),l=!0}else if(se(m)){let w=`_h${s.h}`;s.h+=1,a.push(`@${x}="${w}"`);let{body:N}=m;r.set(w,Array.isArray(N)?{args:["state","e"],body:je(N,{eventParam:"e",statePrefix:"state"})}:{args:dn(m)?Fe(m):["state","event"],body:N}),l=!0}else if(Ee(m)){let w=`_h${s.h}`;s.h+=1,a.push(`@${x}="${w}"`);let N=de(m.$expression,{eventParam:"e",statePrefix:"state"});r.set(w,{args:["state","e"],body:N}),l=!0}}if(J(e.style))for(let[g,m]of Object.entries(e.style)){if(g.startsWith(":")||g.startsWith(".")||g.startsWith("&")||g.startsWith("[")||g.startsWith("@"))continue;if(_l(m))continue;if(W(m)){let x=`_s${s.s}`;s.s+=1,a.push(`:style.${he(g)}="${x}"`),n.set(x,`() => \`${m}\``),l=!0}}if(J(e.attributes)){for(let[g,m]of Object.entries(e.attributes))if(xe(m)){let x=un(m.$ref);a.push(`:attr.${g}="${x}"`),ko(n,x,m.$ref),l=!0}else if(W(m)){let x=`_t${s.t}`;s.t+=1,a.push(`:attr.${g}="${x}"`),n.set(x,`() => \`${m}\``),l=!0}}for(let[g,m]of Object.entries(e)){if(Xe.has(g)||g.startsWith("on")||g.startsWith("$")||g==="tagName"||g==="id"||g==="className"||g==="style"||g==="children"||g==="textContent"||g==="innerHTML"||g==="attributes")continue;if(xe(m)){let x=un(m.$ref);a.push(`:${he(g)}="${x}"`),ko(n,x,m.$ref),l=!0}else if(W(m)){let x=`_t${s.t}`;s.t+=1,a.push(`:${he(g)}="${x}"`),n.set(x,`() => \`${m}\``),l=!0}}let c=bt(e,o.scope),u=l?" data-bind":"",f=a.length>0?` ${a.join(" ")}`:"",p="",d=e;if(d.$switch){s.needsLit=!0;let g=`_sw${s.sw}`;s.sw+=1;let m=xe(d.$switch)?Do(d.$switch.$ref):`\`${String(d.$switch)}\``,x=d.cases??{},w=Object.entries(x).filter(([,E])=>E&&!xe(E)).map(([E,O])=>`${JSON.stringify(E)}: html\`${Io(O,o.preformatted)}\``);n.set(g,`() => ({${w.join(", ")}})[String(${m})] ?? html\`\``),a.push(`:render="${g}"`);let N=` ${a.join(" ")}`;return`<${i}${c} data-bind${N}></${i}>`}if(d.textContent!==void 0&&!l){let g=q(d.textContent,o.scope);p=g==null?"":k(String(g))}else if(d.textContent!==void 0&&l){let g=q(d.textContent,o.scope);p=g==null?"":k(String(g))}else if(d.innerHTML){let g=q(d.innerHTML,o.scope);p=g==null?d.innerHTML:String(g)}else if(te(d.children)){s.needsLit=!0;let g=`_list${s.l}`;s.l+=1;let m=d.children,x=xe(m.items)?Do(m.items.$ref):JSON.stringify(m.items),w=Fo(m.map);n.set(g,`() => (${x} ?? []).map((item, index) => html\`${w}\`)`),a.push(`:render="${g}"`),l=!0;let N=" data-bind",E=` ${a.join(" ")}`;if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${c}${N}${E}>`;return`<${i}${c}${N}${E}></${i}>`}else if(Array.isArray(d.children)&&d.children.some((g)=>te(g))){s.needsLit=!0;let g=`_children${s.l}`;s.l+=1;let m=d.children.map((w)=>Io(w,o.preformatted)).join(Jn(o.preformatted," "));n.set(g,o.preformatted?`() => html\`${m}\``:`() => html\`
170
181
  ${m}
171
- \``),c.push(`:render="${g}"`),a=!0;let x=` ${c.join(" ")}`;return`<${i}${l} data-bind${x}></${i}>`}else if(Array.isArray(d.children))p=d.children.map((g)=>tl(g,o,n,r,s)).join(yn(o.preformatted));if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${l}${u}${f}>`;return`<${i}${l}${u}${f}>${p}</${i}>`}function So(e,t=!1){if(!e)return"";if(Me(e.tagName))throw Error(`A tag chosen at creation is not supported inside a dynamic page's repeater yet (candidates: ${jt(e.tagName).join(", ")}). Move the item into a component, or give it a literal tagName.`);let n=e.tagName??"div",r=t||lt.has(n),s="";if(e.id)s+=` id="${e.id}"`;if(e.className)s+=` class="${ht(e.className)}"`;if(A(e.$props))for(let[a,l]of Object.entries(e.$props))if(he(l))s+=` .${a}="\${${zu(l.$ref)}}"`;else if(L(l))s+=` .${a}="${ht(l)}"`;else s+=` .${a}="\${${JSON.stringify(l)}}"`;if(A(e.attributes))for(let[a,l]of Object.entries(e.attributes)){if(L(l)){s+=` ${a}="${ht(l)}"`;continue}if(me(l)){let u=$t(a,l);if(u!==null)s+=u===""?` ${a}`:` ${a}="${_(u)}"`;continue}s+=` ${a}="${_(String(l))}"`}if(A(e.style)){let a=[];for(let[l,u]of Object.entries(e.style)){if(l.startsWith(":")||l.startsWith(".")||l.startsWith("&")||l.startsWith("[")||l.startsWith("@"))continue;if(rl(u))continue;let f=ge(l);if(L(String(u)))a.push(`${f}: ${ht(String(u))}`);else a.push(`${f}: ${u}`)}if(a.length>0)s+=` style="${a.join("; ")}"`}for(let[a,l]of Object.entries(e)){if(!a.startsWith("on")||a==="observedAttributes")continue;let u=a.slice(2).toLowerCase();if(he(l)){let f=an(l.$ref);s+=` @${u}=\${(e) => { state.$map = { item, index }; on.${f}(e); }}`}else if(st(l)){let f=Ce(l.body,{eventParam:"e",statePrefix:"state"});s+=` @${u}=\${(e) => { state.$map = { item, index }; ${f} }}`}else if(be(l)){let f=ht(l.body);s+=` @${u}=\${(e) => { ${f} }}`}else if(A(l)&&"$expression"in l){let f=pe(l.$expression,{eventParam:"e",statePrefix:"state"});s+=` @${u}=\${(e) => { state.$map = { item, index }; ${f}; }}`}}if(e.contentEditable)s+=` contenteditable="${e.contentEditable}"`;let o=n.includes("-")?Dt:"",i="";if(e.textContent!==void 0){let a=String(e.textContent);if(L(a))i=`${ht(a)}${o}`;else if(he(e.textContent))i=`\${state.${an(e.textContent.$ref)}}${o}`;else i=_(a)}else if(e.innerHTML)i=ht(String(e.innerHTML));else if(ne(e.children))i=`
172
- ${nl(e.children)}${o}
173
- `;else if(Array.isArray(e.children)){let a=e.children.map((l)=>{let u=xo(l,r);return ne(l)||b(l)&&L(l)?`${u}${o}`:u});i=r?a.join(""):`
174
- ${a.join(`
182
+ \``),a.push(`:render="${g}"`),l=!0;let x=` ${a.join(" ")}`;return`<${i}${c} data-bind${x}></${i}>`}else if(Array.isArray(d.children))p=d.children.map((g)=>Tl(g,o,n,r,s)).join(Jn(o.preformatted));if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${c}${u}${f}>`;return`<${i}${c}${u}${f}>${p}</${i}>`}function Fo(e,t=!1){if(!e)return"";if(Me(e.tagName))throw Error(`A tag chosen at creation is not supported inside a dynamic page's repeater yet (candidates: ${Tt(e.tagName).join(", ")}). Move the item into a component, or give it a literal tagName.`);let n=e.tagName??"div",r=t||ct.has(n),s="";if(e.id)s+=` id="${e.id}"`;if(e.className)s+=` class="${vt(e.className)}"`;if(J(e.$props))for(let[l,c]of Object.entries(e.$props))if(xe(c))s+=` .${l}="\${${Wf(c.$ref)}}"`;else if(W(c))s+=` .${l}="${vt(c)}"`;else s+=` .${l}="\${${JSON.stringify(c)}}"`;if(J(e.attributes))for(let[l,c]of Object.entries(e.attributes)){if(W(c)){s+=` ${l}="${vt(c)}"`;continue}if(ge(c)){let u=St(l,c);if(u!==null)s+=u===""?` ${l}`:` ${l}="${k(u)}"`;continue}s+=` ${l}="${k(String(c))}"`}if(J(e.style)){let l=[];for(let[c,u]of Object.entries(e.style)){if(c.startsWith(":")||c.startsWith(".")||c.startsWith("&")||c.startsWith("[")||c.startsWith("@"))continue;if(_l(u))continue;let f=he(c);if(W(String(u)))l.push(`${f}: ${vt(String(u))}`);else l.push(`${f}: ${u}`)}if(l.length>0)s+=` style="${l.join("; ")}"`}for(let[l,c]of Object.entries(e)){if(!l.startsWith("on")||l==="observedAttributes")continue;lt(`inline "${l}" handler`,c);let u=l.slice(2).toLowerCase();if(xe(c)){let f=un(c.$ref);s+=` @${u}=\${(e) => { state.$map = { item, index }; on.${f}(e); }}`}else if(De(c)){let f=je(c.body,{eventParam:"e",statePrefix:"state"});s+=` @${u}=\${(e) => { state.$map = { item, index }; ${f} }}`}else if(se(c)){let f=Df(c.body),p=dn(c)?`((${Fe(c).join(", ")}) => { ${f}
183
+ })(state, e);`:`${f}
184
+ `;s+=` @${u}=\${(e) => { state.$map = { item, index }; ${p}}}`}else if(J(c)&&"$expression"in c){let f=de(c.$expression,{eventParam:"e",statePrefix:"state"});s+=` @${u}=\${(e) => { state.$map = { item, index }; ${f}; }}`}}if(e.contentEditable)s+=` contenteditable="${e.contentEditable}"`;let o=n.includes("-")?Wt:"",i="";if(e.textContent!==void 0){let l=String(e.textContent);if(W(l))i=`${vt(l)}${o}`;else if(xe(e.textContent))i=`\${state.${un(e.textContent.$ref)}}${o}`;else i=k(l)}else if(e.innerHTML)i=vt(String(e.innerHTML));else if(te(e.children))i=`
185
+ ${Rl(e.children)}${o}
186
+ `;else if(Array.isArray(e.children)){let l=e.children.map((c)=>{let u=Io(c,r);return te(c)||S(c)&&W(c)?`${u}${o}`:u});i=r?l.join(""):`
187
+ ${l.join(`
175
188
  `)}
176
- `}if(new Set(["input","br","hr","img","meta","link"]).has(n))return`<${n}${s}>`;return`<${n}${s}>${i}</${n}>`}function xo(e,t=!1){if(b(e))return L(e)?ht(e):_(e);if(se(e)||me(e))return _(String(e));if(ne(e))return nl(e);return So(e,t)}function nl(e){let{items:t}=e,n=he(t)?yo(t.$ref):JSON.stringify(t??[]),r=So(e.map);return`\${(${n} ?? []).map((item, index) => html\`${r}\`)}`}function ht(e){return e.replaceAll("$map.","")}function Bu(e,t,n,r,s,o,i,c,a,l){let u=[],{needsLit:f}=c,p=t.length>0;u.push("// Generated by @jxsuite/compiler — do not edit manually");let d=["reactive","effect"];if(p)d.push("computed");if(u.push(`import { ${d.join(", ")} } from '@vue/reactivity';`),f)u.push("import { html, render } from 'lit-html';");for(let[h,g]of i){let m=l?l(h):h;u.push(`import { ${[...g].join(", ")} } from '${m}';`)}if(u.push("",ar()),o.length>0)u.push("",lr());u.push("","const state = reactive({");for(let[h,g]of e)u.push(` ${ze(h)}: ${JSON.stringify(g)},`);if(u.push("});",""),s.length>0){for(let h of s)u.push(h);u.push("")}if(t.length>0){for(let[h,g]of t)u.push(`${k("state",re(h))} = computed(${g});`);u.push("")}if(o.length>0){for(let h of o)u.push(h);u.push("")}if(n.length>0){u.push("const bind = {");for(let[h,g]of n)u.push(` ${ze(h)}: ${g},`);u.push("};")}else u.push("const bind = {};");if(u.push(""),r.length>0){u.push("const on = {");for(let[h,g]of r){let m=g.args??["state"],x=m.map((E)=>E==="state"?"state":"e").join(", ");u.push(` ${ze(h)}: (e) => { const fn = (${m.join(", ")}) => { ${g.body} }; fn(${x}); },`)}u.push("};")}else u.push("const on = {};");if(u.push("","function hydrate(root) {"," root.querySelectorAll('[data-bind]').forEach(el => {"," [...el.attributes].forEach(a => {"," if (a.name.startsWith(':')) {"," const parts = a.name.slice(1).split('.');"," const key = a.value;"),f)u.push(" if (parts[0] === 'render') {"," effect(() => { render(bind[key](), el); });"," } else if (parts[0] === 'style' && parts.length > 1) {");else u.push(" if (parts[0] === 'style' && parts.length > 1) {");return u.push(" effect(() => { el.style[parts[1]] = bind[key](); });"," } else if (parts[0] === 'attr' && parts.length > 1) {"," effect(() => {",` const _t = ${Mt}(parts[1], bind[key]());`," if (_t === null) { el.removeAttribute(parts[1]); }"," else { el.setAttribute(parts[1], _t); }"," });"," } else {"," const prop = parts[0].replace(/-([a-z])/g, (_, c) => c.toUpperCase());"," effect(() => { el[prop] = bind[key](); });"," }"," } else if (a.name.startsWith('@')) {"," el.addEventListener(a.name.slice(1), on[a.value]);"," }"," });"," });","}","","hydrate(document);",""),u.join(`
177
- `)}function Uu(e,t,n,r){return[`// ${e}: ${t} (key: "${n}")`,"try {",` const _s = ${t}.getItem(${JSON.stringify(n)});`,` state.${e} = _s !== null ? JSON.parse(_s) : ${JSON.stringify(r)};`,`} catch { state.${e} = ${JSON.stringify(r)}; }`,"effect(() => {",` const v = state.${e};`," try {",` if (v === null) ${t}.removeItem(${JSON.stringify(n)});`,` else ${t}.setItem(${JSON.stringify(n)}, JSON.stringify(v));`," } catch {}","});"].join(`
178
- `)}function qu(e,t,n){return[`// ${e}: Cookie (name: "${t}")`,"{",` const _m = document.cookie.match(new RegExp("(?:^|; )${t}=([^;]*)"));`,` try { state.${e} = _m ? JSON.parse(decodeURIComponent(_m[1])) : ${JSON.stringify(n)}; }`,` catch { state.${e} = _m ? _m[1] : ${JSON.stringify(n)}; }`,"}"].join(`
179
- `)}function rl(e){return e===null||A(e)}function zu(e){if(e.startsWith("$map/")){let[t,...n]=qe(e.slice(5));return k(t??"",n.map((r)=>re(r)).join("/"))}if(e.startsWith("#/state/"))return k("state",e.slice(8));return k("state",e)}function yo(e){return _o("state",e.startsWith("#/state/")?e.slice(8):e)}function an(e){return Po(e.startsWith("#/state/")?e.slice(8):e)}function ho(e,t,n){if(e.has(t))return;e.set(t,`() => ${k("state",n.startsWith("#/state/")?n.slice(8):n)}`)}var bo=j(()=>{gn();Lt();z();Tt()});function Ku(e,t){if(t.routing==="prefix-except-default"&&e===t.defaultLocale)return"/";return`/${e.toLowerCase()}/`}function sl(e){if(e===null||e.locales.length<2)return"";let t=JSON.stringify(e.locales),n=JSON.stringify(e.defaultLocale),r=JSON.stringify(Object.fromEntries(e.locales.map((s)=>[s,Ku(s,e)])));return`
189
+ `}if(new Set(["input","br","hr","img","meta","link"]).has(n))return`<${n}${s}>`;return`<${n}${s}>${i}</${n}>`}function Io(e,t=!1){if(S(e))return W(e)?vt(e):k(e);if(re(e)||ge(e))return k(String(e));if(te(e))return Rl(e);return Fo(e,t)}function Rl(e){let{items:t}=e,n=xe(t)?Do(t.$ref):JSON.stringify(t??[]),r=Fo(e.map);return`\${(${n} ?? []).map((item, index) => html\`${r}\`)}`}function vt(e){return e.replaceAll("$map.","")}function Df(e){return e.replaceAll(/(?<![\w$.])\$map\./gu,"")}function Mf(e,t,n,r,s,o,i,a,l,c){let u=[],{needsLit:f}=a,p=t.length>0;u.push("// Generated by @jxsuite/compiler — do not edit manually");let d=["reactive","effect"];if(p)d.push("computed");if(u.push(`import { ${d.join(", ")} } from '@vue/reactivity';`),f)u.push("import { html, render } from 'lit-html';");for(let[h,g]of i){let m=c?c(h):h;u.push(`import { ${[...g].join(", ")} } from '${m}';`)}if(u.push("",xr()),o.length>0)u.push("",yr());u.push("","const state = reactive({");for(let[h,g]of e)u.push(` ${Ke(h)}: ${JSON.stringify(g)},`);if(u.push("});",""),s.length>0){for(let h of s)u.push(h);u.push("")}if(t.length>0){for(let[h,g]of t)u.push(`${L("state",pe(h))} = computed(${g});`);u.push("")}if(o.length>0){for(let h of o)u.push(h);u.push("")}if(n.length>0){u.push("const bind = {");for(let[h,g]of n)u.push(` ${Ke(h)}: ${g},`);u.push("};")}else u.push("const bind = {};");if(u.push(""),r.length>0){u.push("const on = {");for(let[h,g]of r)u.push(` ${Ke(h)}: (e) => { const fn = (${g.args.join(", ")}) => { ${g.body}
190
+ }; fn(state, e); },`);u.push("};")}else u.push("const on = {};");if(u.push("","function hydrate(root) {"," root.querySelectorAll('[data-bind]').forEach(el => {"," [...el.attributes].forEach(a => {"," if (a.name.startsWith(':')) {"," const parts = a.name.slice(1).split('.');"," const key = a.value;"),f)u.push(" if (parts[0] === 'render') {"," effect(() => { render(bind[key](), el); });"," } else if (parts[0] === 'style' && parts.length > 1) {");else u.push(" if (parts[0] === 'style' && parts.length > 1) {");return u.push(" effect(() => { el.style[parts[1]] = bind[key](); });"," } else if (parts[0] === 'attr' && parts.length > 1) {"," effect(() => {",` const _t = ${Lt}(parts[1], bind[key]());`," if (_t === null) { el.removeAttribute(parts[1]); }"," else { el.setAttribute(parts[1], _t); }"," });"," } else {"," const prop = parts[0].replace(/-([a-z])/g, (_, c) => c.toUpperCase());"," effect(() => { el[prop] = bind[key](); });"," }"," } else if (a.name.startsWith('@')) {"," el.addEventListener(a.name.slice(1), on[a.value]);"," }"," });"," });","}","","hydrate(document);",""),u.join(`
191
+ `)}function Ff(e,t,n,r){return[`// ${e}: ${t} (key: "${n}")`,"try {",` const _s = ${t}.getItem(${JSON.stringify(n)});`,` state.${e} = _s !== null ? JSON.parse(_s) : ${JSON.stringify(r)};`,`} catch { state.${e} = ${JSON.stringify(r)}; }`,"effect(() => {",` const v = state.${e};`," try {",` if (v === null) ${t}.removeItem(${JSON.stringify(n)});`,` else ${t}.setItem(${JSON.stringify(n)}, JSON.stringify(v));`," } catch {}","});"].join(`
192
+ `)}function Lf(e,t,n){return[`// ${e}: Cookie (name: "${t}")`,"{",` const _m = document.cookie.match(new RegExp("(?:^|; )${t}=([^;]*)"));`,` try { state.${e} = _m ? JSON.parse(decodeURIComponent(_m[1])) : ${JSON.stringify(n)}; }`,` catch { state.${e} = _m ? _m[1] : ${JSON.stringify(n)}; }`,"}"].join(`
193
+ `)}function _l(e){return e===null||J(e)}function Wf(e){if(e.startsWith("$map/")){let[t,...n]=ze(e.slice(5));return L(t??"",n.map((r)=>pe(r)).join("/"))}if(e.startsWith("#/state/"))return L("state",e.slice(8));return L("state",e)}function Do(e){return ci("state",e.startsWith("#/state/")?e.slice(8):e)}function un(e){return ui(e.startsWith("#/state/")?e.slice(8):e)}function ko(e,t,n){if(e.has(t))return;e.set(t,`() => ${L("state",n.startsWith("#/state/")?n.slice(8):n)}`)}var Lo=A(()=>{mn();bn();Bt();U();_t()});function Vf(e,t){if(t.routing==="prefix-except-default"&&e===t.defaultLocale)return"/";return`/${e.toLowerCase()}/`}function Pl(e){if(e===null||e.locales.length<2)return"";let t=JSON.stringify(e.locales),n=JSON.stringify(e.defaultLocale),r=JSON.stringify(Object.fromEntries(e.locales.map((s)=>[s,Vf(s,e)])));return`
180
194
  // ─── Locale negotiation (RFC 4647 Lookup over Accept-Language) ───────────────
181
195
  const JX_LOCALES = ${t}
182
196
  const JX_DEFAULT_LOCALE = ${n}
@@ -245,24 +259,24 @@ app.use('/', async (c, next) => {
245
259
  res.headers.set('Content-Language', locale)
246
260
  c.res = res
247
261
  })
248
- `}function Gu(e,t="/_jx/server"){return zo(e,t)}function Yu(e,t={}){let{adapter:n=null,mounts:r=[],connectors:s=[],i18n:o=null,base:i=""}=t,c=Gu(i,t.baseUrl);if(e.length===0&&r.length===0&&!n)return null;let a=e.map(({exportName:d,src:h})=>`import { ${d} } from '${h}'`).join(`
249
- `),l=Xu(r,s),u=e.map(({exportName:d})=>Zu(d,c)).join(`
262
+ `}function Bf(e,t="/_jx/server"){return Ei(e,t)}function Hf(e,t={}){let{adapter:n=null,mounts:r=[],connectors:s=[],i18n:o=null,base:i=""}=t,a=Bf(i,t.baseUrl);if(e.length===0&&r.length===0&&!n)return null;let l=e.map(({exportName:d,src:h})=>`import { ${d} } from '${h}'`).join(`
263
+ `),c=Uf(r,s),u=e.map(({exportName:d})=>qf(d,a)).join(`
250
264
  `),f=n==="cloudflare-workers"||n==="cloudflare-pages"?`
251
265
  app.all('*', (c) => c.env.ASSETS.fetch(c.req.raw))
252
266
  `:`
253
- `,p=sl(o);return`// Generated by @jxsuite/compiler — do not edit manually
267
+ `,p=Pl(o);return`// Generated by @jxsuite/compiler — do not edit manually
254
268
  import { Hono } from 'hono'
255
- ${a}${l.imports}
269
+ ${l}${c.imports}
256
270
 
257
271
  const app = new Hono()
258
- ${p}${l.routes}${u}
272
+ ${p}${c.routes}${u}
259
273
  ${f}
260
274
  export default app
261
- `}function Xu(e,t){if(e.length===0)return{imports:"",routes:""};let n=e.toSorted((o,i)=>o.order-i.order),r=[];for(let o of n)r.push(`import { ${o.className} } from '${o.module}'`);for(let o of t)r.push(`import { ${o.className} } from '${o.module}'`);let s=["// Extension server mounts (specs/extensions.md §11): one shared ctx, mounted in order.","const jxCtx = {}",`const jxConnectors = { ${t.map((o)=>`${JSON.stringify(o.provider)}: ${o.className}`).join(", ")} }`];for(let[o,i]of n.entries()){let c=JSON.stringify(i.options);s.push(`const jxMount${o} = await ${i.className}.mount({ ...${c}, connectors: jxConnectors }, jxCtx)`,`app.all('${i.basePath}/*', (c) => jxMount${o}(c.req.raw, c.env))`,`app.all('${i.basePath}', (c) => jxMount${o}(c.req.raw, c.env))`)}return{imports:`
275
+ `}function Uf(e,t){if(e.length===0)return{imports:"",routes:""};let n=e.toSorted((o,i)=>o.order-i.order),r=[];for(let o of n)r.push(`import { ${o.className} } from '${o.module}'`);for(let o of t)r.push(`import { ${o.className} } from '${o.module}'`);let s=["// Extension server mounts (specs/extensions.md §11): one shared ctx, mounted in order.","const jxCtx = {}",`const jxConnectors = { ${t.map((o)=>`${JSON.stringify(o.provider)}: ${o.className}`).join(", ")} }`];for(let[o,i]of n.entries()){let a=JSON.stringify(i.options);s.push(`const jxMount${o} = await ${i.className}.mount({ ...${a}, connectors: jxConnectors }, jxCtx)`,`app.all('${i.basePath}/*', (c) => jxMount${o}(c.req.raw, c.env))`,`app.all('${i.basePath}', (c) => jxMount${o}(c.req.raw, c.env))`)}return{imports:`
262
276
  ${r.join(`
263
277
  `)}`,routes:`${s.join(`
264
278
  `)}
265
- `}}function Zu(e,t){return`
279
+ `}}function qf(e,t){return`
266
280
  app.post('${t}/${e}', async (c) => {
267
281
  const args = await c.req.json().catch(() => ({}))
268
282
  try {
@@ -270,14 +284,14 @@ app.post('${t}/${e}', async (c) => {
270
284
  } catch (e) {
271
285
  return c.json({ ok: false, error: e?.message ?? 'Server error' }, 500)
272
286
  }
273
- })`}var ol=j(()=>{ls()});function al(e){let t=e.title;if(!t)throw Error("compileClassJson: missing title (class name)");let n=ef(e.extends),r=e.$defs,s=r?.fields??{},o=r?.constructor,i=Qu(o)?o:void 0,c=r?.methods??{},a=["// Generated by @jxsuite/compiler from .class.json — do not edit manually"];if(e.$id)a.push(`// Source: ${e.$id}`);a.push("");let l=n!=="Object"?` extends ${n}`:"";a.push(`class ${t}${l} {`);for(let[u,f]of Object.entries(s)){if(f.scope!=="static")continue;let p=f.identifier??u,d=f.access==="private"?"#":"",h=f.initializer!==void 0?JSON.stringify(f.initializer):f.default!==void 0?JSON.stringify(f.default):"null";a.push(` static ${d}${p} = ${h};`)}for(let[u,f]of Object.entries(s)){if(f.scope==="static")continue;if(f.access!=="private")continue;let p=f.identifier??u;a.push(` #${p};`)}if(Object.keys(s).length>0)a.push("");if(a.push(" constructor(config = {}) {"),i?.superCall||n!=="Object"){let u=i?.superCall?.arguments?i.superCall.arguments.join(", "):"";a.push(` super(${u});`)}for(let[u,f]of Object.entries(s)){if(f.scope==="static")continue;let p=f.identifier??u,d=f.access==="private"?"#":"",h=f.initializer!==void 0?JSON.stringify(f.initializer):f.default!==void 0?JSON.stringify(f.default):"null";a.push(` this.${d}${p} = config.${p} !== undefined ? config.${p} : ${h};`)}if(i?.body){let u=Array.isArray(i.body)?i.body:[i.body];for(let f of u)a.push(` ${f}`)}a.push(" }");for(let[u,f]of Object.entries(c)){let p=f.identifier??u,d=f.scope==="static",g=f.access==="private"?"#":"",m=d?"static ":"",x=f.returnType?.$ref?.includes("Promise")||nf(f)?"async ":"",E=il(f.parameters??[]),O=tf(f.body);if(a.push(""),f.role==="accessor"){if(f.getter)a.push(` ${m}get ${g}${p}() {`,` ${f.getter.body}`," }");if(f.setter){let J=il(f.setter.parameters??[]);a.push(` ${m}set ${g}${p}(${J}) {`,` ${f.setter.body}`," }")}}else{a.push(` ${m}${x}${g}${p}(${E}) {`);for(let J of O)a.push(` ${J}`);a.push(" }")}}return a.push("}","",`export { ${t} };`,`export default ${t};`,""),a.join(`
274
- `)}function Qu(e){return typeof e==="object"}function ef(e){if(!e)return"Object";if(b(e))return e;if(e.$ref){let t=e.$ref.match(/([A-Za-z0-9_]+)\.class\.json/);return t?t[1]:"Object"}return"Object"}function il(e){return e.map((t)=>{if(t.$ref)return t.$ref.split("/").pop();let n=t.identifier??t.name;return b(n)?n:"arg"}).join(", ")}function tf(e){if(!e)return[""];return Array.isArray(e)?e:[e]}function nf(e){return(Array.isArray(e.body)?e.body.join(`
275
- `):e.body??"").includes("await ")}var ll=j(()=>{z()});import{readFileSync as rf}from"node:fs";async function sf(e,t={}){let{title:n="Jx App",reactivitySrc:r=nr,litHtmlSrc:s=rr,projectStyle:o=null}=t,i;if(b(e)){let a=rf(e,"utf8");if(Pn(e))i=kn(a,e);else{let{extname:l}=await import("node:path"),u=l(e).toLowerCase(),f=t.formats?.byExtension(u,"parse");if(!f){await Promise.resolve().then(() => po());throw Vr(e,u)}i=await f.parseDocument(a)}}else i=e;if(Ao(i)){await Promise.resolve().then(() => ll());let l=al(i),u=b(e)?e.replace(/\.class\.json$/,".js"):`${i.title}.js`;return{files:[{content:l,path:u}],html:""}}if(!sr(i))return Za(i,{litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...cl(t),title:n});if(i.tagName&&i.tagName.includes("-")){let{tagName:a}=i,l=cr(a),f={content:Ln(i,l,[],t.rewriteSrc,null,t.serverBaseUrl),path:`${a}.js`,tagName:a},p=Ft(i,i.$media??{},o),d=`<!DOCTYPE html>
287
+ })`}var kl=A(()=>{As()});function Dl(e){let t=ni(e,e.title??"a class"),n=t.title;if(!n)throw Error("compileClassJson: missing title (class name)");let r=Kf(t.extends),s=t.$defs,o=s?.fields??{},i=s?.constructor,a=zf(i)?i:void 0,l=s?.methods??{},c=["// Generated by @jxsuite/compiler from .class.json — do not edit manually"];if(t.$id)c.push(`// Source: ${t.$id}`);c.push("");let u=r!=="Object"?` extends ${r}`:"";c.push(`class ${n}${u} {`);for(let[f,p]of Object.entries(o)){if(p.scope!=="static")continue;let d=p.identifier??f,h=p.access==="private"?"#":"",g=p.initializer!==void 0?JSON.stringify(p.initializer):p.default!==void 0?JSON.stringify(p.default):"null";c.push(` static ${h}${d} = ${g};`)}for(let[f,p]of Object.entries(o)){if(p.scope==="static")continue;if(p.access!=="private")continue;let d=p.identifier??f;c.push(` #${d};`)}if(Object.keys(o).length>0)c.push("");if(c.push(" constructor(config = {}) {"),a?.superCall||r!=="Object"){let f=a?.superCall?.arguments?a.superCall.arguments.join(", "):"";c.push(` super(${f});`)}for(let[f,p]of Object.entries(o)){if(p.scope==="static")continue;let d=p.identifier??f,h=p.access==="private"?"#":"",g=p.initializer!==void 0?JSON.stringify(p.initializer):p.default!==void 0?JSON.stringify(p.default):"null";c.push(` this.${h}${d} = config.${d} !== undefined ? config.${d} : ${g};`)}if(a?.body){let f=Array.isArray(a.body)?a.body:[a.body];for(let p of f)c.push(` ${p}`)}c.push(" }");for(let[f,p]of Object.entries(l)){let d=p.identifier??f,h=p.scope==="static",m=p.access==="private"?"#":"",x=h?"static ":"",w=p.returnType?.$ref?.includes("Promise")||Yf(p)?"async ":"",N=Il(p.parameters??[]),E=Gf(p.body);if(c.push(""),p.role==="accessor"){if(p.getter)c.push(` ${x}get ${m}${d}() {`,` ${p.getter.body}`," }");if(p.setter){let O=Il(p.setter.parameters??[]);c.push(` ${x}set ${m}${d}(${O}) {`,` ${p.setter.body}`," }")}}else{c.push(` ${x}${w}${m}${d}(${N}) {`);for(let O of E)c.push(` ${O}`);c.push(" }")}}return c.push("}","",`export { ${n} };`,`export default ${n};`,""),c.join(`
288
+ `)}function zf(e){return typeof e==="object"}function Kf(e){if(!e)return"Object";if(S(e))return e;if(e.$ref){let t=e.$ref.match(/([A-Za-z0-9_]+)\.class\.json/);return t?t[1]:"Object"}return"Object"}function Il(e){return e.map((t)=>{if(t.$ref)return t.$ref.split("/").pop();let n=t.identifier??t.name;return S(n)?n:"arg"}).join(", ")}function Gf(e){if(!e)return[""];return Array.isArray(e)?e:[e]}function Yf(e){return(Array.isArray(e.body)?e.body.join(`
289
+ `):e.body??"").includes("await ")}var Ml=A(()=>{Yn();U()});import{readFileSync as Xf}from"node:fs";async function Zf(e,t={}){let{title:n="Jx App",reactivitySrc:r=pr,litHtmlSrc:s=dr,projectStyle:o=null}=t,i;if(S(e)){let l=Xf(e,"utf8");if(Ln(e))i=Wn(l,e);else{let{extname:c}=await import("node:path"),u=c(e).toLowerCase(),f=t.formats?.byExtension(u,"parse");if(!f){await Promise.resolve().then(() => Ro());throw Zr(e,u)}i=await f.parseDocument(l)}}else i=e;if(i=pn(i,S(e)?e:"the document"),Uo(i)){await Promise.resolve().then(() => Ml());let c=Dl(i),u=S(e)?e.replace(/\.class\.json$/,".js"):`${i.title}.js`;return{files:[{content:c,path:u}],html:""}}if(!mr(i))return Cl(i,{litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...Fl(t),title:n});if(i.tagName&&i.tagName.includes("-")){let{tagName:l}=i,c=$r(l),f={content:qn(i,c,[],t.rewriteSrc,null,t.serverBaseUrl),path:`${l}.js`,tagName:l},p=Vt(i,i.$media??{},o),d=`<!DOCTYPE html>
276
290
  <html lang="en">
277
291
  <head>
278
292
  <meta charset="utf-8">
279
293
  <meta name="viewport" content="width=device-width, initial-scale=1">
280
- <title>${_(n)}</title>
294
+ <title>${k(n)}</title>
281
295
  <script type="importmap">
282
296
  {
283
297
  "imports": {
@@ -289,7 +303,7 @@ app.post('${t}/${e}', async (c) => {
289
303
  ${p}
290
304
  </head>
291
305
  <body>
292
- <${a}></${a}>
293
- <script type="module" src="./${a}.js"></script>
306
+ <${l}></${l}>
307
+ <script type="module" src="./${l}.js"></script>
294
308
  </body>
295
- </html>`;return{files:[f],html:d}}let c={litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...cl(t),title:n};if(t.serverBaseUrl!==void 0)c.serverBaseUrl=t.serverBaseUrl;return $o(i,c)}function cl(e){let t={};if(e.prePaintScheme===!1)t.prePaintScheme=!1;if(e.rewriteSrc)t.rewriteSrc=e.rewriteSrc;return t}async function Gg(e,t){let n=await sf(e),{writeFileSync:r,mkdirSync:s}=await import("node:fs"),{dirname:o,join:i}=await import("node:path");if(t){r(t,n.html,"utf8"),console.error(`Written to ${t}`);let c=o(t);for(let a of n.files){let l=i(c,a.path);s(o(l),{recursive:!0}),r(l,a.content,"utf8"),console.error(`Written to ${l}`)}}else process.stdout.write(n.html)}var of=j(()=>{Lt();qr();el();bo();z();Fr();Lt();ol();qr();bo()});of();export{sf as compile,$o as compileClient,za as compileElement,Du as compileElementPage,Yu as compileSiteServer,sr as isDynamic,Gg as runCli};
309
+ </html>`;return{files:[f],html:d}}let a={litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...Fl(t),title:n};if(t.serverBaseUrl!==void 0)a.serverBaseUrl=t.serverBaseUrl;return Mo(i,a)}function Fl(e){let t={};if(e.prePaintScheme===!1)t.prePaintScheme=!1;if(e.rewriteSrc)t.rewriteSrc=e.rewriteSrc;return t}async function dx(e,t){let n=await Zf(e),{writeFileSync:r,mkdirSync:s}=await import("node:fs"),{dirname:o,join:i}=await import("node:path");if(t){r(t,n.html,"utf8"),console.error(`Written to ${t}`);let a=o(t);for(let l of n.files){let c=i(a,l.path);s(o(c),{recursive:!0}),r(c,l.content,"utf8"),console.error(`Written to ${c}`)}}else process.stdout.write(n.html)}var Qf=A(()=>{Yn();Bt();ns();vl();Lo();U();Gr();Bt();kl();ns();Lo()});Qf();export{Zf as compile,Mo as compileClient,wl as compileElement,_f as compileElementPage,Hf as compileSiteServer,mr as isDynamic,dx as runCli};