@stacksjs/stx 0.2.554 → 0.2.555

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 (58) hide show
  1. package/dist/builtins/image-delivery.js +2 -2
  2. package/dist/{chunk-2jc9e080.js → chunk-1zyht1bb.js} +1 -1
  3. package/dist/{chunk-aqpmja5j.js → chunk-384xy328.js} +1 -1
  4. package/dist/{chunk-wzb6dfd4.js → chunk-3bb0tjs3.js} +1 -1
  5. package/dist/{chunk-ddg0x0pp.js → chunk-3enbxxcs.js} +1 -1
  6. package/dist/{chunk-fm0db2ey.js → chunk-4c5sxq9p.js} +1 -1
  7. package/dist/{chunk-7qjnzhbv.js → chunk-4sbz2y0g.js} +1 -1
  8. package/dist/{chunk-d8221ft9.js → chunk-5pdckdhm.js} +1 -1
  9. package/dist/{chunk-bngcrt1x.js → chunk-66yp3ryj.js} +1 -1
  10. package/dist/{chunk-nmeapbn4.js → chunk-6qfrs1pj.js} +1 -1
  11. package/dist/{chunk-zpyzpp5h.js → chunk-7pk5sqkw.js} +2 -2
  12. package/dist/{chunk-3mv77zv3.js → chunk-7x3az8j6.js} +1 -1
  13. package/dist/chunk-8bqph6jy.js +2 -0
  14. package/dist/{chunk-epxyy8mz.js → chunk-8k5sp2t6.js} +1 -1
  15. package/dist/{chunk-qvjyyns1.js → chunk-96fpvzm2.js} +1 -1
  16. package/dist/{chunk-72qdb639.js → chunk-9wygdzqe.js} +1 -1
  17. package/dist/{chunk-9m93hezh.js → chunk-a1srrv4w.js} +1 -1
  18. package/dist/{chunk-s8x5fe91.js → chunk-afrfcgn4.js} +1 -1
  19. package/dist/{chunk-bn25kybp.js → chunk-b46ejka8.js} +1 -1
  20. package/dist/{chunk-58dkqb3y.js → chunk-cev76nd8.js} +1 -1
  21. package/dist/{chunk-bnh24b88.js → chunk-cvxc2h58.js} +1 -1
  22. package/dist/{chunk-f54c3jwk.js → chunk-d7ec8hgm.js} +1 -1
  23. package/dist/chunk-en30fzej.js +2 -0
  24. package/dist/{chunk-4wwpxt4z.js → chunk-g3gtxcc3.js} +160 -160
  25. package/dist/{chunk-qmew5tzd.js → chunk-gmp7apxp.js} +1 -1
  26. package/dist/{chunk-d44d4n86.js → chunk-knkeqpnk.js} +5 -5
  27. package/dist/{chunk-jjx4913r.js → chunk-kvr304zk.js} +1 -1
  28. package/dist/{chunk-zjerecmr.js → chunk-m2vk8vja.js} +1 -1
  29. package/dist/chunk-n7f2c5vf.js +2 -0
  30. package/dist/{chunk-w6mymv3q.js → chunk-nd7p8f5p.js} +1 -1
  31. package/dist/{chunk-ssb2pdn0.js → chunk-nv62tcmb.js} +1 -1
  32. package/dist/{chunk-h7kzag56.js → chunk-pjbp7axq.js} +1 -1
  33. package/dist/{chunk-8mzsz1k6.js → chunk-pmwzvb3m.js} +1 -1
  34. package/dist/{chunk-fq58g560.js → chunk-qdh45a4k.js} +1 -1
  35. package/dist/{chunk-20xnk6jm.js → chunk-qx9s066f.js} +1 -1
  36. package/dist/{chunk-qd367k3a.js → chunk-rs9c1meq.js} +1 -1
  37. package/dist/{chunk-z0ar2gk7.js → chunk-rv55w3rm.js} +1 -1
  38. package/dist/{chunk-bqg1d720.js → chunk-se734zc5.js} +1 -1
  39. package/dist/{chunk-crcd5phx.js → chunk-tbtg8z35.js} +1 -1
  40. package/dist/{chunk-q1xay7e8.js → chunk-tyrdwvse.js} +2 -2
  41. package/dist/{chunk-d3gdmf4n.js → chunk-vtkfkkzw.js} +1 -1
  42. package/dist/{chunk-6bk7q8ef.js → chunk-wc9344hm.js} +1 -1
  43. package/dist/{chunk-bzvmtger.js → chunk-wcbxh9h9.js} +1 -1
  44. package/dist/{chunk-ndmbsbhk.js → chunk-x0fhwxhv.js} +1 -1
  45. package/dist/{chunk-91za8dqh.js → chunk-x4d6ndn1.js} +1 -1
  46. package/dist/{chunk-kqt67yc7.js → chunk-x8kf5xjf.js} +2 -2
  47. package/dist/{chunk-kw7t9eq7.js → chunk-xp879a67.js} +1 -1
  48. package/dist/{chunk-9mcnkrjx.js → chunk-yty18jzq.js} +1 -1
  49. package/dist/{chunk-h8gs6xfz.js → chunk-zpy0gxqa.js} +1 -1
  50. package/dist/cli.js +7 -7
  51. package/dist/craft-entry.js +1 -1
  52. package/dist/craft.js +1 -1
  53. package/dist/pwa.js +1 -1
  54. package/dist/ssg.js +2 -2
  55. package/package.json +5 -5
  56. package/dist/chunk-2dtvrkpk.js +0 -2
  57. package/dist/chunk-3x3pn8qw.js +0 -2
  58. package/dist/chunk-5c5aqc6z.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{zn,sc,Md,oc,Nd,ic,Hn,b,Ct,be,ac,rs,cc,Ld,G,lc,jd,x,Bd}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{lc as applyFilters,Nd as clearCustomFilters,ac as clientLoopScopes,zn as defaultFilters,b as escapeHtml,Ct as escapeHtmlValue,x as evaluateExpression,ic as findMustacheEnd,oc as getAllFilters,cc as interpolateScriptAttributes,rs as interpolateScriptExpressions,Ld as interpolateScriptsInTemplate,G as processExpressions,sc as registerFilter,Md as registerFilters,Hn as replaceInterpolations,jd as resetRejectedExpressionWarnings,Bd as unescapeHtml,be as usesSignalsInScript};
