@stacksjs/stx 0.2.674 → 0.2.676

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 (244) hide show
  1. package/dist/{chunk-szevd7d5.js → chunk-028e9fty.js} +2 -2
  2. package/dist/{chunk-rr527jt6.js → chunk-078qg8r5.js} +2 -2
  3. package/dist/chunk-0gk78x3r.js +2 -0
  4. package/dist/{chunk-fw413k9q.js → chunk-1b9thkg5.js} +2 -2
  5. package/dist/chunk-1e73whqh.js +2 -0
  6. package/dist/chunk-1rztwjdj.js +130 -0
  7. package/dist/{chunk-srq9fqq8.js → chunk-245sas8r.js} +38 -38
  8. package/dist/chunk-248a88mc.js +2 -0
  9. package/dist/chunk-2nqtmp8c.js +2 -0
  10. package/dist/chunk-2pga7zzb.js +4 -0
  11. package/dist/{chunk-bkkpq8dx.js → chunk-304dbbsw.js} +10 -10
  12. package/dist/{chunk-z22zy22p.js → chunk-34e8e8te.js} +2 -2
  13. package/dist/{chunk-md2jn67b.js → chunk-374nhgyf.js} +2 -2
  14. package/dist/chunk-3bfegbpw.js +2 -0
  15. package/dist/chunk-3gdt16xa.js +2 -0
  16. package/dist/chunk-3wsm9g9c.js +2 -0
  17. package/dist/chunk-3xx9d934.js +2 -0
  18. package/dist/{chunk-ham5x7ts.js → chunk-4fhbh04h.js} +4 -4
  19. package/dist/{chunk-5vt48yce.js → chunk-4jnv2v5e.js} +9 -9
  20. package/dist/chunk-4rk5qnqf.js +24 -0
  21. package/dist/chunk-526mf3fr.js +4 -0
  22. package/dist/chunk-54zkkxmb.js +2 -0
  23. package/dist/{chunk-kdebh22m.js → chunk-551s7ha0.js} +10 -10
  24. package/dist/chunk-5v7vm8cv.js +14 -0
  25. package/dist/{chunk-rdr09efy.js → chunk-5z0q3qv3.js} +5 -5
  26. package/dist/{chunk-6sjtyd0k.js → chunk-5z8mq37c.js} +4 -4
  27. package/dist/{chunk-ce6zddpf.js → chunk-6beg47t4.js} +2 -2
  28. package/dist/{chunk-trz8z4j4.js → chunk-6bwca55g.js} +37 -37
  29. package/dist/chunk-6kam8r5y.js +2 -0
  30. package/dist/{chunk-tddnb5bv.js → chunk-6ycyaf5g.js} +2 -2
  31. package/dist/chunk-707sx5sk.js +20 -0
  32. package/dist/chunk-78d5tn4r.js +2 -0
  33. package/dist/{chunk-pb6erpj3.js → chunk-78x52gz3.js} +5 -5
  34. package/dist/{chunk-zp79zkkd.js → chunk-78yjmbbs.js} +2 -2
  35. package/dist/{chunk-v21bhhjb.js → chunk-7j7h1eg3.js} +1 -1
  36. package/dist/{chunk-zmg1peyg.js → chunk-8aq07a1j.js} +3 -3
  37. package/dist/chunk-8p92r2sc.js +2 -0
  38. package/dist/chunk-909ymsjz.js +2 -0
  39. package/dist/{chunk-r7fdw2v5.js → chunk-97h9ga3b.js} +3 -3
  40. package/dist/chunk-9859r1d5.js +2 -0
  41. package/dist/{chunk-25zmy8q6.js → chunk-9wdd7eq6.js} +2 -2
  42. package/dist/{chunk-p6qd7ad0.js → chunk-a2zb5fgg.js} +2 -2
  43. package/dist/chunk-arh1qgmp.js +2 -0
  44. package/dist/chunk-b18x0v21.js +2 -0
  45. package/dist/chunk-b23vscaq.js +2 -0
  46. package/dist/{chunk-4b9s7wgy.js → chunk-be2rswkw.js} +2 -2
  47. package/dist/{chunk-qz5b8ed4.js → chunk-bh19ezq0.js} +5 -5
  48. package/dist/chunk-bm42rsaa.js +2 -0
  49. package/dist/{chunk-cbjabv1w.js → chunk-bpj387yx.js} +6 -6
  50. package/dist/chunk-c4enpsj8.js +2 -0
  51. package/dist/chunk-cdbaanmx.js +2 -0
  52. package/dist/chunk-cfm6a679.js +2 -0
  53. package/dist/chunk-cs8wq7nv.js +2 -0
  54. package/dist/{chunk-hegfgw27.js → chunk-cxgremn0.js} +5 -5
  55. package/dist/chunk-d2xf5hh9.js +2 -0
  56. package/dist/{chunk-rym0309c.js → chunk-d4ch6exz.js} +3 -3
  57. package/dist/chunk-dda8pdya.js +2 -0
  58. package/dist/{chunk-7adznted.js → chunk-dera8fmc.js} +2 -2
  59. package/dist/chunk-dmd7mgjw.js +3 -0
  60. package/dist/chunk-ds91e0fe.js +2 -0
  61. package/dist/{chunk-hgry3mjd.js → chunk-dxh45gve.js} +1 -1
  62. package/dist/chunk-e492je6q.js +2 -0
  63. package/dist/{chunk-7j1zgrnf.js → chunk-ehzd1yc6.js} +9 -9
  64. package/dist/chunk-etz2dmec.js +2 -0
  65. package/dist/{chunk-4s8zacxg.js → chunk-f26n6y9p.js} +4 -4
  66. package/dist/{chunk-4w6baw62.js → chunk-fbrgz3s8.js} +2 -2
  67. package/dist/chunk-fd72t30s.js +2 -0
  68. package/dist/{chunk-sqn3y9qt.js → chunk-fdvfzknd.js} +2 -2
  69. package/dist/chunk-ft3f9nj0.js +2 -0
  70. package/dist/{chunk-dgc1a3yt.js → chunk-fzc98qgn.js} +7 -7
  71. package/dist/{chunk-s0vtjyyj.js → chunk-g12ht81a.js} +2 -2
  72. package/dist/chunk-g6gqja52.js +2 -0
  73. package/dist/{chunk-hb3edeq9.js → chunk-ga5kjf9b.js} +6 -6
  74. package/dist/chunk-ggwvnpwj.js +2 -0
  75. package/dist/{chunk-hsmcbh0p.js → chunk-ghm9f13q.js} +5 -5
  76. package/dist/chunk-gx6wxmbv.js +2 -0
  77. package/dist/chunk-gz5rvwgx.js +2 -0
  78. package/dist/chunk-hamk3dky.js +2 -0
  79. package/dist/{chunk-vayhx642.js → chunk-haz2ezyk.js} +2 -2
  80. package/dist/chunk-hh58k0nh.js +3 -0
  81. package/dist/chunk-hqj28381.js +3 -0
  82. package/dist/chunk-j60jye3e.js +25 -0
  83. package/dist/chunk-jjet6qxq.js +2 -0
  84. package/dist/chunk-jk7chxkt.js +2 -0
  85. package/dist/{chunk-d09q93yf.js → chunk-jv021x8e.js} +2 -2
  86. package/dist/{chunk-pg2v1pb5.js → chunk-k06n5bjp.js} +3 -3
  87. package/dist/{chunk-35ezh7de.js → chunk-k72jqz6a.js} +3 -3
  88. package/dist/chunk-kn34esxw.js +2 -0
  89. package/dist/chunk-kqbpkg8n.js +2 -0
  90. package/dist/{chunk-aet1pgw7.js → chunk-krcd3039.js} +74 -74
  91. package/dist/{chunk-asezs2n3.js → chunk-kxj8e1gd.js} +6 -6
  92. package/dist/{chunk-5zhp87wv.js → chunk-mabja59q.js} +2 -2
  93. package/dist/chunk-mf19qxgv.js +3 -0
  94. package/dist/chunk-mjsebtg6.js +2 -0
  95. package/dist/{chunk-fd49fahd.js → chunk-mn47s2ef.js} +5 -5
  96. package/dist/{chunk-nj343mw2.js → chunk-mq915g3j.js} +5 -5
  97. package/dist/chunk-n63r9b4f.js +2 -0
  98. package/dist/{chunk-j6m8xqh3.js → chunk-n8wvqnfc.js} +2 -2
  99. package/dist/chunk-n94ts3t9.js +21 -0
  100. package/dist/{chunk-w7t2cfgy.js → chunk-p27ptd9f.js} +65 -65
  101. package/dist/{chunk-t0k16vqv.js → chunk-p9az13b2.js} +2 -2
  102. package/dist/chunk-pwn0j1vq.js +2 -0
  103. package/dist/chunk-q1jcf6vm.js +2 -0
  104. package/dist/{chunk-am2w363p.js → chunk-q3gactm1.js} +4 -4
  105. package/dist/chunk-q3nnaxf9.js +2 -0
  106. package/dist/{chunk-w3d98907.js → chunk-q4rejyd2.js} +2 -2
  107. package/dist/{chunk-hz4x7h0n.js → chunk-qbzqary0.js} +5 -5
  108. package/dist/{chunk-a4p18ybc.js → chunk-qr7a378v.js} +3 -3
  109. package/dist/{chunk-bsajk82t.js → chunk-qwdcts9w.js} +19 -19
  110. package/dist/chunk-rc79yyqx.js +2 -0
  111. package/dist/{chunk-yx3dpdwc.js → chunk-rfc5pdv2.js} +3 -3
  112. package/dist/chunk-rnws0dh3.js +2 -0
  113. package/dist/chunk-rxxajm31.js +31 -0
  114. package/dist/{chunk-thceyzj6.js → chunk-rza1p6e4.js} +2 -2
  115. package/dist/chunk-s73z8zss.js +11 -0
  116. package/dist/chunk-s8qe247r.js +2 -0
  117. package/dist/{chunk-d1a86qx8.js → chunk-sptewgky.js} +1 -1
  118. package/dist/{chunk-mwnhdsbp.js → chunk-sqh3tvtw.js} +2 -2
  119. package/dist/{chunk-6s7tvmqp.js → chunk-sr3hmrah.js} +2 -2
  120. package/dist/chunk-sswy3tfc.js +2 -0
  121. package/dist/chunk-swxznm5v.js +2 -0
  122. package/dist/{chunk-9dtbvjpp.js → chunk-tmqrbs98.js} +31 -20
  123. package/dist/chunk-tst8p27s.js +12 -0
  124. package/dist/chunk-tz09earb.js +2 -0
  125. package/dist/{chunk-fbmth6xv.js → chunk-vay5v6sj.js} +13 -13
  126. package/dist/{chunk-ck2e3e47.js → chunk-vd5w1jaz.js} +3 -3
  127. package/dist/chunk-vewt3464.js +2 -0
  128. package/dist/{chunk-xghcsg3f.js → chunk-vg1pg6yt.js} +1 -1
  129. package/dist/{chunk-s2wptfm1.js → chunk-wav0xbnb.js} +2 -2
  130. package/dist/chunk-whzvx5w5.js +2 -0
  131. package/dist/chunk-wk1gt95z.js +2 -0
  132. package/dist/{chunk-t9kxhe46.js → chunk-wr1gm35v.js} +1 -1
  133. package/dist/{chunk-faakv1p6.js → chunk-wscnjtss.js} +2 -2
  134. package/dist/{chunk-t79jfpv6.js → chunk-x4q4bx3q.js} +2 -2
  135. package/dist/chunk-x63f2ywm.js +2 -0
  136. package/dist/{chunk-y1pcdeg9.js → chunk-x7wr720m.js} +5 -5
  137. package/dist/chunk-xk7cp691.js +2 -0
  138. package/dist/chunk-xna6b7km.js +2 -0
  139. package/dist/{chunk-v6peecfp.js → chunk-xnx06qqt.js} +2 -2
  140. package/dist/chunk-xw4rm5zj.js +2 -0
  141. package/dist/{chunk-5qtthtg3.js → chunk-y34tyrpb.js} +7 -7
  142. package/dist/chunk-yar7fwrb.js +2 -0
  143. package/dist/{chunk-2zzc7006.js → chunk-yn9kvsk1.js} +2 -2
  144. package/dist/chunk-yt33wzqk.js +2 -0
  145. package/dist/chunk-z35ftpqp.js +421 -0
  146. package/dist/{chunk-4bgjrrvz.js → chunk-z7ghjs7w.js} +1 -1
  147. package/dist/chunk-zq7xbc1k.js +2 -0
  148. package/dist/cli.js +22 -22
  149. package/dist/client/signals-for-runtime.js +16 -5
  150. package/dist/craft-entry.js +2 -2
  151. package/dist/craft.js +2 -2
  152. package/dist/native/compiler/headwind-to-style.js +13 -1
  153. package/dist/native/compiler/html-to-ir.d.ts +2 -0
  154. package/dist/native/compiler/html-to-ir.js +9 -0
  155. package/dist/native/compiler/ir.d.ts +1 -0
  156. package/dist/native/compiler/render-screen.js +4 -3
  157. package/dist/native/compiler/style-config.d.ts +3 -0
  158. package/dist/native/compiler/style-config.js +5 -0
  159. package/dist/native/components/primitives.d.ts +2 -0
  160. package/dist/native/event-names.js +2 -0
  161. package/dist/native/prop-names.js +1 -0
  162. package/dist/native/runtime/craft-bridge.js +15 -8
  163. package/dist/pwa.js +3 -3
  164. package/dist/signal-processing.js +75 -16
  165. package/dist/ssg-static-paths.d.ts +12 -0
  166. package/dist/ssg-static-paths.js +62 -0
  167. package/dist/ssg.d.ts +2 -4
  168. package/dist/ssg.js +43 -47
  169. package/dist/utils.js +1 -1
  170. package/package.json +2 -2
  171. package/dist/chunk-0jwdcqj8.js +0 -2
  172. package/dist/chunk-0mwdq478.js +0 -2
  173. package/dist/chunk-0nfqgv4n.js +0 -4
  174. package/dist/chunk-1y6egkty.js +0 -2
  175. package/dist/chunk-280p4q7a.js +0 -2
  176. package/dist/chunk-2881tcqt.js +0 -2
  177. package/dist/chunk-2a775q7x.js +0 -2
  178. package/dist/chunk-2asdbd5e.js +0 -2
  179. package/dist/chunk-34yj93hh.js +0 -2
  180. package/dist/chunk-40tswfe7.js +0 -21
  181. package/dist/chunk-41de209e.js +0 -2
  182. package/dist/chunk-506mv7hb.js +0 -3
  183. package/dist/chunk-5s1ay9mv.js +0 -2
  184. package/dist/chunk-7kznee1g.js +0 -2
  185. package/dist/chunk-7mvz972c.js +0 -12
  186. package/dist/chunk-80zgyaqe.js +0 -2
  187. package/dist/chunk-84tqb1rn.js +0 -2
  188. package/dist/chunk-8azm7nha.js +0 -2
  189. package/dist/chunk-902qnyg0.js +0 -2
  190. package/dist/chunk-9n6jwcpb.js +0 -2
  191. package/dist/chunk-a6y8td0d.js +0 -2
  192. package/dist/chunk-a7kt1ts4.js +0 -2
  193. package/dist/chunk-a81y8g40.js +0 -2
  194. package/dist/chunk-aft1zc84.js +0 -2
  195. package/dist/chunk-bawq4fqy.js +0 -31
  196. package/dist/chunk-bdp2r0v4.js +0 -2
  197. package/dist/chunk-brtvm8mb.js +0 -2
  198. package/dist/chunk-bvzr9zqt.js +0 -2
  199. package/dist/chunk-cbvgtf3m.js +0 -2
  200. package/dist/chunk-cfydbaeq.js +0 -2
  201. package/dist/chunk-dq8c3h4n.js +0 -2
  202. package/dist/chunk-e36pne7n.js +0 -2
  203. package/dist/chunk-e62qfexp.js +0 -2
  204. package/dist/chunk-eq5jzaj5.js +0 -2
  205. package/dist/chunk-f9zyf9n6.js +0 -421
  206. package/dist/chunk-fb7t1nn9.js +0 -24
  207. package/dist/chunk-fr39emcz.js +0 -2
  208. package/dist/chunk-fsq13amm.js +0 -2
  209. package/dist/chunk-fxh12vqd.js +0 -2
  210. package/dist/chunk-gcc9fa33.js +0 -2
  211. package/dist/chunk-h6t2ney6.js +0 -2
  212. package/dist/chunk-hvtzw1jh.js +0 -2
  213. package/dist/chunk-j8g5cvvm.js +0 -2
  214. package/dist/chunk-jzjpyyw2.js +0 -2
  215. package/dist/chunk-k1b8x73j.js +0 -2
  216. package/dist/chunk-nw9bdk2n.js +0 -2
  217. package/dist/chunk-p4jkswz8.js +0 -2
  218. package/dist/chunk-p4r90vqf.js +0 -2
  219. package/dist/chunk-p8bgy5tt.js +0 -2
  220. package/dist/chunk-pqqe2b6m.js +0 -11
  221. package/dist/chunk-q6nwcav4.js +0 -2
  222. package/dist/chunk-qmqavdz2.js +0 -2
  223. package/dist/chunk-qpw72bty.js +0 -2
  224. package/dist/chunk-qwnh1kj6.js +0 -2
  225. package/dist/chunk-qy9m6qdn.js +0 -2
  226. package/dist/chunk-qychcdsm.js +0 -2
  227. package/dist/chunk-rj3w1ama.js +0 -2
  228. package/dist/chunk-rv39s5az.js +0 -20
  229. package/dist/chunk-sf0r963g.js +0 -2
  230. package/dist/chunk-ss820yys.js +0 -2
  231. package/dist/chunk-t4j9g2vh.js +0 -2
  232. package/dist/chunk-trh7s6k3.js +0 -130
  233. package/dist/chunk-ttemwrbx.js +0 -2
  234. package/dist/chunk-twqzn21x.js +0 -14
  235. package/dist/chunk-v14rq8b4.js +0 -3
  236. package/dist/chunk-vdxg7e1y.js +0 -4
  237. package/dist/chunk-vq513cxx.js +0 -2
  238. package/dist/chunk-vvq8xe3n.js +0 -2
  239. package/dist/chunk-w8t31bn9.js +0 -2
  240. package/dist/chunk-x1kz4d7j.js +0 -2
  241. package/dist/chunk-xaa36b0x.js +0 -3
  242. package/dist/chunk-xcsyqwxf.js +0 -25
  243. package/dist/chunk-xn9jrjzh.js +0 -2
  244. package/dist/chunk-z97bwx8m.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- function Di(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="id",dynamicHeight:d=!1,estimatedItemHeight:g=l,direction:x="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return h();let i=Math.max(0,Math.floor(t/l)-s),r=Math.ceil(u/l),m=Math.min(e.length-1,i+r+s*2);return{startIndex:i,endIndex:m}}function h(){let i=0,r=0,m=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+M>t){r=Math.max(0,p-s);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+=M,i>t+u){m=Math.min(e.length-1,p+s);break}}return{startIndex:r,endIndex:m}}function w(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||g;return i}return e.length*l}function y(i){if(d){let r=0;for(let m=0;m<i;m++)r+=n.get(m)||g;return r}return i*l}function S(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:w(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function L(i,r="auto"){let m=y(i);a(m,r)}function a(i,r="auto"){t=Math.max(0,Math.min(i,w()-u))}function o(){f()}function H(i){e=[...i],n.clear(),o()}function I(){e=[],n.clear()}return{scrollToIndex:L,scrollToOffset:a,getState:S,refresh:o,setItems:H,destroy:I}}function Mi(v,c={},l){let u=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${x}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let a=d.trim(),o=Function(`return ${a}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),h=t.overscan||3,w=0,y=Math.min(e.length-1,f+h),S="";for(let a=w;a<=y&&a<e.length;a++){let o=e[a],H=g.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(a));S+=`
2
+ function Mi(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="id",dynamicHeight:d=!1,estimatedItemHeight:g=l,direction:x="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return h();let i=Math.max(0,Math.floor(t/l)-s),r=Math.ceil(u/l),m=Math.min(e.length-1,i+r+s*2);return{startIndex:i,endIndex:m}}function h(){let i=0,r=0,m=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+M>t){r=Math.max(0,p-s);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+=M,i>t+u){m=Math.min(e.length-1,p+s);break}}return{startIndex:r,endIndex:m}}function w(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||g;return i}return e.length*l}function y(i){if(d){let r=0;for(let m=0;m<i;m++)r+=n.get(m)||g;return r}return i*l}function S(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:w(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function L(i,r="auto"){let m=y(i);a(m,r)}function a(i,r="auto"){t=Math.max(0,Math.min(i,w()-u))}function o(){f()}function H(i){e=[...i],n.clear(),o()}function I(){e=[],n.clear()}return{scrollToIndex:L,scrollToOffset:a,getState:S,refresh:o,setItems:H,destroy:I}}function Li(v,c={},l){let u=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${x}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let a=d.trim(),o=Function(`return ${a}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),h=t.overscan||3,w=0,y=Math.min(e.length-1,f+h),S="";for(let a=w;a<=y&&a<e.length;a++){let o=e[a],H=g.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(a));S+=`
3
3
  <div class="virtual-item ${t.itemClass||""}"
4
4
  style="position: absolute; top: ${a*t.itemHeight}px; height: ${t.itemHeight}px; width: 100%;"
5
5
  data-index="${a}">
@@ -76,7 +76,7 @@ function Di(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
76
76
  };
77
77
  })();
