@stacksjs/stx 0.2.869 → 0.2.870

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 (80) hide show
  1. package/dist/{chunk-05dtat6q.js → chunk-04f6r2kh.js} +1 -1
  2. package/dist/{chunk-7vc8b7c5.js → chunk-0jchm9gg.js} +1 -1
  3. package/dist/{chunk-5qk506kn.js → chunk-12sk3dtm.js} +1 -1
  4. package/dist/{chunk-05qpze12.js → chunk-1637r8fg.js} +1 -1
  5. package/dist/{chunk-z2t6f4gt.js → chunk-3asy7ev5.js} +1 -1
  6. package/dist/{chunk-akv760py.js → chunk-3v7xht2q.js} +1 -1
  7. package/dist/{chunk-wcq7a5pv.js → chunk-4t5t33yj.js} +2 -2
  8. package/dist/chunk-79sr2kxg.js +2 -0
  9. package/dist/{chunk-bfww6qxt.js → chunk-7d6jq5j8.js} +1 -1
  10. package/dist/{chunk-f3d1y318.js → chunk-7wae4311.js} +3 -3
  11. package/dist/{chunk-vzq77h80.js → chunk-81n2s24z.js} +1 -1
  12. package/dist/chunk-8cf6995c.js +2 -0
  13. package/dist/chunk-8cgn4re9.js +2 -0
  14. package/dist/{chunk-szfh1sg3.js → chunk-94e6kmjm.js} +1 -1
  15. package/dist/{chunk-2wa1keyw.js → chunk-9ffvh6cr.js} +1 -1
  16. package/dist/chunk-aa6ztwdq.js +2 -0
  17. package/dist/chunk-bz1jgrx8.js +2 -0
  18. package/dist/{chunk-j148k8rf.js → chunk-ca9x39p1.js} +1 -1
  19. package/dist/{chunk-73vtvzb1.js → chunk-cbpxd3qa.js} +1 -1
  20. package/dist/{chunk-xtcba3r1.js → chunk-cwmfxbhz.js} +1 -1
  21. package/dist/{chunk-9rjr7hvf.js → chunk-d4zcwtna.js} +1 -1
  22. package/dist/{chunk-k4dcnc4e.js → chunk-dg4zxpbq.js} +1 -1
  23. package/dist/{chunk-cvpbgf6h.js → chunk-drdr0a53.js} +1 -1
  24. package/dist/{chunk-ajy9tjct.js → chunk-dwqjrbse.js} +2 -2
  25. package/dist/{chunk-wxggf5aq.js → chunk-eh1rdapx.js} +1 -1
  26. package/dist/{chunk-jsyrp1n2.js → chunk-fcvgf88g.js} +1 -1
  27. package/dist/{chunk-gxq3jnkb.js → chunk-gesktj4m.js} +1 -1
  28. package/dist/{chunk-qqvj5zra.js → chunk-h0nxd9xg.js} +1 -1
  29. package/dist/{chunk-kgh1xsfe.js → chunk-hze3158c.js} +6 -6
  30. package/dist/{chunk-1t8tkryw.js → chunk-jksjr12b.js} +1 -1
  31. package/dist/chunk-khe30jmk.js +3 -0
  32. package/dist/{chunk-zfj8rfv2.js → chunk-m1a3a32y.js} +1 -1
  33. package/dist/{chunk-xsbaha1z.js → chunk-mwxehpse.js} +1 -1
  34. package/dist/{chunk-81kk8dnr.js → chunk-n7w8n327.js} +1 -1
  35. package/dist/{chunk-3eqa6hnx.js → chunk-ndrgek64.js} +1 -1
  36. package/dist/{chunk-9mkv1se7.js → chunk-nkwj7eq3.js} +1 -1
  37. package/dist/{chunk-swp254eb.js → chunk-nxecjev1.js} +1 -1
  38. package/dist/{chunk-h2r54207.js → chunk-pdpmtmfj.js} +4 -4
  39. package/dist/{chunk-za61jaep.js → chunk-pfr3cazq.js} +2 -2
  40. package/dist/{chunk-gj16gta9.js → chunk-q58f5wk2.js} +4 -4
  41. package/dist/{chunk-hvh7v5bx.js → chunk-qm0qn2xa.js} +4 -4
  42. package/dist/{chunk-nqz4es8a.js → chunk-qmr5xsjj.js} +1 -1
  43. package/dist/{chunk-0snga2v8.js → chunk-qxxvaxee.js} +1 -1
  44. package/dist/{chunk-gk8472hq.js → chunk-rt55f47q.js} +1 -1
  45. package/dist/chunk-s2a9vfdg.js +2 -0
  46. package/dist/{chunk-mbp7j1a7.js → chunk-sb3dx4dd.js} +1 -1
  47. package/dist/{chunk-k3qh0esd.js → chunk-sew1z7cv.js} +2 -2
  48. package/dist/{chunk-r3eezdg4.js → chunk-swzxhkh2.js} +5 -5
  49. package/dist/{chunk-5f9z82xp.js → chunk-t5ekex4s.js} +2 -2
  50. package/dist/chunk-tg7kt56m.js +2 -0
  51. package/dist/chunk-ttr8ay8h.js +2 -0
  52. package/dist/{chunk-p3yesft1.js → chunk-tv61s6fc.js} +1 -1
  53. package/dist/{chunk-h8h97bcc.js → chunk-w1rrfj39.js} +1 -1
  54. package/dist/{chunk-fzz251r8.js → chunk-wb7s2cnb.js} +1 -1
  55. package/dist/{chunk-wrgaxvxy.js → chunk-wk188ph7.js} +1 -1
  56. package/dist/{chunk-8veysx0v.js → chunk-xb34eyne.js} +1 -1
  57. package/dist/{chunk-d2m57nd1.js → chunk-xr3x6wk6.js} +1 -1
  58. package/dist/chunk-y0dee635.js +2 -0
  59. package/dist/{chunk-095cn3p0.js → chunk-y0msz738.js} +2 -2
  60. package/dist/{chunk-tz7b6fdz.js → chunk-y1cvab1b.js} +1 -1
  61. package/dist/{chunk-r53eeyhv.js → chunk-z8x86cr7.js} +1 -1
  62. package/dist/{chunk-9fk02w6v.js → chunk-zf9n3esr.js} +1 -1
  63. package/dist/{chunk-tdd3765y.js → chunk-zfq2vvex.js} +4 -4
  64. package/dist/{chunk-s6fe2wp6.js → chunk-zpgj4asv.js} +1 -1
  65. package/dist/cli.js +7 -7
  66. package/dist/craft-entry.js +1 -1
  67. package/dist/craft.js +1 -1
  68. package/dist/pwa.js +1 -1
  69. package/dist/ssg.js +2 -2
  70. package/package.json +5 -5
  71. package/dist/chunk-0xqefkqr.js +0 -2
  72. package/dist/chunk-4math14x.js +0 -2
  73. package/dist/chunk-5debppk8.js +0 -2
  74. package/dist/chunk-a9y9ghm2.js +0 -2
  75. package/dist/chunk-ac5sa72c.js +0 -2
  76. package/dist/chunk-bv6rx5w4.js +0 -2
  77. package/dist/chunk-f64wbr0j.js +0 -2
  78. package/dist/chunk-kdat1ht1.js +0 -3
  79. package/dist/chunk-nrpqrqqe.js +0 -2
  80. package/dist/chunk-ympa56f9.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Nf,Df,xe,Mf,pc,cn,ln,Fh,fc,un,ir,Lf,jf,Bf,ds,Ff,zf,gc,dn,Hf,pn,mc,zh}from"./chunk-9fk02w6v.js";import"./chunk-xsbaha1z.js";import"./chunk-9zrvh3pz.js";import"./chunk-095cn3p0.js";import"./chunk-mbp7j1a7.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-sbvkk4cn.js";import"./chunk-dy7vqv1x.js";import"./chunk-kgh1xsfe.js";import"./chunk-h8h97bcc.js";import"./chunk-60yppcbb.js";import"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ir as MODULE_SPECIFIER_PREFIX,gc as assertBundleBuildCanSettle,Nf as bundleCacheDir,Df as bundleCacheEntryLimit,zh as bundleClientEntriesSplit,pn as bundleClientScript,ln as clearBundleFailures,xe as clientBundleDependencies,cn as getBundleFailures,un as hasUserImports,zf as isWithinBundlerCallback,dn as moduleSubstitutionKey,jf as normalizeRegistrySpecifiers,Hf as queueClientBundleBuild,pc as recordBundleFailure,Lf as registryIdForPath,fc as resolveBundlerFallback,Bf as rewriteRegistryImports,Fh as setBundlerFallbackMode,Mf as shouldLogBundlerDiagnostics,mc as tempBuildName,ds as withModuleSubstitutes,Ff as withinBundlerCallback};
