@jxsuite/compiler 7.0.0 → 8.0.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/cli.js +133 -135
- package/dist/compiler.js +43 -43
- package/package.json +15 -8
- package/src/site/bundler-backend.bun.ts +84 -0
- package/src/site/bundler-backend.node.ts +58 -0
- package/src/site/bundler-backend.ts +53 -0
- package/src/site/bundler.ts +49 -110
- package/src/site/client-runtime.ts +6 -11
- package/src/site/format-host.ts +98 -48
- package/src/site/image-cache.ts +38 -12
- package/src/site/schema-command.ts +26 -28
package/dist/compiler.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{createRequire as us}from"node:module";var ss=Object.create;var{getPrototypeOf:os,defineProperty:wn,getOwnPropertyNames:is}=Object;var Cn=Object.prototype.hasOwnProperty;function as(e){return this[e]}var ls,cs,Wo=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?ls??=new WeakMap:cs??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?ss(os(e)):{};let i=t||!e||!e.__esModule||!Cn.call(e,"default")?wn(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let u of is(e))if(!Cn.call(i,u))wn(i,u,{get:as.bind(e,u),enumerable:!0})}if(r)s.set(e,i);return i};var Vo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var I=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var Bo=us(import.meta.url);function J(e){return typeof e==="string"}function ee(e){return typeof e==="number"}function K(e){return typeof e==="boolean"}function te(e){return typeof e==="function"}function C(e){return typeof e==="object"&&e!==null}function L(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function P(e){return L(e)&&typeof e.$ref==="string"}function G(e){return L(e)&&e.$prototype==="Function"}function X(e){return L(e)&&L(e.$expression)}function Ee(e){return X(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function xe(e){return G(e)&&Array.isArray(e.body)}function ye(e){return L(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function le(e){return L(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function vn(e){return L(e)&&!e.$prototype&&!e.$expression&&"default"in e}function $e(e){if(!L(e))return!1;for(let t of Object.keys(e))if(!On.has(t))return!1;return!0}function V(e){return L(e)&&e.$prototype==="Array"}function Pt(e){return(Array.isArray(e)?e:[e]).some((n)=>V(n))}function An(e){return L(e)&&e.$prototype==="Class"}function Fe(e){return L(e)}function N(e){return typeof e==="string"&&e.includes("${")}function we(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function ps(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ce(e){if(!e)return[];return e.map((t)=>J(t)?t:t.name)}function fs(e){return typeof e==="string"}function oe(e){if(typeof e!=="object"||e===null||Array.isArray(e)||!L(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 L(t.cases)&&Object.values(t.cases).every((n)=>J(n))&&typeof t.default==="string";return!1}function Oe(e){if(fs(e))return[e];if(!oe(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 On;var H=I(()=>{On=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function z(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function jn(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let n=e.slice(2,-1).trim();return ms.has(n.toLowerCase())?n:e.slice(1)}return null}function We(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function He(e){return e.startsWith("@keyframes")}function Rn(e,t){let n=[];for(let r of Ve(e))for(let s of Ve(t))n.push(ds(r,s));return n.join(", ")}function ds(e,t){let n=tt(t,e);if(n!==null)return n;if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function Tt(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 tt(e,t){return Tt(e).length>0?gs(e,t):null}function gs(e,t){let n="",r=0;for(let s of Tt(e))n+=e.slice(r,s)+t,r=s+1;return n+e.slice(r)}function Ve(e){let t=[],n=0,r=null,s=0;for(let i=0;i<e.length;i+=1){let u=e[i];if(r){if(u==="\\")i+=1;else if(u===r)r=null;continue}if(u==='"'||u==="'")r=u;else if(u==="("||u==="[")n+=1;else if(u===")"||u==="]")n=Math.max(0,n-1);else if(u===","&&n===0)t.push(e.slice(s,i)),s=i+1}t.push(e.slice(s));let o=t.flatMap((i)=>{let u=i.trim();return u===""?[]:[u]});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 kt(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${se}]))`,forced:`${e}:where([${se}="${t}"])`};return{auto:`:where(:root:not([${se}])) ${e}`,forced:`:where(:root[${se}="${t}"]) ${e}`}}function Se(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function _t(e){return e.startsWith("--")?e:z(e)}function et(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 Nn(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 hs(e,t,n){let r=n.map(({selector:o,declarations:i})=>`${o} { ${i.map(([u,a])=>`${u}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function xs(e){let t=Object.keys(e).filter((r)=>He(r));if(t.length===0)return e;let n={...e};for(let r of t)delete n[r];return n}function ys(e){let n=Tt(e).at(-1),r=n===void 0?e:e.slice(n+1);return r===""||r.startsWith(":")||r.startsWith(".")||r.startsWith("[")}function Ae(e,t={}){let{scope:n=null,mediaQueries:r={},transposeValue:s=(m)=>m,transposeSelector:o=(m)=>m,resolveValue:i}=t,u=[],a=(m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)&&!P(m),c=(m,y)=>{if(a(y))return[y];if(!We(m)||!Array.isArray(y)||y.length===0)return[];return y.every((w)=>a(w))?y:[]},l=(m,y,w,O)=>{if(y===void 0||y===null)return null;if(P(y))return w?i?.(m,y,O)??null:null;if(C(y))return null;let v=String(y);if(N(v))return w?i?.(m,v,O)??null:null;return s(v)},p=(m,y,w=!0,O="self")=>{let v=[];for(let[A,k]of Object.entries(m)){if(c(A,k).length>0)continue;if(y&&(A.startsWith("@")||Se(A)))continue;if(A.startsWith("$"))continue;let S=l(A,k,w,O);if(S!==null)v.push([_t(A),S])}return v},g=(m,y,w,O,v)=>{if(w.length===0)return;let A=y;if(A!==null){let h=o(A);if(h===null)return;A=h}let k=Nn(m,A,w),S={text:k,conditions:[...m],selector:A,declarations:w,target:O,key:et(k)};if(J(v)&&v!=="")S.description=v;u.push(S)},d=(m,y,w)=>{let O=m.slice(10).trim();if(O==="")return;let v=[];for(let[k,S]of Object.entries(y)){if(!a(S))continue;let h=p(S,!0,!1,"unscoped");if(h.length>0)v.push({declarations:h,selector:k.trim()})}if(v.length===0)return;let A=hs(w,O,v);u.push({blocks:v,conditions:[...w],declarations:[],key:et(A),selector:null,target:"unscoped",text:A})},x=(m,y,w,O,v)=>{if(m==="@--")return;if(We(m)){g([...O,m],null,p(y,!1,!0,"unscoped"),"unscoped",y.$description);return}if(He(m)){d(m,y,O);return}let A=jn(m,r),k=A===null?m:`@media ${A}`,S=A===null?null:ue(A);if(S!==null&&w!==null){let{auto:h,forced:b}=kt(w,S);f(y,h,[...O,k],v),f(xs(y),b,O,v);return}f(y,w,[...O,k],v)};function f(m,y,w,O){g(w,y,p(m,!0,!0,O),O,m.$description);for(let[v,A]of Object.entries(m))for(let k of c(v,A))if(v.startsWith("@"))x(v,k,y,w,O);else if(y!==null)f(k,Rn(y,v),w,ys(v)?O:"descendant")}return f(e,n,[],"self"),u}var ms,se="data-color-scheme",nt="jx-color-scheme";var Be=I(()=>{H();ms=new Set(["all","print","screen","speech"])});function Yo(){return`the Intl helpers ${Mt.join(", ")}`}var ie="en-US",Dt="UTC",Pn,Mt,Tn;var kn=I(()=>{Pn=[{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."}],Mt=Pn.map((e)=>e.path),Tn=Object.fromEntries(Pn.map((e)=>[e.path,e.params.indexOf("locale")]))});function $s(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function B(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function pe(e){if(e==="")return[];return e.split("/").map((t)=>$s(t))}function U(e,t){let n=e;for(let r of pe(t))n=n?.[r];return n}function R(e,t){let n=e;for(let r of pe(t))n+=It.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;return n}function _n(e,t){let n=e;for(let[r,s]of pe(t).entries()){let o=r===0?"":"?.";n+=It.test(s)?`${r===0?".":o}${s}`:`${o}[${JSON.stringify(s)}]`}return n}function fe(e){return It.test(e)?e:JSON.stringify(e)}function Dn(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var It;var je=I(()=>{It=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function Lt(e){let t=e.$map;return C(t)?t:void 0}function Fn(e){return C(e)&&!Array.isArray(e)&&"operator"in e}function Ue(e){return C(e)&&!Array.isArray(e)&&"$ref"in e}function Es(e,t,n){let r=Tn[e];if(r===void 0||r<0||t[r]!=null)return t;let s=U(n.$page,"locale");if(!J(s)||s==="")return t;let o=[...t];return o[r]=s,o}function Bn(e){return e.startsWith("window#/")&&bs.has(e.slice(8))}function me(e){return Wn.has(e)}function D(e,t){if(!e)return;let n=(e.depth??0)+1;if(n>ws)return;return{depth:n,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function _(e,t,n,r,s){if(e===null||e===void 0)return e;if(Fn(e))return Z(e,t,n,r,s);if(Ue(e)){let o=rt(e.$ref,t,n,r);return s?.report(s.path??[],o),o}if(Array.isArray(e))return Un(e,t,n,r,s);return s?.report(s.path??[],e),e}function Un(e,t,n,r,s){return e.map((o,i)=>_(o,t,n,r,D(s,i)))}function Cs(e,t,n,r){let s=(o)=>{if(!e.slice(o.length).includes("/"))return t;return rt(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?rt(e.slice(0,e.lastIndexOf("/")),t,n,r):void 0;return}function rt(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?U(o,s.slice(1).join("/")):o}if(e.startsWith("event#/")){let s=e.slice(7);return U(n,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,u=Lt(t);if(o==="item")i=r?.item??u?.item??t["$map/item"];else if(o==="index")i=r?.index??u?.index??t["$map/index"];else i=u?.[o]??t[`$map/${o}`];return s.length>2?U(i,s.slice(2).join("/")):i}if(e.startsWith("#/state/"))return U(t,e.slice(8));if(e.startsWith("parent#/"))return U(t,e.slice(8));if(e.startsWith("window#/"))return U(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return U(globalThis.document,e.slice(10));return U(t,e)??null}function vs(e,t,n,r){if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,u=Lt(t);if(o==="item")i=r?.item??u?.item??t["$map/item"];else if(o==="index")i=r?.index??u?.index??t["$map/index"];else i=u?.[o]??t[`$map/${o}`];if(s.length>2){let a=s.slice(2),c=a.pop(),l=a.length>0?U(i,a.join("/")):i;return{key:c,obj:l}}return{key:o==="item"?"$map/item":"$map/index",obj:Lt(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let i=pe(s),u=i.pop(),a=t;for(let c of i)a=a[c];return{key:u,obj:a}}return{key:e,obj:t}}function Z(e,t,n,r,s){let o=Os(e,t,n,r,s);return s?.report(s.path??[],o),o}function In(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 Os(e,t,n,r,s){let{operator:o,target:i,value:u,initial:a}=e;if(!Ss.has(o))throw Error(`$expression: unknown operator "${o}"`);if(Ft.has(o)&&!("value"in e)){let c=_(i,t,n,r,D(s,"target"));if(o==="!")return!c;if(o==="-")return-c}if(o==="call"){let c=Ue(i)?i.$ref:void 0;if(!J(c))throw TypeError("$expression: call target must be a $ref pointer");let l=(r?.callDepth??0)+1;if(l>Mn)throw Error(`$expression: call depth exceeded (${Mn})`);let p=Array.isArray(u)?u.map((d,x)=>_(d,t,n,r,D(s,["value",x]))):[];if(c.startsWith("window#/")){if(!Bn(c))throw Error(`$expression: "${c}" is not a blessed pure global`);let d=c.slice(8),x=Js.get(d);if(x)return x(...Es(d,p,t));let f=U(globalThis.window,d),m=d.lastIndexOf("/"),y=m===-1?globalThis.window:U(globalThis.window,d.slice(0,m));return f.apply(y,p)}let g=rt(c,t,n,r);if(te(g))return g.apply(Cs(c,t,n,r),p);if(C(g)&&"$expression"in g){let d=g,x={};for(let[f,m]of(d.parameters??[]).entries()){let y=J(m)?m:m?.name??"";if(!y)continue;x[y]=p[f]===void 0&&C(m)&&"default"in m?m.default:p[f]}return Z(d.$expression,t,n,{args:x,callDepth:l})}throw TypeError(`$expression: call target "${c}" is not callable`)}if(Ht.has(o)){if(o==="?:"){let d=_(i,t,n,r,D(s,"target"));if(s){let x=_(u,t,n,r,D(s,"value")),f=_(a,t,n,r,D(s,"initial"));return d?x:f}return d?_(u,t,n,r):_(a,t,n,r)}let c=_(i,t,n,r,D(s,"target")),l=String(c),p=e.cases??{},g=Object.hasOwn(p,l);if(s){let d;for(let[f,m]of Object.entries(p)){let y=_(m,t,n,r,D(s,["cases",f]));if(f===l)d=y}let x=_(e.default,t,n,r,D(s,"default"));return g?d:x}return g?_(p[l],t,n,r):_(e.default,t,n,r)}if(Wt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=_(u,t,n,r,D(s,"value"));switch(o){case"===":return c===l;case"!==":return c!==l;case"&&":return c&&l;case"||":return c||l;case"??":return c??l;default:return In(o,c,l)}}if(Vn.has(o)){let c=_(u,t,n,r,D(s,"value")),{obj:l,key:p}=vs(i.$ref,t,n,r);l[p]=o==="="?c:In(o.slice(0,-1),l[p],c);return}if(Hn.has(o)){let c=_(i,t,n,r,D(s,"target"));switch(o){case"push":return c.push(_(u,t,n,r,D(s,"value")));case"unshift":return c.unshift(_(u,t,n,r,D(s,"value")));case"pop":return c.pop();case"shift":return c.shift();case"splice":{let l=_(u,t,n,r,D(s,"value"));return c.splice(...l)}default:break}}if(Bt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=u===void 0?[]:Array.isArray(u)?Un(u,t,n,r,D(s,"value")):[_(u,t,n,r,D(s,"value"))],p=U(c,o);if(!te(p))return;return p.apply(c,l)}if(Vt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=u;if(o==="reduce"){let p=_(a,t,n,r,D(s,"initial"));for(let[g,d]of c.entries())p=Z(l,t,n,{acc:p,index:g,item:d},g===0?D(s,"value"):void 0);return p}if(o==="map")return c.map((p,g)=>Z(l,t,n,{...r,index:g,item:p},g===0?D(s,"value"):void 0));if(o==="filter")return c.filter((p,g)=>Z(l,t,n,{...r,index:g,item:p},g===0?D(s,"value"):void 0))}return}function M(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(Fn(e))return q(e,t);if(Ue(e))return Ut(e.$ref,t);if(Array.isArray(e))return e.map((n)=>M(n,t)).join(", ");return JSON.stringify(e)}function As(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function Ut(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 R("_args",e.slice(6));if(e.startsWith("event#/"))return R(r,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s;if(o==="item")return s.length>2?R("_item",s.slice(2).join("/")):"_item";if(o==="index")return"_index";return`_${o}`}if(e.startsWith("#/state/"))return R(n,e.slice(8));if(e.startsWith("parent#/"))return R(n,e.slice(8));if(e.startsWith("window#/"))return R("window",e.slice(8));if(e.startsWith("document#/"))return R("document",e.slice(10));return R(n,e)}function Ln(e,t){if(Ue(e))return Ut(e.$ref,t);return M(e,t)}function js(e,t,n){let r=(i)=>t[i]??"undefined",s=`(${n.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(ie)})`,o=JSON.stringify(Dt);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 q(e,t={}){let{operator:n,target:r,value:s,initial:o}=e;if(Ft.has(n)&&!("value"in e)){let i=M(r,t);if(n==="!")return`!(${i})`;if(n==="-")return`-(${i})`}if(n==="call"){let i=(Ue(r)?r.$ref:void 0)??"",u=Array.isArray(s)?s.map((a)=>M(a,t)):[];if(i.startsWith("window#/")){if(!Bn(i))throw Error(`$expression: "${i}" is not a blessed pure global`);let a=js(i.slice(8),u,t);if(a)return a;return`window.${i.slice(8).replaceAll("/",".")}(${u.join(", ")})`}if(i.startsWith("#/state/")){let a=i.slice(8),c=t.formulaParams?.[a];if(c){let l=c.map((p,g)=>`${JSON.stringify(p)}: ${u[g]??"undefined"}`).join(", ");return`${As(a)}(${t.statePrefix??"state"}, { ${l} })`}}return`${Ut(i,t)}(${u.join(", ")})`}if(Ht.has(n)){if(n==="?:"){let c=M(r,t),l=M(s,t),p=M(o,t);return`(${c} ? ${l} : ${p})`}let i=M(r,t),u=Object.entries(e.cases??{}).map(([c,l])=>`_d === ${JSON.stringify(c)} ? ${M(l,t)} : `).join(""),a="default"in e?M(e.default,t):"undefined";return`((_d) => ${u}${a})(String(${i}))`}if(Wt.has(n)){let i=M(r,t),u=M(s,t);return`(${i} ${n} ${u})`}if(Vn.has(n)){let i=Ln(r,t),u=M(s,t);return`${i} ${n} ${u}`}if(Hn.has(n)){let i=Ln(r,t);switch(n){case"push":return`${i}.push(${M(s,t)})`;case"unshift":return`${i}.unshift(${M(s,t)})`;case"pop":return`${i}.pop()`;case"shift":return`${i}.shift()`;case"splice":{let u=Array.isArray(s)?s.map((a)=>M(a,t)).join(", "):M(s,t);return`${i}.splice(${u})`}default:break}}if(Bt.has(n)){let i=M(r,t),u=s===void 0?"":Array.isArray(s)?s.map((a)=>M(a,t)).join(", "):M(s,t);return`(${i})?.${n}?.(${u})`}if(Vt.has(n)){let i=M(r,t),u=q(s,t);if(n==="reduce"){let a=M(o,t);return`${i}.reduce((_acc, _item, _index) => ${u}, ${a})`}if(n==="map")return`${i}.map((_item, _index) => ${u})`;if(n==="filter")return`${i}.filter((_item, _index) => ${u})`}return"undefined"}function Re(e,t,n,r){return _(e,t,n,r)}function de(e,t={}){return M(e,t)}var Wn,Ft,Wt,Vn,Hn,Vt,Ht,Bt,Ss,bs,Js,Mn=64,ws=64;var qe=I(()=>{kn();H();je();Wn=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),Ft=new Set(["!","-"]),Wt=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),Vn=new Set(["=","+=","-=","*=","/="]),Hn=new Set(["push","pop","shift","unshift","splice"]),Vt=new Set(["reduce","map","filter"]),Ht=new Set(["?:","switch"]),Bt=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"]),Ss=new Set([...Wn,...Ft,...Wt,...Vt,...Ht,...Bt,"call"]),bs=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",...Mt]),Js=new Map([["Intl/compare",(e,t,n,r)=>new Intl.Collator(n??ie,r).compare(e,t)],["Intl/displayName",(e,t,n,r)=>new Intl.DisplayNames(n??ie,{...r,type:t??"language"}).of(e)],["Intl/formatDate",(e,t,n)=>new Intl.DateTimeFormat(t??ie,{timeZone:Dt,...n}).format(new Date(e))],["Intl/formatList",(e,t,n)=>new Intl.ListFormat(t??ie,n).format(e)],["Intl/formatNumber",(e,t,n)=>new Intl.NumberFormat(t??ie,n).format(e)],["Intl/formatRelativeTime",(e,t,n,r)=>new Intl.RelativeTimeFormat(n??ie,r).format(e,t)],["Intl/plural",(e,t,n)=>new Intl.PluralRules(t??ie,n).select(e)],["Intl/segment",(e,t,n)=>[...new Intl.Segmenter(n??ie,{granularity:t??"grapheme"}).segment(e)].map((r)=>r.segment)]])});function Rs(e){return e.startsWith(qn)}function ri(e){let t=e;if(Rs(t))t=t.slice(qn.length);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`${qt}${t}.js`}function si(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",n=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`${qt}${n}`:`${qt}${n}.${t}`}function Kn(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function zn(e){let t=Kn(e);return t.startsWith("/")?t:`/${t}`}function Ns(e,t){return[...e].toSorted((n,r)=>r[t].length-n[t].length)}function oi(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 Ns(e,"urlPrefix")){let o=zn(s.urlPrefix);if(!r.startsWith(`${o}/`))continue;let u=r.slice(o.length+1).split("/");if(u.some((c)=>c===""||c==="."||c===".."))return null;let{filter:a}=s;if(a&&!a(u.join("/")))return null;return`${Kn(s.dir)}/${u.join("/")}`}return null}function ii(e,t){let n=new Set;for(let r of t){let s=zn(r.urlPrefix),o=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${Ps}]+`,"g");for(let i of e.matchAll(o)){let u=i[0].split("#")[0].split("?")[0];if(!u.endsWith("/"))n.add(u)}}return[...n].filter(Boolean)}function Ts(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 ks(e){return e.map(({url:t,descriptor:n})=>n?`${t} ${n}`:t).join(", ")}function ai(e){if(!J(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 Yn(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function li(e,t){let n=new URL(t);if(!n.pathname.endsWith("/"))n.pathname+="/";return new URL(e.replace(/^\/+/,""),n).href}var qn="npm:",qt="/assets/",Ps;var Kt=I(()=>{H();Ps=String.raw`"'\s<>()\\`});function Gn(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 _s(e){return(C(e)||te(e))&&"then"in e&&te(e.then)}async function Ne(e,t,n,r={}){let s=r.args?{args:r.args}:void 0;for(let o of e){let i=Gn(o);switch(i.kind){case"expression":{let u=Z(i.node,t,n,s);if(_s(u))await u;break}case"if":{let u=i.node,a=Re(u.if,t,n,s)?u.then:u.else;if(Array.isArray(a))await Ne(a,t,n,r);break}case"switch":{let u=i.node,a=String(Re(u.$switch,t,n,s)),c=u.cases??{},l=Object.hasOwn(c,a)?c[a]:u.default;if(Array.isArray(l))await Ne(l,t,n,r);break}case"dispatch":{let u=i.node,a=te(r.target)?r.target():r.target,c=n?.currentTarget??a;if(!c)break;let l={};if("detail"in u)l.detail=Re(u.detail,t,n,s);if(u.bubbles!==void 0)l.bubbles=u.bubbles;if(u.composed!==void 0)l.composed=u.composed;c.dispatchEvent(new CustomEvent(u.dispatchEvent,l));break}case"stopPropagation":{n?.stopPropagation();break}case"preventDefault":{n?.preventDefault();break}default:break}}}function ne(e,t={}){let n=t.indent??"",r=[];for(let s of e){let o=Gn(s);switch(o.kind){case"expression":{r.push(`${n}${q(o.node,t)};`);break}case"if":{let i=o.node,u=de(i.if,t),a={...t,indent:`${n} `};if(r.push(`${n}if (${u}) {`,ne(i.then??[],a)),i.else)r.push(`${n}} else {`,ne(i.else,a));r.push(`${n}}`);break}case"switch":{let i=o.node,u=de(i.$switch,t),a={...t,indent:`${n} `};r.push(`${n}switch (String(${u})) {`);for(let[c,l]of Object.entries(i.cases??{}))r.push(`${n} case ${JSON.stringify(c)}: {`,ne(l,a),`${n} break;`,`${n} }`);if(i.default)r.push(`${n} default: {`,ne(i.default,a),`${n} }`);r.push(`${n}}`);break}case"dispatch":{let i=o.node,u=t.eventParam??"event",a=t.dispatchTarget??`(${u} && ${u}.currentTarget)`,c=[];if("detail"in i)c.push(`detail: ${de(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 l=c.length>0?`, { ${c.join(", ")} }`:"";r.push(`${n}${a}?.dispatchEvent(new CustomEvent(${JSON.stringify(i.dispatchEvent)}${l}));`);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 st=I(()=>{H();qe()});function ot(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 Zn(){return[...Xn].toSorted()}function Ce(e,t){let n=e.toLowerCase();if(n.startsWith("aria-")||Xn.has(n))return String(t);return t?"":null}var ge,Xn,zt=32,it,at="jx-slot",Yt="data-jx-slots",Gt="jx.slot.group",
|
|
3
|
-
`)}var
|
|
4
|
-
`)}function dt(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o,serverBaseUrl:i="/_jx/server"}=n,u=JSON.stringify(`${i}/${t.$export}`),a=Object.entries(t.arguments??{}),c=a.map(([f,m])=>{if(!P(m))return`${fe(f)}: ${JSON.stringify(m)}`;if(
|
|
5
|
-
`)}function
|
|
6
|
-
${t}`}function $t(){let e=JSON.stringify(nt),t=JSON.stringify(se);return`(function(){try{var s=localStorage.getItem(${e});if(s==="light"||s==="dark"){document.documentElement.setAttribute(${t},s)}}catch(e){}})()`}function ut(e,t,n,r){for(let s of Ae(t,{mediaQueries:r,resolveValue:(o,i)=>ur(o,i,n),scope:n}))e.push(s.text)}function ur(e,t,n){let r=J(t)?t:t.$ref;return
|
|
1
|
+
import{createRequire as cs}from"node:module";var rs=Object.create;var{getPrototypeOf:ss,defineProperty:wn,getOwnPropertyNames:os}=Object;var Cn=Object.prototype.hasOwnProperty;function is(e){return this[e]}var as,ls,Vo=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?as??=new WeakMap:ls??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?rs(ss(e)):{};let i=t||!e||!e.__esModule||!Cn.call(e,"default")?wn(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let u of os(e))if(!Cn.call(i,u))wn(i,u,{get:is.bind(e,u),enumerable:!0})}if(r)s.set(e,i);return i};var Ho=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var I=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var Uo=cs(import.meta.url);function J(e){return typeof e==="string"}function ee(e){return typeof e==="number"}function K(e){return typeof e==="boolean"}function te(e){return typeof e==="function"}function C(e){return typeof e==="object"&&e!==null}function L(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function P(e){return L(e)&&typeof e.$ref==="string"}function G(e){return L(e)&&e.$prototype==="Function"}function X(e){return L(e)&&L(e.$expression)}function Ee(e){return X(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function xe(e){return G(e)&&Array.isArray(e.body)}function ye(e){return L(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function le(e){return L(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function vn(e){return L(e)&&!e.$prototype&&!e.$expression&&"default"in e}function $e(e){if(!L(e))return!1;for(let t of Object.keys(e))if(!On.has(t))return!1;return!0}function V(e){return L(e)&&e.$prototype==="Array"}function Pt(e){return(Array.isArray(e)?e:[e]).some((n)=>V(n))}function An(e){return L(e)&&e.$prototype==="Class"}function Fe(e){return L(e)}function N(e){return typeof e==="string"&&e.includes("${")}function we(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function us(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ce(e){if(!e)return[];return e.map((t)=>J(t)?t:t.name)}function ps(e){return typeof e==="string"}function oe(e){if(typeof e!=="object"||e===null||Array.isArray(e)||!L(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 L(t.cases)&&Object.values(t.cases).every((n)=>J(n))&&typeof t.default==="string";return!1}function Oe(e){if(ps(e))return[e];if(!oe(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 On;var H=I(()=>{On=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function z(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function jn(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let n=e.slice(2,-1).trim();return fs.has(n.toLowerCase())?n:e.slice(1)}return null}function We(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function He(e){return e.startsWith("@keyframes")}function Rn(e,t){let n=[];for(let r of Ve(e))for(let s of Ve(t))n.push(ms(r,s));return n.join(", ")}function ms(e,t){let n=tt(t,e);if(n!==null)return n;if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function Tt(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 tt(e,t){return Tt(e).length>0?ds(e,t):null}function ds(e,t){let n="",r=0;for(let s of Tt(e))n+=e.slice(r,s)+t,r=s+1;return n+e.slice(r)}function Ve(e){let t=[],n=0,r=null,s=0;for(let i=0;i<e.length;i+=1){let u=e[i];if(r){if(u==="\\")i+=1;else if(u===r)r=null;continue}if(u==='"'||u==="'")r=u;else if(u==="("||u==="[")n+=1;else if(u===")"||u==="]")n=Math.max(0,n-1);else if(u===","&&n===0)t.push(e.slice(s,i)),s=i+1}t.push(e.slice(s));let o=t.flatMap((i)=>{let u=i.trim();return u===""?[]:[u]});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 kt(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${se}]))`,forced:`${e}:where([${se}="${t}"])`};return{auto:`:where(:root:not([${se}])) ${e}`,forced:`:where(:root[${se}="${t}"]) ${e}`}}function Se(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function _t(e){return e.startsWith("--")?e:z(e)}function et(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 Nn(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 gs(e,t,n){let r=n.map(({selector:o,declarations:i})=>`${o} { ${i.map(([u,a])=>`${u}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function hs(e){let t=Object.keys(e).filter((r)=>He(r));if(t.length===0)return e;let n={...e};for(let r of t)delete n[r];return n}function xs(e){let n=Tt(e).at(-1),r=n===void 0?e:e.slice(n+1);return r===""||r.startsWith(":")||r.startsWith(".")||r.startsWith("[")}function Ae(e,t={}){let{scope:n=null,mediaQueries:r={},transposeValue:s=(m)=>m,transposeSelector:o=(m)=>m,resolveValue:i}=t,u=[],a=(m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)&&!P(m),c=(m,y)=>{if(a(y))return[y];if(!We(m)||!Array.isArray(y)||y.length===0)return[];return y.every((w)=>a(w))?y:[]},l=(m,y,w,O)=>{if(y===void 0||y===null)return null;if(P(y))return w?i?.(m,y,O)??null:null;if(C(y))return null;let v=String(y);if(N(v))return w?i?.(m,v,O)??null:null;return s(v)},p=(m,y,w=!0,O="self")=>{let v=[];for(let[A,k]of Object.entries(m)){if(c(A,k).length>0)continue;if(y&&(A.startsWith("@")||Se(A)))continue;if(A.startsWith("$"))continue;let S=l(A,k,w,O);if(S!==null)v.push([_t(A),S])}return v},g=(m,y,w,O,v)=>{if(w.length===0)return;let A=y;if(A!==null){let h=o(A);if(h===null)return;A=h}let k=Nn(m,A,w),S={text:k,conditions:[...m],selector:A,declarations:w,target:O,key:et(k)};if(J(v)&&v!=="")S.description=v;u.push(S)},d=(m,y,w)=>{let O=m.slice(10).trim();if(O==="")return;let v=[];for(let[k,S]of Object.entries(y)){if(!a(S))continue;let h=p(S,!0,!1,"unscoped");if(h.length>0)v.push({declarations:h,selector:k.trim()})}if(v.length===0)return;let A=gs(w,O,v);u.push({blocks:v,conditions:[...w],declarations:[],key:et(A),selector:null,target:"unscoped",text:A})},x=(m,y,w,O,v)=>{if(m==="@--")return;if(We(m)){g([...O,m],null,p(y,!1,!0,"unscoped"),"unscoped",y.$description);return}if(He(m)){d(m,y,O);return}let A=jn(m,r),k=A===null?m:`@media ${A}`,S=A===null?null:ue(A);if(S!==null&&w!==null){let{auto:h,forced:b}=kt(w,S);f(y,h,[...O,k],v),f(hs(y),b,O,v);return}f(y,w,[...O,k],v)};function f(m,y,w,O){g(w,y,p(m,!0,!0,O),O,m.$description);for(let[v,A]of Object.entries(m))for(let k of c(v,A))if(v.startsWith("@"))x(v,k,y,w,O);else if(y!==null)f(k,Rn(y,v),w,xs(v)?O:"descendant")}return f(e,n,[],"self"),u}var fs,se="data-color-scheme",nt="jx-color-scheme";var Be=I(()=>{H();fs=new Set(["all","print","screen","speech"])});function Go(){return`the Intl helpers ${Mt.join(", ")}`}var ie="en-US",Dt="UTC",Pn,Mt,Tn;var kn=I(()=>{Pn=[{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."}],Mt=Pn.map((e)=>e.path),Tn=Object.fromEntries(Pn.map((e)=>[e.path,e.params.indexOf("locale")]))});function ys(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function B(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function pe(e){if(e==="")return[];return e.split("/").map((t)=>ys(t))}function U(e,t){let n=e;for(let r of pe(t))n=n?.[r];return n}function R(e,t){let n=e;for(let r of pe(t))n+=It.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;return n}function _n(e,t){let n=e;for(let[r,s]of pe(t).entries()){let o=r===0?"":"?.";n+=It.test(s)?`${r===0?".":o}${s}`:`${o}[${JSON.stringify(s)}]`}return n}function fe(e){return It.test(e)?e:JSON.stringify(e)}function Dn(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var It;var je=I(()=>{It=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function Lt(e){let t=e.$map;return C(t)?t:void 0}function Fn(e){return C(e)&&!Array.isArray(e)&&"operator"in e}function Ue(e){return C(e)&&!Array.isArray(e)&&"$ref"in e}function Js(e,t,n){let r=Tn[e];if(r===void 0||r<0||t[r]!=null)return t;let s=U(n.$page,"locale");if(!J(s)||s==="")return t;let o=[...t];return o[r]=s,o}function Bn(e){return e.startsWith("window#/")&&Ss.has(e.slice(8))}function me(e){return Wn.has(e)}function D(e,t){if(!e)return;let n=(e.depth??0)+1;if(n>Es)return;return{depth:n,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function _(e,t,n,r,s){if(e===null||e===void 0)return e;if(Fn(e))return Z(e,t,n,r,s);if(Ue(e)){let o=rt(e.$ref,t,n,r);return s?.report(s.path??[],o),o}if(Array.isArray(e))return Un(e,t,n,r,s);return s?.report(s.path??[],e),e}function Un(e,t,n,r,s){return e.map((o,i)=>_(o,t,n,r,D(s,i)))}function ws(e,t,n,r){let s=(o)=>{if(!e.slice(o.length).includes("/"))return t;return rt(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?rt(e.slice(0,e.lastIndexOf("/")),t,n,r):void 0;return}function rt(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?U(o,s.slice(1).join("/")):o}if(e.startsWith("event#/")){let s=e.slice(7);return U(n,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,u=Lt(t);if(o==="item")i=r?.item??u?.item??t["$map/item"];else if(o==="index")i=r?.index??u?.index??t["$map/index"];else i=u?.[o]??t[`$map/${o}`];return s.length>2?U(i,s.slice(2).join("/")):i}if(e.startsWith("#/state/"))return U(t,e.slice(8));if(e.startsWith("parent#/"))return U(t,e.slice(8));if(e.startsWith("window#/"))return U(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return U(globalThis.document,e.slice(10));return U(t,e)??null}function Cs(e,t,n,r){if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,u=Lt(t);if(o==="item")i=r?.item??u?.item??t["$map/item"];else if(o==="index")i=r?.index??u?.index??t["$map/index"];else i=u?.[o]??t[`$map/${o}`];if(s.length>2){let a=s.slice(2),c=a.pop(),l=a.length>0?U(i,a.join("/")):i;return{key:c,obj:l}}return{key:o==="item"?"$map/item":"$map/index",obj:Lt(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let i=pe(s),u=i.pop(),a=t;for(let c of i)a=a[c];return{key:u,obj:a}}return{key:e,obj:t}}function Z(e,t,n,r,s){let o=vs(e,t,n,r,s);return s?.report(s.path??[],o),o}function In(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 vs(e,t,n,r,s){let{operator:o,target:i,value:u,initial:a}=e;if(!$s.has(o))throw Error(`$expression: unknown operator "${o}"`);if(Ft.has(o)&&!("value"in e)){let c=_(i,t,n,r,D(s,"target"));if(o==="!")return!c;if(o==="-")return-c}if(o==="call"){let c=Ue(i)?i.$ref:void 0;if(!J(c))throw TypeError("$expression: call target must be a $ref pointer");let l=(r?.callDepth??0)+1;if(l>Mn)throw Error(`$expression: call depth exceeded (${Mn})`);let p=Array.isArray(u)?u.map((d,x)=>_(d,t,n,r,D(s,["value",x]))):[];if(c.startsWith("window#/")){if(!Bn(c))throw Error(`$expression: "${c}" is not a blessed pure global`);let d=c.slice(8),x=bs.get(d);if(x)return x(...Js(d,p,t));let f=U(globalThis.window,d),m=d.lastIndexOf("/"),y=m===-1?globalThis.window:U(globalThis.window,d.slice(0,m));return f.apply(y,p)}let g=rt(c,t,n,r);if(te(g))return g.apply(ws(c,t,n,r),p);if(C(g)&&"$expression"in g){let d=g,x={};for(let[f,m]of(d.parameters??[]).entries()){let y=J(m)?m:m?.name??"";if(!y)continue;x[y]=p[f]===void 0&&C(m)&&"default"in m?m.default:p[f]}return Z(d.$expression,t,n,{args:x,callDepth:l})}throw TypeError(`$expression: call target "${c}" is not callable`)}if(Ht.has(o)){if(o==="?:"){let d=_(i,t,n,r,D(s,"target"));if(s){let x=_(u,t,n,r,D(s,"value")),f=_(a,t,n,r,D(s,"initial"));return d?x:f}return d?_(u,t,n,r):_(a,t,n,r)}let c=_(i,t,n,r,D(s,"target")),l=String(c),p=e.cases??{},g=Object.hasOwn(p,l);if(s){let d;for(let[f,m]of Object.entries(p)){let y=_(m,t,n,r,D(s,["cases",f]));if(f===l)d=y}let x=_(e.default,t,n,r,D(s,"default"));return g?d:x}return g?_(p[l],t,n,r):_(e.default,t,n,r)}if(Wt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=_(u,t,n,r,D(s,"value"));switch(o){case"===":return c===l;case"!==":return c!==l;case"&&":return c&&l;case"||":return c||l;case"??":return c??l;default:return In(o,c,l)}}if(Vn.has(o)){let c=_(u,t,n,r,D(s,"value")),{obj:l,key:p}=Cs(i.$ref,t,n,r);l[p]=o==="="?c:In(o.slice(0,-1),l[p],c);return}if(Hn.has(o)){let c=_(i,t,n,r,D(s,"target"));switch(o){case"push":return c.push(_(u,t,n,r,D(s,"value")));case"unshift":return c.unshift(_(u,t,n,r,D(s,"value")));case"pop":return c.pop();case"shift":return c.shift();case"splice":{let l=_(u,t,n,r,D(s,"value"));return c.splice(...l)}default:break}}if(Bt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=u===void 0?[]:Array.isArray(u)?Un(u,t,n,r,D(s,"value")):[_(u,t,n,r,D(s,"value"))],p=U(c,o);if(!te(p))return;return p.apply(c,l)}if(Vt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=u;if(o==="reduce"){let p=_(a,t,n,r,D(s,"initial"));for(let[g,d]of c.entries())p=Z(l,t,n,{acc:p,index:g,item:d},g===0?D(s,"value"):void 0);return p}if(o==="map")return c.map((p,g)=>Z(l,t,n,{...r,index:g,item:p},g===0?D(s,"value"):void 0));if(o==="filter")return c.filter((p,g)=>Z(l,t,n,{...r,index:g,item:p},g===0?D(s,"value"):void 0))}return}function M(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(Fn(e))return q(e,t);if(Ue(e))return Ut(e.$ref,t);if(Array.isArray(e))return e.map((n)=>M(n,t)).join(", ");return JSON.stringify(e)}function Os(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function Ut(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 R("_args",e.slice(6));if(e.startsWith("event#/"))return R(r,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s;if(o==="item")return s.length>2?R("_item",s.slice(2).join("/")):"_item";if(o==="index")return"_index";return`_${o}`}if(e.startsWith("#/state/"))return R(n,e.slice(8));if(e.startsWith("parent#/"))return R(n,e.slice(8));if(e.startsWith("window#/"))return R("window",e.slice(8));if(e.startsWith("document#/"))return R("document",e.slice(10));return R(n,e)}function Ln(e,t){if(Ue(e))return Ut(e.$ref,t);return M(e,t)}function As(e,t,n){let r=(i)=>t[i]??"undefined",s=`(${n.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(ie)})`,o=JSON.stringify(Dt);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 q(e,t={}){let{operator:n,target:r,value:s,initial:o}=e;if(Ft.has(n)&&!("value"in e)){let i=M(r,t);if(n==="!")return`!(${i})`;if(n==="-")return`-(${i})`}if(n==="call"){let i=(Ue(r)?r.$ref:void 0)??"",u=Array.isArray(s)?s.map((a)=>M(a,t)):[];if(i.startsWith("window#/")){if(!Bn(i))throw Error(`$expression: "${i}" is not a blessed pure global`);let a=As(i.slice(8),u,t);if(a)return a;return`window.${i.slice(8).replaceAll("/",".")}(${u.join(", ")})`}if(i.startsWith("#/state/")){let a=i.slice(8),c=t.formulaParams?.[a];if(c){let l=c.map((p,g)=>`${JSON.stringify(p)}: ${u[g]??"undefined"}`).join(", ");return`${Os(a)}(${t.statePrefix??"state"}, { ${l} })`}}return`${Ut(i,t)}(${u.join(", ")})`}if(Ht.has(n)){if(n==="?:"){let c=M(r,t),l=M(s,t),p=M(o,t);return`(${c} ? ${l} : ${p})`}let i=M(r,t),u=Object.entries(e.cases??{}).map(([c,l])=>`_d === ${JSON.stringify(c)} ? ${M(l,t)} : `).join(""),a="default"in e?M(e.default,t):"undefined";return`((_d) => ${u}${a})(String(${i}))`}if(Wt.has(n)){let i=M(r,t),u=M(s,t);return`(${i} ${n} ${u})`}if(Vn.has(n)){let i=Ln(r,t),u=M(s,t);return`${i} ${n} ${u}`}if(Hn.has(n)){let i=Ln(r,t);switch(n){case"push":return`${i}.push(${M(s,t)})`;case"unshift":return`${i}.unshift(${M(s,t)})`;case"pop":return`${i}.pop()`;case"shift":return`${i}.shift()`;case"splice":{let u=Array.isArray(s)?s.map((a)=>M(a,t)).join(", "):M(s,t);return`${i}.splice(${u})`}default:break}}if(Bt.has(n)){let i=M(r,t),u=s===void 0?"":Array.isArray(s)?s.map((a)=>M(a,t)).join(", "):M(s,t);return`(${i})?.${n}?.(${u})`}if(Vt.has(n)){let i=M(r,t),u=q(s,t);if(n==="reduce"){let a=M(o,t);return`${i}.reduce((_acc, _item, _index) => ${u}, ${a})`}if(n==="map")return`${i}.map((_item, _index) => ${u})`;if(n==="filter")return`${i}.filter((_item, _index) => ${u})`}return"undefined"}function Re(e,t,n,r){return _(e,t,n,r)}function de(e,t={}){return M(e,t)}var Wn,Ft,Wt,Vn,Hn,Vt,Ht,Bt,$s,Ss,bs,Mn=64,Es=64;var qe=I(()=>{kn();H();je();Wn=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),Ft=new Set(["!","-"]),Wt=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),Vn=new Set(["=","+=","-=","*=","/="]),Hn=new Set(["push","pop","shift","unshift","splice"]),Vt=new Set(["reduce","map","filter"]),Ht=new Set(["?:","switch"]),Bt=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"]),$s=new Set([...Wn,...Ft,...Wt,...Vt,...Ht,...Bt,"call"]),Ss=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",...Mt]),bs=new Map([["Intl/compare",(e,t,n,r)=>new Intl.Collator(n??ie,r).compare(e,t)],["Intl/displayName",(e,t,n,r)=>new Intl.DisplayNames(n??ie,{...r,type:t??"language"}).of(e)],["Intl/formatDate",(e,t,n)=>new Intl.DateTimeFormat(t??ie,{timeZone:Dt,...n}).format(new Date(e))],["Intl/formatList",(e,t,n)=>new Intl.ListFormat(t??ie,n).format(e)],["Intl/formatNumber",(e,t,n)=>new Intl.NumberFormat(t??ie,n).format(e)],["Intl/formatRelativeTime",(e,t,n,r)=>new Intl.RelativeTimeFormat(n??ie,r).format(e,t)],["Intl/plural",(e,t,n)=>new Intl.PluralRules(t??ie,n).select(e)],["Intl/segment",(e,t,n)=>[...new Intl.Segmenter(n??ie,{granularity:t??"grapheme"}).segment(e)].map((r)=>r.segment)]])});function js(e){return e.startsWith(qn)}function si(e){let t=e;if(js(t))t=t.slice(qn.length);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`${qt}${t}.js`}function oi(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",n=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`${qt}${n}`:`${qt}${n}.${t}`}function Kn(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function zn(e){let t=Kn(e);return t.startsWith("/")?t:`/${t}`}function Rs(e,t){return[...e].toSorted((n,r)=>r[t].length-n[t].length)}function ii(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 Rs(e,"urlPrefix")){let o=zn(s.urlPrefix);if(!r.startsWith(`${o}/`))continue;let u=r.slice(o.length+1).split("/");if(u.some((c)=>c===""||c==="."||c===".."))return null;let{filter:a}=s;if(a&&!a(u.join("/")))return null;return`${Kn(s.dir)}/${u.join("/")}`}return null}function ai(e,t){let n=new Set;for(let r of t){let s=zn(r.urlPrefix),o=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${Ns}]+`,"g");for(let i of e.matchAll(o)){let u=i[0].split("#")[0].split("?")[0];if(!u.endsWith("/"))n.add(u)}}return[...n].filter(Boolean)}function Ps(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 Ts(e){return e.map(({url:t,descriptor:n})=>n?`${t} ${n}`:t).join(", ")}function li(e){if(!J(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 Yn(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function ci(e,t){let n=new URL(t);if(!n.pathname.endsWith("/"))n.pathname+="/";return new URL(e.replace(/^\/+/,""),n).href}var qn="npm:",qt="/assets/",Ns;var Kt=I(()=>{H();Ns=String.raw`"'\s<>()\\`});function Gn(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 ks(e){return(C(e)||te(e))&&"then"in e&&te(e.then)}async function Ne(e,t,n,r={}){let s=r.args?{args:r.args}:void 0;for(let o of e){let i=Gn(o);switch(i.kind){case"expression":{let u=Z(i.node,t,n,s);if(ks(u))await u;break}case"if":{let u=i.node,a=Re(u.if,t,n,s)?u.then:u.else;if(Array.isArray(a))await Ne(a,t,n,r);break}case"switch":{let u=i.node,a=String(Re(u.$switch,t,n,s)),c=u.cases??{},l=Object.hasOwn(c,a)?c[a]:u.default;if(Array.isArray(l))await Ne(l,t,n,r);break}case"dispatch":{let u=i.node,a=te(r.target)?r.target():r.target,c=n?.currentTarget??a;if(!c)break;let l={};if("detail"in u)l.detail=Re(u.detail,t,n,s);if(u.bubbles!==void 0)l.bubbles=u.bubbles;if(u.composed!==void 0)l.composed=u.composed;c.dispatchEvent(new CustomEvent(u.dispatchEvent,l));break}case"stopPropagation":{n?.stopPropagation();break}case"preventDefault":{n?.preventDefault();break}default:break}}}function ne(e,t={}){let n=t.indent??"",r=[];for(let s of e){let o=Gn(s);switch(o.kind){case"expression":{r.push(`${n}${q(o.node,t)};`);break}case"if":{let i=o.node,u=de(i.if,t),a={...t,indent:`${n} `};if(r.push(`${n}if (${u}) {`,ne(i.then??[],a)),i.else)r.push(`${n}} else {`,ne(i.else,a));r.push(`${n}}`);break}case"switch":{let i=o.node,u=de(i.$switch,t),a={...t,indent:`${n} `};r.push(`${n}switch (String(${u})) {`);for(let[c,l]of Object.entries(i.cases??{}))r.push(`${n} case ${JSON.stringify(c)}: {`,ne(l,a),`${n} break;`,`${n} }`);if(i.default)r.push(`${n} default: {`,ne(i.default,a),`${n} }`);r.push(`${n}}`);break}case"dispatch":{let i=o.node,u=t.eventParam??"event",a=t.dispatchTarget??`(${u} && ${u}.currentTarget)`,c=[];if("detail"in i)c.push(`detail: ${de(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 l=c.length>0?`, { ${c.join(", ")} }`:"";r.push(`${n}${a}?.dispatchEvent(new CustomEvent(${JSON.stringify(i.dispatchEvent)}${l}));`);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 st=I(()=>{H();qe()});function ot(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 Zn(){return[...Xn].toSorted()}function Ce(e,t){let n=e.toLowerCase();if(n.startsWith("aria-")||Xn.has(n))return String(t);return t?"":null}var ge,Xn,zt=32,it,at="jx-slot",Yt="data-jx-slots",Gt="jx.slot.group",vi;var ze=I(()=>{Be();qe();je();H();Kt();st();Be();ge=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"]),Xn=new Set(["contenteditable","draggable","spellcheck"]);it=/^[\t\n\f\r ]+$/u,vi=(()=>{let e=Symbol.for(Gt),t=globalThis;return t[e]??=new WeakMap,t[e]})()});function Qn(e,t,n,r,s=Ds){let o=[],i=(p,g)=>{let d={mediaQueries:t,scope:g,transposeValue:n};if(r)d.resolveValue=(x,f)=>r(x,f,g);for(let x of Ae(p,d))o.push(x.text)},u={},a={},c=[],l=[];for(let[p,g]of Object.entries(e)){if(C(g)&&!Array.isArray(g)){if(p.startsWith("@"))c.push([p,g]);else if(!p.startsWith("--"))l.push([p,g]);continue}if(Se(p)||p.startsWith("@"))continue;if(p.startsWith("--")||p==="colorScheme"||p==="color-scheme")u[p]=g;else a[p]=g}i(u,s.root),i(a,s.body);for(let[p,g]of l)if(p.startsWith("&"))i({[p]:g},s.root);else i(g,p);for(let[p,g]of c){if(We(p)||He(p)){i({[p]:g},null);continue}let d={},x={},f=[];for(let[m,y]of Object.entries(g)){if(C(y)&&!Array.isArray(y)){if(!m.startsWith("@"))f.push([m,y]);continue}if(m.startsWith("--"))d[m]=y;else x[m]=y}i({[p]:d},s.root),i({[p]:x},s.body);for(let[m,y]of f)i({[p]:y},m)}if(Object.values(t).some((p)=>ue(p)!==null)&&!("colorScheme"in e))o.push(`${s.root} { color-scheme: light dark }`,`${s.root}:where([${se}="light"]) { color-scheme: light }`,`${s.root}:where([${se}="dark"]) { color-scheme: dark }`);return o.join(`
|
|
3
|
+
`)}var Ds;var er=I(()=>{Be();H();Ds={body:"body",root:":root"}});function tr(e){return e===!1||e==="open"||e==="closed"}function lt(e,t){let n=e?.$shadow;if(tr(n))return n===!1?null:n;let r=t?.shadow;return tr(r)&&r!==!1?r:null}function nr(e,t){return t===null?e:":host"}function Ge(e,t){let n=[];for(let[r,s]of(e.parameters??[]).entries()){let o=rr(s);if(!o)continue;let i=sr(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 rr(e){return J(e)?e:e?.name??""}function sr(e){return C(e)&&"default"in e}function ft(e,t){let n=nn(e,t);return n===e?e:`${n} as ${e}`}function nn(e,t){let n=t?.$export;return J(n)&&n!==""?n:e}function mt(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o}=n,{url:i}=t,u=N(i),a=t.method??"GET";if(t.manual)return`${s}// ${e}: manual Request — fetch triggered by user action`;let c=[`// ${e}: auto-fetch from ${u?"(dynamic URL)":i}`,o?`${o}.push(effect(() => {`:"effect(() => {"];if(u)c.push(` const url = \`${Is(i,r)}\`;`,' if (!url || url === "undefined" || url.includes("undefined")) return;');else c.push(` const url = ${JSON.stringify(i)};`);let l=[];if(a!=="GET")l.push(`method: ${JSON.stringify(a)}`);if(t.headers)l.push(`headers: ${JSON.stringify(t.headers)}`);if(t.body){let g=C(t.body)?JSON.stringify(JSON.stringify(t.body)):JSON.stringify(t.body);l.push(`body: ${g}`)}let p=l.length>0?`, { ${l.join(", ")} }`:"";return c.push(` fetch(url${p})`," .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((g)=>`${s}${g}`).join(`
|
|
4
|
+
`)}function dt(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o,serverBaseUrl:i="/_jx/server"}=n,u=JSON.stringify(`${i}/${t.$export}`),a=Object.entries(t.arguments??{}),c=a.map(([f,m])=>{if(!P(m))return`${fe(f)}: ${JSON.stringify(m)}`;if(Ms.some((y)=>m.$ref.startsWith(y)))throw Error(`Server function "${e}": argument "${f}" references "${m.$ref}", which a state entry cannot read. Use a #/state/, parent#/, window#/ or document#/ reference.`);return`${fe(f)}: ${de({$ref:m.$ref},{statePrefix:r})}`}),l=a.some(([,f])=>P(f)),p=`${pr}(${u}, ${c.length>0?`{ ${c.join(", ")} }`:"{}"})`,g=R(r,B(e)),d=`console.error(${JSON.stringify(`Jx server function ${t.$export}:`)}, e)`;return(l?[`// ${e}: server function ${t.$export}, called again when an argument changes`,"{"," let _jxSeq = 0;",o?` ${o}.push(effect(() => {`:" effect(() => {"," const _seq = ++_jxSeq;",` ${p}`,` .then((d) => { if (_seq === _jxSeq) ${g} = d; })`,` .catch((e) => { if (_seq === _jxSeq) ${d}; });`,o?" }));":" });","}"]:[`// ${e}: server function ${t.$export}, called once`,p,` .then((d) => { ${g} = d; })`,` .catch((e) => { ${d}; });`]).map((f)=>`${s}${f}`).join(`
|
|
5
|
+
`)}function Is(e,t){if(t==="state")return e;return e.replaceAll(/\$\{([^}]*)\}/g,(n,r)=>`\${${r.replaceAll(/(?<!this\.)\bstate\./g,`${t}.`)}}`)}function xt(e){if(!C(e))return!1;if(e.state)for(let[t,n]of Object.entries(e.state)){if(t==="$site"||t==="$page")continue;if(!C(n)||Array.isArray(n))return!0;if(n.timing==="compiler")continue;if(n.$prototype)return!0;if("default"in n)return!0;if($e(n))continue;return!0}if(e.$switch)return!0;if(V(e)||Pt(e.children))return!0;if(Array.isArray(e.children)&&e.children.some((t)=>xt(t)))return!0;for(let[t,n]of Object.entries(e)){if(ge.has(t))continue;if(P(n))return!0;if(N(n))return!0}if(C(e.style)){for(let t of Object.values(e.style))if(N(t))return!0}if(C(e.attributes)){for(let t of Object.values(e.attributes))if(N(t))return!0}return!1}function ir(e){if(!C(e))return!1;if(e.$switch)return!0;if(V(e)||Pt(e.children))return!0;for(let[t,n]of Object.entries(e)){if(ge.has(t))continue;if(P(n))return!0;if(N(n))return!0}if(C(e.style)){for(let t of Object.values(e.style))if(N(t))return!0}if(C(e.attributes)){for(let t of Object.values(e.attributes))if(N(t))return!0}return!1}function ke(e,t=null,n={},r={}){let s=e?.state?en(e.state,t):t??ar();return{media:r,scope:s,scopeDefs:n}}function ar(e=null){return Object.create(e)}function lr(e){return e[or]}function Qt(e,t){if(J(e)){for(let o of e.matchAll(Ls))t.add(o[1]);for(let o of e.matchAll(Fs))t.add(o[1]);return}if(Array.isArray(e)){for(let o of e)Qt(o,t);return}if(!C(e))return;let n=e,{operator:r,target:s}=n;if(J(r)&&me(r)&&P(s)&&s.$ref.startsWith("#/state/"))t.add(s.$ref.slice(8).split("/")[0]);for(let o of Object.values(n))Qt(o,t)}function en(e={},t=null){let n=ar(t),r=t?lr(t):void 0,s=new Set(r);Object.defineProperty(n,or,{configurable:!0,enumerable:!1,value:s,writable:!0});let o=new Set;for(let c of Object.values(e))if(G(c)||X(c))Qt(c.body??c.$expression,o);for(let c of o)if(c in e)s.add(c);for(let[c,l]of Object.entries(e)){if(!C(l)||Array.isArray(l)){he(n,c,ct(l));continue}if("default"in l){he(n,c,ct(l.default));continue}if(le(l)){s.add(c);continue}if(!l.$prototype&&!("$expression"in l)&&!$e(l))he(n,c,ct(l))}let i=[],u=[];for(let[c,l]of Object.entries(e)){if(N(l)){i.push([c,l]);continue}if(!C(l))continue;if(X(l)){let p=l.$expression;if(Ee(l)){let g=l.parameters;he(n,c,(...d)=>{let x={};for(let[f,m]of g.entries()){let y=rr(m);if(!y)continue;x[y]=d[f]===void 0&&sr(m)?m.default:d[f]}return Z(p,n,null,{args:x})})}else if(me(p.operator))he(n,c,(g,d)=>Z(p,g,d));else Xt(n,c,()=>Z(p,n,null));continue}if(G(l)){if(xe(l)){let{body:p}=l;he(n,c,(g,d)=>{Ne(p,g??n,d??null)})}else if(J(l.body)){let p=l.parameters?ce(l.parameters):l.arguments??[],{body:g}=l,d=p.includes("state")?p:["state",...p],x=Function(...d,g),f=(m,y)=>x(...d.map((w)=>w==="state"?m:y));if(we(g))Xt(n,c,()=>f(n)),u.push([c,g]);else he(n,c,f)}else he(n,c,()=>{}),s.add(c);continue}if(ye(l)&&(l.$prototype==="LocalStorage"||l.$prototype==="SessionStorage")){he(n,c,ct(l.default??null));continue}if(ye(l)&&l.$prototype==="Request")s.add(c)}let a=!0;while(a){a=!1;for(let[c,l]of[...u,...i])if(!s.has(c)&&cr(l,n))s.add(c),a=!0}for(let[c,l]of i)Xt(n,c,()=>rn(l,n));return n}function he(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function Xt(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:n})}function T(e,t){if(P(e))return Ws(e.$ref,t);if(N(e))return rn(e,t);return e}function Y(e){return P(e)}function Ws(e,t){if(!J(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?Zt(o,n.slice(2).join("/")):o}if(e.startsWith("#/state/"))return Zt(t,e.slice(8));return Zt(t,e)??null}function cr(e,t){if(!t)return!1;let n=lr(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(te(o))return!0}return!1}function yt(e){return ot(e)?`(${e.slice(2,-1)})`:`\`${e}\``}function rn(e,t){if(cr(e,t))return null;let n=["state","$map","$site","$page"],r=[t,t?.$map,t?.$site,t?.$page];try{let s=ot(e)?`return (${e.slice(2,-1)})`:`return \`${e}\``;return Function(...n,s)(...r)}catch{return null}}function Zt(e,t){return U(e,t)}function ct(e){if(!C(e))return e;return structuredClone(e)}function Vs(e,t){if(!e||!t)return"";return Object.entries(e).filter(([n,r])=>!n.startsWith(":")&&!n.startsWith(".")&&!n.startsWith("&")&&!n.startsWith("[")&&!n.startsWith("@")&&N(r)).map(([n,r])=>{let s=T(r,t);return s==null?null:`${z(n)}: ${s}`}).filter(Boolean).join("; ")}function ve(e,t,n=""){let r="",s=T(e.id,t),o=T(e.className,t),i=T(e.hidden,t),u=T(e.tabIndex,t),a=T(e.title,t),c=T(e.lang,t),l=T(e.dir,t);if(s)r+=` id="${j(String(s))}"`;if(o)r+=` class="${j(String(o))}"`;if(i)r+=" hidden";if(u!==void 0&&u!==null)r+=` tabindex="${j(String(u))}"`;if(a)r+=` title="${j(String(a))}"`;if(c)r+=` lang="${j(String(c))}"`;if(l)r+=` dir="${j(String(l))}"`;let p=[Vs(e.style,t),n].filter(Boolean).join("; ");if(p)r+=` style="${j(p)}"`;if(e.attributes)for(let[g,d]of Object.entries(e.attributes)){let x=T(d,t);if(K(x)){let f=Ce(g,x);if(f!==null)r+=f===""?` ${g}`:` ${g}="${j(f)}"`;continue}if(J(x)||ee(x))r+=` ${g}="${j(String(x))}"`}if(e.$static)r+=" data-jx-static";else if(e.$prerendered)r+=" data-jx-prerendered";return r}function Xe(e,t=" "){return e?"":`
|
|
6
|
+
${t}`}function $t(){let e=JSON.stringify(nt),t=JSON.stringify(se);return`(function(){try{var s=localStorage.getItem(${e});if(s==="light"||s==="dark"){document.documentElement.setAttribute(${t},s)}}catch(e){}})()`}function ut(e,t,n,r){for(let s of Ae(t,{mediaQueries:r,resolveValue:(o,i)=>ur(o,i,n),scope:n}))e.push(s.text)}function ur(e,t,n){let r=J(t)?t:t.$ref;return Hs.push({property:e,selector:n,source:r}),null}function St(){return`const __jxEnumAttrs = new Set(${JSON.stringify(Zn())});
|
|
7
7
|
function ${_e}(n, v) {
|
|
8
8
|
if (typeof v !== 'boolean') return v;
|
|
9
9
|
const l = n.toLowerCase();
|
|
@@ -12,18 +12,18 @@ function ${_e}(n, v) {
|
|
|
12
12
|
}`}function bt(){return[`async function ${pr}(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
13
|
`)}function fr(){let e=`new RegExp(${JSON.stringify(it.source)}, ${JSON.stringify(it.flags)})`,t=`Symbol.for(${JSON.stringify(Gt)})`,n=JSON.stringify(Yt),r=JSON.stringify(at);return[`const __jxSlotWs = ${e};`,`const __jxSlotRec = globalThis[${t}] || (globalThis[${t}] = new WeakMap());`,`function ${sn}(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 ${on}(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
14
|
`)}function Pe(e){for(let t of an(e)){if(V(t)){if(t.map&&Pe([t.map]))return!0;continue}if(!Fe(t))continue;if(t.tagName==="slot")return!0;let n=Object.values(t.cases??{}).filter((r)=>Fe(r)&&!Y(r));if(Pe(n)||Pe(t.children))return!0}return!1}function an(e){if(V(e))return[e];if(!Array.isArray(e))return[];return e}function Me(e,t={},n=null){let r=[],s=Qn(C(n)?n:{},t,(i)=>i,ur);if(s!=="")r.push(s);if(Te(e,r,t,"",{n:0}),r.length===0)return"";return`<style>
|
|
15
|
-
${
|
|
15
|
+
${Bs(r.join(`
|
|
16
16
|
`))}
|
|
17
|
-
</style>`}function
|
|
18
|
-
${a}`,c.content||=u;else s.set(i,{content:u,html:a})}return{groups:s,id:r,taken:new Set}}function dr(e,t,n){for(let r of an(e)){if(V(r)||!Fe(r))continue;if(r.tagName==="slot"){let s=T(r.attributes?.name,t);n.taken.add(J(s)?s:"")}dr(r.children,t,n)}}function
|
|
17
|
+
</style>`}function Bs(e){return e.replaceAll(/<\/(?=style)/gi,String.raw`<\/`)}function Te(e,t,n,r="",s,o="jx"){let i=s??{n:0};if(!C(e))return;if(e.style&&!e.id&&!e.className)e.className=`${o}-${i.n}`,i.n+=1;let u=Oe(e.tagName).join(", ")||"*",a=e.id?`#${e.id}`:e.className?`.${e.className.split(" ")[0]}`:u;if(e.style)ut(t,e.style,a,n);if(Array.isArray(e.children))for(let c of e.children)Te(c,t,n,a,i,o);if(C(e.cases))for(let c of Object.values(e.cases))Te(c,t,n,a,i,o)}function j(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function Jt(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function Vi(e){let t=[];return mr(e,t),t}function mr(e,t){if(!C(e))return;if(e.state){for(let[n,r]of Object.entries(e.state))if(le(r))t.push({exportName:r.$export,key:n,src:r.$src})}if(Array.isArray(e.children))for(let n of e.children)mr(n,t)}function cn(e,t){if(J(e))return e;let n=Oe(e);if(n.length===0)return"div";if(!oe(e))return n[0];let r=e.$expression,s=r.target;if(r.operator==="?:")return T(s,t)?r.value:r.initial;let o=T(s,t);return r.cases[String(o)]??r.default}function Us(e){if(!e?.slotIds)return null;return e.slotIds.n+=1,e.slotIds.n}function qs(e,t,n,r=null){let s=new Map;for(let o of an(e)){let i="",u=!0,a;if(J(o)||ee(o)||K(o)){if(a=n(o),it.test(a))continue;u=a!==""}else if(V(o))a="";else if(!Fe(o))a=n(o),u=a!=="";else{let l=T(o.attributes?.slot,t),p=J(o.slot)?T(o.slot,t):null;if(J(l)&&l!=="")i=l,a=n(o);else if(J(p)&&p!==""){i=p;let{slot:g,...d}=o;a=n({...d,attributes:{...d.attributes,slot:p}})}else a=n(o)}let c=s.get(i);if(c)c.html=c.html===""?a:`${c.html}
|
|
18
|
+
${a}`,c.content||=u;else s.set(i,{content:u,html:a})}return{groups:s,id:r,taken:new Set}}function dr(e,t,n){for(let r of an(e)){if(V(r)||!Fe(r))continue;if(r.tagName==="slot"){let s=T(r.attributes?.name,t);n.taken.add(J(s)?s:"")}dr(r.children,t,n)}}function Ks(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 gr(e,t){if(!t)return en(e.state??{},null);let n={...e.state};for(let[r,s]of Object.entries(t)){let o=n[r];n[r]=C(o)&&!Array.isArray(o)&&"default"in o?{...o,default:s}:s}return en(n,null)}function zs(e,t){return Object.fromEntries(Object.entries(e??{}).flatMap(([n,r])=>{if(!N(r))return[];let s=T(r,t);return s==null?[]:[[n,s]]}))}function Ye(e,t,n,r){if(e.textContent!==void 0){let s=T(e.textContent,t);return s!=null?j(String(s)):""}if(e.innerHTML){let s=T(e.innerHTML,t);return s!=null?String(s):e.innerHTML}if(Array.isArray(e.children))return e.children.map((s)=>pt(s,t,n,r)).join(`
|
|
19
19
|
`);return""}function pt(e,t,n=null,r=null){if(J(e)){if(N(e)&&t){let u=rn(e,t);return u!=null?j(String(u)):j(e)}return j(e)}if(ee(e)||K(e))return j(String(e));if(Array.isArray(e))return e.map((u)=>pt(u,t,n,r)).join(`
|
|
20
20
|
`);if(!C(e))return"";if(e.$prototype==="Array")return"";if(e.$switch){let u=e.tagName??"div",a=ve(e,t),c=T(e.$switch,t),l=c==null?void 0:e.cases?.[String(c)],p=l!==void 0&&!Y(l)?pt(l,t,n,r):"";return`<${u}${a}>${p}</${u}>`}let s=cn(e.tagName,t);if(s==="slot"&&n){let u=T(e.attributes?.name,t),a=J(u)?u:"",c;if(!n.taken.has(a))n.taken.add(a),c=n.groups.get(a);let l=c?.html??"";if(l!==""&&n.id!==null)l=`<!--${at} ${n.id} ${encodeURIComponent(a)}-->${l}<!--/${at} ${n.id}-->`;if(c?.content)return dr(e.children,t,n),l;let p=Ye(e,t,n,r);return l===""?p:p===""?l:`${l}
|
|
21
|
-
${p}`}let o=r?.componentDefs.get(s);if(o&&r)return
|
|
22
|
-
`):"";v=`<template shadowrootmode="${y}"><link rel="stylesheet" href="/components/${o}.css">${Ye(t,O,null,x)}</template>${h}`}else{A=!w&&Pe(t.children)?
|
|
21
|
+
${p}`}let o=r?.componentDefs.get(s);if(o&&r)return Ys(e,o,t,n,r);let i=ve(e,t);if(ln.has(s))return`<${s}${i}>`;return`<${s}${i}>${Ye(e,t,n,r)}</${s}>`}function Ys(e,t,n,r,s){let o=t.tagName,{lifted:i,rest:u}=Ks(e.attributes),a={...i,...e.$props},c={};for(let[h,b]of Object.entries(a))c[h]=T(b,n)??b;let l=Object.keys(c).length>0,p=s.path??[],g={key:JSON.stringify(c),tag:o},d=[...p.map((h)=>h.tag),o].join(" → ");if(p.some((h)=>h.tag===g.tag&&h.key===g.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(p.length>=zt)throw Error(`Component nesting exceeds ${zt} levels: ${d}. A component that renders itself with changing props needs a case that stops.`);let x={...s,path:[...p,g]},{children:f}=e,m=(h)=>pt(h,n,r,s),y=lt(t,s.defaults),w=Gs(t),O=gr(t,l?c:null),v,A=null;if(y){let h=Array.isArray(f)?f.map((b)=>m(b)).join(`
|
|
22
|
+
`):"";v=`<template shadowrootmode="${y}"><link rel="stylesheet" href="/components/${o}.css">${Ye(t,O,null,x)}</template>${h}`}else{A=!w&&Pe(t.children)?Us(s):null;let h=qs(f,n,m,A);v=Ye(t,O,h,x)}let k=Object.entries(zs(t.style,O)).map(([h,b])=>`${z(h)}: ${b}`).join("; "),S={...e};if(delete S.$props,delete S.children,S.attributes=!w&&l?{...u,"data-jx-props":JSON.stringify(c)}:u,A!==null)S.attributes={...S.attributes,[Yt]:String(A)};if(w)S.$static=!0;else S.$prerendered=!0;return`<${o}${ve(S,n,k)}>${v}</${o}>`}function Hi(e,t=null,n=null,r=null){return Ye(e,gr(e,t),n,r)}function Gs(e){return tn(e)}function tn(e){if(!C(e))return!0;if(Array.isArray(e))return e.every((t)=>tn(t));if(e.$prototype)return!1;if(e.$ref)return!1;if(e.state)for(let t of Object.values(e.state)){if(!C(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)=>tn(t));if(V(e.children))return!1;return!0}function Zs(e,t){return Ve(e).map((n)=>Qs(n,t)).join(", ")}function Qs(e,t){let n=tt(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"&&Xs.test(e))return e;return`${t}${e}`}function Bi(e,t,n=null,r={},s=null){let o=[],i=nr(e,s);if(C(t)){let u={},a=[];for(let[c,l]of Object.entries(t))if(P(l))u[c]=l;else if(C(l)&&!Array.isArray(l))a.push([c,l]);else if(!c.startsWith("@")&&!Se(c))u[c]=l;ut(o,u,i,r);for(let[c,l]of a)if(c.startsWith("@"))ut(o,{[c]:l},i,r);else if(Se(c))ut(o,l,Zs(c,i),r)}if(n&&Array.isArray(n.children)){let u={n:0};for(let a of n.children)Te(a,o,r,"",u,e)}return o.length>0?`${o.join(`
|
|
23
23
|
`)}
|
|
24
|
-
`:""}var
|
|
25
|
-
`,"\r"]);
|
|
26
|
-
`],["r","\r"],["t","\t"]])});function oo(e){return e instanceof Error?e.message:String(e)}function br(e){if(J(e))return Sr.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>br(t));if(L(e))return Jr(e);return e}function Jr(e){let t={};for(let[n,r]of Object.entries(e))t[Sr.test(n)?n.normalize("NFC"):n]=br(r);return t}function un(e,t,n){let r;try{r=JSON.parse(e)}catch(o){throw Error(`Failed to parse ${n} at ${t}: ${oo(o)}`,{cause:o})}if(!L(r))throw Error(`Invalid ${n} at ${t}: expected a JSON object`);let s=xr(e);if(s.length>0){let o=s.map((i)=>yr(i)).join("; ");throw Error(`Invalid ${n} at ${t}: ${o}`)}return Jr(r)}function Et(e,t){return un(e,t,"Jx document")}function Zi(e,t){return un(e,t,"project config")}function Qi(e,t){return un(e,t,"class definition")}var Sr;var pn=I(()=>{H();$r();Sr=/[^\p{ASCII}]/u});function vr(e){if(!J(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(!Er.test(s)||!Er.test(o))return null;let i=o.lastIndexOf("+"),u=i===-1?null:o.slice(i+1),a=i===-1?o:o.slice(0,i);if(u==="")return null;let c=a.indexOf("."),l=c===-1?null:a.slice(0,c),p=l!==null&&io.has(l)?l:null,g=p===null?a:a.slice(p.length+1);if(g==="")return null;let d={};for(let x of n){let f=x.indexOf("=");if(f===-1)return null;let m=x.slice(0,f).trim().toLowerCase(),y=x.slice(f+1).trim();if(m==="")return null;if(y.startsWith('"')&&y.endsWith('"')&&y.length>=2)y=y.slice(1,-1);d[m]=y}return{parameters:d,subtype:g,suffix:u,tree:p,type:s}}function Or(e){if(!J(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(vr(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function Ar(e){let t=vr(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 Er,io,wr="text/markdown; variant=GFM",Cr="application/yaml",na;var jr=I(()=>{H();Er=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,io=new Set(["vnd","prs","x"]);na={".markdown":`${wr}; charset=utf-8`,".md":`${wr}; charset=utf-8`,".yaml":`${Cr}; charset=utf-8`,".yml":`${Cr}; charset=utf-8`}});function Tr(e){if(e===null)throw TypeError("A class descriptor cannot be null");return L(e)?e:{}}class wt{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=Ar(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=lo(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(!te(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 Ct{#t;constructor(e){this.#t=e;for(let t of e){if(t.mediaType===null)continue;let n=Or(t.mediaType);if(n!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${n}`)}for(let t of Nr){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=Rr(e);return this.#t.find((r)=>r.extensions.includes(n)&&(!t||r.capabilities[t]))}byName(e){return this.#t.find((t)=>t.name===e)}withCapability(e){return this.#t.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let n of this.#t){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=Rr(e);return this.#t.some((n)=>n.extensions.includes(t))}}function lo(e){let t={},n=e.$defs?.methods??{};for(let[r,s]of Object.entries(n)){let{role:o}=s;if(!uo(o))continue;let i={identifier:s.identifier??r,timing:s.timing??ao};if(J(s.discriminator))i.discriminator=s.discriminator;t[o]=i}return t}function uo(e){return e!==void 0&&co.has(e)}function Rr(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var Nr,Pr,ao,co;var fn=I(()=>{H();jr();Nr=["parse","serialize","rewrite","discover","load"],Pr=[...Nr,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"];ao=["compiler","server"];co=new Set(Pr)});class kr{#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 Ct(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 _r(e,t,n){let r=[];for(let s of e??[])r.push(await po(s,t,n));return new kr(r)}async function po(e,t,n){let r;if(e.startsWith("./")||e.startsWith("../")){let a=t.resolvePath(n,e);r=t.resolvePath(`${a}/package.json`,`./${Ze}`)}else try{r=t.resolvePath(n,`${e}/${Ze}`)}catch(a){throw Error(`Extension "${e}" is not resolvable: it must export ${Ze} (is the package installed, and does its exports map include it?): ${mn(a)}`,{cause:a})}let s;try{s=await t.loadJson(r)}catch(a){throw Error(`Extension "${e}": cannot read manifest ${r}: ${mn(a)}`,{cause:a})}if(!L(s)||!J(s.name))throw Error(`Extension "${e}": ${Ze} 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,c]of Object.entries(o.classes??{})){let l=t.resolvePath(r,c),p;try{p=await t.loadJson(l)}catch(g){throw Error(`Extension "${e}": cannot read class "${a}" at ${l}: ${mn(g)}`,{cause:g})}i.push(new wt(a,l,Tr(p),t))}let u={};if(o.schemas?.project)u.project=t.resolvePath(r,o.schemas.project);if(o.schemas?.document)u.document=t.resolvePath(r,o.schemas.document);if(o.schemas?.fields)u.fields=t.resolvePath(r,o.schemas.fields);return{specifier:e,manifestPath:r,manifest:o,classes:i,schemas:u}}function mn(e){return e instanceof Error?e.message:String(e)}var Ze="jx-extension.json";var Dr=I(()=>{fn();H();fn()});import{readFileSync as fo}from"node:fs";import{dirname as mo,isAbsolute as go,resolve as dn,sep as vt}from"node:path";import{pathToFileURL as ho}from"node:url";import{createRequire as Mr}from"node:module";async function xo(e){let t=[e],n=`${vt}src${vt}`,r=`${vt}dist${vt}`;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(ho(o).href)}catch(i){s=i}throw s instanceof Error?s:Error(String(s))}function yo(e){return{importModule:(t)=>xo(t),loadJson:async(t)=>JSON.parse(fo(t,"utf8")),resolvePath:(t,n)=>{if(n.startsWith("./")||n.startsWith("../"))return dn(mo(t),n);if(go(n))return n;let r=Mr(dn(e,"package.json"));try{return r.resolve(n)}catch{return Mr(import.meta.url).resolve(n)}}}}async function xa(e,t){return _r(t?.extensions,yo(e),dn(e,"project.json"))}function Ot(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 gn=I(()=>{Dr();H()});async function Wr(e,t={}){let{resolveElementPath:n,$media:r,formats:s}=t,o=[],i=new Set;async function u(a,c){let l,p;if(J(a)){let{readFileSync:v}=await import("node:fs"),{resolve:A}=await import("node:path");if(p=c?A(c,a):A(a),i.has(p))return;if(i.add(p),p.endsWith(".json"))l=Et(v(p,"utf8"),p);else{let{extname:k}=await import("node:path"),S=k(p).toLowerCase(),h=s?.byExtension(S,"parse");if(!h){await Promise.resolve().then(() => gn());throw Ot(p,S)}l=await h.parseDocument(v(p,"utf8"))}}else{if(l=a,p=null,l.tagName&&i.has(l.tagName))return;if(l.tagName)i.add(l.tagName)}let{tagName:g}=l;if(!g||!g.includes("-"))throw Error(`compileElement: tagName "${g}" must contain a hyphen`);let{dirname:d}=await import("node:path"),x=p?d(p):null,f=[];if(Array.isArray(l.$elements))for(let v of l.$elements){let A=P(v)?v.$ref:v;if(!J(A))continue;if(x)await u(A,x);let k=n?n(A,x):A.replace(/\.json$/,".js");f.push(k)}let m=Jt(g);if(r)l.$media={...r,...l.$media};let{rewriteSrc:y}=t,w=Qe(l,m,f,y?(v)=>y(v,x):void 0,lt(l,t.defaults),t.serverBaseUrl),O=p?p.replace(/\.json$/,".js"):`${g}.js`;o.push({content:w,path:O,tagName:g})}return await u(e,t.basePath??null),{files:o}}async function $o(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 Wr(e,t),i=o.files.at(-1);if(!i)throw Error("compileElementPage: no element modules were produced");let{basename:u}=await import("node:path"),a=u(i.path),c=`<!DOCTYPE html>
|
|
24
|
+
`:""}var Ms,or,gt="https://esm.sh/@vue/reactivity@3.5.40",ht="https://esm.sh/lit-html@3.3.0",Ls,Fs,be,Hs,_e="__jxAttrText",pr="__jxServerCall",sn="__jxCaptureSlotted",on="__jxDistributeSlots",De="<!---->",ln,Xs;var Ie=I(()=>{ze();Be();qe();st();er();H();je();ze();qe();st();H();Ms=["$map/","event#/","$args/","$reduce/"];or=Symbol("jx.runtimeOnlyStateKeys");Ls=/\bstate\.([A-Za-z_$][\w$]*)\s*(?:\+\+|--|(?:\*\*|\|\||&&|\?\?|<<|>>>|>>|[-+*/%&|^])?=(?!=))/g,Fs=/\bstate\.([A-Za-z_$][\w$]*)\s*\.\s*(?:push|pop|shift|unshift|splice|sort|reverse|fill|copyWithin)\s*\(/g;be=new Set(["pre","textarea","listing","plaintext","xmp"]);Hs=[];ln=new Set(["input","br","hr","img","meta","link","area","col","source"]);Xs=/^(?:::slotted\(|::part\()/});function xr(e){let t=[],n=[],r=null,s=0,o=()=>n.at(-1)?.path??"",i=()=>r===null?o():no(o(),r),u=()=>{s+=1;let a="";while(s<e.length){let c=e[s];if(c==="\\"){let l=e[s+1]??"";if(l==="u")a+=String.fromCodePoint(Number.parseInt(e.slice(s+2,s+6),16)),s+=6;else a+=eo.get(l)??l,s+=2;continue}if(c==='"')return s+=1,a;a+=c,s+=1}return a};while(s<e.length){let a=e[s];if(hr.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 l=u(),p=n.at(-1);if(p?.kind==="object"&&to(e,s)===":"){if(p.keys.has(l))t.push({detail:l,kind:"duplicate-key",path:p.path});p.keys.add(l),r=l}else r=null;continue}if(a==="-"||a>="0"&&a<="9"){let l=s;while(s<e.length&&/[\d+.eE-]/.test(e[s]))s+=1;let p=e.slice(l,s);if(!ro(p))t.push({detail:p,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 to(e,t){let n=t;while(n<e.length&&hr.has(e[n]))n+=1;return e[n]??""}function no(e,t){return e===""?t:`${e}.${t}`}function ro(e){if(/[.eE]/.test(e))return!0;let t=Number(e);if(!Number.isFinite(t))return!1;return String(t)===e.replace(/^\+/,"")}function yr(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 hr,eo;var $r=I(()=>{hr=new Set([" ","\t",`
|
|
25
|
+
`,"\r"]);eo=new Map([["b","\b"],["f","\f"],["n",`
|
|
26
|
+
`],["r","\r"],["t","\t"]])});function so(e){return e instanceof Error?e.message:String(e)}function br(e){if(J(e))return Sr.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>br(t));if(L(e))return Jr(e);return e}function Jr(e){let t={};for(let[n,r]of Object.entries(e))t[Sr.test(n)?n.normalize("NFC"):n]=br(r);return t}function un(e,t,n){let r;try{r=JSON.parse(e)}catch(o){throw Error(`Failed to parse ${n} at ${t}: ${so(o)}`,{cause:o})}if(!L(r))throw Error(`Invalid ${n} at ${t}: expected a JSON object`);let s=xr(e);if(s.length>0){let o=s.map((i)=>yr(i)).join("; ");throw Error(`Invalid ${n} at ${t}: ${o}`)}return Jr(r)}function Et(e,t){return un(e,t,"Jx document")}function Qi(e,t){return un(e,t,"project config")}function ea(e,t){return un(e,t,"class definition")}var Sr;var pn=I(()=>{H();$r();Sr=/[^\p{ASCII}]/u});function vr(e){if(!J(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(!Er.test(s)||!Er.test(o))return null;let i=o.lastIndexOf("+"),u=i===-1?null:o.slice(i+1),a=i===-1?o:o.slice(0,i);if(u==="")return null;let c=a.indexOf("."),l=c===-1?null:a.slice(0,c),p=l!==null&&oo.has(l)?l:null,g=p===null?a:a.slice(p.length+1);if(g==="")return null;let d={};for(let x of n){let f=x.indexOf("=");if(f===-1)return null;let m=x.slice(0,f).trim().toLowerCase(),y=x.slice(f+1).trim();if(m==="")return null;if(y.startsWith('"')&&y.endsWith('"')&&y.length>=2)y=y.slice(1,-1);d[m]=y}return{parameters:d,subtype:g,suffix:u,tree:p,type:s}}function Or(e){if(!J(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(vr(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function Ar(e){let t=vr(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 Er,oo,wr="text/markdown; variant=GFM",Cr="application/yaml",ra;var jr=I(()=>{H();Er=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,oo=new Set(["vnd","prs","x"]);ra={".markdown":`${wr}; charset=utf-8`,".md":`${wr}; charset=utf-8`,".yaml":`${Cr}; charset=utf-8`,".yml":`${Cr}; charset=utf-8`}});function Tr(e){if(e===null)throw TypeError("A class descriptor cannot be null");return L(e)?e:{}}class wt{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=Ar(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=ao(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(!te(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 Ct{#t;constructor(e){this.#t=e;for(let t of e){if(t.mediaType===null)continue;let n=Or(t.mediaType);if(n!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${n}`)}for(let t of Nr){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=Rr(e);return this.#t.find((r)=>r.extensions.includes(n)&&(!t||r.capabilities[t]))}byName(e){return this.#t.find((t)=>t.name===e)}withCapability(e){return this.#t.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let n of this.#t){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=Rr(e);return this.#t.some((n)=>n.extensions.includes(t))}}function ao(e){let t={},n=e.$defs?.methods??{};for(let[r,s]of Object.entries(n)){let{role:o}=s;if(!co(o))continue;let i={identifier:s.identifier??r,timing:s.timing??io};if(J(s.discriminator))i.discriminator=s.discriminator;t[o]=i}return t}function co(e){return e!==void 0&&lo.has(e)}function Rr(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var Nr,Pr,io,lo;var fn=I(()=>{H();jr();Nr=["parse","serialize","rewrite","discover","load"],Pr=[...Nr,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"];io=["compiler","server"];lo=new Set(Pr)});class kr{#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 Ct(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 _r(e,t,n){let r=[];for(let s of e??[])r.push(await uo(s,t,n));return new kr(r)}async function uo(e,t,n){let r;if(e.startsWith("./")||e.startsWith("../")){let a=t.resolvePath(n,e);r=t.resolvePath(`${a}/package.json`,`./${Ze}`)}else try{r=t.resolvePath(n,`${e}/${Ze}`)}catch(a){throw Error(`Extension "${e}" is not resolvable: it must export ${Ze} (is the package installed, and does its exports map include it?): ${mn(a)}`,{cause:a})}let s;try{s=await t.loadJson(r)}catch(a){throw Error(`Extension "${e}": cannot read manifest ${r}: ${mn(a)}`,{cause:a})}if(!L(s)||!J(s.name))throw Error(`Extension "${e}": ${Ze} 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,c]of Object.entries(o.classes??{})){let l=t.resolvePath(r,c),p;try{p=await t.loadJson(l)}catch(g){throw Error(`Extension "${e}": cannot read class "${a}" at ${l}: ${mn(g)}`,{cause:g})}i.push(new wt(a,l,Tr(p),t))}let u={};if(o.schemas?.project)u.project=t.resolvePath(r,o.schemas.project);if(o.schemas?.document)u.document=t.resolvePath(r,o.schemas.document);if(o.schemas?.fields)u.fields=t.resolvePath(r,o.schemas.fields);return{specifier:e,manifestPath:r,manifest:o,classes:i,schemas:u}}function mn(e){return e instanceof Error?e.message:String(e)}var Ze="jx-extension.json";var Dr=I(()=>{fn();H();fn()});import{readFileSync as po}from"node:fs";import{dirname as fo,isAbsolute as mo,resolve as dn,sep as vt}from"node:path";import{pathToFileURL as go}from"node:url";import{createRequire as ho}from"node:module";async function xo(e){let t=[e],n=`${vt}src${vt}`,r=`${vt}dist${vt}`;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(go(o).href)}catch(i){s=i}throw s instanceof Error?s:Error(String(s))}function yo(e,t){return ho(dn(e,"package.json")).resolve(t)}function $o(e){return{importModule:(t)=>xo(t),loadJson:async(t)=>JSON.parse(po(t,"utf8")),resolvePath:(t,n)=>{if(n.startsWith("./")||n.startsWith("../"))return dn(fo(t),n);if(mo(n))return n;return yo(e,n)}}}async function ya(e,t){return _r(t?.extensions,$o(e),dn(e,"project.json"))}function Ot(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 gn=I(()=>{Dr();H()});async function Fr(e,t={}){let{resolveElementPath:n,$media:r,formats:s}=t,o=[],i=new Set;async function u(a,c){let l,p;if(J(a)){let{readFileSync:v}=await import("node:fs"),{resolve:A}=await import("node:path");if(p=c?A(c,a):A(a),i.has(p))return;if(i.add(p),p.endsWith(".json"))l=Et(v(p,"utf8"),p);else{let{extname:k}=await import("node:path"),S=k(p).toLowerCase(),h=s?.byExtension(S,"parse");if(!h){await Promise.resolve().then(() => gn());throw Ot(p,S)}l=await h.parseDocument(v(p,"utf8"))}}else{if(l=a,p=null,l.tagName&&i.has(l.tagName))return;if(l.tagName)i.add(l.tagName)}let{tagName:g}=l;if(!g||!g.includes("-"))throw Error(`compileElement: tagName "${g}" must contain a hyphen`);let{dirname:d}=await import("node:path"),x=p?d(p):null,f=[];if(Array.isArray(l.$elements))for(let v of l.$elements){let A=P(v)?v.$ref:v;if(!J(A))continue;if(x)await u(A,x);let k=n?n(A,x):A.replace(/\.json$/,".js");f.push(k)}let m=Jt(g);if(r)l.$media={...r,...l.$media};let{rewriteSrc:y}=t,w=Qe(l,m,f,y?(v)=>y(v,x):void 0,lt(l,t.defaults),t.serverBaseUrl),O=p?p.replace(/\.json$/,".js"):`${g}.js`;o.push({content:w,path:O,tagName:g})}return await u(e,t.basePath??null),{files:o}}async function So(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 Fr(e,t),i=o.files.at(-1);if(!i)throw Error("compileElementPage: no element modules were produced");let{basename:u}=await import("node:path"),a=u(i.path),c=`<!DOCTYPE html>
|
|
27
27
|
<html lang="en">
|
|
28
28
|
<head>
|
|
29
29
|
<meta charset="utf-8">
|
|
@@ -42,11 +42,11 @@ ${p}`}let o=r?.componentDefs.get(s);if(o&&r)return Gs(e,o,t,n,r);let i=ve(e,t);i
|
|
|
42
42
|
<${i.tagName}></${i.tagName}>
|
|
43
43
|
<script type="module" src="./${a}"></script>
|
|
44
44
|
</body>
|
|
45
|
-
</html>`;return{files:o.files,html:c}}function
|
|
46
|
-
`)}function
|
|
45
|
+
</html>`;return{files:o.files,html:c}}function bo(e){if(!C(e)||Array.isArray(e))return JSON.stringify(e);if("default"in e)return JSON.stringify(e.default);if($e(e))return;if(e.$prototype==="LocalStorage"||e.$prototype==="SessionStorage")return JSON.stringify(e.default??null);if(e.$prototype==="Request")return"null";if(le(e))return"null";return JSON.stringify(e)}function Jo(e){let t=new Set,n=new Set,r=(o)=>{if(o.startsWith("#/state/"))t.add(o.slice(8).split("/")[0])},s=(o)=>{if(J(o)){for(let u of o.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*\(/g))t.add(u[1]);return}if(!C(o)||n.has(o))return;if(n.add(o),Array.isArray(o)){for(let u of o)s(u);return}let i=o;if(i.operator==="call"&&P(i.target))r(i.target.$ref);for(let[u,a]of Object.entries(i)){if(u.startsWith("on")&&u!=="observedAttributes"&&P(a))r(a.$ref);s(a)}};return s(e.children),s(e.state),t}function Qe(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 u=new Map,a=new Map,c=e.state??{},l=Jo(e);for(let[S,h]of Object.entries(c))if(G(h)&&h.$src){let b=h.$src;if(h.$lazy===!0){if(!l.has(S)&&!Mr.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 F=a.get(b);if(!F)F=[],a.set(b,F);F.push({binding:S,exportName:nn(S,h)});continue}let E=u.get(b);if(!E)E=[],u.set(b,E);E.push(ft(S,h))}for(let[S,h]of u){let b=r?r(S):S;i.push(`import { ${h.join(", ")} } from '${b}';`)}let p=Object.entries(c).flatMap(([S,h])=>ye(h)&&h.$prototype==="Request"?[[S,h]]:[]),g=Object.entries(c).flatMap(([S,h])=>le(h)?[[S,h]]:[]);if(i.push("import { reactive, computed, effect, stop } from '@vue/reactivity';","import { render, html, nothing } from 'lit-html';",St()),g.length>0)i.push(bt());let d=s===null&&Pe(e.children);if(d)i.push(fr());let x=0;for(let[S,h]of a){let b=r?r(S):S,E=`_jxLazy${x}`;x+=1,i.push(`let ${E};`,`const ${E}Load = () => (${E} ??= import('${b}'));`,...h.map(({binding:F,exportName:W})=>`const ${F} = (...args) => ${E}Load().then((m) => m.${W}(...args));`))}i.push("",`class ${t} extends HTMLElement {`," #effects = [];",...s===null?[]:[" #root = null;"],""," constructor() {"," super();");let f=[],m=[],y=[],w=[],O=[];for(let[S,h]of Object.entries(c))if(X(h))if(Ee(h))w.push([S,h]);else if(me(h.$expression.operator))y.push([S,h]);else m.push([S,h]);else if(G(h))if(h.$src&&!J(h.body))if(l.has(S)||Mr.has(S))y.push([S,h]);else m.push([S,h]);else if(J(h.body)&&we(h.body))m.push([S,h]);else y.push([S,h]);else if(J(h)&&h.includes("${"))O.push([S,h]);else{let b=bo(h);if(b!==void 0)f.push([S,b])}i.push(" this.state = reactive({");for(let[S,h]of f)i.push(` ${fe(S)}: ${h},`);i.push(" });");for(let[S,h]of y)if(i.push(""),X(h)){let b=q(h.$expression,{eventParam:"e",statePrefix:"s"});i.push(` ${R("this.state",B(S))} = (s, e) => { ${b}; };`)}else if(xe(h)){let b=ne(h.body,{dispatchTarget:"this",eventParam:"e",indent:" ",statePrefix:"this.state"});i.push(` ${R("this.state",B(S))} = (s, e) => {`,b," };")}else{let b=h.parameters?ce(h.parameters):h.arguments??["state"],E=b.join(", "),F=J(h.body)?h.body:"";if(b[0]==="state")if(h.$src)i.push(` ${R("this.state",B(S))} = (${E}) => ${S}(${E});`);else i.push(` ${R("this.state",B(S))} = (${E}) => {`,` ${F}`," };");else{let W=b.map((re)=>re==="state"?"state":"e").join(", ");if(h.$src)i.push(` ${R("this.state",B(S))} = (state, e) => ${S}(${W});`);else i.push(` ${R("this.state",B(S))} = (state, e) => {`,` const _fn = (${E}) => {`,` ${F}`," };",` return _fn(${W});`," };")}}for(let[S,h]of w){i.push("");let b=q(h.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${R("this.state",B(S))} = ${Ge(h,b)};`)}for(let[S,h]of O)i.push("",` ${R("this.state",B(S))} = computed(() => ${yt(h.replaceAll("state.","this.state."))});`);for(let[S,h]of m)if(i.push(""),X(h)){let b=q(h.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${R("this.state",B(S))} = computed(() => ${b});`)}else if(h.$src)i.push(` ${R("this.state",B(S))} = computed(() => ${S}(this.state));`);else{i.push(` ${R("this.state",B(S))} = computed(() => {`);let b=(J(h.body)?h.body:"").replaceAll("state.","this.state.");i.push(` ${b}`," });")}i.push(" }","");let v=[];if(Array.isArray(e.children)){let S={n:0};for(let h of e.children)Te(h,v,e.$media??{},"",S,e.tagName)}let A=Wr(),k=!Array.isArray(e.children)&&e.textContent!==void 0?` ${Rt(e.textContent)}`:jt(e.children,e.style," ",!1,!1,A);i.push(" template() {"," const s = this.state;",...A.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[S,h]of p)i.push(mt(S,h,{collect:"this.#effects",indent:" ",statePrefix:"this.state"}));for(let[S,h]of g)i.push(dt(S,h,{collect:"this.#effects",indent:" ",serverBaseUrl:o,statePrefix:"this.state"}));if(C(e.style)){let S=[];for(let[h,b]of Object.entries(e.style)){if(h.startsWith(":")||h.startsWith(".")||h.startsWith("&")||h.startsWith("[")||h.startsWith("@"))continue;if(J(b)&&b.includes("${"))S.push([z(h),b])}if(S.length>0){i.push(" this.#effects.push(effect(() => {");for(let[h,b]of S){let E=b.replaceAll(/\$\{([^}]+)\}/g,(F,W)=>`\${${W.replaceAll("state.","this.state.")}}`);i.push(` this.style['${h}'] = \`${E}\`;`)}i.push(" }));")}}if(d)i.push(` const _slotted = ${sn}(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(` ${on}(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(`
|
|
46
|
+
`)}function Wr(){return{byText:new Map,decls:[]}}function Vr(e,t){let n=e.byText.get(t);if(n)return n;let r=`_c${e.decls.length}`;e.decls.push(` const ${r} = html\`
|
|
47
47
|
${t}
|
|
48
|
-
\`;`);let s=`\${${r}}`;return e.byText.set(t,s),s}function jt(e,t,n,r=!1,s=!1,o=null,i=!1){if(!e)return"";let u=i?De:"";if(V(e))return`${
|
|
49
|
-
`)}function xn(e,t,n=!1,r=!1,s=null,o=null){if(J(e)){if(e.includes("${"))return`${t}${Rt(e)}`;return`${t}${j(e)}`}if(ee(e)||K(e))return`${t}${j(String(e))}`;if(!C(e))return"";if(oe(e.tagName)){let f=e.tagName.$expression,m=de(f.target,{eventParam:"e",statePrefix:"s"}),y=f.operator==="?:"?[[!0,f.value],[!1,f.initial]]:[...Object.entries(f.cases),["__default__",f.default]],w=y.map(([,h])=>h),O=w.map((h)=>n||be.has(h)),v=null;if(s&&O.every((h)=>h===O[0])){let h=
|
|
48
|
+
\`;`);let s=`\${${r}}`;return e.byText.set(t,s),s}function jt(e,t,n,r=!1,s=!1,o=null,i=!1){if(!e)return"";let u=i?De:"";if(V(e))return`${Lr(e,n)}${u}`;if(!Array.isArray(e))return"";return e.map((a)=>{if(V(a))return`${Lr(a,n)}${u}`;let c=xn(a,r?"":n,r,s,o);return J(a)&&a.includes("${")||C(a)&&oe(a.tagName)?`${c}${u}`:c}).join(r?"":`
|
|
49
|
+
`)}function xn(e,t,n=!1,r=!1,s=null,o=null){if(J(e)){if(e.includes("${"))return`${t}${Rt(e)}`;return`${t}${j(e)}`}if(ee(e)||K(e))return`${t}${j(String(e))}`;if(!C(e))return"";if(oe(e.tagName)){let f=e.tagName.$expression,m=de(f.target,{eventParam:"e",statePrefix:"s"}),y=f.operator==="?:"?[[!0,f.value],[!1,f.initial]]:[...Object.entries(f.cases),["__default__",f.default]],w=y.map(([,h])=>h),O=w.map((h)=>n||be.has(h)),v=null;if(s&&O.every((h)=>h===O[0])){let h=Ir(e,`${t} `,O[0]===!0,r,s,w.some((b)=>b.includes("-")));if(h.trim()!=="")v=Vr(s,h)}let A=y.map(([h,b])=>{let E={...e,tagName:b};return[h,xn(E,`${t} `,n,r,s,v)]});if(f.operator==="?:"){let[,h]=A[0],[,b]=A[1];return`${t}\${${m}
|
|
50
50
|
? html\`
|
|
51
51
|
${h}
|
|
52
52
|
\`
|
|
@@ -59,25 +59,25 @@ ${k.join(`,
|
|
|
59
59
|
`)}
|
|
60
60
|
}[String(${m})] ?? html\`
|
|
61
61
|
${S}
|
|
62
|
-
\`}`}let i=e.tagName??"div",u=n||be.has(i),a=[];if(e.attributes)for(let[f,m]of Object.entries(e.attributes))if(P(m))a.push(`${f}="\${${_e}('${f}', ${ae(m.$ref)}) ?? nothing}"`);else if(J(m)&&
|
|
62
|
+
\`}`}let i=e.tagName??"div",u=n||be.has(i),a=[];if(e.attributes)for(let[f,m]of Object.entries(e.attributes))if(P(m))a.push(`${f}="\${${_e}('${f}', ${ae(m.$ref)}) ?? nothing}"`);else if(J(m)&&Eo(m))a.push(`${f}="\${${_e}('${f}', ${Q(m).slice(2,-1)}) ?? nothing}"`);else if(J(m)&&m.includes("${"))a.push(`${f}="${Q(m)}"`);else if(K(m)){let y=Ce(f,m);if(y!==null)a.push(y===""?f:`${f}="${y}"`)}else a.push(`${f}="${m}"`);if(e.id)a.push(`id="${Q(String(e.id))}"`);if(e.className)a.push(`class="${Q(String(e.className))}"`);for(let[f,m]of Object.entries(e)){if(ge.has(f)||f.startsWith("$")||f.startsWith("on")||f==="tagName"||f==="id"||f==="className"||f==="style"||f==="children"||f==="textContent"||f==="innerHTML"||f==="attributes")continue;if(At(m))a.push(`.${f}="\${${ae(m.$ref)}}"`);else if(J(m)&&m.includes("${"))a.push(`.${f}="${Q(m)}"`);else a.push(`.${f}="\${${JSON.stringify(m)}}"`)}if(e.$props)for(let[f,m]of Object.entries(e.$props))if(At(m))a.push(`.${f}="\${${ae(m.$ref)}}"`);else if(J(m)&&m.includes("${"))a.push(`.${f}="${Q(m)}"`);else a.push(`.${f}="\${${JSON.stringify(m)}}"`);let c=r?"s.$map = $map; ":"";for(let[f,m]of Object.entries(e)){if(!f.startsWith("on")||f==="observedAttributes")continue;let y=f.slice(2).toLowerCase();if(At(m))a.push(c?`@${y}="\${(e) => { ${c}${ae(m.$ref)}(s, e); }}"`:`@${y}="\${(e) => ${ae(m.$ref)}(s, e)}"`);else if(C(m)&&"$expression"in m){let w=q(m.$expression,{eventParam:"e",statePrefix:"s"});a.push(`@${y}="\${(e) => { ${c}${w}; }}"`)}else if(G(m))a.push(`@${y}="\${(e) => { ${c}${wo(m)} }}"`)}let l=Br(e.style);if(l)a.push(`style="${l}"`);let p=a.length>0?`
|
|
63
63
|
${t} ${a.join(`
|
|
64
64
|
${t} `)}`:"";if(new Set(["input","br","hr","img","meta","link"]).has(i))return`${t}<${i}${p}
|
|
65
|
-
${t}>`;let d=o??
|
|
66
|
-
${t}>${d}${x}</${i}>`}function
|
|
67
|
-
${a.map(([g,d])=>{let x=s&&l.has(d)?
|
|
65
|
+
${t}>`;let d=o??Ir(e,t,u,r,s,i.includes("-")),x=i==="slot"?De:"";return u?`${x}<${i}${p}>${d}${x}</${i}>`:`${t}${x}<${i}${p}
|
|
66
|
+
${t}>${d}${x}</${i}>`}function Ir(e,t,n,r,s,o=!1){if(e.$switch){let i=P(e.$switch)?e.$switch.$ref:e.$switch,u=ae(i),a=[];for(let[g,d]of Object.entries(e.cases??{})){if(!d||P(d))continue;a.push([g,xn(d,`${t} `,!1,r,s)])}let c=a.map(([,g])=>g),l=new Set(c.filter((g,d)=>c.indexOf(g)!==d&&g.trim()!==""));return`\${{
|
|
67
|
+
${a.map(([g,d])=>{let x=s&&l.has(d)?Vr(s,d):d;return` ${JSON.stringify(g)}: html\`
|
|
68
68
|
${x}
|
|
69
69
|
\``}).join(`,
|
|
70
70
|
`)}
|
|
71
71
|
}[${u}]}`}if(e.textContent!==void 0){let i=Rt(e.textContent),u=P(e.textContent)||J(e.textContent)&&e.textContent.includes("${");return o&&u?`${i}${De}`:i}if(e.innerHTML!==void 0)return e.innerHTML;if(e.children)return n?jt(e.children,e.style,"",!0,r,s,o):`
|
|
72
72
|
${jt(e.children,e.style,`${t} `,!1,r,s,o)}
|
|
73
|
-
${t}`;return""}function
|
|
73
|
+
${t}`;return""}function Lr(e,t){let n=P(e.items)?ae(e.items.$ref):"ITEMS",r=e.map;if(!r)return"";let s=r.tagName??"div",o=[];if(r.attributes)for(let[d,x]of Object.entries(r.attributes))if(P(x))o.push(`${d}="\${${hn(x.$ref)}}"`);else if(J(x)&&x.includes("${"))o.push(`${d}="${Q(x)}"`);else o.push(`${d}="${x}"`);if(r.id)o.push(`id="${Q(String(r.id))}"`);if(r.className)o.push(`class="${Q(String(r.className))}"`);for(let[d,x]of Object.entries(r)){if(ge.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(At(x))o.push(`.${d}="\${${hn(x.$ref)}}"`);else if(J(x)&&x.includes("${"))o.push(`.${d}="${Q(x)}"`);else o.push(`.${d}="\${${JSON.stringify(x)}}"`)}if(r.$props)for(let[d,x]of Object.entries(r.$props))if(P(x))o.push(`.${d}="\${${hn(x.$ref)}}"`);else if(J(x)&&x.includes("${"))o.push(`.${d}="${Q(x)}"`);else o.push(`.${d}="\${${JSON.stringify(x)}}"`);let i=Br(r.style);if(i)o.push(`style="${i}"`);for(let[d,x]of Object.entries(r)){if(!d.startsWith("on"))continue;let f=d.slice(2).toLowerCase();if(P(x))o.push(`@${f}="\${(e) => { s.$map = $map; ${ae(x.$ref)}(s, e); }}"`);else if(X(x)){let m=q(x.$expression,{eventParam:"e",statePrefix:"s"});o.push(`@${f}="\${(e) => { s.$map = $map; ${m}; }}"`)}}let u=o.length>0?`
|
|
74
74
|
${t} ${o.join(`
|
|
75
|
-
${t} `)}`:"",a=
|
|
75
|
+
${t} `)}`:"",a=Wr(),c="";if(r.textContent!==void 0)c=Rt(r.textContent);else if(r.children)c=`
|
|
76
76
|
${jt(r.children,null,`${t} `,!1,!0,a)}
|
|
77
77
|
${t} `;let l=`html\`
|
|
78
78
|
${t} <${s}${u}
|
|
79
79
|
${t} >${c}</${s}>
|
|
80
|
-
${t}\``,p=(l.includes("$map")?"const $map = { item, index }; ":"")+a.decls.map((d)=>`${d.trim()} `).join(""),g=p?`(item, index) => { ${p}return ${l}; }`:`(item, index) => ${l}`;return`${t}\${${n}.map(${g})}`}function At(e){return P(e)&&e.$ref!==""}function ae(e){if(e.startsWith("#/state/"))return R("s",e.slice(8));if(e.startsWith("$map/"))return
|
|
80
|
+
${t}\``,p=(l.includes("$map")?"const $map = { item, index }; ":"")+a.decls.map((d)=>`${d.trim()} `).join(""),g=p?`(item, index) => { ${p}return ${l}; }`:`(item, index) => ${l}`;return`${t}\${${n}.map(${g})}`}function At(e){return P(e)&&e.$ref!==""}function ae(e){if(e.startsWith("#/state/"))return R("s",e.slice(8));if(e.startsWith("$map/"))return Hr(e.slice(5));if(e.startsWith("parent#/"))return R("s",e.slice(8));if(e.startsWith("window#/"))return R("window",e.slice(8));if(e.startsWith("document#/"))return R("document",e.slice(10));return R("s",e)}function Hr(e){let[t,...n]=pe(e);return R(t??"",n.map((r)=>B(r)).join("/"))}function hn(e){if(e.startsWith("$map/"))return Hr(e.slice(5));return ae(e)}function Q(e){return e.replaceAll("state.","s.")}function Eo(e){return e.startsWith("${")&&e.endsWith("}")&&!e.slice(2).includes("${")}function Rt(e){if(P(e))return`\${${ae(e.$ref)}}`;if(J(e)&&e.includes("${"))return Q(e);return String(e)}function wo(e){if(xe(e))return ne(e.body,{dispatchTarget:"e.currentTarget",eventParam:"e",statePrefix:"s"});let t=J(e.body)?e.body:"",n=e.parameters?ce(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 Br(e){if(!C(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(J(r)&&r.includes("${")){let s=z(n);t.push(`${s}: ${Q(r)}`)}}return t.join("; ")}var Mr;var Nt=I(()=>{ze();Ie();H();pn();je();Mr=new Set(["onMount","onUnmount","onAdopted"])});function Ur(e,t){let{title:n="Jx App",reactivitySrc:r,litHtmlSrc:s}=t,o=ke(e,null,e.state??{},e.$media??{}),i=Me(e,e.$media??{},t.projectStyle??null),u=[],a=qr(e,!1,o,u),c=[],l="",p="";if(u.length>0){for(let x of u){let f=Qe(x.def,x.className,[],t.rewriteSrc);c.push({content:f,path:`_islands/${x.tagName}.js`,tagName:x.tagName})}l=`<script type="importmap">
|
|
81
81
|
{
|
|
82
82
|
"imports": {
|
|
83
83
|
"@vue/reactivity": "${r}",
|
|
@@ -99,9 +99,9 @@ ${t}\``,p=(l.includes("$map")?"const $map = { item, index }; ":"")+a.decls.map((
|
|
|
99
99
|
${a}
|
|
100
100
|
${p}
|
|
101
101
|
</body>
|
|
102
|
-
</html>`;return{files:c,html:d}}function
|
|
102
|
+
</html>`;return{files:c,html:d}}function qr(e,t,n,r){if(J(e))return j(e);if(ee(e)||K(e))return j(String(e));if(!C(e))return"";let s=ke(e,n.scope,e.state??n.scopeDefs,e.$media??n.media);if(t){let c=r.length,l=`jx-island-${c}`,p=`JxIsland${c}`,g={...e,tagName:l};return r.push({className:p,def:g,tagName:l}),`<${l}></${l}>`}let o=cn(e.tagName,s.scope),i=ve(e,s.scope);if(ln.has(o))return`<${o}${i}>`;let u=n.preformatted===!0||be.has(o),a=Co(e,{...s,preformatted:u},r);return`<${o}${i}>${a}</${o}>`}function Co(e,t,n){if(e.textContent!==void 0){let r=T(e.textContent,t.scope);return r==null?"":j(String(r))}if(e.innerHTML){let r=T(e.innerHTML,t.scope);return r==null?e.innerHTML:String(r)}if(Array.isArray(e.children))return e.children.map((r)=>qr(r,ir(r),t,n)).join(Xe(t.preformatted));return""}var Kr=I(()=>{Ie();Nt();H()});function bn(e,t){let{title:n="Jx App",reactivitySrc:r=gt,litHtmlSrc:s=ht,modulePath:o="app.js",serverBaseUrl:i="/_jx/server"}=t,u=ke(e,null,e.state??{},e.$media??{}),a=Me(e,e.$media??{},t.projectStyle??null),c={h:0,l:0,m:0,needsLit:!1,s:0,sw:0,t:0},l=new Map,p=new Map,g=[],d=[],x=[],f=[],m=[],y=[],w=new Map,O=e.state??{};for(let[b,E]of Object.entries(O)){if(!C(E)||Array.isArray(E)){if(N(E))d.push([b,`() => ${yt(E)}`]);else g.push([b,E]);continue}if(X(E)){let F=E.$expression,W=q(F,{eventParam:"e",statePrefix:"state"});if(Ee(E))m.push(`state[${JSON.stringify(b)}] = ${Ge(E,W)};`);else if(me(F.operator))f.push([b,{args:["state","e"],body:W}]);else d.push([b,`() => ${W}`]);continue}if(G(E)){let F=E.parameters?ce(E.parameters):E.arguments,{body:W}=E;if(Array.isArray(W)){let re=ne(W,{eventParam:"e",statePrefix:"state"});if(E.parameters&&E.parameters.length>0)m.push(`state[${JSON.stringify(b)}] = ${Ge(E,`(() => {
|
|
103
103
|
${re}
|
|
104
|
-
})()`)};`);else f.push([b,{args:["state","e"],body:re}])}else if(E.$src){let re=w.get(E.$src);if(!re)re=new Set,w.set(E.$src,re);re.add(ft(b,E)),d.push([b,`() => { return ${b}(state); }`])}else if(J(W)&&we(W))d.push([b,`() => { ${W} }`]);else f.push([b,{args:F??["state"],body:W}]);continue}if($e(E))continue;if(vn(E)){g.push([b,E.default]);continue}if(ye(E)){if(E.$prototype==="LocalStorage"||E.$prototype==="SessionStorage"){let F=E.$prototype==="LocalStorage"?"localStorage":"sessionStorage",W=E.key??b,re=E.default??null;g.push([b,null]),m.push(
|
|
104
|
+
})()`)};`);else f.push([b,{args:["state","e"],body:re}])}else if(E.$src){let re=w.get(E.$src);if(!re)re=new Set,w.set(E.$src,re);re.add(ft(b,E)),d.push([b,`() => { return ${b}(state); }`])}else if(J(W)&&we(W))d.push([b,`() => { ${W} }`]);else f.push([b,{args:F??["state"],body:W}]);continue}if($e(E))continue;if(vn(E)){g.push([b,E.default]);continue}if(ye(E)){if(E.$prototype==="LocalStorage"||E.$prototype==="SessionStorage"){let F=E.$prototype==="LocalStorage"?"localStorage":"sessionStorage",W=E.key??b,re=E.default??null;g.push([b,null]),m.push(Oo(b,F,W,re));continue}if(E.$prototype==="Request"){g.push([b,null]),m.push(mt(b,E));continue}if(E.$prototype==="Cookie"){g.push([b,null]),m.push(Ao(b,E.name??b,E.default??null));continue}}if(le(E)){g.push([b,null]),y.push(dt(b,E,{serverBaseUrl:i}));continue}g.push([b,E])}let v=zr(e,u,l,p,c);for(let[b,E]of l)if(!x.some(([F])=>F===b))x.push([b,E]);for(let[b,E]of p)if(!f.some(([F])=>F===b))f.push([b,E]);let A=vo(g,d,x,f,m,y,w,c,r,t.rewriteSrc),k=[` "@vue/reactivity": "${r}"`,` "lit-html": "${s}"`],S=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((b)=>ue(String(b))!==null)?`<script>${$t()}</script>
|
|
105
105
|
`:"",h=`<!DOCTYPE html>
|
|
106
106
|
<html lang="en">
|
|
107
107
|
<head>
|
|
@@ -122,17 +122,17 @@ ${k.join(`,
|
|
|
122
122
|
<body>
|
|
123
123
|
${v}
|
|
124
124
|
</body>
|
|
125
|
-
</html>`;return{files:[{content:A,path:o}],html:h}}function
|
|
125
|
+
</html>`;return{files:[{content:A,path:o}],html:h}}function zr(e,t,n,r,s){if(J(e))return j(e);if(ee(e)||K(e))return j(String(e));if(!C(e))return"";let o=ke(e,t.scope,e.state??t.scopeDefs,e.$media??t.media);if(oe(e.tagName))throw Error(`A tag chosen at creation is not supported on a dynamic page yet (candidates: ${Oe(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||be.has(i);let u=[],a=!1;if(e.textContent!==void 0){let f=e.textContent;if(Y(f)){let m=Le(f.$ref);u.push(`:text-content="${m}"`),yn(n,m,f.$ref),a=!0}else if(N(f)){let m=`_t${s.t}`;s.t+=1,u.push(`:text-content="${m}"`),n.set(m,`() => \`${f}\``),a=!0}}for(let[f,m]of Object.entries(e)){if(!f.startsWith("on")||f==="observedAttributes")continue;let y=f.slice(2).toLowerCase();if(Y(m)){let w=Le(m.$ref);u.push(`@${y}="${w}"`),a=!0}else if(G(m)){let w=`_h${s.h}`;s.h+=1,u.push(`@${y}="${w}"`);let{body:O}=m;r.set(w,Array.isArray(O)?{args:["state","e"],body:ne(O,{eventParam:"e",statePrefix:"state"})}:{args:m.parameters?ce(m.parameters):m.arguments??["state","event"],body:O}),a=!0}else if(X(m)){let w=`_h${s.h}`;s.h+=1,u.push(`@${y}="${w}"`);let O=q(m.$expression,{eventParam:"e",statePrefix:"state"});r.set(w,{args:["state","e"],body:O}),a=!0}}if(C(e.style))for(let[f,m]of Object.entries(e.style)){if(f.startsWith(":")||f.startsWith(".")||f.startsWith("&")||f.startsWith("[")||f.startsWith("@"))continue;if(Gr(m))continue;if(N(m)){let y=`_s${s.s}`;s.s+=1,u.push(`:style.${z(f)}="${y}"`),n.set(y,`() => \`${m}\``),a=!0}}if(C(e.attributes)){for(let[f,m]of Object.entries(e.attributes))if(Y(m)){let y=Le(m.$ref);u.push(`:attr.${f}="${y}"`),yn(n,y,m.$ref),a=!0}else if(N(m)){let y=`_t${s.t}`;s.t+=1,u.push(`:attr.${f}="${y}"`),n.set(y,`() => \`${m}\``),a=!0}}for(let[f,m]of Object.entries(e)){if(ge.has(f)||f.startsWith("on")||f.startsWith("$")||f==="tagName"||f==="id"||f==="className"||f==="style"||f==="children"||f==="textContent"||f==="innerHTML"||f==="attributes")continue;if(Y(m)){let y=Le(m.$ref);u.push(`:${z(f)}="${y}"`),yn(n,y,m.$ref),a=!0}else if(N(m)){let y=`_t${s.t}`;s.t+=1,u.push(`:${z(f)}="${y}"`),n.set(y,`() => \`${m}\``),a=!0}}let c=ve(e,o.scope),l=a?" data-bind":"",p=u.length>0?` ${u.join(" ")}`:"",g="",d=e;if(d.$switch){s.needsLit=!0;let f=`_sw${s.sw}`;s.sw+=1;let m=Y(d.$switch)?Sn(d.$switch.$ref):`\`${String(d.$switch)}\``,y=d.cases??{},w=Object.entries(y).filter(([,v])=>v&&!Y(v)).map(([v,A])=>`${JSON.stringify(v)}: html\`${$n(A,o.preformatted)}\``);n.set(f,`() => ({${w.join(", ")}})[String(${m})] ?? html\`\``),u.push(`:render="${f}"`);let O=` ${u.join(" ")}`;return`<${i}${c} data-bind${O}></${i}>`}if(d.textContent!==void 0&&!a){let f=T(d.textContent,o.scope);g=f==null?"":j(String(f))}else if(d.textContent!==void 0&&a){let f=T(d.textContent,o.scope);g=f==null?"":j(String(f))}else if(d.innerHTML){let f=T(d.innerHTML,o.scope);g=f==null?d.innerHTML:String(f)}else if(V(d.children)){s.needsLit=!0;let f=`_list${s.l}`;s.l+=1;let m=d.children,y=Y(m.items)?Sn(m.items.$ref):JSON.stringify(m.items),w=Jn(m.map);n.set(f,`() => (${y} ?? []).map((item, index) => html\`${w}\`)`),u.push(`:render="${f}"`),a=!0;let O=" data-bind",v=` ${u.join(" ")}`;if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${c}${O}${v}>`;return`<${i}${c}${O}${v}></${i}>`}else if(Array.isArray(d.children)&&d.children.some((f)=>V(f))){s.needsLit=!0;let f=`_children${s.l}`;s.l+=1;let m=d.children.map((w)=>$n(w,o.preformatted)).join(Xe(o.preformatted," "));n.set(f,o.preformatted?`() => html\`${m}\``:`() => html\`
|
|
126
126
|
${m}
|
|
127
|
-
\``),u.push(`:render="${f}"`),a=!0;let y=` ${u.join(" ")}`;return`<${i}${c} data-bind${y}></${i}>`}else if(Array.isArray(d.children))g=d.children.map((f)=>
|
|
128
|
-
${
|
|
127
|
+
\``),u.push(`:render="${f}"`),a=!0;let y=` ${u.join(" ")}`;return`<${i}${c} data-bind${y}></${i}>`}else if(Array.isArray(d.children))g=d.children.map((f)=>zr(f,o,n,r,s)).join(Xe(o.preformatted));if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${c}${l}${p}>`;return`<${i}${c}${l}${p}>${g}</${i}>`}function Jn(e,t=!1){if(!e)return"";if(oe(e.tagName))throw Error(`A tag chosen at creation is not supported inside a dynamic page's repeater yet (candidates: ${Oe(e.tagName).join(", ")}). Move the item into a component, or give it a literal tagName.`);let n=e.tagName??"div",r=t||be.has(n),s="";if(e.id)s+=` id="${e.id}"`;if(e.className)s+=` class="${Je(e.className)}"`;if(C(e.$props))for(let[a,c]of Object.entries(e.$props))if(Y(c))s+=` .${a}="\${${jo(c.$ref)}}"`;else if(N(c))s+=` .${a}="${Je(c)}"`;else s+=` .${a}="\${${JSON.stringify(c)}}"`;if(C(e.attributes))for(let[a,c]of Object.entries(e.attributes)){if(N(c)){s+=` ${a}="${Je(c)}"`;continue}if(K(c)){let l=Ce(a,c);if(l!==null)s+=l===""?` ${a}`:` ${a}="${j(l)}"`;continue}s+=` ${a}="${j(String(c))}"`}if(C(e.style)){let a=[];for(let[c,l]of Object.entries(e.style)){if(c.startsWith(":")||c.startsWith(".")||c.startsWith("&")||c.startsWith("[")||c.startsWith("@"))continue;if(Gr(l))continue;let p=z(c);if(N(String(l)))a.push(`${p}: ${Je(String(l))}`);else a.push(`${p}: ${l}`)}if(a.length>0)s+=` style="${a.join("; ")}"`}for(let[a,c]of Object.entries(e)){if(!a.startsWith("on")||a==="observedAttributes")continue;let l=a.slice(2).toLowerCase();if(Y(c)){let p=Le(c.$ref);s+=` @${l}=\${(e) => { state.$map = { item, index }; on.${p}(e); }}`}else if(xe(c)){let p=ne(c.body,{eventParam:"e",statePrefix:"state"});s+=` @${l}=\${(e) => { state.$map = { item, index }; ${p} }}`}else if(G(c)){let p=Je(c.body);s+=` @${l}=\${(e) => { ${p} }}`}else if(C(c)&&"$expression"in c){let p=q(c.$expression,{eventParam:"e",statePrefix:"state"});s+=` @${l}=\${(e) => { state.$map = { item, index }; ${p}; }}`}}if(e.contentEditable)s+=` contenteditable="${e.contentEditable}"`;let o=n.includes("-")?De:"",i="";if(e.textContent!==void 0){let a=String(e.textContent);if(N(a))i=`${Je(a)}${o}`;else if(Y(e.textContent))i=`\${state.${Le(e.textContent.$ref)}}${o}`;else i=j(a)}else if(e.innerHTML)i=Je(String(e.innerHTML));else if(V(e.children))i=`
|
|
128
|
+
${Yr(e.children)}${o}
|
|
129
129
|
`;else if(Array.isArray(e.children)){let a=e.children.map((c)=>{let l=$n(c,r);return V(c)||J(c)&&N(c)?`${l}${o}`:l});i=r?a.join(""):`
|
|
130
130
|
${a.join(`
|
|
131
131
|
`)}
|
|
132
|
-
`}if(new Set(["input","br","hr","img","meta","link"]).has(n))return`<${n}${s}>`;return`<${n}${s}>${i}</${n}>`}function $n(e,t=!1){if(J(e))return N(e)?Je(e):j(e);if(ee(e)||K(e))return j(String(e));if(V(e))return
|
|
133
|
-
`)}function
|
|
134
|
-
`)}function
|
|
135
|
-
`)}function
|
|
132
|
+
`}if(new Set(["input","br","hr","img","meta","link"]).has(n))return`<${n}${s}>`;return`<${n}${s}>${i}</${n}>`}function $n(e,t=!1){if(J(e))return N(e)?Je(e):j(e);if(ee(e)||K(e))return j(String(e));if(V(e))return Yr(e);return Jn(e,t)}function Yr(e){let{items:t}=e,n=Y(t)?Sn(t.$ref):JSON.stringify(t??[]),r=Jn(e.map);return`\${(${n} ?? []).map((item, index) => html\`${r}\`)}`}function Je(e){return e.replaceAll("$map.","")}function vo(e,t,n,r,s,o,i,u,a,c){let l=[],{needsLit:p}=u,g=t.length>0;l.push("// Generated by @jxsuite/compiler — do not edit manually");let d=["reactive","effect"];if(g)d.push("computed");if(l.push(`import { ${d.join(", ")} } from '@vue/reactivity';`),p)l.push("import { html, render } from 'lit-html';");for(let[x,f]of i){let m=c?c(x):x;l.push(`import { ${[...f].join(", ")} } from '${m}';`)}if(l.push("",St()),o.length>0)l.push("",bt());l.push("","const state = reactive({");for(let[x,f]of e)l.push(` ${fe(x)}: ${JSON.stringify(f)},`);if(l.push("});",""),s.length>0){for(let x of s)l.push(x);l.push("")}if(t.length>0){for(let[x,f]of t)l.push(`${R("state",B(x))} = computed(${f});`);l.push("")}if(o.length>0){for(let x of o)l.push(x);l.push("")}if(n.length>0){l.push("const bind = {");for(let[x,f]of n)l.push(` ${fe(x)}: ${f},`);l.push("};")}else l.push("const bind = {};");if(l.push(""),r.length>0){l.push("const on = {");for(let[x,f]of r){let m=f.args??["state"],y=m.map((w)=>w==="state"?"state":"e").join(", ");l.push(` ${fe(x)}: (e) => { const fn = (${m.join(", ")}) => { ${f.body} }; fn(${y}); },`)}l.push("};")}else l.push("const on = {};");if(l.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;"),p)l.push(" if (parts[0] === 'render') {"," effect(() => { render(bind[key](), el); });"," } else if (parts[0] === 'style' && parts.length > 1) {");else l.push(" if (parts[0] === 'style' && parts.length > 1) {");return l.push(" effect(() => { el.style[parts[1]] = bind[key](); });"," } else if (parts[0] === 'attr' && parts.length > 1) {"," effect(() => {",` const _t = ${_e}(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);",""),l.join(`
|
|
133
|
+
`)}function Oo(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(`
|
|
134
|
+
`)}function Ao(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(`
|
|
135
|
+
`)}function Gr(e){return e===null||C(e)}function jo(e){if(e.startsWith("$map/")){let[t,...n]=pe(e.slice(5));return R(t??"",n.map((r)=>B(r)).join("/"))}if(e.startsWith("#/state/"))return R("state",e.slice(8));return R("state",e)}function Sn(e){return _n("state",e.startsWith("#/state/")?e.slice(8):e)}function Le(e){return Dn(e.startsWith("#/state/")?e.slice(8):e)}function yn(e,t,n){if(e.has(t))return;e.set(t,`() => ${R("state",n.startsWith("#/state/")?n.slice(8):n)}`)}var En=I(()=>{ze();Ie();H();je()});function Ro(e,t){if(t.routing==="prefix-except-default"&&e===t.defaultLocale)return"/";return`/${e.toLowerCase()}/`}function Xr(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,Ro(s,e)])));return`
|
|
136
136
|
// ─── Locale negotiation (RFC 4647 Lookup over Accept-Language) ───────────────
|
|
137
137
|
const JX_LOCALES = ${t}
|
|
138
138
|
const JX_DEFAULT_LOCALE = ${n}
|
|
@@ -201,12 +201,12 @@ app.use('/', async (c, next) => {
|
|
|
201
201
|
res.headers.set('Content-Language', locale)
|
|
202
202
|
c.res = res
|
|
203
203
|
})
|
|
204
|
-
`}function
|
|
205
|
-
`),c=
|
|
204
|
+
`}function No(e,t="/_jx/server"){return Yn(e,t)}function Po(e,t={}){let{adapter:n=null,mounts:r=[],connectors:s=[],i18n:o=null,base:i=""}=t,u=No(i,t.baseUrl);if(e.length===0&&r.length===0&&!n)return null;let a=e.map(({exportName:d,src:x})=>`import { ${d} } from '${x}'`).join(`
|
|
205
|
+
`),c=To(r,s),l=e.map(({exportName:d})=>ko(d,u)).join(`
|
|
206
206
|
`),p=n==="cloudflare-workers"||n==="cloudflare-pages"?`
|
|
207
207
|
app.all('*', (c) => c.env.ASSETS.fetch(c.req.raw))
|
|
208
208
|
`:`
|
|
209
|
-
`,g=
|
|
209
|
+
`,g=Xr(o);return`// Generated by @jxsuite/compiler — do not edit manually
|
|
210
210
|
import { Hono } from 'hono'
|
|
211
211
|
${a}${c.imports}
|
|
212
212
|
|
|
@@ -214,11 +214,11 @@ const app = new Hono()
|
|
|
214
214
|
${g}${c.routes}${l}
|
|
215
215
|
${p}
|
|
216
216
|
export default app
|
|
217
|
-
`}function
|
|
217
|
+
`}function To(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 u=JSON.stringify(i.options);s.push(`const jxMount${o} = await ${i.className}.mount({ ...${u}, 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:`
|
|
218
218
|
${r.join(`
|
|
219
219
|
`)}`,routes:`${s.join(`
|
|
220
220
|
`)}
|
|
221
|
-
`}}function
|
|
221
|
+
`}}function ko(e,t){return`
|
|
222
222
|
app.post('${t}/${e}', async (c) => {
|
|
223
223
|
const args = await c.req.json().catch(() => ({}))
|
|
224
224
|
try {
|
|
@@ -226,9 +226,9 @@ app.post('${t}/${e}', async (c) => {
|
|
|
226
226
|
} catch (e) {
|
|
227
227
|
return c.json({ ok: false, error: e?.message ?? 'Server error' }, 500)
|
|
228
228
|
}
|
|
229
|
-
})`}var
|
|
230
|
-
`)}function
|
|
231
|
-
`):e.body??"").includes("await ")}var
|
|
229
|
+
})`}var Zr=I(()=>{Kt()});function es(e){let t=e.title;if(!t)throw Error("compileClassJson: missing title (class name)");let n=Do(e.extends),r=e.$defs,s=r?.fields??{},o=r?.constructor,i=_o(o)?o:void 0,u=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 c=n!=="Object"?` extends ${n}`:"";a.push(`class ${t}${c} {`);for(let[l,p]of Object.entries(s)){if(p.scope!=="static")continue;let g=p.identifier??l,d=p.access==="private"?"#":"",x=p.initializer!==void 0?JSON.stringify(p.initializer):p.default!==void 0?JSON.stringify(p.default):"null";a.push(` static ${d}${g} = ${x};`)}for(let[l,p]of Object.entries(s)){if(p.scope==="static")continue;if(p.access!=="private")continue;let g=p.identifier??l;a.push(` #${g};`)}if(Object.keys(s).length>0)a.push("");if(a.push(" constructor(config = {}) {"),i?.superCall||n!=="Object"){let l=i?.superCall?.arguments?i.superCall.arguments.join(", "):"";a.push(` super(${l});`)}for(let[l,p]of Object.entries(s)){if(p.scope==="static")continue;let g=p.identifier??l,d=p.access==="private"?"#":"",x=p.initializer!==void 0?JSON.stringify(p.initializer):p.default!==void 0?JSON.stringify(p.default):"null";a.push(` this.${d}${g} = config.${g} !== undefined ? config.${g} : ${x};`)}if(i?.body){let l=Array.isArray(i.body)?i.body:[i.body];for(let p of l)a.push(` ${p}`)}a.push(" }");for(let[l,p]of Object.entries(u)){let g=p.identifier??l,d=p.scope==="static",f=p.access==="private"?"#":"",m=d?"static ":"",y=p.returnType?.$ref?.includes("Promise")||Io(p)?"async ":"",w=Qr(p.parameters??[]),O=Mo(p.body);if(a.push(""),p.role==="accessor"){if(p.getter)a.push(` ${m}get ${f}${g}() {`,` ${p.getter.body}`," }");if(p.setter){let v=Qr(p.setter.parameters??[]);a.push(` ${m}set ${f}${g}(${v}) {`,` ${p.setter.body}`," }")}}else{a.push(` ${m}${y}${f}${g}(${w}) {`);for(let v of O)a.push(` ${v}`);a.push(" }")}}return a.push("}","",`export { ${t} };`,`export default ${t};`,""),a.join(`
|
|
230
|
+
`)}function _o(e){return typeof e==="object"}function Do(e){if(!e)return"Object";if(J(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 Qr(e){return e.map((t)=>{if(t.$ref)return t.$ref.split("/").pop();let n=t.identifier??t.name;return J(n)?n:"arg"}).join(", ")}function Mo(e){if(!e)return[""];return Array.isArray(e)?e:[e]}function Io(e){return(Array.isArray(e.body)?e.body.join(`
|
|
231
|
+
`):e.body??"").includes("await ")}var ts=I(()=>{H()});import{readFileSync as Lo}from"node:fs";async function Fo(e,t={}){let{title:n="Jx App",reactivitySrc:r=gt,litHtmlSrc:s=ht,projectStyle:o=null}=t,i;if(J(e)){let a=Lo(e,"utf8");if(e.endsWith(".json"))i=Et(a,e);else{let{extname:c}=await import("node:path"),l=c(e).toLowerCase(),p=t.formats?.byExtension(l,"parse");if(!p){await Promise.resolve().then(() => gn());throw Ot(e,l)}i=await p.parseDocument(a)}}else i=e;if(An(i)){await Promise.resolve().then(() => ts());let c=es(i),l=J(e)?e.replace(/\.class\.json$/,".js"):`${i.title}.js`;return{files:[{content:c,path:l}],html:""}}if(!xt(i))return Ur(i,{litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...ns(t),title:n});if(i.tagName&&i.tagName.includes("-")){let{tagName:a}=i,c=Jt(a),p={content:Qe(i,c,[],t.rewriteSrc,null,t.serverBaseUrl),path:`${a}.js`,tagName:a},g=Me(i,i.$media??{},o),d=`<!DOCTYPE html>
|
|
232
232
|
<html lang="en">
|
|
233
233
|
<head>
|
|
234
234
|
<meta charset="utf-8">
|
|
@@ -248,4 +248,4 @@ app.post('${t}/${e}', async (c) => {
|
|
|
248
248
|
<${a}></${a}>
|
|
249
249
|
<script type="module" src="./${a}.js"></script>
|
|
250
250
|
</body>
|
|
251
|
-
</html>`;return{files:[p],html:d}}let u={litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...
|
|
251
|
+
</html>`;return{files:[p],html:d}}let u={litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...ns(t),title:n};if(t.serverBaseUrl!==void 0)u.serverBaseUrl=t.serverBaseUrl;return bn(i,u)}function ns(e){let t={};if(e.prePaintScheme===!1)t.prePaintScheme=!1;if(e.rewriteSrc)t.rewriteSrc=e.rewriteSrc;return t}async function Ya(e,t){let n=await Fo(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 u=o(t);for(let a of n.files){let c=i(u,a.path);s(o(c),{recursive:!0}),r(c,a.content,"utf8"),console.error(`Written to ${c}`)}}else process.stdout.write(n.html)}var Wo=I(()=>{Ie();Nt();Kr();En();H();pn();Ie();Zr();Nt();En()});Wo();export{Fo as compile,bn as compileClient,Fr as compileElement,So as compileElementPage,Po as compileSiteServer,xt as isDynamic,Ya as runCli};
|