@stacksjs/stx 0.2.917 → 0.2.921

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 (294) hide show
  1. package/dist/app-shell.js +3 -2
  2. package/dist/chunk-0678sab4.js +2 -0
  3. package/dist/chunk-0bnv0aaz.js +2 -0
  4. package/dist/chunk-0bvfm5h5.js +2 -0
  5. package/dist/chunk-0c3q5h03.js +2 -0
  6. package/dist/chunk-0fh84wr5.js +2 -0
  7. package/dist/chunk-0p9x0m5n.js +2 -0
  8. package/dist/{chunk-ngqb22wj.js → chunk-0rq1w0xr.js} +9 -9
  9. package/dist/{chunk-t65f98qv.js → chunk-1pc2p489.js} +2 -2
  10. package/dist/{chunk-1hx6dyy9.js → chunk-1ts1pg90.js} +2 -2
  11. package/dist/{chunk-h0aw9hmc.js → chunk-29cy41z3.js} +5 -5
  12. package/dist/{chunk-952dfmcb.js → chunk-2d0pemtc.js} +3 -3
  13. package/dist/{chunk-0vyytd9v.js → chunk-2qnpr0ty.js} +3 -3
  14. package/dist/chunk-2r2tayyd.js +3 -0
  15. package/dist/chunk-2sfxj244.js +2 -0
  16. package/dist/{chunk-nwef47nx.js → chunk-30d298vs.js} +1 -1
  17. package/dist/chunk-36j2drjv.js +42 -0
  18. package/dist/{chunk-pyyda92j.js → chunk-3d0bjcn7.js} +1 -1
  19. package/dist/chunk-3k9d0h11.js +2 -0
  20. package/dist/chunk-3mc9ew9r.js +25 -0
  21. package/dist/chunk-43r0h76m.js +2 -0
  22. package/dist/{chunk-95j8660f.js → chunk-4f8h38xr.js} +2 -2
  23. package/dist/{chunk-16sfjkc4.js → chunk-4jg8ddfy.js} +2 -2
  24. package/dist/chunk-4jh5t3rz.js +2 -0
  25. package/dist/{chunk-v78hjbz0.js → chunk-4nabpd82.js} +5 -5
  26. package/dist/{chunk-z110bf2c.js → chunk-4w203ddt.js} +9 -9
  27. package/dist/chunk-4y2k14ec.js +2 -0
  28. package/dist/chunk-57xcb1wn.js +2 -0
  29. package/dist/chunk-5ekbye3p.js +2 -0
  30. package/dist/chunk-5s1q4y2j.js +2 -0
  31. package/dist/chunk-6359fekc.js +2 -0
  32. package/dist/{chunk-sdmq09jw.js → chunk-66cz2ph7.js} +2 -2
  33. package/dist/chunk-6bm7t0hm.js +3 -0
  34. package/dist/{chunk-xc5esqcb.js → chunk-6ybq9pfh.js} +2 -2
  35. package/dist/{chunk-nhyv3w4r.js → chunk-7767n5k6.js} +1 -1
  36. package/dist/{chunk-0sj79ha5.js → chunk-78j6c3sf.js} +5 -5
  37. package/dist/{chunk-ftvpz1j4.js → chunk-7d0h2pa3.js} +5 -5
  38. package/dist/{chunk-1hbf5e1h.js → chunk-7g720sk3.js} +2 -2
  39. package/dist/chunk-7nshr15z.js +2 -0
  40. package/dist/{chunk-w98yt4d4.js → chunk-875wejw1.js} +2 -2
  41. package/dist/chunk-8g6cmgn8.js +2 -0
  42. package/dist/chunk-8gfdy17b.js +2 -0
  43. package/dist/{chunk-mgj074y2.js → chunk-8vjsmyrk.js} +5 -5
  44. package/dist/chunk-8yx65vb0.js +2 -0
  45. package/dist/{chunk-frpsrv1e.js → chunk-90ps064x.js} +2 -2
  46. package/dist/chunk-91nwc581.js +2 -0
  47. package/dist/{chunk-mt5ewkbg.js → chunk-94001bha.js} +6 -6
  48. package/dist/chunk-94skx5m6.js +2 -0
  49. package/dist/chunk-9aegppj7.js +2 -0
  50. package/dist/{chunk-11c7xg1z.js → chunk-9ch2qhbw.js} +1 -1
  51. package/dist/{chunk-da05660m.js → chunk-9sk596tw.js} +58 -58
  52. package/dist/{chunk-fn1reean.js → chunk-a3qb13vr.js} +20 -20
  53. package/dist/chunk-a5vzdhsk.js +2 -0
  54. package/dist/{chunk-0jdz31q1.js → chunk-a78k8fkg.js} +3 -3
  55. package/dist/{chunk-jr2r2nh5.js → chunk-ag07tdhn.js} +4 -4
  56. package/dist/chunk-amnfd29h.js +7 -0
  57. package/dist/chunk-aqh48tyw.js +2 -0
  58. package/dist/{chunk-fs43342z.js → chunk-avtq2p0c.js} +2 -2
  59. package/dist/{chunk-phzhmnnm.js → chunk-ayrd026n.js} +3 -3
  60. package/dist/{chunk-eptzpvn0.js → chunk-b0kq5mzq.js} +3 -3
  61. package/dist/chunk-b6am4h24.js +2 -0
  62. package/dist/{chunk-dwt2drzf.js → chunk-b9z4nb1v.js} +8 -8
  63. package/dist/{chunk-qsexsrw2.js → chunk-bwnx71s8.js} +5 -5
  64. package/dist/{chunk-2vx2ben8.js → chunk-c3nmjx26.js} +2 -2
  65. package/dist/chunk-cajg2sz0.js +2 -0
  66. package/dist/{chunk-2f5jjxcj.js → chunk-dhx4m7mf.js} +2 -2
  67. package/dist/chunk-dktqmf4t.js +2 -0
  68. package/dist/chunk-dqwxyk1m.js +2 -0
  69. package/dist/chunk-e2kk1d9z.js +2 -0
  70. package/dist/{chunk-ra2tzsvz.js → chunk-e8aqkt1b.js} +6 -6
  71. package/dist/{chunk-1jxkc6d0.js → chunk-e8hvbc53.js} +2 -2
  72. package/dist/{chunk-p3fepzt9.js → chunk-edjzm0vj.js} +3 -3
  73. package/dist/chunk-ee4ejnk2.js +2 -0
  74. package/dist/chunk-eezp4a40.js +2 -0
  75. package/dist/chunk-eh2ynja3.js +2 -0
  76. package/dist/chunk-emk29htn.js +2 -0
  77. package/dist/{chunk-va4xam1q.js → chunk-eqj8nj5c.js} +1 -1
  78. package/dist/{chunk-xnp031ba.js → chunk-f8sh6289.js} +7 -7
  79. package/dist/{chunk-wj9bqkc0.js → chunk-fb1hyhgf.js} +3 -3
  80. package/dist/chunk-fd0vnz09.js +2 -0
  81. package/dist/chunk-fyhtp2nt.js +2 -0
  82. package/dist/{chunk-ywrpmyzj.js → chunk-g2fxp9zp.js} +3 -3
  83. package/dist/chunk-gbct53j0.js +2 -0
  84. package/dist/{chunk-1jvt9t3r.js → chunk-gsm3rk4j.js} +2 -2
  85. package/dist/{chunk-gfp39bzr.js → chunk-gt9bt8xa.js} +2 -2
  86. package/dist/{chunk-ar6jeqmm.js → chunk-gxdy4qjj.js} +4 -4
  87. package/dist/chunk-gxtq25gr.js +2 -0
  88. package/dist/chunk-h1dnjn9g.js +2 -0
  89. package/dist/chunk-h4nqjks2.js +2 -0
  90. package/dist/{chunk-f0sxbgbm.js → chunk-h7z23fpq.js} +2 -2
  91. package/dist/{chunk-cq4cwfqf.js → chunk-hakevnm1.js} +2 -2
  92. package/dist/chunk-hn7fv830.js +2 -0
  93. package/dist/chunk-hx6tr46s.js +1459 -0
  94. package/dist/chunk-jenk04c8.js +2 -0
  95. package/dist/{chunk-ezqfrea9.js → chunk-jfy0r3hx.js} +28 -28
  96. package/dist/{chunk-3jc6yb02.js → chunk-jh007a8k.js} +9 -9
  97. package/dist/chunk-jh1hdq31.js +3 -0
  98. package/dist/{chunk-fzcqw147.js → chunk-jk1hzawb.js} +3 -3
  99. package/dist/{chunk-wm24jx3t.js → chunk-jya12bfn.js} +2 -2
  100. package/dist/chunk-k1qbgpfy.js +2 -0
  101. package/dist/chunk-kgmwja6f.js +2 -0
  102. package/dist/{chunk-91p8p2cc.js → chunk-khf62zkn.js} +6 -6
  103. package/dist/chunk-kppj8rqa.js +2 -0
  104. package/dist/{chunk-vayzmvf5.js → chunk-m3ra99h8.js} +6 -6
  105. package/dist/{chunk-fznjm7qt.js → chunk-m8rzaqm8.js} +2 -2
  106. package/dist/chunk-msvphygp.js +2 -0
  107. package/dist/chunk-mzbejejf.js +2 -0
  108. package/dist/{chunk-8b8az19t.js → chunk-nkgqhb7s.js} +8 -8
  109. package/dist/{chunk-npj20tj9.js → chunk-p17jeqz0.js} +2 -2
  110. package/dist/{chunk-bvqgq18r.js → chunk-p97h91zx.js} +2 -2
  111. package/dist/{chunk-cxsc37fg.js → chunk-pe5sstex.js} +2 -2
  112. package/dist/chunk-pjv4dskp.js +2 -0
  113. package/dist/chunk-pqr4gn9b.js +4 -0
  114. package/dist/{chunk-zv3rn0ch.js → chunk-prj38cyp.js} +6 -6
  115. package/dist/{chunk-5jc9hmwg.js → chunk-pwg544dw.js} +2 -2
  116. package/dist/chunk-pxvp0cc9.js +3 -0
  117. package/dist/{chunk-hhspwfva.js → chunk-q8snpht6.js} +3 -3
  118. package/dist/chunk-q99y5115.js +3 -0
  119. package/dist/chunk-qnytvyy0.js +2 -0
  120. package/dist/{chunk-23x3k751.js → chunk-qzspvwv6.js} +2 -2
  121. package/dist/chunk-r02asm46.js +2 -0
  122. package/dist/chunk-r7zvrh58.js +70 -0
  123. package/dist/chunk-ra35ptjg.js +3 -0
  124. package/dist/chunk-rc4712qh.js +2 -0
  125. package/dist/chunk-rq7sg012.js +33 -0
  126. package/dist/{chunk-302nw40c.js → chunk-rt4gzqs9.js} +1 -1
  127. package/dist/chunk-rx1xw7q2.js +2 -0
  128. package/dist/{chunk-36cz2v8k.js → chunk-rzmephr2.js} +31 -31
  129. package/dist/{chunk-cwcmmgvz.js → chunk-s1x2pc9b.js} +2 -2
  130. package/dist/{chunk-r7y1196g.js → chunk-s3rhbwgf.js} +4 -4
  131. package/dist/{chunk-0asdv3hk.js → chunk-s6w14v6h.js} +2 -2
  132. package/dist/chunk-sdvv8zge.js +3 -0
  133. package/dist/chunk-sgppgy5e.js +20 -0
  134. package/dist/chunk-sk7pptzf.js +38 -0
  135. package/dist/{chunk-w6ydg43d.js → chunk-sk8x8nw8.js} +3 -3
  136. package/dist/chunk-skjm3zdh.js +2 -0
  137. package/dist/{chunk-388xpdw5.js → chunk-t4exh7c9.js} +76 -36
  138. package/dist/{chunk-yq2krsc9.js → chunk-t64mp8x1.js} +6 -6
  139. package/dist/{chunk-8wqhzzkn.js → chunk-tfpd7aht.js} +3 -3
  140. package/dist/chunk-tsnzhke9.js +2 -0
  141. package/dist/{chunk-c13dv3wm.js → chunk-tt6n2mx6.js} +14 -14
  142. package/dist/chunk-txyze88n.js +2 -0
  143. package/dist/chunk-v1t7sees.js +2 -0
  144. package/dist/chunk-vhp5hqwp.js +54 -0
  145. package/dist/{chunk-88fx8xc1.js → chunk-vn3hsx7v.js} +2 -2
  146. package/dist/chunk-vt410s5m.js +2 -0
  147. package/dist/{chunk-mf5cqv1k.js → chunk-w27j0apm.js} +29 -29
  148. package/dist/{chunk-gg715pj6.js → chunk-w5vxzk5j.js} +6 -6
  149. package/dist/chunk-w81a1e14.js +9 -0
  150. package/dist/{chunk-m8n14s3z.js → chunk-wajvxzt0.js} +2 -2
  151. package/dist/chunk-wrva7jes.js +2 -0
  152. package/dist/chunk-ws25jw6x.js +6 -0
  153. package/dist/{chunk-789yp1tg.js → chunk-ww24mxmd.js} +3 -3
  154. package/dist/chunk-xdprx6tx.js +1331 -0
  155. package/dist/chunk-xgv3gy1b.js +2 -0
  156. package/dist/chunk-xjhv5e5f.js +2 -0
  157. package/dist/{chunk-zkwkhesc.js → chunk-xmy75h5v.js} +2 -2
  158. package/dist/chunk-xnvh4jk2.js +21 -0
  159. package/dist/chunk-xtakhmnb.js +2 -0
  160. package/dist/{chunk-2qk2ppgm.js → chunk-y97g0kwc.js} +1 -1
  161. package/dist/chunk-y9f9d4zv.js +2 -0
  162. package/dist/{chunk-p3x84jj0.js → chunk-yfe380a4.js} +2 -2
  163. package/dist/chunk-ygtz9kc7.js +3 -0
  164. package/dist/chunk-yyypc7s3.js +2 -0
  165. package/dist/chunk-z5j4prza.js +2 -0
  166. package/dist/{chunk-ma5ptt4m.js → chunk-z68teecy.js} +2 -2
  167. package/dist/cli.js +38 -38
  168. package/dist/color-mode-boot.d.ts +1 -8
  169. package/dist/color-mode-boot.js +46 -2
  170. package/dist/composables/use-media-query.js +23 -22
  171. package/dist/craft-entry.js +2 -2
  172. package/dist/craft.js +2 -2
  173. package/dist/document-shell.d.ts +2 -0
  174. package/dist/document-shell.js +15 -3
  175. package/dist/document-tags.d.ts +2 -0
  176. package/dist/document-tags.js +9 -0
  177. package/dist/head-injection.d.ts +2 -0
  178. package/dist/head-injection.js +1 -0
  179. package/dist/head.d.ts +2 -0
  180. package/dist/head.js +2 -2
  181. package/dist/native/accessibility.d.ts +1 -1
  182. package/dist/native/accessibility.js +5 -3
  183. package/dist/native/bridge/protocol.d.ts +1 -0
  184. package/dist/native/compiler/html-to-ir.js +15 -1
  185. package/dist/native/compiler/ir.d.ts +8 -0
  186. package/dist/native/components/primitives.d.ts +2 -0
  187. package/dist/native/event-names.js +6 -0
  188. package/dist/native/prop-names.js +3 -1
  189. package/dist/native/runtime/browser-renderer.d.ts +1 -0
  190. package/dist/native/runtime/browser-renderer.js +27 -6
  191. package/dist/native/runtime/craft-bridge.js +1 -0
  192. package/dist/native/runtime/craft.d.ts +3 -0
  193. package/dist/native/runtime/jsc-globals.js +1 -1
  194. package/dist/native/runtime/native-media.js +8 -3
  195. package/dist/native/runtime/shared-screen.js +8 -3
  196. package/dist/native/testing.d.ts +3 -1
  197. package/dist/native/testing.js +35 -1
  198. package/dist/page-head.js +1 -9
  199. package/dist/process.js +6 -3
  200. package/dist/pwa.js +3 -3
  201. package/dist/signal-processing.d.ts +2 -2
  202. package/dist/signal-processing.js +17 -11
  203. package/dist/ssg.js +13 -13
  204. package/dist/types/config-types.d.ts +1 -1
  205. package/dist/utils.js +2 -1
  206. package/dist/variable-extractor.js +6 -1
  207. package/dist/vue-template.d.ts +2 -0
  208. package/dist/vue-template.js +72 -2
  209. package/package.json +6 -6
  210. package/dist/chunk-0adc8x2h.js +0 -9
  211. package/dist/chunk-0atz8fjx.js +0 -20
  212. package/dist/chunk-0fm6avxt.js +0 -3
  213. package/dist/chunk-0v7555tr.js +0 -42
  214. package/dist/chunk-11rnqey0.js +0 -2
  215. package/dist/chunk-1mx3j280.js +0 -2
  216. package/dist/chunk-20hy5p3p.js +0 -2
  217. package/dist/chunk-29v3b5ks.js +0 -2
  218. package/dist/chunk-2cay3heb.js +0 -2
  219. package/dist/chunk-31yx4sjh.js +0 -2
  220. package/dist/chunk-33fnbw33.js +0 -2
  221. package/dist/chunk-357qjcj1.js +0 -3
  222. package/dist/chunk-38kerh2r.js +0 -2
  223. package/dist/chunk-38y11q8x.js +0 -2
  224. package/dist/chunk-3h4db9yb.js +0 -33
  225. package/dist/chunk-3q80f7mt.js +0 -2
  226. package/dist/chunk-43kz6rx9.js +0 -2
  227. package/dist/chunk-43sgpy4e.js +0 -54
  228. package/dist/chunk-4e18r89n.js +0 -3
  229. package/dist/chunk-4pve3r5a.js +0 -2
  230. package/dist/chunk-4vz17ytv.js +0 -68
  231. package/dist/chunk-5afnyvw5.js +0 -2
  232. package/dist/chunk-5d5dxts6.js +0 -2
  233. package/dist/chunk-5fdsyyfe.js +0 -2
  234. package/dist/chunk-67yr4m5h.js +0 -2
  235. package/dist/chunk-6aqr0e6s.js +0 -2
  236. package/dist/chunk-6bw02d1t.js +0 -2
  237. package/dist/chunk-76mn123c.js +0 -2
  238. package/dist/chunk-7ar11ccn.js +0 -2
  239. package/dist/chunk-7fc0vrs5.js +0 -2
  240. package/dist/chunk-82fg5gp6.js +0 -2
  241. package/dist/chunk-89r7bbsk.js +0 -2
  242. package/dist/chunk-8egbh6z1.js +0 -2
  243. package/dist/chunk-8n9jd8cz.js +0 -2
  244. package/dist/chunk-8tfpv6zf.js +0 -6
  245. package/dist/chunk-8x3yaahc.js +0 -2
  246. package/dist/chunk-94qc4zwb.js +0 -2
  247. package/dist/chunk-9928zdej.js +0 -3
  248. package/dist/chunk-9ay18k46.js +0 -2
  249. package/dist/chunk-9kn81bmp.js +0 -2
  250. package/dist/chunk-9tv0tw7f.js +0 -3
  251. package/dist/chunk-9w9y84t5.js +0 -21
  252. package/dist/chunk-a5h9bwrc.js +0 -2
  253. package/dist/chunk-b5qzed8y.js +0 -1323
  254. package/dist/chunk-bej9kz05.js +0 -2
  255. package/dist/chunk-bh2khcet.js +0 -2
  256. package/dist/chunk-bm6y085n.js +0 -25
  257. package/dist/chunk-c6096ssb.js +0 -2
  258. package/dist/chunk-ccgabq3a.js +0 -2
  259. package/dist/chunk-e0tvd7jj.js +0 -2
  260. package/dist/chunk-e5rag6rh.js +0 -3
  261. package/dist/chunk-fvr3h2fr.js +0 -7
  262. package/dist/chunk-gmmqz698.js +0 -2
  263. package/dist/chunk-hxftzw0x.js +0 -2
  264. package/dist/chunk-js1wayhb.js +0 -2
  265. package/dist/chunk-jz37h2z0.js +0 -4
  266. package/dist/chunk-k2t0w8z1.js +0 -2
  267. package/dist/chunk-k8s3hyh2.js +0 -2
  268. package/dist/chunk-kcpxqsdj.js +0 -2
  269. package/dist/chunk-mjr5fkc2.js +0 -2
  270. package/dist/chunk-n4m50dpk.js +0 -1467
  271. package/dist/chunk-na0e3s88.js +0 -2
  272. package/dist/chunk-new89wh2.js +0 -2
  273. package/dist/chunk-nrap20qt.js +0 -2
  274. package/dist/chunk-p9bghe13.js +0 -2
  275. package/dist/chunk-q2cwzgd0.js +0 -2
  276. package/dist/chunk-q60afqr7.js +0 -2
  277. package/dist/chunk-q9yahsww.js +0 -2
  278. package/dist/chunk-qdwtemy1.js +0 -2
  279. package/dist/chunk-qp0ndbk6.js +0 -2
  280. package/dist/chunk-rzsvxjse.js +0 -2
  281. package/dist/chunk-s2c0ynn9.js +0 -2
  282. package/dist/chunk-senrtnx2.js +0 -2
  283. package/dist/chunk-v1wr2vdx.js +0 -2
  284. package/dist/chunk-v6gkjg5f.js +0 -3
  285. package/dist/chunk-wc10m4tp.js +0 -38
  286. package/dist/chunk-wcxa8xy2.js +0 -2
  287. package/dist/chunk-wgrj0cvs.js +0 -2
  288. package/dist/chunk-wpkwx3wq.js +0 -2
  289. package/dist/chunk-wq17dce6.js +0 -2
  290. package/dist/chunk-wvc6eayq.js +0 -2
  291. package/dist/chunk-xa98a901.js +0 -2
  292. package/dist/chunk-xjt5129x.js +0 -2
  293. package/dist/chunk-yc3frw0z.js +0 -3
  294. package/dist/chunk-yn02d599.js +0 -2
