@stacksjs/stx 0.2.665 → 0.2.667

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 (157) hide show
  1. package/dist/chunk-028ee6q5.js +2 -0
  2. package/dist/chunk-02ymqwmj.js +2 -0
  3. package/dist/chunk-0syr525r.js +2 -0
  4. package/dist/chunk-1e79xcc8.js +2 -0
  5. package/dist/{chunk-2q50h7zv.js → chunk-1ffjj2c6.js} +5 -5
  6. package/dist/chunk-1pnp91wx.js +2 -0
  7. package/dist/{chunk-2h8ea0we.js → chunk-1sr6c0nk.js} +2 -2
  8. package/dist/chunk-1y5ampxc.js +2 -0
  9. package/dist/chunk-2265dwpm.js +2 -0
  10. package/dist/chunk-280p4q7a.js +2 -0
  11. package/dist/{chunk-hb08vrbb.js → chunk-2dp7hyv7.js} +21 -21
  12. package/dist/{chunk-x34scshq.js → chunk-2zzc7006.js} +2 -2
  13. package/dist/{chunk-wpm58d6p.js → chunk-30nes8ne.js} +2 -2
  14. package/dist/{chunk-zaaeneq6.js → chunk-365vg0eg.js} +2 -2
  15. package/dist/{chunk-2qbvsvwc.js → chunk-3850m7ab.js} +6 -6
  16. package/dist/{chunk-ewcrsyr7.js → chunk-3hxd5td3.js} +2 -2
  17. package/dist/{chunk-pxqh758g.js → chunk-3y41efsf.js} +64 -15
  18. package/dist/{chunk-cg3mvq4h.js → chunk-4701f9eh.js} +6 -6
  19. package/dist/{chunk-jrf01hfv.js → chunk-4c183zem.js} +1 -1
  20. package/dist/{chunk-dra341c0.js → chunk-4htp92hr.js} +15 -15
  21. package/dist/{chunk-pc48mjkc.js → chunk-4qh789bq.js} +4 -4
  22. package/dist/chunk-4s284y6c.js +2 -0
  23. package/dist/chunk-5zgrvj4b.js +2 -0
  24. package/dist/{chunk-38b3w1y4.js → chunk-6h06rqmj.js} +1 -1
  25. package/dist/{chunk-s3dyzxwx.js → chunk-6jwey47v.js} +4 -4
  26. package/dist/{chunk-yq021b3r.js → chunk-7d4z944r.js} +3 -3
  27. package/dist/{chunk-rjh2jwxx.js → chunk-7met6yva.js} +8 -8
  28. package/dist/chunk-7y2htsr8.js +2 -0
  29. package/dist/{chunk-zpc06ysq.js → chunk-85sa9q09.js} +1 -1
  30. package/dist/{chunk-2jh21f1n.js → chunk-89jbdtgw.js} +1 -1
  31. package/dist/{chunk-b6xv8jh9.js → chunk-8gy90n5q.js} +1 -1
  32. package/dist/chunk-an6y1v5h.js +2 -0
  33. package/dist/chunk-b42p0kvz.js +2 -0
  34. package/dist/{chunk-mrrrngzd.js → chunk-b4pcw34n.js} +1 -1
  35. package/dist/chunk-b54s3qde.js +2 -0
  36. package/dist/chunk-b7e07ybq.js +3 -0
  37. package/dist/{chunk-0jhdrgpr.js → chunk-b823zxq6.js} +2 -2
  38. package/dist/{chunk-c9k40352.js → chunk-bdg0fydw.js} +1 -1
  39. package/dist/{chunk-11zp67ds.js → chunk-bexp6dsp.js} +4 -4
  40. package/dist/chunk-bey0cjrp.js +2 -0
  41. package/dist/chunk-bheh3z8r.js +2 -0
  42. package/dist/chunk-bj2xzkv6.js +2 -0
  43. package/dist/{chunk-szyqxcfj.js → chunk-bnn7pd62.js} +2 -2
  44. package/dist/chunk-bs7hq5a3.js +2 -0
  45. package/dist/{chunk-qzy8ypk4.js → chunk-c7d09931.js} +40 -40
  46. package/dist/chunk-crcypbbq.js +2 -0
  47. package/dist/{chunk-w2zceynt.js → chunk-dpvxe52r.js} +1 -1
  48. package/dist/chunk-dq42tzg1.js +2 -0
  49. package/dist/chunk-dvrndj0q.js +2 -0
  50. package/dist/{chunk-np1k9vsr.js → chunk-e1fetwbr.js} +1 -1
  51. package/dist/chunk-e4vpr36s.js +2 -0
  52. package/dist/{chunk-43gr8ggc.js → chunk-ec9ztgxx.js} +2 -2
  53. package/dist/{chunk-yh0wb4n1.js → chunk-ecqrkyg8.js} +2 -2
  54. package/dist/{chunk-nm8yr8a9.js → chunk-f62hpbw8.js} +1 -1
  55. package/dist/{chunk-jh3r0qp7.js → chunk-fbcp9hm4.js} +1 -1
  56. package/dist/chunk-fmzhrwt1.js +2 -0
  57. package/dist/{chunk-gf4e5xtr.js → chunk-fqhmee37.js} +27 -27
  58. package/dist/{chunk-1z1632np.js → chunk-fsef9nvs.js} +41 -41
  59. package/dist/{chunk-een2wqah.js → chunk-fvtwec1r.js} +1 -1
  60. package/dist/{chunk-awe50wee.js → chunk-fwwt7nrc.js} +1 -1
  61. package/dist/{chunk-t9mfztcs.js → chunk-fzqj1mjz.js} +3 -3
  62. package/dist/chunk-gfmw85vw.js +2 -0
  63. package/dist/{chunk-tx6p6jnk.js → chunk-ghsmfkq9.js} +1 -1
  64. package/dist/{chunk-p2mrba1n.js → chunk-gjck0t32.js} +107 -107
  65. package/dist/chunk-hc70e121.js +2 -0
  66. package/dist/{chunk-0g4pr7ww.js → chunk-hjn7qqrq.js} +9 -9
  67. package/dist/chunk-hqwr25qg.js +2 -0
  68. package/dist/{chunk-5w2jy5r9.js → chunk-hvf2e7pr.js} +2 -2
  69. package/dist/{chunk-pmwb5kaf.js → chunk-j045bcpb.js} +2 -2
  70. package/dist/{chunk-nf9bykvg.js → chunk-j7mr8h2w.js} +5 -5
  71. package/dist/{chunk-edvmtk21.js → chunk-jzy0pqez.js} +5 -5
  72. package/dist/{chunk-r7kmsq3n.js → chunk-ka8befem.js} +1 -1
  73. package/dist/chunk-m72b5043.js +2 -0
  74. package/dist/{chunk-v2x9vzgw.js → chunk-md2jn67b.js} +2 -2
  75. package/dist/{chunk-zjsyw63k.js → chunk-mekhzhes.js} +9 -9
  76. package/dist/{chunk-2f1bk3bg.js → chunk-mn3mc6ax.js} +1 -1
  77. package/dist/chunk-n5r1xek6.js +2 -0
  78. package/dist/{chunk-8dcemd4a.js → chunk-ndffc344.js} +1 -1
  79. package/dist/{chunk-d3bsfd10.js → chunk-npa7gze7.js} +2 -2
  80. package/dist/{chunk-8nryyqb5.js → chunk-p472crv1.js} +1 -1
  81. package/dist/{chunk-4yf1w261.js → chunk-pn1ehs6a.js} +2 -2
  82. package/dist/{chunk-7rta163c.js → chunk-pxdww4rb.js} +2 -2
  83. package/dist/{chunk-eqrkhc18.js → chunk-qjtpxsyx.js} +2 -2
  84. package/dist/{chunk-bgra36az.js → chunk-qrq88ng0.js} +1 -1
  85. package/dist/{chunk-gf3bxnpq.js → chunk-qxmyaajq.js} +1 -1
  86. package/dist/{chunk-f2z8s2h9.js → chunk-qxsvd26z.js} +2 -2
  87. package/dist/chunk-r883qzmx.js +2 -0
  88. package/dist/{chunk-vjw3qrqj.js → chunk-rns1e0c5.js} +1 -1
  89. package/dist/{chunk-7ae140wv.js → chunk-sgj6dt85.js} +1 -1
  90. package/dist/{chunk-q1svy1nf.js → chunk-t226hswj.js} +1 -1
  91. package/dist/{chunk-a1p327a7.js → chunk-t886718q.js} +9 -9
  92. package/dist/{chunk-jkvr7e91.js → chunk-tp4eqfxq.js} +2 -2
  93. package/dist/chunk-w1qvq9jf.js +2 -0
  94. package/dist/{chunk-fzxyq6k5.js → chunk-w51q85zg.js} +61 -61
  95. package/dist/chunk-wfjq9ww1.js +2 -0
  96. package/dist/chunk-wpsm2p9x.js +2 -0
  97. package/dist/{chunk-xv43szx0.js → chunk-xqp4hstk.js} +1 -1
  98. package/dist/chunk-ydf4fmr6.js +3 -0
  99. package/dist/{chunk-c1dkh0es.js → chunk-yfvm7q6t.js} +3 -3
  100. package/dist/{chunk-d3vgtr0t.js → chunk-yphmswg3.js} +1 -1
  101. package/dist/{chunk-eecgcj41.js → chunk-yscr04dv.js} +1 -1
  102. package/dist/{chunk-v5916r3j.js → chunk-znb4y12p.js} +5 -5
  103. package/dist/{chunk-5z1n02nd.js → chunk-zwkc8yge.js} +37 -37
  104. package/dist/{chunk-577ntqeg.js → chunk-zx2vhrps.js} +1 -1
  105. package/dist/cli.js +36 -36
  106. package/dist/client/signals-for-runtime.js +51 -2
  107. package/dist/client/signals-process-element-runtime.js +1 -1
  108. package/dist/component-renderer.js +4 -2
  109. package/dist/craft-entry.js +1 -1
  110. package/dist/craft.js +1 -1
  111. package/dist/native/compiler/html-to-ir.js +14 -4
  112. package/dist/native/runtime/binding-tree.d.ts +1 -0
  113. package/dist/native/runtime/binding-tree.js +5 -0
  114. package/dist/native/runtime/craft-bridge.js +1 -0
  115. package/dist/native/runtime/craft.d.ts +1 -0
  116. package/dist/pwa.js +3 -3
  117. package/dist/signal-processing.js +1 -2
  118. package/dist/slot-scopes.js +10 -2
  119. package/dist/slots.d.ts +2 -2
  120. package/dist/slots.js +21 -5
  121. package/dist/ssg.js +5 -5
  122. package/dist/utils.js +1 -1
  123. package/package.json +5 -5
  124. package/dist/chunk-0eepx077.js +0 -2
  125. package/dist/chunk-0fhntp63.js +0 -2
  126. package/dist/chunk-2a4szpje.js +0 -3
  127. package/dist/chunk-3d39yer3.js +0 -2
  128. package/dist/chunk-4v9x7zz5.js +0 -2
  129. package/dist/chunk-5etmsv9z.js +0 -2
  130. package/dist/chunk-773frt6c.js +0 -2
  131. package/dist/chunk-8d2f2e42.js +0 -2
  132. package/dist/chunk-a2bw46t9.js +0 -2
  133. package/dist/chunk-d5pt75tp.js +0 -2
  134. package/dist/chunk-em3aepxz.js +0 -2
  135. package/dist/chunk-g53sg7e0.js +0 -2
  136. package/dist/chunk-gsw8g2ev.js +0 -2
  137. package/dist/chunk-gz90fqn8.js +0 -2
  138. package/dist/chunk-gzd7bmp5.js +0 -2
  139. package/dist/chunk-hcqyf26s.js +0 -2
  140. package/dist/chunk-hhmj9gpk.js +0 -2
  141. package/dist/chunk-k2byvram.js +0 -2
  142. package/dist/chunk-kph7cenp.js +0 -2
  143. package/dist/chunk-papqmch6.js +0 -2
  144. package/dist/chunk-qambfx8c.js +0 -2
  145. package/dist/chunk-stfqkgfv.js +0 -2
  146. package/dist/chunk-t34ds1e3.js +0 -2
  147. package/dist/chunk-t4cbrm81.js +0 -2
  148. package/dist/chunk-t60pt4gv.js +0 -2
  149. package/dist/chunk-t6yjxhn8.js +0 -2
  150. package/dist/chunk-w89mazpv.js +0 -2
  151. package/dist/chunk-wq2fq6b7.js +0 -2
  152. package/dist/chunk-wsp8sj9v.js +0 -3
  153. package/dist/chunk-x8knte1j.js +0 -2
  154. package/dist/chunk-y7xshkqn.js +0 -2
  155. package/dist/chunk-ypsym37h.js +0 -2
  156. package/dist/chunk-z58ybwsv.js +0 -2
  157. package/dist/chunk-zteaygxc.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{vo,wo,vt,ie,Zn,Zr,Qn,Qr,es,Pl,Il,Ol,er,Nl,Dl,Ml,Ll,xa,Sa,ka,xo,_a,jl,wt,xt,St,kt,_t,Ct,Ye,Bl}from"./chunk-365vg0eg.js";export{Qn as Router,Ml as abortNavigation,Zr as bracketPathToRegex,wt as clearMiddleware,Sa as createClientCookieManager,_t as createMiddlewareContext,kt as createRouteLocation,xa as createServerCookieManager,ka as createStorageManager,Ll as defineMiddleware,Il as defineRoute,Ol as defineRoutes,Qr as findErrorPage,es as formatRoutes,wo as generateRouteManifest,vo as generateRouteTypes,_a as getMiddleware,xt as getMiddlewareNames,Ye as getRouterScript,Bl as getRouterScriptDev,jl as hasMiddleware,vt as isFileRequestPath,St as loadMiddlewareFromDirectory,Zn as matchRoute,Dl as navigateTo,ie as patternToRegex,xo as registerMiddleware,Nl as resetRoutes,er as route,Ct as runMiddleware,Pl as setAppUrl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{je,mn,ys,Bo,A,Ot}from"./chunk-1sr6c0nk.js";export{mn as currentRuntimeConfig,Ot as injectRuntimeConfig,A as resolveRuntimeConfig,Bo as useRuntimeConfig,ys as useServerRuntimeConfig,je as withRuntimeConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Pc,ki,Iu,Ic,Oc,Ou,Nu}from"./chunk-yphmswg3.js";import"./chunk-j045bcpb.js";import"./chunk-t886718q.js";import"./chunk-ec9ztgxx.js";import"./chunk-md2jn67b.js";import"./chunk-1ffjj2c6.js";import"./chunk-jzy0pqez.js";import"./chunk-p472crv1.js";import"./chunk-fsef9nvs.js";import"./chunk-t226hswj.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{$t,Fl}from"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Pc as buildVirtualSource,$t as extractScriptBlocks,Fl as extractTemplateExpressions,Ic as findRuntimeTypeDeclarations,Oc as findStxModuleDeclarations,Nu as formatTypecheckDiagnostics,Iu as sourcePathFor,Ou as typecheckStxFiles,ki as virtualPathFor};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{it,at,ct}from"./chunk-tp4eqfxq.js";export{it as createContext,at as updateContextStoryFiles,ct as updateContextTree};
