@stacksjs/stx 0.2.807 → 0.2.811

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 (85) hide show
  1. package/dist/{chunk-y46546ng.js → chunk-15hfs2cp.js} +1 -1
  2. package/dist/{chunk-35xkrsc8.js → chunk-161n5e5y.js} +5 -5
  3. package/dist/{chunk-7vqn0jq4.js → chunk-16p71jmw.js} +2 -2
  4. package/dist/{chunk-cg8bchrm.js → chunk-1jr259ct.js} +1 -1
  5. package/dist/{chunk-e9rtxq1j.js → chunk-1jwqjdk7.js} +1 -1
  6. package/dist/chunk-20bcj7cm.js +2 -0
  7. package/dist/{chunk-0n4y5gwq.js → chunk-20qn18ry.js} +2 -2
  8. package/dist/{chunk-ex19yrm8.js → chunk-390v4dv9.js} +1 -1
  9. package/dist/{chunk-hfshp3ng.js → chunk-3affwe7d.js} +1 -1
  10. package/dist/{chunk-525sz0z9.js → chunk-3fq9v4a4.js} +1 -1
  11. package/dist/{chunk-8k1668e5.js → chunk-3hzdpc0m.js} +1 -1
  12. package/dist/chunk-3tf2wwwt.js +2 -0
  13. package/dist/{chunk-2631z9wj.js → chunk-3y6jhcrb.js} +2 -2
  14. package/dist/{chunk-jef0etaf.js → chunk-41n0qrc0.js} +1 -1
  15. package/dist/chunk-45bh5bjj.js +2 -0
  16. package/dist/{chunk-xxfxjd6p.js → chunk-4664b8rv.js} +1 -1
  17. package/dist/{chunk-eem3fbm2.js → chunk-49xn95m7.js} +1 -1
  18. package/dist/chunk-4jmzw6kg.js +2 -0
  19. package/dist/{chunk-na899cb8.js → chunk-5ffzbq9r.js} +2 -2
  20. package/dist/{chunk-eq6yy555.js → chunk-66mz8bf3.js} +1 -1
  21. package/dist/{chunk-gqzcd0ge.js → chunk-6ct3hhae.js} +1 -1
  22. package/dist/{chunk-ftsy0ykz.js → chunk-6nskg4sx.js} +1 -1
  23. package/dist/{chunk-4dnp3pv4.js → chunk-7d1kx4zz.js} +1 -1
  24. package/dist/{chunk-k70m9h98.js → chunk-7vqhm1rx.js} +1 -1
  25. package/dist/chunk-8aw5chnj.js +2 -0
  26. package/dist/{chunk-254w56b2.js → chunk-aak95hpm.js} +1 -1
  27. package/dist/{chunk-8z0psa9p.js → chunk-agcfhj1v.js} +1 -1
  28. package/dist/{chunk-hn2me1qx.js → chunk-bmkm1c8s.js} +8 -5
  29. package/dist/{chunk-4q2y26h9.js → chunk-c84fwzfq.js} +4 -4
  30. package/dist/{chunk-nf90jkq4.js → chunk-cm23d335.js} +1 -1
  31. package/dist/{chunk-csbwcq49.js → chunk-cx2bwpfj.js} +1 -1
  32. package/dist/{chunk-0t5752am.js → chunk-cxf2pdjk.js} +1 -1
  33. package/dist/{chunk-rda1ay0m.js → chunk-ds9c47sj.js} +1 -1
  34. package/dist/{chunk-46mj0hv3.js → chunk-e3qkbq8g.js} +1 -1
  35. package/dist/chunk-ehmy6gyb.js +2 -0
  36. package/dist/{chunk-zqdp8jkn.js → chunk-evnznyg7.js} +1 -1
  37. package/dist/chunk-ez0d7fpw.js +2 -0
  38. package/dist/{chunk-9n5smeee.js → chunk-f33wwacc.js} +4 -4
  39. package/dist/{chunk-hzve1dmt.js → chunk-fg20p7by.js} +1 -1
  40. package/dist/{chunk-r51b2jzt.js → chunk-j54ph3jm.js} +2 -2
  41. package/dist/{chunk-730tqfvd.js → chunk-jd1mvgwb.js} +3 -3
  42. package/dist/{chunk-vmmd87n9.js → chunk-jf0cn7e2.js} +2 -2
  43. package/dist/chunk-jqhcst3j.js +2 -0
  44. package/dist/chunk-jvs9g0c0.js +2 -0
  45. package/dist/{chunk-6zx9trgf.js → chunk-k11bkgx6.js} +1 -1
  46. package/dist/{chunk-pvy3ekgn.js → chunk-kfgbk0x9.js} +1 -1
  47. package/dist/{chunk-ft6gkkq1.js → chunk-kr5jhk30.js} +1 -1
  48. package/dist/{chunk-2qz0p785.js → chunk-m76jbcey.js} +6 -6
  49. package/dist/chunk-mfnyqcfg.js +2 -0
  50. package/dist/{chunk-ptjyp3zj.js → chunk-mt7d37jh.js} +1 -1
  51. package/dist/{chunk-tc1p7zq9.js → chunk-n15eyqcr.js} +1 -1
  52. package/dist/{chunk-ef2b45hd.js → chunk-n9pbkj5v.js} +1 -1
  53. package/dist/{chunk-yq627be9.js → chunk-ncmdmgrj.js} +1 -1
  54. package/dist/{chunk-jdng2ysa.js → chunk-nk51w4tw.js} +1 -1
  55. package/dist/chunk-p8eg9kne.js +2 -0
  56. package/dist/{chunk-dkd29vr5.js → chunk-peabdz2j.js} +1 -1
  57. package/dist/chunk-pmrkv7v3.js +2 -0
  58. package/dist/{chunk-a3g6hw1h.js → chunk-q4efhj8q.js} +1 -1
  59. package/dist/{chunk-nrqv8s48.js → chunk-qckgv0vz.js} +1 -1
  60. package/dist/{chunk-5yrd85bz.js → chunk-s1w9nxws.js} +1 -1
  61. package/dist/{chunk-d73psv96.js → chunk-vt5nrrax.js} +4 -4
  62. package/dist/{chunk-m0cc6371.js → chunk-vz5beayx.js} +1 -1
  63. package/dist/{chunk-taj060c6.js → chunk-w050qx5j.js} +2 -2
  64. package/dist/{chunk-xyykkdeq.js → chunk-y3jx43d7.js} +4 -4
  65. package/dist/chunk-y6pyr4km.js +3 -0
  66. package/dist/{chunk-6dz1fcx1.js → chunk-zfes9kn1.js} +1 -1
  67. package/dist/cli.js +7 -7
  68. package/dist/craft-entry.js +1 -1
  69. package/dist/craft.js +1 -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-13j5cjny.js +0 -2
  74. package/dist/chunk-29v9nvxg.js +0 -2
  75. package/dist/chunk-539ybrej.js +0 -2
  76. package/dist/chunk-6f3rgznm.js +0 -2
  77. package/dist/chunk-6ndpbfmg.js +0 -3
  78. package/dist/chunk-c8va24ad.js +0 -2
  79. package/dist/chunk-j0f4q1wt.js +0 -2
  80. package/dist/chunk-jqejgpae.js +0 -2
  81. package/dist/chunk-nqjte4va.js +0 -2
  82. package/dist/chunk-qv0k6yyd.js +0 -2
  83. package/dist/chunk-rf5fkpbg.js +0 -2
  84. package/dist/chunk-sntkg6n4.js +0 -2
  85. package/dist/chunk-z2d52bhw.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{m,gi,Uc,Wc,ig,ag,cg,lg,ug,Vs,dg,je,Y,Be,pg,Er,fg,Xc,Gc,yi,Fe,s,bn,Jc,h,fe,Xh}from"./chunk-2qz0p785.js";import"./chunk-pvy3ekgn.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Gc as SIGNAL_COMPOSABLE_CALL,fe as clearComponentCache,yi as componentClientSignalNames,gi as convertToCommonJS,h as createDetailedErrorMessage,ug as extractDirectiveNames,Uc as extractScriptFromTemplate,m as extractVariables,s as fileExists,Xh as getComponentCacheStats,ag as getPositionInfo,Y as getSharedTranspiler,Jc as getSourceLineInfo,lg as hasDirectives,Wc as hasVariables,fg as isHydrateTrigger,dg as isJavaScriptScript,Fe as renderComponentWithSlot,bn as resolveTemplatePath,pg as scopeOnRootElement,Vs as scopeSequenceKey,je as shouldTranspileTypeScript,Xc as slotContentHasExpressions,Be as transpileTypeScript,Er as userComponentFileExists,cg as validateDirective,ig as validateTemplate};