@@ -0,0 +1,1331 @@
1
+ // @bun
2
+ import{Qe,Bn,yo,ta,z}from"./chunk-875wejw1.js";import{jn}from"./chunk-yfe380a4.js";import{es,C,Yl,St,la,Zl,ts}from"./chunk-4jg8ddfy.js";import{L}from"./chunk-ayrd026n.js";import{T,A}from"./chunk-a78k8fkg.js";import{Qr,Co,qn,Xl,Be}from"./chunk-ra35ptjg.js";import{bo,d,h,Te,qr,p,ne,X,we,_,bt,vt,G,U,tn,g,zl,ve,re,Hn,V,ko,je,rt,_o}from"./chunk-r7zvrh58.js";import{x}from"./chunk-6bm7t0hm.js";import{se}from"./chunk-q99y5115.js";import{t,y}from"./chunk-amnfd29h.js";import{c}from"./chunk-ws25jw6x.js";import Rt from"path";import xn from"process";import{AsyncLocalStorage as ec}from"async_hooks";var Kr=new ec;function On(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function Jr(e,n){return Kr.run(On(e),n)}async function Xr(e,n){let r=Kr.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(v,S)=>{if(S===void 0||typeof S==="function"||typeof S==="symbol"||typeof S==="bigint"||typeof S==="number"&&!Number.isFinite(S))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(S&&typeof S==="object"&&!Array.isArray(S)&&Object.getPrototypeOf(S)!==Object.prototype&&Object.getPrototypeOf(S)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return S}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function Vr(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Z(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,v=()=>{if(l!==0)return;let S=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(S){if(n&&S[1]==="const")return;let W=S[2];if(!a.has(W))i.push(W),a.add(W);return}let j=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((W)=>{let N=W.trim();if(!N)return;let Y=N.indexOf(":"),te=(Y>=0?N.slice(Y+1).trim():N).split(/[\s=]/)[0];if(te&&!a.has(te))i.push(te),a.add(te)});return}let O=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(O){if(n&&r.slice(u).startsWith("const"))return;O[1].split(",").forEach((W)=>{let N=W.trim().replace(/^\.\.\./,"");if(!N)return;let Y=N.split(/[\s=]/)[0];if(Y&&!a.has(Y))i.push(Y),a.add(Y)});return}if(n)return;let H=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(H){let W=H[1];if(!a.has(W))i.push(W),a.add(W);return}let D=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(D){let W=D[1];if(!a.has(W))i.push(W),a.add(W)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))v();u++}return i.join(", ")}function Zs(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function tc(e,n=Z(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(Z(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Qs(e,n){let r=`{ ${tc(e,n)} }`;return Z(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import fn from"fs";import Ue from"path";function Q(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Gr=new Map;function jr(e,n=!0){let r=Gr.get(e);if(n&&r)return r;let i=new Map,a=[Ue.join(e,"src"),Ue.join(e,"dist"),e];function l(u,f){if(f>6)return;let v;try{v=fn.readdirSync(u,{withFileTypes:!0})}catch{return}for(let S of v){let j=Ue.join(u,S.name);if(S.isDirectory()){if(S.name==="node_modules"||S.name.startsWith("."))continue;l(j,f+1)}else if(S.isFile()&&S.name.endsWith(".stx")){let O=S.name.slice(0,-4);if(!i.has(O))i.set(O,j);let H=O.toLowerCase();if(!i.has(H))i.set(H,j);let D=Q(O);if(!i.has(D))i.set(D,j)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)Gr.set(e,i);return i}function eo(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=Ue.join(r,"node_modules",e);try{if(fn.statSync(i).isDirectory())return i}catch{}let a=Ue.dirname(r);if(a===r)return null;r=a}}function to(e,n,r={}){return[Ue.resolve(Ue.dirname(n),`${e}.stx`),Ue.resolve(Ue.dirname(n),e),Ue.resolve(r.componentsDir||"components",`${e}.stx`),Ue.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function Yr(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=Q(n);return[n,r,i]}function Di(e,n){let[r,i,a]=Yr(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function Li(e,n){let r=n?Ue.resolve(n):void 0,i=Ue.dirname(Ue.resolve(e));for(;;){if(fn.existsSync(Ue.join(i,"package.json")))return r&&i===r?void 0:i;let a=Ue.dirname(i);if(a===i)return;i=a}}var nc=["src/ui","src/components","components","dist"];function ms(e,n){let r=Ue.resolve(e);if(!n&&!r.split(Ue.sep).includes("node_modules"))return[];let i=Li(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(fn.readFileSync(Ue.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((v)=>typeof v==="string")}catch{}let l=a.length?a:nc;return[Ue.dirname(Ue.resolve(e)),...l.map((u)=>Ue.resolve(i,u))]}function*ji(e,n,r={},i){let a=Yr(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield Ue.resolve(Ue.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((v)=>`${v}.stx`))],u=r.projectRoot||process.cwd(),f=[...ms(n,r.projectRoot),...i?.__originalFilePath?[Ue.join(Ue.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],Ue.join(Ue.dirname(n),"components"),Ue.resolve(u,"src/components"),Ue.resolve(u,"components"),...import.meta.dir?[Ue.resolve(import.meta.dir,"components")]:[]];for(let v of new Set(f)){for(let S of l)yield Ue.join(v,S);try{for(let S of fn.readdirSync(v,{withFileTypes:!0}))if(S.isDirectory())for(let j of l)yield Ue.join(v,S.name,j)}catch{}}}function ei(e,n,r={},i){let a=Di(e,i);if(a!==void 0)return a;for(let l of ji(e,n,r,i))try{if(fn.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function no(e,n=[],r={}){let i=new Set([...e].map((S)=>S.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([S,j])=>[S.replace(/[-_]/g,"").toLowerCase(),j])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),v=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!v)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((S)=>i.has(S)))return!1;if([...n].some((S)=>!["load","error"].includes(S.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((S)=>i.has(S))}import Ls from"fs";import xe from"path";import Zt from"path";import Tn from"fs";var sc=new Set(["touchstart","touchmove","wheel","mousewheel"]);function Js(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return sc.has(e.toLowerCase())}var ti=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),ni={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},rc=new Set(["ctrl","alt","shift","meta"]),ii={left:0,middle:1,right:2};function si(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(rc.has(i))n.systemKeys.push(i);else if(i in ii)n.mouse=i;else if(i in ni||/^[a-z]$/.test(i))n.keys.push(ni[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function oi(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,v]=l,S=l.index,j=S+u.length,O=`__stx_evt_${n}${i++}`,H=[],D=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,W;while((W=D.exec(v))!==null){let[,Y,J]=W,te=Y.split("."),K=te[0];if(!ti.has(K))continue;H.push({attribute:`@${Y}`,event:K,handler:J,modifiers:si(te.slice(1)),elementId:O})}let N=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((W=N.exec(v))!==null){let[,Y,J]=W,te=Y.split("."),K=te[0];if(!ti.has(K))continue;H.push({attribute:`@${Y}`,event:K,handler:J,modifiers:si(te.slice(1)),elementId:O})}if(H.length>0)r.push({originalTag:u,elementId:O,events:H,startIndex:S,endIndex:j})}return r}function ic(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=ii[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function oc(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Xs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function ac(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=ic(e),a=oc(Xs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(Js(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
3
+ (function() {
4
+ var $el = document.getElementById('${r}');
5
+ if (!$el) return;
6
+ // Run mounted handler immediately (DOM is ready)
7
+ var scope = $el.closest('[data-stx-scope]');
8
+ if (scope && scope.__stx_execute) {
9
+ scope.__stx_execute('${f}', null, $el);
10
+ }
11
+ else {
12
+ __stx_runHandler('${f}', null, $el);
13
+ }
14
+ })();`;if(e.event==="unmounted")return`
15
+ (function() {
16
+ var $el = document.getElementById('${r}');
17
+ if (!$el) return;
18
+ // Set up MutationObserver to detect removal
19
+ var observer = new MutationObserver(function(mutations) {
20
+ for (var m of mutations) {
21
+ for (var node of m.removedNodes) {
22
+ if (node === $el || (node.contains && node.contains($el))) {
23
+ observer.disconnect();
24
+ var scope = $el.closest('[data-stx-scope]');
25
+ if (scope && scope.__stx_execute) {
26
+ scope.__stx_execute('${f}', null, $el);
27
+ }
28
+ else {
29
+ __stx_runHandler('${f}', null, $el);
30
+ }
31
+ return;
32
+ }
33
+ }
34
+ }
35
+ });
36
+ observer.observe(document.body, { childList: true, subtree: true });
37
+ // Store observer for cleanup
38
+ $el.__stx_unmount_observer = observer;
39
+ })();`;return`
40
+ (function() {
41
+ var $el = document.getElementById('${r}');
42
+ if (!$el) return;
43
+ // eslint-disable-next-line pickier/no-unused-vars
44
+ $el.addEventListener('${e.event}', function($event) {
45
+ ${i?i+";":""}
46
+ // Find the closest reactive scope and execute within its context
47
+ var scope = $el.closest('[data-stx-scope]');
48
+ if (scope && scope.__stx_execute) {
49
+ scope.__stx_execute('${f}', $event, $el);
50
+ }
51
+ else {
52
+ // Fallback for non-reactive context (entity-safe; decoded + run in memory)
53
+ __stx_runHandler('${f}', $event, $el);
54
+ }
55
+ }${u});
56
+ })();`}function Bi(e){if(e.length===0)return"";return`
57
+ <script data-stx-events>
58
+ (function() {
59
+ 'use strict';
60
+
61
+ // Utility functions
62
+ function __stx_debounce(fn, delay) {
63
+ var timeout;
64
+ return function() {
65
+ var args = arguments;
66
+ var ctx = this;
67
+ clearTimeout(timeout);
68
+ timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
69
+ };
70
+ }
71
+
72
+ function __stx_throttle(fn, delay) {
73
+ var last = 0;
74
+ return function() {
75
+ var now = Date.now();
76
+ if (now - last >= delay) {
77
+ last = now;
78
+ fn.apply(this, arguments);
79
+ }
80
+ };
81
+ }
82
+
83
+ // Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
84
+ // so the surrounding script element can never contain raw markup, including
85
+ // its own closing tag; we decode it to JS only in memory here, then run it
86
+ // with $event/$el in scope.
87
+ //
88
+ // This comment must not spell that closing tag out. It used to, as an
89
+ // example, and a browser ends the script element at the FIRST one it sees \u2014
90
+ // so everything below this line, __stx_runHandler included, was emitted as
91
+ // page text and no listener was ever bound. The comment about escaping was
92
+ // the thing that needed escaping.
93
+ function __stx_runHandler(h, $event, $el) {
94
+ var code = h
95
+ .replace(/&lt;/g, '<')
96
+ .replace(/&gt;/g, '>')
97
+ .replace(/&quot;/g, '"')
98
+ .replace(/&#39;/g, "'")
99
+ .replace(/&#x27;/g, "'")
100
+ .replace(/&amp;/g, '&');
101
+ try {
102
+ // eslint-disable-next-line no-new-func
103
+ (new Function('$event', '$el', code)).call($el, $event, $el);
104
+ }
105
+ catch (e) {
106
+ if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
107
+ }
108
+ }
109
+
110
+ // Event listeners
111
+ ${e.map(ac).join(`
112
+ `)}
113
+ })();
114
+ </script>`}function cc(e,n=""){let r=oi(e,n);if(r.length===0)return{template:e,bindings:[]};let i=e,a=[];for(let l=r.length-1;l>=0;l--){let u=r[l],f=u.originalTag;if(!f.includes(" id="))f=f.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${u.elementId}"`);else{let v=f.match(/id=["']([^"']+)["']/);if(v)for(let S of u.events)S.elementId=v[1]}for(let v of u.events){let S=v.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`\\s*${S}\\s*=\\s*"[^"]*"`,"g"),O=new RegExp(`\\s*${S}\\s*=\\s*'[^']*'`,"g");f=f.replace(j,""),f=f.replace(O,"")}i=i.slice(0,u.startIndex)+f+i.slice(u.endIndex),a.push(...u.events)}return{template:i,bindings:a}}function ri(e){let n=e.$uid;return typeof n==="string"&&n?`${n}_`:""}function dl(e,n,r){if(Zl(e))return e;if(n.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(e))return e;let{template:f,bindings:v}=cc(e,ri(n)),S=n.__stx_event_bindings||[];return n.__stx_event_bindings=[...S,...v],f}let i=oi(e,ri(n));if(i.length===0)return e;let a=e;for(let f=i.length-1;f>=0;f--){let v=i[f],S=v.originalTag;if(!S.includes(" id="))S=S.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${v.elementId}"`);else{let j=S.match(/id=["']([^"']+)["']/);if(j)for(let O of v.events)O.elementId=j[1]}for(let j of v.events){let O=j.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=new RegExp(`\\s*${O}\\s*=\\s*"[^"]*"`,"g"),D=new RegExp(`\\s*${O}\\s*=\\s*'[^']*'`,"g");S=S.replace(H,""),S=S.replace(D,"")}a=a.slice(0,v.startIndex)+S+a.slice(v.endIndex)}let l=Bi(i.flatMap((f)=>f.events)),u=c(a);if(u!==-1)a=a.slice(0,u)+l+`
115
+ `+a.slice(u);else a+=l;return a}function ai(e,n){let r=new Set;for(let i of e.split(",")){let a=i.trim().replace(/^\.\.\./,"").trim();if(!a)continue;if(n){let l=a.lastIndexOf(":");if(l!==-1)a=a.slice(l+1).trim()}if(a=a.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(a))r.add(a)}return r}function Vt(e,n){let r=t(e),{depths:i,balanced:a}=y(r),l=(f)=>!a||i[f]===0,u=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${n}\\b)`,"g");for(let f of r.matchAll(u)){let v=(f.index??0)+f[0].length-f[1].length;if(l(v))return!0}for(let f of r.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(l(f.index??0)&&ai(f[1],!0).has(n))return!0;for(let f of r.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(l(f.index??0)&&ai(f[1],!1).has(n))return!0;return!1}var qe="0.2.921";var ci=Symbol.for(`stx.lazy-module-promises.${qe}`);function uc(){let e=globalThis;return e[ci]??=new Map,e[ci]}function o(e,n){let r=uc(),i=`${import.meta.url}\x00${e}`,a=r.get(i);if(a)return a;let l=n();return r.set(i,l),l.catch(()=>{if(r.get(i)===l)r.delete(i)}),l}var pc=/<\/(script)/gi;function he(e){if(!e||e.indexOf("</")===-1)return e;return e.replace(pc,"<\\/$1")}import li from"fs";var ui=[];function k(e){let n=new T(e);return ui.push(n),n}function pl(){for(let e of ui)e.clear()}function E(e,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${e.length}\x00${Bun.hash(e)}`}function Br(e){let n=[];for(let r of new Set(e))try{n.push({path:r,mtimeMs:li.statSync(r).mtimeMs})}catch{}return n}function ro(e){for(let n of e)try{if(li.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var Ne=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var fc=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function dc(e){if(e.startsWith(".")||e.startsWith("/"))return null;if(e.startsWith("@")){let r=e.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!r)return null;return{pkg:r[1],subpath:r[2]||""}}let n=e.match(/^([^/]+)(\/.*)?$/);if(!n)return null;return{pkg:n[1],subpath:n[2]||""}}function gc(e,n){let r=n;while(!0){let i=Zt.join(r,"node_modules",e,"package.json");if(Tn.existsSync(i))return Zt.dirname(i);let a=Zt.dirname(r);if(a===r)return null;r=a}}function mc(e,n){if(!e||typeof e!=="object")return null;let r=(a)=>{if(typeof a==="string")return a;if(a&&typeof a==="object"){if(typeof a.import==="string")return a.import;if(typeof a.default==="string")return a.default;if(typeof a.import==="object")return r(a.import);if(typeof a.default==="object")return r(a.default)}return null};if(Object.prototype.hasOwnProperty.call(e,n))return r(e[n]);let i=null;for(let a of Object.keys(e)){let l=a.indexOf("*");if(l===-1)continue;let u=a.slice(0,l),f=a.slice(l+1);if(!n.startsWith(u)||!n.endsWith(f))continue;if(n.length<u.length+f.length)continue;if(!i||u.length>i.prefix.length)i={pattern:a,prefix:u,suffix:f}}if(i){let a=n.slice(i.prefix.length,n.length-i.suffix.length),l=r(e[i.pattern]);if(l)return l.replace("*",a)}return null}function hc(e,n){let r=dc(e);if(!r||!r.subpath)return null;let i=gc(r.pkg,n);if(!i)return null;let a;try{a=JSON.parse(Tn.readFileSync(Zt.join(i,"package.json"),"utf8"))}catch{return null}let l=`.${r.subpath}`,u=mc(a.exports,l);if(!u)return null;let f=Zt.resolve(i,u);return Tn.existsSync(f)?f:null}function Xi(e,n){let r=n.filePath?Zt.dirname(n.filePath):n.projectRoot||process.cwd(),i=n.projectRoot||process.cwd(),a=new Set,l=[],u=[];return{code:e.replace(fc,(v,S)=>{let j;try{if(S.startsWith("./")||S.startsWith("../")||S.startsWith("/")){if(j=S.startsWith("/")?S:Zt.resolve(r,S),!Tn.existsSync(j))throw Error(`file not found: ${j}`)}else{let O=null;try{O=Bun.resolveSync(S,i)}catch{O=hc(S,i)}if(!O)throw Error(`could not resolve ${S} (Bun.resolveSync + exports fallback both failed)`);j=O}}catch(O){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(S)} (from ${n.filePath||"<unknown>"}): ${O?.message||O}`),u.push(S),""}if(a.has(j))return"";a.add(j);try{let O=Tn.readFileSync(j,"utf8");l.push({source:S,resolvedPath:j,contents:O})}catch(O){console.warn(`[stx:vendor-css] could not read ${j}: ${O?.message||O}`),u.push(S)}return""}),styles:l,unresolved:u}}function xc(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Gi(e){if(e.length===0)return"";return`${e.map((n)=>`<style data-stx-vendor="${xc(n.source)}" data-stx-layer="vendor">
116
+ @layer vendor {
117
+ ${n.contents}
118
+ }
119
+ </style>`).join(`
120
+ `)}
121
+ `}var Kg=C,pi=k(256);function Gt(e){let n=E(e),r=pi.get(n);if(!r)r=bc(e),pi.set(n,r);return{code:r.code,imports:[...r.imports],models:[...r.models]}}function bc(e){let n=t(e),r=new Set;for(let f of e.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let v of f[1].split(",")){let S=v.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(S)r.add(S)}let i=Co(n),a=Ne.filter((f)=>{if(r.has(f)||i.has(f))return!1;return Xg(n,f,!0)}),l=mi(n).filter((f)=>!r.has(f)&&!i.has(f));if(a.length===0&&l.length===0)return{code:e,imports:a,models:l};return{code:`${[a.length>0?`import { ${a.join(", ")} } from '@stacksjs/browser'`:"",l.length>0?"import '@stacksjs/browser'":"",l.length>0?`const { ${l.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
122
+ `)}
123
+ ${e}`,imports:a,models:l}}var yc=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function mi(e,n=Qr(e)){let r=new Set,i=Co(e),a=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let l of n.code.matchAll(a)){let u=l[1];if(yc.has(u)||i.has(u)||u.length<3)continue;if(n.shadows(u,l.index??0))continue;r.add(u)}return Array.from(r)}function _c(e){return Co(e)}var fi=k(128);function Al(e){let n=E(e),r=fi.get(n);if(!r)r=wc(e),fi.set(n,r);return{code:r.code,stxImports:[...r.stxImports],browserImports:[...r.browserImports]}}function wc(e){let n=new Set,r=new Set,i=e;i=i.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let a=new Set,l=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,u;while((u=l.exec(e))!==null){let D=u[1],W=u[2];if(u[0].includes("import type"))continue;let N=[];for(let J of D.split(",")){let te=J.trim();if(!te||te.startsWith("type "))continue;let K=te.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!K)continue;let q=K[1],oe=K[2]||q;if(a.add(q),a.add(oe),W==="stx"||W==="@stacksjs/stx")n.add(q);else r.add(q);if(oe!==q)N.push(`${oe} = ${q}`)}let Y=N.length>0?`var ${N.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";i=i.replace(u[0],Y)}let f=_c(i),v=Qr(i);for(let D of Kg){if(a.has(D)||f.has(D))continue;if(Gs(v,D,!0))n.add(D)}let S=t(i),j=Qr(S),O=new Set;for(let D of i.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let W of D[1].split(",")){let N=W.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let Y of N){let J=Y.trim();if(J)O.add(J)}}for(let D of Ne){if(a.has(D)||f.has(D)||O.has(D))continue;if(Gs(j,D))r.add(D)}let H=mi(S,j);for(let D of H)if(!a.has(D)&&!f.has(D))r.add(D);return{code:i,stxImports:Array.from(n),browserImports:Array.from(r)}}function Xg(e,n,r=!1){return Gs(Qr(e),n,r)}function Gs(e,n,r=!1){let i=e.code,a=new RegExp(`\\b${n.replace(/[$]/g,"\\$")}\\b`,"g");for(let l of i.matchAll(a)){let u=l.index??0;if(e.shadows(n,u))continue;let f=u+n.length,v=u-1;while(v>=0&&/\s/.test(i[v]))v--;if(i[v]==="."&&i.slice(Math.max(0,v-2),v+1)!=="...")continue;let S=f;while(S<i.length&&/\s/.test(i[S]))S++;if(i[S]===":"&&i[S+1]!==":"&&(i[v]==="{"||i[v]===","))continue;if(r&&!/^\s*(?:<[^>]*>)?\s*\(/.test(i.slice(f)))continue;if(vc(i,f))continue;return!0}return!1}function vc(e,n){let r=n;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;if(e[r]!=="(")return!1;let i=0;for(;r<e.length;r++){let a=e[r];if(a==="(")i++;else if(a===")"){if(i--,i===0)break}}if(i!==0)return!1;r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;return e[r]==="{"}function Pl(e,n){let r=[];if(e.length>0)r.push(` var { ${e.join(", ")} } = window.stx || window;`);if(n.length>0)r.push(` var { ${n.join(", ")} } = window.StacksBrowser || {};`);if(r.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
124
+ ${r.join(`
125
+ `)}
126
+ ${$c(e,n)}`;return""}function jy(e,n=[]){let{browserImports:r}=Al(e),i=new Set(n);return Pl([],r.filter((a)=>!i.has(a)))}function $c(e,n){let r=[...e.map((i)=>`['${i}', typeof ${i}, 'stx']`),...n.map((i)=>`['${i}', typeof ${i}, '@stacksjs/browser']`)];if(r.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
127
+ [${r.join(", ")}].forEach(function (e) {
128
+ if (e[1] !== 'undefined') return;
129
+ console.error(
130
+ '[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
131
+ + 'but the client runtime does not provide it. Either it is not exported to the browser, '
132
+ + 'or it should be imported from a relative path so the bundler includes it.'
133
+ );
134
+ });
135
+ `}function Xe(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var Sc=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,di=new Set;function Ec(e,n){let r=Sc.test(e),i=n.length>32768;if(!r&&!i)return;if(di.has(e))return;if(di.add(e),r)console.warn(`[stx] server\u2192client bridge is publishing "${e}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(i)console.warn(`[stx] server\u2192client bridge is publishing ${(n.length/1024).toFixed(1)}KB under "${e}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function Nn(e,n){if(!n)return"";let r=Be(e,new Set(Object.keys(n))),i=n.__stxDeclaredPayload===!0,a=[],l=Object.entries(n).sort(([u],[f])=>u<f?-1:u>f?1:0);for(let[u,f]of l){if(!/^[A-Za-z_$][\w$]*$/.test(u))continue;if(u.startsWith("__")||u.startsWith("$"))continue;if(!i&&!r.has(u))continue;if(Vt(e,u)){if(i)console.warn(`[stx] defineClientPayload declares "${u}", but this client block also declares "${u}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${u}" from defineClientPayload.`);continue}let v;try{v=JSON.stringify(f)}catch{continue}if(v===void 0)continue;Ec(u,v),a.push(` var ${u} = ${v.replace(/</g,"\\u003c")};`)}if(a.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
136
+ ${a.join(`
137
+ `)}
138
+ `}var kc={left:0,middle:1,right:2};function Cc(e){let n=[];if(e.self)n.push("if ($event.target !== $el) return");for(let r of e.systemKeys)n.push(`if (!$event.${r}Key) return`);if(e.keys.length>0){let r=e.keys.map((i)=>`$event.key === '${i}'`).join(" || ");n.push(`if (!(${r})) return`)}if(e.mouse!==null){let r=kc[e.mouse];n.push(`if ($event.button !== ${r}) return`)}if(e.prevent)n.push("$event.preventDefault()");if(e.stop)n.push("$event.stopPropagation()");return n.join("; ")}function Rc(e,n){let{elementId:r,event:i,modifiers:a}=e,l=Xs(e.handler),u=Cc(a),f=[];if(a.once)f.push("once: true");if(a.capture)f.push("capture: true");if(Js(i,a))f.push("passive: true");let v=f.length>0?`, { ${f.join(", ")} }`:"",S="";if(u)S+=`${u}; `;let j=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),O=`var $emit = function(name, detail) {
139
+ $el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
140
+ };`;function H(D){if(/\$emit\s*\(/.test(D))return`${O}
141
+ ${D}`;return`var scope = $el.closest('[data-stx-scope]');
142
+ if (scope && scope.__stx_execute) {
143
+ scope.__stx_execute('${j}', $event, $el);
144
+ }
145
+ else {
146
+ ${D}
147
+ }`}if(a.debounce!==null)return` ;(function() {
148
+ // eslint-disable-next-line pickier/no-unused-vars
149
+ var $el = document.getElementById('${r}')
150
+ if (!$el) return
151
+ var __timer
152
+ $el.addEventListener('${i}', function($event) {
153
+ ${u?u+"; ":""}clearTimeout(__timer)
154
+ __timer = setTimeout(function() { ${H(l)} }, ${a.debounce})
155
+ }${v})
156
+ })()`;if(a.throttle!==null)return` ;(function() {
157
+ // eslint-disable-next-line pickier/no-unused-vars
158
+ var $el = document.getElementById('${r}')
159
+ if (!$el) return
160
+ var __last = 0
161
+ $el.addEventListener('${i}', function($event) {
162
+ ${u?u+"; ":""}var __now = Date.now()
163
+ if (__now - __last >= ${a.throttle}) {
164
+ __last = __now
165
+ ${H(l)}
166
+ }
167
+ }${v})
168
+ })()`;if(/\$emit\s*\(/.test(l))return` var $el = document.getElementById('${r}')
169
+ if ($el) $el.addEventListener('${i}', function($event) {
170
+ ${S}${O}
171
+ ${l}
172
+ }${v})`;return` var $el = document.getElementById('${r}')
173
+ if ($el) $el.addEventListener('${i}', function($event) {
174
+ ${S}var scope = $el.closest('[data-stx-scope]');
175
+ if (scope && scope.__stx_execute) {
176
+ scope.__stx_execute('${j}', $event, $el);
177
+ }
178
+ else {
179
+ ${l}
180
+ }
181
+ }${v})`}function Ac(e){if(e.length===0)return"";return`
182
+ // STX: auto-generated event bindings
183
+ ${e.map((r,i)=>Rc(r,i)).join(`
184
+ `)}`}function gi(e){let n=[],r=new Set,i=e.replace(/^\s*import\s+.*$/gm,""),a=0,l=i.length,u=0;while(u<l){let f=i[u];if(f==="'"||f==='"'||f==="`"){let v=f;if(u++,v==="`"){let S=0;while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]==="`"&&S===0){u++;break}if(i[u]==="$"&&i[u+1]==="{"){S++,u+=2;continue}if(i[u]==="}"&&S>0){S--,u++;continue}u++}}else while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]===v){u++;break}u++}continue}if(f==="/"&&i[u+1]==="/"){while(u<l&&i[u]!==`
185
+ `)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let v=i.slice(u),S=v.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(S){let H=S[1];if(!H.startsWith("_")&&!r.has(H))n.push(H),r.add(H);u+=S[0].length;continue}let j=v.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(j){j[1].split(",").forEach((H)=>{let D=H.trim(),W=D.indexOf(":"),N=W>=0?D.slice(W+1).trim().split(/[\s=]/)[0]:D.split(/[\s=]/)[0];if(N&&!N.startsWith("_")&&!r.has(N))n.push(N),r.add(N)}),u+=j[0].length;continue}let O=v.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(O){let H=O[1];if(!H.startsWith("_")&&!r.has(H))n.push(H),r.add(H);u+=O[0].length;continue}}u++}return n}var Tc=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function Ic(e){let n=new Set,r=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function i(H){let D;while((D=r.exec(H))!==null){let W=D[0];if(!Tc.has(W))n.add(W)}}let a=/\{\{([\s\S]*?)\}\}/g,l;while((l=a.exec(e))!==null)i(l[1]);let u=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((l=u.exec(e))!==null)i(l[1]);let f=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((l=f.exec(e))!==null)i(l[1]);let v=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((l=v.exec(e))!==null)i(l[1]);let S=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((l=S.exec(e))!==null)i(l[1]);let j=/@model\s*=\s*["']([^"']*)["']/gi;while((l=j.exec(e))!==null)i(l[1]);let O=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((l=O.exec(e))!==null)i(l[1]);return n}async function Ge(e,n={}){let r=e,i="",a=!1,l=[],u=Xi(r,{filePath:n.filePath,projectRoot:n.projectRoot});r=u.code;let f=Gi(u.styles),v=Gt(r);r=v.code,l=[...v.imports,...v.models];let{hasUserImports:S,bundleClientScript:j}=await o("stx/client-script-bundler",()=>import("./chunk-aqh48tyw.js"));if(S(r))r=await j(r,n.filePath||"",{projectRoot:n.projectRoot,minify:n.production}),a=!0;if(n.autoImports!==!1){let K=Al(r);r=K.code,i=Pl(K.stxImports,K.browserImports.filter((q)=>!l.includes(q)))}if(i=`${Nn(r,n.serverData)}${i}`,r=L(r),!a&&Je(n.attrs||""))r=Ye(r);let O=Ac(n.eventBindings||[]),H=(n.attrs||"").trim(),D=/\btype\s*=\s*["']module["']/i.test(H),W=n.instanceId?` data-stx-instance="${n.instanceId}"`:"";if(D){let K=H.replace(/\btype\s*=\s*["']module["']/i,"").trim(),q=`type="module" data-stx-scoped${W}${K?` ${K}`:""}`;return`${f}<script ${q}>
186
+ ${he(`${i}${r}
187
+ ${O}`)}
188
+ </script>`}let N=la(e),Y=/function __stx_setup_/.test(r),J=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(e);function te(K){let q=K.length>0?`
189
+ return ${Qs(r,K)};`:"",oe=JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`);return`${f}<script data-stx-scoped data-stx-run="always"${W}>
190
+ window.stx.mount(function() {
191
+ 'use strict';
192
+ try {
193
+ ${he(`${i}${r}
194
+ ${O}${q}`)}
195
+ } catch (error) {
196
+ console.error(${oe}, error);
197
+ return {};
198
+ }
199
+ })</script>`}if(!J&&!Y){if(N)return te(gi(e));if(n.templateContent){let K=gi(e);if(K.length>0){let q=Ic(n.templateContent);if(K.some((le)=>q.has(le)))return te(K)}}}return`${f}<script data-stx-scoped data-stx-run="always"${W}>
200
+ ;(function() {
201
+ 'use strict';
202
+ try {
203
+ ${he(`${i}${r}
204
+ ${O}`)}
205
+ } catch (error) {
206
+ console.error(${JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`)}, error);
207
+ }
208
+ })()</script>`}import{createHash as jc}from"crypto";var hs="__stx_component_client_factories";function xs(e){let n=e[hs];return n instanceof Map?n:null}function El(e){e[hs]=new Map}function Ys(e,n){let r=xs(e);if(!r)return null;let i=jc("sha256").update(n).digest("hex").slice(0,16),a=r.get(i);if(a)a.instances++;else r.set(i,{body:n,instances:1});return i}function Tl(e,n){let r=xs(n);if(!r?.size)return e;let i=new Map;for(let[j,O]of r)if(O.instances===1)i.set(j,O.body);let a=[];if(i.size>0){let j=[...i.keys()].map((D)=>JSON.stringify(D).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),O=new RegExp(`window\\.__stxComponentFactories\\[(${j})\\]\\(("[^"]+")\\);`,"g"),H=O.exec(e);while(H!==null){let D=i.get(JSON.parse(H[1]));if(D!==void 0)a.push({start:H.index,end:H.index+H[0].length,replacement:he(`(${D})(${H[2]});`)});H=O.exec(e)}}let l=[...r].filter(([,j])=>j.instances>1);if(l.length===0)return hi(e,a);let u=l.map(([j,O])=>` try { factories[${JSON.stringify(j)}] = factories[${JSON.stringify(j)}] || ${O.body}; }
209
+ catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(j)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
210
+ `),f=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
211
+ (function() {
212
+ const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
213
+ ${he(u)}
214
+ })();
215
+ </script>`,v,S=/<(?:template\b|script\b(?=[^>]*\bdata-stx-scoped\b))/iy;return g(e,(j,O)=>{if(v===void 0){if(S.lastIndex=O,S.test(j))v=O}return-1}),a.push({start:v??0,end:v??0,replacement:`${f}
216
+ `}),hi(e,a)}function hi(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function xi(e){let n=xs(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function bi(e,n){let r=xs(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function yi(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)Ys(e,r)}function Oe(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import Ci from"fs";var _i=0,er=new Map;function Ml(){_i=0,er.clear()}function bs(e,n){let r=_i++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return er.set(i,{type:e,expression:n}),i}function Dl(){let e={};for(let[n,r]of er)e[n]={type:r.type,expression:r.expression};return e}function Ll(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Yi(e){return e.includes("<!--__STX_")}var Oc=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function Pc(e){return Array.from({length:e},()=>"&#123;").join("&#8288;")}function wi(e){return e.replace(/\{{2,}/g,(n)=>Pc(n.length)).replace(/\{(?=!)/g,"&#123;&#8288;").replace(Oc,"&#64;")}function zr(e,n,r=!1){let{openTag:i,tail:a}=r?Mc(e,n):Dc(e).at(n);return Lc(a,i,r)}function Mc(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Oe(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var ys=null;function Dc(e){if(ys&&ys.source===e)return ys.scanner;let n=Nc(e);return ys={source:e,scanner:n},n}function Nc(e){let n=0,r=-1,i=null,a=-1,l=(f,v)=>{let S=e[f];if(v.quote){if(S===v.quote)v.quote=null;return}if(v.openTag>=0){if(S==='"'||S==="'"){v.quote=S;return}if(S===">"){v.openTag=-1;return}}if(S==="<")v.openTag=f},u=(f,v)=>{if(v.openTag>=0||!e.startsWith("<!--",f))return-1;let S=e.indexOf("-->",f+4);return S<0?e.length:S+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let v={openTag:r,quote:i},S=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let N=Oe(e,n);if(N<0)a=n;else if(N+2<=f){n=N+2;continue}else break}let W=u(n,v);if(W>=0){if(W>f){S=!0;break}n=W;continue}l(n,v),n++}if(r=v.openTag,i=v.quote,S)return{openTag:-1,tail:""};let j=a>=0?a:n,O={openTag:r,quote:i};for(let W=n;W<f;W++){let N=u(W,O);if(N>=0){if(N>f)return{openTag:-1,tail:""};W=N-1;continue}l(W,O)}if(O.openTag<0)return{openTag:-1,tail:""};let H="",D=O.openTag+1;for(let W=D;W<Math.min(f,j);W++){if(!e.startsWith("{{",W))continue;let N=Oe(e,W);H+=e.slice(D,W)+"x",W=N+1,D=N+2}return H+=e.slice(D,f),{openTag:O.openTag,tail:H}}}}function Lc(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,v=e.indexOf(u,i);if(v===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=v+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class ye extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var vi="unsafe:";var zc=/^(?:javascript|vbscript|livescript|mocha|view-source):/,Bc=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,Wc=/^data:(?:text\/html|application\/xhtml\+xml)/,Vc=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Fc(e){return e.replace(Vc,"").toLowerCase()}function tr(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function _s(e,n="navigable"){let r=Fc(e);if(zc.test(r))return!0;return n==="navigable"?Bc.test(r):Wc.test(r)}function Fr(e,n="navigable"){return _s(e,n)?"unsafe:"+e:e}function Uc(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return tr(n[1])}function $i(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function Si(e,n,r=n){let i=Uc(e);return i&&_s(n,i)?"unsafe:"+r:r}function Wt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function ws(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function Ei(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function ki(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Jt(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=Ei(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of ws(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Jt(l,n);continue}let u=Ei(l,":");Jt(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of ws(r.slice(1,-1)))Jt(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function ie(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let v=n.slice(0,l).trim();if(v.startsWith("(")&&ki(v)===v.length-1)v=v.slice(1,-1);for(let S of ws(v))Jt(S,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&ki(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Jt(u[2],r),Jt(u[1],r);else for(let f of ws(l))Jt(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var vs="__stx_client_loop_names";function ht(e){let n=e?.[vs];return Array.isArray(n)?n:[]}function $s(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((j)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(j[1])),v=(f?.[2]??f?.[3])?.trim();if(v&&f?.[1]==="data-stx-slot-binding")try{v=decodeURIComponent(v)}catch{v=void 0}let S=v?{start:a.index+l.length,end:e.length,binding:v}:void 0;if(r.push(S),S)n.push(S)}}return n}var Wn={},Ri=new Map;function Hc(e){let n=Ri.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),Ri.set(e,n)}return n.lastIndex=0,n}var ho={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return ee(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let v of l){if(u===void 0||u===null)break;u=u[v]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([v,S])=>{f=f.replace(Hc(v),()=>String(S))}),f},t:(e,n,r={})=>ho.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function rm(e,n){if(e in ho)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);Wn[e]=n}function Fy(e){for(let[n,r]of Object.entries(e))rm(n,r)}function sm(){return{...ho,...Wn}}function zy(){for(let e of Object.keys(Wn))delete Wn[e]}function Mi(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*Ni(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,v=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let S=e.indexOf(a,u);if(S===-1)break;let j=Oe(e,S,r);if(j===-1)break;if(l+=e.slice(u,S)+n(e.slice(S,j+r),e.slice(S+r,j),S),u=j+r,++f>=64){f=0;let O=performance.now();if(O-v>=i)v=O,yield}}return u===0?e:l+e.slice(u)}function Dn(e,n,r=2){return Mi(Ni(e,n,r,Number.POSITIVE_INFINITY))}function Zc(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=zr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ee(e){return wi(m(e))}function Kc(e){return e.replace(/ /g,"&#32;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;").replace(/\f/g,"&#12;").replace(/=/g,"&#61;").replace(/`/g,"&#96;")}function qc(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function Jc(e,n){let r=qc(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new ye(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new ye(n,"CSS URLs must be local paths or base64 raster images")}}function ce(e,n,r,i=!1,a=0){try{return Xc(e,n,r,i,a)}catch(l){if(l instanceof ye)l.locate(e,n);throw l}}function Xc(e,n,r,i,a){let l=zr(e,n,i),u=ee(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new ye("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let S=e.slice(n+a).trimStart(),j=r.trim();if(!S.startsWith("=")&&(j===""||j.split(/\s+/).every((O)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(O))))return j;throw new ye("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new ye(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=ee(u);if(f==="style")Jc(r,l.name);if(l.quote===null)u=Kc(u);let v=tr(f);if(v&&l.valuePrefix.trim()===""&&_s(r,v))return vi+u;return Si($i(e,n),r,u)}function Ln(e,n){let r=` ${e}="`;return ce(r,r.length,n,!0)}function xo(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Me(e,n){let{scripts:r}=re(e);for(let i of xo(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||Ol.test(i))return!0;if(es(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function om(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(ie(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let v=1,S=e.length;for(let j=f.exec(e);j;j=f.exec(e)){if(j[2]==="/")continue;if(v+=j[1]==="/"?-1:1,v===0){S=j.index+j[0].length;break}}n.push({start:i.index,end:S,names:l})}return n}function Ai(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function Ti(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let S=0;S<i.length;S++){let j=i[S];if(!l&&j==="`"){l=!0,u=0;continue}if(l){if(j==="`"&&u===0){l=!1;continue}if(j==="$"&&i[S+1]==="{"){u++,S++,a+=" ";continue}if(j==="}"&&u>0){u--;continue}if(u>0){a+=j;continue}continue}a+=j}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,v;while((v=f.exec(i))!==null){let S=v[1];if(!i.substring(0,v.index).trimEnd().endsWith(".")){if(!r.includes(S)&&!(S in n))return!1}}return!0}function Gc(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function Yc(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var Ii=new Set;function Oi(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Qc(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
217
+ `,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function Pi(e,n){let r=`${n??"<unknown>"}\x00${e}`;if(process.env.STX_DEBUG||!Ii.has(r))Ii.add(r),console.warn(`[stx] {{ ${e} }} in a <script> in ${n??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function Zi(e,n,r){let i=e;return i=i.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>{try{let u=M(l,n);if(u===void 0)return Oi(l)?Pi(l.trim(),r):a;return u===null?"":String(u)}catch{return a}}),i=Dn(i,(a,l,u)=>{let f=l.trim();if(Qc(i,u,l))return a;if(/^__[A-Z_]+__$/.test(f))return a;try{let v=M(l,n);if(v===void 0)return Oi(f)?Pi(f,r):a;return JSON.stringify(v).replace(/</g,"\\u003c").replace(/@/g,"\\u0040").replace(/\{{2,}/g,(S)=>"\\u007b".repeat(S.length)).replace(/\{(?=!)/g,"\\u007b")}catch{return a}}),i}function im(e,n){if(!e.includes("{"))return e;let r=e;return r=r.replace(/\{!!([\s\S]*?)!!\}/g,(i,a)=>{try{let l=M(a,n);if(l===void 0)return i;return l===null?"":String(l)}catch{return i}}),r=Dn(r,(i,a,l)=>{let u=a.trim();if(/^__[A-Z_]+__$/.test(u))return i;try{let f=M(a,n);if(f===void 0)return i;if(f===null)return"";let v=String(f);return ce(r,l,v,!0,i.length)}catch(f){if(f instanceof ye)throw f;return i}}),r}function Hy(e,n,r={}){let{output:i,scripts:a}=re(e),l=a.map((u)=>{let f=u.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i),v=u.search(/<\/script\s*>$/i);if(!f||v===-1)return u;let S=f[1],j=u.slice(f[0].length,v);if(/\bdata-raw\b/.test(S))return u;if(r.skipServer&&/\bserver\b/.test(S))return u;let H=`<script${im(S,n)}>`;if(/\bsrc\s*=/.test(S)||/\btype\s*=\s*["']application\/json["']/.test(S))return H+j+u.slice(v);return H+Zi(j,n)+u.slice(v)});return Hn(i,l)}function*wo(e,n,r,i){let a=e,l=(N,Y)=>{let J=tn(N,Y);if(J===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(N.slice(Y,J))?-1:J},u=(N,Y,J,te)=>{let K=J.length,{output:q,tokens:oe}=ve(N,Y,(le,ue)=>te(K+ue));return J.push(...oe),q},f=[];a=u(a,l,f,(N)=>`<!--__STX_STYLE_${N}__-->`);let v=[];a=u(a,U,v,(N)=>`<!--__STX_SCRIPT_EXPR_${N}__-->`);let S=n?.__stx_signals_gate===!0||Me(e),j=new Set([...Array.isArray(n?.__stx_client_signal_names)?n.__stx_client_signal_names:[],...Ji(xo(v))]),O=new Set(Array.isArray(n?.__stx_preserved_client_expressions)?n.__stx_preserved_client_expressions:[]);a=Dn(a,(N,Y,J)=>{if(F(Y,j))return N;try{let te=M(Y,n,!1,(K)=>nr(K,N,r,e));return te!==void 0&&te!==null?String(te):""}catch(te){let K=te instanceof Error?te.message:String(te);return w("Expression",`Error evaluating: {{{ ${Y.trim()}}}}: ${K}`,r,e,J,N)}},3),a=a.replace(/\{!!([\s\S]*?)!!\}/g,(N,Y,J)=>{if(F(Y,j))return N;try{let te=M(Y,n,!1,(K)=>nr(K,N,r,e));if(te===void 0&&n.__stx_buildMode==="compile")return bs("raw",Y.trim());return te!==void 0&&te!==null?String(te):""}catch(te){if(n.__stx_buildMode==="compile")return bs("raw",Y.trim());let K=te instanceof Error?te.message:String(te);return w("Expression",`Error evaluating: {!! ${Y.trim()} !!}: ${K}`,r,e,J,N)}}),a=u(a,U,v,(N)=>`<!--__STX_SCRIPT_EXPR_${N}__-->`),a=u(a,l,f,(N)=>`<!--__STX_STYLE_${N}__-->`);let H=S?om(a):[],D=$s(a).map((N)=>({...N,names:new Set(ie(`${N.binding} in __slot`))})),W=new Set(ht(n));if(a=yield*Ni(a,(N,Y,J)=>{let te=Y.trim();if(Zc(a,J,Y))return N;if(Ai(D,J,te))return N;if(F(te,W))return N;if(H.length>0&&Ai(H,J,te))return N;if(O.has(te))return N;let K=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],q=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,le=te.match(q)?.[1],ue=le&&((le in n)||K.includes(le)),fe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,Re=te.match(fe),Ae=Re&&!K.includes(Re[1])&&!(Re[1]in n);if(/^__[A-Z_]+__$/.test(te))return"";if(F(te,j))return N;if(n.__stx_native_screen===!0&&Gc(te,n))return N;let _e;try{let de=M(Y,n,!1,(Ve)=>{_e=Ve});if(S&&!Ti(te,n))return N;if(_e)nr(_e,N,r,e);if(n.__stx_buildMode==="compile"&&!S&&(de===void 0||Yc(te,n)))return bs("expr",te);if(de===void 0||de===null)return"";let We=String(de);return ce(a,J,We,!1,N.length)}catch(de){if(de instanceof ye)throw de;if(S&&!Ti(te,n))return N;if(Ae)return N;let We=de instanceof Error?de.message:String(de);return w("Expression",`Error evaluating: {{ ${te} }}: ${We}`,r,e,J,N)}},2,i),v.length>0)a=a.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(N,Y)=>v[Number(Y)]??N);if(f.length>0)a=a.replace(/<!--__STX_STYLE_(\d+)__-->/g,(N,Y)=>f[Number(Y)]??N);return a}function I(e,n,r){return Mi(wo(e,n,r,Number.POSITIVE_INFINITY))}var el=100;async function Qi(e,n,r,i=el){let a=wo(e,n,r,i),l=a.next();while(!l.done)await A(),l=a.next();return l.value}function am(e,n,r){if(!n.trim())return e;let i=e,a=n.trim();while(a.length>0){let l=a.match(/^(\w+)/);if(!l)break;let u=l[1];a=a.substring(u.length).trim();let f=Wn[u]||ho[u];if(!f)throw Error(`Filter not found: ${u}. Available filters: ${Object.keys(sm()).join(", ")}`);let v=[];if(a.startsWith(":")){let S=a.match(/^:([^|\s]+)/);if(S){let j=S[1].trim();try{let O=Number(j);v=[Number.isNaN(O)?j:O]}catch{v=[j]}a=a.substring(S[0].length).trim()}}else if(a.startsWith("(")){let S=1,j=1;while(S>0&&j<a.length){if(a[j]==="(")S++;if(a[j]===")")S--;j++}if(S===0){let O=a.substring(1,j-1).trim();if(O)try{if(O.startsWith("{")&&O.endsWith("}"))v=[M(`(${O})`,r,!0)];else{let H=[],D="",W=null,N=0,Y=0,J=0,te=!1;for(let K=0;K<O.length;K++){let q=O[K];if(te){D+=q,te=!1;continue}if(q==="\\"){D+=q,te=!0;continue}if(W){if(D+=q,q===W)W=null;continue}if(q==='"'||q==="'"||q==="`"){W=q,D+=q;continue}if(q==="(")N++;else if(q===")")N--;else if(q==="[")Y++;else if(q==="]")Y--;else if(q==="{")J++;else if(q==="}")J--;if(q===","&&N===0&&Y===0&&J===0){H.push(D),D="";continue}D+=q}if(D)H.push(D);v=H.map((K)=>{let q=K.trim();return M(q,r,!0)})}}catch{v=[O]}a=a.substring(j).trim()}}try{i=f(i,r,...v)}catch(S){let j=S instanceof Error?S.message:String(S);throw Error(`Error applying filter '${u}': ${j}`)}if(a.startsWith("|"))a=a.substring(1).trim();else break}return i}function tl(e){let n=!1,r="",i=0,a=0,l=0,u=!1;for(let f=0;f<e.length;f++){let v=e[f],S=e[f+1];if(n&&u){u=!1;continue}if(n&&v==="\\"){u=!0;continue}if(u=!1,(v==='"'||v==="'"||v==="`")&&!u){if(!n)n=!0,r=v;else if(v===r)n=!1,r="";continue}if(n&&r==="`"&&v==="$"&&S==="{"){let j=1;f+=2;while(f<e.length&&j>0){if(e[f]==="{")j++;else if(e[f]==="}")j--;if(j>0)f++}continue}if(n)continue;if(v==="(")i++;else if(v===")")i--;else if(v==="[")a++;else if(v==="]")a--;else if(v==="{")l++;else if(v==="}")l--;if(v==="|"&&i===0&&a===0&&l===0){if(S==="|"){f++;continue}if(S==="="){f++;continue}return f}}return-1}var zn=new Set,nl=1000;function Uy(){zn.clear()}function nr(e,n,r,i){if(!se())return;let a=`${r}\x00${e.expression}`;if(zn.has(a))return;if(zn.size>=nl)zn.clear();zn.add(a);let l=r,u=i;try{if(r&&Ci.existsSync(r))u=Ci.readFileSync(r,"utf8")}catch{}let f=u.indexOf(n);if(f>=0)l=`${r}:${u.slice(0,f).split(`
218
+ `).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function M(e,n,r=!1,i){try{let a=e.trim(),l=tl(a);if(l>0){let f=a.substring(0,l).trim(),v=a.substring(l+1).trim(),S=M(f,n,!0,i);return am(S,v,n)}let u=bo(a);if(u!==null){i?.({expression:a,rule:u});return}try{let f=Object.keys(n),v=Object.values(n);return p(a,f)(...v)}catch{return d(a,n)}}catch(a){if(a instanceof ReferenceError){let l=/(\b\w+)\s+is not defined/.exec(a.message);if(l){let u=l[1],f=sl(u,Object.keys(n));if(f&&f!==u)a.message=`${a.message} \u2014 did you mean '${f}'?`}}if(!r)console.error(`Error evaluating expression: ${e}`,a);throw a}}function sl(e,n){let r=null;for(let a of n){if(a===e)continue;let l=rl(e,a);if(r===null||l<r.dist)r={key:a,dist:l}}if(!r)return null;let i=Math.max(e.length,r.key.length);if(r.dist<=2||r.dist/i<=0.35)return r.key;return null}function rl(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let[r,i]=e.length<n.length?[e,n]:[n,e],a=Array(r.length+1),l=Array(r.length+1);for(let u=0;u<=r.length;u++)a[u]=u;for(let u=1;u<=i.length;u++){l[0]=u;for(let f=1;f<=r.length;f++){let v=r[f-1]===i[u-1]?0:1;l[f]=Math.min(l[f-1]+1,a[f]+1,a[f-1]+v)}for(let f=0;f<=r.length;f++)a[f]=l[f]}return a[r.length]}function Vy(e){if(!e)return"";return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}import il from"process";function P(e="STX_PUBLIC_"){let n={},r={};for(let[i,a]of Object.entries(il.env)){if(!i.startsWith(e)||a===void 0)continue;n[`import.meta.env.${i}`]=JSON.stringify(a),r[i]=a}return n["import.meta.env"]=JSON.stringify(r),n}function vo(e,n=""){let r=`${e}${n}`,i=0;for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);i=(i<<5)-i+l,i=i&i}return`stx-${Math.abs(i).toString(36)}`}function $o(e,n,r={}){let{prefix:i="",preserveHost:a=!0,scopeKeyframes:l=!0,scopeCustomProperties:u=!1}=r;if(!e.trim())return"";let f=sr(e),v=[],S=new Map;if(l)for(let j of f){let O=j.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(O){let H=O[1],D=`${n}_${H}`;S.set(H,D)}}for(let j of f){let O=So(j,n,i,a,S,u);v.push(O)}return v.join(`
219
+
220
+ `)}function sr(e){let n=[],r=e.replace(/\/\*[\s\S]*?\*\//g,""),i=0,a="",l=!1,u="";for(let f=0;f<r.length;f++){let v=r[f];if(v==="@"&&i===0)l=!0;if(v==="{")i++;else if(v==="}"){if(i--,i===0){if(l){u+=v;let S=u.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(S){let[,j,O,H]=S;if(j==="keyframes")n.push({selector:`@keyframes ${O.trim()}`,declarations:H.trim()});else if(j==="media"||j==="supports"||j==="container"){let D=sr(H);n.push({selector:`@${j} ${O.trim()}`,declarations:D.map((W)=>`${W.selector} { ${W.declarations} }`).join(`
221
+ `)})}else n.push({selector:`@${j} ${O.trim()}`,declarations:H.trim()})}u="",l=!1}else if(a.trim()){a+=v;let S=a.match(/([^{]+)\{([^}]*)\}/);if(S)n.push({selector:S[1].trim(),declarations:S[2].trim()});a=""}continue}}if(l)u+=v;else a+=v}return n}function So(e,n,r,i,a,l){let{selector:u,declarations:f}=e;if(u.startsWith("@")){if(u.startsWith("@keyframes")){let j=u.replace("@keyframes ","").trim();return`@keyframes ${a.get(j)||j} { ${f} }`}if(u.startsWith("@media")||u.startsWith("@supports")||u.startsWith("@container")){let O=sr(`x { ${f} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((H)=>So(H,n,r,i,a,l)).join(`
222
+ `);return`${u} {
223
+ ${O}
224
+ }`}return`${u} { ${f} }`}let v=ol(u,n,r,i),S=f;for(let[j,O]of a)S=S.replace(new RegExp(`\\b${j}\\b`,"g"),O);if(l)S=S.replace(/--([a-z-]+)/gi,`--${n}-$1`);return`${v} { ${S} }`}function ol(e,n,r,i){let a=e.split(",").map((u)=>u.trim()),l=[];for(let u of a){if(u.startsWith(":host")){if(i)l.push(u);else{let S=u.replace(/:host(\([^)]*\))?/,`.${n}$1`);l.push(S)}continue}if(u.includes("::slotted")){l.push(u);continue}if(u===":root"){l.push(`:root .${n}`);continue}let f=r?`${r} .${n}`:`.${n}`;l.push(`${f} ${u}`);let v=al(u,n);if(v)l.push(r?`${r} ${v}`:v)}return l.join(", ")}function al(e,n){let r=0,i=e.length;for(let v=0;v<e.length;v++){let S=e[v];if(S==="["||S==="(")r++;else if(S==="]"||S===")")r--;else if(r===0&&(S===" "||S===">"||S==="+"||S==="~")){i=v;break}}let a=e.slice(0,i),l=e.slice(i);if(!a)return"";let u=a.length,f=0;for(let v=0;v<a.length;v++){let S=a[v];if(S==="["||S==="(")f++;else if(S==="]"||S===")")f--;else if(r===0&&f===0&&S===":"){u=v;break}}return`${a.slice(0,u)}.${n}${a.slice(u)}${l}`}var Ao=String.raw`(?<![\w-])scoped(?![\w-])`,rr=/<style\s+([^>]*)>/gi,Eo=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,To=new RegExp(Ao,"i"),cl=new RegExp(Ao,"gi"),ir=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function ll(e){rr.lastIndex=0;let n=rr.exec(e);while(n!==null){if(To.test(n[1]))return!0;n=rr.exec(e)}return!1}function Wi(e){let n=new Set,r=[];ir.lastIndex=0;let i=ir.exec(e);while(i!==null){let a=i[0].trim();if(n.has(a))r.push({start:i.index,end:i.index+i[0].length});else n.add(a);i=ir.exec(e)}return r}function Pn(e){let n=Wi(e);if(n.length===0)return e;let r=Array(n.length+1),i=0;for(let a=0;a<n.length;a++){let l=n[a];r[a]=e.slice(i,l.start),i=l.end}return r[n.length]=e.slice(i),r.join("")}function lo(e,n){if(!ll(e))return{html:e,hasScoped:!1};let r=vo(n),i=`data-v-${r}`,a=e,l=!1;if(Eo.lastIndex=0,a=a.replace(Eo,(u,f,v)=>{if(!To.test(f))return u;l=!0;let S=ul(v,i),j=f.replace(cl,"").trim(),O=j?` ${j}`:"";return`<style data-stx-scoped="${r}"${O}>${S}</style>`}),!l)return{html:e,hasScoped:!1};return a=Bl(a,i),{html:a,hasScoped:!0}}function ul(e,n){return $o(e,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${n}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${n}]`)}var jl=(e)=>`\x00stx-scope-mask-${e}\x00`,Ro=/\u0000stx-scope-mask-(\d+)\u0000/g;function Bl(e,n){let r=ve(e,(a,l)=>{let u=U(a,l);return u>l?u:tn(a,l)},(a,l)=>jl(l)),i=Wl(r.output,n);return Ro.lastIndex=0,i.replace(Ro,(a,l)=>r.tokens[Number(l)])}function Wl(e,n){let r=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return e.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(i,a,l)=>{if(r.has(a.toLowerCase()))return i;if(i.includes(n))return i;if(a.toLowerCase()==="style"||a.toLowerCase()==="script")return i;if(l)return i.replace(`<${a}${l}`,`<${a} ${n}${l}`);if(i.endsWith("/>"))return`<${a} ${n} />`;return`<${a} ${n}>`})}var Vn=/<\/?template\b[^>]*>/gi,Vl=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function Fl(e){let n=e.replace(/^<template\b/i,"").replace(/>$/,"");return Vl.test(n)}function B(e){Vn.lastIndex=0;let n;while((n=Vn.exec(e))!==null){if(n[0].startsWith("</")||Fl(n[0]))continue;let r=n.index,i=Vn.lastIndex,a=1,l;while((l=Vn.exec(e))!==null)if(l[0].startsWith("</")){if(a--,a===0){let u=l.index;return{start:r,openEnd:i,closeStart:u,end:Vn.lastIndex,content:e.slice(i,u)}}}else a++;return null}return null}var Ul=0,Hl=0;function Ss(e,n){let r=/(?:^|\s)([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;for(let i of e.matchAll(r))if(i[1].toLowerCase()===n.toLowerCase())return i[2]??i[3]??i[4]??null;return null}function jo(e){let n=[],r=/<([a-z][a-z0-9-]*)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/iy;return g(e,(i,a)=>{r.lastIndex=a;let l=r.exec(i);if(!l||!Ss(l[2],"x-data"))return-1;return n.push({fullMatch:l[0],tagName:l[1],attributes:l[2],startIndex:a,endIndex:r.lastIndex}),r.lastIndex}),n}function Kl(e){let n=[];for(let{fullMatch:r,tagName:i,attributes:a,startIndex:l}of jo(e)){let u=Ss(a,"x-data");if(!u)continue;let f=`__stx_scope_${Ul++}`,v=Ss(a,"x-init"),S=ql(e,i,l+r.length),j=e.slice(l,S.endIndex),O=Jl(j);n.push({id:f,selector:`[data-stx-scope="${f}"]`,stateExpr:u,initExpr:v,bindings:[],refs:O})}return n}function ql(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s|>)`,"gi"),u=new RegExp(`</${n}>`,"gi"),f=new RegExp(`<${n}[^>]*/\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a,f.lastIndex=a;let v=l.exec(e),S=u.exec(e),j=f.exec(e);if(j&&j.index<(v?.index??1/0)){a=j.index+j[0].length;continue}if(!S)return{endIndex:e.length};if(v&&v.index<S.index)i++,a=v.index+v[0].length;else{if(i--,i===0)return{endIndex:S.index+S[0].length};a=S.index+S[0].length}}return{endIndex:e.length}}function Jl(e){let n=new Map,r=e.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,a;while((a=i.exec(r))!==null){let[,l,u]=a,f=Gl(l);n.set(u,f)}return n}function Gl(e){let n=e.match(/\bid\s*=\s*["']([^"']*)["']/);if(n)return n[1];return`__stx_el_${Hl++}`}function Ql(){return`
225
+ // STX Reactive Runtime - x-cloak and transition CSS
226
+ (function() {
227
+ var style = document.createElement('style');
228
+ style.textContent = [
229
+ '[x-cloak] { display: none !important; }',
230
+ // Default transition classes
231
+ '.stx-enter { opacity: 0; transform: scale(0.95); }',
232
+ '.stx-enter-start { opacity: 0; transform: scale(0.95); }',
233
+ '.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
234
+ '.stx-enter-to { opacity: 1; transform: scale(1); }',
235
+ '.stx-leave { opacity: 1; transform: scale(1); }',
236
+ '.stx-leave-start { opacity: 1; transform: scale(1); }',
237
+ '.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
238
+ '.stx-leave-to { opacity: 0; transform: scale(0.95); }'
239
+ ].join('\\n');
240
+ document.head.appendChild(style);
241
+ })();
242
+
243
+ // STX Reactive Runtime
244
+ /* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
245
+ window.__stx_reactive = (function() {
246
+ 'use strict';
247
+
248
+ // Deep reactive proxy that triggers onChange for any mutation
249
+ function reactive(obj, onChange) {
250
+ if (!obj || typeof obj !== 'object') return obj;
251
+ return new Proxy(obj, {
252
+ get(target, prop) {
253
+ const value = target[prop];
254
+ if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
255
+ return reactive(value, onChange);
256
+ }
257
+ return value;
258
+ },
259
+ set(target, prop, value) {
260
+ target[prop] = value;
261
+ onChange(prop, value);
262
+ return true;
263
+ }
264
+ });
265
+ }
266
+
267
+ // Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
268
+ // then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
269
+ function initScope(scopeEl, initialState, bindings, refs, initExpr, deferInit) {
270
+ // Parse initial state (may contain methods including async init())
271
+ var state;
272
+ try {
273
+ state = new Function('return (' + initialState + ')')();
274
+ } catch (e) {
275
+ console.error('[stx-reactive] Invalid x-data:', initialState, e);
276
+ return;
277
+ }
278
+
279
+ // Build $refs object
280
+ var $refs = {};
281
+ for (var name in refs) {
282
+ if (Object.prototype.hasOwnProperty.call(refs, name)) {
283
+ (function(refName, refId) {
284
+ Object.defineProperty($refs, refName, {
285
+ get: function() { return document.getElementById(refId); }
286
+ });
287
+ })(name, refs[name]);
288
+ }
289
+ }
290
+
291
+ // Extract init method from state if present (Alpine.js convention)
292
+ var initMethod = state.init;
293
+ if (typeof initMethod === 'function') {
294
+ delete state.init;
295
+ }
296
+
297
+ // Make state reactive \u2014 mutations trigger re-render via signals
298
+ var scopeId = scopeEl.getAttribute('data-stx-scope');
299
+ var stx = window.stx;
300
+
301
+ // Create signals for each state property so the signals runtime can track dependencies
302
+ var signalState = {};
303
+ var rawState = {};
304
+ var derivedState = {};
305
+ var accessors = {};
306
+ // A getter must NOT be read here. Reading one calls it, and the old loop did
307
+ // exactly that: the returned value is not a function, so it was wrapped as a
308
+ // plain state() -- a snapshot of the answer at construction time, frozen
309
+ // forever while plain properties beside it updated (#2053). A getter is a
310
+ // derived value, so it is registered as one below, once ctxProxy exists for
311
+ // it to read through.
312
+ var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
313
+ for (var key in state) {
314
+ if (Object.prototype.hasOwnProperty.call(state, key)) {
315
+ var descriptor = ownDescriptors[key];
316
+ if (descriptor && typeof descriptor.get === 'function') {
317
+ accessors[key] = descriptor;
318
+ continue;
319
+ }
320
+ if (typeof state[key] === 'function') {
321
+ // Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
322
+ signalState[key] = state[key];
323
+ } else {
324
+ // Data properties \u2014 wrap in signals for reactivity
325
+ signalState[key] = stx.state(state[key]);
326
+ rawState[key] = true;
327
+ }
328
+ }
329
+ }
330
+
331
+ // Create a proxy context that auto-unwraps signals and writes back through them.
332
+ // Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
333
+ var ctx = {};
334
+ var ctxProxy = new Proxy(ctx, {
335
+ get: function(target, prop) {
336
+ if (prop === '$refs') return $refs;
337
+ if (prop === '$el') return scopeEl;
338
+ if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
339
+ if (prop === Symbol.unscopables) return undefined;
340
+ if (!(prop in signalState)) {
341
+ var owner = stx._scopeForBinding(scopeEl, prop);
342
+ return owner ? owner[prop] : undefined;
343
+ }
344
+ var s = signalState[prop];
345
+ if (!s) return undefined;
346
+ if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
347
+ return s.value; // unwrap signal
348
+ }
349
+ if (typeof s === 'function' && !rawState[prop]) {
350
+ return s.bind(ctxProxy); // bind methods to proxy
351
+ }
352
+ return s;
353
+ },
354
+ set: function(target, prop, value) {
355
+ var accessor = derivedState[prop];
356
+ if (accessor) {
357
+ // A getter/setter pair writes through its setter. A getter alone has
358
+ // nowhere to put the value: a derived has no .value setter, so the
359
+ // assignment would be a silent no-op, which is the same class of
360
+ // failure as the stale read this replaces.
361
+ if (typeof accessor.set === 'function') {
362
+ accessor.set.call(ctxProxy, value);
363
+ return true;
364
+ }
365
+ console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
366
+ return true;
367
+ }
368
+ var s = signalState[prop];
369
+ if (rawState[prop] && s && typeof s === 'function') {
370
+ s.value = value; // write through signal \u2014 triggers effects
371
+ } else {
372
+ signalState[prop] = value;
373
+ }
374
+ return true;
375
+ },
376
+ has: function(target, prop) {
377
+ return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick' || !!stx._scopeForBinding(scopeEl, prop);
378
+ },
379
+ ownKeys: function() {
380
+ return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
381
+ },
382
+ getOwnPropertyDescriptor: function(target, prop) {
383
+ if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
384
+ return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
385
+ }
386
+ return undefined;
387
+ }
388
+ });
389
+
390
+ // Now that ctxProxy exists, a getter becomes a derived that reads through it,
391
+ // so it tracks whatever it touches and recomputes when that changes. derived()
392
+ // is lazy, so nothing is evaluated until a binding actually reads it.
393
+ //
394
+ // Marked rawState as well: that is what makes the proxy unwrap it and what
395
+ // exposes the signal itself to the runtime below, which is where dependency
396
+ // tracking comes from. A getter needs both, exactly like a data property.
397
+ for (var accessorKey in accessors) {
398
+ if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
399
+ (function(name, descriptor) {
400
+ signalState[name] = stx.derived(function() {
401
+ return descriptor.get.call(ctxProxy);
402
+ });
403
+ rawState[name] = true;
404
+ derivedState[name] = descriptor;
405
+ })(accessorKey, accessors[accessorKey]);
406
+ }
407
+ }
408
+
409
+ // Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
410
+ // We need to provide getter/setter descriptors so signals track properly.
411
+ var scopeVars = {};
412
+ for (var k in signalState) {
413
+ if (Object.prototype.hasOwnProperty.call(signalState, k)) {
414
+ if (rawState[k]) {
415
+ // Data: expose the signal directly so expressions trigger dependency tracking
416
+ scopeVars[k] = signalState[k];
417
+ } else {
418
+ // Method: bind to ctxProxy so 'this' works
419
+ scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
420
+ }
421
+ }
422
+ }
423
+ scopeVars.$refs = $refs;
424
+ scopeVars.$el = scopeEl;
425
+ scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
426
+
427
+ // Register scope \u2014 merge with any existing vars from partial signal scripts
428
+ if (!stx._scopes) stx._scopes = {};
429
+ var registered = stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
430
+ registered.__el = scopeEl;
431
+
432
+ // Store on element for findElementScope
433
+ scopeEl.__stx_scope = scopeVars;
434
+
435
+ // Run init() if present (supports async)
436
+ function runInit() {
437
+ var maybePromise;
438
+ if (initMethod) {
439
+ maybePromise = initMethod.call(ctxProxy);
440
+ }
441
+ if (initExpr) {
442
+ try {
443
+ var fn = new Function('with(this){' + initExpr + ';}');
444
+ var result = fn.call(ctxProxy);
445
+ if (result && typeof result.then === 'function') maybePromise = result;
446
+ } catch (e) {
447
+ console.warn('[stx-reactive] init expression error:', e);
448
+ }
449
+ }
450
+ // If init is async, signal updates will trigger effects automatically
451
+ // when init() resolves and sets this.prop = value (writes through signal)
452
+ if (maybePromise && typeof maybePromise.then === 'function') {
453
+ maybePromise.catch(function(e) {
454
+ console.error('[stx-reactive] async init() error:', e);
455
+ });
456
+ }
457
+ }
458
+
459
+ // A component's helper setup follows its markup. Its own mount queue
460
+ // starts the initializer after all component factories have registered.
461
+ // Standalone x-data retains synchronous initialization.
462
+ if (deferInit) {
463
+ registered.__mountCallbacks = registered.__mountCallbacks || [];
464
+ registered.__mountCallbacks.push(runInit);
465
+ } else {
466
+ runInit();
467
+ }
468
+ var destroyExpr = scopeEl.getAttribute('data-stx-xdestroy') || scopeEl.getAttribute('x-destroy');
469
+ if (destroyExpr) {
470
+ registered.__destroyCallbacks = registered.__destroyCallbacks || [];
471
+ var teardown = function() { scopeEl.__stx_execute(destroyExpr); };
472
+ registered.__destroyCallbacks.push(teardown);
473
+ registered.__destroyHooks = registered.__destroyHooks || [];
474
+ registered.__destroyHooks.push(teardown);
475
+ }
476
+
477
+ // Expose for debugging
478
+ scopeEl.__stx_state = ctxProxy;
479
+ scopeEl.__stx_execute = function(stmt, $event, $el) {
480
+ try {
481
+ // Run the statement with the reactive proxy as the lexical scope.
482
+ // Wrapping in a with-block on the proxy makes bare reads/writes go
483
+ // through it (so foo = bar triggers signal.set()) instead of treating
484
+ // each state key as a local function parameter \u2014 bare assignments
485
+ // would otherwise just rebind the local and never reach the signal.
486
+ var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
487
+ fn.call(ctxProxy, $event, $el);
488
+ } catch (e) {
489
+ console.warn('[stx-reactive] execute error:', e);
490
+ }
491
+ };
492
+ }
493
+
494
+ return { initScope: initScope, reactive: reactive };
495
+ })();
496
+ `}function Io(e,n){let r=e.replace(/\{!!([\s\S]*?)!!\}/g,(f,v)=>{try{let S=M(v,n,!0);if(S===void 0)return f;return String(S)}catch{return f}}),i="",a=0,l=null;while(a<r.length){let f=r[a];if(l&&f==="\\"){i+=f+(r[a+1]??""),a+=2;continue}if(f==="{"&&r[a+1]==="{"){let v=r.indexOf("}}",a+2);if(v!==-1){let S=r.slice(a,v+2);i+=u(r.slice(a+2,v),S,l),a=v+2;continue}}if(l){if(f===l)l=null}else if(f==="'"||f==='"'||f==="`")l=f;i+=f,a++}return i;function u(f,v,S){let j;try{j=M(f,n,!0)}catch{return v}if(j===void 0)return v;if(S){let O=String(j).replace(/\\/g,"\\\\").replace(new RegExp(S==="`"?"`":S,"g"),`\\${S}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return S==="`"?O.replace(/\$\{/g,"\\${"):O}if(typeof j==="string"){let O=j.trim();if(O.startsWith("{")&&O.endsWith("}")||O.startsWith("[")&&O.endsWith("]"))try{return JSON.parse(O),O}catch{}}return JSON.stringify(j)}}function eu(e,n,r){if(e.length===0)return"";let i=e.map((a)=>{let l=JSON.stringify(Object.fromEntries(a.refs)),u=Io(a.stateExpr,n),f=a.initExpr?Io(a.initExpr,n):null,v=JSON.stringify(u),S=f?JSON.stringify(f):"null";return`
497
+ (function() {
498
+ var scopeEl = document.querySelector('${a.selector}');
499
+ if (!scopeEl) return;
500
+ var refs = ${l};
501
+ window.__stx_reactive.initScope(scopeEl, ${v}, [], refs, ${S}${r?", true":""});
502
+ })();`}).join(`
503
+ `);return`
504
+ <script data-stx-scoped data-stx-reactive data-stx-run="always">
505
+ ${Ql()}
506
+ ${i}
507
+ </script>`}function xl(e,n,r,i=!1){if(!or(e))return e;let a=Kl(e);if(a.length===0)return e;let l=tu(e,a),u=eu(a,n,i),f=c(l);if(f!==-1)l=l.slice(0,f)+u+`
508
+ `+l.slice(f);else l+=u;return l}function tu(e,n){let r=[],i=0;for(let[l,u]of jo(e).entries()){let f=n[l];if(!f)break;r.push(e.slice(i,u.startIndex));let v=Ss(u.attributes,"data-stx-scope");if(v)f.id=v,f.selector=`[data-stx-scope="${f.id}"]`,r.push(u.fullMatch);else r.push(`<${u.tagName} data-stx-scope="${f.id}"${u.attributes}>`);i=u.endIndex}r.push(e.slice(i));let a=r.join("");return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a=a.replace(/\s*x-destroy\s*=\s*"([^"]*)"/g,' data-stx-xdestroy="$1"'),a=a.replace(/\s*x-destroy\s*=\s*'([^']*)'/g," data-stx-xdestroy='$1'"),a}function or(e){return/x-data\s*=\s*["']/.test(e)}function fo(e,n){let r=e,i=/@json\s*\(/g,a;while((a=i.exec(r))!==null){let l=a.index,u=l+a[0].length-1,f=1,v=u+1,S=null,j=!1;while(v<r.length&&f>0){let K=r[v];if(j){j=!1,v++;continue}if(K==="\\"&&S){j=!0,v++;continue}if(S){if(K===S)S=null;v++;continue}if(K==='"'||K==="'"||K==="`"){S=K,v++;continue}if(K==="(")f++;else if(K===")"){if(f--,f===0)break}v++}if(f!==0)break;let O=r.substring(u+1,v).trim(),H=r.substring(l,v+1),D=-1,W=0,N=null,Y=!1;for(let K=0;K<O.length;K++){let q=O[K];if(Y){Y=!1;continue}if(q==="\\"&&N){Y=!0;continue}if(N){if(q===N)N=null;continue}if(q==='"'||q==="'"||q==="`"){N=q;continue}if(q==="("||q==="["||q==="{")W++;else if(q===")"||q==="]"||q==="}")W--;if(q===","&&W===0){D=K;break}}let J=D>=0?O.substring(0,D).trim():O,te=D>=0?O.substring(D+1).trim():void 0;try{let K=J.trim(),q;if(h(K))q=p(K,Object.keys(n))(...Object.values(n));else q=void 0;let oe;if(te==="true")oe=JSON.stringify(q,null,2);else oe=JSON.stringify(q);let le=oe.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");r=r.substring(0,l)+le+r.substring(v+1),i.lastIndex=l+le.length}catch(K){X.log(K instanceof Error?K:Error(String(K)),{directive:"@json"},"error"),i.lastIndex=l+H.length}}return r}function go(e){return e.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function kl(e){let n=e,r=/@memo\s*\(/g,i,a=[];while((i=r.exec(n))!==null){let l=i.index,u=l+i[0].length,f=1,v=u;while(v<n.length&&f>0){if(n[v]==="(")f++;else if(n[v]===")")f--;v++}if(f!==0)continue;let S=n.slice(u,v-1).trim(),j=v,O=n.slice(j),H=O.indexOf("@endmemo");if(H===-1)continue;let D=O.slice(0,H),W=j+H+8,N=vt(D),Y=D.slice(N),J=D.match(/(\s*)$/),te=J?J[0].length:0,K=Y.slice(0,Y.length-te),q=K.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),oe;if(q){let[le,ue,fe="",Re]=q,Ae=`<${ue}${fe} data-stx-memo="${S}"${Re}>`;oe=D.slice(0,N)+Ae+K.slice(le.length)+D.slice(N+K.length)}else oe=`${D.slice(0,N)}<div data-stx-memo="${S}">${K}</div>${D.slice(N+K.length)}`;a.push({start:l,end:W,replacement:oe}),r.lastIndex=W}for(let l=a.length-1;l>=0;l--){let u=a[l];n=n.slice(0,u.start)+u.replacement+n.slice(u.end)}return n.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function qi(e){let n=e.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return n=n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),n}function Do(e,n){let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=g(e,(f,v)=>{r.lastIndex=v;let S=r.exec(f);if(!S||/^(?:script|style)$/i.test(S[1]))return-1;return r.lastIndex}),a=[],l=0,u=[];for(let{start:f,end:v,token:S}of i){let j=/^<\/?([\w-]+)/.exec(S)[1].toLowerCase();if(S.startsWith("</")){while(a.length&&a.pop()!==j);continue}if(!a.length&&!/\sdata-stx-slot-owner\s*=/.test(S))u.push(e.slice(l,f),S.replace(/\s*\/?>$/,(O)=>` data-stx-slot-owner="${n}"${O}`)),l=v;if(!ar.has(j)&&!/\/>$/.test(S))a.push(j)}return u.push(e.slice(l)),u.join("")}function No(e,n){if(!/\bref\s*=/.test(e))return e;let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=g(e,(v,S)=>{r.lastIndex=S;let j=r.exec(v);if(!j||/^(?:script|style)$/i.test(j[1]))return-1;return r.lastIndex}),a=[],l=0,u=0,f=[];for(let{start:v,end:S,token:j}of i){let O=/^<\/?([\w-]+)/.exec(j)[1].toLowerCase();if(j.startsWith("</")){let N;while(N=a.pop()){if(N.scoped)l--;if(N.name===O)break}continue}let H=/\sdata-stx-scope\s*=/.test(j),D=/\sdata-stx-ref-caller\s*=\s*(["'])(.*?)\1/.exec(j),W=a.find((N)=>N.scoped)?.scopeId;if(D&&W&&D[2]===W)f.push(e.slice(u,v),j.replace(D[0],` data-stx-ref-caller="${n}"`)),u=S;else if(!l&&!H&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(j)&&!/\sdata-stx-ref-caller\s*=/.test(j))f.push(e.slice(u,v),j.replace(/\s*\/?>$/,(N)=>` data-stx-ref-caller="${n}"${N}`)),u=S;if(!ar.has(O)&&!/\/>$/.test(j)){let N=/\sdata-stx-scope\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(j);if(a.push({name:O,scoped:H,scopeId:N?.[1]??N?.[2]}),H)l++}}return f.push(e.slice(u)),f.join("")}var ar=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Lo=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,Oo=/<\/?\s*([a-z][\w-]*)/iy,nu=/\s/;function su(e,n){let r=n-1;while(r>=0&&nu.test(e[r]))r--;return r>=0&&e[r]==="/"}function ru(e,n){let r=!1,i=!1;for(let a=n;a<e.length;a++){let l=e[a];if(r){if(l==="'")r=!1}else if(i){if(l==='"')i=!1}else if(l==="'")r=!0;else if(l==='"')i=!0;else if(l===">")return a}return-1}function iu(e,n){if(e.indexOf("{",n)===-1||e.indexOf("}",n)===-1)return!1;let r=0,i=n,a=!1,l=!1,u=!1;while(i<e.length){let f=e.indexOf("<",i),v=f===-1?e.length:f;if(v>i){if(r===0)while(i<v){let O=e.indexOf(l?"}":"{",i);if(O===-1||O>=v){if(l)u=!1;else a=!1;break}if(O>i)if(l)u=!1;else a=!1;if(l){if(u)return!0;u=!0}else if(a)l=!0,u=!1;else a=!0;i=O+1}i=v;continue}if(e.startsWith("<!--",i)){let O=e.indexOf("-->",i);i=O===-1?e.length:O+3;continue}let S=ru(e,i);if(S===-1)break;Oo.lastIndex=i;let j=Oo.exec(e)?.[1]?.toLowerCase()??"";if(e[i+1]==="/"){if(r===0)break;r--}else if(!su(e,S)&&!ar.has(j))r++;i=S+1}return!1}var Po=k(256);function _l(e){if(e.length<1024)return Mo(e);let n=E(e),r=Po.get(n);if(r!==void 0)return r;let i=Mo(e);return Po.set(n,i),i}function Mo(e){if(e.length>=32768&&!zl(e))return e;let r=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),i="",a=0,l;while((l=r.exec(e))!==null){let u=l.index,f=u+l[0].length,v=!1,S=!1,j=-1;while(f<e.length){let H=e[f];if(v){if(H==="'")v=!1}else if(S){if(H==='"')S=!1}else if(H==="'")v=!0;else if(H==='"')S=!0;else if(H===">"){j=f;break}f++}if(j===-1)continue;let O=e.slice(u,j+1);if(Lo.test(O))continue;if(O.includes("x-cloak"))continue;if(iu(e,j+1))i+=e.slice(a,j)+" x-cloak>",a=j+1}return i+=e.slice(a),i}var ou=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,au=/<\/script>/gi,cu=/<\/style>/gi;function Cl(e){let n=/<[a-z][\w-]*/gi,r="",i=0,a;while((a=n.exec(e))!==null){let l=a.index,u=a[0].slice(1).toLowerCase();if(u==="script"||u==="style"){let W=u==="script"?au:cu;W.lastIndex=l;let N=W.exec(e);if(N!==null)n.lastIndex=N.index+N[0].length;continue}let f=l+a[0].length,v=!1,S=!1,j=-1;while(f<e.length){let W=e[f];if(v){if(W==="'")v=!1}else if(S){if(W==='"')S=!1}else if(W==="'")v=!0;else if(W==='"')S=!0;else if(W===">"){j=f;break}f++}if(j===-1)continue;let O=e.slice(l+a[0].length,j);if(Lo.test(O))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(O))continue;if(!ou.test(O))continue;let H=e[j-1]==="/",D=H?j-1:j;r+=`${e.slice(i,D)} x-cloak${H?" ":""}`,i=D}return r+=e.slice(i),r}function R(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function xt(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}import fa from"path";import cr from"fs";import Un from"path";function zo(e,n,r,i){let a=0;for(let l=n;l<e.length;l++)if(e[l]===r)a++;else if(e[l]===i&&!(i===">"&&e[l-1]==="=")){if(--a===0)return l}return-1}function lu(e){let n=t(e),r=0,i=0,a=[];for(let l=0;l<n.length;l++)if("([{".includes(n[l]))r++;else if(")]}".includes(n[l]))r--;else if(n[l]===","&&r===0)a.push(e.slice(i,l).trim()),i=l+1;return a.push(e.slice(i).trim()),a}function Fn(e,n,r=!1){let i=t(e),a=new RegExp(`\\b(?:${n.map((u)=>u.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),l=r?y(i).depths:void 0;for(let u of i.matchAll(a)){if(l&&l[u.index]!==0)continue;let f=u.index+u[0].length,v="";if(i[f]==="<"){let j=zo(i,f,"<",">");if(j<0)continue;v=e.slice(f+1,j),f=j+1;while(/\s/.test(i[f]||"")&&f<i.length)f++}if(i[f]!=="(")continue;let S=zo(i,f,"(",")");if(S>=0)return{type:v,args:lu(e.slice(f+1,S)),start:u.index,end:S+1}}return null}var Es=`
509
+ type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
510
+ type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
511
+ type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
512
+ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
513
+ type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
514
+ type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
515
+ type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
516
+ `;function ks(e,n){let r=[],i={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},a=t(e),l=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(H,D,W,N,Y)=>{if(a.slice(Y,Y+6)!=="import")return H;if(N.endsWith(".stx"))return"";let J=`${n}Import${r.length}`;if(r.push(`import * as ${J} from ${JSON.stringify(N)};`),D.startsWith("*"))return`import ${D.replace(/^\*\s+as\s+/,"")} = ${J};`;if(!D.startsWith("{"))return`import ${D} = ${J}.default;`;return D.slice(1,-1).split(",").map((te)=>{let[K,q=K]=te.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!K)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(N)&&K in i)i[K].push(q);return`import ${q} = ${J}.${K};`}).join(`
517
+ `)}),u=Fn(e,i.defineProps),f=Fn(e,i.defineEmits),v=Fn(e,i.withDefaults);if(!u&&!f)return{declarations:"",props:null,events:null};let S=[],j=null,O=null;if(u){S.push(`const __options = (${u.args[0]||"{}"}) as const;`),S.push(`const __defaults = (${v?.args[1]||"{}"});`);let H=u.type||"__StxOptions<typeof __options>";S.push(`export type __StxProps = __StxDefaults<${H}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),j=`${n}.__StxProps`}if(f)S.push(`const __events = (${f.args[0]||"[]"}) as const;`),S.push(`export type __StxEvents = ${f.type||"Record<(typeof __events)[number], any[]>"};`),O=`${n}.__StxEvents`;return{declarations:`${r.join(`
518
+ `)}
519
+ namespace ${n} {
520
+ ${l}
521
+ ${S.join(`
522
+ `)}
523
+ }`,props:j,events:O}}var Hr=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Ur(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Hr].some((n)=>n.toLowerCase()===e.toLowerCase());return Hr.has(e)||/[A-Z]/.test(e)}function*uu(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let i=n.lastIndex,a=[];while(i<e.length){while(/\s/.test(e[i]||""))i++;if(e[i]===">"||e.slice(i,i+2)==="/>"){i+=e[i]===">"?1:2;break}let l=/^[^\s=/>]+/.exec(e.slice(i))?.[0];if(!l){i++;continue}let u=i;i+=l.length;while(/\s/.test(e[i]||""))i++;if(e[i]!=="="){a.push({name:l,value:!0,offset:u,braced:!1});continue}i++;while(/\s/.test(e[i]||""))i++;let f=e[i],v=f==="{",S=f==='"'||f==="'";if(S||v)i++;let j=i;if(v){let O=t(e.slice(i)),H=1,D=0;for(;D<O.length;D++){if(O[D]==="{")H++;if(O[D]==="}"&&--H===0)break}i+=D}else if(S)while(i<e.length&&e[i]!==f)i++;else while(i<e.length&&!/[\s/>]/.test(e[i]))i++;if(a.push({name:l,value:e.slice(j,i),offset:j,braced:v}),S||v)i++}n.lastIndex=i,yield{name:r[1],offset:r.index,attributes:a}}}function Bo(e,n,r){let i=[],a=[Es,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],l=new Map,u=new Map,f=new Map,v=r.scriptCode(e,r.filePath),S=t(v);for(let W of v.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(S.slice(W.index,W.index+6)!=="import")continue;let N=W[2],Y=Un.isAbsolute(N)||N.startsWith(".")?Un.resolve(Un.dirname(r.filePath),N):eo(N,Un.dirname(r.filePath));if(!Y)continue;let J=Y.endsWith(".stx")?Y:cr.existsSync(`${Y}.stx`)?`${Y}.stx`:void 0,te=J?null:jr(Y,!1),K=W[1].startsWith("{")?W[1].slice(1,-1).split(","):[W[1]];for(let q of K){let[oe,le=oe]=q.trim().split(/\s+as\s+/),ue=J||te?.get(oe)||te?.get(oe.toLowerCase());if(ue)f.set(le,ue),f.set(le.toLowerCase(),ue),f.set(le.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ue)}}for(let W of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let N of W[1].matchAll(/['"]([^'"]+)['"]/g)){let Y=to(N[1],r.filePath,r).find((J)=>cr.statSync(J,{throwIfNoEntry:!1})?.isFile());if(Y)f.set(Un.basename(N[1]).replace(/\.stx$/,""),Y)}let j={__importedComponents:f},O=new Map,H=(W,N,Y)=>{let J=e.slice(0,W);return{code:N,offset:W,attribute:Y,anchor:!0,kind:"directive",line:J.split(`
524
+ `).length,column:W-J.lastIndexOf(`
525
+ `)}},D=(W,N,Y)=>i.push({expression:W,statement:{text:N+W.code+Y,prefixLength:N.length}});for(let W of uu(n)){if(Ur(W.name)||W.name==="component")continue;let N=ei(W.name,r.filePath,r,j);if(!N)continue;let Y=O.get(N);if(!Y){let te;try{te=r.readComponent?r.readComponent(N):cr.readFileSync(N,"utf8")}catch{continue}if(te===void 0)continue;u.set(N,te),Y=ks(r.scriptCode(te,N),`__StxComponent${O.size}`),O.set(N,Y),a.push(Y.declarations)}let J=[];for(let te of W.attributes){let{name:K,offset:q}=te,oe=te.value===!0?"true":te.value;if(K.startsWith("@")||K.startsWith("v-on:")){if(Y.events&&te.value!==!0)l.set(q,`__StxEvent<${Y.events}, ${JSON.stringify(K.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let le=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(K);if(K.startsWith("v-")&&!K.startsWith("v-bind:")&&!le)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(K))continue;let ue=(le?le[1]||"modelValue":K.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(_e,de)=>de.toUpperCase());if(J.push(ue),!Y.props)continue;let fe=K.startsWith(":")||K.startsWith("v-bind:")||!!le||te.braced,Re=fe?oe:te.value!==!0?JSON.stringify(oe):"true",Ae=!fe&&te.value!==!0&&(oe==="true"||oe==="false");D(H(q,Re,K),";void ((",`) satisfies ${Ae?"__StxStaticProp":"__StxProp"}<${Y.props}, ${JSON.stringify(ue)}>);`)}if(Y.props){let te=[...new Set(J)].map((q)=>`${JSON.stringify(q)}: undefined as any`).join(", "),K=H(W.offset,`<${W.name}>`);i.push({expression:K,statement:{text:`;void ({ ${te} } satisfies ${Y.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:O.size?a.join(`
526
+ `):"",checks:i,events:l,dependencies:u}}import Qo from"fs";import wt from"path";var yt=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function pu(e){let n=new we(e,"javascript").tokenize(),r=e;for(let i of n.reverse())if(i.type==="COMMENT")r=r.slice(0,i.start)+i.value.replace(/[^\r\n]/g," ")+r.slice(i.end);return r}function _t(e,n,r,i){if(e[n]!==r)return-1;let a=0,l=null;for(let u=n;u<e.length;u++){let f=e[u];if(l){if(f==="\\"){u++;continue}if(f===l)l=null;continue}if(f==="'"||f==='"'||f==="`"){l=f;continue}if(f===r)a++;else if(f===i){if(i===">"&&e[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function dt(e,n,r){let i=r?"([{<":"([{",a=r?")]}>":")]}",l=[],u=0,f=null,v="";for(let S=0;S<e.length;S++){let j=e[S];if(f){if(v+=j,j==="\\"){v+=e[++S]??"";continue}if(j===f)f=null;continue}if(j==="'"||j==='"'||j==="`"){f=j,v+=j;continue}if(i.includes(j))u++;else if(a.includes(j)&&!(r&&j===">"&&e[S-1]==="="))u--;if(u===0&&n.includes(j)){l.push(v),v="";continue}v+=j}return l.push(v),l.map((S)=>S.trim()).filter(Boolean)}function fu(e){let n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r=null;continue}if(a==="'"||a==='"'||a==="`"){r=a;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;if(n!==0||a!=="=")continue;let l=e[i-1];if(e[i+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return i}return-1}function Wo(e){switch(e.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function dn(e){let n=pu(e);for(let r of new Set(qn(n).map((i)=>i.start))){let i=du(n,r);if(i)return{...i,text:e.slice(r,r+i.text.length)}}return null}function du(e,n){let r=Object.create(null),i=Object.create(null),a=[],l=Object.create(null),u=Object.create(null),f=n+(/^(?:const|let|var)\s+/.exec(e.slice(n))?.[0].length??0),v=()=>{while(f<e.length&&/\s/.test(e[f]))f++},S;if(e[f]==="{"){let J=_t(e,f,"{","}");if(J===-1)return null;S=e.slice(f,J),f=J}else{let J=/^[A-Za-z_$][\w$]*/.exec(e.slice(f));if(!J)return null;S=J[0],f+=J[0].length}if(v(),e[f]!=="=")return null;f++,v();let j=/^withDefaults\s*\(\s*/.exec(e.slice(f)),O=Boolean(j);if(j)f+=j[0].length;let H=/^defineProps\b/.exec(e.slice(f));if(!H)return null;f+=H[0].length;let D="";if(v(),e[f]==="<"){let J=_t(e,f,"<",">");if(J===-1)return null;D=e.slice(f+1,J-1).trim(),f=J}if(v(),e[f]!=="(")return null;let W=_t(e,f,"(",")");if(W===-1)return null;let N=e.slice(f+1,W-1).trim();if(f=W,O){if(v(),e[f]===",")f++,v();if(e[f]==="{"){let J=_t(e,f,"{","}");if(J===-1)return null;for(let[te,K]of Cs(e.slice(f,J)))i[te]=K;f=J}if(v(),e[f]===",")f++,v();if(e[f]===")")f++}if(e[f]===";")f++;let Y=/^[A-Za-z_$][\w$]*$/.test(D)?D:void 0;if(D.startsWith("{"))for(let J of dt(D.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let te=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(J);if(te)r[te[1]]=te[2].trim()}if(N.startsWith("{"))for(let[J,te]of Cs(N)){if(a.push(J),!te.startsWith("{")){let K=Wo(te);if(K)r[J]=K;continue}for(let[K,q]of Cs(te))if(K==="default")i[J]=q;else if(K==="type"){let oe=Wo(q);if(oe)r[J]=oe}}else if(N.startsWith("["))for(let J of dt(N.slice(1,-1),",",!1))a.push(J.replace(/^['"`]/,"").replace(/['"`]$/,""));if(S.startsWith("{")){a.length=0;for(let J of dt(S.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let te=fu(J),K=te===-1?J:J.slice(0,te),q=K.split(":")[0].trim().replace(/^\.\.\./,"");if(!q)continue;a.push(q),l[q]=K.trim();let oe=K.split(":").at(-1).trim();if(/^[A-Za-z_$][\w$]*$/.test(oe))u[q]=oe;if(te!==-1)i[q]=J.slice(te+1).trim()}}else if(a.length===0)a.push(...Object.keys(r));return{text:e.slice(n,f),propNames:a,propBindings:l,localBindings:u,defaults:i,declared:r,typeName:Y,identifier:S.startsWith("{")?void 0:S}}function Cs(e){let n=e.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],i=0;while(i<n.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=i;let l=a.exec(n);if(!l)break;i=a.lastIndex;let u=0,f="",v=i;while(i<n.length){let j=n[i];if(f){if(j==="\\")i++;else if(j===f)f=""}else if(j==="'"||j==='"'||j==="`")f=j;else if(j==="{"||j==="["||j==="(")u++;else if(j==="}"||j==="]"||j===")")u--;else if(j===","&&u===0)break;i++}let S=n.slice(v,i).trim();if(S)r.push([l[1],S]);i++}return r}function lr(e){let n=/^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/,r=/^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;if(!n.test(e)&&!r.test(e))throw Error("Invalid prop number");return Number(e.replaceAll("_",""))}function Rs(e){let n=new we(e,"javascript").tokenize().filter((a)=>!["COMMENT","WHITESPACE","EOF"].includes(a.type)),r=0;function i(a){if(a>64)throw Error("Prop literal too deep");let l=n[r++];if(!l)throw Error("Missing prop literal");if(l.type==="STRING"||l.type==="TEMPLATE_STRING"){let j=bt(l.value);if(j===null)throw Error("Dynamic prop string");return j}if(l.type==="NUMBER")return lr(l.value);if(l.value==="-"||l.value==="+"){let j=n[r++];if(j?.type!=="NUMBER")throw Error("Dynamic prop number");return(l.value==="-"?-1:1)*lr(j.value)}if(l.value==="true")return!0;if(l.value==="false")return!1;if(l.value==="null")return null;if(l.value==="undefined")return;if(l.value!=="["&&l.value!=="{")throw Error("Dynamic prop default");let u=l.value==="[",f=u?"]":"}",v=[],S=[];while(n[r]?.value!==f){if(u)S.push(i(a+1));else{let j=n[r++];if(!j||!["STRING","IDENTIFIER","NUMBER"].includes(j.type))throw Error("Dynamic prop key");let O=j.type==="STRING"?bt(j.value):j.type==="NUMBER"?String(lr(j.value)):j.value;if(O===null||n[r++]?.value!==":")throw Error("Dynamic prop key");v.push([O,i(a+1)])}if(n[r]?.value!==",")break;r++}if(n[r++]?.value!==f)throw Error("Unclosed prop literal");return u?S:Object.fromEntries(v)}try{let a=i(0);return r===n.length?a:void 0}catch{return}}function As(e,n){let r=t(e),i=y(r).depths,a=/\b(interface|type)\s+([A-Za-z_$][\w$]*)\b/g;for(let l of r.matchAll(a)){if(l[2]!==n||i[l.index]!==0)continue;let u=l.index+l[0].length,f=r.indexOf("{",u);if(l[1]==="interface"&&f>=0){let v=_t(r,f,"{","}");if(v>=0)return e.slice(f,v)}if(l[1]==="type"){let v=r.indexOf("=",u);if(v<0)continue;let S=e.slice(v+1).trimStart();if(S[0]==="{"){let j=_t(S,0,"{","}");if(j>=0)return S.slice(0,j)}}}}function Ts(e){let n=e.trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:bt(n)??void 0}function Vo(e){let n=dt(e.trim().slice(1,-1),",",!0);if(n.length!==1)return e.trim();let r=n[0];if(r.startsWith("..."))return e.trim();let i=/^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(r),a=i?!!i[1]:r.endsWith("?"),l=i?i[2]:a?r.slice(0,-1).trim():r;return a?`(${l}) | undefined | []`:l}function Zn(e){let n=Fn(e,["defineEmits"],!0);if(!n)return null;let r=Object.create(null),i=/^[A-Za-z_$][\w$]*$/.test(n.type.trim())?n.type.trim():void 0,a=i?As(e,i):n.type.trim();if(a?.startsWith("{"))for(let l of dt(a.slice(1,-1),`;,
527
+ `,!0)){if(l.startsWith("(")){let O=_t(l,0,"(",")");if(O<0)continue;let H=dt(l.slice(1,O-1),",",!0),D=H.shift()||"",W=D.indexOf(":");if(W<0)continue;for(let N of dt(D.slice(W+1),"|",!0)){let Y=Ts(N);if(Y!==void 0)r[Y]={detailType:Vo(`[${H.join(", ")}]`)}}continue}let u=new we(l,"javascript").tokenize().filter((O)=>!["WHITESPACE","COMMENT","EOF"].includes(O.type)),f=u[0],v=u.findIndex((O)=>O.value===":");if(!f||v<0)continue;let S=Ts(f.value),j=l.slice(u[v].end).trim();if(S!==void 0)r[S]={detailType:j.startsWith("[")?Vo(j):j}}else{let l=n.args[0]?.trim()||"";if(l.startsWith("["))for(let u of dt(l.slice(1,-1),",",!1)){let f=Ts(u);if(f!==void 0)r[f]={detailType:"unknown"}}else if(l.startsWith("{"))for(let u of dt(l.slice(1,-1),",",!1)){let f=new we(u,"javascript").tokenize().find((S)=>!["WHITESPACE","COMMENT"].includes(S.type)),v=f&&Ts(f.value);if(v!==void 0)r[v]={detailType:"unknown"}}}return{...n,text:e.slice(n.start,n.end),typeName:i,events:r}}import{mkdir as Fo,readFile as gu,readdir as mu,realpath as hu,stat as Uo,writeFile as xu}from"fs/promises";import nt from"path";import{builtinModules as bu}from"module";function Xo(e){if(e==="connectedCallback")return`method "${e}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(e==="disconnectedCallback")return`method "${e}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${e}" is reserved`}var Go=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]),yu=new Set(bu);function _u(e){return e.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function pr(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function wu(e){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(e)&&!e.startsWith("xml")&&!/[A-Z]/.test(e)}function vu(e){if(e===!0)return"open";if(e==="open"||e==="closed")return e;return!1}async function $u(e){let n=[];async function r(i){let a=await mu(i,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=nt.join(i,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(e),n}function Yt(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function fr(e){for(let n of V(Yt(e))){let r=R(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function dr(e,n){let r=fr(e);if(!r)return{};let i=r.code.trim();if(!i)return{};try{let a=JSON.parse(i);if(!a||typeof a!=="object"||Array.isArray(a))throw Error("expected a JSON object");return a}catch(a){throw Error(`${n}: <script component> must contain JSON metadata (${a.message})`)}}function Is(e,n){let r=t(e),i=new Set(qn(e).map((v)=>v.start)),a=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,l=[],u=n?void 0:new Bun.Transpiler({loader:"ts"}),f;while(f=a.exec(r)){if(!i.has(f.index+f[0].indexOf("function")))continue;let v=a.lastIndex;while(/\s/.test(r[v]||""))v++;let S=v;if(r[v]==="<")v=_t(r,v,"<",">");if(v<0)continue;let j=e.slice(S,v).trim();while(/\s/.test(r[v]||""))v++;if(r[v]!=="(")continue;let O=v,H=_t(r,v,"(",")");if(H<0)continue;for(v=H;v<e.length;v++){let D=r[v];if(D!=="{"&&D!==";")continue;let W=e.slice(f.index,v).trim();if(n){if(!n(W,D,f[1]))continue}else{let Y;try{Y=u.transformSync(W+(D==="{"?"{}":";"))}catch{continue}if(D==="{"&&!Y.includes(`function ${f[1]}(`))continue;if(D===";"&&Y.trim())continue}let N=D==="{"?_t(r,v,"{","}"):v+1;if(N<0)break;l.push({name:f[1],header:W,generic:j,parameterOffset:O+1,parameters:e.slice(O+1,H-1),returns:e.slice(H,v).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(f[0]),...D==="{"?{source:e.slice(f.index,N)}:{}}),a.lastIndex=N;break}}return l}function Su(e){let n=dt(e.parameters,",",!0).flatMap((r,i)=>{let a=t(r),l=0,u=-1;for(let N=0;N<a.length;N++){let Y=a[N];if("([{<".includes(Y))l++;else if(")]}>".includes(Y)&&!(Y===">"&&a[N-1]==="="))l--;if(Y==="="&&l===0&&a[N+1]!==">"){u=N;break}}let f=(u<0?r:r.slice(0,u)).trim(),v=dt(f,":",!0),S=v.shift().trim();if(S==="this")return[];let j=/^[A-Za-z_$]|^\.\.\./.test(S)?S:`argument${i}`,O=u<0?"":r.slice(u+1).trim(),H=O==="true"||O==="false"?"boolean":/^-?\d+(?:\.\d+)?$/.test(O)?"number":/^['"`]/.test(O)?"string":j.startsWith("...")?"unknown[]":"unknown",D=v.join(":").trim()||H,W=u>=0&&!j.endsWith("?")&&!j.startsWith("...")?"?":"";return[`${j}${W}: ${D}`]}).join(", ");return`${e.name}${e.generic}(${n}): ${e.returns||(e.async?"Promise<unknown>":"unknown")}`}function Eu(e,n){let r={},i={},a=[],l=[],u=V(Yt(e)).map((N)=>({code:e.slice(N.bodyStart,N.bodyEnd),attributes:R(N.attrs)})).filter(({attributes:N})=>!["src","server","component","stx:component"].some((Y)=>N.has(Y))&&xt(N)),f=u.map((N)=>N.code).join(`
528
+ `),v=dn(f),S=Zn(f);for(let N of u){let{code:Y}=N;try{new Bun.Transpiler({loader:"ts"}).transformSync(Y)}catch(ue){throw Error(`${n}: failed to transpile <script client> (${ue.message})`)}let J=Is(Y),te=new Set(J.filter((ue)=>!ue.source).map((ue)=>ue.name));for(let ue of J){if(Go.has(ue.name))throw Error(`${n}: client ${Xo(ue.name)}`);if(ue.source)r[ue.name]=`${ue.name}(...args) { return this._callScopeMethod(${JSON.stringify(ue.name)}, args); }`;if(!ue.source||!te.has(ue.name))(i[ue.name]??=[]).push(Su(ue))}for(let ue of Y.matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))l.push({binding:ue[1].trim(),module:ue[3]});let K=t(Y),q=y(K).depths,oe=/(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g,le;while(le=oe.exec(K)){if(q[le.index]!==0)continue;let ue=oe.lastIndex,fe=0;for(;ue<K.length;ue++){let Ve=K[ue];if(Ve==="{"){let st=_t(K,ue,"{","}");if(st<0)break;if(ue=st-1,le[1]==="interface"&&fe===0){ue++;break}continue}if("([<".includes(Ve))fe++;else if(")]>".includes(Ve)&&!(Ve===">"&&K[ue-1]==="="))fe--;if(le[1]==="type"&&fe===0&&(Ve===";"||Ve===`
529
+ `)){if(Ve===`
530
+ `&&/^[\s]*[|&]/.test(K.slice(ue+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(Y.slice(le.index,ue));break}catch{}}}let Re=Y.slice(le.index,ue),Ae=le.index,_e=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(le[0])?.[1],de=u.map((Ve)=>{let st=Ve===N?Y.slice(0,Ae)+Y.slice(ue):Ve.code;return t(st.replace(dn(Ve.code)?.text??"\x00","").replace(Zn(Ve.code)?.text??"\x00",""))}).join(`
531
+ `);if(!((v?.typeName===_e||S?.typeName===_e)&&!/^export\s/.test(Re)&&_e&&!new RegExp(`\\b${_e}\\b`).test(de)))a.push(Re.replace(/^export\s+/,"").trim());oe.lastIndex=ue+1}}let j=Object.values(i).flat().join(`
532
+ `)+`
533
+ `+a.join(`
534
+ `)+`
535
+ `+Object.values(S?.events||{}).map((N)=>N.detailType).join(`
536
+ `),O=new we(j,"javascript").tokenize().filter((N)=>!["WHITESPACE","COMMENT"].includes(N.type)),H=new Set(O.filter((N,Y)=>{if(O[Y-1]?.value===".")return!1;let J=O[Y+1]?.value;return J!==":"&&!(J==="?"&&O[Y+2]?.value===":")}).map((N)=>N.value)),D=l.filter((N)=>(N.binding.match(/[A-Za-z_$][\w$]*/g)||[]).filter((Y)=>!["type","as"].includes(Y)).some((Y)=>H.has(Y)));for(let N of D)if(N.module.startsWith(".")||nt.isAbsolute(N.module))throw Error(`${n}: public method types import ${JSON.stringify(N.module)} outside the generated package; declare these types in the component or import them from a published dependency`);let W=[...new Set(D.map((N)=>`import type ${N.binding.replace(/\btype\s+/g,"")} from ${JSON.stringify(N.module)}`))];return{methods:r,declarations:i,types:a.join(`
537
+
538
+ `),typeImports:W.join(`
539
+ `)}}function ku(e){let n=e.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:e).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Ho(e){return[...e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].replace(/\r\n?/g,`
540
+ `).replaceAll("\x00","\uFFFD").trim()).filter(Boolean).join(`
541
+
542
+ `)}function Cu(e){if(!e)return null;let n=e.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function Ru(e){if(e===void 0)return"object";if(e==="true"||e==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(e))return"number";if(/^['"`]/.test(e))return"string";return"object"}function Kn(e,n){if(e[n]!=="(")return null;let r=0,i="";for(let a=n;a<e.length;a++){let l=e[a];if(i!==""){if(l==="\\")a++;else if(l===i)i="";continue}if(l==="'"||l==='"'||l==="`"){i=l;continue}if(l==="(")r++;else if(l===")"){if(r--,r===0)return{expression:e.slice(n+1,a),end:a+1}}}return null}function gr(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function Au(e,n){let r=[],i=0,a=e.replace(/\{\{--[\s\S]*?--\}\}/g,""),l=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,u,f=(v)=>{if(v==="")return;let S=0,j=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}|(data-stx-on-[\w:-]+=")(\d+)(")/g,O;while(O=j.exec(v)){if(O.index>S)r.push(`out += ${JSON.stringify(v.slice(S,O.index))};`);r.push(O[3]!==void 0?`out += ${JSON.stringify(O[3])} + (this._handlers.push(${n[Number(O[4])]}) - 1) + ${JSON.stringify(O[5])};`:O[1]!==void 0?`out += __raw(${O[1]});`:`out += __escape(${O[2]});`),S=O.index+O[0].length}if(S<v.length)r.push(`out += ${JSON.stringify(v.slice(S))};`)};while(u=l.exec(a)){f(a.slice(i,u.index)),i=u.index+u[0].length;let S=u[1]==="if"||u[1]==="elseif"||u[1]==="foreach"?Kn(a,i):null;if(S)i=S.end,l.lastIndex=S.end;let j=S?.expression;switch(u[1]){case"if":r.push(`if (${j}) {`);break;case"elseif":r.push(`} else if (${j}) {`);break;case"else":r.push("} else {");break;case"endif":case"endforeach":r.push("}");break;case"foreach":{let O=gr(j||"");if(!O){r.push(`out += ${JSON.stringify(u[0]+(S?`(${j})`:""))};`);break}let{iterable:H,key:D,value:W}=O;r.push(D?`for (const [${D}, ${W}] of __entries(${H})) {`:`for (const ${W} of __values(${H})) {`);break}}}return f(a.slice(i)),r.join(`
543
+ `)}function Yo(e){let n=t(e),r=y(n).depths,i=[],a=[];for(let u of n.matchAll(/\bimport\b/g)){let f=u.index;if(r[f]!==0)continue;let v=new we(e.slice(f)).tokenize().filter((W)=>!["COMMENT","WHITESPACE"].includes(W.type));if(v[1]?.value==="("||v[1]?.value===".")continue;let S=v[1]?.type==="STRING"?1:-1,j=0;for(let W=1;S===-1&&W<v.length;W++){let N=v[W];if(N.value===";"||N.type==="EOF")break;if(N.value==="{")j++;else if(N.value==="}")j--;else if(j===0&&N.value==="from"&&v[W+1]?.type==="STRING")S=W+1}if(S===-1)continue;let O=v[S],H=S;if(v[H+1]?.value==="with"&&v[H+2]?.value==="{"){H+=2;let W=1;while(W&&v[H+1]?.type!=="EOF")if(H++,v[H]?.value==="{")W++;else if(v[H]?.value==="}")W--}if(v[H+1]?.value===";")H++;let D=f+v[H].end;if(a.push({start:f,end:D}),!["stx","@stacksjs/stx"].includes(O.value.slice(1,-1)))i.push(e.slice(f,D))}let l=e;for(let u of a.reverse())l=l.slice(0,u.start)+l.slice(u.end);return{imports:i,body:l}}function Tu(e){let r=V(Yt(e)).filter((J)=>{let te=R(J.attrs);return xt(te)&&!["component","stx:component","server","src"].some((K)=>te.has(K))});if(!r.length)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{},apis:[]};let i=r.map((J)=>e.slice(J.bodyStart,J.bodyEnd)).join(`
544
+ `),a=[],l=[],u=Object.create(null),f=Object.create(null),v=Object.create(null),S=Yo(i);a.push(...S.imports),i=S.body;let j=dn(i);if(j)l.push(...j.propNames),Object.assign(u,j.propBindings),Object.assign(f,j.defaults),Object.assign(v,j.declared),i=i.replace(j.text,j.identifier?`const ${j.identifier} = this._props();`:"");if(j?.typeName){let J=As(i,j.typeName);if(J)for(let te of dt(J.slice(1,-1),`;,
545
+ `,!0)){let K=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:\s*([\s\S]+)$/.exec(te);if(!K)continue;if(v[K[1]]=K[2].trim(),!l.includes(K[1]))l.push(K[1])}}let O=Zn(i);if(O)i=i.replace(O.text,"this._emitScope.bind(this)");let H=t(i),D=y(H).depths;for(let J of[...H.matchAll(/\bexport\s+(?=(?:interface|type|const|let|var|async|function)\b)/g)].reverse())if(D[J.index]===0)i=i.slice(0,J.index)+" ".repeat(J[0].length)+i.slice(J.index+J[0].length);let W=new Set(qn(i).map((J)=>J.name)),N=t(i),Y=["state","derived","effect","batch","onMount","onDestroy"].filter((J)=>!W.has(J)&&new RegExp(`\\b${J}\\s*(?:<|\\()`).test(N));return{imports:a,body:i.trim(),propNames:l,propBindings:u,defaults:f,declared:v,apis:Y}}function Iu(e){let n=new Set,r=[];return{template:e.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([\s\S]*?)\3/gi,(a,l,u,f,v)=>{let S=l.toLowerCase();n.add(S);let j=(u||"").split(".").filter(Boolean).join(" "),O=r.length;return r.push(/^[A-Za-z_$][\w$]*$/.test(v.trim())?`($event) => (typeof ${v} === 'function' ? ${v} : this[${JSON.stringify(v.trim())}]).call(this, $event)`:`($event) => { ${v} }`),` data-stx-on-${S}="${O}"${j?` data-stx-mod-${S}="${j}"`:""}`}),eventTypes:[...n].sort(),handlers:r}}function ju(e){let n=[];return{template:e.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(i,a,l,u)=>{let f=n.length;return n.push({id:f,name:a,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function Ou(e){let n=new Set;for(let r of e.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function Pu(e){return[...new Set([...e.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function Zo(e,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${e}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function Mu(e,n,r){let i=nt.isAbsolute(n.file)?n.file:nt.resolve(e,n.file),a=await gu(i,"utf8"),l=dr(a,i),u=nt.basename(i,".stx"),f=n.name||l.name||_u(u),v=`${pr(r.prefix||"stx")}-${pr(u)}`,S=n.tag||l.tag||v;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${i}: invalid component class name "${f}"`);if(!wu(S))throw Error(`${i}: invalid custom-element tag "${S}"; tags must be lowercase and contain a hyphen`);let j=n.properties||l.properties||l.props||{},O=Object.fromEntries(Object.entries(j).map(([K,q])=>[K,Zo(K,q)])),H=Iu(ku(a)),D=ju(H.template),W=Tu(a);for(let K of V(Yt(a))){let q=R(K.attrs);if(!q.has("client")||["server","component","stx:component","src"].some((oe)=>q.has(oe))||!xt(q))continue;W.imports.push(...Yo(a.slice(K.bodyStart,K.bodyEnd)).imports)}W.imports=[...new Set(W.imports)];let N=Au(D.template,H.handlers);for(let K of W.propNames){if(O[K])continue;let q=W.defaults[K];O[K]=Zo(K,{type:Cu(W.declared[K])??Ru(q),...q===void 0?{}:{default:Rs(q)}})}let Y=l.methods||{},J=n.methods||{},te=Eu(a,i);return{file:nt.relative(e,i),sourcePath:i,name:f,tag:S,description:n.description||l.description||"",template:D.template,styles:Ho(a),shadowMode:vu(n.shadowDOM??l.shadowDOM??r.shadowDOM),progressive:n.progressive??l.progressive??r.progressive??!0,properties:O,events:{...Zn(V(Yt(a)).filter((K)=>{let q=R(K.attrs);return xt(q)&&!["server","component","stx:component","src"].some((oe)=>q.has(oe))}).map((K)=>a.slice(K.bodyStart,K.bodyEnd)).join(`
546
+ `))?.events||{},...n.events||l.events||{}},methods:{...Y,...J,...te.methods},methodDeclarations:te.declarations,declarationTypes:te.types,declarationImports:te.typeImports,eventTypes:H.eventTypes,handlers:H.handlers,scopeMethods:Object.keys(te.methods),bindings:D.bindings,slots:Ou(D.template),cssProperties:Pu(Ho(a)),scope:W,render:N}}function Ko(e=!1){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`${e?`import { state as nativeState, derived as nativeDerived, effect as nativeEffect, batch as nativeBatch } from './signals.js';
547
+ `:""}const HTMLElementBase = globalThis.HTMLElement || class {};
548
+
549
+ const escapeHTML = (value) => String(value ?? '')
550
+ .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
551
+ .replaceAll('"', '&quot;').replaceAll("'", '&#039;');
552
+
553
+ const valueAt = (host, path) => {
554
+ const parts = path.trim().split('.');
555
+ if (parts[0] === 'this') parts.shift();
556
+ if (!parts.length) return host;
557
+ const first = parts.shift();
558
+ // Render bindings read declared props, including attributes whose names
559
+ // also belong to the native DOM API. The public element keeps that API.
560
+ let value = host._values && Object.prototype.hasOwnProperty.call(host._values, first)
561
+ ? host._values[first]
562
+ : host[first];
563
+ for (const part of parts) value = value?.[part];
564
+ return typeof value === 'function' ? value.call(host) : value;
565
+ };
566
+
567
+ const deserialize = (value, type, fallback) => {
568
+ if (value === null) return type === 'boolean' ? false : fallback;
569
+ if (type === 'boolean') return value !== 'false' && value !== '0';
570
+ if (type === 'number') return Number(value);
571
+ if (type === 'object' || type === 'array') {
572
+ try { return JSON.parse(value); }
573
+ catch { return fallback; }
574
+ }
575
+ return value;
576
+ };
577
+
578
+ const serialize = (value, type) => {
579
+ if (value == null || value === false) return null;
580
+ if (type === 'boolean') return '';
581
+ if (type === 'object' || type === 'array') return JSON.stringify(value);
582
+ return String(value);
583
+ };
584
+
585
+ const cloneDefault = (value, type) => {
586
+ if (value == null || (type !== 'object' && type !== 'array')) return value;
587
+ if (typeof structuredClone === 'function') return structuredClone(value);
588
+ return JSON.parse(JSON.stringify(value));
589
+ };
590
+
591
+ const defaultFor = property => cloneDefault(
592
+ property.default ?? ({ string: '', number: 0, boolean: false, object: {}, array: [] })[property.type],
593
+ property.type,
594
+ );
595
+
596
+ export class StxElement extends HTMLElementBase {
597
+ static definition = {};
598
+ static get observedAttributes() { return this.definition.observedAttributes || []; }
599
+
600
+ constructor() {
601
+ super();
602
+ this._values = Object.create(null);
603
+ this._reflecting = false;
604
+ this._connected = false;
605
+ this._hasConnected = false;
606
+ this._initializing = false;
607
+ this._updatePending = false;
608
+ this._listeners = new Map();
609
+ this._scopeStates = [];
610
+ this._scopeDerived = [];
611
+ this._scopeEffects = [];
612
+ this._scopeSubscriptions = [];
613
+ this._scopeMounts = [];
614
+ this._scopeDestroys = [];
615
+ this._scopeConnectionDestroys = [];
616
+ this._scopeMountCleanups = [];
617
+ const definition = this.constructor.definition;
618
+ for (const [name, property] of Object.entries(definition.properties || {})) {
619
+ this._values[name] = defaultFor(property);
620
+ }
621
+ if (definition.shadowMode && this.attachShadow && !this.shadowRoot) {
622
+ this._closedRoot = this.attachShadow({ mode: definition.shadowMode });
623
+ }
624
+ }
625
+
626
+ get updateComplete() { return this._updateComplete || Promise.resolve(); }
627
+ get renderRoot() { return this._closedRoot || this.shadowRoot || this; }
628
+
629
+ connectedCallback() {
630
+ if (this._connected) return;
631
+ this._connected = true;
632
+ this._initializing = true;
633
+ const definition = this.constructor.definition;
634
+ for (const [name, property] of Object.entries(definition.properties || {})) {
635
+ const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
636
+ if (attribute && this.hasAttribute?.(attribute)) this._values[name] = deserialize(this.getAttribute(attribute), property.type, defaultFor(property));
637
+ }
638
+ // Properties assigned before customElements.define() become own properties.
639
+ // Upgrade them after attributes so imperative state wins, matching the
640
+ // platform's property-first custom-element initialization convention.
641
+ for (const name of Object.keys(definition.properties || {})) this._upgradeProperty(name);
642
+ this._initializing = false;
643
+ const root = this.renderRoot;
644
+ const hasMarkup = [...(root.childNodes || [])].some(node => node.nodeType !== 3 || node.textContent.trim());
645
+ const firstConnection = !this._hasConnected;
646
+ if (!(firstConnection && definition.progressive && hasMarkup)) this._render();
647
+ else {
648
+ if (typeof this.render === 'function') this.render(RENDER_HELPERS);
649
+ this._upgradeDeclarativeEvents();
650
+ }
651
+ this._bindEvents();
652
+ if (firstConnection) {
653
+ this._hasConnected = true;
654
+ this.setAttribute?.('hydrated', '');
655
+ this.dispatchEvent?.(new CustomEvent('stx:hydrated', { bubbles: true, composed: true }));
656
+ }
657
+ // Called last, so a component that acquires something sees its own rendered
658
+ // markup and its events already bound. Reported rather than rethrown: a
659
+ // component that fails to set up must not take the element down with it.
660
+ this._runScopeMounts();
661
+ try { this.onConnect?.(); }
662
+ catch (error) { console.error('[stx] onConnect failed', error); }
663
+ }
664
+
665
+ disconnectedCallback() {
666
+ this._connected = false;
667
+ // Called before the framework releases anything, so the element is still
668
+ // intact for a component that needs to read it on the way out, and inside
669
+ // try/finally so a throwing hook cannot leak the framework's own listeners.
670
+ try { this.onDisconnect?.(); }
671
+ catch (error) { console.error('[stx] onDisconnect failed', error); }
672
+ finally {
673
+ this._disposeScopeEffects();
674
+ for (const dispose of this._scopeSubscriptions.splice(0)) {
675
+ try { dispose?.(); } catch (error) { console.error('[stx] scope subscription cleanup failed', error); }
676
+ }
677
+ for (const cleanup of [...this._scopeDestroys.splice(0), ...this._scopeConnectionDestroys.splice(0), ...this._scopeMountCleanups.splice(0)]) {
678
+ try { cleanup(); } catch (error) { console.error('[stx] scope cleanup failed', error); }
679
+ }
680
+ for (const [event, listener] of this._listeners) this.renderRoot.removeEventListener(event, listener);
681
+ this._listeners.clear();
682
+ }
683
+ }
684
+
685
+ attributeChangedCallback(attribute, oldValue, newValue) {
686
+ if (oldValue === newValue || this._reflecting) return;
687
+ const definition = this.constructor.definition;
688
+ const name = definition.attributeToProperty?.[attribute];
689
+ if (!name) return;
690
+ const property = definition.properties[name];
691
+ const value = deserialize(newValue, property.type, defaultFor(property));
692
+ if (!Object.is(this._values[name], value)) {
693
+ this._values[name] = value;
694
+ this.requestUpdate();
695
+ }
696
+ }
697
+
698
+ /**
699
+ * The props a compiled render reads.
700
+ *
701
+ * Its own method rather than _values directly, so a component that sets a
702
+ * property before upgrade still sees it, and so the generated code has one
703
+ * name to depend on rather than a private field's shape.
704
+ */
705
+ _props() {
706
+ return this._values;
707
+ }
708
+
709
+ requestUpdate() {
710
+ if (!this._connected || this._initializing || this._updatePending) return this.updateComplete;
711
+ this._updatePending = true;
712
+ this._updateComplete = new Promise((resolve) => {
713
+ queueMicrotask(() => {
714
+ this._updatePending = false;
715
+ if (this._connected) this._render();
716
+ resolve();
717
+ });
718
+ });
719
+ return this._updateComplete;
720
+ }
721
+
722
+ emit(name, detail, options = {}) {
723
+ return this.dispatchEvent(new CustomEvent(name, {
724
+ detail, bubbles: true, composed: true, ...options,
725
+ }));
726
+ }
727
+
728
+ _disposeScopeEffects() {
729
+ for (const dispose of this._scopeEffects.splice(0)) {
730
+ try { dispose(); } catch (error) { console.error('[stx] effect cleanup failed', error); }
731
+ }
732
+ }
733
+
734
+ _runScopeMounts() {
735
+ for (const mount of this._scopeMounts) {
736
+ try { const cleanup = mount(); if (typeof cleanup === 'function') this._scopeMountCleanups.push(cleanup); }
737
+ catch (error) { console.error('[stx] onMount failed', error); }
738
+ }
739
+ }
740
+
741
+ ${e?` _beginScope() {
742
+ this._disposeScopeEffects();
743
+ this._scopeMounts = [];
744
+ this._scopeDestroys = [];
745
+ let stateIndex = 0, derivedIndex = 0;
746
+ let rendering = true;
747
+ return {
748
+ finish: () => { rendering = false; },
749
+ state: (initial) => {
750
+ const index = stateIndex++;
751
+ const value = this._scopeStates[index] ||= nativeState(initial);
752
+ if (this._connected && !this._scopeSubscriptions[index]) this._scopeSubscriptions[index] = value.subscribe(() => this.requestUpdate());
753
+ return value;
754
+ },
755
+ derived: (compute, options) => {
756
+ const index = derivedIndex++;
757
+ let entry = this._scopeDerived[index];
758
+ if (!entry) {
759
+ entry = { compute, revision: nativeState(0) };
760
+ entry.value = nativeDerived(() => { entry.revision(); return entry.compute(); }, options);
761
+ this._scopeDerived[index] = entry;
762
+ } else {
763
+ entry.compute = compute;
764
+ entry.revision.update(value => value + 1);
765
+ }
766
+ return entry.value;
767
+ },
768
+ effect: (callback, options) => {
769
+ const dispose = nativeEffect(callback, options);
770
+ this._scopeEffects.push(dispose);
771
+ return dispose;
772
+ },
773
+ batch: nativeBatch,
774
+ onMount: callback => this._scopeMounts.push(callback),
775
+ onDestroy: callback => (rendering ? this._scopeDestroys : this._scopeConnectionDestroys).push(callback),
776
+ };
777
+ }
778
+
779
+ `:""} _emitScope(name, ...args) {
780
+ return this.emit(name, args.length === 1 ? args[0] : args, { cancelable: true });
781
+ }
782
+
783
+ _callScopeMethod(name, args) {
784
+ // Template calls already have this render's current prop closures. Refresh
785
+ // pending props only for an outside call, otherwise a public helper in the
786
+ // template would recursively render while the queued update is pending.
787
+ if (!this._scopeRenderDepth && (!this._scopeMethods || this._updatePending)) this.render(RENDER_HELPERS);
788
+ return this._scopeMethods[name].apply(this, args);
789
+ }
790
+
791
+ _upgradeProperty(name) {
792
+ if (!Object.prototype.hasOwnProperty.call(this, name)) return;
793
+ const value = this[name];
794
+ delete this[name];
795
+ this[name] = value;
796
+ }
797
+
798
+ _upgradeDeclarativeEvents() {
799
+ for (const element of this.renderRoot.querySelectorAll?.('*') || []) {
800
+ const names = element.getAttributeNames?.() || [...(element.attributes || [])].filter(Boolean).map(attribute => attribute.name);
801
+ for (const attributeName of names) {
802
+ if (!attributeName?.startsWith('@')) continue;
803
+ const [event, ...modifiers] = attributeName.slice(1).split('.');
804
+ element.setAttribute('data-stx-on-' + event, element.getAttribute(attributeName));
805
+ if (modifiers.length) element.setAttribute('data-stx-mod-' + event, modifiers.join(' '));
806
+ element.removeAttribute(attributeName);
807
+ }
808
+ }
809
+ }
810
+
811
+ _bindEvents() {
812
+ for (const event of this.constructor.definition.eventTypes || []) {
813
+ if (this._listeners.has(event)) continue;
814
+ const listener = ($event) => {
815
+ const selector = '[data-stx-on-' + event + ']';
816
+ const target = $event.target?.closest?.(selector);
817
+ if (!target || !this.renderRoot.contains(target)) return;
818
+ const modifiers = (target.getAttribute('data-stx-mod-' + event) || '').split(' ');
819
+ if (modifiers.includes('self') && target !== $event.target) return;
820
+ if (modifiers.includes('prevent')) $event.preventDefault();
821
+ if (modifiers.includes('stop')) $event.stopPropagation();
822
+ const method = target.getAttribute('data-stx-on-' + event);
823
+ if (this._handlers?.[method]) this._handlers[method]($event);
824
+ else if (typeof this[method] === 'function') this[method]($event);
825
+ };
826
+ this.renderRoot.addEventListener(event, listener);
827
+ this._listeners.set(event, listener);
828
+ }
829
+ }
830
+
831
+ _render() {
832
+ const definition = this.constructor.definition;
833
+ const root = this.renderRoot;
834
+ const active = root.activeElement || (root.contains?.(globalThis.document?.activeElement) ? globalThis.document.activeElement : null);
835
+ const focusAttribute = active?.getAttribute?.('data-key') ? 'data-key' : active?.id ? 'id' : 'name';
836
+ const focusKey = active?.getAttribute?.(focusAttribute);
837
+ const focusValue = focusAttribute === 'name' && active?.type === 'radio' ? active.value : null;
838
+ const selectionStart = active?.selectionStart, selectionEnd = active?.selectionEnd;
839
+ const selection = Number.isInteger(selectionStart) && Number.isInteger(selectionEnd)
840
+ ? [selectionStart, selectionEnd, active.selectionDirection] : null;
841
+ // A compiled component renders itself: the control flow and the derived
842
+ // values were turned into JavaScript at build time, so there is nothing to
843
+ // interpret here and nothing that needs an eval the page's CSP forbids.
844
+ // The string template remains for components that carry no logic.
845
+ let html = typeof this.render === 'function'
846
+ ? this.render(RENDER_HELPERS)
847
+ : definition.template
848
+ .replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(this, expression) ?? ''))
849
+ .replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(this, expression)));
850
+ if (definition.shadowMode && definition.styles) html = '<style>' + definition.styles + '</style>' + html;
851
+ root.innerHTML = html;
852
+ this._applyBindings();
853
+ this._bindEvents();
854
+ if (focusKey) {
855
+ const escaped = globalThis.CSS?.escape ? globalThis.CSS.escape(focusKey) : focusKey.replace(/["\\\\]/g, '\\$&');
856
+ const selector = '[' + focusAttribute + '="' + escaped + '"]';
857
+ // Name-only radio groups share a name, but their chosen member must stay focused.
858
+ const next = focusValue === null ? root.querySelector(selector)
859
+ : [...root.querySelectorAll(selector)].find(element => element.type === 'radio' && element.value === focusValue);
860
+ next?.focus?.();
861
+ // Several input types expose this method but reject text selection. A
862
+ // rerender can also change a text input into one of those types.
863
+ if (selection && Number.isInteger(next?.selectionStart) && Number.isInteger(next?.selectionEnd) && typeof next?.setSelectionRange === 'function')
864
+ next.setSelectionRange(selection[0], selection[1], selection[2] || 'none');
865
+ }
866
+ this.dispatchEvent?.(new CustomEvent('stx:updated', { bubbles: false }));
867
+ }
868
+
869
+ _applyBindings() {
870
+ for (const binding of this.constructor.definition.bindings || []) {
871
+ const element = this.renderRoot.querySelector('[data-stx-bind-' + binding.id + ']');
872
+ if (!element) continue;
873
+ const value = valueAt(this, binding.expression);
874
+ if (binding.name === 'class') element.className = value || '';
875
+ else if (binding.name === 'style' && typeof value === 'object') {
876
+ Object.assign(element.style, value);
877
+ }
878
+ else if (typeof value === 'boolean') {
879
+ element.toggleAttribute(binding.name, value);
880
+ if (binding.name in element) element[binding.name] = value;
881
+ }
882
+ else if (value == null || value === false) element.removeAttribute(binding.name);
883
+ else element.setAttribute(binding.name, String(value));
884
+ }
885
+ }
886
+ }
887
+
888
+ /**
889
+ * What a compiled render is handed.
890
+ *
891
+ * Passed in rather than closed over so the generated code names no globals, and
892
+ * a component module stays readable on its own: __escape is visibly a
893
+ * parameter, not something the bundler happened to leave in scope.
894
+ */
895
+ const RENDER_HELPERS = {
896
+ escape: escapeHTML,
897
+ // The raw form is the author declaring the value is markup. Null becomes an
898
+ // empty string rather than the word "null", which is the only sensible
899
+ // reading of a missing fragment.
900
+ raw: (value) => String(value ?? ''),
901
+ // A loop over something absent runs zero times. Throwing here would fail a
902
+ // whole page over one empty list, which is never what the author meant.
903
+ values: (value) => value == null ? [] : (value[Symbol.iterator] ? value : Object.values(value)),
904
+ entries: (value) => value == null ? [] : (Array.isArray(value) ? value.entries() : Object.entries(value)),
905
+ };
906
+
907
+ export function defineComponent(Component, definition) {
908
+ const properties = definition.properties || {};
909
+ const attributeToProperty = {};
910
+ const observedAttributes = [];
911
+ for (const [name, property] of Object.entries(properties)) {
912
+ const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
913
+ if (attribute) {
914
+ attributeToProperty[attribute] = name;
915
+ observedAttributes.push(attribute);
916
+ }
917
+ // A style prop is an attribute value, not a replacement for the browser's
918
+ // CSSStyleDeclaration. Native event handler accessors must survive too.
919
+ if (name in HTMLElementBase.prototype) {
920
+ if (!attribute) throw new TypeError('STX prop "' + name + '" overlaps the native DOM API and needs an attribute binding');
921
+ continue;
922
+ }
923
+ Object.defineProperty(Component.prototype, name, {
924
+ configurable: true,
925
+ enumerable: true,
926
+ get() { return this._values[name]; },
927
+ set(value) {
928
+ const oldValue = this._values[name];
929
+ if (Object.is(oldValue, value)) return;
930
+ this._values[name] = value;
931
+ if (property.reflect && attribute && !this._reflecting) {
932
+ const serialized = serialize(value, property.type);
933
+ this._reflecting = true;
934
+ if (serialized === null) this.removeAttribute(attribute);
935
+ else this.setAttribute(attribute, serialized);
936
+ this._reflecting = false;
937
+ }
938
+ this.requestUpdate();
939
+ this.dispatchEvent?.(new CustomEvent(name + '-changed', {
940
+ detail: { value, oldValue }, bubbles: true, composed: true,
941
+ }));
942
+ },
943
+ });
944
+ }
945
+ Component.definition = { ...definition, attributeToProperty, observedAttributes };
946
+ const registry = globalThis.customElements || globalThis.window?.customElements;
947
+ if (registry && !registry.get(definition.tag)) {
948
+ registry.define(definition.tag, Component);
949
+ }
950
+ return Component;
951
+ }
952
+ `}function ur(e,n="./runtime.js"){let r=JSON.stringify({tag:e.tag,template:e.template,styles:e.styles,shadowMode:e.shadowMode,progressive:e.progressive,properties:e.properties,eventTypes:e.eventTypes,bindings:e.bindings},null,2),i=Object.entries(e.methods).map(([j,O])=>{if(Go.has(j))throw Error(`${e.sourcePath}: ${Xo(j)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(O.trim()))return` ${O.trim()}`;return` ${j}($event) {
953
+ ${O}
954
+ }`}).join(`
955
+
956
+ `),a=e.scope,l=new Set(new we([a.body,...a.imports,...Object.keys(e.properties),...Object.values(a.propBindings)].join(`
957
+ `)).tokenize().map((j)=>j.value)),u="__stxScope";while(l.has(u))u+="$";let f=[...new Set([...Object.keys(e.properties),...a.propNames])].map((j)=>{let O=a.propBindings[j]||j;return a.defaults[j]===void 0?O:`${O} = ${a.defaults[j]}`}).join(", "),v=(j)=>j.split(`
958
+ `).map((O)=>O.trim()===""?O:` ${O}`).join(`
959
+ `),S="";if(e.render.trim()!==""||a.body!==""||f!==""){let j=[a.apis.length?`const ${u} = this._beginScope();
960
+ const { ${a.apis.join(", ")} } = ${u};`:"",f?`const { ${f} } = this._props();`:"",a.body,e.scopeMethods.length?`this._scopeMethods = { ${e.scopeMethods.join(", ")} };`:"",e.handlers.length?"this._handlers = [];":"","let out = '';",e.render,a.apis.length?`${u}.finish();`:"","return out;"].filter(Boolean).join(`
961
+ `),O;try{let H=new Bun.Transpiler({loader:"ts"}).transformSync(`export function __render(__helpers) {
962
+ ${j}
963
+ }`),D=H.indexOf("{"),W=H.lastIndexOf("}");O=H.slice(D+1,W).trim()}catch(H){throw Error(`${e.sourcePath}: failed to compile render (${H.message})`)}S=`
964
+ render(__helpers) {
965
+ this._scopeRenderDepth = (this._scopeRenderDepth || 0) + 1;
966
+ try {
967
+ const { escape: __escape, raw: __raw, values: __values, entries: __entries } = __helpers;
968
+ ${v(v(O.trim()))}
969
+ } finally {
970
+ this._scopeRenderDepth--;
971
+ }
972
+ }
973
+ `}return`import { StxElement, defineComponent } from ${n==="./runtime.js"?"'./runtime.js'":JSON.stringify(n)};
974
+ ${a.imports.length?`${a.imports.join(`
975
+ `)}
976
+ `:""}
977
+ /** ${e.description||`${e.name} web component generated from ${e.file}.`} */
978
+ export class ${e.name} extends StxElement {
979
+ ${i}${S}
980
+ }
981
+
982
+ defineComponent(${e.name}, ${r});
983
+ export default ${e.name};
984
+ `}function gn(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function Du(e){let n=[e.declarationTypes,e.declarationImports,e.name,...Object.values(e.methodDeclarations).flat(),...Object.values(e.events).map((H)=>H.detailType)].join(`
985
+ `),r=new Set(new we(n).tokenize().map((H)=>H.value)),i=(H)=>{let D=H;while(r.has(D))D+="$";return r.add(D),D},a=i("__StxSupport"),l=i("__Methods"),u=i("__Details"),f=!!e.declarationTypes,v=Object.entries(e.properties).map(([H,D])=>` ${H}${D.required?"":"?"}: ${gn(D)}`).join(`
986
+ `),S=Object.entries(e.events).map(([H,D])=>` ${JSON.stringify(H)}: CustomEvent<${f?`${a}.${u}[${JSON.stringify(H)}]`:D.detailType||"unknown"}>`).join(`
987
+ `),j=Object.keys(e.methods).flatMap((H)=>e.methodDeclarations[H]||[`${H}($event?: Event): unknown`]).map((H)=>` ${H}`).join(`
988
+ `),O=f?`declare namespace ${a} {
989
+ ${e.declarationTypes}
990
+ export interface ${l} {
991
+ ${j}
992
+ }
993
+ export interface ${u} {
994
+ ${Object.entries(e.events).map(([H,D])=>` ${JSON.stringify(H)}: ${D.detailType||"unknown"}`).join(`
995
+ `)}
996
+ }
997
+ }
998
+
999
+ `:"";return`${e.declarationImports?e.declarationImports+`
1000
+
1001
+ `:""}${O}export interface ${e.name}Props {
1002
+ ${v}
1003
+ }
1004
+
1005
+ export interface ${e.name}EventMap {
1006
+ ${S}
1007
+ }
1008
+
1009
+ export interface ${e.name} extends Required<Pick<${e.name}Props, Exclude<keyof ${e.name}Props, keyof HTMLElement>>>${f?`, ${a}.${l}`:""} {}
1010
+
1011
+ export declare class ${e.name} extends HTMLElement {
1012
+ ${f?"":j}
1013
+ addEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
1014
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
1015
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void
1016
+ removeEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
1017
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
1018
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void
1019
+ readonly updateComplete: Promise<void>
1020
+ requestUpdate(): Promise<void>
1021
+ emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean
1022
+ }
1023
+
1024
+ declare global {
1025
+ interface HTMLElementTagNameMap {
1026
+ ${JSON.stringify(e.tag)}: ${e.name}
1027
+ }
1028
+ }
1029
+
1030
+ export default ${e.name}
1031
+ `}function Nu(e){return`declare global {
1032
+ namespace JSX {
1033
+ interface IntrinsicElements {
1034
+ ${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${gn(u)}`).join(`
1035
+ `),a=Object.keys(r.events).map((l)=>` ${`on${l.split(/[-:]/).map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join("")}`}?: (event: import('./${r.tag}.js').${r.name}EventMap[${JSON.stringify(l)}]) => void`).join(`
1036
+ `);return` ${JSON.stringify(r.tag)}: {
1037
+ ${i}
1038
+ ${a}
1039
+ children?: unknown
1040
+ slot?: string
1041
+ class?: string
1042
+ className?: string
1043
+ }`}).join(`
1044
+ `)}
1045
+ }
1046
+ }
1047
+ }
1048
+
1049
+ export {}
1050
+ `}function Lu(e){return{schemaVersion:"1.0.0",modules:e.map((n)=>({kind:"javascript-module",path:`./${n.tag}.js`,declarations:[{kind:"class",name:n.name,description:n.description||void 0,customElement:!0,tagName:n.tag,members:Object.entries(n.properties).map(([r,i])=>({kind:"field",name:r,description:i.description,type:{text:gn(i)},default:i.default===void 0?void 0:JSON.stringify(i.default),attribute:i.attribute===!1?void 0:i.attribute||pr(r),reflects:i.reflect})),events:Object.entries(n.events).map(([r,i])=>({name:r,description:i.description,type:{text:`CustomEvent<${i.detailType||"unknown"}>`}})),slots:n.slots,cssProperties:n.cssProperties}],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:`./${n.tag}.js`}}]}))}}function qo(e){if(!e.styles)return"";let n=e.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(n))return n;return`@scope (${e.tag}) {
1051
+ ${n}
1052
+ }`}function Jo(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function zu(e){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),i=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(e.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=e.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
1053
+ `);return`const definitions = ${JSON.stringify(a,null,2)};
1054
+ const escapeHTML = (value) => String(value ?? '')
1055
+ .replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
1056
+ .replaceAll('"', '&quot;').replaceAll("'", '&#039;');
1057
+ const valueAt = (values, path) => path.trim().split('.').reduce((value, part) => value?.[part], values);
1058
+
1059
+ export function renderComponent(tag, props = {}, slots = {}) {
1060
+ const definition = definitions[tag];
1061
+ if (!definition) throw new Error('Unknown STX component: ' + tag);
1062
+ const values = Object.fromEntries(Object.entries(definition.properties).map(([name, property]) => [name, property.default]));
1063
+ Object.assign(values, props);
1064
+ let template = definition.template
1065
+ .replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(values, expression) ?? ''))
1066
+ .replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(values, expression)))
1067
+ .replace(new RegExp(${i}, 'gi'), (_match, name) => String(slots[name || 'default'] ?? ''));
1068
+ const attributes = Object.entries(definition.properties).flatMap(([name, property]) => {
1069
+ if (property.attribute === false || !(name in props)) return [];
1070
+ const attribute = property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
1071
+ const value = props[name];
1072
+ if (value == null || value === false) return [];
1073
+ if (value === true) return [attribute];
1074
+ const serialized = typeof value === 'object' ? JSON.stringify(value) : value;
1075
+ return [attribute + '=\\"' + escapeHTML(serialized) + '\\"'];
1076
+ }).join(' ');
1077
+ if (definition.shadowMode) {
1078
+ template = '<template shadowrootmode="' + definition.shadowMode + '">' +
1079
+ (definition.styles ? '<style>' + definition.styles + '</style>' : '') + template + '</template>' +
1080
+ String(slots.default ?? '');
1081
+ }
1082
+ return '<' + tag + (attributes ? ' ' + attributes : '') + '>' + template + '</' + tag + '>';
1083
+ }
1084
+
1085
+ ${l}
1086
+ `}async function fl(e){let n=nt.resolve(e.inputDir),r=nt.resolve(e.outputDir);if(!(await Uo(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let a=e.components?.length?e.components:(await $u(n)).map((K)=>({file:K}));if(!a.length)throw Error(`No .stx components found in ${n}`);let l=await Promise.all(a.map((K)=>Mu(n,K,e)));l.sort((K,q)=>K.tag.localeCompare(q.tag));let u=l.filter((K,q)=>l.findIndex((oe)=>oe.tag===K.tag)!==q);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=l.filter((K,q)=>l.findIndex((oe)=>oe.name===K.name)!==q);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Fo(r,{recursive:!0});let v=[],S=async(K,q)=>{let oe=nt.join(r,K);if(await Fo(nt.dirname(oe),{recursive:!0}),await xu(oe,typeof q==="string"&&!q.endsWith(`
1087
+ `)?`${q}
1088
+ `:q),!v.includes(oe))v.push(oe);return oe},j=l.some((K)=>K.scope.apis.length),O=import.meta.url.endsWith(".ts")?".ts":".js",H=new URL(`./signals-api${O}`,import.meta.url).pathname;if(j)await S("signals.js",`export * from ${JSON.stringify(H)};`);await S("runtime.js",Ko(j));for(let K of l){if(await S(`${K.tag}.js`,ur(K)),e.declarations!==!1)await S(`${K.tag}.d.ts`,Du(K));if(e.css!==!1&&K.styles){let q=K.shadowMode?K.styles:qo(K);await S(`${K.tag}.css`,e.minify?Jo(q):q)}}let D=new Bun.Transpiler({loader:"ts"});if(j||l.some((K)=>K.scope.imports.length||D.scanImports(ur(K)).some((q)=>q.kind==="dynamic-import"))){let K=l.map((_e)=>nt.join(r,`${_e.tag}.js`)),q=new Map(await Promise.all(K.map(async(_e,de)=>[await hu(_e),l[de]])));for(let[_e,de]of K.entries())q.set(de,l[_e]);let oe=new Map(l.map((_e)=>[nt.join(nt.dirname(_e.sourcePath),`.stx-library-${_e.tag}.ts`),_e])),le=nt.join(r,"runtime.js"),ue=nt.join(r,"signals.js"),fe=nt.join(n,".stx-library-runtime.ts"),Re=nt.join(n,".stx-library-signals.ts");if(K.push(le),j)K.push(ue);let Ae=await Bun.build({entrypoints:K,outdir:r,root:r,target:"browser",format:"esm",splitting:!0,naming:{entry:"[name].js",chunk:"chunks/[name]-[hash].js"},minify:!1,loader:{".js":"ts"},plugins:[{name:"stx-element-runtime",setup(_e){_e.onResolve({filter:/.*/},(de)=>{if(de.path==="bun"||de.path.startsWith("bun:")||de.path.startsWith("node:")||yu.has(de.path))throw Error(`Server-only import ${JSON.stringify(de.path)} is not available in a browser component (${de.importer})`);let We=q.get(de.path);if(!de.importer&&We)return{path:nt.join(nt.dirname(We.sourcePath),`.stx-library-${We.tag}.ts`)};if(de.path===le)return{path:fe};if(de.path===ue||de.importer===fe&&de.path==="./signals.js")return{path:Re};if(/^(?:@stacksjs\/stx|stx)\/signals-api(?:\.[jt]s)?$/.test(de.path))return{path:H}}),_e.onLoad({filter:/\.ts$/},(de)=>{if(de.path===fe)return{contents:Ko(j),loader:"ts"};if(de.path===Re)return{contents:`export * from ${JSON.stringify(H)};`,loader:"ts"};let We=oe.get(de.path);if(We)return{contents:ur(We,le),loader:"ts"}})}}]}).catch((_e)=>{let de=(_e instanceof AggregateError?_e.errors:[_e]).map(String).join(`
1089
+ `);throw Error(`Failed to bundle browser component imports
1090
+ ${de}`)});if(!Ae.success)throw Error(`Failed to bundle component imports
1091
+ ${Ae.logs.map(String).join(`
1092
+ `)}`);for(let _e of Ae.outputs)await S(nt.relative(r,_e.path),new Uint8Array(await _e.arrayBuffer()))}let W=l.map((K)=>`export { ${K.name}, default as ${K.name}Element } from './${K.tag}.js';`).join(`
1093
+ `);if(await S("index.js",W),await S("ssr.js",zu(l)),e.declarations!==!1)await S("index.d.ts",l.map((K)=>`export * from './${K.tag}.js'`).join(`
1094
+ `)),await S("custom-elements.d.ts",Nu(l)),await S("ssr.d.ts",`${l.map((K)=>`export declare const render${K.name}: (props?: ${K.name}Props, slots?: Record<string, string>) => string`).join(`
1095
+ `)}
1096
+ export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
1097
+ ${l.map((K)=>`import type { ${K.name}Props } from './${K.tag}.js'`).join(`
1098
+ `)}`);let N;if(e.manifest!==!1)N=await S("custom-elements.json",JSON.stringify(Lu(l),null,2));let Y;if(e.css!==!1){let K=l.filter((q)=>!q.shadowMode&&q.styles).map(qo).join(`
1099
+
1100
+ `);if(K)Y=await S("bundle.css",e.minify?Jo(K):K)}let J;if(e.bundle!==!1){J=nt.join(r,"bundle.js");let K;try{K=await Bun.build({entrypoints:[nt.join(r,"index.js")],outdir:r,naming:"bundle.js",target:"browser",format:"esm",minify:e.minify??!0,sourcemap:e.sourcemap||"none"})}catch(q){let oe=q instanceof AggregateError?q.errors:[q],le=oe.map((ue)=>String(ue).trim()).filter(Boolean).join(`
1101
+ `);throw AggregateError(oe,`Failed to bundle component library${le?`
1102
+ ${le}`:""}`)}if(!K.success){let q=K.logs.map((oe)=>String(oe).trim()).filter(Boolean).join(`
1103
+ `);throw AggregateError(K.logs,`Failed to bundle component library${q?`
1104
+ ${q}`:""}`)}if(v.push(J),e.sourcemap==="external")v.push(`${J}.map`)}let te=await Promise.all(v.map(async(K)=>(await Uo(K)).size));return{components:l.map((K)=>({name:K.name,tag:K.tag,source:K.sourcePath,module:nt.join(r,`${K.tag}.js`),styles:K.styles,shadowMode:K.shadowMode})),files:v,manifest:N,bundle:J,cssBundle:Y,totalBytes:te.reduce((K,q)=>K+q,0)}}var Bu=new Set(yt);function qt(e){let n=Qt(e),r=n.find((O)=>O.name==="InheritedContext");if(!r)return;let i=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(t(r.text).trim()),a=t(e),l=y(a).depths,u=[...a.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((O)=>l[O.index]===0)?.index??0,f=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),v=t(f),S=y(v).depths,j=[...v.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((O)=>S[O.index]===0).map((O)=>O[1]);return{keys:i?j:[],types:n.map((O)=>O.text).join(`
1105
+ `),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function Wu(e){let n=[],r=t(e);for(let i of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(i[1]||r.slice(i.index,i.index+6)!=="import")continue;let a=i[2].trim(),l=["stx","@stacksjs/stx"].includes(i[4]);if(/^[A-Za-z_$][\w$]*$/.test(a)){n.push(a);continue}if(!a.startsWith("{")||!a.endsWith("}"))continue;for(let u of a.slice(1,-1).split(",")){if(/^\s*type\s+/.test(u))continue;let[f,v=f]=u.trim().split(/\s+as\s+/);if(v&&!(l&&Bu.has(f)))n.push(v)}}return n}function so(e){let n=qt(e);if(!n||n.unsupported)return"";let r=new Set(be(e));return n.keys.filter((i)=>!r.has(i)).map((i)=>`declare const ${i}: InheritedContext[${JSON.stringify(i)}];`).join(`
1106
+ `)}function ea(e,n){let r=[Es],i=[],a=new Map,l=wt.resolve(n.filePath),u=l.split(wt.sep).lastIndexOf("views"),f=u>=0?l.split(wt.sep).slice(0,u).join(wt.sep):wt.dirname(l),v=wt.resolve(n.partialsDir||wt.join(f,"partials")),S=wt.resolve(n.layoutsDir||wt.join(f,"views/layouts"));if([v,S].some((Y)=>l===Y||l.startsWith(Y+wt.sep)))return{declarations:"",checks:i,dependencies:a};let j=(Y)=>n.readTemplate?.(Y)??(Qo.existsSync(Y)?Qo.readFileSync(Y,"utf8"):void 0),O=0,H=!1,D=[];function W(Y,J){let te=e.slice(0,Y).split(`
1107
+ `).length,K=Y-e.lastIndexOf(`
1108
+ `,Y-1),q={code:e.slice(Y,e.indexOf(`
1109
+ `,Y)<0?e.length:e.indexOf(`
1110
+ `,Y)),line:te,column:K,kind:"directive",offset:Y,anchor:!0};i.push({expression:q,statement:{text:`;${J}`,prefixLength:1}})}function N(Y,J,te,K,q,oe){let le=`__StxInherited${O++}`;while((e+Y+[...a.values()].join("")).includes(le))le+="_";let ue=Ce(Y).filter((Fe)=>Fe.kind==="server").map((Fe)=>Fe.code).join(`
1111
+ `),fe=`${le}ParentValue`,Re=`${le}ParentType`;r.push(`type ${Re} = ${te};`);let Ae=mr(js(ue,wt.dirname(J)),le);r.push(...Ae.imports);let _e=qt(ue);if(_e&&q!==void 0){H=!0;let Fe=Ae.imports.length?Ae.aliases.join(`
1112
+ `):"",ct=ks(`${Fe}
1113
+ ${_e.types}
1114
+ const __contract = defineProps<InheritedContext>();`,`${le}Contract`);r.push(ct.declarations),r.push(`declare const ${le}Input: ${Re};`),W(q,_e.unsupported?`({})[${JSON.stringify(_e.unsupported)}];`:`${le}Input satisfies ${ct.props};`)}let de=[...new Set([...be(ue),...Wu(ue)])],We=[...new Set([...K,..._e?.keys||[]])].filter((Fe)=>!de.includes(Fe)),Ve=_e?`${Re} & ${le}Contract.__StxProps`:Re,st=An(Ae.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),it=[],At=mn(Y),$t=/@(include|extends|layout)\s*\(/g,ot;while(ot=$t.exec(At)){let Fe=Kn(At,$t.lastIndex-1);if(!Fe)continue;$t.lastIndex=Fe.end;let ct=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(Fe.expression);if(!ct){D.push({offset:q??ot.index,message:`Inherited context cannot be checked across dynamic @${ot[1]}`});continue}let lt=ct[2],De=ot[1];if(De!=="include"&&ct[3])D.push({offset:q??ot.index,message:`Inherited context cannot be checked for unsupported @${De} data arguments`});let Dt=De==="include"?v:S,Nt=wt.resolve(lt.startsWith(".")?wt.dirname(J):Dt,lt.endsWith(".stx")?lt:lt+".stx");if(j(Nt)===void 0){D.push({offset:q??ot.index,message:`Inherited context target cannot be resolved: ${lt}`});continue}it.push({name:`edge${it.length}`,target:Nt,kind:De,args:De==="include"?ct[3]||"{}":"{}",offset:q??ot.index})}let Et=`{ ...${fe}${de.length?", "+de.join(", "):""} }`;r.push(`namespace ${le} {
1115
+ ${Ae.aliases.join(`
1116
+ `)}
1117
+ export async function read(${fe}: ${q===void 0?"{}":Ve}) {
1118
+ ${We.length?`const { ${We.join(", ")} } = ${fe};`:""}
1119
+ ${st}
1120
+ return { context: ${Et}${it.map((Fe)=>`, ${Fe.name}: { ...${Et}, ...(${Fe.args}) }`).join("")} };
1121
+ }
1122
+ }`);for(let Fe of it){if(oe.includes(Fe.target)||oe.length>=32){D.push({offset:Fe.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let ct=j(Fe.target);a.set(Fe.target,ct),N(ct,Fe.target,`Awaited<ReturnType<typeof ${le}.read>>[${JSON.stringify(Fe.name)}]`,[...new Set([...K,...de])],Fe.offset,[...oe,Fe.target])}return le}if(N(e,l,"{}",[],void 0,[l]),H||n.contractsKnown)for(let Y of D)W(Y.offset,`({})[${JSON.stringify(Y.message)}];`);return{declarations:H?r.join(`
1123
+ `):"",checks:i,dependencies:a}}function oo(e,n){let r=Yt(e),i=fr(e);if(!i)return;let a;try{a=dr(e,"component")}catch(q){let oe=i.open,le=q instanceof Error?q.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(le)}];`,line:e.slice(0,oe).split(`
1124
+ `).length,column:oe-e.lastIndexOf(`
1125
+ `,oe-1),origin:"component"}],project:(ue)=>({code:ue,columns:new Map})}}let l=V(r).filter((q)=>{let oe=R(q.attrs);return xt(oe)&&oe.has("client")&&!oe.has("server")&&!oe.has("component")&&!oe.has("stx:component")&&!oe.has("src")}),u=l.map((q)=>e.slice(q.bodyStart,q.bodyEnd)).join(`
1126
+ `),f=Is(u,n),v=Qt(u).some((q)=>q.name==="ComponentState")||Os(u).includes("ComponentState"),S=Object.entries(a.properties||a.props||{}).map(([q,oe])=>`${JSON.stringify(q)}: ${gn(oe)}`).join("; "),j=[...new Set(f.map((q)=>q.name))],O=[`interface __StxMetadataProperties { ${S} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",v?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",v?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",v?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",v?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${j.map((q)=>JSON.stringify(q)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',v?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...j.map((q)=>`${JSON.stringify(q)}: typeof ${q};`),"}"].filter(Boolean).join(`
1127
+ `),H=-1;for(let q of l){let oe=q.bodyStart,le=e.slice(oe,q.bodyEnd),ue=t(le),fe=y(ue).depths,Re=[...ue.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Ae)=>fe[Ae.index]===0)??(Os(le).includes("ComponentState")?/\bComponentState\b/.exec(ue):void 0);if(Re){H=oe+Re.index;break}}let D=v&&H>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,H).split(`
1128
+ `).length,column:H-e.lastIndexOf(`
1129
+ `,H-1)}]:[],{start:W,code:N}=i,Y=t(N),J=y(Y).depths,te=new Map,K=!1;for(let q of N.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let oe=JSON.parse(q[0].slice(0,q[0].lastIndexOf(":")).trim());if(J[q.index]===1&&["properties","props"].includes(oe)){K=!0;continue}if(K&&J[q.index]===1)K=!1;if(K&&J[q.index]===2&&!te.has(oe))te.set(oe,W+q.index)}for(let[q,oe]of Object.entries(a.properties||a.props||{})){let le=te.get(q)??W,ue=e.slice(0,le).split(`
1130
+ `).length,fe=le-e.lastIndexOf(`
1131
+ `,le-1);if(!oe||typeof oe!=="object"||!["string","number","boolean","object","array"].includes(oe.type))D.push({text:`({})[${JSON.stringify(`Property ${q} must declare string, number, boolean, object or array`)}];`,line:ue,column:fe,origin:"component"});if(oe&&oe.default!==void 0)D.push({text:`const __stxDefault${D.length}: ${gn(oe)} = ${JSON.stringify(oe.default)};`,line:ue,column:fe,origin:"component"})}return{declarations:O,checks:D,project(q){let oe=new Map,le=[],ue=0;for(let fe of Is(q,n)){if(/^\s*this\s*:/.test(fe.parameters))continue;let Re=fe.parameterOffset,Ae=`this: __StxNativeComponent${fe.parameters.trim()?", ":""}`;le.push(q.slice(ue,Re),Ae);let _e=q.slice(0,Re).split(`
1132
+ `).length,de=Re-q.lastIndexOf(`
1133
+ `,Re-1),We=oe.get(_e)||[],Ve=We.at(-1),st=de+(Ve?Ve.generatedEnd-Ve.sourceEnd:0);We.push({sourceStart:de,sourceEnd:de,generatedStart:st,generatedEnd:st+Ae.length}),oe.set(_e,We),ue=Re}return le.push(q.slice(ue)),{code:le.join(""),columns:oe}}}}function na(e){let n=[],r=[],i=/@foreach\s*\(|@endforeach\b/g,a;while(a=i.exec(e)){if(a[0].startsWith("@endforeach")){let v=r.pop();if(v)v.end=a.index,n.push(v);continue}let l=Kn(e,i.lastIndex-1);if(!l)continue;let u=gr(l.expression),f=l.end;if(u)r.push({start:f,end:e.length,iterable:u.iterable,binding:u.key?`${u.value}, ${u.key}`:u.value});i.lastIndex=f}return n.sort((l,u)=>l.start-u.start)}function Vu(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function Ce(e){let n=[],r=Vu(e);for(let i of V(r)){let a=i.attrs.trim(),l=R(a),{bodyStart:u,bodyEnd:f}=i,v=e.slice(u,f);if(l.has("src")||l.has("component")||l.has("stx:component"))continue;if(!xt(l))continue;let S=l.has("server")?"server":l.has("client")?"client":"plain",j=Fu(e,u);n.push({kind:S,code:v,startLine:j,startColumn:Uu(e,u),offset:u,attrs:a})}return n}function Fu(e,n){let r=1;for(let i=0;i<n&&i<e.length;i++)if(e.charCodeAt(i)===10)r++;return r}function Uu(e,n){let r=e.lastIndexOf(`
1134
+ `,n-1)+1;return n-r+1}function mn(e){let n=e.split(""),r=(a,l)=>{for(let u=a;u<l&&u<n.length;u++)if(n[u]!==`
1135
+ `)n[u]=" "},i=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function da(e){let n=0,r="";for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r="";continue}if(a==='"'||a==="'"||a==="`"){r=a;continue}if(a==="("||a==="["||a==="{"){n++;continue}if(a===")"||a==="]"||a==="}"){n--;continue}if(a==="|"&&n===0){if(e[i+1]==="|"){i++;continue}if(e[i-1]==="|")continue;return e.slice(0,i)}}return e}var ga=new Set([":for","x-for","v-for"]),Ps=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,xr="__stx_interpolated",sa="__StxElement",ma="__StxTemplateValue",Hu=`type ${ma}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function ra(e){return e.replace(/\{\{[\s\S]*?\}\}/g,xr).replace(/\{!![\s\S]*?!!\}/g,xr)}function Zu(e,n,r){let i=0;for(let a=n;a<e.length;a++){let l=e[a];if(l==="{"){i++;continue}if(l!=="}"&&l!=="!")continue;if(e.startsWith(r,a)&&i===0)return a;if(l==="}"&&i>0)i--}return-1}function Fi(e,n,r="0"){let i=`__stxScript${r}`;while((e+n).includes(i))i+="_";let a=new Map,l=[],u=[],f=t(e),v=yr(e),S=[],j=0;for(let N=0;N<f.length;N++){let Y=f.startsWith("{{",N);if(!Y&&!f.startsWith("{!!",N))continue;let J=Y?2:3,te=Y?"}}":"!!}",K=Zu(f,N+J,te);if(K<0)continue;let q=N,oe=e.slice(q,K+te.length),le=oe.slice(J,-te.length);N=K+te.length-1;let ue=u.length,fe=en(v,q),Re=en(v,q+(Y?2:3));u.push({code:da(le),...Re});let Ae=`${i}_${ue}`,_e=oe.split(`
1136
+ `),de=_e[0].length;_e[0]=Ae+" ".repeat(Math.max(0,de-Ae.length));for(let it=1;it<_e.length;it++)_e[it]=_e[it].replace(/[^\r]/g," ");let We=a.get(fe.line)??[],Ve=We.at(-1),st=fe.column+(Ve?Ve.generatedEnd-Ve.sourceEnd:0);We.push({sourceStart:fe.column,sourceEnd:fe.column+de,generatedStart:st,generatedEnd:st+_e[0].length}),a.set(fe.line,We),S.push(e.slice(j,q),_e.join(`
1137
+ `)),j=q+oe.length}S.push(e.slice(j));let O=S.join("");if(!u.length)return{code:O,columns:a,declarations:l};let{imports:H,aliases:D,body:W}=mr(n,i);for(let N of H)l.push({text:N});l.push({text:`namespace ${i}Scope {
1138
+ ${D.join(`
1139
+ `)}
1140
+ export async function read() {
1141
+ ${An(W).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
1142
+ return {`});for(let[N,Y]of u.entries())l.push({text:`value${N}: (`}),l.push({text:Y.code,origin:{line:Y.line,column:Y.column}}),l.push({text:"),"});l.push({text:`}
1143
+ }
1144
+ }`});for(let N=0;N<u.length;N++)l.push({text:`declare var ${i}_${N}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${N}']`});return{code:O,columns:a,declarations:l}}function mr(e,n){let r=[],{imports:i,body:a}=xa(e),l=[],u=0;for(let f of i.split(/\n(?=import\b)/)){if(!f.trim())continue;let v=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(f);if(!v){r.push(f);continue}let S=`${n}Module${u++}`;r.push(`import * as ${S} from ${v[2]}`);let j=v[1],O=/\{([\s\S]*?)\}/.exec(j);for(let N of O?.[1].split(",")??[]){let[Y,J=Y]=N.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(Y==="default")l.push(`const ${J} = ${S}.default; type ${J} = import(${v[2]}).default`);else if(Y)l.push(`import ${J} = ${S}.${Y}`)}let H=j.replace(/\{[\s\S]*?\}/,""),D=/\*\s+as\s+(\w+)/.exec(H);if(D)l.push(`import ${D[1]} = ${S}`);let W=/^\s*([\w$]+)/.exec(H)?.[1];if(W)l.push(`const ${W} = ${S}.default; type ${W} = import(${v[2]}).default`)}return{imports:r,aliases:l,body:a}}function hr(e,n){let r=0;for(let i of e){if(n<i.generatedStart)break;if(n<i.generatedEnd)return i.sourceStart+Math.min(n-i.generatedStart,i.sourceEnd-i.sourceStart);r=i.sourceEnd-i.generatedEnd}return n+r}var Ku=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],qu=new RegExp(String.raw`^[ \t]*@(?:${Ku.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function An(e){return e.replace(qu,(n)=>n.replace(/[^\n]/g," "))}var ia=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function io(e){let n=mn(e),r=[],i=yr(n),a=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,l;while((l=a.exec(n))!==null){if(l[1]||l[3])continue;let v=l[2]??l[4]??"",S=l[2]!==void 0?2:3,j=da(v);if(!j.trim())continue;let O=l.index+S+(j.length-j.trimStart().length);r.push({code:j.trim(),...en(i,O),offset:O,kind:"interpolation"})}let u=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((l=u.exec(n))!==null){let f=l.index+l[0].length-1,v=0,S=f;for(;S<n.length;S++){let D=n[S];if(D==="(")v++;else if(D===")"){if(v--,v===0)break}}if(v!==0)continue;let j=n.slice(f+1,S),O=j.trim();if(u.lastIndex=S+1,!O)continue;let H=f+1+(j.length-j.trimStart().length);r.push({code:O,...en(i,H),offset:l.index,kind:"condition"})}Ps.lastIndex=0;while((l=Ps.exec(n))!==null){let f=l[1],v=l[3]??"",S=f.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(ia.has(S)||ia.has(f))continue;if(!v.trim())continue;let j=l.index+l[0].indexOf(l[2],l[0].indexOf(f)+f.length)+1;if(ga.has(S)){let H=v.match(/\s+(?:in|of)\s+/);if(!H||H.index===void 0)continue;let D=v.slice(H.index+H[0].length),W=H.index+H[0].length+(D.length-D.trimStart().length);r.push({code:ra(D.trim()),...en(i,j+W),offset:j+W,kind:"directive",attribute:S});continue}let O=v.length-v.trimStart().length;r.push({code:ra(v.trim()),...en(i,j+O),offset:j+O,kind:"directive",attribute:S})}return r.sort((f,v)=>f.line-v.line||f.column-v.column),r}var Ju=2000;function Xu(e,n){let r=0,i=Math.min(e.length,n+Ju);for(let a=n;a<i;a++){let l=e[a];if(l==="(")r++;else if(l===")"){if(r--,r===0)return e.slice(n+1,a)}}return null}function Gu(e){let n=new Map,r=(f,v)=>{let S=f.split(/[,[\]{}()\s]+/).filter(Boolean);for(let j of S){let O=j.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(O))continue;let H=S.length===1?v:void 0,D=n.get(O);if(!D)n.set(O,{name:O,iterable:H});else if(D.iterable!==H)D.iterable=void 0}},i=/^\$?[A-Z_$][\w$]*$/i,a=(f)=>{let v=f.trim();return i.test(v)?v:void 0};for(let f of e.matchAll(/@for(?:each|else)\s*\(/g)){let v=Xu(e,f.index+f[0].length-1);if(v===null)continue;let S=Wt(v);if(!S)continue;r(S.itemVar.replace(/=>/g," "),a(S.arrayExpr))}for(let f of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(f[1],f[2]==="of"?a(f[3]):void 0);for(let f of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(f[1]);let l=mn(e);Ps.lastIndex=0;let u;while((u=Ps.exec(l))!==null){let f=u[1].replace(/\..*$/,"");if(!ga.has(f))continue;let v=u[3].match(/\s+(?:in|of)\s+/);if(!v||v.index===void 0)continue;r(u[3].slice(0,v.index),a(u[3].slice(v.index+v[0].length)))}for(let f of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let v of f[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(v[1]);return[...n.values()].sort((f,v)=>f.name.localeCompare(v.name))}function be(e){return Xl(e)}var br=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],Yu={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string",$native:"declare var $native: boolean"};function gl(e=new Set){return[...br.filter((n)=>!e.has(n)).map((n)=>`declare var ${n}: any`),...Object.entries(Yu).filter(([n])=>!e.has(n)).map(([,n])=>n)].join(`
1145
+ `)}function ml(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function ha(e){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,r,i=!1,a=new Set,l=t(e);while((r=n.exec(l))!==null){i=!0;for(let u of Qu(r[1])){let f=u.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(f))a.add(f)}}return i?[...a]:null}function Qu(e){let n=[],r=0,i="";for(let a of e){if(a===","&&r===0){n.push(i),i="";continue}if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;i+=a}return n.push(i),n.filter((a)=>a.trim().length>0)}function xa(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],i=e.replace(n,(a)=>(r.push(a.trim()),a.split(`
1146
+ `).map(()=>"").join(`
1147
+ `)));return{imports:r.join(`
1148
+ `),body:i}}function Qt(e){let n=t(e),r=Array(n.length),i=0;for(let f=0;f<n.length;f++){let v=n[f];if(v==="}"||v===")"||v==="]")i=Math.max(0,i-1);if(r[f]=i,v==="{"||v==="("||v==="[")i++}let a=[],l=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,u;while((u=l.exec(n))!==null){if(r[u.index]!==0)continue;let f=u[1],v=u[2],S;if(f==="interface"){let j=n.indexOf("{",u.index);if(j===-1)continue;let O=0;S=-1;for(let H=j;H<n.length;H++)if(n[H]==="{")O++;else if(n[H]==="}"&&--O===0){S=H+1;break}if(S===-1)continue}else{let j=0;S=n.length;for(let O=n.indexOf("=",u.index)+1;O<n.length;O++){let H=n[O];if(H==="{"||H==="["||H==="("||H==="<")j++;else if(H==="}"||H==="]"||H===")"||H===">")j--;else if(j<=0&&(H===";"||H===`
1149
+ `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,O-40),O)))){S=H===";"?O+1:O;break}}}a.push({name:v,text:e.slice(u.index,S).replace(/^[ \t]*export[ \t]+/,"")}),l.lastIndex=S}return a}function ep(e){let n=t(e),r=[],i=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,a,l=0,u=0;while((a=i.exec(n))!==null){for(;u<a.index;u++){let S=n[u];if(S==="{"||S==="("||S==="[")l++;else if(S==="}"||S===")"||S==="]")l=Math.max(0,l-1)}if(l!==0)continue;let f=0,v=n.length;for(let S=a.index+a[0].length;S<n.length;S++){let j=n[S];if(j==="{"||j==="("||j==="[")f++;else if(j==="}"||j===")"||j==="]")f--;else if(f<=0&&(j===";"||j===`
1150
+ `)){v=j===";"?S+1:S;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(a.index,v)))r.push(e.slice(a.index,v).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function zi(e){let n=e.filter((a)=>a.kind==="server").map((a)=>a.code).join(`
1151
+ `);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=ba(n),i=e.filter((a)=>a.kind!=="server").flatMap((a)=>{let l=ep(a.code);if(!l.length)return[];return[...Qt(a.code).filter((u)=>!r.has(u.name)).map((u)=>u.text),...l]});return[n,...i].filter(Boolean).join(`
1152
+ `)}function ba(e){return new Set(Qt(e).map((n)=>n.name))}function hl(e,n=""){let r=ha(e),i=ba(n),a=Qt(e).filter((S)=>!i.has(S.name)).map((S)=>S.text);if(!r){let S=be(e).filter((j)=>!Vt(n,j));if(S.length===0&&a.length===0)return"";return["",`// ${sp}`,...a,...S.map((j)=>`declare var ${j}: any`)].join(`
1153
+ `)}if(r.length===0)return a.length>0?["",`// ${aa}`,...a].join(`
1154
+ `):"";let{imports:l,body:u}=xa(e),f=u.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),v=["",`// ${aa}`];if(l)v.push(l);return v.push(...a),v.push(`async function ${ca}() {`,f,` return { ${r.join(", ")} }`,"}",`type ${ua} = Awaited<ReturnType<typeof ${ca}>>`,...r.map((S)=>`declare var ${S}: ${ua}[${JSON.stringify(S)}]`)),v.join(`
1155
+ `)}function ya(e){let n=t(e),r=n.split(""),i=[],a=0,l=0;for(let f=0;f<r.length;f++){let v=r[f];if(v===`
1156
+ `)l=f+1;if(v==="{"||v==="("||v==="["){if(a===0&&v!=="("&&tp.test(n.slice(l,f))){let S=_a(n,f);if(S!==-1)i.push(...wa(n.slice(f,S+1)))}a++;continue}if(v==="}"||v===")"||v==="]"){a=Math.max(0,a-1);continue}if(a>0&&v!==`
1157
+ `)r[f]=" "}let u=be(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var tp=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function _a(e,n){let r=0;for(let i=n;i<e.length;i++){let a=e[i];if(a==="{"||a==="("||a==="[")r++;else if(a==="}"||a===")"||a==="]")r--;if(r===0)return i}return-1}function np(e){let n=[],r=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r--;else if(l===","&&r===0)n.push(e.slice(i,a)),i=a+1}return n.push(e.slice(i)),n}function oa(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="{"||i==="("||i==="[")n++;else if(i==="}"||i===")"||i==="]")n--;else if(n===0&&(i===":"||i==="="))return{index:r,char:i}}return null}function wa(e){let n=[],r=(a)=>{let l=a.trim().replace(/^\.\.\./,"").trim();if(l.startsWith("{")||l.startsWith("[")){let f=_a(l,0);if(f!==-1)n.push(...wa(l.slice(0,f+1)));return}let u=oa(l);if(u)l=l.slice(0,u.index).trim();if(/^[A-Z_$][\w$]*$/i.test(l))n.push(l)},i=e.slice(1,-1);for(let a of np(i)){if(!a.trim())continue;if(e[0]==="["){r(a);continue}let l=oa(a);r(l?.char===":"?a.slice(l.index+1):a)}return n}function yl(e,n){if(ha(e)!==null)return[];let r=ya(e),i=Be(n,new Set(r)),a=new Set(C);return r.filter((l)=>{if(a.has(l))return!1;if(Vt(n,l))return!1;return i.has(l)})}var aa="stx: types for the declared client payload (#1868)",sp="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",ca="__stxServerScope",ua="__StxClientPayload";var pa=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];var rp=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function ip(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let i of e){let a=t(i),{depths:l,balanced:u}=y(a);if(!u)continue;let f=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let v of a.matchAll(f)){let S=v.index??0;if(l[S+v[1].length]!==0)continue;let j=v[2],O=S+v[0].length-v[3].length,H=i.slice(O,S+v[0].length).trim().replace(/;$/,"").trim(),D=v[3],W=r.test(D)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(D)&&!/[,+\-*/%&|?:=]$/.test(H)&&y(D).balanced;n.set(j,n.has(j)||!W?null:H)}}return new Map([...n].filter((i)=>i[1]!==null))}function va(e,n,r=0,i=new Set){if(n.size===0||r>=5)return e;let a=t(e),l="",u=0;for(let f of a.matchAll(/[A-Za-z_$][\w$]*/g)){let v=f.index??0,S=f[0],j=n.get(S);if(!j||i.has(S))continue;let O=a.slice(0,v).trimEnd(),H=a.slice(v+S.length).trimStart();if(O.endsWith(".")||/^:(?!:)/.test(H)&&/[{,]$/.test(O))continue;if(v>0&&/[\w$]/.test(a[v-1]))continue;l+=`${e.slice(u,v)}(${va(j,n,r+1,new Set([...i,S]))})`,u=v+S.length}return l+e.slice(u)}function op(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,i=[],a;while((a=r.exec(e))!==null){if(a.index>n)break;let l=a[1];if(a.index===n){if(l==="elseif"){let f=i[i.length-1];if(f?.current)f.seen.push(f.current);if(f)f.current=null}break}if(l==="endif"||l==="endunless"){i.pop();continue}let u="";if(a[2]==="("){let f=0,v=a.index+a[0].length-1,S=v+1;for(;v<e.length;v++){let j=e[v];if(j==="(")f++;else if(j===")"){if(f--,f===0)break}}u=e.slice(S,v).trim(),r.lastIndex=v+1}if(l==="if")i.push({seen:[],current:u});else if(l==="unless")i.push({seen:[],current:`!(${u})`});else if(l==="elseif"||l==="else"){let f=i[i.length-1];if(!f)continue;if(f.current)f.seen.push(f.current);f.current=l==="elseif"?u:null}}return i.flatMap((l)=>[...l.seen.map((u)=>`!(${u})`),...l.current?[l.current]:[]]).filter(Boolean)}function ap(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(rp.test(n))return null;let i=";(($event: any): void => { ";return{text:`${i}${n} });`,prefixLength:i.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var cp=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function js(e,n){return ao(e,n).code}function ao(e,n){let r=new Map;if(!n)return{code:e,columns:r};let i=yr(e),a=[],l=0;for(let u of e.matchAll(cp)){let f=u.index,[v,S,j,O]=u,H=fa.resolve(n,O).replace(/\\/g,"/"),D=`${S}${j}${H}${j}`;if(a.push(e.slice(l,f),D),l=f+v.length,v.includes(`
1158
+ `))continue;let W=en(i,f),N=r.get(W.line)??[],Y=N.at(-1),J=W.column+(Y?Y.generatedEnd-Y.sourceEnd:0);N.push({sourceStart:W.column,sourceEnd:W.column+v.length,generatedStart:J,generatedEnd:J+D.length}),r.set(W.line,N)}return a.push(e.slice(l)),{code:a.join(""),columns:r}}function lp(e,n,r){let i=hr(e.importColumns?.get(n)??[],r);return hr(e.scriptColumns?.get(n)??[],hr(e.componentColumns?.get(n)??[],i))}function Hi(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Os(e){let n=new Set,r=t(e);for(let i of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let a=i[1],l=/\{([^}]*)\}/.exec(a);for(let S of l?.[1].split(",")??[]){let j=S.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(j&&/^[A-Z_$][\w$]*$/i.test(j))n.add(j)}let u=a.replace(/\{[^}]*\}/,""),f=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(u);if(f)n.add(f[1]);let v=/^\s*([A-Z_$][\w$]*)/i.exec(u);if(v&&v[1]!=="type")n.add(v[1])}return[...n].sort()}function Ui(e,n={}){let r=Ce(e),i=n.scriptKinds?r.filter((q)=>n.scriptKinds.includes(q.kind)):r,a=oo(e,n.componentMethodValidator),l=n.filePath&&n.templateExpressions!==!1?ea(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,u=new Map,f=e.split(`
1159
+ `),v=Array.from({length:f.length},()=>""),S=new Map,j=new Map,O=new Map,H=[],D=zi(r),W=n.filePath&&n.templateExpressions!==!1?Bo(e,mn(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(q,oe)=>Ce(q).map((le)=>js(le.code,fa.dirname(oe))).join(`
1160
+ `)}):void 0,N=new Set,Y=[];for(let[q,oe]of i.entries()){let le=Fi(Hi(oe)+oe.code,D,String(q));for(let[_e,de]of le.columns)j.set(oe.startLine+_e-1,de);for(let _e of le.declarations)H.push({text:js(_e.text,n.originDir??""),origin:_e.origin?{..._e.origin,line:_e.origin.line+oe.startLine-1}:void 0});let ue=oe.kind==="client"&&a?a.project(le.code):void 0;for(let[_e,de]of ue?.columns??[])u.set(oe.startLine+_e-1,de);let fe=An(ue?.code??le.code),Re=ao(fe,n.originDir??"");for(let[_e,de]of Re.columns)O.set(oe.startLine+_e-1,de);let Ae=Re.code.split(`
1161
+ `);Ae.forEach((_e,de)=>{let We=oe.startLine-1+de;if(We<v.length)v[We]=_e,N.add(We)}),Y.push(oe.startLine-1+Ae.length-1)}for(let q of Y){let oe=v[q]?.trim()===""?q:q+1;if(oe<v.length&&v[oe].trim()===""&&(oe===q||!N.has(oe)))v[oe]=";"}let J=(q,oe)=>{for(let[le,ue]of q.split(`
1162
+ `).entries())if(v.push(ue),oe)S.set(v.length,le===0?oe:{...oe,line:oe.line+le,column:1,prefixLength:0})},te=so(i.filter((q)=>q.kind==="server").map((q)=>q.code).join(`
1163
+ `));if(te)J(te);for(let q of i.filter((oe)=>oe.kind==="server")){let oe=qt(q.code);if(!oe?.unsupported)continue;let le=q.code.slice(0,oe.offset),ue=q.startLine+le.split(`
1164
+ `).length-1,fe=oe.offset-q.code.lastIndexOf(`
1165
+ `,oe.offset-1)+(ue===q.startLine?(q.startColumn??1)-1:0);J(`;({})[${JSON.stringify(oe.unsupported)}];`,{line:ue,column:fe,anchor:!0})}if(l?.declarations)J(l.declarations);for(let q of H)J(q.text,q.origin);if(a){if(J(a.declarations),n.nativeChecks!==!1)for(let q of a.checks)J(q.text,{line:q.line,column:q.column,diagnosticOrigin:q.origin,anchor:!0})}if(n.globals!==!1){J("");let q=new Set([...i.flatMap((fe)=>be(fe.code)),...i.flatMap((fe)=>Os(fe.code))]),oe=(fe)=>{if(!q.has(fe)&&!n.declaredGlobals?.includes(fe))J(`declare var ${fe}: any`)};if(n.runtimeGlobals!==!1){if(!q.has("window"))J("declare var window: any");for(let fe of C)oe(fe)}let le=[...new Set([...br,...Ne,...pa])].filter((fe)=>!n.declaredGlobals?.includes(fe)&&(n.runtimeGlobals!==!1||!C.includes(fe)));if(n.contextScope==="global"){J("declare global {");for(let fe of le)J(` var ${fe}: any`);J("}")}else{for(let fe of br)oe(fe);for(let fe of Ne)oe(fe);for(let fe of pa)oe(fe)}J(`declare var ${xr}: any`);let ue=new Set(i.flatMap((fe)=>be(fe.code)));J(`type ${sa}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let fe of a?[]:Gu(e)){if(ue.has(fe.name))continue;let Re=fe.iterable&&ue.has(fe.iterable)?`${sa}<typeof ${fe.iterable}>`:"any";J(`declare var ${fe.name}: ${Re}`)}}if(n.templateExpressions!==!1){if(W?.declarations)for(let oe of W.declarations.split(`
1166
+ `))J(oe);let q=io(e).map((oe)=>{let le=W?.events.get(oe.offset??-1);if(le){oe.anchor=!0;let ue=oe.code.trim(),fe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(ue),Re=fe?`void ((${fe[2]}) satisfies __StxAssignedValue<typeof ${fe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(ue)?`${ue} satisfies (($event: ${le}) => unknown)`:ue,Ae=`;(($event: ${le}): void => { `;return{expression:oe,statement:{text:`${Ae}${Re} });`,prefixLength:Ae.length}}}return{expression:oe,statement:ap(oe)}}).filter((oe)=>oe.statement!==null);if(q.push(...W?.checks||[],...l?.checks||[]),q.length>0){let oe=mn(e),le=$s(oe),ue=a?na(oe):[];if(a)J("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let fe=ip(i.map((de)=>de.code)),Ae=[...new Set(i.flatMap((de)=>be(de.code)))].filter((de)=>/^[A-Z_$][\w$]*$/i.test(de)),_e=0;if(a)J("function __stxNativeTemplate(this: __StxNativeComponent) {");if(Ae.length>0){J(Hu);for(let de of Ae)J(`function __StxRead_${de}() { return ${de} }`),J(`type __StxT_${de} = ${ma}<ReturnType<typeof __StxRead_${de}>>`);J(`;((${Ae.map((de)=>`${de}: __StxT_${de}`).join(", ")}) => {`),_e=1}for(let{expression:de,statement:We}of q){let Ve=" ".repeat(_e),st=de.offset===void 0?[]:le.filter((De)=>de.offset>=De.start&&de.offset<De.end),it=de.offset===void 0?[]:ue.filter((De)=>de.offset>=De.start&&de.offset<De.end),At=it.map((De)=>`;__stxEach(${De.iterable}, (${De.binding}) => { `).join(""),$t=" });".repeat(it.length),ot=At+st.map((De)=>`;((${De.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),Et=" });".repeat(st.length)+$t,Fe=de.offset===void 0?[]:op(oe,de.offset),ct=Fe.length>0?`${Fe.map((De)=>`if (${va(De,fe)}) `).join("")}{ `:"",lt=Fe.length>0?" }":"";J(Ve+ot+ct+We.text+lt+Et,{line:de.line,column:de.column,expression:de,prefixLength:We.prefixLength+Ve.length+ot.length+ct.length,guardPrefixLength:Ve.length+ot.length+ct.length})}if(_e>0)J("});");if(a)J("}")}}let K=!1;if(n.reference&&v[0]!==void 0&&v[0].trim()==="")v[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,K=!0;return J("export {}"),{text:v.join(`
1167
+ `),lineMap:S,sourceLineCount:f.length,componentDependencies:new Map([...W?.dependencies??[],...l?.dependencies??[]]),referenced:K,scriptColumns:j,importColumns:O,componentColumns:u}}function yr(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function en(e,n){let r=0,i=e.length-1;while(r<i){let a=Math.ceil((r+i)/2);if(e[a]<=n)r=a;else i=a-1}return{line:r+1,column:n-e[r]+1}}function bl(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Vi(e,n,r){let i=e.lineMap.get(n);if(!i)return n<=e.sourceLineCount?{line:n,column:lp(e,n,r)}:null;let a=i.anchor||i.expression?.anchor||i.diagnosticOrigin==="component"?0:Math.max(0,r-1-(i.prefixLength??0));return{line:i.line,column:i.column+a,expression:i.expression,diagnosticOrigin:i.diagnosticOrigin,inGuard:r<=(i.guardPrefixLength??0)}}function co(e){let n=new Set;for(let r of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let i=r[1];if(!/\bclient\b/.test(i)||/\bserver\b/.test(i))continue;for(let a of ya(r[2]))n.add(a);for(let a of r[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])n.add(a[1]);if(a[3])n.add(a[3]);for(let l of(a[2]??"").split(",")){let u=l.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(u))n.add(u)}}}return n}var _r=k(256),up=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],$a=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function pp(e){let n=Array.from(e,(a)=>a===`
1168
+ `?`
1169
+ `:" "),r=0,i="";while(r<e.length){let a=e[r],l=e[r+1];if(i){if(a==="\\"){r+=2;continue}if(a===i)i="";r++;continue}if(a==='"'||a==="'"||a==="`"){i=a,r++;continue}if(a==="/"&&l==="/"){while(r<e.length&&e[r]!==`
1170
+ `)n[r]=e[r],r++;continue}if(a==="/"&&l==="*"){let u=e.indexOf("*/",r+2),f=u===-1?e.length:u+2;for(;r<f;r++)n[r]=e[r];continue}if(a==="{"&&l==="{"&&e.slice(r,r+4)==="{{--"){let u=e.indexOf("--}}",r+4),f=u===-1?e.length:u+4;for(;r<f;r++)n[r]=e[r];continue}r++}return n.join("")}function fp(e){let n=new Map,r=pp(e).split(`
1171
+ `),i=e.split(`
1172
+ `);return r.forEach((a,l)=>{$a.lastIndex=0;for(let u of a.matchAll($a)){let f=u[1]==="-next-line",v=(i[l]??"").slice(0,u.index).trim(),S=f||v===""?l+2:l+1,O=(u[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),H=O.filter((W)=>/\w/.test(W));if(O.length>0&&H.length===0)continue;let D=n.get(S);if(D&&D.size===0)continue;if(H.length===0){n.set(S,new Set);continue}if(D)H.forEach((W)=>D.add(W));else n.set(S,new Set(H))}}),n}function dp(e,n,r){let i=e.get(n);if(!i)return!1;if(i.size===0)return!0;return[...i].some((a)=>r.includes(a))}function Ke(e,n,r,i){let a=typeof r==="boolean"?{enabled:r,failOnViolation:r}:r??{enabled:!1};if(!a.enabled)return;let l=E(e,n,i,JSON.stringify(a)),u=_r.get(l);if(u!==void 0){if(u&&a.failOnViolation)throw new ne(u,i??n);return}let f=a.allowPatterns??[],v=fp(e),S=[],j=t(e.replace(/\{\{--[\s\S]*?--\}\}/g,(W)=>W.replace(/[^\n]/g," ")));for(let{pattern:W,message:N,suggestion:Y}of up){if(f.some((te)=>/\w/.test(te)&&N.includes(te)))continue;W.lastIndex=0;let J=j.match(W);if(J&&J.length>0){let te=j.split(`
1173
+ `),K=e.split(`
1174
+ `),q=[];if(te.forEach((fe,Re)=>{if(W.lastIndex=0,W.test(fe)&&!dp(v,Re+1,N))q.push(Re+1)}),q.length===0&&te.some((fe)=>(W.lastIndex=0,W.test(fe))))continue;let oe=q.length>0?` (script line${q.length>1?"s":""} ${q.join(", ")})`:"",le=q.slice(0,3).map((fe)=>` ${fe} | ${(K[fe-1]??"").trim().slice(0,100)}`).join(`
1175
+ `),ue=le?`
1176
+ ${le}`:"";S.push(` \u2717 ${N}${oe}
1177
+ \u2192 ${Y}${ue}`)}}if(S.length===0){_r.set(l,"");return}let O=(W)=>{let N=`${process.cwd()}/`;return W.startsWith(N)?W.slice(N.length):W},D=`[STX] DOM API violation in ${i&&i!==n?`${O(i)} (composed into ${O(n)})`:O(n)}:
1178
+ ${S.join(`
1179
+ `)}
1180
+ Tip: prefer useRef(), navigate(), and composables for component code`;if(_r.set(l,D),console.warn(D),a.failOnViolation)throw new ne(D,i??n)}var gp=new Set(["computed","inject","nextTick","onBeforeMount","onBeforeUnmount","onMounted","onUnmounted","provide","reactive","ref","useSlots","watch","watchEffect"]);function po(e,n){if(!n.endsWith(".stx")||!e.includes("vue")||!e.includes("setup"))return e;let r=/^([ \t]*import\s*\{)([^}]*)(\}\s*from\s*)(['"])vue\4/gm,i=/^([A-Za-z_$][\w$]*)(?:\s+as\s+[A-Za-z_$][\w$]*)?$/,a=[],l=0;for(let u of V(e)){let f=R(u.attrs);if(!f.has("setup")||f.has("server")||f.has("src")||!xt(f))continue;let v=e.slice(u.bodyStart,u.bodyEnd);if(!v.includes("vue"))continue;let S=t(v),j=v.replace(r,(O,H,D,W,N,Y)=>{if(S.slice(Y,Y+H.length).trimStart().slice(0,6)!=="import")return O;return D.split(",").filter((te)=>te.trim()).every((te)=>{let K=i.exec(te.trim())?.[1];return K!==void 0&&gp.has(K)})?H+D+W+N+"stx"+N:O});if(j===v)continue;a.push(e.slice(l,u.bodyStart),j),l=u.bodyEnd}return a.length?a.join("")+e.slice(l):e}var mp=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),hp=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function sn(e,n){let r=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;r.lastIndex=n;let i=r.exec(e);if(!i)return null;let a=/\/\s*>$/.test(i[0])||i[1]===i[1].toLowerCase()&&mp.has(i[1]),l=a?i[2].replace(/\/\s*$/,""):i[2];return{full:i[0],tag:i[1],attrs:l,selfClosing:a,start:i.index,end:i.index+i[0].length}}function xp(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),u=new RegExp(`</${n}\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a;let f=l.exec(e),v=u.exec(e);if(!v)return-1;if(f&&f.index<v.index)i++,a=f.index+f[0].length;else{if(i--,i===0)return v.index+v[0].length;a=v.index+v[0].length}}return-1}function nn(e,n){if(n.selfClosing)return{outerStart:n.start,outerEnd:n.end,innerHTML:""};let r=xp(e,n.tag,n.end);if(r===-1)return{outerStart:n.start,outerEnd:n.end,innerHTML:""};return{outerStart:n.start,outerEnd:r,innerHTML:e.slice(n.end,r-`</${n.tag}>`.length)}}function Sa(e,n){return new RegExp(`(?:^|\\s)${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(e)||e.includes(` ${n}=`)||e.includes(` ${n} `)||e.trimEnd().endsWith(` ${n}`)}function Jn(e,n){let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=e.match(new RegExp(`${r}="([^"]*)"`,"s"))||e.match(new RegExp(`${r}='([^']*)'`,"s"));return i?i[1]:null}function Mt(e,n){let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`\\s*${r}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${r}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${r}(?=\\s|$|>|/)`,"g"),"")}function hn(e,n,r){let i=n.selfClosing?" /":"",a=`<${n.tag}${r}${i}>`;return e.slice(0,n.start)+a+e.slice(n.end)}function bp(e){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(e)||Ea.test(e)}var Ea=/\s(?:v-bind)?:[a-zA-Z_][\w-]*(?=[\s/>])(?!\s*=)/;function yp(e){if(!Ea.test(e))return e;let n=/([^\s="'<>]+)(\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>]+))?/g,r=/^(?:v-bind)?:([a-zA-Z_][\w-]*)$/,i=[],a=0;for(let l of G(e)){if(l.closing||!l.attributes.includes(":"))continue;let u=l.attributes.replace(n,(v,S,j)=>{let O=j===void 0?r.exec(S)?.[1]:void 0;if(!O||ts(O))return v;let H=O.replace(/-([a-zA-Z0-9])/g,(D,W)=>W.toUpperCase());return`:${O}="${H}"`});if(u===l.attributes)continue;let f=l.start+l.name.length+1;i.push(e.slice(a,f),u),a=f+l.attributes.length}return i.length?i.join("")+e.slice(a):e}function _p(e){let n=e,r=0;while(r<n.length){let i=sn(n,r);if(!i)break;let a=Jn(i.attrs,"v-for");if(a===null){r=i.end;continue}let l=a.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!l){r=i.end;continue}let u=l[1].trim(),f=l[2].trim(),v;if(u.includes(",")){let Y=u.split(",").map((K)=>K.trim()),J=Y[0],te=Y[1];v=`${f} as ${te} => ${J}`}else v=`${f} as ${u}`;let S=Mt(i.attrs,"v-for"),j=Mt(S,":key").replace(/\s*v-bind:key="[^"]*"/g,""),O=nn(n,i),H=n.slice(O.outerStart,O.outerEnd),D=hn(H,{...i,start:0,end:i.end-i.start},j),W=`@foreach(${v})
1181
+ `,N=`${W}${D}
1182
+ @endforeach`;n=n.slice(0,O.outerStart)+N+n.slice(O.outerEnd),r=O.outerStart+W.length}return n}function wp(e){let n=e,r=0;while(r<n.length){let i=sn(n,r);if(!i)break;let a=Jn(i.attrs,"v-if");if(a===null){r=i.end;continue}let l=[],u=nn(n,i),f=Mt(i.attrs,"v-if"),v=hn(n.slice(u.outerStart,u.outerEnd),{...i,start:0,end:i.end-i.start},f);l.push({type:"if",expr:a,outerStart:u.outerStart,outerEnd:u.outerEnd,element:v,parsedTag:i});let S=u.outerEnd,j=!0;while(j){let N=n.slice(S).match(/^\s*/),Y=N?N[0].length:0,J=sn(n,S+Y);if(!J){j=!1;break}let te=Jn(J.attrs,"v-else-if"),K=Sa(J.attrs,"v-else");if(te!==null){let q=nn(n,J),oe=Mt(J.attrs,"v-else-if"),le=hn(n.slice(q.outerStart,q.outerEnd),{...J,start:0,end:J.end-J.start},oe);l.push({type:"else-if",expr:te,outerStart:S,outerEnd:q.outerEnd,element:le,parsedTag:J}),S=q.outerEnd}else if(K){let q=nn(n,J),oe=Mt(J.attrs,"v-else"),le=hn(n.slice(q.outerStart,q.outerEnd),{...J,start:0,end:J.end-J.start},oe);l.push({type:"else",outerStart:S,outerEnd:q.outerEnd,element:le,parsedTag:J}),j=!1}else j=!1}let O=[];for(let N of l)if(N.type==="if")O.push(`@if(${N.expr})
1183
+ ${N.element}`);else if(N.type==="else-if")O.push(`@elseif(${N.expr})
1184
+ ${N.element}`);else O.push(`@else
1185
+ ${N.element}`);O.push("@endif");let H=O.join(`
1186
+ `),D=l[0].outerStart,W=l[l.length-1].outerEnd;n=n.slice(0,D)+H+n.slice(W),r=D+H.length}return n}function vp(e){return e.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function $p(e){let n=e,r=0;while(r<n.length){let i=sn(n,r);if(!i)break;let a=hp.has(i.tag),l=i.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(f,v,S)=>{let j=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(v);if(!j||!S||!/^["']/.test(S))return f;let O=j[1]||"modelValue",H=j[2];if(a&&!j[1])return`@model${H}=${S}`;let D=S[0],W=S.slice(1,-1),N=`:${O}=${S} @update:${O}=${D}${W} = $event${D}`;if(H){let Y=j[1]?`${O}Modifiers`:"modelModifiers",J=H.slice(1).split(".").map((te)=>`${te}: true`).join(", ");N+=` :${Y}="{ ${J} }"`}return N});if(l===i.attrs){r=i.end;continue}let u=hn(i.full,{...i,start:0,end:i.full.length},l);n=n.slice(0,i.start)+u+n.slice(i.end),r=i.start+u.length}return n}function Sp(e){return e.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Ep(e){return e.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function kp(e){let n=e,r=0;while(r<n.length){let i=sn(n,r);if(!i)break;let a=Jn(i.attrs,"v-html");if(a===null){r=i.end;continue}if(i.selfClosing){r=i.end;continue}let l=nn(n,i),u=Mt(i.attrs,"v-html"),f=i.selfClosing?" /":"",v=`<${i.tag}${u}${f}>{!! ${a} !!}</${i.tag}>`;n=n.slice(0,l.outerStart)+v+n.slice(l.outerEnd),r=l.outerStart+v.length}return n}function Cp(e){let n=e,r=0;while(r<n.length){let i=sn(n,r);if(!i)break;let a=Jn(i.attrs,"v-text");if(a===null){r=i.end;continue}if(i.selfClosing){r=i.end;continue}let l=nn(n,i),u=Mt(i.attrs,"v-text"),f=i.selfClosing?" /":"",v=`<${i.tag}${u}${f}>{{ ${a} }}</${i.tag}>`;n=n.slice(0,l.outerStart)+v+n.slice(l.outerEnd),r=l.outerStart+v.length}return n}function Rp(e){return e.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function Ap(e){let n=e,r=0;while(r<n.length){let i=sn(n,r);if(!i)break;if(!Sa(i.attrs,"v-once")){r=i.end;continue}let a=Mt(i.attrs,"v-once"),l=nn(n,i),u=n.slice(l.outerStart,l.outerEnd),v=`@once
1187
+ ${hn(u,{...i,start:0,end:i.end-i.start},a)}
1188
+ @endonce`;n=n.slice(0,l.outerStart)+v+n.slice(l.outerEnd),r=l.outerStart+v.length}return n}function Tp(e){return e.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function Ip(e){return e.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Sl(e){if(!bp(e))return e;let n=yp(e);return n=_p(n),n=wp(n),n=Ap(n),n=Sp(n),n=Ep(n),n=$p(n),n=vp(n),n=Ip(n),n=kp(n),n=Cp(n),n=Rp(n),n=Tp(n),n}var jp=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],Op=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],Pp=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function Gg(e){let n=[],r=[];return Mp(e,n),Dp(e,n,r),Np(e,r),Lp(e,n),{valid:n.length===0,errors:n,warnings:r}}function Mp(e,n){let r=(e.match(/\{\{/g)||[]).length,i=(e.match(/\}\}/g)||[]).length;if(r!==i)n.push({type:"expression",message:`Unclosed expression brackets: found ${r} opening '{{' and ${i} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function Dp(e,n,r){for(let i of jp){let a=new RegExp(`${i.open}(?:\\s|\\()`,"g"),l=new RegExp(i.close,"g"),u=(e.match(a)||[]).length,f=(e.match(l)||[]).length;if(i.altClose){let v=new RegExp(i.altClose,"g");f+=(e.match(v)||[]).length}if(u>f)n.push({type:"directive",message:`Unclosed @${i.name} directive: found ${u} opening and ${f} closing`,suggestion:`Add ${u-f} missing ${i.close} tag(s)`});else if(f>u)r.push({type:"directive",message:`Extra ${i.close} found: ${f-u} more closing than opening`,suggestion:`Check for orphaned ${i.close} tags`})}}function Np(e,n){for(let r of Op)if(r.pattern.test(e))n.push({type:"syntax",message:r.message,suggestion:r.suggestion})}function Lp(e,n){for(let r of Pp)if(r.pattern.test(e))n.push({type:"expression",message:`Security warning: ${r.message}`,suggestion:"Remove dangerous code from template expressions"})}function Jg(e,n){let r=e.slice(0,n).split(`
1189
+ `);return{line:r.length,column:r[r.length-1].length+1}}function Yg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function Zg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function Qg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function ka(e,n,r){let i=/^<script\b([^>]*)>/i.exec(e);if(!i||!/(?:^|\s)src\s*=/i.test(i[1]??""))return null;return I(i[0],n,r)+e.slice(i[0].length)}var Xn=new T(500),$r=new Map;function Ca(e){try{let n=Ls.statSync(e);return`${n.size}:${n.mtimeMs}`}catch{return""}}var Ds=new T(1000),Sr=new Map,Er=new T(2000),kr=new T(500),Da=33554432,Cr=Da;function zp(e){let n=e.componentRenderCacheBytes;if(typeof n!=="number"||n<0||n===Cr)return;Cr=n,Ns.setMaxBytes(n)}var Ns=new T(2000,{maxBytes:Da,sizeOf:(e)=>e.output.length});function Bp(e){let n=new WeakSet;try{let r=(i)=>{if(i===void 0)return{__stxType:"undefined"};if(typeof i==="bigint")return{__stxType:"bigint",value:i.toString()};if(typeof i==="function"||typeof i==="symbol")throw TypeError("Non-serializable component input");if(i===null||typeof i!=="object")return i;if(n.has(i))throw TypeError("Circular component input");n.add(i);try{if(i instanceof Date)return{__stxType:"date",value:i.toISOString()};if(Array.isArray(i))return i.map(r);let a=Object.getPrototypeOf(i);if(a!==Object.prototype&&a!==null)throw TypeError("Non-plain component input");let l={};for(let u of Object.keys(i).sort())l[u]=r(i[u]);return l}finally{n.delete(i)}};return JSON.stringify(r(e))}catch{return null}}function Wp(e){let n={};for(let[r,i]of Object.entries(e))if(!r.startsWith("__")||r==="__stxServeContext")n[r]=i;return n}function wr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function mo(e){let n=process.cwd(),r=`${n}\x00${e}`,i=Ra.get(r);if(i===void 0)i=Bun.hash(Na(e,n).split(xe.sep).join("/")).toString(36).slice(0,6),Ra.set(r,i);return i}var Ra=new Map;function Na(e,n){if(!xe.isAbsolute(e))return e;let r=(i)=>{try{return Ls.realpathSync(i)}catch{return i}};return xe.relative(r(n),r(e))}function em(e){return/\bjs\b/.test(e)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(e)}function Je(e){return!em(e)}var Ms=new Map;function ae(e){let n;try{n=JSON.stringify(e)}catch{return new Bun.Transpiler(e)}let r=Ms.get(n);if(r)return r;if(Ms.size>=16)Ms.clear();let i=new Bun.Transpiler(e);return Ms.set(n,i),i}var Aa=new WeakMap,Vp=256;function Ye(e){try{let n=ae({loader:"ts",target:"browser",define:P()}),r=Aa.get(n);if(!r)r=new Map,Aa.set(n,r);let i=r.get(e);if(i!==void 0)return i;let a=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");a=a.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let l=[];a=a.replace(/\{!![\s\S]*?!!\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{\{[\s\S]*?\}\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{[\s\S]*?\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`});let u=n.transformSync(a);for(let f=0;f<l.length;f++)u=u.replace(`"__STX_EXPR_${f}__"`,l[f]),u=u.replace(`'__STX_EXPR_${f}__'`,l[f]);if(r.size>=Vp){let f=r.keys().next();if(!f.done)r.delete(f.value)}return r.set(e,u),u}catch(n){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",n);return e}}function Fp(e){let n=[],r=new Set,i=0,a=0,l=e.length,u=(D)=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]===D){a++;return}a++}},f=()=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]==="`"){a++;return}if(e[a]==="$"&&e[a+1]==="{"){a+=2;let D=1;while(a<l&&D>0)if(e[a]==="{")D++,a++;else if(e[a]==="}")D--,a++;else if(e[a]==="'"||e[a]==='"')u(e[a]);else if(e[a]==="`")f();else a++;continue}a++}},v=()=>{if(e[a]==="/"&&e[a+1]==="/"){while(a<l&&e[a]!==`
1190
+ `)a++;return!0}if(e[a]==="/"&&e[a+1]==="*"){a+=2;while(a<l-1&&!(e[a]==="*"&&e[a+1]==="/"))a++;return a+=2,!0}return!1},S=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]),j=()=>{let D=a-1;while(D>=0&&/\s/.test(e[D]))D--;if(D<0)return!0;let W=e[D];if("(,=:[!&|?{};+-*%<>~^".includes(W))return!0;if(!/[\w$]/.test(W))return!1;let N=D;while(N>0&&/[\w$]/.test(e[N-1]))N--;return S.has(e.slice(N,D+1))},O=()=>{a++;let D=!1;while(a<l&&e[a]!==`
1191
+ `){let W=e[a];if(W==="\\"){a+=2;continue}if(W==="[")D=!0;else if(W==="]")D=!1;else if(W==="/"&&!D){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},H=()=>{if(i!==0)return;let D=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(D){let J=D[2].split(",").map((te)=>{let K=te.trim().split(":");return K[K.length-1].trim()});for(let te of J)if(te&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(te)&&!r.has(te))n.push(te),r.add(te);return}let W=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let J=W[2];if(!r.has(J))n.push(J),r.add(J);return}let N=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(N){let J=N[1];if(!r.has(J))n.push(J),r.add(J);return}let Y=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let J=Y[1];if(!r.has(J))n.push(J),r.add(J)}};while(a<l){if(v())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&j()){O();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))H();a++}return n}function Up(e,n,r){for(let i of V(e)){let a=R(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!xt(a))continue;let l=dn(e.slice(i.bodyStart,i.bodyEnd));if(!l)continue;let u=Object.assign(Object.create(null),r);for(let[f,v]of Object.entries(l.defaults))if(u[f]===void 0)u[f]=Rs(v);for(let f of new Set([...l.propNames,...Object.keys(l.defaults)])){let v=l.localBindings[f]??(l.propBindings[f]?void 0:f);if(v)Object.defineProperty(n,v,{value:u[f],writable:!0,enumerable:!0,configurable:!0})}if(l.identifier)Object.defineProperty(n,l.identifier,{value:u,writable:!0,enumerable:!0,configurable:!0})}}var Hp=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function tm(e,n){let r=vt(e),i=e.slice(r).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);if(!i)return null;let a=i[1].toLowerCase();if(!Hp.has(a))return null;let l=new RegExp(`<\\/?${a}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),u=g(e,(j,O)=>(l.lastIndex=O,l.exec(j)?.index===O?l.lastIndex:-1));if(a==="span"&&/\sdata-stx-scope\s*=/.test(u[0]?.token||""))return null;let f=0,v=!1;for(let j of u){if(f+=j.token.startsWith("</")?-1:1,f<0)return null;if(f===0){if(e.slice(j.end).trim())return null;v=!0;break}}if(!v)return null;let S=r+i[0].length;return e.slice(0,S)+n+e.slice(S)}function La(e,n){if(!e)return!1;return[...n.additionalComponentsDirs??[],...n.fallbackComponentsDir?[n.fallbackComponentsDir]:[]].some((i)=>{let a=xe.relative(xe.resolve(i),xe.resolve(e));return!a.startsWith("..")&&!xe.isAbsolute(a)})}async function Wr(e,n,r,i,a){let l=e.endsWith(".stx")?e.slice(0,-4):e,u=(le)=>le.split("-").map((ue)=>ue.charAt(0).toUpperCase()+ue.slice(1)).join(""),f=r.__importedComponents;if(f){for(let le of[l,l.toLowerCase(),u(l),Q(l)])if(f.has(le))return!0}let v=[...new Set([`${l}.stx`,`${u(l)}.stx`,`${Q(l)}.stx`])],S=typeof a.root==="string"?xe.resolve(a.root):void 0,j=S??xe.dirname(i),O=[],H=(le)=>{if(le&&!O.includes(le))O.push(le)};for(let le of ms(i,S))H(le);let D=r.__originalFilePath;if(D)H(xe.join(xe.dirname(D),"components"));if(La(n,a))H(a._rootComponentsDir);H(n),H(a._rootComponentsDir),H(xe.join(xe.dirname(i),"components")),H(a.componentsDir);for(let le of a.additionalComponentsDirs??[])H(le);let W=a._targetComponentFallbackNames?.some((le)=>le.toLowerCase()===l.toLowerCase());if(!W)for(let le of a._targetComponentDirs??[])H(le);if(S)H(xe.resolve(S,"resources/views/components")),H(xe.resolve(S,"resources/components")),H(xe.resolve(S,"src/components")),H(xe.resolve(S,"components"));for(let le of a._layerComponentDirs??[])H(le);let N=a._pluginComponentDirs;if(Array.isArray(N))for(let le of N)H(typeof le==="string"?le:null);if(H(a.fallbackComponentsDir),W)for(let le of a._targetComponentDirs??[])H(le);let Y=a._nativePrimitivesFallback;if(Y&&!Y.except.some((le)=>le.toLowerCase()===l.toLowerCase()))H(Y.dir);if(l.startsWith("./")||l.startsWith("../"))return s(xe.resolve(xe.dirname(i),`${l}.stx`));let J=Ta(xe.resolve(import.meta.dir,"components")),te=O.map((le)=>xe.isAbsolute(le)?le:xe.resolve(j,le)),K=`${v.join("\x00")}\x00\x00${te.join("\x00")}`,q=Er.get(K);if(q!==void 0)return q;let oe=!1;e:for(let le of te){if(Ta(le)===J)continue;for(let ue of v)if(await s(xe.join(le,ue))){oe=!0;break e}}return Er.set(K,oe),oe}function Ta(e){let n=kr.get(e);if(n!==void 0)return n;let r=e;try{r=Ls.realpathSync(e)}catch{}return kr.set(e,r),r}function nm(e){return e==="visible"||e==="idle"||e==="interaction"||e.startsWith("media:")}function Il(e){if(!e)return!1;let n=e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(n)}function Zp(e,n,r){if(!e.includes("{{")&&!e.includes("{!!"))return e;let i=(a,l)=>{let u;try{u=M(a,n)}catch{return l}if(u===void 0||u===null)return"";let f=String(u);if(/<\/style/i.test(f))return console.warn(`[stx] a <style> expression in ${r??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return f};return e.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>i(l,a)).replace(/\{\{([\s\S]*?)\}\}/g,(a,l)=>i(l,a))}var Ia=new Set;function ja(e,n,r,i){let a=`${e}\x00${n}\x00${i??""}`;if(!process.env.STX_DEBUG&&Ia.has(a))return;Ia.add(a);let l=n?` used in ${n}`:"",u=i?` Cause: ${i}.`:"",f=r.length>0?`
1192
+ searched:
1193
+ ${r.map((v)=>` - ${v}`).join(`
1194
+ `)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function Oa(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var Kp=new Set(["for","if","show","key","ref","class","className","style"]),Pa=new Set,za="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",Ol=new RegExp(`\\b(?:${za})\\s*(?:<[^>]*>)?\\s*\\(`);function Ji(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${za})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Ze(e,n,r,i,a,l,u,f=new Set,v,S=ht(a),j,O=e){let{extractVariables:H}=await o("stx/variable-extractor",()=>import("./chunk-fd0vnz09.js")),D=f??new Set;if(D.has(e))return`[Circular component reference: ${e}]`;let W=new Set(D);W.add(e);let N=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let Y=N&&N!=="load"&&nm(N)?N:"";try{let J=(me)=>me.split("-").map(($e)=>$e.charAt(0).toUpperCase()+$e.slice(1)).join(""),te=O.endsWith(".stx")?O.slice(0,-4):O,K=null,q=a.__importedComponents;if(q){let me=[te,te.toLowerCase(),J(te),Q(te)];for(let $e of me)if(q.has($e)){K=q.get($e);break}}let oe=[];if(!K){let me=[`${te}.stx`,`${J(te)}.stx`,`${Q(te)}.stx`],$e=[...new Set(me)],Le=a.__originalFilePath,Se=[];for(let Pe of ms(l))if(!Se.includes(Pe))Se.push(Pe);let ut=Se.length;for(let Pe of u._layerComponentDirs??[])if(!Se.includes(Pe))Se.push(Pe);if(Le){let Pe=xe.join(xe.dirname(Le),"components");Se.push(Pe)}let et=u._rootComponentsDir;if(typeof et==="string"&&La(i,u)&&!Se.includes(et))Se.push(et);if(i&&!Se.includes(i))Se.push(i);if(typeof et==="string"&&!Se.includes(et))Se.push(et);let It=xe.join(xe.dirname(l),"components");if(!Se.includes(It))Se.push(It);if(u.componentsDir&&u.componentsDir!==i&&!Se.includes(u.componentsDir))Se.push(u.componentsDir);for(let Pe of u.additionalComponentsDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let an=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(te),Pt=(j?.events??[]).map((Pe)=>Pe.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),is=Object.hasOwn(n,"checked")||Boolean(j?.reactiveProps?.includes("checked")),Ws=Object.hasOwn(n,"value")||Boolean(j?.reactiveProps?.includes("value")),Vs=!Pt.includes("valuechange")&&(is||Pt.includes("change")&&!Ws),Ut=u._nativeHostAttrs&&/^textinput$/i.test(te),cn=Pt.includes("update:value")&&!Pt.includes("input"),Rn=u._nativeHostAttrs&&/^video$/i.test(te),Fs=u._nativeHostAttrs&&/^image$/i.test(te),os=no([...Object.keys(n),...j?.reactiveProps??[]],j?.events,n),ln=Object.hasOwn(n,"src")||Boolean(j?.reactiveProps?.includes("src")),as=Object.hasOwn(n,"source")||Boolean(j?.reactiveProps?.includes("source")),cs=Rn&&(ln||as)&&(j?.events??[]).every((Pe)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Pe.replace(/^@/,"").split(".")[0])),ls=new Set(["","primary","secondary","outline","ghost","danger"]),us=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",ps=u._nativeHostAttrs&&/^button$/i.test(te)&&!ls.has(us),Mr=u._targetComponentFallbackNames?.some((Pe)=>Pe.toLowerCase()===te.toLowerCase())??!1,Us=Mr&&(!an||Vs)&&(!Ut||cn)&&(!Rn||cs)&&(!Fs||os)&&!ps;for(let Pe of Us?[]:u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe);let un=typeof u.root==="string"?xe.resolve(u.root):void 0,Dr=un??xe.dirname(l),pn=[];if(un)pn.push(xe.resolve(un,"resources/views/components")),pn.push(xe.resolve(un,"resources/components")),pn.push(xe.resolve(un,"src/components")),pn.push(xe.resolve(un,"components"));pn.push(xe.resolve(import.meta.dir,"components"));for(let Pe of pn)if(!Se.includes(Pe))Se.push(Pe);if(Mr){let Pe=(u._componentPackageDirs??[]).filter((mt)=>typeof mt==="string"&&mt.length>0),jt=(Us?Pe.length?Pe:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((mt)=>typeof mt==="string"&&mt.length>0);if(jt.length){let mt=Se.slice(ut).map((ft)=>xe.isAbsolute(ft)?ft:xe.resolve(Dr,ft)).filter((ft)=>!jt.includes(ft)),ds=`${te}\x00${mt.join("\x00")}`,Ct=Sr.get(ds);if(Ct===void 0){Ct=!1;for(let ft of mt){for(let Ht of $e)if(await s(xe.join(ft,Ht))){Ct=!0;break}if(Ct)break}Sr.set(ds,Ct)}if(!Ct){for(let ft of jt){let Ht=Se.indexOf(ft);if(Ht>=0)Se.splice(Ht,1)}Se.splice(ut,0,...jt)}}}let Nr=u._pluginComponentDirs;if(Array.isArray(Nr)){for(let Pe of Nr)if(typeof Pe==="string"&&!Se.includes(Pe))Se.push(Pe)}if(u.fallbackComponentsDir&&!Se.includes(u.fallbackComponentsDir))Se.push(u.fallbackComponentsDir);if(Us){for(let Pe of u._targetComponentDirs??[])if(Pe&&!Se.includes(Pe))Se.push(Pe)}let fs=u._nativePrimitivesFallback;if(fs&&!fs.except.some((Pe)=>Pe.toLowerCase()===te.toLowerCase())&&!Se.includes(fs.dir))Se.push(fs.dir);let Lr=[...new Set(Se.map((Pe)=>{if(!Pe)return Pe;return xe.isAbsolute(Pe)?Pe:xe.resolve(Dr,Pe)}))];Se.length=0,Se.push(...Lr);let Hs=`${te}\x00${l}\x00${Lr.join("\x00")}`,Ks=Ds.get(Hs);if(Ks)if(await s(Ks))K=Ks;else Ds.delete(Hs);if(!K&&(te.startsWith("./")||te.startsWith("../")))K=xe.resolve(xe.dirname(l),`${te}.stx`),oe.push(K);else if(!K)for(let Pe of Se){if(!Pe)continue;for(let jt of $e){let mt=xe.join(Pe,jt);if(oe.push(mt),await s(mt)){K=mt;break}}if(K)break;if(!K)try{let jt=await import("fs");if(!jt.statSync(Pe,{throwIfNoEntry:!1})?.isDirectory())continue;let ds=8,Ct=[{path:Pe,depth:0}];while(Ct.length>0&&!K){let ft=Ct.pop();if(ft.depth>=ds)continue;let Ht;try{Ht=jt.readdirSync(ft.path,{withFileTypes:!0})}catch{continue}for(let gs of Ht){if(!gs.isDirectory())continue;if(gs.name==="node_modules"||gs.name.startsWith("."))continue;let Zr=xe.join(ft.path,gs.name);for(let Qa of $e){let qs=xe.join(Zr,Qa);if(oe.push(qs),await s(qs)){K=qs;break}}if(K)break;Ct.push({path:Zr,depth:ft.depth+1})}}}catch{}if(K)break}if(K)Ds.set(Hs,K)}if(!K||!await s(K))return ja(e,l,oe),Oa(e);v.add(K);let le;if(Xn.has(K)&&$r.get(K)===Ca(K))le=Xn.get(K);else try{let me=Ca(K);le=po(await Bun.file(K).text(),K),Xn.set(K,le),$r.set(K,me)}catch(me){let $e=me instanceof Error?me.message:String(me);return ja(e,l,[K],$e),Oa(e)}if(j)for(let me of new Set([...Object.keys(n),...j.reactiveProps??[]])){let $e=me.toLowerCase();if($e.startsWith("aria-")||$e.startsWith("data-"))continue;let Le=me.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${Le}\\b`).test(le))j.declaredProps.add(me);if(new RegExp(`\\$props\\s*(?:\\.\\s*${Le}\\b|\\[\\s*['"]${Le}['"]\\s*\\])`).test(le)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${Le}['"]`).test(le))j.consumedProps?.add(me)}if(j?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(le))for(let me of j.reactiveProps){if(Kp.has(me)||j.consumedProps?.has(me))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${me.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(le))continue;let $e=`${K}\x00${me}`;if(Pa.has($e))continue;Pa.add($e),console.warn(`[stx] ${xe.basename(K)} reads \`${me}\` with defineProps(), which is not live, but ${xe.basename(l)} binds it (:${me}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${me}').`)}let ue=new Set(["__originalFilePath","__importedComponents",hs,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),fe={};for(let[me,$e]of Object.entries(a))if(!me.startsWith("__")||ue.has(me))fe[me]=$e;let Re=S.length>0?{[vs]:[...S]}:{},Ae=r;if(r.includes("@include")){let{processIncludes:me}=await o("stx/includes",()=>import("./chunk-kppj8rqa.js"));Ae=await me(r,a,l,u,v)}if(/<[A-Z][\w.-]*[\s/>]/.test(Ae)){let{processComponents:me}=await o("stx/component-renderer",()=>import("./chunk-yyypc7s3.js")),$e={...a,__processedComponents:D,...Re};Ae=await me(Ae,$e,l,u,v);let Le=$e.__stx_preserved_client_expressions;if(Array.isArray(Le)&&Le.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...Le])]}let _e=[];if(Il(Ae)){let{processExpressions:me}=await o("stx/expressions",()=>import("./chunk-emk29htn.js")),$e=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...Re}:S.length>0?{...a,...Re}:a;Ae=me(Ae,$e,l);for(let Le of Ae.matchAll(/\{\{([\s\S]*?)\}\}/g))_e.push(Le[1].trim())}let de=new Set(Array.isArray(a.__stx_client_declared_names)?a.__stx_client_declared_names:[]),We=[];if(de.size>0&&Ae)for(let me of Ae.matchAll(/<[A-Z][\w.-]*\b([^>]*)>/g))for(let $e of me[1].matchAll(/\s(?:v-model(?::[\w-]+)?|:[\w-]+)\s*=\s*"([^"]*)"/g)){let Le=$e[1].trim();try{if(Le&&Te(Le).some((Se)=>de.has(Se)))We.push(Le)}catch{}}let Ve=re(Ae),st=[],it=Ve.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(me,$e)=>{let Le=Ve.scripts[Number($e)]||"",Se=Le.match(/^<script\b([^>]*)>/i)?.[1]||"",ut=Se.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),et=!ut||["module","text/javascript","application/javascript"].includes(ut),It=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${Se}`);if(!/\bserver\b/i.test(Se)&&et&&!It)return st.push(Le),"";return Le}),{extractSlotContent:At}=await o("stx/slots",()=>import("./chunk-wrva7jes.js")),$t=At(it),ot={};if($t.defaultSlot?.trim())ot.default=$t.defaultSlot;for(let[me,$e]of $t.namedSlots)ot[me]=$e.content;let Et=a.__stx_scope_seq??={n:0,key:mo(String(a.__filename??l))},Fe=Na(e,process.cwd()),lt=`stx_${(Fe.endsWith(".stx")?Fe.slice(0,-4):Fe).replace(/[^a-zA-Z0-9]/g,"_")}_${++Et.n}_${Et.key}`,De={...fe,$uid:lt,$native:u._nativeHostAttrs===!0,...n,props:n,slot:it,$slots:ot,__processedComponents:W,__sections:{},__stx_signals_gate:Me(le)||Il(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],..._e],__stx_caller_client_bindings:[...Array.isArray(a.__stx_caller_client_bindings)?a.__stx_caller_client_bindings:[],...We]};if(/import\s/.test(le)){De.__importedComponents=new Map(De.__importedComponents);let{processESImports:me}=await o("stx/component-renderer",()=>import("./chunk-yyypc7s3.js"));le=await me(le,De,K,u,v)}Up(le,De,n);let Dt=le,Nt=B(Dt);if(Nt)Dt=Nt.content.trim();let Bs=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,bn=[...le.matchAll(Bs)];for(let[,me,$e]of bn)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(me))Ke($e,K,u.strict);let gt=[],yn=null,Lt=bn.some((me)=>/\bserver\b/.test(me[1]||"")&&/\bcache\b/.test(me[1]||"")),rn=null,_n=null,wn=null,Yn=0,vn=null;if(zp(u),Lt&&Cr>0){let me=Bp({props:n,slot:Ae,slotContext:r.trim()?Wp(fe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...S].sort(),layers:u._layerGraph?.layers.map(($e)=>$e.configFile),uid:lt});if(me!==null){rn=`${K}\x00${E(le)}\x00${me}`;let $e=Ns.get(rn);if($e){for(let Le of $e.dependencies)v.add(Le);if(yi(a,$e.clientFactories),Et.n+=$e.uidsConsumed,$e.preservedClientExpressions.length>0){let Le=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let Se of $e.preservedClientExpressions)Le.add(Se);a.__stx_preserved_client_expressions=[...Le]}return $e.output}_n=new Set(v),wn=xi(a),Yn=Et.n,vn=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let Tt=new Set;for(let me of bn){let $e=me[1]||"",Le=me[2]||"",Se=$e.includes("server");if(Je($e)&&Le.trim())Le=Ye(Le);if(Se&&Le){for(let et of be(Le))Tt.add(et);try{await H(Le,De,K,{onFailure:(et)=>{if(et.kind!=="unknown")yn=et.kind}})}catch(et){}}if(!Se){let et=Le.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),It=et.includes("{{")&&et.includes("}}"),an=et.includes("{!!")&&et.includes("!!}");if(It||an)et=Zi(et,De,K);let Pt=$e.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");gt.push(`<script${Pt}>${et}</script>`)}}let Ot=re(le).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),$n=Ot?Ot[1]:"",pe=Ot?Ot[2]:"",ge="",ke=$n&&/\bscoped\b/i.test($n);if(Ot)ge=`<style${$n}>${Zp(pe,De,K)}</style>`;let Ie=Dt;if(Ie=Ie.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Ot)Ie=Ie.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let me=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,$e=[];if(Ie=Ie.replace(me,(Le,Se)=>{let ut=Se.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(ut)$e.push(`<style${ut[1]}>${ut[2]}</style>`);return""}),Ie=Ie.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),$e.length>0)ge=`${ge}${$e.join(`
1195
+ `)}`}if(r&&Ie.includes("{{ text || slot }}"))Ie=Ie.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:tt}=await o("stx/slots",()=>import("./chunk-wrva7jes.js")),{defaultSlot:at,namedSlots:on}=$t,Pr=a.__stx_signals_gate===!0&&/\s(?:@[\w:.-]+|x-on:[\w:.-]+)\s*=/.test(it),zt=gt.length>0&&or(Ie)||u._nativeHostAttrs===!0&&gt.length>0||Pr&&gt.length>0||gt.some((me)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(me)),Qn=(me)=>zt?No(me,lt):me,ns=new Map([...on].map(([me,$e])=>[me,{...$e,content:Qn($e.content)}]));Ie=await tt(Ie,zt?Do(Qn(at),lt):at,ns,De,zt?lt:"");let Sn=Ji(gt),En=(Array.isArray(De.__stx_client_signal_names)?De.__stx_client_signal_names:[]).filter((me)=>!Tt.has(me));if(Sn.length>0||En.length>0)De.__stx_client_signal_names=[...new Set([...En,...Sn])];else delete De.__stx_client_signal_names;let kn=co(gt.join(`
1196
+ `)),Cn=(Array.isArray(De.__stx_client_declared_names)?De.__stx_client_declared_names:[]).filter((me)=>!Tt.has(me)&&!(me in n));if(kn.size>0||Cn.length>0)De.__stx_client_declared_names=[...new Set([...Cn,...kn])];else delete De.__stx_client_declared_names;let Bt=S.filter((me)=>!Tt.has(me)&&!(me in n));if(Bt.length>0)De[vs]=Bt;let ss={...u,_rootComponentsDir:u._rootComponentsDir||u.componentsDir,componentsDir:xe.dirname(K),skipSignalsRuntime:!0,skipEventDirectives:u._nativeHostAttrs===!0||zt||gt.length===0,defaultLayout:void 0};De.__stxProcessingDepth=(a.__stxProcessingDepth||0)+1;let{processDirectives:rs}=await o("stx/process",()=>import("./chunk-tsnzhke9.js")),ze=await rs(Ie,De,K,ss,v),kt=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let me of ze.matchAll(/\{\{([\s\S]*?)\}\}/g))kt.add(me[1].trim());if(kt.size>0)a.__stx_preserved_client_expressions=[...kt];let Ft=lt,pt=ze;if(zt){let me="";if(Object.keys(n).length>0)try{me=` data-stx-props="${wr(JSON.stringify(n))}"`}catch{}let $e=Y?` stx-hydrate="${wr(Y)}"`:"",Le=Object.fromEntries(Object.entries(ot).map(([Ut,cn])=>[Ut,Boolean(cn)])),Se=Object.keys(Le).length>0?` data-stx-slots="${wr(JSON.stringify(Le))}"`:"",ut=` data-stx-scope="${Ft}"${me}${Se}${$e}`,et=ze.slice(vt(ze)),It=/^<span(?=[\s/>])/i.test(et),an=/^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(et),Pt=/^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(et),is=It?"span":"div",Ws=an&&u._nativeHostAttrs?' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"':Pt&&u._nativeHostAttrs?' style="width:100%;height:100%"':It||an?' style="display:contents"':"";pt=tm(ze,ut)??`<${is}${ut} data-stx-component-wrapper${Ws}>${ze}</${is}>`;let Vs=await Promise.all(gt.map(async(Ut)=>{let cn=Ut.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!cn)return Ut;let[,Rn,Fs]=cn,os=ka(Ut,De,K);if(os!==null)return os;let ln=await Jp(Fs,K,u.buildMode==="compile"),as=Nn(ln.clientCode,Xe(De)),{vendorStyleTags:cs}=ln,ls=as?`function(__scopeId) {
1197
+ ${as}
1198
+ return (${ln.factoryBody})(__scopeId);
1199
+ }`:ln.factoryBody,us=Y?null:Ys(a,ls),ps=us?`window.__stxComponentFactories[${JSON.stringify(us)}](${JSON.stringify(Ft)});`:`(${ls})(${JSON.stringify(Ft)});`;if(Y)return`${cs}<script type="stx/island" data-stx-island="${Ft}" data-stx-scoped data-stx-owner="${Ft}"${Rn}>${he(ps)}</script>`;return`${cs}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Ft}"${Rn}>${he(ps)}</script>`}));if(pt=pt+`
1200
+ `+Vs.join(`
1201
+ `),ge)pt+=`
1202
+ `+ge}else{if(ge)pt+=`
1203
+ `+ge;if(gt.length>0){let me=De.__stx_event_bindings||[],$e=Xe(De),Le=await Promise.all(gt.map(async(Se)=>{let ut=ka(Se,De,K);if(ut!==null)return ut;let et=Se.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!et)return Se;return await Ge(et[1],{eventBindings:me,templateContent:pt,filePath:K,projectRoot:process.cwd(),serverData:$e,instanceId:lt})}));pt+=`
1204
+ `+Le.join(`
1205
+ `),De.__stx_event_bindings=[]}}if(ke){let me=lo(pt,K);if(me.hasScoped)pt=me.html}if(rn&&_n){let me=Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[];Ns.set(rn,{output:pt,dependencies:[...v].filter(($e)=>!_n.has($e)),clientFactories:wn?bi(a,wn):[],uidsConsumed:Et.n-Yn,preservedClientExpressions:vn?me.filter(($e)=>!vn.has($e)):[]})}if(yn)pt=`<!--stx-render-failed:${yn}-->${pt}`;return st.length>0?`${pt}
1206
+ ${st.join(`
1207
+ `)}`:pt}catch(J){if(J instanceof ne)throw J;return`[Error processing component: ${J instanceof Error?J.message:String(J)}]`}finally{D.delete(e)}}async function s(e){return Bun.file(e).exists()}function Rr(e,n){let r=xe.resolve(n),i=xe.resolve(e),a=r.endsWith(xe.sep)?r:r+xe.sep;if(i===r||i.startsWith(a))return i;return null}async function Ma(e,n,r,i){let a=n.startsWith("layouts/")?n.slice(8):n,l=xe.join(e,a);for(let u of l.endsWith(".stx")?[l]:[l,`${l}.stx`])if(await s(u)){if(i)console.log(`Found layout in ${e}: ${u}`);return r?.add(u),u}return null}async function Mn(e,n,r,i){let a=await qp(e,n,r,i);if(a===null)return null;let l=Rr(a,process.cwd());if(l)return l;let u=[r.root,r.layoutsDir,r.fallbackLayoutsDir,r.componentsDir,r.partialsDir,r.pagesDir,...r._layerLayoutDirs??[]].filter((f)=>typeof f==="string"&&f.length>0);for(let f of u){let v=xe.isAbsolute(f)?f:xe.resolve(process.cwd(),f);if(Rr(a,v))return xe.resolve(a)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${a} (template: ${e}, from: ${n})`),null}async function qp(e,n,r,i){if(r.debug)console.log(`Resolving template path: ${e} from ${n}`);let a=xe.dirname(n),l=process.cwd();if(e.startsWith("/")){let D=xe.join(l,e),W=Rr(D,l);if(!W)return console.warn(`[stx] rejected template path that escapes project root: ${e} (from ${n})`),null;if(r.debug)console.log(`Checking absolute path: ${W}`);if(await s(W)&&i)i.add(W);return W}let u=async(D)=>{if(!r.layoutsDir||!r.fallbackLayoutsDir)return D;let W=xe.relative(xe.resolve(l,r.fallbackLayoutsDir),D);if(W.startsWith("..")||xe.isAbsolute(W))return D;return await Ma(xe.resolve(l,r.layoutsDir),e,i,r.debug)??D},f=xe.join(a,e);if(await s(f)){if(r.debug)console.log(`Found direct path: ${f}`);let D=await u(f);if(i)i.add(D);return D}if(!e.endsWith(".stx")&&!e.endsWith(".jsx")&&!e.endsWith(".tsx"))for(let D of[".stx",".tsx",".jsx"]){let W=`${f}${D}`;if(await s(W)){if(r.debug)console.log(`Found direct path with extension: ${W}`);let N=await u(W);if(i)i.add(N);return N}}let v=[];if(v.push(...r._layerLayoutDirs??[]),r.layoutsDir)v.push(xe.isAbsolute(r.layoutsDir)?r.layoutsDir:xe.resolve(process.cwd(),r.layoutsDir));let S=xe.resolve(a),j=process.cwd();for(let D=0;D<10;D++){let W=xe.join(S,"layouts"),N=!1;try{N=Ls.statSync(W,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(N){v.push(W);break}let Y=xe.dirname(S);if(Y===S||Y.length<j.length)break;S=Y}for(let D of v){let W=await Ma(D,e,i,r.debug);if(W)return W}if(r.fallbackLayoutsDir){let D=xe.isAbsolute(r.fallbackLayoutsDir)?r.fallbackLayoutsDir:xe.resolve(process.cwd(),r.fallbackLayoutsDir),W=e.startsWith("layouts/")?e.slice(8):e,N=[xe.join(D,W)];if(!e.endsWith(".stx"))N.push(`${N[0]}.stx`);for(let Y of N)if(await s(Y)){if(r.debug)console.log(`Found in options.fallbackLayoutsDir: ${Y}`);if(i)i.add(Y);return Y}}if(e.startsWith("layouts/")||e.includes("/layouts/")){let D=e.split("layouts/"),W=xe.join(r.partialsDir||a,"layouts",D[1]);if(await s(W)){if(r.debug)console.log(`Found in layouts path: ${W}`);if(i)i.add(W);return W}if(!W.endsWith(".stx")){let N=`${W}.stx`;if(await s(N)){if(r.debug)console.log(`Found in layouts path with extension: ${N}`);if(i)i.add(N);return N}}}if(r.partialsDir){let D=xe.join(r.partialsDir,"layouts");if(await s(D)){let W=xe.join(D,e);if(await s(W)){if(r.debug)console.log(`Found in partials layouts dir: ${W}`);if(i)i.add(W);return W}if(!e.endsWith(".stx")){let N=`${W}.stx`;if(await s(N)){if(r.debug)console.log(`Found in partials layouts dir with extension: ${N}`);if(i)i.add(N);return N}}}}let O=r.partialsDir||xe.join(process.cwd(),"views"),H=xe.join(O,e);if(await s(H)){if(r.debug)console.log(`Found in views path: ${H}`);if(i)i.add(H);return H}if(!e.endsWith(".stx")){let D=`${H}.stx`;if(await s(D)){if(r.debug)console.log(`Found in views path with extension: ${D}`);if(i)i.add(D);return D}}if(a.includes("temp")){let D=xe.join(xe.dirname(a),"layouts",e);if(await s(D)){if(r.debug)console.log(`Found in temp layouts dir: ${D}`);if(i)i.add(D);return D}if(!e.endsWith(".stx")){let W=`${D}.stx`;if(await s(W)){if(r.debug)console.log(`Found in temp layouts dir with extension: ${W}`);if(i)i.add(W);return W}}}if(r.debug)console.warn(`Template not found after trying all paths: ${e} (referenced from ${n})`);else console.warn(`Template not found: ${e} (referenced from ${n})`);return null}function Nl(e,n,r){let i=0,a="",l="";try{if(typeof n==="number"&&n>=0){let u=e.split(`
1208
+ `),f=0;for(let v=0;v<u.length;v++)if(f+=u[v].length+1,f>=n){i=v+1,a=u[v].trim();let S=Math.max(0,v-2),j=Math.min(u.length,v+3);l=u.slice(S,j).map((O,H)=>{let D=S+H+1;return`${D===i?"> ":" "}${D}: ${O}`}).join(`
1209
+ `);break}}else if(r){let u=e.indexOf(r);if(u>=0)return Nl(e,u)}}catch{}return{lineNumber:i,lineContent:a,context:l}}var He={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function w(e,n,r,i,a,l){let{lineNumber:u,context:f}=Nl(i,a,l),v=r.split("/").pop(),S=0;if(typeof a==="number"&&a>=0&&i){let O=i.lastIndexOf(`
1210
+ `,Math.max(0,a-1));S=a-(O+1)+1}let j="";if(u>0)j+=`
1211
+ ${r}:${u}${S>0?`:${S}`:""}: ${e.toLowerCase()} error: ${n}
1212
+ `;if(j+=`
1213
+ ${He.bold}${He.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${He.reset}
1214
+ `,j+=`${He.bold}${He.red}\u2502${He.reset} ${He.bold}${He.bgRed} ERROR ${He.reset} ${He.red}${e} Error${He.reset}${" ".repeat(Math.max(0,43-e.length))}${He.bold}${He.red}\u2502${He.reset}
1215
+ `,j+=`${He.bold}${He.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${He.reset}
1216
+ `,j+=`
1217
+ ${He.cyan}${He.bold}File:${He.reset} ${He.dim}${v}${He.reset}`,u>0)j+=` ${He.gray}(line ${u}${S>0?`, col ${S}`:""})${He.reset}`;if(j+=`
1218
+ ${He.yellow}${He.bold}Message:${He.reset} ${n}
1219
+ `,f)j+=`
1220
+ ${He.blue}${He.bold}Context:${He.reset}
1221
+ ${He.dim}${f}${He.reset}
1222
+ `;return j}function Ee(){Xn.clear(),$r.clear(),Ds.clear(),Sr.clear(),Er.clear(),kr.clear(),Ns.clear()}function By(){return{size:Xn.size,maxSize:500}}var vr=k(128);async function Jp(e,n,r){let i=E(e,n,r),a=vr.get(i);if(a){if(ro(a.deps))return a;vr.delete(i)}let l=Xi(e,{filePath:n,projectRoot:process.cwd()}),u=l.code,f=Gi(l.styles);u=Gt(u).code;let{hasUserImports:v,bundleClientScript:S}=await o("stx/client-script-bundler",()=>import("./chunk-aqh48tyw.js")),j=[],O=!1;if(v(u)){let te=u;u=await S(te,n,{projectRoot:process.cwd(),minify:r,collectInputs:j}),O=u===te}let{stripStxRuntimeImports:H}=await o("stx/signal-processing",()=>import("./chunk-k1qbgpfy.js"));u=H(u);let D=L(u),W=Fp(D),N=new Set(Z(D,!0).split(",").map((te)=>te.trim())),Y=`function(__scopeId) {
1223
+ ${St("const",[...Yl,...W],D)}
1224
+ const __scope = window.stx._scopes = window.stx._scopes || {};
1225
+ const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
1226
+ __scopeVars.$refs = __scopeVars.$refs || {};
1227
+ const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
1228
+ const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
1229
+ // A clone the runtime is setting up may not be in the document yet (rows
1230
+ // a loop builds inside a closed :if), where a lookup cannot see it, so the
1231
+ // runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
1232
+ const __setupRoot = window.__STX_SETUP_ROOT__;
1233
+ const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
1234
+ __scopeVars.$slots = Object.create(null);
1235
+ if (__componentElement) {
1236
+ try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
1237
+ catch {}
1238
+ }
1239
+ window.__STX_CURRENT_ELEMENT__ = __componentElement;
1240
+ let __componentProps = __componentElement && __componentElement.__stx_props;
1241
+ if (!__componentProps && __componentElement) {
1242
+ try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
1243
+ catch { __componentProps = {}; }
1244
+ }
1245
+ window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
1246
+ const __scopeProps = window.__STX_CURRENT_PROPS__;
1247
+ Object.defineProperty(__scopeVars, '$props', { configurable: true, enumerable: true, get: function() {
1248
+ return (__componentElement && __componentElement.__stx_props) || __scopeProps;
1249
+ } });
1250
+
1251
+ // Scope-specific lifecycle callbacks. The queues drain as they run; the
1252
+ // hook lists keep what setup registered, because a component behind an :if
1253
+ // unmounts at each hide and mounts again at each show (signals.ts,
1254
+ // suspendSubtreeScopes).
1255
+ if (__scopeVars.__suspended && !__scopeVars.__mounted) {
1256
+ // Set up again after an :if hid it -- a <template :if> clones the
1257
+ // component afresh on every show, and the clone's script runs. This run's
1258
+ // hooks close over this run's state, so they replace the ones the hide
1259
+ // kept for a re-show rather than queueing beside them.
1260
+ __scopeVars.__mountCallbacks = [];
1261
+ __scopeVars.__destroyCallbacks = [];
1262
+ __scopeVars.__mountHooks = [];
1263
+ __scopeVars.__destroyHooks = [];
1264
+ // So do its effects: the last run's watched a clone that is gone.
1265
+ if (typeof __scopeVars.__disposeEffects === 'function') __scopeVars.__disposeEffects();
1266
+ __scopeVars.__disposeEffects = null;
1267
+ }
1268
+ __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
1269
+ __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
1270
+ __scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
1271
+ __scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
1272
+ let __registeringSetupHooks = true;
1273
+ const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
1274
+ const onDestroy = (fn) => {
1275
+ __scopeVars.__destroyCallbacks.push(fn);
1276
+ // A teardown registered inside onMount belongs to this mount alone.
1277
+ // Replaying it AND registering the next mount's teardown doubles cleanup.
1278
+ if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
1279
+ };
1280
+ // The effects this setup makes (effect, watch) belong to the scope and are
1281
+ // disposed with it (disposeSubtreeScopes in the runtime), as its bindings
1282
+ // are. Untracked, one reading a store kept running for a component the
1283
+ // router had long swapped out.
1284
+ const __endEffects = window.stx._beginEffects ? window.stx._beginEffects() : null;
1285
+
1286
+ try {
1287
+ ${D}
1288
+
1289
+ // Register all defined signals and functions in this scope
1290
+ const __localVars = {};
1291
+ try {
1292
+ ${W.map((te)=>N.has(te)?`Object.defineProperty(__localVars, '${te}', ${Zs(te)});`:`if (typeof ${te} !== 'undefined') __localVars['${te}'] = ${te};`).join(`
1293
+ `)}
1294
+ }
1295
+ catch (e) {}
1296
+ Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
1297
+ if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
1298
+ }
1299
+ finally {
1300
+ __registeringSetupHooks = false;
1301
+ if (__endEffects) {
1302
+ const __previousDispose = __scopeVars.__disposeEffects;
1303
+ const __disposeSetup = __endEffects();
1304
+ __scopeVars.__disposeEffects = typeof __previousDispose === 'function'
1305
+ ? function() { __previousDispose(); __disposeSetup(); }
1306
+ : __disposeSetup;
1307
+ }
1308
+ window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
1309
+ window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
1310
+ }
1311
+ }`,J={vendorStyleTags:f,factoryBody:Y,clientCode:D,deps:Br([...j,...l.styles.map((te)=>te.resolvedPath)])};if(!O&&l.unresolved.length===0)vr.set(i,J);return J}var Xp=100,Gp=599,Tr="__stxResponseStatus",Gn="__stxResponseHeaders";function zs(e){return typeof e==="number"&&Number.isInteger(e)&&e>=Xp&&e<=Gp}function In(e){for(let n of e.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let r=n[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!r)continue;let i=Number(r[1]);if(zs(i))return i}return}function Ar(e,n){if(!e||typeof e!=="object")return!1;let r=typeof n==="string"&&/^\d+$/.test(n.trim())?Number(n.trim()):n;if(!zs(r))return!1;return e[Tr]=r,!0}function Yp(e,n,r){if(!e||typeof e!=="object")return;let i=String(n??"").trim();if(!i)return;e[Gn]={...e[Gn],[i]:String(r)}}function Kt(e){let n=e?.[Tr];return zs(n)?n:void 0}function Xt(e){let n=e?.[Gn];if(!n||typeof n!=="object")return;let r=Object.entries(n).map(([i,a])=>[i,String(a)]);return r.length>0?Object.fromEntries(r):void 0}function wl(e,n){if(!e||!n||e===n||typeof n!=="object")return;let r=Kt(e);if(r!==void 0)n[Tr]=r;let i=Xt(e);if(i)n[Gn]={...n[Gn],...i}}function uo(e){return{setResponseStatus:(n)=>{Ar(e,n)},notFound:(n=404)=>{let r=zs(n)&&n>=400?n:404;Ar(e,r)},setResponseHeader:(n,r)=>{Yp(e,n,r)}}}function vl(e,n,r={}){if(!e.includes("@status"))return e;let{filePath:i,buildMode:a}=r,l=a==="compile",u="",f=0,v=/@status\s*\(/g,S;while((S=v.exec(e))!==null){let j=Qp(e,S.index+S[0].length-1);if(j<0)break;let O=e.slice(S.index+S[0].length,j).trim(),H=/^\d+$/.test(O)?Number(O):d(O,n),D=i?` in ${i}`:"";if(l)console.warn(`[stx] @status(${O})${D} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${O}) from <script server> instead \u2014 that runs per request.`);else if(!Ar(n,H))console.warn(`[stx] @status(${O})${D} is not an HTTP status (100-599) \u2014 ignoring it.`);u+=e.slice(f,S.index),f=j+1+(e.slice(j+1).match(/^[^\S\n]*\n?/)?.[0].length??0),v.lastIndex=f}return f===0?e:u+e.slice(f)}function Qp(e,n){let r=1,i=null,a=!1;for(let l=n+1;l<e.length;l++){let u=e[l];if(a){a=!1;continue}if(i){if(u==="\\")a=!0;else if(u===i)i=null;continue}if(u==='"'||u==="'"||u==="`"){i=u;continue}if(u==="(")r++;else if(u===")"&&--r===0)return l}return-1}var Ba=new Set(yt),ef=new Set(["props","$props","defineProps"]),tf=new Set(["stx","@stacksjs/stx"]),Wa=k(128),Va=k(64);function nf(e){let n=[],r=0,i=e.split(`
1312
+ `);for(let a of i){let l=r,u=null,f=!1;for(let v=0;v<a.length;v++){let S=a[v];if(f){f=!1;continue}if(S==="\\"){f=!0;continue}if(u){if(S===u)u=null;continue}if(S==="'"||S==='"'||S==="`"){u=S;continue}if(S==="/"&&v+1<a.length&&a[v+1]==="/")break;if(S==="{")r++;else if(S==="}")r--}if(l===0){let v=a.match(/(?:const|let|var)\s+(\w+)\s*=/);if(v)n.push(v[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(a)){let S=a.match(/(?:const|let|var)\s+(\w+)/);if(S)n.push(S[1])}else{let S=a.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(S){let O=S[1].slice(1,-1).split(",").map((H)=>{let D=H.split(":");return(D.length>1?D[1]:D[0]).trim()}).filter((H)=>/^\w+$/.test(H));n.push(...O)}}}}return[...new Set(n)]}function Fg(e){let n=e;n=n.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),n=n.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),n=n.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function r(i){if(!i.includes(":"))return i;let a=[],l="",u=0,f=0,v=null;for(let S=0;S<i.length;S++){let j=i[S];if(v){if(l+=j,j===v)v=null;continue}if(j==='"'||j==="'"||j==="`"){v=j,l+=j;continue}if(j==="<")u++;else if(j===">"&&u>0)u--;else if(j==="(")f++;else if(j===")")f--;if(j===","&&u===0&&f===0){a.push(l),l="";continue}l+=j}if(l)a.push(l);return a.map((S)=>{let j=S.trim(),O=j.startsWith("..."),H=O?j.slice(3):j,D=-1,W=0;for(let oe=0;oe<H.length;oe++)if(H[oe]==="<")W++;else if(H[oe]===">")W--;else if(H[oe]===":"&&W===0){D=oe;break}if(D===-1)return S;let Y=H.substring(0,D).trim().replace(/\?$/,""),J=H.substring(D+1),te=-1,K=0;for(let oe=0;oe<J.length;oe++)if(J[oe]==="<")K++;else if(J[oe]===">")K--;else if(J[oe]==="="&&K===0){te=oe;break}let q=O?"...":"";if(te!==-1)return`${q}${Y} = ${J.substring(te+1).trim()}`;return`${q}${Y}`}).join(", ")}n=n.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(i,a,l)=>{if(!l.includes(":"))return i;return`${a}(${r(l)})`});{let i=/\b(function\s+\w*\s*)\(/g,a,l=[];while((a=i.exec(n))!==null){let u=a.index+a[0].length-1,f=1,v=u+1,S=0,j=null;while(v<n.length&&f>0){let D=n[v];if(j){if(D===j)j=null;v++;continue}if(D==='"'||D==="'"||D==="`"){j=D,v++;continue}if(D==="<")S++;else if(D===">"&&S>0)S--;else if(S===0){if(D==="(")f++;else if(D===")")f--}if(f>0)v++}if(f!==0)continue;let O=n.substring(u+1,v);if(!O.includes(":"))continue;let H=r(O);l.push({start:u+1,end:v,replacement:H})}for(let u=l.length-1;u>=0;u--){let{start:f,end:v,replacement:S}=l[u];n=n.substring(0,f)+S+n.substring(v)}}return n=n.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(i,a)=>{if(!a.includes(":"))return i;if(a.includes("{")||a.includes("}"))return i;return`(${a.split(",").map((u)=>{let[f,...v]=u.split("="),S=f.split(":")[0].trim();if(v.length>0)return`${S} = ${v.join("=").trim()}`;return S}).join(", ")}) =>`}),n=n.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),n=n.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),n=n.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),n=n.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),n=n.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),n=n.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),n=n.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),n=n.replace(/\n\s*\n\s*\n/g,`
1313
+
1314
+ `),n}function zg(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Hg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function Ug(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Vg(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var Fa=new Set;async function b(e,n,r,i={}){if(!e.trim())return;let a=P(),l=E(e,JSON.stringify(a)),u=Wa.get(l);if(u===void 0){try{let pe=ae({loader:"ts",target:"browser",define:a}),ge=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");ge=ge.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),u=pe.transformSync(ge)}catch{u=Fg(e)}Wa.set(l,u)}let f={exports:{}},v=f.exports,S=xn.cwd(),j={},O=[...u.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((pe)=>pe[1]).filter((pe)=>!pe.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(pe)),H=new Map;for(let pe of O)try{if(pe.startsWith(".")){j[pe]=await import(Rt.resolve(Rt.dirname(r),pe));continue}let ge=Rt.resolve(S,"node_modules",pe),ke=Rt.join(ge,"package.json"),Ie=JSON.parse(x("fs").readFileSync(ke,"utf8")),tt=Ie.main||"index.js";if(Ie.exports){let at=typeof Ie.exports==="string"?Ie.exports:Ie.exports["."];if(typeof at==="string")tt=at;else if(at?.bun)tt=at.bun;else if(at?.import)tt=at.import;else if(at?.default)tt=at.default}j[pe]=await import(Rt.resolve(ge,tt))}catch(ge){if(pe.startsWith("."))H.set(pe,ge instanceof Error?ge.message:String(ge))}let D=(pe)=>{if(j[pe])return j[pe];let ge=H.get(pe);if(ge!==void 0)throw Error(`Cannot require '${pe}' from ${r}: ${ge}`);return x(pe)},W=n.props||{},N=(pe)=>{if(!pe)return W;let ge={};for(let[ke,Ie]of Object.entries(pe)){let tt=W[ke];if(tt!==void 0)ge[ke]=tt;else if(typeof Ie==="function")ge[ke]=Ie();else ge[ke]=Ie}return ge};for(let[pe,ge]of Object.entries(W))Object.defineProperty(N,pe,{value:ge,enumerable:!0,configurable:!0,writable:!0});let Y=(pe,ge=!1)=>{if(pe===void 0||pe===null)return ge;if(typeof pe==="string"){let ke=pe.trim().toLowerCase();if(ke===""||ke==="true"||ke==="1"||ke==="on"||ke==="yes")return!0;if(ke==="false"||ke==="0"||ke==="off"||ke==="no")return!1;return!0}return Boolean(pe)},J=(pe,ge=0)=>{if(pe===void 0||pe===null)return ge;if(typeof pe==="string"){let Ie=pe.trim();if(Ie==="")return ge;let tt=Number(Ie);return Number.isFinite(tt)?tt:ge}let ke=Number(pe);return Number.isFinite(ke)?ke:ge};for(let pe of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(W,pe))continue;try{Object.defineProperty(N,pe,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let te=(pe)=>{if(!pe)return W;let ge={...W};for(let[ke,Ie]of Object.entries(pe)){let tt=Ie&&typeof Ie==="object"&&!Array.isArray(Ie)?Ie:{type:Ie};if(ge[ke]===void 0&&tt.default!==void 0)ge[ke]=typeof tt.default==="function"?tt.default():tt.default}return ge},K=()=>n.slots||{},q=(pe,ge)=>{let ke={...pe};for(let[Ie,tt]of Object.entries(ge))if(ke[Ie]===void 0)if(typeof tt==="function")ke[Ie]=tt();else ke[Ie]=tt;return ke},oe=(pe)=>{let ge=()=>pe;return ge.set=(ke)=>{},ge.update=(ke)=>{},ge},le=(pe)=>{let ge,ke=!1;return()=>{if(!ke)try{ge=pe(),ke=!0}catch{ge=void 0}return ge}},ue=(pe)=>{},fe=(pe)=>pe(),Re=(pe)=>{},Ae=(pe)=>{},_e=uo(n);function de(pe){let ge=pe||{};if(ge.cache===!1)n.__stx_skip_cache=!0;if(ge.title!==void 0||ge.description!==void 0)At({title:ge.title,description:ge.description})}function We(pe){if(!pe||typeof pe!=="object")return;let ge=n.__stxClientPayload??{};Object.assign(ge,pe),n.__stxClientPayload=ge}let Ve=()=>{let pe=n.__stxServeContext,ge=n.__stxServeSearch??pe?.search??"",ke=pe?.path??"",Ie=Object.fromEntries(new URLSearchParams(ge)),tt=n.query,at=Object.keys(Ie).length>0?Ie:tt??{},on=ge||(Object.keys(at).length>0?`?${new URLSearchParams(at).toString()}`:"");return{params:n.params??{},query:at,path:ke,name:"",fullPath:ke+on,hash:"",matched:[]}},st=()=>({push:(pe)=>{},replace:(pe)=>{},back:()=>{},forward:()=>{},go:(pe)=>{}}),it=(pe)=>{let ge=n.__stx_runtime_head||{};n.__stx_runtime_head=rt(ge,je(pe||{},{known:ko,source:"useHead()"}))},At=(pe)=>{it(_o(pe||{}))},$t=(pe)=>({value:pe}),ot=(pe)=>pe,Et=(pe)=>({value:typeof pe==="function"?pe():pe}),Fe=(pe,ge)=>{},ct=(pe)=>{},lt=(pe)=>{},De=(pe)=>pe?pe():Promise.resolve(),Dt=(pe)=>(ge,...ke)=>{},Nt=(pe)=>{},Bs=(pe,ge)=>{},bn=(pe,ge)=>ge,gt=()=>({value:"light"}),yn=()=>oe(!1),Lt=(pe)=>oe(!1),rn=()=>oe(!1),_n=()=>Lt("(prefers-color-scheme: dark)"),wn=()=>Lt("(prefers-color-scheme: light)"),Yn=()=>Lt("(prefers-reduced-motion: reduce)"),vn=()=>Lt("(prefers-contrast: more)"),Tt={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},Or=new Proxy(Tt,{get(pe,ge){if(ge in pe)return pe[ge];return},set(pe,ge,ke){return pe[ge]=ke,!0}}),Ot={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},$n=console;try{let pe=Ki(u,r),ge=new Set(Object.keys(W)),ke=Object.keys(n).filter((ze)=>!ge.has(ze)&&!ef.has(ze)&&qr(ze)),Ie=ke.map((ze)=>n[ze]);if(!ke.includes("__stxServeContext"))ke.push("__stxServeContext"),Ie.push(void 0);if(!ge.has("cookies")){let ze=n.cookies??n.__stxServeContext?.cookies??{},kt=ke.indexOf("cookies");if(kt<0)ke.push("cookies"),Ie.push(ze);else Ie[kt]=ze}let tt=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),at=[],on=[];for(let[ze,kt]of Object.entries(W)){if(!qr(ze))continue;if(tt.has(ze))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${ze}\\b`).test(pe))continue;at.push(ze),on.push(kt)}let zt=nf(pe).map((ze)=>`module.exports.${ze} = typeof ${ze} !== 'undefined' ? ${ze} : module.exports.${ze};`).join(`
1315
+ `),Qn=n.params??{},ns=[],Sn=[];for(let ze=0;ze<ke.length;ze++){if(ke[ze]==="params")continue;ns.push(ke[ze]),Sn.push(Ie[ze])}let En=[...yt,...at,...ns],kn=`return (async () => {
1316
+ ${pe}
1317
+ ${zt}
1318
+ return module.exports
1319
+ })()`,Cn=E(kn,En.join("\x00")),Bt=Va.get(Cn);if(!Bt)Bt=Function(...En,kn),Va.set(Cn,Bt);let ss=n.__stx_options?.runtimeConfig;if(ss||/\buse(?:Server)?RuntimeConfig\b/.test(u))await jn(n,r,ss);let rs=await Qe(n.__stx_runtime_config??Bn()??z(),()=>Jr(n,()=>Bt(f,v,D,W,N,Y,J,te,q,We,Xr,ta,yo,oe,le,ue,fe,Re,Ae,de,Ve,st,it,At,_e.setResponseStatus,_e.setResponseHeader,_e.notFound,$t,ot,Et,Fe,ct,lt,De,Dt,Nt,K,Bs,bn,gt,yn,Lt,rn,_n,wn,Yn,vn,Or,Ot,$n,Tt.confirm,Tt.alert,Tt.fetch,Qn,...on,...Sn)));if(i.preserveExisting){for(let[ze,kt]of Object.entries(rs))if(!(ze in n)||n[ze]===void 0)n[ze]=kt}else Object.assign(n,rs);for(let[ze,kt]of Object.entries(W))if(!(ze in n))n[ze]=kt}catch(pe){if(n.__stx_strict_hydration)throw pe;let ge=zg(pe instanceof Error?pe.message:String(pe));if(Hg(ge))console.warn(`[stx] server <script> in ${r??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${ge}`),i.onFailure?.({kind:"module-resolution",message:ge,error:pe});else if(Ug(pe))console.warn(`[stx] server <script> in ${r??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${ge}`),i.onFailure?.({kind:"syntax",message:ge,error:pe});else if(Vg(ge))console.warn(`[stx] server <script> in ${r??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${ge}`),i.onFailure?.({kind:"missing-binding",message:ge,error:pe});else{let ke=`${r??"<unknown>"}\x00${ge}`;if(xn.env.STX_DEBUG||!Fa.has(ke))Fa.add(ke),console.warn(`[stx] server <script> in ${r??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${ge}`);i.onFailure?.({kind:"unknown",message:ge,error:pe})}try{await lf(u,n,r)}catch(ke){if(xn.env.STX_DEBUG){let Ie=ke instanceof Error?ke.message:String(ke);console.warn(`[stx] fallback extraction also failed in ${r??"<unknown>"}: ${Ie}`)}}}}function Wg(e){let n=0,r=null,i=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(r){if(u===r){if(r=null,i||n===0)a=!0}continue}if(u==="'"||u==='"'||u==="`"){r=u;continue}if(u==="{")n++;else if(u==="}")n--;else if(e.startsWith("from",l)&&n===0)i=!0}return r===null&&n===0&&a}var sf=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Ki(e,n){let r=n?Rt.dirname(n):xn.cwd(),i=xn.cwd(),a=e.split(`
1320
+ `),l=[],u=0;while(u<a.length){let f=a[u].trim();if(f.startsWith("interface ")||f.startsWith("export interface ")||f.startsWith("type ")||f.startsWith("export type ")){if(f.includes("{")&&!f.includes("}")){let v=0;for(;u<a.length;u++){for(let S of a[u])if(S==="{")v++;else if(S==="}")v--;if(v<=0)break}}u++;continue}if(f.startsWith("definePageMeta(")){let v=0,S=!1,j=u;for(let D=u;D<a.length&&!S;D++){let W=null,N=!1,Y=a[D];for(let J=0;J<Y.length;J++){let te=Y[J];if(N){N=!1;continue}if(te==="\\"){N=!0;continue}if(W){if(te===W)W=null;continue}if(te==='"'||te==="'"||te==="`"){W=te;continue}if(te==="(")v++;else if(te===")"){if(v--,v===0){u=D+1,S=!0;break}}}}if(!S)u=a.length;let O=a.slice(j,u).join(`
1321
+ `);if(/\bcache\s*:\s*false\s*[,}]/.test(O))l.push("definePageMeta({ cache: false });");let H=[];for(let D of["title","description"]){let W=new RegExp(`\\b${D}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(O);if(W)H.push(`${D}: ${JSON.stringify(W[2])}`)}if(H.length>0)l.push(`useSeoMeta({ ${H.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let v=f,S=0;while(!Wg(v)&&u+S+1<a.length)S++,v=`${v} ${a[u+S].trim()}`;u+=S;let j=v.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),O=v.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),H=v.match(/^import\s*['"](.+?)['"]/),D=v,W=(N)=>{if(N.startsWith("."))return Rt.resolve(r,N);if(N.startsWith("~/")||N.startsWith("@/"))return Rt.resolve(i,N.slice(2));try{return Bun.resolveSync(N,r)}catch{return N}};if(j){let[,N,Y]=j,J=W(Y);l.push(`const ${N} = (await import('${J}')).default`),l.push(`module.exports.${N} = ${N};`)}else if(O){let[,N,Y]=O,J=W(Y),te=[],K=[],q=tf.has(Y);for(let oe of N.split(",")){let le=oe.trim();if(!le)continue;let ue=le.split(/\s+as\s+/);if(ue.length===2){let[fe,Re]=[ue[0].trim(),ue[1].trim()];if(q&&Ba.has(fe)){l.push(`const ${Re} = ${fe};`);continue}te.push(`${fe}: ${Re}`),K.push(Re)}else{if(q&&Ba.has(le))continue;te.push(le),K.push(le)}}if(te.length>0)l.push(`const { ${te.join(", ")} } = await import('${J}')`);for(let oe of K)l.push(`module.exports.${oe} = ${oe};`)}else if(H){let N=W(H[1]);l.push(`await import('${N}')`)}else l.push(D);u++;continue}if(sf.test(f))l.push(a[u]),u++;else if(f.startsWith("export const ")||f.startsWith("export let ")||f.startsWith("export var ")){let v=Ha(a,u),{type:S,name:j,value:O}=v;l.push(`${S} ${j} = ${O};`),l.push(`module.exports.${j} = ${j};`),u=v.nextIndex}else if(f.startsWith("export function ")||f.startsWith("export async function ")){let v=Ir(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("const ")||f.startsWith("let ")||f.startsWith("var ")){let v=Ha(a,u),{type:S,name:j,value:O}=v;l.push(`${S} ${j} = ${O};`),l.push(`module.exports.${j} = ${j};`),u=v.nextIndex}else if(f.startsWith("function ")||f.startsWith("async function ")){let v=Ir(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("export default function ")||f.startsWith("export default async function ")){let v=a[u].replace(/^(\s*)export\s+default\s+/,"$1"),S=[...a];S[u]=v;let j=Ir(S,u);if(l.push(j.functionCode),j.name)l.push(`module.exports.default = ${j.name};`);u=j.nextIndex}else if(f.startsWith("export default ")){let v=f.replace(/^export\s+default\s+/,"").replace(/;$/,"");l.push(`module.exports.default = ${v};`),u++}else if(f.startsWith("class ")||f.startsWith("export class ")){let v=f.match(/(?:export\s+)?class\s+(\w+)/);if(v){let S=v[1],j=a[u].replace(/^export\s+/,""),O=0,H=u;for(;H<a.length;H++){let D=a[H];for(let W of D)if(W==="{")O++;else if(W==="}")O--;if(H>u)j+=`
1322
+ `+D;if(O<=0&&H>=u)break}l.push(j),l.push(`module.exports.${S} = ${S};`),u=H+1}else l.push(f),u++}else if(f.includes("module.exports"))l.push(f),u++;else if(f.trim()&&!f.startsWith("//"))l.push(f),u++;else u++}return rf(l.join(`
1323
+ `),r,i)}function rf(e,n,r){let i=e.length,a="",l=0,u=null,f=!1,v=!1,S=0;while(l<i){let j=e[l],O=e[l+1];if(f){if(a+=j,j===`
1324
+ `)f=!1;l++;continue}if(v){if(a+=j,j==="*"&&O==="/"){a+=O,l+=2,v=!1;continue}l++;continue}if(!u&&j==="/"&&O==="/"){f=!0,a+=j,l++;continue}if(!u&&j==="/"&&O==="*"){v=!0,a+=j,l++;continue}if(u){if(a+=j,j==="\\"){a+=O,l+=2;continue}if(j===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(j==="$"&&O==="{"){S++,a+=O,l+=2;continue}if(j==="`"){u=null,l++;continue}}l++;continue}if(S>0){if(j==="{")S++;else if(j==="}")S--}if(j==='"'||j==="'"||j==="`"){u=j,a+=j,l++;continue}if(j==="a"&&e.startsWith("await",l)){let H=of(e,l);if(H){let{quote:D,path:W,end:N}=H;if(W.startsWith(".")||W.startsWith("~/")||W.startsWith("@/")){let Y=W.startsWith(".")?Rt.resolve(n,W):Rt.resolve(r,W.slice(2));a+=`await import(${D}${Y}${D})`,l=N;continue}}}a+=j,l++}return a}function of(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function Ja(e,n){let r=e[n];if(r!=="{"&&r!=="[")return null;let a=_(e,r,r==="{"?"}":"]",n);if(a===-1)return null;return{pattern:e.slice(n,a+1),endPos:a+1}}function Xa(e){let n=[],r=e.slice(1,-1).trim();if(!r)return n;let i=0,a=0,l="";while(i<r.length){let u=r[i];if(u==="{"||u==="["){let f=a===0?Ja(r,i):null;if(f){n.push(...Xa(f.pattern)),i=f.endPos,l="";continue}a++}else if(u==="}"||u==="]")a--;if(a>0){i++;continue}if(u===","){if(l.trim())n.push(l.trim());l="",i++;continue}if(u===":"){l="",i++;continue}if(u==="="){if(l.trim())n.push(l.trim());l="",i++;while(i<r.length&&r[i]!==","&&a===0){if(r[i]==="{"||r[i]==="[")a++;else if(r[i]==="}"||r[i]==="]")a--;i++}continue}if(/[\w$]/.test(u))l+=u;i++}if(l.trim())n.push(l.trim());return n}function qg(e){let n=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(e);if(!n)return null;let r=n[0].length,i=(a)=>a===" "||a==="\t";while(r<e.length&&i(e[r]))r++;if(e[r]===":"){let a=0,l=null;r++;for(;r<e.length;r++){let u=e[r];if(l){if(u==="\\"){r++;continue}if(u===l)l=null;continue}if(u==="'"||u==='"'||u==="`"){l=u;continue}if(u==="("||u==="["||u==="{"||u==="<"){a++;continue}if(u===")"||u==="]"||u==="}"||u===">"){a--;continue}if(u==="="&&a<=0){let f=e[r+1],v=e[r-1];if(f!=="="&&f!==">"&&v!=="="&&v!=="!"&&v!=="<"&&v!==">")break}}if(e[r]!=="=")return null}while(r<e.length&&i(e[r]))r++;if(e[r]!=="=")return null;return{type:n[1],name:n[2],value:e.slice(r+1).trim()}}function Ua(e,n,r,i){let a=null,l=!1;for(let u of e){if(l){l=!1;continue}if(u==="\\"){l=!0;continue}if(a){if(u===a)a=null;continue}if(u==="'"||u==='"'||u==="`"){a=u;continue}if(u===n)i++;else if(u===r)i--}return i}function Ha(e,n){let r=e[n].trim(),i=qg(r),a=i?[r,i.type,i.name,i.value]:null;if(!a){let j=r.match(/^(?:export\s+)?(const|let|var)\s+/);if(j){let O=r.slice(j[0].length),H=n;if(O.startsWith("{")||O.startsWith("[")){let W=O[0],N=W==="{"?"}":"]",Y=Ua(O,W,N,0),J=O;for(let te=n+1;te<e.length&&Y>0;te++)J+=` ${e[te].trim()}`,H=te,Y=Ua(e[te],W,N,Y);if(Y>0)J=O,H=n;O=J}let D=Ja(O,0);if(D){let W=j[1],N=D.pattern,Y=O.slice(D.endPos).trim();if(Y.startsWith("=")){let J=Y.slice(1).trim(),te=J,K=Math.max(H,n);if(Za(J)){let ue=Ka(e,K,J);te=ue.value,K=ue.nextIndex}else K=K+1;te=te.trim().replace(/;$/,"");let q=Xa(N),oe=`__stx_src_${n}`,le=q.map((ue)=>`module.exports.${ue} = ${ue};`).join(`
1325
+ `);return{type:W,name:oe,value:`${te}; ${W} ${N} = ${oe};
1326
+ ${le}`,nextIndex:K}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,v=f,S=n;if(Za(f)){let j=Ka(e,n,f);v=j.value,S=j.nextIndex}else S=n+1;while(S<e.length){let j=e[S].trim();if(j.startsWith(".")||j.startsWith("?."))v+=`
1327
+ ${e[S]}`,S++;else break}return v=v.trim().replace(/;$/,""),{type:l,name:u,value:v,nextIndex:S}}function Ir(e,n){let r=e[n].trim(),i=r.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!i)throw Error(`Failed to parse function declaration: ${r}`);let[,a]=i,l=r.replace(/^export\s+/,""),u=n;if(af(r)){let f=cf(e,n,l);l=f.functionCode,u=f.nextIndex}else u=n+1;return{name:a,functionCode:l,nextIndex:u}}function Za(e){let n=e.trim();if(n.startsWith("{"))return _(n,"{","}",0)===-1;if(n.startsWith("["))return _(n,"[","]",0)===-1;return!Ga(n)}function Ga(e){let n={paren:0,bracket:0,brace:0},r=null,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((a>0?e[a-1]:"")==="\\"&&r)continue;if((l==='"'||l==="'")&&!r){r=l;continue}if(l===r&&r!=="`"){r=null;continue}if(l==="`"&&!r){r="`";continue}if(l==="`"&&r==="`"&&i===0){r=null;continue}if(r==="`"&&l==="$"&&e[a+1]==="{"){i++,a++;continue}if(i>0&&l==="{"){i++;continue}if(i>0&&l==="}"){i--;continue}if(r)continue;if(l==="(")n.paren++;else if(l===")")n.paren--;else if(l==="[")n.bracket++;else if(l==="]")n.bracket--;else if(l==="{")n.brace++;else if(l==="}")n.brace--}return n.paren===0&&n.bracket===0&&n.brace===0&&r===null}function Ya(e){let n=e.indexOf("(");if(n===-1)return e.indexOf("{");let r=_(e,"(",")",n);if(r===-1)return-1;return e.indexOf("{",r)}function af(e){let n=Ya(e);if(n===-1)return!0;return _(e,"{","}",n)===-1}function Ka(e,n,r){let i=r,a=n+1;while(a<e.length&&!Ga(i)){let l=e[a];i+=`
1328
+ ${l}`,a++}while(a<e.length){let l=e[a].trim();if(l.startsWith(".")||l.startsWith("?."))i+=`
1329
+ ${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function cf(e,n,r){let i=r,a=n+1;while(a<e.length){let l=Ya(i);if(l!==-1){if(_(i,"{","}",l)!==-1)break}let u=e[a];i+=`
1330
+ ${u}`,a++}return{functionCode:i,nextIndex:a}}function qa(e,n){let r=d(e,n)??d(`(${e})`,n);if(r!==void 0)return r;if(!/\bprocess\b/.test(e))return;let i={...n,process:Object.freeze({env:{...xn.env}})},a=Object.keys(i).filter(qr),l=a.map((u)=>i[u]);try{return Function(...a,`'use strict'; return (${e});`)(...l)}catch{try{return Function(...a,`'use strict'; return ${e};`)(...l)}catch{return}}}async function lf(e,n,r){let i=e.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let l of i){let[,,u,f]=l;try{let v=f.trim().replace(/;$/,""),S=qa(v,n);if(S!==void 0)n[u]=S}catch(v){console.warn(`Failed to parse export ${u} in fallback:`,v)}}let a=e.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let l of a){let[,,u,f]=l;if(!(u in n))try{let v=f.trim().replace(/;$/,""),S=qa(v,n);if(S!==void 0)n[u]=S}catch{}}}function $l(e){let n=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=n?n[1]:"",i=n?e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):e;return{scriptContent:r,templateWithoutScript:i}}function Rl(e){let n=e.trim();if(!n)return!1;return/(?:const|let|var|function)\s+\w+/.test(n)}
1331
+ export{qe,Oe,Z,Zs,Qs,Q,jr,eo,to,Di,Li,ji,no,Bi,dl,Vt,o,he,k,pl,E,Br,ro,Ne,P,Ke,B,Fr,zr,ye,Wt,ie,F,ht,R,Hr,Ur,yt,fl,qt,so,oo,Ce,Fi,An,io,be,gl,ml,zi,hl,yl,ao,Hi,Ui,bl,Vi,co,Wi,Pn,lo,In,Kt,Xt,wl,uo,vl,xl,po,Sl,On,Vr,fo,go,kl,qi,_l,Cl,El,Tl,Fg,zg,Hg,Ug,Vg,b,Wg,Ki,qg,$l,Rl,Xi,Gi,Kg,Gt,Al,Xg,Pl,jy,Xe,Nn,Ge,Gg,Jg,Yg,Zg,Qg,mo,em,Je,ae,Ye,tm,Wr,nm,Il,Ol,Ji,Ze,s,Mn,Nl,w,Ee,By,Ml,Dl,Ll,Yi,ho,rm,Fy,sm,zy,Dn,m,ee,ce,Ln,Me,om,Zi,im,Hy,I,Qi,am,Uy,M,Vy};