@stacksjs/stx 0.2.770 → 0.2.774

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 (253) hide show
  1. package/dist/app-shell.d.ts +10 -0
  2. package/dist/app-shell.js +3 -0
  3. package/dist/{chunk-7wwfaj6b.js → chunk-06wqf3t8.js} +3 -3
  4. package/dist/chunk-08c2c9ee.js +2 -0
  5. package/dist/chunk-0jvrzpfs.js +2 -0
  6. package/dist/chunk-0perf9at.js +2 -0
  7. package/dist/{chunk-s8p958da.js → chunk-1frxaa7e.js} +59 -59
  8. package/dist/{chunk-zsfr4dv9.js → chunk-1hdhfc4w.js} +6 -6
  9. package/dist/chunk-1msebzht.js +2 -0
  10. package/dist/chunk-1tvb2stj.js +2 -0
  11. package/dist/{chunk-edetp97r.js → chunk-200z6ew1.js} +5 -5
  12. package/dist/{chunk-krdc3c87.js → chunk-20afyff6.js} +3 -3
  13. package/dist/{chunk-p1mbbdwj.js → chunk-27rzdq3n.js} +2 -2
  14. package/dist/{chunk-xaqtk05e.js → chunk-2gqhfge6.js} +2 -2
  15. package/dist/chunk-2vnhyter.js +2 -0
  16. package/dist/{chunk-4833k99b.js → chunk-2yxva96k.js} +2 -2
  17. package/dist/{chunk-477gjb2b.js → chunk-416jy1m5.js} +2 -2
  18. package/dist/chunk-47qestfz.js +2 -0
  19. package/dist/chunk-4kx7pw6x.js +2 -0
  20. package/dist/{chunk-x148cxrj.js → chunk-4wc5pc19.js} +4 -4
  21. package/dist/{chunk-3csfmhg0.js → chunk-5emrarpf.js} +2 -2
  22. package/dist/{chunk-erjp2w63.js → chunk-5mng4x26.js} +5 -5
  23. package/dist/{chunk-bwzjjxnj.js → chunk-605b93pe.js} +4 -4
  24. package/dist/{chunk-y6hyndrt.js → chunk-6smzs5vp.js} +10 -10
  25. package/dist/chunk-6xapz9dx.js +2 -0
  26. package/dist/chunk-713az4kg.js +2 -0
  27. package/dist/{chunk-0h3sf5tp.js → chunk-79b3sbft.js} +6 -6
  28. package/dist/chunk-7fhw11qd.js +2 -0
  29. package/dist/{chunk-6sa5adg6.js → chunk-7gdwvnwc.js} +2 -2
  30. package/dist/{chunk-g4k0svq6.js → chunk-7qk4exw1.js} +2 -2
  31. package/dist/{chunk-wmnzapn8.js → chunk-7sh9fa3q.js} +2 -2
  32. package/dist/chunk-7y2h7nfd.js +2 -0
  33. package/dist/chunk-7y6ad89y.js +2 -0
  34. package/dist/chunk-8dby49s0.js +2 -0
  35. package/dist/chunk-8ds59ttd.js +2 -0
  36. package/dist/{chunk-6cd5dyje.js → chunk-8k4j2xv8.js} +68 -68
  37. package/dist/{chunk-4qng287p.js → chunk-8nb8b0nf.js} +2 -2
  38. package/dist/chunk-8pyyqev1.js +2 -0
  39. package/dist/chunk-8qhznykd.js +177 -0
  40. package/dist/{chunk-83fh7j8g.js → chunk-985afhhy.js} +2 -2
  41. package/dist/chunk-9896204h.js +2 -0
  42. package/dist/{chunk-2vbgm9t4.js → chunk-9ct3gbyv.js} +6 -6
  43. package/dist/{chunk-yzbdm457.js → chunk-9f6qx8b9.js} +2 -2
  44. package/dist/{chunk-yjzczm2s.js → chunk-9jfva11p.js} +17 -17
  45. package/dist/chunk-9qwkyt81.js +2 -0
  46. package/dist/{chunk-tahdfsp4.js → chunk-9tec9eap.js} +2 -2
  47. package/dist/{chunk-7t1medmh.js → chunk-9z6331xs.js} +2 -2
  48. package/dist/{chunk-prxe37hj.js → chunk-a10y92qp.js} +30 -30
  49. package/dist/{chunk-6k4tbms6.js → chunk-a7f2xqsh.js} +9 -9
  50. package/dist/{chunk-gzxjayvp.js → chunk-abfphkss.js} +9 -9
  51. package/dist/{chunk-vht2rhrj.js → chunk-ady8cnpb.js} +5 -5
  52. package/dist/chunk-aj5b9dm3.js +2 -0
  53. package/dist/chunk-ajj56vrw.js +2 -0
  54. package/dist/{chunk-amnydj3d.js → chunk-ajmexj79.js} +1 -1
  55. package/dist/chunk-b3b9tfpx.js +2 -0
  56. package/dist/{chunk-ytjhb81r.js → chunk-bengxr5p.js} +3 -3
  57. package/dist/{chunk-efr9dgt6.js → chunk-bgc2fm73.js} +2 -2
  58. package/dist/{chunk-wabahwkj.js → chunk-bmfk3b29.js} +2 -2
  59. package/dist/{chunk-5s2dwh5z.js → chunk-bq9xf8nq.js} +16 -16
  60. package/dist/{chunk-392rrp28.js → chunk-br91e06f.js} +2 -2
  61. package/dist/{chunk-hgm6f2t2.js → chunk-c0ejyxfj.js} +3 -3
  62. package/dist/{chunk-9ewhnwcg.js → chunk-c85dv6tv.js} +5 -5
  63. package/dist/chunk-c91y14ae.js +2 -0
  64. package/dist/{chunk-dmj9gk6d.js → chunk-cfpw4c6b.js} +2 -2
  65. package/dist/chunk-cgamtmxv.js +2 -0
  66. package/dist/chunk-cpq9b0fx.js +2 -0
  67. package/dist/{chunk-m207mdpy.js → chunk-cz8mka1b.js} +2 -2
  68. package/dist/{chunk-rkz3k2td.js → chunk-d18xd9x5.js} +3 -3
  69. package/dist/chunk-defwzg9q.js +2 -0
  70. package/dist/chunk-drwa5hjd.js +2 -0
  71. package/dist/{chunk-3png7zhs.js → chunk-dvcfhx4y.js} +6 -6
  72. package/dist/chunk-dxp022r0.js +2 -0
  73. package/dist/{chunk-xr28hjkp.js → chunk-e1gxykm8.js} +7 -7
  74. package/dist/{chunk-rjh7ptw5.js → chunk-e7477r0v.js} +1 -1
  75. package/dist/{chunk-7h0mjwkq.js → chunk-eapt899m.js} +5 -5
  76. package/dist/{chunk-qtja7fpr.js → chunk-et1vz3wd.js} +2 -2
  77. package/dist/{chunk-s3m1ggsn.js → chunk-evb5y7sm.js} +6 -6
  78. package/dist/chunk-fbv7byxx.js +2 -0
  79. package/dist/chunk-fgstg93m.js +2 -0
  80. package/dist/chunk-fmzfmh9n.js +2 -0
  81. package/dist/{chunk-ssd9g1wz.js → chunk-fpn4dren.js} +1 -1
  82. package/dist/chunk-ft994mav.js +2 -0
  83. package/dist/chunk-gbgbhpms.js +2 -0
  84. package/dist/{chunk-cn7zpm1x.js → chunk-gbx5vw81.js} +5 -5
  85. package/dist/chunk-gdkcskm7.js +2 -0
  86. package/dist/chunk-gxp9ms4w.js +2 -0
  87. package/dist/chunk-hc0c0p0r.js +2 -0
  88. package/dist/{chunk-w07n2ddj.js → chunk-he85ksa7.js} +2 -2
  89. package/dist/chunk-hr8rzzcn.js +2 -0
  90. package/dist/{chunk-z846tgfe.js → chunk-j576e8tm.js} +3 -3
  91. package/dist/chunk-jdj1358b.js +3 -0
  92. package/dist/chunk-jpnptbtm.js +2 -0
  93. package/dist/{chunk-mcct58gb.js → chunk-k003phkg.js} +7 -7
  94. package/dist/{chunk-z5vkzbct.js → chunk-k0aejzg9.js} +4 -4
  95. package/dist/{chunk-0wj31pqy.js → chunk-k3rcpnzm.js} +2 -2
  96. package/dist/{chunk-nnzmbfjq.js → chunk-k4bdf0dw.js} +3 -3
  97. package/dist/chunk-k9dg3nyy.js +2 -0
  98. package/dist/{chunk-ddhazq2g.js → chunk-kf8hzvb7.js} +3 -3
  99. package/dist/{chunk-rc4zsymn.js → chunk-kr8qdg0r.js} +2 -2
  100. package/dist/chunk-m1rdq29w.js +2 -0
  101. package/dist/chunk-m3qmj9ec.js +2 -0
  102. package/dist/{chunk-2bm97z09.js → chunk-m4mpyq3d.js} +3 -3
  103. package/dist/{chunk-gzcg563a.js → chunk-m6nkaxcc.js} +3 -3
  104. package/dist/chunk-m90wyzhd.js +2 -0
  105. package/dist/chunk-mcevnfnx.js +2 -0
  106. package/dist/{chunk-am4wadh7.js → chunk-mv3yhspn.js} +2 -2
  107. package/dist/chunk-ndjmt3vg.js +3 -0
  108. package/dist/chunk-nmtwqvq2.js +3 -0
  109. package/dist/chunk-nthzdhsf.js +2 -0
  110. package/dist/chunk-nx20kccb.js +2 -0
  111. package/dist/chunk-p43hw6ef.js +2 -0
  112. package/dist/{chunk-pkyb284z.js → chunk-p45mzeek.js} +2 -2
  113. package/dist/{chunk-mdw5sbbt.js → chunk-p7p3b4s1.js} +2 -2
  114. package/dist/{chunk-3y26rjq6.js → chunk-pebsj489.js} +10 -10
  115. package/dist/chunk-q71qqjy7.js +2 -0
  116. package/dist/{chunk-70nwqsf6.js → chunk-qa6r6mj6.js} +4 -4
  117. package/dist/{chunk-6b32wt31.js → chunk-qby3e5nm.js} +30 -30
  118. package/dist/chunk-qezg1070.js +2 -0
  119. package/dist/{chunk-ngzdcvry.js → chunk-qfcn4btf.js} +1 -1
  120. package/dist/{chunk-7g29avcd.js → chunk-qmj7g7s8.js} +6 -6
  121. package/dist/chunk-qtcxy3y3.js +2 -0
  122. package/dist/{chunk-618d3ng3.js → chunk-r1jzbqr3.js} +6 -6
  123. package/dist/chunk-r5qfxd9s.js +2 -0
  124. package/dist/{chunk-qk61pv1v.js → chunk-ra8f8sm2.js} +15 -10
  125. package/dist/chunk-rgsb3f0j.js +2 -0
  126. package/dist/{chunk-6nf4xhv0.js → chunk-rr58ynsn.js} +6 -6
  127. package/dist/chunk-s53psb1j.js +2 -0
  128. package/dist/{chunk-ddjkt87h.js → chunk-sxwgq49z.js} +1 -1
  129. package/dist/chunk-t482tgm6.js +2 -0
  130. package/dist/{chunk-91q55gjp.js → chunk-td3qp5my.js} +3 -3
  131. package/dist/chunk-tsvnhc0c.js +4 -0
  132. package/dist/{chunk-qr5ddqbf.js → chunk-tyjzye2d.js} +2 -2
  133. package/dist/{chunk-eb8dv03t.js → chunk-vadbp45n.js} +3 -3
  134. package/dist/{chunk-nj2q40p8.js → chunk-vct6dec8.js} +2 -2
  135. package/dist/{chunk-cqfyby1t.js → chunk-vgd3r8g7.js} +2 -2
  136. package/dist/{chunk-1925kbjc.js → chunk-w9d18r1t.js} +1 -1
  137. package/dist/{chunk-5t33zwwg.js → chunk-wj78td69.js} +1 -1
  138. package/dist/{chunk-q3c130w6.js → chunk-wm65y47g.js} +14 -14
  139. package/dist/chunk-wm8wz183.js +2 -0
  140. package/dist/chunk-wn7wmjcr.js +2 -0
  141. package/dist/chunk-x0e0pcn0.js +2 -0
  142. package/dist/chunk-x756yzrc.js +2 -0
  143. package/dist/{chunk-07thf07b.js → chunk-x8anspa5.js} +2 -2
  144. package/dist/{chunk-cak9fp9b.js → chunk-x8js27hd.js} +7 -7
  145. package/dist/chunk-xad5fg2a.js +2 -0
  146. package/dist/chunk-xj5v9rnx.js +2 -0
  147. package/dist/chunk-xq2tfg4v.js +2 -0
  148. package/dist/{chunk-vke28xq8.js → chunk-y38swh5t.js} +2 -2
  149. package/dist/{chunk-pgkcbm6g.js → chunk-y5f04xtb.js} +2 -2
  150. package/dist/{chunk-z1br7qeb.js → chunk-yewd8836.js} +4 -4
  151. package/dist/chunk-ypmx0jhd.js +2 -0
  152. package/dist/chunk-yrdxvphr.js +2 -0
  153. package/dist/chunk-yx563gzr.js +2 -0
  154. package/dist/{chunk-x0qtgyqr.js → chunk-yzs2afn7.js} +9 -9
  155. package/dist/{chunk-nwhv1889.js → chunk-z2m9p8xe.js} +3 -3
  156. package/dist/{chunk-qsc5nse5.js → chunk-zbgh573z.js} +2 -2
  157. package/dist/chunk-zccysq9p.js +3 -0
  158. package/dist/chunk-zh8w0nb6.js +2 -0
  159. package/dist/{chunk-79x0812m.js → chunk-zxfptbac.js} +2 -2
  160. package/dist/cli.js +20 -20
  161. package/dist/client/signals-dom-ready-runtime.js +6 -1
  162. package/dist/craft-entry.js +2 -2
  163. package/dist/craft.js +2 -2
  164. package/dist/dev-server/serve-app.js +2 -2
  165. package/dist/native/bridge/protocol.d.ts +1 -1
  166. package/dist/native/compiler/component-mapping.js +1 -0
  167. package/dist/native/compiler/headwind-to-style.d.ts +2 -10
  168. package/dist/native/compiler/headwind-to-style.js +31 -2
  169. package/dist/native/compiler/html-to-ir.js +15 -4
  170. package/dist/native/compiler/ir.d.ts +5 -0
  171. package/dist/native/event-names.js +14 -1
  172. package/dist/native/primitives/WebView.stx +7 -0
  173. package/dist/native/prop-names.js +8 -1
  174. package/dist/native/runtime/browser-renderer.js +1 -1
  175. package/dist/native/runtime/craft-bridge.js +31 -1
  176. package/dist/native/runtime/craft.d.ts +67 -1
  177. package/dist/native/runtime/native-host.d.ts +1 -0
  178. package/dist/native/runtime/native-host.js +8 -2
  179. package/dist/native/runtime/shared-screen.js +1 -0
  180. package/dist/native/testing.d.ts +1 -1
  181. package/dist/production-server.js +5 -5
  182. package/dist/pwa.js +3 -3
  183. package/dist/ssg.js +10 -10
  184. package/package.json +5 -5
  185. package/dist/chunk-0cvpkj9g.js +0 -2
  186. package/dist/chunk-0qgdex7z.js +0 -2
  187. package/dist/chunk-1hb8q271.js +0 -2
  188. package/dist/chunk-1se5y83a.js +0 -2
  189. package/dist/chunk-2p301rsb.js +0 -2
  190. package/dist/chunk-2zg3jmy7.js +0 -2
  191. package/dist/chunk-33gccrx0.js +0 -2
  192. package/dist/chunk-3754her2.js +0 -2
  193. package/dist/chunk-3jkbs3fc.js +0 -2
  194. package/dist/chunk-3vankrf5.js +0 -2
  195. package/dist/chunk-4jzyd8k0.js +0 -2
  196. package/dist/chunk-4tvty67c.js +0 -2
  197. package/dist/chunk-4xaz5jbs.js +0 -2
  198. package/dist/chunk-4xzk9529.js +0 -3
  199. package/dist/chunk-53md2scd.js +0 -2
  200. package/dist/chunk-56sek7x7.js +0 -2
  201. package/dist/chunk-5g5v7yns.js +0 -2
  202. package/dist/chunk-5gg5jc76.js +0 -2
  203. package/dist/chunk-68j6zb7n.js +0 -2
  204. package/dist/chunk-6wf0ter4.js +0 -2
  205. package/dist/chunk-75st1ttq.js +0 -2
  206. package/dist/chunk-7ctvfad1.js +0 -2
  207. package/dist/chunk-7y0v5dry.js +0 -3
  208. package/dist/chunk-83aq0n9s.js +0 -2
  209. package/dist/chunk-9vgkp3nj.js +0 -2
  210. package/dist/chunk-9vqj5jzp.js +0 -2
  211. package/dist/chunk-a50kn0hn.js +0 -2
  212. package/dist/chunk-bpbhjn4w.js +0 -2
  213. package/dist/chunk-bqyj88qr.js +0 -2
  214. package/dist/chunk-cgv3r6q9.js +0 -2
  215. package/dist/chunk-e645nk33.js +0 -4
  216. package/dist/chunk-e6zv6p3x.js +0 -2
  217. package/dist/chunk-e96jbmkj.js +0 -3
  218. package/dist/chunk-ej4wf9m5.js +0 -2
  219. package/dist/chunk-exfgfjf6.js +0 -2
  220. package/dist/chunk-fvg2p9z0.js +0 -2
  221. package/dist/chunk-fxvhkz72.js +0 -2
  222. package/dist/chunk-g6m3q9n4.js +0 -2
  223. package/dist/chunk-gn5v004x.js +0 -177
  224. package/dist/chunk-h2ymq7fa.js +0 -2
  225. package/dist/chunk-hnen9b45.js +0 -2
  226. package/dist/chunk-j1nyasyk.js +0 -2
  227. package/dist/chunk-j46nvncc.js +0 -2
  228. package/dist/chunk-jjvrm2j8.js +0 -2
  229. package/dist/chunk-kh0szwf3.js +0 -2
  230. package/dist/chunk-krw4m6j1.js +0 -2
  231. package/dist/chunk-mvfj17fr.js +0 -2
  232. package/dist/chunk-nmjgcw4g.js +0 -2
  233. package/dist/chunk-p454tj1h.js +0 -2
  234. package/dist/chunk-q245q8z1.js +0 -2
  235. package/dist/chunk-q4m5p4wx.js +0 -2
  236. package/dist/chunk-q85s8ne0.js +0 -2
  237. package/dist/chunk-qe3hrbge.js +0 -2
  238. package/dist/chunk-qq4ee7px.js +0 -2
  239. package/dist/chunk-rfp5f55f.js +0 -2
  240. package/dist/chunk-th7amyq4.js +0 -2
  241. package/dist/chunk-v95kersm.js +0 -2
  242. package/dist/chunk-w1sjp421.js +0 -2
  243. package/dist/chunk-w5d936jr.js +0 -2
  244. package/dist/chunk-wwnqbv9j.js +0 -3
  245. package/dist/chunk-x3xtyr95.js +0 -2
  246. package/dist/chunk-xb16yy2x.js +0 -2
  247. package/dist/chunk-yavspk55.js +0 -2
  248. package/dist/chunk-yrh9yfnv.js +0 -2
  249. package/dist/chunk-ysm6gaq9.js +0 -2
  250. package/dist/chunk-z515xymr.js +0 -2
  251. package/dist/chunk-z6xfmrtc.js +0 -2
  252. package/dist/chunk-za7v4w04.js +0 -2
  253. package/dist/chunk-zb8wv7sc.js +0 -2
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ll,ul}from"./chunk-yzbdm457.js";import{H,hr,Ps,Is,ni,ri,Os,br,Ne,pe,G,vr,ie,J,I,nt,xr,ai,_r,Fe,r,p,V,bn}from"./chunk-s8p958da.js";import{f,R,rt,d}from"./chunk-5s2dwh5z.js";import{n}from"./chunk-e96jbmkj.js";import{se}from"./chunk-w07n2ddj.js";import{s}from"./chunk-2bm97z09.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import K from"path";import{decode as on,generateThumbHash as an}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import De from"fs";function Ce(e,t,i){let o=Buffer.alloc(i),a=De.readSync(e,o,0,i,t);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let t=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let i=t(12,16);if(i==="VP8X")return(e[20]&16)!==0;if(i==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=De.openSync(e,"r");let i=Ce(t,0,33);if(i.length>=3&&i[0]===255&&i[1]===216&&i[2]===255)return"none";if(i.length>=26&&i[0]===137&&i.toString("latin1",1,4)==="PNG"){let o=i[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(t,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(i.length>=25&&i.toString("latin1",0,4)==="RIFF"&&i.toString("latin1",8,12)==="WEBP"){if(je(i))return"possible";let o=i.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)De.closeSync(t)}}import Yt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Qt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let i=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(i.protocol==="file:"&&Yt.existsSync(mt(i)))return mt(i)}catch{}try{let i=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return i&&sn(i)?i:void 0}catch{return}}function sn(e,t=process.env){let i=e.replace(/\\/g,"/");if(i.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![t.BUN_INSTALL_CACHE_DIR,gt(t.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>i.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof pt!=="function")return he("node:worker_threads has no Worker in this runtime");let i=rn();if(!i)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((o,a)=>{let c;try{c=new pt(i)}catch(y){o(he(`could not start ${i}: ${Le(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:t});return}if(y.type==="result"){u(()=>o(y.value));return}let v=Error(y.error?.message??"image worker failed");if(y.error?.name)v.name=y.error.name;if(y.error?.stack)v.stack=y.error.stack;u(()=>a(v))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Le(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${Le(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var cn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),ln=[320,640,960,1280,1920],ye="/_stx/images",un=`stx:${ye}:alpha-1`,fn=`stx:${ye}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let i=K.dirname(Bun.resolveSync(e,t));while(i!==K.dirname(i)){let o=K.join(i,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}i=K.dirname(i)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=K.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let i;try{i=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${i??"unknown"}`}).join("+"),Pe}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var wt=new Set;function mn(e){return`/${e.split(K.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=K.extname(e),i=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${i||"image"}-${o}`}function $t(e,t=`stx:${ye}`){let i=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(o){let a=K.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:i(o)}:null}catch{return null}},async write(o,a){let c=K.join(e,o);await Q.promises.mkdir(K.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:i(o)}},url:i}}async function At(e,t=e){let i=await Q.promises.readdir(t,{withFileTypes:!0});i.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of i){let c=K.join(t,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!cn.has(K.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:K.relative(e,c)})}return o}function St(e,t){return e.map((i)=>({key:mn(i.relativePath),input:i.absolutePath,name:pn(i.relativePath),...hn(i.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return Me(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),i=new Set,o=8;for(let a=0;a<t.length;a+=8)await Promise.all(t.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await on(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(yn(u.data))i.add(c)}catch{i.add(c)}}));return i}function vn(e,t){let i=[];for(let o of t){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,i.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return i}async function wn(e){let t=[],i=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await an(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));t.push(...c.filter((l)=>l!==null))}return t}function Ue(e){return K.join(e,"undecodable.json")}function $n(e){try{let t=Q.readFileSync(Ue(e),"utf-8"),i=JSON.parse(t);return i&&typeof i==="object"?i:{}}catch{return{}}}function Sn(e,t){try{Q.mkdirSync(K.dirname(Ue(e)),{recursive:!0}),Q.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function Ct(e){try{let t=Q.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function No(e){let t=kt(e);return t?be().catalog.get(t):void 0}function Do(e){let t=kt(e);return t?be().transparent.has(t):!1}function Mo(e){let t=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),i=t(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:t(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<i).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Eh(e){let t=No(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:Mo(t).map(({format:i,srcset:o})=>({type:`image/${i}`,srcset:o})),width:t.source.width,height:t.source.height,placeholder:Do(e)?void 0:t.placeholder?.dataUrl}}function as(){let e=be();e.catalog=new Map,e.transparent=new Set}function Cn(e){let t=be();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function Th(e,t,i={}){if(!e||!Q.existsSync(e))return as(),{count:0,fingerprint:""};if(i.offThread){let h=await ze("delivery",{publicDir:e,outputDir:t});if(h!==ke)return Cn(h.state),h.result}let o=await At(e);if(o.length===0)return as(),{count:0,fingerprint:""};let a=$n(t),c=o.filter((h)=>{let w=a[h.relativePath];if(!w)return!0;let S=Ct(h.absolutePath);return!S||S.mtimeMs!==w.mtimeMs||S.size!==w.size});if(c.length===0)return as(),{count:0,fingerprint:""};let l=$t(K.join(t,"_stx","images"),`${un}:${xt()}`),m={outDir:K.join(t,"_stx","images"),storage:$t(K.join(t,"_stx","images"),`${fn}:${xt()}`),baseUrl:ye,widths:ln,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(h){if(u=await wn(c),u.length===c.length)throw h;let w=new Set(u.map((A)=>A.relativePath)),S=!1;for(let A of c){if(w.has(A.relativePath))continue;let P=Ct(A.absolutePath);if(!P)continue;a[A.relativePath]=P,S=!0}if(S)Sn(t,a);if(u.length===0)return as(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let v=await xn(y.entries),b=vn(y.entries,v),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=v;let x=v.size===0&&b.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:b.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,i,o){let a=ni(e,o);if(a!==void 0)return a;for(let c of ri(e,t,i,o))if(await r(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Rn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function He(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Rn.has(t)}function oe(e,t){let i=[];for(let[o,a]of Object.entries(e.static)){if(t.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)i.push(p(c));continue}if(a===re){i.push(p(c));continue}i.push(`${p(c)}="${bn(c,We(String(a)))}"`)}return i}function ae(e,t){let i=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(t.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){i.push(p(c));continue}if(typeof a==="object")continue;i.push(`${p(c)}="${bn(c,We(String(a)))}"`)}return i}function An(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var qe={name:"StxLink",aliases:["stx-link"],render(e,t,i){let o=An(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(br(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...oe(e,v)),u.push(...ae(e,v)),`<a ${u.join(" ")}>${t}</a>`}};var kn=new Map;function Xe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return kn.get(t)}var Pn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function Z(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}function Ie(e,t,i=!1){let o=e.serverDynamic[t];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[t];if(a!==void 0)return a!=="false"&&a!==!1;return i}function Ve(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),i=[];for(let o of t)if(o.includes(":")){let[a,c]=o.split(":"),l=Pn[a];if(l)i.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))i.push(`(max-width: ${m}px) ${c}`)}}else i.push(o);return i.join(", ")}function Ge(e,t,i,o){return t.map((a)=>`${xe(e,a,void 0,i,o)} ${a}w`).join(", ")}function In(e,t,i,o,a){return t.map((c)=>{let l=i?i*c:void 0;return`${xe(e,l,void 0,o,a)} ${c}x`}).join(", ")}function xe(e,t,i,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(t)c.push(`w_${t}`);if(i)c.push(`h_${i}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(t)c.set("w",String(t));if(i)c.set("h",String(i));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(t)c.set("width",String(t));if(i)c.set("height",String(i));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function En(e,t,i="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${i}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Ke={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,i){let o=Z(e,"src")||"",a=No(o),c=Z(e,"alt")||"",l=Z(e,"width")||(a?String(a.source.width):void 0),m=Z(e,"height")||(a?String(a.source.height):void 0),u=Z(e,"sizes"),y=Z(e,"srcset"),v=Z(e,"densities"),b=Z(e,"format"),C=Do(o)||Xe(o)?.transparent===!0,x=Z(e,"placeholder")||(a&&!C?"thumbhash":void 0),h=Z(e,"placeholderColor")||"#e5e7eb",w=Z(e,"provider"),S=Z(e,"class")||Z(e,"className")||"",A=Z(e,"style")||"",P=Z(e,"objectFit")||Z(e,"fit"),k=Z(e,"objectPosition")||Z(e,"position"),O=Z(e,"quality"),W=Ie(e,"lazy",!0),z=Ie(e,"preload",!1),U=Ie(e,"priority",!1),q=Z(e,"loading"),B=Z(e,"decoding")||"async",N=!!a||Ie(e,"picture",!1)||!!b,T=l?Number.parseInt(l):void 0,j=m?Number.parseInt(m):void 0,F=y||"",X="";if(a)F=a.sources[a.fallback.format]||"",X=u?Ve(u):"100vw";else if(!F&&u&&w&&w!=="local"&&w!=="static")F=Ge(o,Ze,w,b),X=Ve(u);else if(!F&&v){let _=v.split(/\s+/).map((E)=>Number.parseFloat(E.replace("x","")));F=In(o,_,T,w,b)}else if(u)X=Ve(u);let L=[];if(A)L.push(A);if(P)L.push(`object-fit:${P}`);if(k)L.push(`object-position:${k}`);if(T&&j)L.push(`aspect-ratio:${T}/${j}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let _=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:h}:Xe(o);if(_&&x==="color")L.push(`background-color:${_.color}`),D.push("backgroundColor");else if(_)L.push(`background-color:${_.color}`),L.push(`background-image:url(${_.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let E=En(T||16,j||9,h);L.push(`background-image:url(${E})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||xe(o,T,j,w,b),Y=[];if(Y.push(`src="${n(br($e,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let le=q||(U||z?"eager":W?"lazy":"");if(le)Y.push(`loading="${n(le)}"`);if(U)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(B)}"`),S)Y.push(`class="${n(S)}"`);if(L.length>0)Y.push(`style="${n(L.join(";"))}"`);if(F)Y.push(`srcset="${n(br(F,"fetched"))}"`);if(X)Y.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let _=typeof e.static.onload==="string"?e.static.onload:"",E=_n(D)+(_?`;${_}`:"");Y.push(`onload="${n(E)}"`),te.add("onload")}Y.push(...oe(e,te)),Y.push(...ae(e,te));let Te=`<img ${Y.join(" ")} />`,M="";if(z){let E=b==="webp"?"image/webp":b==="avif"?"image/avif":"";M=`<link rel="preload" as="image" href="${n($e)}"${E?` type="${E}"`:""}${F?` imagesrcset="${n(F)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
3
- `}if(N){let _=[];if(a)for(let E of Mo(a))_.push(`<source type="image/${E.format}" srcset="${n(E.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(b==="avif"||b==="auto")){let E=xe(o,T,j,w,"avif"),ee=F?Ge(o,Ze,w,"avif"):`${E}`;_.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(b==="webp"||b==="auto")){let E=xe(o,T,j,w,"webp"),ee=F?Ge(o,Ze,w,"webp"):`${E}`;_.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${M}<picture>
2
+ import{ul,dl}from"./chunk-9f6qx8b9.js";import{H,yr,Is,Os,ri,si,Ns,wr,Ne,pe,G,xr,ie,J,I,rt,Sr,ci,Cr,Fe,r,p,V,wn}from"./chunk-1frxaa7e.js";import{f,R,st,d}from"./chunk-bq9xf8nq.js";import{n}from"./chunk-zccysq9p.js";import{se}from"./chunk-he85ksa7.js";import{s}from"./chunk-m4mpyq3d.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import K from"path";import{decode as on,generateThumbHash as an}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import De from"fs";function Ce(e,t,i){let o=Buffer.alloc(i),a=De.readSync(e,o,0,i,t);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let t=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let i=t(12,16);if(i==="VP8X")return(e[20]&16)!==0;if(i==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=De.openSync(e,"r");let i=Ce(t,0,33);if(i.length>=3&&i[0]===255&&i[1]===216&&i[2]===255)return"none";if(i.length>=26&&i[0]===137&&i.toString("latin1",1,4)==="PNG"){let o=i[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(t,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(i.length>=25&&i.toString("latin1",0,4)==="RIFF"&&i.toString("latin1",8,12)==="WEBP"){if(je(i))return"possible";let o=i.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)De.closeSync(t)}}import Yt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Qt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function en(){if(Ae<Qt()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function tn(){Ae--,yt.shift()?.()}var nn="@stacksjs/stx/builtins/image-warmup-worker";function rn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let i=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(i.protocol==="file:"&&Yt.existsSync(mt(i)))return mt(i)}catch{}try{let i=typeof Bun<"u"?Bun.resolveSync(nn,e):void 0;return i&&sn(i)?i:void 0}catch{return}}function sn(e,t=process.env){let i=e.replace(/\\/g,"/");if(i.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![t.BUN_INSTALL_CACHE_DIR,gt(t.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>i.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof pt!=="function")return he("node:worker_threads has no Worker in this runtime");let i=rn();if(!i)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await en();try{return await new Promise((o,a)=>{let c;try{c=new pt(i)}catch(y){o(he(`could not start ${i}: ${Le(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:t});return}if(y.type==="result"){u(()=>o(y.value));return}let v=Error(y.error?.message??"image worker failed");if(y.error?.name)v.name=y.error.name;if(y.error?.stack)v.stack=y.error.stack;u(()=>a(v))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Le(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${Le(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{tn()}}var cn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),ln=[320,640,960,1280,1920],ye="/_stx/images",un=`stx:${ye}:alpha-1`,fn=`stx:${ye}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let i=K.dirname(Bun.resolveSync(e,t));while(i!==K.dirname(i)){let o=K.join(i,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}i=K.dirname(i)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=K.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let i;try{i=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${i??"unknown"}`}).join("+"),Pe}var vt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[vt]??={catalog:new Map,transparent:new Set},e[vt]}var wt=new Set;function mn(e){return`/${e.split(K.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=K.extname(e),i=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${i||"image"}-${o}`}function $t(e,t=`stx:${ye}`){let i=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(o){let a=K.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:i(o)}:null}catch{return null}},async write(o,a){let c=K.join(e,o);await Q.promises.mkdir(K.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:i(o)}},url:i}}async function At(e,t=e){let i=await Q.promises.readdir(t,{withFileTypes:!0});i.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of i){let c=K.join(t,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!cn.has(K.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:K.relative(e,c)})}return o}function St(e,t){return e.map((i)=>({key:mn(i.relativePath),input:i.absolutePath,name:pn(i.relativePath),...hn(i.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return Me(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function bn(e){let t=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),i=new Set,o=8;for(let a=0;a<t.length;a+=8)await Promise.all(t.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await on(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(yn(u.data))i.add(c)}catch{i.add(c)}}));return i}function xn(e,t){let i=[];for(let o of t){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,i.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return i}async function vn(e){let t=[],i=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await an(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));t.push(...c.filter((l)=>l!==null))}return t}function Ue(e){return K.join(e,"undecodable.json")}function $n(e){try{let t=Q.readFileSync(Ue(e),"utf-8"),i=JSON.parse(t);return i&&typeof i==="object"?i:{}}catch{return{}}}function Sn(e,t){try{Q.mkdirSync(K.dirname(Ue(e)),{recursive:!0}),Q.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function Ct(e){try{let t=Q.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Do(e){let t=kt(e);return t?be().catalog.get(t):void 0}function Mo(e){let t=kt(e);return t?be().transparent.has(t):!1}function Lo(e){let t=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),i=t(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:t(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<i).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Th(e){let t=Do(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:Lo(t).map(({format:i,srcset:o})=>({type:`image/${i}`,srcset:o})),width:t.source.width,height:t.source.height,placeholder:Mo(e)?void 0:t.placeholder?.dataUrl}}function cs(){let e=be();e.catalog=new Map,e.transparent=new Set}function Cn(e){let t=be();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function $h(e,t,i={}){if(!e||!Q.existsSync(e))return cs(),{count:0,fingerprint:""};if(i.offThread){let h=await ze("delivery",{publicDir:e,outputDir:t});if(h!==ke)return Cn(h.state),h.result}let o=await At(e);if(o.length===0)return cs(),{count:0,fingerprint:""};let a=$n(t),c=o.filter((h)=>{let w=a[h.relativePath];if(!w)return!0;let S=Ct(h.absolutePath);return!S||S.mtimeMs!==w.mtimeMs||S.size!==w.size});if(c.length===0)return cs(),{count:0,fingerprint:""};let l=$t(K.join(t,"_stx","images"),`${un}:${xt()}`),m={outDir:K.join(t,"_stx","images"),storage:$t(K.join(t,"_stx","images"),`${fn}:${xt()}`),baseUrl:ye,widths:ln,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(h){if(u=await vn(c),u.length===c.length)throw h;let w=new Set(u.map((A)=>A.relativePath)),S=!1;for(let A of c){if(w.has(A.relativePath))continue;let P=Ct(A.absolutePath);if(!P)continue;a[A.relativePath]=P,S=!0}if(S)Sn(t,a);if(u.length===0)return cs(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let v=await bn(y.entries),b=xn(y.entries,v),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=v;let x=v.size===0&&b.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:b.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,i,o){let a=ri(e,o);if(a!==void 0)return a;for(let c of si(e,t,i,o))if(await r(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Rn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function He(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Rn.has(t)}function oe(e,t){let i=[];for(let[o,a]of Object.entries(e.static)){if(t.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)i.push(p(c));continue}if(a===re){i.push(p(c));continue}i.push(`${p(c)}="${wn(c,We(String(a)))}"`)}return i}function ae(e,t){let i=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(t.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){i.push(p(c));continue}if(typeof a==="object")continue;i.push(`${p(c)}="${wn(c,We(String(a)))}"`)}return i}function An(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var qe={name:"StxLink",aliases:["stx-link"],render(e,t,i){let o=An(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(wr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...oe(e,v)),u.push(...ae(e,v)),`<a ${u.join(" ")}>${t}</a>`}};var kn=new Map;function Xe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return kn.get(t)}var Pn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function Z(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}function Ie(e,t,i=!1){let o=e.serverDynamic[t];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[t];if(a!==void 0)return a!=="false"&&a!==!1;return i}function Ve(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),i=[];for(let o of t)if(o.includes(":")){let[a,c]=o.split(":"),l=Pn[a];if(l)i.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))i.push(`(max-width: ${m}px) ${c}`)}}else i.push(o);return i.join(", ")}function Ge(e,t,i,o){return t.map((a)=>`${xe(e,a,void 0,i,o)} ${a}w`).join(", ")}function In(e,t,i,o,a){return t.map((c)=>{let l=i?i*c:void 0;return`${xe(e,l,void 0,o,a)} ${c}x`}).join(", ")}function xe(e,t,i,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(t)c.push(`w_${t}`);if(i)c.push(`h_${i}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(t)c.set("w",String(t));if(i)c.set("h",String(i));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(t)c.set("width",String(t));if(i)c.set("height",String(i));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function En(e,t,i="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${i}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Ke={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,i){let o=Z(e,"src")||"",a=Do(o),c=Z(e,"alt")||"",l=Z(e,"width")||(a?String(a.source.width):void 0),m=Z(e,"height")||(a?String(a.source.height):void 0),u=Z(e,"sizes"),y=Z(e,"srcset"),v=Z(e,"densities"),b=Z(e,"format"),C=Mo(o)||Xe(o)?.transparent===!0,x=Z(e,"placeholder")||(a&&!C?"thumbhash":void 0),h=Z(e,"placeholderColor")||"#e5e7eb",w=Z(e,"provider"),S=Z(e,"class")||Z(e,"className")||"",A=Z(e,"style")||"",P=Z(e,"objectFit")||Z(e,"fit"),k=Z(e,"objectPosition")||Z(e,"position"),O=Z(e,"quality"),W=Ie(e,"lazy",!0),z=Ie(e,"preload",!1),U=Ie(e,"priority",!1),q=Z(e,"loading"),B=Z(e,"decoding")||"async",N=!!a||Ie(e,"picture",!1)||!!b,T=l?Number.parseInt(l):void 0,j=m?Number.parseInt(m):void 0,F=y||"",X="";if(a)F=a.sources[a.fallback.format]||"",X=u?Ve(u):"100vw";else if(!F&&u&&w&&w!=="local"&&w!=="static")F=Ge(o,Ze,w,b),X=Ve(u);else if(!F&&v){let _=v.split(/\s+/).map((E)=>Number.parseFloat(E.replace("x","")));F=In(o,_,T,w,b)}else if(u)X=Ve(u);let L=[];if(A)L.push(A);if(P)L.push(`object-fit:${P}`);if(k)L.push(`object-position:${k}`);if(T&&j)L.push(`aspect-ratio:${T}/${j}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let _=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:h}:Xe(o);if(_&&x==="color")L.push(`background-color:${_.color}`),D.push("backgroundColor");else if(_)L.push(`background-color:${_.color}`),L.push(`background-image:url(${_.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let E=En(T||16,j||9,h);L.push(`background-image:url(${E})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||xe(o,T,j,w,b),Y=[];if(Y.push(`src="${n(wr($e,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let le=q||(U||z?"eager":W?"lazy":"");if(le)Y.push(`loading="${n(le)}"`);if(U)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(B)}"`),S)Y.push(`class="${n(S)}"`);if(L.length>0)Y.push(`style="${n(L.join(";"))}"`);if(F)Y.push(`srcset="${n(wr(F,"fetched"))}"`);if(X)Y.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let _=typeof e.static.onload==="string"?e.static.onload:"",E=_n(D)+(_?`;${_}`:"");Y.push(`onload="${n(E)}"`),te.add("onload")}Y.push(...oe(e,te)),Y.push(...ae(e,te));let Te=`<img ${Y.join(" ")} />`,M="";if(z){let E=b==="webp"?"image/webp":b==="avif"?"image/avif":"";M=`<link rel="preload" as="image" href="${n($e)}"${E?` type="${E}"`:""}${F?` imagesrcset="${n(F)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
3
+ `}if(N){let _=[];if(a)for(let E of Lo(a))_.push(`<source type="image/${E.format}" srcset="${n(E.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(b==="avif"||b==="auto")){let E=xe(o,T,j,w,"avif"),ee=F?Ge(o,Ze,w,"avif"):`${E}`;_.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(b==="webp"||b==="auto")){let E=xe(o,T,j,w,"webp"),ee=F?Ge(o,Ze,w,"webp"):`${E}`;_.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${M}<picture>
4
4
  ${_.join(`
5
5
  `)}
6
6
  ${Te}
@@ -28,7 +28,7 @@ ${Te}
28
28
  @media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
29
29
  .stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
30
30
  .stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
31
- </style>`}};function de(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}var Ot={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},st={name:"StxDrawer",aliases:["stx-drawer"],render(e,t,i){let o=de(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=de(e,"side")||"right",l=de(e,"size")||"md",m=de(e,"closeOnBackdrop")!=="false",u=de(e,"closeOnEscape")!=="false",y=de(e,"overlay")!=="false",v=Ot[l]||Ot.md,b=c==="left",C=b?"left:0":"right:0",x=b?"translateX(-100%)":"translateX(100%)",h=b?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${m}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;${y?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
31
+ </style>`}};function de(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}var Ot={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},nt={name:"StxDrawer",aliases:["stx-drawer"],render(e,t,i){let o=de(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=de(e,"side")||"right",l=de(e,"size")||"md",m=de(e,"closeOnBackdrop")!=="false",u=de(e,"closeOnEscape")!=="false",y=de(e,"overlay")!=="false",v=Ot[l]||Ot.md,b=c==="left",C=b?"left:0":"right:0",x=b?"translateX(-100%)":"translateX(100%)",h=b?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${m}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;${y?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
32
32
  <div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${C};width:${v};max-width:100vw;transform:${x};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
33
33
  <div style="padding:1.5rem">${t}</div>
34
34
  </div>
@@ -37,6 +37,6 @@ ${Te}
37
37
  @media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
38
38
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
39
39
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
40
- </style>`}};import{existsSync as Bn,readFileSync as Tn}from"fs";var Oe=new Map,Bt=new Set;function Dn(e){if(Bt.has(e))return;Bt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function jn(e){let t=process.cwd();for(let i of[`${t}/node_modules/@iconify-json/${e}/icons.json`,`${t}/pantry/@iconify-json/${e}/icons.json`,`${t}/node_modules/@iconify/json/json/${e}.json`,`${t}/pantry/@iconify/json/json/${e}.json`])if(Bn(i))return i;for(let i of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(i)}catch{}return null}function Mn(e){if(Oe.has(e))return Oe.get(e);let t=jn(e);if(!t)return Dn(e),null;try{let i=JSON.parse(Tn(t,"utf8"));return Oe.set(e,i),i}catch{return null}}function Ln(e,t,i,o){let a=[];if(t.rotate)a.push(`rotate(${t.rotate*90} ${i/2} ${o/2})`);if(t.hFlip)a.push(`translate(${i} 0) scale(-1 1)`);if(t.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function zn(e,t){let i=t,o=e.icons[i],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[i];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;i=u.parent,o=e.icons[i]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Ln(o.body,a,c,l),width:c,height:l}}function ge(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);if(e.static[t]!==void 0)return String(e.static[t]);if(e.clientReactive[t]!==void 0)return e.clientReactive[t];return}var it={name:"Icon",aliases:["icon","stx-icon"],render(e,t,i){let o=ge(e,"name")??ge(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let S=o.split(":");a=S[0],c=S[1]}let l=n(ge(e,"size")||"24"),m=n(ge(e,"color")||"currentColor"),u=n(ge(e,"class")||""),y=n(ge(e,"style")||""),v=Oe.get(a)??Mn(a);if(!v)return`<!-- Icon: collection "${a}" not loaded -->`;let b=zn(v,c);if(!b)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${b.width} ${b.height}`,x=b.body;if(m!=="currentColor")x=x.replace(/currentColor/g,m);let h=u?` class="${u}"`:"",w=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${h}${w}>${x}</svg>`}};function Tt(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}function Dt(e,t){let i=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(i);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ot={name:"Suspense",aliases:["suspense"],render(e,t,i){let o=Dt(t,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Tt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Tt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}var at={name:"TransitionGroup",aliases:["transition-group"],render(e,t,i){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${t}</${a}>`}};function jt(e=ue){e.registerBuiltin(qe),e.registerBuiltin(Ke),e.registerBuiltin(Je),e.registerBuiltin(Qe),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at)}var Mt=new Map;function Un(e){let t=Mt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Mt.set(e.source,t);return t}var Lt=new WeakMap;function zt(e){let t=Lt.get(e);if(!t)t=new Set([...e].map((o)=>o.toLowerCase())),Lt.set(e,t);let i=t;return(o)=>!/[a-z]/.test(o)&&i.has(o.toLowerCase())}function Fn(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function Ut(e,t,i){let o=[],a=0,c=typeof i==="function"?i:i?(l)=>i.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Un(t);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let S=l+1+y.length;while(S<e.length&&e[S]!==">")S++;a=S+1;continue}let v=l+1+y.length,b=null,C=v,x=-1,h=!1;while(v<e.length){let S=e[v];if(b){if(S==="\\"&&v+1<e.length){v+=2;continue}if(S===b)b=null;v++;continue}if(S==='"'||S==="'"){b=S,v++;continue}if(S==="/"&&v+1<e.length&&e[v+1]===">"){x=v+2,h=!0;break}if(S===">"){x=v+1;break}v++}if(x===-1){a=l+1;continue}let w=e.slice(C,h?x-2:x-1).trim();if(h)o.push({fullMatch:e.slice(l,x),tagName:y,attributes:w,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let S=`<${y}`,A=`</${y}>`,P=1,k=x,O=-1;while(P>0&&k<e.length){let U=e.indexOf(S,k),q=e.indexOf(A,k);if(q===-1)break;if(U!==-1&&U<q){let B=e[U+S.length];if(B===" "||B===">"||B==="/"||B===`
41
- `||B==="\t"){let N=Fn(e,U+S.length);if(e[N-1]!=="/")P++;k=N+1}else k=U+S.length}else{if(P--,P===0){O=q;break}k=q+A.length}}if(O===-1){a=x;continue}let W=e.slice(x,O),z=O+A.length;o.push({fullMatch:e.slice(l,z),tagName:y,attributes:w,content:W,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ct(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ft(e,t){try{let i=Buffer.from(e,"base64").toString("utf8");return JSON.parse(i)}catch{}try{let i=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(i)}catch(i){if(t?.debug)console.error("Error decoding __stx_ prop:",i);return e}}function lt(e,t){let i=0,o="",a=t;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")i++;else if(c==="}"){if(i--,i===0)return e.slice(t,a+1)}a++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(lt(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var Wn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function qn(e){return ut(e).map((t)=>[t.start,t.end])}function ut(e){let t=[],i=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,o;while((o=i.exec(e))!==null){let a=o[2]||"",c=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(a);if(!c)continue;let l=J(c[1]??c[2]??c[3]??""),m=o.index,u=m+o[0].length,y=o[1].toLowerCase();if(o[0].endsWith("/>")||Hn.has(y)){t.push({start:m,end:u,names:l});continue}let v=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),b=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");b.lastIndex=u;let C=1,x=u,h;while((h=b.exec(e))!==null)if(h[0].startsWith("</")){if(C--,C===0){x=h.index+h[0].length;break}}else if(!h[0].endsWith("/>"))C++;t.push({start:m,end:x,names:l})}return t}function Ht(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ht(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function sc(e,t){if(!/:[\w-]+=/.test(e))return e;let i=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...qn(e));let l=new Set([...nt(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function m(C){return a.some(([x,h])=>C>=x&&C<h)}let u=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,y=[],v=new Map,b=256;while((c=u.exec(i))!==null){if(m(c.index))continue;let C=c[0],x=c[2];if(!x||!x.includes(":"))continue;let h=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),w=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,S,A=x,P=!1;while((S=w.exec(x))!==null){if(vr(x,S.index,!0)?.kind==="attribute")continue;let k=S[1],O=S[2];if(ll(k))continue;if(I(O,l))continue;if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let W=Object.keys(t),z=Object.values(t),U=O.match(/^([a-zA-Z_$][\w$]*)/);if(U&&!W.includes(U[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(U[1]))continue;let q=JSON.stringify([W,O]),B=v.get(q);if(!B){if(B=Function(...W,`return (${O})`),v.size>=b)v.clear();v.set(q,B)}let N=B(...z);if(k==="class"){let T=V(Ht(N));if(T){let j=A.match(/\sclass="([^"]*)"/);if(j)A=A.replace(j[0],()=>` class="${j[1]} ${T}"`);else A=A.replace(S[0],()=>` class="${T}"`)}else A=A.replace(S[0],"");P=!0;continue}if(Wn.has(k)){if(N)A=A.replace(S[0],` ${k}`);else A=A.replace(S[0],"");P=!0;continue}if(N===null||N===void 0||N===!1)A=A.replace(S[0],"");else{let T=h&&typeof N==="object"?JSON.stringify(N):String(N),j=bn(k,T);A=A.replace(S[0],()=>` ${k}="${j}"`)}P=!0}catch(W){if(W instanceof ie)throw W;continue}}if(P){let k=c[3]?" /":"",W=`<${c[1]}${A}${k}>`;y.push({start:c.index,end:c.index+C.length,replacement:W})}}if(y.length>0){let C=Array(y.length*2+1),x=0;for(let h=0;h<y.length;h++){let{start:w,end:S,replacement:A}=y[h];C[h*2]=i.slice(x,w),C[h*2+1]=A,x=S}C[y.length*2]=i.slice(x),i=C.join("")}return i}import qt from"fs";import Xt from"path";var Zt=!1;function Xn(e,t,i,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),m=(b)=>{if(l.size===0)return!1;let C=s(b),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let h of l){let w=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${w}\\s*\\(`).test(C))return!0}return!1},u=new Set(ul),y=(b)=>{if(!b.includes("-")||b.startsWith("@")||b.startsWith(":")||b.startsWith("x-")||b.startsWith("__"))return b;if(b.startsWith("aria-")||b.startsWith("data-"))return b;return b.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},v=(b,C)=>{let x=y(b);if(c.static[x]=C,x!==b)c.staticNames[x]=b};for(let[b,C]of Object.entries(e)){let x=b.startsWith("x-")&&!u.has(b)&&!b.startsWith("x-bind:")&&!b.startsWith("x-on:")?`:${b.slice(2)}`:b;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let h=y(x.slice(6));c.serverDynamic[h]=Ft(C,i);continue}if(x.startsWith(":")){let h=y(x.slice(1)),w=C===re?h:C;if(h==="if"||h==="for"||h==="show"){c.clientReactive[h]=w;continue}if(o){c.clientReactive[h]=w;continue}if(I(w,a)){c.clientReactive[h]=w;continue}if(m(w)){c.clientReactive[h]=w;continue}try{if(!f(w)){if(i.debug)console.error(`Unsafe expression in :${h} binding: ${w}`);c.clientReactive[h]=w;continue}let S=Object.keys(t),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(rt(w).some((z)=>!A.has(z)&&!S.includes(z)&&(!(z in globalThis)||P.has(z)))){c.clientReactive[h]=w;continue}let W=d(w,S)(...Object.values(t));if(c.serverDynamic[h]=W,h!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[h]=x.slice(1)}catch{c.clientReactive[h]=w}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let h=Zn(C,a);if(h!==null){c.clientReactive[y(x)]=h;continue}let w=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(w)try{let S=w[1];if(f(S)){let P=d(S,Object.keys(t))(...Object.values(t));v(x,P!=null?String(P):"")}else{if(i.debug)console.error(`Unsafe expression in ${x}: ${S}`);v(x,C)}}catch(S){if(i.debug)console.error(`Error evaluating expression for ${x}:`,S);v(x,C)}else{let S=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=A.exec(C))!==null)try{let k=P[1];if(!f(k)){if(i.debug)console.error(`Unsafe expression in ${x}: ${k}`);continue}let W=d(k,Object.keys(t))(...Object.values(t));S=S.replace(P[0],String(W??""))}catch(k){if(i.debug)console.error(`Error evaluating expression in ${x}:`,k)}v(x,S)}continue}v(x,C===re?"true":ct(C))}return c}function Zn(e,t){if(t.size===0)return null;let i=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(i)];if(!o.some((m)=>I(m[1],t)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Vn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Gn(e,t,i){if(!e.includes("@"))return e;if(!Vn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,t,i)}catch{return e}}function me(e){let t={},i=0,o=e.length;while(i<o){while(i<o&&/\s/.test(e[i]))i++;if(i>=o)break;let a="";while(i<o&&!/[\s=]/.test(e[i]))a+=e[i],i++;if(!a)break;while(i<o&&/\s/.test(e[i]))i++;if(i<o&&e[i]==="="){i++;while(i<o&&/\s/.test(e[i]))i++;let c="";if(i<o&&(e[i]==='"'||e[i]==="'")){let l=e[i];i++;while(i<o){let m=e[i];if(m==="\\"&&i+1<o){i++,c+=e[i],i++;continue}if(m===l){i++;break}c+=m,i++}}else if(e[i]==="{"){c=lt(e,i),i+=c.length;let l=Wt(c);if(l!==null){t[`:${a}`]=l;continue}}else while(i<o&&!/\s/.test(e[i]))c+=e[i],i++;t[a]=c}else t[a]=re}return t}function Vt(e){return Object.entries(e).map(([t,i])=>i===re?t:`${t}="${Kn(i)}"`).join(" ")}function Kn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jn(e){let t=new Set,i=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=i.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))t.add(a)}return[...t].sort()}async function Rf(e,t,i,o,a){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,l=Xt.dirname(i),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let b of e.matchAll(u)){let[C,x,h]=b,w=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=h,A,P=[];while((A=w.exec(h))!==null){let[k,O,W,z]=A,U=null,q=null;if(z.startsWith(".")||z.startsWith("/")){let T=Xt.resolve(l,z);if(T.endsWith(".stx"))q=T;else{let j=`${T}.stx`;try{if(qt.statSync(j).isFile())q=j}catch{try{if(qt.statSync(T).isDirectory())U=T}catch{}}}}else U=Ps(z,l);if(!U&&!q)continue;let B=!1,N=(T,j)=>{c.set(T,j),c.set(T.toLowerCase(),j);let F=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(F,j),a.add(j)};if(W&&q)N(W,q),B=!0;else if(O){let T=O.slice(1,-1).split(",").map((F)=>F.trim()).filter(Boolean).map((F)=>{let X=F.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:F,local:F}}),j=U?hr(U):null;for(let{source:F,local:X}of T){let L=null;if(q)L=q;else if(j)L=j.get(F)??j.get(F.toLowerCase())??j.get(F.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)N(X,L),B=!0}}if(B)P.push({start:A.index,end:A.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)S=S.slice(0,P[k].start)+S.slice(P[k].end);m.push({start:b.index,end:b.index+C.length,value:`<script${x}>${S}</script>`})}if(m.length===0)return e;let y=[],v=0;for(let b of m)y.push(e.slice(v,b.start),b.value),v=b.end;return y.push(e.slice(v)),y.join("")}async function Yn(e,t,i,o,a){let c=e;if(!t.__importedComponents)t.__importedComponents=new Map;let l=t.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,v]=u,b=v.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of b){let x=C.split("/"),w=x[x.length-1].replace(/\.stx$/,""),S=w.includes("-")?w.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):w.charAt(0).toUpperCase()+w.slice(1),A=null,P=Is(C,i,o);for(let k of P)try{if(await Bun.file(k).exists()){A=k;break}}catch{}if(A){l.set(S,A),l.set(w,A),l.set(w.toLowerCase(),A);let k=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(k,A),a.add(A),o.debug)console.log(`Imported component: ${S} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function Qn(e,t,i,o,a){let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let v=y.index,b=v+y[0].length-1,C=1,x=b+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let h=c.substring(b+1,x),w=x+1,S=h.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=0;continue}let A=S[1],P,k=h.slice(S[0].length),O=k.match(/^\s*,\s*/);if(O)P=k.slice(O[0].length).trim();let W={};if(P)try{W=R(P,t)}catch(T){let j=T instanceof Error?T.message:String(T);c=c.replace(c.substring(v,w),`[Error parsing component props: ${j}]`);continue}let z="",U=w,B=c.substring(w).match(/^([\s\S]*?)@endcomponent/);if(B)z=B[1].trim(),U=w+B[0].length;let N=await Fe(A,W,z,l,t,i,o,m,a);c=c.substring(0,v)+N+c.substring(U),u.lastIndex=0}return c}async function er(e,t,i,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=rr(c);if(u.size>0){let w=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...w,...u])]}let y=G(c);c=y.output;let v=nt(t);return c=await h(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await h(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(xr)),c=await h(c,/[a-z][a-z0-9]*/,!1,xr),c=y.restore(c),c;async function h(w,S,A,P){if(!w)return w;let k=w,O=Ut(k,S,P),W=ut(k),z=new Map;for(let B=O.length-1;B>=0;B--){let N=O[B],T=A?H(N.tagName):N.tagName,j=me(Gn(N.attributes,t,i)),F=W.filter(({start:_,end:E})=>N.startIndex>=_&&N.startIndex<E),X=F.length>0,L=new Set(v);for(let _ of F)for(let E of _.names)L.add(E);let D=Xn(j,t,o,X,L);if(typeof D.clientReactive.for==="string")for(let _ of J(D.clientReactive.for))L.add(_);let ce=ue.getBuiltin(N.tagName),$e=ce?await _r(N.tagName,l,t,i,o):!1,Y=N.tagName==="Image"&&Os([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((_)=>hr(_).has("Image"));if(ce&&!$e&&!Y){let _={context:t,filePath:i,options:o,dependencies:a},E=ce.render(D,N.content,_);if(Object.keys(D.events).length>0){let ee=Vt(D.events);E=E.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)E=Gt(E,D.clientReactive);z.set(B,E);continue}if(!A&&N.tagName.includes("-")&&!await _r(T,l,t,i,o))continue;let le={};for(let[_,E]of Object.entries(D.static))le[_]=E;for(let[_,E]of Object.entries(D.serverDynamic))le[_]=E;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},M=await Fe(T,le,y.restore(N.content),l,t,i,o,m,a,[...L],te,N.tagName);if(M=tr(M,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let _=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(H),E=ft(M,!0);if(_.length&&E){if(!Object.hasOwn(me(M.slice(E.insertPos,E.tagEnd)),"data-stx-native-host-root"))M=M.slice(0,E.insertPos)+' data-stx-native-host-root="true"'+M.slice(E.insertPos);let ne=we(M);M=M.slice(0,ne.insertPos)+` data-stx-native-forward="${_.join(" ")}"`+M.slice(ne.insertPos)}let ee=ft(M,!0);if(ee){let ne=me(M.slice(ee.insertPos,ee.tagEnd)),Se=we(M),Jt=me(M.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Jt,"data-stx-native-host-owner"))M=M.slice(0,Se.insertPos)+" data-stx-native-host-owner"+M.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let _=we(M);if(_){let E=Vt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");M=M.substring(0,_.insertPos)+` data-stx-parent-events="${ee}" ${E}`+M.substring(_.insertPos)}}if(Object.keys(D.clientReactive).length>0)M=Gt(M,D.clientReactive);z.set(B,M)}if(z.size===0)return k;let U="",q=0;for(let B=0;B<O.length;B++){let N=z.get(B);if(N===void 0)continue;U+=k.slice(q,O[B].startIndex),U+=N,q=O[B].endIndex}return U+=k.slice(q),U}}function Gt(e,t){let i=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(t).filter(([v])=>!i.has(v)),c=a.filter(([v])=>!o.has(v)).map(([v])=>H(v)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let v=a.map(([C,x])=>`:${H(C)}="${x.replace(/"/g,"&quot;")}"`).join(" "),b=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${b} ${v}`+l.substring(m.insertPos)}let u=t.if;if(u)l=`<template :if="${u.replace(/"/g,"&quot;")}">${l}</template>`;let y=t.for;if(y){let v=t.key,b=v?` :key="${v.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${y.replace(/"/g,"&quot;")}"${b}>${l}</template>`}return l}function tr(e,t,i=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=t.serverDynamic.class??t.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let h=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,w=h.test(l)?l.replace(h,(S,A,P,k,O)=>`${A}class="${n(`${ct(P??k??O)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+w+e.slice(c.tagEnd),c.tagEnd+=w.length-l.length,l=w}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:i,v=new Set(Object.keys(me(l))),b=new Set(["class","className"]);for(let h of Object.keys(t.static)){let w=t.staticNames[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}for(let h of Object.keys(t.serverDynamic)){let w=t.serverDynamicNames?.[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}let C=[];if(u){for(let[h,w]of Object.entries(t.static)){if(b.has(h)||w!==!0&&w!==re)continue;b.add(h),C.push(`${n(t.staticNames?.[h]??h)}="true"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!0)continue;b.add(h),C.push(`${n(t.serverDynamicNames?.[h]??h)}="true"`)}}let x=[...oe(t,b),...ae(t,b),...C];if(u){for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!1)continue;let S=t.serverDynamicNames?.[h]??h;x.push(`${n(S)}="false"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w===null||typeof w!=="object")continue;let S=JSON.stringify(w);if(S!==void 0){let A=t.serverDynamicNames?.[h]??h;x.push(`${n(A)}="${n(S)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let t=Kt(e,0);if(t)return t;let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(i)return{insertPos:i.index+1+i[1].length,tagEnd:dt(e,i.index+1+i[1].length)};return null}function ft(e,t=!1){let i=we(e);if(!i)return null;let o=e.slice(i.insertPos,i.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Kt(e,i.tagEnd+1):i;return a&&t?nr(e,a)??a:a}function nr(e,t){if(!e.includes("data-stx-native-host-root"))return null;let i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",t.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let v=e.indexOf("-->",o+4);if(v<0)return null;o=e.indexOf("<",v+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let v=new RegExp(`</${m}\\s*>`,"gi");if(v.lastIndex=y+1,!v.exec(e))return null;o=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(u,y)),b=a>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(c===void 0&&!b&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!i.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&b)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Kt(e,t){let i=t;while(i<e.length){let o=e.slice(i),a=o.match(/^\s+/);if(a){i+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",i+4);if(m===-1)return null;i=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,i+c[0].length);if(u===-1)return null;i=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:i+1+l[1].length,tagEnd:dt(e,i+1+l[1].length)}}return null}function dt(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function rr(e){let t=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=i[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of ai(i[2]))t.add(a);for(let a of i[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])t.add(a[1]);if(a[3])t.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))t.add(l)}}}return t}async function cs(e,t,i,o,a){if(!Zt)jt(ue),Zt=!0;let c=await Rf(e,t,i,o,a);c=await Yn(c,t,i,o,a),c=await Qn(c,t,i,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Ne,(b,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let v=c;if(c=await er(y.output,t,i,o,a),c===v)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Jn(c);if(m.length>0)console.warn(`[stx] ${i}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
- export{No,Do,Mo,Eh,as,Th,sc,Rf,cs};
40
+ </style>`}};import{existsSync as Bn,readFileSync as Tn}from"fs";var Oe=new Map,Bt=new Set;function Dn(e){if(Bt.has(e))return;Bt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function jn(e){let t=process.cwd();for(let i of[`${t}/node_modules/@iconify-json/${e}/icons.json`,`${t}/pantry/@iconify-json/${e}/icons.json`,`${t}/node_modules/@iconify/json/json/${e}.json`,`${t}/pantry/@iconify/json/json/${e}.json`])if(Bn(i))return i;for(let i of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(i)}catch{}return null}function Mn(e){if(Oe.has(e))return Oe.get(e);let t=jn(e);if(!t)return Dn(e),null;try{let i=JSON.parse(Tn(t,"utf8"));return Oe.set(e,i),i}catch{return null}}function Ln(e,t,i,o){let a=[];if(t.rotate)a.push(`rotate(${t.rotate*90} ${i/2} ${o/2})`);if(t.hFlip)a.push(`translate(${i} 0) scale(-1 1)`);if(t.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function zn(e,t){let i=t,o=e.icons[i],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[i];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;i=u.parent,o=e.icons[i]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Ln(o.body,a,c,l),width:c,height:l}}function ge(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);if(e.static[t]!==void 0)return String(e.static[t]);if(e.clientReactive[t]!==void 0)return e.clientReactive[t];return}var it={name:"Icon",aliases:["icon","stx-icon"],render(e,t,i){let o=ge(e,"name")??ge(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let S=o.split(":");a=S[0],c=S[1]}let l=n(ge(e,"size")||"24"),m=n(ge(e,"color")||"currentColor"),u=n(ge(e,"class")||""),y=n(ge(e,"style")||""),v=Oe.get(a)??Mn(a);if(!v)return`<!-- Icon: collection "${a}" not loaded -->`;let b=zn(v,c);if(!b)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${b.width} ${b.height}`,x=b.body;if(m!=="currentColor")x=x.replace(/currentColor/g,m);let h=u?` class="${u}"`:"",w=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${h}${w}>${x}</svg>`}};function Tt(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}function Dt(e,t){let i=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(i);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ot={name:"Suspense",aliases:["suspense"],render(e,t,i){let o=Dt(t,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Tt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Tt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}var at={name:"TransitionGroup",aliases:["transition-group"],render(e,t,i){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${t}</${a}>`}};function jt(e=ue){e.registerBuiltin(qe),e.registerBuiltin(Ke),e.registerBuiltin(Je),e.registerBuiltin(Qe),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at)}var Mt=new Map;function Un(e){let t=Mt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Mt.set(e.source,t);return t}var Lt=new WeakMap;function zt(e){let t=Lt.get(e);if(!t)t=new Set([...e].map((o)=>o.toLowerCase())),Lt.set(e,t);let i=t;return(o)=>!/[a-z]/.test(o)&&i.has(o.toLowerCase())}function Fn(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function Ut(e,t,i){let o=[],a=0,c=typeof i==="function"?i:i?(l)=>i.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Un(t);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let S=l+1+y.length;while(S<e.length&&e[S]!==">")S++;a=S+1;continue}let v=l+1+y.length,b=null,C=v,x=-1,h=!1;while(v<e.length){let S=e[v];if(b){if(S==="\\"&&v+1<e.length){v+=2;continue}if(S===b)b=null;v++;continue}if(S==='"'||S==="'"){b=S,v++;continue}if(S==="/"&&v+1<e.length&&e[v+1]===">"){x=v+2,h=!0;break}if(S===">"){x=v+1;break}v++}if(x===-1){a=l+1;continue}let w=e.slice(C,h?x-2:x-1).trim();if(h)o.push({fullMatch:e.slice(l,x),tagName:y,attributes:w,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let S=`<${y}`,A=`</${y}>`,P=1,k=x,O=-1;while(P>0&&k<e.length){let U=e.indexOf(S,k),q=e.indexOf(A,k);if(q===-1)break;if(U!==-1&&U<q){let B=e[U+S.length];if(B===" "||B===">"||B==="/"||B===`
41
+ `||B==="\t"){let N=Fn(e,U+S.length);if(e[N-1]!=="/")P++;k=N+1}else k=U+S.length}else{if(P--,P===0){O=q;break}k=q+A.length}}if(O===-1){a=x;continue}let W=e.slice(x,O),z=O+A.length;o.push({fullMatch:e.slice(l,z),tagName:y,attributes:w,content:W,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ct(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ft(e,t){try{let i=Buffer.from(e,"base64").toString("utf8");return JSON.parse(i)}catch{}try{let i=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(i)}catch(i){if(t?.debug)console.error("Error decoding __stx_ prop:",i);return e}}function lt(e,t){let i=0,o="",a=t;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")i++;else if(c==="}"){if(i--,i===0)return e.slice(t,a+1)}a++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(lt(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var Wn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Hn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function qn(e){return ut(e).map((t)=>[t.start,t.end])}function ut(e){let t=[],i=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,o;while((o=i.exec(e))!==null){let a=o[2]||"",c=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(a);if(!c)continue;let l=J(c[1]??c[2]??c[3]??""),m=o.index,u=m+o[0].length,y=o[1].toLowerCase();if(o[0].endsWith("/>")||Hn.has(y)){t.push({start:m,end:u,names:l});continue}let v=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),b=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");b.lastIndex=u;let C=1,x=u,h;while((h=b.exec(e))!==null)if(h[0].startsWith("</")){if(C--,C===0){x=h.index+h[0].length;break}}else if(!h[0].endsWith("/>"))C++;t.push({start:m,end:x,names:l})}return t}function Ht(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ht(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function oc(e,t){if(!/:[\w-]+=/.test(e))return e;let i=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...qn(e));let l=new Set([...rt(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function m(C){return a.some(([x,h])=>C>=x&&C<h)}let u=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,y=[],v=new Map,b=256;while((c=u.exec(i))!==null){if(m(c.index))continue;let C=c[0],x=c[2];if(!x||!x.includes(":"))continue;let h=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),w=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,S,A=x,P=!1;while((S=w.exec(x))!==null){if(xr(x,S.index,!0)?.kind==="attribute")continue;let k=S[1],O=S[2];if(ul(k))continue;if(I(O,l))continue;if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let W=Object.keys(t),z=Object.values(t),U=O.match(/^([a-zA-Z_$][\w$]*)/);if(U&&!W.includes(U[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(U[1]))continue;let q=JSON.stringify([W,O]),B=v.get(q);if(!B){if(B=Function(...W,`return (${O})`),v.size>=b)v.clear();v.set(q,B)}let N=B(...z);if(k==="class"){let T=V(Ht(N));if(T){let j=A.match(/\sclass="([^"]*)"/);if(j)A=A.replace(j[0],()=>` class="${j[1]} ${T}"`);else A=A.replace(S[0],()=>` class="${T}"`)}else A=A.replace(S[0],"");P=!0;continue}if(Wn.has(k)){if(N)A=A.replace(S[0],` ${k}`);else A=A.replace(S[0],"");P=!0;continue}if(N===null||N===void 0||N===!1)A=A.replace(S[0],"");else{let T=h&&typeof N==="object"?JSON.stringify(N):String(N),j=wn(k,T);A=A.replace(S[0],()=>` ${k}="${j}"`)}P=!0}catch(W){if(W instanceof ie)throw W;continue}}if(P){let k=c[3]?" /":"",W=`<${c[1]}${A}${k}>`;y.push({start:c.index,end:c.index+C.length,replacement:W})}}if(y.length>0){let C=Array(y.length*2+1),x=0;for(let h=0;h<y.length;h++){let{start:w,end:S,replacement:A}=y[h];C[h*2]=i.slice(x,w),C[h*2+1]=A,x=S}C[y.length*2]=i.slice(x),i=C.join("")}return i}import qt from"fs";import Xt from"path";var Zt=!1;function Xn(e,t,i,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),m=(b)=>{if(l.size===0)return!1;let C=s(b),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let h of l){let w=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${w}\\s*\\(`).test(C))return!0}return!1},u=new Set(dl),y=(b)=>{if(!b.includes("-")||b.startsWith("@")||b.startsWith(":")||b.startsWith("x-")||b.startsWith("__"))return b;if(b.startsWith("aria-")||b.startsWith("data-"))return b;return b.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},v=(b,C)=>{let x=y(b);if(c.static[x]=C,x!==b)c.staticNames[x]=b};for(let[b,C]of Object.entries(e)){let x=b.startsWith("x-")&&!u.has(b)&&!b.startsWith("x-bind:")&&!b.startsWith("x-on:")?`:${b.slice(2)}`:b;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let h=y(x.slice(6));c.serverDynamic[h]=Ft(C,i);continue}if(x.startsWith(":")){let h=y(x.slice(1)),w=C===re?h:C;if(h==="if"||h==="for"||h==="show"){c.clientReactive[h]=w;continue}if(o){c.clientReactive[h]=w;continue}if(I(w,a)){c.clientReactive[h]=w;continue}if(m(w)){c.clientReactive[h]=w;continue}try{if(!f(w)){if(i.debug)console.error(`Unsafe expression in :${h} binding: ${w}`);c.clientReactive[h]=w;continue}let S=Object.keys(t),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(st(w).some((z)=>!A.has(z)&&!S.includes(z)&&(!(z in globalThis)||P.has(z)))){c.clientReactive[h]=w;continue}let W=d(w,S)(...Object.values(t));if(c.serverDynamic[h]=W,h!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[h]=x.slice(1)}catch{c.clientReactive[h]=w}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let h=Zn(C,a);if(h!==null){c.clientReactive[y(x)]=h;continue}let w=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(w)try{let S=w[1];if(f(S)){let P=d(S,Object.keys(t))(...Object.values(t));v(x,P!=null?String(P):"")}else{if(i.debug)console.error(`Unsafe expression in ${x}: ${S}`);v(x,C)}}catch(S){if(i.debug)console.error(`Error evaluating expression for ${x}:`,S);v(x,C)}else{let S=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=A.exec(C))!==null)try{let k=P[1];if(!f(k)){if(i.debug)console.error(`Unsafe expression in ${x}: ${k}`);continue}let W=d(k,Object.keys(t))(...Object.values(t));S=S.replace(P[0],String(W??""))}catch(k){if(i.debug)console.error(`Error evaluating expression in ${x}:`,k)}v(x,S)}continue}v(x,C===re?"true":ct(C))}return c}function Zn(e,t){if(t.size===0)return null;let i=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(i)];if(!o.some((m)=>I(m[1],t)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Vn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Gn(e,t,i){if(!e.includes("@"))return e;if(!Vn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,t,i)}catch{return e}}function me(e){let t={},i=0,o=e.length;while(i<o){while(i<o&&/\s/.test(e[i]))i++;if(i>=o)break;let a="";while(i<o&&!/[\s=]/.test(e[i]))a+=e[i],i++;if(!a)break;while(i<o&&/\s/.test(e[i]))i++;if(i<o&&e[i]==="="){i++;while(i<o&&/\s/.test(e[i]))i++;let c="";if(i<o&&(e[i]==='"'||e[i]==="'")){let l=e[i];i++;while(i<o){let m=e[i];if(m==="\\"&&i+1<o){i++,c+=e[i],i++;continue}if(m===l){i++;break}c+=m,i++}}else if(e[i]==="{"){c=lt(e,i),i+=c.length;let l=Wt(c);if(l!==null){t[`:${a}`]=l;continue}}else while(i<o&&!/\s/.test(e[i]))c+=e[i],i++;t[a]=c}else t[a]=re}return t}function Vt(e){return Object.entries(e).map(([t,i])=>i===re?t:`${t}="${Kn(i)}"`).join(" ")}function Kn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jn(e){let t=new Set,i=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=i.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))t.add(a)}return[...t].sort()}async function Af(e,t,i,o,a){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,l=Xt.dirname(i),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let b of e.matchAll(u)){let[C,x,h]=b,w=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=h,A,P=[];while((A=w.exec(h))!==null){let[k,O,W,z]=A,U=null,q=null;if(z.startsWith(".")||z.startsWith("/")){let T=Xt.resolve(l,z);if(T.endsWith(".stx"))q=T;else{let j=`${T}.stx`;try{if(qt.statSync(j).isFile())q=j}catch{try{if(qt.statSync(T).isDirectory())U=T}catch{}}}}else U=Is(z,l);if(!U&&!q)continue;let B=!1,N=(T,j)=>{c.set(T,j),c.set(T.toLowerCase(),j);let F=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(F,j),a.add(j)};if(W&&q)N(W,q),B=!0;else if(O){let T=O.slice(1,-1).split(",").map((F)=>F.trim()).filter(Boolean).map((F)=>{let X=F.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:F,local:F}}),j=U?yr(U):null;for(let{source:F,local:X}of T){let L=null;if(q)L=q;else if(j)L=j.get(F)??j.get(F.toLowerCase())??j.get(F.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)N(X,L),B=!0}}if(B)P.push({start:A.index,end:A.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)S=S.slice(0,P[k].start)+S.slice(P[k].end);m.push({start:b.index,end:b.index+C.length,value:`<script${x}>${S}</script>`})}if(m.length===0)return e;let y=[],v=0;for(let b of m)y.push(e.slice(v,b.start),b.value),v=b.end;return y.push(e.slice(v)),y.join("")}async function Yn(e,t,i,o,a){let c=e;if(!t.__importedComponents)t.__importedComponents=new Map;let l=t.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,v]=u,b=v.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of b){let x=C.split("/"),w=x[x.length-1].replace(/\.stx$/,""),S=w.includes("-")?w.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):w.charAt(0).toUpperCase()+w.slice(1),A=null,P=Os(C,i,o);for(let k of P)try{if(await Bun.file(k).exists()){A=k;break}}catch{}if(A){l.set(S,A),l.set(w,A),l.set(w.toLowerCase(),A);let k=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(k,A),a.add(A),o.debug)console.log(`Imported component: ${S} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function Qn(e,t,i,o,a){let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let v=y.index,b=v+y[0].length-1,C=1,x=b+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let h=c.substring(b+1,x),w=x+1,S=h.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=0;continue}let A=S[1],P,k=h.slice(S[0].length),O=k.match(/^\s*,\s*/);if(O)P=k.slice(O[0].length).trim();let W={};if(P)try{W=R(P,t)}catch(T){let j=T instanceof Error?T.message:String(T);c=c.replace(c.substring(v,w),`[Error parsing component props: ${j}]`);continue}let z="",U=w,B=c.substring(w).match(/^([\s\S]*?)@endcomponent/);if(B)z=B[1].trim(),U=w+B[0].length;let N=await Fe(A,W,z,l,t,i,o,m,a);c=c.substring(0,v)+N+c.substring(U),u.lastIndex=0}return c}async function er(e,t,i,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=rr(c);if(u.size>0){let w=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...w,...u])]}let y=G(c);c=y.output;let v=rt(t);return c=await h(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await h(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(Sr)),c=await h(c,/[a-z][a-z0-9]*/,!1,Sr),c=y.restore(c),c;async function h(w,S,A,P){if(!w)return w;let k=w,O=Ut(k,S,P),W=ut(k),z=new Map;for(let B=O.length-1;B>=0;B--){let N=O[B],T=A?H(N.tagName):N.tagName,j=me(Gn(N.attributes,t,i)),F=W.filter(({start:_,end:E})=>N.startIndex>=_&&N.startIndex<E),X=F.length>0,L=new Set(v);for(let _ of F)for(let E of _.names)L.add(E);let D=Xn(j,t,o,X,L);if(typeof D.clientReactive.for==="string")for(let _ of J(D.clientReactive.for))L.add(_);let ce=ue.getBuiltin(N.tagName),$e=ce?await Cr(N.tagName,l,t,i,o):!1,Y=N.tagName==="Image"&&Ns([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((_)=>yr(_).has("Image"));if(ce&&!$e&&!Y){let _={context:t,filePath:i,options:o,dependencies:a},E=ce.render(D,N.content,_);if(Object.keys(D.events).length>0){let ee=Vt(D.events);E=E.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)E=Gt(E,D.clientReactive);z.set(B,E);continue}if(!A&&N.tagName.includes("-")&&!await Cr(T,l,t,i,o))continue;let le={};for(let[_,E]of Object.entries(D.static))le[_]=E;for(let[_,E]of Object.entries(D.serverDynamic))le[_]=E;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},M=await Fe(T,le,y.restore(N.content),l,t,i,o,m,a,[...L],te,N.tagName);if(M=tr(M,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let _=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(H),E=ft(M,!0);if(_.length&&E){if(!Object.hasOwn(me(M.slice(E.insertPos,E.tagEnd)),"data-stx-native-host-root"))M=M.slice(0,E.insertPos)+' data-stx-native-host-root="true"'+M.slice(E.insertPos);let ne=we(M);M=M.slice(0,ne.insertPos)+` data-stx-native-forward="${_.join(" ")}"`+M.slice(ne.insertPos)}let ee=ft(M,!0);if(ee){let ne=me(M.slice(ee.insertPos,ee.tagEnd)),Se=we(M),Jt=me(M.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Jt,"data-stx-native-host-owner"))M=M.slice(0,Se.insertPos)+" data-stx-native-host-owner"+M.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let _=we(M);if(_){let E=Vt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");M=M.substring(0,_.insertPos)+` data-stx-parent-events="${ee}" ${E}`+M.substring(_.insertPos)}}if(Object.keys(D.clientReactive).length>0)M=Gt(M,D.clientReactive);z.set(B,M)}if(z.size===0)return k;let U="",q=0;for(let B=0;B<O.length;B++){let N=z.get(B);if(N===void 0)continue;U+=k.slice(q,O[B].startIndex),U+=N,q=O[B].endIndex}return U+=k.slice(q),U}}function Gt(e,t){let i=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(t).filter(([v])=>!i.has(v)),c=a.filter(([v])=>!o.has(v)).map(([v])=>H(v)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let v=a.map(([C,x])=>`:${H(C)}="${x.replace(/"/g,"&quot;")}"`).join(" "),b=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${b} ${v}`+l.substring(m.insertPos)}let u=t.if;if(u)l=`<template :if="${u.replace(/"/g,"&quot;")}">${l}</template>`;let y=t.for;if(y){let v=t.key,b=v?` :key="${v.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${y.replace(/"/g,"&quot;")}"${b}>${l}</template>`}return l}function tr(e,t,i=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=t.serverDynamic.class??t.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let h=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,w=h.test(l)?l.replace(h,(S,A,P,k,O)=>`${A}class="${n(`${ct(P??k??O)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+w+e.slice(c.tagEnd),c.tagEnd+=w.length-l.length,l=w}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:i,v=new Set(Object.keys(me(l))),b=new Set(["class","className"]);for(let h of Object.keys(t.static)){let w=t.staticNames[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}for(let h of Object.keys(t.serverDynamic)){let w=t.serverDynamicNames?.[h]??h;if(v.has(w)||y.has(h)||!u&&!He(w))b.add(h)}let C=[];if(u){for(let[h,w]of Object.entries(t.static)){if(b.has(h)||w!==!0&&w!==re)continue;b.add(h),C.push(`${n(t.staticNames?.[h]??h)}="true"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!0)continue;b.add(h),C.push(`${n(t.serverDynamicNames?.[h]??h)}="true"`)}}let x=[...oe(t,b),...ae(t,b),...C];if(u){for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w!==!1)continue;let S=t.serverDynamicNames?.[h]??h;x.push(`${n(S)}="false"`)}for(let[h,w]of Object.entries(t.serverDynamic)){if(b.has(h)||w===null||typeof w!=="object")continue;let S=JSON.stringify(w);if(S!==void 0){let A=t.serverDynamicNames?.[h]??h;x.push(`${n(A)}="${n(S)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let t=Kt(e,0);if(t)return t;let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(i)return{insertPos:i.index+1+i[1].length,tagEnd:dt(e,i.index+1+i[1].length)};return null}function ft(e,t=!1){let i=we(e);if(!i)return null;let o=e.slice(i.insertPos,i.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Kt(e,i.tagEnd+1):i;return a&&t?nr(e,a)??a:a}function nr(e,t){if(!e.includes("data-stx-native-host-root"))return null;let i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",t.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let v=e.indexOf("-->",o+4);if(v<0)return null;o=e.indexOf("<",v+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let v=new RegExp(`</${m}\\s*>`,"gi");if(v.lastIndex=y+1,!v.exec(e))return null;o=e.indexOf("<",v.lastIndex);continue}else{let v=me(e.slice(u,y)),b=a>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(c===void 0&&!b&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!i.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&b)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Kt(e,t){let i=t;while(i<e.length){let o=e.slice(i),a=o.match(/^\s+/);if(a){i+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",i+4);if(m===-1)return null;i=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,i+c[0].length);if(u===-1)return null;i=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:i+1+l[1].length,tagEnd:dt(e,i+1+l[1].length)}}return null}function dt(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function rr(e){let t=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=i[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of ci(i[2]))t.add(a);for(let a of i[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])t.add(a[1]);if(a[3])t.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))t.add(l)}}}return t}async function ls(e,t,i,o,a){if(!Zt)jt(ue),Zt=!0;let c=await Af(e,t,i,o,a);c=await Yn(c,t,i,o,a),c=await Qn(c,t,i,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Ne,(b,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let v=c;if(c=await er(y.output,t,i,o,a),c===v)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Jn(c);if(m.length>0)console.warn(`[stx] ${i}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
+ export{Do,Mo,Lo,Th,cs,$h,oc,Af,ls};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xe,fi,gi,ng,Dt,Wc,mi,qc,Uh,Me,yn,Le}from"./chunk-1frxaa7e.js";import{Zc,s}from"./chunk-m4mpyq3d.js";import"./chunk-br91e06f.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{xe as BROWSER_CORE_IMPORTS,ng as STX_AUTO_IMPORTS,fi as extractAndStripCssImports,Me as extractBridgeData,Zc as findInterpolationEnd,qc as generateAutoImportDestructuring,Uh as generateBrowserAutoImportDestructuring,yn as generateServerDataBridge,Dt as injectBrowserCoreAutoImports,Le as processClientScript,mi as referencesName,gi as renderVendorStyleTags,s as stripCommentsAndLiterals,Wc as transformAutoImports};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ze,xn,Vs,vi,O,Lt}from"./chunk-27rzdq3n.js";export{xn as currentRuntimeConfig,Lt as injectRuntimeConfig,O as resolveRuntimeConfig,vi as useRuntimeConfig,Vs as useServerRuntimeConfig,ze as withRuntimeConfig};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ue}from"./chunk-z1br7qeb.js";import{ze,O}from"./chunk-p1mbbdwj.js";import{yc}from"./chunk-bwzjjxnj.js";import{l}from"./chunk-4xzk9529.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function sn(s,c={}){let o=m.resolve(s,c.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function To(s,c){let o=l(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of c){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ue(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
- `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function $o(s,c,o={}){let i=sn(s,o);await To(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(c,n),a),f.push({...t,filePath:n})}return f}function E(s,c){let o=s.map((i)=>({route:i,...ue(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await c(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Ro(s,c){return E(c,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function wh(s,c){if(!c)return async()=>null;let o=c===!0?{}:c,i=sn(s,o);return await To(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=sn(s,o);await To(s,t);let{loadStxConfig:e}=await import("./chunk-z515xymr.js"),a=O((await e(s)).runtimeConfig);return await ze(a,()=>E(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
- `));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Ao(s,c,o){if(yc(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(c,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return v.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(c,"server"),m.resolve(c,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
6
- export{sn,To,$o,Ro,wh,Ao};
2
+ import{ue}from"./chunk-yewd8836.js";import{ze,O}from"./chunk-27rzdq3n.js";import{bc}from"./chunk-605b93pe.js";import{l}from"./chunk-jdj1358b.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function on(s,c={}){let o=m.resolve(s,c.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function $o(s,c){let o=l(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of c){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ue(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
+ `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Ro(s,c,o={}){let i=on(s,o);await $o(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
+ `)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(c,n),a),f.push({...t,filePath:n})}return f}function E(s,c){let o=s.map((i)=>({route:i,...ue(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await c(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Ao(s,c){return E(c,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function vh(s,c){if(!c)return async()=>null;let o=c===!0?{}:c,i=on(s,o);return await $o(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=on(s,o);await $o(s,t);let{loadStxConfig:e}=await import("./chunk-r5qfxd9s.js"),a=O((await e(s)).runtimeConfig);return await ze(a,()=>E(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
+ `));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Po(s,c,o){if(bc(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(c,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return v.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(c,"server"),m.resolve(c,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
6
+ export{on,$o,Ro,Ao,vh,Po};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{existsSync as x,realpathSync as b,statSync as y}from"fs";import f from"path";import k from"process";var E=/^[\w-]+(?:\/[\w-]+)*$/,j=/^[\w-]+$/;async function Lr(s,e){let n=f.resolve(s,e.dir);if(!e.languages?.length)throw Error("messages.languages must name at least one language");let a=new Map,r=new Map;for(let t of e.languages){if(!j.test(t))throw Error(`messages: "${t}" is not a language directory name`);let g=f.join(n,t);if(!x(g))throw Error(`messages: ${f.relative(s,g)} does not exist`);let o=new Map;for(let i of[...new Bun.Glob("**/*.{ts,js,mjs,json}").scanSync({cwd:g})].sort()){if(/\.(?:test|spec|d)\.[^.]+$/.test(i))continue;let l=i.replace(/\.[^./]+$/,"").split(f.sep).join("/");if(!E.test(l))throw Error(`messages: ${t}/${i} is not an area name`);if(o.has(l))throw Error(`messages: ${t}/${l} is defined twice`);let c=f.join(g,i),p=await import(c),m=Object.keys(p).filter((S)=>S!=="default");if(m.length)throw Error(`messages: ${t}/${i} exports ${m.join(", ")}; a message module exports its messages as default, and nothing else`);let u=p.default,d=u!==null&&typeof u==="object"&&!Array.isArray(u)?JSON.stringify(u):void 0;if(d===void 0||!Bun.deepEquals(JSON.parse(d),u,!0))throw Error(`messages: ${t}/${i} must export plain data (an object JSON can hold) as default`);o.set(l,d),a.set(c,{language:t,area:l})}r.set(t,o)}return{files:a,data:r}}function h(s,e){return`stx-messages:${s}:${e}`}function _(s,e){let n=JSON.stringify(h(s,e));return`var kept = globalThis.__stxMessages || (globalThis.__stxMessages = {});
3
- export default kept[${n}] || (kept[${n}] = {});`}var M=new Map;function jr(s){let e=[s];try{e.push(b(s))}catch{}for(let n of[...e])if(n.startsWith("/private/"))e.push(n.slice(8));return[...new Set(e)]}function Dg(s,e=k.env){if(!s.messages||e.STX_PAGE_MESSAGES==="0")return!1;return e.STX_PAGE_MESSAGES==="1"||e.NODE_ENV==="production"}async function Mg(s,e){let n=f.resolve(s,e.dir),a=e.languages.map((c)=>{try{return`${c}:${y(f.join(n,c)).mtimeMs}`}catch{return`${c}:-`}}).join("|"),r=`${n}\x00${e.languages.join(",")}\x00${e.fallback??""}`,t=M.get(r);if(t&&t.signature===a)return t.messages;let g=await Lr(s,e),o=new Map;for(let[c,{language:p,area:m}]of g.files){let u=_(p,m);for(let d of jr(c))o.set(d,u)}let i=e.fallback??e.languages[0];if(!e.languages.includes(i))throw Error(`messages.fallback "${i}" is not one of messages.languages`);let l={...g,stubs:o,languages:[...e.languages],fallback:i};return M.set(r,{signature:a,messages:l}),l}function Lg(...s){let e=new Set;for(let n of s){if(!n||!n.includes("stx-messages:"))continue;for(let a of n.matchAll(/stx-messages:[\w-]+:([\w/-]+)/g))e.add(a[1])}return e}function jg(s,e){let n=/<html\b[^>]*>/i.exec(s)?.[0]??"",a=/\slang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(n),r=(a?a[1]??a[2]??a[3]??"":"").trim().toLowerCase(),t=new Map(e.languages.map((o)=>[o.toLowerCase(),o])),g=t.get(r)??t.get(r.split(/[-_]/)[0]??"");if(!g)return[...e.languages];return[...new Set([g,e.fallback])]}var w=new WeakMap;function Bg(s,e,n){let a=[...n].sort(),r=w.get(s);if(!r)w.set(s,r=new Map);let t=`${e.join(",")}\x00${a.join(",")}`;if(r.has(t))return r.get(t);let g=P(s,e,a);return r.set(t,g),g}function P(s,e,n){let a=[];for(let r of e){let t=s.data.get(r);if(!t)continue;for(let g of n){let o=t.get(g);if(o!==void 0)a.push(`put(${JSON.stringify(h(r,g))},${JSON.stringify(o)})`)}}if(a.length===0)return null;return`;(function(){var kept=globalThis.__stxMessages||(globalThis.__stxMessages={}),filled=globalThis.__stxMessagesFilled||(globalThis.__stxMessagesFilled={});function put(key,json){if(filled[key])return;filled[key]=1;var into=kept[key]||(kept[key]={}),data=JSON.parse(json);for(var name in data)into[name]=data[name]}
2
+ import{existsSync as x,realpathSync as b,statSync as y}from"fs";import f from"path";import k from"process";var E=/^[\w-]+(?:\/[\w-]+)*$/,j=/^[\w-]+$/;async function jr(s,e){let n=f.resolve(s,e.dir);if(!e.languages?.length)throw Error("messages.languages must name at least one language");let a=new Map,r=new Map;for(let t of e.languages){if(!j.test(t))throw Error(`messages: "${t}" is not a language directory name`);let g=f.join(n,t);if(!x(g))throw Error(`messages: ${f.relative(s,g)} does not exist`);let o=new Map;for(let i of[...new Bun.Glob("**/*.{ts,js,mjs,json}").scanSync({cwd:g})].sort()){if(/\.(?:test|spec|d)\.[^.]+$/.test(i))continue;let l=i.replace(/\.[^./]+$/,"").split(f.sep).join("/");if(!E.test(l))throw Error(`messages: ${t}/${i} is not an area name`);if(o.has(l))throw Error(`messages: ${t}/${l} is defined twice`);let c=f.join(g,i),p=await import(c),m=Object.keys(p).filter((S)=>S!=="default");if(m.length)throw Error(`messages: ${t}/${i} exports ${m.join(", ")}; a message module exports its messages as default, and nothing else`);let u=p.default,d=u!==null&&typeof u==="object"&&!Array.isArray(u)?JSON.stringify(u):void 0;if(d===void 0||!Bun.deepEquals(JSON.parse(d),u,!0))throw Error(`messages: ${t}/${i} must export plain data (an object JSON can hold) as default`);o.set(l,d),a.set(c,{language:t,area:l})}r.set(t,o)}return{files:a,data:r}}function h(s,e){return`stx-messages:${s}:${e}`}function _(s,e){let n=JSON.stringify(h(s,e));return`var kept = globalThis.__stxMessages || (globalThis.__stxMessages = {});
3
+ export default kept[${n}] || (kept[${n}] = {});`}var M=new Map;function Br(s){let e=[s];try{e.push(b(s))}catch{}for(let n of[...e])if(n.startsWith("/private/"))e.push(n.slice(8));return[...new Set(e)]}function Mg(s,e=k.env){if(!s.messages||e.STX_PAGE_MESSAGES==="0")return!1;return e.STX_PAGE_MESSAGES==="1"||e.NODE_ENV==="production"}async function Lg(s,e){let n=f.resolve(s,e.dir),a=e.languages.map((c)=>{try{return`${c}:${y(f.join(n,c)).mtimeMs}`}catch{return`${c}:-`}}).join("|"),r=`${n}\x00${e.languages.join(",")}\x00${e.fallback??""}`,t=M.get(r);if(t&&t.signature===a)return t.messages;let g=await jr(s,e),o=new Map;for(let[c,{language:p,area:m}]of g.files){let u=_(p,m);for(let d of Br(c))o.set(d,u)}let i=e.fallback??e.languages[0];if(!e.languages.includes(i))throw Error(`messages.fallback "${i}" is not one of messages.languages`);let l={...g,stubs:o,languages:[...e.languages],fallback:i};return M.set(r,{signature:a,messages:l}),l}function jg(...s){let e=new Set;for(let n of s){if(!n||!n.includes("stx-messages:"))continue;for(let a of n.matchAll(/stx-messages:[\w-]+:([\w/-]+)/g))e.add(a[1])}return e}function Bg(s,e){let n=/<html\b[^>]*>/i.exec(s)?.[0]??"",a=/\slang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(n),r=(a?a[1]??a[2]??a[3]??"":"").trim().toLowerCase(),t=new Map(e.languages.map((o)=>[o.toLowerCase(),o])),g=t.get(r)??t.get(r.split(/[-_]/)[0]??"");if(!g)return[...e.languages];return[...new Set([g,e.fallback])]}var w=new WeakMap;function Fg(s,e,n){let a=[...n].sort(),r=w.get(s);if(!r)w.set(s,r=new Map);let t=`${e.join(",")}\x00${a.join(",")}`;if(r.has(t))return r.get(t);let g=P(s,e,a);return r.set(t,g),g}function P(s,e,n){let a=[];for(let r of e){let t=s.data.get(r);if(!t)continue;for(let g of n){let o=t.get(g);if(o!==void 0)a.push(`put(${JSON.stringify(h(r,g))},${JSON.stringify(o)})`)}}if(a.length===0)return null;return`;(function(){var kept=globalThis.__stxMessages||(globalThis.__stxMessages={}),filled=globalThis.__stxMessagesFilled||(globalThis.__stxMessagesFilled={});function put(key,json){if(filled[key])return;filled[key]=1;var into=kept[key]||(kept[key]={}),data=JSON.parse(json);for(var name in data)into[name]=data[name]}
4
4
  ${a.join(`;
5
5
  `)};
6
6
  })();`}
7
- export{Lr,jr,Dg,Mg,Lg,jg,Bg};
7
+ export{jr,Br,Mg,Lg,jg,Bg,Fg};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{AsyncLocalStorage as R}from"async_hooks";var b=Symbol.for("stx.runtime-config.scope"),y=globalThis,m=y[b]??=new R;function ze(n,f){return m.run(n,f)}function vn(){return m.getStore()}function Hs(){let n=m.getStore();if(!n)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:n.public},"private",{value:n.private}))}function wi(){return Hs().public}function O(n={},f=process.env){let s=new Set;function o(e,i){if(i===null)return e===null;if(Array.isArray(i))return Array.isArray(e)&&(!i.length||e.every((r)=>i.some((u)=>o(r,u))));if(typeof i==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.entries(i).every(([r,u])=>Object.hasOwn(e,r)&&o(e[r],u));return typeof e===typeof i}function g(e,i){if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`);let t=Object.create(null);for(let[c,l]of Object.entries(e)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)||["constructor","prototype","__proto__"].includes(c))throw TypeError(`Invalid runtime config key: ${c}`);t[c]=g(l,[...i,c])}return Object.freeze(t)}let r=`STX_RUNTIME_${i.map((t)=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(s.has(r))throw TypeError(`Ambiguous runtime config environment key: ${r}`);s.add(r);let u=f[r],a=e;if(u!==void 0){try{a=typeof e==="string"?u:JSON.parse(u)}catch{throw TypeError(`Invalid runtime config override: ${r}`)}if(!o(a,e))throw TypeError(`Wrong runtime config override type: ${r}`)}function p(t){if(t===null||typeof t==="string"||typeof t==="boolean")return t;if(typeof t==="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(p));if(t&&typeof t==="object"&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null))return Object.freeze(Object.fromEntries(Object.entries(t).map(([c,l])=>[c,p(l)])));throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`)}return p(a)}return Object.freeze({public:g(n.public??{},["public"]),private:g(n.private??{},["private"])})}function C(n){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(n.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Mt(n,f){let s=n.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),o=/<head\b[^>]*>/i.exec(s),g=o?o.index+o[0].length:0;return s.slice(0,g)+C(f)+s.slice(g)}
3
- export{ze,vn,Hs,wi,O,Mt};
2
+ import{AsyncLocalStorage as R}from"async_hooks";var b=Symbol.for("stx.runtime-config.scope"),y=globalThis,m=y[b]??=new R;function ze(n,f){return m.run(n,f)}function xn(){return m.getStore()}function Vs(){let n=m.getStore();if(!n)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:n.public},"private",{value:n.private}))}function vi(){return Vs().public}function O(n={},f=process.env){let s=new Set;function o(e,i){if(i===null)return e===null;if(Array.isArray(i))return Array.isArray(e)&&(!i.length||e.every((r)=>i.some((u)=>o(r,u))));if(typeof i==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.entries(i).every(([r,u])=>Object.hasOwn(e,r)&&o(e[r],u));return typeof e===typeof i}function g(e,i){if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`);let t=Object.create(null);for(let[c,l]of Object.entries(e)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)||["constructor","prototype","__proto__"].includes(c))throw TypeError(`Invalid runtime config key: ${c}`);t[c]=g(l,[...i,c])}return Object.freeze(t)}let r=`STX_RUNTIME_${i.map((t)=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(s.has(r))throw TypeError(`Ambiguous runtime config environment key: ${r}`);s.add(r);let u=f[r],a=e;if(u!==void 0){try{a=typeof e==="string"?u:JSON.parse(u)}catch{throw TypeError(`Invalid runtime config override: ${r}`)}if(!o(a,e))throw TypeError(`Wrong runtime config override type: ${r}`)}function p(t){if(t===null||typeof t==="string"||typeof t==="boolean")return t;if(typeof t==="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(p));if(t&&typeof t==="object"&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null))return Object.freeze(Object.fromEntries(Object.entries(t).map(([c,l])=>[c,p(l)])));throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`)}return p(a)}return Object.freeze({public:g(n.public??{},["public"]),private:g(n.private??{},["private"])})}function C(n){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(n.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Lt(n,f){let s=n.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),o=/<head\b[^>]*>/i.exec(s),g=o?o.index+o[0].length:0;return s.slice(0,g)+C(f)+s.slice(g)}
3
+ export{ze,xn,Vs,vi,O,Lt};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  var f=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),b=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);function l(i){return i.replace(/[^\n]/g," ")}function w(i){let o=i.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,l).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,l).replace(/<!--[\s\S]*?-->/g,l).replace(/\{\{\{[\s\S]*?\}\}\}/g,l).replace(/\{\{[\s\S]*?\}\}/g,l).replace(/\{!![\s\S]*?!!\}/g,l),s=new Map,r=new Map,p=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,t;while((t=p.exec(o))!==null){let e=t[1]==="/",n=t[2],a=t[3]==="/";if(f.has(n.toLowerCase()))continue;if(a)continue;if(e)r.set(n,(r.get(n)??0)+1);else{let g=s.get(n);if(g)g.count++;else{let d=o.slice(0,t.index).split(`
3
- `).length;s.set(n,{count:1,firstLine:d})}}}let c=[];for(let e of new Set([...s.keys(),...r.keys()])){if(b.has(e.toLowerCase()))continue;let n=s.get(e)?.count??0,a=r.get(e)??0;if(n!==a)c.push({tag:e,opened:n,closed:a,firstOpenLine:s.get(e)?.firstLine??0})}return c}var u=new Set;function Oo(i,o){let s;try{s=w(i)}catch{return}if(s.length===0)return;let r=`${o}:${i.length}`;if(u.has(r))return;u.add(r);let p=o?o.split(/[/\\]/).pop()||o:"template";for(let{tag:t,opened:c,closed:e,firstOpenLine:n}of s)if(c>e){let a=n?` (first opened at line ${n})`:"";console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 an unclosed <${t}>${a} may swallow the content that follows it.`)}else console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 ${e-c} stray </${t}>.`)}
4
- export{Oo};
3
+ `).length;s.set(n,{count:1,firstLine:d})}}}let c=[];for(let e of new Set([...s.keys(),...r.keys()])){if(b.has(e.toLowerCase()))continue;let n=s.get(e)?.count??0,a=r.get(e)??0;if(n!==a)c.push({tag:e,opened:n,closed:a,firstOpenLine:s.get(e)?.firstLine??0})}return c}var u=new Set;function No(i,o){let s;try{s=w(i)}catch{return}if(s.length===0)return;let r=`${o}:${i.length}`;if(u.has(r))return;u.add(r);let p=o?o.split(/[/\\]/).pop()||o:"template";for(let{tag:t,opened:c,closed:e,firstOpenLine:n}of s)if(c>e){let a=n?` (first opened at line ${n})`:"";console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 an unclosed <${t}>${a} may swallow the content that follows it.`)}else console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 ${e-c} stray </${t}>.`)}
4
+ export{No};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{jf,Xo}from"./chunk-zxfptbac.js";export{jf as looksLikeGlob,Xo as resolveStxTargets};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
2
  function A(s){let o=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;s=s.replace(o,(e,t)=>`const { ${t.split(",").map((r)=>r.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
3
3
  `);let n=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return s=s.replace(n,(e,t)=>`const { ${t.split(",").map((r)=>r.trim()).filter(Boolean).join(", ")} } = window.__composables
4
- `),s}function Cn(s){return s.replace(/^import\s+[^'"]*?from\s*['"][^'"]+['"]\s*;?[ \t]*$/gm,"").replace(/^import\s+['"][^'"]+['"]\s*;?[ \t]*$/gm,"")}
5
- export{A,Cn};
4
+ `),s}function En(s){return s.replace(/^import\s+[^'"]*?from\s*['"][^'"]+['"]\s*;?[ \t]*$/gm,"").replace(/^import\s+['"][^'"]+['"]\s*;?[ \t]*$/gm,"")}
5
+ export{A,En};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import s from"path";var h=new Set([".jpg",".jpeg",".png",".gif"]),d=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function Hl(e,r){let a=r.formats??d;if(!r.publicDir)return e;let i=y(e),o=[],m=/<img\b[^>]*?>/gi,c=[],u;while((u=m.exec(e))!==null){let t=u[0],n=t.match(/\bsrc=["']([^"']+)["']/i);if(!n)continue;if(A(u.index,i))continue;c.push({idx:u.index,length:t.length,src:n[1],raw:t})}if(c.length===0)return e;let f=await Promise.all(c.map(async(t)=>{let n=await S(t.src,r.publicDir,a);return{match:t,sources:n}}));for(let{match:t,sources:n}of f){if(n.length===0)continue;let x=`<picture>${n.map((p)=>`<source type="${p.mime}" srcset="${P(p.url)}">`).join("")}${t.raw}</picture>`;o.push({start:t.idx,end:t.idx+t.length,replacement:x})}if(o.length===0)return e;let l="",g=0;for(let t of o)l+=e.slice(g,t.start),l+=t.replacement,g=t.end;return l+=e.slice(g),l}async function S(e,r,a){if(!w(e))return[];let i=s.extname(e).toLowerCase();if(!h.has(i))return[];if(!e.startsWith("/"))return[];let o=s.join(r,e.slice(1)),m=s.dirname(o),c=s.basename(o,i),u=s.resolve(m),f=s.resolve(r);if(!u.startsWith(f))return[];let l=s.posix.dirname(e),g=a.map(async(n)=>{let b=s.join(m,`${c}${n.ext}`);if(!await Bun.file(b).exists())return null;return{url:s.posix.join(l,`${c}${n.ext}`),mime:n.mime}});return(await Promise.all(g)).filter((n)=>n!==null)}function w(e){if(!e)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return!1;if(e.startsWith("//"))return!1;if(e.startsWith("data:"))return!1;return!0}function y(e){let r=[],a=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,i;while((i=a.exec(e))!==null)r.push([i.index,i.index+i[0].length]);return r}function A(e,r){for(let[a,i]of r)if(e>=a&&e<i)return!0;return!1}function P(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}
3
- export{Hl};
2
+ import s from"path";var h=new Set([".jpg",".jpeg",".png",".gif"]),d=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function Vl(e,r){let a=r.formats??d;if(!r.publicDir)return e;let i=y(e),o=[],m=/<img\b[^>]*?>/gi,c=[],u;while((u=m.exec(e))!==null){let t=u[0],n=t.match(/\bsrc=["']([^"']+)["']/i);if(!n)continue;if(A(u.index,i))continue;c.push({idx:u.index,length:t.length,src:n[1],raw:t})}if(c.length===0)return e;let f=await Promise.all(c.map(async(t)=>{let n=await S(t.src,r.publicDir,a);return{match:t,sources:n}}));for(let{match:t,sources:n}of f){if(n.length===0)continue;let x=`<picture>${n.map((p)=>`<source type="${p.mime}" srcset="${P(p.url)}">`).join("")}${t.raw}</picture>`;o.push({start:t.idx,end:t.idx+t.length,replacement:x})}if(o.length===0)return e;let l="",g=0;for(let t of o)l+=e.slice(g,t.start),l+=t.replacement,g=t.end;return l+=e.slice(g),l}async function S(e,r,a){if(!w(e))return[];let i=s.extname(e).toLowerCase();if(!h.has(i))return[];if(!e.startsWith("/"))return[];let o=s.join(r,e.slice(1)),m=s.dirname(o),c=s.basename(o,i),u=s.resolve(m),f=s.resolve(r);if(!u.startsWith(f))return[];let l=s.posix.dirname(e),g=a.map(async(n)=>{let b=s.join(m,`${c}${n.ext}`);if(!await Bun.file(b).exists())return null;return{url:s.posix.join(l,`${c}${n.ext}`),mime:n.mime}});return(await Promise.all(g)).filter((n)=>n!==null)}function w(e){if(!e)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return!1;if(e.startsWith("//"))return!1;if(e.startsWith("data:"))return!1;return!0}function y(e){let r=[],a=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,i;while((i=a.exec(e))!==null)r.push([i.index,i.index+i[0].length]);return r}function A(e,r){for(let[a,i]of r)if(e>=a&&e<i)return!0;return!1}function P(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}
3
+ export{Vl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Q,ee,te,Nn,me,Te,Kr,Hl,gt,Xt,Dn,Mn,Ln,ne,jn,Bn,Xr}from"./chunk-cfpw4c6b.js";import"./chunk-c0ejyxfj.js";export{ee as DEFAULT_FORMATS,te as DEFAULT_QUALITY,Q as DEFAULT_WIDTHS,Xr as ImageProcessingError,Bn as formatSize,Xt as generateSizes,gt as generateSrcSet,Dn as getFallbackVariant,Kr as getImageMetadata,ne as getMimeType,jn as getTotalSize,Mn as groupVariantsByFormat,me as isImageBackendAvailable,Ln as isImageFile,Nn as isSharpAvailable,Te as processImage,Hl as resizeAndConvert};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Di,Mi,Li,Ig,ji,Bi,Og,Fi,zi,xl,Ng}from"./chunk-kf8hzvb7.js";export{Di as VideoProcessorCache,xl as analyzeVideo,Ig as clearVideoCache,zi as generateDASHManifest,Fi as generateHLSManifest,ji as generatePoster,Og as generateSpriteSheet,Bi as generateThumbnails,Mi as getCachedVideoResult,Ng as processVideo,Li as setCachedVideoResult};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ue,En,Ai}from"./chunk-nnzmbfjq.js";function Ys(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?Ue(a,e):null,h=u?En(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
2
+ import{Ue,Tn,Pi}from"./chunk-k4bdf0dw.js";function Zs(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?Ue(a,e):null,h=u?Tn(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
3
3
  * Service Worker - Auto-generated by stx
4
4
  * Cache Version: ${i}
5
5
  *
@@ -13,7 +13,7 @@ import{Ue,En,Ai}from"./chunk-nnzmbfjq.js";function Ys(e,a){let t=e.pwa;if(!t?.en
13
13
  * Additional features:
14
14
  * - Push notifications: ${r?.enabled?"enabled":"disabled"}
15
15
  * - Background sync: ${s?.enabled?"enabled":"disabled"}
16
- * - Cache limits: ${n?.maxSize?`${Ai(n.maxSize*1024*1024)}`:"unlimited"}
16
+ * - Cache limits: ${n?.maxSize?`${Pi(n.maxSize*1024*1024)}`:"unlimited"}
17
17
  */
18
18
 
19
19
  const CACHE_VERSION = '${i}';
@@ -825,5 +825,5 @@ self.addEventListener('message', (event) => {
825
825
  event.waitUntil(registerFormSync(event.data.payload));
826
826
  }
827
827
  });
828
- `}function zt(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function bl(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function xg(e,a){if(!e.pwa?.enabled)return"";if(bl(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-4qng287p.js");return t(e,a)}return Ys(e,a)}
829
- export{Ys,zt,bl,xg};
828
+ `}function Ht(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function wl(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function Sg(e,a){if(!e.pwa?.enabled)return"";if(wl(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-8nb8b0nf.js");return t(e,a)}return Zs(e,a)}
829
+ export{Zs,Ht,wl,Sg};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function tt(){if(i)return i;let t="unknown";try{t=String(JSON.parse(n.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let o=a.dirname(s(import.meta.url)),e=0;for(let r of n.readdirSync(o,{recursive:!0,withFileTypes:!0}))if(r.isFile()&&r.name.endsWith(".ts"))e=Math.max(e,n.statSync(a.join(r.parentPath,r.name)).mtimeMs);t+=`+src.${Math.trunc(e)}`}catch{}return i=t,t}
3
- export{tt};
2
+ import n from"fs";import a from"path";import{fileURLToPath as s}from"url";var i;function nt(){if(i)return i;let t="unknown";try{t=String(JSON.parse(n.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let o=a.dirname(s(import.meta.url)),e=0;for(let r of n.readdirSync(o,{recursive:!0,withFileTypes:!0}))if(r.isFile()&&r.name.endsWith(".ts"))e=Math.max(e,n.statSync(a.join(r.parentPath,r.name)).mtimeMs);t+=`+src.${Math.trunc(e)}`}catch{}return i=t,t}
3
+ export{nt};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function Km(s,n={},t){let e=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return s.replace(e,(r,i,o,d)=>{let u=l(),a=p(i||"");return f(u,o.trim(),d.trim(),a)})}function p(s){let n={},t=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,e;while((e=t.exec(s))!==null){let r=e[1],i=e[2]||e[3],o=e[4];switch(r){case"id":n.id=i;break;case"timeout":n.timeout=o?parseInt(o,10):void 0;break}}return n}function f(s,n,t,e){let r=e.timeout||30000,i=e.id||s;return`
2
+ var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function Xm(s,n={},t){let e=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return s.replace(e,(r,i,o,d)=>{let u=l(),a=p(i||"");return f(u,o.trim(),d.trim(),a)})}function p(s){let n={},t=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,e;while((e=t.exec(s))!==null){let r=e[1],i=e[2]||e[3],o=e[4];switch(r){case"id":n.id=i;break;case"timeout":n.timeout=o?parseInt(o,10):void 0;break}}return n}function f(s,n,t,e){let r=e.timeout||30000,i=e.id||s;return`
3
3
  <div class="stx-suspense" data-suspense-id="${s}" data-custom-id="${i}" data-status="pending">
4
4
  <div class="stx-suspense-fallback" data-suspense-fallback="${s}">
5
5
  ${t}
@@ -189,7 +189,7 @@ else {
189
189
  }, 0);
190
190
  })();
191
191
  </script>
192
- `}function Xm(s,n,t){return{id:s,fallback:t,content:n}}async function Gm(s){let n=s.map((e)=>`
192
+ `}function Gm(s,n,t){return{id:s,fallback:t,content:n}}async function Jm(s){let n=s.map((e)=>`
193
193
  <div id="stx-ssr-suspense-${e.id}" class="stx-ssr-suspense">
194
194
  ${e.fallback}
195
195
  </div>
@@ -214,7 +214,7 @@ else {
214
214
  }
215
215
  })();
216
216
  </script>
217
- `}}return{initial:n,streaming:t()}}function Jm(){return`
217
+ `}}return{initial:n,streaming:t()}}function Ym(){return`
218
218
  /* STX Suspense Styles */
219
219
  .stx-suspense {
220
220
  position: relative;
@@ -270,7 +270,7 @@ else {
270
270
  background-size: 200% 100%;
271
271
  }
272
272
  }
273
- `}function Ym(){return`
273
+ `}function Zm(){return`
274
274
  // STX Suspense Runtime
275
275
  (function() {
276
276
  if (typeof window === 'undefined') return;
@@ -338,4 +338,4 @@ else {
338
338
  console.log('[stx] Suspense runtime initialized');
339
339
  })();
340
340
  `}
341
- export{Km,Xm,Gm,Jm,Ym};
341
+ export{Xm,Gm,Jm,Ym,Zm};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function yc(e){try{return w.has(c.realpathSync(e))}catch{return w.has(i.resolve(e))}}var _=new Set(["extends","root",...j.map((e)=>`${e}Dir`),"publicDir","stateDir","cachePath"]),x=(e)=>e!==null&&typeof e==="object"&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function b(e,n,r=""){if(Array.isArray(n))return["middleware","plugins"].includes(r)?[...Array.isArray(e)?e:[],...n]:[...n];if(!x(n))return n;let o={...x(e)?e:{}};for(let[s,a]of Object.entries(n)){if(["__proto__","constructor","prototype"].includes(s))throw Error(`Invalid layer config key: ${s}`);o[s]=b(o[s],a,s)}return o}function v(e){for(let n of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let r=i.join(e,n);if(c.existsSync(r))return c.realpathSync(r)}throw Error(`Application layer has no stx.config.ts: ${e}`)}function E(e,n,r){if(typeof e!=="string"||!e||/^(?:https?:|git[+:])/.test(e))throw Error(`Invalid application layer ${JSON.stringify(e)} in ${n}; use a local path or installed package`);if(e.startsWith(".")||i.isAbsolute(e)){let s=i.resolve(n,e);return c.statSync(s).isDirectory()?v(s):c.realpathSync(s)}let o=n;while(!0){let s=i.join(o,"node_modules",e),a=i.join(s,"package.json");if(c.existsSync(a)){r.add(c.realpathSync(a));let g=JSON.parse(c.readFileSync(a,"utf8"));return g.stx?.layer?c.realpathSync(i.resolve(s,g.stx.layer)):v(s)}let p=i.dirname(o);if(p===o)break;o=p}throw Error(`Cannot resolve application layer ${JSON.stringify(e)} from ${n}`)}async function C(e,n){let r=await Bun.build({entrypoints:[e],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(a){a.onResolve({filter:/^[^./]/},(p)=>{if(p.path.startsWith("node:"))return{path:p.path,external:!0};return{path:Bun.resolveSync(p.path,p.resolveDir),external:!0}}),a.onLoad({filter:/./},(p)=>{let g=c.realpathSync(p.path);n.add(g),w.add(g);return})}}]});if(!r.success)throw Error(`Cannot load layer ${e}: ${r.logs.join(`
3
- `)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function bc(e,n){let r=new Set,o=[],s=[],a=new Set,p=[];async function g(t,l){if(t=c.realpathSync(t),p.includes(t))throw Error(`Application layer cycle: ${[...p,t].join(" -> ")}`);if(a.has(t))return;a.add(t),p.push(t);let d=await C(t,r);l??=i.basename(i.dirname(t))===".config"?i.dirname(i.dirname(t)):i.dirname(t),l=c.realpathSync(l);let D=i.resolve(l,d.root??"."),L=Object.fromEntries(j.map((y)=>[y,i.resolve(D,d[`${y}Dir`]??(y==="composables"?"functions":y))]));o.push({root:l,configFile:t,resources:L});let u={...d};if(u.plugins)u.plugins=u.plugins.map((y)=>{let h=typeof y==="string"?y:y[0],S=h.startsWith(".")?i.resolve(l,h):i.isAbsolute(h)?h:Bun.resolveSync(h,l);return r.add(c.realpathSync(S)),typeof y==="string"?S:[S,y[1]]});if(typeof u.css==="string")u.css=i.resolve(l,u.css);if(u.serverApi)u.serverApi={...typeof u.serverApi==="object"?u.serverApi:{},dir:i.resolve(l,typeof u.serverApi==="object"?u.serverApi.dir??"server/api":"server/api")};if(s.push(u),d.extends!==void 0&&!Array.isArray(d.extends))throw Error(`extends in ${t} must be an array`);for(let y of d.extends??[])await g(E(y,l,r));p.pop()}await g(v(e),e);for(let t of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let l=i.join(e,t);if(c.existsSync(l))r.add(c.realpathSync(l))}let f=b({},n);for(let t=s.length-1;t>=0;t--){let l=t===0?s[t]:Object.fromEntries(Object.entries(s[t]).filter(([d])=>!_.has(d)));f=b(f,l)}let m={layers:o,configDependencies:[...r].sort()};return f._layerGraph=m,f._layerPageDirs=o.map((t)=>t.resources.pages),f._layerComponentDirs=o.map((t)=>t.resources.components),f._layerLayoutDirs=o.map((t)=>t.resources.layouts),f._layerPartialDirs=o.map((t)=>t.resources.partials),f._layerComposableDirs=o.map((t)=>t.resources.composables),await Xo(m,e),{config:f,graph:m}}async function Xo(e,n){let r=new Map,o=[];for(let s of e.layers)for(let[a,p]of Object.entries(s.resources)){if(!c.existsSync(p))continue;let g=new Bun.Glob(a==="composables"?"**/*.ts":"**/*.stx");for(let f of[...g.scanSync({cwd:p})].sort()){let m=`${a}/${f}`,t=i.join(p,f),l=r.get(m);if(l)o.push({resource:m,winner:l,shadowed:t});else r.set(m,t)}}Object.assign(e,{overrides:o}),await Bun.write(i.join(n,".stx/layers.json"),JSON.stringify(e,null,2))}function A(e){let n=new Set(e.configDependencies);function r(o){if(!c.existsSync(o))return;n.add(o);for(let s of c.readdirSync(o,{withFileTypes:!0}).sort((a,p)=>a.name.localeCompare(p.name))){if(s.name.startsWith(".")||s.name==="node_modules")continue;let a=i.join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile())n.add(a)}}for(let o of e.layers)for(let s of Object.values(o.resources))r(s);return[...n].sort()}function vs(e){return O(A(e))}function xs(e){return O(e.configDependencies)}function O(e){return e.map((n)=>{try{let r=c.statSync(n);return`${n}:${r.mtimeMs}:${r.size}`}catch{return`${n}:missing`}}).join(`
4
- `)}function wc(e){return e.layers.map((n)=>({config:i.relative(n.root,n.configFile),files:A({layers:[n],configDependencies:e.configDependencies.filter((r)=>r.startsWith(`${n.root}${i.sep}`))}).filter((r)=>c.statSync(r).isFile()).map((r)=>({path:i.relative(n.root,r).replaceAll(i.sep,"/"),sha256:k("sha256").update(c.readFileSync(r)).digest("hex")}))}))}
5
- export{yc,bc,Xo,vs,xs,wc};
2
+ import c from"fs";import i from"path";import{createHash as k}from"crypto";var j=["pages","components","layouts","partials","composables"],w=new Set;function bc(e){try{return w.has(c.realpathSync(e))}catch{return w.has(i.resolve(e))}}var _=new Set(["extends","root",...j.map((e)=>`${e}Dir`),"publicDir","stateDir","cachePath"]),x=(e)=>e!==null&&typeof e==="object"&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null);function b(e,n,r=""){if(Array.isArray(n))return["middleware","plugins"].includes(r)?[...Array.isArray(e)?e:[],...n]:[...n];if(!x(n))return n;let o={...x(e)?e:{}};for(let[s,a]of Object.entries(n)){if(["__proto__","constructor","prototype"].includes(s))throw Error(`Invalid layer config key: ${s}`);o[s]=b(o[s],a,s)}return o}function v(e){for(let n of["stx.config.ts","stx.config.js","stx.config.mjs",".config/stx.config.ts",".config/stx.ts","ui.config.ts"]){let r=i.join(e,n);if(c.existsSync(r))return c.realpathSync(r)}throw Error(`Application layer has no stx.config.ts: ${e}`)}function E(e,n,r){if(typeof e!=="string"||!e||/^(?:https?:|git[+:])/.test(e))throw Error(`Invalid application layer ${JSON.stringify(e)} in ${n}; use a local path or installed package`);if(e.startsWith(".")||i.isAbsolute(e)){let s=i.resolve(n,e);return c.statSync(s).isDirectory()?v(s):c.realpathSync(s)}let o=n;while(!0){let s=i.join(o,"node_modules",e),a=i.join(s,"package.json");if(c.existsSync(a)){r.add(c.realpathSync(a));let g=JSON.parse(c.readFileSync(a,"utf8"));return g.stx?.layer?c.realpathSync(i.resolve(s,g.stx.layer)):v(s)}let p=i.dirname(o);if(p===o)break;o=p}throw Error(`Cannot resolve application layer ${JSON.stringify(e)} from ${n}`)}async function C(e,n){let r=await Bun.build({entrypoints:[e],target:"bun",format:"esm",splitting:!1,plugins:[{name:"stx-layer-config",setup(a){a.onResolve({filter:/^[^./]/},(p)=>{if(p.path.startsWith("node:"))return{path:p.path,external:!0};return{path:Bun.resolveSync(p.path,p.resolveDir),external:!0}}),a.onLoad({filter:/./},(p)=>{let g=c.realpathSync(p.path);n.add(g),w.add(g);return})}}]});if(!r.success)throw Error(`Cannot load layer ${e}: ${r.logs.join(`
3
+ `)}`);let o=r.outputs.find((a)=>a.kind==="entry-point");if(!o||r.outputs.length!==1)throw Error(`Unsupported layer config output: ${e}`);let s=(await import(`data:text/javascript;base64,${Buffer.from(await o.text()).toString("base64")}`)).default;if(!x(s))throw Error(`Layer ${e} must default-export a config object`);return s}async function wc(e,n){let r=new Set,o=[],s=[],a=new Set,p=[];async function g(t,l){if(t=c.realpathSync(t),p.includes(t))throw Error(`Application layer cycle: ${[...p,t].join(" -> ")}`);if(a.has(t))return;a.add(t),p.push(t);let d=await C(t,r);l??=i.basename(i.dirname(t))===".config"?i.dirname(i.dirname(t)):i.dirname(t),l=c.realpathSync(l);let D=i.resolve(l,d.root??"."),L=Object.fromEntries(j.map((y)=>[y,i.resolve(D,d[`${y}Dir`]??(y==="composables"?"functions":y))]));o.push({root:l,configFile:t,resources:L});let u={...d};if(u.plugins)u.plugins=u.plugins.map((y)=>{let h=typeof y==="string"?y:y[0],S=h.startsWith(".")?i.resolve(l,h):i.isAbsolute(h)?h:Bun.resolveSync(h,l);return r.add(c.realpathSync(S)),typeof y==="string"?S:[S,y[1]]});if(typeof u.css==="string")u.css=i.resolve(l,u.css);if(u.serverApi)u.serverApi={...typeof u.serverApi==="object"?u.serverApi:{},dir:i.resolve(l,typeof u.serverApi==="object"?u.serverApi.dir??"server/api":"server/api")};if(s.push(u),d.extends!==void 0&&!Array.isArray(d.extends))throw Error(`extends in ${t} must be an array`);for(let y of d.extends??[])await g(E(y,l,r));p.pop()}await g(v(e),e);for(let t of["package.json","bun.lock","package-lock.json","pnpm-lock.yaml"]){let l=i.join(e,t);if(c.existsSync(l))r.add(c.realpathSync(l))}let f=b({},n);for(let t=s.length-1;t>=0;t--){let l=t===0?s[t]:Object.fromEntries(Object.entries(s[t]).filter(([d])=>!_.has(d)));f=b(f,l)}let m={layers:o,configDependencies:[...r].sort()};return f._layerGraph=m,f._layerPageDirs=o.map((t)=>t.resources.pages),f._layerComponentDirs=o.map((t)=>t.resources.components),f._layerLayoutDirs=o.map((t)=>t.resources.layouts),f._layerPartialDirs=o.map((t)=>t.resources.partials),f._layerComposableDirs=o.map((t)=>t.resources.composables),await Go(m,e),{config:f,graph:m}}async function Go(e,n){let r=new Map,o=[];for(let s of e.layers)for(let[a,p]of Object.entries(s.resources)){if(!c.existsSync(p))continue;let g=new Bun.Glob(a==="composables"?"**/*.ts":"**/*.stx");for(let f of[...g.scanSync({cwd:p})].sort()){let m=`${a}/${f}`,t=i.join(p,f),l=r.get(m);if(l)o.push({resource:m,winner:l,shadowed:t});else r.set(m,t)}}Object.assign(e,{overrides:o}),await Bun.write(i.join(n,".stx/layers.json"),JSON.stringify(e,null,2))}function A(e){let n=new Set(e.configDependencies);function r(o){if(!c.existsSync(o))return;n.add(o);for(let s of c.readdirSync(o,{withFileTypes:!0}).sort((a,p)=>a.name.localeCompare(p.name))){if(s.name.startsWith(".")||s.name==="node_modules")continue;let a=i.join(o,s.name);if(s.isDirectory())r(a);else if(s.isFile())n.add(a)}}for(let o of e.layers)for(let s of Object.values(o.resources))r(s);return[...n].sort()}function xs(e){return O(A(e))}function Ss(e){return O(e.configDependencies)}function O(e){return e.map((n)=>{try{let r=c.statSync(n);return`${n}:${r.mtimeMs}:${r.size}`}catch{return`${n}:missing`}}).join(`
4
+ `)}function vc(e){return e.layers.map((n)=>({config:i.relative(n.root,n.configFile),files:A({layers:[n],configDependencies:e.configDependencies.filter((r)=>r.startsWith(`${n.root}${i.sep}`))}).filter((r)=>c.statSync(r).isFile()).map((r)=>({path:i.relative(n.root,r).replaceAll(i.sep,"/"),sha256:k("sha256").update(c.readFileSync(r)).digest("hex")}))}))}
5
+ export{bc,wc,Go,xs,Ss,vc};