@stacksjs/stx 0.2.662 → 0.2.664

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/{chunk-8n78w5kh.js → chunk-02e1s1k9.js} +1 -1
  2. package/dist/{chunk-4jyehvz3.js → chunk-08fpcex5.js} +2 -2
  3. package/dist/{chunk-e3crw545.js → chunk-0y05x1ef.js} +1 -1
  4. package/dist/{chunk-q5h1reph.js → chunk-1kn1at1y.js} +1 -1
  5. package/dist/{chunk-sknazxqf.js → chunk-1mf9658r.js} +1 -1
  6. package/dist/{chunk-1hny5z72.js → chunk-2jkq8n45.js} +1 -1
  7. package/dist/{chunk-pm76dy07.js → chunk-2kqdaehp.js} +1 -1
  8. package/dist/{chunk-zxbw2gr0.js → chunk-2xxmhmmj.js} +2 -2
  9. package/dist/{chunk-rxqv3p90.js → chunk-32rg1d9j.js} +2 -2
  10. package/dist/{chunk-h6633jna.js → chunk-39nvwdn6.js} +6 -6
  11. package/dist/{chunk-a3mmhzpa.js → chunk-3bpts69r.js} +1 -1
  12. package/dist/{chunk-3ay916gv.js → chunk-43m1rvh3.js} +1 -1
  13. package/dist/chunk-4q9g7893.js +2 -0
  14. package/dist/{chunk-vp9hse5k.js → chunk-5z1n02nd.js} +1 -1
  15. package/dist/{chunk-k6fyn9gk.js → chunk-6cd5jwvt.js} +1 -1
  16. package/dist/chunk-76j40sff.js +2 -0
  17. package/dist/{chunk-dw5bsya8.js → chunk-8hmds6dt.js} +1 -1
  18. package/dist/{chunk-h2a40417.js → chunk-8x8ndh72.js} +1 -1
  19. package/dist/{chunk-m7wb991z.js → chunk-aq3mpxrm.js} +1 -1
  20. package/dist/{chunk-adzrhca1.js → chunk-c3qd0dk8.js} +1 -1
  21. package/dist/{chunk-m2h91ccn.js → chunk-ckmgf9x1.js} +1 -1
  22. package/dist/{chunk-fr4hs814.js → chunk-djkjc1hj.js} +1 -1
  23. package/dist/chunk-ehy44811.js +2 -0
  24. package/dist/{chunk-pwjre3b2.js → chunk-etpjy429.js} +1 -1
  25. package/dist/{chunk-creeaceg.js → chunk-f0mrs38w.js} +1 -1
  26. package/dist/chunk-f4nrk8sv.js +2 -0
  27. package/dist/{chunk-61pvye5k.js → chunk-f85dmqn3.js} +1 -1
  28. package/dist/{chunk-v0byvxty.js → chunk-fnm6bb59.js} +1 -1
  29. package/dist/{chunk-d419kwfp.js → chunk-g4qz56km.js} +1 -1
  30. package/dist/{chunk-9jcxrc6t.js → chunk-g90jymnr.js} +1 -1
  31. package/dist/{chunk-51n5rfsk.js → chunk-gd14j4h8.js} +1 -1
  32. package/dist/{chunk-7m5sqtq5.js → chunk-gm026tmh.js} +1 -1
  33. package/dist/{chunk-zzk3a426.js → chunk-hj6fjqn8.js} +1 -1
  34. package/dist/{chunk-vzk09hvw.js → chunk-hm4fzr68.js} +1 -1
  35. package/dist/{chunk-mayr8s0x.js → chunk-m040f3x9.js} +1 -1
  36. package/dist/chunk-mhhg2sfa.js +2 -0
  37. package/dist/{chunk-ky5kmg7t.js → chunk-mmwg485j.js} +1 -1
  38. package/dist/{chunk-vsxws200.js → chunk-nz5t3kt9.js} +1 -1
  39. package/dist/chunk-p69f9sdh.js +2 -0
  40. package/dist/{chunk-j0dsavn2.js → chunk-paedp1tc.js} +1 -1
  41. package/dist/chunk-pazbwfkm.js +2 -0
  42. package/dist/{chunk-qvdx99py.js → chunk-pq5qr44q.js} +1 -1
  43. package/dist/{chunk-smyeg8cr.js → chunk-qdvv7h6r.js} +1 -1
  44. package/dist/{chunk-5m8j11b0.js → chunk-qfdy33jq.js} +1 -1
  45. package/dist/chunk-qhx8htx2.js +2 -0
  46. package/dist/{chunk-ftskxb7f.js → chunk-rcwqm2qq.js} +5 -5
  47. package/dist/{chunk-ptx6n9hd.js → chunk-rjekha6p.js} +1 -1
  48. package/dist/{chunk-4f4agvd0.js → chunk-scea207h.js} +9 -9
  49. package/dist/{chunk-r6kbpwzd.js → chunk-tgm4mnn4.js} +2 -2
  50. package/dist/{chunk-q341v4gv.js → chunk-tpyhs3rq.js} +6 -6
  51. package/dist/{chunk-n48cshgz.js → chunk-v6zdb66z.js} +4 -4
  52. package/dist/{chunk-xz261gkh.js → chunk-vmht7yf9.js} +1 -1
  53. package/dist/{chunk-m89yndgc.js → chunk-w0hby6q6.js} +1 -1
  54. package/dist/{chunk-d8kfbhhw.js → chunk-wtfjk49r.js} +1 -1
  55. package/dist/{chunk-4xdpeky6.js → chunk-xn51xrjd.js} +1 -1
  56. package/dist/chunk-xr3nknmb.js +2 -0
  57. package/dist/{chunk-adxt8qcy.js → chunk-y4crq495.js} +2 -2
  58. package/dist/{chunk-z248e3gj.js → chunk-yeb4yc8a.js} +1 -1
  59. package/dist/{chunk-vc2xzscw.js → chunk-yyfcg26x.js} +2 -2
  60. package/dist/{chunk-msvpb1ax.js → chunk-ze3p2wf6.js} +4 -4
  61. package/dist/{chunk-6dz6tpkp.js → chunk-zk537c7a.js} +1 -1
  62. package/dist/chunk-zv2v281j.js +2 -0
  63. package/dist/cli.js +7 -7
  64. package/dist/craft-entry.js +1 -1
  65. package/dist/craft.js +1 -1
  66. package/dist/native/compiler/render-screen.js +9 -6
  67. package/dist/native/runtime/native-host.d.ts +1 -1
  68. package/dist/native/runtime/native-host.js +10 -2
  69. package/dist/pwa.js +1 -1
  70. package/dist/ssg.js +2 -2
  71. package/package.json +5 -5
  72. package/dist/chunk-4xfpq9yp.js +0 -2
  73. package/dist/chunk-6fbxh1we.js +0 -2
  74. package/dist/chunk-721ba72m.js +0 -2
  75. package/dist/chunk-ap1sydzw.js +0 -2
  76. package/dist/chunk-fdfnk654.js +0 -2
  77. package/dist/chunk-mxdm8sw0.js +0 -2
  78. package/dist/chunk-r1hg1yc4.js +0 -2
  79. package/dist/chunk-tr4hseng.js +0 -2
  80. package/dist/chunk-tywr9wc5.js +0 -2
  81. package/dist/chunk-vpa06pyx.js +0 -2
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Je}from"./chunk-zaaeneq6.js";import{pt,On}from"./chunk-pxqh758g.js";import{Pe,cn,Xa,Ja}from"./chunk-h6633jna.js";import{pr,fr,gr,hr,we}from"./chunk-hb08vrbb.js";import{A}from"./chunk-2h8ea0we.js";import{jo}from"./chunk-z248e3gj.js";import{h}from"./chunk-vc2xzscw.js";import{s}from"./chunk-ftskxb7f.js";import{N,o}from"./chunk-adxt8qcy.js";import{wa}from"./chunk-04kg16qs.js";import{ze,Se,$i,Ri,kn}from"./chunk-zxbw2gr0.js";import{Zt,Ks}from"./chunk-d419kwfp.js";import{_n}from"./chunk-vqc4h16r.js";import{qt,jn,Bn}from"./chunk-xaa36b0x.js";import{V}from"./chunk-n48cshgz.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(i){return Q("sha256").update(i).digest("hex").slice(0,8)}function J(i=!1){let l=i?On():pt(),a=W(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function U(){let i=Je(),l=W(i);return{content:i,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(i={}){let l=new Set;return{context:new Proxy(i,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(i,l,a={}){let r=q.resolve(i),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Xa();let _={};try{_=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,f;while((f=d.exec(e))!==null){let R=f[1];if(/\bserver\b/.test(R))y.push(f[2])}let u=new Set(y.flatMap((R)=>Pe(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...N,..._,...a,buildMode:"compile",strict:!1},b=await s(e,D,r,j,w),C=ze(b),P=Ja();return{route:l,sourceFile:i,html:b,fragment:C,placeholders:P,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:cn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(i,l){let a=0,r=0;if(!m.existsSync(i))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let f=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(f,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(f,u),a++,r+=m.statSync(u).size}}}return e(i,l),{copied:a,bytes:r}}async function Mu(i={}){let l=Date.now(),a=c.resolve(i.root||process.cwd()),r=c.resolve(a,i.outputDir||".output");console.log("[stx build] Starting production build...");let e=await o(a),S=c.resolve(a,i.componentsDir??e.componentsDir??"components"),_=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",f=we(e.app?.head,{known:hr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=i.routeRules??e.routeRules??{},j=_n(w),b=i.serverApi??e.serverApi,C=typeof b==="object"?b:{};if(b)Zt(a,C);if(e.runtimeConfig)A(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let n of P)m.mkdirSync(n,{recursive:!0});console.log("[stx build] Discovering routes...");let R=V(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((n)=>!Y.some((g)=>n.pattern.startsWith(`/${g}/`)||n.pattern===`/${g}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(i.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let n of B){let g=j(n.pattern),O=g.rendering==="prerender";if(O&&(n.pattern.includes(":")||n.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${n.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(n.filePath,n.pattern,{configDir:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:i.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=gr(t.html,f,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=pr(t.html,u);if(f.htmlAttrs)t.html=fr(t.html,f.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await h(t.html),O){let p=await kn(t,{params:{},request:new Request(`http://stx.build${n.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${n.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Se(t.html,D);let L=n.pattern==="/"?"index":n.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),k.push({pattern:n.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:n.pattern.includes(":")||n.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${n.pattern}`)}catch(t){if(Object.keys(g).length)throw t;console.error(`[stx build] \u2717 ${n.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(a,d);if(m.existsSync(E)){let{copied:n,bytes:g}=Z(E,c.join(r,"public"));if(n>0)console.log(`[stx build] Copied ${n} public asset${n===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${d}/`)}let H=Bn(a);if(H){let{copied:n,bytes:g}=Z(H,c.join(r,"public",jn));if(n>0)console.log(`[stx build] Copied ${n} asset${n===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${qt}/`)}let F={runtime:v.filename,router:x.filename},T=$i(k,F,r);if(T.routeRules=w,T.routerContainer=D,b)T.apiRoutes=await Ks(a,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await jo(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(wa(e._layerGraph),null,2));Ri(T,r);let K=Date.now()-l;return console.log(`
2
+ import{Je}from"./chunk-zaaeneq6.js";import{pt,On}from"./chunk-pxqh758g.js";import{Pe,cn,Xa,Ja}from"./chunk-39nvwdn6.js";import{pr,fr,gr,hr,we}from"./chunk-hb08vrbb.js";import{A}from"./chunk-2h8ea0we.js";import{jo}from"./chunk-yeb4yc8a.js";import{h}from"./chunk-yyfcg26x.js";import{s}from"./chunk-rcwqm2qq.js";import{N,o}from"./chunk-y4crq495.js";import{wa}from"./chunk-04kg16qs.js";import{ze,Se,$i,Ri,kn}from"./chunk-2xxmhmmj.js";import{Zt,Ks}from"./chunk-g4qz56km.js";import{_n}from"./chunk-vqc4h16r.js";import{qt,jn,Bn}from"./chunk-xaa36b0x.js";import{V}from"./chunk-v6zdb66z.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(i){return Q("sha256").update(i).digest("hex").slice(0,8)}function J(i=!1){let l=i?On():pt(),a=W(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function U(){let i=Je(),l=W(i);return{content:i,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(i={}){let l=new Set;return{context:new Proxy(i,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(i,l,a={}){let r=q.resolve(i),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Xa();let _={};try{_=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,f;while((f=d.exec(e))!==null){let R=f[1];if(/\bserver\b/.test(R))y.push(f[2])}let u=new Set(y.flatMap((R)=>Pe(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...N,..._,...a,buildMode:"compile",strict:!1},b=await s(e,D,r,j,w),C=ze(b),P=Ja();return{route:l,sourceFile:i,html:b,fragment:C,placeholders:P,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:cn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(i,l){let a=0,r=0;if(!m.existsSync(i))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let f=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(f,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(f,u),a++,r+=m.statSync(u).size}}}return e(i,l),{copied:a,bytes:r}}async function Mu(i={}){let l=Date.now(),a=c.resolve(i.root||process.cwd()),r=c.resolve(a,i.outputDir||".output");console.log("[stx build] Starting production build...");let e=await o(a),S=c.resolve(a,i.componentsDir??e.componentsDir??"components"),_=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",f=we(e.app?.head,{known:hr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=i.routeRules??e.routeRules??{},j=_n(w),b=i.serverApi??e.serverApi,C=typeof b==="object"?b:{};if(b)Zt(a,C);if(e.runtimeConfig)A(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let n of P)m.mkdirSync(n,{recursive:!0});console.log("[stx build] Discovering routes...");let R=V(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((n)=>!Y.some((g)=>n.pattern.startsWith(`/${g}/`)||n.pattern===`/${g}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(i.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let n of B){let g=j(n.pattern),O=g.rendering==="prerender";if(O&&(n.pattern.includes(":")||n.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${n.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(n.filePath,n.pattern,{configDir:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:i.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=gr(t.html,f,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=pr(t.html,u);if(f.htmlAttrs)t.html=fr(t.html,f.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await h(t.html),O){let p=await kn(t,{params:{},request:new Request(`http://stx.build${n.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${n.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Se(t.html,D);let L=n.pattern==="/"?"index":n.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),k.push({pattern:n.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:n.pattern.includes(":")||n.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${n.pattern}`)}catch(t){if(Object.keys(g).length)throw t;console.error(`[stx build] \u2717 ${n.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(a,d);if(m.existsSync(E)){let{copied:n,bytes:g}=Z(E,c.join(r,"public"));if(n>0)console.log(`[stx build] Copied ${n} public asset${n===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${d}/`)}let H=Bn(a);if(H){let{copied:n,bytes:g}=Z(H,c.join(r,"public",jn));if(n>0)console.log(`[stx build] Copied ${n} asset${n===1?"":"s"} (${(g/1024).toFixed(1)}KB) from ${qt}/`)}let F={runtime:v.filename,router:x.filename},T=$i(k,F,r);if(T.routeRules=w,T.routerContainer=D,b)T.apiRoutes=await Ks(a,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await jo(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(wa(e._layerGraph),null,2));Ri(T,r);let K=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:F,outputDir:r,duration:K}}
4
4
  export{Mu};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$u}from"./chunk-1mf9658r.js";import"./chunk-2xxmhmmj.js";import"./chunk-g4qz56km.js";import"./chunk-v6zdb66z.js";import"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{$u as startProductionServer};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{f,Po,Va,Ua,Xl,Jl,Yl,Zl,Ql,ms,eu,Ne,G,De,tu,lr,nu,Ga,Do,Me,n,pn,Ka,g,de,Rp}from"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{de as clearComponentCache,Do as componentClientSignalNames,Po as convertToCommonJS,g as createDetailedErrorMessage,Ql as extractDirectiveNames,Va as extractScriptFromTemplate,f as extractVariables,n as fileExists,Rp as getComponentCacheStats,Jl as getPositionInfo,G as getSharedTranspiler,Ka as getSourceLineInfo,Zl as hasDirectives,Ua as hasVariables,nu as isHydrateTrigger,eu as isJavaScriptScript,Me as renderComponentWithSlot,pn as resolveTemplatePath,tu as scopeOnRootElement,ms as scopeSequenceKey,Ne as shouldTranspileTypeScript,Ga as slotContentHasExpressions,De as transpileTypeScript,lr as userComponentFileExists,Yl as validateDirective,Xl as validateTemplate};
2
+ import{f,Po,Va,Ua,Xl,Jl,Yl,Zl,Ql,ms,eu,Ne,G,De,tu,lr,nu,Ga,Do,Me,n,pn,Ka,g,de,Rp}from"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{de as clearComponentCache,Do as componentClientSignalNames,Po as convertToCommonJS,g as createDetailedErrorMessage,Ql as extractDirectiveNames,Va as extractScriptFromTemplate,f as extractVariables,n as fileExists,Rp as getComponentCacheStats,Jl as getPositionInfo,G as getSharedTranspiler,Ka as getSourceLineInfo,Zl as hasDirectives,Ua as hasVariables,nu as isHydrateTrigger,eu as isJavaScriptScript,Me as renderComponentWithSlot,pn as resolveTemplatePath,tu as scopeOnRootElement,ms as scopeSequenceKey,Ne as shouldTranspileTypeScript,Ga as slotContentHasExpressions,De as transpileTypeScript,lr as userComponentFileExists,Yl as validateDirective,Xl as validateTemplate};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{k}from"./chunk-h6633jna.js";import{s}from"./chunk-ftskxb7f.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
2
+ import{k}from"./chunk-39nvwdn6.js";import{s}from"./chunk-rcwqm2qq.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import{ie}from"./chunk-zaaeneq6.js";import{Le,A}from"./chunk-2h8ea0we.js";import{ba}from"./chunk-04kg16qs.js";import{c}from"./chunk-zhf01af3.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Gs(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ie(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
3
  `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Ks(s,l,o={}){let i=Zt(s,o);await Gs(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-j0dsavn2.js"),a=A((await e(s)).runtimeConfig);return await Le(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
4
+ `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-paedp1tc.js"),a=A((await e(s)).runtimeConfig);return await Le(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
5
  `));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Js(s,l,o){if(ba(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
6
6
  export{Zt,Gs,Ks,Xs,sp,Js};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{he,hs,ru,Ap,su,Pp,It,m,F,K,fn,be,ou,Lo,iu,Ip,k,au,Op,_,Np}from"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{au as applyFilters,Pp as clearCustomFilters,ou as clientLoopScopes,hs as defaultFilters,fn as escapeAttributeValue,m as escapeHtml,F as escapeHtmlValue,K as escapeInterpolatedHtmlValue,_ as evaluateExpression,he as findMustacheEnd,su as getAllFilters,iu as interpolateScriptAttributes,Lo as interpolateScriptExpressions,Ip as interpolateScriptsInTemplate,k as processExpressions,ru as registerFilter,Ap as registerFilters,It as replaceInterpolations,Op as resetRejectedExpressionWarnings,Np as unescapeHtml,be as usesSignalsInScript};
2
+ import{he,hs,ru,Ap,su,Pp,It,m,F,K,fn,be,ou,Lo,iu,Ip,k,au,Op,_,Np}from"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{au as applyFilters,Pp as clearCustomFilters,ou as clientLoopScopes,hs as defaultFilters,fn as escapeAttributeValue,m as escapeHtml,F as escapeHtmlValue,K as escapeInterpolatedHtmlValue,_ as evaluateExpression,he as findMustacheEnd,su as getAllFilters,iu as interpolateScriptAttributes,Lo as interpolateScriptExpressions,Ip as interpolateScriptsInTemplate,k as processExpressions,ru as registerFilter,Ap as registerFilters,It as replaceInterpolations,Op as resetRejectedExpressionWarnings,Np as unescapeHtml,be as usesSignalsInScript};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{o}from"./chunk-adxt8qcy.js";import{Fs}from"./chunk-vqc4h16r.js";import p from"path";async function Ku(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Fs(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-tywr9wc5.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
2
+ import{o}from"./chunk-y4crq495.js";import{Fs}from"./chunk-vqc4h16r.js";import p from"path";async function Ku(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Fs(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-ehy44811.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
3
  export{Ku};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{gn,jo}from"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";export{jo as generateRuntimeConfigTypes,gn as prepareRuntimeConfig};
2
+ import{gn,jo}from"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";export{jo as generateRuntimeConfigTypes,gn as prepareRuntimeConfig};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kl,Br}from"./chunk-vzk09hvw.js";import"./chunk-r7kmsq3n.js";import"./chunk-8nryyqb5.js";import{ar}from"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import{et}from"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{et as freeIdentifiers,Br as processComponents,kl as processESImports,ar as rendersAsElement};
2
+ import{kl,Br}from"./chunk-hm4fzr68.js";import"./chunk-r7kmsq3n.js";import"./chunk-8nryyqb5.js";import{ar}from"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import{et}from"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{et as freeIdentifiers,Br as processComponents,kl as processESImports,ar as rendersAsElement};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lc,uc}from"./chunk-7rta163c.js";import{j,ss,os,is,So,ko,sr,Ae,le,q,cs,ne,Tt,ue,Ze,ir,To,lr,Me,n,m,F,fn}from"./chunk-h6633jna.js";import{d,E,et,u}from"./chunk-hb08vrbb.js";import{ee}from"./chunk-r7kmsq3n.js";import{i}from"./chunk-eqrkhc18.js";import{p}from"./chunk-2a4szpje.js";import{createHash as St}from"crypto";import Y from"fs";import J from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as ht}from"ts-images/delivery";import Be from"fs";function Se(e,t,r){let s=Buffer.alloc(r),o=Be.readSync(e,s,0,r,t);return s.subarray(0,o)}function Te(e){if(e.length<25)return!1;let t=(s,o)=>String.fromCharCode(...e.subarray(s,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function De(e){let t;try{t=Be.openSync(e,"r");let r=Se(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===6)return"possible";let o=8;for(let a=0;a<64;a++){let c=Se(t,o,8);if(c.length<8)return"unknown";let f=c.toString("latin1",4,8);if(f==="tRNS")return"possible";if(f==="IDAT"||f==="IEND")return"none";o+=12+c.readUInt32BE(0)}return"unknown"}if(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(Te(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Be.closeSync(t)}}import Jt from"fs";import Ce from"os";import{join as ft}from"path";import{fileURLToPath as dt}from"url";import{Worker as gt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Ce.availableParallelism==="function"?Ce.availableParallelism():Ce.cpus().length){return Math.max(1,Math.min(2,e-1))}var Re=0,pt=[];async function Qt(){if(Re<Yt()){Re++;return}await new Promise((e)=>pt.push(e)),Re++}function en(){Re--,pt.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(dt(r)))return dt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.split("/").some((o)=>/@\d[^/]*@@@\d+$/.test(o)))return!1;return![t.BUN_INSTALL_CACHE_DIR,ft(t.BUN_INSTALL||ft(Ce.homedir(),".bun"),"install","cache")].filter((o)=>!!o).map((o)=>`${o.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((o)=>r.startsWith(o))}var mt=!1;function me(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function je(e){return e instanceof Error?e.message:String(e)}async function Le(e,t){if(typeof gt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,o)=>{let a;try{a=new gt(r)}catch(h){s(me(`could not start ${r}: ${je(h)}`));return}let c=!1,f=!1,l=(h)=>{if(f)return;f=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>s(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>o(v))}),a.on("error",(h)=>{l(()=>c?o(h instanceof Error?h:Error(je(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${je(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):s(me(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let o=JSON.parse(Y.readFileSync(s,"utf8"));if(o.name===e)return o.version}r=J.dirname(r)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var bt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=St("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function vt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let o=J.join(e,s);try{let a=await Y.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:r(s)}:null}catch{return null}},async write(s,o){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,o),await Y.promises.rename(c,a),{bytes:o.byteLength,path:a,url:r(s)}},url:r}}async function Ct(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((o,a)=>o.name.localeCompare(a.name));let s=[];for(let o of r){let a=J.join(t,o.name);if(o.isDirectory()){s.push(...await Ct(e,a));continue}if(!o.isFile()||!an.has(J.extname(o.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function wt(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return De(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,o])=>o.fallback.format==="png"),r=new Set,s=8;for(let o=0;o<t.length;o+=8)await Promise.all(t.slice(o,o+8).map(async([a,c])=>{let f=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await Y.promises.readFile(f?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let o=e[s],a=o?.variants.filter((f)=>f.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((f)=>{let l;try{return l=Y.openSync(f.path,"r"),!Te(Se(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(o.variants=o.variants.filter((f)=>f.format!=="webp"),delete o.sources.webp,r.push(s),!bt.has(s))bt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let o=e.slice(s,s+8),a=await Promise.all(o.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function ze(e){return J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(ze(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(ze(e)),{recursive:!0}),Y.writeFileSync(ze(e),JSON.stringify(t))}catch{}}function $t(e){try{let t=Y.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Qs(e){let t=Rt(e);return t?he().catalog.get(t):void 0}function eo(e){let t=Rt(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((o)=>o.format===s).reduce((o,a)=>o+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,o)=>s.bytes-o.bytes).map(({format:s,srcset:o})=>({format:s,srcset:o}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let g=await Le("delivery",{publicDir:e,outputDir:t});if(g!==ke)return Sn(g.state),g.result}let s=await Ct(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let o=wn(t),a=s.filter((g)=>{let b=o[g.relativePath];if(!b)return!0;let w=$t(g.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return jr(),{count:0,fingerprint:""};let c=vt(J.join(t,"_stx","images"),`${ln}:${yt()}`),f={outDir:J.join(t,"_stx","images"),storage:vt(J.join(t,"_stx","images"),`${un}:${yt()}`),baseUrl:pe,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await ht({...f,entries:wt(a,c)})}catch(g){if(l=await vn(a),l.length===a.length)throw g;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=$t(C.absolutePath);if(!k)continue;o[C.relativePath]=k,w=!0}if(w)$n(t,o);if(l.length===0)return jr(),{count:0,fingerprint:""};h=await ht({...f,entries:wt(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:St("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,r,s){let o=So(e,s);if(o!==void 0)return o;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var ae=new At;function R(e){return F(e)}var re="\x00stx-boolean-attribute";function Ue(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function We(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function se(e,t){let r=[];for(let[s,o]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof o==="boolean"){if(o)r.push(m(a));continue}if(o===re){r.push(m(a));continue}r.push(`${m(a)}="${fn(a,Ue(String(o)))}"`)}return r}function ie(e,t){let r=[];for(let[s,o]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(o===!0){r.push(m(a));continue}if(typeof o==="object")continue;r.push(`${m(a)}="${fn(a,Ue(String(o)))}"`)}return r}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Fe={name:"StxLink",aliases:["stx-link"],render(e,t,r){let s=Rn(e),o=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",f=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(s.reactive)l.push(`:href="${R(s.value)}"`);else l.push(`href="${R(sr(s.value,"navigable"))}"`);if(o)l.push(`class="${R(o)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),f)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...se(e,v)),l.push(...ie(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function He(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qe=[320,640,768,1024,1280,1536,1920];function G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function _e(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return r}function Xe(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[o,a]=s.split(":"),c=kn[o];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let f=Number.parseInt(o);if(!Number.isNaN(f))r.push(`(max-width: ${f}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((o)=>`${ye(e,o,void 0,r,s)} ${o}w`).join(", ")}function Pn(e,t,r,s,o){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,o)} ${a}x`}).join(", ")}function ye(e,t,r,s,o){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));if(o)a.set("format",o);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",o=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(o?String(o.source.width):void 0),f=G(e,"height")||(o?String(o.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||He(s)?.transparent===!0,x=G(e,"placeholder")||(o&&!S?"thumbhash":void 0),g=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",C=G(e,"style")||"",k=G(e,"objectFit")||G(e,"fit"),A=G(e,"objectPosition")||G(e,"position"),I=G(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",_=!!o||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=f?Number.parseInt(f):void 0,z=h||"",V="";if(o)z=o.sources[o.fallback.format]||"",V=l?Xe(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,qe,b,y),V=Xe(l);else if(!z&&v){let P=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,P,O,b,y)}else if(l)V=Xe(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],oe=x==="blur"||x==="color"||x==="thumbhash";if(oe&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:g}:He(s);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let H=In(O||16,B||9,g);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!oe&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let ve=o?.fallback.url||ye(s,O,B,b,y),K=[];if(K.push(`src="${R(sr(ve,"fetched"))}"`),K.push(`alt="${R(a)}"`),c)K.push(`width="${R(c)}"`);if(f)K.push(`height="${R(f)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${R(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${R(N)}"`),w)K.push(`class="${R(w)}"`);if(D.length>0)K.push(`style="${R(D.join(";"))}"`);if(z)K.push(`srcset="${R(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${R(V)}"`);let we=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",H=_n(W)+(P?`;${P}`:"");K.push(`onload="${R(H)}"`),we.add("onload")}K.push(...se(e,we)),K.push(...ie(e,we));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(ve)}"${H?` type="${H}"`:""}${z?` imagesrcset="${R(z)}"`:""}${V?` imagesizes="${R(V)}"`:""} />
2
+ import{lc,uc}from"./chunk-7rta163c.js";import{j,ss,os,is,So,ko,sr,Ae,le,q,cs,ne,Tt,ue,Ze,ir,To,lr,Me,n,m,F,fn}from"./chunk-39nvwdn6.js";import{d,E,et,u}from"./chunk-hb08vrbb.js";import{ee}from"./chunk-r7kmsq3n.js";import{i}from"./chunk-eqrkhc18.js";import{p}from"./chunk-2a4szpje.js";import{createHash as St}from"crypto";import Y from"fs";import J from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as ht}from"ts-images/delivery";import Be from"fs";function Se(e,t,r){let s=Buffer.alloc(r),o=Be.readSync(e,s,0,r,t);return s.subarray(0,o)}function Te(e){if(e.length<25)return!1;let t=(s,o)=>String.fromCharCode(...e.subarray(s,o));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function De(e){let t;try{t=Be.openSync(e,"r");let r=Se(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===6)return"possible";let o=8;for(let a=0;a<64;a++){let c=Se(t,o,8);if(c.length<8)return"unknown";let f=c.toString("latin1",4,8);if(f==="tRNS")return"possible";if(f==="IDAT"||f==="IEND")return"none";o+=12+c.readUInt32BE(0)}return"unknown"}if(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(Te(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Be.closeSync(t)}}import Jt from"fs";import Ce from"os";import{join as ft}from"path";import{fileURLToPath as dt}from"url";import{Worker as gt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Ce.availableParallelism==="function"?Ce.availableParallelism():Ce.cpus().length){return Math.max(1,Math.min(2,e-1))}var Re=0,pt=[];async function Qt(){if(Re<Yt()){Re++;return}await new Promise((e)=>pt.push(e)),Re++}function en(){Re--,pt.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(dt(r)))return dt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.split("/").some((o)=>/@\d[^/]*@@@\d+$/.test(o)))return!1;return![t.BUN_INSTALL_CACHE_DIR,ft(t.BUN_INSTALL||ft(Ce.homedir(),".bun"),"install","cache")].filter((o)=>!!o).map((o)=>`${o.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((o)=>r.startsWith(o))}var mt=!1;function me(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function je(e){return e instanceof Error?e.message:String(e)}async function Le(e,t){if(typeof gt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,o)=>{let a;try{a=new gt(r)}catch(h){s(me(`could not start ${r}: ${je(h)}`));return}let c=!1,f=!1,l=(h)=>{if(f)return;f=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>s(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>o(v))}),a.on("error",(h)=>{l(()=>c?o(h instanceof Error?h:Error(je(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${je(h)}`)))}),a.on("exit",(h)=>{l(()=>c?o(Error("image worker exited before it finished")):s(me(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let o=JSON.parse(Y.readFileSync(s,"utf8"));if(o.name===e)return o.version}r=J.dirname(r)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var bt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=St("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function vt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let o=J.join(e,s);try{let a=await Y.promises.stat(o);return a.size>0?{bytes:a.size,path:o,url:r(s)}:null}catch{return null}},async write(s,o){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,o),await Y.promises.rename(c,a),{bytes:o.byteLength,path:a,url:r(s)}},url:r}}async function Ct(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((o,a)=>o.name.localeCompare(a.name));let s=[];for(let o of r){let a=J.join(t,o.name);if(o.isDirectory()){s.push(...await Ct(e,a));continue}if(!o.isFile()||!an.has(J.extname(o.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function wt(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return De(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,o])=>o.fallback.format==="png"),r=new Set,s=8;for(let o=0;o<t.length;o+=8)await Promise.all(t.slice(o,o+8).map(async([a,c])=>{let f=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await Y.promises.readFile(f?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let o=e[s],a=o?.variants.filter((f)=>f.format==="webp")??[];if(!o||a.length===0)continue;if(!a.some((f)=>{let l;try{return l=Y.openSync(f.path,"r"),!Te(Se(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(o.variants=o.variants.filter((f)=>f.format!=="webp"),delete o.sources.webp,r.push(s),!bt.has(s))bt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let o=e.slice(s,s+8),a=await Promise.all(o.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function ze(e){return J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(ze(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(ze(e)),{recursive:!0}),Y.writeFileSync(ze(e),JSON.stringify(t))}catch{}}function $t(e){try{let t=Y.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Qs(e){let t=Rt(e);return t?he().catalog.get(t):void 0}function eo(e){let t=Rt(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((o)=>o.format===s).reduce((o,a)=>o+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,o)=>s.bytes-o.bytes).map(({format:s,srcset:o})=>({format:s,srcset:o}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let g=await Le("delivery",{publicDir:e,outputDir:t});if(g!==ke)return Sn(g.state),g.result}let s=await Ct(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let o=wn(t),a=s.filter((g)=>{let b=o[g.relativePath];if(!b)return!0;let w=$t(g.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return jr(),{count:0,fingerprint:""};let c=vt(J.join(t,"_stx","images"),`${ln}:${yt()}`),f={outDir:J.join(t,"_stx","images"),storage:vt(J.join(t,"_stx","images"),`${un}:${yt()}`),baseUrl:pe,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await ht({...f,entries:wt(a,c)})}catch(g){if(l=await vn(a),l.length===a.length)throw g;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=$t(C.absolutePath);if(!k)continue;o[C.relativePath]=k,w=!0}if(w)$n(t,o);if(l.length===0)return jr(),{count:0,fingerprint:""};h=await ht({...f,entries:wt(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:St("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,r,s){let o=So(e,s);if(o!==void 0)return o;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var ae=new At;function R(e){return F(e)}var re="\x00stx-boolean-attribute";function Ue(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function We(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function se(e,t){let r=[];for(let[s,o]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof o==="boolean"){if(o)r.push(m(a));continue}if(o===re){r.push(m(a));continue}r.push(`${m(a)}="${fn(a,Ue(String(o)))}"`)}return r}function ie(e,t){let r=[];for(let[s,o]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(o===null||o===void 0||o===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(o===!0){r.push(m(a));continue}if(typeof o==="object")continue;r.push(`${m(a)}="${fn(a,Ue(String(o)))}"`)}return r}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Fe={name:"StxLink",aliases:["stx-link"],render(e,t,r){let s=Rn(e),o=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",f=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(s.reactive)l.push(`:href="${R(s.value)}"`);else l.push(`href="${R(sr(s.value,"navigable"))}"`);if(o)l.push(`class="${R(o)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),f)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...se(e,v)),l.push(...ie(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function He(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qe=[320,640,768,1024,1280,1536,1920];function G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function _e(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let o=e.static[t];if(o!==void 0)return o!=="false"&&o!==!1;return r}function Xe(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[o,a]=s.split(":"),c=kn[o];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let f=Number.parseInt(o);if(!Number.isNaN(f))r.push(`(max-width: ${f}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((o)=>`${ye(e,o,void 0,r,s)} ${o}w`).join(", ")}function Pn(e,t,r,s,o){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,o)} ${a}x`}).join(", ")}function ye(e,t,r,s,o){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(o)a.push(`f_${o}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(o)a.set("fm",o);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));if(o)a.set("format",o);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",o=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(o?String(o.source.width):void 0),f=G(e,"height")||(o?String(o.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||He(s)?.transparent===!0,x=G(e,"placeholder")||(o&&!S?"thumbhash":void 0),g=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",C=G(e,"style")||"",k=G(e,"objectFit")||G(e,"fit"),A=G(e,"objectPosition")||G(e,"position"),I=G(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",_=!!o||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=f?Number.parseInt(f):void 0,z=h||"",V="";if(o)z=o.sources[o.fallback.format]||"",V=l?Xe(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,qe,b,y),V=Xe(l);else if(!z&&v){let P=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,P,O,b,y)}else if(l)V=Xe(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],oe=x==="blur"||x==="color"||x==="thumbhash";if(oe&&!S){let P=o?.placeholder?{dataUrl:o.placeholder.dataUrl,color:g}:He(s);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let H=In(O||16,B||9,g);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!oe&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let ve=o?.fallback.url||ye(s,O,B,b,y),K=[];if(K.push(`src="${R(sr(ve,"fetched"))}"`),K.push(`alt="${R(a)}"`),c)K.push(`width="${R(c)}"`);if(f)K.push(`height="${R(f)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${R(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${R(N)}"`),w)K.push(`class="${R(w)}"`);if(D.length>0)K.push(`style="${R(D.join(";"))}"`);if(z)K.push(`srcset="${R(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${R(V)}"`);let we=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",H=_n(W)+(P?`;${P}`:"");K.push(`onload="${R(H)}"`),we.add("onload")}K.push(...se(e,we)),K.push(...ie(e,we));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(ve)}"${H?` type="${H}"`:""}${z?` imagesrcset="${R(z)}"`:""}${V?` imagesizes="${R(V)}"`:""} />
3
3
  `}if(_){let P=[];if(o)for(let H of to(o))P.push(`<source type="image/${H.format}" srcset="${R(H.srcset)}"${V?` sizes="${R(V)}"`:""} />`);if(!o&&(y==="avif"||y==="auto")){let H=ye(s,O,B,b,"avif"),Q=z?Ve(s,qe,b,"avif"):`${H}`;P.push(`<source type="image/avif" srcset="${R(Q)}"${V?` sizes="${R(V)}"`:""} />`)}if(!o&&(y==="webp"||y==="auto")){let H=ye(s,O,B,b,"webp"),Q=z?Ve(s,qe,b,"webp"):`${H}`;P.push(`<source type="image/webp" srcset="${R(Q)}"${V?` sizes="${R(V)}"`:""} />`)}return`${Z}<picture>
4
4
  ${P.join(`
5
5
  `)}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{x}from"./chunk-7rta163c.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-h6633jna.js";import{o}from"./chunk-adxt8qcy.js";import{zs}from"./chunk-e3crw545.js";import{c}from"./chunk-zhf01af3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=un.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),xe=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let r=y[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),w=p.split(`
2
+ import{x}from"./chunk-7rta163c.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-39nvwdn6.js";import{o}from"./chunk-y4crq495.js";import{zs}from"./chunk-0y05x1ef.js";import{c}from"./chunk-zhf01af3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=un.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),xe=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let r=y[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;s.push({line:w,column:f-(p.lastIndexOf(`
4
4
  `)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Pc(e,t="",s=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",i=$o(e)+Eo(Co(e.code)),l=e.kind==="client"||e.kind==="plain"?Pa(t,e.code):"";return ls(`${u+i}
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{rd,Li,il,sd,od,id,ad,cd,al,cl,ld,ud,dd,pd}from"./chunk-8hmds6dt.js";import"./chunk-rcwqm2qq.js";import"./chunk-yyfcg26x.js";import"./chunk-prf164ct.js";import"./chunk-etpjy429.js";import"./chunk-ze3p2wf6.js";import"./chunk-hm4fzr68.js";import"./chunk-r7kmsq3n.js";import"./chunk-tgm4mnn4.js";import"./chunk-v6zdb66z.js";import"./chunk-8nryyqb5.js";import"./chunk-1kn1at1y.js";import"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{il as SUSPENSE_RESOLVER_RUNTIME,Li as buildSuspenseResolveScript,cd as createStreamRenderer,id as extractStreamBoundaries,pd as generateHydrationRuntime,cl as islandDirective,ud as processSectionDirectives,od as processStreamDirectives,ld as registerStreamingDirectives,sd as renderStreamingPage,rd as streamTemplate,ad as streamTemplateSimple,dd as streamToResponse,al as streamingSuspenseDirective};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-h6633jna.js";import"./chunk-2h8ea0we.js";import"./chunk-z248e3gj.js";import"./chunk-a3d0g4mr.js";import"./chunk-a3mmhzpa.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-39nvwdn6.js";import"./chunk-2h8ea0we.js";import"./chunk-yeb4yc8a.js";import"./chunk-a3d0g4mr.js";import"./chunk-3bpts69r.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-ptx6n9hd.js";import"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
2
+ import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-rjekha6p.js";import"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Hn,s}from"./chunk-rcwqm2qq.js";import"./chunk-yyfcg26x.js";import"./chunk-prf164ct.js";import"./chunk-etpjy429.js";import"./chunk-ze3p2wf6.js";import"./chunk-hm4fzr68.js";import"./chunk-r7kmsq3n.js";import"./chunk-tgm4mnn4.js";import{me}from"./chunk-v6zdb66z.js";import"./chunk-8nryyqb5.js";import"./chunk-1kn1at1y.js";import"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import{Re,ps,gs}from"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Hn as buildModulesTag,me as injectRouterScript,s as processDirectives,ps as processJsonDirective,gs as processOnceDirective,Re as validateClientScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{N,Rl,po,o,R,xp,Sp}from"./chunk-adxt8qcy.js";import"./chunk-a3mmhzpa.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{R as config,N as defaultConfig,xp as defineStxConfig,po as discoverConfig,o as loadStxConfig,Rl as resolveStxDirectories,Sp as validateConfig};
2
+ import{N,Rl,po,o,R,xp,Sp}from"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{R as config,N as defaultConfig,xp as defineStxConfig,po as discoverConfig,o as loadStxConfig,Rl as resolveStxDirectories,Sp as validateConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Pc,ki,Iu,Ic,Oc,Ou,Nu}from"./chunk-m040f3x9.js";import"./chunk-0y05x1ef.js";import"./chunk-djkjc1hj.js";import"./chunk-g4qz56km.js";import"./chunk-v2x9vzgw.js";import"./chunk-tgm4mnn4.js";import"./chunk-v6zdb66z.js";import"./chunk-8nryyqb5.js";import"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import{$t,Fl}from"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pc as buildVirtualSource,$t as extractScriptBlocks,Fl as extractTemplateExpressions,Ic as findRuntimeTypeDeclarations,Oc as findStxModuleDeclarations,Nu as formatTypecheckDiagnostics,Iu as sourcePathFor,Ou as typecheckStxFiles,ki as virtualPathFor};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{x}from"./chunk-7rta163c.js";import{T,vn}from"./chunk-ce6zddpf.js";import{S,G}from"./chunk-h6633jna.js";import{o}from"./chunk-adxt8qcy.js";import{_e,Xt,Jt,Yt}from"./chunk-fr4hs814.js";import{mt}from"./chunk-r6kbpwzd.js";import{dt,In,Wt,se}from"./chunk-d3bsfd10.js";import{C,yr}from"./chunk-fbtv2k1p.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let i of(s[1]??"").split(",")){let l=((i.includes(":")?i.split(":").pop():i)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let i of(s[1]??"").split(",")){let r=i.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Bd(c){let n;if(c)n=p.resolve(c);else{let t=await o();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Jt()}`,i=new Bun.Glob("*.ts"),r=[];try{for await(let t of i.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return se(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>_e(t))])],f=dt(l()),d=Wt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return se(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let y=u.map((t)=>t.file),m=[],g=new Set,v=G({loader:"ts",target:"browser",define:S()});for(let t of y)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),Xt(e))e=await Yt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=mt(e),e=T(e),e=vn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
2
+ import{x}from"./chunk-7rta163c.js";import{T,vn}from"./chunk-ce6zddpf.js";import{S,G}from"./chunk-39nvwdn6.js";import{o}from"./chunk-y4crq495.js";import{_e,Xt,Jt,Yt}from"./chunk-djkjc1hj.js";import{mt}from"./chunk-tgm4mnn4.js";import{dt,In,Wt,se}from"./chunk-d3bsfd10.js";import{C,yr}from"./chunk-fbtv2k1p.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let i of(s[1]??"").split(",")){let l=((i.includes(":")?i.split(":").pop():i)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let i of(s[1]??"").split(",")){let r=i.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function Bd(c){let n;if(c)n=p.resolve(c);else{let t=await o();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Jt()}`,i=new Bun.Glob("*.ts"),r=[];try{for await(let t of i.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return se(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>_e(t))])],f=dt(l()),d=Wt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return se(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let y=u.map((t)=>t.file),m=[],g=new Set,v=G({loader:"ts",target:"browser",define:S()});for(let t of y)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),Xt(e))e=await Yt(e,t,{projectRoot:process.cwd(),externalizeUserModules:C()});e=mt(e),e=T(e),e=vn(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
3
3
  ${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return se(a,s,f,""),null;let h=m.join(`
4
4
 
5
5
  `),w=`;(function(){
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ku}from"./chunk-51n5rfsk.js";import"./chunk-adxt8qcy.js";import"./chunk-a3mmhzpa.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Ku as buildApp};
2
+ import{Ku}from"./chunk-gd14j4h8.js";import"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Ku as buildApp};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Nr,qn,xl}from"./chunk-pwjre3b2.js";import"./chunk-r7kmsq3n.js";import"./chunk-8nryyqb5.js";import{Et}from"./chunk-h6633jna.js";import"./chunk-z248e3gj.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{xl as declareBareLoopHead,Et as parseLoopBinding,qn as processLoops,Nr as reportDeferredLoopWarnings};
2
+ import{Nr,qn,xl}from"./chunk-etpjy429.js";import"./chunk-r7kmsq3n.js";import"./chunk-8nryyqb5.js";import{Et}from"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{xl as declareBareLoopHead,Et as parseLoopBinding,qn as processLoops,Nr as reportDeferredLoopWarnings};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Hi,Vi,Ui,Wi,tp}from"./chunk-vmht7yf9.js";import"./chunk-08fpcex5.js";import"./chunk-c1dkh0es.js";import"./chunk-rcwqm2qq.js";import"./chunk-yyfcg26x.js";import"./chunk-prf164ct.js";import"./chunk-etpjy429.js";import"./chunk-ze3p2wf6.js";import"./chunk-hm4fzr68.js";import"./chunk-r7kmsq3n.js";import"./chunk-tgm4mnn4.js";import"./chunk-v6zdb66z.js";import"./chunk-8nryyqb5.js";import"./chunk-1kn1at1y.js";import"./chunk-y4crq495.js";import"./chunk-3bpts69r.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-39nvwdn6.js";import"./chunk-yeb4yc8a.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Hi as buildNative,tp as default,Vi as findCraftBinary,Wi as getAvailableFormats,Ui as getAvailableTargets};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{_o,Ea,r,Ct,te,S,Re,on,Ae,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Ie,Oe,ms,Me,n,pn,g,m,F,K,be,k,_}from"./chunk-h6633jna.js";import{l,d,E,t,re,z,a,ve,zo,D,hn,Ho,Mt,Vo,ec,pr,tc,nt,nc,fr,rc,yn,Uo,sc,gr,hr,we,Wo}from"./chunk-hb08vrbb.js";import{Ot}from"./chunk-2h8ea0we.js";import{gn}from"./chunk-z248e3gj.js";import{h}from"./chunk-vc2xzscw.js";import{er,ts}from"./chunk-zaaeneq6.js";import{ua,da,Yn,Ke,pa,R}from"./chunk-adxt8qcy.js";import{mo,ho,yo,bo}from"./chunk-t9mfztcs.js";import{oa,Br}from"./chunk-vzk09hvw.js";import{Dr,Mr,Lr}from"./chunk-msvpb1ax.js";import{Nr,qn}from"./chunk-pwjre3b2.js";import{Fr,io,ao,zr,Hr,co}from"./chunk-r6kbpwzd.js";import{Zs}from"./chunk-prf164ct.js";import{ee,no,ro,so}from"./chunk-r7kmsq3n.js";import{Gn,ge,aa,Kn,ca}from"./chunk-n48cshgz.js";import{U,qe}from"./chunk-szyqxcfj.js";import{fa,ga}from"./chunk-a3mmhzpa.js";import{C,bn,qo}from"./chunk-fbtv2k1p.js";import fs from"fs";import ce from"path";function lt(){return`
2
+ import{_o,Ea,r,Ct,te,S,Re,on,Ae,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Ie,Oe,ms,Me,n,pn,g,m,F,K,be,k,_}from"./chunk-39nvwdn6.js";import{l,d,E,t,re,z,a,ve,zo,D,hn,Ho,Mt,Vo,ec,pr,tc,nt,nc,fr,rc,yn,Uo,sc,gr,hr,we,Wo}from"./chunk-hb08vrbb.js";import{Ot}from"./chunk-2h8ea0we.js";import{gn}from"./chunk-yeb4yc8a.js";import{h}from"./chunk-yyfcg26x.js";import{er,ts}from"./chunk-zaaeneq6.js";import{ua,da,Yn,Ke,pa,R}from"./chunk-y4crq495.js";import{mo,ho,yo,bo}from"./chunk-t9mfztcs.js";import{oa,Br}from"./chunk-hm4fzr68.js";import{Dr,Mr,Lr}from"./chunk-ze3p2wf6.js";import{Nr,qn}from"./chunk-etpjy429.js";import{Fr,io,ao,zr,Hr,co}from"./chunk-tgm4mnn4.js";import{Zs}from"./chunk-prf164ct.js";import{ee,no,ro,so}from"./chunk-r7kmsq3n.js";import{Gn,ge,aa,Kn,ca}from"./chunk-v6zdb66z.js";import{U,qe}from"./chunk-szyqxcfj.js";import{fa,ga}from"./chunk-3bpts69r.js";import{C,bn,qo}from"./chunk-fbtv2k1p.js";import fs from"fs";import ce from"path";function lt(){return`
3
3
  // STX Lifecycle Runtime
4
4
  (function() {
5
5
  if (typeof window === 'undefined') return;
@@ -854,13 +854,13 @@ ${I}
854
854
  </style>`;o=o.replace(x,P),v.lastIndex=0}catch(I){}}}return o}import it from"path";var cs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ls=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ds(c,e){if(!e||!c.includes("/"))return c;let u=it.dirname(e);return c.replace(cs,(o,f,i,p)=>{let v=it.resolve(u,p);return`${f}${i}${v.split(it.sep).join("/")}${i}`})}function dn(c,e){if(!e||!c.includes("<script"))return c;return c.replace(ls,(u,o,f,i)=>`${o}${ds(f,e)}${i}`)}var Te="<!--PARENT_CONTENT_PLACEHOLDER-->";function fn(c){return c.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Sn(c,e){let u=c.length,o=e,f=!0,i=[],p=(v)=>v+9<=u&&c[v]==="<"&&c[v+1]==="/"&&(c[v+2]==="s"||c[v+2]==="S")&&(c[v+3]==="c"||c[v+3]==="C")&&(c[v+4]==="r"||c[v+4]==="R")&&(c[v+5]==="i"||c[v+5]==="I")&&(c[v+6]==="p"||c[v+6]==="P")&&(c[v+7]==="t"||c[v+7]==="T")&&(c[v+8]===">"||/\s/.test(c[v+8]));while(o<u){let v=c[o];if(p(o))return o;if(v==="/"&&c[o+1]==="/"){if(o=c.indexOf(`
855
855
  `,o+2),o===-1)return-1;o+=1,f=!0;continue}if(v==="/"&&c[o+1]==="*"){let y=c.indexOf("*/",o+2);if(y===-1)return-1;o=y+2,f=!0;continue}if(v==="/"&&f){let y=o+1,x=!1;while(y<u){let b=c[y];if(b==="\\"){y+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){y++;break}else if(b===`
856
856
  `){y=-1;break}y++}if(y===-1){o++,f=!1;continue}while(y<u&&/[a-z]/.test(c[y]))y++;o=y,f=!1;continue}if(v==="'"||v==='"'){let y=v;o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]===y){o++;break}if(c[o]===`
857
- `)break;o++}f=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,f=!0;break}o++}if(i.length===0)f=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,f=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,f=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))f=!1;else f=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let f=o.index+o[0].length,i=c.indexOf("</script>",f);if(i===-1)return null;let p=c.indexOf(">",i);if(p===-1)return null;return{start:o.index,end:p+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-m89yndgc.js");return`<script ${c} src="${o(e)}"></script>`}async function Hn(c,e,u){try{let{registeredModuleIdsIn:o,buildModuleRegistryScript:f}=await r("stx/client-module-registry",()=>import("./chunk-m2h91ccn.js")),i=[],p=await f(o(...c),{minify:qo(e.buildMode),collectInputs:i});for(let v of i)u?.add(v);if(!p)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-m89yndgc.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(p)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${p.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ys(c,e=""){let u=$n(c,"data-stx-runtime");if(!u)return c;let o=Gn(c);if(o===-1||o===u.start){if(!e)return c;return c.slice(0,u.end)+e+c.slice(u.end)}if(o<u.start)return c.slice(0,o)+c.slice(u.start,u.end)+e+`
857
+ `)break;o++}f=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,f=!0;break}o++}if(i.length===0)f=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,f=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,f=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))f=!1;else f=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let f=o.index+o[0].length,i=c.indexOf("</script>",f);if(i===-1)return null;let p=c.indexOf(">",i);if(p===-1)return null;return{start:o.index,end:p+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-w0hby6q6.js");return`<script ${c} src="${o(e)}"></script>`}async function Hn(c,e,u){try{let{registeredModuleIdsIn:o,buildModuleRegistryScript:f}=await r("stx/client-module-registry",()=>import("./chunk-ckmgf9x1.js")),i=[],p=await f(o(...c),{minify:qo(e.buildMode),collectInputs:i});for(let v of i)u?.add(v);if(!p)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-w0hby6q6.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(p)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${p.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ys(c,e=""){let u=$n(c,"data-stx-runtime");if(!u)return c;let o=Gn(c);if(o===-1||o===u.start){if(!e)return c;return c.slice(0,u.end)+e+c.slice(u.end)}if(o<u.start)return c.slice(0,o)+c.slice(u.start,u.end)+e+`
858
858
  `+c.slice(o,u.start)+c.slice(u.end);let f=c.slice(u.start,u.end),i=c.slice(0,u.start)+c.slice(u.end),p=Gn(i);if(p===-1)return f+e+`
859
859
  `+i;return i.slice(0,p)+f+e+`
860
860
  `+i.slice(p)}function vs(c){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return c.replace(e,(u,o,f)=>{let i=c.slice(0,f);return i.lastIndexOf("<")>i.lastIndexOf(">")?`{{${o}}}`:`{<!--stx-literal-->{${o}}}`})}async function s(c,e,u,o,f){if(o.ssr===!1&&!o.autoShell&&o.buildMode==="spa")return c;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=be(c,u);let i=!e.__stxProcessingDepth;ln(e);for(let p of o._layerGraph?.configDependencies??[])f.add(p);if(i&&o.runtimeConfig)await gn(e,u,o.runtimeConfig);if(i)za(e),e.__stx_scope_seq??={n:0,key:ms(String(e.__filename??u))},e.__stx_head_injections=Vo(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((o.debug||!C()&&!bn())&&u&&u.endsWith(".stx"))Zs(c,u);try{return await te.timeAsync("template-processing",async()=>{let p=await bs(c,e,u,o,f);if(i)p=Ao(p);if(i&&o.autoShell&&o.buildMode!=="compile"){let v=we(o.app?.head,{known:hr,source:"app.head"}),x=(e.__stx_runtime_head||null)??Wo(),b=(e.__stx_head_raw||"").trim(),w,T=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(T)w=T[1].trim(),b=b.replace(T[0],"").trim();let A=e.__sections?.title,O=A?k(A,e,u):void 0,M=x.title||w||O,I=!x.title&&(!!w||!!O),P=x.meta||[],N=new Set(P.map((G)=>nt(G)).filter(Boolean)),V={...v,...M&&{title:M},meta:[...(v.meta||[]).filter((G)=>!N.has(nt(G))),...P],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
861
861
  `),...x.htmlAttrs&&{htmlAttrs:nc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},X=Uo(p);if(p=gr(p,V,{...I&&{titleIsHtml:!0},...o.app?.colorMode&&{colorMode:o.app.colorMode}},X),X)p=sc(p,v),p=fr(p,V.htmlAttrs);let L=p.match(/<!-- stx-layout: ([^ ]+) -->/);if(L&&p.includes("<head")){let G=L[1],J=ts(G);p=p.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
862
862
  <meta name="stx-layout" content="${fn(G)}">
863
- <meta name="stx-layout-group" content="${fn(J)}">`)}let j=p.match(/function (__stx_setup_\w+)\(/),H=j?U(p):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){p=qe(p,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");p=p.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(p);if(y!==null)v.beforeClose.push(y);let x=tn(p);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!p.includes("data-stx-offline"))v.beforeClose.push(nn);p=ec(p,v);let b=o.app?.colorMode;if(b)p=pr(p,b)}if(i)if($n(p,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-721ba72m.js")),M=o.storesDir,I=await O(M);if(I)b=`<script data-stx-stores>${I}</script>`,x=await mn("data-stx-stores",I,o)??b}catch{}y=await Hn([p,b],o,f);try{let{getFrameworkComposableScript:O}=await r("stx/framework-composables",()=>import("./chunk-6dz6tpkp.js"));T=await O(p)}catch{}try{let{getComposableScript:O}=await r("stx/composable-loader",()=>import("./chunk-tr4hseng.js")),M=o.composablesDir,I=[y,b,T].filter((N)=>N!==null),P=await O(o._layerComposableDirs??M,p,I);if(P)w=await mn('data-stx-scoped data-stx-run="always" data-stx-composables',P,o)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${P}</script>`}catch{}let A=[y,x,w,T].filter((O)=>O!==null).map((O)=>`
863
+ <meta name="stx-layout-group" content="${fn(J)}">`)}let j=p.match(/function (__stx_setup_\w+)\(/),H=j?U(p):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){p=qe(p,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");p=p.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(p);if(y!==null)v.beforeClose.push(y);let x=tn(p);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!p.includes("data-stx-offline"))v.beforeClose.push(nn);p=ec(p,v);let b=o.app?.colorMode;if(b)p=pr(p,b)}if(i)if($n(p,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-4q9g7893.js")),M=o.storesDir,I=await O(M);if(I)b=`<script data-stx-stores>${I}</script>`,x=await mn("data-stx-stores",I,o)??b}catch{}y=await Hn([p,b],o,f);try{let{getFrameworkComposableScript:O}=await r("stx/framework-composables",()=>import("./chunk-zk537c7a.js"));T=await O(p)}catch{}try{let{getComposableScript:O}=await r("stx/composable-loader",()=>import("./chunk-zv2v281j.js")),M=o.composablesDir,I=[y,b,T].filter((N)=>N!==null),P=await O(o._layerComposableDirs??M,p,I);if(P)w=await mn('data-stx-scoped data-stx-run="always" data-stx-composables',P,o)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${P}</script>`}catch{}let A=[y,x,w,T].filter((O)=>O!==null).map((O)=>`
864
864
  ${O}`).join("");p=ys(p,A)}else{let y=await Hn([p],o,f);if(y){let x=p.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)p=p.slice(0,x)+y+`
865
865
  `+p.slice(x)}}if(i)p=tc(p);if(i&&e.__stx_inject_css!==!1)p=await h(p,void 0,o.buildMode==="serve",!0);else if(i)p=an(p);if(p=p.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),p=vs(p),i&&e.__stx_runtime_config)p=Ot(p,e.__stx_runtime_config);if(i&&!e.__stx_defer_server_data){let v=cr(e);if(v){let y=/<head\b[^>]*>/i.exec(p),x=y?y.index+y[0].length:0;p=p.slice(0,x)+v+p.slice(x)}}return p})}catch(p){if(p instanceof z)throw p;let v=p instanceof Error?p.message:String(p),y=new re(`Template processing failed: ${v}`,u,void 0,void 0,c.substring(0,200)+(c.length>200?"...":""));if(D.log(y,{filePath:u,context:e}),hn.logDetailedError(y,{filePath:u,template:c.substring(0,500)}),C()&&!o.debug)console.error(`[stx] ${ce.relative(process.cwd(),u)||u}: ${y.message}`);if(o.debug)throw y;return zo.createFallbackContent("Template Processing",y)}}async function bs(c,e,u,o,f){let i=process.cwd(),p={...o,partialsDir:o.partialsDir&&!ce.isAbsolute(o.partialsDir)?ce.resolve(i,o.partialsDir):o.partialsDir,componentsDir:o.componentsDir&&!ce.isAbsolute(o.componentsDir)?ce.resolve(i,o.componentsDir):o.componentsDir,layoutsDir:o.layoutsDir&&!ce.isAbsolute(o.layoutsDir)?ce.resolve(i,o.layoutsDir):o.layoutsDir},v=p,y=c;await ks(u,e),xs(e,v),y=await ve(()=>zt(y,e,u,v),y,(L)=>{D.log(L,{filePath:u,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${u}: ${L.message}`)}),y=y.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=le(y,Ae,(L,j)=>`\x00STX_HTML_COMMENT_${j}\x00`);y=x.output;let b=x.tokens,w=(L)=>b.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(j,H)=>b[Number(H)]??""),T="\x00STX_ESCAPED_AT\x00",A="\x00STX_ESC_MUSTACHE_OPEN\x00",O="\x00STX_ESC_MUSTACHE_CLOSE\x00";y=y.replace(/@@/g,T),y=y.replace(/@\{\{([\s\S]*?)\}\}/g,(L,j)=>`${A}${j}${O}`),y=Jt(y),y=await un(y,u,f);let M={};y=Mr(y,M);let I={...e.__sections||{}},P="",N=mt(ft(c)),V=/@nolayout\b/.test(y)||N===!1;if(/@nolayout\b/.test(y))y=y.replace(/@nolayout\b\s*/g,"");let X=y.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(X)P=X[1],y=y.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(P=N,!/@section\s*\(/.test(y))y=`@section('content')
866
866
  ${y.trim()}
@@ -869,7 +869,7 @@ ${y.trim()}
869
869
  @endsection`}}if(P&&y.includes("<script")){let L=q(y),j=L.scripts.map((H)=>vn(H,u)??H);y=or(L.output,j)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,j,H)=>(I[j]=H,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,j,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return L;try{let G=l(H.trim(),e);if(G===void 0)return L;let Y=(e.__stx_inline_section_values??=[]).push(G)-1;return I[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return L}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,j,H)=>{if(H.includes("@parent"))I[j]=H.replace("@parent",Te);else I[j]=H.trim();return""}),e.__sections=I,y=y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,j,H)=>I[j]||H||""),!("slot"in e)||e.slot===void 0)y=y.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||"");if(y=Lr(y,M),P){let L=[],j=q(y),H=le(j.output,on,(G,J)=>`\x00STX_ORPHAN_STYLE_${J}\x00`);if(y=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(G,J,Y)=>{let ne=J==="SCRIPT"?vn(j.scripts[Number(Y)],u):H.tokens[Number(Y)];if(ne)L.push(ne);return""}),L.length>0){let G=L.join(`
870
870
  `);I.content=I.content?`${I.content}
871
871
  ${G}`:G,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,f.add(P);else L=await ve(()=>pn(P,u,p,f),null,()=>{throw new re(`Failed to resolve layout path: ${P}`,u,void 0,void 0,`Layout referenced from ${u}`)});if(!L){let ne=(oe)=>{if(!oe)return[];try{let ae=ce.isAbsolute(oe)?oe:ce.resolve(process.cwd(),oe);return fs.readdirSync(ae).filter((ue)=>ue.endsWith(".stx")).map((ue)=>ue.replace(/\.stx$/,""))}catch{return[]}},se=[...ne(p.layoutsDir),...ne(p.fallbackLayoutsDir)].filter((oe,ae,ue)=>ue.indexOf(oe)===ae).sort(),de=`Layout not found: ${P} (referenced from ${u})`+(se.length>0?`. Available layouts: ${se.join(", ")}`:p.layoutsDir?`. No .stx layouts found in ${p.layoutsDir}`:"");if(D.log(Error(de),{layoutPath:P,filePath:u,available:se},"error"),console.error(`[stx] ${de}`),p.debug)throw new re(de,u);return y}let j=await ve(()=>Bun.file(L).text(),"",()=>{throw new re(`Failed to read layout file: ${L}`,u,void 0,void 0,"Layout content could not be loaded")});j=dn(j,L);let H=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(p.debug)console.log(`Found nested layout: ${H[1]} in ${L}`);let ne={},se=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ae,ue,ke)=>(ne[ue]=ke.trim(),""));for(let[ae,ue]of Object.entries(ne))if(I[ae]&&I[ae].includes(Te)){let ke=I[ae].indexOf(Te);I[ae]=I[ae].slice(0,ke)+ue+I[ae].slice(ke+Te.length)}else if(!I[ae])I[ae]=ue;let de={...e,__sections:I},oe=`@layout('${H[1]}')${se}`;return await s(oe,de,L,p,f)}let G=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),J=Mr(G,M),Y={};return J=J.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ne,se,de)=>(Y[se]=de.trim(),`@slot('${se}')`)),J=J.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ne,se,de)=>{if(I[se]){let oe=I[se];if(oe.includes(Te)){let ae=Y[se]||"",ue=oe.indexOf(Te);oe=oe.slice(0,ue)+ae+oe.slice(ue+Te.length)}return oe}return de||""}),J=ws(J,I),J=J.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||""),J=Lr(J,M),e.__originalFilePath=u,y=await kn(J,e,L,p,f),y=`<!-- stx-layout: ${P} -->
872
- ${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,p,f))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,f)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return f||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[f,i]of Object.entries(process.env))if(f.startsWith(u)&&i!==void 0)o[f]=i;c.$env=o}async function ks(c,e){await ve(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:f}=await r("stx/signal-processing",()=>import("./chunk-d8kfbhhw.js")),i=[],p=!C()&&!bn();for(let y of f(c)){let x=y.attrs;if(!/\bserver\b/.test(x))continue;let b=y.start+y.fullMatch.indexOf(">")+1,w=Sn(c,b);if(w===-1)continue;let T=c.slice(b,w);if(!T.trim())continue;let A=Ss(x)??u,O={index:y.start,length:w+9-y.start};try{let{extractVariables:M}=await r("stx/variable-extractor",()=>import("./chunk-1hny5z72.js"));await M(T,e,A,{preserveExisting:!0,onFailure:(I)=>{if(I.kind==="unknown")return;if(o?.onServerScriptError?.({sourcePath:A,kind:I.kind,message:I.message}),!p)return;i.push({...O,markup:xn(A,I.kind,I.message)})}})}catch(M){let I=M instanceof Error?M:Error(String(M));if(D.log(I,{filePath:A,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${A}: ${I.message}`),p)i.push({...O,markup:xn(A,"unknown",I.message)})}}if(i.length===0)return c;let v=c;for(let y of i.sort((x,b)=>b.index-x.index))v=v.slice(0,y.index)+y.markup+v.slice(y.index+y.length);return v}async function Es(c,e,u){try{let{interpolateScriptsInTemplate:o}=await r("stx/expressions",()=>import("./chunk-9jcxrc6t.js"));return o(c,e,{skipServer:!0})}catch(o){let f=o instanceof Error?o:Error(String(o));return D.log(f,{filePath:u,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${u}: ${f.message}`),c}}async function kn(c,e,u,o,f){let i=c,p=o;if(i=await $s(i,e,u,o),i=await Bt(i,e,u),i=await Ft(i,e,u),i=await Es(i,e,u),i=await At(i,e,u,p),be(i))i=io(i,e),i=Hr(i,e),i=zr(i,e);i=ao(i);let{processStreamDirectives:v}=await r("stx/streaming",()=>import("./chunk-r1hg1yc4.js"));i=v(i,e),i=qn(i,e,u,p,!0),i=await en(i,e,u,p,f),i=await Br(i,e,u,p,f),i=ua(i,e,u,p);let{processDeferDirectives:y}=await r("stx/defer",()=>import("./chunk-2f17h17f.js"));i=y(i,e,u);let{processTeleportDirectives:x}=await r("stx/teleport",()=>import("./chunk-wq712sw1.js"));i=x(i,e,u);let{processTransitionDirectives:b,processTransitionAttributes:w}=await r("stx/transitions",()=>import("./chunk-k2pa44rf.js"));i=b(i,e,u),i=w(i);let{processErrorBoundaryDirectives:T,stripRenderFailedMarkers:A}=await r("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));i=T(i,e,u),i=A(i);let{processSuspenseDirectives:O}=await r("stx/suspense",()=>import("./chunk-weqc0ssb.js"));i=O(i,e,u);let{processAsyncDirectives:M}=await r("stx/async-components",()=>import("./chunk-67kj14at.js"));i=M(i,e,u);let{processKeepAliveDirectives:I}=await r("stx/keep-alive",()=>import("./chunk-6vzktvyw.js"));i=I(i,e,u);let{processVirtualListDirectives:P,processVirtualGridDirectives:N,processInfiniteListDirectives:V}=await r("stx/virtual-scrolling",()=>import("./chunk-sf0wsq74.js"));i=P(i,e,u),i=N(i,e,u),i=V(i,e,u);let{processPartialHydrationDirectives:X,processStaticDirectives:L}=await r("stx/partial-hydration",()=>import("./chunk-9szxxgv5.js"));i=X(i,e,u),i=L(i);let{processComputedDirectives:j,processWatchDirectives:H}=await r("stx/computed",()=>import("./chunk-1xdzcy9d.js"));i=j(i,e,u),i=H(i,e,u);let{processFormValidationDirectives:G}=await r("stx/forms-validation",()=>import("./chunk-vsxws200.js"));i=G(i,e,u);let{processHeadDirective:J,processTitleDirective:Y,processMetaDirective:ne,resetHead:se}=await r("stx/head",()=>import("./chunk-np1k9vsr.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)se();let de=J(i);if(i=de.content,de.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${de.headContent}
872
+ ${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,p,f))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,f)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return f||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[f,i]of Object.entries(process.env))if(f.startsWith(u)&&i!==void 0)o[f]=i;c.$env=o}async function ks(c,e){await ve(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:f}=await r("stx/signal-processing",()=>import("./chunk-wtfjk49r.js")),i=[],p=!C()&&!bn();for(let y of f(c)){let x=y.attrs;if(!/\bserver\b/.test(x))continue;let b=y.start+y.fullMatch.indexOf(">")+1,w=Sn(c,b);if(w===-1)continue;let T=c.slice(b,w);if(!T.trim())continue;let A=Ss(x)??u,O={index:y.start,length:w+9-y.start};try{let{extractVariables:M}=await r("stx/variable-extractor",()=>import("./chunk-2jkq8n45.js"));await M(T,e,A,{preserveExisting:!0,onFailure:(I)=>{if(I.kind==="unknown")return;if(o?.onServerScriptError?.({sourcePath:A,kind:I.kind,message:I.message}),!p)return;i.push({...O,markup:xn(A,I.kind,I.message)})}})}catch(M){let I=M instanceof Error?M:Error(String(M));if(D.log(I,{filePath:A,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${A}: ${I.message}`),p)i.push({...O,markup:xn(A,"unknown",I.message)})}}if(i.length===0)return c;let v=c;for(let y of i.sort((x,b)=>b.index-x.index))v=v.slice(0,y.index)+y.markup+v.slice(y.index+y.length);return v}async function Es(c,e,u){try{let{interpolateScriptsInTemplate:o}=await r("stx/expressions",()=>import("./chunk-g90jymnr.js"));return o(c,e,{skipServer:!0})}catch(o){let f=o instanceof Error?o:Error(String(o));return D.log(f,{filePath:u,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${u}: ${f.message}`),c}}async function kn(c,e,u,o,f){let i=c,p=o;if(i=await $s(i,e,u,o),i=await Bt(i,e,u),i=await Ft(i,e,u),i=await Es(i,e,u),i=await At(i,e,u,p),be(i))i=io(i,e),i=Hr(i,e),i=zr(i,e);i=ao(i);let{processStreamDirectives:v}=await r("stx/streaming",()=>import("./chunk-mhhg2sfa.js"));i=v(i,e),i=qn(i,e,u,p,!0),i=await en(i,e,u,p,f),i=await Br(i,e,u,p,f),i=ua(i,e,u,p);let{processDeferDirectives:y}=await r("stx/defer",()=>import("./chunk-2f17h17f.js"));i=y(i,e,u);let{processTeleportDirectives:x}=await r("stx/teleport",()=>import("./chunk-wq712sw1.js"));i=x(i,e,u);let{processTransitionDirectives:b,processTransitionAttributes:w}=await r("stx/transitions",()=>import("./chunk-k2pa44rf.js"));i=b(i,e,u),i=w(i);let{processErrorBoundaryDirectives:T,stripRenderFailedMarkers:A}=await r("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));i=T(i,e,u),i=A(i);let{processSuspenseDirectives:O}=await r("stx/suspense",()=>import("./chunk-weqc0ssb.js"));i=O(i,e,u);let{processAsyncDirectives:M}=await r("stx/async-components",()=>import("./chunk-67kj14at.js"));i=M(i,e,u);let{processKeepAliveDirectives:I}=await r("stx/keep-alive",()=>import("./chunk-6vzktvyw.js"));i=I(i,e,u);let{processVirtualListDirectives:P,processVirtualGridDirectives:N,processInfiniteListDirectives:V}=await r("stx/virtual-scrolling",()=>import("./chunk-sf0wsq74.js"));i=P(i,e,u),i=N(i,e,u),i=V(i,e,u);let{processPartialHydrationDirectives:X,processStaticDirectives:L}=await r("stx/partial-hydration",()=>import("./chunk-9szxxgv5.js"));i=X(i,e,u),i=L(i);let{processComputedDirectives:j,processWatchDirectives:H}=await r("stx/computed",()=>import("./chunk-1xdzcy9d.js"));i=j(i,e,u),i=H(i,e,u);let{processFormValidationDirectives:G}=await r("stx/forms-validation",()=>import("./chunk-nz5t3kt9.js"));i=G(i,e,u);let{processHeadDirective:J,processTitleDirective:Y,processMetaDirective:ne,resetHead:se}=await r("stx/head",()=>import("./chunk-np1k9vsr.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)se();let de=J(i);if(i=de.content,de.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${de.headContent}
873
873
  `;if(i=Y(i,e),i=ne(i,e,u),i=Xt(i),i=no(i,e),i=Tt(i),i=Ut(i),i=await Dr(i,e,u,p,f),i=await Br(i,e,u,p,f),e.__stxProcessingDepth===1)i=Ha(i,e);if(i=i.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),i=Ao(i),i=ee(i,e,u),i=Nr(i),i=La(i,e,{filePath:u,buildMode:p.buildMode}),i=ro(i,e),i=so(i,e),i=We(i,e),i=Nt(i,e),i=Ht(i,e),i=await bt(i,e,u,p),i=await pa(i,e,u),i=await fa(i,e,u,p),i=ga(i,e,u,p),i=mo(i,e,u,p),i=ho(i,e,u),i=yo(i,e,u,p),i=Et(i,e,u,p),i=ps(i,e),i=gs(i),i=ja(i),!p.skipEventDirectives)i=Ea(i,e,u);if(i=vt(i,e,u),p.debug){let B=/\bx-data\s*=/.test(i),W=Fr(c);if(B&&W)console.warn(`[stx] ${u}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
874
874
  Both work on the same page, but they manage separate scopes.
875
875
  Prefer signals (state/derived/effect) for new components.`)}i=oa(i,e),i=await k(i,e,u),i=Ba(i),i=Fa(i),i=pt(i);let{processXElementDirectives:oe}=await r("stx/x-element",()=>import("./chunk-zhxdpzga.js"));i=oe(i);let ae=e.__originalFilePath||u,ue=Ie(e);if(i=await co(i,p,ae,ue),i=Pt(i,e),i=await Wt(i,e,u,p),p.media?.image?.autoSiblings){let B=p.publicDir||"public",{rewriteImagesWithSiblings:W}=await r("stx/image-optimization/auto-sibling",()=>import("./chunk-shpc1ttk.js"));i=await W(i,{publicDir:B})}if(p.seo?.enabled)i=bo(i,e,p);let ke=(B,W,Z=!0)=>{if(!W)return B;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),ie=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(B),fe=ie?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(ie[0]):null;if(he&&ie&&fe){if(Z){let Ce=ie.index+fe.index;B=B.slice(0,Ce)+he[0]+B.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return B}if(/<\/head>/i.test(B))return B.replace(/<\/head>/i,`${W}
@@ -883,6 +883,6 @@ ${lt()}
883
883
  `+Ce}else i=i.replace("</head>",`${W}
884
884
  </head>`)}else if(i.includes("<body"))i=i.replace(/<body([^>]*)>/,`<body$1>
885
885
  ${W}`);else i=W+`
886
- `+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-d8kfbhhw.js")),W=[];for(let Z of B(i)){if(!/\bserver\b/i.test(Z.attrs))continue;let he=Z.start+Z.fullMatch.indexOf(">")+1,ie=Sn(i,he);if(ie===-1)continue;let fe=ie+9;while(fe<i.length&&/\s/.test(i[fe]))fe++;W.push({start:Z.start,end:fe})}if(W.length>0){let Z=Array(W.length+1),he=0;for(let ie=0;ie<W.length;ie++){let{start:fe,end:Ce}=W[ie];Z[ie]=i.slice(he,fe),he=Ce}Z[W.length]=i.slice(he),i=Z.join("")}}let at=us(i,u);if(at.hasScoped)i=at.html;let Rn=e.__stx_event_bindings||[],Ge=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(i),{scanScriptTags:Dn}=await r("stx/signal-processing",()=>import("./chunk-d8kfbhhw.js"));for(let B of Dn(i,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:B.fullMatch,attrs:B.attrs,content:B.body});for(let{match:B,attrs:W,content:Z}of ct){Ge=!0;let he=Z;Re(Z,u,o.strict,e.__originalFilePath);let ie=await Oe(Z,{eventBindings:Rn,attrs:W,hasColonDirectives:Mn,templateContent:c,filePath:u,projectRoot:process.cwd(),production:qo(o.buildMode),serverData:ue});i=i.replace(B,()=>ie)}if(Ge)e.__stx_event_bindings=[];if(!Ge&&e.__stxProcessingDepth===1){let B=e.__stx_event_bindings||[];if(B.length>0){let W=_o(B);if(W){let Z=i.lastIndexOf("</body>");i=Z===-1?i+W:i.slice(0,Z)+W+`
886
+ `+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-wtfjk49r.js")),W=[];for(let Z of B(i)){if(!/\bserver\b/i.test(Z.attrs))continue;let he=Z.start+Z.fullMatch.indexOf(">")+1,ie=Sn(i,he);if(ie===-1)continue;let fe=ie+9;while(fe<i.length&&/\s/.test(i[fe]))fe++;W.push({start:Z.start,end:fe})}if(W.length>0){let Z=Array(W.length+1),he=0;for(let ie=0;ie<W.length;ie++){let{start:fe,end:Ce}=W[ie];Z[ie]=i.slice(he,fe),he=Ce}Z[W.length]=i.slice(he),i=Z.join("")}}let at=us(i,u);if(at.hasScoped)i=at.html;let Rn=e.__stx_event_bindings||[],Ge=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(i),{scanScriptTags:Dn}=await r("stx/signal-processing",()=>import("./chunk-wtfjk49r.js"));for(let B of Dn(i,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:B.fullMatch,attrs:B.attrs,content:B.body});for(let{match:B,attrs:W,content:Z}of ct){Ge=!0;let he=Z;Re(Z,u,o.strict,e.__originalFilePath);let ie=await Oe(Z,{eventBindings:Rn,attrs:W,hasColonDirectives:Mn,templateContent:c,filePath:u,projectRoot:process.cwd(),production:qo(o.buildMode),serverData:ue});i=i.replace(B,()=>ie)}if(Ge)e.__stx_event_bindings=[];if(!Ge&&e.__stxProcessingDepth===1){let B=e.__stx_event_bindings||[];if(B.length>0){let W=_o(B);if(W){let Z=i.lastIndexOf("</body>");i=Z===-1?i+W:i.slice(0,Z)+W+`
887
887
  `+i.slice(Z)}e.__stx_event_bindings=[]}}if(!ge(i)&&aa(i))i=await Kn(i,p);if(i=ca(i),p.csp?.enabled&&p.csp.useNonce&&typeof e.cspNonce==="string")i=$t(i,e.cspNonce);return i}
888
888
  export{ft,Ee,ta,Ys,Hn,s};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{k}from"./chunk-h6633jna.js";import{oe}from"./chunk-wbzmr6a4.js";function g(e,t){let r={};for(let n of e)r[n]=oe(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=oe(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Mi(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=oe(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var tl=Mi;class Pn{rules=[];defaultValue="";addRule(e){let t=new Pn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Pn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Pn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var td=new Pn;function nl(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>k(c,{...t,message:l},r)).join(`
2
+ import{k}from"./chunk-39nvwdn6.js";import{oe}from"./chunk-wbzmr6a4.js";function g(e,t){let r={};for(let n of e)r[n]=oe(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=oe(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Mi(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=oe(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var tl=Mi;class Pn{rules=[];defaultValue="";addRule(e){let t=new Pn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Pn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Pn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var td=new Pn;function nl(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>k(c,{...t,message:l},r)).join(`
3
3
  `)}catch{return""}})}function rl(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>k(c,{...t,message:l},r)).join(`
4
4
  `)}catch{return""}})}function sl(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function nd(e,t,r){let n=e;return n=nl(n,t,r),n=rl(n,t,r),n=sl(n,t,r),n}export{Mi,tl,Pn,td,nl,rl,sl,nd};