@stacksjs/stx 0.2.844 → 0.2.845

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 (82) hide show
  1. package/dist/{chunk-3e1hmm3h.js → chunk-010yhk6m.js} +1 -1
  2. package/dist/{chunk-my85fge2.js → chunk-0gg7k9cj.js} +2 -2
  3. package/dist/{chunk-jbb9pjae.js → chunk-12tkqtrv.js} +1 -1
  4. package/dist/{chunk-9hzbqwrp.js → chunk-168fwztf.js} +1 -1
  5. package/dist/{chunk-0tse1k5e.js → chunk-1k751fgt.js} +1 -1
  6. package/dist/{chunk-46wqk1fb.js → chunk-302gek13.js} +1 -1
  7. package/dist/{chunk-y49nzyxf.js → chunk-315q48qy.js} +4 -4
  8. package/dist/chunk-3qa40hgd.js +2 -0
  9. package/dist/{chunk-0q3vkfqt.js → chunk-4rfedg2f.js} +1 -1
  10. package/dist/{chunk-cwwm14b3.js → chunk-5a7etvxz.js} +1 -1
  11. package/dist/chunk-64evx0my.js +2 -0
  12. package/dist/{chunk-pfzwgxk9.js → chunk-6trgwvt0.js} +1 -1
  13. package/dist/{chunk-2524ayee.js → chunk-6tyjvxgb.js} +4 -4
  14. package/dist/{chunk-1efmkw4t.js → chunk-6x6w0v1k.js} +1 -1
  15. package/dist/{chunk-7cxbt404.js → chunk-7r4p7zjn.js} +4 -4
  16. package/dist/{chunk-eq8enrjw.js → chunk-7tdwa595.js} +1 -1
  17. package/dist/{chunk-hws9yb0b.js → chunk-8hy5g1hq.js} +3 -3
  18. package/dist/{chunk-a28rhqq2.js → chunk-97bvpszy.js} +1 -1
  19. package/dist/{chunk-s37e6wjj.js → chunk-afyvnpr9.js} +1 -1
  20. package/dist/{chunk-gd7vyzhw.js → chunk-aw45yjrw.js} +1 -1
  21. package/dist/{chunk-ksaj3br7.js → chunk-b3wcs8bk.js} +1 -1
  22. package/dist/{chunk-3g46mker.js → chunk-c3y7cxe7.js} +1 -1
  23. package/dist/{chunk-a3wv8q6g.js → chunk-c62wxswd.js} +5 -5
  24. package/dist/{chunk-e3r9fybx.js → chunk-dhgjq9jx.js} +2 -2
  25. package/dist/{chunk-35e3qawb.js → chunk-dmmt4psb.js} +1 -1
  26. package/dist/{chunk-rjenga8c.js → chunk-eaz30495.js} +1 -1
  27. package/dist/chunk-emzz6seq.js +2 -0
  28. package/dist/{chunk-vq4nccm4.js → chunk-exr9599h.js} +1 -1
  29. package/dist/{chunk-c4by7m5b.js → chunk-f34ce0pn.js} +1 -1
  30. package/dist/{chunk-sjcvc0bd.js → chunk-fpc1n3je.js} +1 -1
  31. package/dist/{chunk-76a66cw3.js → chunk-fz433ybr.js} +1 -1
  32. package/dist/chunk-hbkh87n2.js +2 -0
  33. package/dist/{chunk-5fspjf7x.js → chunk-hgk1v60t.js} +1 -1
  34. package/dist/chunk-j274w1ac.js +2 -0
  35. package/dist/chunk-jf37tpj2.js +2 -0
  36. package/dist/{chunk-2jwsntc9.js → chunk-k1tbgnhf.js} +1 -1
  37. package/dist/{chunk-chetq1ce.js → chunk-k7am94hr.js} +2 -2
  38. package/dist/{chunk-vhckqe4x.js → chunk-md84j62m.js} +2 -2
  39. package/dist/{chunk-gg63af5n.js → chunk-msd0ezxm.js} +1 -1
  40. package/dist/{chunk-txfz7gc3.js → chunk-mveqaxkr.js} +2 -2
  41. package/dist/{chunk-v7j50pfw.js → chunk-ndsygfeb.js} +1 -1
  42. package/dist/{chunk-v9jfxbwx.js → chunk-nqj1mkkz.js} +1 -1
  43. package/dist/{chunk-71fsg3az.js → chunk-pb9347sn.js} +1 -1
  44. package/dist/{chunk-c1vf7qev.js → chunk-pj1xj34h.js} +1 -1
  45. package/dist/chunk-pv2mrc9g.js +2 -0
  46. package/dist/chunk-pwdnqe30.js +2 -0
  47. package/dist/chunk-qeej9h56.js +2 -0
  48. package/dist/{chunk-r10h4xmw.js → chunk-rapk2r7b.js} +1 -1
  49. package/dist/{chunk-japk9yf6.js → chunk-rncmfgpk.js} +4 -4
  50. package/dist/{chunk-qtkjbz4n.js → chunk-s68p10zh.js} +1 -1
  51. package/dist/{chunk-nsqx4xwn.js → chunk-sss23kn5.js} +1 -1
  52. package/dist/chunk-sv52qc36.js +3 -0
  53. package/dist/{chunk-rf0q3mva.js → chunk-t4n23dh5.js} +1 -1
  54. package/dist/{chunk-gz45xsbg.js → chunk-tjnf4a8g.js} +6 -6
  55. package/dist/{chunk-v7rat63v.js → chunk-vf0xbptq.js} +1 -1
  56. package/dist/{chunk-tpf8v2mb.js → chunk-vhxrrqrg.js} +1 -1
  57. package/dist/{chunk-7k4npa5e.js → chunk-wvwca1e9.js} +1 -1
  58. package/dist/{chunk-t5mnysyw.js → chunk-xjbc3bhs.js} +1 -1
  59. package/dist/{chunk-vyvjbydn.js → chunk-xr8hg79c.js} +1 -1
  60. package/dist/{chunk-t2a78fzq.js → chunk-xtbmntht.js} +1 -1
  61. package/dist/{chunk-vrwdnefe.js → chunk-y06rw18j.js} +1 -1
  62. package/dist/{chunk-e5seb8f7.js → chunk-y7aqf8r7.js} +1 -1
  63. package/dist/{chunk-sfww6v6m.js → chunk-zwxncs2e.js} +2 -2
  64. package/dist/{chunk-th7343bz.js → chunk-zztfp9qh.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/native/runtime/browser-screen.js +27 -4
  69. package/dist/native/runtime/craft.d.ts +8 -1
  70. package/dist/pwa.js +1 -1
  71. package/dist/ssg.js +2 -2
  72. package/package.json +5 -5
  73. package/dist/chunk-54eap9rq.js +0 -2
  74. package/dist/chunk-bgaq87h6.js +0 -2
  75. package/dist/chunk-f404rga4.js +0 -2
  76. package/dist/chunk-mxrmed55.js +0 -2
  77. package/dist/chunk-q5ehy99b.js +0 -2
  78. package/dist/chunk-rm5pnhzx.js +0 -3
  79. package/dist/chunk-t2sqxbv5.js +0 -2
  80. package/dist/chunk-wj93vpy5.js +0 -2
  81. package/dist/chunk-wz30ghcf.js +0 -2
  82. package/dist/chunk-xjthcx9s.js +0 -2
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{nt}from"./chunk-kxj5sp5w.js";import{yt,Wn}from"./chunk-8qjf16yr.js";import{Ar,Pr,Ir,Nr,Ce}from"./chunk-r8xwd8r1.js";import{Me,hn,nl,rl}from"./chunk-gz45xsbg.js";import{D}from"./chunk-47n5s7wk.js";import{_i}from"./chunk-tpf8v2mb.js";import{b}from"./chunk-sfww6v6m.js";import{i}from"./chunk-japk9yf6.js";import{F,a}from"./chunk-vhckqe4x.js";import{Ec}from"./chunk-ncrrxp60.js";import{Nn,qe,Te,fa,ga,Dn}from"./chunk-hws9yb0b.js";import{an,Oo}from"./chunk-3e1hmm3h.js";import{Mn}from"./chunk-py5x8fkq.js";import{Qt,er,tr}from"./chunk-rrj3gv46.js";import{G}from"./chunk-7cxbt404.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Wn():yt(),o=J(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function V(){let n=nt(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,o={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);nl();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Me(R))),{context:A}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...F,..._,...o,buildMode:"compile",strict:!1},y=await i(e,A,r,j,w),C=Nn(y)+qe(y),P=rl();return{route:l,sourceFile:n,html:y,fragment:C,placeholders:P,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(w),contentHash:S,status:hn(e),streamTemplates:A.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function am(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=Ce(e.app?.head,{known:Nr,source:"app.head"}),u=e.app?.colorMode,A=e.router?.container||"main",w=n.routeRules??e.routeRules??{},j=Mn(w),y=n.serverApi??e.serverApi,C=typeof y==="object"?y:{};if(y)an(o,C);if(e.runtimeConfig)D(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=G(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],H=[];for(let s of B){let f=j(s.pattern),O=f.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Ir(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Ar(t.html,u);if(g.htmlAttrs)t.html=Pr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await b(t.html),O){let p=await Dn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Te(t.html,A,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),I=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),H.push({pattern:s.pattern,compiledPath:z,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:f}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let E=tr(o);if(E){let{copied:s,bytes:f}=Z(E,c.join(r,"public",er));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Qt}/`)}let N={runtime:v.filename,router:x.filename},T=fa(H,N,r);if(T.routeRules=w,T.routerContainer=A,y)T.apiRoutes=await Oo(o,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await _i(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Ec(e._layerGraph),null,2));ga(T,r);let K=Date.now()-l;return console.log(`
2
+ import{nt}from"./chunk-kxj5sp5w.js";import{yt,Wn}from"./chunk-8qjf16yr.js";import{Ar,Pr,Ir,Nr,Ce}from"./chunk-r8xwd8r1.js";import{Me,hn,nl,rl}from"./chunk-tjnf4a8g.js";import{D}from"./chunk-47n5s7wk.js";import{_i}from"./chunk-vhxrrqrg.js";import{b}from"./chunk-zwxncs2e.js";import{i}from"./chunk-rncmfgpk.js";import{F,a}from"./chunk-md84j62m.js";import{Ec}from"./chunk-ncrrxp60.js";import{Nn,qe,Te,fa,ga,Dn}from"./chunk-8hy5g1hq.js";import{an,Oo}from"./chunk-010yhk6m.js";import{Mn}from"./chunk-py5x8fkq.js";import{Qt,er,tr}from"./chunk-rrj3gv46.js";import{G}from"./chunk-7r4p7zjn.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function U(n=!1){let l=n?Wn():yt(),o=J(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function V(){let n=nt(),l=J(n);return{content:n,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(n,l,o={}){let r=q.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);nl();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Me(R))),{context:A}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,j={...F,..._,...o,buildMode:"compile",strict:!1},y=await i(e,A,r,j,w),C=Nn(y)+qe(y),P=rl();return{route:l,sourceFile:n,html:y,fragment:C,placeholders:P,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(w),contentHash:S,status:hn(e),streamTemplates:A.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function am(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=Ce(e.app?.head,{known:Nr,source:"app.head"}),u=e.app?.colorMode,A=e.router?.container||"main",w=n.routeRules??e.routeRules??{},j=Mn(w),y=n.serverApi??e.serverApi,C=typeof y==="object"?y:{};if(y)an(o,C);if(e.runtimeConfig)D(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=G(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(n.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],H=[];for(let s of B){let f=j(s.pattern),O=f.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Ir(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Ar(t.html,u);if(g.htmlAttrs)t.html=Pr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await b(t.html),O){let p=await Dn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Te(t.html,A,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),I=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),H.push({pattern:s.pattern,compiledPath:z,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:f}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let E=tr(o);if(E){let{copied:s,bytes:f}=Z(E,c.join(r,"public",er));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Qt}/`)}let N={runtime:v.filename,router:x.filename},T=fa(H,N,r);if(T.routeRules=w,T.routerContainer=A,y)T.apiRoutes=await Oo(o,r,C);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await _i(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Ec(e._layerGraph),null,2));ga(T,r);let K=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:N,outputDir:r,duration:K}}
4
4
  export{am};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{lh,vo,uh,dh,ph,fh}from"./chunk-5a7etvxz.js";import"./chunk-xr8hg79c.js";import"./chunk-010yhk6m.js";import"./chunk-4y6hes3h.js";import"./chunk-mveqaxkr.js";import"./chunk-7r4p7zjn.js";import"./chunk-kbv5nwwd.js";import"./chunk-md84j62m.js";import"./chunk-302gek13.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{fh as clearStoreCache,lh as getStoreScript,ph as getStoreScriptFor,dh as pageStoresAll,vo as storesRead,uh as storesReadInFiles};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Bm,Sa,gu,Fm,zm,Hm,Vm,Um,mu,hu,Wm,qm,Km,Xm}from"./chunk-c4by7m5b.js";import"./chunk-japk9yf6.js";import"./chunk-sfww6v6m.js";import"./chunk-y49nzyxf.js";import"./chunk-4dxq7ft1.js";import"./chunk-5fspjf7x.js";import"./chunk-rm5pnhzx.js";import"./chunk-71fsg3az.js";import"./chunk-48vnw9t9.js";import"./chunk-txfz7gc3.js";import"./chunk-7cxbt404.js";import"./chunk-kbv5nwwd.js";import"./chunk-e5seb8f7.js";import"./chunk-vhckqe4x.js";import"./chunk-46wqk1fb.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-gz45xsbg.js";import"./chunk-tpf8v2mb.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{gu as SUSPENSE_RESOLVER_RUNTIME,Sa as buildSuspenseResolveScript,Um as createStreamRenderer,Hm as extractStreamBoundaries,Xm as generateHydrationRuntime,hu as islandDirective,qm as processSectionDirectives,zm as processStreamDirectives,Wm as registerStreamingDirectives,Fm as renderStreamingPage,Bm as streamTemplate,Vm as streamTemplateSimple,Km as streamToResponse,mu as streamingSuspenseDirective};
2
+ import{Bm,Sa,gu,Fm,zm,Hm,Vm,Um,mu,hu,Wm,qm,Km,Xm}from"./chunk-f34ce0pn.js";import"./chunk-rncmfgpk.js";import"./chunk-zwxncs2e.js";import"./chunk-315q48qy.js";import"./chunk-4dxq7ft1.js";import"./chunk-hgk1v60t.js";import"./chunk-sv52qc36.js";import"./chunk-pb9347sn.js";import"./chunk-48vnw9t9.js";import"./chunk-mveqaxkr.js";import"./chunk-7r4p7zjn.js";import"./chunk-kbv5nwwd.js";import"./chunk-y7aqf8r7.js";import"./chunk-md84j62m.js";import"./chunk-302gek13.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{gu as SUSPENSE_RESOLVER_RUNTIME,Sa as buildSuspenseResolveScript,Um as createStreamRenderer,Hm as extractStreamBoundaries,Xm as generateHydrationRuntime,hu as islandDirective,qm as processSectionDirectives,zm as processStreamDirectives,Wm as registerStreamingDirectives,Fm as renderStreamingPage,Bm as streamTemplate,Vm as streamTemplateSimple,Km as streamToResponse,mu as streamingSuspenseDirective};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m,h,p}from"./chunk-gz45xsbg.js";import{F}from"./chunk-vhckqe4x.js";import{i}from"./chunk-japk9yf6.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Bm(e,t={},o={}){let n={...F,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
2
+ import{m,h,p}from"./chunk-tjnf4a8g.js";import{F}from"./chunk-md84j62m.js";import{i}from"./chunk-rncmfgpk.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Bm(e,t={},o={}){let n={...F,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(d.name,i(d.content,y,e,n,l))}r.enqueue(`
5
5
  <script>
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{kn,_i}from"./chunk-tpf8v2mb.js";import"./chunk-47n5s7wk.js";export{_i as generateRuntimeConfigTypes,kn as prepareRuntimeConfig};
2
+ import{kn,_i}from"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";export{_i as generateRuntimeConfigTypes,kn as prepareRuntimeConfig};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{_f,Cf,ye,Ef,sc,tn,nn,$h,oc,rn,nr,Tf,$f,Rf,is,sn,Af,on,ic,Rh}from"./chunk-vyvjbydn.js";import"./chunk-3e1hmm3h.js";import"./chunk-4y6hes3h.js";import"./chunk-vhckqe4x.js";import"./chunk-46wqk1fb.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-gz45xsbg.js";import"./chunk-tpf8v2mb.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{nr as MODULE_SPECIFIER_PREFIX,_f as bundleCacheDir,Cf as bundleCacheEntryLimit,Rh as bundleClientEntriesSplit,on as bundleClientScript,nn as clearBundleFailures,ye as clientBundleDependencies,tn as getBundleFailures,rn as hasUserImports,sn as moduleSubstitutionKey,$f as normalizeRegistrySpecifiers,Af as queueClientBundleBuild,sc as recordBundleFailure,Tf as registryIdForPath,oc as resolveBundlerFallback,Rf as rewriteRegistryImports,$h as setBundlerFallbackMode,Ef as shouldLogBundlerDiagnostics,ic as tempBuildName,is as withModuleSubstitutes};
2
+ import{_f,Cf,ye,Ef,sc,tn,nn,$h,oc,rn,nr,Tf,$f,Rf,is,sn,Af,on,ic,Rh}from"./chunk-xr8hg79c.js";import"./chunk-010yhk6m.js";import"./chunk-4y6hes3h.js";import"./chunk-md84j62m.js";import"./chunk-302gek13.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{nr as MODULE_SPECIFIER_PREFIX,_f as bundleCacheDir,Cf as bundleCacheEntryLimit,Rh as bundleClientEntriesSplit,on as bundleClientScript,nn as clearBundleFailures,ye as clientBundleDependencies,tn as getBundleFailures,rn as hasUserImports,sn as moduleSubstitutionKey,$f as normalizeRegistrySpecifiers,Af as queueClientBundleBuild,sc as recordBundleFailure,Tf as registryIdForPath,oc as resolveBundlerFallback,Rf as rewriteRegistryImports,$h as setBundlerFallbackMode,Ef as shouldLogBundlerDiagnostics,ic as tempBuildName,is as withModuleSubstitutes};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Yg}from"./chunk-4rfedg2f.js";import"./chunk-rncmfgpk.js";import"./chunk-zwxncs2e.js";import"./chunk-315q48qy.js";import"./chunk-4dxq7ft1.js";import"./chunk-hgk1v60t.js";import"./chunk-sv52qc36.js";import"./chunk-pb9347sn.js";import"./chunk-48vnw9t9.js";import"./chunk-mveqaxkr.js";import"./chunk-7r4p7zjn.js";import"./chunk-kbv5nwwd.js";import"./chunk-y7aqf8r7.js";import"./chunk-md84j62m.js";import"./chunk-302gek13.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{Yg as startInteractive};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{yl,bl}from"./chunk-n91sm385.js";import{f,P,ot,d}from"./chunk-r8xwd8r1.js";import{U,wr,Ds,Ms,ci,li,Ls,fn,De,fe,J,Sr,kr,ie,Y,N,st,_r,pi,Tr,ze,r,p,W,Sn}from"./chunk-gz45xsbg.js";import{n}from"./chunk-rm5pnhzx.js";import{oe}from"./chunk-48vnw9t9.js";import{s}from"./chunk-x0dx1pyf.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Ct}from"crypto";import Q from"fs";import Z from"path";import Me from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=Me.readSync(e,o,0,t,i);return o.subarray(0,a)}function Le(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Me.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Le(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Me.closeSync(i)}}import Yt from"fs";import ke from"os";import{join as pt}from"path";import{fileURLToPath as mt}from"url";var Pe=Symbol("stx.image-worker.unavailable");function Qt(e=typeof ke.availableParallelism==="function"?ke.availableParallelism():ke.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Yt.existsSync(mt(t)))return mt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return t&&sn(t)?t:void 0}catch{return}}function sn(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,pt(i.BUN_INSTALL||pt(ke.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var ht=!1;function ue(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Pe}function Re(e){return e instanceof Error?e.message:String(e)}async function Fe(e,i){let t;try{t=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Re(a)}`)}if(typeof t!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=rn();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((a,c)=>{let l;try{l=new t(o)}catch(y){a(ue(`could not start ${o}: ${Re(y)}`));return}let u=!1,m=!1,v=(y)=>{if(m)return;m=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){v(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;v(()=>c(h))}),l.on("error",(y)=>{v(()=>u?c(y instanceof Error?y:Error(Re(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Re(y)}`)))}),l.on("exit",(y)=>{v(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var on=new Set([".avif",".jpeg",".jpg",".png",".webp"]),an=[320,640,960,1280,1920],ye="/_stx/images",cn=`stx:${ye}:alpha-1`,ln=`stx:${ye}:opaque-1`,un=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ie;function dn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function bt(){if(Ie!==void 0)return Ie;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ie=un.map((i)=>{let t;try{t=e?dn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Ie}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var xt=new Set;function gn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function pn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Ct("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function wt(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function Rt(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await Rt(e,c));continue}if(!a.isFile()||!on.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function $t(e,i){return e.map((t)=>({key:gn(t.relativePath),input:t.absolutePath,name:pn(t.relativePath),...mn(t.absolutePath)?{options:{storage:i}}:{}}))}function mn(e){return Ue(e)==="possible"}function hn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function yn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),t=new Set,o=8;if(i.length===0)return t;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let m=u.variants.filter((v)=>v.format==="png").sort((v,y)=>v.width-y.width)[0];try{let v=await a(new Uint8Array(await Q.promises.readFile(m?.path??u.fallback.path)));if(hn(v.data))t.add(l)}catch{t.add(l)}}));return t}function bn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let m;try{return m=Q.openSync(u.path,"r"),!Le(Ce(m,0,32))}catch{return!0}finally{if(m!==void 0)Q.closeSync(m)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,t.push(o),!xt.has(o))xt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function vn(e){let i=[],t=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function xn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function wn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function St(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Bo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function Fo(e){let i=kt(e);return i?be().transparent.has(i):!1}function zo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Mh(e){let i=Bo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:zo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:Fo(e)?void 0:i.placeholder?.dataUrl}}function ds(){let e=be();e.catalog=new Map,e.transparent=new Set}function $n(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Lh(e,i,t={}){if(!e||!Q.existsSync(e))return ds(),{count:0,fingerprint:""};if(t.offThread){let b=await Fe("delivery",{publicDir:e,outputDir:i});if(b!==Pe)return $n(b.state),b.result}let o=await Rt(e);if(o.length===0)return ds(),{count:0,fingerprint:""};let a=xn(i),c=o.filter((b)=>{let w=a[b.relativePath];if(!w)return!0;let A=St(b.absolutePath);return!A||A.mtimeMs!==w.mtimeMs||A.size!==w.size});if(c.length===0)return ds(),{count:0,fingerprint:""};let l=wt(Z.join(i,"_stx","images"),`${cn}:${bt()}`),u={outDir:Z.join(i,"_stx","images"),storage:wt(Z.join(i,"_stx","images"),`${ln}:${bt()}`),baseUrl:ye,widths:an,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:m}=await import("ts-images/delivery"),v=c,y;try{y=await m({...u,entries:$t(c,l)})}catch(b){if(v=await vn(c),v.length===c.length)throw b;let w=new Set(v.map((k)=>k.relativePath)),A=!1;for(let k of c){if(w.has(k.relativePath))continue;let R=St(k.absolutePath);if(!R)continue;a[k.relativePath]=R,A=!0}if(A)wn(i,a);if(v.length===0)return ds(),{count:0,fingerprint:""};y=await m({...u,entries:$t(v,l)})}let h=await yn(y.entries),C=bn(y.entries,h),x=be();x.catalog=new Map(Object.entries(y.entries)),x.transparent=h;let S=h.size===0&&C.length===0?y.fingerprint:Ct("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...h].sort(),droppedWebp:C.sort()})).digest("hex");return{count:v.length,fingerprint:S}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=ci(e,o);if(a!==void 0)return a;for(let c of li(e,i,t,o))if(await r(c))return c;return null}}var de=new At;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||Cn.has(i)}function se(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${Sn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${Sn(c,He(String(a)))}"`)}return t}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=Rn(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,m=[];if(o.reactive)m.push(`:href="${n(o.value)}"`);else m.push(`href="${n(Sr(o.value,"navigable"))}"`);if(a)m.push(`class="${n(a)}"`);if(m.push("data-stx-link"),m.push(`data-stx-active-class="${n(c)}"`),m.push(`data-stx-exact-active-class="${n(l)}"`),u)m.push("data-stx-prefetch");let v=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(v)m.push(`data-stx-active-match="${n(v)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return m.push(...se(e,y)),m.push(...ae(e,y)),`<a ${m.join(" ")}>${i}</a>`}};var kn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return kn.get(i)}var An={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function V(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=An[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))t.push(`(max-width: ${u}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function Pn(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function In(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function _n(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=V(e,"src")||"",a=Bo(o),c=V(e,"alt")||"",l=V(e,"width")||(a?String(a.source.width):void 0),u=V(e,"height")||(a?String(a.source.height):void 0),m=V(e,"sizes"),v=V(e,"srcset"),y=V(e,"densities"),h=V(e,"format"),C=Fo(o)||Ve(o)?.transparent===!0,x=V(e,"placeholder")||(a&&!C?"thumbhash":void 0),S=V(e,"placeholderColor")||"#e5e7eb",b=V(e,"provider"),w=V(e,"class")||V(e,"className")||"",A=V(e,"style")||"",k=V(e,"objectFit")||V(e,"fit"),R=V(e,"objectPosition")||V(e,"position"),T=V(e,"quality"),G=_e(e,"lazy",!0),M=_e(e,"preload",!1),F=_e(e,"priority",!1),H=V(e,"loading"),E=V(e,"decoding")||"async",O=!!a||_e(e,"picture",!1)||!!h,B=l?Number.parseInt(l):void 0,q=u?Number.parseInt(u):void 0,L=v||"",X="";if(a)L=a.sources[a.fallback.format]||"",X=m?Ge(m):"100vw";else if(!L&&m&&b&&b!=="local"&&b!=="static")L=Ke(o,Ze,b,h),X=Ge(m);else if(!L&&y){let I=y.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));L=Pn(o,I,B,b,h)}else if(m)X=Ge(m);let z=[];if(A)z.push(A);if(k)z.push(`object-fit:${k}`);if(R)z.push(`object-position:${R}`);if(B&&q)z.push(`aspect-ratio:${B}/${q}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:S}:Ve(o);if(I&&x==="color")z.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)z.push(`background-color:${I.color}`),z.push(`background-image:url(${I.dataUrl})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=_n(B||16,q||9,S);z.push(`background-image:url(${_})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")z.push(`background-image:url(${n(x)})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,B,q,b,h),K=[];if(K.push(`src="${n(Sr($e,"fetched"))}"`),K.push(`alt="${n(c)}"`),l)K.push(`width="${n(l)}"`);if(u)K.push(`height="${n(u)}"`);let le=H||(F||M?"eager":G?"lazy":"");if(le)K.push(`loading="${n(le)}"`);if(F)K.push('fetchpriority="high"');if(K.push(`decoding="${n(E)}"`),w)K.push(`class="${n(w)}"`);if(z.length>0)K.push(`style="${n(z.join(";"))}"`);if(L)K.push(`srcset="${n(Sr(L,"fetched"))}"`);if(X)K.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=In(D)+(I?`;${I}`:"");K.push(`onload="${n(_)}"`),te.add("onload")}K.push(...se(e,te)),K.push(...ae(e,te));let je=`<img ${K.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${L?` imagesrcset="${n(L)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
2
+ import{yl,bl}from"./chunk-n91sm385.js";import{f,P,ot,d}from"./chunk-r8xwd8r1.js";import{U,wr,Ds,Ms,ci,li,Ls,fn,De,fe,J,Sr,kr,ie,Y,N,st,_r,pi,Tr,ze,r,p,W,Sn}from"./chunk-tjnf4a8g.js";import{n}from"./chunk-sv52qc36.js";import{oe}from"./chunk-48vnw9t9.js";import{s}from"./chunk-x0dx1pyf.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Ct}from"crypto";import Q from"fs";import Z from"path";import Me from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=Me.readSync(e,o,0,t,i);return o.subarray(0,a)}function Le(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Me.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Le(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Me.closeSync(i)}}import Yt from"fs";import ke from"os";import{join as pt}from"path";import{fileURLToPath as mt}from"url";var Pe=Symbol("stx.image-worker.unavailable");function Qt(e=typeof ke.availableParallelism==="function"?ke.availableParallelism():ke.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Yt.existsSync(mt(t)))return mt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return t&&sn(t)?t:void 0}catch{return}}function sn(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,pt(i.BUN_INSTALL||pt(ke.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var ht=!1;function ue(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Pe}function Re(e){return e instanceof Error?e.message:String(e)}async function Fe(e,i){let t;try{t=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Re(a)}`)}if(typeof t!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=rn();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((a,c)=>{let l;try{l=new t(o)}catch(y){a(ue(`could not start ${o}: ${Re(y)}`));return}let u=!1,m=!1,v=(y)=>{if(m)return;m=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){v(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;v(()=>c(h))}),l.on("error",(y)=>{v(()=>u?c(y instanceof Error?y:Error(Re(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Re(y)}`)))}),l.on("exit",(y)=>{v(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var on=new Set([".avif",".jpeg",".jpg",".png",".webp"]),an=[320,640,960,1280,1920],ye="/_stx/images",cn=`stx:${ye}:alpha-1`,ln=`stx:${ye}:opaque-1`,un=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ie;function dn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function bt(){if(Ie!==void 0)return Ie;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ie=un.map((i)=>{let t;try{t=e?dn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Ie}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var xt=new Set;function gn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function pn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Ct("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function wt(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function Rt(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await Rt(e,c));continue}if(!a.isFile()||!on.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function $t(e,i){return e.map((t)=>({key:gn(t.relativePath),input:t.absolutePath,name:pn(t.relativePath),...mn(t.absolutePath)?{options:{storage:i}}:{}}))}function mn(e){return Ue(e)==="possible"}function hn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function yn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),t=new Set,o=8;if(i.length===0)return t;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let m=u.variants.filter((v)=>v.format==="png").sort((v,y)=>v.width-y.width)[0];try{let v=await a(new Uint8Array(await Q.promises.readFile(m?.path??u.fallback.path)));if(hn(v.data))t.add(l)}catch{t.add(l)}}));return t}function bn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let m;try{return m=Q.openSync(u.path,"r"),!Le(Ce(m,0,32))}catch{return!0}finally{if(m!==void 0)Q.closeSync(m)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,t.push(o),!xt.has(o))xt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function vn(e){let i=[],t=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function xn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function wn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function St(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Bo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function Fo(e){let i=kt(e);return i?be().transparent.has(i):!1}function zo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Mh(e){let i=Bo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:zo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:Fo(e)?void 0:i.placeholder?.dataUrl}}function ds(){let e=be();e.catalog=new Map,e.transparent=new Set}function $n(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Lh(e,i,t={}){if(!e||!Q.existsSync(e))return ds(),{count:0,fingerprint:""};if(t.offThread){let b=await Fe("delivery",{publicDir:e,outputDir:i});if(b!==Pe)return $n(b.state),b.result}let o=await Rt(e);if(o.length===0)return ds(),{count:0,fingerprint:""};let a=xn(i),c=o.filter((b)=>{let w=a[b.relativePath];if(!w)return!0;let A=St(b.absolutePath);return!A||A.mtimeMs!==w.mtimeMs||A.size!==w.size});if(c.length===0)return ds(),{count:0,fingerprint:""};let l=wt(Z.join(i,"_stx","images"),`${cn}:${bt()}`),u={outDir:Z.join(i,"_stx","images"),storage:wt(Z.join(i,"_stx","images"),`${ln}:${bt()}`),baseUrl:ye,widths:an,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:m}=await import("ts-images/delivery"),v=c,y;try{y=await m({...u,entries:$t(c,l)})}catch(b){if(v=await vn(c),v.length===c.length)throw b;let w=new Set(v.map((k)=>k.relativePath)),A=!1;for(let k of c){if(w.has(k.relativePath))continue;let R=St(k.absolutePath);if(!R)continue;a[k.relativePath]=R,A=!0}if(A)wn(i,a);if(v.length===0)return ds(),{count:0,fingerprint:""};y=await m({...u,entries:$t(v,l)})}let h=await yn(y.entries),C=bn(y.entries,h),x=be();x.catalog=new Map(Object.entries(y.entries)),x.transparent=h;let S=h.size===0&&C.length===0?y.fingerprint:Ct("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...h].sort(),droppedWebp:C.sort()})).digest("hex");return{count:v.length,fingerprint:S}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=ci(e,o);if(a!==void 0)return a;for(let c of li(e,i,t,o))if(await r(c))return c;return null}}var de=new At;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||Cn.has(i)}function se(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${Sn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${Sn(c,He(String(a)))}"`)}return t}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=Rn(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,m=[];if(o.reactive)m.push(`:href="${n(o.value)}"`);else m.push(`href="${n(Sr(o.value,"navigable"))}"`);if(a)m.push(`class="${n(a)}"`);if(m.push("data-stx-link"),m.push(`data-stx-active-class="${n(c)}"`),m.push(`data-stx-exact-active-class="${n(l)}"`),u)m.push("data-stx-prefetch");let v=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(v)m.push(`data-stx-active-match="${n(v)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return m.push(...se(e,y)),m.push(...ae(e,y)),`<a ${m.join(" ")}>${i}</a>`}};var kn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return kn.get(i)}var An={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function V(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=An[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))t.push(`(max-width: ${u}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function Pn(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function In(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function _n(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=V(e,"src")||"",a=Bo(o),c=V(e,"alt")||"",l=V(e,"width")||(a?String(a.source.width):void 0),u=V(e,"height")||(a?String(a.source.height):void 0),m=V(e,"sizes"),v=V(e,"srcset"),y=V(e,"densities"),h=V(e,"format"),C=Fo(o)||Ve(o)?.transparent===!0,x=V(e,"placeholder")||(a&&!C?"thumbhash":void 0),S=V(e,"placeholderColor")||"#e5e7eb",b=V(e,"provider"),w=V(e,"class")||V(e,"className")||"",A=V(e,"style")||"",k=V(e,"objectFit")||V(e,"fit"),R=V(e,"objectPosition")||V(e,"position"),T=V(e,"quality"),G=_e(e,"lazy",!0),M=_e(e,"preload",!1),F=_e(e,"priority",!1),H=V(e,"loading"),E=V(e,"decoding")||"async",O=!!a||_e(e,"picture",!1)||!!h,B=l?Number.parseInt(l):void 0,q=u?Number.parseInt(u):void 0,L=v||"",X="";if(a)L=a.sources[a.fallback.format]||"",X=m?Ge(m):"100vw";else if(!L&&m&&b&&b!=="local"&&b!=="static")L=Ke(o,Ze,b,h),X=Ge(m);else if(!L&&y){let I=y.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));L=Pn(o,I,B,b,h)}else if(m)X=Ge(m);let z=[];if(A)z.push(A);if(k)z.push(`object-fit:${k}`);if(R)z.push(`object-position:${R}`);if(B&&q)z.push(`aspect-ratio:${B}/${q}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:S}:Ve(o);if(I&&x==="color")z.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)z.push(`background-color:${I.color}`),z.push(`background-image:url(${I.dataUrl})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=_n(B||16,q||9,S);z.push(`background-image:url(${_})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")z.push(`background-image:url(${n(x)})`),z.push("background-size:cover"),z.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,B,q,b,h),K=[];if(K.push(`src="${n(Sr($e,"fetched"))}"`),K.push(`alt="${n(c)}"`),l)K.push(`width="${n(l)}"`);if(u)K.push(`height="${n(u)}"`);let le=H||(F||M?"eager":G?"lazy":"");if(le)K.push(`loading="${n(le)}"`);if(F)K.push('fetchpriority="high"');if(K.push(`decoding="${n(E)}"`),w)K.push(`class="${n(w)}"`);if(z.length>0)K.push(`style="${n(z.join(";"))}"`);if(L)K.push(`srcset="${n(Sr(L,"fetched"))}"`);if(X)K.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=In(D)+(I?`;${I}`:"");K.push(`onload="${n(_)}"`),te.add("onload")}K.push(...se(e,te)),K.push(...ae(e,te));let je=`<img ${K.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${L?` imagesrcset="${n(L)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
3
3
  `}if(O){let I=[];if(a)for(let _ of zo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,B,q,b,"avif"),ee=L?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,B,q,b,"webp"),ee=L?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${j}<picture>
4
4
  ${I.join(`
5
5
  `)}
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{la,rm,ua,sm,zl,Hl,om,im}from"./chunk-6trgwvt0.js";import"./chunk-97bvpszy.js";import"./chunk-xr8hg79c.js";import"./chunk-010yhk6m.js";import"./chunk-4y6hes3h.js";import"./chunk-mveqaxkr.js";import"./chunk-7r4p7zjn.js";import"./chunk-kbv5nwwd.js";import"./chunk-md84j62m.js";import"./chunk-302gek13.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import{Ot,ng}from"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{la as buildScriptVirtualFile,rm as buildVirtualSource,Ot as extractScriptBlocks,ng as extractTemplateExpressions,zl as findRuntimeTypeDeclarations,Hl as findStxModuleDeclarations,im as formatTypecheckDiagnostics,sm as sourcePathFor,om as typecheckStxFiles,ua as virtualPathFor};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{am}from"./chunk-eaz30495.js";import"./chunk-8hy5g1hq.js";import"./chunk-8qjf16yr.js";import"./chunk-nqj1mkkz.js";import"./chunk-010yhk6m.js";import"./chunk-rncmfgpk.js";import"./chunk-zwxncs2e.js";import"./chunk-315q48qy.js";import"./chunk-4dxq7ft1.js";import"./chunk-hgk1v60t.js";import"./chunk-sv52qc36.js";import"./chunk-pb9347sn.js";import"./chunk-48vnw9t9.js";import"./chunk-mveqaxkr.js";import"./chunk-7r4p7zjn.js";import"./chunk-kbv5nwwd.js";import"./chunk-y7aqf8r7.js";import"./chunk-md84j62m.js";import"./chunk-302gek13.js";import"./chunk-9mtyxvhk.js";import"./chunk-ncrrxp60.js";import"./chunk-rb6vr5v9.js";import"./chunk-kxj5sp5w.js";import"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{am as buildForProduction};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-r8xwd8r1.js";import"./chunk-n91sm385.js";import"./chunk-zjqvbcwa.js";import"./chunk-gz45xsbg.js";import"./chunk-47n5s7wk.js";import"./chunk-tpf8v2mb.js";import"./chunk-9mtyxvhk.js";import"./chunk-46wqk1fb.js";import{c}from"./chunk-bygxt820.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-r8xwd8r1.js";import"./chunk-n91sm385.js";import"./chunk-zjqvbcwa.js";import"./chunk-tjnf4a8g.js";import"./chunk-47n5s7wk.js";import"./chunk-vhxrrqrg.js";import"./chunk-9mtyxvhk.js";import"./chunk-302gek13.js";import{c}from"./chunk-bygxt820.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ut,dt,pt}from"./chunk-ema1c29k.js";import"./chunk-n91sm385.js";import"./chunk-zjqvbcwa.js";import"./chunk-r8xwd8r1.js";import{m}from"./chunk-gz45xsbg.js";import"./chunk-47n5s7wk.js";import"./chunk-tpf8v2mb.js";import{Ut,so,Wt,Ki,lt,Xi,oo,qt,Ji,Kt}from"./chunk-87ksn02m.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()=>{Xi("Config file changed, restarting...");try{await e.onChange()}catch(p){lt(`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),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=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:y,variantViews:n,avgTimeSpent:g}}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:mt(),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 mt(){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{ut,dt,pt}from"./chunk-ema1c29k.js";import"./chunk-n91sm385.js";import"./chunk-zjqvbcwa.js";import"./chunk-r8xwd8r1.js";import{m}from"./chunk-tjnf4a8g.js";import"./chunk-47n5s7wk.js";import"./chunk-vhxrrqrg.js";import{Ut,so,Wt,Ki,lt,Xi,oo,qt,Ji,Kt}from"./chunk-87ksn02m.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()=>{Xi("Config file changed, restarting...");try{await e.onChange()}catch(p){lt(`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),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=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:y,variantViews:n,avgTimeSpent:g}}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:mt(),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 mt(){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 ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),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:ht(),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,yt),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 ht(){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-mxrmed55.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,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=h(e);if(!r)return null;let s={};if(await m(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-mxrmed55.js"),c={...r},n=h(e);if(n)try{await m(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:h(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 ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),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:ht(),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,yt),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 ht(){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-64evx0my.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,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=h(e);if(!r)return null;let s={};if(await m(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-64evx0my.js"),c={...r},n=h(e);if(n)try{await m(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:h(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 h(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 qt(t);dt(t,r);let s=Kt(t.config,r);pt(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 f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=Ji(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await qt(t);dt(t,u);let f=Kt(t.config,u);if(pt(t,f),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=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),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],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],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((g)=>g.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"}">
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{t,l}from"./chunk-r8xwd8r1.js";import{r,vn,h}from"./chunk-gz45xsbg.js";import{nt}from"./chunk-kxj5sp5w.js";import{Es,Ts}from"./chunk-rb6vr5v9.js";import{Cc,ei,_s,Cs}from"./chunk-ncrrxp60.js";import{Sc,kc}from"./chunk-46wqk1fb.js";import{St}from"./chunk-b1q40vq4.js";import{dn,Pc,yr,br}from"./chunk-bygxt820.js";import{g}from"./chunk-0dve54ne.js";import{ro}from"./chunk-69b8mr68.js";import Q from"fs";import N from"path";import{loadConfigWithResult as Bt}from"bunfig";var B={duration:300,delay:0,ease:"ease",direction:"both"};function it(e,n={}){let{duration:i,delay:o,ease:s,direction:c,custom:d}={...B,...n};if(e==="custom"&&d)return d;switch(e){case"fade":return`${c==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
2
+ import{t,l}from"./chunk-r8xwd8r1.js";import{r,vn,h}from"./chunk-tjnf4a8g.js";import{nt}from"./chunk-kxj5sp5w.js";import{Es,Ts}from"./chunk-rb6vr5v9.js";import{Cc,ei,_s,Cs}from"./chunk-ncrrxp60.js";import{Sc,kc}from"./chunk-302gek13.js";import{St}from"./chunk-b1q40vq4.js";import{dn,Pc,yr,br}from"./chunk-bygxt820.js";import{g}from"./chunk-0dve54ne.js";import{ro}from"./chunk-69b8mr68.js";import Q from"fs";import N from"path";import{loadConfigWithResult as Bt}from"bunfig";var B={duration:300,delay:0,ease:"ease",direction:"both"};function it(e,n={}){let{duration:i,delay:o,ease:s,direction:c,custom:d}={...B,...n};if(e==="custom"&&d)return d;switch(e){case"fade":return`${c==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
3
3
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
4
4
  @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${c==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
5
5
  @keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@@ -1307,6 +1307,6 @@ ${y}
1307
1307
  customElements.define('${n}', ${d});
1308
1308
  `}async function Ze(e,n,i,o){if(n.length<1)return l("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let s=n[0].replace(/['"]/g,""),d=(i.__stx_options||{}).componentsDir||"components",p=q.isAbsolute(d)?[q.join(d,`${s}.stx`),q.join(q.dirname(o),`${s}.stx`)]:[q.join(q.dirname(o),d,`${s}.stx`),q.join(process.cwd(),d,`${s}.stx`),q.join(q.dirname(o),`${s}.stx`)],u=null;for(let f of p)if(await r(f)){u=await Bun.file(f).text();break}if(!u)return l("WebComponent",`Component file not found: ${s}.stx`,t.FILE_NOT_FOUND);let m=Ht(u,s);return`<script type="module">
1309
1309
  ${Ut(m)}
1310
- </script>`}var F={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:dn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Te,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Ze,hasEndTag:!1,description:"Include a web component in the template"},Sc,kc,Es,Ts,Pe,Ae,_e,ke,Re,Ee,qe,Se,...ro],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Jt(e,n,i){let o=n||"pages";if(e)return{root:e,pagesDir:o};let s=i||process.cwd(),c=N.join(s,"resources","views"),d=N.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=N.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:o};return{root:".",pagesDir:o}}var Qe=new Set,pe=["partialsDir","componentsDir","layoutsDir"],Ce=new WeakMap;function Kt(e,n){let i=n.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let o=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return o===s||o.startsWith(`${s}/`)}function Wf(e,n){let i=!e.root,o=Jt(e.root,e.pagesDir,n);if(e.root=o.root,e.pagesDir=o.pagesDir,i&&o.root!=="."){let s=`${n}::${o.root}`;if(!Qe.has(s))Qe.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${o.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Ce.has(e)){let s={};for(let c of pe){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Ce.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of pe){let d=e[c];if(typeof d!=="string"||!d)continue;if(N.isAbsolute(d)||Kt(d,s))continue;e[c]=N.join(s,d)}}for(let s of pe){let c=e[s];if(typeof c!=="string"||!c||N.isAbsolute(c))continue;e[s]=N.resolve(n,c)}return e}function Gt(e,n){let i=Ce.get(e);for(let o of pe){let s=e[o];if(typeof s!=="string"||!s)continue;let c=N.isAbsolute(s)?s:N.join(n,s);if(Q.existsSync(c))continue;let d=i?.[o]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(o)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Yt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Xt(e){if(Pc(e.stateDir),e.stateDir=yr(),e.cachePath=br(e.cachePath),e.build)e.build.cacheDir=br(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=br(e.media.cache.directory);if(e.story)e.story.outDir=br(e.story.outDir)}var K=null,Y=new Map,ue=new Map,se=null;async function Zo(e,n=Bt){try{return await n(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function a(e){let n=e?N.resolve(e):process.cwd(),i=ue.get(n);if(i&&i.signature!==_s(i.graph)){let c=Y.get(n);if(Y.delete(n),ue.delete(n),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-gd7vyzhw.js"),{partialsCache:p}=await import("./chunk-th7343bz.js");if(d(),p.clear(),c&&i.configSignature===Cs(i.graph)){let u=c.then(async(m)=>{let y={...i.graph};await ei(y,n),ue.set(n,{graph:y,signature:_s(y),configSignature:Cs(y)});let f={...m,_layerGraph:y};if(!e)K=f;return f});return Y.set(n,u),u}}if(!e){if(K)return K;if(se)return se}let o=Y.get(n);if(o)return o;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(N.join(n,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(N.join(n,"config",`ui${v}`))),u;if(d&&p){let v=await Zo({name:"ui",cwd:N.join(n,"config"),defaultConfig:F,errorPolicy:"throw",verbose:!1});u=(await Zo({name:"stx",alias:"ui",cwd:n,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await Zo({name:"stx",alias:"ui",cwd:n,defaultConfig:F,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await Cc(n,F);u=v.config,ue.set(n,{graph:v.graph,signature:_s(v.graph),configSignature:Cs(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-n4c8srx8.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-sjcvc0bd.js");await b(n,u.runtimeConfig)}Yt(u),Xt(u),Wf(u,n),Gt(u,n);let m=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{g.resolve(b,{paths:[n]}),m.push(b)}catch{}}let f=[...u.plugins??[],...m];if(f.length>0){let{pluginManager:v}=await import("./chunk-z3qgv971.js"),b=[],w=[],k=new Set(u.componentPackages??["@stacksjs/components"]),C=[];for(let A of f){let P=typeof A==="string"?A:A[0],E=typeof A==="string"?{}:A[1]||{};try{let I,D;try{let x=g.resolve(P,{paths:[n]});I=await import(x),D=N.dirname(x)}catch{let x=N.resolve(n,P);I=await import(x),D=N.dirname(x)}let S=I.default||I;if(!v.has(S.name))await v.register(S,u);if(S.components){let x=Array.isArray(S.components)?S.components:[S.components],T=k.has(S.name)||k.has(P)||k.has(P.replace(/\/stx-plugin$/,""));for(let V of x){let M=N.resolve(D,V);if(b.push(M),T)w.push(M)}}if(S.pages){let x=N.resolve(D,S.pages),T=E.path||"/";C.push({dir:x,prefix:T})}if(S.setup){let x={addDirective:(T)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(T)},addRoute:(T,V)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[T]=V},addMiddleware:(T)=>{u.middleware=u.middleware||[],u.middleware.push(T)},pluginDir:D,config:u};await S.setup(E,x)}process.stderr.write(`[stx] Plugin loaded: ${S.name||P}
1310
+ </script>`}var F={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:dn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Te,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Ze,hasEndTag:!1,description:"Include a web component in the template"},Sc,kc,Es,Ts,Pe,Ae,_e,ke,Re,Ee,qe,Se,...ro],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Jt(e,n,i){let o=n||"pages";if(e)return{root:e,pagesDir:o};let s=i||process.cwd(),c=N.join(s,"resources","views"),d=N.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=N.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:o};return{root:".",pagesDir:o}}var Qe=new Set,pe=["partialsDir","componentsDir","layoutsDir"],Ce=new WeakMap;function Kt(e,n){let i=n.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let o=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return o===s||o.startsWith(`${s}/`)}function Wf(e,n){let i=!e.root,o=Jt(e.root,e.pagesDir,n);if(e.root=o.root,e.pagesDir=o.pagesDir,i&&o.root!=="."){let s=`${n}::${o.root}`;if(!Qe.has(s))Qe.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${o.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Ce.has(e)){let s={};for(let c of pe){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Ce.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of pe){let d=e[c];if(typeof d!=="string"||!d)continue;if(N.isAbsolute(d)||Kt(d,s))continue;e[c]=N.join(s,d)}}for(let s of pe){let c=e[s];if(typeof c!=="string"||!c||N.isAbsolute(c))continue;e[s]=N.resolve(n,c)}return e}function Gt(e,n){let i=Ce.get(e);for(let o of pe){let s=e[o];if(typeof s!=="string"||!s)continue;let c=N.isAbsolute(s)?s:N.join(n,s);if(Q.existsSync(c))continue;let d=i?.[o]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(o)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Yt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Xt(e){if(Pc(e.stateDir),e.stateDir=yr(),e.cachePath=br(e.cachePath),e.build)e.build.cacheDir=br(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=br(e.media.cache.directory);if(e.story)e.story.outDir=br(e.story.outDir)}var K=null,Y=new Map,ue=new Map,se=null;async function Zo(e,n=Bt){try{return await n(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function a(e){let n=e?N.resolve(e):process.cwd(),i=ue.get(n);if(i&&i.signature!==_s(i.graph)){let c=Y.get(n);if(Y.delete(n),ue.delete(n),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-aw45yjrw.js"),{partialsCache:p}=await import("./chunk-zztfp9qh.js");if(d(),p.clear(),c&&i.configSignature===Cs(i.graph)){let u=c.then(async(m)=>{let y={...i.graph};await ei(y,n),ue.set(n,{graph:y,signature:_s(y),configSignature:Cs(y)});let f={...m,_layerGraph:y};if(!e)K=f;return f});return Y.set(n,u),u}}if(!e){if(K)return K;if(se)return se}let o=Y.get(n);if(o)return o;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(N.join(n,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(N.join(n,"config",`ui${v}`))),u;if(d&&p){let v=await Zo({name:"ui",cwd:N.join(n,"config"),defaultConfig:F,errorPolicy:"throw",verbose:!1});u=(await Zo({name:"stx",alias:"ui",cwd:n,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await Zo({name:"stx",alias:"ui",cwd:n,defaultConfig:F,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await Cc(n,F);u=v.config,ue.set(n,{graph:v.graph,signature:_s(v.graph),configSignature:Cs(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-n4c8srx8.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-fpc1n3je.js");await b(n,u.runtimeConfig)}Yt(u),Xt(u),Wf(u,n),Gt(u,n);let m=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{g.resolve(b,{paths:[n]}),m.push(b)}catch{}}let f=[...u.plugins??[],...m];if(f.length>0){let{pluginManager:v}=await import("./chunk-z3qgv971.js"),b=[],w=[],k=new Set(u.componentPackages??["@stacksjs/components"]),C=[];for(let A of f){let P=typeof A==="string"?A:A[0],E=typeof A==="string"?{}:A[1]||{};try{let I,D;try{let x=g.resolve(P,{paths:[n]});I=await import(x),D=N.dirname(x)}catch{let x=N.resolve(n,P);I=await import(x),D=N.dirname(x)}let S=I.default||I;if(!v.has(S.name))await v.register(S,u);if(S.components){let x=Array.isArray(S.components)?S.components:[S.components],T=k.has(S.name)||k.has(P)||k.has(P.replace(/\/stx-plugin$/,""));for(let V of x){let M=N.resolve(D,V);if(b.push(M),T)w.push(M)}}if(S.pages){let x=N.resolve(D,S.pages),T=E.path||"/";C.push({dir:x,prefix:T})}if(S.setup){let x={addDirective:(T)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(T)},addRoute:(T,V)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[T]=V},addMiddleware:(T)=>{u.middleware=u.middleware||[],u.middleware.push(T)},pluginDir:D,config:u};await S.setup(E,x)}process.stderr.write(`[stx] Plugin loaded: ${S.name||P}
1311
1311
  `)}catch(I){console.warn(`[stx] Failed to load plugin ${P}:`,I.message)}}u._pluginComponentDirs=b,u._componentPackageDirs=w,u._pluginPageDirs=C}if(u.nativePrimitives!==!1)u._nativePrimitivesFallback={dir:Ss(),except:["Button","Checkbox","Switch","TextInput","Image","Video"]};return u})();if(Y.set(n,s),s.catch(()=>{if(Y.get(n)===s)Y.delete(n)}),!e)se=s,s.then((c)=>{K=c}).catch(()=>{});return s}var O=new Proxy(F,{get(e,n){if(K&&n in K)return K[n];if(!se)a().catch((i)=>{console.warn("[stx] Failed to load config file:",i?.message||i)});return e[n]}});function Kh(e){return e}function Xh(e){let n=[],i=[];if(e.partialsDir!==void 0&&typeof e.partialsDir!=="string")n.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(e.componentsDir!==void 0&&typeof e.componentsDir!=="string")n.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(e.cache!==void 0&&typeof e.cache!=="boolean")n.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(e.debug!==void 0&&typeof e.debug!=="boolean")n.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(e.streaming){if(e.streaming.bufferSize!==void 0){if(typeof e.streaming.bufferSize!=="number"||e.streaming.bufferSize<=0)n.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(e.streaming.timeout!==void 0){if(typeof e.streaming.timeout!=="number"||e.streaming.timeout<=0)n.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(e.streaming.strategy!==void 0){let o=["auto","manual","sections"];if(!o.includes(e.streaming.strategy))n.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${o.join(", ")}`,severity:"error"})}}if(e.i18n){if(e.i18n.format!==void 0){let o=["json","yaml","yml","js"];if(!o.includes(e.i18n.format))n.push({path:"i18n.format",message:`i18n.format must be one of: ${o.join(", ")}`,severity:"error"})}}if(e.animation){if(e.animation.defaultDuration!==void 0){if(typeof e.animation.defaultDuration!=="number"||e.animation.defaultDuration<0)n.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(e.animation.staggerDelay!==void 0){if(typeof e.animation.staggerDelay!=="number"||e.animation.staggerDelay<0)n.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(e.a11y){if(e.a11y.level!==void 0){let o=["AA","AAA"];if(!o.includes(e.a11y.level))n.push({path:"a11y.level",message:`a11y.level must be one of: ${o.join(", ")}`,severity:"error"})}}if(e.hydration){if(e.hydration.mode!==void 0){let o=["progressive","islands"];if(!o.includes(e.hydration.mode))n.push({path:"hydration.mode",message:`hydration.mode must be one of: ${o.join(", ")}`,severity:"error"})}if(e.hydration.preload!==void 0){let o=["none","eager","lazy"];if(!o.includes(e.hydration.preload))n.push({path:"hydration.preload",message:`hydration.preload must be one of: ${o.join(", ")}`,severity:"error"})}}if(e.customDirectives)if(!Array.isArray(e.customDirectives))n.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else e.customDirectives.forEach((o,s)=>{if(!o.name||typeof o.name!=="string")n.push({path:`customDirectives[${s}].name`,message:"Custom directive must have a name string",severity:"error"});if(!o.handler||typeof o.handler!=="function")n.push({path:`customDirectives[${s}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(e.middleware)if(!Array.isArray(e.middleware))n.push({path:"middleware",message:"middleware must be an array",severity:"error"});else e.middleware.forEach((o,s)=>{if(!o.name||typeof o.name!=="string")n.push({path:`middleware[${s}].name`,message:"Middleware must have a name string",severity:"error"});if(!o.handler||typeof o.handler!=="function")n.push({path:`middleware[${s}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!o.timing||!["before","after"].includes(o.timing))n.push({path:`middleware[${s}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(e.debug===!0&&e.cache===!0)i.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(e.seo?.enabled===!0&&!e.seo?.defaultConfig?.title)i.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(e.pwa){if(e.pwa.enabled===!0&&!e.pwa.manifest?.name)n.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(e.pwa.manifest?.display!==void 0){let o=["fullscreen","standalone","minimal-ui","browser"];if(!o.includes(e.pwa.manifest.display))n.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${o.join(", ")}`,severity:"error"})}if(e.pwa.manifest?.orientation!==void 0){let o=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!o.includes(e.pwa.manifest.orientation))n.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${o.join(", ")}`,severity:"error"})}if(e.pwa.routes){let o=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];e.pwa.routes.forEach((s,c)=>{if(!s.pattern||typeof s.pattern!=="string")n.push({path:`pwa.routes[${c}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!o.includes(s.strategy))n.push({path:`pwa.routes[${c}].strategy`,message:`PWA route strategy must be one of: ${o.join(", ")}`,severity:"error"});if(s.maxAgeSeconds!==void 0&&(typeof s.maxAgeSeconds!=="number"||s.maxAgeSeconds<0))n.push({path:`pwa.routes[${c}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(s.maxEntries!==void 0&&(typeof s.maxEntries!=="number"||s.maxEntries<1))n.push({path:`pwa.routes[${c}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(e.pwa.icons?.sizes){if(!Array.isArray(e.pwa.icons.sizes))n.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(e.pwa.icons.sizes.filter((s)=>typeof s!=="number"||s<16||s>1024).length>0)n.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(e.pwa.icons?.purpose){let o=["any","maskable","monochrome"];if(e.pwa.icons.purpose.filter((c)=>!o.includes(c)).length>0)n.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${o.join(", ")}`,severity:"error"})}if(e.pwa.enabled===!0&&!e.pwa.icons?.src)i.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(e.pwa.enabled===!0&&!e.pwa.manifest?.themeColor)i.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:n.length===0,errors:n,warnings:i}}
1312
1312
  export{hc,yc,fr,et,bc,Ss,ks,F,Wf,Zo,a,O,Kh,Xh};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Pf,cc,Ph,lc,If,Of,ln,ar,Ih,Nf,Df,Oh,b}from"./chunk-sfww6v6m.js";import"./chunk-e5seb8f7.js";import"./chunk-gz45xsbg.js";import"./chunk-tpf8v2mb.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{ln as buildCss,Nf as extractClassNames,Of as fingerprintConfig,Df as generateCss,Ih as getCachedCSS,Pf as getCssServeAsset,b as injectCss,cc as loadCssEngine,lc as loadCssEngineConfig,ar as rebuildCss,Ph as resetCssCache,If as resolveUserCssConfig,Oh as withLinkedModuleBundles};
2
+ import{Pf,cc,Ph,lc,If,Of,ln,ar,Ih,Nf,Df,Oh,b}from"./chunk-zwxncs2e.js";import"./chunk-y7aqf8r7.js";import"./chunk-tjnf4a8g.js";import"./chunk-vhxrrqrg.js";import"./chunk-47n5s7wk.js";import"./chunk-r8xwd8r1.js";import"./chunk-zjqvbcwa.js";import"./chunk-n91sm385.js";export{ln as buildCss,Nf as extractClassNames,Of as fingerprintConfig,Df as generateCss,Ih as getCachedCSS,Pf as getCssServeAsset,b as injectCss,cc as loadCssEngine,lc as loadCssEngineConfig,ar as rebuildCss,Ph as resetCssCache,If as resolveUserCssConfig,Oh as withLinkedModuleBundles};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{ct,hl}from"./chunk-n91sm385.js";import{I}from"./chunk-zjqvbcwa.js";import{V,Ns,o,pn,q,y,Nc,Mt,wn,Be,Fe}from"./chunk-gz45xsbg.js";import{ur}from"./chunk-7cxbt404.js";import{B}from"./chunk-ybq56wam.js";import{un}from"./chunk-kbv5nwwd.js";var X=`(?:"[^"]*"|'[^']*'|[^>"'])*`,H=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Q=65536,J=4,O=new Map;function Bh(){O.clear()}function K(e){let c=[];for(let t of y(e,q)){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 ms(e,c={}){let t=e.length>=Q,n=t?O.get(e):void 0;if(n===void 0){if(n=K(e),t)Nc(O,J),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 qo(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 hs(e,c){return hl(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 cr(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(${X})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=y(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=qo(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 Z(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(H);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 Ko(e,c){let t=cr(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,w=1,E=S,x=/@(if\s*\(|endif)/g;x.lastIndex=S;let h;while((h=x.exec(u))!==null)if(h[1].startsWith("if"))w++;else if(h[1]==="endif"){if(w--,w===0){E=h.index+h[0].length;break}}if(w!==0)continue;let R=u.substring(S,E-6).trim(),A;if(Y(R)){let C=un(u.substring(a,E));if(C.length===0)continue;let k=C[0].branches.filter((_)=>_.type!=="else"),L=i(a);if(!(k.length>0&&k.every((_)=>Z(_.condition,t,c,L))))continue;A=C[0].branches.map((_)=>{let N=n(_.content);if(_.type==="elseif")return M(N,"@else-if",_.condition??"");if(_.type==="else")return M(N,"@else");return M(N,"@if",_.condition??"")}).join(`
2
+ import{ct,hl}from"./chunk-n91sm385.js";import{I}from"./chunk-zjqvbcwa.js";import{V,Ns,o,pn,q,y,Nc,Mt,wn,Be,Fe}from"./chunk-tjnf4a8g.js";import{ur}from"./chunk-7r4p7zjn.js";import{B}from"./chunk-ybq56wam.js";import{un}from"./chunk-kbv5nwwd.js";var X=`(?:"[^"]*"|'[^']*'|[^>"'])*`,H=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Q=65536,J=4,O=new Map;function Bh(){O.clear()}function K(e){let c=[];for(let t of y(e,q)){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 ms(e,c={}){let t=e.length>=Q,n=t?O.get(e):void 0;if(n===void 0){if(n=K(e),t)Nc(O,J),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 qo(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 hs(e,c){return hl(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 cr(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(${X})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=y(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=qo(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 Z(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(H);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 Ko(e,c){let t=cr(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,w=1,E=S,x=/@(if\s*\(|endif)/g;x.lastIndex=S;let h;while((h=x.exec(u))!==null)if(h[1].startsWith("if"))w++;else if(h[1]==="endif"){if(w--,w===0){E=h.index+h[0].length;break}}if(w!==0)continue;let R=u.substring(S,E-6).trim(),A;if(Y(R)){let C=un(u.substring(a,E));if(C.length===0)continue;let k=C[0].branches.filter((_)=>_.type!=="else"),L=i(a);if(!(k.length>0&&k.every((_)=>Z(_.condition,t,c,L))))continue;A=C[0].branches.map((_)=>{let N=n(_.content);if(_.type==="elseif")return M(N,"@else-if",_.condition??"");if(_.type==="else")return M(N,"@else");return M(N,"@if",_.condition??"")}).join(`
3
3
  `)}else{if(!Z(b,t,c,i(a)))continue;A=M(n(R),"@if",b)}r.push({start:a,end:E,replacement:A}),p.lastIndex=E}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"]),F=/<(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}F.lastIndex=i;let m=F.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 Xo(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"]);y(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 w=l;while(l<r.length&&!n.test(r[l])&&r[l]!=="="&&r[l]!==">")l++;if(l===w)return-1;let E=r.slice(w,l);if(E.startsWith("@")&&E.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(E))d={attrName:E,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 U=[":for","@for","x-for"];function Ff(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 ys(e,c){if(!c||Object.keys(c).length===0)return e;if(!U.some((i)=>e.includes(`${i}=`)))return e;let t=cr(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=U.map((A)=>({attr:A,m:new RegExp(`\\s${A}="([^"]*)"`).exec(m)})).find((A)=>A.m!==null);if(!g||!g.m)continue;let l=qo(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|$)/,""),w=n.slice(a,b-`</${p}>`.length),E={...c,[l.itemVar]:void 0};if(l.indexVar)E[l.indexVar]=void 0;let x=ys(w,E),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 bs(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=qo(g),b=i==="for"?"@endfor":"@endforeach",S=1,w=l,E=i==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${i}\\s*\\(|end${i})`,"g");E.lastIndex=l;let x;while((x=E.exec(t))!==null)if(x[1].startsWith(i))S++;else if(S--,S===0){w=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:w,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 T=v.split(/[.[(]/)[0].trim(),_=c?T in c:!1,N=f.some((j)=>p>j.start&&p<j.end&&j.vars.includes(T));if(T&&(_||N)){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,w-b.length).trim(),A=c?{...c}:{};if(d.itemVar)delete A[d.itemVar];if(d.indexVar)delete A[d.indexVar];let C=Ff(bs(R,A)),k=C.match(H),L;if(k){let[,v,T,_]=k;L=`<${v}${T} @for="${g}">${_}</${v}>`}else L=`<template @for="${g}">${C}</template>`;u.push({start:p,end:w,replacement:L}),n.lastIndex=w}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(${X})>`,"iy"),t=null,n=null;return y(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 ws(e,c,t,n={}){let s=ms(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-76a66cw3.js"));for(let x of s){let h=x.body;if(Be(x.attrs))h=Fe(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(Mt(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??Mt(f[x].content).code;if(!f[x].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=vt(h);let R=I(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(${X})>`,"iy"),t=null,n=null;return y(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 ws(e,c,t,n={}){let s=ms(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-fz433ybr.js"));for(let x of s){let h=x.body;if(Be(x.attrs))h=Fe(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(Mt(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??Mt(f[x].content).code;if(!f[x].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=vt(h);let R=I(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=V(g).split(",").map((x)=>x.trim()).filter(Boolean),b=wn(g,t),S=`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ts,ns}from"./chunk-r3jf8v5a.js";import{y}from"./chunk-gz45xsbg.js";import{a}from"./chunk-vhckqe4x.js";import{Xe,se}from"./chunk-fm8gfj2g.js";import{Qa}from"./chunk-my85fge2.js";import{B}from"./chunk-ybq56wam.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as z,mkdirSync as S,copyFileSync as P,chmodSync as I,rmSync as ve}from"fs";import{join as c,basename as xe,resolve as X}from"path";import{spawn as _}from"child_process";import{platform as ye}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=y(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 yu=`
2
+ import{ts,ns}from"./chunk-r3jf8v5a.js";import{y}from"./chunk-tjnf4a8g.js";import{a}from"./chunk-md84j62m.js";import{Xe,se}from"./chunk-fm8gfj2g.js";import{Qa}from"./chunk-0gg7k9cj.js";import{B}from"./chunk-ybq56wam.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as z,mkdirSync as S,copyFileSync as P,chmodSync as I,rmSync as ve}from"fs";import{join as c,basename as xe,resolve as X}from"path";import{spawn as _}from"child_process";import{platform as ye}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=y(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 yu=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{q,De}from"./chunk-gz45xsbg.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function en(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=De(t,s);if(p>s){c=p;continue}let a=q(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
2
+ import{q,De}from"./chunk-tjnf4a8g.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function en(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=De(t,s);if(p>s){c=p;continue}let a=q(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
3
3
  export{en};