@stacksjs/stx 0.2.645 → 0.2.648

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 (264) hide show
  1. package/dist/builtins/attrs.js +6 -6
  2. package/dist/builtins/escape.d.ts +0 -11
  3. package/dist/builtins/escape.js +2 -1
  4. package/dist/builtins/safe-image.js +1 -3
  5. package/dist/builtins/stx-image.js +1 -3
  6. package/dist/builtins/stx-link.d.ts +3 -0
  7. package/dist/builtins/stx-link.js +1 -3
  8. package/dist/{chunk-apeyn69a.js → chunk-04kg16qs.js} +4 -4
  9. package/dist/chunk-06w0z1cm.js +31 -0
  10. package/dist/chunk-0en5jwjy.js +2 -0
  11. package/dist/{chunk-ph8dqgr5.js → chunk-0h8tg21j.js} +14 -14
  12. package/dist/{chunk-g2mcw1r4.js → chunk-0jhdrgpr.js} +2 -2
  13. package/dist/chunk-0vkawews.js +21 -0
  14. package/dist/{chunk-hpggz2t4.js → chunk-120ze5ms.js} +3 -3
  15. package/dist/chunk-2a4szpje.js +3 -0
  16. package/dist/chunk-2f17h17f.js +2 -0
  17. package/dist/{chunk-a0ygyftk.js → chunk-2h8ea0we.js} +2 -2
  18. package/dist/{chunk-3ns5k9nf.js → chunk-2jh21f1n.js} +2 -2
  19. package/dist/chunk-2n3pa5gm.js +2 -0
  20. package/dist/{chunk-ktvr45qg.js → chunk-2qbvsvwc.js} +2 -2
  21. package/dist/chunk-354jmw2k.js +3 -0
  22. package/dist/chunk-3b5bphcn.js +2 -0
  23. package/dist/chunk-3p7mk3mw.js +2 -0
  24. package/dist/chunk-3q163st5.js +1312 -0
  25. package/dist/chunk-3zyjqvsq.js +42 -0
  26. package/dist/{chunk-mfd3fca7.js → chunk-481d4kr9.js} +11 -11
  27. package/dist/chunk-4q2dtxdk.js +2 -0
  28. package/dist/{chunk-1t0m4pwg.js → chunk-4yf1w261.js} +2 -2
  29. package/dist/chunk-4yt8tg4j.js +2 -0
  30. package/dist/chunk-52gp2xxk.js +2 -0
  31. package/dist/chunk-55zaxb4s.js +61 -0
  32. package/dist/chunk-57md41g9.js +2 -0
  33. package/dist/chunk-67kj14at.js +2 -0
  34. package/dist/chunk-67xhsacd.js +12 -0
  35. package/dist/{chunk-me1tdtzz.js → chunk-6ajahb2x.js} +3 -3
  36. package/dist/chunk-6ea6az61.js +4 -0
  37. package/dist/chunk-6vh8s0pg.js +2 -0
  38. package/dist/chunk-6vzktvyw.js +2 -0
  39. package/dist/{chunk-r2seygb5.js → chunk-7rta163c.js} +2 -2
  40. package/dist/chunk-84djpte6.js +3 -0
  41. package/dist/chunk-864qtx7y.js +2 -0
  42. package/dist/chunk-88z4wkrj.js +6 -0
  43. package/dist/chunk-89yj6tcd.js +2 -0
  44. package/dist/chunk-8d2f2e42.js +2 -0
  45. package/dist/chunk-8fsq2ynj.js +2 -0
  46. package/dist/chunk-8p9kpfk8.js +4 -0
  47. package/dist/chunk-8tpmz4as.js +2 -0
  48. package/dist/chunk-9121nkpj.js +11 -0
  49. package/dist/{chunk-rmj0n3ss.js → chunk-9p6efb17.js} +1 -1
  50. package/dist/chunk-9szxxgv5.js +2 -0
  51. package/dist/{chunk-4g8zase6.js → chunk-9txn4rvb.js} +2 -2
  52. package/dist/chunk-9x0zt65f.js +2 -0
  53. package/dist/chunk-a2bw46t9.js +2 -0
  54. package/dist/{chunk-gvr10eqb.js → chunk-a3d0g4mr.js} +2 -2
  55. package/dist/chunk-a4sggwcz.js +2 -0
  56. package/dist/chunk-ab7zqtax.js +3 -0
  57. package/dist/{chunk-v1mvbf82.js → chunk-aprhqxky.js} +5 -5
  58. package/dist/chunk-b0hpshvk.js +2 -0
  59. package/dist/chunk-b4fd2dtk.js +2 -0
  60. package/dist/chunk-c1479y92.js +2 -0
  61. package/dist/{chunk-kchphxkm.js → chunk-c1dkh0es.js} +3 -3
  62. package/dist/chunk-c9k40352.js +2 -0
  63. package/dist/{chunk-ahyq08mp.js → chunk-ce6zddpf.js} +3 -3
  64. package/dist/{chunk-9wbtj6tj.js → chunk-dgb4z4kw.js} +2 -2
  65. package/dist/chunk-e87xa4r3.js +4 -0
  66. package/dist/chunk-egg54kd0.js +12 -0
  67. package/dist/chunk-embejqx4.js +2 -0
  68. package/dist/chunk-er60h3j3.js +2 -0
  69. package/dist/{chunk-pp6ycfay.js → chunk-ewcrsyr7.js} +2 -2
  70. package/dist/chunk-eyfxw7ds.js +2 -0
  71. package/dist/chunk-f3y4fnaa.js +2 -0
  72. package/dist/chunk-f46ht5kq.js +20 -0
  73. package/dist/chunk-f7930sce.js +2 -0
  74. package/dist/chunk-fcn71bq1.js +2 -0
  75. package/dist/{chunk-38ngmh6h.js → chunk-fg3jw17w.js} +48 -48
  76. package/dist/chunk-fsbjat59.js +2 -0
  77. package/dist/chunk-g2jmwh7p.js +2 -0
  78. package/dist/chunk-g8r0km7g.js +106 -0
  79. package/dist/{chunk-qa625vwc.js → chunk-gv793yqq.js} +4 -4
  80. package/dist/chunk-gz90fqn8.js +2 -0
  81. package/dist/chunk-h15xb2vd.js +2 -0
  82. package/dist/chunk-h5nmf98w.js +2 -0
  83. package/dist/{chunk-w9zxb26s.js → chunk-hfpv56cp.js} +1 -1
  84. package/dist/chunk-hhmj9gpk.js +2 -0
  85. package/dist/chunk-hjm69qnj.js +2 -0
  86. package/dist/chunk-hvtzw1jh.js +2 -0
  87. package/dist/{chunk-4n24jbfs.js → chunk-hvzzhkhr.js} +2 -2
  88. package/dist/chunk-j0v970k3.js +2 -0
  89. package/dist/chunk-j393gsfd.js +20 -0
  90. package/dist/chunk-j5gd0e53.js +2 -0
  91. package/dist/chunk-jk41jwsc.js +2 -0
  92. package/dist/{chunk-kvn23sz5.js → chunk-jkaszw24.js} +4 -4
  93. package/dist/{chunk-6mnwvn9v.js → chunk-jkvr7e91.js} +2 -2
  94. package/dist/{chunk-2zcbx82x.js → chunk-jxda11cg.js} +2 -2
  95. package/dist/chunk-k2pa44rf.js +2 -0
  96. package/dist/{chunk-kad2cp0z.js → chunk-k79x96ra.js} +37 -37
  97. package/dist/{chunk-75c46b62.js → chunk-kgfgb971.js} +4 -4
  98. package/dist/chunk-m6qfqkbh.js +2 -0
  99. package/dist/{chunk-r7haw6r7.js → chunk-mmwedr93.js} +5 -5
  100. package/dist/chunk-mnp8ecj9.js +2 -0
  101. package/dist/{chunk-dyg6sadv.js → chunk-mrrrngzd.js} +1 -1
  102. package/dist/{chunk-fk1rs7jb.js → chunk-n38yb274.js} +6 -6
  103. package/dist/chunk-ncqh5qe5.js +2 -0
  104. package/dist/chunk-nj1t4g3a.js +25 -0
  105. package/dist/{chunk-3cqxtkqv.js → chunk-np4zm2ph.js} +7 -7
  106. package/dist/{chunk-7jgtphhg.js → chunk-nrvwejdw.js} +5 -5
  107. package/dist/{chunk-c96f3eq5.js → chunk-nt0n0vjm.js} +8 -8
  108. package/dist/chunk-p44kmbdg.js +65 -0
  109. package/dist/chunk-pbtkbe48.js +888 -0
  110. package/dist/{chunk-pf5s5gjp.js → chunk-pg0xzsss.js} +2 -2
  111. package/dist/{chunk-pvfx0dgz.js → chunk-prf164ct.js} +2 -2
  112. package/dist/chunk-pxs7sgnp.js +3 -0
  113. package/dist/chunk-qfe7ps3v.js +18 -0
  114. package/dist/chunk-qm4672dj.js +18 -0
  115. package/dist/{chunk-2bsrmqr8.js → chunk-qv6axke4.js} +2 -2
  116. package/dist/chunk-r1r6311d.js +14 -0
  117. package/dist/{chunk-n54c06wt.js → chunk-r3e6x87d.js} +3 -3
  118. package/dist/chunk-radggg3p.js +49 -0
  119. package/dist/{chunk-zm4s3n4p.js → chunk-rcadtv3x.js} +1 -1
  120. package/dist/{chunk-vbqts5sf.js → chunk-rjh2jwxx.js} +9 -9
  121. package/dist/chunk-sf0wsq74.js +2 -0
  122. package/dist/{chunk-kfq594fh.js → chunk-sgptbhrc.js} +2 -2
  123. package/dist/chunk-shpc1ttk.js +2 -0
  124. package/dist/chunk-sszhz1zh.js +2 -0
  125. package/dist/chunk-szyqxcfj.js +3 -0
  126. package/dist/{chunk-392pj66x.js → chunk-t1k9160w.js} +29 -29
  127. package/dist/{chunk-22hdbqad.js → chunk-t2pzy3x1.js} +3 -3
  128. package/dist/chunk-t6yjxhn8.js +2 -0
  129. package/dist/chunk-t82be9yf.js +2 -0
  130. package/dist/{chunk-g06qzkmp.js → chunk-tre98h62.js} +2 -2
  131. package/dist/{chunk-bsts9pr5.js → chunk-v2x9vzgw.js} +2 -2
  132. package/dist/chunk-vdxjy7j2.js +4 -0
  133. package/dist/{chunk-xbdbn3bf.js → chunk-vmwdt8fr.js} +5 -5
  134. package/dist/{chunk-fqg0espy.js → chunk-vqc4h16r.js} +2 -2
  135. package/dist/chunk-w2zceynt.js +2 -0
  136. package/dist/chunk-weqc0ssb.js +2 -0
  137. package/dist/chunk-wjt0kej9.js +3 -0
  138. package/dist/{chunk-9yk5rasj.js → chunk-wpm58d6p.js} +3 -3
  139. package/dist/{chunk-0zr1zxar.js → chunk-wpmrz872.js} +2 -2
  140. package/dist/chunk-wq6j2h32.js +33 -0
  141. package/dist/chunk-wq712sw1.js +2 -0
  142. package/dist/chunk-x34scshq.js +3 -0
  143. package/dist/{chunk-fb17t651.js → chunk-x5tjb4y4.js} +2 -2
  144. package/dist/chunk-xaa36b0x.js +3 -0
  145. package/dist/chunk-xfzcv0jc.js +2 -0
  146. package/dist/{chunk-dmg8dpah.js → chunk-xm2mee4a.js} +169 -169
  147. package/dist/chunk-xvs04cnp.js +2 -0
  148. package/dist/chunk-y9x4pyp2.js +2 -0
  149. package/dist/chunk-ye8tgmd3.js +2 -0
  150. package/dist/{chunk-febtq3xj.js → chunk-ym41ybz2.js} +6 -6
  151. package/dist/chunk-ymymwzt5.js +3 -0
  152. package/dist/{chunk-wpc04ygt.js → chunk-yq021b3r.js} +11 -11
  153. package/dist/chunk-z8p6tk5z.js +2 -0
  154. package/dist/chunk-zdnc7a4t.js +127 -0
  155. package/dist/chunk-zhf01af3.js +3 -0
  156. package/dist/chunk-zmh9p9aa.js +2 -0
  157. package/dist/{chunk-jtvcxbwd.js → chunk-zqtbtqbq.js} +2 -2
  158. package/dist/chunk-zsgcsqat.js +406 -0
  159. package/dist/chunk-zyqs6a3p.js +2 -0
  160. package/dist/cli.js +62 -62
  161. package/dist/craft-entry.js +2 -2
  162. package/dist/craft.js +2 -2
  163. package/dist/expressions.d.ts +6 -21
  164. package/dist/expressions.js +12 -41
  165. package/dist/forms-validation.d.ts +0 -16
  166. package/dist/forms-validation.js +4 -2
  167. package/dist/forms.js +8 -6
  168. package/dist/i18n.js +6 -4
  169. package/dist/interpolation-context.js +173 -29
  170. package/dist/loops.js +70 -90
  171. package/dist/mustache-span.d.ts +21 -0
  172. package/dist/mustache-span.js +35 -0
  173. package/dist/process.js +4 -3
  174. package/dist/pwa.js +3 -3
  175. package/dist/runtime-injection.js +9 -3
  176. package/dist/server-bindings.js +12 -6
  177. package/dist/ssg.js +28 -28
  178. package/dist/utils.js +1 -2
  179. package/package.json +5 -5
  180. package/dist/chunk-1jgsst0v.js +0 -2
  181. package/dist/chunk-1vrqmdfe.js +0 -2
  182. package/dist/chunk-1vx1ha9v.js +0 -2
  183. package/dist/chunk-1y9jphbg.js +0 -2
  184. package/dist/chunk-22kgdhxy.js +0 -2
  185. package/dist/chunk-2etamr31.js +0 -4
  186. package/dist/chunk-2s49ggrz.js +0 -12
  187. package/dist/chunk-2zbnc6jq.js +0 -2
  188. package/dist/chunk-39beqd1g.js +0 -2
  189. package/dist/chunk-3q5yn5r0.js +0 -6
  190. package/dist/chunk-3tcy2hdt.js +0 -2
  191. package/dist/chunk-3ycbhpa2.js +0 -2
  192. package/dist/chunk-3yqs2ekt.js +0 -2
  193. package/dist/chunk-4mm9ttc7.js +0 -2
  194. package/dist/chunk-4q4vy4g6.js +0 -2
  195. package/dist/chunk-4zapx8zt.js +0 -20
  196. package/dist/chunk-5zkwems4.js +0 -2
  197. package/dist/chunk-6e4es31t.js +0 -3
  198. package/dist/chunk-6hmbzqt8.js +0 -2
  199. package/dist/chunk-7a3kffqy.js +0 -2
  200. package/dist/chunk-7mkw98cr.js +0 -3
  201. package/dist/chunk-7xks65hg.js +0 -3
  202. package/dist/chunk-8k38mddf.js +0 -2
  203. package/dist/chunk-8q05cxzd.js +0 -2
  204. package/dist/chunk-a7y0fk20.js +0 -12
  205. package/dist/chunk-abwxa3tj.js +0 -2
  206. package/dist/chunk-ayjje1hk.js +0 -2
  207. package/dist/chunk-c93291jk.js +0 -2
  208. package/dist/chunk-cf6d5kgb.js +0 -65
  209. package/dist/chunk-crahn5xa.js +0 -4
  210. package/dist/chunk-d1jyxxcm.js +0 -3
  211. package/dist/chunk-d365tseq.js +0 -20
  212. package/dist/chunk-d67qvrzc.js +0 -24
  213. package/dist/chunk-dwnvqy3f.js +0 -4
  214. package/dist/chunk-dxb7jw7g.js +0 -2
  215. package/dist/chunk-e8483tnk.js +0 -2
  216. package/dist/chunk-eaphbqqx.js +0 -2
  217. package/dist/chunk-em0chjea.js +0 -18
  218. package/dist/chunk-ercd4pqc.js +0 -2
  219. package/dist/chunk-ewj4gqwe.js +0 -31
  220. package/dist/chunk-f7bgg2e4.js +0 -2
  221. package/dist/chunk-g6s0xdgb.js +0 -4
  222. package/dist/chunk-jxsgky4v.js +0 -2
  223. package/dist/chunk-k90yzxwp.js +0 -2
  224. package/dist/chunk-kfx4cte8.js +0 -127
  225. package/dist/chunk-kxbw0e2f.js +0 -3
  226. package/dist/chunk-ky043mkv.js +0 -2
  227. package/dist/chunk-mbqqc20a.js +0 -2
  228. package/dist/chunk-mq2kpg6w.js +0 -2
  229. package/dist/chunk-n58ky78d.js +0 -2
  230. package/dist/chunk-n80wh9b5.js +0 -2
  231. package/dist/chunk-p7sfjgtm.js +0 -2
  232. package/dist/chunk-ps9htxmp.js +0 -2
  233. package/dist/chunk-qhaw7f32.js +0 -2
  234. package/dist/chunk-rh33ra9e.js +0 -2
  235. package/dist/chunk-rzs2hpqa.js +0 -2
  236. package/dist/chunk-s3sckkvv.js +0 -2
  237. package/dist/chunk-s89pq4v1.js +0 -2
  238. package/dist/chunk-sdqgmcbk.js +0 -2
  239. package/dist/chunk-srmm69d4.js +0 -2852
  240. package/dist/chunk-t00y30w3.js +0 -2
  241. package/dist/chunk-t1a39rpd.js +0 -2
  242. package/dist/chunk-tj4rzy69.js +0 -2
  243. package/dist/chunk-tme51pg1.js +0 -2
  244. package/dist/chunk-tv1qtqab.js +0 -3
  245. package/dist/chunk-twh5ck5w.js +0 -2
  246. package/dist/chunk-v4tt3t1y.js +0 -2
  247. package/dist/chunk-v5ekdsw0.js +0 -2
  248. package/dist/chunk-vdsrae92.js +0 -2
  249. package/dist/chunk-w88mpbxk.js +0 -11
  250. package/dist/chunk-wg6n7txf.js +0 -2
  251. package/dist/chunk-wj4rf7sb.js +0 -2
  252. package/dist/chunk-wrd5me1w.js +0 -33
  253. package/dist/chunk-xbevgwks.js +0 -2
  254. package/dist/chunk-y2k3ynr2.js +0 -2
  255. package/dist/chunk-y51ndrdb.js +0 -2
  256. package/dist/chunk-y9wqzvxt.js +0 -2
  257. package/dist/chunk-yn2d8x8m.js +0 -3
  258. package/dist/chunk-ysmt4jpn.js +0 -2
  259. package/dist/chunk-zmccfvbf.js +0 -2
  260. package/dist/chunk-ztpqxs72.js +0 -2
  261. package/dist/chunk-ztwnn466.js +0 -2
  262. package/dist/chunk-zx7v6a4g.js +0 -40
  263. package/dist/chunk-zx94g4pg.js +0 -2
  264. package/dist/chunk-zze1ez1c.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function ku(e,t={},c){let o=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,i=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,n=e;return n=n.replace(o,(r,s,a,d)=>{let l=p(),y=u(s);return m(l,y,a.trim(),d.trim())}),n=n.replace(i,(r,s,a)=>{let d=p(),l=u(s);return m(d,l,a.trim(),'<div class="stx-async-error">Failed to load component</div>')}),n}function u(e){let t={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},c=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,o;while((o=c.exec(e))!==null){let i=o[1],n=o[2]||o[3],r=o[4],s=o[5];switch(i){case"component":t.component=n||s||"";break;case"timeout":t.timeout=r?parseInt(r,10):30000;break;case"delay":t.delay=r?parseInt(r,10):200;break;case"suspensible":t.suspensible=s==="true";break;case"retries":t.retries=r?parseInt(r,10):0;break;case"loadingComponent":t.loadingComponent=n||s;break;case"errorComponent":t.errorComponent=n||s;break}}return t}function m(e,t,c,o){let{component:i,timeout:n,delay:r,suspensible:s,retries:a}=t;return`
2
+ var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function Td(e,t={},c){let o=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,i=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,n=e;return n=n.replace(o,(r,s,a,d)=>{let l=p(),y=u(s);return m(l,y,a.trim(),d.trim())}),n=n.replace(i,(r,s,a)=>{let d=p(),l=u(s);return m(d,l,a.trim(),'<div class="stx-async-error">Failed to load component</div>')}),n}function u(e){let t={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},c=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,o;while((o=c.exec(e))!==null){let i=o[1],n=o[2]||o[3],r=o[4],s=o[5];switch(i){case"component":t.component=n||s||"";break;case"timeout":t.timeout=r?parseInt(r,10):30000;break;case"delay":t.delay=r?parseInt(r,10):200;break;case"suspensible":t.suspensible=s==="true";break;case"retries":t.retries=r?parseInt(r,10):0;break;case"loadingComponent":t.loadingComponent=n||s;break;case"errorComponent":t.errorComponent=n||s;break}}return t}function m(e,t,c,o){let{component:i,timeout:n,delay:r,suspensible:s,retries:a}=t;return`
3
3
  <div class="stx-async-component" data-async-id="${e}" data-component="${i}" data-status="pending">
4
4
  <div class="stx-async-loading" data-async-loading="${e}">
5
5
  ${c}
@@ -226,7 +226,7 @@ catch (error) {
226
226
  loadComponent();
227
227
  })();