@@ -1,14 +1,14 @@
1
1
  // @bun
2
- import{rt,cc}from"./chunk-7rta163c.js";import{T}from"./chunk-ce6zddpf.js";import{L,rs,r,sn,W,ce,$a,Pt,dn,Ne,De}from"./chunk-qzy8ypk4.js";import{Kn}from"./chunk-edvmtk21.js";import{U}from"./chunk-szyqxcfj.js";import{tn}from"./chunk-8nryyqb5.js";var j=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Q=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,K=65536,Y=4,O=new Map;function fp(){O.clear()}function q(e){let i=[];for(let s of ce(e,W)){let t=s.token.match(/^<script\b([^>]*)>/i),n=s.token.match(/<\/script\s*>$/i);if(!t||!n)continue;let a=t[0].length,l=s.token.length-n[0].length;i.push(Object.freeze({fullMatch:s.token,attrs:t[1],body:s.token.slice(a,l),start:s.start,end:s.end}))}return i}function _l(e,i={}){let s=e.length>=K,t=s?O.get(e):void 0;if(t===void 0){if(t=q(e),s)$a(O,Y),O.set(e,t)}let n=i.skipAttrs;if(!n)return t.slice();let a=[];for(let l of t)if(n.lastIndex=0,!n.test(l.attrs))a.push(l);return a}function oo(e){let i=e.trim(),s=i.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(s){let n=s[1].trim(),a=s[2].trim(),{itemVar:l,indexVar:o}=B(a);if(l)return{style:"as",iterable:n,itemVar:l,indexVar:o}}let t=i.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let n=t[1].trim(),a=t[2].trim(),{itemVar:l,indexVar:o}=B(n);if(l)return{style:"in",iterable:a,itemVar:l,indexVar:o}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function B(e){let i=e.trim(),s=i.match(/^(\w+)\s*=>\s*(\w+)$/);if(s)return{itemVar:s[2],indexVar:s[1]};let t=i.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let n=i.match(/^(\w+)\s*,\s*(\w+)$/);if(n)return{itemVar:n[1],indexVar:n[2]};let a=i.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Fr(e,i){return cc(e,i)}function ee(e){let i=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,s=0,t;while((t=i.exec(e))!==null){let n=t[1];if(n.startsWith("if"))s++;else if(n==="endif")s--;else if(s===0)return!0}return!1}function J(e){let i=new Set,s=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,n;while((n=s.exec(e))!==null){let a=n[1],l;while((l=t.exec(a))!==null)i.add(l[1])}return i}function te(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let i=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${j})>`,"iy"),s=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=ce(e,(a,l)=>{i.lastIndex=l;let o=i.exec(a);if(!o||o.index!==l||!s.test(o[2]))return-1;return i.lastIndex}),n=[];for(let a of t){i.lastIndex=0;let l=i.exec(a.token);if(!l)continue;let o=l[2].match(s),p=oo(o?.[1]??o?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let u=l[1],g=/\/\s*>$/.test(a.token)||N.has(u.toLowerCase())?a.end:z(e,a.start,u,a.end);if(g!==-1)n.push({start:a.start,end:g,vars:new Set(h)})}return n}var Z=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function ne(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function F(e,i,s,t){if(!e)return!1;let n=ne(e),a=!1,l=!1,o=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(n))!==null){let d=h[1];if(n.slice(0,h.index).trimEnd().endsWith("."))continue;if(Z.has(d))continue;if(i.has(d)||t?.has(d))a=!0;else if(s&&d in s)l=!0}let u=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,c;while((c=u.exec(n))!==null){let d=c[1];if(n.slice(0,c.index).trimEnd().endsWith("."))continue;if(Z.has(d)||s&&d in s)continue;o=!0}return(a||o)&&!l}function M(e,i,s){let t=s===void 0?` ${i}`:` ${i}="${s.replace(/"/g,"&quot;")}"`,n=e.trim(),a=n.match(Q);if(a&&se(a[3],a[1])){let[,l,o,p]=a;return`<${l}${o}${t}>${p}</${l}>`}return`<template${t}>${n}</template>`}function se(e,i){let s=new RegExp(`<(/)?${i}(?=[\\s/>])`,"gi"),t=0,n;while((n=s.exec(e))!==null)if(n[1]){if(t--,t<0)return!1}else t++;return!0}function io(e,i){let s=J(e);function t(n){let a=n,l=te(n),o=(c)=>{let g=new Set;for(let d of l)if(c>d.start&&c<d.end)for(let f of d.vars)g.add(f);return g},p=/@if\s*\(/g,h,u=[];while((h=p.exec(a))!==null){let c=h.index,g=c+h[0].length,d=1,f=g;while(f<a.length&&d>0){if(a[f]==="(")d++;else if(a[f]===")")d--;f++}if(d!==0)continue;let b=a.substring(g,f-1).trim(),E=f,S=1,w=E,m=/@(if\s*\(|endif)/g;m.lastIndex=E;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))S++;else if(x[1]==="endif"){if(S--,S===0){w=x.index+x[0].length;break}}if(S!==0)continue;let C=a.substring(E,w-6).trim(),R;if(ee(C)){let _=tn(a.substring(c,w));if(_.length===0)continue;let v=_[0].branches.filter((A)=>A.type!=="else"),I=o(c);if(!(v.length>0&&v.every((A)=>F(A.condition,s,i,I))))continue;R=_[0].branches.map((A)=>{let V=t(A.content);if(A.type==="elseif")return M(V,"@else-if",A.condition??"");if(A.type==="else")return M(V,"@else");return M(V,"@if",A.condition??"")}).join(`
2
+ import{st,cc}from"./chunk-pxdww4rb.js";import{T}from"./chunk-ce6zddpf.js";import{L,rs,r,sn,W,ce,$a,Pt,dn,De,Me}from"./chunk-c7d09931.js";import{Kn}from"./chunk-jzy0pqez.js";import{U}from"./chunk-bnn7pd62.js";import{tn}from"./chunk-p472crv1.js";var j=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Q=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,K=65536,Y=4,O=new Map;function fp(){O.clear()}function q(e){let i=[];for(let s of ce(e,W)){let t=s.token.match(/^<script\b([^>]*)>/i),n=s.token.match(/<\/script\s*>$/i);if(!t||!n)continue;let a=t[0].length,l=s.token.length-n[0].length;i.push(Object.freeze({fullMatch:s.token,attrs:t[1],body:s.token.slice(a,l),start:s.start,end:s.end}))}return i}function _l(e,i={}){let s=e.length>=K,t=s?O.get(e):void 0;if(t===void 0){if(t=q(e),s)$a(O,Y),O.set(e,t)}let n=i.skipAttrs;if(!n)return t.slice();let a=[];for(let l of t)if(n.lastIndex=0,!n.test(l.attrs))a.push(l);return a}function oo(e){let i=e.trim(),s=i.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(s){let n=s[1].trim(),a=s[2].trim(),{itemVar:l,indexVar:o}=B(a);if(l)return{style:"as",iterable:n,itemVar:l,indexVar:o}}let t=i.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let n=t[1].trim(),a=t[2].trim(),{itemVar:l,indexVar:o}=B(n);if(l)return{style:"in",iterable:a,itemVar:l,indexVar:o}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function B(e){let i=e.trim(),s=i.match(/^(\w+)\s*=>\s*(\w+)$/);if(s)return{itemVar:s[2],indexVar:s[1]};let t=i.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let n=i.match(/^(\w+)\s*,\s*(\w+)$/);if(n)return{itemVar:n[1],indexVar:n[2]};let a=i.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Fr(e,i){return cc(e,i)}function ee(e){let i=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,s=0,t;while((t=i.exec(e))!==null){let n=t[1];if(n.startsWith("if"))s++;else if(n==="endif")s--;else if(s===0)return!0}return!1}function J(e){let i=new Set,s=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,n;while((n=s.exec(e))!==null){let a=n[1],l;while((l=t.exec(a))!==null)i.add(l[1])}return i}function te(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let i=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${j})>`,"iy"),s=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=ce(e,(a,l)=>{i.lastIndex=l;let o=i.exec(a);if(!o||o.index!==l||!s.test(o[2]))return-1;return i.lastIndex}),n=[];for(let a of t){i.lastIndex=0;let l=i.exec(a.token);if(!l)continue;let o=l[2].match(s),p=oo(o?.[1]??o?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let u=l[1],g=/\/\s*>$/.test(a.token)||N.has(u.toLowerCase())?a.end:z(e,a.start,u,a.end);if(g!==-1)n.push({start:a.start,end:g,vars:new Set(h)})}return n}var Z=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function ne(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function F(e,i,s,t){if(!e)return!1;let n=ne(e),a=!1,l=!1,o=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(n))!==null){let d=h[1];if(n.slice(0,h.index).trimEnd().endsWith("."))continue;if(Z.has(d))continue;if(i.has(d)||t?.has(d))a=!0;else if(s&&d in s)l=!0}let u=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,c;while((c=u.exec(n))!==null){let d=c[1];if(n.slice(0,c.index).trimEnd().endsWith("."))continue;if(Z.has(d)||s&&d in s)continue;o=!0}return(a||o)&&!l}function M(e,i,s){let t=s===void 0?` ${i}`:` ${i}="${s.replace(/"/g,"&quot;")}"`,n=e.trim(),a=n.match(Q);if(a&&se(a[3],a[1])){let[,l,o,p]=a;return`<${l}${o}${t}>${p}</${l}>`}return`<template${t}>${n}</template>`}function se(e,i){let s=new RegExp(`<(/)?${i}(?=[\\s/>])`,"gi"),t=0,n;while((n=s.exec(e))!==null)if(n[1]){if(t--,t<0)return!1}else t++;return!0}function io(e,i){let s=J(e);function t(n){let a=n,l=te(n),o=(c)=>{let g=new Set;for(let d of l)if(c>d.start&&c<d.end)for(let f of d.vars)g.add(f);return g},p=/@if\s*\(/g,h,u=[];while((h=p.exec(a))!==null){let c=h.index,g=c+h[0].length,d=1,f=g;while(f<a.length&&d>0){if(a[f]==="(")d++;else if(a[f]===")")d--;f++}if(d!==0)continue;let b=a.substring(g,f-1).trim(),E=f,S=1,w=E,m=/@(if\s*\(|endif)/g;m.lastIndex=E;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))S++;else if(x[1]==="endif"){if(S--,S===0){w=x.index+x[0].length;break}}if(S!==0)continue;let C=a.substring(E,w-6).trim(),R;if(ee(C)){let _=tn(a.substring(c,w));if(_.length===0)continue;let v=_[0].branches.filter((A)=>A.type!=="else"),I=o(c);if(!(v.length>0&&v.every((A)=>F(A.condition,s,i,I))))continue;R=_[0].branches.map((A)=>{let V=t(A.content);if(A.type==="elseif")return M(V,"@else-if",A.condition??"");if(A.type==="else")return M(V,"@else");return M(V,"@if",A.condition??"")}).join(`
3
3
  `)}else{if(!F(b,s,i,o(c)))continue;R=M(t(C),"@if",b)}u.push({start:c,end:w,replacement:R}),p.lastIndex=w}for(let c=u.length-1;c>=0;c--){let{start:g,end:d,replacement:f}=u[c];a=a.substring(0,g)+f+a.substring(d)}return a}return t(e)}function re(e){let i=e.trim();if(i==="")return;if(i==="true")return!0;if(i==="false")return!1;if(i==="null")return!1;if(i==="undefined")return!1;if(i==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(i)){let n=Number(i);return n!==0&&!Number.isNaN(n)}let s=i.match(/^'((?:\\.|[^'\\])*)'$/);if(s)return s[1].length>0;let t=i.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),G=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function z(e,i,s,t){if(N.has(s.toLowerCase()))return t;let n=s.toLowerCase(),a=e.length,l=1,o=t;while(o<a){let p=e.indexOf("<",o);if(p===-1)return-1;if(o=p,e.startsWith("<!--",o)){let g=e.indexOf("-->",o+4);if(g===-1)return-1;o=g+3;continue}G.lastIndex=o;let h=G.exec(e);if(h){let g=e.indexOf(">",o);if(g===-1)return-1;if(e[g-1]==="/"){o=g+1;continue}let d=h[1].toLowerCase()==="script"?ie:oe;d.lastIndex=o;let f=d.exec(e);if(f===null)return-1;let b=e.indexOf(">",f.index);if(b===-1)return-1;o=b+1;continue}if(e[o+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(o,o+64));if(!g){o++;continue}if(g[1].toLowerCase()===n){if(l--,o+=g[0].length,l===0)return o;continue}o+=g[0].length;continue}let u=/^<([a-z][\w-]*)\b/i.exec(e.slice(o,o+64));if(!u){o++;continue}let c=e.indexOf(">",o);if(c===-1)return-1;if(u[1].toLowerCase()===n){let g=e.slice(o,c+1);if(!(/\/\s*>$/.test(g)||N.has(n)))l++}o=c+1}return-1}var ae=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function le(e,i){let s=i,t=e.length;for(;;){while(s<t&&e[s]!=="<")s++;if(s>=t)return!1;if(e.startsWith("<!--",s)){let l=e.indexOf("-->",s+4);if(l===-1)return!1;s=l+3;continue}break}if(e[s+1]==="/")return!1;let n=e.indexOf(">",s);if(n===-1)return!1;let a=e.slice(s,n+1);return ae.test(a)}function ao(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let i=[],s=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,t;while((t=s.exec(e))!==null)i.push([t.index,t.index+t[0].length]);let n=(c)=>i.some(([g,d])=>c>=g&&c<d),a=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,l=[],o;while((o=a.exec(e))!==null){if(n(o.index))continue;let[c,g,d,f,b,E,S]=o,w=re(b);if(w===void 0)continue;let m=o.index,x=m+c.length,_=!!S||/\/\s*>$/.test(c)||N.has(g.toLowerCase())?x:z(e,m,g,x);if(_===-1)continue;if((f===":if"||f==="x-if"||f==="@if")&&le(e,_)){a.lastIndex=x;continue}if(w===!0){let I=`<${g}${d}${E}${S}>`;l.push({start:m,end:x,replacement:I});continue}l.push({start:m,end:_,replacement:""}),a.lastIndex=_}if(l.length===0)return e;l.sort((c,g)=>c.start-g.start);let p=[],h=-1;for(let c of l){if(c.start<h)continue;p.push(c),h=c.end}let u=e;for(let c=p.length-1;c>=0;c--){let{start:g,end:d,replacement:f}=p[c];u=u.substring(0,g)+f+u.substring(d)}return u}var X=[":for","@for","x-for"];function zr(e,i){if(!i||Object.keys(i).length===0)return e;if(!X.some((o)=>e.includes(`${o}=`)))return e;let s=J(e);if(Array.isArray(i.__stx_client_signal_names)){for(let o of i.__stx_client_signal_names)if(typeof o==="string")s.add(o)}let t=e,n=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,l;while((l=a.exec(t))!==null){let[o,p,h]=l,u=l.index,c=u+o.length,g=X.map((R)=>({attr:R,m:new RegExp(`\\s${R}="([^"]*)"`).exec(h)})).find((R)=>R.m!==null);if(!g||!g.m)continue;let d=oo(g.m[1]);if(!d.iterable||!d.itemVar)continue;let f=d.iterable.trim().split(/[.[(]/)[0].trim();if(!f||s.has(f)||!(f in i))continue;let b=z(t,u,p,c);if(b===-1)continue;let E=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),S=t.slice(c,b-`</${p}>`.length),w={...i,[d.itemVar]:void 0};if(d.indexVar)w[d.indexVar]=void 0;let m=zr(S,w),x=d.indexVar?`${d.iterable} as ${d.indexVar} => ${d.itemVar}`:`${d.iterable} as ${d.itemVar}`,C=p.toLowerCase()==="template"?m:`<${p}${E}>${m}</${p}>`;n.push({start:u,end:b,replacement:`@foreach(${x})${C}@endforeach`}),a.lastIndex=b}for(let o=n.length-1;o>=0;o--){let{start:p,end:h,replacement:u}=n[o];t=t.slice(0,p)+u+t.slice(h)}return t}function Hr(e,i){let s=e,t=/@(for|foreach)\s*\(/g,n,a=[],l=[];while((n=t.exec(s))!==null){let o=n[1],p=n.index,h=p+n[0].length,u=1,c=h;while(c<s.length&&u>0){if(s[c]==="(")u++;else if(s[c]===")")u--;c++}if(u!==0)continue;let g=s.substring(h,c-1).trim(),d=c,f=oo(g),b=o==="for"?"@endfor":"@endforeach",E=1,S=d,w=o==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${o}\\s*\\(|end${o})`,"g");w.lastIndex=d;let m;while((m=w.exec(s))!==null)if(m[1].startsWith(o))E++;else if(E--,E===0){S=m.index+m[0].length;break}if(E!==0)continue;let x=()=>{let y=[f.itemVar,f.indexVar].filter(Boolean);if(y.length)l.push({start:p,end:S,vars:y})};if(f.iterable){let y=f.iterable.trim();if(y.startsWith("[")||y.startsWith("{")||y.startsWith("'")||y.startsWith('"')||y.startsWith("`")||/^-?\d/.test(y)){x();continue}let k=y.split(/[.[(]/)[0].trim(),A=i?k in i:!1,V=l.some((P)=>p>P.start&&p<P.end&&P.vars.includes(k));if(k&&(A||V)){x();continue}}if(f.style==="as")g=f.indexVar?`(${f.itemVar}, ${f.indexVar}) in ${f.iterable}`:`${f.itemVar} in ${f.iterable}`;let C=s.substring(d,S-b.length).trim(),R=i?{...i}:{};if(f.itemVar)delete R[f.itemVar];if(f.indexVar)delete R[f.indexVar];let _=Hr(C,R),v=_.match(Q),I;if(v){let[,y,k,A]=v;I=`<${y}${k} @for="${g}">${A}</${y}>`}else I=`<template @for="${g}">${_}</template>`;a.push({start:p,end:S,replacement:I}),t.lastIndex=S}for(let o=a.length-1;o>=0;o--){let{start:p,end:h,replacement:u}=a[o];s=s.substring(0,p)+u+s.substring(h)}return s}function ue(e){let i=new Set,s=[],t=0,n=0,a=e.length,l=(u)=>{let c=t+1;while(c<a){let g=e[c];if(g==="\\"){c+=2;continue}if(g===u)return c+1;c++}return a},o=()=>{let u=t+2;while(u<a&&e[u]!==`
4
4
  `)u++;return u},p=()=>{let u=t+2;while(u<a-1){if(e[u]==="*"&&e[u+1]==="/")return u+2;u++}return a},h=(u)=>{let c=u,g=0;while(c<a){let d=e[c];if(d==="/"&&e[c+1]==="/"){let f=c+2;while(f<a&&e[f]!==`
5
- `)f++;c=f;continue}if(d==="/"&&e[c+1]==="*"){let f=c+2;while(f<a-1&&!(e[f]==="*"&&e[f+1]==="/"))f++;c=f+2;continue}if(d==='"'||d==="'"||d==="`"){let f=c+1;while(f<a){if(e[f]==="\\"){f+=2;continue}if(e[f]===d){f++;break}f++}c=f;continue}if(d==="("||d==="["||d==="{"){g++,c++;continue}if(d===")"||d==="]"||d==="}"){g--,c++;continue}if(d===";"&&g===0)return c+1;c++}return a};while(t<a){let u=e[t];if(u==="/"&&e[t+1]==="/"){let c=o();s.push(e.slice(t,c)),t=c;continue}if(u==="/"&&e[t+1]==="*"){let c=p();s.push(e.slice(t,c)),t=c;continue}if(u==='"'||u==="'"||u==="`"){let c=l(u);s.push(e.slice(t,c)),t=c;continue}if(u==="{"){n++,s.push(u),t++;continue}if(u==="}"){n--,s.push(u),t++;continue}if(n===0){let c=t>0?e[t-1]:"";if(c===""||/\s/.test(c)||c===";"||c==="}"||c==="{"){let d=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(d){let f=d[2],b=h(t+d[0].length);if(i.has(f)){s.push(`/* stx: deduped const ${f} */`),t=b;continue}i.add(f),s.push(e.slice(t,b)),t=b;continue}}}s.push(u),t++}return s.join("")}var fe=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,i,s){for(let t of s){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function de(e,i,s){let t=0;while(t<e.length){let n=e.indexOf(i,t);if(n===-1)return!1;if(!D(n,n+i.length,s))return!0;t=n+i.length}return!1}function ge(e,i){if(de(e,"<body",i)){let n=new RegExp(`<body(${j})>`,"g"),a;while((a=n.exec(e))!==null)if(!D(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let s=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=s.exec(e))!==null){if(D(t.index,t.index+t[0].length,i))continue;if(fe.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function pe(e,i,s,t){let n=[],a=` data-stx="${t}"`,l=0,o=!1,p=(h)=>{if(s!==null&&!o&&s>=l&&s<=h)n.push(e.slice(l,s),a,e.slice(s,h)),o=!0;else n.push(e.slice(l,h))};for(let h of i){if(h.start<l)continue;p(h.start),l=h.end}return p(e.length),n.join("")}async function Vr(e,i,s,t={}){let n=_l(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,l=[],{hasUserImports:o,bundleClientScript:p}=await r("stx/client-script-bundler",()=>import("./chunk-x8knte1j.js"));for(let m of n){let x=m.body;if(Ne(m.attrs))x=De(x);if(t.forceClientSetup||a.test(x)){l.push({content:x,start:m.start,end:m.end});continue}if(!o(x))continue;try{let C=await p(Pt(x).code,i||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(C))l.push({content:x,start:m.start,end:m.end})}catch{}}if(l.length===0)return{output:e,setupCode:null};let h=`${i??""}\x00${l.map((m)=>m.content).join("\x00")}`,u=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,c=[];for(let m=0;m<l.length;m++){let x=l[m].bundled??Pt(l[m].content).code;if(!l[m].bundled&&o(x))x=await p(x,i||"",{projectRoot:process.cwd(),externalizeUserModules:t.forceClientSetup?!1:void 0});x=mt(x);let C=T(x);c.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
5
+ `)f++;c=f;continue}if(d==="/"&&e[c+1]==="*"){let f=c+2;while(f<a-1&&!(e[f]==="*"&&e[f+1]==="/"))f++;c=f+2;continue}if(d==='"'||d==="'"||d==="`"){let f=c+1;while(f<a){if(e[f]==="\\"){f+=2;continue}if(e[f]===d){f++;break}f++}c=f;continue}if(d==="("||d==="["||d==="{"){g++,c++;continue}if(d===")"||d==="]"||d==="}"){g--,c++;continue}if(d===";"&&g===0)return c+1;c++}return a};while(t<a){let u=e[t];if(u==="/"&&e[t+1]==="/"){let c=o();s.push(e.slice(t,c)),t=c;continue}if(u==="/"&&e[t+1]==="*"){let c=p();s.push(e.slice(t,c)),t=c;continue}if(u==='"'||u==="'"||u==="`"){let c=l(u);s.push(e.slice(t,c)),t=c;continue}if(u==="{"){n++,s.push(u),t++;continue}if(u==="}"){n--,s.push(u),t++;continue}if(n===0){let c=t>0?e[t-1]:"";if(c===""||/\s/.test(c)||c===";"||c==="}"||c==="{"){let d=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(d){let f=d[2],b=h(t+d[0].length);if(i.has(f)){s.push(`/* stx: deduped const ${f} */`),t=b;continue}i.add(f),s.push(e.slice(t,b)),t=b;continue}}}s.push(u),t++}return s.join("")}var fe=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,i,s){for(let t of s){if(t.start>=i)return!1;if(t.end>e)return!0}return!1}function de(e,i,s){let t=0;while(t<e.length){let n=e.indexOf(i,t);if(n===-1)return!1;if(!D(n,n+i.length,s))return!0;t=n+i.length}return!1}function ge(e,i){if(de(e,"<body",i)){let n=new RegExp(`<body(${j})>`,"g"),a;while((a=n.exec(e))!==null)if(!D(a.index,a.index+a[0].length,i))return a.index+a[0].length-1;return null}let s=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=s.exec(e))!==null){if(D(t.index,t.index+t[0].length,i))continue;if(fe.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function pe(e,i,s,t){let n=[],a=` data-stx="${t}"`,l=0,o=!1,p=(h)=>{if(s!==null&&!o&&s>=l&&s<=h)n.push(e.slice(l,s),a,e.slice(s,h)),o=!0;else n.push(e.slice(l,h))};for(let h of i){if(h.start<l)continue;p(h.start),l=h.end}return p(e.length),n.join("")}async function Vr(e,i,s,t={}){let n=_l(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,l=[],{hasUserImports:o,bundleClientScript:p}=await r("stx/client-script-bundler",()=>import("./chunk-crcypbbq.js"));for(let m of n){let x=m.body;if(De(m.attrs))x=Me(x);if(t.forceClientSetup||a.test(x)){l.push({content:x,start:m.start,end:m.end});continue}if(!o(x))continue;try{let C=await p(Pt(x).code,i||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(C))l.push({content:x,start:m.start,end:m.end})}catch{}}if(l.length===0)return{output:e,setupCode:null};let h=`${i??""}\x00${l.map((m)=>m.content).join("\x00")}`,u=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,c=[];for(let m=0;m<l.length;m++){let x=l[m].bundled??Pt(l[m].content).code;if(!l[m].bundled&&o(x))x=await p(x,i||"",{projectRoot:process.cwd()});x=ht(x);let C=T(x);c.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
6
6
  ${C}`)}let g=c.join(`
7
7
 
8
8
  `);g=ue(g);let f=L(g).split(",").map((m)=>m.trim()).filter(Boolean),b=dn(g,s),E=`
9
9
  <script data-stx-scoped>
10
10
  function ${u}() {
11
- ${rt("const",f)}
11
+ ${st("const",f)}
12
12
  ${sn(`${b}${g}`)}
13
13
  return ${rs(g,f)};
14
14
  }
@@ -17,5 +17,5 @@ if(window.stx)window.stx._latestSetup=${u};
17
17
  </script>`,S=ge(e,l);return{output:pe(e,l,S,u),setupCode:E}}async function co(e,i,s,t){if(!Fr(e,s))return e;let n=e;if(i.skipSignalsRuntime)return n;let{output:a,setupCode:l}=await Vr(n,s,t);if(n=a,!l){let o=U(n);if(o&&!/data-stx/.test(o.attrs)&&!/data-stx-auto/.test(o.attrs)){let p=o.tag.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>");n=n.slice(0,o.index)+p+n.slice(o.index+o.tag.length)}}if(n=await Kn(n,i),l){let o=ia(n,/<\/head>/i),p=o===-1?ia(n,/<body[^>]*>/i):-1;if(o!==-1)n=`${n.slice(0,o)}${l}
18
18
  ${n.slice(o)}`;else if(p!==-1){let h=/<body[^>]*>/i.exec(n.slice(p))[0],u=p+h.length;n=`${n.slice(0,u)}
19
19
  ${l}${n.slice(u)}`}else n=`${n}
20
- ${l}`}return n}function ia(e,i){let s=/<(script|style)\b[\s\S]*?<\/\1>/gi,t=[],n;while((n=s.exec(e))!==null)t.push([n.index,n.index+n[0].length]);let a=new RegExp(i.source,i.flags.replace(/[gy]/g,"")),l=0;while(l<e.length){let o=a.exec(e.slice(l));if(!o)return-1;let p=l+o.index;if(!t.some(([u,c])=>p>=u&&p<c))return p;l=p+Math.max(o[0].length,1)}return-1}var H="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function Cl(e){let i=[];for(let s of e.split(",")){let t=s.trim();if(!t||t.startsWith("type "))continue;let n=t.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(n&&n[1]!==n[2])i.push(`${n[2]} = ${n[1]}`)}if(i.length===0)return H;return`var ${i.join(", ")}; ${H}`}var he=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function mt(e){return e.replace(he,(i,s)=>Cl(s))}
21
- export{fp,_l,oo,Fr,io,ao,zr,Hr,Vr,co,ia,Cl,mt};
20
+ ${l}`}return n}function ia(e,i){let s=/<(script|style)\b[\s\S]*?<\/\1>/gi,t=[],n;while((n=s.exec(e))!==null)t.push([n.index,n.index+n[0].length]);let a=new RegExp(i.source,i.flags.replace(/[gy]/g,"")),l=0;while(l<e.length){let o=a.exec(e.slice(l));if(!o)return-1;let p=l+o.index;if(!t.some(([u,c])=>p>=u&&p<c))return p;l=p+Math.max(o[0].length,1)}return-1}var H="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function Cl(e){let i=[];for(let s of e.split(",")){let t=s.trim();if(!t||t.startsWith("type "))continue;let n=t.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(n&&n[1]!==n[2])i.push(`${n[2]} = ${n[1]}`)}if(i.length===0)return H;return`var ${i.join(", ")}; ${H}`}var he=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function ht(e){return e.replace(he,(i,s)=>Cl(s))}
21
+ export{fp,_l,oo,Fr,io,ao,zr,Hr,Vr,co,ia,Cl,ht};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Cs,Xo,du,pu,fu}from"./chunk-xqp4hstk.js";import"./chunk-ecqrkyg8.js";export{pu as generateManifestLink,Cs as generatePwaTags,du as generateSwRegistrationScript,fu as generateThemeColorMeta,Xo as injectPwaTags};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{AsyncLocalStorage as R}from"async_hooks";var b=Symbol.for("stx.runtime-config.scope"),y=globalThis,m=y[b]??=new R;function Le(n,f){return m.run(n,f)}function mn(){return m.getStore()}function ys(){let n=m.getStore();if(!n)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:n.public},"private",{value:n.private}))}function Bo(){return ys().public}function A(n={},f=process.env){let s=new Set;function o(e,i){if(i===null)return e===null;if(Array.isArray(i))return Array.isArray(e)&&(!i.length||e.every((r)=>i.some((u)=>o(r,u))));if(typeof i==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.entries(i).every(([r,u])=>Object.hasOwn(e,r)&&o(e[r],u));return typeof e===typeof i}function g(e,i){if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`);let t=Object.create(null);for(let[c,l]of Object.entries(e)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)||["constructor","prototype","__proto__"].includes(c))throw TypeError(`Invalid runtime config key: ${c}`);t[c]=g(l,[...i,c])}return Object.freeze(t)}let r=`STX_RUNTIME_${i.map((t)=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(s.has(r))throw TypeError(`Ambiguous runtime config environment key: ${r}`);s.add(r);let u=f[r],a=e;if(u!==void 0){try{a=typeof e==="string"?u:JSON.parse(u)}catch{throw TypeError(`Invalid runtime config override: ${r}`)}if(!o(a,e))throw TypeError(`Wrong runtime config override type: ${r}`)}function p(t){if(t===null||typeof t==="string"||typeof t==="boolean")return t;if(typeof t==="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(p));if(t&&typeof t==="object"&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null))return Object.freeze(Object.fromEntries(Object.entries(t).map(([c,l])=>[c,p(l)])));throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`)}return p(a)}return Object.freeze({public:g(n.public??{},["public"]),private:g(n.private??{},["private"])})}function C(n){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(n.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Ot(n,f){let s=n.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),o=/<head\b[^>]*>/i.exec(s),g=o?o.index+o[0].length:0;return s.slice(0,g)+C(f)+s.slice(g)}
3
- export{Le,mn,ys,Bo,A,Ot};
2
+ import{AsyncLocalStorage as R}from"async_hooks";var b=Symbol.for("stx.runtime-config.scope"),y=globalThis,m=y[b]??=new R;function je(n,f){return m.run(n,f)}function mn(){return m.getStore()}function ys(){let n=m.getStore();if(!n)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:n.public},"private",{value:n.private}))}function Bo(){return ys().public}function A(n={},f=process.env){let s=new Set;function o(e,i){if(i===null)return e===null;if(Array.isArray(i))return Array.isArray(e)&&(!i.length||e.every((r)=>i.some((u)=>o(r,u))));if(typeof i==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.entries(i).every(([r,u])=>Object.hasOwn(e,r)&&o(e[r],u));return typeof e===typeof i}function g(e,i){if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`);let t=Object.create(null);for(let[c,l]of Object.entries(e)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)||["constructor","prototype","__proto__"].includes(c))throw TypeError(`Invalid runtime config key: ${c}`);t[c]=g(l,[...i,c])}return Object.freeze(t)}let r=`STX_RUNTIME_${i.map((t)=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(s.has(r))throw TypeError(`Ambiguous runtime config environment key: ${r}`);s.add(r);let u=f[r],a=e;if(u!==void 0){try{a=typeof e==="string"?u:JSON.parse(u)}catch{throw TypeError(`Invalid runtime config override: ${r}`)}if(!o(a,e))throw TypeError(`Wrong runtime config override type: ${r}`)}function p(t){if(t===null||typeof t==="string"||typeof t==="boolean")return t;if(typeof t==="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(p));if(t&&typeof t==="object"&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null))return Object.freeze(Object.fromEntries(Object.entries(t).map(([c,l])=>[c,p(l)])));throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`)}return p(a)}return Object.freeze({public:g(n.public??{},["public"]),private:g(n.private??{},["private"])})}function C(n){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(n.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Ot(n,f){let s=n.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),o=/<head\b[^>]*>/i.exec(s),g=o?o.index+o[0].length:0;return s.slice(0,g)+C(f)+s.slice(g)}
3
+ export{je,mn,ys,Bo,A,Ot};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{g,Po,Va,Ua,Xl,Jl,Yl,Zl,Ql,ms,eu,De,G,Me,tu,lr,nu,Ga,Do,Le,n,pn,Ka,m,de,Rp}from"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{de as clearComponentCache,Do as componentClientSignalNames,Po as convertToCommonJS,m as createDetailedErrorMessage,Ql as extractDirectiveNames,Va as extractScriptFromTemplate,g as extractVariables,n as fileExists,Rp as getComponentCacheStats,Jl as getPositionInfo,G as getSharedTranspiler,Ka as getSourceLineInfo,Zl as hasDirectives,Ua as hasVariables,nu as isHydrateTrigger,eu as isJavaScriptScript,Le as renderComponentWithSlot,pn as resolveTemplatePath,tu as scopeOnRootElement,ms as scopeSequenceKey,De as shouldTranspileTypeScript,Ga as slotContentHasExpressions,Me as transpileTypeScript,lr as userComponentFileExists,Yl as validateDirective,Xl as validateTemplate};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xc,Sc}from"./chunk-gjck0t32.js";import"./chunk-fwwt7nrc.js";import"./chunk-fbcp9hm4.js";import"./chunk-7met6yva.js";import"./chunk-7d4z944r.js";import"./chunk-yphmswg3.js";import"./chunk-zqtbtqbq.js";import"./chunk-6h06rqmj.js";import{_i}from"./chunk-znb4y12p.js";import"./chunk-jxda11cg.js";import"./chunk-89jbdtgw.js";import"./chunk-f62hpbw8.js";import"./chunk-rcadtv3x.js";import"./chunk-ydf4fmr6.js";import"./chunk-b823zxq6.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-mn3mc6ax.js";import"./chunk-tre98h62.js";import"./chunk-4701f9eh.js";import"./chunk-dgb4z4kw.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-aprhqxky.js";import"./chunk-kgfgb971.js";import"./chunk-nrvwejdw.js";import"./chunk-qxsvd26z.js";import"./chunk-j045bcpb.js";import"./chunk-3y41efsf.js";import"./chunk-6jwey47v.js";import"./chunk-yfvm7q6t.js";import"./chunk-6ajahb2x.js";import"./chunk-t886718q.js";import"./chunk-ec9ztgxx.js";import"./chunk-md2jn67b.js";import{Te,s}from"./chunk-w51q85zg.js";import"./chunk-j7mr8h2w.js";import"./chunk-prf164ct.js";import"./chunk-4qh789bq.js";import"./chunk-mekhzhes.js";import"./chunk-hjn7qqrq.js";import"./chunk-ka8befem.js";import"./chunk-1ffjj2c6.js";import{me}from"./chunk-jzy0pqez.js";import"./chunk-p472crv1.js";import{Xn,Jn}from"./chunk-qrq88ng0.js";import{qr,N,o}from"./chunk-fsef9nvs.js";import"./chunk-t226hswj.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{g,Ne}from"./chunk-c7d09931.js";import"./chunk-8gy90n5q.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";export{qr as buildWebComponents,Jn as cacheTemplate,Xn as checkCache,_i as classifyAllScripts,xc as createMiddleware,Sc as createRoute,N as defaultConfig,g as extractVariables,me as injectRouterScript,o as loadStxConfig,Ne as processClientScript,s as processDirectives,Te as readMarkdownFile};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{zn,Ee}from"./chunk-md2jn67b.js";export{zn as describeBuildFailure,Ee as formatBuildFailure};
@@ -1,23 +1,23 @@
1
1
  // @bun
2
- import{H}from"./chunk-fbtv2k1p.js";import Oe from"path";var t={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function G(e){for(let[n,r]of Object.entries(t))if(r===e)return n;return}import st from"path";var ot={showRelativePaths:!1,enableAutoRecovery:H(),logRecoveryWarnings:!0},Y={...ot};function N(){return{...Y}}function M(e){if(!Y.showRelativePaths||!e)return e;let n=Y.baseDir||process.cwd();try{let r=st.relative(n,e);return r.startsWith("..")?e:r}catch{return e}}class L extends Error{code;filePath;line;column;context;numericCode;constructor(e,n,r,i,s,o,c){super(e);this.code=n;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=c||t.EVALUATION_ERROR,this.filePath)this.filePath=M(this.filePath)}}class re extends L{constructor(e,n,r,i,s,o){super(e,"stx_RUNTIME_ERROR",n,r,i,s,o||t.EVALUATION_ERROR);this.name="StxRuntimeError"}}class ur extends L{constructor(e,n,r,i,s,o){super(e,"stx_FILE_ERROR",n,r,i,s,o||t.FILE_NOT_FOUND);this.name="StxFileError"}}class z extends L{isFatal=!0;constructor(e,n,r,i,s,o){super(e,"stx_VALIDATION_ERROR",n,r,i,s,o||t.DOM_API_VIOLATION);this.name="StxValidationError"}}function me(e){let{type:n,message:r,code:i,filePath:s,line:o,column:c,template:g,offset:f,snippet:p,suggestion:h,format:m="text"}=e,y=o,x=c;if(!y&&g&&f!==void 0){let K=pt(g,f);y=K.line,x=K.column}let k=s?M(s):void 0,S=i?G(i):void 0,C={type:n,code:i,codeName:S,message:r,filePath:k,line:y,column:x,snippet:p,suggestion:h,timestamp:new Date().toISOString()},T;switch(m){case"html":T=ct(C);break;case"json":T=JSON.stringify(C,null,2);break;case"console":T=lt(C,g,f);break;case"text":default:T=at(C,g,f);break}return{formatted:T,data:C}}function at(e,n,r){let i=[],s=e.code?` [${e.codeName||e.code}]`:"";if(i.push(`[${e.type} Error${s}]`),e.filePath){let o=e.filePath;if(e.line){if(o+=`:${e.line}`,e.column)o+=`:${e.column}`}i.push(`at ${o}`)}if(i.push(`
2
+ import{H}from"./chunk-fbtv2k1p.js";import Oe from"path";var t={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function G(e){for(let[n,r]of Object.entries(t))if(r===e)return n;return}import st from"path";var ot={showRelativePaths:!1,enableAutoRecovery:H(),logRecoveryWarnings:!0},Y={...ot};function N(){return{...Y}}function M(e){if(!Y.showRelativePaths||!e)return e;let n=Y.baseDir||process.cwd();try{let r=st.relative(n,e);return r.startsWith("..")?e:r}catch{return e}}class L extends Error{code;filePath;line;column;context;numericCode;constructor(e,n,r,i,s,o,c){super(e);this.code=n;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=c||t.EVALUATION_ERROR,this.filePath)this.filePath=M(this.filePath)}}class re extends L{constructor(e,n,r,i,s,o){super(e,"stx_RUNTIME_ERROR",n,r,i,s,o||t.EVALUATION_ERROR);this.name="StxRuntimeError"}}class ur extends L{constructor(e,n,r,i,s,o){super(e,"stx_FILE_ERROR",n,r,i,s,o||t.FILE_NOT_FOUND);this.name="StxFileError"}}class z extends L{isFatal=!0;constructor(e,n,r,i,s,o){super(e,"stx_VALIDATION_ERROR",n,r,i,s,o||t.DOM_API_VIOLATION);this.name="StxValidationError"}}function me(e){let{type:n,message:r,code:i,filePath:s,line:o,column:c,template:g,offset:d,snippet:f,suggestion:h,format:m="text"}=e,y=o,x=c;if(!y&&g&&d!==void 0){let K=pt(g,d);y=K.line,x=K.column}let k=s?M(s):void 0,S=i?G(i):void 0,C={type:n,code:i,codeName:S,message:r,filePath:k,line:y,column:x,snippet:f,suggestion:h,timestamp:new Date().toISOString()},T;switch(m){case"html":T=ct(C);break;case"json":T=JSON.stringify(C,null,2);break;case"console":T=lt(C,g,d);break;case"text":default:T=at(C,g,d);break}return{formatted:T,data:C}}function at(e,n,r){let i=[],s=e.code?` [${e.codeName||e.code}]`:"";if(i.push(`[${e.type} Error${s}]`),e.filePath){let o=e.filePath;if(e.line){if(o+=`:${e.line}`,e.column)o+=`:${e.column}`}i.push(`at ${o}`)}if(i.push(`
3
3
  ${e.message}`),n&&e.line){let o=ut(n,e.line,2);if(o)i.push(`
4
4
  ${o}`)}if(e.snippet)i.push(`
5
5
  Snippet: ${e.snippet}`);if(e.suggestion)i.push(`
6
- Suggestion: ${e.suggestion}`);return i.join(" ")}function ct(e){let n=e.code?` [${e.code}]`:"",r=e.filePath?` in ${e.filePath}${e.line?`:${e.line}`:""}`:"",i=`<!-- [${e.type} Error${n}]${r}: ${de(e.message)}`;if(e.suggestion)i+=` | Suggestion: ${de(e.suggestion)}`;return i+=" -->",i}function lt(e,n,r){let p=[],h=e.code?` [${e.codeName||e.code}]`:"";if(p.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${e.type} Error${h} \u2501\u2501\u2501${"\x1B[0m"}`),e.filePath){let m=`\x1B[36m${e.filePath}\x1B[0m`;if(e.line){if(m+=`\x1B[90m:${e.line}\x1B[0m`,e.column)m+=`\x1B[90m:${e.column}\x1B[0m`}p.push(`
7
- \x1B[90mat\x1B[0m ${m}`)}if(p.push(`
6
+ Suggestion: ${e.suggestion}`);return i.join(" ")}function ct(e){let n=e.code?` [${e.code}]`:"",r=e.filePath?` in ${e.filePath}${e.line?`:${e.line}`:""}`:"",i=`<!-- [${e.type} Error${n}]${r}: ${de(e.message)}`;if(e.suggestion)i+=` | Suggestion: ${de(e.suggestion)}`;return i+=" -->",i}function lt(e,n,r){let f=[],h=e.code?` [${e.codeName||e.code}]`:"";if(f.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${e.type} Error${h} \u2501\u2501\u2501${"\x1B[0m"}`),e.filePath){let m=`\x1B[36m${e.filePath}\x1B[0m`;if(e.line){if(m+=`\x1B[90m:${e.line}\x1B[0m`,e.column)m+=`\x1B[90m:${e.column}\x1B[0m`}f.push(`
7
+ \x1B[90mat\x1B[0m ${m}`)}if(f.push(`
8
8
 
9
- ${e.message}`),n&&e.line){let m=gt(n,e.line,2);if(m)p.push(`
9
+ ${e.message}`),n&&e.line){let m=gt(n,e.line,2);if(m)f.push(`
10
10
 
11
11
  \x1B[90mContext:\x1B[0m
12
- ${m}`)}if(e.suggestion)p.push(`
12
+ ${m}`)}if(e.suggestion)f.push(`
13
13
 
14
- \x1B[33mSuggestion:\x1B[0m ${e.suggestion}`);return p.push(`
15
- ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),p.join("")}function ut(e,n,r){let i=e.split(`
16
- `),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),c=[];for(let g=s;g<=o;g++){let f=(g+1).toString().padStart(4),p=g===n-1?">":" ";c.push(`${p}${f} | ${i[g]}`)}return c.join(`
14
+ \x1B[33mSuggestion:\x1B[0m ${e.suggestion}`);return f.push(`
15
+ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),f.join("")}function ut(e,n,r){let i=e.split(`
16
+ `),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),c=[];for(let g=s;g<=o;g++){let d=(g+1).toString().padStart(4),f=g===n-1?">":" ";c.push(`${f}${d} | ${i[g]}`)}return c.join(`
17
17
  `)}function gt(e,n,r){let i=e.split(`
18
- `),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),c="\x1B[90m",g="\x1B[31m",f="\x1B[0m",p=[];for(let h=s;h<=o;h++){let m=(h+1).toString().padStart(4),y=h===n-1,x=y?"\x1B[31m>\x1B[0m":" ",k=y?`\x1B[31m${i[h]}\x1B[0m`:`\x1B[90m${i[h]}\x1B[0m`;p.push(`${x}\x1B[90m${m}\x1B[0m | ${k}`)}return p.join(`
18
+ `),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),c="\x1B[90m",g="\x1B[31m",d="\x1B[0m",f=[];for(let h=s;h<=o;h++){let m=(h+1).toString().padStart(4),y=h===n-1,x=y?"\x1B[31m>\x1B[0m":" ",k=y?`\x1B[31m${i[h]}\x1B[0m`:`\x1B[90m${i[h]}\x1B[0m`;f.push(`${x}\x1B[90m${m}\x1B[0m | ${k}`)}return f.join(`
19
19
  `)}function de(e){return e.replace(/--/g,"- -").replace(/>/g,"&gt;")}function pt(e,n){let i=e.substring(0,n).split(`
20
- `);return{line:i.length,column:i[i.length-1].length}}function a(e,n,r){return me({type:e,message:n,code:r,format:"html"}).formatted}async function ve(e,n,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return n}}var zo={isEnabled(){return N().enableAutoRecovery},fixCommonSyntaxErrors(e){let n=N();if(!n.enableAutoRecovery)return{fixed:e,fixes:[]};let r=e,i=[],s=(r.match(/\{\{/g)||[]).length,o=(r.match(/\}\}/g)||[]).length;if(s>o){let g=s-o;r+="}}".repeat(g),i.push(`Added ${g} missing closing braces '}}'`)}let c=["if","foreach","for","switch","section"];for(let g of c){let f=(r.match(new RegExp(`@${g}\\b`,"g"))||[]).length,p=(r.match(new RegExp(`@end${g}\\b`,"g"))||[]).length;if(f>p){let h=f-p;for(let m=0;m<h;m++)r+=`
20
+ `);return{line:i.length,column:i[i.length-1].length}}function a(e,n,r){return me({type:e,message:n,code:r,format:"html"}).formatted}async function we(e,n,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return n}}var zo={isEnabled(){return N().enableAutoRecovery},fixCommonSyntaxErrors(e){let n=N();if(!n.enableAutoRecovery)return{fixed:e,fixes:[]};let r=e,i=[],s=(r.match(/\{\{/g)||[]).length,o=(r.match(/\}\}/g)||[]).length;if(s>o){let g=s-o;r+="}}".repeat(g),i.push(`Added ${g} missing closing braces '}}'`)}let c=["if","foreach","for","switch","section"];for(let g of c){let d=(r.match(new RegExp(`@${g}\\b`,"g"))||[]).length,f=(r.match(new RegExp(`@end${g}\\b`,"g"))||[]).length;if(d>f){let h=d-f;for(let m=0;m<h;m++)r+=`
21
21
  @end${g}`;i.push(`Added ${h} missing @end${g}`)}}if(i.length>0&&n.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((g)=>console.warn(` - ${g}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,n){if(H())return`<!-- ${e} failed: ${n.message} -->`;return"<!-- stx rendering error -->"}};class J{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,n,r="error"){let i={timestamp:new Date,error:e,context:n,level:r};if(this.errors.push(i),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(i)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let n=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)n.push(` Stack: ${e.error.stack.split(`
22
22
  `).slice(1).join(`
23
23
  `)}`);if(e.context)n.push(` Context: ${JSON.stringify(e.context)}`);return n.join(`
@@ -25,7 +25,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
25
25
  `;n.appendFileSync(this.logFilePath,s,"utf-8")}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",n)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let i=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(i))if(r>=this.maxLogFiles-1)e.unlinkSync(i);else e.renameSync(i,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",n)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((n)=>n.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((n)=>n.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},n={error:0,warning:0,info:0};for(let r of this.errors){let i=r.error.constructor.name;e[i]=(e[i]||0)+1;let s=r.level||"error";n[s]=(n[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:n}}async exportToFile(e,n="json"){let r=await import("fs"),i=await import("path"),s=i.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(n==="json"){let o=this.errors.map((c)=>({timestamp:c.timestamp.toISOString(),level:c.level||"error",type:c.error.constructor.name,message:c.error.message,stack:c.error.stack,context:c.context}));r.writeFileSync(e,JSON.stringify(o,null,2),"utf-8")}else{let o=this.errors.map((c)=>this.formatEntry(c));r.writeFileSync(e,o.join(`
26
26
 
27
27
  `),"utf-8")}}async flush(){await this.writeQueue}}var D=new J,hn={isDevelopment(){return H()},logDetailedError(e,n){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),n)console.error("Context:",n);console.error("========================")},createErrorReport(e,n){let r=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(n)r.push(`Context: ${JSON.stringify(n,null,2)}`);return r.push("========================"),r.join(`
28
- `)}};function w(e,n,r,i=0){let s=0,o=i,c=null,g=0,f=!1;while(o<e.length){let p=e[o];if(c&&f){f=!1,o++;continue}if(c&&p==="\\"){f=!0,o++;continue}if(f=!1,(p==='"'||p==="'"||p==="`")&&!c){c=p,o++;continue}if(p===c&&c!=="`"){c=null,o++;continue}if(c==="`"&&p==="$"&&e[o+1]==="{"){g++,o+=2;continue}if(g>0&&p==="}"){g--,o++;continue}if(p==="`"&&c==="`"&&g===0){c=null,o++;continue}if(c){o++;continue}if(p===n)s++;else if(p===r){if(s--,s===0)return o}o++}return-1}var ft={maxSanitizeDepth:10,allowBracketNotation:!1},Se={...ft};var j=/\bnew\s+/,B="__stx_safe_ctors",ke=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Z=[...ke,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],he=Z.map(()=>{return}),Q=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),te=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,j,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],ne=new Set([...ke,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",B]),ie=new Set(["__proto__","constructor","prototype"]);function $e(e){let n="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o];if(s){s=!1;continue}if(c==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&c==="$"&&o+1<e.length&&e[o+1]==="{"){let g=1;o+=2;while(o<e.length&&g>0){if(e[o]==="{")g++;else if(e[o]==="}")g--;if(g>0)n+=e[o],r.push(o),o++}continue}if(c===i)i=null;continue}if(c==='"'||c==="'"||c==="`"){i=c;continue}n+=c,r.push(o)}return{text:n,map:r}}function Re(e){return $e(e).text}var Ce=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Ae=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Ce)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})(),dt=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,ye=/(?<![\w$])new(?![\w$])/g,Ee=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ce.join(",")}}() are allowed`;function mt(e){let{text:n,map:r}=$e(e),i=[];ye.lastIndex=0;let s;while((s=ye.exec(n))!==null){let c=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,c)))continue;let g=dt.exec(n.slice(c)),f=g?.[3],p=!g?null:f?`Intl_${f}`:g[2];if(!g||!p||!(p in Ae))throw new v(`matched /${j.source}/; ${Ee}`,e);let h=c+g[0].length,m=r[c],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(c,h))throw new v(`matched /${j.source}/; ${Ee}`,e);let x=m+3+g[1].length;i.push({start:x,end:x+g[2].length,key:p})}let o=e;for(let c=i.length-1;c>=0;c--){let g=i[c];o=`${o.slice(0,g.start)}${B}.${g.key}${o.slice(g.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class v extends Error{rule;expression;constructor(e,n,r){super(r??`Potentially unsafe expression (${e}): ${n}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=n}}function bs(e){try{return se(e),null}catch(n){return n instanceof v?n.rule:n instanceof Error?n.message:String(n)}}function Te(e,n){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(ne.has(s))throw new v(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&ie.has(s))throw new v(`matched /.${s}/; property ${s}`,n)}}function _e(e,n=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),c=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(c))continue;let g=s[1].trim(),f=/^'(?:[^'\\]|\\.)*'$/.test(g),p=/^"(?:[^"\\]|\\.)*"$/.test(g);if(/^\d+$/.test(g))continue;if(f||p){let m=g.slice(1,-1);if(ie.has(m))throw new v(`bracket key ${m}`,e);if(!Se.allowBracketNotation)throw new v("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(n&&/^[$A-Z_a-z][$\w]*$/.test(g)){i.add(g);continue}throw new v("dynamic bracket notation is not allowed",e)}return[...i]}function se(e){let n=e.trim(),r=Re(n);Te(r,n);let i=_e(n);for(let s of te){if(s===j)continue;if(s.test(r))throw new v(`matched /${s.source}/`,n)}return{...mt(n),dynamicKeys:i}}function Fo(e){return se(e),e.trim()}var vs=Symbol("stx.sanitizeCache");function U(e){let n={},r=e[vs];n.Math=Math,n.JSON=JSON,n.Date=Date,n.String=String,n.Number=Number,n.Boolean=Boolean,n.Array=Array,n.Object=Q,n.parseInt=Number.parseInt,n.parseFloat=Number.parseFloat,n.isNaN=Number.isNaN,n.isFinite=Number.isFinite,n.encodeURIComponent=encodeURIComponent,n.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||te.some((o)=>o.test(i)))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=ee(s),r?.set(s,o);n[i]=o}else n[i]=s}return n}function ee(e,n=0){if(n>=Se.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>ee(i,n+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=ee(s,n+1);else r[i]=s}return r}function l(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r);return u(e,i)(...s)}catch{return}}function d(e){try{return Fo(e),!0}catch{return!1}}function Qa(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r),o=!1,g=u(e,i,()=>{o=!0})(...s);return!o&&Boolean(g)}catch{return!1}}function E(e,n){try{let r=l(e,n);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var Ie=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),ht=2000,F=new Map;function be(e,n){let r=`${e.join(",")}\x00${n}`,i=F.get(r);if(i)return i;let s=Function(...e,n);if(F.size>=ht)F.clear();return F.set(r,s),s}function et(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var yt=/^[A-Za-z_$][\w$]*$/;function Nt(e){return yt.test(e)&&!Ie.has(e)}function u(e,n,r){let{source:i,usesSafeConstructors:s,dynamicKeys:o}=se(e),c=[];for(let m=0;m<n.length;m++){if(!Nt(n[m]))continue;if(n[m]===B||n[m]==="Object"||ne.has(n[m]))continue;c.push({key:n[m],index:m})}c.sort((m,y)=>m.key.localeCompare(y.key));let g=c.map((m)=>m.key),f=c.map((m)=>m.index),p=`
28
+ `)}};function w(e,n,r,i=0){let s=0,o=i,c=null,g=0,d=!1;while(o<e.length){let f=e[o];if(c&&d){d=!1,o++;continue}if(c&&f==="\\"){d=!0,o++;continue}if(d=!1,(f==='"'||f==="'"||f==="`")&&!c){c=f,o++;continue}if(f===c&&c!=="`"){c=null,o++;continue}if(c==="`"&&f==="$"&&e[o+1]==="{"){g++,o+=2;continue}if(g>0&&f==="}"){g--,o++;continue}if(f==="`"&&c==="`"&&g===0){c=null,o++;continue}if(c){o++;continue}if(f===n)s++;else if(f===r){if(s--,s===0)return o}o++}return-1}var ft={maxSanitizeDepth:10,allowBracketNotation:!1},ke={...ft};var j=/\bnew\s+/,B="__stx_safe_ctors",ve=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Z=[...ve,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],he=Z.map(()=>{return}),Q=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),te=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,j,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],ne=new Set([...ve,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",B]),ie=new Set(["__proto__","constructor","prototype"]);function $e(e){let n="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o];if(s){s=!1;continue}if(c==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&c==="$"&&o+1<e.length&&e[o+1]==="{"){let g=1;o+=2;while(o<e.length&&g>0){if(e[o]==="{")g++;else if(e[o]==="}")g--;if(g>0)n+=e[o],r.push(o),o++}continue}if(c===i)i=null;continue}if(c==='"'||c==="'"||c==="`"){i=c;continue}n+=c,r.push(o)}return{text:n,map:r}}function Re(e){return $e(e).text}var Ce=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Ae=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Ce)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})(),dt=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,ye=/(?<![\w$])new(?![\w$])/g,Ee=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ce.join(",")}}() are allowed`;function mt(e){let{text:n,map:r}=$e(e),i=[];ye.lastIndex=0;let s;while((s=ye.exec(n))!==null){let c=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,c)))continue;let g=dt.exec(n.slice(c)),d=g?.[3],f=!g?null:d?`Intl_${d}`:g[2];if(!g||!f||!(f in Ae))throw new v(`matched /${j.source}/; ${Ee}`,e);let h=c+g[0].length,m=r[c],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(c,h))throw new v(`matched /${j.source}/; ${Ee}`,e);let x=m+3+g[1].length;i.push({start:x,end:x+g[2].length,key:f})}let o=e;for(let c=i.length-1;c>=0;c--){let g=i[c];o=`${o.slice(0,g.start)}${B}.${g.key}${o.slice(g.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class v extends Error{rule;expression;constructor(e,n,r){super(r??`Potentially unsafe expression (${e}): ${n}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=n}}function bs(e){try{return se(e),null}catch(n){return n instanceof v?n.rule:n instanceof Error?n.message:String(n)}}function Te(e,n){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(ne.has(s))throw new v(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&ie.has(s))throw new v(`matched /.${s}/; property ${s}`,n)}}function _e(e,n=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),c=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(c))continue;let g=s[1].trim(),d=/^'(?:[^'\\]|\\.)*'$/.test(g),f=/^"(?:[^"\\]|\\.)*"$/.test(g);if(/^\d+$/.test(g))continue;if(d||f){let m=g.slice(1,-1);if(ie.has(m))throw new v(`bracket key ${m}`,e);if(!ke.allowBracketNotation)throw new v("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(n&&/^[$A-Z_a-z][$\w]*$/.test(g)){i.add(g);continue}throw new v("dynamic bracket notation is not allowed",e)}return[...i]}function se(e){let n=e.trim(),r=Re(n);Te(r,n);let i=_e(n);for(let s of te){if(s===j)continue;if(s.test(r))throw new v(`matched /${s.source}/`,n)}return{...mt(n),dynamicKeys:i}}function Fo(e){return se(e),e.trim()}var vs=Symbol("stx.sanitizeCache");function U(e){let n={},r=e[vs];n.Math=Math,n.JSON=JSON,n.Date=Date,n.String=String,n.Number=Number,n.Boolean=Boolean,n.Array=Array,n.Object=Q,n.parseInt=Number.parseInt,n.parseFloat=Number.parseFloat,n.isNaN=Number.isNaN,n.isFinite=Number.isFinite,n.encodeURIComponent=encodeURIComponent,n.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||te.some((o)=>o.test(i)))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=ee(s),r?.set(s,o);n[i]=o}else n[i]=s}return n}function ee(e,n=0){if(n>=ke.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>ee(i,n+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=ee(s,n+1);else r[i]=s}return r}function l(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r);return u(e,i)(...s)}catch{return}}function p(e){try{return Fo(e),!0}catch{return!1}}function Qa(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r),o=!1,g=u(e,i,()=>{o=!0})(...s);return!o&&Boolean(g)}catch{return!1}}function E(e,n){try{let r=l(e,n);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var Ie=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),ht=2000,F=new Map;function be(e,n){let r=`${e.join(",")}\x00${n}`,i=F.get(r);if(i)return i;let s=Function(...e,n);if(F.size>=ht)F.clear();return F.set(r,s),s}function tt(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var yt=/^[A-Za-z_$][\w$]*$/;function Nt(e){return yt.test(e)&&!Ie.has(e)}function u(e,n,r){let{source:i,usesSafeConstructors:s,dynamicKeys:o}=se(e),c=[];for(let m=0;m<n.length;m++){if(!Nt(n[m]))continue;if(n[m]===B||n[m]==="Object"||ne.has(n[m]))continue;c.push({key:n[m],index:m})}c.sort((m,y)=>m.key.localeCompare(y.key));let g=c.map((m)=>m.key),d=c.map((m)=>m.index),f=`
29
29
  'use strict';
30
30
  try {
31
31
  return ${i};
@@ -36,26 +36,26 @@ catch (e) {
36
36
  }
37
37
  throw e;
38
38
  }
39
- `;return Et(bt(s?(m)=>{let y=be([B,"Object",...Z,...g,...m],p);return(...x)=>y(Ae,Q,...he,...x)}:(m)=>{let y=be(["Object",...Z,...g,...m],p);return(...x)=>y(Q,...he,...x)},g,n,c,f,r),n,o)}function Et(e,n,r){if(r.length===0)return e;let i=r.map((s)=>n.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let c=s[o];if(typeof c==="string"&&ie.has(c))return}return e(...s)}}function bt(e,n,r,i,s,o){let c=e([]),g=i.every((p,h)=>p.index===h);if(n.length===r.length&&g)return xe(c,n,e,void 0,o);return xe((...p)=>{let h=Array(s.length);for(let m=0;m<s.length;m++)h[m]=p[s[m]];return c(...h)},n,e,(p)=>{c=e(p)},o)}function xe(e,n,r,i,s){let c=/^(\w+) is not defined$/,g=e,f=[],p=new Set(n);return(...h)=>{for(let m=0;m<=8;m++)try{return g(...h)}catch(y){let x=y instanceof Error?y.message:"",k=c.exec(x);if(!(y instanceof ReferenceError)||!k)return;let S=k[1];if(p.has(S)||Ie.has(S)||ne.has(S))return;if(s?.(S),p.add(S),f.push(S),i)i(f);else g=r(f)}return}}function ws(e){let n=e.trim();try{let r=Re(n);if(/\b(?:eval|function|import|require|process|globalthis|window|document|fetch|bun|deno|buffer|console|reflect|proxy|prototype|constructor|this)\b/i.test(r))return!1;Te(r,n),_e(n);for(let i of te)if(i.test(r))return!1}catch{return!1}return!0}function Ho(e,n){let r=[];n.lastIndex=0;let i;while((i=n.exec(e))!==null){let s=i.index,o=s+i[0].length-1,c=w(e,"(",")",o);if(c===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),n.lastIndex=o+1;continue}r.push({start:s,end:c+1,args:e.slice(o+1,c),call:e.slice(s,c+1)}),n.lastIndex=c+1}return r}function Dt(e,n,r,i){let s="",o=0;for(let c of Ho(e,n)){if(s+=e.slice(o,c.start),c.end===-1){s+=i(c.call),o=c.start;continue}s+=r(c.args,c.call),o=c.end}return s+e.slice(o)}function Mt(e){let n=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let c=e[o];if(i){if(s+=c,c==="\\"&&o+1<e.length){s+=e[++o];continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`")i=c;else if(c==="("||c==="["||c==="{")r++;else if(c===")"||c==="]"||c==="}")r--;else if(c===","&&r===0){n.push(s.trim()),s="";continue}s+=c}if(s.trim())n.push(s.trim());return n}function ae(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let i="";for(let s=1;s<n.length-1;s++){let o=n[s];if(o==="\\"&&s+1<n.length-1){let c=n[++s];i+=c==="n"?`
40
- `:c==="t"?"\t":c;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[s+1]==="{")return null;i+=o}return i}var xt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Lt(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=bs(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=U(n),o;try{o=u(r,Object.keys(s))(...Object.values(s))}catch(g){return{ok:!1,message:`the expression could not be evaluated: ${g instanceof Error?g.message:String(g)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let c=[...new Set(et(r))].filter((g)=>!xt.has(g)&&!(g in s)&&!(g in globalThis));if(c.length>0)return{ok:!1,message:`${c.map((f)=>`"${f}"`).join(", ")} ${c.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function je(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function tt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Le(e){if(!e)return"";return Oe.isAbsolute(e)?Oe.relative(process.cwd(),e)||e:e}function oe(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function P(e,n,r,i,s=t.EVALUATION_ERROR){let o=i?` in ${Le(i)}`:"";return console.warn(`[stx] ${oe(n)}${o}: ${r}`),a(e,`${oe(n)}: ${r}`,s)}function xs(e,n,r){let i=r?` in ${Le(r)}`:"";console.warn(`[stx] ${oe(e)}${i}: ${n}`)}function Vo(){return{afterOpen:[],beforeClose:[]}}function wt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function ec(e,n){if(!wt(n))return e;let r=n.afterOpen.join(""),i=n.beforeClose.join(""),s=e.lastIndexOf("</head>"),o=r?dr(e):null,c=i&&s!==-1?s:null;if(o===null&&c===null)return e;if(o!==null&&c!==null)return`${e.slice(0,o)}${r}${e.slice(o,c)}${i}${e.slice(c)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,c)}${i}${e.slice(c)}`}var Ne=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function dr(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return null;let r=n.index+n[0].length;Ne.lastIndex=r;let i=Ne.exec(e);return i?r+i[0].length:r}var le="data-stx-color-mode-boot",Me="__STX_COLOR_MODE__",St=new Set(["light","dark","auto","system"]),kt=new Set(["auto","system"]),vt=/^[a-z][\w:-]*$/i,$t=/^[\w-]+$/;function Rt(e){let n=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,c=e.respectExisting===!0;if(typeof n!=="string"||n.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!St.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!$t.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!vt.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!kt.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(c&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:n,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:c}}function Ct(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ue(e={}){let n=Rt(e),r=Ct(n),i=`(function(){"use strict";var o=window.${Me};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${Me}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${le}>${i}</script>`}function pr(e,n={}){if(e.includes(le))return e;let r=ce(e);if(r===null)return e;let i=ue(n);return`${e.slice(0,r)}
41
- ${i}${e.slice(r)}`}var ce=dr,At=new RegExp(`<script\\b[^>]*\\b${le}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Pe=/<meta\b[^>]*\bcharset\b[^>]*>/gi,Fe=/<\/head>/gi;function Tt(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return e;let r=n.index+n[0].length;Fe.lastIndex=r;let i=Fe.exec(e),s=i?i.index:e.length;Pe.lastIndex=r;let o=Pe.exec(e);if(!o||o.index>=s)return e;if(e.slice(r,o.index).trim()==="")return e;let c=o.index+o[0].length;return`${e.slice(0,r)}
39
+ `;return Et(bt(s?(m)=>{let y=be([B,"Object",...Z,...g,...m],f);return(...x)=>y(Ae,Q,...he,...x)}:(m)=>{let y=be(["Object",...Z,...g,...m],f);return(...x)=>y(Q,...he,...x)},g,n,c,d,r),n,o)}function Et(e,n,r){if(r.length===0)return e;let i=r.map((s)=>n.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let c=s[o];if(typeof c==="string"&&ie.has(c))return}return e(...s)}}function bt(e,n,r,i,s,o){let c=e([]),g=i.every((f,h)=>f.index===h);if(n.length===r.length&&g)return Se(c,n,e,void 0,o);return Se((...f)=>{let h=Array(s.length);for(let m=0;m<s.length;m++)h[m]=f[s[m]];return c(...h)},n,e,(f)=>{c=e(f)},o)}function Se(e,n,r,i,s){let c=/^(\w+) is not defined$/,g=e,d=[],f=new Set(n);return(...h)=>{for(let m=0;m<=8;m++)try{return g(...h)}catch(y){let x=y instanceof Error?y.message:"",k=c.exec(x);if(!(y instanceof ReferenceError)||!k)return;let S=k[1];if(f.has(S)||Ie.has(S)||ne.has(S))return;if(s?.(S),f.add(S),d.push(S),i)i(d);else g=r(d)}return}}function ws(e){let n=e.trim();try{let r=Re(n);if(/\b(?:eval|function|import|require|process|globalthis|window|document|fetch|bun|deno|buffer|console|reflect|proxy|prototype|constructor|this)\b/i.test(r))return!1;Te(r,n),_e(n);for(let i of te)if(i.test(r))return!1}catch{return!1}return!0}function Ho(e,n){let r=[];n.lastIndex=0;let i;while((i=n.exec(e))!==null){let s=i.index,o=s+i[0].length-1,c=w(e,"(",")",o);if(c===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),n.lastIndex=o+1;continue}r.push({start:s,end:c+1,args:e.slice(o+1,c),call:e.slice(s,c+1)}),n.lastIndex=c+1}return r}function Dt(e,n,r,i){let s="",o=0;for(let c of Ho(e,n)){if(s+=e.slice(o,c.start),c.end===-1){s+=i(c.call),o=c.start;continue}s+=r(c.args,c.call),o=c.end}return s+e.slice(o)}function Mt(e){let n=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let c=e[o];if(i){if(s+=c,c==="\\"&&o+1<e.length){s+=e[++o];continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`")i=c;else if(c==="("||c==="["||c==="{")r++;else if(c===")"||c==="]"||c==="}")r--;else if(c===","&&r===0){n.push(s.trim()),s="";continue}s+=c}if(s.trim())n.push(s.trim());return n}function ae(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let i="";for(let s=1;s<n.length-1;s++){let o=n[s];if(o==="\\"&&s+1<n.length-1){let c=n[++s];i+=c==="n"?`
40
+ `:c==="t"?"\t":c;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[s+1]==="{")return null;i+=o}return i}var xt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Lt(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=bs(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=U(n),o;try{o=u(r,Object.keys(s))(...Object.values(s))}catch(g){return{ok:!1,message:`the expression could not be evaluated: ${g instanceof Error?g.message:String(g)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let c=[...new Set(tt(r))].filter((g)=>!xt.has(g)&&!(g in s)&&!(g in globalThis));if(c.length>0)return{ok:!1,message:`${c.map((d)=>`"${d}"`).join(", ")} ${c.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function Be(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function nt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Le(e){if(!e)return"";return Oe.isAbsolute(e)?Oe.relative(process.cwd(),e)||e:e}function oe(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function P(e,n,r,i,s=t.EVALUATION_ERROR){let o=i?` in ${Le(i)}`:"";return console.warn(`[stx] ${oe(n)}${o}: ${r}`),a(e,`${oe(n)}: ${r}`,s)}function xs(e,n,r){let i=r?` in ${Le(r)}`:"";console.warn(`[stx] ${oe(e)}${i}: ${n}`)}function Vo(){return{afterOpen:[],beforeClose:[]}}function wt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function ec(e,n){if(!wt(n))return e;let r=n.afterOpen.join(""),i=n.beforeClose.join(""),s=e.lastIndexOf("</head>"),o=r?dr(e):null,c=i&&s!==-1?s:null;if(o===null&&c===null)return e;if(o!==null&&c!==null)return`${e.slice(0,o)}${r}${e.slice(o,c)}${i}${e.slice(c)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,c)}${i}${e.slice(c)}`}var Ne=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function dr(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return null;let r=n.index+n[0].length;Ne.lastIndex=r;let i=Ne.exec(e);return i?r+i[0].length:r}var le="data-stx-color-mode-boot",Me="__STX_COLOR_MODE__",St=new Set(["light","dark","auto","system"]),kt=new Set(["auto","system"]),vt=/^[a-z][\w:-]*$/i,$t=/^[\w-]+$/;function Rt(e){let n=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,c=e.respectExisting===!0;if(typeof n!=="string"||n.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!St.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!$t.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!vt.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!kt.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(c&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:n,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:c}}function Ct(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ue(e={}){let n=Rt(e),r=Ct(n),i=`(function(){"use strict";var o=window.${Me};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${Me}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${le}>${i}</script>`}function pr(e,n={}){if(e.includes(le))return e;let r=ce(e);if(r===null)return e;let i=ue(n);return`${e.slice(0,r)}
41
+ ${i}${e.slice(r)}`}var ce=dr,At=new RegExp(`<script\\b[^>]*\\b${le}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Pe=/<meta\b[^>]*\bcharset\b[^>]*>/gi,De=/<\/head>/gi;function Tt(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return e;let r=n.index+n[0].length;De.lastIndex=r;let i=De.exec(e),s=i?i.index:e.length;Pe.lastIndex=r;let o=Pe.exec(e);if(!o||o.index>=s)return e;if(e.slice(r,o.index).trim()==="")return e;let c=o.index+o[0].length;return`${e.slice(0,r)}
42
42
  ${o[0]}${e.slice(r,o.index)}${e.slice(c,s)}${e.slice(s)}`}function tc(e){return _t(Tt(e))}function _t(e){let n=At.exec(e);if(!n)return e;let r=ce(e);if(r===null)return e;if(n.index<=r||e.slice(r,n.index).trim()==="")return e;let i=e.slice(0,n.index)+e.slice(n.index+n[0].length),s=ce(i);if(s===null)return e;return`${i.slice(0,s)}
43
- ${n[0]}${i.slice(s)}`}var He="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",V="data-stx-html-attrs",W="data-stx-html-class",Ue=/^[A-Za-z_:][\w:.-]*$/;function R(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function It(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function nt(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function Ot(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let i of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function _(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,i])=>`${r}="${R(String(i))}"`).join(" ")}function X(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function Ve(e){let n=_(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${X(e)}</script>`}function Pt(e={},n="en"){let r=[],i=[],s="",o=n;for(let[g,f]of Object.entries(e||{})){if(f==null)continue;let p=g.trim();if(!Ue.test(p))continue;let h=p.toLowerCase();if(h==="lang"){o=String(f);continue}if(h==="class"){s=String(f).trim();continue}r.push(` ${p}="${R(String(f))}"`),i.push(p)}let c=` lang="${R(o)}"`;if(s)c+=` class="${R(s)}"`;if(c+=r.join(""),s)c+=` ${W}="${R(s)}"`;if(i.length)c+=` ${V}="${R(i.join(" "))}"`;return c}function nc(e={},n={}){let r={...e,...n};if(e.class&&n.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of n.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function fr(e,n={}){if(!n||Object.keys(n).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let i={},s=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,c;while((c=o.exec(r[1]))!==null){let h=c[1];if(!(h in i))s.push(h);i[h]=c[2]??c[3]??c[4]??""}let g=[],f=[];for(let[h,m]of Object.entries(n)){if(m==null)continue;let y=h.trim();if(!Ue.test(y))continue;let x=y.toLowerCase();if(x==="class"){let k=(i.class||"").split(/\s+/).filter(Boolean);for(let S of String(m).split(/\s+/).filter(Boolean))if(!k.includes(S))k.push(S),g.push(S);if(!("class"in i))s.push("class");i.class=k.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(m),x!=="lang")f.push(y)}if(g.length){if(!(W in i))s.push(W);i[W]=g.join(" ")}if(f.length){if(!(V in i))s.push(V);i[V]=f.join(" ")}let p=s.map((h)=>` ${h}="${R(i[h])}"`).join("");return e.replace(r[0],()=>`<html${p}>`)}function rc(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${He}
44
- `}function Ft(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),c=o.match(/^\s+/);if(c){r+=c[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",r);if(m===-1)break;r=m+3;continue}let g=o.match(/^<script\b[^>]*>/i);if(g){let m=e.toLowerCase().indexOf("</script>",r+g[0].length);if(m===-1)break;r=m+9;continue}let f=o.match(/^<link\b[^>]*>/i);if(f){n.push(f[0]),r+=f[0].length;continue}let p=o.match(/^<meta\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){n.push(h[0]),r+=h[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),c=o.match(/^<link\b[^>]*>/i);if(c&&n.includes(c[0])){s+=c[0].length;continue}let g=o.match(/^<meta\b[^>]*>/i);if(g&&n.includes(g[0])){s+=g[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f&&n.includes(f[0])){s+=f[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:n}}function jt(e,n={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:c=[],script:g=[],headRaw:f="",htmlAttrs:p={},bodyClass:h="",bodyAttrs:m={}}=n,y=r.title||i,x=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],k=new Set(o.map(nt).filter(Boolean)),{body:S,hoisted:C}=Ft(e),T=new Set(C.flatMap((b)=>{let O=Ot(b);return O?[nt(O)].filter(Boolean):[]})),Ke=[...x.filter((b)=>!k.has(nt(b))),...o].filter((b)=>!T.has(nt(b))).map((b)=>` <meta ${_(b)}>`).join(`
43
+ ${n[0]}${i.slice(s)}`}var He="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",V="data-stx-html-attrs",W="data-stx-html-class",Ue=/^[A-Za-z_:][\w:.-]*$/;function R(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function It(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rt(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function Ot(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let i of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function _(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,i])=>`${r}="${R(String(i))}"`).join(" ")}function X(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function Ve(e){let n=_(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${X(e)}</script>`}function Pt(e={},n="en"){let r=[],i=[],s="",o=n;for(let[g,d]of Object.entries(e||{})){if(d==null)continue;let f=g.trim();if(!Ue.test(f))continue;let h=f.toLowerCase();if(h==="lang"){o=String(d);continue}if(h==="class"){s=String(d).trim();continue}r.push(` ${f}="${R(String(d))}"`),i.push(f)}let c=` lang="${R(o)}"`;if(s)c+=` class="${R(s)}"`;if(c+=r.join(""),s)c+=` ${W}="${R(s)}"`;if(i.length)c+=` ${V}="${R(i.join(" "))}"`;return c}function nc(e={},n={}){let r={...e,...n};if(e.class&&n.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of n.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function fr(e,n={}){if(!n||Object.keys(n).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let i={},s=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,c;while((c=o.exec(r[1]))!==null){let h=c[1];if(!(h in i))s.push(h);i[h]=c[2]??c[3]??c[4]??""}let g=[],d=[];for(let[h,m]of Object.entries(n)){if(m==null)continue;let y=h.trim();if(!Ue.test(y))continue;let x=y.toLowerCase();if(x==="class"){let k=(i.class||"").split(/\s+/).filter(Boolean);for(let S of String(m).split(/\s+/).filter(Boolean))if(!k.includes(S))k.push(S),g.push(S);if(!("class"in i))s.push("class");i.class=k.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(m),x!=="lang")d.push(y)}if(g.length){if(!(W in i))s.push(W);i[W]=g.join(" ")}if(d.length){if(!(V in i))s.push(V);i[V]=d.join(" ")}let f=s.map((h)=>` ${h}="${R(i[h])}"`).join("");return e.replace(r[0],()=>`<html${f}>`)}function rc(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${He}
44
+ `}function Ft(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),c=o.match(/^\s+/);if(c){r+=c[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",r);if(m===-1)break;r=m+3;continue}let g=o.match(/^<script\b[^>]*>/i);if(g){let m=e.toLowerCase().indexOf("</script>",r+g[0].length);if(m===-1)break;r=m+9;continue}let d=o.match(/^<link\b[^>]*>/i);if(d){n.push(d[0]),r+=d[0].length;continue}let f=o.match(/^<meta\b[^>]*>/i);if(f){n.push(f[0]),r+=f[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){n.push(h[0]),r+=h[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),c=o.match(/^<link\b[^>]*>/i);if(c&&n.includes(c[0])){s+=c[0].length;continue}let g=o.match(/^<meta\b[^>]*>/i);if(g&&n.includes(g[0])){s+=g[0].length;continue}let d=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(d&&n.includes(d[0])){s+=d[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:n}}function jt(e,n={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:c=[],script:g=[],headRaw:d="",htmlAttrs:f={},bodyClass:h="",bodyAttrs:m={}}=n,y=r.title||i,x=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],k=new Set(o.map(rt).filter(Boolean)),{body:S,hoisted:C}=Ft(e),T=new Set(C.flatMap((b)=>{let O=Ot(b);return O?[rt(O)].filter(Boolean):[]})),Ke=[...x.filter((b)=>!k.has(rt(b))),...o].filter((b)=>!T.has(rt(b))).map((b)=>` <meta ${_(b)}>`).join(`
45
45
  `),Ge=c.map((b)=>` <link ${_(b)}>`).join(`
46
46
  `),Ye=g.map((b)=>{if(b.src)return` <script ${_(b,(O)=>O==="content")}></script>`;if(b.content)return` ${Ve(b)}`;return""}).filter(Boolean).join(`
47
- `),Je=Pt(p,s),Ze=Object.entries(m).map(([b,O])=>` ${b}="${R(String(O))}"`).join(""),Qe=h?` class="${R(h)}"`:"",rt=[Ke,r.colorMode?` ${ue(r.colorMode)}`:"",` <title>${r.titleIsHtml?y:It(y)}</title>`,` ${He}`,Ge,Ye,f?` ${f}`:"",...(r.styles||[]).map((b)=>` ${b}`),...C.map((b)=>` ${b}`),...(r.headScripts||[]).map((b)=>` ${b}`),r.headStack||""].filter(Boolean),it=[S,...(r.bodyScripts||[]).map((b)=>b),r.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
47
+ `),Je=Pt(f,s),Ze=Object.entries(m).map(([b,O])=>` ${b}="${R(String(O))}"`).join(""),Qe=h?` class="${R(h)}"`:"",et=[Ke,r.colorMode?` ${ue(r.colorMode)}`:"",` <title>${r.titleIsHtml?y:It(y)}</title>`,` ${He}`,Ge,Ye,d?` ${d}`:"",...(r.styles||[]).map((b)=>` ${b}`),...C.map((b)=>` ${b}`),...(r.headScripts||[]).map((b)=>` ${b}`),r.headStack||""].filter(Boolean),it=[S,...(r.bodyScripts||[]).map((b)=>b),r.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
48
48
  <html${Je}>
49
49
  <head>
50
- ${rt.join(`
50
+ ${et.join(`
51
51
  `)}
52
52
  </head>
53
53
  <body${Qe}${Ze}>
54
54
  ${it.join(`
55
55
  `)}
56
56
  </body>
57
- </html>`}var ge=/\s+/y,pe=/<(script|style)\b[^>]*>/iy,zt=/<\/script>/gi,Bt=/<\/style>/gi,De=/<!DOCTYPE\b/iy,ze=/<html[\s>]/iy;function yn(e){let n=0;while(n<e.length){if(ge.lastIndex=n,ge.exec(e)){n=ge.lastIndex;continue}if(e.startsWith("<!--",n)){let s=e.indexOf("-->",n);if(s===-1)return!1;n=s+3;continue}pe.lastIndex=n;let i=pe.exec(e);if(i){let s=i[1].toLowerCase()==="script"?zt:Bt;s.lastIndex=pe.lastIndex;let o=s.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(De.lastIndex=n,De.test(e))return!0;return ze.lastIndex=n,ze.test(e)}return!1}function Uo(e){return yn(e)}function sc(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:c=""}=n,g=e.slice(0,r),f=[];for(let p of i){let h=nt(p);if(h&&g.includes(h))continue;f.push(` <meta ${_(p)}>`)}for(let p of s){if(p.href&&g.includes(`href="${p.href}"`))continue;f.push(` <link ${_(p)}>`)}for(let p of o)if(p.src){if(g.includes(`src="${p.src}"`))continue;f.push(` <script ${_(p,(h)=>h==="content")}></script>`)}else if(p.content){if(g.includes(X(p)))continue;f.push(` ${Ve(p)}`)}if(c&&!g.includes(c))f.push(` ${c}`);if(f.length===0)return e;return`${e.slice(0,r)}${f.join(`
57
+ </html>`}var ge=/\s+/y,pe=/<(script|style)\b[^>]*>/iy,zt=/<\/script>/gi,Bt=/<\/style>/gi,je=/<!DOCTYPE\b/iy,ze=/<html[\s>]/iy;function yn(e){let n=0;while(n<e.length){if(ge.lastIndex=n,ge.exec(e)){n=ge.lastIndex;continue}if(e.startsWith("<!--",n)){let s=e.indexOf("-->",n);if(s===-1)return!1;n=s+3;continue}pe.lastIndex=n;let i=pe.exec(e);if(i){let s=i[1].toLowerCase()==="script"?zt:Bt;s.lastIndex=pe.lastIndex;let o=s.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(je.lastIndex=n,je.test(e))return!0;return ze.lastIndex=n,ze.test(e)}return!1}function Uo(e){return yn(e)}function sc(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:c=""}=n,g=e.slice(0,r),d=[];for(let f of i){let h=rt(f);if(h&&g.includes(h))continue;d.push(` <meta ${_(f)}>`)}for(let f of s){if(f.href&&g.includes(`href="${f.href}"`))continue;d.push(` <link ${_(f)}>`)}for(let f of o)if(f.src){if(g.includes(`src="${f.src}"`))continue;d.push(` <script ${_(f,(h)=>h==="content")}></script>`)}else if(f.content){if(g.includes(X(f)))continue;d.push(` ${Ve(f)}`)}if(c&&!g.includes(c))d.push(` ${c}`);if(d.length===0)return e;return`${e.slice(0,r)}${d.join(`
58
58
  `)}
59
- ${e.slice(r)}`}function gr(e,n={},r={},i){if(i??Uo(e))return e;return jt(e,n,r)}var Ht=["og:","article:","book:","profile:","fb:","music:","video:"],Ut=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function mr(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=Vt(e[0],n);if(typeof r!=="string")return r;let i;if(e.length===2){let o=Wt(e[1],n);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,c=n.openGraph,g=n[o]??(tt(c)?c[o]:void 0);i=g===void 0||g===null||typeof g==="object"?"":String(g)}if(!i)return{kind:"empty"};return{kind:"tag",tag:Ht.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function Vt(e,n){let r=ae(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(Ut.test(e.trim()))return e.trim();let i=Lt(e,n);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${je(i.value)}`,code:t.TYPE_ERROR};return i.value}function Wt(e,n){let r=ae(e);if(r!==null)return r;let i=Lt(e,n);if(!i.ok)return{kind:"error",message:i.message,code:i.code};let s=i.value;if(s===void 0||s===null||s===!1)return"";if(Array.isArray(s))return s.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof s==="object"&&!(s instanceof Date))return{kind:"error",message:`the content must be text, got ${je(s)}`,code:t.TYPE_ERROR};return String(s)}var hr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],Ss=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],qe={links:"link",metas:"meta",scripts:"script",styles:"style"},We=new Set,Xe=new WeakMap;function fe(e){if(We.has(e))return;We.add(e),console.warn(e)}function Xt(e,n){let r=Array.from({length:n.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=r[0];r[0]=i;for(let o=1;o<=n.length;o++){let c=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===n[o-1]?0:1)),s=c}}return r[n.length]}function qt(e,n){let r=e.toLowerCase(),i=n.find((f)=>f.toLowerCase()===r);if(i)return i;let s=qe[r];if(s&&n.includes(s))return s;let o,c=1/0;for(let f of n){let p=Xt(r,f.toLowerCase());if(p<c)o=f,c=p}let g=Math.min(e.length,o?.length??0)<=4?1:2;return c<=g?o:void 0}function we(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=Xe.get(e);if(r)return r;let{known:i,source:s}=n,o=e;for(let c of Object.keys(e)){if(i.includes(c))continue;let g=qe[c];if(g&&i.includes(g)&&Array.isArray(e[c])){if(o===e)o={...e};let p=Array.isArray(o[g])?o[g]:[];o[g]=[...p,...e[c]],delete o[c],fe(`[stx] ${s}.${c} is not a head key; reading it as ${s}.${g}. Rename it to \`${g}\`.`);continue}if(/^styles?$/.test(c)&&!i.includes("style")){fe(`[stx] ${s}.${c} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let f=qt(c,i);fe(f?`[stx] ${s}.${c} is not a head key and is ignored. Did you mean \`${f}\`?`:`[stx] ${s}.${c} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return Xe.set(e,o),o}var A={},Kt=[],q={};function Wo(){return A}function Dp(){return q}function Mp(){A={},Kt.length=0,q={}}function oc(e){A=Be(A,we(e,{known:Ss,source:"useHead()"}))}function Be(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function cu(e){oc(ks(e))}function ks(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let f=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:f})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(i)n.push({property:"og:description",content:i});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let s=e.twitterTitle??e.title,o=e.twitterDescription??e.description,c=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(s)n.push({name:"twitter:title",content:s});if(o)n.push({name:"twitter:description",content:o});if(c){n.push({name:"twitter:image",content:c});let f=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(f)n.push({name:"twitter:image:alt",content:f})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let f of e.articleTags)n.push({property:"article:tag",content:f});let g=[];if(e.canonical)g.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:g}}function Lp(e){if(q={...q,...e},e.title||e.description)cu({title:e.title,description:e.description})}function jp(e){let n=typeof e==="function"?e():e;oc({title:n})}function Bp(e=A){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${I(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${I(s)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s==="httpEquiv"?"http-equiv":s}="${I(String(o))}"`).join(" ");n.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${I(String(o))}"`).join(" ");n.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i,...s}=r,o=Object.entries(s).filter(([c,g])=>g!==void 0).map(([c,g])=>{if(typeof g==="boolean")return g?c:"";return`${c}="${I(String(g))}"`}).filter(Boolean).join(" ");if(i)n.push(`<script ${o}>${X(r)}</script>`);else n.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";n.push(`<style${i}>${r.content}</style>`)}return n.join(`
59
+ ${e.slice(r)}`}function gr(e,n={},r={},i){if(i??Uo(e))return e;return jt(e,n,r)}var Ht=["og:","article:","book:","profile:","fb:","music:","video:"],Ut=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function mr(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=Vt(e[0],n);if(typeof r!=="string")return r;let i;if(e.length===2){let o=Wt(e[1],n);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,c=n.openGraph,g=n[o]??(nt(c)?c[o]:void 0);i=g===void 0||g===null||typeof g==="object"?"":String(g)}if(!i)return{kind:"empty"};return{kind:"tag",tag:Ht.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function Vt(e,n){let r=ae(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(Ut.test(e.trim()))return e.trim();let i=Lt(e,n);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${Be(i.value)}`,code:t.TYPE_ERROR};return i.value}function Wt(e,n){let r=ae(e);if(r!==null)return r;let i=Lt(e,n);if(!i.ok)return{kind:"error",message:i.message,code:i.code};let s=i.value;if(s===void 0||s===null||s===!1)return"";if(Array.isArray(s))return s.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof s==="object"&&!(s instanceof Date))return{kind:"error",message:`the content must be text, got ${Be(s)}`,code:t.TYPE_ERROR};return String(s)}var hr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],Ss=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],qe={links:"link",metas:"meta",scripts:"script",styles:"style"},We=new Set,Xe=new WeakMap;function fe(e){if(We.has(e))return;We.add(e),console.warn(e)}function Xt(e,n){let r=Array.from({length:n.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=r[0];r[0]=i;for(let o=1;o<=n.length;o++){let c=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===n[o-1]?0:1)),s=c}}return r[n.length]}function qt(e,n){let r=e.toLowerCase(),i=n.find((d)=>d.toLowerCase()===r);if(i)return i;let s=qe[r];if(s&&n.includes(s))return s;let o,c=1/0;for(let d of n){let f=Xt(r,d.toLowerCase());if(f<c)o=d,c=f}let g=Math.min(e.length,o?.length??0)<=4?1:2;return c<=g?o:void 0}function xe(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=Xe.get(e);if(r)return r;let{known:i,source:s}=n,o=e;for(let c of Object.keys(e)){if(i.includes(c))continue;let g=qe[c];if(g&&i.includes(g)&&Array.isArray(e[c])){if(o===e)o={...e};let f=Array.isArray(o[g])?o[g]:[];o[g]=[...f,...e[c]],delete o[c],fe(`[stx] ${s}.${c} is not a head key; reading it as ${s}.${g}. Rename it to \`${g}\`.`);continue}if(/^styles?$/.test(c)&&!i.includes("style")){fe(`[stx] ${s}.${c} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let d=qt(c,i);fe(d?`[stx] ${s}.${c} is not a head key and is ignored. Did you mean \`${d}\`?`:`[stx] ${s}.${c} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return Xe.set(e,o),o}var A={},Kt=[],q={};function Wo(){return A}function Dp(){return q}function Mp(){A={},Kt.length=0,q={}}function oc(e){A=Fe(A,xe(e,{known:Ss,source:"useHead()"}))}function Fe(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function cu(e){oc(ks(e))}function ks(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let d=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:d})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(i)n.push({property:"og:description",content:i});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let s=e.twitterTitle??e.title,o=e.twitterDescription??e.description,c=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(s)n.push({name:"twitter:title",content:s});if(o)n.push({name:"twitter:description",content:o});if(c){n.push({name:"twitter:image",content:c});let d=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(d)n.push({name:"twitter:image:alt",content:d})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let d of e.articleTags)n.push({property:"article:tag",content:d});let g=[];if(e.canonical)g.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:g}}function Lp(e){if(q={...q,...e},e.title||e.description)cu({title:e.title,description:e.description})}function jp(e){let n=typeof e==="function"?e():e;oc({title:n})}function Bp(e=A){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${I(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${I(s)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s==="httpEquiv"?"http-equiv":s}="${I(String(o))}"`).join(" ");n.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${I(String(o))}"`).join(" ");n.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i,...s}=r,o=Object.entries(s).filter(([c,g])=>g!==void 0).map(([c,g])=>{if(typeof g==="boolean")return g?c:"";return`${c}="${I(String(g))}"`}).filter(Boolean).join(" ");if(i)n.push(`<script ${o}>${X(r)}</script>`);else n.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";n.push(`<style${i}>${r.content}</style>`)}return n.join(`
60
60
  `)}function Fp(e=A){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function zp(e=A){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Hp(e=A){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),n.name)i.setAttribute("name",n.name);if(n.property)i.setAttribute("property",n.property);document.head.appendChild(i)}i.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[s,o]of Object.entries(n))if(o!==void 0)i.setAttribute(s,String(o))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function Vp(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(n+=s.trim()+`
61
- `,"")),headContent:n.trim()}}function Up(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let c=i?s:n[(o||"").trim()]??o,g=n.__stx_runtime_head??{};return n.__stx_runtime_head=Be(g,{title:c}),""})}function Wp(e,n,r=""){if(!e.includes("@meta"))return e;return Dt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=mr(Mt(i),n);if(o.kind==="error")return P("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let c=n.__stx_runtime_head??{};n.__stx_runtime_head=Be(c,{meta:[o.tag]})}return""},(i)=>P("Meta",i,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{bs,Fo,vs,l,d,Qa,E,et,Nt,u,ws,t,re,ur,z,a,ve,zo,D,hn,w,Ho,Dt,Mt,Lt,je,tt,P,xs,Vo,ec,dr,pr,tc,nt,nc,fr,rc,yn,Uo,sc,gr,mr,hr,Ss,we,Wo,Dp,Mp,oc,Be,cu,ks,Lp,jp,Bp,Fp,zp,Hp,Vp,Up,Wp};
61
+ `,"")),headContent:n.trim()}}function Up(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let c=i?s:n[(o||"").trim()]??o,g=n.__stx_runtime_head??{};return n.__stx_runtime_head=Fe(g,{title:c}),""})}function Wp(e,n,r=""){if(!e.includes("@meta"))return e;return Dt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=mr(Mt(i),n);if(o.kind==="error")return P("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let c=n.__stx_runtime_head??{};n.__stx_runtime_head=Fe(c,{meta:[o.tag]})}return""},(i)=>P("Meta",i,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{bs,Fo,vs,l,p,Qa,E,tt,Nt,u,ws,t,re,ur,z,a,we,zo,D,hn,w,Ho,Dt,Mt,Lt,Be,nt,P,xs,Vo,ec,dr,pr,tc,rt,nc,fr,rc,yn,Uo,sc,gr,mr,hr,Ss,xe,Wo,Dp,Mp,oc,Fe,cu,ks,Lp,jp,Bp,Fp,zp,Hp,Vp,Up,Wp};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function Ye(){if(i)return i;let t="unknown";try{t=String(JSON.parse(n.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let o=a.dirname(s(import.meta.url)),e=0;for(let r of n.readdirSync(o,{recursive:!0,withFileTypes:!0}))if(r.isFile()&&r.name.endsWith(".ts"))e=Math.max(e,n.statSync(a.join(r.parentPath,r.name)).mtimeMs);t+=`+src.${Math.trunc(e)}`}catch{}return i=t,t}
3
- export{Ye};
2
+ import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function Ze(){if(i)return i;let t="unknown";try{t=String(JSON.parse(n.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let o=a.dirname(s(import.meta.url)),e=0;for(let r of n.readdirSync(o,{recursive:!0,withFileTypes:!0}))if(r.isFile()&&r.name.endsWith(".ts"))e=Math.max(e,n.statSync(a.join(r.parentPath,r.name)).mtimeMs);t+=`+src.${Math.trunc(e)}`}catch{}return i=t,t}
3
+ export{Ze};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function Fe(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function wn(e){if(e.entries.length===0)return"[]";return`[
2
+ import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function ze(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function wn(e){if(e.entries.length===0)return"[]";return`[
3
3
  ${e.entries.map((t)=>` { url: '${t.url}', revision: '${t.revision}' }`).join(`,
4
4
  `)}
5
5
  ]`}function Jo(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(2)} MB`}
6
- export{Fe,wn,Jo};
6
+ export{ze,wn,Jo};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function vo(e,t){let a=e.filter((i)=>!b(i.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let i of a){let c=[];for(let l of i.params){let d=i.pattern.includes(`:${l}?`)?"?":"";c.push(`${l}${d}: string`)}let s=c.join("; ");r.push(` '${i.pattern}': { ${s} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
3
  `),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function wo(e,t,a){let r=process.cwd(),n=w.relative(r,a),o=e.filter((c)=>!b(c.pattern)),i=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let c of o){let s=w.relative(r,c.filePath).replace(/\\/g,"/"),l=JSON.stringify(c.params),d=c.layout?`, layout: '${w.relative(r,c.layout).replace(/\\/g,"/")}'`:"";i.push(` { pattern: '${c.pattern}', filePath: '${s}', isDynamic: ${c.isDynamic}, params: ${l}${d} },`)}i.push("] as const",""),i.push("export type RouteName = typeof routes[number]['pattern']",""),p.mkdirSync(t,{recursive:!0}),p.writeFileSync(w.join(t,"routes.ts"),i.join(`
4
- `))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),G=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function bt(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&G.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function ie(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function Zn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function Zr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return ie(a,t)}import j from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(j.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Qn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=ie(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");vo(this.routes,s),wo(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function Qr(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function es(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Pl(e){k=e.replace(/\/$/,"")}function Il(e,t,a={}){f[e]={path:t,name:e,params:a}}function Ol(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function er(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Nl(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Dl(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Ml(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Ll(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function xa(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Sa(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function ka(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function xo(e,t){v.set(e,t)}function _a(e){return v.get(e)}function jl(e){return v.has(e)}function vt(){v.clear()}function wt(){return Array.from(v.keys())}async function xt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")xo(o,s);else if(typeof s==="function")xo(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function K(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function St(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function kt(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?xa(a,i):Sa(),storage:ka(),state:{},request:a,responseHeaders:i}}async function _t(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=_a(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function ts(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function Xe(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||ts(n)}}var A,T;function W(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
4
+ `))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),G=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function vt(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&G.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function ie(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function Zn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function Zr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return ie(a,t)}import j from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(j.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Qn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=ie(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");vo(this.routes,s),wo(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function Qr(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function es(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Pl(e){k=e.replace(/\/$/,"")}function Il(e,t,a={}){f[e]={path:t,name:e,params:a}}function Ol(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function er(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Nl(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Dl(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Ml(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Ll(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function xa(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Sa(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function ka(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function xo(e,t){v.set(e,t)}function _a(e){return v.get(e)}function jl(e){return v.has(e)}function wt(){v.clear()}function xt(){return Array.from(v.keys())}async function St(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")xo(o,s);else if(typeof s==="function")xo(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function K(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function kt(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function _t(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?xa(a,i):Sa(),storage:ka(),state:{},request:a,responseHeaders:i}}async function Ct(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=_a(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function ts(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function Je(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||ts(n)}}var A,T;function W(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
5
5
  ;(function(){
6
6
  'use strict';
7
7
  var ROUTER_REV=7;
@@ -3939,4 +3939,4 @@ else {
3939
3939
 
3940
3940
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
3941
3941
  })();
3942
- `}function Je(){if(A)return A;return A=q(W(X()),!0),A}function Bl(){if(T)return T;return T=q(X()),T}export{vo,wo,bt,ie,Zn,Zr,Qn,Qr,es,Pl,Il,Ol,er,Nl,Dl,Ml,Ll,xa,Sa,ka,xo,_a,jl,vt,wt,xt,St,kt,_t,ts,Xe,Je,Bl};
3942
+ `}function Ye(){if(A)return A;return A=q(W(X()),!0),A}function Bl(){if(T)return T;return T=q(X()),T}export{vo,wo,vt,ie,Zn,Zr,Qn,Qr,es,Pl,Il,Ol,er,Nl,Dl,Ml,Ll,xa,Sa,ka,xo,_a,jl,wt,xt,St,kt,_t,Ct,ts,Je,Ye,Bl};