2
+ import{Nf,Df,xe,Mf,pc,cn,ln,Fh,fc,un,ir,Lf,jf,Bf,ds,Ff,zf,gc,dn,Hf,pn,mc,zh}from"./chunk-zf9n3esr.js";import"./chunk-mwxehpse.js";import"./chunk-9zrvh3pz.js";import"./chunk-y0msz738.js";import"./chunk-sb3dx4dd.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-sbvkk4cn.js";import"./chunk-dy7vqv1x.js";import"./chunk-hze3158c.js";import"./chunk-w1rrfj39.js";import"./chunk-60yppcbb.js";import"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ir as MODULE_SPECIFIER_PREFIX,gc as assertBundleBuildCanSettle,Nf as bundleCacheDir,Df as bundleCacheEntryLimit,zh as bundleClientEntriesSplit,pn as bundleClientScript,ln as clearBundleFailures,xe as clientBundleDependencies,cn as getBundleFailures,un as hasUserImports,zf as isWithinBundlerCallback,dn as moduleSubstitutionKey,jf as normalizeRegistrySpecifiers,Hf as queueClientBundleBuild,pc as recordBundleFailure,Lf as registryIdForPath,fc as resolveBundlerFallback,Bf as rewriteRegistryImports,Fh as setBundlerFallbackMode,Mf as shouldLogBundlerDiagnostics,mc as tempBuildName,ds as withModuleSubstitutes,Ff as withinBundlerCallback};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jh,Yh,Xf,bs}from"./chunk-r53eeyhv.js";import"./chunk-kdat1ht1.js";import"./chunk-hvx6j4a2.js";import"./chunk-311mrz2n.js";import{Ar}from"./chunk-kgh1xsfe.js";import"./chunk-h8h97bcc.js";import"./chunk-60yppcbb.js";import{ut}from"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ut as freeIdentifiers,bs as processComponents,Xf as processESImports,Ar as rendersAsElement,Jh as resetMarginStackWarnings,Yh as resetTemplateLoopWarnings};
2
+ import{Jh,Yh,Xf,bs}from"./chunk-z8x86cr7.js";import"./chunk-khe30jmk.js";import"./chunk-hvx6j4a2.js";import"./chunk-311mrz2n.js";import{Ar}from"./chunk-hze3158c.js";import"./chunk-w1rrfj39.js";import"./chunk-60yppcbb.js";import{ut}from"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ut as freeIdentifiers,bs as processComponents,Xf as processESImports,Ar as rendersAsElement,Jh as resetMarginStackWarnings,Yh as resetTemplateLoopWarnings};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Le,T,ne}from"./chunk-kgh1xsfe.js";import{C}from"./chunk-qjey0jk6.js";import{N,On}from"./chunk-farh4p7f.js";import{a}from"./chunk-095cn3p0.js";import{xe,un,dn,pn}from"./chunk-9fk02w6v.js";import{Ct}from"./chunk-k3qh0esd.js";import{xt,Gn,nn,ge}from"./chunk-gcsy3z1e.js";import{A,In}from"./chunk-rpep1ve3.js";import v from"fs";import b from"path";import x from"process";function U(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=A()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${dn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return ge(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>xe(l))])],f=xt(i()),u=nn(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return ge(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=ne({loader:"ts",target:"browser",define:T()});for(let l of p)try{let c=await Bun.file(l).text(),k=b.basename(l,".ts"),_=new Set;U(c,_);let y=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((I)=>I[2]),E=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(un(c))c=await pn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=Ct(c),c=N(c),c=On(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:k,ids:y.length===E?y:[],declared:_,code:`// Store: ${k}
2
+ import{Le,T,ne}from"./chunk-hze3158c.js";import{C}from"./chunk-qjey0jk6.js";import{N,On}from"./chunk-farh4p7f.js";import{a}from"./chunk-y0msz738.js";import{xe,un,dn,pn}from"./chunk-zf9n3esr.js";import{Ct}from"./chunk-sew1z7cv.js";import{xt,Gn,nn,ge}from"./chunk-gcsy3z1e.js";import{A,In}from"./chunk-rpep1ve3.js";import v from"fs";import b from"path";import x from"process";function U(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=A()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${dn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return ge(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>xe(l))])],f=xt(i()),u=nn(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return ge(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=ne({loader:"ts",target:"browser",define:T()});for(let l of p)try{let c=await Bun.file(l).text(),k=b.basename(l,".ts"),_=new Set;U(c,_);let y=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((I)=>I[2]),E=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(un(c))c=await pn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=Ct(c),c=N(c),c=On(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:k,ids:y.length===E?y:[],declared:_,code:`// Store: ${k}
3
3
  ${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return ge(h,t,f,{chunks:[]}),null;f=xt(i());let S={chunks:g};return ge(h,t,f,S),S}function R(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
4
4
 
5
5
  `),n=`;(function(){
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{wm}from"./chunk-ca9x39p1.js";import"./chunk-7wae4311.js";import"./chunk-mnx6njd4.js";import"./chunk-12sk3dtm.js";import"./chunk-mwxehpse.js";import"./chunk-zfq2vvex.js";import"./chunk-pfr3cazq.js";import"./chunk-pdpmtmfj.js";import"./chunk-q1wxgw5s.js";import"./chunk-z8x86cr7.js";import"./chunk-khe30jmk.js";import"./chunk-wk188ph7.js";import"./chunk-hvx6j4a2.js";import"./chunk-sew1z7cv.js";import"./chunk-q58f5wk2.js";import"./chunk-311mrz2n.js";import"./chunk-nkwj7eq3.js";import"./chunk-y0msz738.js";import"./chunk-sb3dx4dd.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-sbvkk4cn.js";import"./chunk-dy7vqv1x.js";import"./chunk-hze3158c.js";import"./chunk-w1rrfj39.js";import"./chunk-60yppcbb.js";import"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{wm as buildForProduction};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{O,t,u}from"./chunk-0tyyad6q.js";import{re}from"./chunk-kgh1xsfe.js";import{si}from"./chunk-tnp2ta5q.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...T,...s.i18n}.cache&&v[e]){let r=v[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=C(e,s).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function C(e,s){let i={...T,...s.i18n},n=E.isAbsolute(i.translationsDir)?i.translationsDir:E.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:ee(i.format)}):await Y(e,i,n);if(o===void 0){let c=e!==i.defaultLocale?await C(i.defaultLocale,s):{};if(i.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}let l=o;if(i.cache)v[e]={translations:l,loadedAt:Date.now(),locale:e};return l}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return C(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=E.join(i,`${e}${Z(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return Q(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function Q(e){let s={},i=e.split(`
2
+ import{O,t,u}from"./chunk-0tyyad6q.js";import{re}from"./chunk-hze3158c.js";import{si}from"./chunk-tnp2ta5q.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...T,...s.i18n}.cache&&v[e]){let r=v[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=C(e,s).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function C(e,s){let i={...T,...s.i18n},n=E.isAbsolute(i.translationsDir)?i.translationsDir:E.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:ee(i.format)}):await Y(e,i,n);if(o===void 0){let c=e!==i.defaultLocale?await C(i.defaultLocale,s):{};if(i.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}let l=o;if(i.cache)v[e]={translations:l,loadedAt:Date.now(),locale:e};return l}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return C(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=E.join(i,`${e}${Z(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return Q(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function Q(e){let s={},i=e.split(`
3
3
  `),n=[{obj:s,indent:-1}];for(let r of i){let o=r.replace(/#.*$/,"").trimEnd();if(!o.trim())continue;let l=o.search(/\S/);if(l===-1)continue;while(n.length>1&&n[n.length-1].indent>=l)n.pop();let c=n[n.length-1].obj,a=o.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(a){let[,,g,p]=a,f=g.trim(),m=p.trim();if(m==="")c[f]={},n.push({obj:c[f],indent:l});else c[f]=X(m)}}return s}function X(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let s=e.toLowerCase();if(s==="true"||s==="yes")return!0;if(s==="false"||s==="no")return!1;if(s==="null"||s==="~")return null;let i=Number(e);if(!Number.isNaN(i)&&e!=="")return i;return e}function ee(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function te(e,s){return G(e,s)}function ne(e,s){for(let i of e){let n=i.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let l=Number.parseInt(r[1],10);if(s===l)return r[2];continue}let o=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(o){let l=Number.parseInt(o[1],10),c=o[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(o[2],10);if(s>=l&&s<=c)return o[3];continue}}if(e.length===2)return s===1?e[0].trim():e[1].trim();if(s<e.length)return e[s].trim();return e[e.length-1].trim()}function ie(e,s={}){return j(e,s)}function j(e,s){let i="",n=0;while(n<e.length)if(e[n]==="{"){let r=se(e,n);if(r===-1){i+=e[n],n++;continue}let o=e.slice(n+1,r);i+=ae(o,s),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")i+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")i+=e[n+1],n+=2;else i+=e[n],n++;else i+=e[n],n++;return i}function se(e,s){let i=0;for(let n=s;n<e.length;n++)if(e[n]==="{")i++;else if(e[n]==="}"){if(i--,i===0)return n}return-1}function ae(e,s){let i=oe(e);if(i.length===0)return`{${e}}`;let n=i[0].trim(),r=s[n];if(i.length===1)return r!==void 0?String(r):`{${n}}`;switch(i[1].trim().toLowerCase()){case"plural":return le(r,i.slice(2).join(","),s);case"select":return ue(r,i.slice(2).join(","));case"selectordinal":return de(r,i.slice(2).join(","));case"number":return pe(r,i[2]?.trim());case"date":return fe(r,i[2]?.trim());case"time":return me(r,i[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function oe(e){let s=[],i="",n=0;for(let r=0;r<e.length;r++){let o=e[r];if(o==="{")n++,i+=o;else if(o==="}")n--,i+=o;else if(o===","&&n===0)s.push(i),i="";else i+=o}if(i)s.push(i);return s}function le(e,s,i){let n=Number(e)||0,r=P(s),o=`=${n}`;if(r[o])return R(r[o],n,i);let l=ce(n);if(r[l])return R(r[l],n,i);if(r.other)return R(r.other,n,i);return String(n)}function R(e,s,i){let n=e.replace(/#/g,String(s));return j(n,i)}function ce(e){let s=Math.abs(e),i=Math.floor(s),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(i===1&&n===0)return"one";return"other"}function ue(e,s){let i=String(e||""),n=P(s);if(n[i])return n[i];return n.other||String(e)}function de(e,s){let i=Number(e)||0,n=P(s),r=ge(i);if(n[r])return n[r].replace(/#/g,String(i));if(n.other)return n.other.replace(/#/g,String(i));return String(i)}function ge(e){let s=Math.abs(e),i=s%10,n=s%100;if(i===1&&n!==11)return"one";if(i===2&&n!==12)return"two";if(i===3&&n!==13)return"few";return"other"}function P(e){let s={},i=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=i.exec(e);while(n!==null)s[n[1]]=n[2],n=i.exec(e);return s}function pe(e,s){let i=Number(e);if(Number.isNaN(i))return String(e);switch(s){case"integer":return Math.floor(i).toLocaleString();case"percent":return`${(i*100).toFixed(0)}%`;case"currency":return i.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return i.toLocaleString()}}function fe(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return i.toLocaleDateString(void 0,n)}function me(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return i.toLocaleTimeString(void 0,n)}function be(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function N(e,s,i=!0,n={}){let r=e.split("."),o=s;for(let c of r){if(o===void 0||o===null)break;o=o[c]}if(o===void 0||o===null)return i?e:"";let l=String(o);if(be(l))return ie(l,n);if(l.includes("|")&&"count"in n){let c=Number(n.count),a=l.split("|");l=ne(a,c)}for(let[c,a]of Object.entries(n)){let g=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=l.replace(new RegExp(`:${g}`,"g"),()=>String(a))}return l}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),he=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function q(e){if(!e)return"ltr";let s=e.trim().toLowerCase().replace(/_/g,"-").split("-"),i=s[0];if(!i)return"ltr";let n=s[1]?.length===4?s[1]:void 0;if(n)return he.has(n)?"rtl":"ltr";if(s.length>1&&D.has(`${i}-${s[1]}`))return"rtl";return D.has(i)?"rtl":"ltr"}async function Rc(e,s,i,n){let r=e,o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,l={...T,...n.i18n},c=await te(l.locale,n);s.__translations=c,s.__locale=l.locale,s.__i18nConfig=l,r=await F(r,o,async(p,f,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>O(m,s)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}let y=N(f,c,l.fallbackToKey,b);return y?re(r,h,y,!1,p.length):w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return u("Translate",`Error in @translate('${f}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let a=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let p=[...r.matchAll(a)];console.warn(`Found ${p.length} @translate matches`),p.forEach((f,m)=>console.warn(`Match ${m}: ${f[0]}, Key: ${f[1]}, Params: ${f[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(p,f,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>O(m,s)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return re(r,w,N(f,c,l.fallbackToKey,h),!1,p.length)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return u("Translate",`Error in @translate('${f}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,s,i){let n=[];return e.replace(s,(o,...l)=>{let c=i(o,...l).then((a)=>({match:o,replacement:a}));return n.push(c),o}),(await Promise.all(n)).reduce((o,{match:l,replacement:c})=>o.replace(l,()=>c),e)}function _(e,s){if(!e||q(e)!=="rtl")return!1;return!s||s.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function I(e,s){let i=new RegExp(`\\b${s}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!i)return null;return i[2]??i[3]??i[4]??null}function Ac(e,s,i,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,c,a)=>{let p={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[c]||"Make this element accessible";return`<!-- a11y-hint: ${a||p} -->`});let o=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(o,(l,c)=>`<span class="sr-only">${c.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(l,c,a)=>`<span id="${`desc-${c}`}" class="sr-only">${a}</span>`),r}function ye(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function xe(e){let s=new Map,i=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,o,l)=>{let c=s.get(l);if(!c)c=`stx-a11y-component-${s.size}`,s.set(l,c);return`<${o}${c}`}),n=new Map([...s.entries()].map(([r,o])=>[o,r]));return{protectedSource:i,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(o,l,c)=>{let a=n.get(c);return a?`<${l}${a}`:o})}}function we(e,s){let i=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))i.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let o=/<button([^>]*)>\s*<\/button>/gi;r=o.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=o.exec(e)}let l=/<a\s+([^>]*)>\s*<\/a>/gi;r=l.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=l.exec(e)}let c=/<(input|select|textarea)\s+([^>]*)>/gi;r=c.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=c.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),U=r.index,M=e.substring(0,U),Se=e.substring(U),H=(M.match(/<label\b/gi)||[]).length,z=(M.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)i.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=c.exec(e)}let a=/<h([1-6])[^>]*>/gi,g=[];r=a.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=a.exec(e);let p=0;for(let d of g){if(p>0&&d>p+1)i.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${p} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});p=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))i.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let f=e.match(/<html\b([^>]*)>/i);if(f&&_(I(f[1],"lang"),I(f[1],"dir")))i.push({type:"missing-dir",element:f[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(I(r[1],"role"))&&!/<th\b/i.test(d))i.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))i.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)i.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))i.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))i.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return i}async function Ae(e,s){let{protectedSource:i}=xe(e);if(!ye())return we(i,s);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=i,r.querySelectorAll("img").forEach((a)=>{if(!a.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${a.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((a)=>{if(!(a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby")||a.textContent&&a.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${a.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((a)=>{let g=a.getAttribute("id"),p=g&&r.querySelector(`label[for="${g}"]`),f=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),m=a.closest("label")!==null;if(!p&&!f&&!m)n.push({type:"input-missing-label",element:`<${a.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let o=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),l=0;for(let a of o){let g=Number.parseInt(a.tagName.charAt(1));if(l>0&&g>l+1)n.push({type:"heading-skip",element:`<${a.outerHTML}>`,message:`Heading level skipped from h${l} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});l=g}let c=r.querySelector("html");if(i.includes("<html")&&c&&!c.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(c&&_(c.getAttribute("lang"),c.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((a)=>{let g=a.textContent&&a.textContent.trim().length>0,p=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),f=a.hasAttribute("title"),m=a.querySelector("img[alt]");if(!g&&!p&&!f&&!m)n.push({type:"link-missing-text",element:`<${a.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),i.includes("<nav")||i.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((a)=>{if(V(a.getAttribute("role")))return;let g=a.querySelector("caption");if(!a.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!a.hasAttribute("aria-label")&&!a.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((a)=>{let g=a.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${a.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((a)=>{if(!a.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${a.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((a)=>{if(Number.parseInt(a.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${a.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((a)=>{if(!a.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${a.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),i.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((a)=>{if(!a.hasAttribute("title")&&!a.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${s}:`,r)}return n}async function Pc(e,s={}){let i={},{recursive:n=!0,ignorePaths:r=[]}=s,o=Array.isArray(e)?e:[e],l=await si(o,{recursive:n,ignorePaths:r}),c=[];for(let a of l)try{let g=await Bun.file(a).text();if(a.endsWith("good-a11y.stx"))continue;let p=await Ae(g,a);if(c.push(a),p.length>0)i[a]=p}catch(g){console.error(`Error scanning ${a}:`,g)}return{results:i,scannedFiles:c}}var Ic={name:"a11y",handler:(e,s,i,n)=>{if(!s.length)return e;let r=s[0].replace(/['"]/g,""),o=s.length>1?s[1].replace(/['"]/g,""):"",c={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${o||c} -->${e}`},hasEndTag:!1},Oc={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
4
4
  export{Rc,Ac,Pc,Ic,Oc};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{ft,El}from"./chunk-qjey0jk6.js";import{N}from"./chunk-farh4p7f.js";import{K,Bs,o,de,J,w,Uc,zt,kn,Ve,Ue}from"./chunk-kgh1xsfe.js";import{mr}from"./chunk-gj16gta9.js";import{V}from"./chunk-4068rmzv.js";import{hn}from"./chunk-311mrz2n.js";var G=`(?:"[^"]*"|'[^']*'|[^>"'])*`,X=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,H=65536,Q=4,O=new Map;function Zh(){O.clear()}function q(e){let c=[];for(let t of w(e,J)){let n=t.token.match(/^<script\b([^>]*)>/i),s=t.token.match(/<\/script\s*>$/i);if(!n||!s)continue;let u=n[0].length,f=t.token.length-s[0].length;c.push(Object.freeze({fullMatch:t.token,attrs:n[1],body:t.token.slice(u,f),start:t.start,end:t.end}))}return c}function vs(e,c={}){let t=e.length>=H,n=t?O.get(e):void 0;if(n===void 0){if(n=q(e),t)Uc(O,Q),O.set(e,n)}let s=c.skipAttrs;if(!s)return n.slice();let u=[];for(let f of n)if(s.lastIndex=0,!s.test(f.attrs))u.push(f);return u}function Yo(e){let c=e.trim(),t=c.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(t){let s=t[1].trim(),u=t[2].trim(),{itemVar:f,indexVar:i}=z(u);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:i}}let n=c.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(n){let s=n[1].trim(),u=n[2].trim(),{itemVar:f,indexVar:i}=z(s);if(f)return{style:"in",iterable:u,itemVar:f,indexVar:i}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function z(e){let c=e.trim(),t=c.match(/^(\w+)\s*=>\s*(\w+)$/);if(t)return{itemVar:t[2],indexVar:t[1]};let n=c.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(n)return{itemVar:n[1],indexVar:n[2]||null};let s=c.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let u=c.match(/^(\w+)$/);if(u)return{itemVar:u[1],indexVar:null};return{itemVar:null,indexVar:null}}function xs(e,c){return El(e,c)}function Y(e){let c=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,t=0,n;while((n=c.exec(e))!==null){let s=n[1];if(s.startsWith("if"))t++;else if(s==="endif")t--;else if(t===0)return!0}return!1}function fr(e){let c=new Set,t=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,n=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=t.exec(e))!==null){let u=s[1],f;while((f=n.exec(u))!==null)c.add(f[1])}return c}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let c=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${G})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=w(e,(u,f)=>{c.lastIndex=f;let i=c.exec(u);if(!i||i.index!==f||!t.test(i[2]))return-1;return c.lastIndex}),s=[];for(let u of n){c.lastIndex=0;let f=c.exec(u.token);if(!f)continue;let i=f[2].match(t),p=Yo(i?.[1]??i?.[2]??""),m=[p.itemVar,p.indexVar].filter(Boolean);if(m.length===0)continue;let r=f[1],g=/\/\s*>$/.test(u.token)||P.has(r.toLowerCase())?u.end:D(e,u.start,r,u.end);if(g!==-1)s.push({start:u.start,end:g,vars:new Set(m)})}return s}var W=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function te(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function B(e,c,t,n){if(!e)return!1;let s=te(e),u=!1,f=!1,i=!1,p=/([a-zA-Z_$][\w$]*)/g,m;while((m=p.exec(s))!==null){let l=m[1];if(s.slice(0,m.index).trimEnd().endsWith("."))continue;if(W.has(l))continue;if(c.has(l)||n?.has(l))u=!0;else if(t&&l in t)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,a;while((a=r.exec(s))!==null){let l=a[1];if(s.slice(0,a.index).trimEnd().endsWith("."))continue;if(W.has(l)||t&&l in t)continue;i=!0}return(u||i)&&!f}function M(e,c,t){let n=t===void 0?` ${c}`:` ${c}="${t.replace(/"/g,"&quot;")}"`,s=e.trim(),u=s.match(X);if(u&&ne(u[3],u[1])){let[,f,i,p]=u;return`<${f}${i}${n}>${p}</${f}>`}return`<template${n}>${s}</template>`}function ne(e,c){let t=new RegExp(`<(/)?${c}(?=[\\s/>])`,"gi"),n=0,s;while((s=t.exec(e))!==null)if(s[1]){if(n--,n<0)return!1}else n++;return!0}function Zo(e,c){let t=fr(e);function n(s){let u=s,f=ee(s),i=(a)=>{let g=new Set;for(let l of f)if(a>l.start&&a<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,m,r=[];while((m=p.exec(u))!==null){let a=m.index,g=a+m[0].length,l=1,d=g;while(d<u.length&&l>0){if(u[d]==="(")l++;else if(u[d]===")")l--;d++}if(l!==0)continue;let b=u.substring(g,d-1).trim(),S=d,E=1,y=S,x=/@(if\s*\(|endif)/g;x.lastIndex=S;let h;while((h=x.exec(u))!==null)if(h[1].startsWith("if"))E++;else if(h[1]==="endif"){if(E--,E===0){y=h.index+h[0].length;break}}if(E!==0)continue;let R=u.substring(S,y-6).trim(),A;if(Y(R)){let C=hn(u.substring(a,y));if(C.length===0)continue;let T=C[0].branches.filter((_)=>_.type!=="else"),k=i(a);if(!(T.length>0&&T.every((_)=>B(_.condition,t,c,k))))continue;A=C[0].branches.map((_)=>{let L=n(_.content);if(_.type==="elseif")return M(L,"@else-if",_.condition??"");if(_.type==="else")return M(L,"@else");return M(L,"@if",_.condition??"")}).join(`
2
+ import{ft,El}from"./chunk-qjey0jk6.js";import{N}from"./chunk-farh4p7f.js";import{K,Bs,o,de,J,w,Uc,zt,kn,Ve,Ue}from"./chunk-hze3158c.js";import{mr}from"./chunk-q58f5wk2.js";import{V}from"./chunk-4068rmzv.js";import{hn}from"./chunk-311mrz2n.js";var G=`(?:"[^"]*"|'[^']*'|[^>"'])*`,X=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,H=65536,Q=4,O=new Map;function Zh(){O.clear()}function q(e){let c=[];for(let t of w(e,J)){let n=t.token.match(/^<script\b([^>]*)>/i),s=t.token.match(/<\/script\s*>$/i);if(!n||!s)continue;let u=n[0].length,f=t.token.length-s[0].length;c.push(Object.freeze({fullMatch:t.token,attrs:n[1],body:t.token.slice(u,f),start:t.start,end:t.end}))}return c}function vs(e,c={}){let t=e.length>=H,n=t?O.get(e):void 0;if(n===void 0){if(n=q(e),t)Uc(O,Q),O.set(e,n)}let s=c.skipAttrs;if(!s)return n.slice();let u=[];for(let f of n)if(s.lastIndex=0,!s.test(f.attrs))u.push(f);return u}function Yo(e){let c=e.trim(),t=c.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(t){let s=t[1].trim(),u=t[2].trim(),{itemVar:f,indexVar:i}=z(u);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:i}}let n=c.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(n){let s=n[1].trim(),u=n[2].trim(),{itemVar:f,indexVar:i}=z(s);if(f)return{style:"in",iterable:u,itemVar:f,indexVar:i}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function z(e){let c=e.trim(),t=c.match(/^(\w+)\s*=>\s*(\w+)$/);if(t)return{itemVar:t[2],indexVar:t[1]};let n=c.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(n)return{itemVar:n[1],indexVar:n[2]||null};let s=c.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let u=c.match(/^(\w+)$/);if(u)return{itemVar:u[1],indexVar:null};return{itemVar:null,indexVar:null}}function xs(e,c){return El(e,c)}function Y(e){let c=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,t=0,n;while((n=c.exec(e))!==null){let s=n[1];if(s.startsWith("if"))t++;else if(s==="endif")t--;else if(t===0)return!0}return!1}function fr(e){let c=new Set,t=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,n=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=t.exec(e))!==null){let u=s[1],f;while((f=n.exec(u))!==null)c.add(f[1])}return c}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let c=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${G})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=w(e,(u,f)=>{c.lastIndex=f;let i=c.exec(u);if(!i||i.index!==f||!t.test(i[2]))return-1;return c.lastIndex}),s=[];for(let u of n){c.lastIndex=0;let f=c.exec(u.token);if(!f)continue;let i=f[2].match(t),p=Yo(i?.[1]??i?.[2]??""),m=[p.itemVar,p.indexVar].filter(Boolean);if(m.length===0)continue;let r=f[1],g=/\/\s*>$/.test(u.token)||P.has(r.toLowerCase())?u.end:D(e,u.start,r,u.end);if(g!==-1)s.push({start:u.start,end:g,vars:new Set(m)})}return s}var W=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function te(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function B(e,c,t,n){if(!e)return!1;let s=te(e),u=!1,f=!1,i=!1,p=/([a-zA-Z_$][\w$]*)/g,m;while((m=p.exec(s))!==null){let l=m[1];if(s.slice(0,m.index).trimEnd().endsWith("."))continue;if(W.has(l))continue;if(c.has(l)||n?.has(l))u=!0;else if(t&&l in t)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,a;while((a=r.exec(s))!==null){let l=a[1];if(s.slice(0,a.index).trimEnd().endsWith("."))continue;if(W.has(l)||t&&l in t)continue;i=!0}return(u||i)&&!f}function M(e,c,t){let n=t===void 0?` ${c}`:` ${c}="${t.replace(/"/g,"&quot;")}"`,s=e.trim(),u=s.match(X);if(u&&ne(u[3],u[1])){let[,f,i,p]=u;return`<${f}${i}${n}>${p}</${f}>`}return`<template${n}>${s}</template>`}function ne(e,c){let t=new RegExp(`<(/)?${c}(?=[\\s/>])`,"gi"),n=0,s;while((s=t.exec(e))!==null)if(s[1]){if(n--,n<0)return!1}else n++;return!0}function Zo(e,c){let t=fr(e);function n(s){let u=s,f=ee(s),i=(a)=>{let g=new Set;for(let l of f)if(a>l.start&&a<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,m,r=[];while((m=p.exec(u))!==null){let a=m.index,g=a+m[0].length,l=1,d=g;while(d<u.length&&l>0){if(u[d]==="(")l++;else if(u[d]===")")l--;d++}if(l!==0)continue;let b=u.substring(g,d-1).trim(),S=d,E=1,y=S,x=/@(if\s*\(|endif)/g;x.lastIndex=S;let h;while((h=x.exec(u))!==null)if(h[1].startsWith("if"))E++;else if(h[1]==="endif"){if(E--,E===0){y=h.index+h[0].length;break}}if(E!==0)continue;let R=u.substring(S,y-6).trim(),A;if(Y(R)){let C=hn(u.substring(a,y));if(C.length===0)continue;let T=C[0].branches.filter((_)=>_.type!=="else"),k=i(a);if(!(T.length>0&&T.every((_)=>B(_.condition,t,c,k))))continue;A=C[0].branches.map((_)=>{let L=n(_.content);if(_.type==="elseif")return M(L,"@else-if",_.condition??"");if(_.type==="else")return M(L,"@else");return M(L,"@if",_.condition??"")}).join(`
3
3
  `)}else{if(!B(b,t,c,i(a)))continue;A=M(n(R),"@if",b)}r.push({start:a,end:y,replacement:A}),p.lastIndex=y}for(let a=r.length-1;a>=0;a--){let{start:g,end:l,replacement:d}=r[a];u=u.substring(0,g)+d+u.substring(l)}return u}return n(e)}function se(e){let c=e.trim();if(c==="")return;if(c==="true")return!0;if(c==="false")return!1;if(c==="null")return!1;if(c==="undefined")return!1;if(c==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(c)){let s=Number(c);return s!==0&&!Number.isNaN(s)}let t=c.match(/^'((?:\\.|[^'\\])*)'$/);if(t)return t[1].length>0;let n=c.match(/^"((?:\\.|[^"\\])*)"$/);if(n)return n[1].length>0;return}var P=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Z=/<(script|style)\b/iy,re=/<\/script/gi,ie=/<\/style/gi;function D(e,c,t,n){if(P.has(t.toLowerCase()))return n;let s=t.toLowerCase(),u=e.length,f=1,i=n;while(i<u){let p=e.indexOf("<",i);if(p===-1)return-1;if(i=p,e.startsWith("<!--",i)){let g=e.indexOf("-->",i+4);if(g===-1)return-1;i=g+3;continue}Z.lastIndex=i;let m=Z.exec(e);if(m){let g=e.indexOf(">",i);if(g===-1)return-1;if(e[g-1]==="/"){i=g+1;continue}let l=m[1].toLowerCase()==="script"?re:ie;l.lastIndex=i;let d=l.exec(e);if(d===null)return-1;let b=e.indexOf(">",d.index);if(b===-1)return-1;i=b+1;continue}if(e[i+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(i,i+64));if(!g){i++;continue}if(g[1].toLowerCase()===s){if(f--,i+=g[0].length,f===0)return i;continue}i+=g[0].length;continue}let r=/^<([a-z][\w-]*)\b/i.exec(e.slice(i,i+64));if(!r){i++;continue}let a=e.indexOf(">",i);if(a===-1)return-1;if(r[1].toLowerCase()===s){let g=e.slice(i,a+1);if(!(/\/\s*>$/.test(g)||P.has(s)))f++}i=a+1}return-1}var oe=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ce(e,c){let t=c,n=e.length;for(;;){while(t<n&&e[t]!=="<")t++;if(t>=n)return!1;if(e.startsWith("<!--",t)){let f=e.indexOf("-->",t+4);if(f===-1)return!1;t=f+3;continue}break}if(e[t+1]==="/")return!1;let s=e.indexOf(">",t);if(s===-1)return!1;let u=e.slice(t,s+1);return oe.test(u)}function Qo(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let c=[],t=/<([a-zA-Z][\w-]*)/y,n=/\s/,s=new Set([":if",":show","x-if","x-show","@if","@show"]);w(e,(r,a)=>{t.lastIndex=a;let g=t.exec(r);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=t.lastIndex,d;while(l<r.length){let b=l;while(l<r.length&&n.test(r[l]))l++;let S=l;if(r[S]==="/"){S++;while(S<r.length&&n.test(r[S]))S++}if(r[S]===">"){if(d)c.push({start:a,end:S+1,tag:g[1],...d});return-1}if(l===b)return-1;let E=l;while(l<r.length&&!n.test(r[l])&&r[l]!=="="&&r[l]!==">")l++;if(l===E)return-1;let y=r.slice(E,l);if(y.startsWith("@")&&y.includes("("))return-1;let x=l,h=l;while(h<r.length&&n.test(r[h]))h++;if(r[h]!=="="){l=x;continue}h++;while(h<r.length&&n.test(r[h]))h++;let R=r[h];if(R==='"'||R==="'"){let A=r.indexOf(R,h+1);if(A===-1)return-1;if(!d&&R==='"'&&s.has(y))d={attrName:y,attrStart:b,attrEnd:A+1,value:r.slice(h+1,A)};l=A+1}else{l=h;while(l<r.length&&!n.test(r[l])&&r[l]!==">")l++}}return-1});let u=[],f=-1;for(let r of c){let{start:a,end:g,tag:l,attrName:d,value:b}=r;if(a<f)continue;let S=se(b);if(S===void 0)continue;let x=/\/\s*>$/.test(e.slice(a,g))||P.has(l.toLowerCase())?g:D(e,a,l,g);if(x===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ce(e,x))continue;if(S===!0){let R=e.slice(a,r.attrStart)+e.slice(r.attrEnd,g);u.push({start:a,end:g,replacement:R});continue}u.push({start:a,end:x,replacement:""}),f=x}if(u.length===0)return e;u.sort((r,a)=>r.start-a.start);let i=[],p=-1;for(let r of u){if(r.start<p)continue;i.push(r),p=r.end}let m=e;for(let r=i.length-1;r>=0;r--){let{start:a,end:g,replacement:l}=i[r];m=m.substring(0,a)+l+m.substring(g)}return m}var F=[":for","@for","x-for"];function Zf(e){let c=/(\s)((?::|@|x-|v-)[\w.:-]+)\s*=\s*"([^"]*\{\{[^"]*)"/g;return e.replace(c,(t,n,s,u)=>{let f=u.replace(/'((?:[^'\\]|\\.)*)'/g,(i,p)=>{if(!p.includes("{{"))return i;return`\`${p.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{\s*([^}]+?)\s*\}\}/g,(r,a)=>`\${${a}}`)}\``});return`${n}${s}="${f}"`})}function Ss(e,c){if(!c||Object.keys(c).length===0)return e;if(!F.some((i)=>e.includes(`${i}=`)))return e;let t=fr(e);if(Array.isArray(c.__stx_client_signal_names)){for(let i of c.__stx_client_signal_names)if(typeof i==="string")t.add(i)}let n=e,s=[],u=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=u.exec(n))!==null){let[i,p,m]=f,r=f.index,a=r+i.length,g=F.map((A)=>({attr:A,m:new RegExp(`\\s${A}="([^"]*)"`).exec(m)})).find((A)=>A.m!==null);if(!g||!g.m)continue;let l=Yo(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||t.has(d)||!(d in c))continue;let b=D(n,r,p,a);if(b===-1)continue;let S=m.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),E=n.slice(a,b-`</${p}>`.length),y={...c,[l.itemVar]:void 0};if(l.indexVar)y[l.indexVar]=void 0;let x=Ss(E,y),h=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,R=p.toLowerCase()==="template"?x:`<${p}${S}>${x}</${p}>`;s.push({start:r,end:b,replacement:`@foreach(${h})${R}@endforeach`}),u.lastIndex=b}for(let i=s.length-1;i>=0;i--){let{start:p,end:m,replacement:r}=s[i];n=n.slice(0,p)+r+n.slice(m)}return n}function ks(e,c){let t=e,n=/@(for|foreach)\s*\(/g,s,u=[],f=[];while((s=n.exec(t))!==null){let i=s[1],p=s.index,m=p+s[0].length,r=1,a=m;while(a<t.length&&r>0){if(t[a]==="(")r++;else if(t[a]===")")r--;a++}if(r!==0)continue;let g=t.substring(m,a-1).trim(),l=a,d=Yo(g),b=i==="for"?"@endfor":"@endforeach",S=1,E=l,y=i==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${i}\\s*\\(|end${i})`,"g");y.lastIndex=l;let x;while((x=y.exec(t))!==null)if(x[1].startsWith(i))S++;else if(S--,S===0){E=x.index+x[0].length;break}if(S!==0)continue;let h=()=>{let v=[d.itemVar,d.indexVar].filter(Boolean);if(v.length)f.push({start:p,end:E,vars:v})};if(d.iterable){let v=d.iterable.trim();if(v.startsWith("[")||v.startsWith("{")||v.startsWith("'")||v.startsWith('"')||v.startsWith("`")||/^-?\d/.test(v)){h();continue}let I=v.split(/[.[(]/)[0].trim(),_=c?I in c:!1,L=f.some((j)=>p>j.start&&p<j.end&&j.vars.includes(I));if(I&&(_||L)){h();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let R=t.substring(l,E-b.length).trim(),A=c?{...c}:{};if(d.itemVar)delete A[d.itemVar];if(d.indexVar)delete A[d.indexVar];let C=Zf(ks(R,A)),T=C.match(X),k;if(T){let[,v,I,_]=T;k=`<${v}${I} @for="${g}">${_}</${v}>`}else k=`<template @for="${g}">${C}</template>`;u.push({start:p,end:E,replacement:k}),n.lastIndex=E}for(let i=u.length-1;i>=0;i--){let{start:p,end:m,replacement:r}=u[i];t=t.substring(0,p)+r+t.substring(m)}return t}function ae(e){let c=new Set,t=[],n=0,s=0,u=e.length,f=(r)=>{let a=n+1;while(a<u){let g=e[a];if(g==="\\"){a+=2;continue}if(g===r)return a+1;a++}return u},i=()=>{let r=n+2;while(r<u&&e[r]!==`
4
4
  `)r++;return r},p=()=>{let r=n+2;while(r<u-1){if(e[r]==="*"&&e[r+1]==="/")return r+2;r++}return u},m=(r)=>{let a=r,g=0;while(a<u){let l=e[a];if(l==="/"&&e[a+1]==="/"){let d=a+2;while(d<u&&e[d]!==`
5
- `)d++;a=d;continue}if(l==="/"&&e[a+1]==="*"){let d=a+2;while(d<u-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;a=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=a+1;while(d<u){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}a=d;continue}if(l==="("||l==="["||l==="{"){g++,a++;continue}if(l===")"||l==="]"||l==="}"){g--,a++;continue}if(l===";"&&g===0)return a+1;a++}return u};while(n<u){let r=e[n];if(r==="/"&&e[n+1]==="/"){let a=i();t.push(e.slice(n,a)),n=a;continue}if(r==="/"&&e[n+1]==="*"){let a=p();t.push(e.slice(n,a)),n=a;continue}if(r==='"'||r==="'"||r==="`"){let a=f(r);t.push(e.slice(n,a)),n=a;continue}if(r==="{"){s++,t.push(r),n++;continue}if(r==="}"){s--,t.push(r),n++;continue}if(s===0){let a=n>0?e[n-1]:"";if(a===""||/\s/.test(a)||a===";"||a==="}"||a==="{"){let l=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=m(n+l[0].length);if(c.has(d)){t.push(`/* stx: deduped const ${d} */`),n=b;continue}c.add(d),t.push(e.slice(n,b)),n=b;continue}}}t.push(r),n++}return t.join("")}var le=new Set(["script","style","html","head","meta","link","title","!doctype"]);function ue(e){let c=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${G})>`,"iy"),t=null,n=null;return w(e,(s,u)=>{c.lastIndex=u;let f=c.exec(s);if(!f)return-1;let i=f[1].toLowerCase();if(i==="script"||i==="style")return-1;let p=u+f[0].length-1;if(i==="body"&&n===null)n=p;if(t===null&&!le.has(i))t=p;return u+f[0].length}),n??t}function fe(e,c,t,n){let s=[],u=` data-stx="${n}"`,f=0,i=!1,p=(m)=>{if(t!==null&&!i&&t>=f&&t<=m)s.push(e.slice(f,t),u,e.slice(t,m)),i=!0;else s.push(e.slice(f,m))};for(let m of c){if(m.start<f)continue;p(m.start),f=m.end}return p(e.length),s.join("")}async function _s(e,c,t,n={}){let s=vs(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),u=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:i,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-nqz4es8a.js"));for(let x of s){let h=x.body;if(Ve(x.attrs))h=Ue(h);if(n.forceClientSetup||u.test(h)){f.push({content:h,start:x.start,end:x.end});continue}if(!i(h))continue;try{let R=await p(zt(h).code,c||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(u.test(R))f.push({content:h,start:x.start,end:x.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let m=`${c??""}\x00${f.map((x)=>x.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(m).toString(36).slice(0,10)}`,a=[];for(let x=0;x<f.length;x++){let h=f[x].bundled??zt(f[x].content).code;if(!f[x].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=Ct(h);let R=N(h);a.push(`// \u2500\u2500 merged signal script #${x+1} \u2500\u2500
5
+ `)d++;a=d;continue}if(l==="/"&&e[a+1]==="*"){let d=a+2;while(d<u-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;a=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=a+1;while(d<u){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}a=d;continue}if(l==="("||l==="["||l==="{"){g++,a++;continue}if(l===")"||l==="]"||l==="}"){g--,a++;continue}if(l===";"&&g===0)return a+1;a++}return u};while(n<u){let r=e[n];if(r==="/"&&e[n+1]==="/"){let a=i();t.push(e.slice(n,a)),n=a;continue}if(r==="/"&&e[n+1]==="*"){let a=p();t.push(e.slice(n,a)),n=a;continue}if(r==='"'||r==="'"||r==="`"){let a=f(r);t.push(e.slice(n,a)),n=a;continue}if(r==="{"){s++,t.push(r),n++;continue}if(r==="}"){s--,t.push(r),n++;continue}if(s===0){let a=n>0?e[n-1]:"";if(a===""||/\s/.test(a)||a===";"||a==="}"||a==="{"){let l=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=m(n+l[0].length);if(c.has(d)){t.push(`/* stx: deduped const ${d} */`),n=b;continue}c.add(d),t.push(e.slice(n,b)),n=b;continue}}}t.push(r),n++}return t.join("")}var le=new Set(["script","style","html","head","meta","link","title","!doctype"]);function ue(e){let c=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${G})>`,"iy"),t=null,n=null;return w(e,(s,u)=>{c.lastIndex=u;let f=c.exec(s);if(!f)return-1;let i=f[1].toLowerCase();if(i==="script"||i==="style")return-1;let p=u+f[0].length-1;if(i==="body"&&n===null)n=p;if(t===null&&!le.has(i))t=p;return u+f[0].length}),n??t}function fe(e,c,t,n){let s=[],u=` data-stx="${n}"`,f=0,i=!1,p=(m)=>{if(t!==null&&!i&&t>=f&&t<=m)s.push(e.slice(f,t),u,e.slice(t,m)),i=!0;else s.push(e.slice(f,m))};for(let m of c){if(m.start<f)continue;p(m.start),f=m.end}return p(e.length),s.join("")}async function _s(e,c,t,n={}){let s=vs(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),u=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:i,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-qmr5xsjj.js"));for(let x of s){let h=x.body;if(Ve(x.attrs))h=Ue(h);if(n.forceClientSetup||u.test(h)){f.push({content:h,start:x.start,end:x.end});continue}if(!i(h))continue;try{let R=await p(zt(h).code,c||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(u.test(R))f.push({content:h,start:x.start,end:x.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let m=`${c??""}\x00${f.map((x)=>x.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(m).toString(36).slice(0,10)}`,a=[];for(let x=0;x<f.length;x++){let h=f[x].bundled??zt(f[x].content).code;if(!f[x].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=Ct(h);let R=N(h);a.push(`// \u2500\u2500 merged signal script #${x+1} \u2500\u2500
6
6
  ${R}`)}let g=a.join(`
7
7
 
8
8
  `);g=ae(g);let d=K(g).split(",").map((x)=>x.trim()).filter(Boolean),b=kn(g,t),S=`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{L,vn,Bt,Ft,h,s,be,g}from"./chunk-kgh1xsfe.js";import{kt,Ne,hc,ps,zo,Ho,i}from"./chunk-tdd3765y.js";import{fe,se,Or,$e,W,Rn}from"./chunk-0tyyad6q.js";import{$t,wr,Ns,Ds,Ms,Rt,At,Pt,It,Ot,Nt,ot}from"./chunk-dy7vqv1x.js";import{$s,a,M}from"./chunk-095cn3p0.js";import{wt,en,Ae,H,wa,So,Qr,Je,va,Ye,Pe}from"./chunk-f3d1y318.js";import{hr,yr}from"./chunk-9mkv1se7.js";import{e,mn,dr,x}from"./chunk-za61jaep.js";import{tt}from"./chunk-h2r54207.js";import{Oe}from"./chunk-9zrvh3pz.js";import{Dn}from"./chunk-gxq3jnkb.js";import{Q,ke,_e}from"./chunk-gj16gta9.js";import{l}from"./chunk-46pxmpeb.js";import{Z}from"./chunk-rpep1ve3.js";import{c,f}from"./chunk-fd1bpv35.js";async function Wn(t){try{let n=await Bun.file(t).text(),r=Vn(n),p=qn(n,t),o=Kn(n,r),d=Xn(n,r);return{file:t,metrics:r,issues:p,suggestions:o,performance:d}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Vn(t){let n=t.split(`
2
+ import{L,vn,Bt,Ft,h,s,be,g}from"./chunk-hze3158c.js";import{kt,Ne,hc,ps,zo,Ho,i}from"./chunk-zfq2vvex.js";import{fe,se,Or,$e,W,Rn}from"./chunk-0tyyad6q.js";import{$t,wr,Ns,Ds,Ms,Rt,At,Pt,It,Ot,Nt,ot}from"./chunk-dy7vqv1x.js";import{$s,a,M}from"./chunk-y0msz738.js";import{wt,en,Ae,H,wa,So,Qr,Je,va,Ye,Pe}from"./chunk-7wae4311.js";import{hr,yr}from"./chunk-nkwj7eq3.js";import{e,mn,dr,x}from"./chunk-pfr3cazq.js";import{tt}from"./chunk-pdpmtmfj.js";import{Oe}from"./chunk-9zrvh3pz.js";import{Dn}from"./chunk-gesktj4m.js";import{Q,ke,_e}from"./chunk-q58f5wk2.js";import{l}from"./chunk-46pxmpeb.js";import{Z}from"./chunk-rpep1ve3.js";import{c,f}from"./chunk-fd1bpv35.js";async function Wn(t){try{let n=await Bun.file(t).text(),r=Vn(n),p=qn(n,t),o=Kn(n,r),d=Xn(n,r);return{file:t,metrics:r,issues:p,suggestions:o,performance:d}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Vn(t){let n=t.split(`
3
3
  `),r=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),o=(r?r[1]:"").split(`
4
4
  `).length,d={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};d.total=d.conditionals+d.loops+d.includes+d.custom;let u=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,m=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,y=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,b=u+m+y,w=(t.match(/<[A-Z][^>]*>/g)||[]).length,S=(t.match(/@(?:layout|extends)\(/g)||[]).length,T=0,R=0;for(let C of n)if(/@(?:if|unless|foreach|for|while|section)\b/.test(C)&&!/@end/.test(C)&&!/@else/.test(C))R++,T=Math.max(T,R);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(C))R--;let k=T>=4?3:0,v=Math.min(10,Math.ceil(d.total*0.5+b*0.1+w*0.3+(o>10?o*0.05:0)+k));return{lines:n.length,characters:t.length,directives:d,expressions:b,components:w,layouts:S,scriptLines:o,complexity:v}}function qn(t,n){let r=[],p=Yt(t,"if","endif");if(p>0)r.push({type:"error",category:"syntax",message:`Found ${p} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let o=Yt(t,"foreach","endforeach");if(o>0)r.push({type:"error",category:"syntax",message:`Found ${o} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)r.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)r.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let m=t.match(/<img[^>]*>/g);if(m){let w=m.filter((S)=>!S.includes("alt="));if(w.length>0)r.push({type:"warning",category:"accessibility",message:`Found ${w.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let y=t.split(`
5
5
  `).filter((w)=>w.length>120);if(y.length>0)r.push({type:"info",category:"maintainability",message:`Found ${y.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let b=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(b>3)r.push({type:"info",category:"maintainability",message:`Found ${b} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return r}function Kn(t,n){let r=[];if(n.complexity>7)r.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)r.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)r.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)r.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let p=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(p&&p.length>0)r.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)r.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)r.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return r}function Xn(t,n){let r=1;if(r+=n.directives.conditionals*0.1,r+=n.directives.loops*0.5,r+=n.directives.includes*2,r+=n.expressions*0.05,r+=n.components*1,n.scriptLines>10)r+=n.scriptLines*0.1;let p;if(n.expressions===0&&n.directives.total===0)p="high";else if(n.expressions<5&&n.directives.total<3)p="medium";else p="low";let o=[];if(r>10)o.push("Consider optimizing template complexity");if(p==="low"&&n.directives.total>5)o.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)o.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(r*100)/100,complexityScore:n.complexity,cacheability:p,recommendations:o}}function Yt(t,n,r){let p=t.replace(/<!--[\s\S]*?-->/g,""),o=(p.match(new RegExp(`@${n}\\b`,"g"))||[]).length,d=(p.match(new RegExp(`@${r}\\b`,"g"))||[]).length;return Math.abs(o-d)}async function ia(t=["**/*.stx"],n){let r=[],p=[];for(let d of t){let u=await Array.fromAsync(new Bun.Glob(d).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));p.push(...u.filter((m)=>m.endsWith(".stx")))}for(let d of p)try{let u=await Wn(d);r.push(u)}catch(u){console.warn(`Failed to analyze ${d}:`,u)}let o=Gn(r);return{results:r,summary:o}}function Gn(t){let n=t.length,r=t.reduce((b,w)=>b+w.metrics.lines,0),p=n>0?t.reduce((b,w)=>b+w.metrics.complexity,0)/n:0,o=t.reduce((b,w)=>b+w.issues.length,0),d={};t.forEach((b)=>{b.issues.forEach((w)=>{d[w.category]=(d[w.category]||0)+1})});let u=n>0?t.reduce((b,w)=>b+w.performance.estimatedRenderTime,0)/n:0,m=Math.max(1,Math.min(10,Math.round(10-u/2-p/2))),y=[];if(p>6)y.push("Project has high average complexity. Consider refactoring complex templates.");if(o>n*2)y.push("High number of issues detected. Run detailed analysis on individual files.");if(d.security>0)y.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:r,avgComplexity:Math.round(p*100)/100,totalIssues:o,issuesByCategory:d,performanceScore:m,recommendations:y}}import{mkdir as Jn,readFile as Yn,readdir as Qn,stat as Qt,writeFile as Zn}from"fs/promises";import Te from"path";function sn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var an=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function er(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function jt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function tr(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function nr(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function rr(t){let n=[];async function r(p){let o=await Qn(p,{withFileTypes:!0});o.sort((d,u)=>d.name.localeCompare(u.name));for(let d of o){let u=Te.join(p,d.name);if(d.isDirectory()){if(!d.name.startsWith(".")&&d.name!=="node_modules")await r(u)}else if(d.isFile()&&d.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(d.name))n.push(u)}}return await r(t),n}function or(t,n){let r=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!r)return{};let p=r[1].trim();if(!p)return{};try{return JSON.parse(p)}catch(o){throw Error(`${n}: <script component> must contain JSON metadata (${o.message})`)}}function sr(t,n){let r={},p=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let o of p){if(!/\bclient\b/i.test(o[1])||/\bcomponent\b|\bstx:component\b/i.test(o[1]))continue;let d;try{d=new Bun.Transpiler({loader:"ts"}).transformSync(o[2])}catch(y){throw Error(`${n}: failed to transpile <script client> (${y.message})`)}let u=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,m;while(m=u.exec(d)){let y=m[1];if(an.has(y))throw Error(`${n}: client ${sn(y)}`);let b=u.lastIndex,w=1,S="",T=!1,R=b;for(;R<d.length&&w>0;R++){let v=d[R];if(T){T=!1;continue}if(S){if(v==="\\")T=!0;else if(v===S)S="";continue}if(v==='"'||v==="'"||v==="`")S=v;else if(v==="{")w++;else if(v==="}")w--}if(w!==0)throw Error(`${n}: unterminated client function "${y}"`);let k=m[0].includes("async")?"async ":"";r[y]=`${k}${y}(${m[2]}) {${d.slice(b,R-1)}}`,u.lastIndex=R}}return r}function ir(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Zt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
@@ -887,7 +887,7 @@ else {
887
887
  };
888
888
  })();
889
889
  </script>
890
- `}function We(t,n,r={}){let p=Fr(n,r),o=c(t);if(o!==-1)return t.slice(0,o)+p+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${p}</html>`);return t+p}function bt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function xt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((p)=>n.endsWith(p))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var rt=null;function St(t){if(!rt)rt=new cn(t);return rt}function ct(){if(rt)rt.stop(),rt=null}import Tt from"path";var st={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},p=new Set,o=r.webComponents?.enabled?`./${Tt.relative(Tt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",d=[];if(r.webComponents?.enabled)try{let u=await $s(r,p);if(d.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(r.cache&&r.cachePath){let v=await hr(u,r);if(v){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:v,loader:"html"}}}let y=await $e(()=>Bun.file(u).text(),"",(v)=>{throw new Or(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${v.message}`)});if(!y)throw new Or(`stx file is empty: ${u}`,u);let{scriptContent:b,templateContent:w,allScripts:S}=fe.time("script-extraction",()=>{let v=y,C=L(y);if(C)v=C.content.trim();let I=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",P=[];for(let E of I){let _=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),X=B?B[1]:"";if(/\bserver\b/i.test(X))O=_;else P.push(E)}let D=v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:D,allScripts:P}}),T={__filename:u,__dirname:Tt.dirname(u),__stx:{webComponentsPath:o,builtComponents:d}};await $e(()=>h(b,T,u),void 0,(v)=>{let C=new se(`Script execution failed in ${u}: ${v.message}`,u,void 0,void 0,b.substring(0,100));if(W.log(C,{filePath:u,scriptContent:b}),r.debug)throw C});let k=await fe.timeAsync("directive-processing",async()=>await i(w,T,u,r,m));if(S.length>0){let{interpolateScriptsInTemplate:v}=await import("./chunk-qqvj5zra.js"),C=v(S.join(`
890
+ `}function We(t,n,r={}){let p=Fr(n,r),o=c(t);if(o!==-1)return t.slice(0,o)+p+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${p}</html>`);return t+p}function bt(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function xt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((p)=>n.endsWith(p))}function vt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var rt=null;function St(t){if(!rt)rt=new cn(t);return rt}function ct(){if(rt)rt.stop(),rt=null}import Tt from"path";var st={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},p=new Set,o=r.webComponents?.enabled?`./${Tt.relative(Tt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",d=[];if(r.webComponents?.enabled)try{let u=await $s(r,p);if(d.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(r.cache&&r.cachePath){let v=await hr(u,r);if(v){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:v,loader:"html"}}}let y=await $e(()=>Bun.file(u).text(),"",(v)=>{throw new Or(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${v.message}`)});if(!y)throw new Or(`stx file is empty: ${u}`,u);let{scriptContent:b,templateContent:w,allScripts:S}=fe.time("script-extraction",()=>{let v=y,C=L(y);if(C)v=C.content.trim();let I=y.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",P=[];for(let E of I){let _=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),X=B?B[1]:"";if(/\bserver\b/i.test(X))O=_;else P.push(E)}let D=v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:D,allScripts:P}}),T={__filename:u,__dirname:Tt.dirname(u),__stx:{webComponentsPath:o,builtComponents:d}};await $e(()=>h(b,T,u),void 0,(v)=>{let C=new se(`Script execution failed in ${u}: ${v.message}`,u,void 0,void 0,b.substring(0,100));if(W.log(C,{filePath:u,scriptContent:b}),r.debug)throw C});let k=await fe.timeAsync("directive-processing",async()=>await i(w,T,u,r,m));if(S.length>0){let{interpolateScriptsInTemplate:v}=await import("./chunk-h0nxd9xg.js"),C=v(S.join(`
891
891
  `),T),I=k.search(/<\/body>/i);if(I!==-1)k=k.slice(0,I)+C+`
892
892
  `+k.slice(I);else k+=`
893
893
  ${C}`}if(k=await _e(k),m.forEach((v)=>p.add(v)),r.cache&&r.cachePath){if(await yr(u,k,m,r),r.debug)console.log(`Cached template ${u} with ${m.size} dependencies`)}return{contents:k,loader:"html"}}catch(m){let y=m instanceof Error?m:new se(`Plugin processing failed: ${String(m)}`,u);if(W.log(y,{filePath:u,buildConfig:t.config}),Rn.logDetailedError(y,{filePath:u,plugin:"bun-plugin-stx"}),r.debug)console.error("stx Plugin Error:",y);let b=y,w=b.line||null,S=b.context||null;return{contents:r.debug||Z()?`<!DOCTYPE html>
@@ -950,7 +950,7 @@ ${C}`}if(k=await _e(k),m.forEach((v)=>p.add(v)),r.cache&&r.cachePath){if(await y
950
950
  <h1>Something went wrong</h1>
951
951
  <p>An internal error occurred. Please try again later.</p>
952
952
  </body>
953
- </html>`,loader:"html"}}})}};async function Kr(t,n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=he.resolve(t);if(!Fe.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Wt(m,n);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let y=l(process.cwd(),"output");Fe.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let b=null,w=async()=>{try{let _={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},B=await Bun.build({entrypoints:[m],outdir:y,plugins:[_,st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let X=B.outputs.find((ve)=>ve.path.endsWith(".html"));if(!X)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return b=await Bun.file(X.path).text(),!0}catch(_){return console.error(`${e.red}Error building stx file:${e.reset}`,_),!1}};if(!await w())return!1;let T=he.dirname(m);await mn(T);let R=r;try{if(R=await qe(r),R!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let _=n.hmrPort||R+1;d=St({wsPort:_,verbose:!1}),u=d.start(_)}let k={},v=null,C;try{let{loadStxConfig:_}=await import("./chunk-a9y9ghm2.js"),B=await _();if(C=n.stxOptions?.serverApi??B.serverApi,B?.apiRouter)v=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){k=B.apiRoutes;let X=Object.keys(k).length;if(X>0)console.log(`${e.blue}Loaded ${e.bright}${X} API route${X>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:X,loadChannels:ee}=await import("./chunk-rqa92xm4.js"),ve=B.broadcasting;await X(ve);let pe=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let Re=he.join(process.cwd(),"channels.ts");if(Fe.existsSync(Re))try{let ie=await ee(Re);console.log(`${e.blue}Loaded ${e.bright}${ie} broadcast channel${ie!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ie){console.warn(`${e.yellow}Failed to load channels.ts: ${ie.message}${e.reset}`)}}catch(X){console.warn(`${e.yellow}Broadcasting failed to start: ${X.message}${e.reset}`)}}catch{}let{createServerApi:I,isServerApiSource:O}=await import("./chunk-z2t6f4gt.js"),P=await I(process.cwd(),C);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${R}/${e.reset}...`),o)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let D=zr({port:R,async fetch(_){return Dn(_,await(async()=>{let B=new URL(_.url);if([y,he.dirname(m),he.join(process.cwd(),"public")].some((ie)=>O(he.join(ie,B.pathname),process.cwd(),C)))return new Response("Not Found",{status:404});if(v)try{let ie=await v.handleRequest(_);if(ie.status!==404)return ie}catch{}if(k[B.pathname])try{return await k[B.pathname](_)}catch(ie){return new Response(JSON.stringify({error:ie.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X=await P(_);if(X)return X;if(B.pathname==="/")return(async()=>{let U=await x(b||"");if(o)U=We(U,u);if(n.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(n.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=he.join(y,B.pathname);if(Fe.existsSync(ee)&&Fe.statSync(ee).isFile()){let ie=Bun.file(ee),U=he.extname(ee).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let ze=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ie.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{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(ie,{headers:{"Content-Type":j}})}let ve=he.dirname(m),pe=he.join(ve,B.pathname);if(Fe.existsSync(pe)&&Fe.statSync(pe).isFile()){let ie=Bun.file(pe),U=he.extname(pe).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let ze=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ie.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{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(ie,{headers:{"Content-Type":j}})}let Re=he.join(process.cwd(),"public",B.pathname);if(Fe.existsSync(Re)&&Fe.statSync(Re).isFile()){let ie=Bun.file(Re),U=he.extname(Re).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let ze=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ie.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{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(ie,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(_){return new Response(`<pre>${_}
953
+ </html>`,loader:"html"}}})}};async function Kr(t,n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=he.resolve(t);if(!Fe.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Wt(m,n);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let y=l(process.cwd(),"output");Fe.mkdirSync(y,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let b=null,w=async()=>{try{let _={name:"public-assets",setup(ve){ve.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},B=await Bun.build({entrypoints:[m],outdir:y,plugins:[_,st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let X=B.outputs.find((ve)=>ve.path.endsWith(".html"));if(!X)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return b=await Bun.file(X.path).text(),!0}catch(_){return console.error(`${e.red}Error building stx file:${e.reset}`,_),!1}};if(!await w())return!1;let T=he.dirname(m);await mn(T);let R=r;try{if(R=await qe(r),R!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let _=n.hmrPort||R+1;d=St({wsPort:_,verbose:!1}),u=d.start(_)}let k={},v=null,C;try{let{loadStxConfig:_}=await import("./chunk-bz1jgrx8.js"),B=await _();if(C=n.stxOptions?.serverApi??B.serverApi,B?.apiRouter)v=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){k=B.apiRoutes;let X=Object.keys(k).length;if(X>0)console.log(`${e.blue}Loaded ${e.bright}${X} API route${X>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:X,loadChannels:ee}=await import("./chunk-rqa92xm4.js"),ve=B.broadcasting;await X(ve);let pe=ve.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let Re=he.join(process.cwd(),"channels.ts");if(Fe.existsSync(Re))try{let ie=await ee(Re);console.log(`${e.blue}Loaded ${e.bright}${ie} broadcast channel${ie!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ie){console.warn(`${e.yellow}Failed to load channels.ts: ${ie.message}${e.reset}`)}}catch(X){console.warn(`${e.yellow}Broadcasting failed to start: ${X.message}${e.reset}`)}}catch{}let{createServerApi:I,isServerApiSource:O}=await import("./chunk-3asy7ev5.js"),P=await I(process.cwd(),C);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${R}/${e.reset}...`),o)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let D=zr({port:R,async fetch(_){return Dn(_,await(async()=>{let B=new URL(_.url);if([y,he.dirname(m),he.join(process.cwd(),"public")].some((ie)=>O(he.join(ie,B.pathname),process.cwd(),C)))return new Response("Not Found",{status:404});if(v)try{let ie=await v.handleRequest(_);if(ie.status!==404)return ie}catch{}if(k[B.pathname])try{return await k[B.pathname](_)}catch(ie){return new Response(JSON.stringify({error:ie.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X=await P(_);if(X)return X;if(B.pathname==="/")return(async()=>{let U=await x(b||"");if(o)U=We(U,u);if(n.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(n.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=he.join(y,B.pathname);if(Fe.existsSync(ee)&&Fe.statSync(ee).isFile()){let ie=Bun.file(ee),U=he.extname(ee).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let ze=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ie.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{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(ie,{headers:{"Content-Type":j}})}let ve=he.dirname(m),pe=he.join(ve,B.pathname);if(Fe.existsSync(pe)&&Fe.statSync(pe).isFile()){let ie=Bun.file(pe),U=he.extname(pe).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let ze=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ie.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{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(ie,{headers:{"Content-Type":j}})}let Re=he.join(process.cwd(),"public",B.pathname);if(Fe.existsSync(Re)&&Fe.statSync(Re).isFile()){let ie=Bun.file(Re),U=he.extname(Re).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let ze=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ie.text(),Qe=ze.transformSync(Ue);return new Response(Qe,{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(ie,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(_){return new Response(`<pre>${_}
954
954
  ${_.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
955
955
  ${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(`
956
956
  ${e.bright}\u2192 ${e.cyan}http://localhost:${R}/${e.reset}`),console.log(`
@@ -1435,12 +1435,12 @@ ${k.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1435
1435
  ${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(`
1436
1436
  ${e.bright}\u2192 ${e.cyan}http://localhost:${w}/${e.reset}`),console.log(`
1437
1437
  ${e.yellow}Routes:${e.reset}`);let T=new Set(m.map((k)=>k.routeTemplate)),R=Object.entries(u).filter(([k])=>!T.has(k)).sort(([k],[v])=>k.localeCompare(v)).map(([k,v])=>({route:k==="/"?"/":k,filePath:Ce.relative(process.cwd(),v.filePath),fileType:v.fileType}));for(let k of m){let v=k.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");R.push({route:v,filePath:Ce.relative(process.cwd(),k.filePath),fileType:"stx"})}if(R.sort((k,v)=>k.route.localeCompare(v.route)),R.forEach((k,v)=>{let I=v===R.length-1?"\u2514\u2500 ":"\u251C\u2500 ",O=k.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${I}${k.route}${e.reset} \u2192 ${e.bright}${k.filePath}${e.reset} ${O}`)}),console.log(`
1438
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(S.url.toString(),()=>{if(p)Xe.watch(d,{recursive:!0}).close();S.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let k=Xe.watch(d,{recursive:!0},async(v,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),tt.clear(),be(),await y()});process.on("SIGINT",()=>{k.close(),S.stop(),process.exit(0)})}return!0}function dn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ur}=globalThis.Bun;import ge from"fs";import oe from"path";async function un(t){try{return vn(await Bun.file(t).text())}catch{return}}function Vt(t){let n=Bun.file(t),r=oe.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"},d=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":p[r]||"application/octet-stream",...d}})}async function Xr(t=".",n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=oe.resolve(t),{loadStxConfig:y}=await import("./chunk-a9y9ghm2.js"),b=await y(m),{createServerApi:w,isServerApiSource:S}=await import("./chunk-z2t6f4gt.js"),T=n.stxOptions?.serverApi??b.serverApi,R=await w(m,T),k=b.root&&b.root!=="."?oe.join(m,b.root):m,v=n.pagesDir||b.pagesDir||"pages",C=oe.join(k,v);if(!ge.existsSync(C)&&!b._layerPageDirs?.some((A)=>ge.existsSync(A)))return console.error(`${e.red}Error: No '${v}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${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 ${v}/index.stx for the homepage.${e.reset}`),!1;let I=Q(k,{pagesDir:v,pagesDirs:b._layerPageDirs?[C,...b._layerPageDirs.slice(1)]:void 0});if(I.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${I.length}${e.blue} routes${e.reset}`);let O=b?._pluginPageDirs||[],P=[];for(let{dir:A,prefix:F}of O)if(ge.existsSync(A)){let V=Q(oe.dirname(A),{pagesDir:oe.basename(A)});for(let te of V){let G=F==="/"?te.pattern:`${F}${te.pattern==="/"?"":te.pattern}`;P.push({route:{...te,pattern:G},prefix:F})}if(V.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${V.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let D=new Map,E=null,_=null;if(n.stxOptions?.shell!==!1){if(_=await wa(m,n.stxOptions?.shell),_){if(E=await So(_,n.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${oe.relative(m,_)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Rt(),await Pt(m);let B=At();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let X={},ee=null;try{let{loadStxConfig:A}=await import("./chunk-a9y9ghm2.js"),F=await A(m);if(F?.apiRouter)ee=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){X=F.apiRoutes;let V=Object.keys(X).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:te}=await import("./chunk-rqa92xm4.js"),G=F.broadcasting;await V(G);let Ee=G.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ee}/ws${e.reset}`);let we=oe.join(process.cwd(),"channels.ts");if(ge.existsSync(we))try{let q=await te(we);console.log(`${e.blue}Loaded ${e.bright}${q} broadcast channel${q!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(q){console.warn(`${e.yellow}Failed to load channels.ts: ${q.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let ve=l(m,"output");ge.mkdirSync(ve,{recursive:!0});let pe=new Map,Re=new Set,ie=async(A)=>{let F=Ds(C,A);if(!F)return null;try{let V=await Bun.build({entrypoints:[F],outdir:ve,plugins:[st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!V.success)return null;let te=V.outputs.find((G)=>G.path.endsWith(".html"));if(!te)return null;return await Bun.file(te.path).text()}catch{return null}},U=new Map,j=async(A,F)=>{try{let{processDirectives:V,extractVariables:te,defaultConfig:G,loadStxConfig:Ee,injectRouterScript:we}=await import("./chunk-a9y9ghm2.js"),{checkCache:q,cacheTemplate:Y,readFileCached:K,templateCache:ue}=await import("./chunk-zfj8rfv2.js"),J=await Ee(m),Ve=(le)=>{if(!le)return le;if(oe.isAbsolute(le))return le;return oe.resolve(m,le)},de={...G,...J,...n.stxOptions,autoShell:!0};if(n.debugDirectives)de.debug=!0;de.partialsDir=Ve(de.partialsDir),de.componentsDir=Ve(de.componentsDir),de.layoutsDir=Ve(de.layoutsDir),de.storesDir=Ve(de.storesDir||"stores"),de.cachePath=Ve(de.cachePath)??l(m,"cache");let z=!F&&!n.profile,ae=de.cache!==!1;if(ae&&z){let le=ue.get(A.filePath);if(le)try{if((await ge.promises.stat(A.filePath)).mtime.getTime()<=le.mtime){let He=!0;for(let Se of le.dependencies){if(!ge.existsSync(Se)){He=!1;break}if((await ge.promises.stat(Se)).mtime.getTime()>le.mtime){He=!1;break}}if(He){let Se=le.output;if(E)Se=Je(Se,{preserveHead:!0});let at=U.get(A.filePath);return{route:A,content:Se,status:at?.status??await un(A.filePath),headers:at?.headers}}}}catch{}let je=await q(A.filePath,de);if(je){let Be=je;if(E)Be=Je(Be,{preserveHead:!0});let He=U.get(A.filePath);return{route:A,content:Be,status:He?.status??await un(A.filePath),headers:He?.headers}}}let ne=ae?await K(A.filePath):await Bun.file(A.filePath).text(),ce=vn(ne),{classifyAllScripts:me}=await import("./chunk-a9y9ghm2.js"),N=me(ne),Ie=N.server.map((le)=>le.content),Me=ne;for(let le of N.server)Me=Me.replace(le.fullTag,"");let re={__filename:A.filePath,__dirname:oe.dirname(A.filePath),__stx_options:de,params:F??{},__stx_runtime_head:{}};for(let le of Ie)try{await te(le,re,A.filePath)}catch(je){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",A.filePath,je?.message||je)}let De=new Set,ye;if(n.profile){let le=performance.now();ye=await V(Me,re,A.filePath,de,De);let je=performance.now()-le,Be=oe.relative(m,A.filePath)||A.filePath;console.log(`[stx:profile] ${Be} \u2192 ${je.toFixed(2)}ms`)}else ye=await V(Me,re,A.filePath,de,De);if(!E)ye=await we(ye,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-qqvj5zra.js");ye=ye.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(je,Be,He)=>{if(!/function\s+__stx_setup_/.test(He))return je;return`<script${Be}>${le(He,re)}</script>`})}if(E)ye=Je(ye,{preserveHead:!0});if(ae&&z)await Y(A.filePath,ye,De,de);let{extractStreamBoundaries:pt}=await import("./chunk-05dtat6q.js"),Ze=pt(re),it=re.__streamTemplates;if(it&&typeof it==="object"&&Object.keys(it).length>0){let le=re.streamBoundaries||{},je={...de,autoShell:!1},Be=Object.keys(it).map((Se)=>({id:Se,render:async()=>{let at=typeof le[Se]==="function"?await le[Se]():void 0;return V(it[Se],{...re,$boundary:at},A.filePath,je,new Set)}})),He=new Set(Be.map((Se)=>Se.id));Ze=[...(Ze||[]).filter((Se)=>!He.has(Se.id)),...Be]}if(Ze&&Ze.length>0)Re.add(A.pattern);else Ze=void 0;let Xt=Bt(re),Gt=Ft(re);if(z)U.set(A.filePath,{status:Xt,headers:Gt});return{route:A,content:ye,status:Xt??ce,headers:Gt,boundaries:Ze}}catch(V){return console.error(`${e.red}Error building ${e.bright}${A.pattern}${e.reset}:`,V),null}},ze=8,Ue=async()=>{let A=new Set(pe.keys()),F=new Set(D.keys());pe.clear(),D.clear();let V=n.prebuild===!1?I.filter((G)=>A.has(G.pattern)):I,te=n.prebuild===!1?P.filter(({route:G})=>F.has(G.pattern)):P;for(let G=0;G<V.length;G+=ze){let Ee=V.slice(G,G+ze),we=await Promise.all(Ee.map((q)=>j(q)));for(let q of we)if(q)pe.set(q.route.pattern,q)}for(let G=0;G<te.length;G+=ze){let Ee=te.slice(G,G+ze),we=await Promise.all(Ee.map(({route:q})=>j(q)));for(let q of we)if(q)D.set(q.route.pattern,q)}return pe.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?I.length+P.length>0:await Ue()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await mn(m);let Ge=r;try{if(Ge=await qe(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let A=n.hmrPort||Ge+1;d=St({wsPort:A,verbose:!1}),u=d.start(A)}let Et=(A,F)=>{let te=`<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(A.includes("</head>"))return f(A,te,"");if(A.includes("<body"))return A.replace(/<body([^>]*)>/,`<body$1>${te}`);return te+A};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Ur({port:Ge,hostname:n.hostname,async fetch(A){let F=new URL(A.url),V=n.stxOptions?.offline??b.offline;if(F.pathname===zo&&V?.enabled){if(!["GET","HEAD"].includes(A.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(A.method==="HEAD"?null:Ho(V,ps()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let te=b?.publicDir||"public",G=oe.join(m,te,F.pathname),Ee=oe.join(m,F.pathname),we=oe.join(ve,F.pathname);if([G,Ee,we].some((z)=>S(z,m,T)))return new Response("Not Found",{status:404});let[q,Y,K]=await Promise.all([ge.promises.stat(G).catch(()=>null),ge.promises.stat(Ee).catch(()=>null),ge.promises.stat(we).catch(()=>null)]);if(q?.isFile()&&!S(G,m,T))return Vt(G);if(Y?.isFile()&&!S(Ee,m,T))return Vt(Ee);if(K?.isFile()&&!S(we,m,T))return Vt(we);if(F.pathname.startsWith("/_stx/component/")){let z=decodeURIComponent(F.pathname.slice(16));if(z)try{let ae=`<${z} />`,ne={...buildConfig,autoShell:!1},ce=await processDirectives(ae,{},oe.join(m,"components",`${z}.stx`),ne,new Set);return new Response(ce,{headers:{"Content-Type":"text/html"}})}catch(ae){return new Response(`<div class="stx-async-error">${ae.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:z}=await import("./chunk-hb6r4pxp.js"),ae=await z(A,{publicDir:oe.join(m,te),cacheDir:l(m,"cache","img")});if(ae)return ae}if(ee)try{let z=await ee.handleRequest(A);if(z.status!==404)return z}catch{}if(X[F.pathname])try{return await X[F.pathname](A)}catch(z){return new Response(JSON.stringify({error:z.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await R(A);if(ue)return ue;let J=wr(F.pathname,I);if(J){let z=pe.get(J.route.pattern),ae=Re.has(J.route.pattern);if(!z||J.route.isDynamic&&Object.keys(J.params).length>0||ae){let ne=await j(J.route,J.params);if(ne){if(z=ne,!J.route.isDynamic&&!ae)pe.set(J.route.pattern,ne)}}if(z){let ne=z.status??200,ce=z.headers??{},me=(J.route.filePath?kt(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(me.validate){if(!await me.validate({params:J.params})){let Me=await ie(404);if(Me){let re=Me;if(re=await x(re,m),o)re=We(re,u);return new Response(re,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(me.middleware){let Ie=It(F.pathname,J.params,me,F.search),Me=Ot(Ie,null,A,{isServer:!0}),re=await Nt(me.middleware,Me);if(re.redirect){let De=re.redirect.path,ye=re.redirect.options.redirectCode||302,pt=new Headers(re.responseHeaders);return pt.set("Location",De),new Response(null,{status:ye,headers:pt})}if(re.abort){let{statusCode:De,message:ye}=re.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${ye}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(re.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(re.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;z.content=f(z.content,De,"")}}let N=z.content;if(E&&va(A)&&Ye(N,b?.router?.container||"main")){let Ie=ot(N),Me=ke(N),re=N.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=re?en(re[1].trim()):"";if(Object.keys(J.params).length>0)N=Et(N,J.params);N=await x(N,m);let ye=b?.router?.container||"main";return N=Pe(N,ye,!0),new Response(N,{status:ne,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Ie.layout,"X-STX-Layout-Group":Ie.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[hc]:ps(),...H(),"Cache-Control":wt}})}if(E)N=Qr(E,N);if(Object.keys(J.params).length>0)N=Et(N,J.params);if(N=await x(N,m),o)N=We(N,u);if(n.native)if(N.includes("<head>"))N=N.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 N="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+N;if(n.titlebarHidden)if(N.includes("<head>"))N=N.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 N=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${N}`;if(z.boundaries&&z.boundaries.length>0){let{renderStreamingPage:Ie,streamToResponse:Me}=await import("./chunk-05dtat6q.js");return Me(Ie(N,z.boundaries,{timeoutMs:30000}),{status:ne,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(N,{status:ne,headers:{"Content-Type":"text/html",...H(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ce}})}}if(P.length>0){let z=P.map((ne)=>ne.route),ae=wr(F.pathname,z);if(ae){let ne=D.get(ae.route.pattern);if(!ne||ae.route.isDynamic){let ce=await j(ae.route,ae.params);if(ce){if(ne=ce,!ae.route.isDynamic)D.set(ae.route.pattern,ce)}}if(ne){let ce=ne.content;if(E)ce=Qr(E,ce);if(Object.keys(ae.params).length>0)ce=Et(ce,ae.params);if(ce=await x(ce,m),o)ce=We(ce,u);return new Response(ce,{status:ne.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ne}of O)if(ne!=="/"&&F.pathname.startsWith(ne)){let ce=D.get(ne)||D.get(ne+"/");if(!ce){let me=P.find(({route:N})=>N.pattern===ne||N.pattern===`${ne}/`);if(me){let N=await j(me.route);if(N)ce=N,D.set(me.route.pattern,N)}}if(ce){let me=ce.content;if(E)me=Qr(E,me);if(me=await x(me,m),o)me=We(me,u);return new Response(me,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if($t(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ve=pe.get("/");if(Ve){let z=Ve.content;if(z=await x(z,m),o)z=We(z,u);if(n.native)if(z.includes("<head>"))z=z.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 z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;return new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await ie(404);if(de){let z=de;if(z=await x(z,m),o)z=We(z,u);return new Response(z,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(A){let F=await ie(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${A}
1438
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(S.url.toString(),()=>{if(p)Xe.watch(d,{recursive:!0}).close();S.stop()}),p){console.log(`${e.blue}Watching for changes...${e.reset}`);let k=Xe.watch(d,{recursive:!0},async(v,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),tt.clear(),be(),await y()});process.on("SIGINT",()=>{k.close(),S.stop(),process.exit(0)})}return!0}function dn(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ur}=globalThis.Bun;import ge from"fs";import oe from"path";async function un(t){try{return vn(await Bun.file(t).text())}catch{return}}function Vt(t){let n=Bun.file(t),r=oe.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"},d=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":p[r]||"application/octet-stream",...d}})}async function Xr(t=".",n={}){let r=n.port||3000,p=n.watch!==!1,o=n.hotReload!==!1&&p,d=null,u=n.hmrPort||r+1,m=oe.resolve(t),{loadStxConfig:y}=await import("./chunk-bz1jgrx8.js"),b=await y(m),{createServerApi:w,isServerApiSource:S}=await import("./chunk-3asy7ev5.js"),T=n.stxOptions?.serverApi??b.serverApi,R=await w(m,T),k=b.root&&b.root!=="."?oe.join(m,b.root):m,v=n.pagesDir||b.pagesDir||"pages",C=oe.join(k,v);if(!ge.existsSync(C)&&!b._layerPageDirs?.some((A)=>ge.existsSync(A)))return console.error(`${e.red}Error: No '${v}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${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 ${v}/index.stx for the homepage.${e.reset}`),!1;let I=Q(k,{pagesDir:v,pagesDirs:b._layerPageDirs?[C,...b._layerPageDirs.slice(1)]:void 0});if(I.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${I.length}${e.blue} routes${e.reset}`);let O=b?._pluginPageDirs||[],P=[];for(let{dir:A,prefix:F}of O)if(ge.existsSync(A)){let V=Q(oe.dirname(A),{pagesDir:oe.basename(A)});for(let te of V){let G=F==="/"?te.pattern:`${F}${te.pattern==="/"?"":te.pattern}`;P.push({route:{...te,pattern:G},prefix:F})}if(V.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${V.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let D=new Map,E=null,_=null;if(n.stxOptions?.shell!==!1){if(_=await wa(m,n.stxOptions?.shell),_){if(E=await So(_,n.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${oe.relative(m,_)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Rt(),await Pt(m);let B=At();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let X={},ee=null;try{let{loadStxConfig:A}=await import("./chunk-bz1jgrx8.js"),F=await A(m);if(F?.apiRouter)ee=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){X=F.apiRoutes;let V=Object.keys(X).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:te}=await import("./chunk-rqa92xm4.js"),G=F.broadcasting;await V(G);let Ee=G.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ee}/ws${e.reset}`);let we=oe.join(process.cwd(),"channels.ts");if(ge.existsSync(we))try{let q=await te(we);console.log(`${e.blue}Loaded ${e.bright}${q} broadcast channel${q!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(q){console.warn(`${e.yellow}Failed to load channels.ts: ${q.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let ve=l(m,"output");ge.mkdirSync(ve,{recursive:!0});let pe=new Map,Re=new Set,ie=async(A)=>{let F=Ds(C,A);if(!F)return null;try{let V=await Bun.build({entrypoints:[F],outdir:ve,plugins:[st],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!V.success)return null;let te=V.outputs.find((G)=>G.path.endsWith(".html"));if(!te)return null;return await Bun.file(te.path).text()}catch{return null}},U=new Map,j=async(A,F)=>{try{let{processDirectives:V,extractVariables:te,defaultConfig:G,loadStxConfig:Ee,injectRouterScript:we}=await import("./chunk-bz1jgrx8.js"),{checkCache:q,cacheTemplate:Y,readFileCached:K,templateCache:ue}=await import("./chunk-m1a3a32y.js"),J=await Ee(m),Ve=(le)=>{if(!le)return le;if(oe.isAbsolute(le))return le;return oe.resolve(m,le)},de={...G,...J,...n.stxOptions,autoShell:!0};if(n.debugDirectives)de.debug=!0;de.partialsDir=Ve(de.partialsDir),de.componentsDir=Ve(de.componentsDir),de.layoutsDir=Ve(de.layoutsDir),de.storesDir=Ve(de.storesDir||"stores"),de.cachePath=Ve(de.cachePath)??l(m,"cache");let z=!F&&!n.profile,ae=de.cache!==!1;if(ae&&z){let le=ue.get(A.filePath);if(le)try{if((await ge.promises.stat(A.filePath)).mtime.getTime()<=le.mtime){let He=!0;for(let Se of le.dependencies){if(!ge.existsSync(Se)){He=!1;break}if((await ge.promises.stat(Se)).mtime.getTime()>le.mtime){He=!1;break}}if(He){let Se=le.output;if(E)Se=Je(Se,{preserveHead:!0});let at=U.get(A.filePath);return{route:A,content:Se,status:at?.status??await un(A.filePath),headers:at?.headers}}}}catch{}let je=await q(A.filePath,de);if(je){let Be=je;if(E)Be=Je(Be,{preserveHead:!0});let He=U.get(A.filePath);return{route:A,content:Be,status:He?.status??await un(A.filePath),headers:He?.headers}}}let ne=ae?await K(A.filePath):await Bun.file(A.filePath).text(),ce=vn(ne),{classifyAllScripts:me}=await import("./chunk-bz1jgrx8.js"),N=me(ne),Ie=N.server.map((le)=>le.content),Me=ne;for(let le of N.server)Me=Me.replace(le.fullTag,"");let re={__filename:A.filePath,__dirname:oe.dirname(A.filePath),__stx_options:de,params:F??{},__stx_runtime_head:{}};for(let le of Ie)try{await te(le,re,A.filePath)}catch(je){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",A.filePath,je?.message||je)}let De=new Set,ye;if(n.profile){let le=performance.now();ye=await V(Me,re,A.filePath,de,De);let je=performance.now()-le,Be=oe.relative(m,A.filePath)||A.filePath;console.log(`[stx:profile] ${Be} \u2192 ${je.toFixed(2)}ms`)}else ye=await V(Me,re,A.filePath,de,De);if(!E)ye=await we(ye,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-h0nxd9xg.js");ye=ye.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(je,Be,He)=>{if(!/function\s+__stx_setup_/.test(He))return je;return`<script${Be}>${le(He,re)}</script>`})}if(E)ye=Je(ye,{preserveHead:!0});if(ae&&z)await Y(A.filePath,ye,De,de);let{extractStreamBoundaries:pt}=await import("./chunk-04f6r2kh.js"),Ze=pt(re),it=re.__streamTemplates;if(it&&typeof it==="object"&&Object.keys(it).length>0){let le=re.streamBoundaries||{},je={...de,autoShell:!1},Be=Object.keys(it).map((Se)=>({id:Se,render:async()=>{let at=typeof le[Se]==="function"?await le[Se]():void 0;return V(it[Se],{...re,$boundary:at},A.filePath,je,new Set)}})),He=new Set(Be.map((Se)=>Se.id));Ze=[...(Ze||[]).filter((Se)=>!He.has(Se.id)),...Be]}if(Ze&&Ze.length>0)Re.add(A.pattern);else Ze=void 0;let Xt=Bt(re),Gt=Ft(re);if(z)U.set(A.filePath,{status:Xt,headers:Gt});return{route:A,content:ye,status:Xt??ce,headers:Gt,boundaries:Ze}}catch(V){return console.error(`${e.red}Error building ${e.bright}${A.pattern}${e.reset}:`,V),null}},ze=8,Ue=async()=>{let A=new Set(pe.keys()),F=new Set(D.keys());pe.clear(),D.clear();let V=n.prebuild===!1?I.filter((G)=>A.has(G.pattern)):I,te=n.prebuild===!1?P.filter(({route:G})=>F.has(G.pattern)):P;for(let G=0;G<V.length;G+=ze){let Ee=V.slice(G,G+ze),we=await Promise.all(Ee.map((q)=>j(q)));for(let q of we)if(q)pe.set(q.route.pattern,q)}for(let G=0;G<te.length;G+=ze){let Ee=te.slice(G,G+ze),we=await Promise.all(Ee.map(({route:q})=>j(q)));for(let q of we)if(q)D.set(q.route.pattern,q)}return pe.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?I.length+P.length>0:await Ue()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await mn(m);let Ge=r;try{if(Ge=await qe(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let A=n.hmrPort||Ge+1;d=St({wsPort:A,verbose:!1}),u=d.start(A)}let Et=(A,F)=>{let te=`<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(A.includes("</head>"))return f(A,te,"");if(A.includes("<body"))return A.replace(/<body([^>]*)>/,`<body$1>${te}`);return te+A};console.log(`${e.blue}Starting server...${e.reset}`);let Dt=Ur({port:Ge,hostname:n.hostname,async fetch(A){let F=new URL(A.url),V=n.stxOptions?.offline??b.offline;if(F.pathname===zo&&V?.enabled){if(!["GET","HEAD"].includes(A.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(A.method==="HEAD"?null:Ho(V,ps()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let te=b?.publicDir||"public",G=oe.join(m,te,F.pathname),Ee=oe.join(m,F.pathname),we=oe.join(ve,F.pathname);if([G,Ee,we].some((z)=>S(z,m,T)))return new Response("Not Found",{status:404});let[q,Y,K]=await Promise.all([ge.promises.stat(G).catch(()=>null),ge.promises.stat(Ee).catch(()=>null),ge.promises.stat(we).catch(()=>null)]);if(q?.isFile()&&!S(G,m,T))return Vt(G);if(Y?.isFile()&&!S(Ee,m,T))return Vt(Ee);if(K?.isFile()&&!S(we,m,T))return Vt(we);if(F.pathname.startsWith("/_stx/component/")){let z=decodeURIComponent(F.pathname.slice(16));if(z)try{let ae=`<${z} />`,ne={...buildConfig,autoShell:!1},ce=await processDirectives(ae,{},oe.join(m,"components",`${z}.stx`),ne,new Set);return new Response(ce,{headers:{"Content-Type":"text/html"}})}catch(ae){return new Response(`<div class="stx-async-error">${ae.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:z}=await import("./chunk-hb6r4pxp.js"),ae=await z(A,{publicDir:oe.join(m,te),cacheDir:l(m,"cache","img")});if(ae)return ae}if(ee)try{let z=await ee.handleRequest(A);if(z.status!==404)return z}catch{}if(X[F.pathname])try{return await X[F.pathname](A)}catch(z){return new Response(JSON.stringify({error:z.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await R(A);if(ue)return ue;let J=wr(F.pathname,I);if(J){let z=pe.get(J.route.pattern),ae=Re.has(J.route.pattern);if(!z||J.route.isDynamic&&Object.keys(J.params).length>0||ae){let ne=await j(J.route,J.params);if(ne){if(z=ne,!J.route.isDynamic&&!ae)pe.set(J.route.pattern,ne)}}if(z){let ne=z.status??200,ce=z.headers??{},me=(J.route.filePath?kt(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(me.validate){if(!await me.validate({params:J.params})){let Me=await ie(404);if(Me){let re=Me;if(re=await x(re,m),o)re=We(re,u);return new Response(re,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(me.middleware){let Ie=It(F.pathname,J.params,me,F.search),Me=Ot(Ie,null,A,{isServer:!0}),re=await Nt(me.middleware,Me);if(re.redirect){let De=re.redirect.path,ye=re.redirect.options.redirectCode||302,pt=new Headers(re.responseHeaders);return pt.set("Location",De),new Response(null,{status:ye,headers:pt})}if(re.abort){let{statusCode:De,message:ye}=re.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${ye}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(re.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(re.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;z.content=f(z.content,De,"")}}let N=z.content;if(E&&va(A)&&Ye(N,b?.router?.container||"main")){let Ie=ot(N),Me=ke(N),re=N.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=re?en(re[1].trim()):"";if(Object.keys(J.params).length>0)N=Et(N,J.params);N=await x(N,m);let ye=b?.router?.container||"main";return N=Pe(N,ye,!0),new Response(N,{status:ne,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Ie.layout,"X-STX-Layout-Group":Ie.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[hc]:ps(),...H(),"Cache-Control":wt}})}if(E)N=Qr(E,N);if(Object.keys(J.params).length>0)N=Et(N,J.params);if(N=await x(N,m),o)N=We(N,u);if(n.native)if(N.includes("<head>"))N=N.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 N="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+N;if(n.titlebarHidden)if(N.includes("<head>"))N=N.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 N=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${N}`;if(z.boundaries&&z.boundaries.length>0){let{renderStreamingPage:Ie,streamToResponse:Me}=await import("./chunk-04f6r2kh.js");return Me(Ie(N,z.boundaries,{timeoutMs:30000}),{status:ne,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(N,{status:ne,headers:{"Content-Type":"text/html",...H(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ce}})}}if(P.length>0){let z=P.map((ne)=>ne.route),ae=wr(F.pathname,z);if(ae){let ne=D.get(ae.route.pattern);if(!ne||ae.route.isDynamic){let ce=await j(ae.route,ae.params);if(ce){if(ne=ce,!ae.route.isDynamic)D.set(ae.route.pattern,ce)}}if(ne){let ce=ne.content;if(E)ce=Qr(E,ce);if(Object.keys(ae.params).length>0)ce=Et(ce,ae.params);if(ce=await x(ce,m),o)ce=We(ce,u);return new Response(ce,{status:ne.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ne}of O)if(ne!=="/"&&F.pathname.startsWith(ne)){let ce=D.get(ne)||D.get(ne+"/");if(!ce){let me=P.find(({route:N})=>N.pattern===ne||N.pattern===`${ne}/`);if(me){let N=await j(me.route);if(N)ce=N,D.set(me.route.pattern,N)}}if(ce){let me=ce.content;if(E)me=Qr(E,me);if(me=await x(me,m),o)me=We(me,u);return new Response(me,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if($t(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ve=pe.get("/");if(Ve){let z=Ve.content;if(z=await x(z,m),o)z=We(z,u);if(n.native)if(z.includes("<head>"))z=z.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 z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;return new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await ie(404);if(de){let z=de;if(z=await x(z,m),o)z=We(z,u);return new Response(z,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(A){let F=await ie(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${A}
1439
1439
  ${A.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1440
1440
  ${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(`
1441
1441
  ${e.bright}\u2192 ${e.cyan}http://localhost:${Ge}/${e.reset}`),o)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
1442
1442
  ${e.yellow}Routes:${e.reset}`);let Mt=[...Ms(I,m)];for(let{route:A}of P)Mt.push(`${A.pattern}`);if(Mt.forEach((A,F)=>{let te=F===Mt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${te}${e.reset}${A}`)}),console.log(`
1443
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(Dt.url.toString(),()=>{if(d)ct();Dt.stop()}),n.native){let A,F=oe.join(C,"index.stx");if(ge.existsSync(F)){let te=await Bun.file(F).text();A=yt(te)}let V=b?.app?.window??{};await et(Ge,{title:b?.app?.head?.title||oe.basename(m)||"stx App",width:V.width,height:V.height,darkMode:V.darkMode,hotReload:V.hotReload,titlebarHidden:V.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!A,sidebarConfig:A})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let A=(q)=>q.startsWith("public/")||q.startsWith("public\\"),F=(q)=>{let Y=q.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},V=new Map,te=()=>{let q=new Set([m,...b._layerGraph?.layers.map((Y)=>Y.root)??[],...b._layerGraph?.configDependencies.map((Y)=>oe.dirname(Y))??[]].filter((Y)=>ge.existsSync(Y)).map((Y)=>ge.realpathSync(Y)));for(let Y of b._layerGraph?.layers??[])for(let K of Object.values(Y.resources)){if(!ge.existsSync(K))continue;let ue=ge.realpathSync(K);if(![...q].some((J)=>ue===J||ue.startsWith(`${J}${oe.sep}`)))q.add(ue)}for(let[Y,K]of V)if(!q.has(Y))K.close(),V.delete(Y);for(let Y of q)if(!V.has(Y)&&ge.existsSync(Y))V.set(Y,ge.watch(Y,{recursive:!0},(K,ue)=>{Ee(Y,K,ue).catch((J)=>console.error("[stx] Layer rebuild failed:",J))}))},G=Promise.resolve(),Ee=(q,Y,K)=>(G=G.catch(()=>{}).then(()=>we(q,Y,K)),G),we=async(q,Y,K)=>{if(!K||vt(K))return;if(xt(K)){if(b._layerGraph){let ue=await y(m);Object.assign(b,ue),I.splice(0,I.length,...Q(k,{pagesDir:v,pagesDirs:ue._layerPageDirs?[C,...ue._layerPageDirs.slice(1)]:void 0})),te()}if(A(K)){if(console.log(`${e.cyan}${K} changed${e.reset}`),o&&d)d.reload(K)}else if(F(K)){console.log(`${e.yellow}${K} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:J}=await import("./chunk-zfj8rfv2.js");ue(oe.resolve(q,K)),J.delete(oe.resolve(q,K))}catch{}if(_&&K){if(oe.resolve(q,K)===_||oe.basename(_)===K){let J=await So(_,n.stxOptions||{});if(J)E=J}}if(await Ue(),await dr(m),o&&d)d.reload(K)}else{console.log(`${e.yellow}${K} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:J}=await import("./chunk-zfj8rfv2.js");ue(oe.resolve(q,K)),J.delete(oe.resolve(q,K))}catch{}if(await Ue(),o&&d)d.reload(K)}}else if(bt(K)){if(console.log(`${e.cyan}CSS ${K} changed${e.reset}`),o&&d)d.updateCss(K)}};te(),process.on("SIGINT",()=>{for(let q of V.values())q.close();if(d)ct();Dt.stop(),process.exit(0)})}return!0}import qt from"fs";import lt from"path";async function Wr(t){try{let r=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return[];let p=r[1],o=[],d=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=d.exec(p))!==null){let m=u[1],y=u[2]||u[3]||u[4];if(!y)continue;let b={name:y},w=m.match(/@type\s+\{([^}]+)\}/i);if(w)b.type=w[1].trim();if(m.match(/@required/i))b.required=!0;let T=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(T)b.default=T[1].trim();let R=m.split(`
1443
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(Dt.url.toString(),()=>{if(d)ct();Dt.stop()}),n.native){let A,F=oe.join(C,"index.stx");if(ge.existsSync(F)){let te=await Bun.file(F).text();A=yt(te)}let V=b?.app?.window??{};await et(Ge,{title:b?.app?.head?.title||oe.basename(m)||"stx App",width:V.width,height:V.height,darkMode:V.darkMode,hotReload:V.hotReload,titlebarHidden:V.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!A,sidebarConfig:A})}if(p){console.log(`${e.blue}Watching for changes...${e.reset}`);let A=(q)=>q.startsWith("public/")||q.startsWith("public\\"),F=(q)=>{let Y=q.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},V=new Map,te=()=>{let q=new Set([m,...b._layerGraph?.layers.map((Y)=>Y.root)??[],...b._layerGraph?.configDependencies.map((Y)=>oe.dirname(Y))??[]].filter((Y)=>ge.existsSync(Y)).map((Y)=>ge.realpathSync(Y)));for(let Y of b._layerGraph?.layers??[])for(let K of Object.values(Y.resources)){if(!ge.existsSync(K))continue;let ue=ge.realpathSync(K);if(![...q].some((J)=>ue===J||ue.startsWith(`${J}${oe.sep}`)))q.add(ue)}for(let[Y,K]of V)if(!q.has(Y))K.close(),V.delete(Y);for(let Y of q)if(!V.has(Y)&&ge.existsSync(Y))V.set(Y,ge.watch(Y,{recursive:!0},(K,ue)=>{Ee(Y,K,ue).catch((J)=>console.error("[stx] Layer rebuild failed:",J))}))},G=Promise.resolve(),Ee=(q,Y,K)=>(G=G.catch(()=>{}).then(()=>we(q,Y,K)),G),we=async(q,Y,K)=>{if(!K||vt(K))return;if(xt(K)){if(b._layerGraph){let ue=await y(m);Object.assign(b,ue),I.splice(0,I.length,...Q(k,{pagesDir:v,pagesDirs:ue._layerPageDirs?[C,...ue._layerPageDirs.slice(1)]:void 0})),te()}if(A(K)){if(console.log(`${e.cyan}${K} changed${e.reset}`),o&&d)d.reload(K)}else if(F(K)){console.log(`${e.yellow}${K} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:J}=await import("./chunk-m1a3a32y.js");ue(oe.resolve(q,K)),J.delete(oe.resolve(q,K))}catch{}if(_&&K){if(oe.resolve(q,K)===_||oe.basename(_)===K){let J=await So(_,n.stxOptions||{});if(J)E=J}}if(await Ue(),await dr(m),o&&d)d.reload(K)}else{console.log(`${e.yellow}${K} changed, rebuilding...${e.reset}`),tt.clear(),be();try{let{invalidateFileCache:ue,templateCache:J}=await import("./chunk-m1a3a32y.js");ue(oe.resolve(q,K)),J.delete(oe.resolve(q,K))}catch{}if(await Ue(),o&&d)d.reload(K)}}else if(bt(K)){if(console.log(`${e.cyan}CSS ${K} changed${e.reset}`),o&&d)d.updateCss(K)}};te(),process.on("SIGINT",()=>{for(let q of V.values())q.close();if(d)ct();Dt.stop(),process.exit(0)})}return!0}import qt from"fs";import lt from"path";async function Wr(t){try{let r=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return[];let p=r[1],o=[],d=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=d.exec(p))!==null){let m=u[1],y=u[2]||u[3]||u[4];if(!y)continue;let b={name:y},w=m.match(/@type\s+\{([^}]+)\}/i);if(w)b.type=w[1].trim();if(m.match(/@required/i))b.required=!0;let T=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(T)b.default=T[1].trim();let R=m.split(`
1444
1444
  `).map((k)=>k.trim().replace(/^\*\s*/,"")).filter((k)=>!k.startsWith("@")&&k.length>0);b.description=R.join(" ").trim(),o.push(b)}if(o.length===0){let m=p.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(m){let b=m[1].split(",").map((w)=>w.trim()).filter(Boolean);for(let w of b){let[S]=w.split(":").map((T)=>T.trim());if(S)o.push({name:S})}}}return o}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function Vr(t){try{let n=await Bun.file(t).text(),r=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(r)return r[1].split(`
1445
1445
  `).map((p)=>p.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function qr(t,n=!1,r){let p=lt.basename(t,".stx"),o=await Wr(t),d=await Vr(t),u="";if(n&&r)u=`<${r}></${r}>`;else{let m=o.map((y)=>{if(y.type==="boolean")return`:${y.name}="true"`;return`${y.name}="value"`}).join(`
1446
1446
  `);u=`<${p}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{mt,ht,yt}from"./chunk-pbakxcv8.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-0tyyad6q.js";import{h}from"./chunk-kgh1xsfe.js";import"./chunk-60yppcbb.js";import"./chunk-h8h97bcc.js";import{Xt,lo,Jt,ta,gt,na,uo,Yt,sa,Zt}from"./chunk-zbvfjm4a.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{na("Config file changed, restarting...");try{await e.onChange()}catch(p){gt(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,f=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:f,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:dt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function dt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{mt,ht,yt}from"./chunk-pbakxcv8.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import"./chunk-0tyyad6q.js";import{h}from"./chunk-hze3158c.js";import"./chunk-60yppcbb.js";import"./chunk-w1rrfj39.js";import{Xt,lo,Jt,ta,gt,na,uo,Yt,sa,Zt}from"./chunk-zbvfjm4a.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{na("Config file changed, restarting...");try{await e.onChange()}catch(p){gt(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,f=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:f,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:dt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function dt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,7 +556,7 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var lt=".stx/story/presets.json",R=1,ut=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ft(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,ut),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ft(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-nrpqrqqe.js"),p={},u=y(n);if(u)try{await h(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=y(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=y(e);if(!r)return null;let s={};if(await h(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-nrpqrqqe.js"),c={...r},n=y(e);if(n)try{await h(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:y(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var lt=".stx/story/presets.json",R=1,ut=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ft(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,ut),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ft(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-79sr2kxg.js"),p={},u=y(n);if(u)try{await h(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=y(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=y(e);if(!r)return null;let s={};if(await h(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-79sr2kxg.js"),c={...r},n=y(e);if(n)try{await h(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:y(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function y(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
561
  `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await Yt(t);ht(t,r);let s=Zt(t.config,r);yt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return xt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,g,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,f=sa(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await Yt(t);ht(t,m);let g=Zt(t.config,m);if(yt(t,g),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{f(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",f,i=n.searchParams.get("props");if(i)try{f=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,f);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xh,Co,Sh,kh,_h,Ch}from"./chunk-rt55f47q.js";import"./chunk-zf9n3esr.js";import"./chunk-mwxehpse.js";import"./chunk-9zrvh3pz.js";import"./chunk-sew1z7cv.js";import"./chunk-q58f5wk2.js";import"./chunk-311mrz2n.js";import"./chunk-y0msz738.js";import"./chunk-sb3dx4dd.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-sbvkk4cn.js";import"./chunk-dy7vqv1x.js";import"./chunk-hze3158c.js";import"./chunk-w1rrfj39.js";import"./chunk-60yppcbb.js";import"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Ch as clearStoreCache,xh as getStoreScript,_h as getStoreScriptFor,kh as pageStoresAll,Co as storesRead,Sh as storesReadInFiles};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{dm}from"./chunk-gesktj4m.js";import"./chunk-7wae4311.js";import"./chunk-12sk3dtm.js";import"./chunk-mwxehpse.js";import"./chunk-khe30jmk.js";import"./chunk-q58f5wk2.js";import"./chunk-y0msz738.js";import"./chunk-sb3dx4dd.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-sbvkk4cn.js";import"./chunk-dy7vqv1x.js";import"./chunk-hze3158c.js";import"./chunk-w1rrfj39.js";import"./chunk-60yppcbb.js";import"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{dm as startProductionServer};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{R}from"./chunk-kgh1xsfe.js";import{i}from"./chunk-tdd3765y.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
2
+ import{R}from"./chunk-hze3158c.js";import{i}from"./chunk-zfq2vvex.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$n,B}from"./chunk-60yppcbb.js";import m from"fs";import e from"path";async function Tn(r,o,i){if(r.__stx_runtime_config)return;let n=$n();if(n||i){r.__stx_runtime_config=n??B(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-szfh1sg3.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=B(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Pi(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
2
+ import{$n,B}from"./chunk-60yppcbb.js";import m from"fs";import e from"path";async function Tn(r,o,i){if(r.__stx_runtime_config)return;let n=$n();if(n||i){r.__stx_runtime_config=n??B(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-94e6kmjm.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=B(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Pi(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
3
3
  declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
4
4
  `),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
5
5
  declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{is,as}from"./chunk-79y9amt1.js";import{w}from"./chunk-kgh1xsfe.js";import{a}from"./chunk-095cn3p0.js";import{Ze,le}from"./chunk-5h9d6jew.js";import{ac}from"./chunk-wcq7a5pv.js";import{V}from"./chunk-4068rmzv.js";import{b}from"./chunk-94mpe1ny.js";import{f}from"./chunk-fd1bpv35.js";import{existsSync as z,mkdirSync as C,copyFileSync as I,chmodSync as B,rmSync as xe}from"fs";import{join as c,basename as ye,resolve as K}from"path";import{spawn as _}from"child_process";import{platform as Se}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=w(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var Tu=`
2
+ import{is,as}from"./chunk-79y9amt1.js";import{w}from"./chunk-hze3158c.js";import{a}from"./chunk-y0msz738.js";import{Ze,le}from"./chunk-5h9d6jew.js";import{ac}from"./chunk-4t5t33yj.js";import{V}from"./chunk-4068rmzv.js";import{b}from"./chunk-94mpe1ny.js";import{f}from"./chunk-fd1bpv35.js";import{existsSync as z,mkdirSync as C,copyFileSync as I,chmodSync as B,rmSync as xe}from"fs";import{join as c,basename as ye,resolve as K}from"path";import{spawn as _}from"child_process";import{platform as Se}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=w(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var Tu=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';