@stacksjs/stx 0.2.713 → 0.2.714

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 (215) hide show
  1. package/dist/chunk-00bf81ep.js +2 -0
  2. package/dist/chunk-04bhg3nn.js +2 -0
  3. package/dist/{chunk-vstvadc2.js → chunk-05qf3e2p.js} +3 -3
  4. package/dist/{chunk-f8fekg2d.js → chunk-0babpwqd.js} +22 -22
  5. package/dist/chunk-0g9a1kks.js +2 -0
  6. package/dist/{chunk-rt7q8dfs.js → chunk-0k1nwbch.js} +9 -9
  7. package/dist/{chunk-x45dv67k.js → chunk-142z94rk.js} +4 -4
  8. package/dist/chunk-19vshytp.js +2 -0
  9. package/dist/{chunk-13z9b912.js → chunk-1kpfkjy7.js} +18 -18
  10. package/dist/{chunk-mzfbpcy0.js → chunk-1ncmrzk1.js} +2 -2
  11. package/dist/chunk-2fmn23mb.js +2 -0
  12. package/dist/{chunk-3ps07041.js → chunk-2mqzpzy7.js} +4 -4
  13. package/dist/{chunk-wbfg7p3k.js → chunk-2t00wxz0.js} +1 -1
  14. package/dist/chunk-336t7zzz.js +2 -0
  15. package/dist/{chunk-w246aa0j.js → chunk-35br675g.js} +4 -4
  16. package/dist/chunk-362sjw8c.js +2 -0
  17. package/dist/{chunk-dxqvv686.js → chunk-39nkd53v.js} +2 -2
  18. package/dist/{chunk-yw66yks2.js → chunk-3e40sm05.js} +4 -4
  19. package/dist/{chunk-zjw6j2x0.js → chunk-3fwdxxh1.js} +4 -4
  20. package/dist/chunk-3j8x8mhx.js +2 -0
  21. package/dist/chunk-3nbvr34s.js +2 -0
  22. package/dist/chunk-3r0zha0y.js +2 -0
  23. package/dist/{chunk-zav8yrtp.js → chunk-3xyvc3g1.js} +5 -5
  24. package/dist/{chunk-stvw8y3c.js → chunk-4c86wr9a.js} +2 -2
  25. package/dist/chunk-4ee5msma.js +2 -0
  26. package/dist/chunk-54a60nh2.js +2 -0
  27. package/dist/chunk-5d1c504j.js +2 -0
  28. package/dist/chunk-5wpgbwap.js +2 -0
  29. package/dist/{chunk-s3ms09rt.js → chunk-5zg56hwd.js} +5 -5
  30. package/dist/{chunk-qa9t9k6z.js → chunk-62awa752.js} +1 -1
  31. package/dist/{chunk-mr3r8crk.js → chunk-630yrhzv.js} +2 -2
  32. package/dist/{chunk-kxf8z7vp.js → chunk-6fx89gvg.js} +2 -2
  33. package/dist/chunk-6h1qa3hw.js +2 -0
  34. package/dist/chunk-6jn0p1a9.js +2 -0
  35. package/dist/chunk-6vj7vx7z.js +2 -0
  36. package/dist/{chunk-ckrmrdjp.js → chunk-72hfqwvk.js} +5 -5
  37. package/dist/{chunk-qd6s902s.js → chunk-7407ac26.js} +5 -5
  38. package/dist/{chunk-cwhzk2n3.js → chunk-74fepz6h.js} +2 -2
  39. package/dist/{chunk-y083wv0f.js → chunk-77rjnavp.js} +13 -13
  40. package/dist/{chunk-42w6snem.js → chunk-78x8qfvt.js} +4 -4
  41. package/dist/chunk-79sjdpfy.js +2 -0
  42. package/dist/{chunk-aa6fa3x4.js → chunk-7nmrycrz.js} +4 -4
  43. package/dist/{chunk-t413xatv.js → chunk-87zvjhp9.js} +10 -10
  44. package/dist/{chunk-zecgd1wz.js → chunk-88rftjjk.js} +4 -4
  45. package/dist/chunk-8dfq934n.js +2 -0
  46. package/dist/{chunk-t6ayy0t5.js → chunk-8fazd6fr.js} +2 -2
  47. package/dist/chunk-8w1ep4w3.js +2 -0
  48. package/dist/chunk-918xy0ra.js +2 -0
  49. package/dist/{chunk-tvcr9sct.js → chunk-9chqvq23.js} +3 -3
  50. package/dist/chunk-a0r5011d.js +2 -0
  51. package/dist/chunk-a49at1ah.js +2 -0
  52. package/dist/{chunk-ak09a5v6.js → chunk-a9kxcdkz.js} +2 -2
  53. package/dist/chunk-agjysd2b.js +2 -0
  54. package/dist/chunk-ajcb0z8k.js +2 -0
  55. package/dist/chunk-ak04tgvw.js +2 -0
  56. package/dist/chunk-anew18ct.js +2 -0
  57. package/dist/chunk-azatpcm0.js +2 -0
  58. package/dist/chunk-c1481efw.js +2 -0
  59. package/dist/chunk-c510b95e.js +2 -0
  60. package/dist/chunk-c8yrvpr7.js +2 -0
  61. package/dist/chunk-cbbjepfk.js +2 -0
  62. package/dist/{chunk-max3smha.js → chunk-cgpf1fva.js} +2 -2
  63. package/dist/{chunk-6cz1sbb1.js → chunk-d9hw6n2d.js} +3 -3
  64. package/dist/{chunk-zjaw79zp.js → chunk-dhy6n39n.js} +2 -2
  65. package/dist/{chunk-edka95zp.js → chunk-dmnncw90.js} +3 -3
  66. package/dist/chunk-dn8x6c98.js +2 -0
  67. package/dist/{chunk-b7j48bq9.js → chunk-dnqzrktd.js} +2 -2
  68. package/dist/chunk-dph9dzzs.js +2 -0
  69. package/dist/{chunk-af7av42v.js → chunk-dxzs589r.js} +3 -3
  70. package/dist/{chunk-e6ky15dr.js → chunk-ez35607j.js} +2 -2
  71. package/dist/{chunk-768evhvm.js → chunk-f2c3t1ky.js} +2 -2
  72. package/dist/{chunk-x2gxx8eg.js → chunk-f4gqzg1y.js} +2 -2
  73. package/dist/chunk-f9smbpkp.js +2 -0
  74. package/dist/chunk-fb8sw7fc.js +2 -0
  75. package/dist/{chunk-029qng4p.js → chunk-fsz9k5k0.js} +5 -5
  76. package/dist/chunk-g8fg3kq8.js +2 -0
  77. package/dist/{chunk-vapj4s7f.js → chunk-g8ve8pag.js} +6 -6
  78. package/dist/{chunk-0tay8xjs.js → chunk-gjfgmhpw.js} +1 -1
  79. package/dist/chunk-gw4pycg0.js +2 -0
  80. package/dist/{chunk-an387127.js → chunk-h16qbyjd.js} +2 -2
  81. package/dist/chunk-h5srt1gz.js +2 -0
  82. package/dist/{chunk-t63f15yh.js → chunk-hez09ssh.js} +2 -2
  83. package/dist/{chunk-2aarvd3a.js → chunk-hnqpqtk2.js} +6 -6
  84. package/dist/chunk-hrb9fmq0.js +2 -0
  85. package/dist/{chunk-gecdjyb5.js → chunk-hx2s1j09.js} +8 -8
  86. package/dist/{chunk-xjge15am.js → chunk-j0sj81bg.js} +6 -6
  87. package/dist/{chunk-fcbd7kwj.js → chunk-j28r2d0q.js} +2 -2
  88. package/dist/chunk-jb5najk3.js +1101 -0
  89. package/dist/chunk-jc7823qy.js +2 -0
  90. package/dist/chunk-jresy8fn.js +2 -0
  91. package/dist/{chunk-bjejmqk4.js → chunk-jtgb1s62.js} +2 -2
  92. package/dist/{chunk-tnmz1t1p.js → chunk-k3j8kd19.js} +5 -5
  93. package/dist/{chunk-mj8c8949.js → chunk-k93mp66m.js} +4 -4
  94. package/dist/{chunk-cc2ss77r.js → chunk-m1n9re2p.js} +6 -6
  95. package/dist/{chunk-8v2vbc4y.js → chunk-m5nzpjej.js} +1 -1
  96. package/dist/chunk-m6d2bq3y.js +2 -0
  97. package/dist/chunk-m8r7v1js.js +2 -0
  98. package/dist/{chunk-c1fjdp7s.js → chunk-mpphyb4g.js} +1 -1
  99. package/dist/{chunk-s9b6abkb.js → chunk-mwxbdpb1.js} +2 -2
  100. package/dist/chunk-mymb85q5.js +3 -0
  101. package/dist/{chunk-83p5k4eb.js → chunk-narz7105.js} +2 -2
  102. package/dist/chunk-ngahc72q.js +2 -0
  103. package/dist/{chunk-khrckvwn.js → chunk-nqfpvejh.js} +1 -1
  104. package/dist/chunk-nvtp22qp.js +2 -0
  105. package/dist/{chunk-46bd866e.js → chunk-ny5j5jhm.js} +3 -3
  106. package/dist/{chunk-4ckxs446.js → chunk-pd89jnqk.js} +3 -3
  107. package/dist/{chunk-067sgh2j.js → chunk-q73xkgn0.js} +76 -76
  108. package/dist/{chunk-3t3p2c1t.js → chunk-q7fh1xka.js} +6 -6
  109. package/dist/{chunk-5n4qg8za.js → chunk-qc93ce5h.js} +2 -2
  110. package/dist/{chunk-3457kk19.js → chunk-qf2aa8qe.js} +6 -6
  111. package/dist/{chunk-jb5sftzz.js → chunk-r3hden6p.js} +2 -2
  112. package/dist/{chunk-7dc3n69c.js → chunk-r3j4m04w.js} +2 -2
  113. package/dist/chunk-r5re2zj0.js +2 -0
  114. package/dist/{chunk-wp6q0geg.js → chunk-rbmt5w9v.js} +2 -2
  115. package/dist/chunk-rgv7rjrs.js +2 -0
  116. package/dist/{chunk-67abad76.js → chunk-rj4j7qcj.js} +1 -1
  117. package/dist/chunk-s9hw4vcx.js +2 -0
  118. package/dist/{chunk-g1tq4xdb.js → chunk-serrx31a.js} +2 -2
  119. package/dist/{chunk-42rw3f1h.js → chunk-sfkexejc.js} +2 -2
  120. package/dist/{chunk-cpyc6t0d.js → chunk-snxzvyz3.js} +1 -1
  121. package/dist/chunk-sx1aer4p.js +2 -0
  122. package/dist/{chunk-p3dkhz9v.js → chunk-tdrcn1mn.js} +30 -30
  123. package/dist/chunk-tdvmf3ge.js +2 -0
  124. package/dist/{chunk-h54w4fg6.js → chunk-tz4wh90e.js} +5 -5
  125. package/dist/chunk-tzhm09xq.js +2 -0
  126. package/dist/{chunk-0sg7zzmr.js → chunk-tzk4cmvm.js} +5 -5
  127. package/dist/{chunk-9dg5ja4w.js → chunk-v402swbm.js} +1 -1
  128. package/dist/chunk-vf9s563f.js +2 -0
  129. package/dist/chunk-vpmk1w2t.js +2 -0
  130. package/dist/chunk-wj5j2ekg.js +2 -0
  131. package/dist/{chunk-b6318vv3.js → chunk-wk50m71x.js} +1 -1
  132. package/dist/{chunk-vh879axx.js → chunk-wv412s1h.js} +7 -7
  133. package/dist/{chunk-rb2a1qxb.js → chunk-x5dc06p5.js} +6 -6
  134. package/dist/chunk-x7z2s532.js +2 -0
  135. package/dist/{chunk-ap30qs8p.js → chunk-x9wwd2ee.js} +2 -2
  136. package/dist/{chunk-ncs2j5kc.js → chunk-xaddgvkx.js} +2 -2
  137. package/dist/{chunk-6n11z33h.js → chunk-y3w2rc1y.js} +5 -5
  138. package/dist/{chunk-hcve898s.js → chunk-ye3yyq6n.js} +4 -4
  139. package/dist/{chunk-5ctdwyq1.js → chunk-yen9xzzg.js} +6 -6
  140. package/dist/chunk-yg1wcsbj.js +2 -0
  141. package/dist/{chunk-vcpynqvy.js → chunk-z4dpz6dh.js} +3 -3
  142. package/dist/{chunk-39073rh9.js → chunk-z5pm69w1.js} +39 -39
  143. package/dist/{chunk-xyyt8v1r.js → chunk-zkx2m308.js} +12 -12
  144. package/dist/cli.js +19 -19
  145. package/dist/craft-bridge.d.ts +0 -18
  146. package/dist/craft-bridge.js +12 -7
  147. package/dist/craft-components.d.ts +0 -20
  148. package/dist/craft-components.js +5 -13
  149. package/dist/craft-entry.js +2 -2
  150. package/dist/craft.js +2 -2
  151. package/dist/document-injection.d.ts +2 -0
  152. package/dist/document-injection.js +8 -0
  153. package/dist/native-build.js +2 -1
  154. package/dist/pwa.js +3 -3
  155. package/dist/ssg.js +15 -15
  156. package/package.json +5 -5
  157. package/dist/chunk-07sc6jtz.js +0 -2
  158. package/dist/chunk-0kjac48x.js +0 -2
  159. package/dist/chunk-0wtqxs6s.js +0 -2
  160. package/dist/chunk-12vjp2gr.js +0 -2
  161. package/dist/chunk-18fr730w.js +0 -2
  162. package/dist/chunk-1hzf9rcy.js +0 -2
  163. package/dist/chunk-29sapda2.js +0 -2
  164. package/dist/chunk-2qf6kd9r.js +0 -2
  165. package/dist/chunk-2snfd93r.js +0 -2
  166. package/dist/chunk-4c1fbthr.js +0 -2
  167. package/dist/chunk-4fxg20je.js +0 -2
  168. package/dist/chunk-58v34kba.js +0 -2
  169. package/dist/chunk-5fjc7402.js +0 -2
  170. package/dist/chunk-5wrgzs4c.js +0 -2
  171. package/dist/chunk-5x6y26y1.js +0 -2
  172. package/dist/chunk-6q2647s6.js +0 -2
  173. package/dist/chunk-77msvbad.js +0 -3033
  174. package/dist/chunk-8s4rxgs8.js +0 -2
  175. package/dist/chunk-9736003n.js +0 -2
  176. package/dist/chunk-97r557ws.js +0 -2
  177. package/dist/chunk-bcr8sq50.js +0 -2
  178. package/dist/chunk-ccv7dw6h.js +0 -2
  179. package/dist/chunk-cx1xn3j3.js +0 -2
  180. package/dist/chunk-d9ryb159.js +0 -2
  181. package/dist/chunk-dhdt7e54.js +0 -2
  182. package/dist/chunk-et83qyc2.js +0 -2
  183. package/dist/chunk-faa56mhz.js +0 -2
  184. package/dist/chunk-fphxtr18.js +0 -2
  185. package/dist/chunk-fvk1xr5a.js +0 -2
  186. package/dist/chunk-g6wd49b5.js +0 -2
  187. package/dist/chunk-gk0nq2ky.js +0 -2
  188. package/dist/chunk-h8kbcz9t.js +0 -2
  189. package/dist/chunk-hava1caf.js +0 -3
  190. package/dist/chunk-hsthpqed.js +0 -2
  191. package/dist/chunk-jyz9frny.js +0 -2
  192. package/dist/chunk-kyymkayr.js +0 -2
  193. package/dist/chunk-mzwa2478.js +0 -2
  194. package/dist/chunk-n3z0cek6.js +0 -2
  195. package/dist/chunk-nbew0ttz.js +0 -2
  196. package/dist/chunk-nefv911a.js +0 -2
  197. package/dist/chunk-p41knx6v.js +0 -2
  198. package/dist/chunk-qcx9yp5x.js +0 -2
  199. package/dist/chunk-r6bc2q44.js +0 -2
  200. package/dist/chunk-rdj74dqc.js +0 -2
  201. package/dist/chunk-rtbkjq0y.js +0 -2
  202. package/dist/chunk-rwjgpmrw.js +0 -2
  203. package/dist/chunk-s4ks8rjm.js +0 -2
  204. package/dist/chunk-s9vfypaf.js +0 -2
  205. package/dist/chunk-sy1btryy.js +0 -2
  206. package/dist/chunk-t7mbaf69.js +0 -2
  207. package/dist/chunk-w2h6nn70.js +0 -2
  208. package/dist/chunk-wrv0tf80.js +0 -2
  209. package/dist/chunk-x5h95nnq.js +0 -2
  210. package/dist/chunk-xferp2q8.js +0 -2
  211. package/dist/chunk-xge355wc.js +0 -2
  212. package/dist/chunk-xn1hv092.js +0 -2
  213. package/dist/chunk-yd199exa.js +0 -2
  214. package/dist/chunk-ykmcnk3x.js +0 -2
  215. package/dist/chunk-z05dbey1.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{q}from"./chunk-ncs2j5kc.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 it from"path";var ot={showRelativePaths:!1,enableAutoRecovery:q(),logRecoveryWarnings:!0},Y={...ot};function M(){return{...Y}}function P(e){if(!Y.showRelativePaths||!e)return e;let n=Y.baseDir||process.cwd();try{let r=it.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,a){super(e);this.code=n;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=a||t.EVALUATION_ERROR,this.filePath)this.filePath=P(this.filePath)}}class ae 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 xr 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 W 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:a,template:l,offset:p,snippet:g,suggestion:h,format:m="text"}=e,y=o,x=a;if(!y&&l&&p!==void 0){let K=pt(l,p);y=K.line,x=K.column}let S=s?P(s):void 0,w=i?G(i):void 0,C={type:n,code:i,codeName:w,message:r,filePath:S,line:y,column:x,snippet:g,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,l,p);break;case"text":default:T=at(C,l,p);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{K}from"./chunk-xaddgvkx.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 it from"path";var ot={showRelativePaths:!1,enableAutoRecovery:K(),logRecoveryWarnings:!0},Y={...ot};function M(){return{...Y}}function P(e){if(!Y.showRelativePaths||!e)return e;let n=Y.baseDir||process.cwd();try{let r=it.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,a){super(e);this.code=n;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=a||t.EVALUATION_ERROR,this.filePath)this.filePath=P(this.filePath)}}class ae 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 xr 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 q 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:a,template:l,offset:p,snippet:g,suggestion:h,format:m="text"}=e,y=o,x=a;if(!y&&l&&p!==void 0){let X=pt(l,p);y=X.line,x=X.column}let S=s?P(s):void 0,w=i?G(i):void 0,C={type:n,code:i,codeName:w,message:r,filePath:S,line:y,column:x,snippet:g,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,l,p);break;case"text":default:T=at(C,l,p);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(`
@@ -17,15 +17,15 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
17
17
  `)}function gt(e,n,r){let i=e.split(`
18
18
  `),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),a="\x1B[90m",l="\x1B[31m",p="\x1B[0m",g=[];for(let h=s;h<=o;h++){let m=(h+1).toString().padStart(4),y=h===n-1,x=y?"\x1B[31m>\x1B[0m":" ",S=y?`\x1B[31m${i[h]}\x1B[0m`:`\x1B[90m${i[h]}\x1B[0m`;g.push(`${x}\x1B[90m${m}\x1B[0m | ${S}`)}return g.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 c(e,n,r){return me({type:e,message:n,code:r,format:"html"}).formatted}async function Se(e,n,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return n}}var li={isEnabled(){return M().enableAutoRecovery},fixCommonSyntaxErrors(e){let n=M();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 l=s-o;r+="}}".repeat(l),i.push(`Added ${l} missing closing braces '}}'`)}let a=["if","foreach","for","switch","section"];for(let l of a){let p=(r.match(new RegExp(`@${l}\\b`,"g"))||[]).length,g=(r.match(new RegExp(`@end${l}\\b`,"g"))||[]).length;if(p>g){let h=p-g;for(let m=0;m<h;m++)r+=`
21
- @end${l}`;i.push(`Added ${h} missing @end${l}`)}}if(i.length>0&&n.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((l)=>console.warn(` - ${l}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,n){if(q())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(`
20
+ `);return{line:i.length,column:i[i.length-1].length}}function c(e,n,r){return me({type:e,message:n,code:r,format:"html"}).formatted}async function Se(e,n,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return n}}var ui={isEnabled(){return M().enableAutoRecovery},fixCommonSyntaxErrors(e){let n=M();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 l=s-o;r+="}}".repeat(l),i.push(`Added ${l} missing closing braces '}}'`)}let a=["if","foreach","for","switch","section"];for(let l of a){let p=(r.match(new RegExp(`@${l}\\b`,"g"))||[]).length,g=(r.match(new RegExp(`@end${l}\\b`,"g"))||[]).length;if(p>g){let h=p-g;for(let m=0;m<h;m++)r+=`
21
+ @end${l}`;i.push(`Added ${h} missing @end${l}`)}}if(i.length>0&&n.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((l)=>console.warn(` - ${l}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,n){if(K())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(`
24
24
  `)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let n=await import("fs"),r=await import("path"),i=r.dirname(this.logFilePath);if(!n.existsSync(i))n.mkdirSync(i,{recursive:!0});await this.rotateIfNeeded(n);let s=`${this.formatEntry(e)}
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((a)=>({timestamp:a.timestamp.toISOString(),level:a.level||"error",type:a.error.constructor.name,message:a.error.message,stack:a.error.stack,context:a.context}));r.writeFileSync(e,JSON.stringify(o,null,2),"utf-8")}else{let o=this.errors.map((a)=>this.formatEntry(a));r.writeFileSync(e,o.join(`
26
26
 
27
- `),"utf-8")}}async flush(){await this.writeQueue}}var j=new J,wn={isDevelopment(){return q()},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 b(e,n,r,i=0){let s=0,o=i,a=null,l=0,p=!1;while(o<e.length){let g=e[o];if(a&&p){p=!1,o++;continue}if(a&&g==="\\"){p=!0,o++;continue}if(p=!1,(g==='"'||g==="'"||g==="`")&&!a){a=g,o++;continue}if(g===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&g==="$"&&e[o+1]==="{"){l++,o+=2;continue}if(l>0&&g==="}"){l--,o++;continue}if(g==="`"&&a==="`"&&l===0){a=null,o++;continue}if(a){o++;continue}if(g===n)s++;else if(g===r){if(s--,s===0)return o}o++}return-1}function Bc(e,n){let r=n,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(n,r),endPos:r}}var ft={maxSanitizeDepth:10,allowBracketNotation:!1},we={...ft};var D=/\bnew\s+/,z="__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*\(/,D,/\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",z]),re=new Set(["__proto__","constructor","prototype"]);function $e(e){let n="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let l=1;o+=2;while(o<e.length&&l>0){if(e[o]==="{")l++;else if(e[o]==="}")l--;if(l>0)n+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}n+=a,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 a=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,a)))continue;let l=dt.exec(n.slice(a)),p=l?.[3],g=!l?null:p?`Intl_${p}`:l[2];if(!l||!g||!(g in Ae))throw new k(`matched /${D.source}/; ${Ee}`,e);let h=a+l[0].length,m=r[a],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(a,h))throw new k(`matched /${D.source}/; ${Ee}`,e);let x=m+3+l[1].length;i.push({start:x,end:x+l[2].length,key:g})}let o=e;for(let a=i.length-1;a>=0;a--){let l=i[a];o=`${o.slice(0,l.start)}${z}.${l.key}${o.slice(l.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class k 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 Ns(e){try{return ie(e),null}catch(n){return n instanceof k?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 k(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&re.has(s))throw new k(`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("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let l=s[1].trim(),p=/^'(?:[^'\\]|\\.)*'$/.test(l),g=/^"(?:[^"\\]|\\.)*"$/.test(l);if(/^\d+$/.test(l))continue;if(p||g){let m=l.slice(1,-1);if(re.has(m))throw new k(`bracket key ${m}`,e);if(!we.allowBracketNotation)throw new k("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(l)){i.add(l);continue}throw new k("dynamic bracket notation is not allowed",e)}return[...i]}function ie(e){let n=e.trim(),r=Re(n);Te(r,n);let i=_e(n);for(let s of te){if(s===D)continue;if(s.test(r))throw new k(`matched /${s.source}/`,n)}return{...mt(n),dynamicKeys:i}}function ci(e){return ie(e),e.trim()}var Ds=Symbol("stx.sanitizeCache");function B(e){let n={},r=e[Ds];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>=we.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 u(e,n){try{let r=B(n),i=Object.keys(r),s=Object.values(r);return d(e,i)(...s)}catch{return}}function f(e){try{return ci(e),!0}catch{return!1}}function jc(e,n){try{let r=B(n),i=Object.keys(r),s=Object.values(r),o=!1,l=d(e,i,()=>{o=!0})(...s);return!o&&Boolean(l)}catch{return!1}}function R(e,n){try{let r=u(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 nt(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 Mt(e){return yt.test(e)&&!Ie.has(e)}function d(e,n,r){let{source:i,usesSafeConstructors:s,dynamicKeys:o}=ie(e),a=[];for(let m=0;m<n.length;m++){if(!Mt(n[m]))continue;if(n[m]===z||n[m]==="Object"||ne.has(n[m]))continue;a.push({key:n[m],index:m})}a.sort((m,y)=>m.key.localeCompare(y.key));let l=a.map((m)=>m.key),p=a.map((m)=>m.index),g=`
27
+ `),"utf-8")}}async flush(){await this.writeQueue}}var B=new J,wn={isDevelopment(){return K()},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 b(e,n,r,i=0){let s=0,o=i,a=null,l=0,p=!1;while(o<e.length){let g=e[o];if(a&&p){p=!1,o++;continue}if(a&&g==="\\"){p=!0,o++;continue}if(p=!1,(g==='"'||g==="'"||g==="`")&&!a){a=g,o++;continue}if(g===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&g==="$"&&e[o+1]==="{"){l++,o+=2;continue}if(l>0&&g==="}"){l--,o++;continue}if(g==="`"&&a==="`"&&l===0){a=null,o++;continue}if(a){o++;continue}if(g===n)s++;else if(g===r){if(s--,s===0)return o}o++}return-1}function Fc(e,n){let r=n,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(n,r),endPos:r}}var ft={maxSanitizeDepth:10,allowBracketNotation:!1},we={...ft};var D=/\bnew\s+/,j="__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*\(/,D,/\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",j]),re=new Set(["__proto__","constructor","prototype"]);function $e(e){let n="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let l=1;o+=2;while(o<e.length&&l>0){if(e[o]==="{")l++;else if(e[o]==="}")l--;if(l>0)n+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}n+=a,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 a=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,a)))continue;let l=dt.exec(n.slice(a)),p=l?.[3],g=!l?null:p?`Intl_${p}`:l[2];if(!l||!g||!(g in Ae))throw new k(`matched /${D.source}/; ${Ee}`,e);let h=a+l[0].length,m=r[a],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(a,h))throw new k(`matched /${D.source}/; ${Ee}`,e);let x=m+3+l[1].length;i.push({start:x,end:x+l[2].length,key:g})}let o=e;for(let a=i.length-1;a>=0;a--){let l=i[a];o=`${o.slice(0,l.start)}${j}.${l.key}${o.slice(l.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class k 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 Ds(e){try{return ie(e),null}catch(n){return n instanceof k?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 k(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&re.has(s))throw new k(`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("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let l=s[1].trim(),p=/^'(?:[^'\\]|\\.)*'$/.test(l),g=/^"(?:[^"\\]|\\.)*"$/.test(l);if(/^\d+$/.test(l))continue;if(p||g){let m=l.slice(1,-1);if(re.has(m))throw new k(`bracket key ${m}`,e);if(!we.allowBracketNotation)throw new k("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(l)){i.add(l);continue}throw new k("dynamic bracket notation is not allowed",e)}return[...i]}function ie(e){let n=e.trim(),r=Re(n);Te(r,n);let i=_e(n);for(let s of te){if(s===D)continue;if(s.test(r))throw new k(`matched /${s.source}/`,n)}return{...mt(n),dynamicKeys:i}}function li(e){return ie(e),e.trim()}var Ms=Symbol("stx.sanitizeCache");function z(e){let n={},r=e[Ms];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>=we.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 u(e,n){try{let r=z(n),i=Object.keys(r),s=Object.values(r);return d(e,i)(...s)}catch{return}}function f(e){try{return li(e),!0}catch{return!1}}function Bc(e,n){try{let r=z(n),i=Object.keys(r),s=Object.values(r),o=!1,l=d(e,i,()=>{o=!0})(...s);return!o&&Boolean(l)}catch{return!1}}function R(e,n){try{let r=u(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 nt(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 Mt(e){return yt.test(e)&&!Ie.has(e)}function d(e,n,r){let{source:i,usesSafeConstructors:s,dynamicKeys:o}=ie(e),a=[];for(let m=0;m<n.length;m++){if(!Mt(n[m]))continue;if(n[m]===j||n[m]==="Object"||ne.has(n[m]))continue;a.push({key:n[m],index:m})}a.sort((m,y)=>m.key.localeCompare(y.key));let l=a.map((m)=>m.key),p=a.map((m)=>m.index),g=`
29
29
  'use strict';
30
30
  try {
31
31
  return ${i};
@@ -36,11 +36,11 @@ catch (e) {
36
36
  }
37
37
  throw e;
38
38
  }
39
- `;return Et(bt(s?(m)=>{let y=be([z,"Object",...Z,...l,...m],g);return(...x)=>y(Ae,Q,...he,...x)}:(m)=>{let y=be(["Object",...Z,...l,...m],g);return(...x)=>y(Q,...he,...x)},l,n,a,p,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 a=s[o];if(typeof a==="string"&&re.has(a))return}return e(...s)}}function bt(e,n,r,i,s,o){let a=e([]),l=i.every((g,h)=>g.index===h);if(n.length===r.length&&l)return xe(a,n,e,void 0,o);return xe((...g)=>{let h=Array(s.length);for(let m=0;m<s.length;m++)h[m]=g[s[m]];return a(...h)},n,e,(g)=>{a=e(g)},o)}function xe(e,n,r,i,s){let a=/^(\w+) is not defined$/,l=e,p=[],g=new Set(n);return(...h)=>{for(let m=0;m<=8;m++)try{return l(...h)}catch(y){let x=y instanceof Error?y.message:"",S=a.exec(x);if(!(y instanceof ReferenceError)||!S)return;let w=S[1];if(g.has(w)||Ie.has(w)||ne.has(w))return;if(s?.(w),g.add(w),p.push(w),i)i(p);else l=r(p)}return}}function Ms(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 ui(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,a=b(e,"(",")",o);if(a===-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:a+1,args:e.slice(o+1,a),call:e.slice(s,a+1)}),n.lastIndex=a+1}return r}function Lt(e,n,r,i){let s="",o=0;for(let a of ui(e,n)){if(s+=e.slice(o,a.start),a.end===-1){s+=i(a.call),o=a.start;continue}s+=r(a.args,a.call),o=a.end}return s+e.slice(o)}function jt(e){let n=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let a=e[o];if(i){if(s+=a,a==="\\"&&o+1<e.length){s+=e[++o];continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`")i=a;else if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===","&&r===0){n.push(s.trim()),s="";continue}s+=a}if(s.trim())n.push(s.trim());return n}function oe(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 a=n[++s];i+=a==="n"?`
40
- `:a==="t"?"\t":a;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 Bt(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=Ns(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=B(n),o;try{o=d(r,Object.keys(s))(...Object.values(s))}catch(l){return{ok:!1,message:`the expression could not be evaluated: ${l instanceof Error?l.message:String(l)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(nt(r))].filter((l)=>!xt.has(l)&&!(l in s)&&!(l in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((p)=>`"${p}"`).join(", ")} ${a.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 ze(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 rt(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 se(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function N(e,n,r,i,s=t.EVALUATION_ERROR){let o=i?` in ${Le(i)}`:"";return console.warn(`[stx] ${se(n)}${o}: ${r}`),c(e,`${se(n)}: ${r}`,s)}function Ls(e,n,r){let i=r?` in ${Le(r)}`:"";console.warn(`[stx] ${se(e)}${i}: ${n}`)}function di(){return{afterOpen:[],beforeClose:[]}}function wt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Fc(e,n){if(!wt(n))return e;let r=n.afterOpen.join(""),i=n.beforeClose.join(""),s=e.lastIndexOf("</head>"),o=r?Sr(e):null,a=i&&s!==-1?s:null;if(o===null&&a===null)return e;if(o!==null&&a!==null)return`${e.slice(0,o)}${r}${e.slice(o,a)}${i}${e.slice(a)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,a)}${i}${e.slice(a)}`}var Ne=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function Sr(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,a=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(a&&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:a}}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 kr(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)}
39
+ `;return Et(bt(s?(m)=>{let y=be([j,"Object",...Z,...l,...m],g);return(...x)=>y(Ae,Q,...he,...x)}:(m)=>{let y=be(["Object",...Z,...l,...m],g);return(...x)=>y(Q,...he,...x)},l,n,a,p,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 a=s[o];if(typeof a==="string"&&re.has(a))return}return e(...s)}}function bt(e,n,r,i,s,o){let a=e([]),l=i.every((g,h)=>g.index===h);if(n.length===r.length&&l)return xe(a,n,e,void 0,o);return xe((...g)=>{let h=Array(s.length);for(let m=0;m<s.length;m++)h[m]=g[s[m]];return a(...h)},n,e,(g)=>{a=e(g)},o)}function xe(e,n,r,i,s){let a=/^(\w+) is not defined$/,l=e,p=[],g=new Set(n);return(...h)=>{for(let m=0;m<=8;m++)try{return l(...h)}catch(y){let x=y instanceof Error?y.message:"",S=a.exec(x);if(!(y instanceof ReferenceError)||!S)return;let w=S[1];if(g.has(w)||Ie.has(w)||ne.has(w))return;if(s?.(w),g.add(w),p.push(w),i)i(p);else l=r(p)}return}}function Ls(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 di(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,a=b(e,"(",")",o);if(a===-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:a+1,args:e.slice(o+1,a),call:e.slice(s,a+1)}),n.lastIndex=a+1}return r}function Lt(e,n,r,i){let s="",o=0;for(let a of di(e,n)){if(s+=e.slice(o,a.start),a.end===-1){s+=i(a.call),o=a.start;continue}s+=r(a.args,a.call),o=a.end}return s+e.slice(o)}function jt(e){let n=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let a=e[o];if(i){if(s+=a,a==="\\"&&o+1<e.length){s+=e[++o];continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`")i=a;else if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===","&&r===0){n.push(s.trim()),s="";continue}s+=a}if(s.trim())n.push(s.trim());return n}function oe(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 a=n[++s];i+=a==="n"?`
40
+ `:a==="t"?"\t":a;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 Bt(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=Ds(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=z(n),o;try{o=d(r,Object.keys(s))(...Object.values(s))}catch(l){return{ok:!1,message:`the expression could not be evaluated: ${l instanceof Error?l.message:String(l)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(nt(r))].filter((l)=>!xt.has(l)&&!(l in s)&&!(l in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((p)=>`"${p}"`).join(", ")} ${a.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 ze(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 rt(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 se(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function N(e,n,r,i,s=t.EVALUATION_ERROR){let o=i?` in ${Le(i)}`:"";return console.warn(`[stx] ${se(n)}${o}: ${r}`),c(e,`${se(n)}: ${r}`,s)}function js(e,n,r){let i=r?` in ${Le(r)}`:"";console.warn(`[stx] ${se(e)}${i}: ${n}`)}function pi(){return{afterOpen:[],beforeClose:[]}}function wt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function zc(e,n){if(!wt(n))return e;let r=n.afterOpen.join(""),i=n.beforeClose.join(""),s=e.lastIndexOf("</head>"),o=r?Sr(e):null,a=i&&s!==-1?s:null;if(o===null&&a===null)return e;if(o!==null&&a!==null)return`${e.slice(0,o)}${r}${e.slice(o,a)}${i}${e.slice(a)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,a)}${i}${e.slice(a)}`}var Ne=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function Sr(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,a=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(a&&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:a}}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 kr(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
41
  ${i}${e.slice(r)}`}var ce=Sr,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 a=o.index+o[0].length;return`${e.slice(0,r)}
42
- ${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function zc(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 Be="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",H="data-stx-html-attrs",U="data-stx-html-class",Ue=/^[A-Za-z_:][\w:.-]*$/;function v(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 st(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}="${v(String(i))}"`).join(" ")}function V(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}`:""}>${V(e)}</script>`}function Nt(e={},n="en"){let r=[],i=[],s="",o=n;for(let[l,p]of Object.entries(e||{})){if(p==null)continue;let g=l.trim();if(!Ue.test(g))continue;let h=g.toLowerCase();if(h==="lang"){o=String(p);continue}if(h==="class"){s=String(p).trim();continue}r.push(` ${g}="${v(String(p))}"`),i.push(g)}let a=` lang="${v(o)}"`;if(s)a+=` class="${v(s)}"`;if(a+=r.join(""),s)a+=` ${U}="${v(s)}"`;if(i.length)a+=` ${H}="${v(i.join(" "))}"`;return a}function Hc(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 _r(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,a;while((a=o.exec(r[1]))!==null){let h=a[1];if(!(h in i))s.push(h);i[h]=a[2]??a[3]??a[4]??""}let l=[],p=[];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 S=(i.class||"").split(/\s+/).filter(Boolean);for(let w of String(m).split(/\s+/).filter(Boolean))if(!S.includes(w))S.push(w),l.push(w);if(!("class"in i))s.push("class");i.class=S.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(m),x!=="lang")p.push(y)}if(l.length){if(!(U in i))s.push(U);i[U]=l.join(" ")}if(p.length){if(!(H in i))s.push(H);i[H]=p.join(" ")}let g=s.map((h)=>` ${h}="${v(i[h])}"`).join("");return e.replace(r[0],()=>`<html${g}>`)}function Vc(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${Be}
42
+ ${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function Hc(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 Be="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",H="data-stx-html-attrs",U="data-stx-html-class",Ue=/^[A-Za-z_:][\w:.-]*$/;function v(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 st(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}="${v(String(i))}"`).join(" ")}function V(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}`:""}>${V(e)}</script>`}function Nt(e={},n="en"){let r=[],i=[],s="",o=n;for(let[l,p]of Object.entries(e||{})){if(p==null)continue;let g=l.trim();if(!Ue.test(g))continue;let h=g.toLowerCase();if(h==="lang"){o=String(p);continue}if(h==="class"){s=String(p).trim();continue}r.push(` ${g}="${v(String(p))}"`),i.push(g)}let a=` lang="${v(o)}"`;if(s)a+=` class="${v(s)}"`;if(a+=r.join(""),s)a+=` ${U}="${v(s)}"`;if(i.length)a+=` ${H}="${v(i.join(" "))}"`;return a}function Vc(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 _r(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,a;while((a=o.exec(r[1]))!==null){let h=a[1];if(!(h in i))s.push(h);i[h]=a[2]??a[3]??a[4]??""}let l=[],p=[];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 S=(i.class||"").split(/\s+/).filter(Boolean);for(let w of String(m).split(/\s+/).filter(Boolean))if(!S.includes(w))S.push(w),l.push(w);if(!("class"in i))s.push("class");i.class=S.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(m),x!=="lang")p.push(y)}if(l.length){if(!(U in i))s.push(U);i[U]=l.join(" ")}if(p.length){if(!(H in i))s.push(H);i[H]=p.join(" ")}let g=s.map((h)=>` ${h}="${v(i[h])}"`).join("");return e.replace(r[0],()=>`<html${g}>`)}function Uc(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${Be}
44
44
  `}function Pt(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),a=o.match(/^\s+/);if(a){r+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",r);if(m===-1)break;r=m+3;continue}let l=o.match(/^<script\b[^>]*>/i);if(l){let m=e.toLowerCase().indexOf("</script>",r+l[0].length);if(m===-1)break;r=m+9;continue}let p=o.match(/^<link\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let g=o.match(/^<meta\b[^>]*>/i);if(g){n.push(g[0]),r+=g[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),a=o.match(/^<link\b[^>]*>/i);if(a&&n.includes(a[0])){s+=a[0].length;continue}let l=o.match(/^<meta\b[^>]*>/i);if(l&&n.includes(l[0])){s+=l[0].length;continue}let p=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(p&&n.includes(p[0])){s+=p[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:n}}function Ft(e,n={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:l=[],headRaw:p="",htmlAttrs:g={},bodyClass:h="",bodyAttrs:m={}}=n,y=r.title||i,x=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],S=new Set(o.map(st).filter(Boolean)),{body:w,hoisted:C}=Pt(e),T=new Set(C.flatMap((E)=>{let O=Ot(E);return O?[st(O)].filter(Boolean):[]})),Ke=[...x.filter((E)=>!S.has(st(E))),...o].filter((E)=>!T.has(st(E))).map((E)=>` <meta ${_(E)}>`).join(`
45
45
  `),Ge=a.map((E)=>` <link ${_(E)}>`).join(`
46
46
  `),Ye=l.map((E)=>{if(E.src)return` <script ${_(E,(O)=>O==="content")}></script>`;if(E.content)return` ${Ve(E)}`;return""}).filter(Boolean).join(`
@@ -54,8 +54,8 @@ ${et.join(`
54
54
  ${tt.join(`
55
55
  `)}
56
56
  </body>
57
- </html>`}var ge=/\s+/y,pe=/<(script|style)\b[^>]*>/iy,Dt=/<\/script>/gi,zt=/<\/style>/gi,De=/<!DOCTYPE\b/iy,je=/<html[\s>]/iy;function xn(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"?Dt:zt;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 je.lastIndex=n,je.test(e)}return!1}function pi(e){return xn(e)}function Uc(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:a=""}=n,l=e.slice(0,r),p=[];for(let g of i){let h=st(g);if(h&&l.includes(h))continue;p.push(` <meta ${_(g)}>`)}for(let g of s){if(g.href&&l.includes(`href="${g.href}"`))continue;p.push(` <link ${_(g)}>`)}for(let g of o)if(g.src){if(l.includes(`src="${g.src}"`))continue;p.push(` <script ${_(g,(h)=>h==="content")}></script>`)}else if(g.content){if(l.includes(V(g)))continue;p.push(` ${Ve(g)}`)}if(a&&!l.includes(a))p.push(` ${a}`);if(p.length===0)return e;return`${e.slice(0,r)}${p.join(`
57
+ </html>`}var ge=/\s+/y,pe=/<(script|style)\b[^>]*>/iy,Dt=/<\/script>/gi,zt=/<\/style>/gi,De=/<!DOCTYPE\b/iy,je=/<html[\s>]/iy;function xn(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"?Dt:zt;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 je.lastIndex=n,je.test(e)}return!1}function fi(e){return xn(e)}function Wc(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:a=""}=n,l=e.slice(0,r),p=[];for(let g of i){let h=st(g);if(h&&l.includes(h))continue;p.push(` <meta ${_(g)}>`)}for(let g of s){if(g.href&&l.includes(`href="${g.href}"`))continue;p.push(` <link ${_(g)}>`)}for(let g of o)if(g.src){if(l.includes(`src="${g.src}"`))continue;p.push(` <script ${_(g,(h)=>h==="content")}></script>`)}else if(g.content){if(l.includes(V(g)))continue;p.push(` ${Ve(g)}`)}if(a&&!l.includes(a))p.push(` ${a}`);if(p.length===0)return e;return`${e.slice(0,r)}${p.join(`
58
58
  `)}
59
- ${e.slice(r)}`}function Cr(e,n={},r={},i){if(i??pi(e))return e;return Ft(e,n,r)}var Ht=["og:","article:","book:","profile:","fb:","music:","video:"],Ut=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Er(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,a=n.openGraph,l=n[o]??(rt(a)?a[o]:void 0);i=l===void 0||l===null||typeof l==="object"?"":String(l)}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=oe(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=Bt(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 ${ze(i.value)}`,code:t.TYPE_ERROR};return i.value}function Wt(e,n){let r=oe(e);if(r!==null)return r;let i=Bt(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 ${ze(s)}`,code:t.TYPE_ERROR};return String(s)}var Tr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],js=["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 a=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===n[o-1]?0:1)),s=a}}return r[n.length]}function qt(e,n){let r=e.toLowerCase(),i=n.find((p)=>p.toLowerCase()===r);if(i)return i;let s=qe[r];if(s&&n.includes(s))return s;let o,a=1/0;for(let p of n){let g=Xt(r,p.toLowerCase());if(g<a)o=p,a=g}let l=Math.min(e.length,o?.length??0)<=4?1:2;return a<=l?o:void 0}function ke(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 a of Object.keys(e)){if(i.includes(a))continue;let l=qe[a];if(l&&i.includes(l)&&Array.isArray(e[a])){if(o===e)o={...e};let g=Array.isArray(o[l])?o[l]:[];o[l]=[...g,...e[a]],delete o[a],fe(`[stx] ${s}.${a} is not a head key; reading it as ${s}.${l}. Rename it to \`${l}\`.`);continue}if(/^styles?$/.test(a)&&!i.includes("style")){fe(`[stx] ${s}.${a} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=qt(a,i);fe(p?`[stx] ${s}.${a} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${s}.${a} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return Xe.set(e,o),o}var A={},Kt=[],X={};function fi(){return A}function Eh(){return X}function Th(){A={},Kt.length=0,X={}}function Wc(e){A=He(A,ke(e,{known:js,source:"useHead()"}))}function He(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 Qf(e){Wc(Bs(e))}function Bs(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}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,a=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(a){n.push({name:"twitter:image",content:a});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}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 p of e.articleTags)n.push({property:"article:tag",content:p});let l=[];if(e.canonical)l.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:l}}function $h(e){if(X={...X,...e},e.title||e.description)Qf({title:e.title,description:e.description})}function Rh(e){let n=typeof e==="function"?e():e;Wc({title:n})}function Ah(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(([a,l])=>l!==void 0).map(([a,l])=>{if(typeof l==="boolean")return l?a:"";return`${a}="${I(String(l))}"`}).filter(Boolean).join(" ");if(i)n.push(`<script ${o}>${V(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 Cr(e,n={},r={},i){if(i??fi(e))return e;return Ft(e,n,r)}var Ht=["og:","article:","book:","profile:","fb:","music:","video:"],Ut=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Er(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,a=n.openGraph,l=n[o]??(rt(a)?a[o]:void 0);i=l===void 0||l===null||typeof l==="object"?"":String(l)}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=oe(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=Bt(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 ${ze(i.value)}`,code:t.TYPE_ERROR};return i.value}function Wt(e,n){let r=oe(e);if(r!==null)return r;let i=Bt(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 ${ze(s)}`,code:t.TYPE_ERROR};return String(s)}var Tr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],Bs=["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 a=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===n[o-1]?0:1)),s=a}}return r[n.length]}function qt(e,n){let r=e.toLowerCase(),i=n.find((p)=>p.toLowerCase()===r);if(i)return i;let s=qe[r];if(s&&n.includes(s))return s;let o,a=1/0;for(let p of n){let g=Xt(r,p.toLowerCase());if(g<a)o=p,a=g}let l=Math.min(e.length,o?.length??0)<=4?1:2;return a<=l?o:void 0}function ke(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 a of Object.keys(e)){if(i.includes(a))continue;let l=qe[a];if(l&&i.includes(l)&&Array.isArray(e[a])){if(o===e)o={...e};let g=Array.isArray(o[l])?o[l]:[];o[l]=[...g,...e[a]],delete o[a],fe(`[stx] ${s}.${a} is not a head key; reading it as ${s}.${l}. Rename it to \`${l}\`.`);continue}if(/^styles?$/.test(a)&&!i.includes("style")){fe(`[stx] ${s}.${a} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=qt(a,i);fe(p?`[stx] ${s}.${a} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${s}.${a} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return Xe.set(e,o),o}var A={},Kt=[],W={};function gi(){return A}function Eh(){return W}function Th(){A={},Kt.length=0,W={}}function qc(e){A=He(A,ke(e,{known:Bs,source:"useHead()"}))}function He(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 tg(e){qc(Fs(e))}function Fs(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}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,a=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(a){n.push({name:"twitter:image",content:a});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}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 p of e.articleTags)n.push({property:"article:tag",content:p});let l=[];if(e.canonical)l.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:l}}function $h(e){if(W={...W,...e},e.title||e.description)tg({title:e.title,description:e.description})}function Rh(e){let n=typeof e==="function"?e():e;qc({title:n})}function Ah(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(([a,l])=>l!==void 0).map(([a,l])=>{if(typeof l==="boolean")return l?a:"";return`${a}="${I(String(l))}"`}).filter(Boolean).join(" ");if(i)n.push(`<script ${o}>${V(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 Ph(e=A){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function Ih(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 Oh(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 Nh(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(n+=s.trim()+`
61
- `,"")),headContent:n.trim()}}function Dh(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let a=i?s:n[(o||"").trim()]??o,l=n.__stx_runtime_head??{};return n.__stx_runtime_head=He(l,{title:a}),""})}function Mh(e,n,r=""){if(!e.includes("@meta"))return e;return Lt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=Er(jt(i),n);if(o.kind==="error")return N("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let a=n.__stx_runtime_head??{};n.__stx_runtime_head=He(a,{meta:[o.tag]})}return""},(i)=>N("Meta",i,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{Ns,ci,Ds,u,f,jc,R,nt,Mt,d,Ms,t,ae,xr,W,c,Se,li,j,wn,b,Bc,ui,Lt,jt,Bt,ze,rt,N,Ls,di,Fc,Sr,kr,zc,st,Hc,_r,Vc,xn,pi,Uc,Cr,Er,Tr,js,ke,fi,Eh,Th,Wc,He,Qf,Bs,$h,Rh,Ah,Ph,Ih,Oh,Nh,Dh,Mh};
61
+ `,"")),headContent:n.trim()}}function Dh(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let a=i?s:n[(o||"").trim()]??o,l=n.__stx_runtime_head??{};return n.__stx_runtime_head=He(l,{title:a}),""})}function Mh(e,n,r=""){if(!e.includes("@meta"))return e;return Lt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=Er(jt(i),n);if(o.kind==="error")return N("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let a=n.__stx_runtime_head??{};n.__stx_runtime_head=He(a,{meta:[o.tag]})}return""},(i)=>N("Meta",i,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{Ds,li,Ms,u,f,Bc,R,nt,Mt,d,Ls,t,ae,xr,q,c,Se,ui,B,wn,b,Fc,di,Lt,jt,Bt,ze,rt,N,js,pi,zc,Sr,kr,Hc,st,Vc,_r,Uc,xn,fi,Wc,Cr,Er,Tr,Bs,ke,gi,Eh,Th,qc,He,tg,Fs,$h,Rh,Ah,Ph,Ih,Oh,Nh,Dh,Mh};