78
78
  </script>
79
- `})}function Hc(){return`
79
+ `})}function Uc(){return`
80
80
  .virtual-list-container {
81
81
  position: relative;
82
82
  overflow-y: auto;
@@ -124,7 +124,7 @@ function Di(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
124
124
  0% { background-position: 200% 0; }
125
125
  100% { background-position: -200% 0; }
126
126
  }
127
- `}function Vc(v,c){let l=null,u=()=>{if(!l)l=Di(v(),c);return l};return{visibleItems:()=>u().getState().visibleItems,totalHeight:()=>u().getState().totalHeight,containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(s)=>{let b=s.target;if(l)l.scrollToOffset(b.scrollTop)}}),itemProps:(s)=>({style:{position:"absolute",top:`${s*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":s}),scrollToIndex:(s)=>{u().scrollToIndex(s)}}}function Uc(v,c={},l){let u=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(u,(s,b,d,g,x)=>{let e=b.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let w=Function(`return ${d.trim()}`)();n={...n,...w}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,h=Mi(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${g}@endvirtualList`,c);return h=h.replace("</script>",`
127
+ `}function Wc(v,c){let l=null,u=()=>{if(!l)l=Mi(v(),c);return l};return{visibleItems:()=>u().getState().visibleItems,totalHeight:()=>u().getState().totalHeight,containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(s)=>{let b=s.target;if(l)l.scrollToOffset(b.scrollTop)}}),itemProps:(s)=>({style:{position:"absolute",top:`${s*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":s}),scrollToIndex:(s)=>{u().scrollToIndex(s)}}}function qc(v,c={},l){let u=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(u,(s,b,d,g,x)=>{let e=b.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let w=Function(`return ${d.trim()}`)();n={...n,...w}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,h=Li(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${g}@endvirtualList`,c);return h=h.replace("</script>",`
128
128
  // Infinite scroll detection
129
129
  container.addEventListener('scroll', function() {
130
130
  const scrollBottom = container.scrollTop + container.clientHeight;
@@ -142,7 +142,7 @@ function Di(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
142
142
  ${x}
143
143
  </div>
144
144
  </div>
145
- `})}function Wc(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
145
+ `})}function Kc(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
146
146
  <div class="virtual-grid-item"
147
147
  style="position: absolute; top: ${m}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
148
148
  data-index="${I}">
@@ -212,5 +212,5 @@ function Di(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
212
212
  });
213
213
  })();
214
214
  </script>
215
- `})}var ed={createVirtualList:Di,processVirtualListDirectives:Mi,processInfiniteListDirectives:Uc,processVirtualGridDirectives:Wc,generateVirtualListCSS:Hc,useVirtualList:Vc};
216
- export{Di,Mi,Hc,Vc,Uc,Wc,ed};
215
+ `})}var nd={createVirtualList:Mi,processVirtualListDirectives:Li,processInfiniteListDirectives:qc,processVirtualGridDirectives:Kc,generateVirtualListCSS:Uc,useVirtualList:Wc};
216
+ export{Mi,Li,Uc,Wc,qc,Kc,nd};
@@ -298,5 +298,5 @@ catch (error) {
298
298
  init();
299
299
  }
