@stacksjs/stx 0.2.460 → 0.2.462

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 (111) hide show
  1. package/dist/chunk-03ek5ag5.js +2 -0
  2. package/dist/chunk-0a2w25j8.js +2 -0
  3. package/dist/chunk-0e1rga0j.js +2 -0
  4. package/dist/chunk-0f1f6y2w.js +2 -0
  5. package/dist/chunk-14p5jgqp.js +2 -0
  6. package/dist/{chunk-26gxw0e2.js → chunk-18pagcsc.js} +5 -5
  7. package/dist/chunk-1fccwkkq.js +2 -0
  8. package/dist/{chunk-ab56jdah.js → chunk-1k01h1zb.js} +1 -1
  9. package/dist/chunk-22972c8b.js +2 -0
  10. package/dist/{chunk-w1zvh5y7.js → chunk-2jbyks2t.js} +2 -2
  11. package/dist/{chunk-2cy956js.js → chunk-3rpbzfw5.js} +2 -2
  12. package/dist/{chunk-s25yesdx.js → chunk-3rrzxapr.js} +1 -1
  13. package/dist/{chunk-kp54j5hy.js → chunk-4mcmbvxb.js} +1 -1
  14. package/dist/{chunk-vqdv6ay9.js → chunk-501kq69r.js} +1 -1
  15. package/dist/{chunk-bq2e9qf6.js → chunk-5bqs0ve6.js} +1 -1
  16. package/dist/chunk-5ex4hjt3.js +2 -0
  17. package/dist/{chunk-dxxs52yw.js → chunk-5j5msbks.js} +2 -2
  18. package/dist/{chunk-jfps4n28.js → chunk-5pgvfxtx.js} +2 -2
  19. package/dist/{chunk-w6zz18jt.js → chunk-5w87wmc4.js} +2 -2
  20. package/dist/{chunk-18fa768q.js → chunk-6ths0ktv.js} +1 -1
  21. package/dist/{chunk-fm7crc6s.js → chunk-6wqvgy6x.js} +1 -1
  22. package/dist/{chunk-zchtjtq9.js → chunk-6yt2dpsb.js} +1 -1
  23. package/dist/{chunk-n1dyjhte.js → chunk-7h57dt0z.js} +3 -3
  24. package/dist/chunk-8xkr55v2.js +2 -0
  25. package/dist/{chunk-exgyf65a.js → chunk-8yrk8ybh.js} +3 -3
  26. package/dist/chunk-995ytskb.js +2 -0
  27. package/dist/chunk-9mmsb0zb.js +2 -0
  28. package/dist/{chunk-kppgyqwb.js → chunk-9n10mh5q.js} +1 -1
  29. package/dist/{chunk-ks35e0ze.js → chunk-9y6bn8hk.js} +1 -1
  30. package/dist/{chunk-mhpsz5m0.js → chunk-9yywhkc7.js} +8 -8
  31. package/dist/{chunk-6pyydsn1.js → chunk-a51ftv2n.js} +137 -7
  32. package/dist/{chunk-jkyb1f9r.js → chunk-a6pjaw6w.js} +1 -1
  33. package/dist/chunk-amvnckr7.js +2 -0
  34. package/dist/{chunk-zskhxkbk.js → chunk-b6e36vr2.js} +127 -112
  35. package/dist/{chunk-6cp3afft.js → chunk-b8p9y1kv.js} +2 -2
  36. package/dist/{chunk-12w518qc.js → chunk-bagh6sc1.js} +4 -4
  37. package/dist/chunk-c0wcvbhr.js +2 -0
  38. package/dist/chunk-darbqs38.js +2 -0
  39. package/dist/{chunk-1wtm4ayp.js → chunk-e02b66yn.js} +1 -1
  40. package/dist/chunk-e38fyh0y.js +2 -0
  41. package/dist/chunk-gcz1wex2.js +2 -0
  42. package/dist/{chunk-qxcw9k0z.js → chunk-gn32cr6z.js} +1 -1
  43. package/dist/{chunk-n866vbgj.js → chunk-gxhwg1f4.js} +2 -2
  44. package/dist/{chunk-5erw0wsr.js → chunk-hp901qmd.js} +1 -1
  45. package/dist/chunk-jbdvkj3q.js +2 -0
  46. package/dist/{chunk-9r6nd1nf.js → chunk-jnn745tt.js} +1 -1
  47. package/dist/chunk-jy58t59b.js +2 -0
  48. package/dist/{chunk-xz6dfe70.js → chunk-kggx9jc1.js} +1 -1
  49. package/dist/chunk-khx54f41.js +2 -0
  50. package/dist/{chunk-y15ybsg3.js → chunk-m2yy86d8.js} +4 -4
  51. package/dist/{chunk-5p56w2ke.js → chunk-n1mspzv7.js} +1 -1
  52. package/dist/{chunk-y1hx8re2.js → chunk-n3r5m938.js} +1 -1
  53. package/dist/chunk-n76phhd2.js +2 -0
  54. package/dist/{chunk-9z22zs86.js → chunk-neq30d52.js} +1 -1
  55. package/dist/{chunk-h9e032kq.js → chunk-pf0d8y9n.js} +2 -2
  56. package/dist/{chunk-fyh1w7j0.js → chunk-pq84ycrv.js} +1 -1
  57. package/dist/{chunk-fzs6v9x5.js → chunk-ptxvex42.js} +45 -45
  58. package/dist/{chunk-aeb8621d.js → chunk-q0d0q8r8.js} +2 -2
  59. package/dist/{chunk-ps54xqba.js → chunk-qer8jpr5.js} +1 -1
  60. package/dist/{chunk-1vgmzmsw.js → chunk-qr68w6qf.js} +1 -1
  61. package/dist/chunk-sd2gc341.js +2 -0
  62. package/dist/{chunk-bf519g5n.js → chunk-t0j0d802.js} +1 -1
  63. package/dist/chunk-t1s00kj6.js +2 -0
  64. package/dist/{chunk-ycdzhjt0.js → chunk-ty3j2ryw.js} +1 -1
  65. package/dist/{chunk-4fa3jec9.js → chunk-ver2yf41.js} +1 -1
  66. package/dist/chunk-vvyfeyxk.js +2 -0
  67. package/dist/{chunk-7sbgpmwt.js → chunk-vxhy0a3n.js} +2 -2
  68. package/dist/{chunk-tr7dz5g5.js → chunk-w28dbef2.js} +1 -1
  69. package/dist/{chunk-h356tjvs.js → chunk-wz29ahjp.js} +1 -1
  70. package/dist/{chunk-c491hsm1.js → chunk-x4yqyea2.js} +2 -2
  71. package/dist/{chunk-jdhs9w6h.js → chunk-xq4x3cy0.js} +1 -1
  72. package/dist/chunk-y2p3scx0.js +2 -0
  73. package/dist/{chunk-bf7aa9w7.js → chunk-yfbj4qce.js} +1 -1
  74. package/dist/{chunk-r6pax860.js → chunk-ynvce0q6.js} +2 -2
  75. package/dist/chunk-yxwam84p.js +2 -0
  76. package/dist/{chunk-mp633tnh.js → chunk-zkp2cw7q.js} +1 -1
  77. package/dist/chunk-zxbz8v00.js +2 -0
  78. package/dist/cli.js +9 -9
  79. package/dist/craft-entry.js +1 -1
  80. package/dist/craft.js +1 -1
  81. package/dist/pwa.js +1 -1
  82. package/dist/signals.js +133 -3
  83. package/dist/ssg.js +3 -3
  84. package/dist/utils.js +18 -3
  85. package/package.json +5 -5
  86. package/dist/chunk-0r0cbqpj.js +0 -2
  87. package/dist/chunk-0snysm7z.js +0 -2
  88. package/dist/chunk-3wkrrps3.js +0 -2
  89. package/dist/chunk-5m8q7c5r.js +0 -2
  90. package/dist/chunk-6vye2exm.js +0 -2
  91. package/dist/chunk-80a84qry.js +0 -2
  92. package/dist/chunk-8p2vfjg2.js +0 -2
  93. package/dist/chunk-9r1jj3rm.js +0 -2
  94. package/dist/chunk-cq7se10f.js +0 -2
  95. package/dist/chunk-cy2bskcx.js +0 -2
  96. package/dist/chunk-ef0gstkd.js +0 -2
  97. package/dist/chunk-f8hd3kh3.js +0 -2
  98. package/dist/chunk-fb1711er.js +0 -2
  99. package/dist/chunk-g7ksavh1.js +0 -2
  100. package/dist/chunk-hskrxdcc.js +0 -2
  101. package/dist/chunk-m00nek1y.js +0 -2
  102. package/dist/chunk-nqvb9094.js +0 -2
  103. package/dist/chunk-p0nx92aq.js +0 -2
  104. package/dist/chunk-q0qd0bm4.js +0 -2
  105. package/dist/chunk-q98v7bhs.js +0 -2
  106. package/dist/chunk-r61m4j2j.js +0 -2
  107. package/dist/chunk-rf9hm92z.js +0 -2
  108. package/dist/chunk-rpsjz8jd.js +0 -2
  109. package/dist/chunk-t68s37hg.js +0 -2
  110. package/dist/chunk-twb35cwb.js +0 -2
  111. package/dist/chunk-wz1bgf8q.js +0 -2
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{G}from"./chunk-w6zz18jt.js";import{le,C}from"./chunk-zydg3wgt.js";import{hi}from"./chunk-0trfbqa7.js";import{a}from"./chunk-7tt84v1y.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function bt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.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 u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Hr(s,l){let o=a(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:p}=G(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
2
+ import{G}from"./chunk-5w87wmc4.js";import{le,C}from"./chunk-zydg3wgt.js";import{hi}from"./chunk-0trfbqa7.js";import{a}from"./chunk-7tt84v1y.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function bt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.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 u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Hr(s,l){let o=a(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:p}=G(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: 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 Vr(s,l,o={}){let i=bt(s,o);await Hr(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 p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)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 p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...G(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,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.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=c.regex.exec(f),g=Object.create(null);try{c.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(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.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 Ur(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function yu(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=bt(s,o);return await Hr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=bt(s,o);await Hr(s,t);let{loadStxConfig:e}=await import("./chunk-0snysm7z.js"),p=C((await e(s)).runtimeConfig);return await le(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
4
+ `)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)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 p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...G(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,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.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=c.regex.exec(f),g=Object.create(null);try{c.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(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.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 Ur(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function yu(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=bt(s,o);return await Hr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=bt(s,o);await Hr(s,t);let{loadStxConfig:e}=await import("./chunk-1fccwkkq.js"),p=C((await e(s)).runtimeConfig);return await le(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
5
  `));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.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 Wr(s,l,o){if(hi(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(v.realpathSync(s))))return!0}catch{}if(R.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=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
6
6
  export{bt,Hr,Vr,Ur,yu,Wr};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import x from"fs";import u from"path";import p from"fs";import v from"path";var y=["components","layouts","partials","emails"];function P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function Os(e,t){let a=e.filter((i)=>!b(i.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let i of a){let c=[];for(let l of i.params){let d=i.pattern.includes(`:${l}?`)?"?":"";c.push(`${l}${d}: string`)}let s=c.join("; ");r.push(` '${i.pattern}': { ${s} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
3
  `),o=v.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function Ms(e,t,a){let r=process.cwd(),n=v.relative(r,a),o=e.filter((c)=>!b(c.pattern)),i=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let c of o){let s=v.relative(r,c.filePath).replace(/\\/g,"/"),l=JSON.stringify(c.params),d=c.layout?`, layout: '${v.relative(r,c.layout).replace(/\\/g,"/")}'`:"";i.push(` { pattern: '${c.pattern}', filePath: '${s}', isDynamic: ${c.isDynamic}, params: ${l}${d} },`)}i.push("] as const",""),i.push("export type RouteName = typeof routes[number]['pattern']",""),p.mkdirSync(t,{recursive:!0}),p.writeFileSync(v.join(t,"routes.ts"),i.join(`
4
- `))}import D from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),I=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),j=new RegExp(`\\.(?:${I})$`),E=`(?![^/]*\\.(?:${I})$)`;function Ze(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&j.test(r)}function R(e,t){let r=D.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(D.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function G(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function mn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function ir(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return G(a,t)}import K from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(K.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class hn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=G(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Os(this.routes,s),Ms(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function ar(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function cr(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function _c(e){k=e.replace(/\/$/,"")}function Rc(e,t,a={}){f[e]={path:t,name:e,params:a}}function Ac(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function yn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Pc(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Ic(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Dc(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Oc(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Ai(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Pi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Ii(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var w=new Map;function Ns(e,t){w.set(e,t)}function Di(e){return w.get(e)}function Mc(e){return w.has(e)}function Qe(){w.clear()}function et(){return Array.from(w.keys())}async function tt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Ns(o,s);else if(typeof s==="function")Ns(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function W(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function nt(e,t,a,r=""){return{path:e,params:t,query:W(r),fullPath:r?`${e}?${r}`:e,meta:a}}function rt(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Ai(a,i):Pi(),storage:Ii(),state:{},request:a,responseHeaders:i}}async function st(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=Di(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function lr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function xe(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||lr(n)}}var A,T;function V(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
4
+ `))}import D from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),I=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),j=new RegExp(`\\.(?:${I})$`),E=`(?![^/]*\\.(?:${I})$)`;function Ze(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&j.test(r)}function R(e,t){let r=D.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(D.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function G(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function mn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function ir(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return G(a,t)}import K from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(K.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class hn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=G(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Os(this.routes,s),Ms(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function ar(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function cr(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Tc(e){k=e.replace(/\/$/,"")}function Rc(e,t,a={}){f[e]={path:t,name:e,params:a}}function Ac(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function yn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Pc(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Ic(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Dc(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Oc(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Ai(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Pi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Ii(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var w=new Map;function Ns(e,t){w.set(e,t)}function Di(e){return w.get(e)}function Mc(e){return w.has(e)}function Qe(){w.clear()}function et(){return Array.from(w.keys())}async function tt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Ns(o,s);else if(typeof s==="function")Ns(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function W(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function nt(e,t,a,r=""){return{path:e,params:t,query:W(r),fullPath:r?`${e}?${r}`:e,meta:a}}function rt(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Ai(a,i):Pi(),storage:Ii(),state:{},request:a,responseHeaders:i}}async function st(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=Di(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function lr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function xe(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||lr(n)}}var A,T;function V(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
5
5
  ;(function(){
6
6
  'use strict';
7
7
  var ROUTER_REV=7;
@@ -3682,4 +3682,4 @@ else {
3682
3682
 
3683
3683
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
3684
3684
  })();
3685
- `}function Se(){if(A)return A;return A=q(V(X()),!0),A}function Nc(){if(T)return T;return T=q(X()),T}export{Os,Ms,Ze,G,mn,ir,hn,ar,cr,_c,Rc,Ac,yn,Pc,Ic,Dc,Oc,Ai,Pi,Ii,Ns,Di,Mc,Qe,et,tt,nt,rt,st,lr,xe,Se,Nc};
3685
+ `}function Se(){if(A)return A;return A=q(V(X()),!0),A}function Nc(){if(T)return T;return T=q(X()),T}export{Os,Ms,Ze,G,mn,ir,hn,ar,cr,Tc,Rc,Ac,yn,Pc,Ic,Dc,Oc,Ai,Pi,Ii,Ns,Di,Mc,Qe,et,tt,nt,rt,st,lr,xe,Se,Nc};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{cn,xs}from"./chunk-y1hx8re2.js";import"./chunk-zydg3wgt.js";export{xs as generateRuntimeConfigTypes,cn as prepareRuntimeConfig};
2
+ import{cn,xs}from"./chunk-n3r5m938.js";import"./chunk-zydg3wgt.js";export{xs as generateRuntimeConfigTypes,cn as prepareRuntimeConfig};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  import g from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...r){let o=new Set;for(let s of r){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{o.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...o].sort()}async function M(r,o={}){if(r.length===0)return null;let s=process.cwd(),e=[],l=[];r.forEach((t,h)=>{let x=t.startsWith("npm:")?t.slice(4):g.resolve(s,t),a=`__stxRegistered${h}`,d=JSON.stringify(t);e.push(`import * as ${a} from ${JSON.stringify(x)};`),l.push(`if (!globalThis.__stxModules[${d}]) globalThis.__stxModules[${d}] = ${a};`)});let u=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...l].join(`
3
- `),n;try{let{bundleClientScript:t}=await import("./chunk-kp54j5hy.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-ps54xqba.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-nqvb9094.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
3
+ `),n;try{let{bundleClientScript:t}=await import("./chunk-4mcmbvxb.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-qer8jpr5.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-0e1rga0j.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
4
4
  `)}export{M as buildModuleRegistryScript,I as registeredModuleIdsIn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{q,n}from"./chunk-zskhxkbk.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 r=u[t[0]];console.log(`
2
+ import{q,n}from"./chunk-b6e36vr2.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 r=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${r.description}`),console.log(` Usage: ${e.cyan}${r.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{_,k,Ft,zt,Ht}from"./chunk-6cp3afft.js";import{resolve as Q,basename as J,extname as K,join as Y}from"path";import{mkdir as Z}from"fs/promises";var N={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class Tr{config;constructor(t={}){this.config={...N,...t}}async get(t,e){return Ft(t,e,"video",this.config)}async set(t,e,a){return zt(t,e,a,"video",this.config)}async clear(){return Ht("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var V=null;function T(t){if(!V)V=new Tr(t);else if(t)V.updateConfig(t);return V}async function _r(t,e,a){let c=a?{directory:`${a.outputDir}/../.cache`}:{};return T(c).get(t,e)}async function Rr(t,e,a,c){let r=c?{directory:`${c.outputDir}/../.cache`}:{};return T(r).set(t,e,a)}async function oa(){return T().clear()}import{resolve as B,basename as D,extname as A,join as v}from"path";import{mkdir as M}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function Ar(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let n=B(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await _(n),s=D(t,A(t)),o=e.format||"webp",h=e.timestamp||0,y=`${s}-poster-${i}.${o}`,u=v(a,y),m=await r.extractThumbnails(n,{timestamps:[h],width:e.width||1280,height:e.height,format:o,quality:e.quality||85,outputDir:a,outputPattern:y.replace(`.${o}`,"")});if(m&&m.length>0){let d=m[0];return{path:u,url:`${c}/${y}`,width:d.width||e.width||1280,height:d.height||720,timestamp:h,size:d.size||0}}return null}catch(n){return console.warn(`[stx-media] Failed to generate poster: ${n}`),null}}async function Pr(t,e,a,c){let r=await L();if(!r)return[];try{let n=B(t);if(!await k(n))return[];await M(a,{recursive:!0});let i=await _(n),s=D(t,A(t)),o=e.format||"webp",u=(await new r.Input(n).getInfo()).duration||60,m=e.count||10,d=e.interval||u/m,g=[];for(let f=0;f<m&&f*d<u;f++)g.push(f*d);let l=await r.extractThumbnails(n,{timestamps:g,width:e.width||320,format:o,quality:e.quality||80,outputDir:a,outputPattern:`${s}-thumb-${i}`});if(l&&l.length>0)return l.map((f,b)=>({path:f.path||v(a,`${s}-thumb-${i}-${b}.${o}`),url:`${c}/${s}-thumb-${i}-${b}.${o}`,width:f.width||e.width||320,height:f.height||180,timestamp:g[b],size:f.size||0}));return[]}catch(n){return console.warn(`[stx-media] Failed to generate thumbnails: ${n}`),[]}}async function ia(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let n=B(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await _(n),s=D(t,A(t)),y=(await new r.Input(n).getInfo()).duration||60,u=e.columns||10,m=e.interval||5,d=e.thumbnailWidth||160,g=e.thumbnailHeight||90,l=e.format||"jpeg",f=Math.ceil(y/m),b=Math.ceil(f/u),S=`${s}-sprite-${i}.${l}`,w=v(a,S),C=[];for(let P=0;P<f;P++)C.push(P*m);let p=await r.extractThumbnails(n,{timestamps:C,width:d,height:g,format:l,quality:e.quality||70,outputDir:v(a,".temp")});if(!p||p.length===0)return null;try{let P=await import("ts-images"),x=u*d,ie=b*g,re=await P.createSprite({images:p.map((U)=>U.path),columns:u,padding:0,outputPath:w,format:l,quality:e.quality||70});return{url:`${c}/${S}`,path:w,columns:u,rows:b,thumbnailWidth:d,thumbnailHeight:g,interval:m,totalFrames:f}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(n){return console.warn(`[stx-media] Failed to generate sprite sheet: ${n}`),null}}import{resolve as E,basename as F,extname as W,join as R}from"path";import{mkdir as H,writeFile as q}from"fs/promises";async function z(){try{return await import("ts-videos")}catch{return null}}var j=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function Ir(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await _(i),o=F(t,W(t)),h=R(a,`${o}-${s}-hls`);await H(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||6,g=(await new n.Input(i).getInfo()).duration||0,l=[],f=0;for(let w of y){let C=R(h,w.label);await H(C,{recursive:!0});let p=`${w.label}.m3u8`,P=R(C,p);try{let x=await n.generateHLS(i,{outputDir:C,segmentDuration:u,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(x)l.push({quality:w,url:`${c}/${o}-${s}-hls/${w.label}/${p}`,path:P}),f+=x.segmentCount||Math.ceil(g/u)}catch(x){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${x}`)}}if(l.length===0)return null;let b=R(h,"master.m3u8"),S=X(l,c,o,s);return await q(b,S),{manifestUrl:`${c}/${o}-${s}-hls/master.m3u8`,manifestPath:b,playlists:l,segmentCount:f,duration:g}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function X(t,e,a,c){let r=["#EXTM3U","#EXT-X-VERSION:3"];for(let n of t){let{quality:i}=n,s=i.bitrate+(i.audioBitrate||128000),o=`${i.width}x${i.height||Math.round(i.width*9/16)}`;r.push(`#EXT-X-STREAM-INF:BANDWIDTH=${s},RESOLUTION=${o},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return r.join(`
3
- `)}async function Dr(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await _(i),o=F(t,W(t)),h=R(a,`${o}-${s}-dash`);await H(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||4,m=r?.minBufferTime||2,l=(await new n.Input(i).getInfo()).duration||0,f=[],b=[];for(let p of y){let P=R(h,p.label);await H(P,{recursive:!0});try{if(await n.generateDASH(i,{outputDir:P,segmentDuration:u,width:p.width,height:p.height,videoBitrate:p.bitrate,audioBitrate:p.audioBitrate})){if(f.push({bandwidth:p.bitrate,width:p.width,height:p.height||Math.round(p.width*9/16),url:`${c}/${o}-${s}-dash/${p.label}/video`}),p.audioBitrate)b.push({bandwidth:p.audioBitrate,url:`${c}/${o}-${s}-dash/${p.label}/audio`})}}catch(x){console.warn(`[stx-media] Failed to generate DASH for ${p.label}: ${x}`)}}if(f.length===0)return null;let S=R(h,"manifest.mpd"),w=G(f,b,l,u,m);await q(S,w);let C=[{type:"video",representations:f}];if(b.length>0)C.push({type:"audio",representations:b});return{manifestUrl:`${c}/${o}-${s}-dash/manifest.mpd`,manifestPath:S,adaptationSets:C,duration:l}}catch(i){return console.warn(`[stx-media] Failed to generate DASH manifest: ${i}`),null}}function G(t,e,a,c,r){let n=I(a),i=I(r),s=`<?xml version="1.0" encoding="UTF-8"?>
2
+ import{T,k,Ft,zt,Ht}from"./chunk-b8p9y1kv.js";import{resolve as Q,basename as J,extname as K,join as Y}from"path";import{mkdir as Z}from"fs/promises";var N={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class _r{config;constructor(t={}){this.config={...N,...t}}async get(t,e){return Ft(t,e,"video",this.config)}async set(t,e,a){return zt(t,e,a,"video",this.config)}async clear(){return Ht("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var V=null;function B(t){if(!V)V=new _r(t);else if(t)V.updateConfig(t);return V}async function Tr(t,e,a){let c=a?{directory:`${a.outputDir}/../.cache`}:{};return B(c).get(t,e)}async function Rr(t,e,a,c){let r=c?{directory:`${c.outputDir}/../.cache`}:{};return B(r).set(t,e,a)}async function oa(){return B().clear()}import{resolve as _,basename as D,extname as A,join as v}from"path";import{mkdir as M}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function Ar(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let n=_(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await T(n),s=D(t,A(t)),o=e.format||"webp",h=e.timestamp||0,y=`${s}-poster-${i}.${o}`,u=v(a,y),m=await r.extractThumbnails(n,{timestamps:[h],width:e.width||1280,height:e.height,format:o,quality:e.quality||85,outputDir:a,outputPattern:y.replace(`.${o}`,"")});if(m&&m.length>0){let d=m[0];return{path:u,url:`${c}/${y}`,width:d.width||e.width||1280,height:d.height||720,timestamp:h,size:d.size||0}}return null}catch(n){return console.warn(`[stx-media] Failed to generate poster: ${n}`),null}}async function Pr(t,e,a,c){let r=await L();if(!r)return[];try{let n=_(t);if(!await k(n))return[];await M(a,{recursive:!0});let i=await T(n),s=D(t,A(t)),o=e.format||"webp",u=(await new r.Input(n).getInfo()).duration||60,m=e.count||10,d=e.interval||u/m,g=[];for(let f=0;f<m&&f*d<u;f++)g.push(f*d);let l=await r.extractThumbnails(n,{timestamps:g,width:e.width||320,format:o,quality:e.quality||80,outputDir:a,outputPattern:`${s}-thumb-${i}`});if(l&&l.length>0)return l.map((f,b)=>({path:f.path||v(a,`${s}-thumb-${i}-${b}.${o}`),url:`${c}/${s}-thumb-${i}-${b}.${o}`,width:f.width||e.width||320,height:f.height||180,timestamp:g[b],size:f.size||0}));return[]}catch(n){return console.warn(`[stx-media] Failed to generate thumbnails: ${n}`),[]}}async function ia(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let n=_(t);if(!await k(n))return null;await M(a,{recursive:!0});let i=await T(n),s=D(t,A(t)),y=(await new r.Input(n).getInfo()).duration||60,u=e.columns||10,m=e.interval||5,d=e.thumbnailWidth||160,g=e.thumbnailHeight||90,l=e.format||"jpeg",f=Math.ceil(y/m),b=Math.ceil(f/u),S=`${s}-sprite-${i}.${l}`,w=v(a,S),C=[];for(let P=0;P<f;P++)C.push(P*m);let p=await r.extractThumbnails(n,{timestamps:C,width:d,height:g,format:l,quality:e.quality||70,outputDir:v(a,".temp")});if(!p||p.length===0)return null;try{let P=await import("ts-images"),x=u*d,ie=b*g,re=await P.createSprite({images:p.map((U)=>U.path),columns:u,padding:0,outputPath:w,format:l,quality:e.quality||70});return{url:`${c}/${S}`,path:w,columns:u,rows:b,thumbnailWidth:d,thumbnailHeight:g,interval:m,totalFrames:f}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(n){return console.warn(`[stx-media] Failed to generate sprite sheet: ${n}`),null}}import{resolve as E,basename as F,extname as W,join as R}from"path";import{mkdir as H,writeFile as q}from"fs/promises";async function z(){try{return await import("ts-videos")}catch{return null}}var j=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function Ir(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await T(i),o=F(t,W(t)),h=R(a,`${o}-${s}-hls`);await H(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||6,g=(await new n.Input(i).getInfo()).duration||0,l=[],f=0;for(let w of y){let C=R(h,w.label);await H(C,{recursive:!0});let p=`${w.label}.m3u8`,P=R(C,p);try{let x=await n.generateHLS(i,{outputDir:C,segmentDuration:u,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(x)l.push({quality:w,url:`${c}/${o}-${s}-hls/${w.label}/${p}`,path:P}),f+=x.segmentCount||Math.ceil(g/u)}catch(x){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${x}`)}}if(l.length===0)return null;let b=R(h,"master.m3u8"),S=X(l,c,o,s);return await q(b,S),{manifestUrl:`${c}/${o}-${s}-hls/master.m3u8`,manifestPath:b,playlists:l,segmentCount:f,duration:g}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function X(t,e,a,c){let r=["#EXTM3U","#EXT-X-VERSION:3"];for(let n of t){let{quality:i}=n,s=i.bitrate+(i.audioBitrate||128000),o=`${i.width}x${i.height||Math.round(i.width*9/16)}`;r.push(`#EXT-X-STREAM-INF:BANDWIDTH=${s},RESOLUTION=${o},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return r.join(`
3
+ `)}async function Dr(t,e,a,c,r){let n=await z();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let i=E(t);if(!await k(i))return null;let s=await T(i),o=F(t,W(t)),h=R(a,`${o}-${s}-dash`);await H(h,{recursive:!0});let y=e.length>0?e:j,u=r?.segmentDuration||4,m=r?.minBufferTime||2,l=(await new n.Input(i).getInfo()).duration||0,f=[],b=[];for(let p of y){let P=R(h,p.label);await H(P,{recursive:!0});try{if(await n.generateDASH(i,{outputDir:P,segmentDuration:u,width:p.width,height:p.height,videoBitrate:p.bitrate,audioBitrate:p.audioBitrate})){if(f.push({bandwidth:p.bitrate,width:p.width,height:p.height||Math.round(p.width*9/16),url:`${c}/${o}-${s}-dash/${p.label}/video`}),p.audioBitrate)b.push({bandwidth:p.audioBitrate,url:`${c}/${o}-${s}-dash/${p.label}/audio`})}}catch(x){console.warn(`[stx-media] Failed to generate DASH for ${p.label}: ${x}`)}}if(f.length===0)return null;let S=R(h,"manifest.mpd"),w=G(f,b,l,u,m);await q(S,w);let C=[{type:"video",representations:f}];if(b.length>0)C.push({type:"audio",representations:b});return{manifestUrl:`${c}/${o}-${s}-dash/manifest.mpd`,manifestPath:S,adaptationSets:C,duration:l}}catch(i){return console.warn(`[stx-media] Failed to generate DASH manifest: ${i}`),null}}function G(t,e,a,c,r){let n=I(a),i=I(r),s=`<?xml version="1.0" encoding="UTF-8"?>
4
4
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
5
5
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
6
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -26,4 +26,4 @@ import{_,k,Ft,zt,Ht}from"./chunk-6cp3afft.js";import{resolve as Q,basename as J,
26
26
  </Representation>
27
27
  `}s+=` </AdaptationSet>
28
28
  `}return s+=` </Period>
29
- </MPD>`,s}function I(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function fo(t){let e=await O();if(!e)return null;try{let a=Q(t),r=await new e.Input(a).getInfo();return{duration:r.duration||0,width:r.width||0,height:r.height||0,frameRate:r.frameRate||0,bitrate:r.bitrate||0,codec:r.videoCodec||"",audioCodec:r.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function aa(t,e,a,c){let r=await O();if(!r)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let n=await _r(t,e,a);if(n)return n;try{let i=Q(t);if(!await k(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let s=a.outputDir||"dist/videos",o=a.baseUrl||"/videos";await Z(s,{recursive:!0});let h=await _(i),y=J(t,K(t)),u={src:t,processed:!0,hash:h};c?.({percentage:5,stage:"analyzing"}),u.metadata=await fo(i)||void 0;let m={};if(e.quality)m.bitrate=ee(e.quality);if(e.platform)Object.assign(m,te(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){c?.({percentage:10,stage:"transcoding"});let d=`${y}-${h}.mp4`,g=Y(s,d);try{let l=await ae(i,g,m,r,(f)=>c?.({percentage:10+f*0.5,stage:"transcoding"}));if(l)u.transcoded={path:g,url:`${o}/${d}`,duration:l.duration,size:l.size,video:{codec:m.codec||"h264",width:l.width,height:l.height,bitrate:l.bitrate,frameRate:l.frameRate},audio:l.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(l){u.errors=u.errors||[],u.errors.push(`Transcoding failed: ${l}`)}}if(e.generatePoster){c?.({percentage:65,stage:"generating-poster"});let d=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},g=await Ar(i,d,s,o);if(g)u.poster=g}if(a.thumbnails?.enabled){c?.({percentage:70,stage:"generating-thumbnails"});let d=await Pr(i,a.thumbnails,s,o);if(d.length>0)u.thumbnails=d}if(e.streaming){c?.({percentage:80,stage:"generating-manifests"});let d=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(d.format==="hls"||d.format===void 0){let g=await Ir(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,hls:g}}if(d.format==="dash"){let g=await Dr(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,dash:g}}}if(e.spriteSheet)c?.({percentage:90,stage:"generating-sprite-sheet"});return c?.({percentage:100,stage:"complete"}),await Rr(t,e,u,a),u}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ae(t,e,a,c,r){try{let i=await new c.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((s)=>{r?.(s.percentage/100)});return{duration:i.duration||0,size:i.size||0,width:i.width||a.maxWidth||0,height:i.height||a.maxHeight||0,bitrate:i.bitrate||a.bitrate||0,frameRate:i.frameRate||a.frameRate||30,audioCodec:i.audioCodec}}catch(n){return console.error(`[stx-media] Transcoding failed: ${n}`),null}}export{Tr,_r,Rr,oa,Ar,Pr,ia,Ir,Dr,fo,aa};
29
+ </MPD>`,s}function I(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function fo(t){let e=await O();if(!e)return null;try{let a=Q(t),r=await new e.Input(a).getInfo();return{duration:r.duration||0,width:r.width||0,height:r.height||0,frameRate:r.frameRate||0,bitrate:r.bitrate||0,codec:r.videoCodec||"",audioCodec:r.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function aa(t,e,a,c){let r=await O();if(!r)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let n=await Tr(t,e,a);if(n)return n;try{let i=Q(t);if(!await k(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let s=a.outputDir||"dist/videos",o=a.baseUrl||"/videos";await Z(s,{recursive:!0});let h=await T(i),y=J(t,K(t)),u={src:t,processed:!0,hash:h};c?.({percentage:5,stage:"analyzing"}),u.metadata=await fo(i)||void 0;let m={};if(e.quality)m.bitrate=ee(e.quality);if(e.platform)Object.assign(m,te(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){c?.({percentage:10,stage:"transcoding"});let d=`${y}-${h}.mp4`,g=Y(s,d);try{let l=await ae(i,g,m,r,(f)=>c?.({percentage:10+f*0.5,stage:"transcoding"}));if(l)u.transcoded={path:g,url:`${o}/${d}`,duration:l.duration,size:l.size,video:{codec:m.codec||"h264",width:l.width,height:l.height,bitrate:l.bitrate,frameRate:l.frameRate},audio:l.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(l){u.errors=u.errors||[],u.errors.push(`Transcoding failed: ${l}`)}}if(e.generatePoster){c?.({percentage:65,stage:"generating-poster"});let d=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},g=await Ar(i,d,s,o);if(g)u.poster=g}if(a.thumbnails?.enabled){c?.({percentage:70,stage:"generating-thumbnails"});let d=await Pr(i,a.thumbnails,s,o);if(d.length>0)u.thumbnails=d}if(e.streaming){c?.({percentage:80,stage:"generating-manifests"});let d=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(d.format==="hls"||d.format===void 0){let g=await Ir(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,hls:g}}if(d.format==="dash"){let g=await Dr(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,dash:g}}}if(e.spriteSheet)c?.({percentage:90,stage:"generating-sprite-sheet"});return c?.({percentage:100,stage:"complete"}),await Rr(t,e,u,a),u}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ae(t,e,a,c,r){try{let i=await new c.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((s)=>{r?.(s.percentage/100)});return{duration:i.duration||0,size:i.size||0,width:i.width||a.maxWidth||0,height:i.height||a.maxHeight||0,bitrate:i.bitrate||a.bitrate||0,frameRate:i.frameRate||a.frameRate||30,audioCodec:i.audioCodec}}catch(n){return console.error(`[stx-media] Transcoding failed: ${n}`),null}}export{_r,Tr,Rr,oa,Ar,Pr,ia,Ir,Dr,fo,aa};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Yi,ul,Zi,Qi,dl,pl}from"./chunk-ty3j2ryw.js";import"./chunk-b6e36vr2.js";import"./chunk-5bqs0ve6.js";import"./chunk-8xz8t9xp.js";import"./chunk-0trfbqa7.js";import"./chunk-n3r5m938.js";import"./chunk-zydg3wgt.js";import"./chunk-ver2yf41.js";import"./chunk-8yrk8ybh.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-5w87wmc4.js";import"./chunk-jz7pvh7b.js";export{pl as applySlots,dl as extractSlotContent,ul as parseSlotElement,Yi as parseSlots,Qi as processSlots,Zi as renderSlot};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{t,i,pn,Ps,ve,l}from"./chunk-r6pax860.js";function S(e,n,r,o=0){let a=0,s=o,u=null,c=0,p=!1;while(s<e.length){let h=e[s];if(u&&p){p=!1,s++;continue}if(u&&h==="\\"){p=!0,s++;continue}if(p=!1,(h==='"'||h==="'"||h==="`")&&!u){u=h,s++;continue}if(h===u&&u!=="`"){u=null,s++;continue}if(u==="`"&&h==="$"&&e[s+1]==="{"){c++,s+=2;continue}if(c>0&&h==="}"){c--,s++;continue}if(h==="`"&&u==="`"&&c===0){u=null,s++;continue}if(u){s++;continue}if(h===n)a++;else if(h===r){if(a--,a===0)return s}s++}return-1}import T from"path";function Ts(e,n){let r=[];n.lastIndex=0;let o;while((o=n.exec(e))!==null){let a=o.index,s=a+o[0].length-1,u=S(e,"(",")",s);if(u===-1){r.push({start:a,end:-1,args:"",call:e.slice(a,Math.min(e.length,a+80))}),n.lastIndex=s+1;continue}r.push({start:a,end:u+1,args:e.slice(s+1,u),call:e.slice(a,u+1)}),n.lastIndex=u+1}return r}function Xe(e,n,r,o){let a="",s=0;for(let u of Ts(e,n)){if(a+=e.slice(s,u.start),u.end===-1){a+=o(u.call),s=u.start;continue}a+=r(u.args,u.call),s=u.end}return a+e.slice(s)}function Ge(e){let n=[],r=0,o=null,a="";for(let s=0;s<e.length;s++){let u=e[s];if(o){if(a+=u,u==="\\"&&s+1<e.length){a+=e[++s];continue}if(u===o)o=null;continue}if(u==="'"||u==='"'||u==="`")o=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0){n.push(a.trim()),a="";continue}a+=u}if(a.trim())n.push(a.trim());return n}function y(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let o="";for(let a=1;a<n.length-1;a++){let s=n[a];if(s==="\\"&&a+1<n.length-1){let u=n[++a];o+=u==="n"?`
3
- `:u==="t"?"\t":u;continue}if(s===r)return null;if(r==="`"&&s==="$"&&n[a+1]==="{")return null;o+=s}return o}var R=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Je(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let o=pn(r);if(o)return{ok:!1,message:`the expression is not allowed (${o})`,code:t.UNSAFE_EXPRESSION};let a=Ps(n),s;try{s=l(r,Object.keys(a))(...Object.values(a))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:t.EVALUATION_ERROR}}if(s!==void 0&&s!==null)return{ok:!0,value:s};let u=[...new Set(ve(r))].filter((c)=>!R.has(c)&&!(c in a)&&!(c in globalThis));if(u.length>0)return{ok:!1,message:`${u.map((p)=>`"${p}"`).join(", ")} ${u.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(s===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:s}}function ue(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function we(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function v(e){if(!e)return"";return T.isAbsolute(e)?T.relative(process.cwd(),e)||e:e}function f(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function E(e,n,r,o,a=t.EVALUATION_ERROR){let s=o?` in ${v(o)}`:"";return console.warn(`[stx] ${f(n)}${s}: ${r}`),i(e,`${f(n)}: ${r}`,a)}function er(e,n,r){let o=r?` in ${v(r)}`:"";console.warn(`[stx] ${f(e)}${o}: ${n}`)}var x=["og:","article:","book:","profile:","fb:","music:","video:"],I=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function ln(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=_(e[0],n);if(typeof r!=="string")return r;let o;if(e.length===2){let s=C(e[1],n);if(typeof s!=="string")return s;o=s}else{let s=r.includes(":")?r.slice(r.indexOf(":")+1):r,u=n.openGraph,c=n[s]??(we(u)?u[s]:void 0);o=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!o)return{kind:"empty"};return{kind:"tag",tag:x.some((s)=>r.startsWith(s))?{property:r,content:o}:{name:r,content:o}}}function _(e,n){let r=y(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(I.test(e.trim()))return e.trim();let o=Je(e,n);if(!o.ok)return{kind:"error",message:`meta name: ${o.message}`,code:o.code};if(typeof o.value!=="string"||!o.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${ue(o.value)}`,code:t.TYPE_ERROR};return o.value}function C(e,n){let r=y(e);if(r!==null)return r;let o=Je(e,n);if(!o.ok)return{kind:"error",message:o.message,code:o.code};let a=o.value;if(a===void 0||a===null||a===!1)return"";if(Array.isArray(a))return a.filter((s)=>s!==void 0&&s!==null&&s!=="").map(String).join(", ");if(typeof a==="object"&&!(a instanceof Date))return{kind:"error",message:`the content must be text, got ${ue(a)}`,code:t.TYPE_ERROR};return String(a)}var un=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],tr=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],w={links:"link",metas:"meta",scripts:"script",styles:"style"},b=new Set,A=new WeakMap;function k(e){if(b.has(e))return;b.add(e),console.warn(e)}function N(e,n){let r=Array.from({length:n.length+1},(o,a)=>a);for(let o=1;o<=e.length;o++){let a=r[0];r[0]=o;for(let s=1;s<=n.length;s++){let u=r[s];r[s]=Math.min(r[s]+1,r[s-1]+1,a+(e[o-1]===n[s-1]?0:1)),a=u}}return r[n.length]}function M(e,n){let r=e.toLowerCase(),o=n.find((p)=>p.toLowerCase()===r);if(o)return o;let a=w[r];if(a&&n.includes(a))return a;let s,u=1/0;for(let p of n){let h=N(r,p.toLowerCase());if(h<u)s=p,u=h}let c=Math.min(e.length,s?.length??0)<=4?1:2;return u<=c?s:void 0}function de(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=A.get(e);if(r)return r;let{known:o,source:a}=n,s=e;for(let u of Object.keys(e)){if(o.includes(u))continue;let c=w[u];if(c&&o.includes(c)&&Array.isArray(e[u])){if(s===e)s={...e};let h=Array.isArray(s[c])?s[c]:[];s[c]=[...h,...e[u]],delete s[u],k(`[stx] ${a}.${u} is not a head key; reading it as ${a}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(u)&&!o.includes("style")){k(`[stx] ${a}.${u} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=M(u,o);k(p?`[stx] ${a}.${u} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${a}.${u} is not a head key and is ignored. Known keys: ${o.join(", ")}.`)}return A.set(e,s),s}var d={},D=[],g={};function _s(){return d}function Ku(){return g}function Xu(){d={},D.length=0,g={}}function vi(e){d=pe(d,de(e,{known:tr,source:"useHead()"}))}function pe(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function Tc(e){vi(nr(e))}function nr(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,o=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(o)n.push({property:"og:description",content:o});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let a=e.twitterTitle??e.title,s=e.twitterDescription??e.description,u=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(a)n.push({name:"twitter:title",content:a});if(s)n.push({name:"twitter:description",content:s});if(u){n.push({name:"twitter:image",content:u});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:c}}function Gu(e){if(g={...g,...e},e.title||e.description)Tc({title:e.title,description:e.description})}function Ju(e){let n=typeof e==="function"?e():e;vi({title:n})}function Yu(e=d){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${m(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([o,a])=>`${o}="${m(a)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a==="httpEquiv"?"http-equiv":a}="${m(String(s))}"`).join(" ");n.push(`<meta ${o}>`)}for(let r of e.link||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a}="${m(String(s))}"`).join(" ");n.push(`<link ${o}>`)}for(let r of e.script||[]){let{content:o,...a}=r,s=Object.entries(a).filter(([u,c])=>c!==void 0).map(([u,c])=>{if(typeof c==="boolean")return c?u:"";return`${u}="${m(String(c))}"`}).filter(Boolean).join(" ");if(o)n.push(`<script ${s}>${o}</script>`);else n.push(`<script ${s}></script>`)}for(let r of e.style||[]){let o=r.type?` type="${r.type}"`:"";n.push(`<style${o}>${r.content}</style>`)}return n.join(`
2
+ import{t,i,pn,Ps,ve,l}from"./chunk-ynvce0q6.js";function S(e,n,r,o=0){let a=0,s=o,u=null,c=0,p=!1;while(s<e.length){let h=e[s];if(u&&p){p=!1,s++;continue}if(u&&h==="\\"){p=!0,s++;continue}if(p=!1,(h==='"'||h==="'"||h==="`")&&!u){u=h,s++;continue}if(h===u&&u!=="`"){u=null,s++;continue}if(u==="`"&&h==="$"&&e[s+1]==="{"){c++,s+=2;continue}if(c>0&&h==="}"){c--,s++;continue}if(h==="`"&&u==="`"&&c===0){u=null,s++;continue}if(u){s++;continue}if(h===n)a++;else if(h===r){if(a--,a===0)return s}s++}return-1}import T from"path";function _s(e,n){let r=[];n.lastIndex=0;let o;while((o=n.exec(e))!==null){let a=o.index,s=a+o[0].length-1,u=S(e,"(",")",s);if(u===-1){r.push({start:a,end:-1,args:"",call:e.slice(a,Math.min(e.length,a+80))}),n.lastIndex=s+1;continue}r.push({start:a,end:u+1,args:e.slice(s+1,u),call:e.slice(a,u+1)}),n.lastIndex=u+1}return r}function Xe(e,n,r,o){let a="",s=0;for(let u of _s(e,n)){if(a+=e.slice(s,u.start),u.end===-1){a+=o(u.call),s=u.start;continue}a+=r(u.args,u.call),s=u.end}return a+e.slice(s)}function Ge(e){let n=[],r=0,o=null,a="";for(let s=0;s<e.length;s++){let u=e[s];if(o){if(a+=u,u==="\\"&&s+1<e.length){a+=e[++s];continue}if(u===o)o=null;continue}if(u==="'"||u==='"'||u==="`")o=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0){n.push(a.trim()),a="";continue}a+=u}if(a.trim())n.push(a.trim());return n}function y(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let o="";for(let a=1;a<n.length-1;a++){let s=n[a];if(s==="\\"&&a+1<n.length-1){let u=n[++a];o+=u==="n"?`
3
+ `:u==="t"?"\t":u;continue}if(s===r)return null;if(r==="`"&&s==="$"&&n[a+1]==="{")return null;o+=s}return o}var R=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Je(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let o=pn(r);if(o)return{ok:!1,message:`the expression is not allowed (${o})`,code:t.UNSAFE_EXPRESSION};let a=Ps(n),s;try{s=l(r,Object.keys(a))(...Object.values(a))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:t.EVALUATION_ERROR}}if(s!==void 0&&s!==null)return{ok:!0,value:s};let u=[...new Set(ve(r))].filter((c)=>!R.has(c)&&!(c in a)&&!(c in globalThis));if(u.length>0)return{ok:!1,message:`${u.map((p)=>`"${p}"`).join(", ")} ${u.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(s===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:s}}function ue(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function we(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function v(e){if(!e)return"";return T.isAbsolute(e)?T.relative(process.cwd(),e)||e:e}function f(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function E(e,n,r,o,a=t.EVALUATION_ERROR){let s=o?` in ${v(o)}`:"";return console.warn(`[stx] ${f(n)}${s}: ${r}`),i(e,`${f(n)}: ${r}`,a)}function er(e,n,r){let o=r?` in ${v(r)}`:"";console.warn(`[stx] ${f(e)}${o}: ${n}`)}var x=["og:","article:","book:","profile:","fb:","music:","video:"],I=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function ln(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=_(e[0],n);if(typeof r!=="string")return r;let o;if(e.length===2){let s=C(e[1],n);if(typeof s!=="string")return s;o=s}else{let s=r.includes(":")?r.slice(r.indexOf(":")+1):r,u=n.openGraph,c=n[s]??(we(u)?u[s]:void 0);o=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!o)return{kind:"empty"};return{kind:"tag",tag:x.some((s)=>r.startsWith(s))?{property:r,content:o}:{name:r,content:o}}}function _(e,n){let r=y(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(I.test(e.trim()))return e.trim();let o=Je(e,n);if(!o.ok)return{kind:"error",message:`meta name: ${o.message}`,code:o.code};if(typeof o.value!=="string"||!o.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${ue(o.value)}`,code:t.TYPE_ERROR};return o.value}function C(e,n){let r=y(e);if(r!==null)return r;let o=Je(e,n);if(!o.ok)return{kind:"error",message:o.message,code:o.code};let a=o.value;if(a===void 0||a===null||a===!1)return"";if(Array.isArray(a))return a.filter((s)=>s!==void 0&&s!==null&&s!=="").map(String).join(", ");if(typeof a==="object"&&!(a instanceof Date))return{kind:"error",message:`the content must be text, got ${ue(a)}`,code:t.TYPE_ERROR};return String(a)}var un=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],tr=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],w={links:"link",metas:"meta",scripts:"script",styles:"style"},b=new Set,A=new WeakMap;function k(e){if(b.has(e))return;b.add(e),console.warn(e)}function N(e,n){let r=Array.from({length:n.length+1},(o,a)=>a);for(let o=1;o<=e.length;o++){let a=r[0];r[0]=o;for(let s=1;s<=n.length;s++){let u=r[s];r[s]=Math.min(r[s]+1,r[s-1]+1,a+(e[o-1]===n[s-1]?0:1)),a=u}}return r[n.length]}function M(e,n){let r=e.toLowerCase(),o=n.find((p)=>p.toLowerCase()===r);if(o)return o;let a=w[r];if(a&&n.includes(a))return a;let s,u=1/0;for(let p of n){let h=N(r,p.toLowerCase());if(h<u)s=p,u=h}let c=Math.min(e.length,s?.length??0)<=4?1:2;return u<=c?s:void 0}function de(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=A.get(e);if(r)return r;let{known:o,source:a}=n,s=e;for(let u of Object.keys(e)){if(o.includes(u))continue;let c=w[u];if(c&&o.includes(c)&&Array.isArray(e[u])){if(s===e)s={...e};let h=Array.isArray(s[c])?s[c]:[];s[c]=[...h,...e[u]],delete s[u],k(`[stx] ${a}.${u} is not a head key; reading it as ${a}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(u)&&!o.includes("style")){k(`[stx] ${a}.${u} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=M(u,o);k(p?`[stx] ${a}.${u} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${a}.${u} is not a head key and is ignored. Known keys: ${o.join(", ")}.`)}return A.set(e,s),s}var d={},D=[],g={};function Ts(){return d}function Ku(){return g}function Xu(){d={},D.length=0,g={}}function vi(e){d=pe(d,de(e,{known:tr,source:"useHead()"}))}function pe(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function _c(e){vi(nr(e))}function nr(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,o=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(o)n.push({property:"og:description",content:o});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let a=e.twitterTitle??e.title,s=e.twitterDescription??e.description,u=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(a)n.push({name:"twitter:title",content:a});if(s)n.push({name:"twitter:description",content:s});if(u){n.push({name:"twitter:image",content:u});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:c}}function Gu(e){if(g={...g,...e},e.title||e.description)_c({title:e.title,description:e.description})}function Ju(e){let n=typeof e==="function"?e():e;vi({title:n})}function Yu(e=d){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${m(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([o,a])=>`${o}="${m(a)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a==="httpEquiv"?"http-equiv":a}="${m(String(s))}"`).join(" ");n.push(`<meta ${o}>`)}for(let r of e.link||[]){let o=Object.entries(r).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a}="${m(String(s))}"`).join(" ");n.push(`<link ${o}>`)}for(let r of e.script||[]){let{content:o,...a}=r,s=Object.entries(a).filter(([u,c])=>c!==void 0).map(([u,c])=>{if(typeof c==="boolean")return c?u:"";return`${u}="${m(String(c))}"`}).filter(Boolean).join(" ");if(o)n.push(`<script ${s}>${o}</script>`);else n.push(`<script ${s}></script>`)}for(let r of e.style||[]){let o=r.type?` type="${r.type}"`:"";n.push(`<style${o}>${r.content}</style>`)}return n.join(`
4
4
  `)}function Zu(e=d){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${m(r)}"`).join(" ")}function Qu(e=d){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${m(r)}"`).join(" ")}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ed(e=d){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let o=document.querySelector(r);if(!o){if(o=document.createElement("meta"),n.name)o.setAttribute("name",n.name);if(n.property)o.setAttribute("property",n.property);document.head.appendChild(o)}o.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,o=document.querySelector(r);if(!o)o=document.createElement("link"),document.head.appendChild(o);for(let[a,s]of Object.entries(n))if(s!==void 0)o.setAttribute(a,String(s))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let o of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(o);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function td(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(o,a)=>(n+=a.trim()+`
5
- `,"")),headContent:n.trim()}}function nd(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,o,a,s)=>{let u=o?a:n[(s||"").trim()]??s,c=n.__stx_runtime_head??{};return n.__stx_runtime_head=pe(c,{title:u}),""})}function rd(e,n,r=""){if(!e.includes("@meta"))return e;return Xe(e,/(?<![\w$@])@meta\s*\(/g,(o,a)=>{let s=ln(Ge(o),n);if(s.kind==="error")return E("Meta",a,s.message,r,s.code);if(s.kind==="tag"){let u=n.__stx_runtime_head??{};n.__stx_runtime_head=pe(u,{meta:[s.tag]})}return""},(o)=>E("Meta",o,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,Ts,Xe,Ge,Je,ue,we,E,er,ln,un,tr,de,_s,Ku,Xu,vi,pe,Tc,nr,Gu,Ju,Yu,Zu,Qu,ed,td,nd,rd};
5
+ `,"")),headContent:n.trim()}}function nd(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,o,a,s)=>{let u=o?a:n[(s||"").trim()]??s,c=n.__stx_runtime_head??{};return n.__stx_runtime_head=pe(c,{title:u}),""})}function rd(e,n,r=""){if(!e.includes("@meta"))return e;return Xe(e,/(?<![\w$@])@meta\s*\(/g,(o,a)=>{let s=ln(Ge(o),n);if(s.kind==="error")return E("Meta",a,s.message,r,s.code);if(s.kind==="tag"){let u=n.__stx_runtime_head??{};n.__stx_runtime_head=pe(u,{meta:[s.tag]})}return""},(o)=>E("Meta",o,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,_s,Xe,Ge,Je,ue,we,E,er,ln,un,tr,de,Ts,Ku,Xu,vi,pe,_c,nr,Gu,Ju,Yu,Zu,Qu,ed,td,nd,rd};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ui,eo,Uc,Wi,qi,Wc,qc}from"./chunk-jnn745tt.js";import"./chunk-e02b66yn.js";import"./chunk-a6pjaw6w.js";import"./chunk-5pgvfxtx.js";import{ze,rc}from"./chunk-b6e36vr2.js";import"./chunk-5bqs0ve6.js";import"./chunk-8xz8t9xp.js";import"./chunk-0trfbqa7.js";import"./chunk-n3r5m938.js";import"./chunk-zydg3wgt.js";import"./chunk-ver2yf41.js";import"./chunk-8yrk8ybh.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-5w87wmc4.js";import"./chunk-jz7pvh7b.js";export{Ui as buildVirtualSource,ze as extractScriptBlocks,rc as extractTemplateExpressions,Wi as findRuntimeTypeDeclarations,qi as findStxModuleDeclarations,qc as formatTypecheckDiagnostics,Uc as sourcePathFor,Wc as typecheckStxFiles,eo as virtualPathFor};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Me,Ga,Cu,$u,Eu,_u,Ja,Ya,Tu,Ru,Ho,Au,Qt,en,Mn}from"./chunk-b6e36vr2.js";import"./chunk-5bqs0ve6.js";import"./chunk-8xz8t9xp.js";import"./chunk-0trfbqa7.js";import"./chunk-n3r5m938.js";import"./chunk-zydg3wgt.js";import"./chunk-ver2yf41.js";import"./chunk-8yrk8ybh.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-5w87wmc4.js";import"./chunk-jz7pvh7b.js";export{_u as __setSignalsGeneratorsForTest,Me as cacheEngineFingerprint,en as cacheTemplate,Qt as checkCache,Au as clearDevCaches,Ya as getCachedRouterScript,Ja as getCachedSignalsRuntime,Tu as getServeClientAsset,Ho as getServeModuleBundle,Mn as hashFilePath,$u as invalidateFileCache,Eu as invalidateFileCacheByDir,Cu as readFileCached,Ru as registerServeModuleBundle,Ga as templateCache};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-r6pax860.js";import"./chunk-8xz8t9xp.js";import"./chunk-bq2e9qf6.js";import{a}from"./chunk-7tt84v1y.js";import f 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},o=t.snapshotDir||a(e.root,"story","snapshots");await f.promises.mkdir(o,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((i)=>t.filter.some((p)=>i.fileName.toLowerCase().includes(p.toLowerCase())));for(let i of r)await h(i,o,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let o=e.story;if(!o)return;for(let r of o.variants){n.total++;let i=l.join(t,`${e.id}-${r.id}.snap`),p=g(r.source||""),c=await w(i);if(s.update||!c){let u={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:p};if(await f.promises.writeFile(i,JSON.stringify(u,null,2)),!c)n.new++;n.passed++}else try{let u=await f.promises.readFile(i,"utf-8"),m=JSON.parse(u);if(m.hash===p)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,p)})}catch(u){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${u}`})}}}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 f.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-ynvce0q6.js";import"./chunk-8xz8t9xp.js";import"./chunk-5bqs0ve6.js";import{a}from"./chunk-7tt84v1y.js";import f 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},o=t.snapshotDir||a(e.root,"story","snapshots");await f.promises.mkdir(o,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((i)=>t.filter.some((p)=>i.fileName.toLowerCase().includes(p.toLowerCase())));for(let i of r)await h(i,o,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let o=e.story;if(!o)return;for(let r of o.variants){n.total++;let i=l.join(t,`${e.id}-${r.id}.snap`),p=g(r.source||""),c=await w(i);if(s.update||!c){let u={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:p};if(await f.promises.writeFile(i,JSON.stringify(u,null,2)),!c)n.new++;n.passed++}else try{let u=await f.promises.readFile(i,"utf-8"),m=JSON.parse(u);if(m.hash===p)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,p)})}catch(u){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${u}`})}}}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 f.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{Dn,Va,wu,Ua,vu,Wa,On,b,vt,he,qa,Yr,Ka,xu,q,Xa,Su,x,ku}from"./chunk-zskhxkbk.js";import"./chunk-bq2e9qf6.js";import"./chunk-8xz8t9xp.js";import"./chunk-0trfbqa7.js";import"./chunk-y1hx8re2.js";import"./chunk-zydg3wgt.js";import"./chunk-4fa3jec9.js";import"./chunk-exgyf65a.js";import"./chunk-r6pax860.js";import"./chunk-h9e032kq.js";import"./chunk-w1zvh5y7.js";import"./chunk-w6zz18jt.js";import"./chunk-jz7pvh7b.js";export{Xa as applyFilters,vu as clearCustomFilters,qa as clientLoopScopes,Dn as defaultFilters,b as escapeHtml,vt as escapeHtmlValue,x as evaluateExpression,Wa as findMustacheEnd,Ua as getAllFilters,Ka as interpolateScriptAttributes,Yr as interpolateScriptExpressions,xu as interpolateScriptsInTemplate,q as processExpressions,Va as registerFilter,wu as registerFilters,On as replaceInterpolations,Su as resetRejectedExpressionWarnings,ku as unescapeHtml,he as usesSignalsInScript};
2
+ import{Dn,Va,wu,Ua,vu,Wa,On,b,vt,he,qa,Yr,Ka,xu,q,Xa,Su,x,ku}from"./chunk-b6e36vr2.js";import"./chunk-5bqs0ve6.js";import"./chunk-8xz8t9xp.js";import"./chunk-0trfbqa7.js";import"./chunk-n3r5m938.js";import"./chunk-zydg3wgt.js";import"./chunk-ver2yf41.js";import"./chunk-8yrk8ybh.js";import"./chunk-ynvce0q6.js";import"./chunk-pf0d8y9n.js";import"./chunk-2jbyks2t.js";import"./chunk-5w87wmc4.js";import"./chunk-jz7pvh7b.js";export{Xa as applyFilters,vu as clearCustomFilters,qa as clientLoopScopes,Dn as defaultFilters,b as escapeHtml,vt as escapeHtmlValue,x as evaluateExpression,Wa as findMustacheEnd,Ua as getAllFilters,Ka as interpolateScriptAttributes,Yr as interpolateScriptExpressions,xu as interpolateScriptsInTemplate,q as processExpressions,Va as registerFilter,wu as registerFilters,On as replaceInterpolations,Su as resetRejectedExpressionWarnings,ku as unescapeHtml,he as usesSignalsInScript};
@@ -1,30 +1,30 @@
1
1
  // @bun
2
2
  import S from"fs";import _ from"path";function hr(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function Gs(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function xn(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await Gs(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function yr(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function br(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function At(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function lt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function Js(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
3
3
  `)+`
4
- `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Sn(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function kn(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function wr(e,t){let i=await Sn(e),s=t||kn(i),n=Js(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function vr(e){return m.existsSync(y.join(e,"netlify.toml"))}async function zc(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new Te(`No Netlify auth token found.
4
+ `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Sn(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function kn(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function wr(e,t){let i=await Sn(e),s=t||kn(i),n=Js(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function vr(e){return m.existsSync(y.join(e,"netlify.toml"))}async function zc(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new _e(`No Netlify auth token found.
5
5
 
6
6
  To deploy to Netlify:
7
7
  1. Create account at https://app.netlify.com
8
8
  2. Get token at https://app.netlify.com/user/applications#personal-access-tokens
9
9
  3. Set NETLIFY_AUTH_TOKEN environment variable
10
10
 
11
- export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!f)throw new Te(`No Netlify site ID found.
11
+ export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!f)throw new _e(`No Netlify site ID found.
12
12
 
13
13
  Either:
14
14
  1. Set NETLIFY_SITE_ID environment variable
15
15
  2. Pass --site-id option
16
16
  3. Run \`stx deploy --init\` to set up
17
17
 
18
- Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!S.existsSync(l))throw new Te(`Build directory not found: ${l}
18
+ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!S.existsSync(l))throw new _e(`Build directory not found: ${l}
19
19
 
20
- Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(l).length>0))throw new Te(`Build directory is empty: ${l}
20
+ Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(l).length>0))throw new _e(`Build directory is empty: ${l}
21
21
 
22
- Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await xn(l),w=lt(c);return n(`Would deploy ${c.length} files (${At(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=hr({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new Te(`Site not found: ${f}
22
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await xn(l),w=lt(c);return n(`Would deploy ${c.length} files (${At(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=hr({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new _e(`Site not found: ${f}
23
23
 
24
- Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await xn(l),g=lt(a);if(n(`Found ${a.length} files (${At(g)})`),a.length===0)throw new Te(`No files found in ${l}`,"NO_FILES");let b=yr(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=br(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=lt(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${At(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:lt(h)}}async function Hc(e={}){let t=e.directory||process.cwd(),i;if(vr(t))i=_.join(t,"netlify.toml");else{let s=await Sn(t);i=await wr(t,kn(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
24
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await xn(l),g=lt(a);if(n(`Found ${a.length} files (${At(g)})`),a.length===0)throw new _e(`No files found in ${l}`,"NO_FILES");let b=yr(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=br(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=lt(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${At(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:lt(h)}}async function Hc(e={}){let t=e.directory||process.cwd(),i;if(vr(t))i=_.join(t,"netlify.toml");else{let s=await Sn(t);i=await wr(t,kn(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
25
25
  `).filter((r)=>!r.startsWith("NETLIFY_SITE_ID=")).join(`
26
26
  `),n&&!n.endsWith(`
27
27
  `))n+=`
28
28
  `}n+=`NETLIFY_SITE_ID=${e.siteId}
29
- `,await Bun.write(s,n)}return{configPath:i,siteId:e.siteId}}class Te extends Error{code;constructor(e,t){super(e);this.name="DeployError",this.code=t}}function I(e){let t=process.platform,i=t==="darwin"?"open":t==="win32"?"start":"xdg-open";Bun.spawn([i,e],{stdio:["ignore","ignore","ignore"]})}
30
- export{hr,Gs,xn,yr,br,At,lt,Js,Sn,kn,wr,vr,zc,Hc,Te};
29
+ `,await Bun.write(s,n)}return{configPath:i,siteId:e.siteId}}class _e extends Error{code;constructor(e,t){super(e);this.name="DeployError",this.code=t}}function I(e){let t=process.platform,i=t==="darwin"?"open":t==="win32"?"start":"xdg-open";Bun.spawn([i,e],{stdio:["ignore","ignore","ignore"]})}
30
+ export{hr,Gs,xn,yr,br,At,lt,Js,Sn,kn,wr,vr,zc,Hc,_e};