228
228
  </script>
229
- `}function Cu(e){return{__asyncComponent:!0,...typeof e==="function"?{loader:e}:e}}function _u(e){return typeof e==="object"&&e!==null&&"__asyncComponent"in e&&e.__asyncComponent===!0}function Eu(){return`
229
+ `}function $d(e){return{__asyncComponent:!0,...typeof e==="function"?{loader:e}:e}}function Rd(e){return typeof e==="object"&&e!==null&&"__asyncComponent"in e&&e.__asyncComponent===!0}function Ad(){return`
230
230
  /* STX Async Component Styles */
231
231
  .stx-async-component {
232
232
  position: relative;
@@ -300,7 +300,7 @@ catch (error) {
300
300
  background-size: 200% 100%;
301
301
  }
302
302
  }
303
- `}function Tu(){return`
303
+ `}function Pd(){return`
304
304
  // STX Async Component Runtime
305
305
  (function() {
306
306
  if (typeof window === 'undefined') return;
@@ -355,4 +355,4 @@ catch (error) {
355
355
  console.log('[stx] Async component runtime initialized');
356
356
  })();
357
357
  `}
358
- export{ku,Cu,_u,Eu,Tu};
358
+ export{Td,$d,Rd,Ad,Pd};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-6ea6az61.js";import"./chunk-zsgcsqat.js";import"./chunk-x5tjb4y4.js";import"./chunk-2h8ea0we.js";import"./chunk-55zaxb4s.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:t.enterActiveClass||`${e}-enter-active`,enterTo:t.enterToClass||`${e}-enter-to`,leaveFrom:t.leaveClass||`${e}-leave-from`,leaveActive:t.leaveActiveClass||`${e}-leave-active`,leaveTo:t.leaveToClass||`${e}-leave-to`}}function u(e){let t=getComputedStyle(e),o=t.transitionDuration||"0s",n=t.animationDuration||"0s",s=(a)=>{let i=a.match(/^([\d.]+)(s|ms)?$/);if(!i)return 0;let r=parseFloat(i[1]);return(i[2]||"s")==="ms"?r:r*1000};return Math.max(s(o),s(n))}function v(e,t){return new Promise((o)=>{let n=t??u(e);if(n===0){o();return}let s=!1,a=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",i),e.removeEventListener("animationend",i),o()},i=(r)=>{if(r.target===e)a()};e.addEventListener("transitionend",i),e.addEventListener("animationend",i),setTimeout(a,n+50)})}function f(e){e.offsetHeight}async function pu(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.enter:t.duration;if(t.onBeforeEnter?.(e),e.classList.add(n.enterFrom),e.classList.add(n.enterActive),f(e),e.classList.remove(n.enterFrom),e.classList.add(n.enterTo),t.onEnter)await new Promise((a)=>{t.onEnter(e,a)});else await v(e,s);e.classList.remove(n.enterActive),e.classList.remove(n.enterTo),t.onAfterEnter?.(e)}async function fu(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.leave:t.duration;if(t.onBeforeLeave?.(e),e.classList.add(n.leaveFrom),e.classList.add(n.leaveActive),f(e),e.classList.remove(n.leaveFrom),e.classList.add(n.leaveTo),t.onLeave)await new Promise((a)=>{t.onLeave(e,a)});else await v(e,s);e.classList.remove(n.leaveActive),e.classList.remove(n.leaveTo),t.onAfterLeave?.(e)}function gu(e,t={},o){let n=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return e.replace(n,(s,a,i)=>{let r=p(a),l=r.name||"stx",c=r.duration||300,d=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
2
+ function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:t.enterActiveClass||`${e}-enter-active`,enterTo:t.enterToClass||`${e}-enter-to`,leaveFrom:t.leaveClass||`${e}-leave-from`,leaveActive:t.leaveActiveClass||`${e}-leave-active`,leaveTo:t.leaveToClass||`${e}-leave-to`}}function u(e){let t=getComputedStyle(e),o=t.transitionDuration||"0s",n=t.animationDuration||"0s",s=(a)=>{let i=a.match(/^([\d.]+)(s|ms)?$/);if(!i)return 0;let r=parseFloat(i[1]);return(i[2]||"s")==="ms"?r:r*1000};return Math.max(s(o),s(n))}function v(e,t){return new Promise((o)=>{let n=t??u(e);if(n===0){o();return}let s=!1,a=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",i),e.removeEventListener("animationend",i),o()},i=(r)=>{if(r.target===e)a()};e.addEventListener("transitionend",i),e.addEventListener("animationend",i),setTimeout(a,n+50)})}function f(e){e.offsetHeight}async function hd(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.enter:t.duration;if(t.onBeforeEnter?.(e),e.classList.add(n.enterFrom),e.classList.add(n.enterActive),f(e),e.classList.remove(n.enterFrom),e.classList.add(n.enterTo),t.onEnter)await new Promise((a)=>{t.onEnter(e,a)});else await v(e,s);e.classList.remove(n.enterActive),e.classList.remove(n.enterTo),t.onAfterEnter?.(e)}async function yd(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.leave:t.duration;if(t.onBeforeLeave?.(e),e.classList.add(n.leaveFrom),e.classList.add(n.leaveActive),f(e),e.classList.remove(n.leaveFrom),e.classList.add(n.leaveTo),t.onLeave)await new Promise((a)=>{t.onLeave(e,a)});else await v(e,s);e.classList.remove(n.leaveActive),e.classList.remove(n.leaveTo),t.onAfterLeave?.(e)}function bd(e,t={},o){let n=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return e.replace(n,(s,a,i)=>{let r=p(a),l=r.name||"stx",c=r.duration||300,d=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
3
3
  <div
4
4
  class="stx-transition-wrapper"
5
5
  data-transition="${l}"
@@ -41,7 +41,7 @@ function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:
41
41
  });
42
42
  })();
43
43
  </script>
44
- `})}function p(e){let t={},o=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,n;while((n=o.exec(e))!==null){let s=n[1],a=n[2]||n[3]||n[4]||n[5];switch(s){case"name":t.name=a;break;case"duration":t.duration=parseInt(a,10);break;case"mode":t.mode=a;break;case"easing":t.easing=a;break}}return t}function mu(){return`
44
+ `})}function p(e){let t={},o=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,n;while((n=o.exec(e))!==null){let s=n[1],a=n[2]||n[3]||n[4]||n[5];switch(s){case"name":t.name=a;break;case"duration":t.duration=parseInt(a,10);break;case"mode":t.mode=a;break;case"easing":t.easing=a;break}}return t}function vd(){return`
45
45
  /* STX Transition Presets */
46
46
 
47
47
  /* Fade */
@@ -228,7 +228,7 @@ function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:
228
228
  opacity: 1;
229
229
  max-height: 1000px;
230
230
  }
231
- `}function hu(){return`
231
+ `}function wd(){return`
232
232
  // STX Transition Runtime
233
233
  (function() {
234
234
  if (typeof window === 'undefined') return;
@@ -317,5 +317,5 @@ else {
317
317
 
318
318
  console.log('[stx] Transition runtime initialized');
319
319
  })();
320
- `}function yu(e){let t=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return e.replace(t,(o,n,s,a)=>{let i=s||"300",r=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${n}" data-stx-transition-duration="${i}" data-stx-transition-condition="${a}" data-stx-transition-id="${r}"`})}
321
- export{pu,fu,gu,mu,hu,yu};
320
+ `}function xd(e){let t=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return e.replace(t,(o,n,s,a)=>{let i=s||"300",r=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${n}" data-stx-transition-duration="${i}" data-stx-transition-condition="${a}" data-stx-transition-id="${r}"`})}
321
+ export{hd,yd,bd,vd,wd,xd};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Es,jt,bc,gu}from"./chunk-jkaszw24.js";export{Es as generateServiceWorker,gu as generateServiceWorkerAuto,jt as getServiceWorkerFileName,bc as isWorkboxEnabled};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{je,Be,Fe}from"./chunk-6mnwvn9v.js";import{vt,wt,Le,ho,xt,St}from"./chunk-1t0m4pwg.js";import o from"fs";import i from"path";var c=[];function m(a){c=[];for(let e of a.storyFiles)if(c.push({text:e.fileName.toLowerCase(),original:e.fileName,type:"story",storyId:e.id}),c.push({text:e.relativePath.toLowerCase(),original:e.relativePath,type:"story",storyId:e.id}),e.story)for(let t of e.story.variants)c.push({text:t.title.toLowerCase(),original:t.title,type:"story",storyId:e.id,variantId:t.id})}function f(){return JSON.stringify(c)}async function F(a={}){let e=Date.now();vt();let t=await je({mode:"build"});if(!t.config.enabled){Le("Story feature is disabled in config.");return}let n=await xt(t);Be(t,n);let l=St(t.config,n);Fe(t,l),wt(n.length);let d=a.outDir??t.config.outDir,s=i.resolve(t.root,d);await o.promises.mkdir(s,{recursive:!0}),console.log(` Building to ${d}...`);let g=v(t);await o.promises.writeFile(i.join(s,"index.html"),g);let y={files:n.map((r)=>({id:r.id,fileName:r.fileName,relativePath:r.relativePath,treePath:r.treePath})),tree:l};await o.promises.writeFile(i.join(s,"stories.json"),JSON.stringify(y,null,2));let u={theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets};await o.promises.writeFile(i.join(s,"config.json"),JSON.stringify(u,null,2));let p=i.join(s,"stories");await o.promises.mkdir(p,{recursive:!0});for(let r of n){let b=await o.promises.readFile(r.path,"utf-8");await o.promises.writeFile(i.join(p,`${r.id}.stx`),b)}m(t);let h=f();await o.promises.writeFile(i.join(s,"search-index.json"),h);let x=Date.now()-e;ho(n.length,d,x)}function v(a){let{theme:e}=a.config,t=e.title||"STX Story";return`<!DOCTYPE html>
2
+ import{ot,it,at}from"./chunk-jkvr7e91.js";import{Bt,Ft,st,li,zt,Ht}from"./chunk-4yf1w261.js";import o from"fs";import i from"path";var c=[];function m(a){c=[];for(let e of a.storyFiles)if(c.push({text:e.fileName.toLowerCase(),original:e.fileName,type:"story",storyId:e.id}),c.push({text:e.relativePath.toLowerCase(),original:e.relativePath,type:"story",storyId:e.id}),e.story)for(let t of e.story.variants)c.push({text:t.title.toLowerCase(),original:t.title,type:"story",storyId:e.id,variantId:t.id})}function f(){return JSON.stringify(c)}async function F(a={}){let e=Date.now();Bt();let t=await ot({mode:"build"});if(!t.config.enabled){st("Story feature is disabled in config.");return}let n=await zt(t);it(t,n);let l=Ht(t.config,n);at(t,l),Ft(n.length);let d=a.outDir??t.config.outDir,s=i.resolve(t.root,d);await o.promises.mkdir(s,{recursive:!0}),console.log(` Building to ${d}...`);let g=v(t);await o.promises.writeFile(i.join(s,"index.html"),g);let y={files:n.map((r)=>({id:r.id,fileName:r.fileName,relativePath:r.relativePath,treePath:r.treePath})),tree:l};await o.promises.writeFile(i.join(s,"stories.json"),JSON.stringify(y,null,2));let u={theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets};await o.promises.writeFile(i.join(s,"config.json"),JSON.stringify(u,null,2));let p=i.join(s,"stories");await o.promises.mkdir(p,{recursive:!0});for(let r of n){let b=await o.promises.readFile(r.path,"utf-8");await o.promises.writeFile(i.join(p,`${r.id}.stx`),b)}m(t);let h=f();await o.promises.writeFile(i.join(s,"search-index.json"),h);let x=Date.now()-e;li(n.length,d,x)}function v(a){let{theme:e}=a.config,t=e.title||"STX Story";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -159,7 +159,7 @@ else {
159
159
  stxIslands.initIslands();
160
160
  }
161
161
  })();
162
- </script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function Xa(){let e=new Map;return{islands:e,register(t){e.set(t.id,t)},get(t){return e.get(t)},async hydrate(t){let n=e.get(t);if(!n||n.hydrated)return;if(n.hydrated=!0,typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hydrate",{detail:{id:t,component:n.component}}))},async hydrateAll(){let t=Array.from(e.values()).filter((n)=>!n.hydrated).map((n)=>this.hydrate(n.id));await Promise.all(t)}}}function I(e){return`
162
+ </script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function Wc(){let e=new Map;return{islands:e,register(t){e.set(t.id,t)},get(t){return e.get(t)},async hydrate(t){let n=e.get(t);if(!n||n.hydrated)return;if(n.hydrated=!0,typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hydrate",{detail:{id:t,component:n.component}}))},async hydrateAll(){let t=Array.from(e.values()).filter((n)=>!n.hydrated).map((n)=>this.hydrate(n.id));await Promise.all(t)}}}function I(e){return`
163
163
  <script data-hydrate="${e}">
164
164
  (function() {
165
165
  const island = document.querySelector('[data-island="${e}"]');
@@ -311,7 +311,7 @@ else {
311
311
  });
312
312
  })();
313
313
  </script>
314
- `}function Ja(e,t={},n){let r=e,i=!1,d=/@client:(load|idle|visible|media|only|hover|event)/i.test(e);if(r=u(r,"load",t),r=u(r,"idle",t),r=u(r,"visible",t),r=u(r,"media",t),r=M(r),r=u(r,"hover",t),r=u(r,"event",t),i=d&&r!==e,i)r+=`
314
+ `}function qc(e,t={},n){let r=e,i=!1,d=/@client:(load|idle|visible|media|only|hover|event)/i.test(e);if(r=u(r,"load",t),r=u(r,"idle",t),r=u(r,"visible",t),r=u(r,"media",t),r=M(r),r=u(r,"hover",t),r=u(r,"event",t),i=d&&r!==e,i)r+=`
315
315
  `+v();return r}function u(e,t,n){let r=new RegExp(`@client:${t}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return e.replace(r,(i,d,o)=>{let a={strategy:t};if(d)try{let E=d.split(",").map((h)=>h.trim());for(let h of E){let[m,g]=h.split(":").map((p)=>p.trim());if(m&&g){let p=g.replace(/^['"]|['"]$/g,"");a[m]=p}}}catch{}let s=`island-${Math.random().toString(36).substring(2,9)}`,y=b(o.trim()),f=w(o.trim(),n),c=[];if(a.rootMargin)c.push(`data-root-margin="${a.rootMargin}"`);if(a.threshold!==void 0)c.push(`data-threshold="${a.threshold}"`);if(a.media)c.push(`data-media="${a.media}"`);if(a.event)c.push(`data-event="${a.event}"`);if(y)c.push(`data-component="${y}"`);let x=Object.keys(f).length>0?`
316
316
  <script type="application/json" data-island-props="${s}">${JSON.stringify(f)}</script>`:"",l="";switch(t){case"load":l=I(s);break;case"idle":l=L(s,a);break;case"visible":l=C(s,a);break;case"media":l=S(s,a);break;case"hover":l=k(s);break;case"event":l=H(s,a);break}return`
317
317
  <div data-island="${s}"
@@ -342,7 +342,7 @@ else {
342
342
  }
343
343
  })();
344
344
  </script>
345
- `})}function Ya(){return`
345
+ `})}function Gc(){return`
346
346
  /* Island base styles */
347
347
  .stx-island {
348
348
  display: contents;
@@ -383,9 +383,9 @@ else {
383
383
  .stx-island.hydrated {
384
384
  opacity: 1;
385
385
  }
386
- `}function Za(e){if(typeof window>"u")return;let t=document.querySelector(`[data-island="${e}"]`);if(!t||t.classList.contains("hydrated"))return;t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))}function Qa(e){if(typeof window>"u")return;document.querySelectorAll(`[data-strategy="${e}"]:not(.hydrated)`).forEach((n)=>{n.classList.add("hydrated"),n.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function ec(){if(typeof window>"u")return;document.querySelectorAll(".stx-island:not(.hydrated)").forEach((t)=>{t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function tc(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function nc(e){return new Promise((t)=>{if(typeof window>"u"){t();return}let n=document.querySelector(`[data-island="${e}"]`);if(!n){t();return}if(n.classList.contains("hydrated")){t();return}n.addEventListener("stx:hydrated",()=>t(),{once:!0})})}function rc(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function sc(e){let t=e.map((n)=>({id:n.id,component:n.component,strategy:n.options.strategy,props:n.props}));return`
386
+ `}function Kc(e){if(typeof window>"u")return;let t=document.querySelector(`[data-island="${e}"]`);if(!t||t.classList.contains("hydrated"))return;t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))}function Xc(e){if(typeof window>"u")return;document.querySelectorAll(`[data-strategy="${e}"]:not(.hydrated)`).forEach((n)=>{n.classList.add("hydrated"),n.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function Jc(){if(typeof window>"u")return;document.querySelectorAll(".stx-island:not(.hydrated)").forEach((t)=>{t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function Yc(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function Zc(e){return new Promise((t)=>{if(typeof window>"u"){t();return}let n=document.querySelector(`[data-island="${e}"]`);if(!n){t();return}if(n.classList.contains("hydrated")){t();return}n.addEventListener("stx:hydrated",()=>t(),{once:!0})})}function Qc(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function el(e){let t=e.map((n)=>({id:n.id,component:n.component,strategy:n.options.strategy,props:n.props}));return`
387
387
  <script type="application/json" id="stx-island-manifest">
388
388
  ${JSON.stringify(t)}
389
389
  </script>
390
- `}var su={processPartialHydrationDirectives:Ja,processStaticDirectives:rc,generatePartialHydrationCSS:Ya,generateIslandManifest:sc,createIslandRegistry:Xa,hydrateIsland:Za,hydrateByStrategy:Qa,hydrateAll:ec,isHydrated:tc,onHydrated:nc};
391
- export{Xa,Ja,Ya,Za,Qa,ec,tc,nc,rc,sc,su};
390
+ `}var ed={processPartialHydrationDirectives:qc,processStaticDirectives:Qc,generatePartialHydrationCSS:Gc,generateIslandManifest:el,createIslandRegistry:Wc,hydrateIsland:Kc,hydrateByStrategy:Xc,hydrateAll:Jc,isHydrated:Yc,onHydrated:Zc};
391
+ export{Wc,qc,Gc,Kc,Xc,Jc,Yc,Zc,Qc,el,ed};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xc,Sc}from"./chunk-xm2mee4a.js";import"./chunk-0h8tg21j.js";import"./chunk-wjt0kej9.js";import"./chunk-rjh2jwxx.js";import"./chunk-yq021b3r.js";import"./chunk-j393gsfd.js";import"./chunk-zqtbtqbq.js";import"./chunk-8p9kpfk8.js";import{_i}from"./chunk-06w0z1cm.js";import"./chunk-jxda11cg.js";import"./chunk-2jh21f1n.js";import"./chunk-9txn4rvb.js";import"./chunk-rcadtv3x.js";import"./chunk-sgptbhrc.js";import"./chunk-0jhdrgpr.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-6ea6az61.js";import"./chunk-tre98h62.js";import"./chunk-481d4kr9.js";import"./chunk-dgb4z4kw.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-aprhqxky.js";import"./chunk-kgfgb971.js";import"./chunk-nrvwejdw.js";import"./chunk-9121nkpj.js";import"./chunk-wq6j2h32.js";import"./chunk-fg3jw17w.js";import"./chunk-qm4672dj.js";import"./chunk-c1dkh0es.js";import"./chunk-6ajahb2x.js";import"./chunk-f46ht5kq.js";import"./chunk-88z4wkrj.js";import"./chunk-v2x9vzgw.js";import{Ee,s}from"./chunk-pbtkbe48.js";import"./chunk-qfe7ps3v.js";import"./chunk-prf164ct.js";import"./chunk-nj1t4g3a.js";import"./chunk-radggg3p.js";import"./chunk-3zyjqvsq.js";import"./chunk-ymymwzt5.js";import"./chunk-0vkawews.js";import{me}from"./chunk-r1r6311d.js";import"./chunk-ye8tgmd3.js";import{Xn,Jn}from"./chunk-pxs7sgnp.js";import{qr,N,i}from"./chunk-3q163st5.js";import"./chunk-e87xa4r3.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-p44kmbdg.js";import"./chunk-gv793yqq.js";import{f,Oe}from"./chunk-zsgcsqat.js";import"./chunk-x5tjb4y4.js";import"./chunk-2h8ea0we.js";import"./chunk-55zaxb4s.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";export{qr as buildWebComponents,Jn as cacheTemplate,Xn as checkCache,_i as classifyAllScripts,xc as createMiddleware,Sc as createRoute,N as defaultConfig,f as extractVariables,me as injectRouterScript,i as loadStxConfig,Oe as processClientScript,s as processDirectives,Ee as readMarkdownFile};
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ import{Fo,vs,l,d,C,et,u,ws,t,a,w}from"./chunk-55zaxb4s.js";import{he,Et,It,K,k}from"./chunk-zsgcsqat.js";import{ee}from"./chunk-ymymwzt5.js";import{Ur}from"./chunk-ye8tgmd3.js";var ae=1000,ue=!1;function fe(n,r){let o=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",s=0,i;while((i=o.exec(n))!==null){let p=i.index+i[0].length,y=i.index+i[0].indexOf("("),m=w(n,"(",")",y);if(m===-1)continue;let c=n.slice(p,m).trim();if(!c)continue;if(!Object.keys(r).some((b)=>new RegExp(`(?:^|[^\\w$.])${b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(c)))continue;let g;try{let b=C(c,r);if(!b||typeof b!=="object")continue;g=JSON.stringify(b)}catch{continue}e+=n.slice(s,p)+g,s=m,o.lastIndex=m}return s===0?n:e+n.slice(s)}function ge(n,r){let o=/@component\s*\(/g,e=n,s,i=[];while((s=o.exec(e))!==null){let p=s.index,y=p+s[0].length-1,m=1,c=y+1;while(c<e.length&&m>0){if(e[c]==="(")m++;else if(e[c]===")"){if(m--,m===0)break}c++}if(m!==0)continue;let f=e.substring(y+1,c),g=c+1,b=f.match(/^\s*['"]([^'"]+)['"]/);if(!b)continue;let x=b[1],h=f.slice(b[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let I=h.slice(O[0].length).trim();if(!I)continue;try{let P=C(I,r),S=JSON.stringify(P),E=`@component('${x}', ${S})`;i.push({start:p,end:g,replacement:E})}catch{continue}}for(let p=i.length-1;p>=0;p--){let{start:y,end:m,replacement:c}=i[p];e=e.substring(0,y)+c+e.substring(m)}return e}function te(n,r,o){let e=n,s=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=s.exec(e))!==null){let p=i.index,y=p+i[0].length-1,m=1,c=y+1,f=null,g=!1;while(c<e.length&&m>0){let h=e[c];if(g){g=!1,c++;continue}if(h==="\\"&&f){g=!0,c++;continue}if(f){if(h===f)f=null;c++;continue}if(h==='"'||h==="'"||h==="`"){f=h,c++;continue}if(h==="(")m++;else if(h===")"){if(m--,m===0)break}c++}if(m!==0)break;let b=e.substring(y+1,c),x=o(b);e=e.substring(0,p)+x+e.substring(c+1)}return e}function pe(n,r){let o=n;return o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,s)=>{if(s in r)return`:${s}="${s}"`;return e}),o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,s,i)=>{try{let p=Object.keys(r),y=Object.values(r);Fo(i);let c=u(i,p)(...y),f=JSON.stringify(c);if(f===void 0){if(!et(i).some((x)=>!(x in r)))return"";return e}let g=Buffer.from(f,"utf8").toString("base64");return`__stx_${s}="${g}"`}catch(p){return e}}),o}var Y="<!--__STX_BREAK__-->",G="<!--__STX_CONTINUE__-->";function se(n,r){let o=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",s=0;for(let i=o.exec(n);i;i=o.exec(n)){if(!i[1]){let c=i[0].length===3&&i[0]==="{{{"?3:2,f=i[0]==="{!!"?n.indexOf("!!}",o.lastIndex):he(n,i.index,c);if(f<0)break;o.lastIndex=f+(i[0]==="{!!"?3:c);continue}let p=o.lastIndex,y=!0,m=/^\s*\(/.exec(n.slice(p));if(m){let c=p+m[0].length-1,f=w(n,"(",")",c);if(f<0)break;p=f+1;try{let g=`!!(${n.slice(c+1,f).trim()})`;y=d(g)?Boolean(u(g,Object.keys(r))(...Object.values(r))):Boolean(l(g,r))}catch{y=!1}}if(e+=n.slice(s,i.index),y)return e+(i[1]==="break"?Y:G);s=p,o.lastIndex=p}return e+n.slice(s)}function oe(n){let r=(s)=>s.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),o="",e=0;return It(n,(s,i,p)=>(o+=ne(r(n.slice(e,p))),o+=`\${__stxRenderLoopValue(${p}, (${i}), ${s.length})}`,e=p+s.length,s)),o+ne(r(n.slice(e)))}function ie(n,r,o,e){return K(n,r,o==null?"":String(o),!1,e)}function ne(n){let r=n;return r=te(r,"@break",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { break; } result += \``}),r=te(r,"@continue",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function de(n){let r=/@forelse\s*\(/g,o,e=[],s=/@foreach\s*\(/g,i=/@endforeach/g,p;while((p=s.exec(n))!==null)e.push({pos:p.index,delta:1});while((p=i.exec(n))!==null)e.push({pos:p.index,delta:-1});e.sort((f,g)=>f.pos-g.pos);let y=[],m=0;for(let f of e)m+=f.delta,y.push({pos:f.pos,depth:m});function c(f){let g=0,b=y.length-1,x=0;while(g<=b){let h=g+b>>1;if(y[h].pos<=f)x=y[h].depth,g=h+1;else b=h-1}return x}while((o=r.exec(n))!==null){if(c(o.index)>0)continue;let f=o.index,g=o.index+o[0].length-1,b=1,x=g+1,h=-1;while(x<n.length&&b>0){if(n[x]==="(")b++;else if(n[x]===")"){if(b--,b===0){h=x;break}}x++}if(h===-1)continue;let O=n.substring(g+1,h),I=Et(O);if(!I)continue;let{arrayExpr:P,itemVar:S}=I,E=h+1,N=1,U=E,F=/@forelse\s*\(/g,V=/@endforelse/g,_=-1;while(N>0&&U<n.length){F.lastIndex=U,V.lastIndex=U;let R=F.exec(n),T=V.exec(n);if(!T)break;if(R&&R.index<T.index)N++,U=R.index+R[0].length;else{if(N--,N===0){_=T.index;break}U=T.index+11}}if(_===-1)continue;let j=n.substring(E,_),z=_+11,M=-1,W=0,A=0;while(A<j.length){let R=j.indexOf("@",A);if(R===-1)break;let T=j.substring(R);if(/^@forelse\s*\(/.test(T))W++,A=R+1;else if(T.startsWith("@endforelse"))W--,A=R+11;else if(W===0&&T.startsWith("@empty")){if(j.length<=R+6||!/[a-z]/i.test(j[R+6])){M=R;break}A=R+1}else A=R+1}if(M===-1)continue;return{start:f,end:z,arrayExpr:P,itemVar:S,foreachContent:j.substring(0,M),emptyContent:j.substring(M+6)}}return null}function re(n,r){let o=n;while(!0){let e=de(o);if(!e)break;let{start:s,end:i,arrayExpr:p,itemVar:y,foreachContent:m,emptyContent:c}=e;try{let f;if(d(p))f=u(p,Object.keys(r))(...Object.values(r));else f=l(p,r);let g;if(!Array.isArray(f)||f.length===0)g=c;else g=`@foreach (${p} as ${y})${m}@endforeach`;o=o.substring(0,s)+g+o.substring(i)}catch(f){let g=f instanceof Error?f.message:String(f),b=a("Forelse",`Error in @forelse(${p} as ${y}): ${g}`,t.EVALUATION_ERROR);o=o.substring(0,s)+b+o.substring(i)}}return o}var ce="<!--stx:foreach-not-iterable:",me=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function be(n,r){return`${ce}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function xe(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Nr(n){if(!n.includes(ce))return n;return n.replace(me,(r,o,e)=>(xe(decodeURIComponent(o),decodeURIComponent(e)),""))}function qn(n,r,o,e,s=!1){let i=n;i=re(i,r);function p(c){let f=/@foreach\s*\(/g,g;while((g=f.exec(c))!==null){let b=g.index,x=g.index+g[0].length-1,h=1,O=x+1,I=-1;while(O<c.length&&h>0){if(c[O]==="(")h++;else if(c[O]===")"){if(h--,h===0){I=O;break}}O++}if(I===-1)continue;let P=c.substring(x+1,I),S=Et(P);if(!S)continue;let E=b,{arrayExpr:N,itemVar:U}=S,F=I+1,V=1,_=F,j=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&_<c.length){j.lastIndex=_,z.lastIndex=_;let M=j.exec(c),W=z.exec(c);if(!W)break;if(M&&M.index<W.index)V++,_=M.index+M[0].length;else{if(V--,V===0){let A=c.substring(F,W.index),R=W.index+11;return{start:E,end:R,arrayExpr:N,itemVar:U,content:A}}_=W.index+11}}}return null}function y(c,f){let g=c;while(!0){let b=p(g);if(!b)break;let{start:x,end:h,arrayExpr:O,itemVar:I,content:P}=b;try{let S=O.trim(),E;if(d(S))E=u(S,Object.keys(f))(...Object.values(f));else E=l(S,f);let N=!1;if(!Array.isArray(E))if(E instanceof Map)E=Array.from(E),N=!0;else if(E instanceof Set)E=Array.from(E);else if(typeof E==="string")E=Array.from(E);else if(E&&typeof E==="object"&&!(E instanceof Date)&&!(E instanceof RegExp))E=Object.entries(E),N=!0;else{let A=be(S,o)+a("Foreach",`Error in @foreach: ${S} is not iterable`,t.TYPE_ERROR);g=g.substring(0,x)+A+g.substring(h);continue}let U=e?.loops?.useAltLoopVariable??ue,F=I.trim(),V=null,_,j=!1;if(F.includes("=>")){let A=F.split("=>").map((R)=>R.trim());if(A.length===2&&A[0]&&A[1])V=A[0],_=A[1];else _=F}else if(!F.startsWith("[")&&!F.startsWith("{")&&F.includes(",")){let A=F.split(",").map((R)=>R.trim());if(A.length===2&&A[0]&&A[1])_=A[0],V=A[1],j=!0;else _=F}else _=F;let z="",M=E,W=f[vs]??new WeakMap;for(let A=0;A<M.length;A++){let R=M[A],T={index:A,iteration:A+1,first:A===0,last:A===M.length-1,count:M.length},L={...f,loop:T,$loop:T,[vs]:W};if(_.startsWith("[")&&_.endsWith("]")){let J=_.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(R))J.forEach((B,D)=>{if(B)L[B]=R[D]});else L[_]=R}else if(_.startsWith("{")&&_.endsWith("}")){let J=_.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(R!==null&&typeof R==="object")J.forEach((B)=>{let D=B.indexOf(":"),q=(D===-1?B:B.slice(0,D)).trim(),Q=D===-1?q:B.slice(D+1).trim();if(q&&Q)L[Q]=R[q]});else L[_]=R}else L[_]=R;if(V)if(!j&&N&&Array.isArray(R)&&R.length===2)L[V]=R[0],L[_]=R[1];else L[V]=A;let v=re(P,L);v=qn(v,L,o,e,!0),v=ee(v,L,o),v=se(v,L);let Z=v.indexOf(Y),H=v.indexOf(G),X=Z<0?H:H<0?Z:Math.min(Z,H);if(X>=0)v=v.slice(0,X);if(v=k(v,L,o),v=pe(v,L),v=ge(v,L),v=fe(v,L),z+=v,X>=0&&X===Z)break}g=g.substring(0,x)+z+g.substring(h)}catch(S){let E=a("Foreach",`Error in @foreach(${O.trim()} as ${I.trim()}): ${S instanceof Error?S.message:String(S)}`,t.EVALUATION_ERROR);g=g.substring(0,x)+E+g.substring(h)}}return g}i=y(i,r),i=ye(i,r,o,e);let m=e?.loops?.maxWhileIterations??ae;return i=Re(i,r,m),s?i:Nr(i)}function xl(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function le(n){return ws(n)}function ye(n,r,o,e){let s=n,i=!0;while(i){i=!1;let p=s.match(/@for\s*\(/);if(!p||p.index===void 0)break;let y=p.index,m=y+p[0].length-1,c=w(s,"(",")",m);if(c===-1)break;let f=xl(s.slice(m+1,c)),g=c+1,b=Ur(s.slice(y),"for","endfor");if(b.length===0)break;let x=b[0].content,h=y+b[0].end;if(!le(f)){let O=a("For",`Unsafe expression in @for: ${f}`,t.UNSAFE_EXPRESSION);s=s.substring(0,y)+O+s.substring(h),i=!0;continue}try{let O=Ee(f),I=/@(?:for|foreach|if|unless)\s*\(/.test(x);if(O.length>0&&I){let F=$e({forExpr:f,content:x,iterVarNames:O,context:r,filePath:o,options:e});s=s.substring(0,y)+F+s.substring(h),i=!0;continue}let P=Object.keys(r),S=Object.values(r),E=oe(x),U=Function(...P,"__stxRenderLoopValue",`
3
+ let result = '';
4
+ for (${f}) {
5
+ result += \`${E}\`;
6
+ }
7
+ return result;
8
+ `)(...S,(F,V,_)=>ie(x,F,V,_));s=s.substring(0,y)+U+s.substring(h),i=!0}catch(O){let I=a("For",`Error in @for(${f}): ${O instanceof Error?O.message:String(O)}`,t.EVALUATION_ERROR);s=s.substring(0,y)+I+s.substring(h),i=!0}}return s}function Ee(n){let r=n.trim(),o=r.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(o){let i=o[1];return i.slice(1,-1).split(",").map((y)=>{let m=y.trim();if(!m)return"";let c=m.indexOf(":");if(c>=0&&i.startsWith("{")){let b=m.slice(c+1).trim(),x=b.indexOf("=");return(x>=0?b.slice(0,x):b).trim()}let f=m.indexOf("="),g=(f>=0?m.slice(0,f):m).trim();return/^[A-Za-z_$][\w$]*$/.test(g)?g:""}).filter(Boolean)}let e=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(e)return[e[1]];let s=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(s)return[s[1]];return[]}function $e(n){let{forExpr:r,content:o,iterVarNames:e,context:s,filePath:i,options:p}=n,y=Object.keys(s),m=Object.values(s),c=i??"inline.stx",f="";return Function(...y,"__renderIteration",`
9
+ for (${r}) {
10
+ if (!__renderIteration([${e.join(", ")}])) break;
11
+ }
12
+ `)(...m,(b)=>{let x={...s};e.forEach((S,E)=>{x[S]=b[E]});let h=qn(o,x,c,p,!0);h=ee(h,x,c),h=se(h,x);let O=h.indexOf(Y),I=h.indexOf(G),P=O<0?I:I<0?O:Math.min(O,I);if(P>=0)h=h.slice(0,P);return f+=k(h,x,c),P<0||P!==O}),f}function Re(n,r,o){let e=n,s=!0;while(s){s=!1;let i=e.match(/@while\s*\(/);if(!i||i.index===void 0)break;let p=i.index,y=p+i[0].length-1,m=w(e,"(",")",y);if(m===-1)break;let c=e.slice(y+1,m),f=Ur(e.slice(p),"while","endwhile");if(f.length===0)break;let g=f[0].content,b=p+f[0].end;if(!le(c)){let x=a("While",`Unsafe expression in @while: ${c}`,t.UNSAFE_EXPRESSION);e=e.substring(0,p)+x+e.substring(b),s=!0;continue}try{let x=Object.keys(r),h=Object.values(r),O=oe(g),P=Function(...x,"__stxRenderLoopValue",`
13
+ let result = '';
14
+ let maxIterations = ${o}; // Configurable safety limit
15
+ let counter = 0;
16
+ while (${c} && counter < maxIterations) {
17
+ counter++;
18
+ result += \`${O}\`;
19
+ }
20
+ if (counter > maxIterations) {
21
+ result += '<!-- [While Error [1104]]: Maximum iterations (${o}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
22
+ }
23
+ return result;
24
+ `)(...h,(S,E,N)=>ie(g,S,E,N));e=e.substring(0,p)+P+e.substring(b),s=!0}catch(x){let h=a("While",`Error in @while(${c}): ${x instanceof Error?x.message:String(x)}`,t.EVALUATION_ERROR);e=e.substring(0,p)+h+e.substring(b),s=!0}}return e}
25
+ export{Nr,qn,xl};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{qe}from"./chunk-kvn23sz5.js";function sr(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=qe(e),i=`
2
+ import{jt}from"./chunk-jkaszw24.js";function Cs(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=jt(e),i=`
3
3
  <!-- stx PWA Meta Tags -->
4
4
  <link rel="manifest" href="/manifest.json">
5
5
  <meta name="theme-color" content="${a(r?.themeColor||"#000000")}">
@@ -43,12 +43,12 @@ if ('serviceWorker' in navigator) {
43
43
  });
44
44
  }
45
45
  </script>
46
- <!-- End stx PWA -->`,i}function ds(e,n){let r=n.pwa;if(!r?.enabled||r.autoInject===!1)return e;if(e.includes("<!-- stx PWA Meta Tags -->"))return e;if(!e.includes("</head>")){let o=e.lastIndexOf("</body>");if(o!==-1){let i=sr(n);return e.slice(0,o)+i+`
47
- `+e.slice(o)}return e+sr(n)}let t=sr(n);return e.replace("</head>",`${t}
48
- </head>`)}function mc(e){if(!e.pwa?.enabled)return"";return`<script>
46
+ <!-- End stx PWA -->`,i}function Xo(e,n){let r=n.pwa;if(!r?.enabled||r.autoInject===!1)return e;if(e.includes("<!-- stx PWA Meta Tags -->"))return e;if(!e.includes("</head>")){let o=e.lastIndexOf("</body>");if(o!==-1){let i=Cs(n);return e.slice(0,o)+i+`
47
+ `+e.slice(o)}return e+Cs(n)}let t=Cs(n);return e.replace("</head>",`${t}
48
+ </head>`)}function du(e){if(!e.pwa?.enabled)return"";return`<script>
49
49
  if ('serviceWorker' in navigator) {
50
50
  window.addEventListener('load', function() {
51
- navigator.serviceWorker.register('/${qe(e)}')
51
+ navigator.serviceWorker.register('/${jt(e)}')
52
52
  .then(function(registration) {
53
53
  console.log('[PWA] Service Worker registered:', registration.scope);
54
54
  })
@@ -57,5 +57,5 @@ if ('serviceWorker' in navigator) {
57
57
  });
58
58
  });
59
59
  }
60
- </script>`}function hc(){return'<link rel="manifest" href="/manifest.json">'}function yc(e){return`<meta name="theme-color" content="${a(e)}">`}function a(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}
61
- export{sr,ds,mc,hc,yc};
60
+ </script>`}function pu(){return'<link rel="manifest" href="/manifest.json">'}function fu(e){return`<meta name="theme-color" content="${a(e)}">`}function a(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}
61
+ export{Cs,Xo,du,pu,fu};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var d=0;function l(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function Jl(e,t={},n){let i=/@keepAlive(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@endkeepAlive/gi;return e.replace(i,(a,c,o)=>{let s=l(),r=u(c||"");return p(s,o.trim(),r)})}function u(e){let t={max:10},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,i;while((i=n.exec(e))!==null){let a=i[1],c=i[2]||i[3],o=i[4];switch(a){case"max":t.max=o?parseInt(o,10):10;break;case"include":t.include=c;break;case"exclude":t.exclude=c;break;case"id":t.id=c;break}}return t}function p(e,t,n){let{max:i,include:a,exclude:c}=n,o=n.id||e;return`
2
+ var d=0;function l(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function Id(e,t={},n){let i=/@keepAlive(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@endkeepAlive/gi;return e.replace(i,(a,c,o)=>{let s=l(),r=u(c||"");return p(s,o.trim(),r)})}function u(e){let t={max:10},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,i;while((i=n.exec(e))!==null){let a=i[1],c=i[2]||i[3],o=i[4];switch(a){case"max":t.max=o?parseInt(o,10):10;break;case"include":t.include=c;break;case"exclude":t.exclude=c;break;case"id":t.id=c;break}}return t}function p(e,t,n){let{max:i,include:a,exclude:c}=n,o=n.id||e;return`
3
3
  <div class="stx-keep-alive" data-keep-alive-id="${e}" data-custom-id="${o}">
4
4
  <div class="stx-keep-alive-content" data-keep-alive-content="${e}">
5
5
  ${t}
@@ -286,7 +286,7 @@ else {
286
286
  });
287
287
  })();
288
288
  </script>
289
- `}function Yl(e={}){return{id:e.id||l(),cache:new Map,max:e.max||10,include:e.include?e.include.split(",").map((n)=>n.trim()):null,exclude:e.exclude?e.exclude.split(",").map((n)=>n.trim()):null}}function Zl(e,t){if(t.exclude&&t.exclude.includes(e))return!1;if(t.include&&!t.include.includes(e))return!1;return!0}function Ql(){return`
289
+ `}function Od(e={}){return{id:e.id||l(),cache:new Map,max:e.max||10,include:e.include?e.include.split(",").map((n)=>n.trim()):null,exclude:e.exclude?e.exclude.split(",").map((n)=>n.trim()):null}}function Nd(e,t){if(t.exclude&&t.exclude.includes(e))return!1;if(t.include&&!t.include.includes(e))return!1;return!0}function Dd(){return`
290
290
  /* STX Keep-Alive Styles */
291
291
  .stx-keep-alive {
292
292
  position: relative;
@@ -311,7 +311,7 @@ else {
311
311
  .stx-keep-alive-content > [data-activated] {
312
312
  opacity: 1;
313
313
  }
314
- `}function eu(){return`
314
+ `}function Md(){return`
315
315
  // STX Keep-Alive Runtime
316
316
  (function() {
317
317
  if (typeof window === 'undefined') return;
@@ -347,5 +347,5 @@ else {
347
347
 
348
348
  console.log('[stx] Keep-alive runtime initialized');
349
349
  })();
350
- `}function tu(e){if(typeof document<"u")document.addEventListener("stx:activated",(t)=>{e(t.detail)})}function nu(e){if(typeof document<"u")document.addEventListener("stx:deactivated",(t)=>{e(t.detail)})}
351
- export{Jl,Yl,Zl,Ql,eu,tu,nu};
350
+ `}function Ld(e){if(typeof document<"u")document.addEventListener("stx:activated",(t)=>{e(t.detail)})}function jd(e){if(typeof document<"u")document.addEventListener("stx:deactivated",(t)=>{e(t.detail)})}
351
+ export{Id,Od,Nd,Dd,Md,Ld,jd};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{je,Be,Fe}from"./chunk-6mnwvn9v.js";import"./chunk-r2seygb5.js";import"./chunk-ahyq08mp.js";import{u}from"./chunk-srmm69d4.js";import"./chunk-zx7v6a4g.js";import"./chunk-gvr10eqb.js";import"./chunk-qa625vwc.js";import"./chunk-d67qvrzc.js";import"./chunk-cf6d5kgb.js";import"./chunk-apeyn69a.js";import"./chunk-a0ygyftk.js";import"./chunk-fb17t651.js";import"./chunk-pvfx0dgz.js";import{vt,Lr,wt,go,Le,mo,jr,xt,yo,St}from"./chunk-1t0m4pwg.js";import"./chunk-2etamr31.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{mo("Config file changed, restarting...");try{await e.onChange()}catch(p){Le(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:dt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function dt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{ot,it,at}from"./chunk-jkvr7e91.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{f}from"./chunk-zsgcsqat.js";import"./chunk-55zaxb4s.js";import"./chunk-2h8ea0we.js";import"./chunk-x5tjb4y4.js";import{Bt,$s,Ft,ai,st,ci,Rs,zt,ui,Ht}from"./chunk-4yf1w261.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ci("Config file changed, restarting...");try{await e.onChange()}catch(p){st(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var ct=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,ct),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -223,7 +223,7 @@ else {
223
223
  }
224
224
  })();
225
225
  </script>
226
- `}var L=[{key:"k",modifiers:["meta"],description:"Open search",category:"Navigation",action:"openSearch"},{key:"ArrowUp",description:"Previous story",category:"Navigation",action:"prevStory"},{key:"ArrowDown",description:"Next story",category:"Navigation",action:"nextStory"},{key:"ArrowLeft",description:"Previous variant",category:"Navigation",action:"prevVariant"},{key:"ArrowRight",description:"Next variant",category:"Navigation",action:"nextVariant"},{key:"Enter",description:"Select story",category:"Navigation",action:"selectStory"},{key:"Escape",description:"Close panel/modal",category:"Navigation",action:"closePanel"},{key:"d",description:"Toggle dark mode",category:"View",action:"toggleDarkMode"},{key:"f",description:"Toggle fullscreen",category:"View",action:"toggleFullscreen"},{key:"s",description:"Toggle sidebar",category:"View",action:"toggleSidebar"},{key:"a",description:"Toggle addons panel",category:"View",action:"toggleAddons"},{key:"z",description:"Zoom in",category:"View",action:"zoomIn"},{key:"x",description:"Zoom out",category:"View",action:"zoomOut"},{key:"0",description:"Reset zoom",category:"View",action:"resetZoom"},{key:"r",description:"Reload story",category:"Actions",action:"reloadStory"},{key:"c",description:"Copy story code",category:"Actions",action:"copyCode"},{key:"p",description:"Open props panel",category:"Actions",action:"openProps"},{key:"b",description:"Toggle bookmark",category:"Actions",action:"toggleBookmark"},{key:"t",description:"Run tests",category:"Actions",action:"runTests"},{key:"?",description:"Show shortcuts",category:"Help",action:"showShortcuts"}];function pt(t){let e=[];if(t.modifiers)for(let s of t.modifiers)switch(s){case"meta":e.push("\u2318");break;case"ctrl":e.push("Ctrl");break;case"alt":e.push("Alt");break;case"shift":e.push("\u21E7");break}let r=t.key;switch(r){case"ArrowUp":r="\u2191";break;case"ArrowDown":r="\u2193";break;case"ArrowLeft":r="\u2190";break;case"ArrowRight":r="\u2192";break;case"Enter":r="\u21B5";break;case"Escape":r="Esc";break;default:r=r.toUpperCase()}return e.push(r),e.join(" + ")}function D(t=L){let e=new Map;for(let s of t){let o=e.get(s.category)||[];o.push(s),e.set(s.category,o)}return`
226
+ `}var L=[{key:"k",modifiers:["meta"],description:"Open search",category:"Navigation",action:"openSearch"},{key:"ArrowUp",description:"Previous story",category:"Navigation",action:"prevStory"},{key:"ArrowDown",description:"Next story",category:"Navigation",action:"nextStory"},{key:"ArrowLeft",description:"Previous variant",category:"Navigation",action:"prevVariant"},{key:"ArrowRight",description:"Next variant",category:"Navigation",action:"nextVariant"},{key:"Enter",description:"Select story",category:"Navigation",action:"selectStory"},{key:"Escape",description:"Close panel/modal",category:"Navigation",action:"closePanel"},{key:"d",description:"Toggle dark mode",category:"View",action:"toggleDarkMode"},{key:"f",description:"Toggle fullscreen",category:"View",action:"toggleFullscreen"},{key:"s",description:"Toggle sidebar",category:"View",action:"toggleSidebar"},{key:"a",description:"Toggle addons panel",category:"View",action:"toggleAddons"},{key:"z",description:"Zoom in",category:"View",action:"zoomIn"},{key:"x",description:"Zoom out",category:"View",action:"zoomOut"},{key:"0",description:"Reset zoom",category:"View",action:"resetZoom"},{key:"r",description:"Reload story",category:"Actions",action:"reloadStory"},{key:"c",description:"Copy story code",category:"Actions",action:"copyCode"},{key:"p",description:"Open props panel",category:"Actions",action:"openProps"},{key:"b",description:"Toggle bookmark",category:"Actions",action:"toggleBookmark"},{key:"t",description:"Run tests",category:"Actions",action:"runTests"},{key:"?",description:"Show shortcuts",category:"Help",action:"showShortcuts"}];function gt(t){let e=[];if(t.modifiers)for(let s of t.modifiers)switch(s){case"meta":e.push("\u2318");break;case"ctrl":e.push("Ctrl");break;case"alt":e.push("Alt");break;case"shift":e.push("\u21E7");break}let r=t.key;switch(r){case"ArrowUp":r="\u2191";break;case"ArrowDown":r="\u2193";break;case"ArrowLeft":r="\u2190";break;case"ArrowRight":r="\u2192";break;case"Enter":r="\u21B5";break;case"Escape":r="Esc";break;default:r=r.toUpperCase()}return e.push(r),e.join(" + ")}function D(t=L){let e=new Map;for(let s of t){let o=e.get(s.category)||[];o.push(s),e.set(s.category,o)}return`
227
227
  <div class="shortcuts-modal" id="shortcuts-modal" style="display: none;">
228
228
  <div class="shortcuts-backdrop" onclick="closeShortcutsModal()"></div>
229
229
  <div class="shortcuts-content">
@@ -239,7 +239,7 @@ else {
239
239
  ${o.map((a)=>`
240
240
  <div class="shortcut-item">
241
241
  <span class="shortcut-desc">${a.description}</span>
242
- <kbd class="shortcut-key">${pt(a)}</kbd>
242
+ <kbd class="shortcut-key">${gt(a)}</kbd>
243
243
  </div>
244
244
  `).join("")}
245
245
  </div>
@@ -487,7 +487,7 @@ else {
487
487
  window.__stxShortcuts.init();
488
488
  }
489
489
  </script>
490
- `}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var Dt=new J;function G(){return`
490
+ `}class J{metrics=new Map;maxHistorySize=100;enabled=!0;setEnabled(t){this.enabled=t}recordRender(t,e,r,s){if(!this.enabled)return;let o=this.metrics.get(t);if(!o)o={componentId:t,componentName:e,renderCount:0,totalRenderTime:0,avgRenderTime:0,minRenderTime:1/0,maxRenderTime:0,lastRenderTime:0,history:[]},this.metrics.set(t,o);o.renderCount++,o.totalRenderTime+=r,o.avgRenderTime=o.totalRenderTime/o.renderCount,o.minRenderTime=Math.min(o.minRenderTime,r),o.maxRenderTime=Math.max(o.maxRenderTime,r),o.lastRenderTime=r;let a=this.getMemoryUsage();if(a!==void 0)o.memoryUsage=a;if(o.history.push({timestamp:Date.now(),duration:r,props:s,memory:a}),o.history.length>this.maxHistorySize)o.history=o.history.slice(-this.maxHistorySize)}getMetrics(t){return this.metrics.get(t)}getAllMetrics(){return Array.from(this.metrics.values())}getSlowestComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.avgRenderTime-e.avgRenderTime).slice(0,t)}getMostRenderedComponents(t=10){return this.getAllMetrics().sort((e,r)=>r.renderCount-e.renderCount).slice(0,t)}clear(){this.metrics.clear()}clearComponent(t){this.metrics.delete(t)}getMemoryUsage(){if(typeof performance<"u"&&"memory"in performance)return performance.memory?.usedJSHeapSize;return}exportMetrics(){return JSON.stringify({timestamp:Date.now(),metrics:this.getAllMetrics()},null,2)}createTimer(t,e){return new X(this,t,e)}}class X{profiler;componentId;componentName;startTime;props;constructor(t,e,r){this.profiler=t;this.componentId=e;this.componentName=r;this.startTime=performance.now()}setProps(t){return this.props=t,this}end(){let t=performance.now()-this.startTime;return this.profiler.recordRender(this.componentId,this.componentName,t,this.props),t}}var Xt=new J;function G(){return`
491
491
  <script>
492
492
  window.__stxPerformance = {
493
493
  metrics: new Map(),
@@ -556,9 +556,9 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ut(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,mt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-1vrqmdfe.js"),p={},g=h(n);if(g)try{await u(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function gt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await u(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await gt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return ft(t,a.source,c);return b(t,e.path,{props:c})}async function ft(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-1vrqmdfe.js"),c={...r},n=h(e);if(n)try{await u(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-zyqs6a3p.js"),p={},u=h(n);if(u)try{await f(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await f(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-zyqs6a3p.js"),c={...r},n=h(e);if(n)try{await f(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
- `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await xt(t);Be(t,r);let s=St(t.config,r);Fe(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return yt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return ht(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=yo(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await xt(t);Be(t,m);let f=St(t.config,m);if(Fe(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function yt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,g,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function ht(t,e,r){let s=bt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function bt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
561
+ `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await zt(t);it(t,r);let s=Ht(t.config,r);at(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return xt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,g,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=ui(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);it(t,m);let g=Ht(t.config,m);if(at(t,g),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
563
563
  <head>
564
564
  <meta charset="UTF-8">
@@ -1276,5 +1276,5 @@ else {
1276
1276
  <style>${W()}</style>
1277
1277
  ${D()}
1278
1278
  </body>
1279
- </html>`}import kt from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await kt.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){vt();let e=await je({mode:"dev"});if(!e.config.enabled){Le("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),wt(e.storyFiles.length),Lr(s.url),jr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await je({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
1280
- `),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":jr();break;case"o":try{let{exec:p}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${g} ${s.url}`)}catch{go("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),vt(),wt(e.storyFiles.length),Lr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
1279
+ </html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function nt(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Bt();let e=await ot({mode:"dev"});if(!e.config.enabled){st("Story feature is disabled in config.");return}await nt(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ft(e.storyFiles.length),$s(s.url),Rs()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await ot({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
1280
+ `),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":Rs();break;case"o":try{let{exec:p}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${u} ${s.url}`)}catch{ai("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Bt(),Ft(e.storyFiles.length),$s(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
@@ -0,0 +1,65 @@
1
+ // @bun
2
+ import{t,a,Dt,Mt,Lt,je,tt,P,xs,mr,Be}from"./chunk-55zaxb4s.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>P(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function mo(e,r,n,g){if(!e.includes("@meta"))return e;let i=Dt(e,O,(s,c)=>{let o=mr(Mt(s),r);if(o.kind==="tag")return N(o.tag);if(o.kind==="empty")return"";return P("Meta",c,o.message,n,o.code)},_("Meta",n));return i=Dt(i,I,(s,c)=>{let o=Lt(s,r);if(!o.ok)return P("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!tt(o.value))return P("MetaTag",c,`expected an object such as { name, content }, got ${je(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return P("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),i}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(tt(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(tt))return e.map(r);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function ho(e,r,n){if(!e.includes("@structuredData"))return e;return Dt(e,C,(g,i)=>{let s=Lt(g,r);if(!s.ok)return P("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=b(s.value);if(!c)return P("StructuredData",i,`expected an object or an array of objects, got ${je(s.value)}`,n,t.TYPE_ERROR);try{return E(c)}catch(o){let u=o instanceof Error?o.message:String(o);return P("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function yo(e,r,n,g){if(!e.includes("@seo"))return e;return Dt(e,k,(i,s)=>{if(!i.trim())return P("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Lt(i,r);if(!c.ok)return P("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!tt(c.value))return P("SEO",s,`expected an object such as { title, description }, got ${je(c.value)}`,n,t.TYPE_ERROR);try{return L(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return P("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function R(e,r,n,g){let i=e[r];if(i===void 0||i===null||i===!1)return;if(tt(i))return i;xs(n,`${r} must be an object, got ${je(i)}; its tags were left out`,g);return}function L(e,r,n){let g=Object.keys(e).filter((o)=>!j.has(o));if(g.length>0){let o=g.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");xs(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
3
+ `,i+=`<meta name="title" content="${l(e.title)}">
4
+ `;if(e.description)i+=`<meta name="description" content="${l(e.description)}">
5
+ `;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;i+=`<meta name="keywords" content="${l(o)}">
6
+ `}if(e.robots)i+=`<meta name="robots" content="${l(e.robots)}">
7
+ `;if(e.canonical)i+=`<link rel="canonical" href="${l(e.canonical)}">
8
+ `;let s=R(e,"openGraph",r,n);if(s){if(i+=`<meta property="og:type" content="${l(s.type||"website")}">
9
+ `,s.title||e.title){let o=s.title||e.title||"";i+=`<meta property="og:title" content="${l(o)}">
10
+ `}if(s.description||e.description){let o=s.description||e.description||"";i+=`<meta property="og:description" content="${l(o)}">
11
+ `}if(s.url||e.canonical){let o=s.url||e.canonical||"";i+=`<meta property="og:url" content="${l(o)}">
12
+ `}if(s.image){if(i+=`<meta property="og:image" content="${l(s.image)}">
13
+ `,s.imageAlt)i+=`<meta property="og:image:alt" content="${l(s.imageAlt)}">
14
+ `;if(s.imageWidth)i+=`<meta property="og:image:width" content="${l(String(s.imageWidth))}">
15
+ `;if(s.imageHeight)i+=`<meta property="og:image:height" content="${l(String(s.imageHeight))}">
16
+ `;if(s.imageType)i+=`<meta property="og:image:type" content="${l(s.imageType)}">
17
+ `}if(s.siteName)i+=`<meta property="og:site_name" content="${l(s.siteName)}">
18
+ `;if(s.locale)i+=`<meta property="og:locale" content="${l(s.locale)}">
19
+ `;if(s.profile){let o=[["first_name",s.profile.firstName],["last_name",s.profile.lastName],["username",s.profile.username],["gender",s.profile.gender]];for(let[u,p]of o)if(p)i+=`<meta property="profile:${u}" content="${l(p)}">
20
+ `}}let c=R(e,"twitter",r,n);if(c){if(i+=`<meta name="twitter:card" content="${l(c.card||"summary_large_image")}">
21
+ `,c.title||e.title){let o=c.title||e.title||"";i+=`<meta name="twitter:title" content="${l(o)}">
22
+ `}if(c.description||e.description){let o=c.description||e.description||"";i+=`<meta name="twitter:description" content="${l(o)}">
23
+ `}if(c.image||s&&s.image){let o=c.image||(s?s.image:"")||"";i+=`<meta name="twitter:image" content="${l(o)}">
24
+ `;let u=c.imageAlt||(!c.image&&s?s.imageAlt:void 0);if(u)i+=`<meta name="twitter:image:alt" content="${l(u)}">
25
+ `}if(c.site)i+=`<meta name="twitter:site" content="${l(c.site)}">
26
+ `;if(c.creator)i+=`<meta name="twitter:creator" content="${l(c.creator)}">
27
+ `}if(e.structuredData!==void 0&&e.structuredData!==null){let o=b(e.structuredData);if(o)i+=`${E(o)}
28
+ `;else xs(r,`structuredData must be an object or an array of objects, got ${je(e.structuredData)}; it was left out`,n)}return i.trim()}function bo(e,r,n){if(n.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||r.__stx_seo_staged===!0||n.skipDefaultSeoTags===!0)return e;let g=r.__stx_runtime_head;if(!!(g?.title||g?.meta?.some((S)=>S.property==="og:title"||S.name==="og:title"||S.name==="twitter:title"||S.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let s=e.includes("<title>")||e.includes("</title>"),c=q(e),o=M(c),u=G(c),p="";if(r.title)p=r.title;else if(r.meta&&r.meta.title)p=r.meta.title;else if(o)p=o;else if(n.seo?.defaultConfig?.title)p=n.seo.defaultConfig.title;else p=n.defaultTitle||"stx Project";let m="";if(r.description)m=r.description;else if(r.meta&&r.meta.description)m=r.meta.description;else if(u)m=u;else if(n.seo?.defaultConfig?.description)m=n.seo.defaultConfig.description;else m=n.defaultDescription||"A website built with stx templating engine";let d="";if(r.image)d=r.image;else if(r.meta&&r.meta.image)d=r.meta.image;else if(r.openGraph&&r.openGraph.image)d=r.openGraph.image;else if(n.seo?.defaultImage)d=n.seo.defaultImage;else if(n.defaultImage)d=n.defaultImage;let f=s?"":`
29
+ <meta name="title" content="${l(p)}">`,D=V(c)?"":`
30
+ <meta name="description" content="${l(m)}">`,y=`
31
+ <!-- stx SEO Tags -->${f}${D}
32
+ <meta property="og:title" content="${l(p)}">
33
+ <meta property="og:description" content="${l(m)}">
34
+ <meta property="og:type" content="website">
35
+ <meta name="twitter:card" content="summary_large_image">
36
+ <meta name="twitter:title" content="${l(p)}">
37
+ <meta name="twitter:description" content="${l(m)}">
38
+ `;if(d)y+=`
39
+ <meta property="og:image" content="${l(d)}">
40
+ <meta name="twitter:image" content="${l(d)}">
41
+ `;let h=e;if(!s)h=h.replace(/<head[^>]*>/,`$&
42
+ <title>${l(p)}</title>`);let w=r.__stx_head_injections;if(w)return r.__stx_seo_staged=!0,w.afterOpen.push(`
43
+ ${y}
44
+ `),h;return h.replace(/<head[^>]*>/,`$&
45
+ ${y}
46
+ `)}function q(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function M(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function V(e){return x(e).length>0}function G(e){for(let r of x(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return v(g)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Xr={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let i=mr(r,n??{});if(i.kind==="error")return P("Meta",`@meta(${r.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=Be(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Jr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function kp(){return[Xr,Jr]}function _p(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
47
+ <loc>${T(d)}</loc>`;for(let w of m.alternates??[])h+=`
48
+ <xhtml:link rel="alternate" hreflang="${T(w.hreflang)}" href="${T(o(w.href))}"/>`;if(f)h+=`
49
+ <lastmod>${f}</lastmod>`;return h+=`
50
+ <changefreq>${D}</changefreq>`,h+=`
51
+ <priority>${y.toFixed(1)}</priority>`,h+=`
52
+ </url>`,h});return`<?xml version="1.0" encoding="UTF-8"?>
53
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${e.some((m)=>m.alternates?.length)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>
54
+ ${u.join(`
55
+ `)}
56
+ </urlset>`}function Cp(e,r){let n=r.replace(/\/$/,""),g=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
57
+ <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
58
+ ${e.map((s)=>{let c=s.startsWith("http")?s:`${n}${s.startsWith("/")?"":"/"}${s}`;return` <sitemap>
59
+ <loc>${T(c)}</loc>
60
+ <lastmod>${g}</lastmod>
61
+ </sitemap>`}).join(`
62
+ `)}
63
+ </sitemapindex>`}async function Ep(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:g=["_*",".*","node_modules","components","partials","layouts"]}=r,i=[],s=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${s}`);for await(let o of c.scan(e)){if(g.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let p=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!p.startsWith("/"))p=`/${p}`;if(p!=="/"&&p.endsWith("/"))p=p.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}i.push({loc:p||"/",lastmod:d,priority:p==="/"?1:0.5})}return i.sort((o,u)=>o.loc.localeCompare(u.loc)),i}function Yr(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let g of n.allow)r.push(`Allow: ${g}`);if(n.disallow)for(let g of n.disallow)r.push(`Disallow: ${g}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let g of n)r.push(`Sitemap: ${g}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
64
+ `).trim()}function Tp(e){return Yr({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function T(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}
65
+ export{mo,ho,yo,bo,Xr,Jr,kp,_p,Cp,Ep,Yr,Tp};