300
300
  })();
301
- </script>`}var hu={name:"pwa.installButton",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return r(t,n)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},yu={name:"pwa.updatePrompt",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return p(t,n)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},bu={name:"pwa.offlineIndicator",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return d(t,n)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},vu={name:"pwa.pushSubscribe",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return l(t,n)},hasEndTag:!0,description:"Renders a push notification subscription button"},$s=[hu,yu,bu,vu];function Gp(t){return[...t,...$s]}
302
- export{hu,yu,bu,vu,$s,Gp};
301
+ </script>`}var bu={name:"pwa.installButton",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return r(t,n)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},vu={name:"pwa.updatePrompt",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return p(t,n)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},wu={name:"pwa.offlineIndicator",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return d(t,n)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},xu={name:"pwa.pushSubscribe",handler:(t,i,e,a)=>{let n=e.__stx_options||{};return l(t,n)},hasEndTag:!0,description:"Renders a push notification subscription button"},As=[bu,vu,wu,xu];function Xp(t){return[...t,...As]}
302
+ export{bu,vu,wu,xu,As,Xp};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import i from"path";var sn=".stx",o="STX_DIR",e=null;function Ta(t){e=t?.trim()||null}function sr(){return process.env[o]?.trim()||e||sn}function c(t=process.cwd(),...n){let r=sr();return i.isAbsolute(r)?i.join(r,...n):i.join(t,r,...n)}function or(t){if(!t||i.isAbsolute(t))return t;let n=t.replace(/\\/g,"/");if(n!==sn&&!n.startsWith(`${sn}/`))return t;let r=n.slice(sn.length+1);return r?i.join(sr(),r):sr()}
3
+ export{sn,Ta,sr,c,or};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{bo,vo,wo,xo,Zr,Qr,Ep,Tp,$p,Rp,es,Ap}from"./chunk-y34tyrpb.js";import"./chunk-qwdcts9w.js";export{Ap as generateDefaultRobotsTxt,es as generateRobotsTxt,Tp as generateSitemap,$p as generateSitemapIndex,xo as injectSeoTags,Zr as metaDirective,bo as processMetaDirectives,wo as processSeoDirective,vo as processStructuredData,Ep as registerSeoDirectives,Rp as scanForSitemapEntries,Qr as structuredDataDirective};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import S from"fs";import _ from"path";function Ns(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function vi(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function Er(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await vi(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function Ds(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function Ms(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function Sn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function Vt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function wi(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
2
+ import S from"fs";import _ from"path";function Ms(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function xi(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function $r(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await xi(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function Ls(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function js(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function _n(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function Ut(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function Si(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
3
3
  `)+`
4
- `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Tr(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function $r(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function Ls(e,t){let i=await Tr(e),s=t||$r(i),n=wi(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function js(e){return m.existsSync(y.join(e,"netlify.toml"))}async function Au(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new lt(`No Netlify auth token found.
4
+ `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Rr(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function Ar(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function Bs(e,t){let i=await Rr(e),s=t||Ar(i),n=Si(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function Fs(e){return m.existsSync(y.join(e,"netlify.toml"))}async function Iu(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new lt(`No Netlify auth token found.
5
5
 
6
6
  To deploy to Netlify:
7
7
  1. Create account at https://app.netlify.com
@@ -19,12 +19,12 @@ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,
19
19
 
20
20
  Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(l).length>0))throw new lt(`Build directory is empty: ${l}
21
21
 
22
- Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await Er(l),w=Vt(c);return n(`Would deploy ${c.length} files (${Sn(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=Ns({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new lt(`Site not found: ${f}
22
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await $r(l),w=Ut(c);return n(`Would deploy ${c.length} files (${_n(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=Ms({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new lt(`Site not found: ${f}
23
23
 
24
- Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await Er(l),g=Vt(a);if(n(`Found ${a.length} files (${Sn(g)})`),a.length===0)throw new lt(`No files found in ${l}`,"NO_FILES");let b=Ds(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=Ms(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=Vt(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${Sn(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:Vt(h)}}async function Pu(e={}){let t=e.directory||process.cwd(),i;if(js(t))i=_.join(t,"netlify.toml");else{let s=await Tr(t);i=await Ls(t,$r(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
24
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await $r(l),g=Ut(a);if(n(`Found ${a.length} files (${_n(g)})`),a.length===0)throw new lt(`No files found in ${l}`,"NO_FILES");let b=Ls(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=js(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=Ut(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${_n(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:Ut(h)}}async function Ou(e={}){let t=e.directory||process.cwd(),i;if(Fs(t))i=_.join(t,"netlify.toml");else{let s=await Rr(t);i=await Bs(t,Ar(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
25
25
  `).filter((r)=>!r.startsWith("NETLIFY_SITE_ID=")).join(`
26
26
  `),n&&!n.endsWith(`
27
27
  `))n+=`
28
28
  `}n+=`NETLIFY_SITE_ID=${e.siteId}
29
29
  `,await Bun.write(s,n)}return{configPath:i,siteId:e.siteId}}class lt extends Error{code;constructor(e,t){super(e);this.name="DeployError",this.code=t}}function I(e){let t=process.platform,i=t==="darwin"?"open":t==="win32"?"start":"xdg-open";Bun.spawn([i,e],{stdio:["ignore","ignore","ignore"]})}
30
- export{Ns,vi,Er,Ds,Ms,Sn,Vt,wi,Tr,$r,Ls,js,Au,Pu,lt};
30
+ export{Ms,xi,$r,Ls,js,_n,Ut,Si,Rr,Ar,Bs,Fs,Iu,Ou,lt};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-zp79zkkd.js";import"./chunk-ce6zddpf.js";import{g}from"./chunk-f9zyf9n6.js";import"./chunk-bsajk82t.js";import"./chunk-25zmy8q6.js";import"./chunk-mwnhdsbp.js";import{Bt,Rs,Ft,ci,ot,li,As,zt,di,Ht}from"./chunk-szevd7d5.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()=>{li("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`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 st=".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,st),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`
2
+ import{it,at,ct}from"./chunk-tp4eqfxq.js";import"./chunk-78yjmbbs.js";import"./chunk-6beg47t4.js";import{g}from"./chunk-z35ftpqp.js";import"./chunk-qwdcts9w.js";import"./chunk-9wdd7eq6.js";import"./chunk-sqh3tvtw.js";import{Ft,Ps,zt,ui,ot,di,Is,Ht,fi,Vt}from"./chunk-028e9fty.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()=>{di("Config file changed, restarting...");try{await e.onChange()}catch(p){ot(`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 st=".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,st),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}');
@@ -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 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-jzjpyyw2.js"),p={},u=h(n);if(u)try{await g(u,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 vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(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-jzjpyyw2.js"),c={...r},n=h(e);if(n)try{await g(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-wk1gt95z.js"),p={},u=h(n);if(u)try{await g(u,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 vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await g(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-wk1gt95z.js"),c={...r},n=h(e);if(n)try{await g(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 zt(t);at(t,r);let s=Ht(t.config,r);ct(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 xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,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=di(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);at(t,m);let f=Ht(t.config,m);if(ct(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=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>
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 Ht(t);at(t,r);let s=Vt(t.config,r);ct(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 xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,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=fi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await Ht(t);at(t,m);let f=Vt(t.config,m);if(ct(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=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 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 it({mode:"dev"});if(!e.config.enabled){ot("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),Rs(s.url),As()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await it({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":As();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{ci("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Bt(),Ft(e.storyFiles.length),Rs(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we 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={}){Ft();let e=await it({mode:"dev"});if(!e.config.enabled){ot("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}),zt(e.storyFiles.length),Ps(s.url),Is()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await it({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":Is();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{ui("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Ft(),zt(e.storyFiles.length),Ps(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{El,Hr}from"./chunk-ehzd1yc6.js";import"./chunk-xnx06qqt.js";import"./chunk-dxh45gve.js";import{ur}from"./chunk-z35ftpqp.js";import"./chunk-sqh3tvtw.js";import"./chunk-9wdd7eq6.js";import{tt}from"./chunk-qwdcts9w.js";import"./chunk-6beg47t4.js";import"./chunk-78yjmbbs.js";export{tt as freeIdentifiers,Hr as processComponents,El as processESImports,ur as rendersAsElement};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as qu}from"ts-broadcasting";import{Broadcast as Gu,BroadcastServer as Ku}from"ts-broadcasting";var e=null,u=[];function ju(){return e}async function Bu(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function Fu(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function zu(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();Mc(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function Mc(n,t,r){if(!i())return;s.send(n,t,r)}function Hu(n,t,r){if(!i())return;s.toUser(n,t,r)}function Vu(n,t,r){if(!i())return;s.toUsers(n,t,r)}function Uu(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function Wu(n,t,r){if(!i())return;s.presence(n,t,r)}
3
- export{ju,Bu,Fu,zu,Mc,Hu,Vu,Uu,Wu,qu,Gu,Ku};
2
+ import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as Gu}from"ts-broadcasting";import{Broadcast as Xu,BroadcastServer as Ju}from"ts-broadcasting";var e=null,u=[];function Fu(){return e}async function zu(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function Hu(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function Vu(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();jc(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function jc(n,t,r){if(!i())return;s.send(n,t,r)}function Uu(n,t,r){if(!i())return;s.toUser(n,t,r)}function Wu(n,t,r){if(!i())return;s.toUsers(n,t,r)}function qu(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function Ku(n,t,r){if(!i())return;s.presence(n,t,r)}
3
+ export{Fu,zu,Hu,Vu,jc,Uu,Wu,qu,Ku,Gu,Xu,Ju};
@@ -0,0 +1,21 @@
1
+ // @bun
2
+ import{st,dc}from"./chunk-78yjmbbs.js";import{T}from"./chunk-6beg47t4.js";import{L,is,s,an,F,se,Aa,It,fn,Me,Le}from"./chunk-z35ftpqp.js";import{Yn}from"./chunk-5v7vm8cv.js";import{q}from"./chunk-a2zb5fgg.js";import{rn}from"./chunk-dxh45gve.js";var j=`(?:"[^"]*"|'[^']*'|[^>"'])*`,H=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Q=65536,J=4,O=new Map;function hp(){O.clear()}function K(e){let o=[];for(let n of se(e,F)){let t=n.token.match(/^<script\b([^>]*)>/i),r=n.token.match(/<\/script\s*>$/i);if(!t||!r)continue;let a=t[0].length,f=n.token.length-r[0].length;o.push(Object.freeze({fullMatch:n.token,attrs:t[1],body:n.token.slice(a,f),start:n.start,end:n.end}))}return o}function Tl(e,o={}){let n=e.length>=Q,t=n?O.get(e):void 0;if(t===void 0){if(t=K(e),n)Aa(O,J),O.set(e,t)}let r=o.skipAttrs;if(!r)return t.slice();let a=[];for(let f of t)if(r.lastIndex=0,!r.test(f.attrs))a.push(f);return a}function co(e){let o=e.trim(),n=o.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(n){let r=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:c}=W(a);if(f)return{style:"as",iterable:r,itemVar:f,indexVar:c}}let t=o.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(t){let r=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:c}=W(r);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:c}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function W(e){let o=e.trim(),n=o.match(/^(\w+)\s*=>\s*(\w+)$/);if(n)return{itemVar:n[2],indexVar:n[1]};let t=o.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(t)return{itemVar:t[1],indexVar:t[2]||null};let r=o.match(/^(\w+)\s*,\s*(\w+)$/);if(r)return{itemVar:r[1],indexVar:r[2]};let a=o.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Vr(e,o){return dc(e,o)}function Y(e){let o=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,n=0,t;while((t=o.exec(e))!==null){let r=t[1];if(r.startsWith("if"))n++;else if(r==="endif")n--;else if(n===0)return!0}return!1}function Xn(e){let o=new Set,n=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,t=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,r;while((r=n.exec(e))!==null){let a=r[1],f;while((f=t.exec(a))!==null)o.add(f[1])}return o}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let o=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${j})>`,"iy"),n=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,t=se(e,(a,f)=>{o.lastIndex=f;let c=o.exec(a);if(!c||c.index!==f||!n.test(c[2]))return-1;return o.lastIndex}),r=[];for(let a of t){o.lastIndex=0;let f=o.exec(a.token);if(!f)continue;let c=f[2].match(n),p=co(c?.[1]??c?.[2]??""),h=[p.itemVar,p.indexVar].filter(Boolean);if(h.length===0)continue;let i=f[1],g=/\/\s*>$/.test(a.token)||M.has(i.toLowerCase())?a.end:z(e,a.start,i,a.end);if(g!==-1)r.push({start:a.start,end:g,vars:new Set(h)})}return r}var B=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function te(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function Z(e,o,n,t){if(!e)return!1;let r=te(e),a=!1,f=!1,c=!1,p=/([a-zA-Z_$][\w$]*)/g,h;while((h=p.exec(r))!==null){let l=h[1];if(r.slice(0,h.index).trimEnd().endsWith("."))continue;if(B.has(l))continue;if(o.has(l)||t?.has(l))a=!0;else if(n&&l in n)f=!0}let i=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,u;while((u=i.exec(r))!==null){let l=u[1];if(r.slice(0,u.index).trimEnd().endsWith("."))continue;if(B.has(l)||n&&l in n)continue;c=!0}return(a||c)&&!f}function N(e,o,n){let t=n===void 0?` ${o}`:` ${o}="${n.replace(/"/g,"&quot;")}"`,r=e.trim(),a=r.match(H);if(a&&ne(a[3],a[1])){let[,f,c,p]=a;return`<${f}${c}${t}>${p}</${f}>`}return`<template${t}>${r}</template>`}function ne(e,o){let n=new RegExp(`<(/)?${o}(?=[\\s/>])`,"gi"),t=0,r;while((r=n.exec(e))!==null)if(r[1]){if(t--,t<0)return!1}else t++;return!0}function lo(e,o){let n=Xn(e);function t(r){let a=r,f=ee(r),c=(u)=>{let g=new Set;for(let l of f)if(u>l.start&&u<l.end)for(let d of l.vars)g.add(d);return g},p=/@if\s*\(/g,h,i=[];while((h=p.exec(a))!==null){let u=h.index,g=u+h[0].length,l=1,d=g;while(d<a.length&&l>0){if(a[d]==="(")l++;else if(a[d]===")")l--;d++}if(l!==0)continue;let b=a.substring(g,d-1).trim(),S=d,w=1,E=S,m=/@(if\s*\(|endif)/g;m.lastIndex=S;let x;while((x=m.exec(a))!==null)if(x[1].startsWith("if"))w++;else if(x[1]==="endif"){if(w--,w===0){E=x.index+x[0].length;break}}if(w!==0)continue;let y=a.substring(S,E-6).trim(),R;if(Y(y)){let _=rn(a.substring(u,E));if(_.length===0)continue;let I=_[0].branches.filter((v)=>v.type!=="else"),k=c(u);if(!(I.length>0&&I.every((v)=>Z(v.condition,n,o,k))))continue;R=_[0].branches.map((v)=>{let V=t(v.content);if(v.type==="elseif")return N(V,"@else-if",v.condition??"");if(v.type==="else")return N(V,"@else");return N(V,"@if",v.condition??"")}).join(`
3
+ `)}else{if(!Z(b,n,o,c(u)))continue;R=N(t(y),"@if",b)}i.push({start:u,end:E,replacement:R}),p.lastIndex=E}for(let u=i.length-1;u>=0;u--){let{start:g,end:l,replacement:d}=i[u];a=a.substring(0,g)+d+a.substring(l)}return a}return t(e)}function re(e){let o=e.trim();if(o==="")return;if(o==="true")return!0;if(o==="false")return!1;if(o==="null")return!1;if(o==="undefined")return!1;if(o==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(o)){let r=Number(o);return r!==0&&!Number.isNaN(r)}let n=o.match(/^'((?:\\.|[^'\\])*)'$/);if(n)return n[1].length>0;let t=o.match(/^"((?:\\.|[^"\\])*)"$/);if(t)return t[1].length>0;return}var M=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),U=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function z(e,o,n,t){if(M.has(n.toLowerCase()))return t;let r=n.toLowerCase(),a=e.length,f=1,c=t;while(c<a){let p=e.indexOf("<",c);if(p===-1)return-1;if(c=p,e.startsWith("<!--",c)){let g=e.indexOf("-->",c+4);if(g===-1)return-1;c=g+3;continue}U.lastIndex=c;let h=U.exec(e);if(h){let g=e.indexOf(">",c);if(g===-1)return-1;if(e[g-1]==="/"){c=g+1;continue}let l=h[1].toLowerCase()==="script"?ie:oe;l.lastIndex=c;let d=l.exec(e);if(d===null)return-1;let b=e.indexOf(">",d.index);if(b===-1)return-1;c=b+1;continue}if(e[c+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(c,c+64));if(!g){c++;continue}if(g[1].toLowerCase()===r){if(f--,c+=g[0].length,f===0)return c;continue}c+=g[0].length;continue}let i=/^<([a-z][\w-]*)\b/i.exec(e.slice(c,c+64));if(!i){c++;continue}let u=e.indexOf(">",c);if(u===-1)return-1;if(i[1].toLowerCase()===r){let g=e.slice(c,u+1);if(!(/\/\s*>$/.test(g)||M.has(r)))f++}c=u+1}return-1}var ce=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ae(e,o){let n=o,t=e.length;for(;;){while(n<t&&e[n]!=="<")n++;if(n>=t)return!1;if(e.startsWith("<!--",n)){let f=e.indexOf("-->",n+4);if(f===-1)return!1;n=f+3;continue}break}if(e[n+1]==="/")return!1;let r=e.indexOf(">",n);if(r===-1)return!1;let a=e.slice(n,r+1);return ce.test(a)}function uo(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let o=[],n=/<([a-zA-Z][\w-]*)/y,t=/\s/,r=new Set([":if",":show","x-if","x-show","@if","@show"]);se(e,(i,u)=>{n.lastIndex=u;let g=n.exec(i);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let l=n.lastIndex,d;while(l<i.length){let b=l;while(l<i.length&&t.test(i[l]))l++;let S=l;if(i[S]==="/"){S++;while(S<i.length&&t.test(i[S]))S++}if(i[S]===">"){if(d)o.push({start:u,end:S+1,tag:g[1],...d});return-1}if(l===b)return-1;let w=l;while(l<i.length&&!t.test(i[l])&&i[l]!=="="&&i[l]!==">")l++;if(l===w)return-1;let E=i.slice(w,l);if(E.startsWith("@")&&E.includes("("))return-1;let m=l,x=l;while(x<i.length&&t.test(i[x]))x++;if(i[x]!=="="){l=m;continue}x++;while(x<i.length&&t.test(i[x]))x++;let y=i[x];if(y==='"'||y==="'"){let R=i.indexOf(y,x+1);if(R===-1)return-1;if(!d&&y==='"'&&r.has(E))d={attrName:E,attrStart:b,attrEnd:R+1,value:i.slice(x+1,R)};l=R+1}else{l=x;while(l<i.length&&!t.test(i[l])&&i[l]!==">")l++}}return-1});let a=[],f=-1;for(let i of o){let{start:u,end:g,tag:l,attrName:d,value:b}=i;if(u<f)continue;let S=re(b);if(S===void 0)continue;let m=/\/\s*>$/.test(e.slice(u,g))||M.has(l.toLowerCase())?g:z(e,u,l,g);if(m===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ae(e,m))continue;if(S===!0){let y=e.slice(u,i.attrStart)+e.slice(i.attrEnd,g);a.push({start:u,end:g,replacement:y});continue}a.push({start:u,end:m,replacement:""}),f=m}if(a.length===0)return e;a.sort((i,u)=>i.start-u.start);let c=[],p=-1;for(let i of a){if(i.start<p)continue;c.push(i),p=i.end}let h=e;for(let i=c.length-1;i>=0;i--){let{start:u,end:g,replacement:l}=c[i];h=h.substring(0,u)+l+h.substring(g)}return h}var G=[":for","@for","x-for"];function Ur(e,o){if(!o||Object.keys(o).length===0)return e;if(!G.some((c)=>e.includes(`${c}=`)))return e;let n=Xn(e);if(Array.isArray(o.__stx_client_signal_names)){for(let c of o.__stx_client_signal_names)if(typeof c==="string")n.add(c)}let t=e,r=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=a.exec(t))!==null){let[c,p,h]=f,i=f.index,u=i+c.length,g=G.map((R)=>({attr:R,m:new RegExp(`\\s${R}="([^"]*)"`).exec(h)})).find((R)=>R.m!==null);if(!g||!g.m)continue;let l=co(g.m[1]);if(!l.iterable||!l.itemVar)continue;let d=l.iterable.trim().split(/[.[(]/)[0].trim();if(!d||n.has(d)||!(d in o))continue;let b=z(t,i,p,u);if(b===-1)continue;let S=h.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),w=t.slice(u,b-`</${p}>`.length),E={...o,[l.itemVar]:void 0};if(l.indexVar)E[l.indexVar]=void 0;let m=Ur(w,E),x=l.indexVar?`${l.iterable} as ${l.indexVar} => ${l.itemVar}`:`${l.iterable} as ${l.itemVar}`,y=p.toLowerCase()==="template"?m:`<${p}${S}>${m}</${p}>`;r.push({start:i,end:b,replacement:`@foreach(${x})${y}@endforeach`}),a.lastIndex=b}for(let c=r.length-1;c>=0;c--){let{start:p,end:h,replacement:i}=r[c];t=t.slice(0,p)+i+t.slice(h)}return t}function Wr(e,o){let n=e,t=/@(for|foreach)\s*\(/g,r,a=[],f=[];while((r=t.exec(n))!==null){let c=r[1],p=r.index,h=p+r[0].length,i=1,u=h;while(u<n.length&&i>0){if(n[u]==="(")i++;else if(n[u]===")")i--;u++}if(i!==0)continue;let g=n.substring(h,u-1).trim(),l=u,d=co(g),b=c==="for"?"@endfor":"@endforeach",S=1,w=l,E=c==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${c}\\s*\\(|end${c})`,"g");E.lastIndex=l;let m;while((m=E.exec(n))!==null)if(m[1].startsWith(c))S++;else if(S--,S===0){w=m.index+m[0].length;break}if(S!==0)continue;let x=()=>{let A=[d.itemVar,d.indexVar].filter(Boolean);if(A.length)f.push({start:p,end:w,vars:A})};if(d.iterable){let A=d.iterable.trim();if(A.startsWith("[")||A.startsWith("{")||A.startsWith("'")||A.startsWith('"')||A.startsWith("`")||/^-?\d/.test(A)){x();continue}let C=A.split(/[.[(]/)[0].trim(),v=o?C in o:!1,V=f.some((P)=>p>P.start&&p<P.end&&P.vars.includes(C));if(C&&(v||V)){x();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let y=n.substring(l,w-b.length).trim(),R=o?{...o}:{};if(d.itemVar)delete R[d.itemVar];if(d.indexVar)delete R[d.indexVar];let _=Wr(y,R),I=_.match(H),k;if(I){let[,A,C,v]=I;k=`<${A}${C} @for="${g}">${v}</${A}>`}else k=`<template @for="${g}">${_}</template>`;a.push({start:p,end:w,replacement:k}),t.lastIndex=w}for(let c=a.length-1;c>=0;c--){let{start:p,end:h,replacement:i}=a[c];n=n.substring(0,p)+i+n.substring(h)}return n}function le(e){let o=new Set,n=[],t=0,r=0,a=e.length,f=(i)=>{let u=t+1;while(u<a){let g=e[u];if(g==="\\"){u+=2;continue}if(g===i)return u+1;u++}return a},c=()=>{let i=t+2;while(i<a&&e[i]!==`
4
+ `)i++;return i},p=()=>{let i=t+2;while(i<a-1){if(e[i]==="*"&&e[i+1]==="/")return i+2;i++}return a},h=(i)=>{let u=i,g=0;while(u<a){let l=e[u];if(l==="/"&&e[u+1]==="/"){let d=u+2;while(d<a&&e[d]!==`
5
+ `)d++;u=d;continue}if(l==="/"&&e[u+1]==="*"){let d=u+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;u=d+2;continue}if(l==='"'||l==="'"||l==="`"){let d=u+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===l){d++;break}d++}u=d;continue}if(l==="("||l==="["||l==="{"){g++,u++;continue}if(l===")"||l==="]"||l==="}"){g--,u++;continue}if(l===";"&&g===0)return u+1;u++}return a};while(t<a){let i=e[t];if(i==="/"&&e[t+1]==="/"){let u=c();n.push(e.slice(t,u)),t=u;continue}if(i==="/"&&e[t+1]==="*"){let u=p();n.push(e.slice(t,u)),t=u;continue}if(i==='"'||i==="'"||i==="`"){let u=f(i);n.push(e.slice(t,u)),t=u;continue}if(i==="{"){r++,n.push(i),t++;continue}if(i==="}"){r--,n.push(i),t++;continue}if(r===0){let u=t>0?e[t-1]:"";if(u===""||/\s/.test(u)||u===";"||u==="}"||u==="{"){let l=e.slice(t).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(l){let d=l[2],b=h(t+l[0].length);if(o.has(d)){n.push(`/* stx: deduped const ${d} */`),t=b;continue}o.add(d),n.push(e.slice(t,b)),t=b;continue}}}n.push(i),t++}return n.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function D(e,o,n){for(let t of n){if(t.start>=o)return!1;if(t.end>e)return!0}return!1}function fe(e,o,n){let t=0;while(t<e.length){let r=e.indexOf(o,t);if(r===-1)return!1;if(!D(r,r+o.length,n))return!0;t=r+o.length}return!1}function de(e,o){if(fe(e,"<body",o)){let r=new RegExp(`<body(${j})>`,"g"),a;while((a=r.exec(e))!==null)if(!D(a.index,a.index+a[0].length,o))return a.index+a[0].length-1;return null}let n=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${j})>`,"gi"),t;while((t=n.exec(e))!==null){if(D(t.index,t.index+t[0].length,o))continue;if(ue.has(t[1].toLowerCase()))continue;return t.index+t[0].length-1}return null}function ge(e,o,n,t){let r=[],a=` data-stx="${t}"`,f=0,c=!1,p=(h)=>{if(n!==null&&!c&&n>=f&&n<=h)r.push(e.slice(f,n),a,e.slice(n,h)),c=!0;else r.push(e.slice(f,h))};for(let h of o){if(h.start<f)continue;p(h.start),f=h.end}return p(e.length),r.join("")}async function qr(e,o,n,t={}){let r=Tl(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:c,bundleClientScript:p}=await s("stx/client-script-bundler",()=>import("./chunk-cs8wq7nv.js"));for(let m of r){let x=m.body;if(Me(m.attrs))x=Le(x);if(t.forceClientSetup||a.test(x)){f.push({content:x,start:m.start,end:m.end});continue}if(!c(x))continue;try{let y=await p(It(x).code,o||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(y))f.push({content:x,start:m.start,end:m.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let h=`${o??""}\x00${f.map((m)=>m.content).join("\x00")}`,i=`__stx_setup_${Bun.hash(h).toString(36).slice(0,10)}`,u=[];for(let m=0;m<f.length;m++){let x=f[m].bundled??It(f[m].content).code;if(!f[m].bundled&&c(x))x=await p(x,o||"",{projectRoot:process.cwd()});x=ht(x);let y=T(x);u.push(`// \u2500\u2500 merged signal script #${m+1} \u2500\u2500
6
+ ${y}`)}let g=u.join(`
7
+
8
+ `);g=le(g);let d=L(g).split(",").map((m)=>m.trim()).filter(Boolean),b=fn(g,n),S=`
9
+ <script data-stx-scoped>
10
+ function ${i}() {
11
+ ${st("const",d)}
12
+ ${an(`${b}${g}`)}
13
+ return ${is(g,d)};
14
+ }
15
+ window.__stx_latestSetup=${i};
16
+ if(window.stx)window.stx._latestSetup=${i};
17
+ </script>`,w=de(e,f);return{output:ge(e,f,w,i),setupCode:S}}async function po(e,o,n,t){if(!Vr(e,n))return e;let r=e;if(o.skipSignalsRuntime)return r;let{output:a,setupCode:f}=await qr(r,n,t);if(r=a,!f){let c=q(r);if(c&&!/data-stx/.test(c.attrs)&&!/data-stx-auto/.test(c.attrs)){let p=c.tag.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>");r=r.slice(0,c.index)+p+r.slice(c.index+c.tag.length)}}if(r=await Yn(r,o),f){let c=ca(r,/<\/head>/i),p=c===-1?ca(r,/<body[^>]*>/i):-1;if(c!==-1)r=`${r.slice(0,c)}${f}
18
+ ${r.slice(c)}`;else if(p!==-1){let h=/<body[^>]*>/i.exec(r.slice(p))[0],i=p+h.length;r=`${r.slice(0,i)}
19
+ ${f}${r.slice(i)}`}else r=`${r}
20
+ ${f}`}return r}function ca(e,o){let n=/<(script|style)\b[\s\S]*?<\/\1>/gi,t=[],r;while((r=n.exec(e))!==null)t.push([r.index,r.index+r[0].length]);let a=new RegExp(o.source,o.flags.replace(/[gy]/g,"")),f=0;while(f<e.length){let c=a.exec(e.slice(f));if(!c)return-1;let p=f+c.index;if(!t.some(([i,u])=>p>=i&&p<u))return p;f=p+Math.max(c[0].length,1)}return-1}var X="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function $l(e){let o=[];for(let n of e.split(",")){let t=n.trim();if(!t||t.startsWith("type "))continue;let r=t.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(r&&r[1]!==r[2])o.push(`${r[2]} = ${r[1]}`)}if(o.length===0)return X;return`var ${o.join(", ")}; ${X}`}var pe=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function ht(e){return e.replace(pe,(o,n)=>$l(n))}
21
+ export{hp,Tl,co,Vr,Xn,lo,uo,Ur,Wr,qr,po,ca,$l,ht};