2
+ import{m,gi,Uc,Wc,ig,ag,cg,lg,ug,Vs,dg,je,Y,Be,pg,Er,fg,Xc,Gc,yi,Fe,s,bn,Jc,h,fe,Xh}from"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Gc as SIGNAL_COMPOSABLE_CALL,fe as clearComponentCache,yi as componentClientSignalNames,gi as convertToCommonJS,h as createDetailedErrorMessage,ug as extractDirectiveNames,Uc as extractScriptFromTemplate,m as extractVariables,s as fileExists,Xh as getComponentCacheStats,ag as getPositionInfo,Y as getSharedTranspiler,Jc as getSourceLineInfo,lg as hasDirectives,Wc as hasVariables,fg as isHydrateTrigger,dg as isJavaScriptScript,Fe as renderComponentWithSlot,bn as resolveTemplatePath,pg as scopeOnRootElement,Vs as scopeSequenceKey,je as shouldTranspileTypeScript,Xc as slotContentHasExpressions,Be as transpileTypeScript,Er as userComponentFileExists,cg as validateDirective,ig as validateTemplate};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{de,gn,It,Ot,m,s,fe,p}from"./chunk-2qz0p785.js";import{yt,Re,rc,is,No,Mo,i}from"./chunk-4q2y26h9.js";import{ie,ae,Tr,ke,F,Sn}from"./chunk-gebb12ak.js";import{St,pr,$s,Rs,As,kt,_t,Ct,Et,Tt,$t,et}from"./chunk-hn2me1qx.js";import{Ss,a,I}from"./chunk-0n4y5gwq.js";import{ft,An,Ce,L,aa,mo,Kr,We,ca,qe,Ee}from"./chunk-730tqfvd.js";import{lr,ur}from"./chunk-xxfxjd6p.js";import{$n}from"./chunk-eq6yy555.js";import{e,cn,sr,y}from"./chunk-r51b2jzt.js";import{Je}from"./chunk-xyykkdeq.js";import{$e}from"./chunk-7sh9fa3q.js";import{X,be,we}from"./chunk-9n5smeee.js";import{c}from"./chunk-0rjcbqk3.js";import{K}from"./chunk-c5vzr1va.js";async function Nn(t){try{let n=await Bun.file(t).text(),r=Un(n),d=Wn(n,t),o=Vn(n,r),l=qn(n,r);return{file:t,metrics:r,issues:d,suggestions:o,performance:l}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Un(t){let n=t.split(`
2
+ import{de,gn,It,Ot,m,s,fe,p}from"./chunk-m76jbcey.js";import{yt,Re,rc,is,No,Mo,i}from"./chunk-c84fwzfq.js";import{ie,ae,Tr,ke,F,Sn}from"./chunk-gebb12ak.js";import{St,pr,$s,Rs,As,kt,_t,Ct,Et,Tt,$t,et}from"./chunk-bmkm1c8s.js";import{Ss,a,I}from"./chunk-20qn18ry.js";import{ft,An,Ce,L,aa,mo,Kr,We,ca,qe,Ee}from"./chunk-jd1mvgwb.js";import{lr,ur}from"./chunk-4664b8rv.js";import{$n}from"./chunk-66mz8bf3.js";import{e,cn,sr,y}from"./chunk-j54ph3jm.js";import{Je}from"./chunk-y3jx43d7.js";import{$e}from"./chunk-7sh9fa3q.js";import{X,be,we}from"./chunk-f33wwacc.js";import{c}from"./chunk-0rjcbqk3.js";import{K}from"./chunk-c5vzr1va.js";async function Nn(t){try{let n=await Bun.file(t).text(),r=Un(n),d=Wn(n,t),o=Vn(n,r),l=qn(n,r);return{file:t,metrics:r,issues:d,suggestions:o,performance:l}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Un(t){let n=t.split(`
3
3
  `),r=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),o=(r?r[1]:"").split(`
4
4
  `).length,l={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};l.total=l.conditionals+l.loops+l.includes+l.custom;let u=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,f=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,g=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,h=u+f+g,x=(t.match(/<[A-Z][^>]*>/g)||[]).length,v=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,T=0;for(let k of n)if(/@(?:if|unless|foreach|for|while|section)\b/.test(k)&&!/@end/.test(k)&&!/@else/.test(k))T++,S=Math.max(S,T);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(k))T--;let w=S>=4?3:0,b=Math.min(10,Math.ceil(l.total*0.5+h*0.1+x*0.3+(o>10?o*0.05:0)+w));return{lines:n.length,characters:t.length,directives:l,expressions:h,components:x,layouts:v,scriptLines:o,complexity:b}}function Wn(t,n){let r=[],d=Xt(t,"if","endif");if(d>0)r.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let o=Xt(t,"foreach","endforeach");if(o>0)r.push({type:"error",category:"syntax",message:`Found ${o} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let l=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(l&&l.length>0)r.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)r.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let f=t.match(/<img[^>]*>/g);if(f){let x=f.filter((v)=>!v.includes("alt="));if(x.length>0)r.push({type:"warning",category:"accessibility",message:`Found ${x.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let g=t.split(`
5
5
  `).filter((x)=>x.length>120);if(g.length>0)r.push({type:"info",category:"maintainability",message:`Found ${g.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)r.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return r}function Vn(t,n){let r=[];if(n.complexity>7)r.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)r.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)r.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)r.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)r.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)r.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)r.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return r}function qn(t,n){let r=1;if(r+=n.directives.conditionals*0.1,r+=n.directives.loops*0.5,r+=n.directives.includes*2,r+=n.expressions*0.05,r+=n.components*1,n.scriptLines>10)r+=n.scriptLines*0.1;let d;if(n.expressions===0&&n.directives.total===0)d="high";else if(n.expressions<5&&n.directives.total<3)d="medium";else d="low";let o=[];if(r>10)o.push("Consider optimizing template complexity");if(d==="low"&&n.directives.total>5)o.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)o.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(r*100)/100,complexityScore:n.complexity,cacheability:d,recommendations:o}}function Xt(t,n,r){let d=t.replace(/<!--[\s\S]*?-->/g,""),o=(d.match(new RegExp(`@${n}\\b`,"g"))||[]).length,l=(d.match(new RegExp(`@${r}\\b`,"g"))||[]).length;return Math.abs(o-l)}async function Xi(t=["**/*.stx"],n){let r=[],d=[];for(let l of t){let u=await Array.fromAsync(new Bun.Glob(l).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((f)=>f.endsWith(".stx")))}for(let l of d)try{let u=await Nn(l);r.push(u)}catch(u){console.warn(`Failed to analyze ${l}:`,u)}let o=Kn(r);return{results:r,summary:o}}function Kn(t){let n=t.length,r=t.reduce((h,x)=>h+x.metrics.lines,0),d=n>0?t.reduce((h,x)=>h+x.metrics.complexity,0)/n:0,o=t.reduce((h,x)=>h+x.issues.length,0),l={};t.forEach((h)=>{h.issues.forEach((x)=>{l[x.category]=(l[x.category]||0)+1})});let u=n>0?t.reduce((h,x)=>h+x.performance.estimatedRenderTime,0)/n:0,f=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),g=[];if(d>6)g.push("Project has high average complexity. Consider refactoring complex templates.");if(o>n*2)g.push("High number of issues detected. Run detailed analysis on individual files.");if(l.security>0)g.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:r,avgComplexity:Math.round(d*100)/100,totalIssues:o,issuesByCategory:l,performanceScore:f,recommendations:g}}import{mkdir as Xn,readFile as Gn,readdir as Jn,stat as Gt,writeFile as Yn}from"fs/promises";import Te from"path";function tn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var nn=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function Qn(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function jt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Zn(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function er(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function tr(t){let n=[];async function r(d){let o=await Jn(d,{withFileTypes:!0});o.sort((l,u)=>l.name.localeCompare(u.name));for(let l of o){let u=Te.join(d,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(t),n}function nr(t,n){let r=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!r)return{};let d=r[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(o){throw Error(`${n}: <script component> must contain JSON metadata (${o.message})`)}}function rr(t,n){let r={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let o of d){if(!/\bclient\b/i.test(o[1])||/\bcomponent\b|\bstx:component\b/i.test(o[1]))continue;let l;try{l=new Bun.Transpiler({loader:"ts"}).transformSync(o[2])}catch(g){throw Error(`${n}: failed to transpile <script client> (${g.message})`)}let u=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,f;while(f=u.exec(l)){let g=f[1];if(nn.has(g))throw Error(`${n}: client ${tn(g)}`);let h=u.lastIndex,x=1,v="",S=!1,T=h;for(;T<l.length&&x>0;T++){let b=l[T];if(S){S=!1;continue}if(v){if(b==="\\")S=!0;else if(b===v)v="";continue}if(b==='"'||b==="'"||b==="`")v=b;else if(b==="{")x++;else if(b==="}")x--}if(x!==0)throw Error(`${n}: unterminated client function "${g}"`);let w=f[0].includes("async")?"async ":"";r[g]=`${w}${g}(${f[2]}) {${l.slice(h,T-1)}}`,u.lastIndex=T}}return r}function or(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Jt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
@@ -887,7 +887,7 @@ else {
887
887
  };
888
888
  })();
889
889
  </script>
890
- `}function Ne(t,n,r={}){let d=Br(n,r),o=t.lastIndexOf("</body>");if(o!==-1)return t.slice(0,o)+d+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function xt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var nt=null;function vt(t){if(!nt)nt=new on(t);return nt}function it(){if(nt)nt.stop(),nt=null}import wt from"path";var rt={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},d=new Set,o=r.webComponents?.enabled?`./${wt.relative(wt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(r.webComponents?.enabled)try{let u=await Ss(r,d);if(l.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let f=new Set;if(r.cache&&r.cachePath){let b=await lr(u,r);if(b){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:b,loader:"html"}}}let g=await ke(()=>Bun.file(u).text(),"",(b)=>{throw new Tr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${b.message}`)});if(!g)throw new Tr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:x,allScripts:v}=ie.time("script-extraction",()=>{let b=g,k=de(g);if(k)b=k.content.trim();let D=g.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],E="",R=[];for(let C of D){let A=C.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",_=C.match(/<script\b([^>]*)>/i),V=_?_[1]:"";if(/\bserver\b/i.test(V))E=A;else R.push(C)}let O=b.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:E,templateContent:O,allScripts:R}}),S={__filename:u,__dirname:wt.dirname(u),__stx:{webComponentsPath:o,builtComponents:l}};await ke(()=>m(h,S,u),void 0,(b)=>{let k=new ae(`Script execution failed in ${u}: ${b.message}`,u,void 0,void 0,h.substring(0,100));if(F.log(k,{filePath:u,scriptContent:h}),r.debug)throw k});let w=await ie.timeAsync("directive-processing",async()=>await i(x,S,u,r,f));if(v.length>0){let{interpolateScriptsInTemplate:b}=await import("./chunk-0t5752am.js"),k=b(v.join(`
890
+ `}function Ne(t,n,r={}){let d=Br(n,r),o=t.lastIndexOf("</body>");if(o!==-1)return t.slice(0,o)+d+t.slice(o);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function xt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((r)=>r.test(t))}var nt=null;function vt(t){if(!nt)nt=new on(t);return nt}function it(){if(nt)nt.stop(),nt=null}import wt from"path";var rt={name:"bun-plugin-stx",async setup(t){let r={...await a(),...t.config?.stx},d=new Set,o=r.webComponents?.enabled?`./${wt.relative(wt.dirname(t.config?.outdir||"dist"),r.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(r.webComponents?.enabled)try{let u=await Ss(r,d);if(l.push(...u),r.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let f=new Set;if(r.cache&&r.cachePath){let b=await lr(u,r);if(b){if(r.debug)console.log(`Using cached version of ${u}`);return{contents:b,loader:"html"}}}let g=await ke(()=>Bun.file(u).text(),"",(b)=>{throw new Tr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${b.message}`)});if(!g)throw new Tr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:x,allScripts:v}=ie.time("script-extraction",()=>{let b=g,k=de(g);if(k)b=k.content.trim();let D=g.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],E="",R=[];for(let C of D){let A=C.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",_=C.match(/<script\b([^>]*)>/i),V=_?_[1]:"";if(/\bserver\b/i.test(V))E=A;else R.push(C)}let O=b.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:E,templateContent:O,allScripts:R}}),S={__filename:u,__dirname:wt.dirname(u),__stx:{webComponentsPath:o,builtComponents:l}};await ke(()=>m(h,S,u),void 0,(b)=>{let k=new ae(`Script execution failed in ${u}: ${b.message}`,u,void 0,void 0,h.substring(0,100));if(F.log(k,{filePath:u,scriptContent:h}),r.debug)throw k});let w=await ie.timeAsync("directive-processing",async()=>await i(x,S,u,r,f));if(v.length>0){let{interpolateScriptsInTemplate:b}=await import("./chunk-cxf2pdjk.js"),k=b(v.join(`
891
891
  `),S),D=w.search(/<\/body>/i);if(D!==-1)w=w.slice(0,D)+k+`
892
892
  `+w.slice(D);else w+=`
893
893
  ${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),r.cache&&r.cachePath){if(await ur(u,w,f,r),r.debug)console.log(`Cached template ${u} with ${f.size} dependencies`)}return{contents:w,loader:"html"}}catch(f){let g=f instanceof Error?f:new ae(`Plugin processing failed: ${String(f)}`,u);if(F.log(g,{filePath:u,buildConfig:t.config}),Sn.logDetailedError(g,{filePath:u,plugin:"bun-plugin-stx"}),r.debug)console.error("stx Plugin Error:",g);let h=g,x=h.line||null,v=h.context||null;return{contents:r.debug||K()?`<!DOCTYPE html>
@@ -950,7 +950,7 @@ ${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),r.cache&&r.cachePath){if(await u
950
950
  <h1>Something went wrong</h1>
951
951
  <p>An internal error occurred. Please try again later.</p>
952
952
  </body>
953
- </html>`,loader:"html"}}})}};async function zr(t,n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,l=null,u=n.hmrPort||r+1,f=ge.resolve(t);if(!Be.existsSync(f))return console.error(`${e.red}Error: File not found: ${e.bright}${f}${e.reset}`),!1;if(f.endsWith(".md"))return zt(f,n);else if(!f.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${f}${e.reset}. Only .stx and .md files are supported.`),!1;let g=c(process.cwd(),"output");Be.mkdirSync(g,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let h=null,x=async()=>{try{let A={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},_=await Bun.build({entrypoints:[f],outdir:g,plugins:[A,rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!_.success)return console.error(`${e.red}Build failed:${e.reset}`,_.logs),!1;let V=_.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(A){return console.error(`${e.red}Error building stx file:${e.reset}`,A),!1}};if(!await x())return!1;let S=ge.dirname(f);await cn(S);let T=r;try{if(T=await Ve(r),T!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${T} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let A=n.hmrPort||T+1;l=vt({wsPort:A,verbose:!1}),u=l.start(A)}let w={},b=null,k;try{let{loadStxConfig:A}=await import("./chunk-sntkg6n4.js"),_=await A();if(k=n.stxOptions?.serverApi??_.serverApi,_?.apiRouter)b=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){w=_.apiRoutes;let V=Object.keys(w).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(_?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-7agp0wj2.js"),xe=_.broadcasting;await V(xe);let le=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Oe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Oe))try{let ne=await Y(Oe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:D,isServerApiSource:E}=await import("./chunk-8k1668e5.js"),R=await D(process.cwd(),k);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${T}/${e.reset}...`),o)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let O=Fr({port:T,async fetch(A){return $n(A,await(async()=>{let _=new URL(A.url);if([g,ge.dirname(f),ge.join(process.cwd(),"public")].some((ne)=>E(ge.join(ne,_.pathname),process.cwd(),k)))return new Response("Not Found",{status:404});if(b)try{let ne=await b.handleRequest(A);if(ne.status!==404)return ne}catch{}if(w[_.pathname])try{return await w[_.pathname](A)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await R(A);if(V)return V;if(_.pathname==="/")return(async()=>{let z=await y(h||"");if(o)z=Ne(z,u);if(n.native)if(z.includes("<head>"))z=z.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;if(n.titlebarHidden)if(z.includes("<head>"))z=z.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else z=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${z}`;return z})().then((z)=>new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(g,_.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),z=ge.extname(Y).toLowerCase(),M="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":M}})}let xe=ge.dirname(f),le=ge.join(xe,_.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),z=ge.extname(le).toLowerCase(),M="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".svg":M="image/svg+xml";break;case".ico":M="image/x-icon";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":M}})}let Oe=ge.join(process.cwd(),"public",_.pathname);if(Be.existsSync(Oe)&&Be.statSync(Oe).isFile()){let ne=Bun.file(Oe),z=ge.extname(Oe).toLowerCase(),M="application/octet-stream";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".svg":M="image/svg+xml";break;case".ico":M="image/x-icon";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":M}})}return new Response("Not Found",{status:404})})())},error(A){return new Response(`<pre>${A}
953
+ </html>`,loader:"html"}}})}};async function zr(t,n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,l=null,u=n.hmrPort||r+1,f=ge.resolve(t);if(!Be.existsSync(f))return console.error(`${e.red}Error: File not found: ${e.bright}${f}${e.reset}`),!1;if(f.endsWith(".md"))return zt(f,n);else if(!f.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${f}${e.reset}. Only .stx and .md files are supported.`),!1;let g=c(process.cwd(),"output");Be.mkdirSync(g,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let h=null,x=async()=>{try{let A={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},_=await Bun.build({entrypoints:[f],outdir:g,plugins:[A,rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!_.success)return console.error(`${e.red}Build failed:${e.reset}`,_.logs),!1;let V=_.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(A){return console.error(`${e.red}Error building stx file:${e.reset}`,A),!1}};if(!await x())return!1;let S=ge.dirname(f);await cn(S);let T=r;try{if(T=await Ve(r),T!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${T} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let A=n.hmrPort||T+1;l=vt({wsPort:A,verbose:!1}),u=l.start(A)}let w={},b=null,k;try{let{loadStxConfig:A}=await import("./chunk-jqhcst3j.js"),_=await A();if(k=n.stxOptions?.serverApi??_.serverApi,_?.apiRouter)b=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){w=_.apiRoutes;let V=Object.keys(w).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(_?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-7agp0wj2.js"),xe=_.broadcasting;await V(xe);let le=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Oe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Oe))try{let ne=await Y(Oe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:D,isServerApiSource:E}=await import("./chunk-3hzdpc0m.js"),R=await D(process.cwd(),k);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${T}/${e.reset}...`),o)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let O=Fr({port:T,async fetch(A){return $n(A,await(async()=>{let _=new URL(A.url);if([g,ge.dirname(f),ge.join(process.cwd(),"public")].some((ne)=>E(ge.join(ne,_.pathname),process.cwd(),k)))return new Response("Not Found",{status:404});if(b)try{let ne=await b.handleRequest(A);if(ne.status!==404)return ne}catch{}if(w[_.pathname])try{return await w[_.pathname](A)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await R(A);if(V)return V;if(_.pathname==="/")return(async()=>{let z=await y(h||"");if(o)z=Ne(z,u);if(n.native)if(z.includes("<head>"))z=z.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;if(n.titlebarHidden)if(z.includes("<head>"))z=z.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else z=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${z}`;return z})().then((z)=>new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(g,_.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),z=ge.extname(Y).toLowerCase(),M="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":M}})}let xe=ge.dirname(f),le=ge.join(xe,_.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),z=ge.extname(le).toLowerCase(),M="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".svg":M="image/svg+xml";break;case".ico":M="image/x-icon";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":M}})}let Oe=ge.join(process.cwd(),"public",_.pathname);if(Be.existsSync(Oe)&&Be.statSync(Oe).isFile()){let ne=Bun.file(Oe),z=ge.extname(Oe).toLowerCase(),M="application/octet-stream";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":M="text/html";break;case".css":M="text/css";break;case".js":M="text/javascript";break;case".json":M="application/json";break;case".png":M="image/png";break;case".jpg":case".jpeg":M="image/jpeg";break;case".gif":M="image/gif";break;case".svg":M="image/svg+xml";break;case".ico":M="image/x-icon";break;case".woff":M="font/woff";break;case".woff2":M="font/woff2";break;case".ttf":M="font/ttf";break;case".otf":M="font/otf";break;case".eot":M="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":M}})}return new Response("Not Found",{status:404})})())},error(A){return new Response(`<pre>${A}
954
954
  ${A.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
955
955
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
956
956
  ${e.bright}\u2192 ${e.cyan}http://localhost:${T}/${e.reset}`),console.log(`
@@ -1437,12 +1437,12 @@ ${w.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1437
1437
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1438
1438
  ${e.bright}\u2192 ${e.cyan}http://localhost:${x}/${e.reset}`),console.log(`
1439
1439
  ${e.yellow}Routes:${e.reset}`);let S=new Set(f.map((w)=>w.routeTemplate)),T=Object.entries(u).filter(([w])=>!S.has(w)).sort(([w],[b])=>w.localeCompare(b)).map(([w,b])=>({route:w==="/"?"/":w,filePath:Pe.relative(process.cwd(),b.filePath),fileType:b.fileType}));for(let w of f){let b=w.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");T.push({route:b,filePath:Pe.relative(process.cwd(),w.filePath),fileType:"stx"})}if(T.sort((w,b)=>w.route.localeCompare(b.route)),T.forEach((w,b)=>{let D=b===T.length-1?"\u2514\u2500 ":"\u251C\u2500 ",E=w.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${D}${w.route}${e.reset} \u2192 ${e.bright}${w.filePath}${e.reset} ${E}`)}),console.log(`
1440
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(v.url.toString(),()=>{if(d)Xe.watch(l,{recursive:!0}).close();v.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Xe.watch(l,{recursive:!0},async(b,k)=>{if(!k)return;if(k.endsWith(".stx")||k.endsWith(".js")||k.endsWith(".ts")||k.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${k}${e.yellow} changed, rebuilding...${e.reset}`),Je.clear(),fe(),await g()});process.on("SIGINT",()=>{w.close(),v.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ur}=globalThis.Bun;import me from"fs";import te from"path";async function dn(t){try{return gn(await Bun.file(t).text())}catch{return}}function Nt(t){let n=Bun.file(t),r=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[r]||"application/octet-stream",...l}})}async function Vr(t=".",n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,l=null,u=n.hmrPort||r+1,f=te.resolve(t),{loadStxConfig:g}=await import("./chunk-sntkg6n4.js"),h=await g(f),{createServerApi:x,isServerApiSource:v}=await import("./chunk-8k1668e5.js"),S=n.stxOptions?.serverApi??h.serverApi,T=await x(f,S),w=h.root&&h.root!=="."?te.join(f,h.root):f,b=n.pagesDir||h.pagesDir||"pages",k=te.join(w,b);if(!me.existsSync(k)&&!h._layerPageDirs?.some((P)=>me.existsSync(P)))return console.error(`${e.red}Error: No '${b}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${k}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${b}/index.stx for the homepage.${e.reset}`),!1;let D=X(w,{pagesDir:b,pagesDirs:h._layerPageDirs?[k,...h._layerPageDirs.slice(1)]:void 0});if(D.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${k}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${D.length}${e.blue} routes${e.reset}`);let E=h?._pluginPageDirs||[],R=[];for(let{dir:P,prefix:j}of E)if(me.existsSync(P)){let N=X(te.dirname(P),{pagesDir:te.basename(P)});for(let Q of N){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;R.push({route:{...Q,pattern:q},prefix:j})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let O=new Map,C=null,A=null;if(n.stxOptions?.shell!==!1){if(A=await aa(f,n.stxOptions?.shell),A){if(C=await mo(A,n.stxOptions||{}),C)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(f,A)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}kt(),await Ct(f);let _=_t();if(_.length>0)console.log(`${e.blue}Loaded ${e.bright}${_.length}${e.blue} middleware: ${e.dim}${_.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:P}=await import("./chunk-sntkg6n4.js"),j=await P(f);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let N=Object.keys(V).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:Q}=await import("./chunk-7agp0wj2.js"),q=j.broadcasting;await N(q);let Ae=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ae}/ws${e.reset}`);let ve=te.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let U=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let xe=c(f,"output");me.mkdirSync(xe,{recursive:!0});let le=new Map,Oe=new Set,ne=async(P)=>{let j=Rs(k,P);if(!j)return null;try{let N=await Bun.build({entrypoints:[j],outdir:xe,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!N.success)return null;let Q=N.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},z=new Map,M=async(P,j)=>{try{let{processDirectives:N,extractVariables:Q,defaultConfig:q,loadStxConfig:Ae,injectRouterScript:ve}=await import("./chunk-sntkg6n4.js"),{checkCache:U,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-yq627be9.js"),G=await Ae(f),Ue=(se)=>{if(!se)return se;if(te.isAbsolute(se))return se;return te.resolve(f,se)},ce={...q,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=Ue(ce.partialsDir),ce.componentsDir=Ue(ce.componentsDir),ce.layoutsDir=Ue(ce.layoutsDir),ce.storesDir=Ue(ce.storesDir||"stores"),ce.cachePath=Ue(ce.cachePath)??c(f,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let se=pe.get(P.filePath);if(se)try{if((await me.promises.stat(P.filePath)).mtime.getTime()<=se.mtime){let He=!0;for(let Se of se.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>se.mtime){He=!1;break}}if(He){let Se=se.output;if(C)Se=We(Se,{preserveHead:!0});let st=z.get(P.filePath);return{route:P,content:Se,status:st?.status??await dn(P.filePath),headers:st?.headers}}}}catch{}let Ie=await U(P.filePath,ce);if(Ie){let je=Ie;if(C)je=We(je,{preserveHead:!0});let He=z.get(P.filePath);return{route:P,content:je,status:He?.status??await dn(P.filePath),headers:He?.headers}}}let Z=re?await W(P.filePath):await Bun.file(P.filePath).text(),oe=gn(Z),{classifyAllScripts:ue}=await import("./chunk-sntkg6n4.js"),B=ue(Z),Le=B.server.map((se)=>se.content),Me=Z;for(let se of B.server)Me=Me.replace(se.fullTag,"");let ee={__filename:P.filePath,__dirname:te.dirname(P.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let se of Le)try{await Q(se,ee,P.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,Ie?.message||Ie)}let De=new Set,he;if(n.profile){let se=performance.now();he=await N(Me,ee,P.filePath,ce,De);let Ie=performance.now()-se,je=te.relative(f,P.filePath)||P.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await N(Me,ee,P.filePath,ce,De);if(!C)he=await ve(he,{router:ce.router});{let{interpolateScriptExpressions:se}=await import("./chunk-0t5752am.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${se(He,ee)}</script>`})}if(C)he=We(he,{preserveHead:!0});if(re&&H)await J(P.filePath,he,De,ce);let{extractStreamBoundaries:ct}=await import("./chunk-nqjte4va.js"),Qe=ct(ee),ot=ee.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let se=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof se[Se]==="function"?await se[Se]():void 0;return N(ot[Se],{...ee,$boundary:st},P.filePath,Ie,new Set)}})),He=new Set(je.map((Se)=>Se.id));Qe=[...(Qe||[]).filter((Se)=>!He.has(Se.id)),...je]}if(Qe&&Qe.length>0)Oe.add(P.pattern);else Qe=void 0;let Vt=It(ee),qt=Ot(ee);if(H)z.set(P.filePath,{status:Vt,headers:qt});return{route:P,content:he,status:Vt??oe,headers:qt,boundaries:Qe}}catch(N){return console.error(`${e.red}Error building ${e.bright}${P.pattern}${e.reset}:`,N),null}},Fe=8,ze=async()=>{let P=new Set(le.keys()),j=new Set(O.keys());le.clear(),O.clear();let N=n.prebuild===!1?D.filter((q)=>P.has(q.pattern)):D,Q=n.prebuild===!1?R.filter(({route:q})=>j.has(q.pattern)):R;for(let q=0;q<N.length;q+=Fe){let Ae=N.slice(q,q+Fe),ve=await Promise.all(Ae.map((U)=>M(U)));for(let U of ve)if(U)le.set(U.route.pattern,U)}for(let q=0;q<Q.length;q+=Fe){let Ae=Q.slice(q,q+Fe),ve=await Promise.all(Ae.map(({route:U})=>M(U)));for(let U of ve)if(U)O.set(U.route.pattern,U)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?D.length+R.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await cn(f);let Ge=r;try{if(Ge=await Ve(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let P=n.hmrPort||Ge+1;l=vt({wsPort:P,verbose:!1}),u=l.start(P)}let Pt=(P,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${Q}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+P};console.log(`${e.blue}Starting server...${e.reset}`);let At=Ur({port:Ge,hostname:n.hostname,async fetch(P){let j=new URL(P.url),N=n.stxOptions?.offline??h.offline;if(j.pathname===No&&N?.enabled){if(!["GET","HEAD"].includes(P.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(P.method==="HEAD"?null:Mo(N,is()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",q=te.join(f,Q,j.pathname),Ae=te.join(f,j.pathname),ve=te.join(xe,j.pathname);if([q,Ae,ve].some((H)=>v(H,f,S)))return new Response("Not Found",{status:404});let[U,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Ae).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(U?.isFile()&&!v(q,f,S))return Nt(q);if(J?.isFile()&&!v(Ae,f,S))return Nt(Ae);if(W?.isFile()&&!v(ve,f,S))return Nt(ve);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},oe=await processDirectives(re,{},te.join(f,"components",`${H}.stx`),Z,new Set);return new Response(oe,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-ewzdsksb.js"),re=await H(P,{publicDir:te.join(f,Q),cacheDir:c(f,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(P);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](P)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await T(P);if(pe)return pe;let G=pr(j.pathname,D);if(G){let H=le.get(G.route.pattern),re=Oe.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await M(G.route,G.params);if(Z){if(H=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(H){let Z=H.status??200,oe=H.headers??{},ue=(G.route.filePath?yt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let Me=await ne(404);if(Me){let ee=Me;if(ee=await y(ee,f),o)ee=Ne(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=Et(j.pathname,G.params,ue,j.search),Me=Tt(Le,null,P,{isServer:!0}),ee=await $t(ue.middleware,Me);if(ee.redirect){let De=ee.redirect.path,he=ee.redirect.options.redirectCode||302,ct=new Headers(ee.responseHeaders);return ct.set("Location",De),new Response(null,{status:he,headers:ct})}if(ee.abort){let{statusCode:De,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${he}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${De}</head>`)}}let B=H.content;if(C&&ca(P)&&qe(B,h?.router?.container||"main")){let Le=et(B),Me=be(B),ee=B.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ee?An(ee[1].trim()):"";if(Object.keys(G.params).length>0)B=Pt(B,G.params);B=await y(B,f);let he=h?.router?.container||"main";return B=Ee(B,he,!0),new Response(B,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[rc]:is(),...L(),"Cache-Control":ft}})}if(C)B=Kr(C,B);if(Object.keys(G.params).length>0)B=Pt(B,G.params);if(B=await y(B,f),o)B=Ne(B,u);if(n.native)if(B.includes("<head>"))B=B.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else B="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+B;if(n.titlebarHidden)if(B.includes("<head>"))B=B.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else B=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${B}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Me}=await import("./chunk-nqjte4va.js");return Me(Le(B,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(B,{status:Z,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...oe}})}}if(R.length>0){let H=R.map((Z)=>Z.route),re=pr(j.pathname,H);if(re){let Z=O.get(re.route.pattern);if(!Z||re.route.isDynamic){let oe=await M(re.route,re.params);if(oe){if(Z=oe,!re.route.isDynamic)O.set(re.route.pattern,oe)}}if(Z){let oe=Z.content;if(C)oe=Kr(C,oe);if(Object.keys(re.params).length>0)oe=Pt(oe,re.params);if(oe=await y(oe,f),o)oe=Ne(oe,u);return new Response(oe,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of E)if(Z!=="/"&&j.pathname.startsWith(Z)){let oe=O.get(Z)||O.get(Z+"/");if(!oe){let ue=R.find(({route:B})=>B.pattern===Z||B.pattern===`${Z}/`);if(ue){let B=await M(ue.route);if(B)oe=B,O.set(ue.route.pattern,B)}}if(oe){let ue=oe.content;if(C)ue=Kr(C,ue);if(ue=await y(ue,f),o)ue=Ne(ue,u);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(St(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ue=le.get("/");if(Ue){let H=Ue.content;if(H=await y(H,f),o)H=Ne(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,f),o)H=Ne(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
1440
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(v.url.toString(),()=>{if(d)Xe.watch(l,{recursive:!0}).close();v.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Xe.watch(l,{recursive:!0},async(b,k)=>{if(!k)return;if(k.endsWith(".stx")||k.endsWith(".js")||k.endsWith(".ts")||k.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${k}${e.yellow} changed, rebuilding...${e.reset}`),Je.clear(),fe(),await g()});process.on("SIGINT",()=>{w.close(),v.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Ur}=globalThis.Bun;import me from"fs";import te from"path";async function dn(t){try{return gn(await Bun.file(t).text())}catch{return}}function Nt(t){let n=Bun.file(t),r=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(r)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[r]||"application/octet-stream",...l}})}async function Vr(t=".",n={}){let r=n.port||3000,d=n.watch!==!1,o=n.hotReload!==!1&&d,l=null,u=n.hmrPort||r+1,f=te.resolve(t),{loadStxConfig:g}=await import("./chunk-jqhcst3j.js"),h=await g(f),{createServerApi:x,isServerApiSource:v}=await import("./chunk-3hzdpc0m.js"),S=n.stxOptions?.serverApi??h.serverApi,T=await x(f,S),w=h.root&&h.root!=="."?te.join(f,h.root):f,b=n.pagesDir||h.pagesDir||"pages",k=te.join(w,b);if(!me.existsSync(k)&&!h._layerPageDirs?.some((P)=>me.existsSync(P)))return console.error(`${e.red}Error: No '${b}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${k}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${b}/index.stx for the homepage.${e.reset}`),!1;let D=X(w,{pagesDir:b,pagesDirs:h._layerPageDirs?[k,...h._layerPageDirs.slice(1)]:void 0});if(D.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${k}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${D.length}${e.blue} routes${e.reset}`);let E=h?._pluginPageDirs||[],R=[];for(let{dir:P,prefix:j}of E)if(me.existsSync(P)){let N=X(te.dirname(P),{pagesDir:te.basename(P)});for(let Q of N){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;R.push({route:{...Q,pattern:q},prefix:j})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let O=new Map,C=null,A=null;if(n.stxOptions?.shell!==!1){if(A=await aa(f,n.stxOptions?.shell),A){if(C=await mo(A,n.stxOptions||{}),C)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(f,A)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}kt(),await Ct(f);let _=_t();if(_.length>0)console.log(`${e.blue}Loaded ${e.bright}${_.length}${e.blue} middleware: ${e.dim}${_.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:P}=await import("./chunk-jqhcst3j.js"),j=await P(f);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let N=Object.keys(V).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:Q}=await import("./chunk-7agp0wj2.js"),q=j.broadcasting;await N(q);let Ae=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ae}/ws${e.reset}`);let ve=te.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let U=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let xe=c(f,"output");me.mkdirSync(xe,{recursive:!0});let le=new Map,Oe=new Set,ne=async(P)=>{let j=Rs(k,P);if(!j)return null;try{let N=await Bun.build({entrypoints:[j],outdir:xe,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!N.success)return null;let Q=N.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},z=new Map,M=async(P,j)=>{try{let{processDirectives:N,extractVariables:Q,defaultConfig:q,loadStxConfig:Ae,injectRouterScript:ve}=await import("./chunk-jqhcst3j.js"),{checkCache:U,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-ncmdmgrj.js"),G=await Ae(f),Ue=(se)=>{if(!se)return se;if(te.isAbsolute(se))return se;return te.resolve(f,se)},ce={...q,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=Ue(ce.partialsDir),ce.componentsDir=Ue(ce.componentsDir),ce.layoutsDir=Ue(ce.layoutsDir),ce.storesDir=Ue(ce.storesDir||"stores"),ce.cachePath=Ue(ce.cachePath)??c(f,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let se=pe.get(P.filePath);if(se)try{if((await me.promises.stat(P.filePath)).mtime.getTime()<=se.mtime){let He=!0;for(let Se of se.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>se.mtime){He=!1;break}}if(He){let Se=se.output;if(C)Se=We(Se,{preserveHead:!0});let st=z.get(P.filePath);return{route:P,content:Se,status:st?.status??await dn(P.filePath),headers:st?.headers}}}}catch{}let Ie=await U(P.filePath,ce);if(Ie){let je=Ie;if(C)je=We(je,{preserveHead:!0});let He=z.get(P.filePath);return{route:P,content:je,status:He?.status??await dn(P.filePath),headers:He?.headers}}}let Z=re?await W(P.filePath):await Bun.file(P.filePath).text(),oe=gn(Z),{classifyAllScripts:ue}=await import("./chunk-jqhcst3j.js"),B=ue(Z),Le=B.server.map((se)=>se.content),Me=Z;for(let se of B.server)Me=Me.replace(se.fullTag,"");let ee={__filename:P.filePath,__dirname:te.dirname(P.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let se of Le)try{await Q(se,ee,P.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,Ie?.message||Ie)}let De=new Set,he;if(n.profile){let se=performance.now();he=await N(Me,ee,P.filePath,ce,De);let Ie=performance.now()-se,je=te.relative(f,P.filePath)||P.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await N(Me,ee,P.filePath,ce,De);if(!C)he=await ve(he,{router:ce.router});{let{interpolateScriptExpressions:se}=await import("./chunk-cxf2pdjk.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${se(He,ee)}</script>`})}if(C)he=We(he,{preserveHead:!0});if(re&&H)await J(P.filePath,he,De,ce);let{extractStreamBoundaries:ct}=await import("./chunk-mfnyqcfg.js"),Qe=ct(ee),ot=ee.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let se=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof se[Se]==="function"?await se[Se]():void 0;return N(ot[Se],{...ee,$boundary:st},P.filePath,Ie,new Set)}})),He=new Set(je.map((Se)=>Se.id));Qe=[...(Qe||[]).filter((Se)=>!He.has(Se.id)),...je]}if(Qe&&Qe.length>0)Oe.add(P.pattern);else Qe=void 0;let Vt=It(ee),qt=Ot(ee);if(H)z.set(P.filePath,{status:Vt,headers:qt});return{route:P,content:he,status:Vt??oe,headers:qt,boundaries:Qe}}catch(N){return console.error(`${e.red}Error building ${e.bright}${P.pattern}${e.reset}:`,N),null}},Fe=8,ze=async()=>{let P=new Set(le.keys()),j=new Set(O.keys());le.clear(),O.clear();let N=n.prebuild===!1?D.filter((q)=>P.has(q.pattern)):D,Q=n.prebuild===!1?R.filter(({route:q})=>j.has(q.pattern)):R;for(let q=0;q<N.length;q+=Fe){let Ae=N.slice(q,q+Fe),ve=await Promise.all(Ae.map((U)=>M(U)));for(let U of ve)if(U)le.set(U.route.pattern,U)}for(let q=0;q<Q.length;q+=Fe){let Ae=Q.slice(q,q+Fe),ve=await Promise.all(Ae.map(({route:U})=>M(U)));for(let U of ve)if(U)O.set(U.route.pattern,U)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?D.length+R.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await cn(f);let Ge=r;try{if(Ge=await Ve(r),Ge!==r)console.log(`${e.yellow}Port ${r} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(o){let P=n.hmrPort||Ge+1;l=vt({wsPort:P,verbose:!1}),u=l.start(P)}let Pt=(P,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${Q}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+P};console.log(`${e.blue}Starting server...${e.reset}`);let At=Ur({port:Ge,hostname:n.hostname,async fetch(P){let j=new URL(P.url),N=n.stxOptions?.offline??h.offline;if(j.pathname===No&&N?.enabled){if(!["GET","HEAD"].includes(P.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(P.method==="HEAD"?null:Mo(N,is()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",q=te.join(f,Q,j.pathname),Ae=te.join(f,j.pathname),ve=te.join(xe,j.pathname);if([q,Ae,ve].some((H)=>v(H,f,S)))return new Response("Not Found",{status:404});let[U,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Ae).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(U?.isFile()&&!v(q,f,S))return Nt(q);if(J?.isFile()&&!v(Ae,f,S))return Nt(Ae);if(W?.isFile()&&!v(ve,f,S))return Nt(ve);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},oe=await processDirectives(re,{},te.join(f,"components",`${H}.stx`),Z,new Set);return new Response(oe,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-ewzdsksb.js"),re=await H(P,{publicDir:te.join(f,Q),cacheDir:c(f,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(P);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](P)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await T(P);if(pe)return pe;let G=pr(j.pathname,D);if(G){let H=le.get(G.route.pattern),re=Oe.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await M(G.route,G.params);if(Z){if(H=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(H){let Z=H.status??200,oe=H.headers??{},ue=(G.route.filePath?yt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let Me=await ne(404);if(Me){let ee=Me;if(ee=await y(ee,f),o)ee=Ne(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=Et(j.pathname,G.params,ue,j.search),Me=Tt(Le,null,P,{isServer:!0}),ee=await $t(ue.middleware,Me);if(ee.redirect){let De=ee.redirect.path,he=ee.redirect.options.redirectCode||302,ct=new Headers(ee.responseHeaders);return ct.set("Location",De),new Response(null,{status:he,headers:ct})}if(ee.abort){let{statusCode:De,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${he}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${De}</head>`)}}let B=H.content;if(C&&ca(P)&&qe(B,h?.router?.container||"main")){let Le=et(B),Me=be(B),ee=B.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ee?An(ee[1].trim()):"";if(Object.keys(G.params).length>0)B=Pt(B,G.params);B=await y(B,f);let he=h?.router?.container||"main";return B=Ee(B,he,!0),new Response(B,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[rc]:is(),...L(),"Cache-Control":ft}})}if(C)B=Kr(C,B);if(Object.keys(G.params).length>0)B=Pt(B,G.params);if(B=await y(B,f),o)B=Ne(B,u);if(n.native)if(B.includes("<head>"))B=B.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else B="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+B;if(n.titlebarHidden)if(B.includes("<head>"))B=B.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else B=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${B}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Me}=await import("./chunk-mfnyqcfg.js");return Me(Le(B,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(B,{status:Z,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...oe}})}}if(R.length>0){let H=R.map((Z)=>Z.route),re=pr(j.pathname,H);if(re){let Z=O.get(re.route.pattern);if(!Z||re.route.isDynamic){let oe=await M(re.route,re.params);if(oe){if(Z=oe,!re.route.isDynamic)O.set(re.route.pattern,oe)}}if(Z){let oe=Z.content;if(C)oe=Kr(C,oe);if(Object.keys(re.params).length>0)oe=Pt(oe,re.params);if(oe=await y(oe,f),o)oe=Ne(oe,u);return new Response(oe,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of E)if(Z!=="/"&&j.pathname.startsWith(Z)){let oe=O.get(Z)||O.get(Z+"/");if(!oe){let ue=R.find(({route:B})=>B.pattern===Z||B.pattern===`${Z}/`);if(ue){let B=await M(ue.route);if(B)oe=B,O.set(ue.route.pattern,B)}}if(oe){let ue=oe.content;if(C)ue=Kr(C,ue);if(ue=await y(ue,f),o)ue=Ne(ue,u);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(St(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ue=le.get("/");if(Ue){let H=Ue.content;if(H=await y(H,f),o)H=Ne(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,f),o)H=Ne(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
1441
1441
  ${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1442
1442
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1443
1443
  ${e.bright}\u2192 ${e.cyan}http://localhost:${Ge}/${e.reset}`),o)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
1444
1444
  ${e.yellow}Routes:${e.reset}`);let Dt=[...As(D,f)];for(let{route:P}of R)Dt.push(`${P.pattern}`);if(Dt.forEach((P,j)=>{let Q=j===Dt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${P}`)}),console.log(`
1445
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.url.toString(),()=>{if(l)it();At.stop()}),n.native){let P,j=te.join(k,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();P=gt(Q)}let N=h?.app?.window??{};await Ze(Ge,{title:h?.app?.head?.title||te.basename(f)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let P=(U)=>U.startsWith("public/")||U.startsWith("public\\"),j=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,Q=()=>{let U=new Set([f,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...U].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))U.add(pe)}for(let[J,W]of N)if(!U.has(J))W.close(),N.delete(J);for(let J of U)if(!N.has(J)&&me.existsSync(J))N.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Ae(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Ae=(U,J,W)=>(q=q.catch(()=>{}).then(()=>ve(U,J,W)),q),ve=async(U,J,W)=>{if(!W||xt(W))return;if(bt(W)){if(h._layerGraph){let pe=await g(f);Object.assign(h,pe),D.splice(0,D.length,...X(w,{pagesDir:b,pagesDirs:pe._layerPageDirs?[k,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(P(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),o&&l)l.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-yq627be9.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(A&&W){if(te.resolve(U,W)===A||te.basename(A)===W){let G=await mo(A,n.stxOptions||{});if(G)C=G}}if(await ze(),await sr(f),o&&l)l.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-yq627be9.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(await ze(),o&&l)l.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),o&&l)l.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let U of N.values())U.close();if(l)it();At.stop(),process.exit(0)})}return!0}import Ut from"fs";import at from"path";async function Wr(t){try{let r=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return[];let d=r[1],o=[],l=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=l.exec(d))!==null){let f=u[1],g=u[2]||u[3]||u[4];if(!g)continue;let h={name:g},x=f.match(/@type\s+\{([^}]+)\}/i);if(x)h.type=x[1].trim();if(f.match(/@required/i))h.required=!0;let S=f.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)h.default=S[1].trim();let T=f.split(`
1445
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.url.toString(),()=>{if(l)it();At.stop()}),n.native){let P,j=te.join(k,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();P=gt(Q)}let N=h?.app?.window??{};await Ze(Ge,{title:h?.app?.head?.title||te.basename(f)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let P=(U)=>U.startsWith("public/")||U.startsWith("public\\"),j=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,Q=()=>{let U=new Set([f,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...U].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))U.add(pe)}for(let[J,W]of N)if(!U.has(J))W.close(),N.delete(J);for(let J of U)if(!N.has(J)&&me.existsSync(J))N.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Ae(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Ae=(U,J,W)=>(q=q.catch(()=>{}).then(()=>ve(U,J,W)),q),ve=async(U,J,W)=>{if(!W||xt(W))return;if(bt(W)){if(h._layerGraph){let pe=await g(f);Object.assign(h,pe),D.splice(0,D.length,...X(w,{pagesDir:b,pagesDirs:pe._layerPageDirs?[k,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(P(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),o&&l)l.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-ncmdmgrj.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(A&&W){if(te.resolve(U,W)===A||te.basename(A)===W){let G=await mo(A,n.stxOptions||{});if(G)C=G}}if(await ze(),await sr(f),o&&l)l.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-ncmdmgrj.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(await ze(),o&&l)l.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),o&&l)l.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let U of N.values())U.close();if(l)it();At.stop(),process.exit(0)})}return!0}import Ut from"fs";import at from"path";async function Wr(t){try{let r=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return[];let d=r[1],o=[],l=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=l.exec(d))!==null){let f=u[1],g=u[2]||u[3]||u[4];if(!g)continue;let h={name:g},x=f.match(/@type\s+\{([^}]+)\}/i);if(x)h.type=x[1].trim();if(f.match(/@required/i))h.required=!0;let S=f.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)h.default=S[1].trim();let T=f.split(`
1446
1446
  `).map((w)=>w.trim().replace(/^\*\s*/,"")).filter((w)=>!w.startsWith("@")&&w.length>0);h.description=T.join(" ").trim(),o.push(h)}if(o.length===0){let f=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(f){let h=f[1].split(",").map((x)=>x.trim()).filter(Boolean);for(let x of h){let[v]=x.split(":").map((S)=>S.trim());if(v)o.push({name:v})}}}return o}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function qr(t){try{let n=await Bun.file(t).text(),r=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(r)return r[1].split(`
1447
1447
  `).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Xr(t,n=!1,r){let d=at.basename(t,".stx"),o=await Wr(t),l=await qr(t),u="";if(n&&r)u=`<${r}></${r}>`;else{let f=o.map((g)=>{if(g.type==="boolean")return`:${g.name}="true"`;return`${g.name}="value"`}).join(`
1448
1448
  `);u=`<${d}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{de,Lc,Fs,mn,m,De,Le}from"./chunk-2qz0p785.js";import{dr,Qe,B}from"./chunk-0n4y5gwq.js";import{tr,i}from"./chunk-4q2y26h9.js";import{we}from"./chunk-9n5smeee.js";function b(s){return s.endsWith(".md")||s.endsWith(".markdown")}function k(s){let e=[];g(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];g(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function g(n,p){let u;while((u=n.exec(s))!==null){let t=u.index,o=t+u[0].length;if(p?.some((l)=>t>=l.start&&o<=l.end))continue;e.push({start:t,end:o})}}if(e.length===0)return s;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=s.slice(a,n.start),c+=`@raw${s.slice(n.start,n.end)}@endraw`,a=n.end}return c+=s.slice(a),c}async function R(s,e={}){let{data:r,content:g}=dr(s),a=await(e.renderer??((n)=>Qe(n)))(g);return{html:k(a),frontmatter:r??{}}}import{dirname as v,resolve as _}from"path";function M(s){let e=s,r=de(s);if(r)e=r.content.trim();let g=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(o)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(o),u;while((u=g.exec(s))!==null){let o=u[1],l=u[2],d=u[0],f=o.includes("server");if(p(l))n.push(d);else if(f)a.push(l);else c.push(d)}let t=e;{let o=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=o.exec(t))!==null){let f=l.index+l[0].length,x=t.indexOf("</script>",f);if(x===-1)continue;d.push({start:l.index,end:x+9}),o.lastIndex=x+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let o of c)t=t.replace(o,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function E(s,e){return`<!DOCTYPE html>
2
+ import{de,Lc,Fs,mn,m,De,Le}from"./chunk-m76jbcey.js";import{dr,Qe,B}from"./chunk-20qn18ry.js";import{tr,i}from"./chunk-c84fwzfq.js";import{we}from"./chunk-f33wwacc.js";function b(s){return s.endsWith(".md")||s.endsWith(".markdown")}function k(s){let e=[];g(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];g(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function g(n,p){let u;while((u=n.exec(s))!==null){let t=u.index,o=t+u[0].length;if(p?.some((l)=>t>=l.start&&o<=l.end))continue;e.push({start:t,end:o})}}if(e.length===0)return s;e.sort((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=s.slice(a,n.start),c+=`@raw${s.slice(n.start,n.end)}@endraw`,a=n.end}return c+=s.slice(a),c}async function R(s,e={}){let{data:r,content:g}=dr(s),a=await(e.renderer??((n)=>Qe(n)))(g);return{html:k(a),frontmatter:r??{}}}import{dirname as v,resolve as _}from"path";function M(s){let e=s,r=de(s);if(r)e=r.content.trim();let g=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],p=(o)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(o),u;while((u=g.exec(s))!==null){let o=u[1],l=u[2],d=u[0],f=o.includes("server");if(p(l))n.push(d);else if(f)a.push(l);else c.push(d)}let t=e;{let o=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=o.exec(t))!==null){let f=l.index+l[0].length,x=t.indexOf("</script>",f);if(x===-1)continue;d.push({start:l.index,end:x+9}),o.lastIndex=x+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let o of c)t=t.replace(o,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function E(s,e){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -14,5 +14,5 @@ ${a.join(`
14
14
  `)}`}else{if(r.processClientScripts!==!1&&a.length>0){let o=p.__stx_event_bindings||[],l=De(p),d=await Promise.all(a.map(async(w)=>{let C=w.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(C))return w;let h=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!h)return w;return await Le(h[1],{eventBindings:o,templateContent:t,serverData:l,filePath:e})})),x=[await tr(d,{...n,buildMode:"compile"}),...d].filter(Boolean).join(`
15
15
  `);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${x}
16
16
  $1`);else t+=`
17
- ${x}`}t=await we(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=E(t,r.title)}if(r.injectCSS)try{let{injectCss:o}=await import("./chunk-dkd29vr5.js");t=await o(t)}catch{}return t}
17
+ ${x}`}t=await we(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=E(t,r.title)}if(r.injectCSS)try{let{injectCss:o}=await import("./chunk-peabdz2j.js");t=await o(t)}catch{}return t}
18
18
  export{Ga};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{jr,so,jg,_l,oo}from"./chunk-taj060c6.js";export{jg as buildModuleRegistryScript,oo as buildSharedModuleRegistries,_l as exportsMutableBinding,jr as registeredModuleIdsIn,so as registeredModuleNamesIn};
2
+ import{jr,so,jg,_l,oo}from"./chunk-w050qx5j.js";export{jg as buildModuleRegistryScript,oo as buildSharedModuleRegistries,_l as exportsMutableBinding,jr as registeredModuleIdsIn,so as registeredModuleNamesIn};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{A,t,l}from"./chunk-gebb12ak.js";import{Z}from"./chunk-2qz0p785.js";import{Jo}from"./chunk-2ws2qe1k.js";import C from"path";var L;async function W(){if(L!==void 0)return L;try{let e=await import("@stacksjs/ts-i18n");L=e.loadLocale??null}catch{L=null}return L}var P={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},k={},v={},R={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...P,...s.i18n}.cache&&k[e]){let r=k[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(v[e]?.state==="loading")return v[e].promise;R[e]="loading";let n=T(e,s).then((r)=>(R[e]="loaded",delete v[e],r)).catch((r)=>{throw R[e]="error",v[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return v[e]={promise:n,state:"loading"},n}async function T(e,s){let i={...P,...s.i18n},n=C.isAbsolute(i.translationsDir)?i.translationsDir:C.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:te(i.format)}):await Y(e,i,n);if(o===void 0){let u=e!==i.defaultLocale?await T(i.defaultLocale,s):{};if(i.cache)k[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=o;if(i.cache)k[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return T(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=C.join(i,`${e}${Q(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return X(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Q(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function X(e){let s={},i=e.split(`
2
+ import{A,t,l}from"./chunk-gebb12ak.js";import{Z}from"./chunk-m76jbcey.js";import{Jo}from"./chunk-2ws2qe1k.js";import C from"path";var L;async function W(){if(L!==void 0)return L;try{let e=await import("@stacksjs/ts-i18n");L=e.loadLocale??null}catch{L=null}return L}var P={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},k={},v={},R={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...P,...s.i18n}.cache&&k[e]){let r=k[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(v[e]?.state==="loading")return v[e].promise;R[e]="loading";let n=T(e,s).then((r)=>(R[e]="loaded",delete v[e],r)).catch((r)=>{throw R[e]="error",v[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return v[e]={promise:n,state:"loading"},n}async function T(e,s){let i={...P,...s.i18n},n=C.isAbsolute(i.translationsDir)?i.translationsDir:C.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:te(i.format)}):await Y(e,i,n);if(o===void 0){let u=e!==i.defaultLocale?await T(i.defaultLocale,s):{};if(i.cache)k[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=o;if(i.cache)k[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return T(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=C.join(i,`${e}${Q(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return X(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Q(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function X(e){let s={},i=e.split(`
3
3
  `),n=[{obj:s,indent:-1}];for(let r of i){let o=r.replace(/#.*$/,"").trimEnd();if(!o.trim())continue;let c=o.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,a=o.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(a){let[,,g,p]=a,f=g.trim(),m=p.trim();if(m==="")u[f]={},n.push({obj:u[f],indent:c});else u[f]=ee(m)}}return s}function ee(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let s=e.toLowerCase();if(s==="true"||s==="yes")return!0;if(s==="false"||s==="no")return!1;if(s==="null"||s==="~")return null;let i=Number(e);if(!Number.isNaN(i)&&e!=="")return i;return e}function te(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function re(e,s){return G(e,s)}function ne(e,s){for(let i of e){let n=i.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(s===c)return r[2];continue}let o=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(o){let c=Number.parseInt(o[1],10),u=o[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(o[2],10);if(s>=c&&s<=u)return o[3];continue}}if(e.length===2)return s===1?e[0].trim():e[1].trim();if(s<e.length)return e[s].trim();return e[e.length-1].trim()}function ie(e,s={}){return j(e,s)}function j(e,s){let i="",n=0;while(n<e.length)if(e[n]==="{"){let r=se(e,n);if(r===-1){i+=e[n],n++;continue}let o=e.slice(n+1,r);i+=ae(o,s),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")i+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")i+=e[n+1],n+=2;else i+=e[n],n++;else i+=e[n],n++;return i}function se(e,s){let i=0;for(let n=s;n<e.length;n++)if(e[n]==="{")i++;else if(e[n]==="}"){if(i--,i===0)return n}return-1}function ae(e,s){let i=oe(e);if(i.length===0)return`{${e}}`;let n=i[0].trim(),r=s[n];if(i.length===1)return r!==void 0?String(r):`{${n}}`;switch(i[1].trim().toLowerCase()){case"plural":return le(r,i.slice(2).join(","),s);case"select":return ue(r,i.slice(2).join(","));case"selectordinal":return de(r,i.slice(2).join(","));case"number":return pe(r,i[2]?.trim());case"date":return fe(r,i[2]?.trim());case"time":return me(r,i[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function oe(e){let s=[],i="",n=0;for(let r=0;r<e.length;r++){let o=e[r];if(o==="{")n++,i+=o;else if(o==="}")n--,i+=o;else if(o===","&&n===0)s.push(i),i="";else i+=o}if(i)s.push(i);return s}function le(e,s,i){let n=Number(e)||0,r=I(s),o=`=${n}`;if(r[o])return E(r[o],n,i);let c=ce(n);if(r[c])return E(r[c],n,i);if(r.other)return E(r.other,n,i);return String(n)}function E(e,s,i){let n=e.replace(/#/g,String(s));return j(n,i)}function ce(e){let s=Math.abs(e),i=Math.floor(s),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(i===1&&n===0)return"one";return"other"}function ue(e,s){let i=String(e||""),n=I(s);if(n[i])return n[i];return n.other||String(e)}function de(e,s){let i=Number(e)||0,n=I(s),r=ge(i);if(n[r])return n[r].replace(/#/g,String(i));if(n.other)return n.other.replace(/#/g,String(i));return String(i)}function ge(e){let s=Math.abs(e),i=s%10,n=s%100;if(i===1&&n!==11)return"one";if(i===2&&n!==12)return"two";if(i===3&&n!==13)return"few";return"other"}function I(e){let s={},i=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=i.exec(e);while(n!==null)s[n[1]]=n[2],n=i.exec(e);return s}function pe(e,s){let i=Number(e);if(Number.isNaN(i))return String(e);switch(s){case"integer":return Math.floor(i).toLocaleString();case"percent":return`${(i*100).toFixed(0)}%`;case"currency":return i.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return i.toLocaleString()}}function fe(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return i.toLocaleDateString(void 0,n)}function me(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return i.toLocaleTimeString(void 0,n)}function be(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,s,i=!0,n={}){let r=e.split("."),o=s;for(let u of r){if(o===void 0||o===null)break;o=o[u]}if(o===void 0||o===null)return i?e:"";let c=String(o);if(be(c))return ie(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),a=c.split("|");c=ne(a,u)}for(let[u,a]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),()=>String(a))}return c}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),he=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function q(e){if(!e)return"ltr";let s=e.trim().toLowerCase().replace(/_/g,"-").split("-"),i=s[0];if(!i)return"ltr";let n=s[1]?.length===4?s[1]:void 0;if(n)return he.has(n)?"rtl":"ltr";if(s.length>1&&D.has(`${i}-${s[1]}`))return"rtl";return D.has(i)?"rtl":"ltr"}async function mc(e,s,i,n){let r=e,o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...P,...n.i18n},u=await re(c.locale,n);s.__translations=u,s.__locale=c.locale,s.__i18nConfig=c,r=await F(r,o,async(p,f,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,S=JSON.parse(x);return typeof S.data==="object"?S.data:{}},()=>A(m,s)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}let y=O(f,u,c.fallbackToKey,b);return y?Z(r,h,y,!1,p.length):w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return l("Translate",`Error in @translate('${f}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let a=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let p=[...r.matchAll(a)];console.warn(`Found ${p.length} @translate matches`),p.forEach((f,m)=>console.warn(`Match ${m}: ${f[0]}, Key: ${f[1]}, Params: ${f[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(p,f,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>A(m,s)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return Z(r,w,O(f,u,c.fallbackToKey,h),!1,p.length)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return l("Translate",`Error in @translate('${f}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,s,i){let n=[];return e.replace(s,(o,...c)=>{let u=i(o,...c).then((a)=>({match:o,replacement:a}));return n.push(u),o}),(await Promise.all(n)).reduce((o,{match:c,replacement:u})=>o.replace(c,()=>u),e)}function _(e,s){if(!e||q(e)!=="rtl")return!1;return!s||s.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function U(e,s){let i=new RegExp(`\\b${s}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!i)return null;return i[2]??i[3]??i[4]??null}function hc(e,s,i,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,a)=>{let p={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${a||p} -->`});let o=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(o,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,a)=>`<span id="${`desc-${u}`}" class="sr-only">${a}</span>`),r}function ye(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function xe(e){let s=new Map,i=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,o,c)=>{let u=s.get(c);if(!u)u=`stx-a11y-component-${s.size}`,s.set(c,u);return`<${o}${u}`}),n=new Map([...s.entries()].map(([r,o])=>[o,r]));return{protectedSource:i,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(o,c,u)=>{let a=n.get(u);return a?`<${c}${a}`:o})}}function we(e,s){let i=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))i.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let o=/<button([^>]*)>\s*<\/button>/gi;r=o.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=o.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),S=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=S&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${S[1]}["']`,"i").test(e),M=r.index,N=e.substring(0,M),Se=e.substring(M),H=(N.match(/<label\b/gi)||[]).length,z=(N.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)i.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let a=/<h([1-6])[^>]*>/gi,g=[];r=a.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=a.exec(e);let p=0;for(let d of g){if(p>0&&d>p+1)i.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${p} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});p=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))i.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let f=e.match(/<html\b([^>]*)>/i);if(f&&_(U(f[1],"lang"),U(f[1],"dir")))i.push({type:"missing-dir",element:f[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(U(r[1],"role"))&&!/<th\b/i.test(d))i.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))i.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)i.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))i.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))i.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return i}async function Ae(e,s){let{protectedSource:i}=xe(e);if(!ye())return we(i,s);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=i,r.querySelectorAll("img").forEach((a)=>{if(!a.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${a.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((a)=>{if(!(a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby")||a.textContent&&a.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${a.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((a)=>{let g=a.getAttribute("id"),p=g&&r.querySelector(`label[for="${g}"]`),f=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),m=a.closest("label")!==null;if(!p&&!f&&!m)n.push({type:"input-missing-label",element:`<${a.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let o=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let a of o){let g=Number.parseInt(a.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${a.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(i.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&_(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((a)=>{let g=a.textContent&&a.textContent.trim().length>0,p=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),f=a.hasAttribute("title"),m=a.querySelector("img[alt]");if(!g&&!p&&!f&&!m)n.push({type:"link-missing-text",element:`<${a.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),i.includes("<nav")||i.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((a)=>{if(V(a.getAttribute("role")))return;let g=a.querySelector("caption");if(!a.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!a.hasAttribute("aria-label")&&!a.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((a)=>{let g=a.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${a.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((a)=>{if(!a.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${a.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((a)=>{if(Number.parseInt(a.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${a.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((a)=>{if(!a.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${a.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),i.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((a)=>{if(!a.hasAttribute("title")&&!a.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${s}:`,r)}return n}async function yc(e,s={}){let i={},{recursive:n=!0,ignorePaths:r=[]}=s,o=Array.isArray(e)?e:[e],c=await Jo(o,{recursive:n,ignorePaths:r}),u=[];for(let a of c)try{let g=await Bun.file(a).text();if(a.endsWith("good-a11y.stx"))continue;let p=await Ae(g,a);if(u.push(a),p.length>0)i[a]=p}catch(g){console.error(`Error scanning ${a}:`,g)}return{results:i,scannedFiles:u}}var bc={name:"a11y",handler:(e,s,i,n)=>{if(!s.length)return e;let r=s[0].replace(/['"]/g,""),o=s.length>1?s[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${o||u} -->${e}`},hasEndTag:!1},wc={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
4
4
  export{mc,hc,yc,bc,wc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{rh,bo,sh,oh,ih,ah}from"./chunk-nk51w4tw.js";import"./chunk-49xn95m7.js";import"./chunk-3y6jhcrb.js";import"./chunk-7sh9fa3q.js";import"./chunk-jf0cn7e2.js";import"./chunk-f33wwacc.js";import"./chunk-1carv1dw.js";import"./chunk-20qn18ry.js";import"./chunk-1jwqjdk7.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{ah as clearStoreCache,rh as getStoreScript,ih as getStoreScriptFor,oh as pageStoresAll,bo as storesRead,sh as storesReadInFiles};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{t,l}from"./chunk-gebb12ak.js";import{s,bn,h}from"./chunk-2qz0p785.js";import{tt}from"./chunk-hn2me1qx.js";import{Cs,Es}from"./chunk-3z0e637x.js";import{xc,Yo,ks,_s}from"./chunk-vbc8a8fh.js";import{bc,wc}from"./chunk-e9rtxq1j.js";import{xt}from"./chunk-mv3yhspn.js";import{un,Tc,mr,hr}from"./chunk-0rjcbqk3.js";import{g}from"./chunk-0dve54ne.js";import{to}from"./chunk-gqjb1y7c.js";import Q from"fs";import j from"path";import{loadConfigWithResult as Bt}from"bunfig";var U={duration:300,delay:0,ease:"ease",direction:"both"};function it(e,r={}){let{duration:i,delay:o,ease:n,direction:c,custom:d}={...U,...r};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-gebb12ak.js";import{s,bn,h}from"./chunk-m76jbcey.js";import{tt}from"./chunk-bmkm1c8s.js";import{Cs,Es}from"./chunk-3z0e637x.js";import{xc,Yo,ks,_s}from"./chunk-vbc8a8fh.js";import{bc,wc}from"./chunk-1jwqjdk7.js";import{xt}from"./chunk-mv3yhspn.js";import{un,Tc,mr,hr}from"./chunk-0rjcbqk3.js";import{g}from"./chunk-0dve54ne.js";import{to}from"./chunk-gqjb1y7c.js";import Q from"fs";import j from"path";import{loadConfigWithResult as Bt}from"bunfig";var U={duration:300,delay:0,ease:"ease",direction:"both"};function it(e,r={}){let{duration:i,delay:o,ease:n,direction:c,custom:d}={...U,...r};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('${r}', ${d});
1308
1308
  `}async function Ze(e,r,i,o){if(r.length<1)return l("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let n=r[0].replace(/['"]/g,""),d=(i.__stx_options||{}).componentsDir||"components",p=F.isAbsolute(d)?[F.join(d,`${n}.stx`),F.join(F.dirname(o),`${n}.stx`)]:[F.join(F.dirname(o),d,`${n}.stx`),F.join(process.cwd(),d,`${n}.stx`),F.join(F.dirname(o),`${n}.stx`)],u=null;for(let f of p)if(await s(f)){u=await Bun.file(f).text();break}if(!u)return l("WebComponent",`Component file not found: ${n}.stx`,t.FILE_NOT_FOUND);let m=Ht(u,n);return`<script type="module">
1309
1309
  ${Ut(m)}
1310
- </script>`}var B={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:un,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"},bc,wc,Cs,Es,Pe,Ae,_e,ke,Re,Ee,qe,Se,...to],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,r,i){let o=r||"pages";if(e)return{root:e,pagesDir:o};let n=i||process.cwd(),c=j.join(n,"resources","views"),d=j.join(n,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(n,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:o};return{root:".",pagesDir:o}}var et=new Set,pe=["partialsDir","componentsDir","layoutsDir"],Ce=new WeakMap;function Kt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let o=e.replace(/\\/g,"/"),n=i.replace(/\\/g,"/");return o===n||o.startsWith(`${n}/`)}function Bf(e,r){let i=!e.root,o=Jt(e.root,e.pagesDir,r);if(e.root=o.root,e.pagesDir=o.pagesDir,i&&o.root!=="."){let n=`${r}::${o.root}`;if(!et.has(n))et.add(n),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 n={};for(let c of pe){let d=e[c];if(typeof d==="string"&&d)n[c]=d}Ce.set(e,n)}if(e.root&&e.root!=="."){let n=e.root;for(let c of pe){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Kt(d,n))continue;e[c]=j.join(n,d)}}for(let n of pe){let c=e[n];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[n]=j.resolve(r,c)}return e}function Gt(e,r){let i=Ce.get(e);for(let o of pe){let n=e[o];if(typeof n!=="string"||!n)continue;let c=j.isAbsolute(n)?n:j.join(r,n);if(Q.existsSync(c))continue;let d=i?.[o]??n,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(Tc(e.stateDir),e.stateDir=mr(),e.cachePath=hr(e.cachePath),e.build)e.build.cacheDir=hr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=hr(e.media.cache.directory);if(e.story)e.story.outDir=hr(e.story.outDir)}var K=null,Y=new Map,ue=new Map,se=null;async function Go(e,r=Bt){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function a(e){let r=e?j.resolve(e):process.cwd(),i=ue.get(r);if(i&&i.signature!==ks(i.graph)){let c=Y.get(r);if(Y.delete(r),ue.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-y46546ng.js"),{partialsCache:p}=await import("./chunk-hfshp3ng.js");if(d(),p.clear(),c&&i.configSignature===_s(i.graph)){let u=c.then(async(m)=>{let y={...i.graph};await Yo(y,r),ue.set(r,{graph:y,signature:ks(y),configSignature:_s(y)});let f={...m,_layerGraph:y};if(!e)K=f;return f});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let o=Y.get(r);if(o)return o;let n=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await Go({name:"ui",cwd:j.join(r,"config"),defaultConfig:B,errorPolicy:"throw",verbose:!1});u=(await Go({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await Go({name:"stx",alias:"ui",cwd:r,defaultConfig:B,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await xc(r,B);u=v.config,ue.set(r,{graph:v.graph,signature:ks(v.graph),configSignature:_s(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-m5cdkb11.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-6dz1fcx1.js");await b(r,u.runtimeConfig)}Yt(u),Xt(u),Bf(u,r),Gt(u,r);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:[r]}),m.push(b)}catch{}}let f=[...u.plugins??[],...m];if(f.length>0){let{pluginManager:v}=await import("./chunk-3e85etrf.js"),b=[],x=[];for(let P of f){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,O;try{let w=g.resolve(S,{paths:[r]});k=await import(w),O=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),O=j.dirname(w)}let E=k.default||k;if(!v.has(E.name))await v.register(E,u);if(E.components){let w=Array.isArray(E.components)?E.components:[E.components];for(let C of w)b.push(j.resolve(O,C))}if(E.pages){let w=j.resolve(O,E.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(E.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:O,config:u};await E.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${E.name||S}
1310
+ </script>`}var B={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:un,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"},bc,wc,Cs,Es,Pe,Ae,_e,ke,Re,Ee,qe,Se,...to],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,r,i){let o=r||"pages";if(e)return{root:e,pagesDir:o};let n=i||process.cwd(),c=j.join(n,"resources","views"),d=j.join(n,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(n,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:o};return{root:".",pagesDir:o}}var et=new Set,pe=["partialsDir","componentsDir","layoutsDir"],Ce=new WeakMap;function Kt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let o=e.replace(/\\/g,"/"),n=i.replace(/\\/g,"/");return o===n||o.startsWith(`${n}/`)}function Bf(e,r){let i=!e.root,o=Jt(e.root,e.pagesDir,r);if(e.root=o.root,e.pagesDir=o.pagesDir,i&&o.root!=="."){let n=`${r}::${o.root}`;if(!et.has(n))et.add(n),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 n={};for(let c of pe){let d=e[c];if(typeof d==="string"&&d)n[c]=d}Ce.set(e,n)}if(e.root&&e.root!=="."){let n=e.root;for(let c of pe){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Kt(d,n))continue;e[c]=j.join(n,d)}}for(let n of pe){let c=e[n];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[n]=j.resolve(r,c)}return e}function Gt(e,r){let i=Ce.get(e);for(let o of pe){let n=e[o];if(typeof n!=="string"||!n)continue;let c=j.isAbsolute(n)?n:j.join(r,n);if(Q.existsSync(c))continue;let d=i?.[o]??n,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(Tc(e.stateDir),e.stateDir=mr(),e.cachePath=hr(e.cachePath),e.build)e.build.cacheDir=hr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=hr(e.media.cache.directory);if(e.story)e.story.outDir=hr(e.story.outDir)}var K=null,Y=new Map,ue=new Map,se=null;async function Go(e,r=Bt){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function a(e){let r=e?j.resolve(e):process.cwd(),i=ue.get(r);if(i&&i.signature!==ks(i.graph)){let c=Y.get(r);if(Y.delete(r),ue.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-15hfs2cp.js"),{partialsCache:p}=await import("./chunk-3affwe7d.js");if(d(),p.clear(),c&&i.configSignature===_s(i.graph)){let u=c.then(async(m)=>{let y={...i.graph};await Yo(y,r),ue.set(r,{graph:y,signature:ks(y),configSignature:_s(y)});let f={...m,_layerGraph:y};if(!e)K=f;return f});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let o=Y.get(r);if(o)return o;let n=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await Go({name:"ui",cwd:j.join(r,"config"),defaultConfig:B,errorPolicy:"throw",verbose:!1});u=(await Go({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await Go({name:"stx",alias:"ui",cwd:r,defaultConfig:B,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await xc(r,B);u=v.config,ue.set(r,{graph:v.graph,signature:ks(v.graph),configSignature:_s(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-m5cdkb11.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-zfes9kn1.js");await b(r,u.runtimeConfig)}Yt(u),Xt(u),Bf(u,r),Gt(u,r);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:[r]}),m.push(b)}catch{}}let f=[...u.plugins??[],...m];if(f.length>0){let{pluginManager:v}=await import("./chunk-3e85etrf.js"),b=[],x=[];for(let P of f){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,O;try{let w=g.resolve(S,{paths:[r]});k=await import(w),O=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),O=j.dirname(w)}let E=k.default||k;if(!v.has(E.name))await v.register(E,u);if(E.components){let w=Array.isArray(E.components)?E.components:[E.components];for(let C of w)b.push(j.resolve(O,C))}if(E.pages){let w=j.resolve(O,E.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(E.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:O,config:u};await E.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${E.name||S}
1311
1311
  `)}catch(k){console.warn(`[stx] Failed to load plugin ${S}:`,k.message)}}u._pluginComponentDirs=b,u._pluginPageDirs=x}if(u.nativePrimitives!==!1)u._nativePrimitivesFallback={dir:xs(),except:["Button","Checkbox","Switch","TextInput","Image","Video"]};return u})();if(Y.set(r,n),n.catch(()=>{if(Y.get(r)===n)Y.delete(r)}),!e)se=n,n.then((c)=>{K=c}).catch(()=>{});return n}var I=new Proxy(B,{get(e,r){if(K&&r in K)return K[r];if(!se)a().catch((i)=>{console.warn("[stx] Failed to load config file:",i?.message||i)});return e[r]}});function Fh(e){return e}function zh(e){let r=[],i=[];if(e.partialsDir!==void 0&&typeof e.partialsDir!=="string")r.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(e.componentsDir!==void 0&&typeof e.componentsDir!=="string")r.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(e.cache!==void 0&&typeof e.cache!=="boolean")r.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(e.debug!==void 0&&typeof e.debug!=="boolean")r.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)r.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)r.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))r.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))r.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)r.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)r.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))r.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))r.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))r.push({path:"hydration.preload",message:`hydration.preload must be one of: ${o.join(", ")}`,severity:"error"})}}if(e.customDirectives)if(!Array.isArray(e.customDirectives))r.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else e.customDirectives.forEach((o,n)=>{if(!o.name||typeof o.name!=="string")r.push({path:`customDirectives[${n}].name`,message:"Custom directive must have a name string",severity:"error"});if(!o.handler||typeof o.handler!=="function")r.push({path:`customDirectives[${n}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(e.middleware)if(!Array.isArray(e.middleware))r.push({path:"middleware",message:"middleware must be an array",severity:"error"});else e.middleware.forEach((o,n)=>{if(!o.name||typeof o.name!=="string")r.push({path:`middleware[${n}].name`,message:"Middleware must have a name string",severity:"error"});if(!o.handler||typeof o.handler!=="function")r.push({path:`middleware[${n}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!o.timing||!["before","after"].includes(o.timing))r.push({path:`middleware[${n}].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)r.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))r.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))r.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((n,c)=>{if(!n.pattern||typeof n.pattern!=="string")r.push({path:`pwa.routes[${c}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!o.includes(n.strategy))r.push({path:`pwa.routes[${c}].strategy`,message:`PWA route strategy must be one of: ${o.join(", ")}`,severity:"error"});if(n.maxAgeSeconds!==void 0&&(typeof n.maxAgeSeconds!=="number"||n.maxAgeSeconds<0))r.push({path:`pwa.routes[${c}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(n.maxEntries!==void 0&&(typeof n.maxEntries!=="number"||n.maxEntries<1))r.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))r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(e.pwa.icons.sizes.filter((n)=>typeof n!=="number"||n<16||n>1024).length>0)r.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)r.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:r.length===0,errors:r,warnings:i}}
1312
1312
  export{pc,fc,dr,Qe,gc,xs,Ss,B,Bf,Go,a,I,Fh,zh};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ya,ou,Fn,Pm,iu,au,cu,Im}from"./chunk-525sz0z9.js";import"./chunk-2qz0p785.js";import"./chunk-pvy3ekgn.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Fn as Validator,ou as defineForm,iu as processErrorDirective,au as processErrorsDirective,Im as processFormValidationDirectives,cu as processHasErrorsDirective,ya as useForm,Pm as v};
2
+ import{ya,ou,Fn,Pm,iu,au,cu,Im}from"./chunk-3fq9v4a4.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Fn as Validator,ou as defineForm,iu as processErrorDirective,au as processErrorsDirective,Im as processFormValidationDirectives,cu as processHasErrorsDirective,ya as useForm,Pm as v};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$h,Pf,Je,ic,Rh,as,cs,ls}from"./chunk-xyykkdeq.js";import"./chunk-ft6gkkq1.js";import"./chunk-6ndpbfmg.js";import"./chunk-y7sf7aj0.js";import"./chunk-1carv1dw.js";import"./chunk-2qz0p785.js";import"./chunk-pvy3ekgn.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Rh as clearOnceStore,ic as onceStore,Je as partialsCache,as as processIncludes,cs as processStackPushDirectives,ls as processStackReplacements,$h as resetUnscopedSignalWarnings,Pf as topLevelElements};
2
+ import{$h,Pf,Je,ic,Rh,as,cs,ls}from"./chunk-y3jx43d7.js";import"./chunk-kr5jhk30.js";import"./chunk-y6pyr4km.js";import"./chunk-y7sf7aj0.js";import"./chunk-1carv1dw.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Rh as clearOnceStore,ic as onceStore,Je as partialsCache,as as processIncludes,cs as processStackPushDirectives,ls as processStackReplacements,$h as resetUnscopedSignalWarnings,Pf as topLevelElements};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{_}from"./chunk-2qz0p785.js";import{le}from"./chunk-kvz01wzc.js";function g(e,t){let r={};for(let n of e)r[n]=le(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=le(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function ya(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=le(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var ou=ya;class Fn{rules=[];defaultValue="";addRule(e){let t=new Fn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Fn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Fn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var Pm=new Fn;function iu(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>_(c,{...t,message:l},r)).join(`
2
+ import{_}from"./chunk-m76jbcey.js";import{le}from"./chunk-kvz01wzc.js";function g(e,t){let r={};for(let n of e)r[n]=le(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=le(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function ya(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=le(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var ou=ya;class Fn{rules=[];defaultValue="";addRule(e){let t=new Fn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Fn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Fn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var Pm=new Fn;function iu(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>_(c,{...t,message:l},r)).join(`
3
3
  `)}catch{return""}})}function au(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>_(c,{...t,message:l},r)).join(`
4
4
  `)}catch{return""}})}function cu(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function Im(e,t,r){let n=e;return n=iu(n,t,r),n=au(n,t,r),n=cu(n,t,r),n}export{ya,ou,Fn,Pm,iu,au,cu,Im};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{on,Ao,Po,Io,_h,Oo}from"./chunk-2631z9wj.js";import"./chunk-vbc8a8fh.js";import"./chunk-hn2me1qx.js";import"./chunk-m7hfcxt3.js";export{Po as buildServerApi,_h as createServerApi,on as discoverServerApi,Ao as generateApiTypes,Oo as isServerApiSource,Io as productionApiDispatcher};
2
+ import{on,Ao,Po,Io,_h,Oo}from"./chunk-3y6jhcrb.js";import"./chunk-vbc8a8fh.js";import"./chunk-bmkm1c8s.js";import"./chunk-m7hfcxt3.js";export{Po as buildServerApi,_h as createServerApi,on as discoverServerApi,Ao as generateApiTypes,Oo as isServerApiSource,Io as productionApiDispatcher};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{oa,Yg,ia,Zg,Dl,Ll,Qg,em}from"./chunk-6ct3hhae.js";import"./chunk-6nskg4sx.js";import"./chunk-49xn95m7.js";import"./chunk-3y6jhcrb.js";import"./chunk-7sh9fa3q.js";import"./chunk-jf0cn7e2.js";import"./chunk-f33wwacc.js";import"./chunk-1carv1dw.js";import"./chunk-20qn18ry.js";import"./chunk-1jwqjdk7.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import{Pt,Jf}from"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{oa as buildScriptVirtualFile,Yg as buildVirtualSource,Pt as extractScriptBlocks,Jf as extractTemplateExpressions,Dl as findRuntimeTypeDeclarations,Ll as findStxModuleDeclarations,em as formatTypecheckDiagnostics,Zg as sourcePathFor,Qg as typecheckStxFiles,ia as virtualPathFor};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ue}from"./chunk-hn2me1qx.js";import{ze,N}from"./chunk-m7hfcxt3.js";import{vc}from"./chunk-vbc8a8fh.js";import{c}from"./chunk-0rjcbqk3.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function on(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Ao(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ue(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
2
+ import{ue}from"./chunk-bmkm1c8s.js";import{ze,N}from"./chunk-m7hfcxt3.js";import{vc}from"./chunk-vbc8a8fh.js";import{c}from"./chunk-0rjcbqk3.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function on(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Ao(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ue(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
3
  `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Po(s,l,o={}){let i=on(s,o);await Ao(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...ue(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Io(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function _h(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=on(s,o);return await Ao(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=on(s,o);await Ao(s,t);let{loadStxConfig:e}=await import("./chunk-8z0psa9p.js"),a=N((await e(s)).runtimeConfig);return await ze(a,()=>E(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
4
+ `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...ue(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Io(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function _h(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=on(s,o);return await Ao(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=on(s,o);await Ao(s,t);let{loadStxConfig:e}=await import("./chunk-agcfhj1v.js"),a=N((await e(s)).runtimeConfig);return await ze(a,()=>E(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
5
  `));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Oo(s,l,o){if(vc(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return v.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
6
6
  export{on,Ao,Po,Io,_h,Oo};