2
+ import{zn,sc,Md,oc,Nd,ic,Hn,b,Ct,be,ac,rs,cc,Ld,G,lc,jd,x,Bd}from"./chunk-g3gtxcc3.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-66yp3ryj.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{lc as applyFilters,Nd as clearCustomFilters,ac as clientLoopScopes,zn as defaultFilters,b as escapeHtml,Ct as escapeHtmlValue,x as evaluateExpression,ic as findMustacheEnd,oc as getAllFilters,cc as interpolateScriptAttributes,rs as interpolateScriptExpressions,Ld as interpolateScriptsInTemplate,G as processExpressions,sc as registerFilter,Md as registerFilters,Hn as replaceInterpolations,jd as resetRejectedExpressionWarnings,Bd as unescapeHtml,be as usesSignalsInScript};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{X,wn,ne,P,Pt}from"./chunk-a5kaw8sc.js";import{tt,kn,pr,fr,gr,nt,rt,st,ot,it,at,Ce}from"./chunk-kvmg6r89.js";import{W,b,sn,on,e,Et,an,f,ze,_t,He,Ue,Q,N,le,K,d,we,hi,xs,n,r,te,Zn,o,A,de}from"./chunk-4wwpxt4z.js";import{Pe,lo,re,_,uo,Tr,In,he,po,se}from"./chunk-zpyzpp5h.js";import{Dt}from"./chunk-epxyy8mz.js";import{ce}from"./chunk-azb58ven.js";import{a}from"./chunk-4cmqjmqr.js";import{D}from"./chunk-3nk8cnrm.js";function Xs(t,s){let i=[],p=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
2
+ import{X,wn,ne,P,Pt}from"./chunk-a5kaw8sc.js";import{tt,kn,pr,fr,gr,nt,rt,st,ot,it,at,Ce}from"./chunk-kvmg6r89.js";import{W,b,sn,on,e,Et,an,f,ze,_t,He,Ue,Q,N,le,K,d,we,hi,xs,n,r,te,Zn,o,A,de}from"./chunk-g3gtxcc3.js";import{Pe,lo,re,_,uo,Tr,In,he,po,se}from"./chunk-7pk5sqkw.js";import{Dt}from"./chunk-8k5sp2t6.js";import{ce}from"./chunk-azb58ven.js";import{a}from"./chunk-4cmqjmqr.js";import{D}from"./chunk-3nk8cnrm.js";function Xs(t,s){let i=[],p=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(p)){let m=l.slice(p.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
3
3
  /* Theme selector for code blocks */
4
4
  .theme-selector {
5
5
  margin: 1rem 0;
@@ -1786,7 +1786,7 @@ else {
1786
1786
  })()
1787
1787
  </script>
1788
1788
  `;import _e from"fs";import Te from"path";function Pn(t){try{return _e.statSync(t).mtimeMs}catch{return null}}function At(t,s){let i=Math.max(0,Math.round((s-t)/1000));if(i<60)return`${i}s ago`;if(i<3600)return`${Math.round(i/60)}m ago`;return`${Math.round(i/3600)}h ago`}function Ei(t,s){try{return globalThis.Bun?.resolveSync(t,s)??null}catch{return null}}function On(t,s="stx"){let i=Te.resolve(t);for(let p=0;p<10;p++){let c=Te.join(i,"pantry","@stacksjs",s);if(_e.existsSync(c))return c;let l=Te.dirname(i);if(l===i)break;i=l}return null}var An=["@stacksjs/stx","bun-plugin-stx"];function Pi(t){try{let s=_e.readFileSync(Te.join(t,"package.json"),"utf8"),i=JSON.parse(s)?.version;return typeof i==="string"?i:null}catch{return null}}function Oi(t,s=6){let i=Te.resolve(t),p=[],c=new Set;function l(u,h){if(h>s)return;let g;try{g=_e.realpathSync(u)}catch{return}if(c.has(g))return;c.add(g);for(let w of An){let S=Te.join(u,w),C=Pi(S);if(C!==null)p.push({name:w,version:C,dir:Te.relative(i,S)||S,nested:h>0})}let y;try{y=_e.readdirSync(u,{withFileTypes:!0})}catch{return}for(let w of y){if(!w.isDirectory()&&!w.isSymbolicLink())continue;if(w.name===".bin"||w.name===".cache")continue;let S=Te.join(u,w.name);if(w.name.startsWith("@")){let v;try{v=_e.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let T=Te.join(S,x.name,"node_modules");if(_e.existsSync(T))l(T,h+1)}continue}let C=Te.join(S,"node_modules");if(_e.existsSync(C))l(C,h+1)}}let m=Te.join(i,"node_modules");if(_e.existsSync(m))l(m,0);return p}function Ai(t){let s=[];for(let i of An){let p=t.filter((m)=>m.name===i);if(p.length<=1)continue;let c=[...new Set(p.map((m)=>m.version))],l=p.map((m)=>`${m.version} at ${m.dir}`).join("; ");if(c.length===1){s.push({name:`${i} copies`,status:"info",detail:`${p.length} copies, all ${c[0]} \u2014 duplicated but in agreement`});continue}s.push({name:`${i} copies disagree`,status:"error",detail:`${c.length} versions installed, so which one runs depends on who imports it: ${l}`,fix:`remove the nested copies, or add an overrides entry pinning ${i}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${i}/package.json' -exec grep -H '"version"' {} +`})}return s}async function vr(t={}){let s=t.cwd?Te.resolve(t.cwd):process.cwd(),i=t.resolve??Ei,p=Date.now(),c=[],l=i("@stacksjs/stx",s);c.push(l?{name:"@stacksjs/stx resolves to",status:"ok",detail:l}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let m=i("bun-plugin-stx",s);if(m)c.push({name:"bun-plugin-stx resolves to",status:"ok",detail:m});for(let h of Ai(Oi(s)))c.push(h);let u=On(s,"stx");if(!u)c.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let h=Te.join(u,"src/signals.ts"),g=[Te.join(u,"dist/index.js"),Te.join(u,"dist/signals.js")].find((v)=>_e.existsSync(v))||null,y=Pn(h),w=g?Pn(g):null;if(y==null)c.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${u} but no src/signals.ts to compare`});else if(w==null)c.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${u} && bun build.ts`});else if(w<y){let v=Math.round((y-w)/1000);c.push({name:"pantry dist freshness",status:"error",detail:`dist (${At(w,p)}) is OLDER than src/signals.ts (${At(y,p)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${u} && bun build.ts`})}else c.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${At(y,p)}, dist ${At(w,p)})`});let S=Te.join(s,"node_modules/@stacksjs/stx"),C=null;try{C=_e.lstatSync(S)}catch{C=null}if(!C)c.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(C.isSymbolicLink()){let v=null;try{v=_e.realpathSync(S)}catch{}let x=(()=>{try{return _e.realpathSync(u)}catch{return u}})();c.push(v===x?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else c.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(c.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),t.generateRuntime)try{let g=t.generateRuntime().length;c.push(g>1000?{name:"signals runtime",status:"ok",detail:`generated ${g.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${g} chars \u2014 suspiciously short`})}catch(h){c.push({name:"signals runtime",status:"error",detail:`failed to generate: ${h.message}`})}return{checks:c,ok:!c.some((h)=>h.status==="error")}}function xr(t){let s={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},i=["stx runtime resolution:"];for(let p of t.checks)if(i.push(` ${s[p.status]} ${p.name}: ${p.detail}`),p.fix)i.push(` \u2192 ${p.fix}`);return i.push(""),i.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),i.join(`
1789
- `)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},p=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Zn(i,p);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(i.cache&&i.cachePath){let x=await sn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await ne(()=>Bun.file(m).text(),"",(x)=>{throw new wn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new wn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=W.time("script-extraction",()=>{let x=h,T=Q(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let R of k){let L=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=R.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(R)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await ne(()=>d(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(P.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await W.timeAsync("directive-processing",async()=>await n(y,S,m,i,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-qmew5tzd.js"),T=x(w.join(`
1789
+ `)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},p=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Zn(i,p);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let u=new Set;if(i.cache&&i.cachePath){let x=await sn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await ne(()=>Bun.file(m).text(),"",(x)=>{throw new wn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new wn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=W.time("script-extraction",()=>{let x=h,T=Q(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let R of k){let L=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=R.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(R)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await ne(()=>d(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(P.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await W.timeAsync("directive-processing",async()=>await n(y,S,m,i,u));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-gmp7apxp.js"),T=x(w.join(`
1790
1790
  `),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+T+`
1791
1791
  `+v.slice(k);else v+=`
1792
1792
  ${T}`}if(v=await K(v),u.forEach((x)=>p.add(x)),i.cache&&i.cachePath){if(await on(m,v,u,i),i.debug)console.log(`Cached template ${m} with ${u.size} dependencies`)}return{contents:v,loader:"html"}}catch(u){let h=u instanceof Error?u:new X(`Plugin processing failed: ${String(u)}`,m);if(P.log(h,{filePath:m,buildConfig:t.config}),Pt.logDetailedError(h,{filePath:m,plugin:"bun-plugin-stx"}),i.debug)console.error("stx Plugin Error:",h);let g=h,y=g.line||null,w=g.context||null;return{contents:i.debug||D()?`<!DOCTYPE html>
@@ -1849,7 +1849,7 @@ ${T}`}if(v=await K(v),u.forEach((x)=>p.add(x)),i.cache&&i.cachePath){if(await on
1849
1849
  <h1>Something went wrong</h1>
1850
1850
  <p>An internal error occurred. Please try again later.</p>
1851
1851
  </body>
1852
- </html>`,loader:"html"}}})}};async function _n(t,s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=Se.resolve(t);if(!Fe.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,s);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Fe.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ye)=>({path:ye.path,external:!0}))}},B=await Bun.build({entrypoints:[u],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find(($e)=>$e.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(u);await Et(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Ct({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-5c5aqc6z.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:ee}=await import("./chunk-tgfpk4ng.js"),$e=B.broadcasting;await G($e);let ye=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ye}/ws${e.reset}`);let De=Se.join(process.cwd(),"channels.ts");if(Fe.existsSync(De))try{let ae=await ee(De);console.log(`${e.blue}Loaded ${e.bright}${ae} broadcast channel${ae!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ae){console.warn(`${e.yellow}Failed to load channels.ts: ${ae.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-w6mymv3q.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Fi({port:C,async fetch(L){return Dt(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(u),Se.join(process.cwd(),"public")].some((ae)=>H(Se.join(ae,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ae=await x.handleRequest(L);if(ae.status!==404)return ae}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(ae){return new Response(JSON.stringify({error:ae.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let U=await f(g||"");if(c)U=Xe(U,m);if(s.native)if(U.includes("<head>"))U=U.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(U.includes("<html"))U=U.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(s.titlebarHidden)if(U.includes("<head>"))U=U.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(U.includes("<html"))U=U.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;return U})().then((U)=>new Response(U,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let ee=Se.join(h,B.pathname);if(Fe.existsSync(ee)&&Fe.statSync(ee).isFile()){let ae=Bun.file(ee),U=Se.extname(ee).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let $e=Se.dirname(u),ye=Se.join($e,B.pathname);if(Fe.existsSync(ye)&&Fe.statSync(ye).isFile()){let ae=Bun.file(ye),U=Se.extname(ye).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let De=Se.join(process.cwd(),"public",B.pathname);if(Fe.existsSync(De)&&Fe.statSync(De).isFile()){let ae=Bun.file(De),U=Se.extname(De).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
1852
+ </html>`,loader:"html"}}})}};async function _n(t,s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=Se.resolve(t);if(!Fe.existsSync(u))return console.error(`${e.red}Error: File not found: ${e.bright}${u}${e.reset}`),!1;if(u.endsWith(".md"))return Ft(u,s);else if(!u.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${u}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Fe.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup($e){$e.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ye)=>({path:ye.path,external:!0}))}},B=await Bun.build({entrypoints:[u],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find(($e)=>$e.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(u);await Et(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Ct({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-n7f2c5vf.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:ee}=await import("./chunk-tgfpk4ng.js"),$e=B.broadcasting;await G($e);let ye=$e.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ye}/ws${e.reset}`);let De=Se.join(process.cwd(),"channels.ts");if(Fe.existsSync(De))try{let ae=await ee(De);console.log(`${e.blue}Loaded ${e.bright}${ae} broadcast channel${ae!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ae){console.warn(`${e.yellow}Failed to load channels.ts: ${ae.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-nd7p8f5p.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Fi({port:C,async fetch(L){return Dt(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(u),Se.join(process.cwd(),"public")].some((ae)=>H(Se.join(ae,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let ae=await x.handleRequest(L);if(ae.status!==404)return ae}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(ae){return new Response(JSON.stringify({error:ae.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let U=await f(g||"");if(c)U=Xe(U,m);if(s.native)if(U.includes("<head>"))U=U.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(U.includes("<html"))U=U.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(s.titlebarHidden)if(U.includes("<head>"))U=U.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(U.includes("<html"))U=U.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;return U})().then((U)=>new Response(U,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let ee=Se.join(h,B.pathname);if(Fe.existsSync(ee)&&Fe.statSync(ee).isFile()){let ae=Bun.file(ee),U=Se.extname(ee).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let $e=Se.dirname(u),ye=Se.join($e,B.pathname);if(Fe.existsSync(ye)&&Fe.statSync(ye).isFile()){let ae=Bun.file(ye),U=Se.extname(ye).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}let De=Se.join(process.cwd(),"public",B.pathname);if(Fe.existsSync(De)&&Fe.statSync(De).isFile()){let ae=Bun.file(De),U=Se.extname(De).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let Ne=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),qe=await ae.text(),ct=Ne.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(ae,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
1853
1853
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1854
1854
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1855
1855
  ${e.bright}\u2192 ${e.cyan}http://localhost:${C}/${e.reset}`),console.log(`
@@ -2025,9 +2025,9 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
2025
2025
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2026
2026
  ${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
2027
2027
  ${e.yellow}Routes:${e.reset}`);let S=new Set(u.map((v)=>v.routeTemplate)),C=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Ae.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of u){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");C.push({route:x,filePath:Ae.relative(process.cwd(),v.filePath),fileType:"stx"})}if(C.sort((v,x)=>v.route.localeCompare(x.route)),C.forEach((v,x)=>{let k=x===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ",H=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${H}`)}),console.log(`
2028
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(p)Ze.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),we.clear(),te(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ni}=globalThis.Bun;import xe from"fs";import ie from"path";async function qn(t){try{return _t(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":p[i]||"application/octet-stream",...l}})}async function $n(t=".",s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-5c5aqc6z.js"),g=await h(u),{createServerApi:y,isServerApiSource:w}=await import("./chunk-w6mymv3q.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!xe.existsSync(T)&&!g._layerPageDirs?.some((E)=>xe.existsSync(E)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:E,prefix:F}of H)if(xe.existsSync(E)){let z=N(ie.dirname(E),{pagesDir:ie.basename(E)});for(let V of z){let ve=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:ve},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,R=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await uo(u,s.stxOptions?.shell),L){if(R=await Tr(L,s.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}nt(),await st(u);let B=rt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},ee=null;try{let{loadStxConfig:E}=await import("./chunk-5c5aqc6z.js"),F=await E(u);if(F?.apiRouter)ee=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-tgfpk4ng.js"),ve=F.broadcasting;await z(ve);let We=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(xe.existsSync(Ge))try{let oe=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${oe} broadcast channel${oe!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(oe){console.warn(`${e.yellow}Failed to load channels.ts: ${oe.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let $e=a(u,"output");xe.mkdirSync($e,{recursive:!0});let ye=new Map,De=new Set,ae=async(E)=>{let F=fr(T,E);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},U=new Map,j=async(E,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:ve,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-5c5aqc6z.js"),{checkCache:oe,cacheTemplate:Z,readFileCached:q,templateCache:J}=await import("./chunk-qvjyyns1.js"),ke=await We(u),Je=(pe)=>{if(!pe)return pe;if(ie.isAbsolute(pe))return pe;return ie.resolve(u,pe)},O={...ve,...ke,...s.stxOptions,autoShell:!0};if(s.debugDirectives)O.debug=!0;O.partialsDir=Je(O.partialsDir),O.componentsDir=Je(O.componentsDir),O.layoutsDir=Je(O.layoutsDir),O.storesDir=Je(O.storesDir||"stores"),O.cachePath=Je(O.cachePath)??a(u,"cache");let be=!F&&!s.profile,ue=O.cache!==!1;if(ue&&be){let pe=J.get(E.filePath);if(pe)try{if((await xe.promises.stat(E.filePath)).mtime.getTime()<=pe.mtime){let Be=!0;for(let Ee of pe.dependencies){if(!xe.existsSync(Ee)){Be=!1;break}if((await xe.promises.stat(Ee)).mtime.getTime()>pe.mtime){Be=!1;break}}if(Be){let Ee=pe.output;if(R)Ee=he(Ee,{preserveHead:!0});let gt=U.get(E.filePath);return{route:E,content:Ee,status:gt?.status??await qn(E.filePath),headers:gt?.headers}}}}catch{}let Ie=await oe(E.filePath,O);if(Ie){let je=Ie;if(R)je=he(je,{preserveHead:!0});let Be=U.get(E.filePath);return{route:E,content:je,status:Be?.status??await qn(E.filePath),headers:Be?.headers}}}let ge=ue?await q(E.filePath):await Bun.file(E.filePath).text(),Re=_t(ge),{classifyAllScripts:Y}=await import("./chunk-5c5aqc6z.js"),Le=Y(ge),Ve=Le.server.map((pe)=>pe.content),fe=ge;for(let pe of Le.server)fe=fe.replace(pe.fullTag,"");let me={__filename:E.filePath,__dirname:ie.dirname(E.filePath),__stx_options:O,params:F??{},__stx_runtime_head:{}};for(let pe of Ve)try{await V(pe,me,E.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let pe=performance.now();Me=await z(fe,me,E.filePath,O,Ke);let Ie=performance.now()-pe,je=ie.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(fe,me,E.filePath,O,Ke);if(!R)Me=await Ge(Me,{router:O.router});{let{interpolateScriptExpressions:pe}=await import("./chunk-qmew5tzd.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,Be)=>{if(!/function\s+__stx_setup_/.test(Be))return Ie;return`<script${je}>${pe(Be,me)}</script>`})}if(R)Me=he(Me,{preserveHead:!0});if(ue&&be)await Z(E.filePath,Me,Ke,O);let{extractStreamBoundaries:Kn}=await import("./chunk-20xnk6jm.js"),lt=Kn(me),mt=me.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let pe=me.streamBoundaries||{},Ie={...O,autoShell:!1},je=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof pe[Ee]==="function"?await pe[Ee]():void 0;return z(mt[Ee],{...me,$boundary:gt},E.filePath,Ie,new Set)}})),Be=new Set(je.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!Be.has(Ee.id)),...je]}if(lt&&lt.length>0)De.add(E.pattern);else lt=void 0;let Kt=He(me),Xt=Ue(me);if(be)U.set(E.filePath,{status:Kt,headers:Xt});return{route:E,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Ne=8,qe=async()=>{ye.clear(),I.clear();for(let E=0;E<k.length;E+=Ne){let F=k.slice(E,E+Ne),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)ye.set(V.route.pattern,V)}for(let E=0;E<M.length;E+=Ne){let F=M.slice(E,E+Ne),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return ye.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Et(u);let et=i;try{if(et=await Ye(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let E=s.hmrPort||et+1;l=Ct({wsPort:E,verbose:!1}),m=l.start(E)}let Lt=(E,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${V}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+E};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ni({port:et,async fetch(E){let F=new URL(E.url),z=g?.publicDir||"public",V=ie.join(u,z,F.pathname),ve=ie.join(u,F.pathname),We=ie.join($e,F.pathname);if([V,ve,We].some((O)=>w(O,u,S)))return new Response("Not Found",{status:404});let[Ge,oe,Z]=await Promise.all([xe.promises.stat(V).catch(()=>null),xe.promises.stat(ve).catch(()=>null),xe.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(oe?.isFile()&&!w(ve,u,S))return qt(ve);if(Z?.isFile()&&!w(We,u,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let O=decodeURIComponent(F.pathname.slice(16));if(O)try{let be=`<${O} />`,ue={...buildConfig,autoShell:!1},ge=await processDirectives(be,{},ie.join(u,"components",`${O}.stx`),ue,new Set);return new Response(ge,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:O}=await import("./chunk-zfypzka2.js"),be=await O(E,{publicDir:ie.join(u,z),cacheDir:a(u,"cache","img")});if(be)return be}if(ee)try{let O=await ee.handleRequest(E);if(O.status!==404)return O}catch{}if(G[F.pathname])try{return await G[F.pathname](E)}catch(O){return new Response(JSON.stringify({error:O.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(E);if(q)return q;let J=kn(F.pathname,k);if(J){let O=ye.get(J.route.pattern),be=De.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let ue=await j(J.route,J.params);if(ue)O=ue}if(O){let ue=O.status??200,ge=O.headers??{},Re=(J.route.filePath?ze(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await ae(404);if(Ve){let fe=Ve;if(fe=await f(fe,u),c)fe=Xe(fe,m);return new Response(fe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=ot(F.pathname,J.params,Re,F.search),Ve=it(Le,null,E,{isServer:!0}),fe=await at(Re.middleware,Ve);if(fe.redirect){let me=fe.redirect.path,Ke=fe.redirect.options.redirectCode||302,Me=new Headers(fe.responseHeaders);return Me.set("Location",me),new Response(null,{status:Ke,headers:Me})}if(fe.abort){let{statusCode:me,message:Ke}=fe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${me}</title></head><body><h1>Error ${me}</h1><p>${Ke}</p></body></html>`,{status:me,headers:{"Content-Type":"text/html"}})}if(Object.keys(fe.state).length>0){let me=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(fe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;O.content=O.content.replace("</head>",`${me}</head>`)}}let Y=O.content;if(R&&po(E)){let Le=Ce(Y),Ve=le(Y),fe=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),me=fe?lo(fe[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=se(Y,Ke),new Response(Y,{status:ue,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...me&&{"X-STX-Title":encodeURIComponent(me)},[hi]:xs(),..._(),"Cache-Control":Pe}})}if(R)Y=In(R,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(O.boundaries&&O.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-20xnk6jm.js");return Ve(Le(Y,O.boundaries,{timeoutMs:30000}),{status:ue,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:ue,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ge}})}}if(M.length>0){let O=M.map((ue)=>ue.route),be=kn(F.pathname,O);if(be){let ue=I.get(be.route.pattern);if(ue){let ge=ue.content;if(R)ge=In(R,ge);if(Object.keys(be.params).length>0)ge=Lt(ge,be.params);if(ge=await f(ge,u),c)ge=Xe(ge,m);return new Response(ge,{status:ue.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ue}of H)if(ue!=="/"&&F.pathname.startsWith(ue)){let ge=I.get(ue)||I.get(ue+"/");if(ge){let Re=ge.content;if(R)Re=In(R,Re);if(Re=await f(Re,u),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(tt(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=ye.get("/");if(ke){let O=ke.content;if(O=await f(O,u),c)O=Xe(O,m);if(s.native)if(O.includes("<head>"))O=O.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else O="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+O;return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await ae(404);if(Je){let O=Je;if(O=await f(O,u),c)O=Xe(O,m);return new Response(O,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let F=await ae(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
2028
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(p)Ze.watch(l,{recursive:!0}).close();w.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),we.clear(),te(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ni}=globalThis.Bun;import xe from"fs";import ie from"path";async function qn(t){try{return _t(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),p={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":p[i]||"application/octet-stream",...l}})}async function $n(t=".",s={}){let i=s.port||3000,p=s.watch!==!1,c=s.hotReload!==!1&&p,l=null,m=s.hmrPort||i+1,u=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-n7f2c5vf.js"),g=await h(u),{createServerApi:y,isServerApiSource:w}=await import("./chunk-nd7p8f5p.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(u,S),v=g.root&&g.root!=="."?ie.join(u,g.root):u,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!xe.existsSync(T)&&!g._layerPageDirs?.some((E)=>xe.existsSync(E)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:E,prefix:F}of H)if(xe.existsSync(E)){let z=N(ie.dirname(E),{pagesDir:ie.basename(E)});for(let V of z){let ve=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:ve},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,R=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await uo(u,s.stxOptions?.shell),L){if(R=await Tr(L,s.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(u,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}nt(),await st(u);let B=rt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},ee=null;try{let{loadStxConfig:E}=await import("./chunk-n7f2c5vf.js"),F=await E(u);if(F?.apiRouter)ee=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-tgfpk4ng.js"),ve=F.broadcasting;await z(ve);let We=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(xe.existsSync(Ge))try{let oe=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${oe} broadcast channel${oe!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(oe){console.warn(`${e.yellow}Failed to load channels.ts: ${oe.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let $e=a(u,"output");xe.mkdirSync($e,{recursive:!0});let ye=new Map,De=new Set,ae=async(E)=>{let F=fr(T,E);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:$e,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((ve)=>ve.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},U=new Map,j=async(E,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:ve,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-n7f2c5vf.js"),{checkCache:oe,cacheTemplate:Z,readFileCached:q,templateCache:J}=await import("./chunk-96fpvzm2.js"),ke=await We(u),Je=(pe)=>{if(!pe)return pe;if(ie.isAbsolute(pe))return pe;return ie.resolve(u,pe)},O={...ve,...ke,...s.stxOptions,autoShell:!0};if(s.debugDirectives)O.debug=!0;O.partialsDir=Je(O.partialsDir),O.componentsDir=Je(O.componentsDir),O.layoutsDir=Je(O.layoutsDir),O.storesDir=Je(O.storesDir||"stores"),O.cachePath=Je(O.cachePath)??a(u,"cache");let be=!F&&!s.profile,ue=O.cache!==!1;if(ue&&be){let pe=J.get(E.filePath);if(pe)try{if((await xe.promises.stat(E.filePath)).mtime.getTime()<=pe.mtime){let Be=!0;for(let Ee of pe.dependencies){if(!xe.existsSync(Ee)){Be=!1;break}if((await xe.promises.stat(Ee)).mtime.getTime()>pe.mtime){Be=!1;break}}if(Be){let Ee=pe.output;if(R)Ee=he(Ee,{preserveHead:!0});let gt=U.get(E.filePath);return{route:E,content:Ee,status:gt?.status??await qn(E.filePath),headers:gt?.headers}}}}catch{}let Ie=await oe(E.filePath,O);if(Ie){let je=Ie;if(R)je=he(je,{preserveHead:!0});let Be=U.get(E.filePath);return{route:E,content:je,status:Be?.status??await qn(E.filePath),headers:Be?.headers}}}let ge=ue?await q(E.filePath):await Bun.file(E.filePath).text(),Re=_t(ge),{classifyAllScripts:Y}=await import("./chunk-n7f2c5vf.js"),Le=Y(ge),Ve=Le.server.map((pe)=>pe.content),fe=ge;for(let pe of Le.server)fe=fe.replace(pe.fullTag,"");let me={__filename:E.filePath,__dirname:ie.dirname(E.filePath),__stx_options:O,params:F??{},__stx_runtime_head:{}};for(let pe of Ve)try{await V(pe,me,E.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let pe=performance.now();Me=await z(fe,me,E.filePath,O,Ke);let Ie=performance.now()-pe,je=ie.relative(u,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(fe,me,E.filePath,O,Ke);if(!R)Me=await Ge(Me,{router:O.router});{let{interpolateScriptExpressions:pe}=await import("./chunk-gmp7apxp.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,Be)=>{if(!/function\s+__stx_setup_/.test(Be))return Ie;return`<script${je}>${pe(Be,me)}</script>`})}if(R)Me=he(Me,{preserveHead:!0});if(ue&&be)await Z(E.filePath,Me,Ke,O);let{extractStreamBoundaries:Kn}=await import("./chunk-qx9s066f.js"),lt=Kn(me),mt=me.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let pe=me.streamBoundaries||{},Ie={...O,autoShell:!1},je=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof pe[Ee]==="function"?await pe[Ee]():void 0;return z(mt[Ee],{...me,$boundary:gt},E.filePath,Ie,new Set)}})),Be=new Set(je.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!Be.has(Ee.id)),...je]}if(lt&&lt.length>0)De.add(E.pattern);else lt=void 0;let Kt=He(me),Xt=Ue(me);if(be)U.set(E.filePath,{status:Kt,headers:Xt});return{route:E,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Ne=8,qe=async()=>{ye.clear(),I.clear();for(let E=0;E<k.length;E+=Ne){let F=k.slice(E,E+Ne),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)ye.set(V.route.pattern,V)}for(let E=0;E<M.length;E+=Ne){let F=M.slice(E,E+Ne),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return ye.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Et(u);let et=i;try{if(et=await Ye(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let E=s.hmrPort||et+1;l=Ct({wsPort:E,verbose:!1}),m=l.start(E)}let Lt=(E,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${V}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+E};console.log(`${e.blue}Starting server...${e.reset}`);let It=Ni({port:et,async fetch(E){let F=new URL(E.url),z=g?.publicDir||"public",V=ie.join(u,z,F.pathname),ve=ie.join(u,F.pathname),We=ie.join($e,F.pathname);if([V,ve,We].some((O)=>w(O,u,S)))return new Response("Not Found",{status:404});let[Ge,oe,Z]=await Promise.all([xe.promises.stat(V).catch(()=>null),xe.promises.stat(ve).catch(()=>null),xe.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,u,S))return qt(V);if(oe?.isFile()&&!w(ve,u,S))return qt(ve);if(Z?.isFile()&&!w(We,u,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let O=decodeURIComponent(F.pathname.slice(16));if(O)try{let be=`<${O} />`,ue={...buildConfig,autoShell:!1},ge=await processDirectives(be,{},ie.join(u,"components",`${O}.stx`),ue,new Set);return new Response(ge,{headers:{"Content-Type":"text/html"}})}catch(be){return new Response(`<div class="stx-async-error">${be.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:O}=await import("./chunk-zfypzka2.js"),be=await O(E,{publicDir:ie.join(u,z),cacheDir:a(u,"cache","img")});if(be)return be}if(ee)try{let O=await ee.handleRequest(E);if(O.status!==404)return O}catch{}if(G[F.pathname])try{return await G[F.pathname](E)}catch(O){return new Response(JSON.stringify({error:O.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(E);if(q)return q;let J=kn(F.pathname,k);if(J){let O=ye.get(J.route.pattern),be=De.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||be){let ue=await j(J.route,J.params);if(ue)O=ue}if(O){let ue=O.status??200,ge=O.headers??{},Re=(J.route.filePath?ze(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await ae(404);if(Ve){let fe=Ve;if(fe=await f(fe,u),c)fe=Xe(fe,m);return new Response(fe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=ot(F.pathname,J.params,Re,F.search),Ve=it(Le,null,E,{isServer:!0}),fe=await at(Re.middleware,Ve);if(fe.redirect){let me=fe.redirect.path,Ke=fe.redirect.options.redirectCode||302,Me=new Headers(fe.responseHeaders);return Me.set("Location",me),new Response(null,{status:Ke,headers:Me})}if(fe.abort){let{statusCode:me,message:Ke}=fe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${me}</title></head><body><h1>Error ${me}</h1><p>${Ke}</p></body></html>`,{status:me,headers:{"Content-Type":"text/html"}})}if(Object.keys(fe.state).length>0){let me=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(fe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;O.content=O.content.replace("</head>",`${me}</head>`)}}let Y=O.content;if(R&&po(E)){let Le=Ce(Y),Ve=le(Y),fe=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),me=fe?lo(fe[1].trim()):"";if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);Y=await f(Y,u);let Ke=g?.router?.container||"main";return Y=se(Y,Ke),new Response(Y,{status:ue,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...me&&{"X-STX-Title":encodeURIComponent(me)},[hi]:xs(),..._(),"Cache-Control":Pe}})}if(R)Y=In(R,Y);if(Object.keys(J.params).length>0)Y=Lt(Y,J.params);if(Y=await f(Y,u),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(O.boundaries&&O.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-qx9s066f.js");return Ve(Le(Y,O.boundaries,{timeoutMs:30000}),{status:ue,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:ue,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ge}})}}if(M.length>0){let O=M.map((ue)=>ue.route),be=kn(F.pathname,O);if(be){let ue=I.get(be.route.pattern);if(ue){let ge=ue.content;if(R)ge=In(R,ge);if(Object.keys(be.params).length>0)ge=Lt(ge,be.params);if(ge=await f(ge,u),c)ge=Xe(ge,m);return new Response(ge,{status:ue.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ue}of H)if(ue!=="/"&&F.pathname.startsWith(ue)){let ge=I.get(ue)||I.get(ue+"/");if(ge){let Re=ge.content;if(R)Re=In(R,Re);if(Re=await f(Re,u),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(tt(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let ke=ye.get("/");if(ke){let O=ke.content;if(O=await f(O,u),c)O=Xe(O,m);if(s.native)if(O.includes("<head>"))O=O.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else O="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+O;return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await ae(404);if(Je){let O=Je;if(O=await f(O,u),c)O=Xe(O,m);return new Response(O,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let F=await ae(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
2029
2029
  ${E.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
2030
2030
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
2031
2031
  ${e.bright}\u2192 ${e.cyan}http://localhost:${et}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
2032
2032
  ${e.yellow}Routes:${e.reset}`);let jt=[...gr(k,u)];for(let{route:E}of M)jt.push(`${E.pattern}`);if(jt.forEach((E,F)=>{let V=F===jt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${E}`)}),console.log(`
2033
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(It.url.toString(),()=>{if(l)ht();It.stop()}),s.native){let E,F=ie.join(T,"index.stx");if(xe.existsSync(F)){let V=await Bun.file(F).text();E=St(V)}let z=g?.app?.window??{};await dt(et,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(oe)=>oe.startsWith("public/")||oe.startsWith("public\\"),F=(oe)=>{let Z=oe.toLowerCase();return Z.endsWith(".stx")||Z.endsWith(".html")||Z.endsWith(".md")},z=new Map,V=()=>{let oe=new Set([u,...g._layerGraph?.layers.map((Z)=>Z.root)??[],...g._layerGraph?.configDependencies.map((Z)=>ie.dirname(Z))??[]].filter((Z)=>xe.existsSync(Z)).map((Z)=>xe.realpathSync(Z)));for(let Z of g._layerGraph?.layers??[])for(let q of Object.values(Z.resources)){if(!xe.existsSync(q))continue;let J=xe.realpathSync(q);if(![...oe].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))oe.add(J)}for(let[Z,q]of z)if(!oe.has(Z))q.close(),z.delete(Z);for(let Z of oe)if(!z.has(Z)&&xe.existsSync(Z))z.set(Z,xe.watch(Z,{recursive:!0},(q,J)=>{We(Z,q,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},ve=Promise.resolve(),We=(oe,Z,q)=>(ve=ve.catch(()=>{}).then(()=>Ge(oe,Z,q)),ve),Ge=async(oe,Z,q)=>{if(!q||$t(q))return;if(Tt(q)){if(g._layerGraph){let J=await h(u);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(E(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-qvjyyns1.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(L&&q){if(ie.resolve(oe,q)===L||ie.basename(L)===q){let ke=await Tr(L,s.stxOptions||{});if(ke)R=ke}}if(await qe(),await an(u),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-qvjyyns1.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if(kt(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let oe of z.values())oe.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Xs,Js,Ys,Zs,wr,Qs,eo,to,Xi,Ji,vr,xr,_n,Tn,$n};
2033
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(It.url.toString(),()=>{if(l)ht();It.stop()}),s.native){let E,F=ie.join(T,"index.stx");if(xe.existsSync(F)){let V=await Bun.file(F).text();E=St(V)}let z=g?.app?.window??{};await dt(et,{title:g?.app?.head?.title||ie.basename(u)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(oe)=>oe.startsWith("public/")||oe.startsWith("public\\"),F=(oe)=>{let Z=oe.toLowerCase();return Z.endsWith(".stx")||Z.endsWith(".html")||Z.endsWith(".md")},z=new Map,V=()=>{let oe=new Set([u,...g._layerGraph?.layers.map((Z)=>Z.root)??[],...g._layerGraph?.configDependencies.map((Z)=>ie.dirname(Z))??[]].filter((Z)=>xe.existsSync(Z)).map((Z)=>xe.realpathSync(Z)));for(let Z of g._layerGraph?.layers??[])for(let q of Object.values(Z.resources)){if(!xe.existsSync(q))continue;let J=xe.realpathSync(q);if(![...oe].some((ke)=>J===ke||J.startsWith(`${ke}${ie.sep}`)))oe.add(J)}for(let[Z,q]of z)if(!oe.has(Z))q.close(),z.delete(Z);for(let Z of oe)if(!z.has(Z)&&xe.existsSync(Z))z.set(Z,xe.watch(Z,{recursive:!0},(q,J)=>{We(Z,q,J).catch((ke)=>console.error("[stx] Layer rebuild failed:",ke))}))},ve=Promise.resolve(),We=(oe,Z,q)=>(ve=ve.catch(()=>{}).then(()=>Ge(oe,Z,q)),ve),Ge=async(oe,Z,q)=>{if(!q||$t(q))return;if(Tt(q)){if(g._layerGraph){let J=await h(u);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(E(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-96fpvzm2.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(L&&q){if(ie.resolve(oe,q)===L||ie.basename(L)===q){let ke=await Tr(L,s.stxOptions||{});if(ke)R=ke}}if(await qe(),await an(u),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),we.clear(),te();try{let{invalidateFileCache:J,templateCache:ke}=await import("./chunk-96fpvzm2.js");J(ie.resolve(oe,q)),ke.delete(ie.resolve(oe,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if(kt(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let oe of z.values())oe.close();if(l)ht();It.stop(),process.exit(0)})}return!0}export{Xs,Js,Ys,Zs,wr,Qs,eo,to,Xi,Ji,vr,xr,_n,Tn,$n};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ro,Ao,Po,Ad}from"./chunk-8mzsz1k6.js";import"./chunk-q1xay7e8.js";import"./chunk-tqnh98j7.js";import"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Ro as buildNative,Ad as default,Po as getAvailableFormats,Ao as getAvailableTargets};
2
+ import{Ro,Ao,Po,Ad}from"./chunk-pmwzvb3m.js";import"./chunk-tyrdwvse.js";import"./chunk-tqnh98j7.js";import"./chunk-g3gtxcc3.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-66yp3ryj.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Ro as buildNative,Ad as default,Po as getAvailableFormats,Ao as getAvailableTargets};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Tt,kc,Cc,Ec,_c,Tc,d,$c,hs,Rc,pi,fi}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Tt as STX_ENGINE_BINDING_NAMES,hs as convertToCommonJS,pi as extractScriptFromTemplate,d as extractVariables,fi as hasVariables,$c as isCompleteImport,Tc as isMissingBindingFailure,Ec as isModuleResolutionFailure,_c as isSyntaxFailure,Rc as splitDeclaration,kc as stripTypeScript,Cc as withoutStxReferrer};
2
+ import{Tt,kc,Cc,Ec,_c,Tc,d,$c,hs,Rc,pi,fi}from"./chunk-g3gtxcc3.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-66yp3ryj.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Tt as STX_ENGINE_BINDING_NAMES,hs as convertToCommonJS,pi as extractScriptFromTemplate,d as extractVariables,fi as hasVariables,$c as isCompleteImport,Tc as isMissingBindingFailure,Ec as isModuleResolutionFailure,_c as isSyntaxFailure,Rc as splitDeclaration,kc as stripTypeScript,Cc as withoutStxReferrer};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Xi,Ji}from"./chunk-knkeqpnk.js";import"./chunk-3enbxxcs.js";import"./chunk-8k5sp2t6.js";import"./chunk-b9jb44kv.js";import"./chunk-frgpx23w.js";import"./chunk-tbtg8z35.js";import"./chunk-yq1mvakj.js";import"./chunk-x4d6ndn1.js";import{co}from"./chunk-7pk5sqkw.js";import"./chunk-vvkfde23.js";import"./chunk-ah7h9q0x.js";import"./chunk-afrfcgn4.js";import"./chunk-75hb7wg6.js";import"./chunk-3nc2fr4q.js";import"./chunk-rs9c1meq.js";import"./chunk-v79qs0qh.js";import"./chunk-8nwzd6eg.js";import"./chunk-gjx5256r.js";import"./chunk-pz8mf91e.js";import"./chunk-77j26p6r.js";import"./chunk-d37enreq.js";import"./chunk-zmq9hwta.js";import"./chunk-d7ec8hgm.js";import"./chunk-kch9a9v1.js";import"./chunk-39tkfkp7.js";import"./chunk-7ze47qgv.js";import"./chunk-wy4hfmjs.js";import"./chunk-m6m19hwd.js";import"./chunk-xp879a67.js";import"./chunk-0fatkxpr.js";import"./chunk-wcbxh9h9.js";import"./chunk-tyrdwvse.js";import"./chunk-tqnh98j7.js";import"./chunk-wk85dz07.js";import"./chunk-nv62tcmb.js";import"./chunk-qdh45a4k.js";import"./chunk-azb58ven.js";import{ye,sn,on,K,d,n,Zn,R,o,de}from"./chunk-g3gtxcc3.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-66yp3ryj.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Zn as buildWebComponents,on as cacheTemplate,sn as checkCache,co as classifyAllScripts,Xi as createMiddleware,Ji as createRoute,R as defaultConfig,d as extractVariables,K as injectRouterScript,o as loadStxConfig,ye as processClientScript,n as processDirectives,de as readMarkdownFile};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{xt,Kr,Xr,Jr,Od,Yr}from"./chunk-fq58g560.js";import"./chunk-dyreg5df.js";import"./chunk-e124cgb6.js";import"./chunk-kvmg6r89.js";export{Xr as buildServerApi,Od as createServerApi,xt as discoverServerApi,Kr as generateApiTypes,Yr as isServerApiSource,Jr as productionApiDispatcher};
2
+ import{xt,Kr,Xr,Jr,Od,Yr}from"./chunk-qdh45a4k.js";import"./chunk-dyreg5df.js";import"./chunk-e124cgb6.js";import"./chunk-kvmg6r89.js";export{Xr as buildServerApi,Od as createServerApi,xt as discoverServerApi,Kr as generateApiTypes,Yr as isServerApiSource,Jr as productionApiDispatcher};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{nn,ce}from"./chunk-azb58ven.js";import{m,rn,w,je,o,A}from"./chunk-4wwpxt4z.js";import{Yr}from"./chunk-fq58g560.js";import{s,ve}from"./chunk-7wfh2hqy.js";import{a}from"./chunk-4cmqjmqr.js";import h from"path";import v from"fs";var pe=10;function V(e,n,i){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(h.basename(e))||Yr(e,n,i)}var ne=1,re=new Map,W=600,fe=100,P=new Map;async function me(e){let n=P.get(e)??0;if(n>0&&n<fe){P.set(e,n+1);return}P.set(e,1);try{let i=(await v.promises.readdir(e)).filter((u)=>u.endsWith(".js"));if(i.length<=W)return;let g=(await Promise.all(i.map(async(u)=>{try{return{name:u,at:(await v.promises.stat(h.join(e,u))).mtimeMs}}catch{return null}}))).filter((u)=>u!==null);g.sort((u,l)=>l.at-u.at);for(let u of g.slice(W)){let l=u.name.slice(0,-3);await v.promises.rm(h.join(e,`${l}.js`),{force:!0}),await v.promises.rm(h.join(e,`${l}.deps.json`),{force:!0})}I("pruned bundle cache to",W,"entries")}catch{}}function ae(e){return re.get(e)??[]}function X(e,n){if(e)re.set(e,n)}function Ya(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function I(...e){if(Ya())console.log("[stx:bundler]",...e)}var Z=[];function Uo(e,n,i){Z.push({filePath:e||"<inline>",message:n,details:i})}function yt(){return Z.slice()}function bt(){Z.length=0}var q;function Id(e){q=e}function Vo(){if(q)return q;try{let e=A.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var H=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function wt(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,i;while((i=n.exec(e))!==null){let g=i[1];if(!H.some((l)=>l.test(g)))return I("detected user import:",g),!0}let c=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((i=c.exec(e))!==null){let g=i[1];if(/\.css(?:\?.*)?$/.test(g))continue;if(!H.some((l)=>l.test(g)))return I("detected side-effect import:",g),!0}return!1}var tn="stx-module:",ge=/\.(?:[cm]?[jt]sx?|json)$/i;function Za(e,n){return h.relative(e,n).split(h.sep).join("/")}function Qa(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(i,c,g,u)=>{let l=n.get(u);return l&&!u.startsWith(tn)?`${c}${g}${l}${g}`:i})}function ec(e,n){let i=0,c=(u)=>{let l=`__stxMod${i++}`,S=JSON.stringify(u);return n.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${S}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(S)} + " is not registered on this page (#1957)");`),l},g=(u,l)=>{for(let S of u.split(",")){let M=S.trim();if(!M)continue;let f=M.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;let t=f[1].startsWith('"')?JSON.parse(f[1]):f[1],r=f[2]??t;n.push(`var ${r} = ${l}[${JSON.stringify(t)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(u,l,S)=>{let M=S.slice(tn.length),f=c(M),t=l.trim(),r=t.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!t.startsWith("{")&&!t.startsWith("*"))n.push(`var ${r[1]} = ${f}.default;`),t=t.slice(r[0].length).trim();let d=t.match(/^\*\s*as\s+([\w$]+)$/);if(d)n.push(`var ${d[1]} = ${f};`);else if(t.startsWith("{"))g(t.replace(/^\{|\}$/g,""),f);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(u,l)=>(c(l.slice(tn.length)),"")),e}function ee(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,h.join(e,"index.ts"),h.join(e,"index.tsx"),h.join(e,"index.js"),h.join(e,"index.mjs")];for(let i of n)try{if(v.existsSync(i)&&v.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return}function he(e,n,i,c,g,u=new Map,l){let S=(f,t,r)=>{if(V(t,e,l))return null;if(!g||f!==i||!ge.test(t))return null;try{if(!v.statSync(t,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(t);let d=`${tn}${Za(process.cwd(),t)}`;return u.set(r,d),{path:d,external:!0}},M=(f,t)=>{let r=f===i?n:h.dirname(f),d=h.resolve(r,t);return ee(d)??d};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(t)=>({path:t.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(t)=>({path:t.path,external:!0})),f.onResolve({filter:/^\//},(t)=>{let r=ee(t.path);if(r){let d=S(t.importer,r,t.path);if(d)return d;if(r!==i)c.add(r);return{path:r}}return{path:t.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(t)=>{let r=M(t.importer,t.path),d=S(t.importer,r,t.path);if(d)return d;return c.add(r),{path:r}}),f.onResolve({filter:/^[@~]\//},(t)=>{let r=h.resolve(e,t.path.slice(2)),d=[r,`${r}.ts`,`${r}.tsx`,`${r}.js`,`${r}.mjs`,`${r}.jsx`,h.join(r,"index.ts"),h.join(r,"index.tsx"),h.join(r,"index.js"),h.join(r,"index.mjs")];for(let E of d)if(v.existsSync(E)&&v.statSync(E,{throwIfNoEntry:!1})?.isFile()){let C=S(t.importer,E,t.path);if(C)return C;return I(`resolved ${t.path[0]}/ import:`,t.path,"\u2192",E),c.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${t.path[0]}/ import:`,t.path),{path:r}}),g)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(t)=>{if(t.importer!==i)return;let r=`${tn}npm:${t.path}`;return u.set(t.path,r),{path:r,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(t)=>{if(V(t.path,e,l))throw Error(`Server-only API source cannot be imported by a client script: ${t.path}`);let r=h.extname(t.path).toLowerCase(),d=r===".json"?"json":r===".tsx"?"tsx":r===".jsx"?"jsx":r===".ts"||r===".mts"||r===".cts"?"ts":"js";if(t.path!==i)c.add(t.path);return{contents:v.readFileSync(t.path,"utf8"),loader:d}})}}}var G=new Map,L=m(64),te=Symbol.for("stx.client-bundle-build-queue");function tc(e){let n=globalThis,c=(n[te]??Promise.resolve()).then(e,e);return n[te]=c.then(()=>{return},()=>{return}),c}async function vt(e,n,i={}){let c=i.projectRoot||process.cwd(),g=(await o(c)).serverApi,u=i.minify??!1,l=i.externalizeUserModules??!0,S=i.expose?.length?[...new Set(i.expose)].sort():void 0,M=i.cacheDir||a(c,"bundle-cache"),f=new Bun.CryptoHasher("md5");f.update(`${pe}\x00${je()}\x00${JSON.stringify(g??!1)}\x00${l?"registry":"inline"}\x00${S?S.join(","):"*"}\x00${e}\x00${n}`);let t=f.digest("hex").slice(0,12),r=h.join(M,`${t}.js`),d=L.get(r);if(d){if(rn(d.files)&&d.files.every((N)=>!V(N.path,c,g))){I("memo hit:",t);let N=d.files.map((B)=>B.path);return X(n,N),i.collectInputs?.push(...N),d.code}L.delete(r),I("memo invalidated by dep change:",t)}let E=h.join(M,`${t}.deps.json`),C=Bun.file(r);if(await C.exists()){let N=Bun.file(E),B=!1,R=null;if(await N.exists())try{let O=JSON.parse(await N.text());if(O.metadataVersion!==ne||!Array.isArray(O.files))B=!1;else R=O.files,B=!0;if(R&&(!rn(R)||R.some((D)=>V(D.path,c,g))))B=!1}catch{B=!1}if(B){if(I("cache hit:",t),R)X(n,R.map((D)=>D.path)),i.collectInputs?.push(...R.map((D)=>D.path));let O=await C.text();if(R)L.set(r,{code:O,files:R});return O}I("cache invalidated by dep change:",t)}let _=G.get(t);if(_){let N=await _;if(i.collectInputs)i.collectInputs.push(...(L.get(r)?.files??[]).map((B)=>B.path));return N}let z=tc(()=>$e(e,n,{projectRoot:c,minify:u,cacheDir:M,hash:t,cachePath:r,depsPath:E,collectInputs:i.collectInputs,externalizeUserModules:l,serverApi:g,expose:S,throwOnFailure:i.throwOnFailure}));G.set(t,z);try{return await z}finally{G.delete(t)}}var xe=0;function nc(e){return`${e}-${process.pid}-${++xe}`}async function $e(e,n,i){let{projectRoot:c,minify:g,cacheDir:u,hash:l,cachePath:S,depsPath:M,externalizeUserModules:f}=i,t=a(c,"bundle-tmp"),r=nc(l),d=h.join(t,`${r}.ts`),E=h.join(t,"out",r);v.mkdirSync(t,{recursive:!0}),v.mkdirSync(E,{recursive:!0});let C=h.dirname(n),_=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,N=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,B=s(e),{depths:R,balanced:O}=ve(B),D=(j)=>!O||R[j]===0,y;while((y=z.exec(B))!==null){if(y[1])continue;if(!D(y.index))continue;if(y[2])y[2].split(",").forEach((j)=>{let p=we(j);if(p)_.add(p)});else if(y[3])_.add(y[3])}while((y=N.exec(B))!==null){if(y[1])continue;if(!D(y.index))continue;_.add(y[2])}let se=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((y=se.exec(B))!==null){if(!D(y.index))continue;let j=/^\s*['"]([^'"]+)['"]/.exec(e.slice(y.index+y[0].length))?.[1];if(j&&H.some((p)=>p.test(j)))continue;if(y[1])_.add(y[1]);if(y[2])_.add(y[2]);for(let p of(y[3]??"").split(",")){let b=p.trim();if(!b||/^type\s/.test(b))continue;let U=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(U)_.add(U)}}for(let j of B.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let p of j[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(p)?.[1]??/^\s*(\w+)\s*$/.exec(p)?.[1];if(b)_.delete(b)}let ie=_.size>0?`
2
+ import{nn,ce}from"./chunk-azb58ven.js";import{m,rn,w,je,o,A}from"./chunk-g3gtxcc3.js";import{Yr}from"./chunk-qdh45a4k.js";import{s,ve}from"./chunk-7wfh2hqy.js";import{a}from"./chunk-4cmqjmqr.js";import h from"path";import v from"fs";var pe=10;function V(e,n,i){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(h.basename(e))||Yr(e,n,i)}var ne=1,re=new Map,W=600,fe=100,P=new Map;async function me(e){let n=P.get(e)??0;if(n>0&&n<fe){P.set(e,n+1);return}P.set(e,1);try{let i=(await v.promises.readdir(e)).filter((u)=>u.endsWith(".js"));if(i.length<=W)return;let g=(await Promise.all(i.map(async(u)=>{try{return{name:u,at:(await v.promises.stat(h.join(e,u))).mtimeMs}}catch{return null}}))).filter((u)=>u!==null);g.sort((u,l)=>l.at-u.at);for(let u of g.slice(W)){let l=u.name.slice(0,-3);await v.promises.rm(h.join(e,`${l}.js`),{force:!0}),await v.promises.rm(h.join(e,`${l}.deps.json`),{force:!0})}I("pruned bundle cache to",W,"entries")}catch{}}function ae(e){return re.get(e)??[]}function X(e,n){if(e)re.set(e,n)}function Ya(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function I(...e){if(Ya())console.log("[stx:bundler]",...e)}var Z=[];function Uo(e,n,i){Z.push({filePath:e||"<inline>",message:n,details:i})}function yt(){return Z.slice()}function bt(){Z.length=0}var q;function Id(e){q=e}function Vo(){if(q)return q;try{let e=A.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var H=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function wt(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,i;while((i=n.exec(e))!==null){let g=i[1];if(!H.some((l)=>l.test(g)))return I("detected user import:",g),!0}let c=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((i=c.exec(e))!==null){let g=i[1];if(/\.css(?:\?.*)?$/.test(g))continue;if(!H.some((l)=>l.test(g)))return I("detected side-effect import:",g),!0}return!1}var tn="stx-module:",ge=/\.(?:[cm]?[jt]sx?|json)$/i;function Za(e,n){return h.relative(e,n).split(h.sep).join("/")}function Qa(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(i,c,g,u)=>{let l=n.get(u);return l&&!u.startsWith(tn)?`${c}${g}${l}${g}`:i})}function ec(e,n){let i=0,c=(u)=>{let l=`__stxMod${i++}`,S=JSON.stringify(u);return n.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${S}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(S)} + " is not registered on this page (#1957)");`),l},g=(u,l)=>{for(let S of u.split(",")){let M=S.trim();if(!M)continue;let f=M.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;let t=f[1].startsWith('"')?JSON.parse(f[1]):f[1],r=f[2]??t;n.push(`var ${r} = ${l}[${JSON.stringify(t)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(u,l,S)=>{let M=S.slice(tn.length),f=c(M),t=l.trim(),r=t.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!t.startsWith("{")&&!t.startsWith("*"))n.push(`var ${r[1]} = ${f}.default;`),t=t.slice(r[0].length).trim();let d=t.match(/^\*\s*as\s+([\w$]+)$/);if(d)n.push(`var ${d[1]} = ${f};`);else if(t.startsWith("{"))g(t.replace(/^\{|\}$/g,""),f);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(u,l)=>(c(l.slice(tn.length)),"")),e}function ee(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,h.join(e,"index.ts"),h.join(e,"index.tsx"),h.join(e,"index.js"),h.join(e,"index.mjs")];for(let i of n)try{if(v.existsSync(i)&&v.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return}function he(e,n,i,c,g,u=new Map,l){let S=(f,t,r)=>{if(V(t,e,l))return null;if(!g||f!==i||!ge.test(t))return null;try{if(!v.statSync(t,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(t);let d=`${tn}${Za(process.cwd(),t)}`;return u.set(r,d),{path:d,external:!0}},M=(f,t)=>{let r=f===i?n:h.dirname(f),d=h.resolve(r,t);return ee(d)??d};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(t)=>({path:t.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(t)=>({path:t.path,external:!0})),f.onResolve({filter:/^\//},(t)=>{let r=ee(t.path);if(r){let d=S(t.importer,r,t.path);if(d)return d;if(r!==i)c.add(r);return{path:r}}return{path:t.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(t)=>{let r=M(t.importer,t.path),d=S(t.importer,r,t.path);if(d)return d;return c.add(r),{path:r}}),f.onResolve({filter:/^[@~]\//},(t)=>{let r=h.resolve(e,t.path.slice(2)),d=[r,`${r}.ts`,`${r}.tsx`,`${r}.js`,`${r}.mjs`,`${r}.jsx`,h.join(r,"index.ts"),h.join(r,"index.tsx"),h.join(r,"index.js"),h.join(r,"index.mjs")];for(let E of d)if(v.existsSync(E)&&v.statSync(E,{throwIfNoEntry:!1})?.isFile()){let C=S(t.importer,E,t.path);if(C)return C;return I(`resolved ${t.path[0]}/ import:`,t.path,"\u2192",E),c.add(E),{path:E}}return console.warn(`[stx:bundler] could not resolve ${t.path[0]}/ import:`,t.path),{path:r}}),g)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(t)=>{if(t.importer!==i)return;let r=`${tn}npm:${t.path}`;return u.set(t.path,r),{path:r,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(t)=>{if(V(t.path,e,l))throw Error(`Server-only API source cannot be imported by a client script: ${t.path}`);let r=h.extname(t.path).toLowerCase(),d=r===".json"?"json":r===".tsx"?"tsx":r===".jsx"?"jsx":r===".ts"||r===".mts"||r===".cts"?"ts":"js";if(t.path!==i)c.add(t.path);return{contents:v.readFileSync(t.path,"utf8"),loader:d}})}}}var G=new Map,L=m(64),te=Symbol.for("stx.client-bundle-build-queue");function tc(e){let n=globalThis,c=(n[te]??Promise.resolve()).then(e,e);return n[te]=c.then(()=>{return},()=>{return}),c}async function vt(e,n,i={}){let c=i.projectRoot||process.cwd(),g=(await o(c)).serverApi,u=i.minify??!1,l=i.externalizeUserModules??!0,S=i.expose?.length?[...new Set(i.expose)].sort():void 0,M=i.cacheDir||a(c,"bundle-cache"),f=new Bun.CryptoHasher("md5");f.update(`${pe}\x00${je()}\x00${JSON.stringify(g??!1)}\x00${l?"registry":"inline"}\x00${S?S.join(","):"*"}\x00${e}\x00${n}`);let t=f.digest("hex").slice(0,12),r=h.join(M,`${t}.js`),d=L.get(r);if(d){if(rn(d.files)&&d.files.every((N)=>!V(N.path,c,g))){I("memo hit:",t);let N=d.files.map((B)=>B.path);return X(n,N),i.collectInputs?.push(...N),d.code}L.delete(r),I("memo invalidated by dep change:",t)}let E=h.join(M,`${t}.deps.json`),C=Bun.file(r);if(await C.exists()){let N=Bun.file(E),B=!1,R=null;if(await N.exists())try{let O=JSON.parse(await N.text());if(O.metadataVersion!==ne||!Array.isArray(O.files))B=!1;else R=O.files,B=!0;if(R&&(!rn(R)||R.some((D)=>V(D.path,c,g))))B=!1}catch{B=!1}if(B){if(I("cache hit:",t),R)X(n,R.map((D)=>D.path)),i.collectInputs?.push(...R.map((D)=>D.path));let O=await C.text();if(R)L.set(r,{code:O,files:R});return O}I("cache invalidated by dep change:",t)}let _=G.get(t);if(_){let N=await _;if(i.collectInputs)i.collectInputs.push(...(L.get(r)?.files??[]).map((B)=>B.path));return N}let z=tc(()=>$e(e,n,{projectRoot:c,minify:u,cacheDir:M,hash:t,cachePath:r,depsPath:E,collectInputs:i.collectInputs,externalizeUserModules:l,serverApi:g,expose:S,throwOnFailure:i.throwOnFailure}));G.set(t,z);try{return await z}finally{G.delete(t)}}var xe=0;function nc(e){return`${e}-${process.pid}-${++xe}`}async function $e(e,n,i){let{projectRoot:c,minify:g,cacheDir:u,hash:l,cachePath:S,depsPath:M,externalizeUserModules:f}=i,t=a(c,"bundle-tmp"),r=nc(l),d=h.join(t,`${r}.ts`),E=h.join(t,"out",r);v.mkdirSync(t,{recursive:!0}),v.mkdirSync(E,{recursive:!0});let C=h.dirname(n),_=new Set,z=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,N=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,B=s(e),{depths:R,balanced:O}=ve(B),D=(j)=>!O||R[j]===0,y;while((y=z.exec(B))!==null){if(y[1])continue;if(!D(y.index))continue;if(y[2])y[2].split(",").forEach((j)=>{let p=we(j);if(p)_.add(p)});else if(y[3])_.add(y[3])}while((y=N.exec(B))!==null){if(y[1])continue;if(!D(y.index))continue;_.add(y[2])}let se=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((y=se.exec(B))!==null){if(!D(y.index))continue;let j=/^\s*['"]([^'"]+)['"]/.exec(e.slice(y.index+y[0].length))?.[1];if(j&&H.some((p)=>p.test(j)))continue;if(y[1])_.add(y[1]);if(y[2])_.add(y[2]);for(let p of(y[3]??"").split(",")){let b=p.trim();if(!b||/^type\s/.test(b))continue;let U=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(U)_.add(U)}}for(let j of B.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let p of j[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(p)?.[1]??/^\s*(\w+)\s*$/.exec(p)?.[1];if(b)_.delete(b)}let ie=_.size>0?`
3
3
  export { ${[..._].join(", ")} }`:"";await Bun.write(d,e+ie),I("bundling:",l,"from:",h.basename(n));let Y=new Set,Q=new Map;try{let j=await Bun.build({entrypoints:[d],outdir:E,target:"browser",format:"esm",minify:g?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[he(c,C,d,Y,f,Q,i.serverApi)],define:{"process.env.NODE_ENV":g?'"production"':'"development"',...w()},root:c});if(!j.success){let F=j.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${h.basename(n)}`,k=nn(j.logs,n||void 0);if(console.warn("[stx:bundler] build failed:",F),Uo(n||"",F,k),i.throwOnFailure||Vo()==="error")throw Error(F);return e}let p="";for(let x of j.outputs){p=await x.text();break}let b=[];for(let x of p.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let F of x[1].split(",")){let k=F.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k){b.push([k[2],k[1]]);continue}let T=F.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))b.push([T,T])}if(i.expose){let x=new Set(i.expose);for(let F=b.length-1;F>=0;F--)if(!x.has(b[F][0]))b.splice(F,1)}let U=[];p=ec(Qa(p,Q),U);let oe=p.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(p=p.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),g&&p)try{p=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(p)}catch{}let K=`__stxBundle_${l}`,le=b.map(([x,F])=>`${JSON.stringify(x)}: ${F}`).join(", "),ue=b.map(([x])=>`var ${x} = undefined;`).join(`
4
4
  `),de=b.map(([x])=>`${x} = ${K}[${JSON.stringify(x)}];`).join(`
5
5
  `);if(p=`${oe.join(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kt,ys,gi,Ac}from"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Ac as declareBareLoopHead,kt as parseLoopBinding,gi as processLoops,ys as reportDeferredLoopWarnings};
2
+ import{kt,ys,gi,Ac}from"./chunk-g3gtxcc3.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-66yp3ryj.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Ac as declareBareLoopHead,kt as parseLoopBinding,gi as processLoops,ys as reportDeferredLoopWarnings};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Me,V}from"./chunk-tqnh98j7.js";import{Do}from"./chunk-q1xay7e8.js";import{u}from"./chunk-cg8hg6cs.js";var Cd=`
2
+ import{Me,V}from"./chunk-tqnh98j7.js";import{Do}from"./chunk-tyrdwvse.js";import{u}from"./chunk-cg8hg6cs.js";var Cd=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import{J}from"./chunk-kvmg6r89.js";import{ue,C}from"./chunk-e124cgb6.js";import{Ei}from"./chunk-dyreg5df.js";import{a}from"./chunk-4cmqjmqr.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 xt(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 Kr(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}=J(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 Xr(s,l,o={}){let i=xt(s,o);await Kr(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,...J(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 Jr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Od(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=xt(s,o);return await Kr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=xt(s,o);await Kr(s,t);let{loadStxConfig:e}=await import("./chunk-bqg1d720.js"),p=C((await e(s)).runtimeConfig);return await ue(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,...J(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 Jr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Od(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=xt(s,o);return await Kr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=xt(s,o);await Kr(s,t);let{loadStxConfig:e}=await import("./chunk-se734zc5.js"),p=C((await e(s)).runtimeConfig);return await ue(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 Yr(s,l,o){if(Ei(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{xt,Kr,Xr,Jr,Od,Yr};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{gd,Co,Ha,md,hd,yd,bd,wd,Ua,Va,vd,xd,Sd,kd}from"./chunk-bzvmtger.js";import"./chunk-4wwpxt4z.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-bngcrt1x.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Ha as SUSPENSE_RESOLVER_RUNTIME,Co as buildSuspenseResolveScript,wd as createStreamRenderer,yd as extractStreamBoundaries,kd as generateHydrationRuntime,Va as islandDirective,xd as processSectionDirectives,hd as processStreamDirectives,vd as registerStreamingDirectives,md as renderStreamingPage,gd as streamTemplate,bd as streamTemplateSimple,Sd as streamToResponse,Ua as streamingSuspenseDirective};
2
+ import{gd,Co,Ha,md,hd,yd,bd,wd,Ua,Va,vd,xd,Sd,kd}from"./chunk-wcbxh9h9.js";import"./chunk-g3gtxcc3.js";import"./chunk-1b50m7e7.js";import"./chunk-ec8k75ep.js";import"./chunk-dyreg5df.js";import"./chunk-66yp3ryj.js";import"./chunk-e124cgb6.js";import"./chunk-jmvp99ay.js";import"./chunk-j2erwdgt.js";import"./chunk-a5kaw8sc.js";import"./chunk-6v1gwdbv.js";import"./chunk-r4199q6x.js";import"./chunk-kvmg6r89.js";import"./chunk-1xgs9gd5.js";export{Ha as SUSPENSE_RESOLVER_RUNTIME,Co as buildSuspenseResolveScript,wd as createStreamRenderer,yd as extractStreamBoundaries,kd as generateHydrationRuntime,Va as islandDirective,xd as processSectionDirectives,hd as processStreamDirectives,vd as registerStreamingDirectives,md as renderStreamingPage,gd as streamTemplate,bd as streamTemplateSimple,Sd as streamToResponse,Ua as streamingSuspenseDirective};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{p,c}from"./chunk-a5kaw8sc.js";import{b}from"./chunk-4wwpxt4z.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=x(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let l=i.lastIndexOf(u);if(l!==-1)i.splice(l);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),h=g||w.has(u)?-1:N(t,u,s);if(h===-1)o.push({start:n,end:s,slotName:l,element:m}),e=s;else o.push({start:n,end:h,slotName:l,element:m+t.slice(s,h)}),e=h;continue}if(!g&&!w.has(u)){if(i.push(u),u==="script"||u==="style"){let l=t.toLowerCase().indexOf(`</${u}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let l=i.lastIndexOf(g);if(l!==-1)i.splice(l);e=s;continue}if(g==="template"&&i.length===0){let l=a.match(r);if(l){let m=y(t,s);if(m!==-1){let h=l[1]||l[2]||l[3];o.push({start:n,end:m,slotName:h,content:t.slice(s,m-11).trim(),propsBinding:l[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!w.has(g)){if(i.push(g),g==="script"||g==="style"){let l=t.toLowerCase().indexOf(`</${g}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function pa(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function _l(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function fa(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((l)=>l.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return b(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return c(t,Object.keys(o))(...Object.values(o))}catch{return}}async function ga(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",l=f||"",m={},h=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,S;while((S=h.exec(l))!==null){let E=S[1],R=S[2];m[E]=k(R,i)}return await fa(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function Tl(t){let o=pa(t);return{defaultSlot:o.default,namedSlots:o.named}}async function $l(t,o,i,r){return await ga(t,{default:o,named:i},r)}
2
+ import{p,c}from"./chunk-a5kaw8sc.js";import{b}from"./chunk-g3gtxcc3.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=x(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let l=i.lastIndexOf(u);if(l!==-1)i.splice(l);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),h=g||w.has(u)?-1:N(t,u,s);if(h===-1)o.push({start:n,end:s,slotName:l,element:m}),e=s;else o.push({start:n,end:h,slotName:l,element:m+t.slice(s,h)}),e=h;continue}if(!g&&!w.has(u)){if(i.push(u),u==="script"||u==="style"){let l=t.toLowerCase().indexOf(`</${u}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let l=i.lastIndexOf(g);if(l!==-1)i.splice(l);e=s;continue}if(g==="template"&&i.length===0){let l=a.match(r);if(l){let m=y(t,s);if(m!==-1){let h=l[1]||l[2]||l[3];o.push({start:n,end:m,slotName:h,content:t.slice(s,m-11).trim(),propsBinding:l[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!w.has(g)){if(i.push(g),g==="script"||g==="style"){let l=t.toLowerCase().indexOf(`</${g}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function pa(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function _l(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function fa(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((l)=>l.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return b(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return c(t,Object.keys(o))(...Object.values(o))}catch{return}}async function ga(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",l=f||"",m={},h=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,S;while((S=h.exec(l))!==null){let E=S[1],R=S[2];m[E]=k(R,i)}return await fa(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function Tl(t){let o=pa(t);return{defaultSlot:o.default,namedSlots:o.named}}async function $l(t,o,i,r){return await ga(t,{default:o,named:i},r)}
3
3
  export{pa,_l,fa,ga,Tl,$l};