@stacksjs/stx 0.2.908 → 0.2.910
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/{chunk-tpryfx8t.js → chunk-13kfjnyn.js} +4 -4
- package/dist/chunk-1a911c4c.js +2 -0
- package/dist/{chunk-6mw288vd.js → chunk-24hrd8sg.js} +1 -1
- package/dist/{chunk-6756txp1.js → chunk-29trx6h3.js} +1 -1
- package/dist/{chunk-kt3f4rpy.js → chunk-2cbrcb9m.js} +1 -1
- package/dist/{chunk-jg5xc2m1.js → chunk-2r84qtat.js} +2 -2
- package/dist/{chunk-amye7vb0.js → chunk-3760wpvw.js} +1 -1
- package/dist/chunk-3rzpkjmn.js +2 -0
- package/dist/{chunk-kydh790y.js → chunk-44qcbbc4.js} +1 -1
- package/dist/{chunk-1pdntpwe.js → chunk-4ccbj4z6.js} +1 -1
- package/dist/{chunk-d8mnaesb.js → chunk-4kh0616n.js} +4 -4
- package/dist/{chunk-4hrryats.js → chunk-4zw9trtx.js} +1 -1
- package/dist/{chunk-q4nk8sq2.js → chunk-5k55yk8g.js} +1 -1
- package/dist/{chunk-y9xq82ep.js → chunk-688hf1mx.js} +1 -1
- package/dist/chunk-6w9sgs52.js +2 -0
- package/dist/{chunk-zkp5awqw.js → chunk-7apr0ww2.js} +1 -1
- package/dist/chunk-7w9ksdbp.js +2 -0
- package/dist/{chunk-f2yqqpvr.js → chunk-850b0cxa.js} +1 -1
- package/dist/{chunk-3qneemwh.js → chunk-87aqcw1w.js} +1 -1
- package/dist/{chunk-ddn98yz4.js → chunk-8d6wkfdx.js} +1 -1
- package/dist/{chunk-4ajsp5dp.js → chunk-94k80qpp.js} +1 -1
- package/dist/{chunk-trnw1tg5.js → chunk-9grwqzpe.js} +1 -1
- package/dist/{chunk-xqe3c7pa.js → chunk-9nf58keq.js} +1 -1
- package/dist/chunk-9yvhj108.js +2 -0
- package/dist/{chunk-sxqha69q.js → chunk-a259mfax.js} +2 -2
- package/dist/{chunk-vkxrsy13.js → chunk-ah615efp.js} +1 -1
- package/dist/{chunk-c0kgwh4k.js → chunk-anj2j86n.js} +2 -2
- package/dist/{chunk-xwarwkaw.js → chunk-azyq6fds.js} +1 -1
- package/dist/{chunk-f74qzgp8.js → chunk-ba27s9vr.js} +1 -1
- package/dist/{chunk-1x0wcskp.js → chunk-c829tgwv.js} +1 -1
- package/dist/{chunk-14497kj1.js → chunk-caaexbqy.js} +1 -1
- package/dist/{chunk-vqys4n8f.js → chunk-ccq7d7ar.js} +1 -1
- package/dist/{chunk-mrx20xza.js → chunk-cd2jc724.js} +1 -1
- package/dist/chunk-cf4apy9s.js +3 -0
- package/dist/{chunk-f3msm5tk.js → chunk-cqcxj08t.js} +1 -1
- package/dist/{chunk-qpf782pt.js → chunk-cw7vnkc8.js} +1 -1
- package/dist/{chunk-a0esj80g.js → chunk-d5szrgdq.js} +1 -1
- package/dist/{chunk-skxkqh9a.js → chunk-dh4p07cc.js} +1 -1
- package/dist/{chunk-s91tcznf.js → chunk-dqt1kw68.js} +1 -1
- package/dist/{chunk-p2b90rz9.js → chunk-e4fseqnv.js} +1 -1
- package/dist/{chunk-69wpv1pr.js → chunk-g17g6w1t.js} +2 -2
- package/dist/{chunk-0ek3s3b6.js → chunk-ggez55jb.js} +107 -107
- package/dist/{chunk-av45fw8a.js → chunk-gt3426kc.js} +1 -1
- package/dist/{chunk-v25gm9d9.js → chunk-gwvkqf5r.js} +4 -4
- package/dist/{chunk-xn8eabng.js → chunk-jcp3rs1t.js} +1 -1
- package/dist/{chunk-7xpez9tc.js → chunk-kvcz1926.js} +1 -1
- package/dist/{chunk-45326z5v.js → chunk-kvrbdez2.js} +1 -1
- package/dist/{chunk-cjntf1jg.js → chunk-magfdzdj.js} +1 -1
- package/dist/{chunk-5baag5dz.js → chunk-pgqc8895.js} +4 -4
- package/dist/{chunk-59bbk5gx.js → chunk-ph8k7jdx.js} +2 -2
- package/dist/{chunk-4jmztn9d.js → chunk-pmmctgdd.js} +1 -1
- package/dist/{chunk-yvp5tfrz.js → chunk-pn3gj7zm.js} +1 -1
- package/dist/{chunk-pb2mztar.js → chunk-q33tyfpp.js} +1 -1
- package/dist/{chunk-hg4vfrxr.js → chunk-q6jecdtg.js} +1 -1
- package/dist/{chunk-cfbmjgd0.js → chunk-r2ns89f7.js} +1 -1
- package/dist/{chunk-zk6qmkhb.js → chunk-r425m35g.js} +1 -1
- package/dist/chunk-ssdjny2r.js +2 -0
- package/dist/chunk-sx1jg8dw.js +2 -0
- package/dist/{chunk-rdeje2dd.js → chunk-vd03gnnb.js} +5 -5
- package/dist/chunk-vf29gp9a.js +2 -0
- package/dist/{chunk-yjhktn0b.js → chunk-x40j9ta1.js} +2 -2
- package/dist/{chunk-am610nan.js → chunk-xjbj655y.js} +3 -3
- package/dist/{chunk-9343arqn.js → chunk-ya8nwtdn.js} +1 -1
- package/dist/{chunk-3npzxjr4.js → chunk-zbzfkh3m.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/stx-virtual-ts.js +5 -9
- package/package.json +5 -5
- package/dist/chunk-7hgqyea0.js +0 -2
- package/dist/chunk-7m5rpqjy.js +0 -2
- package/dist/chunk-b25twdd7.js +0 -2
- package/dist/chunk-b7fmkwz2.js +0 -2
- package/dist/chunk-cssvev8r.js +0 -2
- package/dist/chunk-g67xjfe6.js +0 -3
- package/dist/chunk-naj7m2av.js +0 -2
- package/dist/chunk-qn9rrwp8.js +0 -2
- package/dist/chunk-z8e2m6kz.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{et,Ln,go,Yi,z}from"./chunk-w98yt4d4.js";import{Dn}from"./chunk-4hrryats.js";import{Zr,C,Ul,vt,oa,Vl}from"./chunk-4b110x6r.js";import{D}from"./chunk-phzhmnnm.js";import{T,R}from"./chunk-0jdz31q1.js";import{Yr,xo,Hn,Fl,je}from"./chunk-ck4ypzet.js";import{mo,d,m,Ee,Ur,p,te,K,be,_,yt,wo,Le,nt,vo}from"./chunk-c08jvjqt.js";import{w}from"./chunk-v6gkjg5f.js";import{ne}from"./chunk-e5rag6rh.js";import{t,h}from"./chunk-ahf9j8wb.js";import{c}from"./chunk-8tfpv6zf.js";import Rt from"path";import gn from"process";import{AsyncLocalStorage as lc}from"async_hooks";var ii=new lc;function Pn(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function oi(e,n){return ii.run(Pn(e),n)}async function ai(e,n){let r=ii.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(v,S)=>{if(S===void 0||typeof S==="function"||typeof S==="symbol"||typeof S==="bigint"||typeof S==="number"&&!Number.isFinite(S))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(S&&typeof S==="object"&&!Array.isArray(S)&&Object.getPrototypeOf(S)!==Object.prototype&&Object.getPrototypeOf(S)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return S}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function zr(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function G(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,v=()=>{if(l!==0)return;let S=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(S){if(n&&S[1]==="const")return;let V=S[2];if(!a.has(V))i.push(V),a.add(V);return}let I=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){if(n&&r.slice(u).startsWith("const"))return;I[1].split(",").forEach((V)=>{let W=V.trim();if(!W)return;let Z=W.indexOf(":"),X=(Z>=0?W.slice(Z+1).trim():W).split(/[\s=]/)[0];if(X&&!a.has(X))i.push(X),a.add(X)});return}let j=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((V)=>{let W=V.trim().replace(/^\.\.\./,"");if(!W)return;let Z=W.split(/[\s=]/)[0];if(Z&&!a.has(Z))i.push(Z),a.add(Z)});return}if(n)return;let L=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let V=L[1];if(!a.has(V))i.push(V),a.add(V);return}let M=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(M){let V=M[1];if(!a.has(V))i.push(V),a.add(V)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))v();u++}return i.join(", ")}function Js(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function uc(e,n=G(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(G(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Ys(e,n){let r=`{ ${uc(e,n)} }`;return G(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import cn from"fs";import Ue from"path";function J(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ci=new Map;function Nr(e,n=!0){let r=ci.get(e);if(n&&r)return r;let i=new Map,a=[Ue.join(e,"src"),Ue.join(e,"dist"),e];function l(u,f){if(f>6)return;let v;try{v=cn.readdirSync(u,{withFileTypes:!0})}catch{return}for(let S of v){let I=Ue.join(u,S.name);if(S.isDirectory()){if(S.name==="node_modules"||S.name.startsWith("."))continue;l(I,f+1)}else if(S.isFile()&&S.name.endsWith(".stx")){let j=S.name.slice(0,-4);if(!i.has(j))i.set(j,I);let L=j.toLowerCase();if(!i.has(L))i.set(L,I);let M=J(j);if(!i.has(M))i.set(M,I)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)ci.set(e,i);return i}function Zs(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=Ue.join(r,"node_modules",e);try{if(cn.statSync(i).isDirectory())return i}catch{}let a=Ue.dirname(r);if(a===r)return null;r=a}}function Qs(e,n,r={}){return[Ue.resolve(Ue.dirname(n),`${e}.stx`),Ue.resolve(Ue.dirname(n),e),Ue.resolve(r.componentsDir||"components",`${e}.stx`),Ue.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function li(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=J(n);return[n,r,i]}function Ii(e,n){let[r,i,a]=li(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function Oi(e,n){let r=n?Ue.resolve(n):void 0,i=Ue.dirname(Ue.resolve(e));for(;;){if(cn.existsSync(Ue.join(i,"package.json")))return r&&i===r?void 0:i;let a=Ue.dirname(i);if(a===i)return;i=a}}var pc=["src/ui","src/components","components","dist"];function ps(e,n){let r=Ue.resolve(e);if(!n&&!r.split(Ue.sep).includes("node_modules"))return[];let i=Oi(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(cn.readFileSync(Ue.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((v)=>typeof v==="string")}catch{}let l=a.length?a:pc;return[Ue.dirname(Ue.resolve(e)),...l.map((u)=>Ue.resolve(i,u))]}function*Ni(e,n,r={},i){let a=li(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield Ue.resolve(Ue.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((v)=>`${v}.stx`))],u=r.projectRoot||process.cwd(),f=[...ps(n,r.projectRoot),...i?.__originalFilePath?[Ue.join(Ue.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],Ue.join(Ue.dirname(n),"components"),Ue.resolve(u,"src/components"),Ue.resolve(u,"components"),...import.meta.dir?[Ue.resolve(import.meta.dir,"components")]:[]];for(let v of new Set(f)){for(let S of l)yield Ue.join(v,S);try{for(let S of cn.readdirSync(v,{withFileTypes:!0}))if(S.isDirectory())for(let I of l)yield Ue.join(v,S.name,I)}catch{}}}function ui(e,n,r={},i){let a=Ii(e,i);if(a!==void 0)return a;for(let l of Ni(e,n,r,i))try{if(cn.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function eo(e,n=[],r={}){let i=new Set([...e].map((S)=>S.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([S,I])=>[S.replace(/[-_]/g,"").toLowerCase(),I])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),v=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!v)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((S)=>i.has(S)))return!1;if([...n].some((S)=>!["load","error"].includes(S.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((S)=>i.has(S))}import Ls from"fs";import xe from"path";import Zt from"path";import Cn from"fs";var fc=new Set(["touchstart","touchmove","wheel","mousewheel"]);function Xs(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return fc.has(e.toLowerCase())}var pi=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),fi={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},dc=new Set(["ctrl","alt","shift","meta"]),mi={left:0,middle:1,right:2};function di(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(dc.has(i))n.systemKeys.push(i);else if(i in mi)n.mouse=i;else if(i in fi||/^[a-z]$/.test(i))n.keys.push(fi[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function hi(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,v]=l,S=l.index,I=S+u.length,j=`__stx_evt_${n}${i++}`,L=[],M=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,V;while((V=M.exec(v))!==null){let[,Z,q]=V,X=Z.split("."),U=X[0];if(!pi.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:di(X.slice(1)),elementId:j})}let W=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((V=W.exec(v))!==null){let[,Z,q]=V,X=Z.split("."),U=X[0];if(!pi.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:di(X.slice(1)),elementId:j})}if(L.length>0)r.push({originalTag:u,elementId:j,events:L,startIndex:S,endIndex:I})}return r}function gc(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=mi[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function mc(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Gs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function hc(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=gc(e),a=mc(Gs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(Xs(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
|
|
2
|
+
import{et,Ln,go,Yi,z}from"./chunk-w98yt4d4.js";import{Dn}from"./chunk-4zw9trtx.js";import{Zr,C,Ul,vt,oa,Vl}from"./chunk-4b110x6r.js";import{D}from"./chunk-phzhmnnm.js";import{T,R}from"./chunk-0jdz31q1.js";import{Yr,xo,Hn,Fl,je}from"./chunk-ck4ypzet.js";import{mo,d,m,Ee,Ur,p,te,K,be,_,yt,wo,Le,nt,vo}from"./chunk-c08jvjqt.js";import{w}from"./chunk-v6gkjg5f.js";import{ne}from"./chunk-e5rag6rh.js";import{t,h}from"./chunk-ahf9j8wb.js";import{c}from"./chunk-8tfpv6zf.js";import Rt from"path";import mn from"process";import{AsyncLocalStorage as ac}from"async_hooks";var ri=new ac;function Pn(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function ii(e,n){return ri.run(Pn(e),n)}async function oi(e,n){let r=ri.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(v,S)=>{if(S===void 0||typeof S==="function"||typeof S==="symbol"||typeof S==="bigint"||typeof S==="number"&&!Number.isFinite(S))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(S&&typeof S==="object"&&!Array.isArray(S)&&Object.getPrototypeOf(S)!==Object.prototype&&Object.getPrototypeOf(S)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return S}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function zr(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function G(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,v=()=>{if(l!==0)return;let S=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(S){if(n&&S[1]==="const")return;let V=S[2];if(!a.has(V))i.push(V),a.add(V);return}let I=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){if(n&&r.slice(u).startsWith("const"))return;I[1].split(",").forEach((V)=>{let W=V.trim();if(!W)return;let Z=W.indexOf(":"),X=(Z>=0?W.slice(Z+1).trim():W).split(/[\s=]/)[0];if(X&&!a.has(X))i.push(X),a.add(X)});return}let j=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((V)=>{let W=V.trim().replace(/^\.\.\./,"");if(!W)return;let Z=W.split(/[\s=]/)[0];if(Z&&!a.has(Z))i.push(Z),a.add(Z)});return}if(n)return;let L=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let V=L[1];if(!a.has(V))i.push(V),a.add(V);return}let M=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(M){let V=M[1];if(!a.has(V))i.push(V),a.add(V)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))v();u++}return i.join(", ")}function Js(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function cc(e,n=G(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(G(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Ys(e,n){let r=`{ ${cc(e,n)} }`;return G(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import ln from"fs";import Ue from"path";function J(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ai=new Map;function Nr(e,n=!0){let r=ai.get(e);if(n&&r)return r;let i=new Map,a=[Ue.join(e,"src"),Ue.join(e,"dist"),e];function l(u,f){if(f>6)return;let v;try{v=ln.readdirSync(u,{withFileTypes:!0})}catch{return}for(let S of v){let I=Ue.join(u,S.name);if(S.isDirectory()){if(S.name==="node_modules"||S.name.startsWith("."))continue;l(I,f+1)}else if(S.isFile()&&S.name.endsWith(".stx")){let j=S.name.slice(0,-4);if(!i.has(j))i.set(j,I);let L=j.toLowerCase();if(!i.has(L))i.set(L,I);let M=J(j);if(!i.has(M))i.set(M,I)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)ai.set(e,i);return i}function Zs(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=Ue.join(r,"node_modules",e);try{if(ln.statSync(i).isDirectory())return i}catch{}let a=Ue.dirname(r);if(a===r)return null;r=a}}function Qs(e,n,r={}){return[Ue.resolve(Ue.dirname(n),`${e}.stx`),Ue.resolve(Ue.dirname(n),e),Ue.resolve(r.componentsDir||"components",`${e}.stx`),Ue.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function ci(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=J(n);return[n,r,i]}function Ii(e,n){let[r,i,a]=ci(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function Oi(e,n){let r=n?Ue.resolve(n):void 0,i=Ue.dirname(Ue.resolve(e));for(;;){if(ln.existsSync(Ue.join(i,"package.json")))return r&&i===r?void 0:i;let a=Ue.dirname(i);if(a===i)return;i=a}}var lc=["src/ui","src/components","components","dist"];function us(e,n){let r=Ue.resolve(e);if(!n&&!r.split(Ue.sep).includes("node_modules"))return[];let i=Oi(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(ln.readFileSync(Ue.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((v)=>typeof v==="string")}catch{}let l=a.length?a:lc;return[Ue.dirname(Ue.resolve(e)),...l.map((u)=>Ue.resolve(i,u))]}function*Ni(e,n,r={},i){let a=ci(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield Ue.resolve(Ue.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((v)=>`${v}.stx`))],u=r.projectRoot||process.cwd(),f=[...us(n,r.projectRoot),...i?.__originalFilePath?[Ue.join(Ue.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],Ue.join(Ue.dirname(n),"components"),Ue.resolve(u,"src/components"),Ue.resolve(u,"components"),...import.meta.dir?[Ue.resolve(import.meta.dir,"components")]:[]];for(let v of new Set(f)){for(let S of l)yield Ue.join(v,S);try{for(let S of ln.readdirSync(v,{withFileTypes:!0}))if(S.isDirectory())for(let I of l)yield Ue.join(v,S.name,I)}catch{}}}function li(e,n,r={},i){let a=Ii(e,i);if(a!==void 0)return a;for(let l of Ni(e,n,r,i))try{if(ln.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function eo(e,n=[],r={}){let i=new Set([...e].map((S)=>S.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([S,I])=>[S.replace(/[-_]/g,"").toLowerCase(),I])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),v=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!v)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((S)=>i.has(S)))return!1;if([...n].some((S)=>!["load","error"].includes(S.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((S)=>i.has(S))}import Ns from"fs";import xe from"path";import Zt from"path";import jn from"fs";var uc=new Set(["touchstart","touchmove","wheel","mousewheel"]);function qs(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return uc.has(e.toLowerCase())}var ui=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),pi={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},pc=new Set(["ctrl","alt","shift","meta"]),gi={left:0,middle:1,right:2};function fi(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(pc.has(i))n.systemKeys.push(i);else if(i in gi)n.mouse=i;else if(i in pi||/^[a-z]$/.test(i))n.keys.push(pi[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function mi(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,v]=l,S=l.index,I=S+u.length,j=`__stx_evt_${n}${i++}`,L=[],M=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,V;while((V=M.exec(v))!==null){let[,Z,q]=V,X=Z.split("."),U=X[0];if(!ui.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:fi(X.slice(1)),elementId:j})}let W=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((V=W.exec(v))!==null){let[,Z,q]=V,X=Z.split("."),U=X[0];if(!ui.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:fi(X.slice(1)),elementId:j})}if(L.length>0)r.push({originalTag:u,elementId:j,events:L,startIndex:S,endIndex:I})}return r}function fc(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=gi[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function dc(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Xs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function gc(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=fc(e),a=dc(Xs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(qs(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
|
|
3
3
|
(function() {
|
|
4
4
|
var $el = document.getElementById('${r}');
|
|
5
5
|
if (!$el) return;
|
|
@@ -108,22 +108,22 @@ else {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// Event listeners
|
|
111
|
-
${e.map(
|
|
111
|
+
${e.map(gc).join(`
|
|
112
112
|
`)}
|
|
113
113
|
})();
|
|
114
|
-
</script>`}function
|
|
115
|
-
`+a.slice(u);else a+=l;return a}function
|
|
114
|
+
</script>`}function mc(e,n=""){let r=mi(e,n);if(r.length===0)return{template:e,bindings:[]};let i=e,a=[];for(let l=r.length-1;l>=0;l--){let u=r[l],f=u.originalTag;if(!f.includes(" id="))f=f.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${u.elementId}"`);else{let v=f.match(/id=["']([^"']+)["']/);if(v)for(let S of u.events)S.elementId=v[1]}for(let v of u.events){let S=v.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=new RegExp(`\\s*${S}\\s*=\\s*"[^"]*"`,"g"),j=new RegExp(`\\s*${S}\\s*=\\s*'[^']*'`,"g");f=f.replace(I,""),f=f.replace(j,"")}i=i.slice(0,u.startIndex)+f+i.slice(u.endIndex),a.push(...u.events)}return{template:i,bindings:a}}function di(e){let n=e.$uid;return typeof n==="string"&&n?`${n}_`:""}function ol(e,n,r){if(Vl(e))return e;if(n.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(e))return e;let{template:f,bindings:v}=mc(e,di(n)),S=n.__stx_event_bindings||[];return n.__stx_event_bindings=[...S,...v],f}let i=mi(e,di(n));if(i.length===0)return e;let a=e;for(let f=i.length-1;f>=0;f--){let v=i[f],S=v.originalTag;if(!S.includes(" id="))S=S.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${v.elementId}"`);else{let I=S.match(/id=["']([^"']+)["']/);if(I)for(let j of v.events)j.elementId=I[1]}for(let I of v.events){let j=I.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=new RegExp(`\\s*${j}\\s*=\\s*"[^"]*"`,"g"),M=new RegExp(`\\s*${j}\\s*=\\s*'[^']*'`,"g");S=S.replace(L,""),S=S.replace(M,"")}a=a.slice(0,v.startIndex)+S+a.slice(v.endIndex)}let l=Mi(i.flatMap((f)=>f.events)),u=c(a);if(u!==-1)a=a.slice(0,u)+l+`
|
|
115
|
+
`+a.slice(u);else a+=l;return a}function hi(e,n){let r=new Set;for(let i of e.split(",")){let a=i.trim().replace(/^\.\.\./,"").trim();if(!a)continue;if(n){let l=a.lastIndexOf(":");if(l!==-1)a=a.slice(l+1).trim()}if(a=a.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(a))r.add(a)}return r}function Ut(e,n){let r=t(e),{depths:i,balanced:a}=h(r),l=(f)=>!a||i[f]===0,u=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${n}\\b)`,"g");for(let f of r.matchAll(u)){let v=(f.index??0)+f[0].length-f[1].length;if(l(v))return!0}for(let f of r.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(l(f.index??0)&&hi(f[1],!0).has(n))return!0;for(let f of r.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(l(f.index??0)&&hi(f[1],!1).has(n))return!0;return!1}var qe="0.2.910";var xi=Symbol.for(`stx.lazy-module-promises.${qe}`);function xc(){let e=globalThis;return e[xi]??=new Map,e[xi]}function o(e,n){let r=xc(),i=`${import.meta.url}\x00${e}`,a=r.get(i);if(a)return a;let l=n();return r.set(i,l),l.catch(()=>{if(r.get(i)===l)r.delete(i)}),l}var bc=/<\/(script)/gi;function me(e){if(!e||e.indexOf("</")===-1)return e;return e.replace(bc,"<\\/$1")}import bi from"fs";var yi=[];function k(e){let n=new T(e);return yi.push(n),n}function il(){for(let e of yi)e.clear()}function E(e,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${e.length}\x00${Bun.hash(e)}`}function Mr(e){let n=[];for(let r of new Set(e))try{n.push({path:r,mtimeMs:bi.statSync(r).mtimeMs})}catch{}return n}function to(e){for(let n of e)try{if(bi.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var Oe=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var yc=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function _c(e){if(e.startsWith(".")||e.startsWith("/"))return null;if(e.startsWith("@")){let r=e.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!r)return null;return{pkg:r[1],subpath:r[2]||""}}let n=e.match(/^([^/]+)(\/.*)?$/);if(!n)return null;return{pkg:n[1],subpath:n[2]||""}}function wc(e,n){let r=n;while(!0){let i=Zt.join(r,"node_modules",e,"package.json");if(jn.existsSync(i))return Zt.dirname(i);let a=Zt.dirname(r);if(a===r)return null;r=a}}function vc(e,n){if(!e||typeof e!=="object")return null;let r=(a)=>{if(typeof a==="string")return a;if(a&&typeof a==="object"){if(typeof a.import==="string")return a.import;if(typeof a.default==="string")return a.default;if(typeof a.import==="object")return r(a.import);if(typeof a.default==="object")return r(a.default)}return null};if(Object.prototype.hasOwnProperty.call(e,n))return r(e[n]);let i=null;for(let a of Object.keys(e)){let l=a.indexOf("*");if(l===-1)continue;let u=a.slice(0,l),f=a.slice(l+1);if(!n.startsWith(u)||!n.endsWith(f))continue;if(n.length<u.length+f.length)continue;if(!i||u.length>i.prefix.length)i={pattern:a,prefix:u,suffix:f}}if(i){let a=n.slice(i.prefix.length,n.length-i.suffix.length),l=r(e[i.pattern]);if(l)return l.replace("*",a)}return null}function Sc(e,n){let r=_c(e);if(!r||!r.subpath)return null;let i=wc(r.pkg,n);if(!i)return null;let a;try{a=JSON.parse(jn.readFileSync(Zt.join(i,"package.json"),"utf8"))}catch{return null}let l=`.${r.subpath}`,u=vc(a.exports,l);if(!u)return null;let f=Zt.resolve(i,u);return jn.existsSync(f)?f:null}function Vi(e,n){let r=n.filePath?Zt.dirname(n.filePath):n.projectRoot||process.cwd(),i=n.projectRoot||process.cwd(),a=new Set,l=[],u=[];return{code:e.replace(yc,(v,S)=>{let I;try{if(S.startsWith("./")||S.startsWith("../")||S.startsWith("/")){if(I=S.startsWith("/")?S:Zt.resolve(r,S),!jn.existsSync(I))throw Error(`file not found: ${I}`)}else{let j=null;try{j=Bun.resolveSync(S,i)}catch{j=Sc(S,i)}if(!j)throw Error(`could not resolve ${S} (Bun.resolveSync + exports fallback both failed)`);I=j}}catch(j){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(S)} (from ${n.filePath||"<unknown>"}): ${j?.message||j}`),u.push(S),""}if(a.has(I))return"";a.add(I);try{let j=jn.readFileSync(I,"utf8");l.push({source:S,resolvedPath:I,contents:j})}catch(j){console.warn(`[stx:vendor-css] could not read ${I}: ${j?.message||j}`),u.push(S)}return""}),styles:l,unresolved:u}}function $c(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Wi(e){if(e.length===0)return"";return`${e.map((n)=>`<style data-stx-vendor="${$c(n.source)}" data-stx-layer="vendor">
|
|
116
116
|
@layer vendor {
|
|
117
117
|
${n.contents}
|
|
118
118
|
}
|
|
119
119
|
</style>`).join(`
|
|
120
120
|
`)}
|
|
121
|
-
`}var Fg=C,
|
|
121
|
+
`}var Fg=C,_i=k(256);function Gt(e){let n=E(e),r=_i.get(n);if(!r)r=Ec(e),_i.set(n,r);return{code:r.code,imports:[...r.imports],models:[...r.models]}}function Ec(e){let n=t(e),r=new Set;for(let f of e.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let v of f[1].split(",")){let S=v.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(S)r.add(S)}let i=xo(n),a=Oe.filter((f)=>{if(r.has(f)||i.has(f))return!1;return zg(n,f,!0)}),l=$i(n).filter((f)=>!r.has(f)&&!i.has(f));if(a.length===0&&l.length===0)return{code:e,imports:a,models:l};return{code:`${[a.length>0?`import { ${a.join(", ")} } from '@stacksjs/browser'`:"",l.length>0?"import '@stacksjs/browser'":"",l.length>0?`const { ${l.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
122
122
|
`)}
|
|
123
|
-
${e}`,imports:a,models:l}}var
|
|
123
|
+
${e}`,imports:a,models:l}}var kc=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function $i(e,n=Yr(e)){let r=new Set,i=xo(e),a=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let l of n.code.matchAll(a)){let u=l[1];if(kc.has(u)||i.has(u)||u.length<3)continue;if(n.shadows(u,l.index??0))continue;r.add(u)}return Array.from(r)}function Cc(e){return xo(e)}var wi=k(128);function _l(e){let n=E(e),r=wi.get(n);if(!r)r=Rc(e),wi.set(n,r);return{code:r.code,stxImports:[...r.stxImports],browserImports:[...r.browserImports]}}function Rc(e){let n=new Set,r=new Set,i=e;i=i.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let a=new Set,l=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,u;while((u=l.exec(e))!==null){let M=u[1],V=u[2];if(u[0].includes("import type"))continue;let W=[];for(let q of M.split(",")){let X=q.trim();if(!X||X.startsWith("type "))continue;let U=X.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!U)continue;let H=U[1],re=U[2]||H;if(a.add(H),a.add(re),V==="stx"||V==="@stacksjs/stx")n.add(H);else r.add(H);if(re!==H)W.push(`${re} = ${H}`)}let Z=W.length>0?`var ${W.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";i=i.replace(u[0],Z)}let f=Cc(i),v=Yr(i);for(let M of Fg){if(a.has(M)||f.has(M))continue;if(Gs(v,M,!0))n.add(M)}let S=t(i),I=Yr(S),j=new Set;for(let M of i.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let V of M[1].split(",")){let W=V.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let Z of W){let q=Z.trim();if(q)j.add(q)}}for(let M of Oe){if(a.has(M)||f.has(M)||j.has(M))continue;if(Gs(I,M))r.add(M)}let L=$i(S,I);for(let M of L)if(!a.has(M)&&!f.has(M))r.add(M);return{code:i,stxImports:Array.from(n),browserImports:Array.from(r)}}function zg(e,n,r=!1){return Gs(Yr(e),n,r)}function Gs(e,n,r=!1){let i=e.code,a=new RegExp(`\\b${n.replace(/[$]/g,"\\$")}\\b`,"g");for(let l of i.matchAll(a)){let u=l.index??0;if(e.shadows(n,u))continue;let f=u+n.length,v=u-1;while(v>=0&&/\s/.test(i[v]))v--;if(i[v]==="."&&i.slice(Math.max(0,v-2),v+1)!=="...")continue;let S=f;while(S<i.length&&/\s/.test(i[S]))S++;if(i[S]===":"&&i[S+1]!==":"&&(i[v]==="{"||i[v]===","))continue;if(r&&!/^\s*(?:<[^>]*>)?\s*\(/.test(i.slice(f)))continue;if(Ac(i,f))continue;return!0}return!1}function Ac(e,n){let r=n;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;if(e[r]!=="(")return!1;let i=0;for(;r<e.length;r++){let a=e[r];if(a==="(")i++;else if(a===")"){if(i--,i===0)break}}if(i!==0)return!1;r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;return e[r]==="{"}function Cl(e,n){let r=[];if(e.length>0)r.push(` var { ${e.join(", ")} } = window.stx || window;`);if(n.length>0)r.push(` var { ${n.join(", ")} } = window.StacksBrowser || {};`);if(r.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
124
124
|
${r.join(`
|
|
125
125
|
`)}
|
|
126
|
-
${
|
|
126
|
+
${Tc(e,n)}`;return""}function Py(e,n=[]){let{browserImports:r}=_l(e),i=new Set(n);return Cl([],r.filter((a)=>!i.has(a)))}function Tc(e,n){let r=[...e.map((i)=>`['${i}', typeof ${i}, 'stx']`),...n.map((i)=>`['${i}', typeof ${i}, '@stacksjs/browser']`)];if(r.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
127
127
|
[${r.join(", ")}].forEach(function (e) {
|
|
128
128
|
if (e[1] !== 'undefined') return;
|
|
129
129
|
console.error(
|
|
@@ -132,10 +132,10 @@ ${Oc(e,n)}`;return""}function Py(e,n=[]){let{browserImports:r}=_l(e),i=new Set(n
|
|
|
132
132
|
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
133
133
|
);
|
|
134
134
|
});
|
|
135
|
-
`}function Ge(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var
|
|
135
|
+
`}function Ge(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var Ic=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,vi=new Set;function Oc(e,n){let r=Ic.test(e),i=n.length>32768;if(!r&&!i)return;if(vi.has(e))return;if(vi.add(e),r)console.warn(`[stx] server\u2192client bridge is publishing "${e}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(i)console.warn(`[stx] server\u2192client bridge is publishing ${(n.length/1024).toFixed(1)}KB under "${e}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function In(e,n){if(!n)return"";let r=je(e,new Set(Object.keys(n))),i=n.__stxDeclaredPayload===!0,a=[],l=Object.entries(n).sort(([u],[f])=>u<f?-1:u>f?1:0);for(let[u,f]of l){if(!/^[A-Za-z_$][\w$]*$/.test(u))continue;if(u.startsWith("__")||u.startsWith("$"))continue;if(!i&&!r.has(u))continue;if(Ut(e,u)){if(i)console.warn(`[stx] defineClientPayload declares "${u}", but this client block also declares "${u}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${u}" from defineClientPayload.`);continue}let v;try{v=JSON.stringify(f)}catch{continue}if(v===void 0)continue;Oc(u,v),a.push(` var ${u} = ${v.replace(/</g,"\\u003c")};`)}if(a.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
136
136
|
${a.join(`
|
|
137
137
|
`)}
|
|
138
|
-
`}var
|
|
138
|
+
`}var jc={left:0,middle:1,right:2};function Pc(e){let n=[];if(e.self)n.push("if ($event.target !== $el) return");for(let r of e.systemKeys)n.push(`if (!$event.${r}Key) return`);if(e.keys.length>0){let r=e.keys.map((i)=>`$event.key === '${i}'`).join(" || ");n.push(`if (!(${r})) return`)}if(e.mouse!==null){let r=jc[e.mouse];n.push(`if ($event.button !== ${r}) return`)}if(e.prevent)n.push("$event.preventDefault()");if(e.stop)n.push("$event.stopPropagation()");return n.join("; ")}function Mc(e,n){let{elementId:r,event:i,modifiers:a}=e,l=Xs(e.handler),u=Pc(a),f=[];if(a.once)f.push("once: true");if(a.capture)f.push("capture: true");if(qs(i,a))f.push("passive: true");let v=f.length>0?`, { ${f.join(", ")} }`:"",S="";if(u)S+=`${u}; `;let I=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),j=`var $emit = function(name, detail) {
|
|
139
139
|
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
140
140
|
};`;function L(M){if(/\$emit\s*\(/.test(M))return`${j}
|
|
141
141
|
${M}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
@@ -178,11 +178,11 @@ else {
|
|
|
178
178
|
else {
|
|
179
179
|
${l}
|
|
180
180
|
}
|
|
181
|
-
}${v})`}function
|
|
181
|
+
}${v})`}function Dc(e){if(e.length===0)return"";return`
|
|
182
182
|
// STX: auto-generated event bindings
|
|
183
|
-
${e.map((r,i)=>
|
|
184
|
-
`)}`}function
|
|
185
|
-
`)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let v=i.slice(u),S=v.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(S){let L=S[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=S[0].length;continue}let I=v.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){I[1].split(",").forEach((L)=>{let M=L.trim(),V=M.indexOf(":"),W=V>=0?M.slice(V+1).trim().split(/[\s=]/)[0]:M.split(/[\s=]/)[0];if(W&&!W.startsWith("_")&&!r.has(W))n.push(W),r.add(W)}),u+=I[0].length;continue}let j=v.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(j){let L=j[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=j[0].length;continue}}u++}return n}var
|
|
183
|
+
${e.map((r,i)=>Mc(r,i)).join(`
|
|
184
|
+
`)}`}function Si(e){let n=[],r=new Set,i=e.replace(/^\s*import\s+.*$/gm,""),a=0,l=i.length,u=0;while(u<l){let f=i[u];if(f==="'"||f==='"'||f==="`"){let v=f;if(u++,v==="`"){let S=0;while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]==="`"&&S===0){u++;break}if(i[u]==="$"&&i[u+1]==="{"){S++,u+=2;continue}if(i[u]==="}"&&S>0){S--,u++;continue}u++}}else while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]===v){u++;break}u++}continue}if(f==="/"&&i[u+1]==="/"){while(u<l&&i[u]!==`
|
|
185
|
+
`)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let v=i.slice(u),S=v.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(S){let L=S[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=S[0].length;continue}let I=v.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){I[1].split(",").forEach((L)=>{let M=L.trim(),V=M.indexOf(":"),W=V>=0?M.slice(V+1).trim().split(/[\s=]/)[0]:M.split(/[\s=]/)[0];if(W&&!W.startsWith("_")&&!r.has(W))n.push(W),r.add(W)}),u+=I[0].length;continue}let j=v.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(j){let L=j[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=j[0].length;continue}}u++}return n}var Nc=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function Lc(e){let n=new Set,r=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function i(L){let M;while((M=r.exec(L))!==null){let V=M[0];if(!Nc.has(V))n.add(V)}}let a=/\{\{([\s\S]*?)\}\}/g,l;while((l=a.exec(e))!==null)i(l[1]);let u=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((l=u.exec(e))!==null)i(l[1]);let f=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((l=f.exec(e))!==null)i(l[1]);let v=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((l=v.exec(e))!==null)i(l[1]);let S=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((l=S.exec(e))!==null)i(l[1]);let I=/@model\s*=\s*["']([^"']*)["']/gi;while((l=I.exec(e))!==null)i(l[1]);let j=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((l=j.exec(e))!==null)i(l[1]);return n}async function Je(e,n={}){let r=e,i="",a=!1,l=[],u=Vi(r,{filePath:n.filePath,projectRoot:n.projectRoot});r=u.code;let f=Wi(u.styles),v=Gt(r);r=v.code,l=[...v.imports,...v.models];let{hasUserImports:S,bundleClientScript:I}=await o("stx/client-script-bundler",()=>import("./chunk-q33tyfpp.js"));if(S(r))r=await I(r,n.filePath||"",{projectRoot:n.projectRoot,minify:n.production}),a=!0;if(n.autoImports!==!1){let U=_l(r);r=U.code,i=Cl(U.stxImports,U.browserImports.filter((H)=>!l.includes(H)))}if(i=`${In(r,n.serverData)}${i}`,r=D(r),!a&&Ye(n.attrs||""))r=Ze(r);let j=Dc(n.eventBindings||[]),L=(n.attrs||"").trim(),M=/\btype\s*=\s*["']module["']/i.test(L),V=n.instanceId?` data-stx-instance="${n.instanceId}"`:"";if(M){let U=L.replace(/\btype\s*=\s*["']module["']/i,"").trim(),H=`type="module" data-stx-scoped${V}${U?` ${U}`:""}`;return`${f}<script ${H}>
|
|
186
186
|
${me(`${i}${r}
|
|
187
187
|
${j}`)}
|
|
188
188
|
</script>`}let W=oa(e),Z=/function __stx_setup_/.test(r),q=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(e);function X(U){let H=U.length>0?`
|
|
@@ -196,7 +196,7 @@ ${j}${H}`)}
|
|
|
196
196
|
console.error(${re}, error);
|
|
197
197
|
return {};
|
|
198
198
|
}
|
|
199
|
-
})</script>`}if(!q&&!Z){if(W)return X(
|
|
199
|
+
})</script>`}if(!q&&!Z){if(W)return X(Si(e));if(n.templateContent){let U=Si(e);if(U.length>0){let H=Lc(n.templateContent);if(U.some((ce)=>H.has(ce)))return X(U)}}}return`${f}<script data-stx-scoped data-stx-run="always"${V}>
|
|
200
200
|
;(function() {
|
|
201
201
|
'use strict';
|
|
202
202
|
try {
|
|
@@ -205,7 +205,7 @@ ${j}`)}
|
|
|
205
205
|
} catch (error) {
|
|
206
206
|
console.error(${JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`)}, error);
|
|
207
207
|
}
|
|
208
|
-
})()</script>`}import{createHash as
|
|
208
|
+
})()</script>`}import{createHash as Kc}from"crypto";var er=/\s*/y,tr=/\x00STX_HTML_COMMENT_\d+\x00/y;function Vt(e){let n=0;while(n<e.length){if(er.lastIndex=n,er.exec(e),n=er.lastIndex,e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)return n;n=r+3;continue}if(tr.lastIndex=n,tr.test(e)){n=tr.lastIndex;continue}return n}return n}var nr=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,zc=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function Ne(e){let n=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let L=e.indexOf("-->",i+4);if(L===-1)break;r=L+3;continue}nr.lastIndex=i;let a=nr.exec(e);if(!a){r=i+1;continue}let l=nr.lastIndex,u=l,f=null;for(;u<e.length;u++){let L=e[u];if(f){if(L===f)f=null}else if(L==='"'||L==="'")f=L;else if(L===">")break}if(u===e.length)break;let v=a[1]==="/",S=e[u-1]==="/";n.push({start:i,end:u+1,name:a[2],attributes:e.slice(l,S?u-1:u),closing:v,selfClosing:S}),r=u+1;let I=a[2].toLowerCase();if(!v&&I==="plaintext")break;let j=zc.get(I);if(!v&&(I==="script"||I==="style"||j)){let L=j??(I==="script"?ds:gs);L.lastIndex=r;let M=L.exec(e);if(!M)break;r=M.index}}return n}var ps=/<script\b[^>]*>/iy,ds=/<\/script\s*>/ig,fs=/<style\b[^>]*>/iy,gs=/<\/style\s*>/ig;function Ei(e,n,r,i){r.lastIndex=n;let a=r.exec(e);if(!a||a.index!==n)return-1;i.lastIndex=r.lastIndex;let l=i.exec(e);if(!l)return-1;return l.index+l[0].length}function Q(e,n){return Ei(e,n,ps,ds)}function Tn(e,n){return Ei(e,n,fs,gs)}function Xe(e,n){if(!e.startsWith("<!--",n))return-1;let r=e.indexOf("-->",n+4);if(r===-1)return-1;return r+3}function ki(e,n){if(e.startsWith("<!--",n)){let a=Xe(e,n);return a===-1?e.length:a}if(ps.lastIndex=n,ps.exec(e)?.index===n){ds.lastIndex=ps.lastIndex;let a=ds.exec(e);return a?a.index+a[0].length:e.length}if(fs.lastIndex=n,fs.exec(e)?.index===n){gs.lastIndex=fs.lastIndex;let a=gs.exec(e);return a?a.index+a[0].length:e.length}return-1}function x(e,n){let r=[],i=0,a=e.length,l=!1,u=null;while(i<a){let f=e[i];if(l){if(u){if(f===u)u=null}else if(f==='"'||f==="'")u=f;else if(f===">")l=!1;i++;continue}if(f!=="<"){let j=e.indexOf("<",i+1);if(j===-1)break;i=j;continue}let v=n(e,i);if(v>i){r.push({start:i,end:v,token:e.slice(i,v)}),i=v;continue}let S=ki(e,i);if(S>i){i=S;continue}let I=e.charCodeAt(i+1);if(I>=65&&I<=90||I>=97&&I<=122)l=!0;i++}return r}function Ci(e){let n=0,r=0,i=0,a=!1,l=null;while(i<e.length){if(a){let j=e[i];if(l){if(j===l)l=null}else if(j==='"'||j==="'")l=j;else if(j===">")a=!1;i++;continue}let u=e.indexOf("<",i),f=u===-1?e.length:u;while(i<f){let j=e[i++];if(j==="{")n++;else if(j==="}")r++;if(n>=2&&r>=2)return!0}if(u===-1)break;let v=ki(e,u);if(v>u){i=v;continue}let S=e.charCodeAt(u+1),I=S===47?e.charCodeAt(u+2):S;if(I>=65&&I<=90||I>=97&&I<=122)a=!0;i=u+1}return!1}function al(e,n){while(e.size>=n){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Bc=1024,Wc=16777216,un=new Map,sr=0;function Fc(e,n){un.set(e,n),sr+=e.length+n.output.length;for(let[r,i]of un){if(sr<=Wc)break;un.delete(r),sr-=r.length+i.output.length}}function ke(e,n,r,i){let a=i!==void 0&&e.length>=Bc,l=a?`${i}\x00${e}`:"";if(a){let I=un.get(l);if(I)return un.delete(l),un.set(l,I),{output:I.output,tokens:I.tokens.slice()}}let u=x(e,n);if(u.length===0)return{output:e,tokens:[]};let f=u.map((I)=>I.token),v="",S=0;for(let I=0;I<u.length;I++){let j=u[I];v+=e.slice(S,j.start),v+=r(j.token,I),S=j.end}if(v+=e.slice(S),a)return Fc(l,{output:v,tokens:f}),{output:v,tokens:f.slice()};return{output:v,tokens:f}}var Vc=1024,Uc=16777216,pn=new Map,rr=0;function Hc(e,n){pn.set(e,n),rr+=e.length+n.output.length;for(let[r,i]of pn){if(rr<=Uc)break;pn.delete(r),rr-=r.length+i.output.length}}function ir(e,n,r){return{output:n,scripts:r,restore:(i)=>i===n?e:Dr(i,r)}}function se(e){let n=e.length>=Vc;if(n){let a=pn.get(e);if(a)return pn.delete(e),pn.set(e,a),ir(e,a.output,a.scripts.slice())}let{output:r,tokens:i}=ke(e,Q,(a,l)=>`\x00STX_SCRIPT_${l}\x00`);if(n)return Hc(e,{output:r,scripts:i}),ir(e,r,i.slice());return ir(e,r,i)}function Dr(e,n){if(n.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>n[+i]??"")}function ee(e){let n=Ne(e),r=[];for(let i=0;i<n.length;i++){let a=n[i],l=n[i+1];if(a.name.toLowerCase()!=="script"||a.closing||l?.name.toLowerCase()!=="script"||!l.closing)continue;r.push({start:a.start,end:l.end,bodyStart:a.end,bodyEnd:l.start,attrs:a.attributes})}return r}var ms="__stx_component_client_factories";function hs(e){let n=e[ms];return n instanceof Map?n:null}function vl(e){e[ms]=new Map}function or(e,n){let r=hs(e);if(!r)return null;let i=Kc("sha256").update(n).digest("hex").slice(0,16),a=r.get(i);if(a)a.instances++;else r.set(i,{body:n,instances:1});return i}function xl(e,n){let r=hs(n);if(!r?.size)return e;let i=new Map;for(let[I,j]of r)if(j.instances===1)i.set(I,j.body);let a=[];if(i.size>0){let I=[...i.keys()].map((M)=>JSON.stringify(M).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),j=new RegExp(`window\\.__stxComponentFactories\\[(${I})\\]\\(("[^"]+")\\);`,"g"),L=j.exec(e);while(L!==null){let M=i.get(JSON.parse(L[1]));if(M!==void 0)a.push({start:L.index,end:L.index+L[0].length,replacement:me(`(${M})(${L[2]});`)});L=j.exec(e)}}let l=[...r].filter(([,I])=>I.instances>1);if(l.length===0)return Ri(e,a);let u=l.map(([I,j])=>` try { factories[${JSON.stringify(I)}] = factories[${JSON.stringify(I)}] || ${j.body}; }
|
|
209
209
|
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(I)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
210
210
|
`),f=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
211
211
|
(function() {
|
|
@@ -213,15 +213,15 @@ ${j}`)}
|
|
|
213
213
|
${me(u)}
|
|
214
214
|
})();
|
|
215
215
|
</script>`,v,S=/<(?:template\b|script\b(?=[^>]*\bdata-stx-scoped\b))/iy;return x(e,(I,j)=>{if(v===void 0){if(S.lastIndex=j,S.test(I))v=j}return-1}),a.push({start:v??0,end:v??0,replacement:`${f}
|
|
216
|
-
`}),Ai(e,a)}function Ai(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function Ti(e){let n=xs(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function Pi(e,n){let r=xs(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function Zi(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)ar(e,r)}function Ie(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import $o from"fs";var Ji=0,cr=new Map;function Rl(){Ji=0,cr.clear()}function bs(e,n){let r=Ji++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return cr.set(i,{type:e,expression:n}),i}function Al(){let e={};for(let[n,r]of cr)e[n]={type:r.type,expression:r.expression};return e}function Pl(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Ki(e){return e.includes("<!--__STX_")}var Jc=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function Xc(e){return Array.from({length:e},()=>"{").join("⁠")}function Qi(e){return e.replace(/\{{2,}/g,(n)=>Xc(n.length)).replace(/\{(?=!)/g,"{⁠").replace(Jc,"@")}function jr(e,n,r=!1){let{openTag:i,tail:a}=r?Gc(e,n):Yc(e).at(n);return el(a,i,r)}function Gc(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Ie(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var ys=null;function Yc(e){if(ys&&ys.source===e)return ys.scanner;let n=Qc(e);return ys={source:e,scanner:n},n}function Qc(e){let n=0,r=-1,i=null,a=-1,l=(f,v)=>{let S=e[f];if(v.quote){if(S===v.quote)v.quote=null;return}if(v.openTag>=0){if(S==='"'||S==="'"){v.quote=S;return}if(S===">"){v.openTag=-1;return}}if(S==="<")v.openTag=f},u=(f,v)=>{if(v.openTag>=0||!e.startsWith("<!--",f))return-1;let S=e.indexOf("-->",f+4);return S<0?e.length:S+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let v={openTag:r,quote:i},S=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let W=Ie(e,n);if(W<0)a=n;else if(W+2<=f){n=W+2;continue}else break}let V=u(n,v);if(V>=0){if(V>f){S=!0;break}n=V;continue}l(n,v),n++}if(r=v.openTag,i=v.quote,S)return{openTag:-1,tail:""};let I=a>=0?a:n,j={openTag:r,quote:i};for(let V=n;V<f;V++){let W=u(V,j);if(W>=0){if(W>f)return{openTag:-1,tail:""};V=W-1;continue}l(V,j)}if(j.openTag<0)return{openTag:-1,tail:""};let L="",M=j.openTag+1;for(let V=M;V<Math.min(f,I);V++){if(!e.startsWith("{{",V))continue;let W=Ie(e,V);L+=e.slice(M,V)+"x",V=W+1,M=W+2}return L+=e.slice(M,f),{openTag:j.openTag,tail:L}}}}function el(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,v=e.indexOf(u,i);if(v===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=v+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class he extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var ho="unsafe:";var tl=/^(?:javascript|vbscript|livescript|mocha|view-source):/,nl=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,sl=/^data:(?:text\/html|application\/xhtml\+xml)/,rl=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Il(e){return e.replace(rl,"").toLowerCase()}function lr(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function _s(e,n="navigable"){let r=Il(e);if(tl.test(r))return!0;return n==="navigable"?nl.test(r):sl.test(r)}function Lr(e,n="navigable"){return _s(e,n)?"unsafe:"+e:e}function Ol(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return lr(n[1])}function bo(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function yo(e,n,r=n){let i=Ol(e);return i&&_s(n,i)?"unsafe:"+r:r}function Wt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function ws(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function _o(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function So(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Jt(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=_o(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of ws(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Jt(l,n);continue}let u=_o(l,":");Jt(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of ws(r.slice(1,-1)))Jt(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function oe(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let v=n.slice(0,l).trim();if(v.startsWith("(")&&So(v)===v.length-1)v=v.slice(1,-1);for(let S of ws(v))Jt(S,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&So(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Jt(u[2],r),Jt(u[1],r);else for(let f of ws(l))Jt(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var vs="__stx_client_loop_names";function mt(e){let n=e?.[vs];return Array.isArray(n)?n:[]}function Ss(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((I)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(I[1])),v=(f?.[2]??f?.[3])?.trim();if(v&&f?.[1]==="data-stx-slot-binding")try{v=decodeURIComponent(v)}catch{v=void 0}let S=v?{start:a.index+l.length,end:e.length,binding:v}:void 0;if(r.push(S),S)n.push(S)}}return n}var zn={},Eo=new Map;function jl(e){let n=Eo.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),Eo.set(e,n)}return n.lastIndex=0,n}var fo={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return Y(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let v of l){if(u===void 0||u===null)break;u=u[v]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([v,S])=>{f=f.replace(jl(v),()=>String(S))}),f},t:(e,n,r={})=>fo.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function Jg(e,n){if(e in fo)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);zn[e]=n}function Oy(e){for(let[n,r]of Object.entries(e))Jg(n,r)}function Yg(){return{...fo,...zn}}function Ny(){for(let e of Object.keys(zn))delete zn[e]}function Io(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*Oo(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,v=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let S=e.indexOf(a,u);if(S===-1)break;let I=Ie(e,S,r);if(I===-1)break;if(l+=e.slice(u,S)+n(e.slice(S,I+r),e.slice(S+r,I),S),u=I+r,++f>=64){f=0;let j=performance.now();if(j-v>=i)v=j,yield}}return u===0?e:l+e.slice(u)}function Nn(e,n,r=2){return Io(Oo(e,n,r,Number.POSITIVE_INFINITY))}function Ml(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=jr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Y(e){return Qi(g(e))}function Dl(e){return e.replace(/ /g," ").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ").replace(/\f/g,"").replace(/=/g,"=").replace(/`/g,"`")}function Nl(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function Ll(e,n){let r=Nl(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new he(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new he(n,"CSS URLs must be local paths or base64 raster images")}}function ae(e,n,r,i=!1,a=0){try{return zl(e,n,r,i,a)}catch(l){if(l instanceof he)l.locate(e,n);throw l}}function zl(e,n,r,i,a){let l=jr(e,n,i),u=Y(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new he("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let S=e.slice(n+a).trimStart(),I=r.trim();if(!S.startsWith("=")&&(I===""||I.split(/\s+/).every((j)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(j))))return I;throw new he("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new he(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=Y(u);if(f==="style")Ll(r,l.name);if(l.quote===null)u=Dl(u);let v=lr(f);if(v&&l.valuePrefix.trim()===""&&_s(r,v))return ho+u;return yo(bo(e,n),r,u)}function Mn(e,n){let r=` ${e}="`;return ae(r,r.length,n,!0)}function jo(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Me(e,n){let{scripts:r}=se(e);for(let i of jo(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||Tl.test(i))return!0;if(Zr(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function Zg(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(oe(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let v=1,S=e.length;for(let I=f.exec(e);I;I=f.exec(e)){if(I[2]==="/")continue;if(v+=I[1]==="/"?-1:1,v===0){S=I.index+I[0].length;break}}n.push({start:i.index,end:S,names:l})}return n}function ko(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function Co(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let S=0;S<i.length;S++){let I=i[S];if(!l&&I==="`"){l=!0,u=0;continue}if(l){if(I==="`"&&u===0){l=!1;continue}if(I==="$"&&i[S+1]==="{"){u++,S++,a+=" ";continue}if(I==="}"&&u>0){u--;continue}if(u>0){a+=I;continue}continue}a+=I}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,v;while((v=f.exec(i))!==null){let S=v[1];if(!i.substring(0,v.index).trimEnd().endsWith(".")){if(!r.includes(S)&&!(S in n))return!1}}return!0}function Bl(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function Wl(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var Ro=new Set;function Ao(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Hl(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
|
|
217
|
-
`,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function
|
|
218
|
-
`).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function N(e,n,r=!1,i){try{let a=e.trim(),l=
|
|
216
|
+
`}),Ri(e,a)}function Ri(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function Ai(e){let n=hs(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function Ti(e,n){let r=hs(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function Pi(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)or(e,r)}function Ie(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import So from"fs";var Zi=0,ar=new Map;function Rl(){Zi=0,ar.clear()}function xs(e,n){let r=Zi++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return ar.set(i,{type:e,expression:n}),i}function Al(){let e={};for(let[n,r]of ar)e[n]={type:r.type,expression:r.expression};return e}function Pl(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Ki(e){return e.includes("<!--__STX_")}var qc=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function Zc(e){return Array.from({length:e},()=>"{").join("⁠")}function Ji(e){return e.replace(/\{{2,}/g,(n)=>Zc(n.length)).replace(/\{(?=!)/g,"{⁠").replace(qc,"@")}function jr(e,n,r=!1){let{openTag:i,tail:a}=r?Jc(e,n):Xc(e).at(n);return Yc(a,i,r)}function Jc(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Ie(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var bs=null;function Xc(e){if(bs&&bs.source===e)return bs.scanner;let n=Gc(e);return bs={source:e,scanner:n},n}function Gc(e){let n=0,r=-1,i=null,a=-1,l=(f,v)=>{let S=e[f];if(v.quote){if(S===v.quote)v.quote=null;return}if(v.openTag>=0){if(S==='"'||S==="'"){v.quote=S;return}if(S===">"){v.openTag=-1;return}}if(S==="<")v.openTag=f},u=(f,v)=>{if(v.openTag>=0||!e.startsWith("<!--",f))return-1;let S=e.indexOf("-->",f+4);return S<0?e.length:S+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let v={openTag:r,quote:i},S=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let W=Ie(e,n);if(W<0)a=n;else if(W+2<=f){n=W+2;continue}else break}let V=u(n,v);if(V>=0){if(V>f){S=!0;break}n=V;continue}l(n,v),n++}if(r=v.openTag,i=v.quote,S)return{openTag:-1,tail:""};let I=a>=0?a:n,j={openTag:r,quote:i};for(let V=n;V<f;V++){let W=u(V,j);if(W>=0){if(W>f)return{openTag:-1,tail:""};V=W-1;continue}l(V,j)}if(j.openTag<0)return{openTag:-1,tail:""};let L="",M=j.openTag+1;for(let V=M;V<Math.min(f,I);V++){if(!e.startsWith("{{",V))continue;let W=Ie(e,V);L+=e.slice(M,V)+"x",V=W+1,M=W+2}return L+=e.slice(M,f),{openTag:j.openTag,tail:L}}}}function Yc(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,v=e.indexOf(u,i);if(v===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=v+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class he extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var Qi="unsafe:";var Qc=/^(?:javascript|vbscript|livescript|mocha|view-source):/,el=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,tl=/^data:(?:text\/html|application\/xhtml\+xml)/,nl=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function sl(e){return e.replace(nl,"").toLowerCase()}function cr(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function ys(e,n="navigable"){let r=sl(e);if(Qc.test(r))return!0;return n==="navigable"?el.test(r):tl.test(r)}function Lr(e,n="navigable"){return ys(e,n)?"unsafe:"+e:e}function rl(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return cr(n[1])}function ho(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function bo(e,n,r=n){let i=rl(e);return i&&ys(n,i)?"unsafe:"+r:r}function Wt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function _s(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function yo(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function _o(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Jt(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=yo(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of _s(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Jt(l,n);continue}let u=yo(l,":");Jt(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of _s(r.slice(1,-1)))Jt(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function oe(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let v=n.slice(0,l).trim();if(v.startsWith("(")&&_o(v)===v.length-1)v=v.slice(1,-1);for(let S of _s(v))Jt(S,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&_o(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Jt(u[2],r),Jt(u[1],r);else for(let f of _s(l))Jt(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var ws="__stx_client_loop_names";function mt(e){let n=e?.[ws];return Array.isArray(n)?n:[]}function vs(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((I)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(I[1])),v=(f?.[2]??f?.[3])?.trim();if(v&&f?.[1]==="data-stx-slot-binding")try{v=decodeURIComponent(v)}catch{v=void 0}let S=v?{start:a.index+l.length,end:e.length,binding:v}:void 0;if(r.push(S),S)n.push(S)}}return n}var Bn={},$o=new Map;function Il(e){let n=$o.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),$o.set(e,n)}return n.lastIndex=0,n}var fo={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return Y(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let v of l){if(u===void 0||u===null)break;u=u[v]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([v,S])=>{f=f.replace(Il(v),()=>String(S))}),f},t:(e,n,r={})=>fo.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function Jg(e,n){if(e in fo)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);Bn[e]=n}function Oy(e){for(let[n,r]of Object.entries(e))Jg(n,r)}function Yg(){return{...fo,...Bn}}function Ny(){for(let e of Object.keys(Bn))delete Bn[e]}function To(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*Io(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,v=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let S=e.indexOf(a,u);if(S===-1)break;let I=Ie(e,S,r);if(I===-1)break;if(l+=e.slice(u,S)+n(e.slice(S,I+r),e.slice(S+r,I),S),u=I+r,++f>=64){f=0;let j=performance.now();if(j-v>=i)v=j,yield}}return u===0?e:l+e.slice(u)}function Nn(e,n,r=2){return To(Io(e,n,r,Number.POSITIVE_INFINITY))}function Ol(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=jr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Y(e){return Ji(g(e))}function jl(e){return e.replace(/ /g," ").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ").replace(/\f/g,"").replace(/=/g,"=").replace(/`/g,"`")}function Ml(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function Dl(e,n){let r=Ml(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new he(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new he(n,"CSS URLs must be local paths or base64 raster images")}}function ae(e,n,r,i=!1,a=0){try{return Nl(e,n,r,i,a)}catch(l){if(l instanceof he)l.locate(e,n);throw l}}function Nl(e,n,r,i,a){let l=jr(e,n,i),u=Y(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new he("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let S=e.slice(n+a).trimStart(),I=r.trim();if(!S.startsWith("=")&&(I===""||I.split(/\s+/).every((j)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(j))))return I;throw new he("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new he(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=Y(u);if(f==="style")Dl(r,l.name);if(l.quote===null)u=jl(u);let v=cr(f);if(v&&l.valuePrefix.trim()===""&&ys(r,v))return Qi+u;return bo(ho(e,n),r,u)}function Mn(e,n){let r=` ${e}="`;return ae(r,r.length,n,!0)}function Oo(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Me(e,n){let{scripts:r}=se(e);for(let i of Oo(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||Tl.test(i))return!0;if(Zr(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function Zg(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(oe(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let v=1,S=e.length;for(let I=f.exec(e);I;I=f.exec(e)){if(I[2]==="/")continue;if(v+=I[1]==="/"?-1:1,v===0){S=I.index+I[0].length;break}}n.push({start:i.index,end:S,names:l})}return n}function Eo(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function ko(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let S=0;S<i.length;S++){let I=i[S];if(!l&&I==="`"){l=!0,u=0;continue}if(l){if(I==="`"&&u===0){l=!1;continue}if(I==="$"&&i[S+1]==="{"){u++,S++,a+=" ";continue}if(I==="}"&&u>0){u--;continue}if(u>0){a+=I;continue}continue}a+=I}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,v;while((v=f.exec(i))!==null){let S=v[1];if(!i.substring(0,v.index).trimEnd().endsWith(".")){if(!r.includes(S)&&!(S in n))return!1}}return!0}function Ll(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function zl(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var Co=new Set;function Ro(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Bl(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
|
|
217
|
+
`,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function Ao(e,n){let r=`${n??"<unknown>"}\x00${e}`;if(process.env.STX_DEBUG||!Co.has(r))Co.add(r),console.warn(`[stx] {{ ${e} }} in a <script> in ${n??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function Xi(e,n,r){let i=e;return i=i.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>{try{let u=N(l,n);if(u===void 0)return Ro(l)?Ao(l.trim(),r):a;return u===null?"":String(u)}catch{return a}}),i=Nn(i,(a,l,u)=>{let f=l.trim();if(Bl(i,u,l))return a;if(/^__[A-Z_]+__$/.test(f))return a;try{let v=N(l,n);if(v===void 0)return Ro(f)?Ao(f,r):a;return JSON.stringify(v).replace(/</g,"\\u003c").replace(/@/g,"\\u0040").replace(/\{{2,}/g,(S)=>"\\u007b".repeat(S.length)).replace(/\{(?=!)/g,"\\u007b")}catch{return a}}),i}function Qg(e,n){if(!e.includes("{"))return e;let r=e;return r=r.replace(/\{!!([\s\S]*?)!!\}/g,(i,a)=>{try{let l=N(a,n);if(l===void 0)return i;return l===null?"":String(l)}catch{return i}}),r=Nn(r,(i,a,l)=>{let u=a.trim();if(/^__[A-Z_]+__$/.test(u))return i;try{let f=N(a,n);if(f===void 0)return i;if(f===null)return"";let v=String(f);return ae(r,l,v,!0,i.length)}catch(f){if(f instanceof he)throw f;return i}}),r}function My(e,n,r={}){let{output:i,scripts:a}=se(e),l=a.map((u)=>{let f=u.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i),v=u.search(/<\/script\s*>$/i);if(!f||v===-1)return u;let S=f[1],I=u.slice(f[0].length,v);if(/\bdata-raw\b/.test(S))return u;if(r.skipServer&&/\bserver\b/.test(S))return u;let L=`<script${Qg(S,n)}>`;if(/\bsrc\s*=/.test(S)||/\btype\s*=\s*["']application\/json["']/.test(S))return L+I+u.slice(v);return L+Xi(I,n)+u.slice(v)});return Dr(i,l)}function*jo(e,n,r,i){let a=e,l=(W,Z)=>{let q=Tn(W,Z);if(q===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(W.slice(Z,q))?-1:q},u=(W,Z,q,X)=>{let U=q.length,{output:H,tokens:re}=ke(W,Z,(ce,le)=>X(U+le));return q.push(...re),H},f=[];a=u(a,l,f,(W)=>`<!--__STX_STYLE_${W}__-->`);let v=[];a=u(a,Q,v,(W)=>`<!--__STX_SCRIPT_EXPR_${W}__-->`);let S=n?.__stx_signals_gate===!0||Me(e),I=new Set([...Array.isArray(n?.__stx_client_signal_names)?n.__stx_client_signal_names:[],...qi(Oo(v))]),j=new Set(Array.isArray(n?.__stx_preserved_client_expressions)?n.__stx_preserved_client_expressions:[]);a=Nn(a,(W,Z,q)=>{if(F(Z,I))return W;try{let X=N(Z,n,!1,(U)=>lr(U,W,r,e));return X!==void 0&&X!==null?String(X):""}catch(X){let U=X instanceof Error?X.message:String(X);return b("Expression",`Error evaluating: {{{ ${Z.trim()}}}}: ${U}`,r,e,q,W)}},3),a=a.replace(/\{!!([\s\S]*?)!!\}/g,(W,Z,q)=>{if(F(Z,I))return W;try{let X=N(Z,n,!1,(U)=>lr(U,W,r,e));if(X===void 0&&n.__stx_buildMode==="compile")return xs("raw",Z.trim());return X!==void 0&&X!==null?String(X):""}catch(X){if(n.__stx_buildMode==="compile")return xs("raw",Z.trim());let U=X instanceof Error?X.message:String(X);return b("Expression",`Error evaluating: {!! ${Z.trim()} !!}: ${U}`,r,e,q,W)}}),a=u(a,Q,v,(W)=>`<!--__STX_SCRIPT_EXPR_${W}__-->`),a=u(a,l,f,(W)=>`<!--__STX_STYLE_${W}__-->`);let L=S?Zg(a):[],M=vs(a).map((W)=>({...W,names:new Set(oe(`${W.binding} in __slot`))})),V=new Set(mt(n));if(a=yield*Io(a,(W,Z,q)=>{let X=Z.trim();if(Ol(a,q,Z))return W;if(Eo(M,q,X))return W;if(F(X,V))return W;if(L.length>0&&Eo(L,q,X))return W;if(j.has(X))return W;let U=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ce=X.match(H)?.[1],le=ce&&((ce in n)||U.includes(ce)),pe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,Re=X.match(pe),Ae=Re&&!U.includes(Re[1])&&!(Re[1]in n);if(/^__[A-Z_]+__$/.test(X))return"";if(F(X,I))return W;if(n.__stx_native_screen===!0&&Ll(X,n))return W;let we;try{let fe=N(Z,n,!1,(Fe)=>{we=Fe});if(S&&!ko(X,n))return W;if(we)lr(we,W,r,e);if(n.__stx_buildMode==="compile"&&!S&&(fe===void 0||zl(X,n)))return xs("expr",X);if(fe===void 0||fe===null)return"";let We=String(fe);return ae(a,q,We,!1,W.length)}catch(fe){if(fe instanceof he)throw fe;if(S&&!ko(X,n))return W;if(Ae)return W;let We=fe instanceof Error?fe.message:String(fe);return b("Expression",`Error evaluating: {{ ${X} }}: ${We}`,r,e,q,W)}},2,i),v.length>0)a=a.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(W,Z)=>v[Number(Z)]??W);if(f.length>0)a=a.replace(/<!--__STX_STYLE_(\d+)__-->/g,(W,Z)=>f[Number(Z)]??W);return a}function P(e,n,r){return To(jo(e,n,r,Number.POSITIVE_INFINITY))}var Wl=100;async function Gi(e,n,r,i=Wl){let a=jo(e,n,r,i),l=a.next();while(!l.done)await R(),l=a.next();return l.value}function em(e,n,r){if(!n.trim())return e;let i=e,a=n.trim();while(a.length>0){let l=a.match(/^(\w+)/);if(!l)break;let u=l[1];a=a.substring(u.length).trim();let f=Bn[u]||fo[u];if(!f)throw Error(`Filter not found: ${u}. Available filters: ${Object.keys(Yg()).join(", ")}`);let v=[];if(a.startsWith(":")){let S=a.match(/^:([^|\s]+)/);if(S){let I=S[1].trim();try{let j=Number(I);v=[Number.isNaN(j)?I:j]}catch{v=[I]}a=a.substring(S[0].length).trim()}}else if(a.startsWith("(")){let S=1,I=1;while(S>0&&I<a.length){if(a[I]==="(")S++;if(a[I]===")")S--;I++}if(S===0){let j=a.substring(1,I-1).trim();if(j)try{if(j.startsWith("{")&&j.endsWith("}"))v=[N(`(${j})`,r,!0)];else{let L=[],M="",V=null,W=0,Z=0,q=0,X=!1;for(let U=0;U<j.length;U++){let H=j[U];if(X){M+=H,X=!1;continue}if(H==="\\"){M+=H,X=!0;continue}if(V){if(M+=H,H===V)V=null;continue}if(H==='"'||H==="'"||H==="`"){V=H,M+=H;continue}if(H==="(")W++;else if(H===")")W--;else if(H==="[")Z++;else if(H==="]")Z--;else if(H==="{")q++;else if(H==="}")q--;if(H===","&&W===0&&Z===0&&q===0){L.push(M),M="";continue}M+=H}if(M)L.push(M);v=L.map((U)=>{let H=U.trim();return N(H,r,!0)})}}catch{v=[j]}a=a.substring(I).trim()}}try{i=f(i,r,...v)}catch(S){let I=S instanceof Error?S.message:String(S);throw Error(`Error applying filter '${u}': ${I}`)}if(a.startsWith("|"))a=a.substring(1).trim();else break}return i}function Hl(e){let n=!1,r="",i=0,a=0,l=0,u=!1;for(let f=0;f<e.length;f++){let v=e[f],S=e[f+1];if(n&&u){u=!1;continue}if(n&&v==="\\"){u=!0;continue}if(u=!1,(v==='"'||v==="'"||v==="`")&&!u){if(!n)n=!0,r=v;else if(v===r)n=!1,r="";continue}if(n&&r==="`"&&v==="$"&&S==="{"){let I=1;f+=2;while(f<e.length&&I>0){if(e[f]==="{")I++;else if(e[f]==="}")I--;if(I>0)f++}continue}if(n)continue;if(v==="(")i++;else if(v===")")i--;else if(v==="[")a++;else if(v==="]")a--;else if(v==="{")l++;else if(v==="}")l--;if(v==="|"&&i===0&&a===0&&l===0){if(S==="|"){f++;continue}if(S==="="){f++;continue}return f}}return-1}var zn=new Set,Kl=1000;function Dy(){zn.clear()}function lr(e,n,r,i){if(!ne())return;let a=`${r}\x00${e.expression}`;if(zn.has(a))return;if(zn.size>=Kl)zn.clear();zn.add(a);let l=r,u=i;try{if(r&&So.existsSync(r))u=So.readFileSync(r,"utf8")}catch{}let f=u.indexOf(n);if(f>=0)l=`${r}:${u.slice(0,f).split(`
|
|
218
|
+
`).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function N(e,n,r=!1,i){try{let a=e.trim(),l=Hl(a);if(l>0){let f=a.substring(0,l).trim(),v=a.substring(l+1).trim(),S=N(f,n,!0,i);return em(S,v,n)}let u=mo(a);if(u!==null){i?.({expression:a,rule:u});return}try{let f=Object.keys(n),v=Object.values(n);return p(a,f)(...v)}catch{return d(a,n)}}catch(a){if(a instanceof ReferenceError){let l=/(\b\w+)\s+is not defined/.exec(a.message);if(l){let u=l[1],f=ql(u,Object.keys(n));if(f&&f!==u)a.message=`${a.message} \u2014 did you mean '${f}'?`}}if(!r)console.error(`Error evaluating expression: ${e}`,a);throw a}}function ql(e,n){let r=null;for(let a of n){if(a===e)continue;let l=Zl(e,a);if(r===null||l<r.dist)r={key:a,dist:l}}if(!r)return null;let i=Math.max(e.length,r.key.length);if(r.dist<=2||r.dist/i<=0.35)return r.key;return null}function Zl(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let[r,i]=e.length<n.length?[e,n]:[n,e],a=Array(r.length+1),l=Array(r.length+1);for(let u=0;u<=r.length;u++)a[u]=u;for(let u=1;u<=i.length;u++){l[0]=u;for(let f=1;f<=r.length;f++){let v=r[f-1]===i[u-1]?0:1;l[f]=Math.min(l[f-1]+1,a[f]+1,a[f-1]+v)}for(let f=0;f<=r.length;f++)a[f]=l[f]}return a[r.length]}function Ly(e){if(!e)return"";return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import Jl from"process";function A(e="STX_PUBLIC_"){let n={},r={};for(let[i,a]of Object.entries(Jl.env)){if(!i.startsWith(e)||a===void 0)continue;n[`import.meta.env.${i}`]=JSON.stringify(a),r[i]=a}return n["import.meta.env"]=JSON.stringify(r),n}function Po(e,n=""){let r=`${e}${n}`,i=0;for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);i=(i<<5)-i+l,i=i&i}return`stx-${Math.abs(i).toString(36)}`}function Mo(e,n,r={}){let{prefix:i="",preserveHost:a=!0,scopeKeyframes:l=!0,scopeCustomProperties:u=!1}=r;if(!e.trim())return"";let f=ur(e),v=[],S=new Map;if(l)for(let I of f){let j=I.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(j){let L=j[1],M=`${n}_${L}`;S.set(L,M)}}for(let I of f){let j=Do(I,n,i,a,S,u);v.push(j)}return v.join(`
|
|
219
219
|
|
|
220
|
-
`)}function
|
|
221
|
-
`)})}else n.push({selector:`@${I} ${j.trim()}`,declarations:L.trim()})}u="",l=!1}else if(a.trim()){a+=v;let S=a.match(/([^{]+)\{([^}]*)\}/);if(S)n.push({selector:S[1].trim(),declarations:S[2].trim()});a=""}continue}}if(l)u+=v;else a+=v}return n}function
|
|
220
|
+
`)}function ur(e){let n=[],r=e.replace(/\/\*[\s\S]*?\*\//g,""),i=0,a="",l=!1,u="";for(let f=0;f<r.length;f++){let v=r[f];if(v==="@"&&i===0)l=!0;if(v==="{")i++;else if(v==="}"){if(i--,i===0){if(l){u+=v;let S=u.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(S){let[,I,j,L]=S;if(I==="keyframes")n.push({selector:`@keyframes ${j.trim()}`,declarations:L.trim()});else if(I==="media"||I==="supports"||I==="container"){let M=ur(L);n.push({selector:`@${I} ${j.trim()}`,declarations:M.map((V)=>`${V.selector} { ${V.declarations} }`).join(`
|
|
221
|
+
`)})}else n.push({selector:`@${I} ${j.trim()}`,declarations:L.trim()})}u="",l=!1}else if(a.trim()){a+=v;let S=a.match(/([^{]+)\{([^}]*)\}/);if(S)n.push({selector:S[1].trim(),declarations:S[2].trim()});a=""}continue}}if(l)u+=v;else a+=v}return n}function Do(e,n,r,i,a,l){let{selector:u,declarations:f}=e;if(u.startsWith("@")){if(u.startsWith("@keyframes")){let I=u.replace("@keyframes ","").trim();return`@keyframes ${a.get(I)||I} { ${f} }`}if(u.startsWith("@media")||u.startsWith("@supports")||u.startsWith("@container")){let j=ur(`x { ${f} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((L)=>Do(L,n,r,i,a,l)).join(`
|
|
222
222
|
`);return`${u} {
|
|
223
223
|
${j}
|
|
224
|
-
}`}return`${u} { ${f} }`}let v=
|
|
224
|
+
}`}return`${u} { ${f} }`}let v=Xl(u,n,r,i),S=f;for(let[I,j]of a)S=S.replace(new RegExp(`\\b${I}\\b`,"g"),j);if(l)S=S.replace(/--([a-z-]+)/gi,`--${n}-$1`);return`${v} { ${S} }`}function Xl(e,n,r,i){let a=e.split(",").map((u)=>u.trim()),l=[];for(let u of a){if(u.startsWith(":host")){if(i)l.push(u);else{let S=u.replace(/:host(\([^)]*\))?/,`.${n}$1`);l.push(S)}continue}if(u.includes("::slotted")){l.push(u);continue}if(u===":root"){l.push(`:root .${n}`);continue}let f=r?`${r} .${n}`:`.${n}`;l.push(`${f} ${u}`);let v=Gl(u,n);if(v)l.push(r?`${r} ${v}`:v)}return l.join(", ")}function Gl(e,n){let r=0,i=e.length;for(let v=0;v<e.length;v++){let S=e[v];if(S==="["||S==="(")r++;else if(S==="]"||S===")")r--;else if(r===0&&(S===" "||S===">"||S==="+"||S==="~")){i=v;break}}let a=e.slice(0,i),l=e.slice(i);if(!a)return"";let u=a.length,f=0;for(let v=0;v<a.length;v++){let S=a[v];if(S==="["||S==="(")f++;else if(S==="]"||S===")")f--;else if(r===0&&f===0&&S===":"){u=v;break}}return`${a.slice(0,u)}.${n}${a.slice(u)}${l}`}var zo=String.raw`(?<![\w-])scoped(?![\w-])`,pr=/<style\s+([^>]*)>/gi,No=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Bo=new RegExp(zo,"i"),Yl=new RegExp(zo,"gi"),fr=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function Ql(e){pr.lastIndex=0;let n=pr.exec(e);while(n!==null){if(Bo.test(n[1]))return!0;n=pr.exec(e)}return!1}function zi(e){let n=new Set,r=[];fr.lastIndex=0;let i=fr.exec(e);while(i!==null){let a=i[0].trim();if(n.has(a))r.push({start:i.index,end:i.index+i[0].length});else n.add(a);i=fr.exec(e)}return r}function Rn(e){let n=zi(e);if(n.length===0)return e;let r=Array(n.length+1),i=0;for(let a=0;a<n.length;a++){let l=n[a];r[a]=e.slice(i,l.start),i=l.end}return r[n.length]=e.slice(i),r.join("")}function ao(e,n){if(!Ql(e))return{html:e,hasScoped:!1};let r=Po(n),i=`data-v-${r}`,a=e,l=!1;if(No.lastIndex=0,a=a.replace(No,(u,f,v)=>{if(!Bo.test(f))return u;l=!0;let S=eu(v,i),I=f.replace(Yl,"").trim(),j=I?` ${I}`:"";return`<style data-stx-scoped="${r}"${j}>${S}</style>`}),!l)return{html:e,hasScoped:!1};return a=nu(a,i),{html:a,hasScoped:!0}}function eu(e,n){return Mo(e,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${n}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${n}]`)}var tu=(e)=>`\x00stx-scope-mask-${e}\x00`,Lo=/\u0000stx-scope-mask-(\d+)\u0000/g;function nu(e,n){let r=ke(e,(a,l)=>{let u=Q(a,l);return u>l?u:Tn(a,l)},(a,l)=>tu(l)),i=su(r.output,n);return Lo.lastIndex=0,i.replace(Lo,(a,l)=>r.tokens[Number(l)])}function su(e,n){let r=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return e.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(i,a,l)=>{if(r.has(a.toLowerCase()))return i;if(i.includes(n))return i;if(a.toLowerCase()==="style"||a.toLowerCase()==="script")return i;if(l)return i.replace(`<${a}${l}`,`<${a} ${n}${l}`);if(i.endsWith("/>"))return`<${a} ${n} />`;return`<${a} ${n}>`})}var Wn=/<\/?template\b[^>]*>/gi,ru=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function iu(e){let n=e.replace(/^<template\b/i,"").replace(/>$/,"");return ru.test(n)}function B(e){Wn.lastIndex=0;let n;while((n=Wn.exec(e))!==null){if(n[0].startsWith("</")||iu(n[0]))continue;let r=n.index,i=Wn.lastIndex,a=1,l;while((l=Wn.exec(e))!==null)if(l[0].startsWith("</")){if(a--,a===0){let u=l.index;return{start:r,openEnd:i,closeStart:u,end:Wn.lastIndex,content:e.slice(i,u)}}}else a++;return null}return null}var ou=0,au=0;function Ss(e,n){let r=/(?:^|\s)([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;for(let i of e.matchAll(r))if(i[1].toLowerCase()===n.toLowerCase())return i[2]??i[3]??i[4]??null;return null}function Fo(e){let n=[],r=/<([a-z][a-z0-9-]*)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/iy;return x(e,(i,a)=>{r.lastIndex=a;let l=r.exec(i);if(!l||!Ss(l[2],"x-data"))return-1;return n.push({fullMatch:l[0],tagName:l[1],attributes:l[2],startIndex:a,endIndex:r.lastIndex}),r.lastIndex}),n}function cu(e){let n=[];for(let{fullMatch:r,tagName:i,attributes:a,startIndex:l}of Fo(e)){let u=Ss(a,"x-data");if(!u)continue;let f=`__stx_scope_${ou++}`,v=Ss(a,"x-init"),S=lu(e,i,l+r.length),I=e.slice(l,S.endIndex),j=uu(I);n.push({id:f,selector:`[data-stx-scope="${f}"]`,stateExpr:u,initExpr:v,bindings:[],refs:j})}return n}function lu(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s|>)`,"gi"),u=new RegExp(`</${n}>`,"gi"),f=new RegExp(`<${n}[^>]*/\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a,f.lastIndex=a;let v=l.exec(e),S=u.exec(e),I=f.exec(e);if(I&&I.index<(v?.index??1/0)){a=I.index+I[0].length;continue}if(!S)return{endIndex:e.length};if(v&&v.index<S.index)i++,a=v.index+v[0].length;else{if(i--,i===0)return{endIndex:S.index+S[0].length};a=S.index+S[0].length}}return{endIndex:e.length}}function uu(e){let n=new Map,r=e.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,a;while((a=i.exec(r))!==null){let[,l,u]=a,f=pu(l);n.set(u,f)}return n}function pu(e){let n=e.match(/\bid\s*=\s*["']([^"']*)["']/);if(n)return n[1];return`__stx_el_${au++}`}function fu(){return`
|
|
225
225
|
// STX Reactive Runtime - x-cloak and transition CSS
|
|
226
226
|
(function() {
|
|
227
227
|
var style = document.createElement('style');
|
|
@@ -493,7 +493,7 @@ window.__stx_reactive = (function() {
|
|
|
493
493
|
|
|
494
494
|
return { initScope: initScope, reactive: reactive };
|
|
495
495
|
})();
|
|
496
|
-
`}function
|
|
496
|
+
`}function Wo(e,n){let r=e.replace(/\{!!([\s\S]*?)!!\}/g,(f,v)=>{try{let S=N(v,n,!0);if(S===void 0)return f;return String(S)}catch{return f}}),i="",a=0,l=null;while(a<r.length){let f=r[a];if(l&&f==="\\"){i+=f+(r[a+1]??""),a+=2;continue}if(f==="{"&&r[a+1]==="{"){let v=r.indexOf("}}",a+2);if(v!==-1){let S=r.slice(a,v+2);i+=u(r.slice(a+2,v),S,l),a=v+2;continue}}if(l){if(f===l)l=null}else if(f==="'"||f==='"'||f==="`")l=f;i+=f,a++}return i;function u(f,v,S){let I;try{I=N(f,n,!0)}catch{return v}if(I===void 0)return v;if(S){let j=String(I).replace(/\\/g,"\\\\").replace(new RegExp(S==="`"?"`":S,"g"),`\\${S}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return S==="`"?j.replace(/\$\{/g,"\\${"):j}if(typeof I==="string"){let j=I.trim();if(j.startsWith("{")&&j.endsWith("}")||j.startsWith("[")&&j.endsWith("]"))try{return JSON.parse(j),j}catch{}}return JSON.stringify(I)}}function du(e,n,r){if(e.length===0)return"";let i=e.map((a)=>{let l=JSON.stringify(Object.fromEntries(a.refs)),u=Wo(a.stateExpr,n),f=a.initExpr?Wo(a.initExpr,n):null,v=JSON.stringify(u),S=f?JSON.stringify(f):"null";return`
|
|
497
497
|
(function() {
|
|
498
498
|
var scopeEl = document.querySelector('${a.selector}');
|
|
499
499
|
if (!scopeEl) return;
|
|
@@ -502,10 +502,10 @@ window.__stx_reactive = (function() {
|
|
|
502
502
|
})();`}).join(`
|
|
503
503
|
`);return`
|
|
504
504
|
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
505
|
-
${
|
|
505
|
+
${fu()}
|
|
506
506
|
${i}
|
|
507
|
-
</script>`}function hl(e,n,r,i=!1){if(!
|
|
508
|
-
`+l.slice(f);else l+=u;return l}function
|
|
507
|
+
</script>`}function hl(e,n,r,i=!1){if(!dr(e))return e;let a=cu(e);if(a.length===0)return e;let l=gu(e,a),u=du(a,n,i),f=c(l);if(f!==-1)l=l.slice(0,f)+u+`
|
|
508
|
+
`+l.slice(f);else l+=u;return l}function gu(e,n){let r=[],i=0;for(let[l,u]of Fo(e).entries()){let f=n[l];if(!f)break;r.push(e.slice(i,u.startIndex));let v=Ss(u.attributes,"data-stx-scope");if(v)f.id=v,f.selector=`[data-stx-scope="${f.id}"]`,r.push(u.fullMatch);else r.push(`<${u.tagName} data-stx-scope="${f.id}"${u.attributes}>`);i=u.endIndex}r.push(e.slice(i));let a=r.join("");return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a=a.replace(/\s*x-destroy\s*=\s*"([^"]*)"/g,' data-stx-xdestroy="$1"'),a=a.replace(/\s*x-destroy\s*=\s*'([^']*)'/g," data-stx-xdestroy='$1'"),a}function dr(e){return/x-data\s*=\s*["']/.test(e)}function lo(e,n){let r=e,i=/@json\s*\(/g,a;while((a=i.exec(r))!==null){let l=a.index,u=l+a[0].length-1,f=1,v=u+1,S=null,I=!1;while(v<r.length&&f>0){let U=r[v];if(I){I=!1,v++;continue}if(U==="\\"&&S){I=!0,v++;continue}if(S){if(U===S)S=null;v++;continue}if(U==='"'||U==="'"||U==="`"){S=U,v++;continue}if(U==="(")f++;else if(U===")"){if(f--,f===0)break}v++}if(f!==0)break;let j=r.substring(u+1,v).trim(),L=r.substring(l,v+1),M=-1,V=0,W=null,Z=!1;for(let U=0;U<j.length;U++){let H=j[U];if(Z){Z=!1;continue}if(H==="\\"&&W){Z=!0;continue}if(W){if(H===W)W=null;continue}if(H==='"'||H==="'"||H==="`"){W=H;continue}if(H==="("||H==="["||H==="{")V++;else if(H===")"||H==="]"||H==="}")V--;if(H===","&&V===0){M=U;break}}let q=M>=0?j.substring(0,M).trim():j,X=M>=0?j.substring(M+1).trim():void 0;try{let U=q.trim(),H;if(m(U))H=p(U,Object.keys(n))(...Object.values(n));else H=void 0;let re;if(X==="true")re=JSON.stringify(H,null,2);else re=JSON.stringify(H);let ce=re.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");r=r.substring(0,l)+ce+r.substring(v+1),i.lastIndex=l+ce.length}catch(U){K.log(U instanceof Error?U:Error(String(U)),{directive:"@json"},"error"),i.lastIndex=l+L.length}}return r}function uo(e){return e.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function yl(e){let n=e,r=/@memo\s*\(/g,i,a=[];while((i=r.exec(n))!==null){let l=i.index,u=l+i[0].length,f=1,v=u;while(v<n.length&&f>0){if(n[v]==="(")f++;else if(n[v]===")")f--;v++}if(f!==0)continue;let S=n.slice(u,v-1).trim(),I=v,j=n.slice(I),L=j.indexOf("@endmemo");if(L===-1)continue;let M=j.slice(0,L),V=I+L+8,W=Vt(M),Z=M.slice(W),q=M.match(/(\s*)$/),X=q?q[0].length:0,U=Z.slice(0,Z.length-X),H=U.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),re;if(H){let[ce,le,pe="",Re]=H,Ae=`<${le}${pe} data-stx-memo="${S}"${Re}>`;re=M.slice(0,W)+Ae+U.slice(ce.length)+M.slice(W+U.length)}else re=`${M.slice(0,W)}<div data-stx-memo="${S}">${U}</div>${M.slice(W+U.length)}`;a.push({start:l,end:V,replacement:re}),r.lastIndex=V}for(let l=a.length-1;l>=0;l--){let u=a[l];n=n.slice(0,u.start)+u.replacement+n.slice(u.end)}return n.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Hi(e){let n=e.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return n=n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),n}function Ko(e,n){let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=x(e,(f,v)=>{r.lastIndex=v;let S=r.exec(f);if(!S||/^(?:script|style)$/i.test(S[1]))return-1;return r.lastIndex}),a=[],l=0,u=[];for(let{start:f,end:v,token:S}of i){let I=/^<\/?([\w-]+)/.exec(S)[1].toLowerCase();if(S.startsWith("</")){while(a.length&&a.pop()!==I);continue}if(!a.length&&!/\sdata-stx-slot-owner\s*=/.test(S))u.push(e.slice(l,f),S.replace(/\s*\/?>$/,(j)=>` data-stx-slot-owner="${n}"${j}`)),l=v;if(!gr.has(I)&&!/\/>$/.test(S))a.push(I)}return u.push(e.slice(l)),u.join("")}function qo(e,n){if(!/\bref\s*=/.test(e))return e;let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=x(e,(v,S)=>{r.lastIndex=S;let I=r.exec(v);if(!I||/^(?:script|style)$/i.test(I[1]))return-1;return r.lastIndex}),a=[],l=0,u=0,f=[];for(let{start:v,end:S,token:I}of i){let j=/^<\/?([\w-]+)/.exec(I)[1].toLowerCase();if(I.startsWith("</")){let W;while(W=a.pop()){if(W.scoped)l--;if(W.name===j)break}continue}let L=/\sdata-stx-scope\s*=/.test(I),M=/\sdata-stx-ref-caller\s*=\s*(["'])(.*?)\1/.exec(I),V=a.find((W)=>W.scoped)?.scopeId;if(M&&V&&M[2]===V)f.push(e.slice(u,v),I.replace(M[0],` data-stx-ref-caller="${n}"`)),u=S;else if(!l&&!L&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(I)&&!/\sdata-stx-ref-caller\s*=/.test(I))f.push(e.slice(u,v),I.replace(/\s*\/?>$/,(W)=>` data-stx-ref-caller="${n}"${W}`)),u=S;if(!gr.has(j)&&!/\/>$/.test(I)){let W=/\sdata-stx-scope\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(I);if(a.push({name:j,scoped:L,scopeId:W?.[1]??W?.[2]}),L)l++}}return f.push(e.slice(u)),f.join("")}var gr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Zo=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,Vo=/<\/?\s*([a-z][\w-]*)/iy,mu=/\s/;function hu(e,n){let r=n-1;while(r>=0&&mu.test(e[r]))r--;return r>=0&&e[r]==="/"}function xu(e,n){let r=!1,i=!1;for(let a=n;a<e.length;a++){let l=e[a];if(r){if(l==="'")r=!1}else if(i){if(l==='"')i=!1}else if(l==="'")r=!0;else if(l==='"')i=!0;else if(l===">")return a}return-1}function bu(e,n){if(e.indexOf("{",n)===-1||e.indexOf("}",n)===-1)return!1;let r=0,i=n,a=!1,l=!1,u=!1;while(i<e.length){let f=e.indexOf("<",i),v=f===-1?e.length:f;if(v>i){if(r===0)while(i<v){let j=e.indexOf(l?"}":"{",i);if(j===-1||j>=v){if(l)u=!1;else a=!1;break}if(j>i)if(l)u=!1;else a=!1;if(l){if(u)return!0;u=!0}else if(a)l=!0,u=!1;else a=!0;i=j+1}i=v;continue}if(e.startsWith("<!--",i)){let j=e.indexOf("-->",i);i=j===-1?e.length:j+3;continue}let S=xu(e,i);if(S===-1)break;Vo.lastIndex=i;let I=Vo.exec(e)?.[1]?.toLowerCase()??"";if(e[i+1]==="/"){if(r===0)break;r--}else if(!hu(e,S)&&!gr.has(I))r++;i=S+1}return!1}var Uo=k(256);function bl(e){if(e.length<1024)return Ho(e);let n=E(e),r=Uo.get(n);if(r!==void 0)return r;let i=Ho(e);return Uo.set(n,i),i}function Ho(e){if(e.length>=32768&&!Ci(e))return e;let r=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),i="",a=0,l;while((l=r.exec(e))!==null){let u=l.index,f=u+l[0].length,v=!1,S=!1,I=-1;while(f<e.length){let L=e[f];if(v){if(L==="'")v=!1}else if(S){if(L==='"')S=!1}else if(L==="'")v=!0;else if(L==='"')S=!0;else if(L===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(u,I+1);if(Zo.test(j))continue;if(j.includes("x-cloak"))continue;if(bu(e,I+1))i+=e.slice(a,I)+" x-cloak>",a=I+1}return i+=e.slice(a),i}var yu=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,_u=/<\/script>/gi,wu=/<\/style>/gi;function wl(e){let n=/<[a-z][\w-]*/gi,r="",i=0,a;while((a=n.exec(e))!==null){let l=a.index,u=a[0].slice(1).toLowerCase();if(u==="script"||u==="style"){let V=u==="script"?_u:wu;V.lastIndex=l;let W=V.exec(e);if(W!==null)n.lastIndex=W.index+W[0].length;continue}let f=l+a[0].length,v=!1,S=!1,I=-1;while(f<e.length){let V=e[f];if(v){if(V==="'")v=!1}else if(S){if(V==='"')S=!1}else if(V==="'")v=!0;else if(V==='"')S=!0;else if(V===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(l+a[0].length,I);if(Zo.test(j))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(j))continue;if(!yu.test(j))continue;let L=e[I-1]==="/",M=L?I-1:I;r+=`${e.slice(i,M)} x-cloak${L?" ":""}`,i=M}return r+=e.slice(i),r}function O(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function kt(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}import wa from"path";import mr from"fs";import Vn from"path";function Jo(e,n,r,i){let a=0;for(let l=n;l<e.length;l++)if(e[l]===r)a++;else if(e[l]===i&&!(i===">"&&e[l-1]==="=")){if(--a===0)return l}return-1}function vu(e){let n=t(e),r=0,i=0,a=[];for(let l=0;l<n.length;l++)if("([{".includes(n[l]))r++;else if(")]}".includes(n[l]))r--;else if(n[l]===","&&r===0)a.push(e.slice(i,l).trim()),i=l+1;return a.push(e.slice(i).trim()),a}function Fn(e,n,r=!1){let i=t(e),a=new RegExp(`\\b(?:${n.map((u)=>u.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),l=r?h(i).depths:void 0;for(let u of i.matchAll(a)){if(l&&l[u.index]!==0)continue;let f=u.index+u[0].length,v="";if(i[f]==="<"){let I=Jo(i,f,"<",">");if(I<0)continue;v=e.slice(f+1,I),f=I+1;while(/\s/.test(i[f]||"")&&f<i.length)f++}if(i[f]!=="(")continue;let S=Jo(i,f,"(",")");if(S>=0)return{type:v,args:vu(e.slice(f+1,S)),start:u.index,end:S+1}}return null}var $s=`
|
|
509
509
|
type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
|
|
510
510
|
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
511
511
|
type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
|
|
@@ -513,21 +513,21 @@ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K
|
|
|
513
513
|
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
514
514
|
type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
|
|
515
515
|
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
516
|
-
`;function
|
|
517
|
-
`)}),u=
|
|
516
|
+
`;function Es(e,n){let r=[],i={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},a=t(e),l=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(L,M,V,W,Z)=>{if(a.slice(Z,Z+6)!=="import")return L;if(W.endsWith(".stx"))return"";let q=`${n}Import${r.length}`;if(r.push(`import * as ${q} from ${JSON.stringify(W)};`),M.startsWith("*"))return`import ${M.replace(/^\*\s+as\s+/,"")} = ${q};`;if(!M.startsWith("{"))return`import ${M} = ${q}.default;`;return M.slice(1,-1).split(",").map((X)=>{let[U,H=U]=X.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!U)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(W)&&U in i)i[U].push(H);return`import ${H} = ${q}.${U};`}).join(`
|
|
517
|
+
`)}),u=Fn(e,i.defineProps),f=Fn(e,i.defineEmits),v=Fn(e,i.withDefaults);if(!u&&!f)return{declarations:"",props:null,events:null};let S=[],I=null,j=null;if(u){S.push(`const __options = (${u.args[0]||"{}"}) as const;`),S.push(`const __defaults = (${v?.args[1]||"{}"});`);let L=u.type||"__StxOptions<typeof __options>";S.push(`export type __StxProps = __StxDefaults<${L}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),I=`${n}.__StxProps`}if(f)S.push(`const __events = (${f.args[0]||"[]"}) as const;`),S.push(`export type __StxEvents = ${f.type||"Record<(typeof __events)[number], any[]>"};`),j=`${n}.__StxEvents`;return{declarations:`${r.join(`
|
|
518
518
|
`)}
|
|
519
519
|
namespace ${n} {
|
|
520
520
|
${l}
|
|
521
521
|
${S.join(`
|
|
522
522
|
`)}
|
|
523
|
-
}`,props:I,events:j}}var Br=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Fr(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Br].some((n)=>n.toLowerCase()===e.toLowerCase());return Br.has(e)||/[A-Z]/.test(e)}function*
|
|
523
|
+
}`,props:I,events:j}}var Br=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Fr(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Br].some((n)=>n.toLowerCase()===e.toLowerCase());return Br.has(e)||/[A-Z]/.test(e)}function*Su(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let i=n.lastIndex,a=[];while(i<e.length){while(/\s/.test(e[i]||""))i++;if(e[i]===">"||e.slice(i,i+2)==="/>"){i+=e[i]===">"?1:2;break}let l=/^[^\s=/>]+/.exec(e.slice(i))?.[0];if(!l){i++;continue}let u=i;i+=l.length;while(/\s/.test(e[i]||""))i++;if(e[i]!=="="){a.push({name:l,value:!0,offset:u,braced:!1});continue}i++;while(/\s/.test(e[i]||""))i++;let f=e[i],v=f==="{",S=f==='"'||f==="'";if(S||v)i++;let I=i;if(v){let j=t(e.slice(i)),L=1,M=0;for(;M<j.length;M++){if(j[M]==="{")L++;if(j[M]==="}"&&--L===0)break}i+=M}else if(S)while(i<e.length&&e[i]!==f)i++;else while(i<e.length&&!/[\s/>]/.test(e[i]))i++;if(a.push({name:l,value:e.slice(I,i),offset:I,braced:v}),S||v)i++}n.lastIndex=i,yield{name:r[1],offset:r.index,attributes:a}}}function Xo(e,n,r){let i=[],a=[$s,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],l=new Map,u=new Map,f=new Map,v=r.scriptCode(e,r.filePath),S=t(v);for(let V of v.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(S.slice(V.index,V.index+6)!=="import")continue;let W=V[2],Z=Vn.isAbsolute(W)||W.startsWith(".")?Vn.resolve(Vn.dirname(r.filePath),W):Zs(W,Vn.dirname(r.filePath));if(!Z)continue;let q=Z.endsWith(".stx")?Z:mr.existsSync(`${Z}.stx`)?`${Z}.stx`:void 0,X=q?null:Nr(Z,!1),U=V[1].startsWith("{")?V[1].slice(1,-1).split(","):[V[1]];for(let H of U){let[re,ce=re]=H.trim().split(/\s+as\s+/),le=q||X?.get(re)||X?.get(re.toLowerCase());if(le)f.set(ce,le),f.set(ce.toLowerCase(),le),f.set(ce.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),le)}}for(let V of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let W of V[1].matchAll(/['"]([^'"]+)['"]/g)){let Z=Qs(W[1],r.filePath,r).find((q)=>mr.statSync(q,{throwIfNoEntry:!1})?.isFile());if(Z)f.set(Vn.basename(W[1]).replace(/\.stx$/,""),Z)}let I={__importedComponents:f},j=new Map,L=(V,W,Z)=>{let q=e.slice(0,V);return{code:W,offset:V,attribute:Z,anchor:!0,kind:"directive",line:q.split(`
|
|
524
524
|
`).length,column:V-q.lastIndexOf(`
|
|
525
|
-
`)}},M=(V,W,Z)=>i.push({expression:V,statement:{text:W+V.code+Z,prefixLength:W.length}});for(let V of
|
|
526
|
-
`):"",checks:i,events:l,dependencies:u}}import
|
|
527
|
-
`,!0)){if(l.startsWith("(")){let j=_t(l,0,"(",")");if(j<0)continue;let L=gt(l.slice(1,j-1),",",!0),M=L.shift()||"",V=M.indexOf(":");if(V<0)continue;for(let W of gt(M.slice(V+1),"|",!0)){let Z=
|
|
528
|
-
`),v=
|
|
525
|
+
`)}},M=(V,W,Z)=>i.push({expression:V,statement:{text:W+V.code+Z,prefixLength:W.length}});for(let V of Su(n)){if(Fr(V.name)||V.name==="component")continue;let W=li(V.name,r.filePath,r,I);if(!W)continue;let Z=j.get(W);if(!Z){let X;try{X=r.readComponent?r.readComponent(W):mr.readFileSync(W,"utf8")}catch{continue}if(X===void 0)continue;u.set(W,X),Z=Es(r.scriptCode(X,W),`__StxComponent${j.size}`),j.set(W,Z),a.push(Z.declarations)}let q=[];for(let X of V.attributes){let{name:U,offset:H}=X,re=X.value===!0?"true":X.value;if(U.startsWith("@")||U.startsWith("v-on:")){if(Z.events&&X.value!==!0)l.set(H,`__StxEvent<${Z.events}, ${JSON.stringify(U.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ce=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(U);if(U.startsWith("v-")&&!U.startsWith("v-bind:")&&!ce)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(U))continue;let le=(ce?ce[1]||"modelValue":U.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(we,fe)=>fe.toUpperCase());if(q.push(le),!Z.props)continue;let pe=U.startsWith(":")||U.startsWith("v-bind:")||!!ce||X.braced,Re=pe?re:X.value!==!0?JSON.stringify(re):"true",Ae=!pe&&X.value!==!0&&(re==="true"||re==="false");M(L(H,Re,U),";void ((",`) satisfies ${Ae?"__StxStaticProp":"__StxProp"}<${Z.props}, ${JSON.stringify(le)}>);`)}if(Z.props){let X=[...new Set(q)].map((H)=>`${JSON.stringify(H)}: undefined as any`).join(", "),U=L(V.offset,`<${V.name}>`);i.push({expression:U,statement:{text:`;void ({ ${X} } satisfies ${Z.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:j.size?a.join(`
|
|
526
|
+
`):"",checks:i,events:l,dependencies:u}}import ua from"fs";import wt from"path";var ht=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function $u(e){let n=new be(e,"javascript").tokenize(),r=e;for(let i of n.reverse())if(i.type==="COMMENT")r=r.slice(0,i.start)+i.value.replace(/[^\r\n]/g," ")+r.slice(i.end);return r}function _t(e,n,r,i){if(e[n]!==r)return-1;let a=0,l=null;for(let u=n;u<e.length;u++){let f=e[u];if(l){if(f==="\\"){u++;continue}if(f===l)l=null;continue}if(f==="'"||f==='"'||f==="`"){l=f;continue}if(f===r)a++;else if(f===i){if(i===">"&&e[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function gt(e,n,r){let i=r?"([{<":"([{",a=r?")]}>":")]}",l=[],u=0,f=null,v="";for(let S=0;S<e.length;S++){let I=e[S];if(f){if(v+=I,I==="\\"){v+=e[++S]??"";continue}if(I===f)f=null;continue}if(I==="'"||I==='"'||I==="`"){f=I,v+=I;continue}if(i.includes(I))u++;else if(a.includes(I)&&!(r&&I===">"&&e[S-1]==="="))u--;if(u===0&&n.includes(I)){l.push(v),v="";continue}v+=I}return l.push(v),l.map((S)=>S.trim()).filter(Boolean)}function Eu(e){let n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r=null;continue}if(a==="'"||a==='"'||a==="`"){r=a;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;if(n!==0||a!=="=")continue;let l=e[i-1];if(e[i+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return i}return-1}function Go(e){switch(e.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function fn(e){let n=$u(e);for(let r of new Set(Hn(n).map((i)=>i.start))){let i=ku(n,r);if(i)return{...i,text:e.slice(r,r+i.text.length)}}return null}function ku(e,n){let r=Object.create(null),i=Object.create(null),a=[],l=Object.create(null),u=Object.create(null),f=n+(/^(?:const|let|var)\s+/.exec(e.slice(n))?.[0].length??0),v=()=>{while(f<e.length&&/\s/.test(e[f]))f++},S;if(e[f]==="{"){let q=_t(e,f,"{","}");if(q===-1)return null;S=e.slice(f,q),f=q}else{let q=/^[A-Za-z_$][\w$]*/.exec(e.slice(f));if(!q)return null;S=q[0],f+=q[0].length}if(v(),e[f]!=="=")return null;f++,v();let I=/^withDefaults\s*\(\s*/.exec(e.slice(f)),j=Boolean(I);if(I)f+=I[0].length;let L=/^defineProps\b/.exec(e.slice(f));if(!L)return null;f+=L[0].length;let M="";if(v(),e[f]==="<"){let q=_t(e,f,"<",">");if(q===-1)return null;M=e.slice(f+1,q-1).trim(),f=q}if(v(),e[f]!=="(")return null;let V=_t(e,f,"(",")");if(V===-1)return null;let W=e.slice(f+1,V-1).trim();if(f=V,j){if(v(),e[f]===",")f++,v();if(e[f]==="{"){let q=_t(e,f,"{","}");if(q===-1)return null;for(let[X,U]of ks(e.slice(f,q)))i[X]=U;f=q}if(v(),e[f]===",")f++,v();if(e[f]===")")f++}if(e[f]===";")f++;let Z=/^[A-Za-z_$][\w$]*$/.test(M)?M:void 0;if(M.startsWith("{"))for(let q of gt(M.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let X=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(q);if(X)r[X[1]]=X[2].trim()}if(W.startsWith("{"))for(let[q,X]of ks(W)){if(a.push(q),!X.startsWith("{")){let U=Go(X);if(U)r[q]=U;continue}for(let[U,H]of ks(X))if(U==="default")i[q]=H;else if(U==="type"){let re=Go(H);if(re)r[q]=re}}else if(W.startsWith("["))for(let q of gt(W.slice(1,-1),",",!1))a.push(q.replace(/^['"`]/,"").replace(/['"`]$/,""));if(S.startsWith("{")){a.length=0;for(let q of gt(S.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let X=Eu(q),U=X===-1?q:q.slice(0,X),H=U.split(":")[0].trim().replace(/^\.\.\./,"");if(!H)continue;a.push(H),l[H]=U.trim();let re=U.split(":").at(-1).trim();if(/^[A-Za-z_$][\w$]*$/.test(re))u[H]=re;if(X!==-1)i[H]=q.slice(X+1).trim()}}else if(a.length===0)a.push(...Object.keys(r));return{text:e.slice(n,f),propNames:a,propBindings:l,localBindings:u,defaults:i,declared:r,typeName:Z,identifier:S.startsWith("{")?void 0:S}}function ks(e){let n=e.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],i=0;while(i<n.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=i;let l=a.exec(n);if(!l)break;i=a.lastIndex;let u=0,f="",v=i;while(i<n.length){let I=n[i];if(f){if(I==="\\")i++;else if(I===f)f=""}else if(I==="'"||I==='"'||I==="`")f=I;else if(I==="{"||I==="["||I==="(")u++;else if(I==="}"||I==="]"||I===")")u--;else if(I===","&&u===0)break;i++}let S=n.slice(v,i).trim();if(S)r.push([l[1],S]);i++}return r}function hr(e){let n=/^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/,r=/^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;if(!n.test(e)&&!r.test(e))throw Error("Invalid prop number");return Number(e.replaceAll("_",""))}function Cs(e){let n=new be(e,"javascript").tokenize().filter((a)=>!["COMMENT","WHITESPACE","EOF"].includes(a.type)),r=0;function i(a){if(a>64)throw Error("Prop literal too deep");let l=n[r++];if(!l)throw Error("Missing prop literal");if(l.type==="STRING"||l.type==="TEMPLATE_STRING"){let I=yt(l.value);if(I===null)throw Error("Dynamic prop string");return I}if(l.type==="NUMBER")return hr(l.value);if(l.value==="-"||l.value==="+"){let I=n[r++];if(I?.type!=="NUMBER")throw Error("Dynamic prop number");return(l.value==="-"?-1:1)*hr(I.value)}if(l.value==="true")return!0;if(l.value==="false")return!1;if(l.value==="null")return null;if(l.value==="undefined")return;if(l.value!=="["&&l.value!=="{")throw Error("Dynamic prop default");let u=l.value==="[",f=u?"]":"}",v=[],S=[];while(n[r]?.value!==f){if(u)S.push(i(a+1));else{let I=n[r++];if(!I||!["STRING","IDENTIFIER","NUMBER"].includes(I.type))throw Error("Dynamic prop key");let j=I.type==="STRING"?yt(I.value):I.type==="NUMBER"?String(hr(I.value)):I.value;if(j===null||n[r++]?.value!==":")throw Error("Dynamic prop key");v.push([j,i(a+1)])}if(n[r]?.value!==",")break;r++}if(n[r++]?.value!==f)throw Error("Unclosed prop literal");return u?S:Object.fromEntries(v)}try{let a=i(0);return r===n.length?a:void 0}catch{return}}function Rs(e,n){let r=t(e),i=h(r).depths,a=/\b(interface|type)\s+([A-Za-z_$][\w$]*)\b/g;for(let l of r.matchAll(a)){if(l[2]!==n||i[l.index]!==0)continue;let u=l.index+l[0].length,f=r.indexOf("{",u);if(l[1]==="interface"&&f>=0){let v=_t(r,f,"{","}");if(v>=0)return e.slice(f,v)}if(l[1]==="type"){let v=r.indexOf("=",u);if(v<0)continue;let S=e.slice(v+1).trimStart();if(S[0]==="{"){let I=_t(S,0,"{","}");if(I>=0)return S.slice(0,I)}}}}function As(e){let n=e.trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:yt(n)??void 0}function Yo(e){let n=gt(e.trim().slice(1,-1),",",!0);if(n.length!==1)return e.trim();let r=n[0];if(r.startsWith("..."))return e.trim();let i=/^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(r),a=i?!!i[1]:r.endsWith("?"),l=i?i[2]:a?r.slice(0,-1).trim():r;return a?`(${l}) | undefined | []`:l}function Un(e){let n=Fn(e,["defineEmits"],!0);if(!n)return null;let r=Object.create(null),i=/^[A-Za-z_$][\w$]*$/.test(n.type.trim())?n.type.trim():void 0,a=i?Rs(e,i):n.type.trim();if(a?.startsWith("{"))for(let l of gt(a.slice(1,-1),`;,
|
|
527
|
+
`,!0)){if(l.startsWith("(")){let j=_t(l,0,"(",")");if(j<0)continue;let L=gt(l.slice(1,j-1),",",!0),M=L.shift()||"",V=M.indexOf(":");if(V<0)continue;for(let W of gt(M.slice(V+1),"|",!0)){let Z=As(W);if(Z!==void 0)r[Z]={detailType:Yo(`[${L.join(", ")}]`)}}continue}let u=new be(l,"javascript").tokenize().filter((j)=>!["WHITESPACE","COMMENT","EOF"].includes(j.type)),f=u[0],v=u.findIndex((j)=>j.value===":");if(!f||v<0)continue;let S=As(f.value),I=l.slice(u[v].end).trim();if(S!==void 0)r[S]={detailType:I.startsWith("[")?Yo(I):I}}else{let l=n.args[0]?.trim()||"";if(l.startsWith("["))for(let u of gt(l.slice(1,-1),",",!1)){let f=As(u);if(f!==void 0)r[f]={detailType:"unknown"}}else if(l.startsWith("{"))for(let u of gt(l.slice(1,-1),",",!1)){let f=new be(u,"javascript").tokenize().find((S)=>!["WHITESPACE","COMMENT"].includes(S.type)),v=f&&As(f.value);if(v!==void 0)r[v]={detailType:"unknown"}}}return{...n,text:e.slice(n.start,n.end),typeName:i,events:r}}import{mkdir as Qo,readFile as Cu,readdir as Ru,realpath as Au,stat as ea,writeFile as Tu}from"fs/promises";import rt from"path";import{builtinModules as Iu}from"module";function aa(e){if(e==="connectedCallback")return`method "${e}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(e==="disconnectedCallback")return`method "${e}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${e}" is reserved`}var ca=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]),Ou=new Set(Iu);function ju(e){return e.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function br(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Pu(e){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(e)&&!e.startsWith("xml")&&!/[A-Z]/.test(e)}function Mu(e){if(e===!0)return"open";if(e==="open"||e==="closed")return e;return!1}async function Du(e){let n=[];async function r(i){let a=await Ru(i,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=rt.join(i,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(e),n}function Yt(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function yr(e){for(let n of ee(Yt(e))){let r=O(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function _r(e,n){let r=yr(e);if(!r)return{};let i=r.code.trim();if(!i)return{};try{let a=JSON.parse(i);if(!a||typeof a!=="object"||Array.isArray(a))throw Error("expected a JSON object");return a}catch(a){throw Error(`${n}: <script component> must contain JSON metadata (${a.message})`)}}function Ts(e,n){let r=t(e),i=new Set(Hn(e).map((v)=>v.start)),a=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,l=[],u=n?void 0:new Bun.Transpiler({loader:"ts"}),f;while(f=a.exec(r)){if(!i.has(f.index+f[0].indexOf("function")))continue;let v=a.lastIndex;while(/\s/.test(r[v]||""))v++;let S=v;if(r[v]==="<")v=_t(r,v,"<",">");if(v<0)continue;let I=e.slice(S,v).trim();while(/\s/.test(r[v]||""))v++;if(r[v]!=="(")continue;let j=v,L=_t(r,v,"(",")");if(L<0)continue;for(v=L;v<e.length;v++){let M=r[v];if(M!=="{"&&M!==";")continue;let V=e.slice(f.index,v).trim();if(n){if(!n(V,M,f[1]))continue}else{let Z;try{Z=u.transformSync(V+(M==="{"?"{}":";"))}catch{continue}if(M==="{"&&!Z.includes(`function ${f[1]}(`))continue;if(M===";"&&Z.trim())continue}let W=M==="{"?_t(r,v,"{","}"):v+1;if(W<0)break;l.push({name:f[1],header:V,generic:I,parameterOffset:j+1,parameters:e.slice(j+1,L-1),returns:e.slice(L,v).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(f[0]),...M==="{"?{source:e.slice(f.index,W)}:{}}),a.lastIndex=W;break}}return l}function Nu(e){let n=gt(e.parameters,",",!0).flatMap((r,i)=>{let a=t(r),l=0,u=-1;for(let W=0;W<a.length;W++){let Z=a[W];if("([{<".includes(Z))l++;else if(")]}>".includes(Z)&&!(Z===">"&&a[W-1]==="="))l--;if(Z==="="&&l===0&&a[W+1]!==">"){u=W;break}}let f=(u<0?r:r.slice(0,u)).trim(),v=gt(f,":",!0),S=v.shift().trim();if(S==="this")return[];let I=/^[A-Za-z_$]|^\.\.\./.test(S)?S:`argument${i}`,j=u<0?"":r.slice(u+1).trim(),L=j==="true"||j==="false"?"boolean":/^-?\d+(?:\.\d+)?$/.test(j)?"number":/^['"`]/.test(j)?"string":I.startsWith("...")?"unknown[]":"unknown",M=v.join(":").trim()||L,V=u>=0&&!I.endsWith("?")&&!I.startsWith("...")?"?":"";return[`${I}${V}: ${M}`]}).join(", ");return`${e.name}${e.generic}(${n}): ${e.returns||(e.async?"Promise<unknown>":"unknown")}`}function Lu(e,n){let r={},i={},a=[],l=[],u=ee(Yt(e)).map((W)=>({code:e.slice(W.bodyStart,W.bodyEnd),attributes:O(W.attrs)})).filter(({attributes:W})=>!["src","server","component","stx:component"].some((Z)=>W.has(Z))&&kt(W)),f=u.map((W)=>W.code).join(`
|
|
528
|
+
`),v=fn(f),S=Un(f);for(let W of u){let{code:Z}=W;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z)}catch(le){throw Error(`${n}: failed to transpile <script client> (${le.message})`)}let q=Ts(Z),X=new Set(q.filter((le)=>!le.source).map((le)=>le.name));for(let le of q){if(ca.has(le.name))throw Error(`${n}: client ${aa(le.name)}`);if(le.source)r[le.name]=`${le.name}(...args) { return this._callScopeMethod(${JSON.stringify(le.name)}, args); }`;if(!le.source||!X.has(le.name))(i[le.name]??=[]).push(Nu(le))}for(let le of Z.matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))l.push({binding:le[1].trim(),module:le[3]});let U=t(Z),H=h(U).depths,re=/(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g,ce;while(ce=re.exec(U)){if(H[ce.index]!==0)continue;let le=re.lastIndex,pe=0;for(;le<U.length;le++){let Fe=U[le];if(Fe==="{"){let it=_t(U,le,"{","}");if(it<0)break;if(le=it-1,ce[1]==="interface"&&pe===0){le++;break}continue}if("([<".includes(Fe))pe++;else if(")]>".includes(Fe)&&!(Fe===">"&&U[le-1]==="="))pe--;if(ce[1]==="type"&&pe===0&&(Fe===";"||Fe===`
|
|
529
529
|
`)){if(Fe===`
|
|
530
|
-
`&&/^[\s]*[|&]/.test(U.slice(le+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z.slice(ce.index,le));break}catch{}}}let Re=Z.slice(ce.index,le),Ae=ce.index,we=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(ce[0])?.[1],fe=u.map((Fe)=>{let it=Fe===W?Z.slice(0,Ae)+Z.slice(le):Fe.code;return t(it.replace(
|
|
530
|
+
`&&/^[\s]*[|&]/.test(U.slice(le+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z.slice(ce.index,le));break}catch{}}}let Re=Z.slice(ce.index,le),Ae=ce.index,we=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(ce[0])?.[1],fe=u.map((Fe)=>{let it=Fe===W?Z.slice(0,Ae)+Z.slice(le):Fe.code;return t(it.replace(fn(Fe.code)?.text??"\x00","").replace(Un(Fe.code)?.text??"\x00",""))}).join(`
|
|
531
531
|
`);if(!((v?.typeName===we||S?.typeName===we)&&!/^export\s/.test(Re)&&we&&!new RegExp(`\\b${we}\\b`).test(fe)))a.push(Re.replace(/^export\s+/,"").trim());re.lastIndex=le+1}}let I=Object.values(i).flat().join(`
|
|
532
532
|
`)+`
|
|
533
533
|
`+a.join(`
|
|
@@ -536,14 +536,14 @@ ${S.join(`
|
|
|
536
536
|
`),j=new be(I,"javascript").tokenize().filter((W)=>!["WHITESPACE","COMMENT"].includes(W.type)),L=new Set(j.filter((W,Z)=>{if(j[Z-1]?.value===".")return!1;let q=j[Z+1]?.value;return q!==":"&&!(q==="?"&&j[Z+2]?.value===":")}).map((W)=>W.value)),M=l.filter((W)=>(W.binding.match(/[A-Za-z_$][\w$]*/g)||[]).filter((Z)=>!["type","as"].includes(Z)).some((Z)=>L.has(Z)));for(let W of M)if(W.module.startsWith(".")||rt.isAbsolute(W.module))throw Error(`${n}: public method types import ${JSON.stringify(W.module)} outside the generated package; declare these types in the component or import them from a published dependency`);let V=[...new Set(M.map((W)=>`import type ${W.binding.replace(/\btype\s+/g,"")} from ${JSON.stringify(W.module)}`))];return{methods:r,declarations:i,types:a.join(`
|
|
537
537
|
|
|
538
538
|
`),typeImports:V.join(`
|
|
539
|
-
`)}}function
|
|
539
|
+
`)}}function zu(e){let n=e.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:e).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function ta(e){return[...e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].replace(/\r\n?/g,`
|
|
540
540
|
`).replaceAll("\x00","\uFFFD").trim()).filter(Boolean).join(`
|
|
541
541
|
|
|
542
|
-
`)}function
|
|
543
|
-
`)}function
|
|
544
|
-
`),a=[],l=[],u=Object.create(null),f=Object.create(null),v=Object.create(null),S=
|
|
545
|
-
`,!0)){let U=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:\s*([\s\S]+)$/.exec(X);if(!U)continue;if(v[U[1]]=U[2].trim(),!l.includes(U[1]))l.push(U[1])}}let j=
|
|
546
|
-
`))?.events||{},...n.events||l.events||{}},methods:{...Z,...q,...X.methods},methodDeclarations:X.declarations,declarationTypes:X.types,declarationImports:X.typeImports,eventTypes:L.eventTypes,handlers:L.handlers,scopeMethods:Object.keys(X.methods),bindings:M.bindings,slots:
|
|
542
|
+
`)}function Bu(e){if(!e)return null;let n=e.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function Wu(e){if(e===void 0)return"object";if(e==="true"||e==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(e))return"number";if(/^['"`]/.test(e))return"string";return"object"}function Kn(e,n){if(e[n]!=="(")return null;let r=0,i="";for(let a=n;a<e.length;a++){let l=e[a];if(i!==""){if(l==="\\")a++;else if(l===i)i="";continue}if(l==="'"||l==='"'||l==="`"){i=l;continue}if(l==="(")r++;else if(l===")"){if(r--,r===0)return{expression:e.slice(n+1,a),end:a+1}}}return null}function wr(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function Fu(e,n){let r=[],i=0,a=e.replace(/\{\{--[\s\S]*?--\}\}/g,""),l=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,u,f=(v)=>{if(v==="")return;let S=0,I=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}|(data-stx-on-[\w:-]+=")(\d+)(")/g,j;while(j=I.exec(v)){if(j.index>S)r.push(`out += ${JSON.stringify(v.slice(S,j.index))};`);r.push(j[3]!==void 0?`out += ${JSON.stringify(j[3])} + (this._handlers.push(${n[Number(j[4])]}) - 1) + ${JSON.stringify(j[5])};`:j[1]!==void 0?`out += __raw(${j[1]});`:`out += __escape(${j[2]});`),S=j.index+j[0].length}if(S<v.length)r.push(`out += ${JSON.stringify(v.slice(S))};`)};while(u=l.exec(a)){f(a.slice(i,u.index)),i=u.index+u[0].length;let S=u[1]==="if"||u[1]==="elseif"||u[1]==="foreach"?Kn(a,i):null;if(S)i=S.end,l.lastIndex=S.end;let I=S?.expression;switch(u[1]){case"if":r.push(`if (${I}) {`);break;case"elseif":r.push(`} else if (${I}) {`);break;case"else":r.push("} else {");break;case"endif":case"endforeach":r.push("}");break;case"foreach":{let j=wr(I||"");if(!j){r.push(`out += ${JSON.stringify(u[0]+(S?`(${I})`:""))};`);break}let{iterable:L,key:M,value:V}=j;r.push(M?`for (const [${M}, ${V}] of __entries(${L})) {`:`for (const ${V} of __values(${L})) {`);break}}}return f(a.slice(i)),r.join(`
|
|
543
|
+
`)}function la(e){let n=t(e),r=h(n).depths,i=[],a=[];for(let u of n.matchAll(/\bimport\b/g)){let f=u.index;if(r[f]!==0)continue;let v=new be(e.slice(f)).tokenize().filter((V)=>!["COMMENT","WHITESPACE"].includes(V.type));if(v[1]?.value==="("||v[1]?.value===".")continue;let S=v[1]?.type==="STRING"?1:-1,I=0;for(let V=1;S===-1&&V<v.length;V++){let W=v[V];if(W.value===";"||W.type==="EOF")break;if(W.value==="{")I++;else if(W.value==="}")I--;else if(I===0&&W.value==="from"&&v[V+1]?.type==="STRING")S=V+1}if(S===-1)continue;let j=v[S],L=S;if(v[L+1]?.value==="with"&&v[L+2]?.value==="{"){L+=2;let V=1;while(V&&v[L+1]?.type!=="EOF")if(L++,v[L]?.value==="{")V++;else if(v[L]?.value==="}")V--}if(v[L+1]?.value===";")L++;let M=f+v[L].end;if(a.push({start:f,end:M}),!["stx","@stacksjs/stx"].includes(j.value.slice(1,-1)))i.push(e.slice(f,M))}let l=e;for(let u of a.reverse())l=l.slice(0,u.start)+l.slice(u.end);return{imports:i,body:l}}function Vu(e){let r=ee(Yt(e)).filter((q)=>{let X=O(q.attrs);return kt(X)&&!["component","stx:component","server","src"].some((U)=>X.has(U))});if(!r.length)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{},apis:[]};let i=r.map((q)=>e.slice(q.bodyStart,q.bodyEnd)).join(`
|
|
544
|
+
`),a=[],l=[],u=Object.create(null),f=Object.create(null),v=Object.create(null),S=la(i);a.push(...S.imports),i=S.body;let I=fn(i);if(I)l.push(...I.propNames),Object.assign(u,I.propBindings),Object.assign(f,I.defaults),Object.assign(v,I.declared),i=i.replace(I.text,I.identifier?`const ${I.identifier} = this._props();`:"");if(I?.typeName){let q=Rs(i,I.typeName);if(q)for(let X of gt(q.slice(1,-1),`;,
|
|
545
|
+
`,!0)){let U=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:\s*([\s\S]+)$/.exec(X);if(!U)continue;if(v[U[1]]=U[2].trim(),!l.includes(U[1]))l.push(U[1])}}let j=Un(i);if(j)i=i.replace(j.text,"this._emitScope.bind(this)");let L=t(i),M=h(L).depths;for(let q of[...L.matchAll(/\bexport\s+(?=(?:interface|type|const|let|var|async|function)\b)/g)].reverse())if(M[q.index]===0)i=i.slice(0,q.index)+" ".repeat(q[0].length)+i.slice(q.index+q[0].length);let V=new Set(Hn(i).map((q)=>q.name)),W=t(i),Z=["state","derived","effect","batch","onMount","onDestroy"].filter((q)=>!V.has(q)&&new RegExp(`\\b${q}\\s*(?:<|\\()`).test(W));return{imports:a,body:i.trim(),propNames:l,propBindings:u,defaults:f,declared:v,apis:Z}}function Uu(e){let n=new Set,r=[];return{template:e.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([\s\S]*?)\3/gi,(a,l,u,f,v)=>{let S=l.toLowerCase();n.add(S);let I=(u||"").split(".").filter(Boolean).join(" "),j=r.length;return r.push(/^[A-Za-z_$][\w$]*$/.test(v.trim())?`($event) => (typeof ${v} === 'function' ? ${v} : this[${JSON.stringify(v.trim())}]).call(this, $event)`:`($event) => { ${v} }`),` data-stx-on-${S}="${j}"${I?` data-stx-mod-${S}="${I}"`:""}`}),eventTypes:[...n].sort(),handlers:r}}function Hu(e){let n=[];return{template:e.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(i,a,l,u)=>{let f=n.length;return n.push({id:f,name:a,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function Ku(e){let n=new Set;for(let r of e.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function qu(e){return[...new Set([...e.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function na(e,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${e}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function Zu(e,n,r){let i=rt.isAbsolute(n.file)?n.file:rt.resolve(e,n.file),a=await Cu(i,"utf8"),l=_r(a,i),u=rt.basename(i,".stx"),f=n.name||l.name||ju(u),v=`${br(r.prefix||"stx")}-${br(u)}`,S=n.tag||l.tag||v;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${i}: invalid component class name "${f}"`);if(!Pu(S))throw Error(`${i}: invalid custom-element tag "${S}"; tags must be lowercase and contain a hyphen`);let I=n.properties||l.properties||l.props||{},j=Object.fromEntries(Object.entries(I).map(([U,H])=>[U,na(U,H)])),L=Uu(zu(a)),M=Hu(L.template),V=Vu(a);for(let U of ee(Yt(a))){let H=O(U.attrs);if(!H.has("client")||["server","component","stx:component","src"].some((re)=>H.has(re))||!kt(H))continue;V.imports.push(...la(a.slice(U.bodyStart,U.bodyEnd)).imports)}V.imports=[...new Set(V.imports)];let W=Fu(M.template,L.handlers);for(let U of V.propNames){if(j[U])continue;let H=V.defaults[U];j[U]=na(U,{type:Bu(V.declared[U])??Wu(H),...H===void 0?{}:{default:Cs(H)}})}let Z=l.methods||{},q=n.methods||{},X=Lu(a,i);return{file:rt.relative(e,i),sourcePath:i,name:f,tag:S,description:n.description||l.description||"",template:M.template,styles:ta(a),shadowMode:Mu(n.shadowDOM??l.shadowDOM??r.shadowDOM),progressive:n.progressive??l.progressive??r.progressive??!0,properties:j,events:{...Un(ee(Yt(a)).filter((U)=>{let H=O(U.attrs);return kt(H)&&!["server","component","stx:component","src"].some((re)=>H.has(re))}).map((U)=>a.slice(U.bodyStart,U.bodyEnd)).join(`
|
|
546
|
+
`))?.events||{},...n.events||l.events||{}},methods:{...Z,...q,...X.methods},methodDeclarations:X.declarations,declarationTypes:X.types,declarationImports:X.typeImports,eventTypes:L.eventTypes,handlers:L.handlers,scopeMethods:Object.keys(X.methods),bindings:M.bindings,slots:Ku(M.template),cssProperties:qu(ta(a)),scope:V,render:W}}function sa(e=!1){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`${e?`import { state as nativeState, derived as nativeDerived, effect as nativeEffect, batch as nativeBatch } from './signals.js';
|
|
547
547
|
`:""}const HTMLElementBase = globalThis.HTMLElement || class {};
|
|
548
548
|
|
|
549
549
|
const escapeHTML = (value) => String(value ?? '')
|
|
@@ -949,7 +949,7 @@ export function defineComponent(Component, definition) {
|
|
|
949
949
|
}
|
|
950
950
|
return Component;
|
|
951
951
|
}
|
|
952
|
-
`}function
|
|
952
|
+
`}function xr(e,n="./runtime.js"){let r=JSON.stringify({tag:e.tag,template:e.template,styles:e.styles,shadowMode:e.shadowMode,progressive:e.progressive,properties:e.properties,eventTypes:e.eventTypes,bindings:e.bindings},null,2),i=Object.entries(e.methods).map(([I,j])=>{if(ca.has(I))throw Error(`${e.sourcePath}: ${aa(I)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(j.trim()))return` ${j.trim()}`;return` ${I}($event) {
|
|
953
953
|
${j}
|
|
954
954
|
}`}).join(`
|
|
955
955
|
|
|
@@ -981,8 +981,8 @@ ${i}${S}
|
|
|
981
981
|
|
|
982
982
|
defineComponent(${e.name}, ${r});
|
|
983
983
|
export default ${e.name};
|
|
984
|
-
`}function
|
|
985
|
-
`),r=new Set(new be(n).tokenize().map((L)=>L.value)),i=(L)=>{let M=L;while(r.has(M))M+="$";return r.add(M),M},a=i("__StxSupport"),l=i("__Methods"),u=i("__Details"),f=!!e.declarationTypes,v=Object.entries(e.properties).map(([L,M])=>` ${L}${M.required?"":"?"}: ${
|
|
984
|
+
`}function dn(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function Ju(e){let n=[e.declarationTypes,e.declarationImports,e.name,...Object.values(e.methodDeclarations).flat(),...Object.values(e.events).map((L)=>L.detailType)].join(`
|
|
985
|
+
`),r=new Set(new be(n).tokenize().map((L)=>L.value)),i=(L)=>{let M=L;while(r.has(M))M+="$";return r.add(M),M},a=i("__StxSupport"),l=i("__Methods"),u=i("__Details"),f=!!e.declarationTypes,v=Object.entries(e.properties).map(([L,M])=>` ${L}${M.required?"":"?"}: ${dn(M)}`).join(`
|
|
986
986
|
`),S=Object.entries(e.events).map(([L,M])=>` ${JSON.stringify(L)}: CustomEvent<${f?`${a}.${u}[${JSON.stringify(L)}]`:M.detailType||"unknown"}>`).join(`
|
|
987
987
|
`),I=Object.keys(e.methods).flatMap((L)=>e.methodDeclarations[L]||[`${L}($event?: Event): unknown`]).map((L)=>` ${L}`).join(`
|
|
988
988
|
`),j=f?`declare namespace ${a} {
|
|
@@ -1028,10 +1028,10 @@ declare global {
|
|
|
1028
1028
|
}
|
|
1029
1029
|
|
|
1030
1030
|
export default ${e.name}
|
|
1031
|
-
`}function
|
|
1031
|
+
`}function Xu(e){return`declare global {
|
|
1032
1032
|
namespace JSX {
|
|
1033
1033
|
interface IntrinsicElements {
|
|
1034
|
-
${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${
|
|
1034
|
+
${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${dn(u)}`).join(`
|
|
1035
1035
|
`),a=Object.keys(r.events).map((l)=>` ${`on${l.split(/[-:]/).map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join("")}`}?: (event: import('./${r.tag}.js').${r.name}EventMap[${JSON.stringify(l)}]) => void`).join(`
|
|
1036
1036
|
`);return` ${JSON.stringify(r.tag)}: {
|
|
1037
1037
|
${i}
|
|
@@ -1047,9 +1047,9 @@ ${a}
|
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
1049
|
export {}
|
|
1050
|
-
`}function
|
|
1050
|
+
`}function Gu(e){return{schemaVersion:"1.0.0",modules:e.map((n)=>({kind:"javascript-module",path:`./${n.tag}.js`,declarations:[{kind:"class",name:n.name,description:n.description||void 0,customElement:!0,tagName:n.tag,members:Object.entries(n.properties).map(([r,i])=>({kind:"field",name:r,description:i.description,type:{text:dn(i)},default:i.default===void 0?void 0:JSON.stringify(i.default),attribute:i.attribute===!1?void 0:i.attribute||br(r),reflects:i.reflect})),events:Object.entries(n.events).map(([r,i])=>({name:r,description:i.description,type:{text:`CustomEvent<${i.detailType||"unknown"}>`}})),slots:n.slots,cssProperties:n.cssProperties}],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:`./${n.tag}.js`}}]}))}}function ra(e){if(!e.styles)return"";let n=e.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(n))return n;return`@scope (${e.tag}) {
|
|
1051
1051
|
${n}
|
|
1052
|
-
}`}function
|
|
1052
|
+
}`}function ia(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Yu(e){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),i=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(e.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=e.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
|
|
1053
1053
|
`);return`const definitions = ${JSON.stringify(a,null,2)};
|
|
1054
1054
|
const escapeHTML = (value) => String(value ?? '')
|
|
1055
1055
|
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
@@ -1083,35 +1083,35 @@ export function renderComponent(tag, props = {}, slots = {}) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
1085
|
${l}
|
|
1086
|
-
`}async function cl(e){let n=rt.resolve(e.inputDir),r=rt.resolve(e.outputDir);if(!(await
|
|
1086
|
+
`}async function cl(e){let n=rt.resolve(e.inputDir),r=rt.resolve(e.outputDir);if(!(await ea(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let a=e.components?.length?e.components:(await Du(n)).map((U)=>({file:U}));if(!a.length)throw Error(`No .stx components found in ${n}`);let l=await Promise.all(a.map((U)=>Zu(n,U,e)));l.sort((U,H)=>U.tag.localeCompare(H.tag));let u=l.filter((U,H)=>l.findIndex((re)=>re.tag===U.tag)!==H);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=l.filter((U,H)=>l.findIndex((re)=>re.name===U.name)!==H);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Qo(r,{recursive:!0});let v=[],S=async(U,H)=>{let re=rt.join(r,U);if(await Qo(rt.dirname(re),{recursive:!0}),await Tu(re,typeof H==="string"&&!H.endsWith(`
|
|
1087
1087
|
`)?`${H}
|
|
1088
|
-
`:H),!v.includes(re))v.push(re);return re},I=l.some((U)=>U.scope.apis.length),j=import.meta.url.endsWith(".ts")?".ts":".js",L=new URL(`./signals-api${j}`,import.meta.url).pathname;if(I)await S("signals.js",`export * from ${JSON.stringify(L)};`);await S("runtime.js",
|
|
1088
|
+
`:H),!v.includes(re))v.push(re);return re},I=l.some((U)=>U.scope.apis.length),j=import.meta.url.endsWith(".ts")?".ts":".js",L=new URL(`./signals-api${j}`,import.meta.url).pathname;if(I)await S("signals.js",`export * from ${JSON.stringify(L)};`);await S("runtime.js",sa(I));for(let U of l){if(await S(`${U.tag}.js`,xr(U)),e.declarations!==!1)await S(`${U.tag}.d.ts`,Ju(U));if(e.css!==!1&&U.styles){let H=U.shadowMode?U.styles:ra(U);await S(`${U.tag}.css`,e.minify?ia(H):H)}}let M=new Bun.Transpiler({loader:"ts"});if(I||l.some((U)=>U.scope.imports.length||M.scanImports(xr(U)).some((H)=>H.kind==="dynamic-import"))){let U=l.map((we)=>rt.join(r,`${we.tag}.js`)),H=new Map(await Promise.all(U.map(async(we,fe)=>[await Au(we),l[fe]])));for(let[we,fe]of U.entries())H.set(fe,l[we]);let re=new Map(l.map((we)=>[rt.join(rt.dirname(we.sourcePath),`.stx-library-${we.tag}.ts`),we])),ce=rt.join(r,"runtime.js"),le=rt.join(r,"signals.js"),pe=rt.join(n,".stx-library-runtime.ts"),Re=rt.join(n,".stx-library-signals.ts");if(U.push(ce),I)U.push(le);let Ae=await Bun.build({entrypoints:U,outdir:r,root:r,target:"browser",format:"esm",splitting:!0,naming:{entry:"[name].js",chunk:"chunks/[name]-[hash].js"},minify:!1,loader:{".js":"ts"},plugins:[{name:"stx-element-runtime",setup(we){we.onResolve({filter:/.*/},(fe)=>{if(fe.path==="bun"||fe.path.startsWith("bun:")||fe.path.startsWith("node:")||Ou.has(fe.path))throw Error(`Server-only import ${JSON.stringify(fe.path)} is not available in a browser component (${fe.importer})`);let We=H.get(fe.path);if(!fe.importer&&We)return{path:rt.join(rt.dirname(We.sourcePath),`.stx-library-${We.tag}.ts`)};if(fe.path===ce)return{path:pe};if(fe.path===le||fe.importer===pe&&fe.path==="./signals.js")return{path:Re};if(/^(?:@stacksjs\/stx|stx)\/signals-api(?:\.[jt]s)?$/.test(fe.path))return{path:L}}),we.onLoad({filter:/\.ts$/},(fe)=>{if(fe.path===pe)return{contents:sa(I),loader:"ts"};if(fe.path===Re)return{contents:`export * from ${JSON.stringify(L)};`,loader:"ts"};let We=re.get(fe.path);if(We)return{contents:xr(We,ce),loader:"ts"}})}}]}).catch((we)=>{let fe=(we instanceof AggregateError?we.errors:[we]).map(String).join(`
|
|
1089
1089
|
`);throw Error(`Failed to bundle browser component imports
|
|
1090
1090
|
${fe}`)});if(!Ae.success)throw Error(`Failed to bundle component imports
|
|
1091
1091
|
${Ae.logs.map(String).join(`
|
|
1092
1092
|
`)}`);for(let we of Ae.outputs)await S(rt.relative(r,we.path),new Uint8Array(await we.arrayBuffer()))}let V=l.map((U)=>`export { ${U.name}, default as ${U.name}Element } from './${U.tag}.js';`).join(`
|
|
1093
|
-
`);if(await S("index.js",V),await S("ssr.js",
|
|
1094
|
-
`)),await S("custom-elements.d.ts",
|
|
1093
|
+
`);if(await S("index.js",V),await S("ssr.js",Yu(l)),e.declarations!==!1)await S("index.d.ts",l.map((U)=>`export * from './${U.tag}.js'`).join(`
|
|
1094
|
+
`)),await S("custom-elements.d.ts",Xu(l)),await S("ssr.d.ts",`${l.map((U)=>`export declare const render${U.name}: (props?: ${U.name}Props, slots?: Record<string, string>) => string`).join(`
|
|
1095
1095
|
`)}
|
|
1096
1096
|
export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
|
|
1097
1097
|
${l.map((U)=>`import type { ${U.name}Props } from './${U.tag}.js'`).join(`
|
|
1098
|
-
`)}`);let W;if(e.manifest!==!1)W=await S("custom-elements.json",JSON.stringify(
|
|
1098
|
+
`)}`);let W;if(e.manifest!==!1)W=await S("custom-elements.json",JSON.stringify(Gu(l),null,2));let Z;if(e.css!==!1){let U=l.filter((H)=>!H.shadowMode&&H.styles).map(ra).join(`
|
|
1099
1099
|
|
|
1100
|
-
`);if(U)Z=await S("bundle.css",e.minify?
|
|
1100
|
+
`);if(U)Z=await S("bundle.css",e.minify?ia(U):U)}let q;if(e.bundle!==!1){q=rt.join(r,"bundle.js");let U;try{U=await Bun.build({entrypoints:[rt.join(r,"index.js")],outdir:r,naming:"bundle.js",target:"browser",format:"esm",minify:e.minify??!0,sourcemap:e.sourcemap||"none"})}catch(H){let re=H instanceof AggregateError?H.errors:[H],ce=re.map((le)=>String(le).trim()).filter(Boolean).join(`
|
|
1101
1101
|
`);throw AggregateError(re,`Failed to bundle component library${ce?`
|
|
1102
1102
|
${ce}`:""}`)}if(!U.success){let H=U.logs.map((re)=>String(re).trim()).filter(Boolean).join(`
|
|
1103
1103
|
`);throw AggregateError(U.logs,`Failed to bundle component library${H?`
|
|
1104
|
-
${H}`:""}`)}if(v.push(q),e.sourcemap==="external")v.push(`${q}.map`)}let X=await Promise.all(v.map(async(U)=>(await
|
|
1105
|
-
`),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function
|
|
1106
|
-
`)}function
|
|
1104
|
+
${H}`:""}`)}if(v.push(q),e.sourcemap==="external")v.push(`${q}.map`)}let X=await Promise.all(v.map(async(U)=>(await ea(U)).size));return{components:l.map((U)=>({name:U.name,tag:U.tag,source:U.sourcePath,module:rt.join(r,`${U.tag}.js`),styles:U.styles,shadowMode:U.shadowMode})),files:v,manifest:W,bundle:q,cssBundle:Z,totalBytes:X.reduce((U,H)=>U+H,0)}}var Qu=new Set(ht);function qt(e){let n=Qt(e),r=n.find((j)=>j.name==="InheritedContext");if(!r)return;let i=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(t(r.text).trim()),a=t(e),l=h(a).depths,u=[...a.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((j)=>l[j.index]===0)?.index??0,f=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),v=t(f),S=h(v).depths,I=[...v.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((j)=>S[j.index]===0).map((j)=>j[1]);return{keys:i?I:[],types:n.map((j)=>j.text).join(`
|
|
1105
|
+
`),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function ep(e){let n=[],r=t(e);for(let i of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(i[1]||r.slice(i.index,i.index+6)!=="import")continue;let a=i[2].trim(),l=["stx","@stacksjs/stx"].includes(i[4]);if(/^[A-Za-z_$][\w$]*$/.test(a)){n.push(a);continue}if(!a.startsWith("{")||!a.endsWith("}"))continue;for(let u of a.slice(1,-1).split(",")){if(/^\s*type\s+/.test(u))continue;let[f,v=f]=u.trim().split(/\s+as\s+/);if(v&&!(l&&Qu.has(f)))n.push(v)}}return n}function no(e){let n=qt(e);if(!n||n.unsupported)return"";let r=new Set(ye(e));return n.keys.filter((i)=>!r.has(i)).map((i)=>`declare const ${i}: InheritedContext[${JSON.stringify(i)}];`).join(`
|
|
1106
|
+
`)}function pa(e,n){let r=[$s],i=[],a=new Map,l=wt.resolve(n.filePath),u=l.split(wt.sep).lastIndexOf("views"),f=u>=0?l.split(wt.sep).slice(0,u).join(wt.sep):wt.dirname(l),v=wt.resolve(n.partialsDir||wt.join(f,"partials")),S=wt.resolve(n.layoutsDir||wt.join(f,"views/layouts"));if([v,S].some((Z)=>l===Z||l.startsWith(Z+wt.sep)))return{declarations:"",checks:i,dependencies:a};let I=(Z)=>n.readTemplate?.(Z)??(ua.existsSync(Z)?ua.readFileSync(Z,"utf8"):void 0),j=0,L=!1,M=[];function V(Z,q){let X=e.slice(0,Z).split(`
|
|
1107
1107
|
`).length,U=Z-e.lastIndexOf(`
|
|
1108
1108
|
`,Z-1),H={code:e.slice(Z,e.indexOf(`
|
|
1109
1109
|
`,Z)<0?e.length:e.indexOf(`
|
|
1110
1110
|
`,Z)),line:X,column:U,kind:"directive",offset:Z,anchor:!0};i.push({expression:H,statement:{text:`;${q}`,prefixLength:1}})}function W(Z,q,X,U,H,re){let ce=`__StxInherited${j++}`;while((e+Z+[...a.values()].join("")).includes(ce))ce+="_";let le=_e(Z).filter((Ve)=>Ve.kind==="server").map((Ve)=>Ve.code).join(`
|
|
1111
|
-
`),pe=`${ce}ParentValue`,Re=`${ce}ParentType`;r.push(`type ${Re} = ${X};`);let Ae=
|
|
1112
|
-
`):"",lt=
|
|
1111
|
+
`),pe=`${ce}ParentValue`,Re=`${ce}ParentType`;r.push(`type ${Re} = ${X};`);let Ae=vr(Is(le,wt.dirname(q)),ce);r.push(...Ae.imports);let we=qt(le);if(we&&H!==void 0){L=!0;let Ve=Ae.imports.length?Ae.aliases.join(`
|
|
1112
|
+
`):"",lt=Es(`${Ve}
|
|
1113
1113
|
${we.types}
|
|
1114
|
-
const __contract = defineProps<InheritedContext>();`,`${ce}Contract`);r.push(lt.declarations),r.push(`declare const ${ce}Input: ${Re};`),V(H,we.unsupported?`({})[${JSON.stringify(we.unsupported)}];`:`${ce}Input satisfies ${lt.props};`)}let fe=[...new Set([...ye(le),...
|
|
1114
|
+
const __contract = defineProps<InheritedContext>();`,`${ce}Contract`);r.push(lt.declarations),r.push(`declare const ${ce}Input: ${Re};`),V(H,we.unsupported?`({})[${JSON.stringify(we.unsupported)}];`:`${ce}Input satisfies ${lt.props};`)}let fe=[...new Set([...ye(le),...ep(le)])],We=[...new Set([...U,...we?.keys||[]])].filter((Ve)=>!fe.includes(Ve)),Fe=we?`${Re} & ${ce}Contract.__StxProps`:Re,it=$n(Ae.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),ot=[],At=gn(Z),St=/@(include|extends|layout)\s*\(/g,at;while(at=St.exec(At)){let Ve=Kn(At,St.lastIndex-1);if(!Ve)continue;St.lastIndex=Ve.end;let lt=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(Ve.expression);if(!lt){M.push({offset:H??at.index,message:`Inherited context cannot be checked across dynamic @${at[1]}`});continue}let ut=lt[2],De=at[1];if(De!=="include"&<[3])M.push({offset:H??at.index,message:`Inherited context cannot be checked for unsupported @${De} data arguments`});let Mt=De==="include"?v:S,Dt=wt.resolve(ut.startsWith(".")?wt.dirname(q):Mt,ut.endsWith(".stx")?ut:ut+".stx");if(I(Dt)===void 0){M.push({offset:H??at.index,message:`Inherited context target cannot be resolved: ${ut}`});continue}ot.push({name:`edge${ot.length}`,target:Dt,kind:De,args:De==="include"?lt[3]||"{}":"{}",offset:H??at.index})}let $t=`{ ...${pe}${fe.length?", "+fe.join(", "):""} }`;r.push(`namespace ${ce} {
|
|
1115
1115
|
${Ae.aliases.join(`
|
|
1116
1116
|
`)}
|
|
1117
1117
|
export async function read(${pe}: ${H===void 0?"{}":Fe}) {
|
|
@@ -1120,83 +1120,83 @@ ${it}
|
|
|
1120
1120
|
return { context: ${$t}${ot.map((Ve)=>`, ${Ve.name}: { ...${$t}, ...(${Ve.args}) }`).join("")} };
|
|
1121
1121
|
}
|
|
1122
1122
|
}`);for(let Ve of ot){if(re.includes(Ve.target)||re.length>=32){M.push({offset:Ve.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let lt=I(Ve.target);a.set(Ve.target,lt),W(lt,Ve.target,`Awaited<ReturnType<typeof ${ce}.read>>[${JSON.stringify(Ve.name)}]`,[...new Set([...U,...fe])],Ve.offset,[...re,Ve.target])}return ce}if(W(e,l,"{}",[],void 0,[l]),L||n.contractsKnown)for(let Z of M)V(Z.offset,`({})[${JSON.stringify(Z.message)}];`);return{declarations:L?r.join(`
|
|
1123
|
-
`):"",checks:i,dependencies:a}}function ro(e,n){let r=Yt(e),i=
|
|
1123
|
+
`):"",checks:i,dependencies:a}}function ro(e,n){let r=Yt(e),i=yr(e);if(!i)return;let a;try{a=_r(e,"component")}catch(H){let re=i.open,ce=H instanceof Error?H.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(ce)}];`,line:e.slice(0,re).split(`
|
|
1124
1124
|
`).length,column:re-e.lastIndexOf(`
|
|
1125
1125
|
`,re-1),origin:"component"}],project:(le)=>({code:le,columns:new Map})}}let l=ee(r).filter((H)=>{let re=O(H.attrs);return kt(re)&&re.has("client")&&!re.has("server")&&!re.has("component")&&!re.has("stx:component")&&!re.has("src")}),u=l.map((H)=>e.slice(H.bodyStart,H.bodyEnd)).join(`
|
|
1126
|
-
`),f=
|
|
1127
|
-
`),L=-1;for(let H of l){let re=H.bodyStart,ce=e.slice(re,H.bodyEnd),le=t(ce),pe=h(le).depths,Re=[...le.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Ae)=>pe[Ae.index]===0)??(
|
|
1126
|
+
`),f=Ts(u,n),v=Qt(u).some((H)=>H.name==="ComponentState")||Os(u).includes("ComponentState"),S=Object.entries(a.properties||a.props||{}).map(([H,re])=>`${JSON.stringify(H)}: ${dn(re)}`).join("; "),I=[...new Set(f.map((H)=>H.name))],j=[`interface __StxMetadataProperties { ${S} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",v?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",v?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",v?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",v?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${I.map((H)=>JSON.stringify(H)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',v?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...I.map((H)=>`${JSON.stringify(H)}: typeof ${H};`),"}"].filter(Boolean).join(`
|
|
1127
|
+
`),L=-1;for(let H of l){let re=H.bodyStart,ce=e.slice(re,H.bodyEnd),le=t(ce),pe=h(le).depths,Re=[...le.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Ae)=>pe[Ae.index]===0)??(Os(ce).includes("ComponentState")?/\bComponentState\b/.exec(le):void 0);if(Re){L=re+Re.index;break}}let M=v&&L>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,L).split(`
|
|
1128
1128
|
`).length,column:L-e.lastIndexOf(`
|
|
1129
1129
|
`,L-1)}]:[],{start:V,code:W}=i,Z=t(W),q=h(Z).depths,X=new Map,U=!1;for(let H of W.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let re=JSON.parse(H[0].slice(0,H[0].lastIndexOf(":")).trim());if(q[H.index]===1&&["properties","props"].includes(re)){U=!0;continue}if(U&&q[H.index]===1)U=!1;if(U&&q[H.index]===2&&!X.has(re))X.set(re,V+H.index)}for(let[H,re]of Object.entries(a.properties||a.props||{})){let ce=X.get(H)??V,le=e.slice(0,ce).split(`
|
|
1130
1130
|
`).length,pe=ce-e.lastIndexOf(`
|
|
1131
|
-
`,ce-1);if(!re||typeof re!=="object"||!["string","number","boolean","object","array"].includes(re.type))M.push({text:`({})[${JSON.stringify(`Property ${H} must declare string, number, boolean, object or array`)}];`,line:le,column:pe,origin:"component"});if(re&&re.default!==void 0)M.push({text:`const __stxDefault${M.length}: ${
|
|
1131
|
+
`,ce-1);if(!re||typeof re!=="object"||!["string","number","boolean","object","array"].includes(re.type))M.push({text:`({})[${JSON.stringify(`Property ${H} must declare string, number, boolean, object or array`)}];`,line:le,column:pe,origin:"component"});if(re&&re.default!==void 0)M.push({text:`const __stxDefault${M.length}: ${dn(re)} = ${JSON.stringify(re.default)};`,line:le,column:pe,origin:"component"})}return{declarations:j,checks:M,project(H){let re=new Map,ce=[],le=0;for(let pe of Ts(H,n)){if(/^\s*this\s*:/.test(pe.parameters))continue;let Re=pe.parameterOffset,Ae=`this: __StxNativeComponent${pe.parameters.trim()?", ":""}`;ce.push(H.slice(le,Re),Ae);let we=H.slice(0,Re).split(`
|
|
1132
1132
|
`).length,fe=Re-H.lastIndexOf(`
|
|
1133
|
-
`,Re-1),We=re.get(we)||[],Fe=We.at(-1),it=fe+(Fe?Fe.generatedEnd-Fe.sourceEnd:0);We.push({sourceStart:fe,sourceEnd:fe,generatedStart:it,generatedEnd:it+Ae.length}),re.set(we,We),le=Re}return ce.push(H.slice(le)),{code:ce.join(""),columns:re}}}}function
|
|
1134
|
-
`,n-1)+1;return n-r+1}function
|
|
1135
|
-
`)n[u]=" "},i=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function
|
|
1133
|
+
`,Re-1),We=re.get(we)||[],Fe=We.at(-1),it=fe+(Fe?Fe.generatedEnd-Fe.sourceEnd:0);We.push({sourceStart:fe,sourceEnd:fe,generatedStart:it,generatedEnd:it+Ae.length}),re.set(we,We),le=Re}return ce.push(H.slice(le)),{code:ce.join(""),columns:re}}}}function fa(e){let n=[],r=[],i=/@foreach\s*\(|@endforeach\b/g,a;while(a=i.exec(e)){if(a[0].startsWith("@endforeach")){let v=r.pop();if(v)v.end=a.index,n.push(v);continue}let l=Kn(e,i.lastIndex-1);if(!l)continue;let u=wr(l.expression),f=l.end;if(u)r.push({start:f,end:e.length,iterable:u.iterable,binding:u.key?`${u.value}, ${u.key}`:u.value});i.lastIndex=f}return n.sort((l,u)=>l.start-u.start)}function tp(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function _e(e){let n=[],r=tp(e);for(let i of ee(r)){let a=i.attrs.trim(),l=O(a),{bodyStart:u,bodyEnd:f}=i,v=e.slice(u,f);if(l.has("src")||l.has("component")||l.has("stx:component"))continue;if(!kt(l))continue;let S=l.has("server")?"server":l.has("client")?"client":"plain",I=np(e,u);n.push({kind:S,code:v,startLine:I,startColumn:sp(e,u),offset:u,attrs:a})}return n}function np(e,n){let r=1;for(let i=0;i<n&&i<e.length;i++)if(e.charCodeAt(i)===10)r++;return r}function sp(e,n){let r=e.lastIndexOf(`
|
|
1134
|
+
`,n-1)+1;return n-r+1}function gn(e){let n=e.split(""),r=(a,l)=>{for(let u=a;u<l&&u<n.length;u++)if(n[u]!==`
|
|
1135
|
+
`)n[u]=" "},i=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function va(e){let n=0,r="";for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r="";continue}if(a==='"'||a==="'"||a==="`"){r=a;continue}if(a==="("||a==="["||a==="{"){n++;continue}if(a===")"||a==="]"||a==="}"){n--;continue}if(a==="|"&&n===0){if(e[i+1]==="|"){i++;continue}if(e[i-1]==="|")continue;return e.slice(0,i)}}return e}var Sa=new Set([":for","x-for","v-for"]),js=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,$r="__stx_interpolated",da="__StxElement",$a="__StxTemplateValue",rp=`type ${$a}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function ga(e){return e.replace(/\{\{[\s\S]*?\}\}/g,$r).replace(/\{!![\s\S]*?!!\}/g,$r)}function ip(e,n,r){let i=0;for(let a=n;a<e.length;a++){let l=e[a];if(l==="{"){i++;continue}if(l!=="}"&&l!=="!")continue;if(e.startsWith(r,a)&&i===0)return a;if(l==="}"&&i>0)i--}return-1}function Di(e,n,r="0"){let i=`__stxScript${r}`;while((e+n).includes(i))i+="_";let a=new Map,l=[],u=[],f=t(e),v=kr(e),S=[],I=0;for(let W=0;W<f.length;W++){let Z=f.startsWith("{{",W);if(!Z&&!f.startsWith("{!!",W))continue;let q=Z?2:3,X=Z?"}}":"!!}",U=ip(f,W+q,X);if(U<0)continue;let H=W,re=e.slice(H,U+X.length),ce=re.slice(q,-X.length);W=U+X.length-1;let le=u.length,pe=en(v,H),Re=en(v,H+(Z?2:3));u.push({code:va(ce),...Re});let Ae=`${i}_${le}`,we=re.split(`
|
|
1136
1136
|
`),fe=we[0].length;we[0]=Ae+" ".repeat(Math.max(0,fe-Ae.length));for(let ot=1;ot<we.length;ot++)we[ot]=we[ot].replace(/[^\r]/g," ");let We=a.get(pe.line)??[],Fe=We.at(-1),it=pe.column+(Fe?Fe.generatedEnd-Fe.sourceEnd:0);We.push({sourceStart:pe.column,sourceEnd:pe.column+fe,generatedStart:it,generatedEnd:it+we[0].length}),a.set(pe.line,We),S.push(e.slice(I,H),we.join(`
|
|
1137
|
-
`)),I=H+re.length}S.push(e.slice(I));let j=S.join("");if(!u.length)return{code:j,columns:a,declarations:l};let{imports:L,aliases:M,body:V}=
|
|
1137
|
+
`)),I=H+re.length}S.push(e.slice(I));let j=S.join("");if(!u.length)return{code:j,columns:a,declarations:l};let{imports:L,aliases:M,body:V}=vr(n,i);for(let W of L)l.push({text:W});l.push({text:`namespace ${i}Scope {
|
|
1138
1138
|
${M.join(`
|
|
1139
1139
|
`)}
|
|
1140
1140
|
export async function read() {
|
|
1141
1141
|
${$n(V).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
|
|
1142
1142
|
return {`});for(let[W,Z]of u.entries())l.push({text:`value${W}: (`}),l.push({text:Z.code,origin:{line:Z.line,column:Z.column}}),l.push({text:"),"});l.push({text:`}
|
|
1143
1143
|
}
|
|
1144
|
-
}`});for(let W=0;W<u.length;W++)l.push({text:`declare var ${i}_${W}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${W}']`});return{code:j,columns:a,declarations:l}}function
|
|
1145
|
-
`)}function ul(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function
|
|
1144
|
+
}`});for(let W=0;W<u.length;W++)l.push({text:`declare var ${i}_${W}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${W}']`});return{code:j,columns:a,declarations:l}}function vr(e,n){let r=[],{imports:i,body:a}=ka(e),l=[],u=0;for(let f of i.split(/\n(?=import\b)/)){if(!f.trim())continue;let v=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(f);if(!v){r.push(f);continue}let S=`${n}Module${u++}`;r.push(`import * as ${S} from ${v[2]}`);let I=v[1],j=/\{([\s\S]*?)\}/.exec(I);for(let W of j?.[1].split(",")??[]){let[Z,q=Z]=W.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(Z==="default")l.push(`const ${q} = ${S}.default; type ${q} = import(${v[2]}).default`);else if(Z)l.push(`import ${q} = ${S}.${Z}`)}let L=I.replace(/\{[\s\S]*?\}/,""),M=/\*\s+as\s+(\w+)/.exec(L);if(M)l.push(`import ${M[1]} = ${S}`);let V=/^\s*([\w$]+)/.exec(L)?.[1];if(V)l.push(`const ${V} = ${S}.default; type ${V} = import(${v[2]}).default`)}return{imports:r,aliases:l,body:a}}function Sr(e,n){let r=0;for(let i of e){if(n<i.generatedStart)break;if(n<i.generatedEnd)return i.sourceStart+Math.min(n-i.generatedStart,i.sourceEnd-i.sourceStart);r=i.sourceEnd-i.generatedEnd}return n+r}var op=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],ap=new RegExp(String.raw`^[ \t]*@(?:${op.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function $n(e){return e.replace(ap,(n)=>n.replace(/[^\n]/g," "))}var ma=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function so(e){let n=gn(e),r=[],i=kr(n),a=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,l;while((l=a.exec(n))!==null){if(l[1]||l[3])continue;let v=l[2]??l[4]??"",S=l[2]!==void 0?2:3,I=va(v);if(!I.trim())continue;let j=l.index+S+(I.length-I.trimStart().length);r.push({code:I.trim(),...en(i,j),offset:j,kind:"interpolation"})}let u=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((l=u.exec(n))!==null){let f=l.index+l[0].length-1,v=0,S=f;for(;S<n.length;S++){let M=n[S];if(M==="(")v++;else if(M===")"){if(v--,v===0)break}}if(v!==0)continue;let I=n.slice(f+1,S),j=I.trim();if(u.lastIndex=S+1,!j)continue;let L=f+1+(I.length-I.trimStart().length);r.push({code:j,...en(i,L),offset:l.index,kind:"condition"})}js.lastIndex=0;while((l=js.exec(n))!==null){let f=l[1],v=l[3]??"",S=f.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(ma.has(S)||ma.has(f))continue;if(!v.trim())continue;let I=l.index+l[0].indexOf(l[2],l[0].indexOf(f)+f.length)+1;if(Sa.has(S)){let L=v.match(/\s+(?:in|of)\s+/);if(!L||L.index===void 0)continue;let M=v.slice(L.index+L[0].length),V=L.index+L[0].length+(M.length-M.trimStart().length);r.push({code:ga(M.trim()),...en(i,I+V),offset:I+V,kind:"directive",attribute:S});continue}let j=v.length-v.trimStart().length;r.push({code:ga(v.trim()),...en(i,I+j),offset:I+j,kind:"directive",attribute:S})}return r.sort((f,v)=>f.line-v.line||f.column-v.column),r}var cp=2000;function lp(e,n){let r=0,i=Math.min(e.length,n+cp);for(let a=n;a<i;a++){let l=e[a];if(l==="(")r++;else if(l===")"){if(r--,r===0)return e.slice(n+1,a)}}return null}function up(e){let n=new Map,r=(f,v)=>{let S=f.split(/[,[\]{}()\s]+/).filter(Boolean);for(let I of S){let j=I.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(j))continue;let L=S.length===1?v:void 0,M=n.get(j);if(!M)n.set(j,{name:j,iterable:L});else if(M.iterable!==L)M.iterable=void 0}},i=/^\$?[A-Z_$][\w$]*$/i,a=(f)=>{let v=f.trim();return i.test(v)?v:void 0};for(let f of e.matchAll(/@for(?:each|else)\s*\(/g)){let v=lp(e,f.index+f[0].length-1);if(v===null)continue;let S=Wt(v);if(!S)continue;r(S.itemVar.replace(/=>/g," "),a(S.arrayExpr))}for(let f of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(f[1],f[2]==="of"?a(f[3]):void 0);for(let f of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(f[1]);let l=gn(e);js.lastIndex=0;let u;while((u=js.exec(l))!==null){let f=u[1].replace(/\..*$/,"");if(!Sa.has(f))continue;let v=u[3].match(/\s+(?:in|of)\s+/);if(!v||v.index===void 0)continue;r(u[3].slice(0,v.index),a(u[3].slice(v.index+v[0].length)))}for(let f of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let v of f[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(v[1]);return[...n.values()].sort((f,v)=>f.name.localeCompare(v.name))}function ye(e){return Fl(e)}var Er=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],pp={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string",$native:"declare var $native: boolean"};function ll(e=new Set){return[...Er.filter((n)=>!e.has(n)).map((n)=>`declare var ${n}: any`),...Object.entries(pp).filter(([n])=>!e.has(n)).map(([,n])=>n)].join(`
|
|
1145
|
+
`)}function ul(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function Ea(e){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,r,i=!1,a=new Set,l=t(e);while((r=n.exec(l))!==null){i=!0;for(let u of fp(r[1])){let f=u.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(f))a.add(f)}}return i?[...a]:null}function fp(e){let n=[],r=0,i="";for(let a of e){if(a===","&&r===0){n.push(i),i="";continue}if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;i+=a}return n.push(i),n.filter((a)=>a.trim().length>0)}function ka(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],i=e.replace(n,(a)=>(r.push(a.trim()),a.split(`
|
|
1146
1146
|
`).map(()=>"").join(`
|
|
1147
1147
|
`)));return{imports:r.join(`
|
|
1148
1148
|
`),body:i}}function Qt(e){let n=t(e),r=Array(n.length),i=0;for(let f=0;f<n.length;f++){let v=n[f];if(v==="}"||v===")"||v==="]")i=Math.max(0,i-1);if(r[f]=i,v==="{"||v==="("||v==="[")i++}let a=[],l=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,u;while((u=l.exec(n))!==null){if(r[u.index]!==0)continue;let f=u[1],v=u[2],S;if(f==="interface"){let I=n.indexOf("{",u.index);if(I===-1)continue;let j=0;S=-1;for(let L=I;L<n.length;L++)if(n[L]==="{")j++;else if(n[L]==="}"&&--j===0){S=L+1;break}if(S===-1)continue}else{let I=0;S=n.length;for(let j=n.indexOf("=",u.index)+1;j<n.length;j++){let L=n[j];if(L==="{"||L==="["||L==="("||L==="<")I++;else if(L==="}"||L==="]"||L===")"||L===">")I--;else if(I<=0&&(L===";"||L===`
|
|
1149
1149
|
`&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,j-40),j)))){S=L===";"?j+1:j;break}}}a.push({name:v,text:e.slice(u.index,S).replace(/^[ \t]*export[ \t]+/,"")}),l.lastIndex=S}return a}function dp(e){let n=t(e),r=[],i=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,a,l=0,u=0;while((a=i.exec(n))!==null){for(;u<a.index;u++){let S=n[u];if(S==="{"||S==="("||S==="[")l++;else if(S==="}"||S===")"||S==="]")l=Math.max(0,l-1)}if(l!==0)continue;let f=0,v=n.length;for(let S=a.index+a[0].length;S<n.length;S++){let I=n[S];if(I==="{"||I==="("||I==="[")f++;else if(I==="}"||I===")"||I==="]")f--;else if(f<=0&&(I===";"||I===`
|
|
1150
1150
|
`)){v=I===";"?S+1:S;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(a.index,v)))r.push(e.slice(a.index,v).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function Li(e){let n=e.filter((a)=>a.kind==="server").map((a)=>a.code).join(`
|
|
1151
|
-
`);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=
|
|
1152
|
-
`)}function
|
|
1153
|
-
`)}if(r.length===0)return a.length>0?["",`// ${
|
|
1154
|
-
`):"";let{imports:l,body:u}=
|
|
1155
|
-
`)}function
|
|
1156
|
-
`)l=f+1;if(v==="{"||v==="("||v==="["){if(a===0&&v!=="("&&gp.test(n.slice(l,f))){let S=
|
|
1157
|
-
`)r[f]=" "}let u=ye(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var gp=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function
|
|
1158
|
-
`))continue;let V=
|
|
1159
|
-
`),v=Array.from({length:f.length},()=>""),S=new Map,I=new Map,j=new Map,L=[],M=Li(r),V=n.filePath&&n.templateExpressions!==!1?
|
|
1160
|
-
`)}):void 0,W=new Set,Z=[];for(let[H,re]of i.entries()){let ce=Di(ji(re)+re.code,M,String(H));for(let[we,fe]of ce.columns)I.set(re.startLine+we-1,fe);for(let we of ce.declarations)L.push({text:
|
|
1151
|
+
`);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=Ca(n),i=e.filter((a)=>a.kind!=="server").flatMap((a)=>{let l=dp(a.code);if(!l.length)return[];return[...Qt(a.code).filter((u)=>!r.has(u.name)).map((u)=>u.text),...l]});return[n,...i].filter(Boolean).join(`
|
|
1152
|
+
`)}function Ca(e){return new Set(Qt(e).map((n)=>n.name))}function dl(e,n=""){let r=Ea(e),i=Ca(n),a=Qt(e).filter((S)=>!i.has(S.name)).map((S)=>S.text);if(!r){let S=ye(e).filter((I)=>!Ut(n,I));if(S.length===0&&a.length===0)return"";return["",`// ${hp}`,...a,...S.map((I)=>`declare var ${I}: any`)].join(`
|
|
1153
|
+
`)}if(r.length===0)return a.length>0?["",`// ${xa}`,...a].join(`
|
|
1154
|
+
`):"";let{imports:l,body:u}=ka(e),f=u.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),v=["",`// ${xa}`];if(l)v.push(l);return v.push(...a),v.push(`async function ${ba}() {`,f,` return { ${r.join(", ")} }`,"}",`type ${ya} = Awaited<ReturnType<typeof ${ba}>>`,...r.map((S)=>`declare var ${S}: ${ya}[${JSON.stringify(S)}]`)),v.join(`
|
|
1155
|
+
`)}function Ra(e){let n=t(e),r=n.split(""),i=[],a=0,l=0;for(let f=0;f<r.length;f++){let v=r[f];if(v===`
|
|
1156
|
+
`)l=f+1;if(v==="{"||v==="("||v==="["){if(a===0&&v!=="("&&gp.test(n.slice(l,f))){let S=Aa(n,f);if(S!==-1)i.push(...Ta(n.slice(f,S+1)))}a++;continue}if(v==="}"||v===")"||v==="]"){a=Math.max(0,a-1);continue}if(a>0&&v!==`
|
|
1157
|
+
`)r[f]=" "}let u=ye(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var gp=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function Aa(e,n){let r=0;for(let i=n;i<e.length;i++){let a=e[i];if(a==="{"||a==="("||a==="[")r++;else if(a==="}"||a===")"||a==="]")r--;if(r===0)return i}return-1}function mp(e){let n=[],r=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r--;else if(l===","&&r===0)n.push(e.slice(i,a)),i=a+1}return n.push(e.slice(i)),n}function ha(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="{"||i==="("||i==="[")n++;else if(i==="}"||i===")"||i==="]")n--;else if(n===0&&(i===":"||i==="="))return{index:r,char:i}}return null}function Ta(e){let n=[],r=(a)=>{let l=a.trim().replace(/^\.\.\./,"").trim();if(l.startsWith("{")||l.startsWith("[")){let f=Aa(l,0);if(f!==-1)n.push(...Ta(l.slice(0,f+1)));return}let u=ha(l);if(u)l=l.slice(0,u.index).trim();if(/^[A-Z_$][\w$]*$/i.test(l))n.push(l)},i=e.slice(1,-1);for(let a of mp(i)){if(!a.trim())continue;if(e[0]==="["){r(a);continue}let l=ha(a);r(l?.char===":"?a.slice(l.index+1):a)}return n}function pl(e,n){if(Ea(e)!==null)return[];let r=Ra(e),i=je(n,new Set(r)),a=new Set(C);return r.filter((l)=>{if(a.has(l))return!1;if(Ut(n,l))return!1;return i.has(l)})}var xa="stx: types for the declared client payload (#1868)",hp="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",ba="__stxServerScope",ya="__StxClientPayload";var _a=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];var xp=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function bp(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let i of e){let a=t(i),{depths:l,balanced:u}=h(a);if(!u)continue;let f=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let v of a.matchAll(f)){let S=v.index??0;if(l[S+v[1].length]!==0)continue;let I=v[2],j=S+v[0].length-v[3].length,L=i.slice(j,S+v[0].length).trim().replace(/;$/,"").trim(),M=v[3],V=r.test(M)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(M)&&!/[,+\-*/%&|?:=]$/.test(L)&&h(M).balanced;n.set(I,n.has(I)||!V?null:L)}}return new Map([...n].filter((i)=>i[1]!==null))}function Ia(e,n,r=0,i=new Set){if(n.size===0||r>=5)return e;let a=t(e),l="",u=0;for(let f of a.matchAll(/[A-Za-z_$][\w$]*/g)){let v=f.index??0,S=f[0],I=n.get(S);if(!I||i.has(S))continue;let j=a.slice(0,v).trimEnd(),L=a.slice(v+S.length).trimStart();if(j.endsWith(".")||/^:(?!:)/.test(L)&&/[{,]$/.test(j))continue;if(v>0&&/[\w$]/.test(a[v-1]))continue;l+=`${e.slice(u,v)}(${Ia(I,n,r+1,new Set([...i,S]))})`,u=v+S.length}return l+e.slice(u)}function yp(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,i=[],a;while((a=r.exec(e))!==null){if(a.index>n)break;let l=a[1];if(a.index===n){if(l==="elseif"){let f=i[i.length-1];if(f?.current)f.seen.push(f.current);if(f)f.current=null}break}if(l==="endif"||l==="endunless"){i.pop();continue}let u="";if(a[2]==="("){let f=0,v=a.index+a[0].length-1,S=v+1;for(;v<e.length;v++){let I=e[v];if(I==="(")f++;else if(I===")"){if(f--,f===0)break}}u=e.slice(S,v).trim(),r.lastIndex=v+1}if(l==="if")i.push({seen:[],current:u});else if(l==="unless")i.push({seen:[],current:`!(${u})`});else if(l==="elseif"||l==="else"){let f=i[i.length-1];if(!f)continue;if(f.current)f.seen.push(f.current);f.current=l==="elseif"?u:null}}return i.flatMap((l)=>[...l.seen.map((u)=>`!(${u})`),...l.current?[l.current]:[]]).filter(Boolean)}function _p(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(xp.test(n))return null;let i=";(($event: any): void => { ";return{text:`${i}${n} });`,prefixLength:i.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var wp=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Is(e,n){return oo(e,n).code}function oo(e,n){let r=new Map;if(!n)return{code:e,columns:r};let i=kr(e),a=[],l=0;for(let u of e.matchAll(wp)){let f=u.index,[v,S,I,j]=u,L=wa.resolve(n,j).replace(/\\/g,"/"),M=`${S}${I}${L}${I}`;if(a.push(e.slice(l,f),M),l=f+v.length,v.includes(`
|
|
1158
|
+
`))continue;let V=en(i,f),W=r.get(V.line)??[],Z=W.at(-1),q=V.column+(Z?Z.generatedEnd-Z.sourceEnd:0);W.push({sourceStart:V.column,sourceEnd:V.column+v.length,generatedStart:q,generatedEnd:q+M.length}),r.set(V.line,W)}return a.push(e.slice(l)),{code:a.join(""),columns:r}}function vp(e,n,r){let i=Sr(e.importColumns?.get(n)??[],r);return Sr(e.scriptColumns?.get(n)??[],Sr(e.componentColumns?.get(n)??[],i))}function ji(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Os(e){let n=new Set,r=t(e);for(let i of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let a=i[1],l=/\{([^}]*)\}/.exec(a);for(let S of l?.[1].split(",")??[]){let I=S.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(I&&/^[A-Z_$][\w$]*$/i.test(I))n.add(I)}let u=a.replace(/\{[^}]*\}/,""),f=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(u);if(f)n.add(f[1]);let v=/^\s*([A-Z_$][\w$]*)/i.exec(u);if(v&&v[1]!=="type")n.add(v[1])}return[...n].sort()}function Bi(e,n={}){let r=_e(e),i=n.scriptKinds?r.filter((H)=>n.scriptKinds.includes(H.kind)):r,a=ro(e,n.componentMethodValidator),l=n.filePath&&n.templateExpressions!==!1?pa(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,u=new Map,f=e.split(`
|
|
1159
|
+
`),v=Array.from({length:f.length},()=>""),S=new Map,I=new Map,j=new Map,L=[],M=Li(r),V=n.filePath&&n.templateExpressions!==!1?Xo(e,gn(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(H,re)=>_e(H).map((ce)=>Is(ce.code,wa.dirname(re))).join(`
|
|
1160
|
+
`)}):void 0,W=new Set,Z=[];for(let[H,re]of i.entries()){let ce=Di(ji(re)+re.code,M,String(H));for(let[we,fe]of ce.columns)I.set(re.startLine+we-1,fe);for(let we of ce.declarations)L.push({text:Is(we.text,n.originDir??""),origin:we.origin?{...we.origin,line:we.origin.line+re.startLine-1}:void 0});let le=re.kind==="client"&&a?a.project(ce.code):void 0;for(let[we,fe]of le?.columns??[])u.set(re.startLine+we-1,fe);let pe=$n(le?.code??ce.code),Re=oo(pe,n.originDir??"");for(let[we,fe]of Re.columns)j.set(re.startLine+we-1,fe);let Ae=Re.code.split(`
|
|
1161
1161
|
`);Ae.forEach((we,fe)=>{let We=re.startLine-1+fe;if(We<v.length)v[We]=we,W.add(We)}),Z.push(re.startLine-1+Ae.length-1)}for(let H of Z){let re=v[H]?.trim()===""?H:H+1;if(re<v.length&&v[re].trim()===""&&(re===H||!W.has(re)))v[re]=";"}let q=(H,re)=>{for(let[ce,le]of H.split(`
|
|
1162
1162
|
`).entries())if(v.push(le),re)S.set(v.length,ce===0?re:{...re,line:re.line+ce,column:1,prefixLength:0})},X=no(i.filter((H)=>H.kind==="server").map((H)=>H.code).join(`
|
|
1163
1163
|
`));if(X)q(X);for(let H of i.filter((re)=>re.kind==="server")){let re=qt(H.code);if(!re?.unsupported)continue;let ce=H.code.slice(0,re.offset),le=H.startLine+ce.split(`
|
|
1164
1164
|
`).length-1,pe=re.offset-H.code.lastIndexOf(`
|
|
1165
|
-
`,re.offset-1)+(le===H.startLine?(H.startColumn??1)-1:0);q(`;({})[${JSON.stringify(re.unsupported)}];`,{line:le,column:pe,anchor:!0})}if(l?.declarations)q(l.declarations);for(let H of L)q(H.text,H.origin);if(a){if(q(a.declarations),n.nativeChecks!==!1)for(let H of a.checks)q(H.text,{line:H.line,column:H.column,diagnosticOrigin:H.origin,anchor:!0})}if(n.globals!==!1){q("");let H=new Set([...i.flatMap((pe)=>ye(pe.code)),...i.flatMap((pe)=>
|
|
1166
|
-
`))q(re);let H=so(e).map((re)=>{let ce=V?.events.get(re.offset??-1);if(ce){re.anchor=!0;let le=re.code.trim(),pe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(le),Re=pe?`void ((${pe[2]}) satisfies __StxAssignedValue<typeof ${pe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(le)?`${le} satisfies (($event: ${ce}) => unknown)`:le,Ae=`;(($event: ${ce}): void => { `;return{expression:re,statement:{text:`${Ae}${Re} });`,prefixLength:Ae.length}}}return{expression:re,statement:_p(re)}}).filter((re)=>re.statement!==null);if(H.push(...V?.checks||[],...l?.checks||[]),H.length>0){let re=
|
|
1167
|
-
`),lineMap:S,sourceLineCount:f.length,componentDependencies:new Map([...V?.dependencies??[],...l?.dependencies??[]]),referenced:U,scriptColumns:I,importColumns:j,componentColumns:u}}function
|
|
1165
|
+
`,re.offset-1)+(le===H.startLine?(H.startColumn??1)-1:0);q(`;({})[${JSON.stringify(re.unsupported)}];`,{line:le,column:pe,anchor:!0})}if(l?.declarations)q(l.declarations);for(let H of L)q(H.text,H.origin);if(a){if(q(a.declarations),n.nativeChecks!==!1)for(let H of a.checks)q(H.text,{line:H.line,column:H.column,diagnosticOrigin:H.origin,anchor:!0})}if(n.globals!==!1){q("");let H=new Set([...i.flatMap((pe)=>ye(pe.code)),...i.flatMap((pe)=>Os(pe.code))]),re=(pe)=>{if(!H.has(pe)&&!n.declaredGlobals?.includes(pe))q(`declare var ${pe}: any`)};if(n.runtimeGlobals!==!1){if(!H.has("window"))q("declare var window: any");for(let pe of C)re(pe)}let ce=[...new Set([...Er,...Oe,..._a])].filter((pe)=>!n.declaredGlobals?.includes(pe)&&(n.runtimeGlobals!==!1||!C.includes(pe)));if(n.contextScope==="global"){q("declare global {");for(let pe of ce)q(` var ${pe}: any`);q("}")}else{for(let pe of Er)re(pe);for(let pe of Oe)re(pe);for(let pe of _a)re(pe)}q(`declare var ${$r}: any`);let le=new Set(i.flatMap((pe)=>ye(pe.code)));q(`type ${da}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let pe of a?[]:up(e)){if(le.has(pe.name))continue;let Re=pe.iterable&&le.has(pe.iterable)?`${da}<typeof ${pe.iterable}>`:"any";q(`declare var ${pe.name}: ${Re}`)}}if(n.templateExpressions!==!1){if(V?.declarations)for(let re of V.declarations.split(`
|
|
1166
|
+
`))q(re);let H=so(e).map((re)=>{let ce=V?.events.get(re.offset??-1);if(ce){re.anchor=!0;let le=re.code.trim(),pe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(le),Re=pe?`void ((${pe[2]}) satisfies __StxAssignedValue<typeof ${pe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(le)?`${le} satisfies (($event: ${ce}) => unknown)`:le,Ae=`;(($event: ${ce}): void => { `;return{expression:re,statement:{text:`${Ae}${Re} });`,prefixLength:Ae.length}}}return{expression:re,statement:_p(re)}}).filter((re)=>re.statement!==null);if(H.push(...V?.checks||[],...l?.checks||[]),H.length>0){let re=gn(e),ce=vs(re),le=a?fa(re):[];if(a)q("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let pe=bp(i.map((fe)=>fe.code)),Ae=[...new Set(i.flatMap((fe)=>ye(fe.code)))].filter((fe)=>/^[A-Z_$][\w$]*$/i.test(fe)),we=0;if(a)q("function __stxNativeTemplate(this: __StxNativeComponent) {");if(Ae.length>0){q(rp);for(let fe of Ae)q(`function __StxRead_${fe}() { return ${fe} }`),q(`type __StxT_${fe} = ${$a}<ReturnType<typeof __StxRead_${fe}>>`);q(`;((${Ae.map((fe)=>`${fe}: __StxT_${fe}`).join(", ")}) => {`),we=1}for(let{expression:fe,statement:We}of H){let Fe=" ".repeat(we),it=fe.offset===void 0?[]:ce.filter((De)=>fe.offset>=De.start&&fe.offset<De.end),ot=fe.offset===void 0?[]:le.filter((De)=>fe.offset>=De.start&&fe.offset<De.end),At=ot.map((De)=>`;__stxEach(${De.iterable}, (${De.binding}) => { `).join(""),St=" });".repeat(ot.length),at=At+it.map((De)=>`;((${De.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),$t=" });".repeat(it.length)+St,Ve=fe.offset===void 0?[]:yp(re,fe.offset),lt=Ve.length>0?`${Ve.map((De)=>`if (${Ia(De,pe)}) `).join("")}{ `:"",ut=Ve.length>0?" }":"";q(Fe+at+lt+We.text+ut+$t,{line:fe.line,column:fe.column,expression:fe,prefixLength:We.prefixLength+Fe.length+at.length+lt.length,guardPrefixLength:Fe.length+at.length+lt.length})}if(we>0)q("});");if(a)q("}")}}let U=!1;if(n.reference&&v[0]!==void 0&&v[0].trim()==="")v[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,U=!0;return q("export {}"),{text:v.join(`
|
|
1167
|
+
`),lineMap:S,sourceLineCount:f.length,componentDependencies:new Map([...V?.dependencies??[],...l?.dependencies??[]]),referenced:U,scriptColumns:I,importColumns:j,componentColumns:u}}function kr(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function en(e,n){let r=0,i=e.length-1;while(r<i){let a=Math.ceil((r+i)/2);if(e[a]<=n)r=a;else i=a-1}return{line:r+1,column:n-e[r]+1}}function fl(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Fi(e,n,r){let i=e.lineMap.get(n);if(!i)return n<=e.sourceLineCount?{line:n,column:vp(e,n,r)}:null;let a=i.anchor||i.expression?.anchor||i.diagnosticOrigin==="component"?0:Math.max(0,r-1-(i.prefixLength??0));return{line:i.line,column:i.column+a,expression:i.expression,diagnosticOrigin:i.diagnosticOrigin,inGuard:r<=(i.guardPrefixLength??0)}}function io(e){let n=new Set;for(let r of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=r[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let a of Ra(r[2]))n.add(a);for(let a of r[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])n.add(a[1]);if(a[3])n.add(a[3]);for(let l of(a[2]??"").split(",")){let u=l.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(u))n.add(u)}}}return n}var Cr=k(256),Sp=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],Oa=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function $p(e){let n=Array.from(e,(a)=>a===`
|
|
1168
1168
|
`?`
|
|
1169
1169
|
`:" "),r=0,i="";while(r<e.length){let a=e[r],l=e[r+1];if(i){if(a==="\\"){r+=2;continue}if(a===i)i="";r++;continue}if(a==='"'||a==="'"||a==="`"){i=a,r++;continue}if(a==="/"&&l==="/"){while(r<e.length&&e[r]!==`
|
|
1170
1170
|
`)n[r]=e[r],r++;continue}if(a==="/"&&l==="*"){let u=e.indexOf("*/",r+2),f=u===-1?e.length:u+2;for(;r<f;r++)n[r]=e[r];continue}if(a==="{"&&l==="{"&&e.slice(r,r+4)==="{{--"){let u=e.indexOf("--}}",r+4),f=u===-1?e.length:u+4;for(;r<f;r++)n[r]=e[r];continue}r++}return n.join("")}function Ep(e){let n=new Map,r=$p(e).split(`
|
|
1171
1171
|
`),i=e.split(`
|
|
1172
|
-
`);return r.forEach((a,l)=>{
|
|
1172
|
+
`);return r.forEach((a,l)=>{Oa.lastIndex=0;for(let u of a.matchAll(Oa)){let f=u[1]==="-next-line",v=(i[l]??"").slice(0,u.index).trim(),S=f||v===""?l+2:l+1,j=(u[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),L=j.filter((V)=>/\w/.test(V));if(j.length>0&&L.length===0)continue;let M=n.get(S);if(M&&M.size===0)continue;if(L.length===0){n.set(S,new Set);continue}if(M)L.forEach((V)=>M.add(V));else n.set(S,new Set(L))}}),n}function kp(e,n,r){let i=e.get(n);if(!i)return!1;if(i.size===0)return!0;return[...i].some((a)=>r.includes(a))}function Ke(e,n,r,i){let a=typeof r==="boolean"?{enabled:r,failOnViolation:r}:r??{enabled:!1};if(!a.enabled)return;let l=E(e,n,i,JSON.stringify(a)),u=Cr.get(l);if(u!==void 0){if(u&&a.failOnViolation)throw new te(u,i??n);return}let f=a.allowPatterns??[],v=Ep(e),S=[],I=t(e.replace(/\{\{--[\s\S]*?--\}\}/g,(V)=>V.replace(/[^\n]/g," ")));for(let{pattern:V,message:W,suggestion:Z}of Sp){if(f.some((X)=>/\w/.test(X)&&W.includes(X)))continue;V.lastIndex=0;let q=I.match(V);if(q&&q.length>0){let X=I.split(`
|
|
1173
1173
|
`),U=e.split(`
|
|
1174
1174
|
`),H=[];if(X.forEach((pe,Re)=>{if(V.lastIndex=0,V.test(pe)&&!kp(v,Re+1,W))H.push(Re+1)}),H.length===0&&X.some((pe)=>(V.lastIndex=0,V.test(pe))))continue;let re=H.length>0?` (script line${H.length>1?"s":""} ${H.join(", ")})`:"",ce=H.slice(0,3).map((pe)=>` ${pe} | ${(U[pe-1]??"").trim().slice(0,100)}`).join(`
|
|
1175
1175
|
`),le=ce?`
|
|
1176
1176
|
${ce}`:"";S.push(` \u2717 ${W}${re}
|
|
1177
|
-
\u2192 ${Z}${le}`)}}if(S.length===0){
|
|
1177
|
+
\u2192 ${Z}${le}`)}}if(S.length===0){Cr.set(l,"");return}let j=(V)=>{let W=`${process.cwd()}/`;return V.startsWith(W)?V.slice(W.length):V},M=`[STX] DOM API violation in ${i&&i!==n?`${j(i)} (composed into ${j(n)})`:j(n)}:
|
|
1178
1178
|
${S.join(`
|
|
1179
1179
|
`)}
|
|
1180
|
-
Tip: prefer useRef(), navigate(), and composables for component code`;if(
|
|
1181
|
-
`);return{line:r.length,column:r[r.length-1].length+1}}function Vg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function Wg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function qg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function
|
|
1180
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(Cr.set(l,M),console.warn(M),a.failOnViolation)throw new te(M,i??n)}var Cp=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],Rp=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],Ap=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function Hg(e){let n=[],r=[];return Tp(e,n),Ip(e,n,r),Op(e,r),jp(e,n),{valid:n.length===0,errors:n,warnings:r}}function Tp(e,n){let r=(e.match(/\{\{/g)||[]).length,i=(e.match(/\}\}/g)||[]).length;if(r!==i)n.push({type:"expression",message:`Unclosed expression brackets: found ${r} opening '{{' and ${i} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function Ip(e,n,r){for(let i of Cp){let a=new RegExp(`${i.open}(?:\\s|\\()`,"g"),l=new RegExp(i.close,"g"),u=(e.match(a)||[]).length,f=(e.match(l)||[]).length;if(i.altClose){let v=new RegExp(i.altClose,"g");f+=(e.match(v)||[]).length}if(u>f)n.push({type:"directive",message:`Unclosed @${i.name} directive: found ${u} opening and ${f} closing`,suggestion:`Add ${u-f} missing ${i.close} tag(s)`});else if(f>u)r.push({type:"directive",message:`Extra ${i.close} found: ${f-u} more closing than opening`,suggestion:`Check for orphaned ${i.close} tags`})}}function Op(e,n){for(let r of Rp)if(r.pattern.test(e))n.push({type:"syntax",message:r.message,suggestion:r.suggestion})}function jp(e,n){for(let r of Ap)if(r.pattern.test(e))n.push({type:"expression",message:`Security warning: ${r.message}`,suggestion:"Remove dangerous code from template expressions"})}function Ug(e,n){let r=e.slice(0,n).split(`
|
|
1181
|
+
`);return{line:r.length,column:r[r.length-1].length+1}}function Vg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function Wg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function qg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function ja(e,n,r){let i=/^<script\b([^>]*)>/i.exec(e);if(!i||!/(?:^|\s)src\s*=/i.test(i[1]??""))return null;return P(i[0],n,r)+e.slice(i[0].length)}var qn=new T(500),Tr=new Map;function Pa(e){try{let n=Ns.statSync(e);return`${n.size}:${n.mtimeMs}`}catch{return""}}var Ms=new T(1000),Ir=new Map,Or=new T(2000),Pr=new T(500),Va=33554432,Wr=Va;function Pp(e){let n=e.componentRenderCacheBytes;if(typeof n!=="number"||n<0||n===Wr)return;Wr=n,Ds.setMaxBytes(n)}var Ds=new T(2000,{maxBytes:Va,sizeOf:(e)=>e.output.length});function Mp(e){let n=new WeakSet;try{let r=(i)=>{if(i===void 0)return{__stxType:"undefined"};if(typeof i==="bigint")return{__stxType:"bigint",value:i.toString()};if(typeof i==="function"||typeof i==="symbol")throw TypeError("Non-serializable component input");if(i===null||typeof i!=="object")return i;if(n.has(i))throw TypeError("Circular component input");n.add(i);try{if(i instanceof Date)return{__stxType:"date",value:i.toISOString()};if(Array.isArray(i))return i.map(r);let a=Object.getPrototypeOf(i);if(a!==Object.prototype&&a!==null)throw TypeError("Non-plain component input");let l={};for(let u of Object.keys(i).sort())l[u]=r(i[u]);return l}finally{n.delete(i)}};return JSON.stringify(r(e))}catch{return null}}function Dp(e){let n={};for(let[r,i]of Object.entries(e))if(!r.startsWith("__")||r==="__stxServeContext")n[r]=i;return n}function Rr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function po(e){let n=process.cwd(),r=`${n}\x00${e}`,i=Ma.get(r);if(i===void 0)i=Bun.hash(Ua(e,n).split(xe.sep).join("/")).toString(36).slice(0,6),Ma.set(r,i);return i}var Ma=new Map;function Ua(e,n){if(!xe.isAbsolute(e))return e;let r=(i)=>{try{return Ns.realpathSync(i)}catch{return i}};return xe.relative(r(n),r(e))}function Kg(e){return/\bjs\b/.test(e)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(e)}function Ye(e){return!Kg(e)}var Ps=new Map;function ie(e){let n;try{n=JSON.stringify(e)}catch{return new Bun.Transpiler(e)}let r=Ps.get(n);if(r)return r;if(Ps.size>=16)Ps.clear();let i=new Bun.Transpiler(e);return Ps.set(n,i),i}var Da=new WeakMap,Np=256;function Ze(e){try{let n=ie({loader:"ts",target:"browser",define:A()}),r=Da.get(n);if(!r)r=new Map,Da.set(n,r);let i=r.get(e);if(i!==void 0)return i;let a=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");a=a.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let l=[];a=a.replace(/\{!![\s\S]*?!!\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{\{[\s\S]*?\}\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{[\s\S]*?\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`});let u=n.transformSync(a);for(let f=0;f<l.length;f++)u=u.replace(`"__STX_EXPR_${f}__"`,l[f]),u=u.replace(`'__STX_EXPR_${f}__'`,l[f]);if(r.size>=Np){let f=r.keys().next();if(!f.done)r.delete(f.value)}return r.set(e,u),u}catch(n){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",n);return e}}function Lp(e){let n=[],r=new Set,i=0,a=0,l=e.length,u=(M)=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]===M){a++;return}a++}},f=()=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]==="`"){a++;return}if(e[a]==="$"&&e[a+1]==="{"){a+=2;let M=1;while(a<l&&M>0)if(e[a]==="{")M++,a++;else if(e[a]==="}")M--,a++;else if(e[a]==="'"||e[a]==='"')u(e[a]);else if(e[a]==="`")f();else a++;continue}a++}},v=()=>{if(e[a]==="/"&&e[a+1]==="/"){while(a<l&&e[a]!==`
|
|
1182
1182
|
`)a++;return!0}if(e[a]==="/"&&e[a+1]==="*"){a+=2;while(a<l-1&&!(e[a]==="*"&&e[a+1]==="/"))a++;return a+=2,!0}return!1},S=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]),I=()=>{let M=a-1;while(M>=0&&/\s/.test(e[M]))M--;if(M<0)return!0;let V=e[M];if("(,=:[!&|?{};+-*%<>~^".includes(V))return!0;if(!/[\w$]/.test(V))return!1;let W=M;while(W>0&&/[\w$]/.test(e[W-1]))W--;return S.has(e.slice(W,M+1))},j=()=>{a++;let M=!1;while(a<l&&e[a]!==`
|
|
1183
|
-
`){let V=e[a];if(V==="\\"){a+=2;continue}if(V==="[")M=!0;else if(V==="]")M=!1;else if(V==="/"&&!M){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},L=()=>{if(i!==0)return;let M=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(M){let q=M[2].split(",").map((X)=>{let U=X.trim().split(":");return U[U.length-1].trim()});for(let X of q)if(X&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(X)&&!r.has(X))n.push(X),r.add(X);return}let V=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(V){let q=V[2];if(!r.has(q))n.push(q),r.add(q);return}let W=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let q=W[1];if(!r.has(q))n.push(q),r.add(q);return}let Z=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Z){let q=Z[1];if(!r.has(q))n.push(q),r.add(q)}};while(a<l){if(v())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&I()){j();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))L();a++}return n}function zp(e,n,r){for(let i of ee(e)){let a=O(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!kt(a))continue;let l=
|
|
1183
|
+
`){let V=e[a];if(V==="\\"){a+=2;continue}if(V==="[")M=!0;else if(V==="]")M=!1;else if(V==="/"&&!M){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},L=()=>{if(i!==0)return;let M=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(M){let q=M[2].split(",").map((X)=>{let U=X.trim().split(":");return U[U.length-1].trim()});for(let X of q)if(X&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(X)&&!r.has(X))n.push(X),r.add(X);return}let V=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(V){let q=V[2];if(!r.has(q))n.push(q),r.add(q);return}let W=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let q=W[1];if(!r.has(q))n.push(q),r.add(q);return}let Z=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Z){let q=Z[1];if(!r.has(q))n.push(q),r.add(q)}};while(a<l){if(v())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&I()){j();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))L();a++}return n}function zp(e,n,r){for(let i of ee(e)){let a=O(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!kt(a))continue;let l=fn(e.slice(i.bodyStart,i.bodyEnd));if(!l)continue;let u=Object.assign(Object.create(null),r);for(let[f,v]of Object.entries(l.defaults))if(u[f]===void 0)u[f]=Cs(v);for(let f of new Set([...l.propNames,...Object.keys(l.defaults)])){let v=l.localBindings[f]??(l.propBindings[f]?void 0:f);if(v)Object.defineProperty(n,v,{value:u[f],writable:!0,enumerable:!0,configurable:!0})}if(l.identifier)Object.defineProperty(n,l.identifier,{value:u,writable:!0,enumerable:!0,configurable:!0})}}var Bp=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function Xg(e,n){let r=Vt(e),i=e.slice(r).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);if(!i)return null;let a=i[1].toLowerCase();if(!Bp.has(a))return null;let l=new RegExp(`<\\/?${a}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),u=x(e,(I,j)=>(l.lastIndex=j,l.exec(I)?.index===j?l.lastIndex:-1));if(a==="span"&&/\sdata-stx-scope\s*=/.test(u[0]?.token||""))return null;let f=0,v=!1;for(let I of u){if(f+=I.token.startsWith("</")?-1:1,f<0)return null;if(f===0){if(e.slice(I.end).trim())return null;v=!0;break}}if(!v)return null;let S=r+i[0].length;return e.slice(0,S)+n+e.slice(S)}function Ha(e,n){if(!e)return!1;return[...n.additionalComponentsDirs??[],...n.fallbackComponentsDir?[n.fallbackComponentsDir]:[]].some((i)=>{let a=xe.relative(xe.resolve(i),xe.resolve(e));return!a.startsWith("..")&&!xe.isAbsolute(a)})}async function Hr(e,n,r,i,a){let l=e.endsWith(".stx")?e.slice(0,-4):e,u=(ce)=>ce.split("-").map((le)=>le.charAt(0).toUpperCase()+le.slice(1)).join(""),f=r.__importedComponents;if(f){for(let ce of[l,l.toLowerCase(),u(l),J(l)])if(f.has(ce))return!0}let v=[...new Set([`${l}.stx`,`${u(l)}.stx`,`${J(l)}.stx`])],S=typeof a.root==="string"?xe.resolve(a.root):void 0,I=S??xe.dirname(i),j=[],L=(ce)=>{if(ce&&!j.includes(ce))j.push(ce)};for(let ce of us(i,S))L(ce);let M=r.__originalFilePath;if(M)L(xe.join(xe.dirname(M),"components"));if(Ha(n,a))L(a._rootComponentsDir);L(n),L(a._rootComponentsDir),L(xe.join(xe.dirname(i),"components")),L(a.componentsDir);for(let ce of a.additionalComponentsDirs??[])L(ce);let V=a._targetComponentFallbackNames?.some((ce)=>ce.toLowerCase()===l.toLowerCase());if(!V)for(let ce of a._targetComponentDirs??[])L(ce);if(S)L(xe.resolve(S,"resources/views/components")),L(xe.resolve(S,"resources/components")),L(xe.resolve(S,"src/components")),L(xe.resolve(S,"components"));for(let ce of a._layerComponentDirs??[])L(ce);let W=a._pluginComponentDirs;if(Array.isArray(W))for(let ce of W)L(typeof ce==="string"?ce:null);if(L(a.fallbackComponentsDir),V)for(let ce of a._targetComponentDirs??[])L(ce);let Z=a._nativePrimitivesFallback;if(Z&&!Z.except.some((ce)=>ce.toLowerCase()===l.toLowerCase()))L(Z.dir);if(l.startsWith("./")||l.startsWith("../"))return s(xe.resolve(xe.dirname(i),`${l}.stx`));let q=Na(xe.resolve(import.meta.dir,"components")),X=j.map((ce)=>xe.isAbsolute(ce)?ce:xe.resolve(I,ce)),U=`${v.join("\x00")}\x00\x00${X.join("\x00")}`,H=Or.get(U);if(H!==void 0)return H;let re=!1;e:for(let ce of X){if(Na(ce)===q)continue;for(let le of v)if(await s(xe.join(ce,le))){re=!0;break e}}return Or.set(U,re),re}function Na(e){let n=Pr.get(e);if(n!==void 0)return n;let r=e;try{r=Ns.realpathSync(e)}catch{}return Pr.set(e,r),r}function Gg(e){return e==="visible"||e==="idle"||e==="interaction"||e.startsWith("media:")}function El(e){if(!e)return!1;let n=e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(n)}function Wp(e,n,r){if(!e.includes("{{")&&!e.includes("{!!"))return e;let i=(a,l)=>{let u;try{u=N(a,n)}catch{return l}if(u===void 0||u===null)return"";let f=String(u);if(/<\/style/i.test(f))return console.warn(`[stx] a <style> expression in ${r??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return f};return e.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>i(l,a)).replace(/\{\{([\s\S]*?)\}\}/g,(a,l)=>i(l,a))}var La=new Set;function za(e,n,r,i){let a=`${e}\x00${n}\x00${i??""}`;if(!process.env.STX_DEBUG&&La.has(a))return;La.add(a);let l=n?` used in ${n}`:"",u=i?` Cause: ${i}.`:"",f=r.length>0?`
|
|
1184
1184
|
searched:
|
|
1185
1185
|
${r.map((v)=>` - ${v}`).join(`
|
|
1186
|
-
`)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function Fa(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var Fp=new Set(["for","if","show","key","ref","class","className","style"]),Va=new Set,Za="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",Tl=new RegExp(`\\b(?:${Za})\\s*(?:<[^>]*>)?\\s*\\(`);function qi(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${Za})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Qe(e,n,r,i,a,l,u,f=new Set,v,S=mt(a),I,j=e){let{extractVariables:L}=await o("stx/variable-extractor",()=>import("./chunk-amye7vb0.js")),M=f??new Set;if(M.has(e))return`[Circular component reference: ${e}]`;let V=new Set(M);V.add(e);let W=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let Z=W&&W!=="load"&&Gg(W)?W:"";try{let q=(ge)=>ge.split("-").map((ve)=>ve.charAt(0).toUpperCase()+ve.slice(1)).join(""),X=j.endsWith(".stx")?j.slice(0,-4):j,U=null,H=a.__importedComponents;if(H){let ge=[X,X.toLowerCase(),q(X),J(X)];for(let ve of ge)if(H.has(ve)){U=H.get(ve);break}}let re=[];if(!U){let ge=[`${X}.stx`,`${q(X)}.stx`,`${J(X)}.stx`],ve=[...new Set(ge)],ze=a.__originalFilePath,Se=[];for(let Pe of ps(l))if(!Se.includes(Pe))Se.push(Pe);let pt=Se.length;for(let Pe of u._layerComponentDirs??[])if(!Se.includes(Pe))Se.push(Pe);if(ze){let Pe=xe.join(xe.dirname(ze),"components");Se.push(Pe)}let tt=u._rootComponentsDir;if(typeof tt==="string"&&qa(i,u)&&!Se.includes(tt))Se.push(tt);if(i&&!Se.includes(i))Se.push(i);if(typeof tt==="string"&&!Se.includes(tt))Se.push(tt);let It=xe.join(xe.dirname(l),"components");if(!Se.includes(It))Se.push(It);if(u.componentsDir&&u.componentsDir!==i&&!Se.includes(u.componentsDir))Se.push(u.componentsDir);for(let Pe of u.additionalComponentsDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let nn=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(X),Pt=(I?.events??[]).map((Pe)=>Pe.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),ts=Object.hasOwn(n,"checked")||Boolean(I?.reactiveProps?.includes("checked")),Ws=Object.hasOwn(n,"value")||Boolean(I?.reactiveProps?.includes("value")),Fs=!Pt.includes("valuechange")&&(ts||Pt.includes("change")&&!Ws),Ft=u._nativeHostAttrs&&/^textinput$/i.test(X),sn=Pt.includes("update:value")&&!Pt.includes("input"),kn=u._nativeHostAttrs&&/^video$/i.test(X),Vs=u._nativeHostAttrs&&/^image$/i.test(X),ns=eo([...Object.keys(n),...I?.reactiveProps??[]],I?.events,n),rn=Object.hasOwn(n,"src")||Boolean(I?.reactiveProps?.includes("src")),ss=Object.hasOwn(n,"source")||Boolean(I?.reactiveProps?.includes("source")),rs=kn&&(rn||ss)&&(I?.events??[]).every((Pe)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Pe.replace(/^@/,"").split(".")[0])),is=new Set(["","primary","secondary","outline","ghost","danger"]),os=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",as=u._nativeHostAttrs&&/^button$/i.test(X)&&!is.has(os),ei=u._targetComponentFallbackNames?.some((Pe)=>Pe.toLowerCase()===X.toLowerCase())??!1,Us=ei&&(!nn||Fs)&&(!Ft||sn)&&(!kn||rs)&&(!Vs||ns)&&!as;for(let Pe of Us?[]:u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let on=typeof u.root==="string"?xe.resolve(u.root):void 0,ti=on??xe.dirname(l),an=[];if(on)an.push(xe.resolve(on,"resources/views/components")),an.push(xe.resolve(on,"resources/components")),an.push(xe.resolve(on,"src/components")),an.push(xe.resolve(on,"components"));an.push(xe.resolve(import.meta.dir,"components"));for(let Pe of an)if(!Se.includes(Pe))Se.push(Pe);if(ei){let Pe=(u._componentPackageDirs??[]).filter((bt)=>typeof bt==="string"&&bt.length>0),Ot=(Us?Pe.length?Pe:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((bt)=>typeof bt==="string"&&bt.length>0);if(Ot.length){let bt=Se.slice(pt).map((dt)=>xe.isAbsolute(dt)?dt:xe.resolve(ti,dt)).filter((dt)=>!Ot.includes(dt)),ls=`${X}\x00${bt.join("\x00")}`,Ct=Or.get(ls);if(Ct===void 0){Ct=!1;for(let dt of bt){for(let Ht of ve)if(await s(xe.join(dt,Ht))){Ct=!0;break}if(Ct)break}Or.set(ls,Ct)}if(!Ct){for(let dt of Ot){let Ht=Se.indexOf(dt);if(Ht>=0)Se.splice(Ht,1)}Se.splice(pt,0,...Ot)}}}let ni=u._pluginComponentDirs;if(Array.isArray(ni)){for(let Pe of ni)if(typeof Pe==="string"&&!Se.includes(Pe))Se.push(Pe)}if(u.fallbackComponentsDir&&!Se.includes(u.fallbackComponentsDir))Se.push(u.fallbackComponentsDir);if(Us){for(let Pe of u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe)}let cs=u._nativePrimitivesFallback;if(cs&&!cs.except.some((Pe)=>Pe.toLowerCase()===X.toLowerCase())&&!Se.includes(cs.dir))Se.push(cs.dir);let si=[...new Set(Se.map((Pe)=>{if(!Pe)return Pe;return xe.isAbsolute(Pe)?Pe:xe.resolve(ti,Pe)}))];Se.length=0,Se.push(...si);let Hs=`${X}\x00${l}\x00${si.join("\x00")}`,Ks=Ds.get(Hs);if(Ks)if(await s(Ks))U=Ks;else Ds.delete(Hs);if(!U&&(X.startsWith("./")||X.startsWith("../")))U=xe.resolve(xe.dirname(l),`${X}.stx`),re.push(U);else if(!U)for(let Pe of Se){if(!Pe)continue;for(let Ot of ve){let bt=xe.join(Pe,Ot);if(re.push(bt),await s(bt)){U=bt;break}}if(U)break;if(!U)try{let Ot=await import("fs");if(!Ot.statSync(Pe,{throwIfNoEntry:!1})?.isDirectory())continue;let ls=8,Ct=[{path:Pe,depth:0}];while(Ct.length>0&&!U){let dt=Ct.pop();if(dt.depth>=ls)continue;let Ht;try{Ht=Ot.readdirSync(dt.path,{withFileTypes:!0})}catch{continue}for(let us of Ht){if(!us.isDirectory())continue;if(us.name==="node_modules"||us.name.startsWith("."))continue;let ri=xe.join(dt.path,us.name);for(let cc of ve){let qs=xe.join(ri,cc);if(re.push(qs),await s(qs)){U=qs;break}}if(U)break;Ct.push({path:ri,depth:dt.depth+1})}}}catch{}if(U)break}if(U)Ds.set(Hs,U)}if(!U||!await s(U))return Wa(e,l,re),Fa(e);v.add(U);let ce;if(Zn.has(U)&&Ir.get(U)===Da(U))ce=Zn.get(U);else try{let ge=Da(U);ce=await Bun.file(U).text(),Zn.set(U,ce),Ir.set(U,ge)}catch(ge){let ve=ge instanceof Error?ge.message:String(ge);return Wa(e,l,[U],ve),Fa(e)}if(I)for(let ge of new Set([...Object.keys(n),...I.reactiveProps??[]])){let ve=ge.toLowerCase();if(ve.startsWith("aria-")||ve.startsWith("data-"))continue;let ze=ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${ze}\\b`).test(ce))I.declaredProps.add(ge);if(new RegExp(`\\$props\\s*(?:\\.\\s*${ze}\\b|\\[\\s*['"]${ze}['"]\\s*\\])`).test(ce)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${ze}['"]`).test(ce))I.consumedProps?.add(ge)}if(I?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(ce))for(let ge of I.reactiveProps){if(Fp.has(ge)||I.consumedProps?.has(ge))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(ce))continue;let ve=`${U}\x00${ge}`;if(Va.has(ve))continue;Va.add(ve),console.warn(`[stx] ${xe.basename(U)} reads \`${ge}\` with defineProps(), which is not live, but ${xe.basename(l)} binds it (:${ge}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${ge}').`)}let le=new Set(["__originalFilePath","__importedComponents",hs,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),pe={};for(let[ge,ve]of Object.entries(a))if(!ge.startsWith("__")||le.has(ge))pe[ge]=ve;let Re=S.length>0?{[vs]:[...S]}:{},Ae=r;if(r.includes("@include")){let{processIncludes:ge}=await o("stx/includes",()=>import("./chunk-kt3f4rpy.js"));Ae=await ge(r,a,l,u,v)}if(/<[A-Z][\w.-]*[\s/>]/.test(Ae)){let{processComponents:ge}=await o("stx/component-renderer",()=>import("./chunk-s91tcznf.js")),ve={...a,__processedComponents:M,...Re};Ae=await ge(Ae,ve,l,u,v);let ze=ve.__stx_preserved_client_expressions;if(Array.isArray(ze)&&ze.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...ze])]}let we=[];if(El(Ae)){let{processExpressions:ge}=await o("stx/expressions",()=>import("./chunk-4jmztn9d.js")),ve=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...Re}:S.length>0?{...a,...Re}:a;Ae=ge(Ae,ve,l);for(let ze of Ae.matchAll(/\{\{([\s\S]*?)\}\}/g))we.push(ze[1].trim())}let fe=new Set(Array.isArray(a.__stx_client_declared_names)?a.__stx_client_declared_names:[]),We=[];if(fe.size>0&&Ae)for(let ge of Ae.matchAll(/<[A-Z][\w.-]*\b([^>]*)>/g))for(let ve of ge[1].matchAll(/\s(?:v-model(?::[\w-]+)?|:[\w-]+)\s*=\s*"([^"]*)"/g)){let ze=ve[1].trim();try{if(ze&&Ee(ze).some((Se)=>fe.has(Se)))We.push(ze)}catch{}}let Fe=se(Ae),it=[],ot=Fe.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(ge,ve)=>{let ze=Fe.scripts[Number(ve)]||"",Se=ze.match(/^<script\b([^>]*)>/i)?.[1]||"",pt=Se.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),tt=!pt||["module","text/javascript","application/javascript"].includes(pt),It=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${Se}`);if(!/\bserver\b/i.test(Se)&&tt&&!It)return it.push(ze),"";return ze}),{extractSlotContent:At}=await o("stx/slots",()=>import("./chunk-p2b90rz9.js")),St=At(ot),at={};if(St.defaultSlot?.trim())at.default=St.defaultSlot;for(let[ge,ve]of St.namedSlots)at[ge]=ve.content;let $t=a.__stx_scope_seq??={n:0,key:po(String(a.__filename??l))},Ve=Ka(e,process.cwd()),ut=`stx_${(Ve.endsWith(".stx")?Ve.slice(0,-4):Ve).replace(/[^a-zA-Z0-9]/g,"_")}_${++$t.n}_${$t.key}`,De={...pe,$uid:ut,$native:u._nativeHostAttrs===!0,...n,props:n,slot:ot,$slots:at,__processedComponents:V,__sections:{},__stx_signals_gate:Me(ce)||El(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...we],__stx_caller_client_bindings:[...Array.isArray(a.__stx_caller_client_bindings)?a.__stx_caller_client_bindings:[],...We]};if(/import\s/.test(ce)){De.__importedComponents=new Map(De.__importedComponents);let{processESImports:ge}=await o("stx/component-renderer",()=>import("./chunk-s91tcznf.js"));ce=await ge(ce,De,U,u,v)}zp(ce,De,n);let Mt=ce,Dt=B(Mt);if(Dt)Mt=Dt.content.trim();let Bs=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,mn=[...ce.matchAll(Bs)];for(let[,ge,ve]of mn)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(ge))Ke(ve,U,u.strict);let xt=[],hn=null,Nt=mn.some((ge)=>/\bserver\b/.test(ge[1]||"")&&/\bcache\b/.test(ge[1]||"")),en=null,xn=null,bn=null,Xn=0,yn=null;if(Pp(u),Nt&&Vr>0){let ge=Mp({props:n,slot:Ae,slotContext:r.trim()?Dp(pe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...S].sort(),layers:u._layerGraph?.layers.map((ve)=>ve.configFile),uid:ut});if(ge!==null){en=`${U}\x00${E(ce)}\x00${ge}`;let ve=Ns.get(en);if(ve){for(let ze of ve.dependencies)v.add(ze);if(Zi(a,ve.clientFactories),$t.n+=ve.uidsConsumed,ve.preservedClientExpressions.length>0){let ze=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let Se of ve.preservedClientExpressions)ze.add(Se);a.__stx_preserved_client_expressions=[...ze]}return ve.output}xn=new Set(v),bn=Ti(a),Xn=$t.n,yn=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let Tt=new Set;for(let ge of mn){let ve=ge[1]||"",ze=ge[2]||"",Se=ve.includes("server");if(Ye(ve)&&ze.trim())ze=Ze(ze);if(Se&&ze){for(let tt of ye(ze))Tt.add(tt);try{await L(ze,De,U,{onFailure:(tt)=>{if(tt.kind!=="unknown")hn=tt.kind}})}catch(tt){}}if(!Se){let tt=ze.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),It=tt.includes("{{")&&tt.includes("}}"),nn=tt.includes("{!!")&&tt.includes("!!}");if(It||nn)tt=Xi(tt,De,U);let Pt=ve.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");xt.push(`<script${Pt}>${tt}</script>`)}}let jt=se(ce).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),_n=jt?jt[1]:"",ue=jt?jt[2]:"",de="",$e=_n&&/\bscoped\b/i.test(_n);if(jt)de=`<style${_n}>${Wp(ue,De,U)}</style>`;let Te=Mt;if(Te=Te.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),jt)Te=Te.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let ge=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,ve=[];if(Te=Te.replace(ge,(ze,Se)=>{let pt=Se.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(pt)ve.push(`<style${pt[1]}>${pt[2]}</style>`);return""}),Te=Te.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),ve.length>0)de=`${de}${ve.join(`
|
|
1187
|
-
`)}`}if(r&&Te.includes("{{ text || slot }}"))Te=Te.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:st}=await o("stx/slots",()=>import("./chunk-
|
|
1188
|
-
`)),
|
|
1189
|
-
${
|
|
1190
|
-
return (${
|
|
1191
|
-
}`:
|
|
1192
|
-
`+
|
|
1186
|
+
`)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function Ba(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var Fp=new Set(["for","if","show","key","ref","class","className","style"]),Wa=new Set,Ka="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",Tl=new RegExp(`\\b(?:${Ka})\\s*(?:<[^>]*>)?\\s*\\(`);function qi(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${Ka})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Qe(e,n,r,i,a,l,u,f=new Set,v,S=mt(a),I,j=e){let{extractVariables:L}=await o("stx/variable-extractor",()=>import("./chunk-3760wpvw.js")),M=f??new Set;if(M.has(e))return`[Circular component reference: ${e}]`;let V=new Set(M);V.add(e);let W=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let Z=W&&W!=="load"&&Gg(W)?W:"";try{let q=(ge)=>ge.split("-").map((ve)=>ve.charAt(0).toUpperCase()+ve.slice(1)).join(""),X=j.endsWith(".stx")?j.slice(0,-4):j,U=null,H=a.__importedComponents;if(H){let ge=[X,X.toLowerCase(),q(X),J(X)];for(let ve of ge)if(H.has(ve)){U=H.get(ve);break}}let re=[];if(!U){let ge=[`${X}.stx`,`${q(X)}.stx`,`${J(X)}.stx`],ve=[...new Set(ge)],ze=a.__originalFilePath,Se=[];for(let Pe of us(l))if(!Se.includes(Pe))Se.push(Pe);let pt=Se.length;for(let Pe of u._layerComponentDirs??[])if(!Se.includes(Pe))Se.push(Pe);if(ze){let Pe=xe.join(xe.dirname(ze),"components");Se.push(Pe)}let tt=u._rootComponentsDir;if(typeof tt==="string"&&Ha(i,u)&&!Se.includes(tt))Se.push(tt);if(i&&!Se.includes(i))Se.push(i);if(typeof tt==="string"&&!Se.includes(tt))Se.push(tt);let It=xe.join(xe.dirname(l),"components");if(!Se.includes(It))Se.push(It);if(u.componentsDir&&u.componentsDir!==i&&!Se.includes(u.componentsDir))Se.push(u.componentsDir);for(let Pe of u.additionalComponentsDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let sn=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(X),Pt=(I?.events??[]).map((Pe)=>Pe.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),es=Object.hasOwn(n,"checked")||Boolean(I?.reactiveProps?.includes("checked")),Bs=Object.hasOwn(n,"value")||Boolean(I?.reactiveProps?.includes("value")),Ws=!Pt.includes("valuechange")&&(es||Pt.includes("change")&&!Bs),Ft=u._nativeHostAttrs&&/^textinput$/i.test(X),rn=Pt.includes("update:value")&&!Pt.includes("input"),Cn=u._nativeHostAttrs&&/^video$/i.test(X),Fs=u._nativeHostAttrs&&/^image$/i.test(X),ts=eo([...Object.keys(n),...I?.reactiveProps??[]],I?.events,n),on=Object.hasOwn(n,"src")||Boolean(I?.reactiveProps?.includes("src")),ns=Object.hasOwn(n,"source")||Boolean(I?.reactiveProps?.includes("source")),ss=Cn&&(on||ns)&&(I?.events??[]).every((Pe)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Pe.replace(/^@/,"").split(".")[0])),rs=new Set(["","primary","secondary","outline","ghost","danger"]),is=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",os=u._nativeHostAttrs&&/^button$/i.test(X)&&!rs.has(is),Qr=u._targetComponentFallbackNames?.some((Pe)=>Pe.toLowerCase()===X.toLowerCase())??!1,Vs=Qr&&(!sn||Ws)&&(!Ft||rn)&&(!Cn||ss)&&(!Fs||ts)&&!os;for(let Pe of Vs?[]:u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let an=typeof u.root==="string"?xe.resolve(u.root):void 0,ei=an??xe.dirname(l),cn=[];if(an)cn.push(xe.resolve(an,"resources/views/components")),cn.push(xe.resolve(an,"resources/components")),cn.push(xe.resolve(an,"src/components")),cn.push(xe.resolve(an,"components"));cn.push(xe.resolve(import.meta.dir,"components"));for(let Pe of cn)if(!Se.includes(Pe))Se.push(Pe);if(Qr){let Pe=(u._componentPackageDirs??[]).filter((bt)=>typeof bt==="string"&&bt.length>0),Ot=(Vs?Pe.length?Pe:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((bt)=>typeof bt==="string"&&bt.length>0);if(Ot.length){let bt=Se.slice(pt).map((dt)=>xe.isAbsolute(dt)?dt:xe.resolve(ei,dt)).filter((dt)=>!Ot.includes(dt)),cs=`${X}\x00${bt.join("\x00")}`,Ct=Ir.get(cs);if(Ct===void 0){Ct=!1;for(let dt of bt){for(let Ht of ve)if(await s(xe.join(dt,Ht))){Ct=!0;break}if(Ct)break}Ir.set(cs,Ct)}if(!Ct){for(let dt of Ot){let Ht=Se.indexOf(dt);if(Ht>=0)Se.splice(Ht,1)}Se.splice(pt,0,...Ot)}}}let ti=u._pluginComponentDirs;if(Array.isArray(ti)){for(let Pe of ti)if(typeof Pe==="string"&&!Se.includes(Pe))Se.push(Pe)}if(u.fallbackComponentsDir&&!Se.includes(u.fallbackComponentsDir))Se.push(u.fallbackComponentsDir);if(Vs){for(let Pe of u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe)}let as=u._nativePrimitivesFallback;if(as&&!as.except.some((Pe)=>Pe.toLowerCase()===X.toLowerCase())&&!Se.includes(as.dir))Se.push(as.dir);let ni=[...new Set(Se.map((Pe)=>{if(!Pe)return Pe;return xe.isAbsolute(Pe)?Pe:xe.resolve(ei,Pe)}))];Se.length=0,Se.push(...ni);let Us=`${X}\x00${l}\x00${ni.join("\x00")}`,Hs=Ms.get(Us);if(Hs)if(await s(Hs))U=Hs;else Ms.delete(Us);if(!U&&(X.startsWith("./")||X.startsWith("../")))U=xe.resolve(xe.dirname(l),`${X}.stx`),re.push(U);else if(!U)for(let Pe of Se){if(!Pe)continue;for(let Ot of ve){let bt=xe.join(Pe,Ot);if(re.push(bt),await s(bt)){U=bt;break}}if(U)break;if(!U)try{let Ot=await import("fs");if(!Ot.statSync(Pe,{throwIfNoEntry:!1})?.isDirectory())continue;let cs=8,Ct=[{path:Pe,depth:0}];while(Ct.length>0&&!U){let dt=Ct.pop();if(dt.depth>=cs)continue;let Ht;try{Ht=Ot.readdirSync(dt.path,{withFileTypes:!0})}catch{continue}for(let ls of Ht){if(!ls.isDirectory())continue;if(ls.name==="node_modules"||ls.name.startsWith("."))continue;let si=xe.join(dt.path,ls.name);for(let oc of ve){let Ks=xe.join(si,oc);if(re.push(Ks),await s(Ks)){U=Ks;break}}if(U)break;Ct.push({path:si,depth:dt.depth+1})}}}catch{}if(U)break}if(U)Ms.set(Us,U)}if(!U||!await s(U))return za(e,l,re),Ba(e);v.add(U);let ce;if(qn.has(U)&&Tr.get(U)===Pa(U))ce=qn.get(U);else try{let ge=Pa(U);ce=await Bun.file(U).text(),qn.set(U,ce),Tr.set(U,ge)}catch(ge){let ve=ge instanceof Error?ge.message:String(ge);return za(e,l,[U],ve),Ba(e)}if(I)for(let ge of new Set([...Object.keys(n),...I.reactiveProps??[]])){let ve=ge.toLowerCase();if(ve.startsWith("aria-")||ve.startsWith("data-"))continue;let ze=ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${ze}\\b`).test(ce))I.declaredProps.add(ge);if(new RegExp(`\\$props\\s*(?:\\.\\s*${ze}\\b|\\[\\s*['"]${ze}['"]\\s*\\])`).test(ce)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${ze}['"]`).test(ce))I.consumedProps?.add(ge)}if(I?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(ce))for(let ge of I.reactiveProps){if(Fp.has(ge)||I.consumedProps?.has(ge))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${ge.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(ce))continue;let ve=`${U}\x00${ge}`;if(Wa.has(ve))continue;Wa.add(ve),console.warn(`[stx] ${xe.basename(U)} reads \`${ge}\` with defineProps(), which is not live, but ${xe.basename(l)} binds it (:${ge}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${ge}').`)}let le=new Set(["__originalFilePath","__importedComponents",ms,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),pe={};for(let[ge,ve]of Object.entries(a))if(!ge.startsWith("__")||le.has(ge))pe[ge]=ve;let Re=S.length>0?{[ws]:[...S]}:{},Ae=r;if(r.includes("@include")){let{processIncludes:ge}=await o("stx/includes",()=>import("./chunk-2cbrcb9m.js"));Ae=await ge(r,a,l,u,v)}if(/<[A-Z][\w.-]*[\s/>]/.test(Ae)){let{processComponents:ge}=await o("stx/component-renderer",()=>import("./chunk-dqt1kw68.js")),ve={...a,__processedComponents:M,...Re};Ae=await ge(Ae,ve,l,u,v);let ze=ve.__stx_preserved_client_expressions;if(Array.isArray(ze)&&ze.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...ze])]}let we=[];if(El(Ae)){let{processExpressions:ge}=await o("stx/expressions",()=>import("./chunk-pmmctgdd.js")),ve=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...Re}:S.length>0?{...a,...Re}:a;Ae=ge(Ae,ve,l);for(let ze of Ae.matchAll(/\{\{([\s\S]*?)\}\}/g))we.push(ze[1].trim())}let fe=new Set(Array.isArray(a.__stx_client_declared_names)?a.__stx_client_declared_names:[]),We=[];if(fe.size>0&&Ae)for(let ge of Ae.matchAll(/<[A-Z][\w.-]*\b([^>]*)>/g))for(let ve of ge[1].matchAll(/\s(?:v-model(?::[\w-]+)?|:[\w-]+)\s*=\s*"([^"]*)"/g)){let ze=ve[1].trim();try{if(ze&&Ee(ze).some((Se)=>fe.has(Se)))We.push(ze)}catch{}}let Fe=se(Ae),it=[],ot=Fe.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(ge,ve)=>{let ze=Fe.scripts[Number(ve)]||"",Se=ze.match(/^<script\b([^>]*)>/i)?.[1]||"",pt=Se.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),tt=!pt||["module","text/javascript","application/javascript"].includes(pt),It=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${Se}`);if(!/\bserver\b/i.test(Se)&&tt&&!It)return it.push(ze),"";return ze}),{extractSlotContent:At}=await o("stx/slots",()=>import("./chunk-e4fseqnv.js")),St=At(ot),at={};if(St.defaultSlot?.trim())at.default=St.defaultSlot;for(let[ge,ve]of St.namedSlots)at[ge]=ve.content;let $t=a.__stx_scope_seq??={n:0,key:po(String(a.__filename??l))},Ve=Ua(e,process.cwd()),ut=`stx_${(Ve.endsWith(".stx")?Ve.slice(0,-4):Ve).replace(/[^a-zA-Z0-9]/g,"_")}_${++$t.n}_${$t.key}`,De={...pe,$uid:ut,$native:u._nativeHostAttrs===!0,...n,props:n,slot:ot,$slots:at,__processedComponents:V,__sections:{},__stx_signals_gate:Me(ce)||El(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...we],__stx_caller_client_bindings:[...Array.isArray(a.__stx_caller_client_bindings)?a.__stx_caller_client_bindings:[],...We]};if(/import\s/.test(ce)){De.__importedComponents=new Map(De.__importedComponents);let{processESImports:ge}=await o("stx/component-renderer",()=>import("./chunk-dqt1kw68.js"));ce=await ge(ce,De,U,u,v)}zp(ce,De,n);let Mt=ce,Dt=B(Mt);if(Dt)Mt=Dt.content.trim();let zs=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,hn=[...ce.matchAll(zs)];for(let[,ge,ve]of hn)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(ge))Ke(ve,U,u.strict);let xt=[],xn=null,Nt=hn.some((ge)=>/\bserver\b/.test(ge[1]||"")&&/\bcache\b/.test(ge[1]||"")),tn=null,bn=null,yn=null,Jn=0,_n=null;if(Pp(u),Nt&&Wr>0){let ge=Mp({props:n,slot:Ae,slotContext:r.trim()?Dp(pe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...S].sort(),layers:u._layerGraph?.layers.map((ve)=>ve.configFile),uid:ut});if(ge!==null){tn=`${U}\x00${E(ce)}\x00${ge}`;let ve=Ds.get(tn);if(ve){for(let ze of ve.dependencies)v.add(ze);if(Pi(a,ve.clientFactories),$t.n+=ve.uidsConsumed,ve.preservedClientExpressions.length>0){let ze=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let Se of ve.preservedClientExpressions)ze.add(Se);a.__stx_preserved_client_expressions=[...ze]}return ve.output}bn=new Set(v),yn=Ai(a),Jn=$t.n,_n=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let Tt=new Set;for(let ge of hn){let ve=ge[1]||"",ze=ge[2]||"",Se=ve.includes("server");if(Ye(ve)&&ze.trim())ze=Ze(ze);if(Se&&ze){for(let tt of ye(ze))Tt.add(tt);try{await L(ze,De,U,{onFailure:(tt)=>{if(tt.kind!=="unknown")xn=tt.kind}})}catch(tt){}}if(!Se){let tt=ze.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),It=tt.includes("{{")&&tt.includes("}}"),sn=tt.includes("{!!")&&tt.includes("!!}");if(It||sn)tt=Xi(tt,De,U);let Pt=ve.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");xt.push(`<script${Pt}>${tt}</script>`)}}let jt=se(ce).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),wn=jt?jt[1]:"",ue=jt?jt[2]:"",de="",$e=wn&&/\bscoped\b/i.test(wn);if(jt)de=`<style${wn}>${Wp(ue,De,U)}</style>`;let Te=Mt;if(Te=Te.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),jt)Te=Te.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let ge=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,ve=[];if(Te=Te.replace(ge,(ze,Se)=>{let pt=Se.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(pt)ve.push(`<style${pt[1]}>${pt[2]}</style>`);return""}),Te=Te.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),ve.length>0)de=`${de}${ve.join(`
|
|
1187
|
+
`)}`}if(r&&Te.includes("{{ text || slot }}"))Te=Te.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:st}=await o("stx/slots",()=>import("./chunk-e4fseqnv.js")),{defaultSlot:ct,namedSlots:nn}=St,Gr=a.__stx_signals_gate===!0&&/\s(?:@[\w:.-]+|x-on:[\w:.-]+)\s*=/.test(ot),Lt=xt.length>0&&dr(Te)||u._nativeHostAttrs===!0&&xt.length>0||Gr&&xt.length>0||xt.some((ge)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(ge)),Xn=(ge)=>Lt?qo(ge,ut):ge,Gn=new Map([...nn].map(([ge,ve])=>[ge,{...ve,content:Xn(ve.content)}]));Te=await st(Te,Lt?Ko(Xn(ct),ut):ct,Gn,De,Lt?ut:"");let vn=qi(xt),Sn=(Array.isArray(De.__stx_client_signal_names)?De.__stx_client_signal_names:[]).filter((ge)=>!Tt.has(ge));if(vn.length>0||Sn.length>0)De.__stx_client_signal_names=[...new Set([...Sn,...vn])];else delete De.__stx_client_signal_names;let En=io(xt.join(`
|
|
1188
|
+
`)),kn=(Array.isArray(De.__stx_client_declared_names)?De.__stx_client_declared_names:[]).filter((ge)=>!Tt.has(ge)&&!(ge in n));if(En.size>0||kn.length>0)De.__stx_client_declared_names=[...new Set([...kn,...En])];else delete De.__stx_client_declared_names;let zt=S.filter((ge)=>!Tt.has(ge)&&!(ge in n));if(zt.length>0)De[ws]=zt;let Yn={...u,_rootComponentsDir:u._rootComponentsDir||u.componentsDir,componentsDir:xe.dirname(U),skipSignalsRuntime:!0,skipEventDirectives:u._nativeHostAttrs===!0||Lt||xt.length===0,defaultLayout:void 0};De.__stxProcessingDepth=(a.__stxProcessingDepth||0)+1;let{processDirectives:Qn}=await o("stx/process",()=>import("./chunk-ssdjny2r.js")),Be=await Qn(Te,De,U,Yn,v),Et=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let ge of Be.matchAll(/\{\{([\s\S]*?)\}\}/g))Et.add(ge[1].trim());if(Et.size>0)a.__stx_preserved_client_expressions=[...Et];let Bt=ut,ft=Be;if(Lt){let ge="";if(Object.keys(n).length>0)try{ge=` data-stx-props="${Rr(JSON.stringify(n))}"`}catch{}let ve=Z?` stx-hydrate="${Rr(Z)}"`:"",ze=Object.fromEntries(Object.entries(at).map(([Ft,rn])=>[Ft,Boolean(rn)])),Se=Object.keys(ze).length>0?` data-stx-slots="${Rr(JSON.stringify(ze))}"`:"",pt=` data-stx-scope="${Bt}"${ge}${Se}${ve}`,tt=Be.slice(Vt(Be)),It=/^<span(?=[\s/>])/i.test(tt),sn=/^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(tt),Pt=/^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(tt),es=It?"span":"div",Bs=sn&&u._nativeHostAttrs?' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"':Pt&&u._nativeHostAttrs?' style="width:100%;height:100%"':It||sn?' style="display:contents"':"";ft=Xg(Be,pt)??`<${es}${pt} data-stx-component-wrapper${Bs}>${Be}</${es}>`;let Ws=await Promise.all(xt.map(async(Ft)=>{let rn=Ft.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!rn)return Ft;let[,Cn,Fs]=rn,ts=ja(Ft,De,U);if(ts!==null)return ts;let on=await Up(Fs,U,u.buildMode==="compile"),ns=In(on.clientCode,Ge(De)),{vendorStyleTags:ss}=on,rs=ns?`function(__scopeId) {
|
|
1189
|
+
${ns}
|
|
1190
|
+
return (${on.factoryBody})(__scopeId);
|
|
1191
|
+
}`:on.factoryBody,is=Z?null:or(a,rs),os=is?`window.__stxComponentFactories[${JSON.stringify(is)}](${JSON.stringify(Bt)});`:`(${rs})(${JSON.stringify(Bt)});`;if(Z)return`${ss}<script type="stx/island" data-stx-island="${Bt}" data-stx-scoped data-stx-owner="${Bt}"${Cn}>${me(os)}</script>`;return`${ss}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Bt}"${Cn}>${me(os)}</script>`}));if(ft=ft+`
|
|
1192
|
+
`+Ws.join(`
|
|
1193
1193
|
`),de)ft+=`
|
|
1194
1194
|
`+de}else{if(de)ft+=`
|
|
1195
|
-
`+de;if(xt.length>0){let ge=De.__stx_event_bindings||[],ve=Ge(De),ze=await Promise.all(xt.map(async(Se)=>{let pt=
|
|
1195
|
+
`+de;if(xt.length>0){let ge=De.__stx_event_bindings||[],ve=Ge(De),ze=await Promise.all(xt.map(async(Se)=>{let pt=ja(Se,De,U);if(pt!==null)return pt;let tt=Se.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!tt)return Se;return await Je(tt[1],{eventBindings:ge,templateContent:ft,filePath:U,projectRoot:process.cwd(),serverData:ve,instanceId:ut})}));ft+=`
|
|
1196
1196
|
`+ze.join(`
|
|
1197
|
-
`),De.__stx_event_bindings=[]}}if($e){let ge=ao(ft,U);if(ge.hasScoped)ft=ge.html}if(
|
|
1197
|
+
`),De.__stx_event_bindings=[]}}if($e){let ge=ao(ft,U);if(ge.hasScoped)ft=ge.html}if(tn&&bn){let ge=Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[];Ds.set(tn,{output:ft,dependencies:[...v].filter((ve)=>!bn.has(ve)),clientFactories:yn?Ti(a,yn):[],uidsConsumed:$t.n-Jn,preservedClientExpressions:_n?ge.filter((ve)=>!_n.has(ve)):[]})}if(xn)ft=`<!--stx-render-failed:${xn}-->${ft}`;return it.length>0?`${ft}
|
|
1198
1198
|
${it.join(`
|
|
1199
|
-
`)}`:ft}catch(q){if(q instanceof te)throw q;return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{M.delete(e)}}async function s(e){return Bun.file(e).exists()}function
|
|
1199
|
+
`)}`:ft}catch(q){if(q instanceof te)throw q;return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{M.delete(e)}}async function s(e){return Bun.file(e).exists()}function Vr(e,n){let r=xe.resolve(n),i=xe.resolve(e),a=r.endsWith(xe.sep)?r:r+xe.sep;if(i===r||i.startsWith(a))return i;return null}async function Fa(e,n,r,i){let a=n.startsWith("layouts/")?n.slice(8):n,l=xe.join(e,a);for(let u of l.endsWith(".stx")?[l]:[l,`${l}.stx`])if(await s(u)){if(i)console.log(`Found layout in ${e}: ${u}`);return r?.add(u),u}return null}async function On(e,n,r,i){let a=await Vp(e,n,r,i);if(a===null)return null;let l=Vr(a,process.cwd());if(l)return l;let u=[r.root,r.layoutsDir,r.fallbackLayoutsDir,r.componentsDir,r.partialsDir,r.pagesDir,...r._layerLayoutDirs??[]].filter((f)=>typeof f==="string"&&f.length>0);for(let f of u){let v=xe.isAbsolute(f)?f:xe.resolve(process.cwd(),f);if(Vr(a,v))return xe.resolve(a)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${a} (template: ${e}, from: ${n})`),null}async function Vp(e,n,r,i){if(r.debug)console.log(`Resolving template path: ${e} from ${n}`);let a=xe.dirname(n),l=process.cwd();if(e.startsWith("/")){let M=xe.join(l,e),V=Vr(M,l);if(!V)return console.warn(`[stx] rejected template path that escapes project root: ${e} (from ${n})`),null;if(r.debug)console.log(`Checking absolute path: ${V}`);if(await s(V)&&i)i.add(V);return V}let u=async(M)=>{if(!r.layoutsDir||!r.fallbackLayoutsDir)return M;let V=xe.relative(xe.resolve(l,r.fallbackLayoutsDir),M);if(V.startsWith("..")||xe.isAbsolute(V))return M;return await Fa(xe.resolve(l,r.layoutsDir),e,i,r.debug)??M},f=xe.join(a,e);if(await s(f)){if(r.debug)console.log(`Found direct path: ${f}`);let M=await u(f);if(i)i.add(M);return M}if(!e.endsWith(".stx")&&!e.endsWith(".jsx")&&!e.endsWith(".tsx"))for(let M of[".stx",".tsx",".jsx"]){let V=`${f}${M}`;if(await s(V)){if(r.debug)console.log(`Found direct path with extension: ${V}`);let W=await u(V);if(i)i.add(W);return W}}let v=[];if(v.push(...r._layerLayoutDirs??[]),r.layoutsDir)v.push(xe.isAbsolute(r.layoutsDir)?r.layoutsDir:xe.resolve(process.cwd(),r.layoutsDir));let S=xe.resolve(a),I=process.cwd();for(let M=0;M<10;M++){let V=xe.join(S,"layouts"),W=!1;try{W=Ns.statSync(V,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(W){v.push(V);break}let Z=xe.dirname(S);if(Z===S||Z.length<I.length)break;S=Z}for(let M of v){let V=await Fa(M,e,i,r.debug);if(V)return V}if(r.fallbackLayoutsDir){let M=xe.isAbsolute(r.fallbackLayoutsDir)?r.fallbackLayoutsDir:xe.resolve(process.cwd(),r.fallbackLayoutsDir),V=e.startsWith("layouts/")?e.slice(8):e,W=[xe.join(M,V)];if(!e.endsWith(".stx"))W.push(`${W[0]}.stx`);for(let Z of W)if(await s(Z)){if(r.debug)console.log(`Found in options.fallbackLayoutsDir: ${Z}`);if(i)i.add(Z);return Z}}if(e.startsWith("layouts/")||e.includes("/layouts/")){let M=e.split("layouts/"),V=xe.join(r.partialsDir||a,"layouts",M[1]);if(await s(V)){if(r.debug)console.log(`Found in layouts path: ${V}`);if(i)i.add(V);return V}if(!V.endsWith(".stx")){let W=`${V}.stx`;if(await s(W)){if(r.debug)console.log(`Found in layouts path with extension: ${W}`);if(i)i.add(W);return W}}}if(r.partialsDir){let M=xe.join(r.partialsDir,"layouts");if(await s(M)){let V=xe.join(M,e);if(await s(V)){if(r.debug)console.log(`Found in partials layouts dir: ${V}`);if(i)i.add(V);return V}if(!e.endsWith(".stx")){let W=`${V}.stx`;if(await s(W)){if(r.debug)console.log(`Found in partials layouts dir with extension: ${W}`);if(i)i.add(W);return W}}}}let j=r.partialsDir||xe.join(process.cwd(),"views"),L=xe.join(j,e);if(await s(L)){if(r.debug)console.log(`Found in views path: ${L}`);if(i)i.add(L);return L}if(!e.endsWith(".stx")){let M=`${L}.stx`;if(await s(M)){if(r.debug)console.log(`Found in views path with extension: ${M}`);if(i)i.add(M);return M}}if(a.includes("temp")){let M=xe.join(xe.dirname(a),"layouts",e);if(await s(M)){if(r.debug)console.log(`Found in temp layouts dir: ${M}`);if(i)i.add(M);return M}if(!e.endsWith(".stx")){let V=`${M}.stx`;if(await s(V)){if(r.debug)console.log(`Found in temp layouts dir with extension: ${V}`);if(i)i.add(V);return V}}}if(r.debug)console.warn(`Template not found after trying all paths: ${e} (referenced from ${n})`);else console.warn(`Template not found: ${e} (referenced from ${n})`);return null}function $l(e,n,r){let i=0,a="",l="";try{if(typeof n==="number"&&n>=0){let u=e.split(`
|
|
1200
1200
|
`),f=0;for(let v=0;v<u.length;v++)if(f+=u[v].length+1,f>=n){i=v+1,a=u[v].trim();let S=Math.max(0,v-2),I=Math.min(u.length,v+3);l=u.slice(S,I).map((j,L)=>{let M=S+L+1;return`${M===i?"> ":" "}${M}: ${j}`}).join(`
|
|
1201
1201
|
`);break}}else if(r){let u=e.indexOf(r);if(u>=0)return $l(e,u)}}catch{}return{lineNumber:i,lineContent:a,context:l}}var He={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function b(e,n,r,i,a,l){let{lineNumber:u,context:f}=$l(i,a,l),v=r.split("/").pop(),S=0;if(typeof a==="number"&&a>=0&&i){let j=i.lastIndexOf(`
|
|
1202
1202
|
`,Math.max(0,a-1));S=a-(j+1)+1}let I="";if(u>0)I+=`
|
|
@@ -1211,7 +1211,7 @@ ${He.yellow}${He.bold}Message:${He.reset} ${n}
|
|
|
1211
1211
|
`,f)I+=`
|
|
1212
1212
|
${He.blue}${He.bold}Context:${He.reset}
|
|
1213
1213
|
${He.dim}${f}${He.reset}
|
|
1214
|
-
`;return I}function Ce(){
|
|
1214
|
+
`;return I}function Ce(){qn.clear(),Tr.clear(),Ms.clear(),Ir.clear(),Or.clear(),Pr.clear(),Ds.clear()}function Iy(){return{size:qn.size,maxSize:500}}var Ar=k(128);async function Up(e,n,r){let i=E(e,n,r),a=Ar.get(i);if(a){if(to(a.deps))return a;Ar.delete(i)}let l=Vi(e,{filePath:n,projectRoot:process.cwd()}),u=l.code,f=Wi(l.styles);u=Gt(u).code;let{hasUserImports:v,bundleClientScript:S}=await o("stx/client-script-bundler",()=>import("./chunk-q33tyfpp.js")),I=[],j=!1;if(v(u)){let X=u;u=await S(X,n,{projectRoot:process.cwd(),minify:r,collectInputs:I}),j=u===X}let{stripStxRuntimeImports:L}=await o("stx/signal-processing",()=>import("./chunk-r425m35g.js"));u=L(u);let M=D(u),V=Lp(M),W=new Set(G(M,!0).split(",").map((X)=>X.trim())),Z=`function(__scopeId) {
|
|
1215
1215
|
${vt("const",[...Ul,...V],M)}
|
|
1216
1216
|
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
1217
1217
|
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
@@ -1300,24 +1300,24 @@ finally {
|
|
|
1300
1300
|
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
1301
1301
|
window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
|
|
1302
1302
|
}
|
|
1303
|
-
}`,q={vendorStyleTags:f,factoryBody:Z,clientCode:M,deps:Mr([...I,...l.styles.map((X)=>X.resolvedPath)])};if(!j&&l.unresolved.length===0)
|
|
1303
|
+
}`,q={vendorStyleTags:f,factoryBody:Z,clientCode:M,deps:Mr([...I,...l.styles.map((X)=>X.resolvedPath)])};if(!j&&l.unresolved.length===0)Ar.set(i,q);return q}var Hp=100,Kp=599,qr="__stxResponseStatus",Zn="__stxResponseHeaders";function Ls(e){return typeof e==="number"&&Number.isInteger(e)&&e>=Hp&&e<=Kp}function An(e){for(let n of e.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let r=n[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!r)continue;let i=Number(r[1]);if(Ls(i))return i}return}function Kr(e,n){if(!e||typeof e!=="object")return!1;let r=typeof n==="string"&&/^\d+$/.test(n.trim())?Number(n.trim()):n;if(!Ls(r))return!1;return e[qr]=r,!0}function qp(e,n,r){if(!e||typeof e!=="object")return;let i=String(n??"").trim();if(!i)return;e[Zn]={...e[Zn],[i]:String(r)}}function Kt(e){let n=e?.[qr];return Ls(n)?n:void 0}function Xt(e){let n=e?.[Zn];if(!n||typeof n!=="object")return;let r=Object.entries(n).map(([i,a])=>[i,String(a)]);return r.length>0?Object.fromEntries(r):void 0}function gl(e,n){if(!e||!n||e===n||typeof n!=="object")return;let r=Kt(e);if(r!==void 0)n[qr]=r;let i=Xt(e);if(i)n[Zn]={...n[Zn],...i}}function co(e){return{setResponseStatus:(n)=>{Kr(e,n)},notFound:(n=404)=>{let r=Ls(n)&&n>=400?n:404;Kr(e,r)},setResponseHeader:(n,r)=>{qp(e,n,r)}}}function ml(e,n,r={}){if(!e.includes("@status"))return e;let{filePath:i,buildMode:a}=r,l=a==="compile",u="",f=0,v=/@status\s*\(/g,S;while((S=v.exec(e))!==null){let I=Zp(e,S.index+S[0].length-1);if(I<0)break;let j=e.slice(S.index+S[0].length,I).trim(),L=/^\d+$/.test(j)?Number(j):d(j,n),M=i?` in ${i}`:"";if(l)console.warn(`[stx] @status(${j})${M} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${j}) from <script server> instead \u2014 that runs per request.`);else if(!Kr(n,L))console.warn(`[stx] @status(${j})${M} is not an HTTP status (100-599) \u2014 ignoring it.`);u+=e.slice(f,S.index),f=I+1+(e.slice(I+1).match(/^[^\S\n]*\n?/)?.[0].length??0),v.lastIndex=f}return f===0?e:u+e.slice(f)}function Zp(e,n){let r=1,i=null,a=!1;for(let l=n+1;l<e.length;l++){let u=e[l];if(a){a=!1;continue}if(i){if(u==="\\")a=!0;else if(u===i)i=null;continue}if(u==='"'||u==="'"||u==="`"){i=u;continue}if(u==="(")r++;else if(u===")"&&--r===0)return l}return-1}var qa=new Set(ht),Jp=new Set(["props","$props","defineProps"]),Xp=new Set(["stx","@stacksjs/stx"]),Za=k(128),Ja=k(64);function Gp(e){let n=[],r=0,i=e.split(`
|
|
1304
1304
|
`);for(let a of i){let l=r,u=null,f=!1;for(let v=0;v<a.length;v++){let S=a[v];if(f){f=!1;continue}if(S==="\\"){f=!0;continue}if(u){if(S===u)u=null;continue}if(S==="'"||S==='"'||S==="`"){u=S;continue}if(S==="/"&&v+1<a.length&&a[v+1]==="/")break;if(S==="{")r++;else if(S==="}")r--}if(l===0){let v=a.match(/(?:const|let|var)\s+(\w+)\s*=/);if(v)n.push(v[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(a)){let S=a.match(/(?:const|let|var)\s+(\w+)/);if(S)n.push(S[1])}else{let S=a.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(S){let j=S[1].slice(1,-1).split(",").map((L)=>{let M=L.split(":");return(M.length>1?M[1]:M[0]).trim()}).filter((L)=>/^\w+$/.test(L));n.push(...j)}}}}return[...new Set(n)]}function Og(e){let n=e;n=n.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),n=n.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),n=n.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function r(i){if(!i.includes(":"))return i;let a=[],l="",u=0,f=0,v=null;for(let S=0;S<i.length;S++){let I=i[S];if(v){if(l+=I,I===v)v=null;continue}if(I==='"'||I==="'"||I==="`"){v=I,l+=I;continue}if(I==="<")u++;else if(I===">"&&u>0)u--;else if(I==="(")f++;else if(I===")")f--;if(I===","&&u===0&&f===0){a.push(l),l="";continue}l+=I}if(l)a.push(l);return a.map((S)=>{let I=S.trim(),j=I.startsWith("..."),L=j?I.slice(3):I,M=-1,V=0;for(let re=0;re<L.length;re++)if(L[re]==="<")V++;else if(L[re]===">")V--;else if(L[re]===":"&&V===0){M=re;break}if(M===-1)return S;let Z=L.substring(0,M).trim().replace(/\?$/,""),q=L.substring(M+1),X=-1,U=0;for(let re=0;re<q.length;re++)if(q[re]==="<")U++;else if(q[re]===">")U--;else if(q[re]==="="&&U===0){X=re;break}let H=j?"...":"";if(X!==-1)return`${H}${Z} = ${q.substring(X+1).trim()}`;return`${H}${Z}`}).join(", ")}n=n.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(i,a,l)=>{if(!l.includes(":"))return i;return`${a}(${r(l)})`});{let i=/\b(function\s+\w*\s*)\(/g,a,l=[];while((a=i.exec(n))!==null){let u=a.index+a[0].length-1,f=1,v=u+1,S=0,I=null;while(v<n.length&&f>0){let M=n[v];if(I){if(M===I)I=null;v++;continue}if(M==='"'||M==="'"||M==="`"){I=M,v++;continue}if(M==="<")S++;else if(M===">"&&S>0)S--;else if(S===0){if(M==="(")f++;else if(M===")")f--}if(f>0)v++}if(f!==0)continue;let j=n.substring(u+1,v);if(!j.includes(":"))continue;let L=r(j);l.push({start:u+1,end:v,replacement:L})}for(let u=l.length-1;u>=0;u--){let{start:f,end:v,replacement:S}=l[u];n=n.substring(0,f)+S+n.substring(v)}}return n=n.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(i,a)=>{if(!a.includes(":"))return i;if(a.includes("{")||a.includes("}"))return i;return`(${a.split(",").map((u)=>{let[f,...v]=u.split("="),S=f.split(":")[0].trim();if(v.length>0)return`${S} = ${v.join("=").trim()}`;return S}).join(", ")}) =>`}),n=n.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),n=n.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),n=n.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),n=n.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),n=n.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),n=n.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),n=n.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),n=n.replace(/\n\s*\n\s*\n/g,`
|
|
1305
1305
|
|
|
1306
|
-
`),n}function Ng(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Mg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function Dg(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Lg(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var
|
|
1307
|
-
`),
|
|
1306
|
+
`),n}function Ng(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Mg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function Dg(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Lg(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var Xa=new Set;async function y(e,n,r,i={}){if(!e.trim())return;let a=A(),l=E(e,JSON.stringify(a)),u=Za.get(l);if(u===void 0){try{let ue=ie({loader:"ts",target:"browser",define:a}),de=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");de=de.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),u=ue.transformSync(de)}catch{u=Og(e)}Za.set(l,u)}let f={exports:{}},v=f.exports,S=mn.cwd(),I={},j=[...u.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((ue)=>ue[1]).filter((ue)=>!ue.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(ue)),L=new Map;for(let ue of j)try{if(ue.startsWith(".")){I[ue]=await import(Rt.resolve(Rt.dirname(r),ue));continue}let de=Rt.resolve(S,"node_modules",ue),$e=Rt.join(de,"package.json"),Te=JSON.parse(w("fs").readFileSync($e,"utf8")),st=Te.main||"index.js";if(Te.exports){let ct=typeof Te.exports==="string"?Te.exports:Te.exports["."];if(typeof ct==="string")st=ct;else if(ct?.bun)st=ct.bun;else if(ct?.import)st=ct.import;else if(ct?.default)st=ct.default}I[ue]=await import(Rt.resolve(de,st))}catch(de){if(ue.startsWith("."))L.set(ue,de instanceof Error?de.message:String(de))}let M=(ue)=>{if(I[ue])return I[ue];let de=L.get(ue);if(de!==void 0)throw Error(`Cannot require '${ue}' from ${r}: ${de}`);return w(ue)},V=n.props||{},W=(ue)=>{if(!ue)return V;let de={};for(let[$e,Te]of Object.entries(ue)){let st=V[$e];if(st!==void 0)de[$e]=st;else if(typeof Te==="function")de[$e]=Te();else de[$e]=Te}return de};for(let[ue,de]of Object.entries(V))Object.defineProperty(W,ue,{value:de,enumerable:!0,configurable:!0,writable:!0});let Z=(ue,de=!1)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let $e=ue.trim().toLowerCase();if($e===""||$e==="true"||$e==="1"||$e==="on"||$e==="yes")return!0;if($e==="false"||$e==="0"||$e==="off"||$e==="no")return!1;return!0}return Boolean(ue)},q=(ue,de=0)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let Te=ue.trim();if(Te==="")return de;let st=Number(Te);return Number.isFinite(st)?st:de}let $e=Number(ue);return Number.isFinite($e)?$e:de};for(let ue of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(V,ue))continue;try{Object.defineProperty(W,ue,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let X=(ue)=>{if(!ue)return V;let de={...V};for(let[$e,Te]of Object.entries(ue)){let st=Te&&typeof Te==="object"&&!Array.isArray(Te)?Te:{type:Te};if(de[$e]===void 0&&st.default!==void 0)de[$e]=typeof st.default==="function"?st.default():st.default}return de},U=()=>n.slots||{},H=(ue,de)=>{let $e={...ue};for(let[Te,st]of Object.entries(de))if($e[Te]===void 0)if(typeof st==="function")$e[Te]=st();else $e[Te]=st;return $e},re=(ue)=>{let de=()=>ue;return de.set=($e)=>{},de.update=($e)=>{},de},ce=(ue)=>{let de,$e=!1;return()=>{if(!$e)try{de=ue(),$e=!0}catch{de=void 0}return de}},le=(ue)=>{},pe=(ue)=>ue(),Re=(ue)=>{},Ae=(ue)=>{},we=co(n);function fe(ue){let de=ue||{};if(de.title!==void 0||de.description!==void 0)At({title:de.title,description:de.description})}function We(ue){if(!ue||typeof ue!=="object")return;let de=n.__stxClientPayload??{};Object.assign(de,ue),n.__stxClientPayload=de}let Fe=()=>{let ue=n.__stxServeContext,de=n.__stxServeSearch??ue?.search??"",$e=ue?.path??"",Te=Object.fromEntries(new URLSearchParams(de)),st=n.query,ct=Object.keys(Te).length>0?Te:st??{},nn=de||(Object.keys(ct).length>0?`?${new URLSearchParams(ct).toString()}`:"");return{params:n.params??{},query:ct,path:$e,name:"",fullPath:$e+nn,hash:"",matched:[]}},it=()=>({push:(ue)=>{},replace:(ue)=>{},back:()=>{},forward:()=>{},go:(ue)=>{}}),ot=(ue)=>{let de=n.__stx_runtime_head||{};n.__stx_runtime_head=nt(de,Le(ue||{},{known:wo,source:"useHead()"}))},At=(ue)=>{ot(vo(ue||{}))},St=(ue)=>({value:ue}),at=(ue)=>ue,$t=(ue)=>({value:typeof ue==="function"?ue():ue}),Ve=(ue,de)=>{},lt=(ue)=>{},ut=(ue)=>{},De=(ue)=>ue?ue():Promise.resolve(),Mt=(ue)=>(de,...$e)=>{},Dt=(ue)=>{},zs=(ue,de)=>{},hn=(ue,de)=>de,xt=()=>({value:"light"}),xn=()=>re(!1),Nt=(ue)=>re(!1),tn=()=>re(!1),bn=()=>Nt("(prefers-color-scheme: dark)"),yn=()=>Nt("(prefers-color-scheme: light)"),Jn=()=>Nt("(prefers-reduced-motion: reduce)"),_n=()=>Nt("(prefers-contrast: more)"),Tt={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},Xr=new Proxy(Tt,{get(ue,de){if(de in ue)return ue[de];return},set(ue,de,$e){return ue[de]=$e,!0}}),jt={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},wn=console;try{let ue=Ui(u,r),de=new Set(Object.keys(V)),$e=Object.keys(n).filter((Be)=>!de.has(Be)&&!Jp.has(Be)&&Ur(Be)),Te=$e.map((Be)=>n[Be]);if(!$e.includes("__stxServeContext"))$e.push("__stxServeContext"),Te.push(void 0);if(!de.has("cookies")){let Be=n.cookies??n.__stxServeContext?.cookies??{},Et=$e.indexOf("cookies");if(Et<0)$e.push("cookies"),Te.push(Be);else Te[Et]=Be}let st=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),ct=[],nn=[];for(let[Be,Et]of Object.entries(V)){if(!Ur(Be))continue;if(st.has(Be))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${Be}\\b`).test(ue))continue;ct.push(Be),nn.push(Et)}let Lt=Gp(ue).map((Be)=>`module.exports.${Be} = typeof ${Be} !== 'undefined' ? ${Be} : module.exports.${Be};`).join(`
|
|
1307
|
+
`),Xn=n.params??{},Gn=[],vn=[];for(let Be=0;Be<$e.length;Be++){if($e[Be]==="params")continue;Gn.push($e[Be]),vn.push(Te[Be])}let Sn=[...ht,...ct,...Gn],En=`return (async () => {
|
|
1308
1308
|
${ue}
|
|
1309
1309
|
${Lt}
|
|
1310
1310
|
return module.exports
|
|
1311
|
-
})()`,
|
|
1311
|
+
})()`,kn=E(En,Sn.join("\x00")),zt=Ja.get(kn);if(!zt)zt=Function(...Sn,En),Ja.set(kn,zt);let Yn=n.__stx_options?.runtimeConfig;if(Yn||/\buse(?:Server)?RuntimeConfig\b/.test(u))await Dn(n,r,Yn);let Qn=await et(n.__stx_runtime_config??Ln()??z(),()=>ii(n,()=>zt(f,v,M,V,W,Z,q,X,H,We,oi,Yi,go,re,ce,le,pe,Re,Ae,fe,Fe,it,ot,At,we.setResponseStatus,we.setResponseHeader,we.notFound,St,at,$t,Ve,lt,ut,De,Mt,Dt,U,zs,hn,xt,xn,Nt,tn,bn,yn,Jn,_n,Xr,jt,wn,Tt.confirm,Tt.alert,Tt.fetch,Xn,...nn,...vn)));if(i.preserveExisting){for(let[Be,Et]of Object.entries(Qn))if(!(Be in n)||n[Be]===void 0)n[Be]=Et}else Object.assign(n,Qn);for(let[Be,Et]of Object.entries(V))if(!(Be in n))n[Be]=Et}catch(ue){if(n.__stx_strict_hydration)throw ue;let de=Ng(ue instanceof Error?ue.message:String(ue));if(Mg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"module-resolution",message:de,error:ue});else if(Dg(ue))console.warn(`[stx] server <script> in ${r??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"syntax",message:de,error:ue});else if(Lg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${de}`),i.onFailure?.({kind:"missing-binding",message:de,error:ue});else{let $e=`${r??"<unknown>"}\x00${de}`;if(mn.env.STX_DEBUG||!Xa.has($e))Xa.add($e),console.warn(`[stx] server <script> in ${r??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${de}`);i.onFailure?.({kind:"unknown",message:de,error:ue})}try{await sf(u,n,r)}catch($e){if(mn.env.STX_DEBUG){let Te=$e instanceof Error?$e.message:String($e);console.warn(`[stx] fallback extraction also failed in ${r??"<unknown>"}: ${Te}`)}}}}function jg(e){let n=0,r=null,i=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(r){if(u===r){if(r=null,i||n===0)a=!0}continue}if(u==="'"||u==='"'||u==="`"){r=u;continue}if(u==="{")n++;else if(u==="}")n--;else if(e.startsWith("from",l)&&n===0)i=!0}return r===null&&n===0&&a}var Yp=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Ui(e,n){let r=n?Rt.dirname(n):mn.cwd(),i=mn.cwd(),a=e.split(`
|
|
1312
1312
|
`),l=[],u=0;while(u<a.length){let f=a[u].trim();if(f.startsWith("interface ")||f.startsWith("export interface ")||f.startsWith("type ")||f.startsWith("export type ")){if(f.includes("{")&&!f.includes("}")){let v=0;for(;u<a.length;u++){for(let S of a[u])if(S==="{")v++;else if(S==="}")v--;if(v<=0)break}}u++;continue}if(f.startsWith("definePageMeta(")){let v=0,S=!1,I=u;for(let M=u;M<a.length&&!S;M++){let V=null,W=!1,Z=a[M];for(let q=0;q<Z.length;q++){let X=Z[q];if(W){W=!1;continue}if(X==="\\"){W=!0;continue}if(V){if(X===V)V=null;continue}if(X==='"'||X==="'"||X==="`"){V=X;continue}if(X==="(")v++;else if(X===")"){if(v--,v===0){u=M+1,S=!0;break}}}}if(!S)u=a.length;let j=a.slice(I,u).join(`
|
|
1313
|
-
`),L=[];for(let M of["title","description"]){let V=new RegExp(`\\b${M}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(j);if(V)L.push(`${M}: ${JSON.stringify(V[2])}`)}if(L.length>0)l.push(`useSeoMeta({ ${L.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let v=f,S=0;while(!jg(v)&&u+S+1<a.length)S++,v=`${v} ${a[u+S].trim()}`;u+=S;let I=v.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),j=v.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),L=v.match(/^import\s*['"](.+?)['"]/),M=v,V=(W)=>{if(W.startsWith("."))return Rt.resolve(r,W);if(W.startsWith("~/")||W.startsWith("@/"))return Rt.resolve(i,W.slice(2));try{return Bun.resolveSync(W,r)}catch{return W}};if(I){let[,W,Z]=I,q=V(Z);l.push(`const ${W} = (await import('${q}')).default`),l.push(`module.exports.${W} = ${W};`)}else if(j){let[,W,Z]=j,q=V(Z),X=[],U=[],H=Xp.has(Z);for(let re of W.split(",")){let ce=re.trim();if(!ce)continue;let le=ce.split(/\s+as\s+/);if(le.length===2){let[pe,Re]=[le[0].trim(),le[1].trim()];if(H&&
|
|
1313
|
+
`),L=[];for(let M of["title","description"]){let V=new RegExp(`\\b${M}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(j);if(V)L.push(`${M}: ${JSON.stringify(V[2])}`)}if(L.length>0)l.push(`useSeoMeta({ ${L.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let v=f,S=0;while(!jg(v)&&u+S+1<a.length)S++,v=`${v} ${a[u+S].trim()}`;u+=S;let I=v.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),j=v.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),L=v.match(/^import\s*['"](.+?)['"]/),M=v,V=(W)=>{if(W.startsWith("."))return Rt.resolve(r,W);if(W.startsWith("~/")||W.startsWith("@/"))return Rt.resolve(i,W.slice(2));try{return Bun.resolveSync(W,r)}catch{return W}};if(I){let[,W,Z]=I,q=V(Z);l.push(`const ${W} = (await import('${q}')).default`),l.push(`module.exports.${W} = ${W};`)}else if(j){let[,W,Z]=j,q=V(Z),X=[],U=[],H=Xp.has(Z);for(let re of W.split(",")){let ce=re.trim();if(!ce)continue;let le=ce.split(/\s+as\s+/);if(le.length===2){let[pe,Re]=[le[0].trim(),le[1].trim()];if(H&&qa.has(pe)){l.push(`const ${Re} = ${pe};`);continue}X.push(`${pe}: ${Re}`),U.push(Re)}else{if(H&&qa.has(ce))continue;X.push(ce),U.push(ce)}}if(X.length>0)l.push(`const { ${X.join(", ")} } = await import('${q}')`);for(let re of U)l.push(`module.exports.${re} = ${re};`)}else if(L){let W=V(L[1]);l.push(`await import('${W}')`)}else l.push(M);u++;continue}if(Yp.test(f))l.push(a[u]),u++;else if(f.startsWith("export const ")||f.startsWith("export let ")||f.startsWith("export var ")){let v=Ya(a,u),{type:S,name:I,value:j}=v;l.push(`${S} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=v.nextIndex}else if(f.startsWith("export function ")||f.startsWith("export async function ")){let v=Jr(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("const ")||f.startsWith("let ")||f.startsWith("var ")){let v=Ya(a,u),{type:S,name:I,value:j}=v;l.push(`${S} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=v.nextIndex}else if(f.startsWith("function ")||f.startsWith("async function ")){let v=Jr(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("export default function ")||f.startsWith("export default async function ")){let v=a[u].replace(/^(\s*)export\s+default\s+/,"$1"),S=[...a];S[u]=v;let I=Jr(S,u);if(l.push(I.functionCode),I.name)l.push(`module.exports.default = ${I.name};`);u=I.nextIndex}else if(f.startsWith("export default ")){let v=f.replace(/^export\s+default\s+/,"").replace(/;$/,"");l.push(`module.exports.default = ${v};`),u++}else if(f.startsWith("class ")||f.startsWith("export class ")){let v=f.match(/(?:export\s+)?class\s+(\w+)/);if(v){let S=v[1],I=a[u].replace(/^export\s+/,""),j=0,L=u;for(;L<a.length;L++){let M=a[L];for(let V of M)if(V==="{")j++;else if(V==="}")j--;if(L>u)I+=`
|
|
1314
1314
|
`+M;if(j<=0&&L>=u)break}l.push(I),l.push(`module.exports.${S} = ${S};`),u=L+1}else l.push(f),u++}else if(f.includes("module.exports"))l.push(f),u++;else if(f.trim()&&!f.startsWith("//"))l.push(f),u++;else u++}return Qp(l.join(`
|
|
1315
1315
|
`),r,i)}function Qp(e,n,r){let i=e.length,a="",l=0,u=null,f=!1,v=!1,S=0;while(l<i){let I=e[l],j=e[l+1];if(f){if(a+=I,I===`
|
|
1316
|
-
`)f=!1;l++;continue}if(v){if(a+=I,I==="*"&&j==="/"){a+=j,l+=2,v=!1;continue}l++;continue}if(!u&&I==="/"&&j==="/"){f=!0,a+=I,l++;continue}if(!u&&I==="/"&&j==="*"){v=!0,a+=I,l++;continue}if(u){if(a+=I,I==="\\"){a+=j,l+=2;continue}if(I===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(I==="$"&&j==="{"){S++,a+=j,l+=2;continue}if(I==="`"){u=null,l++;continue}}l++;continue}if(S>0){if(I==="{")S++;else if(I==="}")S--}if(I==='"'||I==="'"||I==="`"){u=I,a+=I,l++;continue}if(I==="a"&&e.startsWith("await",l)){let L=ef(e,l);if(L){let{quote:M,path:V,end:W}=L;if(V.startsWith(".")||V.startsWith("~/")||V.startsWith("@/")){let Z=V.startsWith(".")?Rt.resolve(n,V):Rt.resolve(r,V.slice(2));a+=`await import(${M}${Z}${M})`,l=W;continue}}}a+=I,l++}return a}function ef(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function
|
|
1316
|
+
`)f=!1;l++;continue}if(v){if(a+=I,I==="*"&&j==="/"){a+=j,l+=2,v=!1;continue}l++;continue}if(!u&&I==="/"&&j==="/"){f=!0,a+=I,l++;continue}if(!u&&I==="/"&&j==="*"){v=!0,a+=I,l++;continue}if(u){if(a+=I,I==="\\"){a+=j,l+=2;continue}if(I===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(I==="$"&&j==="{"){S++,a+=j,l+=2;continue}if(I==="`"){u=null,l++;continue}}l++;continue}if(S>0){if(I==="{")S++;else if(I==="}")S--}if(I==='"'||I==="'"||I==="`"){u=I,a+=I,l++;continue}if(I==="a"&&e.startsWith("await",l)){let L=ef(e,l);if(L){let{quote:M,path:V,end:W}=L;if(V.startsWith(".")||V.startsWith("~/")||V.startsWith("@/")){let Z=V.startsWith(".")?Rt.resolve(n,V):Rt.resolve(r,V.slice(2));a+=`await import(${M}${Z}${M})`,l=W;continue}}}a+=I,l++}return a}function ef(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function nc(e,n){let r=e[n];if(r!=="{"&&r!=="[")return null;let a=_(e,r,r==="{"?"}":"]",n);if(a===-1)return null;return{pattern:e.slice(n,a+1),endPos:a+1}}function sc(e){let n=[],r=e.slice(1,-1).trim();if(!r)return n;let i=0,a=0,l="";while(i<r.length){let u=r[i];if(u==="{"||u==="["){let f=a===0?nc(r,i):null;if(f){n.push(...sc(f.pattern)),i=f.endPos,l="";continue}a++}else if(u==="}"||u==="]")a--;if(a>0){i++;continue}if(u===","){if(l.trim())n.push(l.trim());l="",i++;continue}if(u===":"){l="",i++;continue}if(u==="="){if(l.trim())n.push(l.trim());l="",i++;while(i<r.length&&r[i]!==","&&a===0){if(r[i]==="{"||r[i]==="[")a++;else if(r[i]==="}"||r[i]==="]")a--;i++}continue}if(/[\w$]/.test(u))l+=u;i++}if(l.trim())n.push(l.trim());return n}function Bg(e){let n=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(e);if(!n)return null;let r=n[0].length,i=(a)=>a===" "||a==="\t";while(r<e.length&&i(e[r]))r++;if(e[r]===":"){let a=0,l=null;r++;for(;r<e.length;r++){let u=e[r];if(l){if(u==="\\"){r++;continue}if(u===l)l=null;continue}if(u==="'"||u==='"'||u==="`"){l=u;continue}if(u==="("||u==="["||u==="{"||u==="<"){a++;continue}if(u===")"||u==="]"||u==="}"||u===">"){a--;continue}if(u==="="&&a<=0){let f=e[r+1],v=e[r-1];if(f!=="="&&f!==">"&&v!=="="&&v!=="!"&&v!=="<"&&v!==">")break}}if(e[r]!=="=")return null}while(r<e.length&&i(e[r]))r++;if(e[r]!=="=")return null;return{type:n[1],name:n[2],value:e.slice(r+1).trim()}}function Ga(e,n,r,i){let a=null,l=!1;for(let u of e){if(l){l=!1;continue}if(u==="\\"){l=!0;continue}if(a){if(u===a)a=null;continue}if(u==="'"||u==='"'||u==="`"){a=u;continue}if(u===n)i++;else if(u===r)i--}return i}function Ya(e,n){let r=e[n].trim(),i=Bg(r),a=i?[r,i.type,i.name,i.value]:null;if(!a){let I=r.match(/^(?:export\s+)?(const|let|var)\s+/);if(I){let j=r.slice(I[0].length),L=n;if(j.startsWith("{")||j.startsWith("[")){let V=j[0],W=V==="{"?"}":"]",Z=Ga(j,V,W,0),q=j;for(let X=n+1;X<e.length&&Z>0;X++)q+=` ${e[X].trim()}`,L=X,Z=Ga(e[X],V,W,Z);if(Z>0)q=j,L=n;j=q}let M=nc(j,0);if(M){let V=I[1],W=M.pattern,Z=j.slice(M.endPos).trim();if(Z.startsWith("=")){let q=Z.slice(1).trim(),X=q,U=Math.max(L,n);if(Qa(q)){let le=ec(e,U,q);X=le.value,U=le.nextIndex}else U=U+1;X=X.trim().replace(/;$/,"");let H=sc(W),re=`__stx_src_${n}`,ce=H.map((le)=>`module.exports.${le} = ${le};`).join(`
|
|
1317
1317
|
`);return{type:V,name:re,value:`${X}; ${V} ${W} = ${re};
|
|
1318
|
-
${ce}`,nextIndex:U}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,v=f,S=n;if(
|
|
1319
|
-
${e[S]}`,S++;else break}return v=v.trim().replace(/;$/,""),{type:l,name:u,value:v,nextIndex:S}}function
|
|
1318
|
+
${ce}`,nextIndex:U}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,v=f,S=n;if(Qa(f)){let I=ec(e,n,f);v=I.value,S=I.nextIndex}else S=n+1;while(S<e.length){let I=e[S].trim();if(I.startsWith(".")||I.startsWith("?."))v+=`
|
|
1319
|
+
${e[S]}`,S++;else break}return v=v.trim().replace(/;$/,""),{type:l,name:u,value:v,nextIndex:S}}function Jr(e,n){let r=e[n].trim(),i=r.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!i)throw Error(`Failed to parse function declaration: ${r}`);let[,a]=i,l=r.replace(/^export\s+/,""),u=n;if(tf(r)){let f=nf(e,n,l);l=f.functionCode,u=f.nextIndex}else u=n+1;return{name:a,functionCode:l,nextIndex:u}}function Qa(e){let n=e.trim();if(n.startsWith("{"))return _(n,"{","}",0)===-1;if(n.startsWith("["))return _(n,"[","]",0)===-1;return!rc(n)}function rc(e){let n={paren:0,bracket:0,brace:0},r=null,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((a>0?e[a-1]:"")==="\\"&&r)continue;if((l==='"'||l==="'")&&!r){r=l;continue}if(l===r&&r!=="`"){r=null;continue}if(l==="`"&&!r){r="`";continue}if(l==="`"&&r==="`"&&i===0){r=null;continue}if(r==="`"&&l==="$"&&e[a+1]==="{"){i++,a++;continue}if(i>0&&l==="{"){i++;continue}if(i>0&&l==="}"){i--;continue}if(r)continue;if(l==="(")n.paren++;else if(l===")")n.paren--;else if(l==="[")n.bracket++;else if(l==="]")n.bracket--;else if(l==="{")n.brace++;else if(l==="}")n.brace--}return n.paren===0&&n.bracket===0&&n.brace===0&&r===null}function ic(e){let n=e.indexOf("(");if(n===-1)return e.indexOf("{");let r=_(e,"(",")",n);if(r===-1)return-1;return e.indexOf("{",r)}function tf(e){let n=ic(e);if(n===-1)return!0;return _(e,"{","}",n)===-1}function ec(e,n,r){let i=r,a=n+1;while(a<e.length&&!rc(i)){let l=e[a];i+=`
|
|
1320
1320
|
${l}`,a++}while(a<e.length){let l=e[a].trim();if(l.startsWith(".")||l.startsWith("?."))i+=`
|
|
1321
|
-
${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function nf(e,n,r){let i=r,a=n+1;while(a<e.length){let l=
|
|
1322
|
-
${u}`,a++}return{functionCode:i,nextIndex:a}}function
|
|
1321
|
+
${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function nf(e,n,r){let i=r,a=n+1;while(a<e.length){let l=ic(i);if(l!==-1){if(_(i,"{","}",l)!==-1)break}let u=e[a];i+=`
|
|
1322
|
+
${u}`,a++}return{functionCode:i,nextIndex:a}}function tc(e,n){let r=d(e,n)??d(`(${e})`,n);if(r!==void 0)return r;if(!/\bprocess\b/.test(e))return;let i={...n,process:Object.freeze({env:{...mn.env}})},a=Object.keys(i).filter(Ur),l=a.map((u)=>i[u]);try{return Function(...a,`'use strict'; return (${e});`)(...l)}catch{try{return Function(...a,`'use strict'; return ${e};`)(...l)}catch{return}}}async function sf(e,n,r){let i=e.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let l of i){let[,,u,f]=l;try{let v=f.trim().replace(/;$/,""),S=tc(v,n);if(S!==void 0)n[u]=S}catch(v){console.warn(`Failed to parse export ${u} in fallback:`,v)}}let a=e.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let l of a){let[,,u,f]=l;if(!(u in n))try{let v=f.trim().replace(/;$/,""),S=tc(v,n);if(S!==void 0)n[u]=S}catch{}}}function Sl(e){let n=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=n?n[1]:"",i=n?e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):e;return{scriptContent:r,templateWithoutScript:i}}function kl(e){let n=e.trim();if(!n)return!1;return/(?:const|let|var|function)\s+\w+/.test(n)}
|
|
1323
1323
|
export{qe,Ie,G,Js,Ys,J,Nr,Zs,Qs,Ii,Oi,Ni,eo,Mi,ol,Ut,o,me,k,il,E,Mr,to,Oe,A,Ke,B,Vt,Ne,Q,Tn,Xe,x,al,ke,se,Dr,ee,Lr,jr,he,Wt,oe,F,mt,O,Br,Fr,ht,cl,qt,no,ro,_e,Di,$n,so,ye,ll,ul,Li,dl,pl,oo,ji,Bi,fl,Fi,io,zi,Rn,ao,An,Kt,Xt,gl,co,ml,hl,Pn,zr,lo,uo,yl,Hi,bl,wl,vl,xl,Og,Ng,Mg,Dg,Lg,y,jg,Ui,Bg,Sl,kl,Vi,Wi,Fg,Gt,_l,zg,Cl,Py,Ge,In,Je,Hg,Ug,Vg,Wg,qg,po,Kg,Ye,ie,Ze,Xg,Hr,Gg,El,Tl,qi,Qe,s,On,$l,b,Ce,Iy,Rl,Al,Pl,Ki,fo,Jg,Oy,Yg,Ny,Nn,g,Y,ae,Mn,Me,Zg,Xi,Qg,My,P,Gi,em,Dy,N,Ly};
|