@stacksjs/stx 0.2.633 → 0.2.635

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 (223) hide show
  1. package/dist/chunk-0d7dqt4d.js +2 -0
  2. package/dist/chunk-0grt24vd.js +2 -0
  3. package/dist/{chunk-7q55jxf5.js → chunk-0tm9ep8b.js} +2 -2
  4. package/dist/{chunk-7gq7w95h.js → chunk-14yjt309.js} +3 -3
  5. package/dist/{chunk-ygpa12ez.js → chunk-1d25z8q2.js} +3 -3
  6. package/dist/{chunk-6bhaa9g7.js → chunk-1wb98s7b.js} +13 -13
  7. package/dist/{chunk-nh7bcc4h.js → chunk-2efrxnnt.js} +2 -2
  8. package/dist/chunk-2vzfn6vy.js +2 -0
  9. package/dist/chunk-3bsz101e.js +2 -0
  10. package/dist/{chunk-w9e17a74.js → chunk-3e2v2fdh.js} +4 -4
  11. package/dist/{chunk-jq7ymh7q.js → chunk-3f4xy76k.js} +6 -6
  12. package/dist/chunk-3jwjesb5.js +2 -0
  13. package/dist/{chunk-968jp303.js → chunk-3td99hnc.js} +3 -3
  14. package/dist/chunk-4b4es5wg.js +2 -0
  15. package/dist/{chunk-phbnrw2h.js → chunk-4n24jbfs.js} +2 -2
  16. package/dist/{chunk-72p9brmx.js → chunk-4vkpgz28.js} +9 -9
  17. package/dist/chunk-4xeafdr6.js +2 -0
  18. package/dist/chunk-4xkqdfqd.js +2 -0
  19. package/dist/chunk-5k989nr4.js +2 -0
  20. package/dist/chunk-5v95x083.js +3 -0
  21. package/dist/chunk-5yf9yzkp.js +2 -0
  22. package/dist/{chunk-923vrf9c.js → chunk-6gwrmn3w.js} +7 -7
  23. package/dist/{chunk-p77g4mhy.js → chunk-6w1ngwsd.js} +2 -2
  24. package/dist/chunk-7m5xrqnj.js +2852 -0
  25. package/dist/chunk-7mtdjjbt.js +2 -0
  26. package/dist/{chunk-94yycjz8.js → chunk-7vdcsr14.js} +2 -2
  27. package/dist/{chunk-k5atee35.js → chunk-839m1t8t.js} +1 -1
  28. package/dist/chunk-88dxeynx.js +2 -0
  29. package/dist/chunk-8er7jc3c.js +2 -0
  30. package/dist/chunk-8phbb8wj.js +2 -0
  31. package/dist/{chunk-p4hmv654.js → chunk-8y3mff5c.js} +2 -2
  32. package/dist/{chunk-gqdh68vx.js → chunk-954tcahb.js} +2 -2
  33. package/dist/{chunk-sg5zgq5v.js → chunk-97zrn4wb.js} +5 -5
  34. package/dist/{chunk-q6evk3a4.js → chunk-9gx5p7zh.js} +2 -2
  35. package/dist/{chunk-g2rxbaah.js → chunk-a6hv03yw.js} +3 -3
  36. package/dist/chunk-a7s1j320.js +127 -0
  37. package/dist/chunk-a83r1xx9.js +2 -0
  38. package/dist/chunk-abpeac2d.js +2 -0
  39. package/dist/chunk-adzsqsjt.js +2 -0
  40. package/dist/{chunk-4fv3jq16.js → chunk-ahyq08mp.js} +2 -2
  41. package/dist/chunk-b1ndskw9.js +2 -0
  42. package/dist/chunk-b7fp3zta.js +2 -0
  43. package/dist/{chunk-pbphq5pj.js → chunk-b7hv69ty.js} +2 -2
  44. package/dist/{chunk-avt9cske.js → chunk-baw176ay.js} +6 -6
  45. package/dist/chunk-bgfkbesj.js +2 -0
  46. package/dist/{chunk-cy1j2zpr.js → chunk-bk9bx2ns.js} +2 -2
  47. package/dist/{chunk-gh34r6qb.js → chunk-bsts9pr5.js} +2 -2
  48. package/dist/{chunk-jzmz66a3.js → chunk-bysyrwfa.js} +3 -3
  49. package/dist/{chunk-y89m80pf.js → chunk-c4ysk7x2.js} +4 -4
  50. package/dist/{chunk-90pe63me.js → chunk-camd8j1q.js} +3 -3
  51. package/dist/{chunk-0qt1887j.js → chunk-cdab66xt.js} +2 -2
  52. package/dist/{chunk-gv15dd41.js → chunk-cjr8cpb7.js} +3 -3
  53. package/dist/{chunk-y8h823cb.js → chunk-cw9pc5yx.js} +41 -41
  54. package/dist/chunk-cy83yfy9.js +2 -0
  55. package/dist/chunk-dbqb1a51.js +2 -0
  56. package/dist/{chunk-pk757m0k.js → chunk-e0nq8g9j.js} +1 -1
  57. package/dist/chunk-e8t64hxk.js +2 -0
  58. package/dist/chunk-e943xk88.js +2 -0
  59. package/dist/{chunk-w8bf4mbw.js → chunk-emcbmr0r.js} +3 -3
  60. package/dist/{chunk-kpxty3pe.js → chunk-f30t1g74.js} +2 -2
  61. package/dist/{chunk-tx4xxpgg.js → chunk-f3agc1a3.js} +3 -3
  62. package/dist/{chunk-27784ceh.js → chunk-fm80xpxn.js} +4 -4
  63. package/dist/{chunk-xrrkf04f.js → chunk-fwawm5r3.js} +2 -2
  64. package/dist/chunk-g039c67x.js +2 -0
  65. package/dist/{chunk-gxpgwpq7.js → chunk-g9dz0mx9.js} +2 -2
  66. package/dist/{chunk-bd5na0h0.js → chunk-g9sdjgfw.js} +5 -5
  67. package/dist/{chunk-k2nrx78c.js → chunk-gcj5jfbv.js} +2 -2
  68. package/dist/chunk-ghfxfcr9.js +2 -0
  69. package/dist/chunk-gvyq9xt6.js +2 -0
  70. package/dist/chunk-h30y9k44.js +2 -0
  71. package/dist/{chunk-236twqn4.js → chunk-hbzk179w.js} +3 -3
  72. package/dist/chunk-hwp3m8a8.js +2 -0
  73. package/dist/{chunk-2bxsc7gf.js → chunk-j79f6syh.js} +4 -4
  74. package/dist/chunk-jarptkbv.js +2 -0
  75. package/dist/{chunk-ftkrsvqp.js → chunk-jtr30kkz.js} +1 -1
  76. package/dist/{chunk-fdy0hka5.js → chunk-kjtvdqb9.js} +13 -13
  77. package/dist/chunk-kk6tq07c.js +3 -0
  78. package/dist/chunk-km4xp898.js +2 -0
  79. package/dist/{chunk-j1rnhv0w.js → chunk-kr14jt4m.js} +3 -3
  80. package/dist/{chunk-az1y9jks.js → chunk-kwwrrasa.js} +2 -2
  81. package/dist/chunk-kxbw0e2f.js +3 -0
  82. package/dist/{chunk-a887js9p.js → chunk-m56ee2tw.js} +5 -5
  83. package/dist/chunk-meze7k8v.js +2 -0
  84. package/dist/chunk-mfwrxz9z.js +2 -0
  85. package/dist/chunk-mmpm1awz.js +2 -0
  86. package/dist/{chunk-0whv8hnp.js → chunk-mn97jhaq.js} +2 -2
  87. package/dist/{chunk-3yh585yv.js → chunk-mpb0ezee.js} +3 -3
  88. package/dist/{chunk-g35zftfn.js → chunk-mvt5n2q4.js} +1 -1
  89. package/dist/chunk-n7vetrt4.js +2 -0
  90. package/dist/chunk-nd716zha.js +2 -0
  91. package/dist/{chunk-0hs8jgw5.js → chunk-npn3h566.js} +2 -2
  92. package/dist/{chunk-5x59qjzs.js → chunk-pak6ngv0.js} +6 -6
  93. package/dist/{chunk-v5500ews.js → chunk-pp6ycfay.js} +2 -2
  94. package/dist/{chunk-vhktd16g.js → chunk-psranzfr.js} +2 -2
  95. package/dist/chunk-ptjz4f2e.js +2 -0
  96. package/dist/{chunk-8qrhz7n7.js → chunk-ptv5f34x.js} +6 -6
  97. package/dist/{chunk-86zj56pf.js → chunk-q0kbn64j.js} +5 -5
  98. package/dist/chunk-q4hmgj72.js +2 -0
  99. package/dist/chunk-q841b6x4.js +2 -0
  100. package/dist/{chunk-v4tmwamd.js → chunk-qa58qdz8.js} +2 -2
  101. package/dist/{chunk-8hjrr8j3.js → chunk-qczse5w4.js} +33 -33
  102. package/dist/{chunk-tn7hgtyn.js → chunk-qjfgdcck.js} +5 -5
  103. package/dist/chunk-qnh5x7vv.js +2 -0
  104. package/dist/chunk-qxjfvkjt.js +2 -0
  105. package/dist/chunk-rhhwz7e9.js +2 -0
  106. package/dist/chunk-rpbe5h6v.js +2 -0
  107. package/dist/chunk-rrdn4qnn.js +2 -0
  108. package/dist/{chunk-xm911f1g.js → chunk-ry1w4ghk.js} +1 -1
  109. package/dist/chunk-s7c9kb53.js +2 -0
  110. package/dist/chunk-sfj84n72.js +2 -0
  111. package/dist/chunk-sgr2hhsc.js +2 -0
  112. package/dist/{chunk-jbmjcs83.js → chunk-shcn4wve.js} +2 -2
  113. package/dist/{chunk-zs7t42b5.js → chunk-sn0a8cjd.js} +5 -5
  114. package/dist/chunk-taztcvv3.js +2 -0
  115. package/dist/chunk-vczt5k2j.js +2 -0
  116. package/dist/chunk-vj5fghnv.js +2 -0
  117. package/dist/{chunk-6dzqjbsz.js → chunk-vyjdzpb8.js} +2 -2
  118. package/dist/chunk-wj4rf7sb.js +2 -0
  119. package/dist/chunk-wn1s8af8.js +2 -0
  120. package/dist/{chunk-t7e9y46s.js → chunk-x7g0946r.js} +1 -1
  121. package/dist/{chunk-rq1c46zb.js → chunk-xdwpbqzz.js} +34 -9
  122. package/dist/chunk-y3jyk5bj.js +2 -0
  123. package/dist/chunk-y51ndrdb.js +2 -0
  124. package/dist/{chunk-xrkechs8.js → chunk-y5b25eks.js} +5 -5
  125. package/dist/{chunk-tc7gm68a.js → chunk-ycz5th6b.js} +2 -2
  126. package/dist/{chunk-3kkf43fv.js → chunk-ym0e374a.js} +2 -2
  127. package/dist/{chunk-pxpmx8vc.js → chunk-ymntav9f.js} +1 -1
  128. package/dist/{chunk-8kc6byaz.js → chunk-yp8tk3v3.js} +5 -5
  129. package/dist/{chunk-bng1ayzm.js → chunk-ytv0k9gy.js} +9 -9
  130. package/dist/chunk-ytxzy6eg.js +2 -0
  131. package/dist/chunk-ywf319rp.js +2 -0
  132. package/dist/chunk-yww6c9we.js +2 -0
  133. package/dist/chunk-yy43hxb7.js +2 -0
  134. package/dist/chunk-z42jb949.js +2 -0
  135. package/dist/{chunk-y04hzz4w.js → chunk-zfrpss8y.js} +4 -4
  136. package/dist/{chunk-8b2452m1.js → chunk-zpzk4wd2.js} +11 -11
  137. package/dist/chunk-zw20a7q4.js +2 -0
  138. package/dist/cli.js +76 -76
  139. package/dist/client/signals-public-api-runtime.js +1 -0
  140. package/dist/client/signals-timer-runtime.js +24 -0
  141. package/dist/craft-entry.js +2 -2
  142. package/dist/craft.js +2 -2
  143. package/dist/lazy-module.js +2 -1
  144. package/dist/menubar.d.ts +2 -0
  145. package/dist/menubar.js +15 -2
  146. package/dist/native/compiler/headwind-to-style.d.ts +6 -3
  147. package/dist/native/compiler/headwind-to-style.js +25 -3
  148. package/dist/native/compiler/html-to-ir.js +4 -4
  149. package/dist/native/prop-names.d.ts +1 -1
  150. package/dist/native/prop-names.js +3 -1
  151. package/dist/native/runtime/native-host.js +66 -7
  152. package/dist/pwa.js +3 -3
  153. package/dist/runtime-globals.js +1 -0
  154. package/dist/ssg.js +9 -9
  155. package/dist/stx-module.d.ts +1 -0
  156. package/package.json +5 -5
  157. package/stx-module.d.ts +1 -0
  158. package/stx.d.ts +7 -0
  159. package/dist/chunk-0mgtrbaa.js +0 -2
  160. package/dist/chunk-0xc6rncm.js +0 -2852
  161. package/dist/chunk-1tpr8d8n.js +0 -2
  162. package/dist/chunk-20kjbf3h.js +0 -2
  163. package/dist/chunk-3gcg3gvy.js +0 -2
  164. package/dist/chunk-3wsrhj0k.js +0 -2
  165. package/dist/chunk-575cqc6z.js +0 -2
  166. package/dist/chunk-5x836mv3.js +0 -2
  167. package/dist/chunk-5yceay9n.js +0 -2
  168. package/dist/chunk-6pg2kxsq.js +0 -2
  169. package/dist/chunk-7nthebqr.js +0 -2
  170. package/dist/chunk-7s5304ae.js +0 -2
  171. package/dist/chunk-8dybd0g5.js +0 -2
  172. package/dist/chunk-8em788gc.js +0 -2
  173. package/dist/chunk-9svygzeg.js +0 -2
  174. package/dist/chunk-9z4qr5w9.js +0 -2
  175. package/dist/chunk-af4ss0p5.js +0 -2
  176. package/dist/chunk-aj34t5h3.js +0 -2
  177. package/dist/chunk-atcy4zq6.js +0 -2
  178. package/dist/chunk-az28kd7f.js +0 -2
  179. package/dist/chunk-cncdgxk3.js +0 -2
  180. package/dist/chunk-d2t2pq1s.js +0 -3
  181. package/dist/chunk-dcx2t3sy.js +0 -2
  182. package/dist/chunk-dn28q0m3.js +0 -2
  183. package/dist/chunk-dn89zg1v.js +0 -2
  184. package/dist/chunk-dwddzp5f.js +0 -2
  185. package/dist/chunk-enchx79c.js +0 -2
  186. package/dist/chunk-ev8ma4ph.js +0 -2
  187. package/dist/chunk-ftrsaag8.js +0 -2
  188. package/dist/chunk-g6efz3ww.js +0 -2
  189. package/dist/chunk-gd59tkhr.js +0 -2
  190. package/dist/chunk-h1g9m148.js +0 -2
  191. package/dist/chunk-h8tew5mz.js +0 -2
  192. package/dist/chunk-hdrcgepx.js +0 -127
  193. package/dist/chunk-hn64343d.js +0 -2
  194. package/dist/chunk-htaed68z.js +0 -2
  195. package/dist/chunk-j5jkh05f.js +0 -2
  196. package/dist/chunk-j90yng9b.js +0 -2
  197. package/dist/chunk-jabb3v4c.js +0 -2
  198. package/dist/chunk-jczvjn7z.js +0 -2
  199. package/dist/chunk-kqkhcbrx.js +0 -2
  200. package/dist/chunk-mgzegkvk.js +0 -2
  201. package/dist/chunk-mk71833d.js +0 -2
  202. package/dist/chunk-n3s3w1f5.js +0 -2
  203. package/dist/chunk-nj0b4ryt.js +0 -2
  204. package/dist/chunk-ny6enm8b.js +0 -3
  205. package/dist/chunk-p8ndfekp.js +0 -2
  206. package/dist/chunk-qhjm9hvz.js +0 -2
  207. package/dist/chunk-qzy34xmt.js +0 -2
  208. package/dist/chunk-ra40trfh.js +0 -2
  209. package/dist/chunk-rjq597cn.js +0 -2
  210. package/dist/chunk-rrdwynz4.js +0 -2
  211. package/dist/chunk-sddytf9n.js +0 -2
  212. package/dist/chunk-shhtbdnj.js +0 -2
  213. package/dist/chunk-t4g97h08.js +0 -2
  214. package/dist/chunk-t7f9zmy8.js +0 -2
  215. package/dist/chunk-tme29zh9.js +0 -3
  216. package/dist/chunk-x1xx8qt0.js +0 -2
  217. package/dist/chunk-xmfhb2v0.js +0 -2
  218. package/dist/chunk-xsw183n7.js +0 -2
  219. package/dist/chunk-xtwe2rnp.js +0 -2
  220. package/dist/chunk-xxnh7gv8.js +0 -2
  221. package/dist/chunk-y84n0dvg.js +0 -2
  222. package/dist/chunk-zr0k9pz5.js +0 -2
  223. package/dist/chunk-zytcxy8p.js +0 -2
@@ -1,2852 +0,0 @@
1
- // @bun
2
- import{Fn,y,ta,qt,oo,na,ra,sa,oa}from"./chunk-d2t2pq1s.js";import{I}from"./chunk-4fv3jq16.js";import{t,W,q,i,ae,no,O,Ut,Ln,ro,Er,l,p,ea,N,Ie,ut,c,$r}from"./chunk-8qrhz7n7.js";import{Hn,Vn,Or,Ne}from"./chunk-y89m80pf.js";import{S,Zs,ct,Qs,Ki,An,Pn,Xi,Pe,Ji,In,Yi,Vt,eo,Zi,On,Dn,_r,we,to,xe,Cr}from"./chunk-8b2452m1.js";import{Ks,Xs,Js,Ys,wr,xr}from"./chunk-6bhaa9g7.js";import{Wi,Ws,yr,br}from"./chunk-2bxsc7gf.js";import{be,Ht,vr,Gs,_,it}from"./chunk-xrrkf04f.js";import{Rn}from"./chunk-cy1j2zpr.js";import{uo}from"./chunk-3kkf43fv.js";import{ji,Bi,zi,Hi}from"./chunk-jzmz66a3.js";import{ot}from"./chunk-v5500ews.js";import{s,Re}from"./chunk-w9e17a74.js";import{zt,Gi,Tn,a,$n}from"./chunk-ny6enm8b.js";import{d}from"./chunk-yn2d8x8m.js";import{E,D,jn,so}from"./chunk-jbmjcs83.js";import{Nr}from"./chunk-p4hmv654.js";import rs from"path";import Mo from"fs";var Gh=new Set(["touchstart","touchmove","wheel","mousewheel"]);function lc(v,k){if(k.passive)return!0;if(k.prevent||k.nonpassive)return!1;return Gh.has(v.toLowerCase())}var Xu=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),Zu={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},Jh=new Set(["ctrl","alt","shift","meta"]),Yu={left:0,middle:1,right:2};function Gu(v){let k={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let C of v){let R=C.toLowerCase();if(R==="prevent")k.prevent=!0;else if(R==="stop")k.stop=!0;else if(R==="once")k.once=!0;else if(R==="capture")k.capture=!0;else if(R==="self")k.self=!0;else if(R==="passive")k.passive=!0;else if(R==="nonpassive")k.nonpassive=!0;else if(Jh.has(R))k.systemKeys.push(R);else if(R in Yu)k.mouse=R;else if(R in Zu||/^[a-z]$/.test(R))k.keys.push(Zu[R]||R.toUpperCase());else if(R.startsWith("debounce")){let T=R.match(/debounce(?:\.(\d+))?/);k.debounce=T?.[1]?Number.parseInt(T[1],10):300}else if(R.startsWith("throttle")){let T=R.match(/throttle(?:\.(\d+))?/);k.throttle=T?.[1]?Number.parseInt(T[1],10):300}}return k}function $d(v,k=""){let C=[],R=0,T=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,z;while((z=T.exec(v))!==null){let[F,V,H]=z,K=z.index,X=K+F.length,G=`__stx_evt_${k}${R++}`,te=[],ce=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,ee;while((ee=ce.exec(H))!==null){let[,ue,de]=ee,fe=ue.split("."),pe=fe[0];if(!Xu.has(pe))continue;te.push({attribute:`@${ue}`,event:pe,handler:de,modifiers:Gu(fe.slice(1)),elementId:G})}let le=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((ee=le.exec(H))!==null){let[,ue,de]=ee,fe=ue.split("."),pe=fe[0];if(!Xu.has(pe))continue;te.push({attribute:`@${ue}`,event:pe,handler:de,modifiers:Gu(fe.slice(1)),elementId:G})}if(te.length>0)C.push({originalTag:F,elementId:G,events:te,startIndex:K,endIndex:X})}return C}function Yh(v){let k=[],{modifiers:C}=v;if(C.self)k.push("if ($event.target !== $el) return");for(let R of C.systemKeys)k.push(`if (!$event.${R}Key) return`);if(C.keys.length>0){let R=C.keys.map((T)=>`$event.key === '${T}'`).join(" || ");k.push(`if (!(${R})) return`)}if(C.mouse!==null){let R=Yu[C.mouse];k.push(`if ($event.button !== ${R}) return`)}if(C.prevent)k.push("$event.preventDefault()");if(C.stop)k.push("$event.stopPropagation()");return k.join("; ")}function Qh(v,k){let C=v;if(k.debounce!==null)C=`__stx_debounce(() => { ${C} }, ${k.debounce})`;else if(k.throttle!==null)C=`__stx_throttle(() => { ${C} }, ${k.throttle})`;return C}function uc(v){let k=v.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(k))return v;return`if (typeof ${k} === 'function' && !${k}._isSignal) ${k}($event);`}function ey(v){let{modifiers:k}=v,C=v.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),R=Yh(v),T=Qh(uc(v.handler),k),z=[];if(k.once)z.push("once: true");if(k.capture)z.push("capture: true");if(lc(v.event,k))z.push("passive: true");let F=z.length>0?`, { ${z.join(", ")} }`:"",V=T.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(v.event==="mounted")return`
3
- (function() {
4
- var $el = document.getElementById('${C}');
5
- if (!$el) return;
6
- // Run mounted handler immediately (DOM is ready)
7
- var scope = $el.closest('[data-stx-scope]');
8
- if (scope && scope.__stx_execute) {
9
- scope.__stx_execute('${V}', null, $el);
10
- }
11
- else {
12
- __stx_runHandler('${V}', null, $el);
13
- }
14
- })();`;if(v.event==="unmounted")return`
15
- (function() {
16
- var $el = document.getElementById('${C}');
17
- if (!$el) return;
18
- // Set up MutationObserver to detect removal
19
- var observer = new MutationObserver(function(mutations) {
20
- for (var m of mutations) {
21
- for (var node of m.removedNodes) {
22
- if (node === $el || (node.contains && node.contains($el))) {
23
- observer.disconnect();
24
- var scope = $el.closest('[data-stx-scope]');
25
- if (scope && scope.__stx_execute) {
26
- scope.__stx_execute('${V}', null, $el);
27
- }
28
- else {
29
- __stx_runHandler('${V}', null, $el);
30
- }
31
- return;
32
- }
33
- }
34
- }
35
- });
36
- observer.observe(document.body, { childList: true, subtree: true });
37
- // Store observer for cleanup
38
- $el.__stx_unmount_observer = observer;
39
- })();`;return`
40
- (function() {
41
- var $el = document.getElementById('${C}');
42
- if (!$el) return;
43
- // eslint-disable-next-line pickier/no-unused-vars
44
- $el.addEventListener('${v.event}', function($event) {
45
- ${R?R+";":""}
46
- // Find the closest reactive scope and execute within its context
47
- var scope = $el.closest('[data-stx-scope]');
48
- if (scope && scope.__stx_execute) {
49
- scope.__stx_execute('${V}', $event, $el);
50
- }
51
- else {
52
- // Fallback for non-reactive context (entity-safe; decoded + run in memory)
53
- __stx_runHandler('${V}', $event, $el);
54
- }
55
- }${F});
56
- })();`}function dc(v){if(v.length===0)return"";return`
57
- <script data-stx-events>
58
- (function() {
59
- 'use strict';
60
-
61
- // Utility functions
62
- function __stx_debounce(fn, delay) {
63
- var timeout;
64
- return function() {
65
- var args = arguments;
66
- var ctx = this;
67
- clearTimeout(timeout);
68
- timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
69
- };
70
- }
71
-
72
- function __stx_throttle(fn, delay) {
73
- var last = 0;
74
- return function() {
75
- var now = Date.now();
76
- if (now - last >= delay) {
77
- last = now;
78
- fn.apply(this, arguments);
79
- }
80
- };
81
- }
82
-
83
- // Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
84
- // so the surrounding script element can never contain raw markup, including
85
- // its own closing tag; we decode it to JS only in memory here, then run it
86
- // with $event/$el in scope.
87
- //
88
- // This comment must not spell that closing tag out. It used to, as an
89
- // example, and a browser ends the script element at the FIRST one it sees \u2014
90
- // so everything below this line, __stx_runHandler included, was emitted as
91
- // page text and no listener was ever bound. The comment about escaping was
92
- // the thing that needed escaping.
93
- function __stx_runHandler(h, $event, $el) {
94
- var code = h
95
- .replace(/&lt;/g, '<')
96
- .replace(/&gt;/g, '>')
97
- .replace(/&quot;/g, '"')
98
- .replace(/&#39;/g, "'")
99
- .replace(/&#x27;/g, "'")
100
- .replace(/&amp;/g, '&');
101
- try {
102
- // eslint-disable-next-line no-new-func
103
- (new Function('$event', '$el', code)).call($el, $event, $el);
104
- }
105
- catch (e) {
106
- if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
107
- }
108
- }
109
-
110
- // Event listeners
111
- ${v.map(ey).join(`
112
- `)}
113
- })();
114
- </script>`}function ty(v,k=""){let C=$d(v,k);if(C.length===0)return{template:v,bindings:[]};let R=v,T=[];for(let z=C.length-1;z>=0;z--){let F=C[z],V=F.originalTag;if(!V.includes(" id="))V=V.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${F.elementId}"`);else{let H=V.match(/id=["']([^"']+)["']/);if(H)for(let K of F.events)K.elementId=H[1]}for(let H of F.events){let K=H.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=new RegExp(`\\s*${K}\\s*=\\s*"[^"]*"`,"g"),G=new RegExp(`\\s*${K}\\s*=\\s*'[^']*'`,"g");V=V.replace(X,""),V=V.replace(G,"")}R=R.slice(0,F.startIndex)+V+R.slice(F.endIndex),T.push(...F.events)}return{template:R,bindings:T}}function Ju(v){let k=v.$uid;return typeof k==="string"&&k?`${k}_`:""}function _d(v,k,C){if(na(v))return v;if(k.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(v))return v;let{template:V,bindings:H}=ty(v,Ju(k)),K=k.__stx_event_bindings||[];return k.__stx_event_bindings=[...K,...H],V}let R=$d(v,Ju(k));if(R.length===0)return v;let T=v;for(let V=R.length-1;V>=0;V--){let H=R[V],K=H.originalTag;if(!K.includes(" id="))K=K.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${H.elementId}"`);else{let X=K.match(/id=["']([^"']+)["']/);if(X)for(let G of H.events)G.elementId=X[1]}for(let X of H.events){let G=X.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),te=new RegExp(`\\s*${G}\\s*=\\s*"[^"]*"`,"g"),ce=new RegExp(`\\s*${G}\\s*=\\s*'[^']*'`,"g");K=K.replace(te,""),K=K.replace(ce,"")}T=T.slice(0,H.startIndex)+K+T.slice(H.endIndex)}let z=dc(R.flatMap((V)=>V.events)),F=T.lastIndexOf("</body>");if(F!==-1)T=T.slice(0,F)+z+`
115
- `+T.slice(F);else T+=z;return T}function Ed(v,k){let C=new Set;for(let R of v.split(",")){let T=R.trim().replace(/^\.\.\./,"").trim();if(!T)continue;if(k){let z=T.lastIndexOf(":");if(z!==-1)T=T.slice(z+1).trim()}if(T=T.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(T))C.add(T)}return C}function Ui(v,k){let C=s(v),{depths:R,balanced:T}=Re(C),z=(V)=>!T||R[V]===0,F=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${k}\\b)`,"g");for(let V of C.matchAll(F)){let H=(V.index??0)+V[0].length-V[1].length;if(z(H))return!0}for(let V of C.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(z(V.index??0)&&Ed(V[1],!0).has(k))return!0;for(let V of C.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(z(V.index??0)&&Ed(V[1],!1).has(k))return!0;return!1}function M(v,k=!1){let C=s(v),R=[],T=new Set,z=0,F=0,V=C.length,H=()=>{if(z!==0)return;let K=C.slice(F).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(K){if(k&&K[1]==="const")return;let ee=K[2];if(!T.has(ee))R.push(ee),T.add(ee);return}let X=C.slice(F).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(X){if(k&&C.slice(F).startsWith("const"))return;X[1].split(",").forEach((ee)=>{let le=ee.trim();if(!le)return;let ue=le.indexOf(":"),fe=(ue>=0?le.slice(ue+1).trim():le).split(/[\s=]/)[0];if(fe&&!T.has(fe))R.push(fe),T.add(fe)});return}let G=C.slice(F).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(G){if(k&&C.slice(F).startsWith("const"))return;G[1].split(",").forEach((ee)=>{let le=ee.trim().replace(/^\.\.\./,"");if(!le)return;let ue=le.split(/[\s=]/)[0];if(ue&&!T.has(ue))R.push(ue),T.add(ue)});return}if(k)return;let te=C.slice(F).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let ee=te[1];if(!T.has(ee))R.push(ee),T.add(ee);return}let ce=C.slice(F).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ce){let ee=ce[1];if(!T.has(ee))R.push(ee),T.add(ee)}};while(F<V){if(C[F]==="{"){z++,F++;continue}if(C[F]==="}"){z--,F++;continue}if(z===0&&/[a-z]/i.test(C[F])&&(F===0||/\s|[;{}()]/.test(C[F-1])))H();F++}return R.join(", ")}function qo(v){return`{ enumerable: true, configurable: true, get() { return ${v} }, set(__stxValue_${v}) { ${v} = __stxValue_${v} } }`}function ny(v,k=M(v).split(",").map((C)=>C.trim()).filter(Boolean)){let C=new Set(M(v,!0).split(",").map((R)=>R.trim()));return k.map((R)=>C.has(R)?`get ${R}() { return ${R} }, set ${R}(__stxValue_${R}) { ${R} = __stxValue_${R} }`:R).join(", ")}function Ko(v,k){let C=`{ ${ny(v,k)} }`;return M(v).split(",").some((R)=>R.trim()==="__stxLiveBindings")?`Object.defineProperties(${C}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:C}var Cd="",Xo,Ar=/^[A-Za-z_$][\w$]*$/,ry=new Set(["if","for","while","switch","with"]),Rd=["(","[","{"],Ad=[")","]","}"],sy=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function iy(v){let k=s(v),C=[];for(let R of k.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let T=R.index??0;C.push({text:R[0],start:T,end:T+R[0].length})}return{code:k,tokens:C}}function fc(v){if(Xo&&v===Cd)return Xo;let{code:k,tokens:C}=iy(v),R=new Map,T=[];for(let ee=0;ee<C.length;ee++){let le=C[ee].text;if(["(","[","{"].includes(le))T.push(ee);else if([")","]","}"].includes(le)){let ue=T.at(-1);if(ue!==void 0&&["()","[]","{}"].includes(C[ue].text+le))T.pop(),R.set(ue,ee),R.set(ee,ue)}}function z(ee,le){let ue=[],de=ee;for(let fe=ee;fe<le;fe++){if(["(","[","{"].includes(C[fe].text)&&(R.get(fe)??le)<le){fe=R.get(fe);continue}if(C[fe].text===",")ue.push([de,fe]),de=fe+1}return ue.push([de,le]),ue}let F=[];function V(ee,le,ue,de=!1){if(C[ee]?.text==="...")ee++;if(ee>=le)return;let fe=C[ee].text;if(Ar.test(fe)){if(ue.add(fe),ue===X)F.push({name:fe,token:ee,functionScoped:de});return}if(fe!=="{"&&fe!=="[")return;let pe=R.get(ee);if(pe===void 0||pe>=le)return;for(let[Ae,Se]of z(ee+1,pe)){let ve=Ae;if(fe==="{")for(let De=Ae;De<Se;De++){if(C[De].text===":"){ve=De+1;break}if(C[De].text==="=")break;if(["(","[","{"].includes(C[De].text)&&R.has(De))De=R.get(De)}V(ve,Se,ue,de)}}function H(ee,le){let ue=new Set;for(let[de,fe]of z(ee,le))V(de,fe,ue);return ue}function K(ee){let le=ee;for(;le<C.length;le++){let ue=C[le].text;if(["(","[","{"].includes(ue)&&R.has(le)){le=R.get(le);continue}if([",",";",")","]","}"].includes(ue))break}return C[Math.max(ee,le-1)]?.end??k.length}let X=new Set,G=[];for(let ee=0;ee<C.length;ee++)if(C[ee].text==="=>"){let le=ee-1,ue=le,de;if(C[le]?.text===")"&&R.has(le))ue=R.get(le),de=H(ue+1,le);else if(C[le]&&Ar.test(C[le].text))de=new Set([C[le].text]);else continue;let fe=ee+1,pe=C[fe]?.text==="{"&&R.has(fe)?C[R.get(fe)].end:K(fe);G.push({start:C[ue].start,end:pe,bodyStart:C[fe]?.start??pe,functionBody:!0,names:de})}else if(C[ee].text==="("&&R.has(ee)){let le=C[ee-1]?.text;if(!le||ry.has(le)||!Ar.test(le)&&le!=="*"&&le!=="]")continue;let ue=R.get(ee),de=ue+1;if(C[de]?.text===":"){de++;while(de<C.length&&!["{","=>",";","="].includes(C[de].text))de++}if(C[de]?.text!=="{"||!R.has(de))continue;G.push({start:C[ee].start,end:C[R.get(de)].end,bodyStart:C[de].start,functionBody:le!=="catch",names:H(ee+1,ue)})}function te(ee){let le=ee;for(;le<C.length;le++){let ue=C[le].text;if(Rd.includes(ue)&&R.has(le)){le=R.get(le);continue}if(ue===";"||Ad.includes(ue))break;let de=C[le-1];if(le>ee&&sy.has(ue)&&de.text!==".")break;if(le>ee&&/[\n\r]/.test(k.slice(de.end,C[le].start))&&(/^[\w$]+$/.test(de.text)||Ad.includes(de.text)||['"',"'","`"].includes(de.text))&&Ar.test(ue)&&!["in","of","instanceof"].includes(ue))break}return le}let ce=[];for(let ee=0;ee<C.length;ee++){if(C[ee].text!=="for")continue;let le=C[ee+1]?.text==="await"?ee+2:ee+1;if(C[le]?.text!=="("||!R.has(le))continue;let ue=R.get(le),de=ue+1,fe=C[de]?.text==="{"&&R.has(de)?R.get(de):te(de),pe=C[fe]?.text===";"||C[fe]?.text==="}"?C[fe].end:C[Math.max(de,fe-1)]?.end??k.length;ce.push({headStart:le,headEnd:ue,start:C[le].start,end:pe})}for(let ee=0;ee<C.length;ee++){let le=C[ee].text,ue=C[ee-1]?.text;if(ue==="."||C[ee+1]?.text===":")continue;if(ue==="as"||ue==="<")continue;if(le==="const"||le==="let"||le==="var"){let de=te(ee+1),fe=ee+1,pe=!1,Ae=!1,Se=0;for(let ve=ee+1;ve<=de;ve++){let De=C[ve]?.text;if(ve<de&&Rd.includes(De)&&R.has(ve)&&R.get(ve)<de){ve=R.get(ve);continue}if(ve<de&&De===":"&&!Ae)pe=!0;else if(ve<de&&De==="="&&Se===0)pe=!1,Ae=!0;else if(ve<de&&pe&&De==="<")Se++;else if(ve<de&&pe&&De===">"&&Se>0)Se--;else if(ve===de||De===","&&Se===0)V(fe,ve,X,le==="var"),fe=ve+1,pe=!1,Ae=!1}}else if(le==="function"||le==="class"){let de=ee+1;if(C[de]?.text==="*")de++;if(C[de]&&Ar.test(C[de].text)&&C[de].text!=="extends")X.add(C[de].text),F.push({name:C[de].text,token:de})}else if(le==="import"){let de=ee+1;if(C[de]?.text==="*"&&C[de+1]?.text==="as")de+=2;let fe=C[de]?.text;if(fe&&Ar.test(fe)&&fe!=="type"&&C[de+1]?.text!=="("&&C[de+1]?.text!==".")X.add(fe),F.push({name:fe,token:de,file:!0});let pe=C[de]?.text==="{"?de:C[de+1]?.text===","&&C[de+2]?.text==="{"?de+2:-1;if(pe!==-1&&R.has(pe)){let Ae=R.get(pe);for(let[Se,ve]of z(pe+1,Ae)){let De=ve-1;while(De>=Se&&!Ar.test(C[De].text))De--;if(De>=Se&&C[De].text!=="type")F.push({name:C[De].text,token:De,file:!0})}}}}return Cd=v,Xo={code:k,scopes:G,loops:ce,declarations:X,sites:F,tokens:C,pairs:R},Xo}function pc(v){let k=fc(v);return{code:k.code,shadows:(C,R)=>k.scopes.some((T)=>R>=T.start&&R<T.end&&T.names.has(C))}}function Zo(v){return new Set(fc(v).declarations)}function Ot(v,k){let{scopes:C,loops:R,sites:T,tokens:z,pairs:F}=fc(v),V=Array.from({length:z.length},()=>-1),H=[];for(let ce=0;ce<z.length;ce++){V[ce]=H.length?H[H.length-1]:-1;let ee=z[ce].text;if(ee==="{"&&F.has(ce))H.push(ce);else if(ee==="}"&&H.length&&F.get(ce)===H[H.length-1])H.pop()}let K=new Set,X=new Map;for(let ce of T){if(!k.has(ce.name))continue;K.add(ce.token);let ee=ce.file?-1:V[ce.token],le=ee===-1?[0,Number.POSITIVE_INFINITY]:[z[ee].start,z[F.get(ee)].end];if(ce.functionScoped){let de=z[ce.token].start,fe=C.filter((pe)=>pe.functionBody&&de>=pe.bodyStart&&de<pe.end).sort((pe,Ae)=>pe.end-pe.bodyStart-(Ae.end-Ae.bodyStart))[0];le=fe?[fe.bodyStart,fe.end]:[0,Number.POSITIVE_INFINITY]}else if(!ce.file){let de=R.filter((fe)=>ce.token>fe.headStart&&ce.token<fe.headEnd).sort((fe,pe)=>fe.headEnd-fe.headStart-(pe.headEnd-pe.headStart))[0];if(de)le=[de.start,de.end]}let ue=X.get(ce.name);if(ue)ue.push(le);else X.set(ce.name,[le])}let G=new Set;for(let ce=0;ce<z.length;ce++){if(z[ce].text!=="import"||z[ce-1]?.text===".")continue;let ee=ce+1;if(z[ee]?.text==="type")ee++;if(z[ee]&&Ar.test(z[ee].text)&&z[ee+1]?.text===",")ee+=2;if(z[ee]?.text==="{"&&F.has(ee))for(let le=ee+1;le<F.get(ee);le++)G.add(le)}let te=new Set;for(let ce=0;ce<z.length;ce++){let ee=z[ce].text;if(!k.has(ee)||te.has(ee)||K.has(ce)||G.has(ce))continue;let le=z[ce-1]?.text;if(le==="#"||le==="."&&z[ce-2]?.text!=="..")continue;if(z[ce+1]?.text===":"&&(le==="{"||le===","))continue;let ue=z[ce].start;if(X.get(ee)?.some(([de,fe])=>ue>=de&&ue<fe))continue;if(C.some((de)=>ue>=de.start&&ue<de.end&&de.names.has(ee)))continue;te.add(ee)}return te}import Go from"fs";import Qt from"path";function gn(v){return v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Td=new Map;function Jo(v,k=!0){let C=Td.get(v);if(k&&C)return C;let R=new Map,T=[Qt.join(v,"src"),Qt.join(v,"dist"),v];function z(F,V){if(V>6)return;let H;try{H=Go.readdirSync(F,{withFileTypes:!0})}catch{return}for(let K of H){let X=Qt.join(F,K.name);if(K.isDirectory()){if(K.name==="node_modules"||K.name.startsWith("."))continue;z(X,V+1)}else if(K.isFile()&&K.name.endsWith(".stx")){let G=K.name.slice(0,-4);if(!R.has(G))R.set(G,X);let te=G.toLowerCase();if(!R.has(te))R.set(te,X);let ce=gn(G);if(!R.has(ce))R.set(ce,X)}}}for(let F of T)if(z(F,0),R.size>0)break;if(k)Td.set(v,R);return R}function Yo(v,k){if(v.startsWith(".")||v.startsWith("/"))return null;let C=k;while(!0){let R=Qt.join(C,"node_modules",v);try{if(Go.statSync(R).isDirectory())return R}catch{}let T=Qt.dirname(C);if(T===C)return null;C=T}}function Qo(v,k,C={}){return[Qt.resolve(Qt.dirname(k),`${v}.stx`),Qt.resolve(Qt.dirname(k),v),Qt.resolve(C.componentsDir||"components",`${v}.stx`),Qt.resolve(C.componentsDir||"components",v),v.endsWith(".stx")?v:`${v}.stx`]}function Id(v){let k=v.endsWith(".stx")?v.slice(0,-4):v,C=k.split("-").map((T)=>T.charAt(0).toUpperCase()+T.slice(1)).join(""),R=gn(k);return[k,C,R]}function gc(v,k){let[C,R,T]=Id(v);for(let z of[C,C.toLowerCase(),R,T]){let F=k?.__importedComponents?.get(z);if(F!==void 0)return F}}function*mc(v,k,C={},R){let T=Id(v);if(T[0].startsWith("./")||T[0].startsWith("../")){yield Qt.resolve(Qt.dirname(k),`${T[0]}.stx`);return}let z=[...new Set(T.map((H)=>`${H}.stx`))],F=C.projectRoot||process.cwd(),V=[...R?.__originalFilePath?[Qt.join(Qt.dirname(R.__originalFilePath),"components")]:[],...C.componentsDir?[C.componentsDir]:[],Qt.join(Qt.dirname(k),"components"),Qt.resolve(F,"src/components"),Qt.resolve(F,"components"),...import.meta.dir?[Qt.resolve(import.meta.dir,"components")]:[]];for(let H of new Set(V)){for(let K of z)yield Qt.join(H,K);try{for(let K of Go.readdirSync(H,{withFileTypes:!0}))if(K.isDirectory())for(let X of z)yield Qt.join(H,K.name,X)}catch{}}}function Pd(v,k,C={},R){let T=gc(v,R);if(T!==void 0)return T;for(let z of mc(v,k,C,R))try{if(Go.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}catch{}return null}import Uu from"fs";import pt from"path";import{createHash as oy}from"crypto";var ia="__stx_component_client_factories";function aa(v){let k=v[ia];return k instanceof Map?k:null}function Od(v){v[ia]=new Map}function hc(v,k){let C=aa(v);if(!C)return null;let R=oy("sha256").update(k).digest("hex").slice(0,16),T=C.get(R);if(T)T.instances++;else C.set(R,{body:k,instances:1});return R}function Md(v,k){let C=aa(k);if(!C?.size)return v;let R=new Map;for(let[X,G]of C)if(G.instances===1)R.set(X,G.body);let T=[];if(R.size>0){let X=[...R.keys()].map((ce)=>JSON.stringify(ce).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),G=new RegExp(`window\\.__stxComponentFactories\\[(${X})\\]\\(("[^"]+")\\);`,"g"),te=G.exec(v);while(te!==null){let ce=R.get(JSON.parse(te[1]));if(ce!==void 0)T.push({start:te.index,end:te.index+te[0].length,replacement:`(${ce})(${te[2]});`});te=G.exec(v)}}let z=[...C].filter(([,X])=>X.instances>1);if(z.length===0)return Dd(v,T);let V=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
116
- (function() {
117
- const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
118
- ${z.map(([X,G])=>` try { factories[${JSON.stringify(X)}] = factories[${JSON.stringify(X)}] || ${G.body}; }
119
- catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(X)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
120
- `)}
121
- })();
122
- </script>`,H=v.search(/<script\b(?=[^>]*\bdata-stx-scoped\b)/i),K=H<0?0:H;return T.push({start:K,end:K,replacement:`${V}
123
- `}),Dd(v,T)}function Dd(v,k){if(k.length===0)return v;k.sort((z,F)=>z.start-F.start||z.end-F.end);let C=Array(k.length*2+1),R=0,T=0;for(let z of k)C[T++]=v.slice(R,z.start),C[T++]=z.replacement,R=z.end;return C[T]=v.slice(R),C.join("")}function Nd(v){let k=aa(v),C=new Map;if(k)for(let[R,T]of k)C.set(R,T.instances);return C}function jd(v,k){let C=aa(v);if(!C)return[];let R=[];for(let[T,z]of C){let F=z.instances-(k.get(T)??0);if(F>0)R.push({body:z.body,count:F})}return R}function Ld(v,k){for(let{body:C,count:R}of k)for(let T=0;T<R;T++)hc(v,C)}import Jd from"fs";var Bd=0,yc=new Map;function fi(){Bd=0,yc.clear()}function ca(v,k){let C=Bd++,R=`<!--__STX_${v.toUpperCase()}_${C}__-->`;return yc.set(R,{type:v,expression:k}),R}function gi(){let v={};for(let[k,C]of yc)v[k]={type:C.type,expression:C.expression};return v}function mi(v,k){let C=v;for(let[R,T]of k)C=C.split(R).join(T);return C}function ws(v){return v.includes("<!--__STX_")}var ay=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function cy(v){return Array.from({length:v},()=>"&#123;").join("&#8288;")}function zd(v){return v.replace(/\{{2,}/g,(k)=>cy(k.length)).replace(/\{(?=!)/g,"&#123;&#8288;").replace(ay,"&#64;")}function Wd(v,k,C=!1){let R=v.slice(0,k),T=R.lastIndexOf("<"),z=R.lastIndexOf(">");if(T>=0&&z>T)return null;if(T<0&&!C)return null;let F=T>=0?R.slice(T+1):R;if(T>=0&&/^\s*[!/?]/.test(F))return/^\s*\/?\s*$/.test(F)?{kind:"tag-name"}:null;if(T>=0&&/^\s*$/.test(F))return{kind:"tag-name"};let V=/(?:^|\s)([^\s"'<>/=]+)\s*=\s*"([^"]*)$/.exec(F);if(V)return{kind:"attribute",name:V[1],quote:'"',valuePrefix:V[2]};let H=/(?:^|\s)([^\s"'<>/=]+)\s*=\s*'([^']*)$/.exec(F);if(H)return{kind:"attribute",name:H[1],quote:"'",valuePrefix:H[2]};let K=/(?:^|\s)([^\s"'<>/=]+)\s*=\s*([^\s"'=<>`]*)$/.exec(F);if(K)return{kind:"attribute",name:K[1],quote:null,valuePrefix:K[2]};return T>=0||/^\s*[^<>]*$/.test(F)?{kind:"tag"}:null}class er extends Error{attribute;constructor(v,k){super(`Unsafe interpolation in ${v}: ${k}`);this.name="UnsafeInterpolationContextError",this.attribute=v}}var Fd="unsafe:";var ly=/^(?:javascript|vbscript|livescript|mocha|view-source):/,uy=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,dy=/^data:(?:text\/html|application\/xhtml\+xml)/,fy=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function py(v){return v.replace(fy,"").toLowerCase()}function xc(v){let k=v.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(k))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(k))return"fetched";return null}function la(v,k="navigable"){let C=py(v);if(ly.test(C))return!0;return k==="navigable"?uy.test(C):dy.test(C)}function qi(v,k="navigable"){return la(v,k)?"unsafe:"+v:v}function gy(v){let k=v.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!k)return null;if(k[3].trim()!=="")return null;return xc(k[1])}function Vd(v,k,C=256){if(k<=C)return v.slice(0,k);let R=v.slice(k-C,k),T=R.search(/[\s"'`/]/);return T===-1?"":R.slice(T)}function Ud(v,k,C=k){let R=gy(v);return R&&la(k,R)?"unsafe:"+C:C}var ua=/<script\b[^>]*>/iy,Sc=/<\/script\s*>/ig,da=/<style\b[^>]*>/iy,kc=/<\/style\s*>/ig;function Hd(v,k,C,R){C.lastIndex=k;let T=C.exec(v);if(!T||T.index!==k)return-1;R.lastIndex=C.lastIndex;let z=R.exec(v);if(!z)return-1;return z.index+z[0].length}function U(v,k){return Hd(v,k,ua,Sc)}function us(v,k){return Hd(v,k,da,kc)}function Ke(v,k){if(!v.startsWith("<!--",k))return-1;let C=v.indexOf("-->",k+4);if(C===-1)return-1;return C+3}function qd(v,k){if(v.startsWith("<!--",k)){let T=Ke(v,k);return T===-1?v.length:T}if(ua.lastIndex=k,ua.exec(v)?.index===k){Sc.lastIndex=ua.lastIndex;let T=Sc.exec(v);return T?T.index+T[0].length:v.length}if(da.lastIndex=k,da.exec(v)?.index===k){kc.lastIndex=da.lastIndex;let T=kc.exec(v);return T?T.index+T[0].length:v.length}return-1}function ne(v,k){let C=[],R=0,T=v.length,z=!1,F=null;while(R<T){let V=v[R];if(z){if(F){if(V===F)F=null}else if(V==='"'||V==="'")F=V;else if(V===">")z=!1;R++;continue}if(V!=="<"){let G=v.indexOf("<",R+1);if(G===-1)break;R=G;continue}let H=k(v,R);if(H>R){C.push({start:R,end:H,token:v.slice(R,H)}),R=H;continue}let K=qd(v,R);if(K>R){R=K;continue}let X=v.charCodeAt(R+1);if(X>=65&&X<=90||X>=97&&X<=122)z=!0;R++}return C}function Kd(v){let k=0,C=0,R=0,T=!1,z=null;while(R<v.length){if(T){let G=v[R];if(z){if(G===z)z=null}else if(G==='"'||G==="'")z=G;else if(G===">")T=!1;R++;continue}let F=v.indexOf("<",R),V=F===-1?v.length:F;while(R<V){let G=v[R++];if(G==="{")k++;else if(G==="}")C++;if(k>=2&&C>=2)return!0}if(F===-1)break;let H=qd(v,F);if(H>F){R=H;continue}let K=v.charCodeAt(F+1),X=K===47?v.charCodeAt(F+2):K;if(X>=65&&X<=90||X>=97&&X<=122)T=!0;R=F+1}return!1}function Xd(v,k){while(v.size>=k){let C=v.keys().next();if(C.done)return;v.delete(C.value)}}var my=1024,hy=16777216,cs=new Map,bc=0;function yy(v,k){cs.set(v,k),bc+=v.length+k.output.length;for(let[C,R]of cs){if(bc<=hy)break;cs.delete(C),bc-=C.length+R.output.length}}function Un(v,k,C,R){let T=R!==void 0&&v.length>=my,z=T?`${R}\x00${v}`:"";if(T){let X=cs.get(z);if(X)return cs.delete(z),cs.set(z,X),{output:X.output,tokens:X.tokens.slice()}}let F=ne(v,k);if(F.length===0)return{output:v,tokens:[]};let V=F.map((X)=>X.token),H="",K=0;for(let X=0;X<F.length;X++){let G=F[X];H+=v.slice(K,G.start),H+=C(G.token,X),K=G.end}if(H+=v.slice(K),T)return yy(z,{output:H,tokens:V}),{output:H,tokens:V.slice()};return{output:H,tokens:V}}var xy=1024,by=16777216,ls=new Map,vc=0;function vy(v,k){ls.set(v,k),vc+=v.length+k.output.length;for(let[C,R]of ls){if(vc<=by)break;ls.delete(C),vc-=C.length+R.output.length}}function wc(v,k,C){return{output:k,scripts:C,restore:(R)=>R===k?v:ds(R,C)}}function Mn(v){let k=v.length>=xy;if(k){let T=ls.get(v);if(T)return ls.delete(v),ls.set(v,T),wc(v,T.output,T.scripts.slice())}let{output:C,tokens:R}=Un(v,U,(T,z)=>`\x00STX_SCRIPT_${z}\x00`);if(k)return vy(v,{output:C,scripts:R}),wc(v,C,R.slice());return wc(v,C,R)}function ds(v,k){if(k.length===0)return v;return v.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(C,R)=>k[+R]??"")}function Dt(v){let k=v.indexOf(" as ");if(k!==-1){let z=v.slice(0,k).trim(),F=v.slice(k+4).trim();return z&&F?{arrayExpr:z,itemVar:F}:null}let C=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(v);if(!C)return null;let R=C[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),T=C[2].trim();return R&&T?{arrayExpr:T,itemVar:R}:null}function fa(v){let k=[],C=0,R="",T=0;for(let z=0;z<v.length;z++){let F=v[z];if(R){if(F==="\\")z++;else if(F===R)R="";continue}if(F==="'"||F==='"'||F==="`")R=F;else if(F==="("||F==="["||F==="{")C++;else if(F===")"||F==="]"||F==="}")C--;else if(F===","&&C===0)k.push(v.slice(T,z)),T=z+1}return k.push(v.slice(T)),k}function Zd(v,k){let C=0;for(let R=0;R<v.length;R++){let T=v[R];if(T==="("||T==="["||T==="{")C++;else if(T===")"||T==="]"||T==="}")C--;else if(T===k&&C===0)return R}return-1}function Gd(v){let k=0;for(let C=0;C<v.length;C++){let R=v[C];if(R==="("||R==="["||R==="{")k++;else if((R===")"||R==="]"||R==="}")&&--k===0)return C}return-1}function Hr(v,k){let C=v.trim().replace(/^\.\.\./,"").trim(),R=Zd(C,"=");if(R!==-1&&C[R+1]!==">")C=C.slice(0,R).trim();if(!C)return;if(C.startsWith("{")&&C.endsWith("}")){for(let T of fa(C.slice(1,-1))){let z=T.trim();if(!z)continue;if(z.startsWith("...")){Hr(z,k);continue}let F=Zd(z,":");Hr(F===-1?z:z.slice(F+1),k)}return}if(C.startsWith("[")&&C.endsWith("]")){for(let T of fa(C.slice(1,-1)))Hr(T,k);return}if(/^[A-Z_$][\w$]*$/i.test(C))k.push(C)}function qr(v){let k=v.trim(),C=[],R=0;for(let z=0;z<k.length;z++){let F=k[z];if(F==="("||F==="["||F==="{")R++;else if(F===")"||F==="]"||F==="}")R--;else if(R===0&&/\s/.test(F)){if(!/^\s+(?:in|of)\s/.exec(k.slice(z)))continue;let H=k.slice(0,z).trim();if(H.startsWith("(")&&Gd(H)===H.length-1)H=H.slice(1,-1);for(let K of fa(H))Hr(K,C);if(C.length>0)return C;break}}let T=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(k);if(T){let z=T[1].trim();if(z.startsWith("(")&&Gd(z)===z.length-1)z=z.slice(1,-1);let F=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(z);if(F)Hr(F[2],C),Hr(F[1],C);else for(let V of fa(z))Hr(V,C)}return C}function re(v,k){let C=k instanceof Set?k:new Set(k);if(C.size===0)return!1;let F=v.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let V of F.match(/[a-zA-Z_$][\w$]*/g)||[])if(C.has(V))return!0;return!1}var pa="__stx_client_loop_names";function Tr(v){let k=v?.[pa];return Array.isArray(k)?k:[]}function ga(v){if(!v.includes("#")&&!v.includes("v-slot:"))return[];let k=[],C=[],R=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let T of v.matchAll(R)){let z=T[0];if(/^<\/template\s*>$/i.test(z)){let F=C.pop();if(F)F.end=T.index}else if(/^<template\b/i.test(z)&&!/\/\s*>$/.test(z)){let V=[...z.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((X)=>/^(?:#[\w-]+|v-slot:[\w-]+)$/i.test(X[1])),H=(V?.[2]??V?.[3])?.trim(),K=H?{start:T.index+z.length,end:v.length,binding:H}:void 0;if(C.push(K),K)k.push(K)}}return k}var io={},Yd=new Map;function wy(v){let k=Yd.get(v);if(!k){let C=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");k=new RegExp(`:${C}(?!\\w)`,"g"),Yd.set(v,k)}return k.lastIndex=0,k}var ir={uppercase:(v,k)=>v!==void 0&&v!==null?String(v).toUpperCase():"",lowercase:(v,k)=>v!==void 0&&v!==null?String(v).toLowerCase():"",capitalize:(v,k)=>{if(v===void 0||v===null)return"";let C=String(v);return C.charAt(0).toUpperCase()+C.slice(1)},number:(v,k,C=0)=>{if(v===void 0||v===null)return"";try{let R=Number(v);return Number.isNaN(R)?"":R.toFixed(Number.parseInt(String(C),10))}catch{return""}},fmt:(v,k,C="en-US")=>{if(v===void 0||v===null)return"";try{let R=Number(v);if(Number.isNaN(R))return String(v);return R.toLocaleString(C)}catch{return String(v)}},join:(v,k,C=",")=>{if(!Array.isArray(v))return"";return v.join(String(C))},escape:(v,k)=>{if(v===void 0||v===null)return"";return Mt(String(v))},translate:(v,k,C={})=>{if(!k||!k.__translations)return v;let R=k.__translations,T=k.__i18nConfig?.fallbackToKey??!0,z=String(v).split("."),F=R;for(let H of z){if(F===void 0||F===null)break;F=F[H]}if(F===void 0||F===null)return T?v:"";let V=String(F);return Object.entries(C).forEach(([H,K])=>{V=V.replace(wy(H),String(K))}),V},t:(v,k,C={})=>ir.translate(v,k,C),truncate:(v,k,C=50,R="...")=>{if(v===void 0||v===null)return"";let T=String(v);if(T.length<=C)return T;if(C<=R.length)return R.substring(0,C);return T.substring(0,C-R.length)+R},date:(v,k,C="short",R="en-US")=>{if(v===void 0||v===null)return"";try{let T=v instanceof Date?v:new Date(v);if(Number.isNaN(T.getTime()))return String(v);let z={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(C==="iso")return T.toISOString();return new Intl.DateTimeFormat(R,z[C]||z.short).format(T)}catch{return String(v)}},currency:(v,k,C="USD",R="en-US")=>{if(v===void 0||v===null)return"";try{let T=Number(v);if(Number.isNaN(T))return String(v);return new Intl.NumberFormat(R,{style:"currency",currency:C}).format(T)}catch{return String(v)}},pluralize:(v,k,C,R)=>{let T=Number(v);if(Number.isNaN(T))return C;let z=R||`${C}s`;return T===1?C:z},first:(v,k)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return v.length===0?"":v[0];return String(v).charAt(0)},last:(v,k)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return v.length===0?"":v[v.length-1];let C=String(v);return C.charAt(C.length-1)},length:(v,k)=>{if(v===void 0||v===null)return 0;if(Array.isArray(v)||typeof v==="string")return v.length;if(v instanceof Map||v instanceof Set)return v.size;if(typeof v==="object")return Object.keys(v).length;return 0},json:(v,k,C=!1)=>{if(v===void 0)return"undefined";if(v===null)return"null";try{return C?JSON.stringify(v,null,2):JSON.stringify(v)}catch{return String(v)}},default:(v,k,C="")=>v===void 0||v===null||v===""?C:v,reverse:(v,k)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return[...v].reverse();return String(v).split("").reverse().join("")},slice:(v,k,C=0,R)=>{if(v===void 0||v===null)return"";if(Array.isArray(v)||typeof v==="string")return v.slice(C,R);return v},replace:(v,k,C,R="")=>{if(v===void 0||v===null)return"";let T=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(v).replace(new RegExp(T,"g"),()=>R)},stripTags:(v,k)=>{if(v===void 0||v===null)return"";return String(v).replace(/<[^>]*>/g,"")},urlencode:(v,k)=>{if(v===void 0||v===null)return"";return encodeURIComponent(String(v))},abs:(v,k)=>{let C=Number(v);return Number.isNaN(C)?0:Math.abs(C)},round:(v,k,C=0)=>{let R=Number(v);if(Number.isNaN(R))return 0;let T=10**C;return Math.round(R*T)/T}};function Cc(v,k){if(v in ir)console.warn(`Filter "${v}" already exists as a built-in filter. Custom filter will take precedence.`);io[v]=k}function ed(v){for(let[k,C]of Object.entries(v))Cc(k,C)}function Ec(){return{...ir,...io}}function td(){for(let v of Object.keys(io))delete io[v]}function Tc(v,k,C=2){let R=0,T=null;for(let z=k+C;z<v.length;z++){let F=v[z];if(T){if(F==="\\"){z++;continue}if(F===T)T=null;continue}if(F==='"'||F==="'"||F==="`"){T=F;continue}if(F==="{"){R++;continue}if(F==="}"){if(R>0){R--;continue}let V=0;while(v[z+V]==="}")V++;if(V>=C)return z}}return-1}function ar(v,k,C=2){let R="{".repeat(C);if(!v.includes(R))return v;let T="",z=0;for(;;){let F=v.indexOf(R,z);if(F===-1)break;let V=Tc(v,F,C);if(V===-1)break;T+=v.slice(z,F)+k(v.slice(F,V+C),v.slice(F+C,V),F),z=V+C}return z===0?v:T+v.slice(z)}function b(v){return v.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Mt(v){return zd(b(v))}function Sy(v){return v.replace(/ /g,"&#32;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;").replace(/\f/g,"&#12;").replace(/=/g,"&#61;").replace(/`/g,"&#96;")}function $y(v){return v.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(k,C)=>String.fromCodePoint(Number.parseInt(C,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function _y(v,k){let C=$y(v);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(C))throw new er(k,"network-capable or executable CSS is not allowed in an escaped interpolation");let R=/url\(([^)]*)\)/g,T;while((T=R.exec(C))!==null){let z=T[1].replace(/^["']|["']$/g,""),F=z.startsWith("/")&&!z.startsWith("//")||z.startsWith("./")||z.startsWith("../")||z.startsWith("#"),V=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(z);if(!F&&!V)throw new er(k,"CSS URLs must be local paths or base64 raster images")}}function sf(v,k,C,R=!1,T=0){let z=Wd(v,k,R),F=Mt(C);if(!z)return F;if(z.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(C))throw new er("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return C}if(z.kind==="tag"){let K=v.slice(k+T).trimStart(),X=C.trim();if(!K.startsWith("=")&&(X===""||/^(?!on)[A-Za-z_:][\w:.-]*(?:\s+(?!on)[A-Za-z_:][\w:.-]*)*$/.test(X)))return X;throw new er("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let V=z.name.toLowerCase();if(/^on[a-z]/.test(V))throw new er(z.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(V==="srcdoc")F=Mt(F);if(V==="style")_y(C,z.name);if(z.quote===null)F=Sy(F);let H=xc(V);if(H&&z.valuePrefix.trim()===""&&la(C,H))return Fd+F;return Ud(Vd(v,k),C,F)}function of(v){return v.flatMap((k)=>{let C=k.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!C||/\bserver\b|\bsrc\s*=/.test(C[1])?[]:[C[2]]})}function Ce(v,k){let{scripts:C}=Mn(v);for(let R of of(C)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(R))return!0;if(Fn(R,k))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(v))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(v))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(v))return!0;return!1}function $c(v){let k=[],C=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let R=C.exec(v);R;R=C.exec(v)){let T=R[1].toLowerCase(),z=new Set(qr(R[3]));if(z.size===0)continue;let F=R.index+R[0].length;if(R[0].endsWith("/>")){k.push({start:R.index,end:F,names:z});continue}let V=new RegExp(`<(/?)${T}\\b[^>]*?(/?)>`,"gi");V.lastIndex=F;let H=1,K=v.length;for(let X=V.exec(v);X;X=V.exec(v)){if(X[2]==="/")continue;if(H+=X[1]==="/"?-1:1,H===0){K=X.index+X[0].length;break}}k.push({start:R.index,end:K,names:z})}return k}function Qd(v,k,C){let R=s(C);for(let T of v){if(k<T.start||k>=T.end)continue;for(let z of T.names)if(new RegExp(`(?<![.#\\w$])${z.replace(/\$/g,"\\$")}(?![\\w$])`).test(R))return!0}return!1}function ef(v,k){let C=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],R=v.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),T="",z=!1,F=0;for(let K=0;K<R.length;K++){let X=R[K];if(!z&&X==="`"){z=!0,F=0;continue}if(z){if(X==="`"&&F===0){z=!1;continue}if(X==="$"&&R[K+1]==="{"){F++,K++,T+=" ";continue}if(X==="}"&&F>0){F--;continue}if(F>0){T+=X;continue}continue}T+=X}R=T;let V=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,H;while((H=V.exec(R))!==null){let K=H[1];if(!R.substring(0,H.index).trimEnd().endsWith(".")){if(!C.includes(K)&&!(K in k))return!1}}return!0}function ky(v,k){let C=k.__stx_serverDeclared;if(!C||C.size===0)return!1;let R=s(v);for(let T of C)if(new RegExp(`(?<![.#\\w$])${T}(?![\\w$])`).test(R))return!0;return!1}var tf=new Set;function nf(v){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(v.trim())}function rf(v,k){let C=`${k??"<unknown>"}\x00${v}`;if(process.env.STX_DEBUG||!tf.has(C))tf.add(C),console.warn(`[stx] {{ ${v} }} in a <script> in ${k??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function xs(v,k,C){let R=v;return R=R.replace(/\{!!([\s\S]*?)!!\}/g,(T,z)=>{try{let F=x(z,k);if(F===void 0)return nf(z)?rf(z.trim(),C):T;return F===null?"":String(F)}catch{return T}}),R=ar(R,(T,z,F)=>{let V=z.trim();if(/^__[A-Z_]+__$/.test(V))return T;try{let H=x(z,k);if(H===void 0)return nf(V)?rf(V,C):T;return JSON.stringify(H).replace(/</g,"\\u003c")}catch{return T}}),R}function Rc(v,k){if(!v.includes("{"))return v;let C=v;return C=C.replace(/\{!!([\s\S]*?)!!\}/g,(R,T)=>{try{let z=x(T,k);if(z===void 0)return R;return z===null?"":String(z)}catch{return R}}),C=ar(C,(R,T,z)=>{let F=T.trim();if(/^__[A-Z_]+__$/.test(F))return R;try{let V=x(T,k);if(V===void 0)return R;if(V===null)return"";let H=String(V);return sf(C,z,H,!0,R.length)}catch(V){if(V instanceof er)throw V;return R}}),C}function nd(v,k,C={}){let{output:R,scripts:T}=Mn(v),z=T.map((F)=>{let V=F.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),H=F.match(/^<script\b[^>]*>/i),K=F.search(/<\/script\s*>$/i);if(!V||!H||K===-1)return F;let X=V[1],G=V[2];if(/\bdata-raw\b/.test(X))return F;if(C.skipServer&&/\bserver\b/.test(X))return F;let ce=`<script${Rc(X,k)}>`;if(/\bsrc\s*=/.test(X)||/\btype\s*=\s*["']application\/json["']/.test(X))return ce+G+F.slice(K);return ce+xs(G,k)+F.slice(K)});return ds(R,z)}function Z(v,k,C){let R=v,T=(ee,le)=>{let ue=us(ee,le);if(ue===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(ee.slice(le,ue))?-1:ue},z=(ee,le,ue,de)=>{let fe=ue.length,{output:pe,tokens:Ae}=Un(ee,le,(Se,ve)=>de(fe+ve));return ue.push(...Ae),pe},F=[];R=z(R,T,F,(ee)=>`<!--__STX_STYLE_${ee}__-->`);let V=[];R=z(R,U,V,(ee)=>`<!--__STX_SCRIPT_EXPR_${ee}__-->`);let H=k?.__stx_signals_gate===!0||Ce(v),K=new Set([...Array.isArray(k?.__stx_client_signal_names)?k.__stx_client_signal_names:[],...Hs(of(V))]),X=new Set(Array.isArray(k?.__stx_preserved_client_expressions)?k.__stx_preserved_client_expressions:[]);R=ar(R,(ee,le,ue)=>{try{let de=x(le,k,!1,(fe)=>il(fe,ee,C,v));return de!==void 0&&de!==null?String(de):""}catch(de){let fe=de instanceof Error?de.message:String(de);return g("Expression",`Error evaluating: {{{ ${le.trim()}}}}: ${fe}`,C,v,ue,ee)}},3),R=R.replace(/\{!!([\s\S]*?)!!\}/g,(ee,le,ue)=>{try{let de=x(le,k,!1,(fe)=>il(fe,ee,C,v));if(de===void 0&&k.__stx_buildMode==="compile")return ca("raw",le.trim());return de!==void 0&&de!==null?String(de):""}catch(de){if(k.__stx_buildMode==="compile")return ca("raw",le.trim());let fe=de instanceof Error?de.message:String(de);return g("Expression",`Error evaluating: {!! ${le.trim()} !!}: ${fe}`,C,v,ue,ee)}}),R=z(R,U,V,(ee)=>`<!--__STX_SCRIPT_EXPR_${ee}__-->`),R=z(R,T,F,(ee)=>`<!--__STX_STYLE_${ee}__-->`);let G=H?$c(R):[],te=ga(R).map((ee)=>({...ee,names:new Set(qr(`${ee.binding} in __slot`))})),ce=new Set(Tr(k));if(R=ar(R,(ee,le,ue)=>{let de=le.trim();if(Qd(te,ue,de))return ee;if(re(de,ce))return ee;if(G.length>0&&Qd(G,ue,de))return ee;if(X.has(de))return ee;let fe=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],pe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,Se=de.match(pe)?.[1],ve=Se&&((Se in k)||fe.includes(Se)),De=Boolean(Se&&K.has(Se)),Me=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,je=de.match(Me),Le=je&&!fe.includes(je[1])&&!(je[1]in k);if(/^__[A-Z_]+__$/.test(de))return"";if(De)return ee;let Be;try{let Oe=x(le,k,!1,(Fe)=>{Be=Fe});if(H&&!ef(de,k))return ee;if(Be)il(Be,ee,C,v);if(k.__stx_buildMode==="compile"&&!H&&(Oe===void 0||ky(de,k)))return ca("expr",de);if(Oe===void 0||Oe===null)return"";let We=String(Oe);return sf(R,ue,We,!1,ee.length)}catch(Oe){if(Oe instanceof er)throw Oe;if(H&&!ef(de,k))return ee;if(Le)return ee;let We=Oe instanceof Error?Oe.message:String(Oe);return g("Expression",`Error evaluating: {{ ${de} }}: ${We}`,C,v,ue,ee)}}),V.length>0)R=R.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(ee,le)=>V[Number(le)]??ee);if(F.length>0)R=R.replace(/<!--__STX_STYLE_(\d+)__-->/g,(ee,le)=>F[Number(le)]??ee);return R}function Ac(v,k,C){if(!k.trim())return v;let R=v,T=k.trim();while(T.length>0){let z=T.match(/^(\w+)/);if(!z)break;let F=z[1];T=T.substring(F.length).trim();let V=io[F]||ir[F];if(!V)throw Error(`Filter not found: ${F}. Available filters: ${Object.keys(Ec()).join(", ")}`);let H=[];if(T.startsWith(":")){let K=T.match(/^:([^|\s]+)/);if(K){let X=K[1].trim();try{let G=Number(X);H=[Number.isNaN(G)?X:G]}catch{H=[X]}T=T.substring(K[0].length).trim()}}else if(T.startsWith("(")){let K=1,X=1;while(K>0&&X<T.length){if(T[X]==="(")K++;if(T[X]===")")K--;X++}if(K===0){let G=T.substring(1,X-1).trim();if(G)try{if(G.startsWith("{")&&G.endsWith("}"))H=[x(`(${G})`,C,!0)];else{let te=[],ce="",ee=null,le=0,ue=0,de=0,fe=!1;for(let pe=0;pe<G.length;pe++){let Ae=G[pe];if(fe){ce+=Ae,fe=!1;continue}if(Ae==="\\"){ce+=Ae,fe=!0;continue}if(ee){if(ce+=Ae,Ae===ee)ee=null;continue}if(Ae==='"'||Ae==="'"||Ae==="`"){ee=Ae,ce+=Ae;continue}if(Ae==="(")le++;else if(Ae===")")le--;else if(Ae==="[")ue++;else if(Ae==="]")ue--;else if(Ae==="{")de++;else if(Ae==="}")de--;if(Ae===","&&le===0&&ue===0&&de===0){te.push(ce),ce="";continue}ce+=Ae}if(ce)te.push(ce);H=te.map((pe)=>{let Ae=pe.trim();return x(Ae,C,!0)})}}catch{H=[G]}T=T.substring(X).trim()}}try{R=V(R,C,...H)}catch(K){let X=K instanceof Error?K.message:String(K);throw Error(`Error applying filter '${F}': ${X}`)}if(T.startsWith("|"))T=T.substring(1).trim();else break}return R}function Ey(v){let k=!1,C="",R=0,T=0,z=0,F=!1;for(let V=0;V<v.length;V++){let H=v[V],K=v[V+1];if(k&&F){F=!1;continue}if(k&&H==="\\"){F=!0;continue}if(F=!1,(H==='"'||H==="'"||H==="`")&&!F){if(!k)k=!0,C=H;else if(H===C)k=!1,C="";continue}if(k&&C==="`"&&H==="$"&&K==="{"){let X=1;V+=2;while(V<v.length&&X>0){if(v[V]==="{")X++;else if(v[V]==="}")X--;if(X>0)V++}continue}if(k)continue;if(H==="(")R++;else if(H===")")R--;else if(H==="[")T++;else if(H==="]")T--;else if(H==="{")z++;else if(H==="}")z--;if(H==="|"&&R===0&&T===0&&z===0){if(K==="|"){V++;continue}if(K==="="){V++;continue}return V}}return-1}var Qi=new Set,Cy=1000;function rd(){Qi.clear()}function il(v,k,C,R){if(!D())return;let T=`${C}\x00${v.expression}`;if(Qi.has(T))return;if(Qi.size>=Cy)Qi.clear();Qi.add(T);let z=C,F=R;try{if(C&&Jd.existsSync(C))F=Jd.readFileSync(C,"utf8")}catch{}let V=F.indexOf(k);if(V>=0)z=`${C}:${F.slice(0,V).split(`
124
- `).length}`;console.warn(`${z}: stx warning: ${k} rendered as an empty string. The safe evaluator rejected \`${v.expression}\` (${v.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function x(v,k,C=!1,R){try{let T=v.trim(),z=Ey(T);if(z>0){let V=T.substring(0,z).trim(),H=T.substring(z+1).trim(),K=x(V,k,!0,R);return Ac(K,H,k)}let F=Ln(T);if(F!==null){R?.({expression:T,rule:F});return}try{let V=Object.keys(k),H=Object.values(k);return c(T,V)(...H)}catch{return l(T,k)}}catch(T){if(T instanceof ReferenceError){let z=/(\b\w+)\s+is not defined/.exec(T.message);if(z){let F=z[1],V=Ry(F,Object.keys(k));if(V&&V!==F)T.message=`${T.message} \u2014 did you mean '${V}'?`}}if(!C)console.error(`Error evaluating expression: ${v}`,T);throw T}}function Ry(v,k){let C=null;for(let T of k){if(T===v)continue;let z=Ay(v,T);if(C===null||z<C.dist)C={key:T,dist:z}}if(!C)return null;let R=Math.max(v.length,C.key.length);if(C.dist<=2||C.dist/R<=0.35)return C.key;return null}function Ay(v,k){if(v===k)return 0;if(v.length===0)return k.length;if(k.length===0)return v.length;let[C,R]=v.length<k.length?[v,k]:[k,v],T=Array(C.length+1),z=Array(C.length+1);for(let F=0;F<=C.length;F++)T[F]=F;for(let F=1;F<=R.length;F++){z[0]=F;for(let V=1;V<=C.length;V++){let H=C[V-1]===R[F-1]?0:1;z[V]=Math.min(z[V-1]+1,T[V]+1,T[V-1]+H)}for(let V=0;V<=C.length;V++)T[V]=z[V]}return T[C.length]}function sd(v){if(!v)return"";return v.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}import lf from"fs";class L{cache=new Map;maxSize;options;sizes;bytes=0;constructor(v=100,k){this.maxSize=v,this.options=k??null,this.sizes=k?new Map:null}get byteSize(){return this.bytes}setMaxBytes(v){if(!this.options)return;this.options={...this.options,maxBytes:v};while(this.bytes>v&&this.cache.size>0){let k=this.cache.keys().next().value;if(k===void 0)break;this.delete(k)}}get(v){if(!this.cache.has(v))return;let k=this.cache.get(v);return this.cache.delete(v),this.cache.set(v,k),k}set(v,k){if(this.cache.has(v))this.delete(v);let C=this.options?this.options.sizeOf(k):0;if(this.options&&C>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+C>this.options.maxBytes)){let R=this.cache.keys().next().value;if(R===void 0)break;this.delete(R)}if(this.cache.set(v,k),this.sizes)this.sizes.set(v,C),this.bytes+=C}has(v){return this.cache.has(v)}delete(v){if(this.sizes){let k=this.sizes.get(v);if(k!==void 0)this.bytes-=k,this.sizes.delete(v)}return this.cache.delete(v)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}var fs=new Map,Ty=500;function Kr(v,k){if(k?.includes("g"))return new RegExp(v,k);let C=`${v}:${k||""}`;if(!fs.has(C)){if(fs.size>=Ty){let R=fs.keys().next().value;if(R)fs.delete(R)}fs.set(C,new RegExp(v,k))}return fs.get(C)}class af{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(v){let k=Array.from(new Set(v)),C=k.sort().join(","),R=this.pool.find((V)=>V.context.join(",")===C);if(R)return R.func;let T=this.fnCache,z=this.fnCacheMaxSize,F=(...V)=>(H)=>{try{let K=`${C}:${H}`,X=T.get(K);if(!X){if(T.size>=z){let G=T.keys().next().value;if(G)T.delete(G)}X=Function(...k,`
125
- 'use strict';
126
- try {
127
- return ${H};
128
- }
129
- catch (e) {
130
- if (e instanceof ReferenceError || e instanceof TypeError) {
131
- return undefined;
132
- }
133
- throw e;
134
- }
135
- `),T.set(K,X)}return X(...V)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:F,context:k.slice()});return F}clear(){this.pool.length=0,this.fnCache.clear()}}var j$=new af;class cf{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(v){this.enabled=v}isEnabled(){return this.enabled}setBudget(v,k){this.budgets.set(v,{warnThreshold:0.8,action:"warn",...k})}setBudgets(v){for(let[k,C]of Object.entries(v))this.setBudget(k,C)}removeBudget(v){this.budgets.delete(v)}getBudgets(){let v={};for(let[k,C]of this.budgets.entries())v[k]=C;return v}onViolation(v){this.violationHandlers.push(v)}offViolation(v){let k=this.violationHandlers.indexOf(v);if(k!==-1)this.violationHandlers.splice(k,1)}time(v,k){if(!this.enabled)return k();let C=performance.now(),R=k(),T=performance.now()-C;return this.recordTime(v,T),this.checkBudget(v,T),R}async timeAsync(v,k){if(!this.enabled)return k();let C=performance.now(),R=await k(),T=performance.now()-C;return this.recordTime(v,T),this.checkBudget(v,T),R}checkBudget(v,k){let C=this.budgets.get(v);if(!C)return;let R=k/C.maxTime*100,T=C.warnThreshold!==void 0?k>=C.maxTime*C.warnThreshold&&k<C.maxTime:!1,z=k>=C.maxTime;if(!T&&!z)return;let F={label:v,actualTime:k,budgetTime:C.maxTime,exceedancePercent:R,timestamp:new Date,isWarning:T};this.violations.push(F);while(this.violations.length>this.maxViolations)this.violations.shift();for(let H of this.violationHandlers)try{H(F)}catch{}let V=T?`[Performance Warning] "${v}" took ${k.toFixed(2)}ms (${R.toFixed(1)}% of ${C.maxTime}ms budget)`:`[Performance Budget Exceeded] "${v}" took ${k.toFixed(2)}ms (exceeded ${C.maxTime}ms budget by ${(R-100).toFixed(1)}%)`;switch(C.action){case"log":console.log(V);break;case"warn":console.warn(V);break;case"error":console.error(V);break;case"throw":if(z)throw Error(V);else console.warn(V);break}}recordTime(v,k){let C=this.metrics.get(v);if(C)C.count++,C.totalTime+=k,C.maxTime=Math.max(C.maxTime,k),C.minTime=Math.min(C.minTime,k);else this.metrics.set(v,{count:1,totalTime:k,maxTime:k,minTime:k})}getStats(v){if(v){let C=this.metrics.get(v);if(!C)return{};let R=this.budgets.get(v);return{count:C.count,avgTime:C.totalTime/C.count,totalTime:C.totalTime,maxTime:C.maxTime,minTime:C.minTime,budget:R?.maxTime,budgetUtilization:R?C.totalTime/C.count/R.maxTime*100:void 0}}let k={};for(let[C,R]of this.metrics.entries()){let T=this.budgets.get(C);k[C]={count:R.count,avgTime:R.totalTime/R.count,totalTime:R.totalTime,maxTime:R.maxTime,minTime:R.minTime,budget:T?.maxTime,budgetUtilization:T?R.totalTime/R.count/T.maxTime*100:void 0}}return k}getViolations(v){if(v)return this.violations.filter((k)=>k.label===v);return[...this.violations]}getViolationStats(){let v={},k=0,C=0;for(let R of this.violations)if(v[R.label]=(v[R.label]||0)+1,R.isWarning)k++;else C++;return{total:this.violations.length,byLabel:v,warnings:k,errors:C}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var al=null;function Iy(){if(!al)al=new cf;return al}var J=new Proxy({},{get(v,k){return Iy()[k]}});var uf=[];function m(v){let k=new L(v);return uf.push(k),k}function df(){for(let v of uf)v.clear()}function h(v,...k){return`${k.map((C)=>String(C??"")).join("\x00")}\x00${v.length}\x00${Bun.hash(v)}`}function bn(v){let k=[];for(let C of new Set(v))try{k.push({path:C,mtimeMs:lf.statSync(C).mtimeMs})}catch{}return k}function or(v){for(let k of v)try{if(lf.statSync(k.path).mtimeMs!==k.mtimeMs)return!1}catch{return!1}return!0}import JS from"fs";import fn from"path";import lo from"fs";import Xt from"path";import{hasLocalConfig as Nf}from"bunfig";import qn from"fs";import Xr from"path";import cl from"fs";import ff from"path";import{fileURLToPath as Py}from"url";var ll;function Ge(){if(ll)return ll;let v="unknown";try{v=String(JSON.parse(cl.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let k=ff.dirname(Py(import.meta.url)),C=0;for(let R of cl.readdirSync(k,{recursive:!0,withFileTypes:!0}))if(R.isFile()&&R.name.endsWith(".ts"))C=Math.max(C,cl.statSync(ff.join(R.parentPath,R.name)).mtimeMs);v+=`+src.${Math.trunc(C)}`}catch{}return ll=v,v}var Pc=new Map,Zr=new Map;async function od(v){let C;for(let R=0;R<3;R++)try{let z=(await qn.promises.stat(v)).mtime.getTime(),F=Zr.get(v);if(F&&F.mtime===z)return F.content;let V=await Bun.file(v).text(),K=(await qn.promises.stat(v)).mtime.getTime();if(K!==z)continue;return Zr.set(v,{content:V,mtime:K}),V}catch(T){C=T;break}throw Zr.delete(v),Error(`File not found: ${v}${C?` (${C.message})`:""}`)}function id(v){Zr.delete(v)}function ad(v){for(let k of Zr.keys())if(k.startsWith(v))Zr.delete(k)}var ha=null,Dy=null,gf=null;function cd(v){gf=v}async function Ic(v=!1){let k=gf??await import("./chunk-az28kd7f.js");if(v)return k.generateSignalsRuntimeDev();if(ha===null)ha=k.generateSignalsRuntime();return ha}var ya=null;async function Oc(){if(ya===null){let{getRouterScript:v}=await import("./chunk-g6efz3ww.js");ya=v()}return ya}var pf={};async function ld(v,k=!1){let C=v==="runtime"?await Ic(k):await Oc(),R=v==="runtime"&&k?"runtime-debug":v,T=pf[R];if(!T||T.content!==C)T={content:C,hash:Bun.hash(C).toString(16).padStart(16,"0").slice(0,16)},pf[R]=T;return{content:C,hash:T.hash,url:`/_stx/${v}.${T.hash}.js`}}var Oy=500,My=33554432,tr=new Map,ma=0;function mf(v){return a(process.cwd(),"module-bundles",`${v}.js`)}function ud(v){let k=Bun.hash(v).toString(16).padStart(16,"0").slice(0,16),C=tr.get(k),R=C!==void 0;if(R)tr.delete(k),ma-=C.length*2;tr.set(k,v),ma+=v.length*2;while(tr.size>1&&(tr.size>Oy||ma>My)){let T=tr.keys().next().value;ma-=tr.get(T).length*2,tr.delete(T)}if(!R)try{let T=mf(k);if(!qn.existsSync(T))qn.mkdirSync(Xr.dirname(T),{recursive:!0}),qn.writeFileSync(T,v)}catch{}return`/_stx/modules.${k}.js`}function hi(v){if(!/^[0-9a-f]{16}$/.test(v))return;let k=tr.get(v);if(k!==void 0)return k;try{return qn.readFileSync(mf(v),"utf8")}catch{return}}function dd(){Zr.clear(),ie(),df(),ha=null,Dy=null,ya=null}function hf(v){let k={debug:v.debug===!0,middleware:(v.middleware??[]).map((C)=>({name:C.name,timing:C.timing,handler:String(C.handler)})),customDirectives:(v.customDirectives??[]).map((C)=>({name:C.name,hasEndTag:C.hasEndTag===!0,rawParams:C.rawParams===!0,handler:String(C.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(k)).digest("hex")}async function wn(v,k){try{if(!k.cachePath)return null;let C=Xr.resolve(k.cachePath),R=Xr.join(C,`${cr(v)}.html`),T=Xr.join(C,`${cr(v)}.meta.json`);if(!await r(R)||!await r(T))return null;let z=await Bun.file(T).text(),F=JSON.parse(z);if(F.cacheVersion!==k.cacheVersion)return null;if(F.engine!==Ge())return null;if(F.optionsSignature!==hf(k))return null;if((await qn.promises.stat(v)).mtime.getTime()>F.mtime)return null;for(let H of F.dependencies)if(await r(H)){if((await qn.promises.stat(H)).mtime.getTime()>F.mtime)return null}else return null;return await Bun.file(R).text()}catch(C){return console.warn(`Cache error for ${v}:`,C),null}}async function xn(v,k,C,R){try{if(!R.cachePath)return;let T=Xr.resolve(R.cachePath);await qn.promises.mkdir(T,{recursive:!0});let z=Xr.join(T,`${cr(v)}.html`),F=Xr.join(T,`${cr(v)}.meta.json`),V=await qn.promises.stat(v);await Bun.write(z,k);let H={sourcePath:v,mtime:V.mtime.getTime(),dependencies:Array.from(C),cacheVersion:R.cacheVersion,engine:Ge(),optionsSignature:hf(R),generatedAt:Date.now()};await Bun.write(F,JSON.stringify(H,null,2)),Pc.set(v,{output:k,mtime:V.mtime.getTime(),dependencies:C})}catch(T){console.warn(`Failed to cache template ${v}:`,T)}}var Ny=16;function cr(v){return new Bun.CryptoHasher("sha1").update(v).digest("hex").substring(0,Ny)}var Xe={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Ee(v){return`--stx-${v}`}function xa(v,k){let C=k.lastIndexOf("-");if(C===-1)return typeof v[k]==="string"?v[k]:void 0;let R=v[k.slice(0,C)];if(!R||typeof R!=="object")return;let T=R[k.slice(C+1)];return typeof T==="string"?T:void 0}var jy=/^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;function yf(v,k){let C=k.trim();return xa(v,C)??(jy.test(C)?C:void 0)}function xf(v={}){return[...Object.keys(v.roles??{}).filter((k)=>!Xe[k]).map((k)=>`roles.${k}`),...Object.keys(v.shapes??{}).filter((k)=>!se[k]).map((k)=>`shapes.${k}`),...Object.keys(v.density??{}).filter((k)=>!ge[k]).map((k)=>`density.${k}`)]}function bf(v){let k={};for(let[C,R]of Object.entries(Xe)){let T=xa(v,R.light);if(T===void 0)continue;k[C]=`var(${Ee(C)}, ${T})`}return k}function vf(v,k={}){let C=[],R=[];for(let[T,z]of Object.entries(Xe)){let F=k[T],V=typeof F==="string"?F:F?.light,H=typeof F==="string"?F:F?.dark,K=V&&yf(v,V)||xa(v,z.light),X=H&&yf(v,H)||xa(v,z.dark);if(K===void 0)continue;if(C.push(` ${Ee(T)}: ${K};`),X!==void 0)R.push(` ${Ee(T)}: ${X};`)}if(C.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...C,"}",".dark {",...R,"}",""].join(`
136
- `)}var se={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function Lt(v){return`--stx-radius-${v}`}function wf(){let v={};for(let[k,C]of Object.entries(se))v[k]=`var(${Lt(k)}, ${C.value})`;return v}function Sf(v={}){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(se).map(([k,C])=>` ${Lt(k)}: ${v[k]??C.value};`),"}",""].join(`
137
- `)}var ge={"control-px":{value:"1rem",description:"Inline padding of a md text control \u2014 px-4"},"control-py":{value:"0.5rem",description:"Block padding of a md text control \u2014 py-2"},"control-text":{value:"1rem",description:"Font size of a md text control \u2014 text-base"},"control-leading":{value:"1.5rem",description:"Line height of a md text control \u2014 text-base"},"cell-px":{value:"1.5rem",description:"Inline padding of every table cell, header or body \u2014 px-6"},"cell-py":{value:"1rem",description:"Block padding of a body cell \u2014 py-4"},"cell-text":{value:"0.875rem",description:"Font size of a body cell \u2014 text-sm"},"cell-leading":{value:"1.25rem",description:"Line height of a body cell \u2014 text-sm"},"cell-head-py":{value:"0.75rem",description:"Block padding of a header cell \u2014 py-3"},"cell-head-text":{value:"0.75rem",description:"Font size of a header cell \u2014 text-xs"},"cell-head-leading":{value:"1rem",description:"Line height of a header cell \u2014 text-xs"}},Sn={"control-x":"control-px","control-y":"control-py","cell-x":"cell-px","cell-y":"cell-py","cell-head-y":"cell-head-py"},kn={control:{size:"control-text",leading:"control-leading"},cell:{size:"cell-text",leading:"cell-leading"},"cell-head":{size:"cell-head-text",leading:"cell-head-leading"}};function Te(v){return`--stx-${v}`}function ul(v){let k=ge[v];if(!k)throw Error(`[stx] unknown density token "${v}"`);return`var(${Te(v)}, ${k.value})`}function $f(){let v={};for(let[k,C]of Object.entries(Sn))v[k]=ul(C);return v}function _f(){let v={};for(let[k,{size:C,leading:R}]of Object.entries(kn))v[k]=[ul(C),{lineHeight:ul(R)}];return v}function kf(v={}){return["/* stx density tokens \u2014 how much room a control or a table cell takes. */",":root {",...Object.entries(ge).map(([k,C])=>` ${Te(k)}: ${v[k]??C.value};`),"}",""].join(`
138
- `)}function Ef(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function dl(v,k){let C={...v};for(let[R,T]of Object.entries(k))C[R]=Ef(T)&&Ef(C[R])?dl(C[R],T):T;return C}function Cf(v,k){if(!k.fonts)return"";let C=new v({...k.config,fonts:k.fonts,cssVariables:!1}).toCSS(!1,k.minify);return C&&!k.minify?`${C}
139
- `:C}function Rf(v={},k={}){let C=v.theme||{},R=k.theme||{},{extend:T,...z}=R,{extend:F,...V}=C,H=V.colors||{};V.colors={...H,...bf(H)};let K=V.borderRadius||{};V.borderRadius={...K,...wf()};let X=V.spacing||{};V.spacing={...X,...$f()};let G=V.fontSize||{};V.fontSize={...G,..._f()};let te=dl(V,z),ce=dl(F||{},T||{});if(Object.keys(ce).length>0)te.extend=ce;let ee=[...v.safelist||[],...k.safelist||[]],le={...v.shortcuts||{},...k.shortcuts||{}},ue=[...v.preflights||[],...k.preflights||[]],{fonts:de,...fe}=v,{fonts:pe,roles:Ae,shapes:Se,density:ve,...De}=k,Me={roles:Ae,shapes:Se,density:ve},je=pe??de;return{config:{...fe,...De,theme:te,safelist:ee,shortcuts:le,...ue.length>0?{preflights:ue}:{},content:[],output:""},safelist:ee,shortcuts:le,includePreflight:k.preflight!==!1,minify:k.minify===!0,tokenCSS:vf({...H,...te.colors},Ae)+Sf(Se)+kf(ve),unknownRoles:xf(Me),...je?{fonts:je}:{}}}function Af(v,k=""){let C=`${v}${k}`,R=0;for(let T=0;T<C.length;T++){let z=C.charCodeAt(T);R=(R<<5)-R+z,R=R&R}return`stx-${Math.abs(R).toString(36)}`}function Tf(v,k,C={}){let{prefix:R="",preserveHost:T=!0,scopeKeyframes:z=!0,scopeCustomProperties:F=!1}=C;if(!v.trim())return"";let V=fl(v),H=[],K=new Map;if(z)for(let X of V){let G=X.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(G){let te=G[1],ce=`${k}_${te}`;K.set(te,ce)}}for(let X of V){let G=If(X,k,R,T,K,F);H.push(G)}return H.join(`
140
-
141
- `)}function fl(v){let k=[],C=v.replace(/\/\*[\s\S]*?\*\//g,""),R=0,T="",z=!1,F="";for(let V=0;V<C.length;V++){let H=C[V];if(H==="@"&&R===0)z=!0;if(H==="{")R++;else if(H==="}"){if(R--,R===0){if(z){F+=H;let K=F.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(K){let[,X,G,te]=K;if(X==="keyframes")k.push({selector:`@keyframes ${G.trim()}`,declarations:te.trim()});else if(X==="media"||X==="supports"||X==="container"){let ce=fl(te);k.push({selector:`@${X} ${G.trim()}`,declarations:ce.map((ee)=>`${ee.selector} { ${ee.declarations} }`).join(`
142
- `)})}else k.push({selector:`@${X} ${G.trim()}`,declarations:te.trim()})}F="",z=!1}else if(T.trim()){T+=H;let K=T.match(/([^{]+)\{([^}]*)\}/);if(K)k.push({selector:K[1].trim(),declarations:K[2].trim()});T=""}continue}}if(z)F+=H;else T+=H}return k}function If(v,k,C,R,T,z){let{selector:F,declarations:V}=v;if(F.startsWith("@")){if(F.startsWith("@keyframes")){let X=F.replace("@keyframes ","").trim();return`@keyframes ${T.get(X)||X} { ${V} }`}if(F.startsWith("@media")||F.startsWith("@supports")||F.startsWith("@container")){let G=fl(`x { ${V} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((te)=>If(te,k,C,R,T,z)).join(`
143
- `);return`${F} {
144
- ${G}
145
- }`}return`${F} { ${V} }`}let H=Ly(F,k,C,R),K=V;for(let[X,G]of T)K=K.replace(new RegExp(`\\b${X}\\b`,"g"),G);if(z)K=K.replace(/--([a-z-]+)/gi,`--${k}-$1`);return`${H} { ${K} }`}function Ly(v,k,C,R){let T=v.split(",").map((F)=>F.trim()),z=[];for(let F of T){if(F.startsWith(":host")){if(R)z.push(F);else{let K=F.replace(/:host(\([^)]*\))?/,`.${k}$1`);z.push(K)}continue}if(F.includes("::slotted")){z.push(F);continue}if(F===":root"){z.push(`:root .${k}`);continue}let V=C?`${C} .${k}`:`.${k}`;z.push(`${V} ${F}`);let H=By(F,k);if(H)z.push(C?`${C} ${H}`:H)}return z.join(", ")}function By(v,k){let C=0,R=v.length;for(let H=0;H<v.length;H++){let K=v[H];if(K==="["||K==="(")C++;else if(K==="]"||K===")")C--;else if(C===0&&(K===" "||K===">"||K==="+"||K==="~")){R=H;break}}let T=v.slice(0,R),z=v.slice(R);if(!T)return"";let F=T.length,V=0;for(let H=0;H<T.length;H++){let K=T[H];if(K==="["||K==="(")V++;else if(K==="]"||K===")")V--;else if(C===0&&V===0&&K===":"){F=H;break}}return`${T.slice(0,F)}.${k}${T.slice(F)}${z}`}var Of=String.raw`(?<![\w-])scoped(?![\w-])`,pl=/<style\s+([^>]*)>/gi,Pf=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Mf=new RegExp(Of,"i"),zy=new RegExp(Of,"gi"),gl=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function Wy(v){pl.lastIndex=0;let k=pl.exec(v);while(k!==null){if(Mf.test(k[1]))return!0;k=pl.exec(v)}return!1}function ml(v){let k=new Set,C=[];gl.lastIndex=0;let R=gl.exec(v);while(R!==null){let T=R[0].trim();if(k.has(T))C.push({start:R.index,end:R.index+R[0].length});else k.add(T);R=gl.exec(v)}return C}function ao(v){let k=ml(v);if(k.length===0)return v;let C=Array(k.length+1),R=0;for(let T=0;T<k.length;T++){let z=k[T];C[T]=v.slice(R,z.start),R=z.end}return C[k.length]=v.slice(R),C.join("")}function ba(v,k){if(!Wy(v))return{html:v,hasScoped:!1};let C=Af(k),R=`data-v-${C}`,T=v,z=!1;if(Pf.lastIndex=0,T=T.replace(Pf,(F,V,H)=>{if(!Mf.test(V))return F;z=!0;let K=Fy(H,R),X=V.replace(zy,"").trim(),G=X?` ${X}`:"";return`<style data-stx-scoped="${C}"${G}>${K}</style>`}),!z)return{html:v,hasScoped:!1};return T=Uy(T,R),{html:T,hasScoped:!0}}function Fy(v,k){return Tf(v,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${k}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${k}]`)}var Vy=(v)=>`\x00stx-scope-mask-${v}\x00`,Df=/\u0000stx-scope-mask-(\d+)\u0000/g;function Uy(v,k){let C=Un(v,(T,z)=>{let F=U(T,z);return F>z?F:us(T,z)},(T,z)=>Vy(z)),R=Hy(C.output,k);return Df.lastIndex=0,R.replace(Df,(T,z)=>C.tokens[Number(z)])}function Hy(v,k){let C=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return v.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(R,T,z)=>{if(C.has(T.toLowerCase()))return R;if(R.includes(k))return R;if(T.toLowerCase()==="style"||T.toLowerCase()==="script")return R;if(z)return R.replace(`<${T}${z}`,`<${T} ${k}${z}`);if(R.endsWith("/>"))return`<${T} ${k} />`;return`<${T} ${k}>`})}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var Kn=null,va="";function jf(v){try{let k=v.startsWith("file:")?new URL(v).pathname:v;va=`${k}@${Math.trunc(lo.statSync(k).mtimeMs)}`}catch{va=v}}var yl=!1,Gr=null,co="",ps=!1,Wf=256,Ir=new Map,Xn=new Map,wa=null,Ff=null,Sa=new Map,Lf=new Set;function $a(v){return Bun.hash(v).toString(16).padStart(16,"0").slice(0,16)}function hl(v,k){if(Ir.has(v))Ir.delete(v);else if(Ir.size>=Wf)Ir.delete(Ir.keys().next().value);Ir.set(v,k)}function qy(v){let k=$a(v);if(Xn.has(k))Xn.delete(k);else if(Xn.size>=Wf)Xn.delete(Xn.keys().next().value);return Xn.set(k,v),k}function pd(v){let k=Xn.get(v);if(k===void 0)return;return Xn.delete(v),Xn.set(v,k),k}async function Ky(v,k=wa){if(!k)return null;try{let C=Bun.file(Xt.join(k,`cw-${$a(v)}.css`));if(!await C.exists())return null;return await C.text()}catch{return null}}async function Xy(v,k,C=wa){if(!C)return;try{if(!lo.existsSync(C))lo.mkdirSync(C,{recursive:!0});await Bun.write(Xt.join(C,`cw-${$a(v)}.css`),k)}catch{}}async function Bf(v){try{let k=await import(v);if(k&&k.CSSGenerator)return{CSSGenerator:k.CSSGenerator,config:k.config,build:k.build,defaultConfig:k.defaultConfig,extractClasses:k.extractClasses}}catch{}return null}var Zy=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],Gy=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function Jy(){let v=[],k=process.cwd();while(k!==Xt.dirname(k)){for(let C of["node_modules","pantry"])for(let R of Zy)v.push(Xt.join(k,C,...R));k=Xt.dirname(k)}return v}function Yy(){let v=[],k=process.env.HOME||process.env.USERPROFILE||"",C=[k&&Xt.join(k,"Code","Tools","ts-css"),k&&Xt.join(k,"Code","Tools","crosswind"),k&&Xt.join(k,"repos","stacks-org","ts-css"),k&&Xt.join(k,"repos","stacks-org","crosswind"),Xt.join(process.cwd(),"..","ts-css"),Xt.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let R of C)v.push(Xt.join(R,"packages","toolkit","dist","engine","index.js")),v.push(Xt.join(R,"packages","toolkit","src","engine","index.ts"));if(k)v.push(Xt.join(k,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return v}async function yi(){if(yl)return Kn;yl=!0;try{let v=async(T)=>{for(let z of T){if(!await Bun.file(z).exists())continue;let F=await Bf(z);if(F){if(jf(z),!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${Xt.dirname(Xt.dirname(z))}`);return F}}return null};if(process.env.CROSSWIND_SRC){let T=Xt.resolve(process.env.CROSSWIND_SRC),z=await v([T]);if(!z)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${T}`);return Kn=z,Kn}let k=await v(Jy());if(k)return Kn=k,Kn;let C=Gy;for(let T of C){let z=await Bf(T);if(z){Kn=z;try{jf(import.meta.resolve(T))}catch{va=T}if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return Kn}}let R=await v(Yy());if(R)return Kn=R,Kn;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function fd(){xl.clear(),Kn=null,yl=!1,Gr=null,co="",Ir.clear(),Xn.clear(),Ff=null,Sa.clear()}var zf=!1;async function bi(v){try{let k=Nf({name:"css",cwd:v})?"css":Nf({name:"crosswind",cwd:v})?"crosswind":null;if(!k)return null;if(k==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!zf)zf=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:C}=await import("bunfig"),R=await C({name:k,cwd:v,defaultConfig:{},checkEnv:!1,verbose:!1});if(!R?.path||!R.config||Object.keys(R.config).length===0)return null;let T=Xt.relative(v,R.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${T||R.path}`);return R.config}catch(k){if(k instanceof Error&&k.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,k instanceof Error?k.message:k),null}}async function Nc(v){let k=null;try{let{loadStxConfig:C}=await import("./chunk-8em788gc.js"),R=await C(v);if(R.css)if(typeof R.css==="string"){let T=Xt.isAbsolute(R.css)?R.css:Xt.resolve(v,R.css);if(await Bun.file(T).exists()){let z=await import(T);k=z.default||z,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(k={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=Xt.isAbsolute(R.css.config)?R.css.config:Xt.resolve(v,R.css.config);if(await Bun.file(T).exists()){let z=await import(T);k={...z.default||z,...k}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return k||await bi(v)}function Dc(v){try{let k=new WeakSet;return $a(JSON.stringify(v??{},(C,R)=>{if(typeof R==="function")return`[fn]${String(R)}`;if(typeof R==="object"&&R!==null){if(k.has(R))return"[circular]";k.add(R)}return R})??"")}catch{return"unhashable"}}async function jt(v){if(ps)return co;ps=!0;try{let k=await yi();if(!k||!k.build)return ps=!1,"";if(!Gr)Gr=await bi(v);if(!Gr)return ps=!1,"";let C=k.defaultConfig?.theme||{},R=Gr.theme||{},T={...k.defaultConfig,...Gr,theme:{...C,...R,extend:{...C.extend||{},...R.extend||{}}}},z=performance.now(),F=await k.build(T),V=performance.now()-z;if(co=F.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${F.classes.size} classes in ${V.toFixed(1)}ms`),T.output){let H=Xt.isAbsolute(T.output)?T.output:Xt.join(v,T.output),K=Xt.dirname(H);if(!lo.existsSync(K))lo.mkdirSync(K,{recursive:!0});await Bun.write(H,F.css)}return ps=!1,F.css}catch(k){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,k),ps=!1,co}}async function _n(v){Gr=null,await jt(v)}function gd(){return co}function Mc(v){let k=new Set,C=/class\s*=\s*["']([^"']+)["']/gi,R=C.exec(v);while(R!==null){for(let F of R[1].split(/\s+/))if(F.trim())k.add(F.trim());R=C.exec(v)}let T=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,z=T.exec(v);while(z!==null){let F=z[1].match(/'([^']+)'/g);if(F){for(let V of F)for(let H of V.slice(1,-1).split(/\s+/))if(H.trim())k.add(H.trim())}z=T.exec(v)}return k}var xl=m(64);async function Lc(v,k){let C=()=>Sa.get(k?Xt.resolve(k):process.cwd())?.fingerprint??null,R=xl.get(h(v,k,C()));if(R!==void 0)return R;let T=await Qy(v,k);if(T)xl.set(h(v,k,C()),T);return T}function*Vf(v){yield v;let k=new Set;for(let C of v.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let R=C[1];if(k.has(R))continue;k.add(R);let T=hi(R);if(T)yield T}}function md(v){return[...Vf(v)].join(`
146
- `)}async function Qy(v,k){try{let C=await yi();if(!C)return"";let R=new Set;for(let Me of Vf(v)){let je=typeof C.extractClasses==="function"?C.extractClasses(Me):Mc(Me);for(let Le of je)R.add(Le)}if(R.size===0)return"";let T=k?Xt.resolve(k):process.cwd(),z=a(T,"cache");if(!wa)wa=z;let F=Sa.get(T);if(!F){let Me=await Nc(T);F={config:Me,fingerprint:Dc(Me)},Sa.set(T,F),Ff=F.fingerprint}let V=[...R].sort().join(" "),H=`${va}::${F.fingerprint||"default"}::${V}`,K=Ir.get(H);if(K!==void 0)return hl(H,K),K;let X=await Ky(H,z);if(X!==null)return hl(H,X),X;let G=C.defaultConfig||C.config,te=F.config||{},ce=Rf(G,te),{safelist:ee,includePreflight:le,minify:ue,tokenCSS:de}=ce;if(ce.unknownRoles.length>0&&!Lf.has(T))Lf.add(T),console.warn(`${e.yellow}[ts-css]${e.reset} No stx role for ${ce.unknownRoles.join(", ")} - these keep the stock value. Role names: semanticTokenNames() in @stacksjs/stx/theme-tokens.`);let fe=ce.config,pe=new C.CSSGenerator(fe),Ae=fe.shortcuts||te.shortcuts||{},Se=Object.keys(Ae).filter((Me)=>R.has(Me)||ee.includes(Me));for(let Me of ee)if(!Ae[Me])pe.generate(Me);for(let Me of R)if(!Ae[Me])pe.generate(Me);let ve="";if(Se.length>0){let Me=new C.CSSGenerator(fe);for(let je of Se)Me.generate(je);if(ve=Me.toCSS(!1,ue),ve&&!ve.endsWith(`
147
- `))ve+=`
148
- `}let De=ve+pe.toCSS(le,ue);return De=Cf(C.CSSGenerator,ce)+de+De,hl(H,De),Xy(H,De,z),De}catch(C){return console.warn("Failed to generate Css CSS:",C),""}}async function f(v,k,C=!1,R=!1){let T=await Lc(v,k);if(!T)return R?ao(v):v;let z=C?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${qy(T)}.css">`:`<style data-css="generated">
149
- ${T}
150
- </style>`;if(R)return ex(v,z);let F=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(F.test(v)){let V=!1;return v.replace(F,()=>{if(V)return"";return V=!0,z})}if(v.includes("</head>"))return v.replace("</head>",`${z}
151
- </head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>
152
- ${z}`);return z+v}function ex(v,k){let C=ml(v).map((H)=>({...H,replacement:""})),R=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,T=R.exec(v);if(T!==null){let H=!0;while(T!==null)C.push({start:T.index,end:T.index+T[0].length,replacement:H?k:""}),H=!1,T=R.exec(v)}else{let H=v.indexOf("</head>");if(H!==-1)C.push({start:H,end:H,replacement:`${k}
153
- `});else{let K=v.match(/<body([^>]*)>/);if(K?.index!==void 0)C.push({start:K.index,end:K.index+K[0].length,replacement:`${K[0]}
154
- ${k}`});else C.push({start:0,end:0,replacement:k})}}C.sort((H,K)=>H.start-K.start||H.end-K.end);for(let H=1;H<C.length;H++)if(C[H].start<C[H-1].end)return tx(ao(v),k);let z=Array(C.length*2+1),F=0,V=0;for(let H of C)z[V++]=v.slice(F,H.start),z[V++]=H.replacement,F=H.end;return z[V]=v.slice(F),z.join("")}function tx(v,k){let C=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(C.test(v)){let R=!1;return v.replace(C,()=>{if(R)return"";return R=!0,k})}if(v.includes("</head>"))return v.replace("</head>",`${k}
155
- </head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>
156
- ${k}`);return k+v}var bl=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],Uf=/<body\b([^>]*)>/gi;function Zn(v){let k=0,C,R=bl.map(()=>{return});while(k<v.length){if(C===void 0||C!==null&&C.index<k)Uf.lastIndex=k,C=Uf.exec(v);if(!C)return null;let T=C.index,z=-1,F=null;for(let H=0;H<bl.length;H++){let K=bl[H],X=R[H];if(X===void 0||X!==null&&X.index<k)K.open.lastIndex=k,X=K.open.exec(v),R[H]=X;if(!X)continue;if(X.index<T&&(z===-1||X.index<z))z=X.index,F=K.close}if(z===-1||!F)return{index:T,tag:C[0],attrs:C[1]??""};F.lastIndex=z;let V=F.exec(v);if(!V)return null;k=V.index+V[0].length}return null}function gs(v,k){let C=Zn(v);if(!C)return v;return v.slice(0,C.index)+k(C.tag,C.attrs)+v.slice(C.index+C.tag.length)}var Hf=/<style\b[^>]*>/iy,qf=/<\/style>/gi,Kf=/<script\b[^>]*>/iy,Xf=/<template(?=[\s>/])[^>]*>/iy,Zf=/<\/template\s*>/iy;function fo(v){let k=0,C=0,R=-1;while(k<v.length){let T=v.indexOf("<",k);if(T===-1)return-1;if(v.startsWith("<!--",T)){let H=v.indexOf("-->",T+4);k=H===-1?v.length:H+3;continue}Hf.lastIndex=T;let z=Hf.exec(v);if(z){qf.lastIndex=T+z[0].length;let H=qf.exec(v);k=H===null?v.length:H.index+8;continue}Xf.lastIndex=T;let F=Xf.exec(v);if(F){if(C===0)R=T;C++,k=T+F[0].length;continue}Zf.lastIndex=T;let V=Zf.exec(v);if(V){if(C>0)C--;k=T+V[0].length;continue}if(Kf.lastIndex=T,Kf.test(v))return C>0?R:T;k=T+1}return-1}function Gf(){return`
157
- // STX Lifecycle Runtime
158
- (function() {
159
- if (typeof window === 'undefined') return;
160
-
161
- const instances = new Map();
162
- let currentInstance = null;
163
- let idCounter = 0;
164
-
165
- function generateId() {
166
- return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
167
- }
168
-
169
- function createInstance(element) {
170
- const instance = {
171
- id: generateId(),
172
- element: element,
173
- mountHooks: [],
174
- destroyHooks: [],
175
- updateHooks: [],
176
- refs: new Map(),
177
- watchers: [],
178
- isMounted: false
179
- };
180
- instances.set(instance.id, instance);
181
- return instance;
182
- }
183
-
184
- window.STX = window.STX || {};
185
-
186
- // Lifecycle hooks
187
- window.STX.onMount = function(hook) {
188
- if (currentInstance) currentInstance.mountHooks.push(hook);
189
- };
190
-
191
- window.STX.onDestroy = function(hook) {
192
- if (currentInstance) currentInstance.destroyHooks.push(hook);
193
- };
194
-
195
- window.STX.onUpdate = function(hook) {
196
- if (currentInstance) currentInstance.updateHooks.push(hook);
197
- };
198
-
199
- // Aliases
200
- window.STX.onMounted = window.STX.onMount;
201
- window.STX.onUnmounted = window.STX.onDestroy;
202
- window.STX.onUpdated = window.STX.onUpdate;
203
-
204
- // Refs
205
- window.STX.ref = function(initialValue) {
206
- const r = { value: initialValue || null };
207
- Object.defineProperty(r, 'current', {
208
- get: function() { return this.value; }
209
- });
210
- if (currentInstance) {
211
- currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
212
- }
213
- return r;
214
- };
215
-
216
- // Watch
217
- window.STX.watch = function(source, callback, options) {
218
- options = options || {};
219
- let oldValue;
220
- let cleanup;
221
- let isActive = true;
222
-
223
- function run() {
224
- if (!isActive) return;
225
- const newValue = source();
226
- if (oldValue !== newValue || options.immediate) {
227
- if (cleanup) cleanup();
228
- cleanup = callback(newValue, oldValue);
229
- oldValue = newValue;
230
- }
231
- }
232
-
233
- if (options.immediate) {
234
- run();
235
- }
236
- else {
237
- oldValue = source();
238
- }
239
-
240
- const intervalId = setInterval(run, 16);
241
-
242
- function stop() {
243
- isActive = false;
244
- clearInterval(intervalId);
245
- if (cleanup) cleanup();
246
- }
247
-
248
- if (currentInstance) {
249
- currentInstance.watchers.push({ stop: stop });
250
- currentInstance.destroyHooks.push(stop);
251
- }
252
-
253
- return stop;
254
- };
255
-
256
- // Computed
257
- window.STX.computed = function(getter) {
258
- let cached;
259
- let dirty = true;
260
- return {
261
- get value() {
262
- if (dirty) {
263
- cached = getter();
264
- dirty = false;
265
- queueMicrotask(function() { dirty = true; });
266
- }
267
- return cached;
268
- }
269
- };
270
- };
271
-
272
- // Component management
273
- window.STX.setupComponent = function(element, setup) {
274
- const instance = createInstance(element);
275
- currentInstance = instance;
276
- try {
277
- setup();
278
- }
279
- finally {
280
- currentInstance = null;
281
- }
282
- return instance;
283
- };
284
-
285
- window.STX.mountComponent = function(instance) {
286
- if (instance.isMounted) return;
287
- instance.isMounted = true;
288
- instance.mountHooks.forEach(function(hook) {
289
- try {
290
- const cleanup = hook();
291
- if (typeof cleanup === 'function') {
292
- instance.destroyHooks.push(cleanup);
293
- }
294
- else if (cleanup && typeof cleanup.then === 'function') {
295
- cleanup.catch(function(e) { console.error('[stx] onMount error:', e); });
296
- }
297
- }
298
- catch (e) {
299
- console.error('[stx] onMount error:', e);
300
- }
301
- });
302
- };
303
-
304
- window.STX.destroyComponent = function(instance) {
305
- if (!instance.isMounted) return;
306
- instance.watchers.forEach(function(w) { w.stop(); });
307
- instance.destroyHooks.forEach(function(hook) {
308
- try { hook(); }
309
- catch (e) { console.error('[stx] onDestroy error:', e); }
310
- });
311
- instance.refs.forEach(function(ref) { ref.value = null; });
312
- instance.isMounted = false;
313
- instances.delete(instance.id);
314
- };
315
-
316
- // ==========================================================================
317
- // Vue-Style Refs System - No document.** required!
318
- // ==========================================================================
319
-
320
- // Internal: Query for ref elements without exposing document API
321
- function queryRef(name, root) {
322
- return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
323
- }
324
-
325
- function queryAllRefs(root) {
326
- return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
327
- }
328
-
329
- // Auto-bind refs from ref attributes (Vue-style)
330
- window.STX.bindRefs = function(root, refs) {
331
- if (!root) return;
332
- queryAllRefs(root).forEach(function(el) {
333
- var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
334
- if (refs[refName]) {
335
- refs[refName].value = el;
336
- }
337
- });
338
- };
339
-
340
- // Vue-style useRefs() - returns object with all refs as direct elements
341
- // Usage: const { input, button, container } = STX.useRefs()
342
- window.STX.useRefs = function(root) {
343
- var refs = {};
344
- queryAllRefs(root).forEach(function(el) {
345
- var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
346
- if (refName) {
347
- refs[refName] = el;
348
- }
349
- });
350
- return refs;
351
- };
352
-
353
- // Get a single ref by name - Vue's useTemplateRef equivalent
354
- // Usage: const input = STX.useRef('input')
355
- window.STX.useRef = function(name, root) {
356
- return queryRef(name, root);
357
- };
358
-
359
- // Two-way binding helper for form elements
360
- // Usage: STX.model(inputEl, state, 'username')
361
- window.STX.model = function(el, state, key) {
362
- if (!el || !state) return;
363
-
364
- var isCheckbox = el.type === 'checkbox';
365
- var isRadio = el.type === 'radio';
366
- var isSelect = el.tagName === 'SELECT';
367
-
368
- // Set initial value
369
- if (isCheckbox) {
370
- el.checked = !!state[key];
371
- }
372
- else if (isRadio) {
373
- el.checked = el.value === state[key];
374
- }
375
- else {
376
- el.value = state[key] || '';
377
- }
378
-
379
- // Listen for changes
380
- var eventType = isCheckbox || isRadio ? 'change' : 'input';
381
- el.addEventListener(eventType, function() {
382
- if (isCheckbox) {
383
- state[key] = el.checked;
384
- }
385
- else if (isRadio) {
386
- if (el.checked) state[key] = el.value;
387
- }
388
- else {
389
- state[key] = el.value;
390
- }
391
- });
392
-
393
- // Return cleanup function
394
- return function() {
395
- el.removeEventListener(eventType, arguments.callee);
396
- };
397
- };
398
-
399
- // Batch event binding helper - cleaner than manual addEventListener
400
- // Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
401
- window.STX.on = function(el, event, handler) {
402
- if (!el) return function() {};
403
- el.addEventListener(event, handler);
404
- return function() { el.removeEventListener(event, handler); };
405
- };
406
-
407
- // Bind multiple events at once
408
- // Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
409
- window.STX.events = function(el, eventMap) {
410
- if (!el) return function() {};
411
- var cleanups = [];
412
- Object.keys(eventMap).forEach(function(event) {
413
- el.addEventListener(event, eventMap[event]);
414
- cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
415
- });
416
- return function() { cleanups.forEach(function(c) { c(); }); };
417
- };
418
-
419
- // ==========================================================================
420
- // DOM Helpers - Eliminate document.* usage
421
- // ==========================================================================
422
-
423
- // Global keyboard event listener
424
- // Usage: STX.onKey('Escape', () => closeModal())
425
- window.STX.onKey = function(key, handler, options) {
426
- var listener = function(e) {
427
- if (e.key === key) {
428
- handler(e);
429
- }
430
- };
431
- document.addEventListener('keydown', listener, options);
432
- return function() { document.removeEventListener('keydown', listener, options); };
433
- };
434
-
435
- // Create element helper
436
- // Usage: STX.el('div', { class: 'foo' }, 'text content')
437
- window.STX.el = function(tag, attrs, content) {
438
- var el = document.createElement(tag);
439
- if (attrs) {
440
- Object.keys(attrs).forEach(function(key) {
441
- if (key === 'class') {
442
- el.className = attrs[key];
443
- }
444
- else if (key.startsWith('on')) {
445
- el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
446
- }
447
- else {
448
- el.setAttribute(key, attrs[key]);
449
- }
450
- });
451
- }
452
- if (content) {
453
- if (typeof content === 'string') {
454
- el.textContent = content;
455
- }
456
- else if (Array.isArray(content)) {
457
- content.forEach(function(child) { el.appendChild(child); });
458
- }
459
- else {
460
- el.appendChild(content);
461
- }
462
- }
463
- return el;
464
- };
465
-
466
- // Get currently focused element
467
- // Usage: const focused = STX.activeElement()
468
- window.STX.activeElement = function() {
469
- return document.activeElement;
470
- };
471
-
472
- // Escape HTML helper
473
- // Usage: const safe = STX.escapeHtml(userInput)
474
- window.STX.escapeHtml = function(text) {
475
- var div = document.createElement('div');
476
- div.textContent = text;
477
- return div.innerHTML;
478
- };
479
-
480
- // MutationObserver for automatic lifecycle management
481
- const observer = new MutationObserver(function(mutations) {
482
- mutations.forEach(function(mutation) {
483
- // Handle removed nodes
484
- mutation.removedNodes.forEach(function(node) {
485
- if (node.nodeType === 1 && node.__stx_instance__) {
486
- window.STX.destroyComponent(node.__stx_instance__);
487
- }
488
- });
489
- });
490
- });
491
-
492
- // Start observing when DOM is ready
493
- if (document.readyState === 'loading') {
494
- document.addEventListener('DOMContentLoaded', function() {
495
- observer.observe(document.body, { childList: true, subtree: true });
496
- });
497
- }
498
- else {
499
- observer.observe(document.body, { childList: true, subtree: true });
500
- }
501
-
502
- console.log('[stx] Lifecycle runtime initialized');
503
- })();
504
- `}function vl(v){return Symbol(v)}var v_=vl("theme"),w_=vl("router"),S_=vl("i18n");import*as Yf from"crypto";function Jf(v){let k=/\$(\w+)\./g,C=[],R;while((R=k.exec(v))!==null)if(!C.includes(R[1]))C.push(R[1]);return C}function nx(){return`stx-${Yf.randomBytes(4).toString("hex")}`}function rx(v){return/\$\w+\./.test(v)}function sx(v){if(!v.includes("{{")||!/\$\w+\./.test(v))return{html:v,bindings:[],stores:new Set};let k=[],C=new Set,R=/<(\w+)([^>]*?)(\s*\/?>)/g,T=v;return T=T.replace(R,(z,F,V,H)=>{if(["script","style","template"].includes(F.toLowerCase()))return z;let K=[],X=!1,G=V,te=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,ce=[...V.matchAll(te)];for(let ue of ce){let de=ue[0],fe=ue[1],pe=ue[2];if(rx(pe)){X=!0;let Ae=pe.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(Ae){let Se=Ae[1];if(K.push({attr:fe,expr:Se,fullMatch:de,originalAttr:fe}),Jf(Se).forEach((De)=>C.add(De)),fe==="text")G=G.replace(de,"");else if(fe==="class")G=G.replace(de,'class=""');else if(fe==="disabled"||fe==="hidden")G=G.replace(de,"");else G=G.replace(de,`${fe}=""`)}}}if(!X)return z;let ee=G.match(/\bid\s*=\s*"([^"]+)"/),le;if(ee)le=ee[1];else le=nx(),G=` id="${le}"${G}`;for(let ue of K)k.push({elementId:le,attribute:ue.attr,expression:ue.expr,stores:Jf(ue.expr)});return`<${F}${G}${H}`}),{html:T,bindings:k,stores:C}}function ix(v,k){if(v.length===0)return"";let C=Array.from(k),R=`
505
- <script>
506
- (function() {
507
- 'use strict';
508
-
509
- // Wait for stores to be available
510
- function initBindings() {
511
- var stores = window.VoideStores;
512
- if (!stores) {
513
- setTimeout(initBindings, 10);
514
- return;
515
- }
516
-
517
- // Store references for expressions
518
- // eslint-disable-next-line pickier/no-unused-vars
519
- var $state = {};
520
- `;for(let T of C)R+=` $state.${T} = stores.${T} ? stores.${T}.get() : {};
521
- `;R+=`
522
- // Binding update functions
523
- function updateBindings() {
524
- `;for(let T of v){let{elementId:z,attribute:F,expression:V}=T,H=V.replace(/\$(\w+)\./g,"$state.$1.");if(F==="text")R+=` (function() {
525
- var el = document.getElementById('${z}');
526
- if (el) {
527
- try {
528
- el.textContent = ${H};
529
- }
530
- catch (e) { console.error('Binding error:', e); }
531
- }
532
- })();
533
- `;else if(F==="html")R+=` (function() {
534
- var el = document.getElementById('${z}');
535
- if (el) {
536
- try {
537
- el.innerHTML = ${H};
538
- }
539
- catch (e) { console.error('Binding error:', e); }
540
- }
541
- })();
542
- `;else if(F==="class")R+=` (function() {
543
- var el = document.getElementById('${z}');
544
- if (el) {
545
- try {
546
- var value = ${H};
547
- if (typeof value === 'string') {
548
- // Dynamic class string - merge with existing static classes
549
- // eslint-disable-next-line pickier/no-unused-vars
550
- var staticClasses = el.getAttribute('data-static-class') || el.className;
551
- if (!el.hasAttribute('data-static-class')) {
552
- el.setAttribute('data-static-class', el.className);
553
- }
554
- el.className = (el.getAttribute('data-static-class') + ' ' + value).trim();
555
- }
556
- else if (typeof value === 'object') {
557
- // Object syntax: { 'class-name': condition }
558
- for (var cls in value) {
559
- if (value[cls]) {
560
- el.classList.add(cls);
561
- }
562
- else {
563
- el.classList.remove(cls);
564
- }
565
- }
566
- }
567
- }
568
- catch (e) { console.error('Binding error:', e); }
569
- }
570
- })();
571
- `;else if(F==="show")R+=` (function() {
572
- var el = document.getElementById('${z}');
573
- if (el) {
574
- try {
575
- el.style.display = (${H}) ? '' : 'none';
576
- }
577
- catch (e) { console.error('Binding error:', e); }
578
- }
579
- })();
580
- `;else if(F==="if")R+=` (function() {
581
- var el = document.getElementById('${z}');
582
- if (el) {
583
- try {
584
- el.style.visibility = (${H}) ? 'visible' : 'hidden';
585
- }
586
- catch (e) { console.error('Binding error:', e); }
587
- }
588
- })();
589
- `;else R+=` (function() {
590
- var el = document.getElementById('${z}');
591
- if (el) {
592
- try {
593
- var value = ${H};
594
- if (value === false || value === null || value === undefined) {
595
- el.removeAttribute('${F}');
596
- }
597
- else if (value === true) {
598
- el.setAttribute('${F}', '');
599
- }
600
- else {
601
- el.setAttribute('${F}', value);
602
- }
603
- }
604
- catch (e) { console.error('Binding error:', e); }
605
- }
606
- })();
607
- `}R+=` }
608
-
609
- // Subscribe to stores and update on changes. Capture the disposers so
610
- // SPA fragment swaps can tear down old bindings before the next page's
611
- // runtime takes over \u2014 without this, every navigation between pages
612
- // using reactive-bindings stacked another subscription on every store,
613
- // walking detached DOM forever. See stacksjs/stx#1709.
614
- var _disposers = [];
615
- `;for(let T of C)R+=` if (stores.${T}) {
616
- var _unsub_${T} = stores.${T}.subscribe(function(state) {
617
- $state.${T} = state;
618
- updateBindings();
619
- });
620
- // store.subscribe() may return the disposer (preferred) or void; both
621
- // are tolerated here.
622
- if (typeof _unsub_${T} === 'function') _disposers.push(_unsub_${T});
623
- }
624
- `;return R+=`
625
- // Initial update
626
- updateBindings();
627
-
628
- // Register this runtime's cleanup so SPA navigation can run it before
629
- // swapping pages. The router (and any code) can call
630
- // window.__stxCleanupBindings() to dispose subscriptions; we also wire
631
- // 'popstate' and 'beforeunload' as a safety net for browser-driven nav.
632
- function _cleanup() {
633
- for (var i = 0; i < _disposers.length; i++) {
634
- try { _disposers[i](); } catch (e) { /* swallow */ }
635
- }
636
- _disposers.length = 0;
637
- }
638
- if (!window.__stxBindingsCleanups) window.__stxBindingsCleanups = [];
639
- window.__stxBindingsCleanups.push(_cleanup);
640
- if (!window.__stxCleanupBindings) {
641
- window.__stxCleanupBindings = function() {
642
- var fns = window.__stxBindingsCleanups || [];
643
- for (var i = 0; i < fns.length; i++) {
644
- try { fns[i](); } catch (e) { /* swallow */ }
645
- }
646
- window.__stxBindingsCleanups = [];
647
- };
648
- window.addEventListener('popstate', window.__stxCleanupBindings);
649
- window.addEventListener('beforeunload', window.__stxCleanupBindings);
650
- }
651
- }
652
-
653
- // Start when DOM is ready
654
- if (document.readyState === 'loading') {
655
- document.addEventListener('DOMContentLoaded', initBindings);
656
- }
657
- else {
658
- initBindings();
659
- }
660
- })();
661
- </script>
662
- `,R}function Qf(v){let{html:k,bindings:C,stores:R}=sx(v);if(C.length===0)return v;let T=ix(C,R),z=k.lastIndexOf("</body>");if(z!==-1)return k.slice(0,z)+T+k.slice(z);return k+T}function ox(v){let k=v.analytics;if(!k?.enabled)return"";switch(k.driver){case"fathom":return ax(k);case"google-analytics":return cx(k);case"plausible":return lx(k);case"self-hosted":return ux(k);case"custom":return dx(k);default:return""}}function ax(v){let k=v.fathom;if(!k?.siteId)return"";let C=k.scriptUrl||"https://cdn.usefathom.com/script.js",R=k.defer!==!1?" defer":"",T=[`data-site="${hn(k.siteId)}"`];if(k.honorDnt)T.push('data-honor-dnt="true"');if(k.spa)T.push('data-spa="auto"');if(k.canonical)T.push(`data-canonical="${hn(k.canonical)}"`);if(k.auto===!1)T.push('data-auto="false"');return`
663
- <!-- Fathom Analytics -->
664
- <script src="${hn(C)}" ${T.join(" ")}${R}></script>
665
- `}function cx(v){let k=v.googleAnalytics;if(!k?.measurementId)return"";let C=hn(k.measurementId),R=k.debug?`gtag('config', '${C}', { 'debug_mode': true });`:"";return`
666
- <!-- Google Analytics -->
667
- <script async src="https://www.googletagmanager.com/gtag/js?id=${C}"></script>
668
- <script>
669
- window.dataLayer = window.dataLayer || [];
670
- function gtag(){dataLayer.push(arguments);}
671
- gtag('js', new Date());
672
- gtag('config', '${C}');
673
- ${R}
674
- </script>
675
- `}function lx(v){let k=v.plausible;if(!k?.domain)return"";let C=k.scriptUrl||"https://plausible.io/js/script.js",R=[`data-domain="${hn(k.domain)}"`],T=C,z=[];if(k.trackLocalhost)z.push("local");if(k.hashMode)z.push("hash");if(z.length>0&&C==="https://plausible.io/js/script.js")T=`https://plausible.io/js/script.${z.join(".")}.js`;return`
676
- <!-- Plausible Analytics -->
677
- <script defer data-domain="${hn(k.domain)}" src="${hn(T)}"></script>
678
- `}function ux(v){let k=v.selfHosted;if(!k?.siteId||!k?.apiEndpoint)return"";let C=hn(k.siteId),R=hn(k.apiEndpoint),T=k.honorDnt?'if(n.doNotTrack==="1")return;':"",z=k.trackHashChanges?"w.addEventListener('hashchange',pv);":"",F=k.trackOutboundLinks?`
679
- d.addEventListener('click',function(e){
680
- var a=e.target.closest('a');
681
- if(a&&a.hostname!==location.hostname){
682
- t('outbound',{url:a.href});
683
- }
684
- });`:"";return`
685
- <!-- Self-Hosted Analytics -->
686
- <script data-site="${C}" data-api="${R}" defer>
687
- (function(){
688
- 'use strict';
689
- var d=document,w=window,n=navigator,s=d.currentScript;
690
- var site=s.dataset.site,api=s.dataset.api;
691
- ${T}
692
- var q=[],sid=Math.random().toString(36).slice(2);
693
- function t(e,p){
694
- var x=new XMLHttpRequest();
695
- x.open('POST',api+'/collect',true);
696
- x.setRequestHeader('Content-Type','application/json');
697
- x.send(JSON.stringify({
698
- s:site,sid:sid,e:e,p:p||{},
699
- u:location.href,r:d.referrer,t:d.title,
700
- sw:screen.width,sh:screen.height
701
- }));
702
- }
703
- function pv(){t('pageview');}
704
- ${z}
705
- ${F}
706
- if(d.readyState==='complete')pv();
707
- else w.addEventListener('load',pv);
708
- w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
709
- })();
710
- </script>
711
- `}function dx(v){let k=v.custom;if(!k)return"";if(k.inlineScript)return`
712
- <!-- Custom Analytics -->
713
- <script>
714
- ${k.inlineScript}
715
- </script>
716
- `;if(!k.scriptUrl)return"";let C=[];if(k.scriptId)C.push(`id="${hn(k.scriptId)}"`);if(k.attributes)for(let[T,z]of Object.entries(k.attributes))C.push(`${hn(T)}="${hn(z)}"`);return`
717
- <!-- Custom Analytics -->
718
- <script${C.length>0?` ${C.join(" ")}`:""} src="${hn(k.scriptUrl)}" defer></script>
719
- `}function ep(v,k){let C=ox(k);if(!C)return v;if(!v.includes("</head>")){let R=v.lastIndexOf("</body>");if(R!==-1)return v.slice(0,R)+C+v.slice(R);return v+C}return v.replace("</head>",`${C}</head>`)}function hn(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var fx={enabled:!1,trackMouse:!0,trackClicks:!0,trackScroll:!0,samplingRate:100,honorDnt:!0,batchSize:50,maxDataPoints:1000,sessionTimeout:30,persistData:!1,storagePrefix:"stx_heatmap",captureAttributes:["data-heatmap-id","data-track"],ignoreSelectors:["[data-heatmap-ignore]",".heatmap-ignore"],debugOverlay:!1};function tp(v){let k=v.heatmap;if(!k?.enabled)return"";let C={...fx,...k};return`
720
- <!-- stx Heatmap - Privacy-Compliant Tracking -->
721
- <script>
722
- (function() {
723
- 'use strict';
724
-
725
- // Configuration
726
- var config = ${JSON.stringify({trackMouse:C.trackMouse,trackClicks:C.trackClicks,trackScroll:C.trackScroll,samplingRate:C.samplingRate,honorDnt:C.honorDnt,endpoint:C.endpoint,batchSize:C.batchSize,maxDataPoints:C.maxDataPoints,sessionTimeout:C.sessionTimeout,persistData:C.persistData,storagePrefix:C.storagePrefix,captureAttributes:C.captureAttributes,ignoreSelectors:C.ignoreSelectors,zones:C.zones,debugOverlay:C.debugOverlay,minViewportWidth:C.minViewportWidth,maxViewportWidth:C.maxViewportWidth})};
727
-
728
- // Check Do Not Track
729
- if (config.honorDnt && navigator.doNotTrack === '1') {
730
- return;
731
- }
732
-
733
- // Check viewport constraints
734
- var vw = window.innerWidth;
735
- if (config.minViewportWidth && vw < config.minViewportWidth) return;
736
- if (config.maxViewportWidth && vw > config.maxViewportWidth) return;
737
-
738
- // Session management (anonymous, no cookies)
739
- var session = {
740
- sid: Math.random().toString(36).slice(2) + Date.now().toString(36),
741
- page: location.pathname,
742
- vw: window.innerWidth,
743
- vh: window.innerHeight,
744
- points: [],
745
- started: Date.now(),
746
- lastActivity: Date.now()
747
- };
748
-
749
- // Throttle helper
750
- var lastMove = 0;
751
- function throttle(fn, wait) {
752
- return function() {
753
- var now = Date.now();
754
- if (now - lastMove >= wait) {
755
- lastMove = now;
756
- fn.apply(this, arguments);
757
- }
758
- };
759
- }
760
-
761
- // Get relative coordinates (percentage)
762
- function getRelativeCoords(e) {
763
- return {
764
- x: Math.round((e.clientX / window.innerWidth) * 10000) / 100,
765
- y: Math.round((e.clientY / window.innerHeight) * 10000) / 100
766
- };
767
- }
768
-
769
- // Check if element should be ignored
770
- function shouldIgnore(el) {
771
- if (!el || !config.ignoreSelectors) return false;
772
- for (var i = 0; i < config.ignoreSelectors.length; i++) {
773
- if (el.matches && el.matches(config.ignoreSelectors[i])) return true;
774
- if (el.closest && el.closest(config.ignoreSelectors[i])) return true;
775
- }
776
- return false;
777
- }
778
-
779
- // Get element selector (simplified, no IDs to preserve privacy)
780
- function getSelector(el) {
781
- if (!el || !el.tagName) return null;
782
- var tag = el.tagName.toLowerCase();
783
- var classes = el.className && typeof el.className === 'string'
784
- ? '.' + el.className.trim().split(/\\s+/).slice(0, 2).join('.')
785
- : '';
786
- return tag + classes;
787
- }
788
-
789
- // Find zone for element
790
- function findZone(el) {
791
- if (!config.zones || !el) return null;
792
- for (var i = 0; i < config.zones.length; i++) {
793
- var zone = config.zones[i];
794
- if (el.closest && el.closest(zone.selector)) {
795
- return zone.id;
796
- }
797
- }
798
- return null;
799
- }
800
-
801
- // Capture custom attributes
802
- function captureAttributes(el) {
803
- if (!config.captureAttributes || !el) return null;
804
- var attrs = {};
805
- var hasAttrs = false;
806
- for (var i = 0; i < config.captureAttributes.length; i++) {
807
- var attr = config.captureAttributes[i];
808
- var value = el.getAttribute && el.getAttribute(attr);
809
- if (value) {
810
- attrs[attr] = value;
811
- hasAttrs = true;
812
- }
813
- }
814
- return hasAttrs ? attrs : null;
815
- }
816
-
817
- // Add data point
818
- function addPoint(point) {
819
- session.lastActivity = Date.now();
820
- if (session.points.length >= config.maxDataPoints) {
821
- session.points.shift();
822
- }
823
- session.points.push(point);
824
-
825
- // Send batch if threshold reached
826
- if (config.endpoint && session.points.length >= config.batchSize) {
827
- sendData();
828
- }
829
- }
830
-
831
- // Send data to endpoint
832
- function sendData() {
833
- if (!config.endpoint || session.points.length === 0) return;
834
-
835
- var data = {
836
- sid: session.sid,
837
- page: session.page,
838
- vw: session.vw,
839
- vh: session.vh,
840
- points: session.points.splice(0, config.batchSize)
841
- };
842
-
843
- // Use sendBeacon for reliability
844
- if (navigator.sendBeacon) {
845
- navigator.sendBeacon(config.endpoint, JSON.stringify(data));
846
- }
847
- else {
848
- var xhr = new XMLHttpRequest();
849
- xhr.open('POST', config.endpoint, true);
850
- xhr.setRequestHeader('Content-Type', 'application/json');
851
- xhr.send(JSON.stringify(data));
852
- }
853
- }
854
-
855
- // Mouse move handler
856
- if (config.trackMouse) {
857
- document.addEventListener('mousemove', throttle(function(e) {
858
- if (shouldIgnore(e.target)) return;
859
- var coords = getRelativeCoords(e);
860
- addPoint({
861
- x: coords.x,
862
- y: coords.y,
863
- type: 'move',
864
- t: Date.now(),
865
- zone: findZone(e.target)
866
- });
867
- }, config.samplingRate), { passive: true });
868
- }
869
-
870
- // Click handler
871
- if (config.trackClicks) {
872
- document.addEventListener('click', function(e) {
873
- if (shouldIgnore(e.target)) return;
874
- var coords = getRelativeCoords(e);
875
- var point = {
876
- x: coords.x,
877
- y: coords.y,
878
- type: 'click',
879
- t: Date.now(),
880
- el: getSelector(e.target),
881
- zone: findZone(e.target)
882
- };
883
- var attrs = captureAttributes(e.target);
884
- if (attrs) point.attrs = attrs;
885
- addPoint(point);
886
- }, { passive: true });
887
- }
888
-
889
- // Scroll handler
890
- if (config.trackScroll) {
891
- var lastScrollDepth = 0;
892
- document.addEventListener('scroll', throttle(function() {
893
- var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
894
- var scrollHeight = document.documentElement.scrollHeight - window.innerHeight;
895
- var depth = scrollHeight > 0 ? Math.round((scrollTop / scrollHeight) * 100) : 0;
896
-
897
- // Only track significant scroll changes (every 10%)
898
- if (Math.abs(depth - lastScrollDepth) >= 10) {
899
- lastScrollDepth = depth;
900
- addPoint({
901
- x: 50,
902
- y: depth,
903
- type: 'scroll',
904
- t: Date.now(),
905
- depth: depth
906
- });
907
- }
908
- }, config.samplingRate * 2), { passive: true });
909
- }
910
-
911
- // Send remaining data on page unload
912
- window.addEventListener('beforeunload', sendData);
913
- window.addEventListener('visibilitychange', function() {
914
- if (document.visibilityState === 'hidden') {
915
- sendData();
916
- }
917
- });
918
-
919
- // Persist data to localStorage if enabled
920
- if (config.persistData) {
921
- var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
922
-
923
- // Load existing data
924
- try {
925
- var stored = localStorage.getItem(storageKey);
926
- if (stored) {
927
- var parsed = JSON.parse(stored);
928
- if (Date.now() - parsed.lastActivity < config.sessionTimeout * 60000) {
929
- session.points = parsed.points || [];
930
- }
931
- }
932
- }
933
- catch (e) {}
934
-
935
- // Save periodically
936
- setInterval(function() {
937
- try {
938
- localStorage.setItem(storageKey, JSON.stringify({
939
- points: session.points,
940
- lastActivity: session.lastActivity
941
- }));
942
- }
943
- catch (e) {}
944
- }, 5000);
945
- }
946
-
947
- // Debug overlay
948
- if (config.debugOverlay) {
949
- var overlay = document.createElement('div');
950
- overlay.id = 'stx-heatmap-overlay';
951
- overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:999999;';
952
- document.body.appendChild(overlay);
953
-
954
- var canvas = document.createElement('canvas');
955
- canvas.width = window.innerWidth;
956
- canvas.height = window.innerHeight;
957
- canvas.style.cssText = 'width:100%;height:100%;';
958
- overlay.appendChild(canvas);
959
- var ctx = canvas.getContext('2d');
960
-
961
- function renderOverlay() {
962
- ctx.clearRect(0, 0, canvas.width, canvas.height);
963
- session.points.forEach(function(p) {
964
- var x = (p.x / 100) * canvas.width;
965
- var y = (p.y / 100) * canvas.height;
966
- ctx.beginPath();
967
- ctx.arc(x, y, p.type === 'click' ? 8 : 3, 0, Math.PI * 2);
968
- ctx.fillStyle = p.type === 'click' ? 'rgba(255,0,0,0.5)' : 'rgba(0,0,255,0.2)';
969
- ctx.fill();
970
- });
971
- requestAnimationFrame(renderOverlay);
972
- }
973
- renderOverlay();
974
-
975
- window.addEventListener('resize', function() {
976
- canvas.width = window.innerWidth;
977
- canvas.height = window.innerHeight;
978
- });
979
- }
980
-
981
- // Expose API for manual tracking and data export
982
- window.stxHeatmap = {
983
- // Get current session data
984
- getData: function() {
985
- return {
986
- sid: session.sid,
987
- page: session.page,
988
- vw: session.vw,
989
- vh: session.vh,
990
- points: session.points.slice(),
991
- started: session.started,
992
- lastActivity: session.lastActivity
993
- };
994
- },
995
- // Export data as JSON
996
- exportJSON: function() {
997
- return JSON.stringify(this.getData(), null, 2);
998
- },
999
- // Export data as CSV
1000
- exportCSV: function() {
1001
- var data = this.getData();
1002
- var lines = ['x,y,type,timestamp,element,zone,depth'];
1003
- data.points.forEach(function(p) {
1004
- lines.push([p.x, p.y, p.type, p.t, p.el || '', p.zone || '', p.depth || ''].join(','));
1005
- });
1006
- return lines.join('\\n');
1007
- },
1008
- // Manual data send
1009
- flush: function() {
1010
- sendData();
1011
- },
1012
- // Clear data
1013
- clear: function() {
1014
- session.points = [];
1015
- if (config.persistData) {
1016
- var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
1017
- try { localStorage.removeItem(storageKey); }
1018
- catch (e) {}
1019
- }
1020
- },
1021
- // Add custom event
1022
- track: function(type, data) {
1023
- addPoint({
1024
- x: data && data.x || 0,
1025
- y: data && data.y || 0,
1026
- type: type,
1027
- t: Date.now(),
1028
- attrs: data
1029
- });
1030
- },
1031
- // Generate heatmap visualization
1032
- visualize: function(options) {
1033
- options = options || {};
1034
- var data = this.getData();
1035
- var width = options.width || data.vw;
1036
- var height = options.height || data.vh;
1037
- var radius = options.radius || 20;
1038
- var blur = options.blur || 15;
1039
- var maxOpacity = options.maxOpacity || 0.6;
1040
-
1041
- var canvas = document.createElement('canvas');
1042
- canvas.width = width;
1043
- canvas.height = height;
1044
- var ctx = canvas.getContext('2d');
1045
-
1046
- // Create heat points
1047
- data.points.forEach(function(p) {
1048
- var x = (p.x / 100) * width;
1049
- var y = (p.y / 100) * height;
1050
- var intensity = p.type === 'click' ? 1 : 0.3;
1051
-
1052
- var gradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
1053
- gradient.addColorStop(0, 'rgba(255,0,0,' + intensity + ')');
1054
- gradient.addColorStop(1, 'rgba(255,0,0,0)');
1055
- ctx.fillStyle = gradient;
1056
- ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
1057
- });
1058
-
1059
- // Apply blur
1060
- ctx.filter = 'blur(' + blur + 'px)';
1061
- ctx.drawImage(canvas, 0, 0);
1062
- ctx.filter = 'none';
1063
-
1064
- // Colorize
1065
- var imageData = ctx.getImageData(0, 0, width, height);
1066
- var pixels = imageData.data;
1067
- for (var i = 0; i < pixels.length; i += 4) {
1068
- var alpha = pixels[i + 3];
1069
- if (alpha > 0) {
1070
- var ratio = alpha / 255;
1071
- // Gradient: blue -> cyan -> green -> yellow -> red
1072
- if (ratio < 0.25) {
1073
- pixels[i] = 0;
1074
- pixels[i + 1] = Math.round(ratio * 4 * 255);
1075
- pixels[i + 2] = 255;
1076
- }
1077
- else if (ratio < 0.5) {
1078
- pixels[i] = 0;
1079
- pixels[i + 1] = 255;
1080
- pixels[i + 2] = Math.round((1 - (ratio - 0.25) * 4) * 255);
1081
- }
1082
- else if (ratio < 0.75) {
1083
- pixels[i] = Math.round((ratio - 0.5) * 4 * 255);
1084
- pixels[i + 1] = 255;
1085
- pixels[i + 2] = 0;
1086
- }
1087
- else {
1088
- pixels[i] = 255;
1089
- pixels[i + 1] = Math.round((1 - (ratio - 0.75) * 4) * 255);
1090
- pixels[i + 2] = 0;
1091
- }
1092
- pixels[i + 3] = Math.round(alpha * maxOpacity);
1093
- }
1094
- }
1095
- ctx.putImageData(imageData, 0, 0);
1096
-
1097
- return canvas;
1098
- }
1099
- };
1100
- })();
1101
- </script>
1102
- `}function np(v,k){let C=tp(k);if(!C)return v;let R=v.lastIndexOf("</body>");if(R!==-1)return v.slice(0,R)+C+v.slice(R);return v+C}var rp={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async(v,k,C,R)=>{let T=C.__stx_config||{};if(k.length>0){let z=px(k.join(" "));T.heatmap={...T.heatmap,...z,enabled:!0}}return tp(T)}};function px(v){let k={},C=v.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let R of C){let[T,z]=R.split("="),F=z?.replace(/["']/g,"");switch(T){case"endpoint":k.endpoint=F;break;case"samplingRate":k.samplingRate=Number.parseInt(F,10);break;case"batchSize":k.batchSize=Number.parseInt(F,10);break;case"trackMouse":k.trackMouse=F==="true";break;case"trackClicks":k.trackClicks=F==="true";break;case"trackScroll":k.trackScroll=F==="true";break;case"honorDnt":k.honorDnt=F==="true";break;case"debugOverlay":k.debugOverlay=F==="true";break}}return k}var nr={duration:300,delay:0,ease:"ease",direction:"both"};function gx(v,k={}){let{duration:C,delay:R,ease:T,direction:z,custom:F}={...nr,...k};if(v==="custom"&&F)return F;switch(v){case"fade":return`${z==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
1103
- @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
1104
- @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${z==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
1105
- @keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
1106
- @keyframes slideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(20px); opacity: 0; } }`;case"scale":return`${z==="in"?"transform: scale(0.95); opacity: 0; animation: scaleIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: scale(1); opacity: 1; animation: scaleOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: scale(1); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
1107
- @keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
1108
- @keyframes scaleOut { from { transform: scale(1); opacity: 1; } to { transform: scale(0.95); opacity: 0; } }`;case"flip":return`${z==="in"?"transform: perspective(400px) rotateX(-90deg); opacity: 0; animation: flipIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: perspective(400px) rotateX(0); opacity: 1; animation: flipOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: perspective(400px) rotateX(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
1109
- @keyframes flipIn { from { transform: perspective(400px) rotateX(-90deg); opacity: 0; } to { transform: perspective(400px) rotateX(0); opacity: 1; } }
1110
- @keyframes flipOut { from { transform: perspective(400px) rotateX(0); opacity: 1; } to { transform: perspective(400px) rotateX(90deg); opacity: 0; } }`;case"rotate":return`${z==="in"?"transform: rotate(-90deg); opacity: 0; animation: rotateIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: rotate(0); opacity: 1; animation: rotateOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: rotate(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
1111
- @keyframes rotateIn { from { transform: rotate(-90deg); opacity: 0; } to { transform: rotate(0); opacity: 1; } }
1112
- @keyframes rotateOut { from { transform: rotate(0); opacity: 1; } to { transform: rotate(90deg); opacity: 0; } }`;default:return""}}function mx(){return`
1113
- <script data-stx-scoped data-stx-run="once">
1114
- // Motion preferences handling
1115
- (function() {
1116
- const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
1117
-
1118
- if (prefersReducedMotion) {
1119
- // Apply reduced motion settings
1120
- document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
1121
- document.documentElement.setAttribute('data-reduced-motion', 'true');
1122
- }
1123
- else {
1124
- document.documentElement.setAttribute('data-reduced-motion', 'false');
1125
- }
1126
-
1127
- // Listen for changes in preference
1128
- window.matchMedia('(prefers-reduced-motion: reduce)').addEventListener('change', (e) => {
1129
- if (e.matches) {
1130
- document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
1131
- document.documentElement.setAttribute('data-reduced-motion', 'true');
1132
- }
1133
- else {
1134
- document.documentElement.style.setProperty('--stx-transition-duration', '');
1135
- document.documentElement.setAttribute('data-reduced-motion', 'false');
1136
- }
1137
- });
1138
- })();
1139
- </script>
1140
- `}function hx(v){return[/@animate\b/,/@transition\b/,/@scroll(?:Animate)?\b/,/@staggered\b/,/@sequence\b/,/@motion\b/,/@animationGroup\b/,/\bstx-transition\b/,/\bstx-(?:fade|scale|flip|rotate|slide|from-|observe)\b/,/data-animate=['"](?:auto|true|false)['"]/].some((C)=>C.test(v))}function yx(v=0.1,k="0px"){return`
1141
- <script data-stx-scoped data-stx-run="always">
1142
- // Intersection Observer for scroll animations
1143
- (function() {
1144
- const initObserver = () => {
1145
- if (!('IntersectionObserver' in window)) {
1146
- // For browsers that don't support IntersectionObserver, show all elements immediately
1147
- const elements = document.querySelectorAll('.stx-observe');
1148
- elements.forEach(el => el.classList.remove('stx-out'));
1149
- return;
1150
- }
1151
-
1152
- // Create the observer
1153
- const options = {
1154
- root: null, // Use viewport
1155
- rootMargin: '${k}',
1156
- threshold: ${v}
1157
- };
1158
-
1159
- const observer = new IntersectionObserver((entries) => {
1160
- entries.forEach(entry => {
1161
- if (entry.isIntersecting) {
1162
- entry.target.classList.remove('stx-out');
1163
- // Stop observing after animation is triggered
1164
- observer.unobserve(entry.target);
1165
- }
1166
- });
1167
- }, options);
1168
-
1169
- // Start observing elements
1170
- const elements = document.querySelectorAll('.stx-observe');
1171
- elements.forEach(el => observer.observe(el));
1172
- };
1173
-
1174
- // Initialize observer when DOM is ready
1175
- if (document.readyState === 'loading') {
1176
- document.addEventListener('DOMContentLoaded', initObserver);
1177
- }
1178
- else {
1179
- initObserver();
1180
- }
1181
- })();
1182
- </script>
1183
- `}function xx(){return`
1184
- <style id="stx-animation-base">
1185
- :root {
1186
- --stx-transition-duration: 300ms;
1187
- --stx-transition-delay: 0ms;
1188
- --stx-transition-ease: ease;
1189
- }
1190
-
1191
- @media (prefers-reduced-motion: reduce) {
1192
- :root {
1193
- --stx-transition-duration: 0ms;
1194
- }
1195
- }
1196
-
1197
- [data-animate="false"] * {
1198
- --stx-transition-duration: 0ms !important;
1199
- animation-duration: 0ms !important;
1200
- transition-duration: 0ms !important;
1201
- }
1202
-
1203
- /* Base transition classes */
1204
- .stx-transition {
1205
- transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1206
- transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1207
- backface-visibility: hidden; /* Improve animation performance */
1208
- transform-style: preserve-3d; /* Better 3D transforms */
1209
- }
1210
-
1211
- /* Fade animations */
1212
- .stx-fade {
1213
- transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1214
- }
1215
-
1216
- .stx-fade.stx-out {
1217
- opacity: 0 !important;
1218
- }
1219
-
1220
- /* Scale animations */
1221
- .stx-scale {
1222
- transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1223
- opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1224
- }
1225
-
1226
- .stx-scale.stx-out {
1227
- transform: scale(0.85) !important;
1228
- opacity: 0 !important;
1229
- }
1230
-
1231
- /* Flip animations */
1232
- .stx-flip {
1233
- transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1234
- opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1235
- perspective: 600px;
1236
- }
1237
-
1238
- .stx-flip.stx-out {
1239
- transform: perspective(600px) rotateX(-90deg) !important;
1240
- opacity: 0 !important;
1241
- }
1242
-
1243
- /* Rotate animations */
1244
- .stx-rotate {
1245
- transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1246
- opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1247
- }
1248
-
1249
- .stx-rotate.stx-out {
1250
- transform: rotate(-90deg) !important;
1251
- opacity: 0 !important;
1252
- }
1253
-
1254
- /* Direction-based animations */
1255
- .stx-from-left, .stx-from-right, .stx-from-top, .stx-from-bottom {
1256
- transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1257
- opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1258
- }
1259
-
1260
- .stx-from-left.stx-out {
1261
- transform: translateX(-30px) !important;
1262
- opacity: 0 !important;
1263
- }
1264
-
1265
- .stx-from-right.stx-out {
1266
- transform: translateX(30px) !important;
1267
- opacity: 0 !important;
1268
- }
1269
-
1270
- .stx-from-top.stx-out {
1271
- transform: translateY(-30px) !important;
1272
- opacity: 0 !important;
1273
- }
1274
-
1275
- .stx-from-bottom.stx-out {
1276
- transform: translateY(30px) !important;
1277
- opacity: 0 !important;
1278
- }
1279
-
1280
- /* Generic slide animations */
1281
- .stx-slide {
1282
- transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1283
- opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1284
- }
1285
-
1286
- .stx-slide.stx-out {
1287
- transform: translateY(30px) !important;
1288
- opacity: 0 !important;
1289
- }
1290
-
1291
- /* Scroll animation observer class */
1292
- .stx-observe {
1293
- will-change: opacity, transform;
1294
- transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
1295
- transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
1296
- }
1297
- </style>
1298
- `}function bx(v,k,C={}){let{staggerDelay:R=50,sequence:T=!1}=C;return`
1299
- <script data-stx-scoped data-stx-run="always">
1300
- // Animation Group: ${v}
1301
- (function() {
1302
- const elements = ${JSON.stringify(k)};
1303
- const staggerDelay = ${R};
1304
- const sequence = ${T};
1305
-
1306
- function animateGroup() {
1307
- elements.forEach((selector, index) => {
1308
- const element = document.querySelector(selector);
1309
- if (!element) return;
1310
-
1311
- const delay = sequence ? index * staggerDelay : 0;
1312
- element.style.setProperty('--stx-transition-delay', delay + 'ms');
1313
-
1314
- // For elements using animation keyframes
1315
- element.style.animationDelay = delay + 'ms';
1316
-
1317
- // If the element is initially hidden, show it
1318
- if (element.classList.contains('stx-out')) {
1319
- setTimeout(() => {
1320
- element.classList.remove('stx-out');
1321
- }, 10); // Small delay to ensure styles are applied
1322
- }
1323
- });
1324
- }
1325
-
1326
- // Run when DOM is fully loaded
1327
- if (document.readyState === 'loading') {
1328
- document.addEventListener('DOMContentLoaded', animateGroup);
1329
- }
1330
- else {
1331
- animateGroup();
1332
- }
1333
- })();
1334
- </script>
1335
- `}var sp={name:"transition",handler:(v,k,C,R)=>{if(k.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${v}`;let T=k[0],z=k.length>1?Number.parseInt(k[1],10)||nr.duration:nr.duration,F=k.length>2?k[2]||nr.ease:nr.ease,V=k.length>3?Number.parseInt(k[3],10)||nr.delay:nr.delay,H=k.length>4?k[4]||nr.direction:nr.direction,K=`stx-transition-${Math.random().toString(36).substr(2,9)}`,X=gx(T,{duration:z,delay:V,ease:F,direction:H}),G="stx-transition",te="";if(T==="fade")te="stx-fade";else if(T==="slide")te="stx-slide";else if(T==="scale")te="stx-scale";else if(T==="flip")te="stx-flip";else if(T==="rotate")te="stx-rotate";return`<div id="${K}" class="${G} ${te} ${H==="out"?"stx-out":""}"
1336
- style="--stx-transition-duration: ${z}ms; --stx-transition-ease: ${F}; --stx-transition-delay: ${V}ms;">${v}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},ip={name:"scrollAnimate",handler:(v,k,C,R)=>{if(k.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${v}`;let T=k[0],z=k.length>1?Number.parseInt(k[1],10)||300:300,F=k.length>2?k[2]||"ease":"ease",V=k.length>3?Number.parseFloat(k[3])||0.2:0.2,H=k.length>4?Number.parseInt(k[4],10)||0:0,K=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,X=`--stx-transition-duration: ${z}ms; --stx-transition-ease: ${F}; --stx-transition-delay: ${H}ms; will-change: opacity, transform;`,G="stx-transition stx-observe stx-out";if(T==="fade")G+=" stx-fade";else if(T==="slide-up"||T==="slide")G+=" stx-from-bottom";else if(T==="slide-down")G+=" stx-from-top";else if(T==="slide-left")G+=" stx-from-right";else if(T==="slide-right")G+=" stx-from-left";else if(T==="scale")G+=" stx-scale";else if(T.includes("-"))G+=` stx-${T}`;else G+=` stx-${T}`;return`<div id="${K}" class="${G}" style="${X}" data-threshold="${V}">${v}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},op={name:"animationGroup",handler:(v,k,C,R)=>{if(k.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${v}`;let T=k[0],z=k.slice(1).map((K)=>K.startsWith("#")||K.startsWith(".")?K:`#${K}`),F=C.staggerDelay||50,V=C.sequence||!0,H=bx(T,z,{staggerDelay:F,sequence:V});return`${v}
1337
- ${H}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},ap={name:"motion",handler:(v,k,C,R)=>{let T=k.length>0?k[0].toLowerCase()==="true":!0,z=mx();return`<div data-animate="${T?"auto":"true"}">${v}</div>${z}`},hasEndTag:!0,description:"Controls motion and animation preferences"};function cp(v,k,C,R){let T=v;if(R.animation?.enabled===!1)return T;let z=C.includes("test")&&C.includes("animation");if(!hx(T)&&!z)return T;if(!T.includes('<style id="stx-animation-base">')){let V=xx();T=T.replace("</head>",`${V}
1338
- </head>`)}if(T.includes("stx-observe")){if(!T.includes("Intersection Observer for scroll animations")){let H=yx(),K=T.lastIndexOf("</body>");if(K!==-1)T=T.slice(0,K)+H+`
1339
- `+T.slice(K)}}return T}function Je(v){let k=v.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!k)return null;try{return Function(`return ${k[1]}`)()}catch{return null}}function lp(v){let k=v?.layout;if(k===!1)return!1;return typeof k==="string"&&k.trim()?k.trim():void 0}var vx=100,wx=599,Sl="__stxResponseStatus",po="__stxResponseHeaders";function _a(v){return typeof v==="number"&&Number.isInteger(v)&&v>=vx&&v<=wx}function Bt(v){for(let k of v.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let C=k[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!C)continue;let R=Number(C[1]);if(_a(R))return R}return}function wl(v,k){if(!v||typeof v!=="object")return!1;let C=typeof k==="string"&&/^\d+$/.test(k.trim())?Number(k.trim()):k;if(!_a(C))return!1;return v[Sl]=C,!0}function Sx(v,k,C){if(!v||typeof v!=="object")return;let R=String(k??"").trim();if(!R)return;v[po]={...v[po],[R]:String(C)}}function Ye(v){let k=v?.[Sl];return _a(k)?k:void 0}function Ze(v){let k=v?.[po];if(!k||typeof k!=="object")return;let C=Object.entries(k).map(([R,T])=>[R,String(T)]);return C.length>0?Object.fromEntries(C):void 0}function vi(v,k){if(!v||!k||v===k||typeof k!=="object")return;let C=Ye(v);if(C!==void 0)k[Sl]=C;let R=Ze(v);if(R)k[po]={...k[po],...R}}function lr(v){return{setResponseStatus:(k)=>{wl(v,k)},notFound:(k=404)=>{let C=_a(k)&&k>=400?k:404;wl(v,C)},setResponseHeader:(k,C)=>{Sx(v,k,C)}}}function up(v,k,C={}){if(!v.includes("@status"))return v;let{filePath:R,buildMode:T}=C,z=T==="compile",F="",V=0,H=/@status\s*\(/g,K;while((K=H.exec(v))!==null){let X=$x(v,K.index+K[0].length-1);if(X<0)break;let G=v.slice(K.index+K[0].length,X).trim(),te=/^\d+$/.test(G)?Number(G):l(G,k),ce=R?` in ${R}`:"";if(z)console.warn(`[stx] @status(${G})${ce} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${G}) from <script server> instead \u2014 that runs per request.`);else if(!wl(k,te))console.warn(`[stx] @status(${G})${ce} is not an HTTP status (100-599) \u2014 ignoring it.`);F+=v.slice(V,K.index),V=X+1+(v.slice(X+1).match(/^[^\S\n]*\n?/)?.[0].length??0),H.lastIndex=V}return V===0?v:F+v.slice(V)}function $x(v,k){let C=1,R=null,T=!1;for(let z=k+1;z<v.length;z++){let F=v[z];if(T){T=!1;continue}if(R){if(F==="\\")T=!0;else if(F===R)R=null;continue}if(F==='"'||F==="'"||F==="`"){R=F;continue}if(F==="(")C++;else if(F===")"&&--C===0)return z}return-1}var _x=0,kx=0;function dp(v,k){let C=v.match(new RegExp(`${k}\\s*=\\s*"([^"]*)"`,"i"));if(C)return C[1];let R=v.match(new RegExp(`${k}\\s*=\\s*'([^']*)'`,"i"));if(R)return R[1];return null}function Ex(v){let k=[],C=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,R;while((R=C.exec(v))!==null){let[T,z,F]=R,V=R.index,H=dp(F,"x-data");if(!H)continue;let K=`__stx_scope_${_x++}`,X=dp(F,"x-init"),G=Cx(v,z,V+T.length),te=v.slice(V,G.endIndex),ce=Rx(te);k.push({id:K,selector:`[data-stx-scope="${K}"]`,stateExpr:H,initExpr:X,bindings:[],refs:ce})}return k}function Cx(v,k,C){let R=1,T=C,z=new RegExp(`<${k}(?:\\s|>)`,"gi"),F=new RegExp(`</${k}>`,"gi"),V=new RegExp(`<${k}[^>]*/\\s*>`,"gi");while(R>0&&T<v.length){z.lastIndex=T,F.lastIndex=T,V.lastIndex=T;let H=z.exec(v),K=F.exec(v),X=V.exec(v);if(X&&X.index<(H?.index??1/0)){T=X.index+X[0].length;continue}if(!K)return{endIndex:v.length};if(H&&H.index<K.index)R++,T=H.index+H[0].length;else{if(R--,R===0)return{endIndex:K.index+K[0].length};T=K.index+K[0].length}}return{endIndex:v.length}}function Rx(v){let k=new Map,C=v.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),R=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,T;while((T=R.exec(C))!==null){let[,z,F]=T,V=Ax(z);k.set(F,V)}return k}function Ax(v){let k=v.match(/\bid\s*=\s*["']([^"']*)["']/);if(k)return k[1];return`__stx_el_${kx++}`}function Tx(){return`
1340
- // STX Reactive Runtime - x-cloak and transition CSS
1341
- (function() {
1342
- var style = document.createElement('style');
1343
- style.textContent = [
1344
- '[x-cloak] { display: none !important; }',
1345
- // Default transition classes
1346
- '.stx-enter { opacity: 0; transform: scale(0.95); }',
1347
- '.stx-enter-start { opacity: 0; transform: scale(0.95); }',
1348
- '.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
1349
- '.stx-enter-to { opacity: 1; transform: scale(1); }',
1350
- '.stx-leave { opacity: 1; transform: scale(1); }',
1351
- '.stx-leave-start { opacity: 1; transform: scale(1); }',
1352
- '.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
1353
- '.stx-leave-to { opacity: 0; transform: scale(0.95); }'
1354
- ].join('\\n');
1355
- document.head.appendChild(style);
1356
- })();
1357
-
1358
- // STX Reactive Runtime
1359
- /* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
1360
- window.__stx_reactive = (function() {
1361
- 'use strict';
1362
-
1363
- // Deep reactive proxy that triggers onChange for any mutation
1364
- function reactive(obj, onChange) {
1365
- if (!obj || typeof obj !== 'object') return obj;
1366
- return new Proxy(obj, {
1367
- get(target, prop) {
1368
- const value = target[prop];
1369
- if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
1370
- return reactive(value, onChange);
1371
- }
1372
- return value;
1373
- },
1374
- set(target, prop, value) {
1375
- target[prop] = value;
1376
- onChange(prop, value);
1377
- return true;
1378
- }
1379
- });
1380
- }
1381
-
1382
- // Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
1383
- // then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
1384
- function initScope(scopeEl, initialState, bindings, refs, initExpr) {
1385
- // Parse initial state (may contain methods including async init())
1386
- var state;
1387
- try {
1388
- state = new Function('return (' + initialState + ')')();
1389
- } catch (e) {
1390
- console.error('[stx-reactive] Invalid x-data:', initialState, e);
1391
- return;
1392
- }
1393
-
1394
- // Build $refs object
1395
- var $refs = {};
1396
- for (var name in refs) {
1397
- if (Object.prototype.hasOwnProperty.call(refs, name)) {
1398
- (function(refName, refId) {
1399
- Object.defineProperty($refs, refName, {
1400
- get: function() { return document.getElementById(refId); }
1401
- });
1402
- })(name, refs[name]);
1403
- }
1404
- }
1405
-
1406
- // Extract init method from state if present (Alpine.js convention)
1407
- var initMethod = state.init;
1408
- if (typeof initMethod === 'function') {
1409
- delete state.init;
1410
- }
1411
-
1412
- // Make state reactive \u2014 mutations trigger re-render via signals
1413
- var scopeId = scopeEl.getAttribute('data-stx-scope');
1414
- var stx = window.stx;
1415
-
1416
- // Create signals for each state property so the signals runtime can track dependencies
1417
- var signalState = {};
1418
- var rawState = {};
1419
- var derivedState = {};
1420
- var accessors = {};
1421
- // A getter must NOT be read here. Reading one calls it, and the old loop did
1422
- // exactly that: the returned value is not a function, so it was wrapped as a
1423
- // plain state() -- a snapshot of the answer at construction time, frozen
1424
- // forever while plain properties beside it updated (#2053). A getter is a
1425
- // derived value, so it is registered as one below, once ctxProxy exists for
1426
- // it to read through.
1427
- var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
1428
- for (var key in state) {
1429
- if (Object.prototype.hasOwnProperty.call(state, key)) {
1430
- var descriptor = ownDescriptors[key];
1431
- if (descriptor && typeof descriptor.get === 'function') {
1432
- accessors[key] = descriptor;
1433
- continue;
1434
- }
1435
- if (typeof state[key] === 'function') {
1436
- // Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
1437
- signalState[key] = state[key];
1438
- } else {
1439
- // Data properties \u2014 wrap in signals for reactivity
1440
- signalState[key] = stx.state(state[key]);
1441
- rawState[key] = true;
1442
- }
1443
- }
1444
- }
1445
-
1446
- // Create a proxy context that auto-unwraps signals and writes back through them.
1447
- // Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
1448
- var ctx = {};
1449
- var ctxProxy = new Proxy(ctx, {
1450
- get: function(target, prop) {
1451
- if (prop === '$refs') return $refs;
1452
- if (prop === '$el') return scopeEl;
1453
- if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
1454
- var s = signalState[prop];
1455
- if (!s) return undefined;
1456
- if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
1457
- return s.value; // unwrap signal
1458
- }
1459
- if (typeof s === 'function' && !rawState[prop]) {
1460
- return s.bind(ctxProxy); // bind methods to proxy
1461
- }
1462
- return s;
1463
- },
1464
- set: function(target, prop, value) {
1465
- var accessor = derivedState[prop];
1466
- if (accessor) {
1467
- // A getter/setter pair writes through its setter. A getter alone has
1468
- // nowhere to put the value: a derived has no .value setter, so the
1469
- // assignment would be a silent no-op, which is the same class of
1470
- // failure as the stale read this replaces.
1471
- if (typeof accessor.set === 'function') {
1472
- accessor.set.call(ctxProxy, value);
1473
- return true;
1474
- }
1475
- console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
1476
- return true;
1477
- }
1478
- var s = signalState[prop];
1479
- if (rawState[prop] && s && typeof s === 'function') {
1480
- s.value = value; // write through signal \u2014 triggers effects
1481
- } else {
1482
- signalState[prop] = value;
1483
- }
1484
- return true;
1485
- },
1486
- has: function(target, prop) {
1487
- return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick';
1488
- },
1489
- ownKeys: function() {
1490
- return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
1491
- },
1492
- getOwnPropertyDescriptor: function(target, prop) {
1493
- if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
1494
- return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
1495
- }
1496
- return undefined;
1497
- }
1498
- });
1499
-
1500
- // Now that ctxProxy exists, a getter becomes a derived that reads through it,
1501
- // so it tracks whatever it touches and recomputes when that changes. derived()
1502
- // is lazy, so nothing is evaluated until a binding actually reads it.
1503
- //
1504
- // Marked rawState as well: that is what makes the proxy unwrap it and what
1505
- // exposes the signal itself to the runtime below, which is where dependency
1506
- // tracking comes from. A getter needs both, exactly like a data property.
1507
- for (var accessorKey in accessors) {
1508
- if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
1509
- (function(name, descriptor) {
1510
- signalState[name] = stx.derived(function() {
1511
- return descriptor.get.call(ctxProxy);
1512
- });
1513
- rawState[name] = true;
1514
- derivedState[name] = descriptor;
1515
- })(accessorKey, accessors[accessorKey]);
1516
- }
1517
- }
1518
-
1519
- // Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
1520
- // We need to provide getter/setter descriptors so signals track properly.
1521
- var scopeVars = {};
1522
- for (var k in signalState) {
1523
- if (Object.prototype.hasOwnProperty.call(signalState, k)) {
1524
- if (rawState[k]) {
1525
- // Data: expose the signal directly so expressions trigger dependency tracking
1526
- scopeVars[k] = signalState[k];
1527
- } else {
1528
- // Method: bind to ctxProxy so 'this' works
1529
- scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
1530
- }
1531
- }
1532
- }
1533
- scopeVars.$refs = $refs;
1534
- scopeVars.$el = scopeEl;
1535
- scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
1536
-
1537
- // Register scope \u2014 merge with any existing vars from partial signal scripts
1538
- if (!stx._scopes) stx._scopes = {};
1539
- stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
1540
-
1541
- // Store on element for findElementScope
1542
- scopeEl.__stx_scope = scopeVars;
1543
-
1544
- // Run init() if present (supports async)
1545
- function runInit() {
1546
- var maybePromise;
1547
- if (initMethod) {
1548
- maybePromise = initMethod.call(ctxProxy);
1549
- }
1550
- if (initExpr) {
1551
- try {
1552
- var keys = Object.keys(scopeVars);
1553
- var vals = keys.map(function(k) { return scopeVars[k]; });
1554
- var fn = new Function(keys.join(','), initExpr);
1555
- var result = fn.apply(ctxProxy, vals);
1556
- if (result && typeof result.then === 'function') maybePromise = result;
1557
- } catch (e) {
1558
- console.warn('[stx-reactive] init expression error:', e);
1559
- }
1560
- }
1561
- // If init is async, signal updates will trigger effects automatically
1562
- // when init() resolves and sets this.prop = value (writes through signal)
1563
- if (maybePromise && typeof maybePromise.then === 'function') {
1564
- maybePromise.catch(function(e) {
1565
- console.error('[stx-reactive] async init() error:', e);
1566
- });
1567
- }
1568
- }
1569
-
1570
- // Run init before the signals runtime processes this scope
1571
- runInit();
1572
-
1573
- // Expose for debugging
1574
- scopeEl.__stx_state = ctxProxy;
1575
- scopeEl.__stx_execute = function(stmt, $event, $el) {
1576
- try {
1577
- // Run the statement with the reactive proxy as the lexical scope.
1578
- // Wrapping in a with-block on the proxy makes bare reads/writes go
1579
- // through it (so foo = bar triggers signal.set()) instead of treating
1580
- // each state key as a local function parameter \u2014 bare assignments
1581
- // would otherwise just rebind the local and never reach the signal.
1582
- var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
1583
- fn.call(ctxProxy, $event, $el);
1584
- } catch (e) {
1585
- console.warn('[stx-reactive] execute error:', e);
1586
- }
1587
- };
1588
- }
1589
-
1590
- return { initScope: initScope, reactive: reactive };
1591
- })();
1592
- `}function fp(v,k){let C=v.replace(/\{!!([\s\S]*?)!!\}/g,(V,H)=>{try{let K=x(H,k,!0);if(K===void 0)return V;return String(K)}catch{return V}}),R="",T=0,z=null;while(T<C.length){let V=C[T];if(z&&V==="\\"){R+=V+(C[T+1]??""),T+=2;continue}if(V==="{"&&C[T+1]==="{"){let H=C.indexOf("}}",T+2);if(H!==-1){let K=C.slice(T,H+2);R+=F(C.slice(T+2,H),K,z),T=H+2;continue}}if(z){if(V===z)z=null}else if(V==="'"||V==='"'||V==="`")z=V;R+=V,T++}return R;function F(V,H,K){let X;try{X=x(V,k,!0)}catch{return H}if(X===void 0)return H;if(K){let G=String(X).replace(/\\/g,"\\\\").replace(new RegExp(K==="`"?"`":K,"g"),`\\${K}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return K==="`"?G.replace(/\$\{/g,"\\${"):G}if(typeof X==="string"){let G=X.trim();if(G.startsWith("{")&&G.endsWith("}")||G.startsWith("[")&&G.endsWith("]"))try{return JSON.parse(G),G}catch{}}return JSON.stringify(X)}}function Ix(v,k){if(v.length===0)return"";let C=v.map((R)=>{let T=JSON.stringify(Object.fromEntries(R.refs)),z=fp(R.stateExpr,k),F=R.initExpr?fp(R.initExpr,k):null,V=JSON.stringify(z),H=F?JSON.stringify(F):"null";return`
1593
- (function() {
1594
- var scopeEl = document.querySelector('${R.selector}');
1595
- if (!scopeEl) return;
1596
- var refs = ${T};
1597
- __stx_reactive.initScope(scopeEl, ${V}, [], refs, ${H});
1598
- })();`}).join(`
1599
- `);return`
1600
- <script data-stx-scoped data-stx-reactive data-stx-run="always">
1601
- ${Tx()}
1602
- ${C}
1603
- </script>`}function pp(v,k,C){if(!Dx(v))return v;let R=Ex(v);if(R.length===0)return v;let T=Px(v,R),z=Ix(R,k),F=T.lastIndexOf("</body>");if(F!==-1)T=T.slice(0,F)+z+`
1604
- `+T.slice(F);else T+=z;return T}function Px(v,k){let C=0,R=v.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(T,z,F)=>{let V=k[C++];if(!V)return T;let H=/data-stx-scope="([^"]*)"/.exec(F);if(H)return V.id=H[1],V.selector=`[data-stx-scope="${V.id}"]`,T;return`<${z} data-stx-scope="${V.id}"${F}>`});return R=R.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),R=R.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),R=R.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),R=R.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),R}function Dx(v){return/x-data\s*=\s*["']/.test(v)}import yb from"fs";import Ml from"path";import{createHighlighter as xb}from"ts-syntax-highlighter";import hs from"fs";import un from"path";import{loadConfigWithResult as db}from"bunfig";async function Ox(v,k,C,R){let T=k[0]?.replace(/['"]/g,"")||"main",z=Ne();if(T!=="main")z=z.replace("container:'main'",`container:'${T}'`);return`<script data-stx-router>${z}</script>`}var gp={name:"stxRouter",handler:Ox,hasEndTag:!1,description:"Inject the STX SPA router script for client-side navigation"};function Pr(v){return v.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function mp(v){let k=v.trim().toLowerCase();return!k.startsWith("javascript:")&&!k.startsWith("vbscript:")&&!k.startsWith("data:text/html")}function sr(v){let k=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,C=v.match(k);if(!C)return{data:{},content:v.trim()};let R=C[1],T=v.slice(C[0].length),z={};for(let F of R.split(`
1605
- `)){let V=F.trim();if(!V||V.startsWith("#"))continue;let H=V.indexOf(":");if(H===-1)continue;let K=V.slice(0,H).trim(),X=V.slice(H+1).trim();if(typeof X==="string"){if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))X=X.slice(1,-1);else if(X.startsWith("[")&&X.endsWith("]"))try{X=JSON.parse(X)}catch{}else if(X==="true")X=!0;else if(X==="false")X=!1;else if(/^-?\d+(?:\.\d+)?$/.test(X))X=Number(X)}z[K]=X}return{data:z,content:T.trim()}}function qe(v,k={}){let{gfm:C=!0,breaks:R=!1}=k,T=v,z=[];if(T=T.replace(/```(\w*)\n([\s\S]*?)```/g,(X,G,te)=>{let ce=z.length,ee=G?` class="language-${Pr(G)}"`:"";return z.push(`<pre><code${ee}>${Pr(te.trim())}</code></pre>`),`\x00CODEBLOCK${ce}\x00`}),T=T.replace(/`([^`]*)`/g,(X,G)=>`<code>${Pr(G)}</code>`),T=T.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),T=T.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),T=T.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),T=T.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),T=T.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),T=T.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),T=T.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),T=T.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),T=T.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),T=T.replace(/__(.+?)__/g,"<strong>$1</strong>"),T=T.replace(/\*(.+?)\*/g,"<em>$1</em>"),T=T.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),C)T=T.replace(/~~(.+?)~~/g,"<del>$1</del>");if(T=T.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(X,G,te)=>`<img src="${mp(te)?Pr(te):""}" alt="${Pr(G)}" />`),T=T.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(X,G,te)=>`<a href="${mp(te)?Pr(te):""}">${G}</a>`),T=T.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),T=T.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),T=T.replace(/<\/blockquote>\n<blockquote>/g,`
1606
- `),T=T.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),T=T.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),T=T.replace(/<\/ul>\n<ul>/g,""),T=T.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),T=T.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),T=T.replace(/<\/ol>\n<ol>/g,""),T=T.replace(/<li data-ul>/g,"<li>"),T=T.replace(/<li data-ol>/g,"<li>"),C)T=T.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(X,G,te)=>{let ee=`<tr>${G.split("|").map((ue)=>ue.trim()).filter(Boolean).map((ue)=>`<th>${Pr(ue)}</th>`).join("")}</tr>`,le=te.trim().split(`
1607
- `).map((ue)=>`<tr>${ue.split("|").map((fe)=>fe.trim()).filter(Boolean).map((fe)=>`<td>${Pr(fe)}</td>`).join("")}</tr>`).join(`
1608
- `);return`<table>
1609
- <thead>
1610
- ${ee}
1611
- </thead>
1612
- <tbody>
1613
- ${le}
1614
- </tbody>
1615
- </table>`});if(C)T=T.replace(/<li>\s*\[\s*\]\s*/g,'<li><input type="checkbox" disabled /> '),T=T.replace(/<li>\s*\[x\]\s*/gi,'<li><input type="checkbox" checked disabled /> ');let F=T.split(`
1616
- `),V=[],H=!1,K=[];for(let X of F){let G=X.trim();if(/^<(?:h[1-6]|ul|ol|li|blockquote|pre|table|thead|tbody|tr|th|td|hr|div|p)/.test(G)||/^\0CODEBLOCK\d+\0$/.test(G)||G===""){if(H&&K.length>0)V.push(`<p>${K.join(R?`<br />
1617
- `:`
1618
- `)}</p>`),K=[],H=!1;V.push(X)}else H=!0,K.push(G)}if(H&&K.length>0)V.push(`<p>${K.join(R?`<br />
1619
- `:`
1620
- `)}</p>`);if(T=V.join(`
1621
- `),R)T=T.replace(/\n/g,`<br />
1622
- `);for(let X=0;X<z.length;X++)T=T.replace(`\x00CODEBLOCK${X}\x00`,z[X]);return T=T.replace(/<p>\s*<\/p>/g,""),T.trim()}async function hp(v,k,C=""){let R=v,T=[],z=/@markdown(?:\([^)]*\))?/g,F;while((F=z.exec(v))!==null){let V=F.index,H=F[0].match(/@markdown\(([^)]*)\)/),K=H?H[1]:"",X=V+F[0].length,G=1,te=X,ce=-1;while(G>0&&te<v.length){let ue=v.indexOf("@markdown",te),de=v.indexOf("@endmarkdown",te);if(de===-1)break;if(ue!==-1&&ue<de&&ue!==V){let fe=v[ue+9];if(fe==="("||fe===`
1623
- `||fe==="\r"||fe===" "||fe===void 0)G++;te=ue+9}else{if(G--,G===0){ce=de;break}te=de+12}}if(ce===-1)continue;let ee=v.slice(X,ce),le=v.slice(V,ce+12);T.push({fullMatch:le,options:K,content:ee,index:V}),z.lastIndex=ce+12}for(let{fullMatch:V,options:H,content:K,index:X}of T)try{let G={};if(H)H.split(",").forEach((ee)=>{let le=ee.trim();if(le)G[le]=!0});let te={gfm:G.gfm??!0,breaks:G.breaks??!1},ce=qe(K.trim(),te);R=R.split(V).join(ce)}catch(G){let te=G instanceof Error?G.message:String(G),ce=g("Markdown Directive",`Error processing markdown: ${te}`,C,v,X,V);R=R.split(V).join(ce)}return R}async function yp(v,k,C,R){let T={gfm:!0,breaks:!1};return k.forEach((z)=>{let F=z.trim().replace(/['"]/g,"");if(F==="breaks")T.breaks=!0;if(F==="no-gfm")T.gfm=!1}),qe(v.trim(),T)}var ms=[320,480,640,768,1024,1280,1536,1920,2560],Mx=[1,1.5,2,3],go=["avif","webp","jpeg"],Nx={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"};function $l(v,k=ms,C={},R){return k.sort((T,z)=>T-z).map((T)=>`${mo(v,{...C,w:T,fm:R})} ${T}w`).join(", ")}function xp(v,k,C=Mx,R={},T){return C.sort((z,F)=>z-F).map((z)=>{let F=Math.round(k*z);return`${mo(v,{...R,w:F,dpr:z,fm:T})} ${z}x`}).join(", ")}function _l(v,k="100vw"){if(!v||Object.keys(v).length===0)return k;let R=Object.entries(v).map(([T,z])=>{let F=/^\d+$/.test(T)?`${T}px`:T;return{bp:F,size:z,numericBp:Number.parseInt(F)||0}}).sort((T,z)=>T.numericBp-z.numericBp).map(({bp:T,size:z})=>`(max-width: ${T}) ${z}`);return R.push(k),R.join(", ")}function mo(v,k={}){let C=Object.entries(k).filter(([,z])=>z!==void 0&&z!==null).map(([z,F])=>{if(Array.isArray(F))return[z,F.join(",")];return[z,String(F)]});if(C.length===0)return v;let R=C.map(([z,F])=>`${z}=${encodeURIComponent(F)}`).join("&"),T=v.includes("?")?"&":"?";return`${v}${T}${R}`}function kl(v){return Nx[v]||"application/octet-stream"}var jx={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},Cl=`
1624
- .stx-img-placeholder {
1625
- position: relative;
1626
- overflow: hidden;
1627
- background-size: cover;
1628
- background-position: center;
1629
- background-repeat: no-repeat;
1630
- }
1631
-
1632
- .stx-img-placeholder img {
1633
- opacity: 0;
1634
- transition: opacity var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
1635
- }
1636
-
1637
- .stx-img-placeholder.stx-img-loaded img {
1638
- opacity: 1;
1639
- }
1640
-
1641
- .stx-img-blur {
1642
- filter: blur(20px);
1643
- transform: scale(1.1);
1644
- transition: filter var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out),
1645
- transform var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
1646
- }
1647
-
1648
- .stx-img-loaded .stx-img-blur {
1649
- filter: blur(0);
1650
- transform: scale(1);
1651
- }
1652
- `.trim();async function Lx(){try{return await import("ts-images")}catch{return null}}async function Bx(v,k={}){let C={...jx,...k},R=await Lx();if(R)try{return await zx(v,C,R)}catch(T){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${T}`)}return Wx(v,C)}async function zx(v,k,C){let{generatePlaceholder:R,generateThumbHash:T}=C,F={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[k.strategy]||"blur";if(k.strategy==="thumbhash")return{dataURL:(await T(v)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let V=await R(v,{width:k.width,height:k.height,quality:k.quality,blurLevel:k.blurLevel,strategy:F,base64Encode:!0});return{dataURL:V.dataURL,width:V.width,height:V.height,aspectRatio:V.aspectRatio,originalWidth:V.originalWidth,originalHeight:V.originalHeight,strategy:k.strategy,dominantColor:V.dominantColor,css:V.css}}function Wx(v,k){let C=k.width||20,R=k.height||C,T="#e5e7eb",z=`<svg xmlns="http://www.w3.org/2000/svg" width="${C}" height="${R}" viewBox="0 0 ${C} ${R}"><rect fill="#e5e7eb" width="${C}" height="${R}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(z)}`,width:C,height:R,aspectRatio:C/R,originalWidth:0,originalHeight:0,strategy:k.strategy,dominantColor:"#e5e7eb"}}function bp(v,k,C={}){let R=C.transitionDuration||300,T=C.easing||"ease-out";return`
1653
- #${v} {
1654
- --stx-img-transition-duration: ${R}ms;
1655
- --stx-img-transition-easing: ${T};
1656
- background-image: url('${k.dataURL}');
1657
- background-size: cover;
1658
- background-position: center;
1659
- }
1660
-
1661
- #${v} img {
1662
- opacity: 0;
1663
- transition: opacity var(--stx-img-transition-duration) var(--stx-img-transition-easing);
1664
- }
1665
-
1666
- #${v}.stx-img-loaded img {
1667
- opacity: 1;
1668
- }
1669
- `.trim()}var El=new Map;async function vp(v,k={}){let C=`${v}:${JSON.stringify(k)}`;if(El.has(C))return El.get(C);let R=await Bx(v,k);return El.set(C,R),R}async function Fx(){try{return await import("./chunk-3gcg3gvy.js")}catch(v){if(!wp)console.warn("[stx-media] Image processor not available, some features disabled:",v),wp=!0;return null}}var wp=!1,Rl=80,Ea="async",Ca="lazy",Sp=!1;async function ka(v,k={}){let C=k,R=v;if(R.process&&!R.skipOptimization){if(C.tsImagesConfig?.enabled&&!C.isDev)return qx(R,C)}if(C.processedResult?.processed)return Il(v,C.processedResult,k);if(C.responsiveVariants)return kp(v,C.responsiveVariants,k);let{src:T,alt:z,width:F,height:V,sizes:H,widths:K=ms,dpr:X,formats:G=go,quality:te=Rl,params:ce={},placeholder:ee="none",placeholderOptions:le={},lazy:ue=!0,priority:de=!1,loading:fe=de?"eager":Ca,decoding:pe=Ea,fetchpriority:Ae,objectFit:Se,objectPosition:ve,crossorigin:De,referrerpolicy:Me}=v,{class:je,style:Le,id:Be}=v,Oe=v.data||{},{isDev:We=!1,baseUrl:Fe=""}=k;if(We&&!k.optimize)return Hx(v);let Ve,ze,at=Be||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(ee!=="none"&&!de)try{Ve=await vp(T,{strategy:ee,...le}),ze=bp(at,Ve,le)}catch{}let St=X!==void 0&&F!==void 0,bt;if(St)bt=Ux(v,at,Ve,k);else bt=await Vx(v,at,Ve,k);let Tt;if(de){let Et=G.includes("webp")?"webp":G[0],vt=$l(T,K,{...ce,q:te},Et),dt=typeof H==="object"?_l(H):H||"100vw";Tt=`<link rel="preload" as="image" imagesrcset="${vt}" imagesizes="${dt}" />`}let wt=[];if(!Sp&&ee!=="none")wt.push(Cl),Sp=!0;if(ze)wt.push(ze);let gt=ue?_p(at):void 0;return{html:bt,preloadLink:Tt,css:wt.length>0?wt.join(`
1670
- `):void 0,script:gt}}async function Vx(v,k,C,R){let{src:T,alt:z,width:F,height:V,sizes:H,widths:K=ms,formats:X=go,quality:G=Rl,params:te={},lazy:ce=!0,priority:ee=!1,loading:le=ee?"eager":Ca,decoding:ue=Ea,fetchpriority:de,objectFit:fe,objectPosition:pe,crossorigin:Ae,referrerpolicy:Se}=v,{class:ve,style:De}=v,Me=v.data||{},je=typeof H==="object"?_l(H):H||"100vw",Le=[];for(let We of X){let Fe=$l(T,K,{...te,q:G},We),Ve=kl(We);if(ce&&!ee)Le.push(` <source type="${Ve}" data-srcset="${Fe}" data-sizes="${je}" />`);else Le.push(` <source type="${Ve}" srcset="${Fe}" sizes="${je}" />`)}let Be=Al({src:mo(T,{...te,q:G}),alt:z,width:F,height:V,loading:ee?void 0:le,decoding:ue,fetchpriority:ee?"high":de,objectFit:fe,objectPosition:pe,crossorigin:Ae,referrerpolicy:Se,className:$p(ve,C),style:Tl(De,fe,pe,C),lazy:ce&&!ee,data:Me}),Oe;if(C){let We=`background-image: url('${C.dataURL}'); background-size: cover; background-position: center;`;Oe=`<div id="${k}" class="stx-img-placeholder" style="${We}">
1671
- <picture>
1672
- ${Le.join(`
1673
- `)}
1674
- <img ${Be} />
1675
- </picture>
1676
- </div>`}else Oe=`<picture${k?` id="${k}"`:""}>
1677
- ${Le.join(`
1678
- `)}
1679
- <img ${Be} />
1680
- </picture>`;return Oe}function Ux(v,k,C,R){let{src:T,alt:z,width:F,height:V,dpr:H=[1,2,3],quality:K=Rl,params:X={},lazy:G=!0,priority:te=!1,loading:ce=te?"eager":Ca,decoding:ee=Ea,fetchpriority:le,objectFit:ue,objectPosition:de,crossorigin:fe,referrerpolicy:pe}=v,{class:Ae,style:Se}=v,ve=v.data||{},De=typeof F==="number"?F:Number.parseInt(String(F),10),Me=xp(T,De,H,{...X,q:K}),je=Al({src:mo(T,{...X,w:De,q:K}),alt:z,width:F,height:V,loading:te?void 0:ce,decoding:ee,fetchpriority:te?"high":le,objectFit:ue,objectPosition:de,crossorigin:fe,referrerpolicy:pe,className:$p(Ae,C),style:Tl(Se,ue,de,C),lazy:G&&!te,data:ve}),Le=G&&!te?`data-srcset="${Me}"`:`srcset="${Me}"`;if(C){let Be=`background-image: url('${C.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${k}" class="stx-img-placeholder" style="${Be}">
1681
- <img ${je} ${Le} />
1682
- </div>`}return`<img ${k?`id="${k}" `:""}${je} ${Le} />`}function Hx(v){let{src:k,alt:C,width:R,height:T,loading:z=Ca,decoding:F=Ea,fetchpriority:V,objectFit:H,objectPosition:K,crossorigin:X,referrerpolicy:G,priority:te=!1}=v,{class:ce,style:ee,id:le}=v,ue=v.data||{};return{html:`<img ${Al({src:k,alt:C,width:R,height:T,loading:te?"eager":z,decoding:F,fetchpriority:te?"high":V,objectFit:H,objectPosition:K,crossorigin:X,referrerpolicy:G,className:ce,style:Tl(ee,H,K),id:le,data:ue})} />`}}function Al(v){let k=[];if(v.lazy)k.push(`data-src="${Wn(v.src)}"`),k.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else k.push(`src="${Wn(v.src)}"`);if(k.push(`alt="${Wn(v.alt)}"`),v.width)k.push(`width="${v.width}"`);if(v.height)k.push(`height="${v.height}"`);if(v.loading)k.push(`loading="${v.loading}"`);if(v.decoding)k.push(`decoding="${v.decoding}"`);if(v.fetchpriority)k.push(`fetchpriority="${v.fetchpriority}"`);if(v.crossorigin)k.push(`crossorigin="${v.crossorigin}"`);if(v.referrerpolicy)k.push(`referrerpolicy="${v.referrerpolicy}"`);if(v.className)k.push(`class="${Wn(v.className)}"`);if(v.style)k.push(`style="${Wn(v.style)}"`);if(v.id)k.push(`id="${Wn(v.id)}"`);if(v.data)for(let[C,R]of Object.entries(v.data))k.push(`data-${C}="${Wn(R)}"`);if(v.lazy)k.push("data-stx-lazy");return k.join(" ")}function $p(v,k){let C=[];if(v)C.push(v);if(k)C.push("stx-img-blur");return C.join(" ")||""}function Tl(v,k,C,R){let T=[];if(k)T.push(`object-fit: ${k}`);if(C)T.push(`object-position: ${C}`);if(R)T.push("opacity: 0; transition: opacity 300ms ease-out");if(v)T.push(v);return T.join("; ")}function Wn(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _p(v){return`
1683
- (function() {
1684
- const container = document.getElementById('${v}');
1685
- if (!container) return;
1686
-
1687
- const img = container.querySelector('img[data-stx-lazy]') || container;
1688
- if (!img.dataset.src && !img.dataset.srcset) return;
1689
-
1690
- const observer = new IntersectionObserver((entries) => {
1691
- entries.forEach(entry => {
1692
- if (entry.isIntersecting) {
1693
- // Load image
1694
- if (img.dataset.src) img.src = img.dataset.src;
1695
- if (img.dataset.srcset) img.srcset = img.dataset.srcset;
1696
-
1697
- // Load sources
1698
- const sources = container.querySelectorAll('source[data-srcset]');
1699
- sources.forEach(source => {
1700
- if (source.dataset.srcset) source.srcset = source.dataset.srcset;
1701
- if (source.dataset.sizes) source.sizes = source.dataset.sizes;
1702
- });
1703
-
1704
- // Handle load completion
1705
- img.onload = () => {
1706
- img.style.opacity = '1';
1707
- if (container.classList.contains('stx-img-placeholder')) {
1708
- container.classList.add('stx-img-loaded');
1709
- }
1710
- };
1711
-
1712
- observer.disconnect();
1713
- }
1714
- });
1715
- }, { rootMargin: '50px' });
1716
-
1717
- observer.observe(container);
1718
- })();
1719
- `.trim()}async function qx(v,k){let C=await Fx();if(!C)return ka({...v,process:!1},k);let R=k.tsImagesConfig;if(v.responsiveWidths&&v.responsiveWidths.length>0||v.widths&&v.widths.length>0||!v.width&&!v.dpr){let z=await C.generateResponsiveVariants(v.src,v,R);if(z)return kp(v,z,k)}else{let z=await C.processImage(v.src,v,R);if(z.processed)return Il(v,z,k)}return ka({...v,process:!1},k)}async function Il(v,k,C){let{alt:R,width:T,height:z,lazy:F=!0,priority:V=!1,objectFit:H,objectPosition:K,crossorigin:X,referrerpolicy:G}=v,{class:te,style:ce}=v,ee=v.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,le=v.data||{},ue=k.variants||[],de=ue.find((ze)=>ze.format==="jpeg")||ue.find((ze)=>ze.format==="webp")||ue[0],fe=de?.url||v.src,pe=ue.filter((ze)=>ze.format===(de?.format||"jpeg")).map((ze)=>`${ze.url} ${ze.width}w`).join(", "),Ae=new Map;for(let ze of ue){if(!Ae.has(ze.format))Ae.set(ze.format,[]);Ae.get(ze.format).push(ze)}let Se=[],ve=["avif","webp","jpeg","png"];for(let ze of ve){let at=Ae.get(ze);if(at&&at.length>0){let St=at.map((Tt)=>`${Tt.url} ${Tt.width}w`).join(", "),bt=kl(ze);if(F&&!V)Se.push(` <source type="${bt}" data-srcset="${St}" />`);else Se.push(` <source type="${bt}" srcset="${St}" />`)}}let De=[];if(F&&!V){if(De.push(`data-src="${Wn(fe)}"`),De.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),pe)De.push(`data-srcset="${pe}"`)}else if(De.push(`src="${Wn(fe)}"`),pe)De.push(`srcset="${pe}"`);De.push(`alt="${Wn(R)}"`);let Me=T||k.originalWidth,je=z||k.originalHeight;if(Me)De.push(`width="${Me}"`);if(je)De.push(`height="${je}"`);if(!V)De.push(`loading="${F?"lazy":"eager"}"`);if(De.push('decoding="async"'),V)De.push('fetchpriority="high"');if(X)De.push(`crossorigin="${X}"`);if(G)De.push(`referrerpolicy="${G}"`);let Le=[];if(H)Le.push(`object-fit: ${H}`);if(K)Le.push(`object-position: ${K}`);if(k.placeholder&&F)Le.push("opacity: 0; transition: opacity 300ms ease-out");if(ce)Le.push(ce);if(Le.length>0)De.push(`style="${Le.join("; ")}"`);let Be=[];if(te)Be.push(te);if(k.placeholder)Be.push("stx-img-blur");if(Be.length>0)De.push(`class="${Be.join(" ")}"`);if(F&&!V)De.push("data-stx-lazy");for(let[ze,at]of Object.entries(le))De.push(`data-${ze}="${Wn(at)}"`);let Oe;if(k.placeholder||k.dominantColor&&v.useDominantColor){let ze=k.placeholder?`background-image: url('${k.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${k.dominantColor};`;Oe=`<div id="${ee}" class="stx-img-placeholder" style="${ze}">
1720
- <picture>
1721
- ${Se.join(`
1722
- `)}
1723
- <img ${De.join(" ")} />
1724
- </picture>
1725
- </div>`}else Oe=`<picture${ee?` id="${ee}"`:""}>
1726
- ${Se.join(`
1727
- `)}
1728
- <img ${De.join(" ")} />
1729
- </picture>`;let We=[];if(k.placeholder)We.push(Cl);let Fe=F?_p(ee):void 0,Ve;if(V&&pe)Ve=`<link rel="preload" as="image" imagesrcset="${pe}" />`;return{html:Oe,preloadLink:Ve,css:We.length>0?We.join(`
1730
- `):void 0,script:Fe}}async function kp(v,k,C){let R={src:k.src,processed:!0,variants:[],placeholder:k.placeholder?.dataURL,originalWidth:k.placeholder?.width,originalHeight:k.placeholder?.height};for(let[T,z]of Object.entries(k.byFormat))if(z)R.variants.push(...z);return Il(v,R,C)}function Kx(){return ot({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async(v,k,C,R)=>{let{src:T,alt:z,options:F}=Xx(v,k,C);if(!T)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let V={src:T,alt:z||"",widths:F.widths||ms,formats:F.formats||go,quality:F.quality,sizes:F.sizes,dpr:F.dpr,params:F.params,placeholder:F.placeholder,placeholderOptions:F.placeholderOptions,lazy:F.lazy!==!1,priority:F.priority||!1,loading:F.loading,decoding:F.decoding,fetchpriority:F.fetchpriority,objectFit:F.objectFit,objectPosition:F.objectPosition,class:F.class,style:F.style,id:F.id,width:F.width,height:F.height},H=C.__isDev||!1,K=await ka(V,{isDev:H}),X=K.html;if(K.preloadLink)X=K.preloadLink+`
1731
- `+X;if(K.css)X+=`
1732
- <style>${K.css}</style>`;if(K.script)X+=`
1733
- <script>${K.script}</script>`;return X},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function Xx(v,k,C){if(k.src)return{src:String(k.src),alt:String(k.alt||""),options:k.options||{}};let R=v.trim();if(R.startsWith("@img(")||R.startsWith("("))R=R.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let T=Zx(R),z=Pl(T[0],C)||"",F=Pl(T[1],C)||"",V={};if(T[2]){let H=Pl(T[2],C);if(typeof H==="object"&&H!==null)V=H;else if(typeof T[2]==="string")try{V=JSON.parse(T[2])}catch{}}return{src:z,alt:F,options:V}}function Zx(v){let k=[],C="",R=!1,T="",z=0,F=0;for(let V=0;V<v.length;V++){let H=v[V],K=V>0?v[V-1]:"";if((H==='"'||H==="'"||H==="`")&&K!=="\\"){if(!R)R=!0,T=H;else if(H===T)R=!1,T="";else C+=H;continue}if(!R){if(H==="{")z++;if(H==="}")z--;if(H==="[")F++;if(H==="]")F--;if(H===","&&z===0&&F===0){k.push(C.trim()),C="";continue}}C+=H}if(C.trim())k.push(C.trim());return k}function Pl(v,k){if(typeof v!=="string")return v;let C=v.trim();if(C.startsWith('"')&&C.endsWith('"')||C.startsWith("'")&&C.endsWith("'"))return C.slice(1,-1);if(!C.startsWith("/")&&!C.startsWith(".")&&!C.startsWith("http")&&!C.startsWith("{")){let R=k[C];if(R!==void 0)return R}if(C.startsWith("{")||C.startsWith("["))try{return JSON.parse(C)}catch{}return C}var Ep=Kx();async function Rp(){try{return await import("./chunk-nj0b4ryt.js")}catch(v){if(!Cp)console.warn("[stx-media] Video processor not available, some features disabled:",v),Cp=!0;return null}}var Cp=!1,Ap=!0,Tp="metadata",Gx="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";async function Ra(v,k={}){let C=k,R=v;if(R.process&&!R.skipProcessing){if(C.tsVideosConfig?.enabled&&!C.isDev)return tb(R,C)}if(C.processedResult?.processed)return Pp(v,C.processedResult,k);let T;if(R.generatePoster&&R.src&&!v.poster)T=await nb(R,C);let{src:z,sources:F=[],poster:V,posterPlaceholder:H,controls:K=Ap,autoplay:X=!1,muted:G=!1,loop:te=!1,preload:ce=Tp,playsinline:ee=!0,lazy:le=!0,player:ue="native",type:de,width:fe,height:pe,crossorigin:Ae,disablePictureInPicture:Se=!1,disableRemotePlayback:ve=!1}=v,De=T||V,{class:Me,style:je}=v,Le=v.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(ue==="ts-video")return Yx(v,k);if(de&&de!=="video")return Jx(z||"",de,v);let Be=F.length>0?F:z?[{src:z,type:Ip(z)}]:[],Oe=[`id="${Le}"`];if(K)Oe.push("controls");if(X)Oe.push("autoplay");if(G)Oe.push("muted");if(te)Oe.push("loop");if(ee)Oe.push("playsinline");if(Se)Oe.push("disablepictureinpicture");if(ve)Oe.push("disableremoteplayback");if(Ae)Oe.push(`crossorigin="${Ae}"`);if(le){if(Oe.push(`data-preload="${ce}"`),Oe.push('preload="none"'),De)Oe.push(`data-poster="${ln(De)}"`);Oe.push("data-stx-lazy")}else if(Oe.push(`preload="${ce}"`),De)Oe.push(`poster="${ln(De)}"`);if(fe)Oe.push(`width="${fe}"`);if(pe)Oe.push(`height="${pe}"`);if(Me)Oe.push(`class="${ln(Me)}"`);if(je)Oe.push(`style="${ln(je)}"`);let We=Be.map((ze)=>` <source ${le?`data-src="${ln(ze.src)}"`:`src="${ln(ze.src)}"`} type="${ze.type}"${ze.media?` media="${ze.media}"`:""} />`).join(`
1734
- `),Fe=`<video ${Oe.join(" ")}>
1735
- ${We}
1736
- Your browser does not support the video tag.
1737
- </video>`,Ve;if(le)Ve=`
1738
- (function() {
1739
- var video = document.getElementById('${Le}');
1740
- if (!video) return;
1741
-
1742
- var observer = new IntersectionObserver(function(entries) {
1743
- entries.forEach(function(entry) {
1744
- if (entry.isIntersecting) {
1745
- // Load poster
1746
- if (video.dataset.poster) {
1747
- video.poster = video.dataset.poster;
1748
- delete video.dataset.poster;
1749
- }
1750
-
1751
- // Load sources
1752
- var sources = video.querySelectorAll('source[data-src]');
1753
- sources.forEach(function(source) {
1754
- source.src = source.dataset.src;
1755
- delete source.dataset.src;
1756
- });
1757
-
1758
- // Set preload
1759
- if (video.dataset.preload) {
1760
- video.preload = video.dataset.preload;
1761
- delete video.dataset.preload;
1762
- }
1763
-
1764
- video.load();
1765
- observer.disconnect();
1766
- }
1767
- });
1768
- }, { rootMargin: '50px' });
1769
-
1770
- observer.observe(video);
1771
- })();
1772
- `.trim();return{html:Fe,script:Ve}}function Jx(v,k,C){let{width:R=640,height:T=360}=C,{class:z,style:F}=C,V=C.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,H,K=null;switch(k){case"youtube":K=Qx(v),H=K?`https://www.youtube-nocookie.com/embed/${K}`:v;break;case"vimeo":K=eb(v),H=K?`https://player.vimeo.com/video/${K}`:v;break;case"dailymotion":K=v.split("/").pop()||"",H=`https://www.dailymotion.com/embed/video/${K}`;break;case"twitch":K=v.split("/").pop()||"",H=`https://player.twitch.tv/?video=${K}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:H=v}let X=[`id="${V}"`,`src="${ln(H)}"`,`width="${R}"`,`height="${T}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(z)X.push(`class="${ln(z)}"`);if(F)X.push(`style="${ln(F)}"`);if(C.lazy)X.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
1773
- <iframe ${X.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
1774
- </div>`}}function Yx(v,k={}){let{src:C,sources:R=[],poster:T,controls:z=!0,autoplay:F=!1,muted:V=!1,loop:H=!1,preload:K="metadata",playsinline:X=!0,lazy:G=!0,width:te,height:ce}=v,{class:ee,style:le}=v,ue=v.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,de={src:R.length>0?R:C,autoplay:F,loop:H,muted:V,playsinline:X,preload:K,poster:T,controls:z,title:v.title},fe=["position: relative",te?`width: ${typeof te==="number"?te+"px":te}`:"width: 100%",ce?`height: ${typeof ce==="number"?ce+"px":ce}`:"",le||""].filter(Boolean).join("; "),pe=`
1775
- <div
1776
- id="${ue}"
1777
- class="ts-video-player${ee?" "+ln(ee):""}"
1778
- style="${fe}"
1779
- data-ts-video-player
1780
- data-config='${JSON.stringify(de)}'
1781
- ${G?"data-lazy":""}
1782
- >
1783
- <div class="ts-video-player__container">
1784
- ${T?`
1785
- <div class="ts-video-player__placeholder" style="background-image: url('${ln(T)}');">
1786
- <button class="ts-video-player__play-button" aria-label="Play video">
1787
- <svg viewBox="0 0 24 24" fill="currentColor" width="64" height="64">
1788
- <path d="M8 5v14l11-7z"/>
1789
- </svg>
1790
- </button>
1791
- </div>
1792
- `:""}
1793
- </div>
1794
- </div>
1795
- `.trim(),Ae=`
1796
- (function() {
1797
- var container = document.getElementById('${ue}');
1798
- if (!container) return;
1799
-
1800
- var config = JSON.parse(container.dataset.config || '{}');
1801
- var isLazy = container.hasAttribute('data-lazy');
1802
-
1803
- function loadPlayer() {
1804
- if (typeof TSVideoPlayer !== 'undefined') {
1805
- initPlayer();
1806
- return;
1807
- }
1808
-
1809
- // Load ts-video-player from CDN
1810
- var script = document.createElement('script');
1811
- script.src = '${Gx}';
1812
- script.onload = initPlayer;
1813
- script.onerror = function() {
1814
- console.error('[stx] Failed to load ts-video-player');
1815
- fallbackToNative();
1816
- };
1817
- document.head.appendChild(script);
1818
- }
1819
-
1820
- function initPlayer() {
1821
- var player = TSVideoPlayer.createPlayer(container, config);
1822
- if (config.src) {
1823
- player.setSrc(config.src);
1824
- }
1825
- container.__tsVideoPlayer = player;
1826
-
1827
- // Remove placeholder
1828
- var placeholder = container.querySelector('.ts-video-player__placeholder');
1829
- if (placeholder) {
1830
- placeholder.style.display = 'none';
1831
- }
1832
- }
1833
-
1834
- function fallbackToNative() {
1835
- // Fallback to native video element
1836
- var video = document.createElement('video');
1837
- video.controls = config.controls !== false;
1838
- video.autoplay = config.autoplay;
1839
- video.muted = config.muted;
1840
- video.loop = config.loop;
1841
- video.playsInline = config.playsinline;
1842
- video.preload = config.preload || 'metadata';
1843
- if (config.poster) video.poster = config.poster;
1844
- if (config.src) video.src = typeof config.src === 'string' ? config.src : config.src[0]?.src || config.src[0];
1845
- video.style.width = '100%';
1846
- video.style.height = '100%';
1847
-
1848
- var containerEl = container.querySelector('.ts-video-player__container');
1849
- if (containerEl) {
1850
- containerEl.innerHTML = '';
1851
- containerEl.appendChild(video);
1852
- }
1853
- }
1854
-
1855
- if (isLazy) {
1856
- var observer = new IntersectionObserver(function(entries) {
1857
- entries.forEach(function(entry) {
1858
- if (entry.isIntersecting) {
1859
- loadPlayer();
1860
- observer.disconnect();
1861
- }
1862
- });
1863
- }, { rootMargin: '50px' });
1864
- observer.observe(container);
1865
- }
1866
- else {
1867
- if (document.readyState === 'loading') {
1868
- document.addEventListener('DOMContentLoaded', loadPlayer);
1869
- }
1870
- else {
1871
- loadPlayer();
1872
- }
1873
- }
1874
-
1875
- // Handle play button click
1876
- var playButton = container.querySelector('.ts-video-player__play-button');
1877
- if (playButton) {
1878
- playButton.addEventListener('click', function() {
1879
- loadPlayer();
1880
- var check = setInterval(function() {
1881
- if (container.__tsVideoPlayer && container.__tsVideoPlayer.ready) {
1882
- container.__tsVideoPlayer.play();
1883
- clearInterval(check);
1884
- }
1885
- }, 100);
1886
- });
1887
- }
1888
- })();
1889
- `.trim(),Se=`
1890
- .ts-video-player {
1891
- position: relative;
1892
- background: #000;
1893
- }
1894
-
1895
- .ts-video-player__container {
1896
- position: relative;
1897
- width: 100%;
1898
- padding-bottom: 56.25%;
1899
- }
1900
-
1901
- .ts-video-player__container > * {
1902
- position: absolute;
1903
- top: 0;
1904
- left: 0;
1905
- width: 100%;
1906
- height: 100%;
1907
- }
1908
-
1909
- .ts-video-player__placeholder {
1910
- display: flex;
1911
- align-items: center;
1912
- justify-content: center;
1913
- background-color: #1a1a1a;
1914
- background-size: cover;
1915
- background-position: center;
1916
- cursor: pointer;
1917
- }
1918
-
1919
- .ts-video-player__play-button {
1920
- display: flex;
1921
- align-items: center;
1922
- justify-content: center;
1923
- width: 80px;
1924
- height: 80px;
1925
- background: rgba(0, 0, 0, 0.7);
1926
- border: none;
1927
- border-radius: 50%;
1928
- color: white;
1929
- cursor: pointer;
1930
- transition: transform 0.2s, background 0.2s;
1931
- }
1932
-
1933
- .ts-video-player__play-button:hover {
1934
- transform: scale(1.1);
1935
- background: rgba(0, 0, 0, 0.9);
1936
- }
1937
-
1938
- .ts-video-player__play-button svg {
1939
- margin-left: 4px;
1940
- }
1941
- `.trim();return{html:pe,script:Ae,css:Se}}function Ip(v){switch(v.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function Qx(v){let k=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let C of k){let R=v.match(C);if(R)return R[1]}return null}function eb(v){let k=v.match(/vimeo\.com\/(\d+)/);return k?k[1]:null}function ln(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}async function tb(v,k){let C=await Rp();if(!C)return Ra({...v,process:!1},k);let R=k.tsVideosConfig,T=await C.processVideo(v.src,v,R,v.onProcessProgress);if(T.processed)return Pp(v,T,k);return Ra({...v,process:!1},k)}async function nb(v,k){let C=await Rp();if(!C||!v.src)return;let R=typeof v.generatePoster==="object"?v.generatePoster:{timestamp:0},T=k.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await C.generatePoster(v.src,R,T.outputDir,T.baseUrl||"/videos"))?.url}function Pp(v,k,C){let{controls:R=Ap,autoplay:T=!1,muted:z=!1,loop:F=!1,preload:V=Tp,playsinline:H=!0,lazy:K=!0,width:X,height:G,crossorigin:te,disablePictureInPicture:ce=!1,disableRemotePlayback:ee=!1}=v,{class:le,style:ue}=v,de=v.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,fe=v.src,pe=Ip(fe);if(k.transcoded)fe=k.transcoded.url,pe="video/mp4";let Ae=k.streaming?.hls||k.streaming?.dash;if(Ae){if(k.streaming?.hls)fe=k.streaming.hls.manifestUrl,pe="application/x-mpegURL";else if(k.streaming?.dash)fe=k.streaming.dash.manifestUrl,pe="application/dash+xml"}let Se=k.poster?.url||v.poster,ve=[`id="${de}"`];if(R)ve.push("controls");if(T)ve.push("autoplay");if(z)ve.push("muted");if(F)ve.push("loop");if(H)ve.push("playsinline");if(ce)ve.push("disablepictureinpicture");if(ee)ve.push("disableremoteplayback");if(te)ve.push(`crossorigin="${te}"`);if(K){if(ve.push(`data-preload="${V}"`),ve.push('preload="none"'),Se)ve.push(`data-poster="${ln(Se)}"`);ve.push("data-stx-lazy")}else if(ve.push(`preload="${V}"`),Se)ve.push(`poster="${ln(Se)}"`);let De=X||k.metadata?.width,Me=G||k.metadata?.height;if(De)ve.push(`width="${De}"`);if(Me)ve.push(`height="${Me}"`);if(le)ve.push(`class="${ln(le)}"`);if(ue)ve.push(`style="${ln(ue)}"`);let Le=` <source ${K?`data-src="${ln(fe)}"`:`src="${ln(fe)}"`} type="${pe}" />`,Be=`<video ${ve.join(" ")}>
1942
- ${Le}
1943
- Your browser does not support the video tag.
1944
- </video>`;if(k.spriteSheet)Be=`<div class="stx-video-wrapper" data-sprite-sheet="${ln(k.spriteSheet.url)}" data-sprite-cols="${k.spriteSheet.columns}" data-sprite-interval="${k.spriteSheet.interval}">
1945
- ${Be}
1946
- </div>`;let Oe;if(K)Oe=`
1947
- (function() {
1948
- var video = document.getElementById('${de}');
1949
- if (!video) return;
1950
-
1951
- var observer = new IntersectionObserver(function(entries) {
1952
- entries.forEach(function(entry) {
1953
- if (entry.isIntersecting) {
1954
- // Load poster
1955
- if (video.dataset.poster) {
1956
- video.poster = video.dataset.poster;
1957
- delete video.dataset.poster;
1958
- }
1959
-
1960
- // Load sources
1961
- var sources = video.querySelectorAll('source[data-src]');
1962
- sources.forEach(function(source) {
1963
- source.src = source.dataset.src;
1964
- delete source.dataset.src;
1965
- });
1966
-
1967
- // Set preload
1968
- if (video.dataset.preload) {
1969
- video.preload = video.dataset.preload;
1970
- delete video.dataset.preload;
1971
- }
1972
-
1973
- video.load();
1974
- observer.disconnect();
1975
- }
1976
- });
1977
- }, { rootMargin: '50px' });
1978
-
1979
- observer.observe(video);
1980
- })();
1981
- `.trim();let We;if(Ae)We=`
1982
- .stx-video-wrapper {
1983
- position: relative;
1984
- width: 100%;
1985
- }
1986
- .stx-video-wrapper video {
1987
- width: 100%;
1988
- height: auto;
1989
- }
1990
- `.trim();return{html:Be,script:Oe,css:We}}function Dp(){return ot({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async(v,k,C,R)=>{let{src:T,options:z}=rb(v,k,C);if(!T)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let F={src:T,poster:z.poster,controls:z.controls!==!1,autoplay:z.autoplay||!1,muted:z.muted||!1,loop:z.loop||!1,preload:z.preload||"metadata",playsinline:z.playsinline!==!1,lazy:z.lazy!==!1,player:z.player||"native",type:z.type,width:z.width,height:z.height,class:z.class,style:z.style,id:z.id,crossorigin:z.crossorigin,disablePictureInPicture:z.disablePictureInPicture,disableRemotePlayback:z.disableRemotePlayback,title:z.title,quality:z.quality,platform:z.platform,process:z.process,generatePoster:z.generatePoster,streaming:z.streaming,transcode:z.transcode,spriteSheet:z.spriteSheet,waveform:z.waveform},H={isDev:C.__isDev||!1,tsVideosConfig:C.__tsVideosConfig},K=await Ra(F,H),X=K.html;if(K.css)X+=`
1991
- <style>${K.css}</style>`;if(K.script)X+=`
1992
- <script>${K.script}</script>`;return X},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function rb(v,k,C){if(k.src)return{src:String(k.src),options:k.options||{}};let R=v.trim();if(R.startsWith("@video(")||R.startsWith("("))R=R.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let T=sb(R),z=Op(T[0],C)||"",F={};if(T[1]){let V=Op(T[1],C);if(typeof V==="object"&&V!==null)F=V;else if(typeof T[1]==="string")try{F=JSON.parse(T[1])}catch{}}return{src:z,options:F}}function sb(v){let k=[],C="",R=!1,T="",z=0,F=0;for(let V=0;V<v.length;V++){let H=v[V],K=V>0?v[V-1]:"";if((H==='"'||H==="'"||H==="`")&&K!=="\\"){if(!R)R=!0,T=H;else if(H===T)R=!1,T="";else C+=H;continue}if(!R){if(H==="{")z++;if(H==="}")z--;if(H==="[")F++;if(H==="]")F--;if(H===","&&z===0&&F===0){k.push(C.trim()),C="";continue}}C+=H}if(C.trim())k.push(C.trim());return k}function Op(v,k){if(typeof v!=="string")return v;let C=v.trim();if(C.startsWith('"')&&C.endsWith('"')||C.startsWith("'")&&C.endsWith("'"))return C.slice(1,-1);if(!C.startsWith("/")&&!C.startsWith(".")&&!C.startsWith("http")&&!C.startsWith("{")){let R=k[C];if(R!==void 0)return R}if(C.startsWith("{")||C.startsWith("["))try{return JSON.parse(C)}catch{}return C}var Dl=Dp();import ib from"fs";import Nn from"path";async function hr(v,k){if(!v.webComponents?.enabled)return[];let C=v.webComponents.components||[],R=[];if(C.length>0){if(v.debug)console.log(`Building ${C.length} web components...`);for(let T of C)try{let z=await ob(T,v,k);if(z)R.push(z)}catch(z){if(console.error(`Error building web component ${T.name}:`,z),v.debug)throw z}}return R}async function ob(v,k,C){let{name:R,file:T,tag:z,extends:F}=v;if(!R||!T||!z)return console.error("Invalid web component configuration, missing required fields:",v),null;let V=null;if(Nn.isAbsolute(T)&&await r(T))V=T;else if(k.componentsDir){let le=Nn.join(k.componentsDir,T);if(await r(le))V=le}if(!V)V=await mr(T,process.cwd(),k,C);if(!V)return console.error(`Web component source file not found: ${T}`),null;let H=await Bun.file(V).text();C.add(V);let X=(v.outputFormat||"js")==="ts",G=X?cb({name:R,tag:z,baseElement:F,source:H,shadowDOM:v.shadowDOM??!0,template:v.template??!0,styleSource:v.styleSource,attributes:v.attributes||[],attributeTypes:v.attributeTypes||{}}):ab({name:R,tag:z,baseElement:F,source:H,shadowDOM:v.shadowDOM??!0,template:v.template??!0,styleSource:v.styleSource,attributes:v.attributes||[]}),te=k.webComponents?.outputDir||"dist/web-components";await ib.promises.mkdir(te,{recursive:!0});let ce=X?"ts":"js",ee=Nn.join(te,`${z}.${ce}`);if(await Bun.write(ee,G),k.debug)console.log(`Built web component ${R} -> ${ee}`);return ee}function ab(v){let{name:k,tag:C,baseElement:R="HTMLElement",source:T,shadowDOM:z,template:F,styleSource:V,attributes:H=[]}=v,K=T.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!z)K=K.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),K=K.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),K=K.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),K=K.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let X="";if(V)X=`<link rel="stylesheet" href="${V}">`;return`/**
1993
- * ${k} Web Component
1994
- * Auto-generated from stx component
1995
- */
1996
- class ${k.replace(/\W/g,"")} extends ${R} {
1997
- constructor() {
1998
- super()
1999
- this._initialized = false
2000
- ${z?"":"this._slotContent = []"}
2001
- ${z?'this.attachShadow({ mode: "open" })':""}
2002
- }
2003
-
2004
- ${F?`
2005
- _createTemplate() {
2006
- const template = document.createElement('template')
2007
- template.innerHTML = \`${X}${K}\`
2008
- ${z?"this.shadowRoot.appendChild(template.content.cloneNode(true))":"this.appendChild(template.content.cloneNode(true))"}
2009
- this._processSlots()
2010
- }
2011
- `:`
2012
- _render() {
2013
- ${z?"this.shadowRoot.innerHTML":"this.innerHTML"} = \`${X}${K}\`
2014
- this._processSlots()
2015
- }
2016
- `}
2017
-
2018
- _processSlots() {
2019
- ${z?`// Shadow DOM handles slot assignment automatically
2020
- // Listen for slot changes if needed
2021
- const slots = this.shadowRoot.querySelectorAll('slot')
2022
- slots.forEach(slot => {
2023
- slot.addEventListener('slotchange', (e) => {
2024
- const assignedNodes = slot.assignedNodes()
2025
- this.dispatchEvent(new CustomEvent('slot-changed', {
2026
- detail: { slotName: slot.name || 'default', assignedNodes }
2027
- }))
2028
- })
2029
- })`:`// Manual slot processing for non-shadow DOM mode
2030
- const slots = this.querySelectorAll('[data-slot]')
2031
-
2032
- // Process named slots
2033
- slots.forEach(slotEl => {
2034
- const slotName = slotEl.getAttribute('data-slot')
2035
- const slottedContent = this._slotContent.filter(
2036
- node => node.nodeType === Node.ELEMENT_NODE && node.getAttribute('slot') === slotName
2037
- )
2038
- if (slottedContent.length > 0) {
2039
- slotEl.innerHTML = ''
2040
- slottedContent.forEach(content => slotEl.appendChild(content))
2041
- }
2042
- })
2043
-
2044
- // Process default slot
2045
- const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]')
2046
- if (defaultSlot) {
2047
- const unslottedContent = this._slotContent.filter(
2048
- node => node.nodeType !== Node.ELEMENT_NODE || !node.hasAttribute('slot')
2049
- )
2050
- if (unslottedContent.length > 0) {
2051
- defaultSlot.innerHTML = ''
2052
- unslottedContent.forEach(content => defaultSlot.appendChild(content))
2053
- }
2054
- }`}
2055
- }
2056
-
2057
- ${H.length>0?`
2058
- static get observedAttributes() {
2059
- return [${H.map((G)=>`'${G}'`).join(", ")}]
2060
- }
2061
-
2062
- attributeChangedCallback(name, oldValue, newValue) {
2063
- if (oldValue !== newValue) {
2064
- this[name] = newValue
2065
- ${F?"":"if (this._initialized) this._render()"}
2066
- }
2067
- }
2068
- `:""}
2069
-
2070
- connectedCallback() {
2071
- if (this._initialized) return
2072
- ${z?"":"this._slotContent = Array.from(this.childNodes)"}
2073
- this._initialized = true
2074
- ${F?"this._createTemplate()":"this._render()"}
2075
- }
2076
-
2077
- disconnectedCallback() {
2078
- // Component removed from the DOM
2079
- }
2080
- }
2081
-
2082
- // Register the web component
2083
- customElements.define('${C}', ${k.replace(/\W/g,"")})
2084
- `}function cb(v){let{name:k,tag:C,baseElement:R="HTMLElement",source:T,shadowDOM:z,template:F,styleSource:V,attributes:H=[],attributeTypes:K={}}=v,X=k.replace(/\W/g,""),G=T.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!z)G=G.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),G=G.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),G=G.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),G=G.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");G=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${");let te=V?`<link rel="stylesheet" href="${V}">`:"",ce=(Se)=>{switch(K[Se]){case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";default:return"string"}},ee=(Se)=>Se.replace(/-([a-z])/g,(ve,De)=>De.toUpperCase()),le=H.map((Se)=>` private _${ee(Se)}: ${ce(Se)} | null = null;`).join(`
2085
- `),ue=H.map((Se)=>{let ve=ce(Se),De=ee(Se);return`
2086
- get ${De}(): ${ve} | null {
2087
- return this._${De};
2088
- }
2089
-
2090
- set ${De}(value: ${ve} | null) {
2091
- this._${De} = value;
2092
- if (value !== null) {
2093
- this.setAttribute('${Se}', String(value));
2094
- }
2095
- else {
2096
- this.removeAttribute('${Se}');
2097
- }
2098
- }`}).join(`
2099
- `),de=H.length>0?`/**
2100
- * Props interface for ${k}
2101
- */
2102
- export interface ${X}Props {
2103
- ${H.map((Se)=>{let ve=ce(Se);return` ${ee(Se)}?: ${ve};`}).join(`
2104
- `)}
2105
- }
2106
- `:"",fe=H.length>0?`
2107
- static get observedAttributes(): string[] {
2108
- return [${H.map((Se)=>`'${Se}'`).join(", ")}];
2109
- }
2110
-
2111
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
2112
- if (oldValue !== newValue) {
2113
- const camelCase = name.replace(/-([a-z])/g, (_: string, letter: string) => letter.toUpperCase());
2114
- (this as unknown as Record<string, unknown>)[\`_\${camelCase}\`] = this._parseAttributeValue(name, newValue);
2115
- ${F?"":"if (this._initialized) this._render();"}
2116
- }
2117
- }
2118
-
2119
- private _parseAttributeValue(name: string, value: string | null): unknown {
2120
- if (value === null) return null;
2121
- const typeMap: Record<string, string> = ${JSON.stringify(K)};
2122
- const type = typeMap[name] || 'string';
2123
- switch (type) {
2124
- case 'number': return Number(value);
2125
- case 'boolean': return value !== 'false' && value !== '0';
2126
- case 'object': try { return JSON.parse(value); }
2127
- catch { return value; }
2128
- default: return value;
2129
- }
2130
- }
2131
- `:"",pe=F?`
2132
- private _createTemplate(): void {
2133
- const template = document.createElement('template');
2134
- template.innerHTML = \`${te}${G}\`;
2135
- ${z?"this.shadowRoot!.appendChild(template.content.cloneNode(true));":"this.appendChild(template.content.cloneNode(true));"}
2136
- this._processSlots();
2137
- }`:`
2138
- private _render(): void {
2139
- ${z?"this.shadowRoot!.innerHTML":"this.innerHTML"} = \`${te}${G}\`;
2140
- this._processSlots();
2141
- }`;return`/**
2142
- * ${k} Web Component
2143
- * Auto-generated from stx component (TypeScript)
2144
- *
2145
- * @example
2146
- * \`\`\`html
2147
- * <${C}></${C}>
2148
- * \`\`\`
2149
- */
2150
-
2151
- /**
2152
- * Detail type for slot-changed event
2153
- */
2154
- interface SlotChangeDetail {
2155
- slotName: string;
2156
- assignedNodes: Node[];
2157
- }
2158
-
2159
- ${de}
2160
- /**
2161
- * ${k} custom element class
2162
- * @customElement ${C}
2163
- */
2164
- export class ${X} extends ${R} {
2165
- ${le}
2166
- private _initialized = false;
2167
- ${z?"":"private _slotContent: Node[] = [];"}
2168
-
2169
- constructor() {
2170
- super();
2171
- ${z?'this.attachShadow({ mode: "open" });':""}
2172
- }
2173
- ${pe}
2174
- ${z?`
2175
- private _processSlots(): void {
2176
- const slots = this.shadowRoot!.querySelectorAll('slot');
2177
- slots.forEach((slot) => {
2178
- slot.addEventListener('slotchange', () => {
2179
- const assignedNodes = (slot as HTMLSlotElement).assignedNodes();
2180
- this.dispatchEvent(new CustomEvent<SlotChangeDetail>('slot-changed', {
2181
- detail: { slotName: slot.getAttribute('name') || 'default', assignedNodes }
2182
- }));
2183
- });
2184
- });
2185
- }`:`
2186
- private _processSlots(): void {
2187
- const slots = this.querySelectorAll('[data-slot]');
2188
- slots.forEach((slotEl) => {
2189
- const slotName = slotEl.getAttribute('data-slot');
2190
- if (slotName) {
2191
- const slottedContent = this._slotContent.filter(
2192
- node => node.nodeType === Node.ELEMENT_NODE && (node as Element).getAttribute('slot') === slotName
2193
- );
2194
- if (slottedContent.length > 0) {
2195
- slotEl.innerHTML = '';
2196
- slottedContent.forEach(content => slotEl.appendChild(content));
2197
- }
2198
- }
2199
- });
2200
- const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]');
2201
- if (defaultSlot) {
2202
- const unslottedContent = this._slotContent.filter(
2203
- node => node.nodeType !== Node.ELEMENT_NODE || !(node as Element).hasAttribute('slot')
2204
- );
2205
- if (unslottedContent.length > 0) {
2206
- defaultSlot.innerHTML = '';
2207
- unslottedContent.forEach(content => defaultSlot.appendChild(content));
2208
- }
2209
- }
2210
- }`}
2211
- ${fe}
2212
- ${ue}
2213
-
2214
- connectedCallback(): void {
2215
- if (this._initialized) return;
2216
- ${z?"":"this._slotContent = Array.from(this.childNodes);"}
2217
- this._initialized = true;
2218
- ${F?"this._createTemplate();":"this._render();"}
2219
- }
2220
-
2221
- disconnectedCallback(): void {
2222
- // Component removed from the DOM
2223
- }
2224
-
2225
- adoptedCallback(): void {
2226
- // Component moved to a new document
2227
- }
2228
- }
2229
-
2230
- // Type augmentation for HTMLElementTagNameMap
2231
- declare global {
2232
- interface HTMLElementTagNameMap {
2233
- '${C}': ${X};
2234
- }
2235
- }
2236
-
2237
- // Register the web component
2238
- customElements.define('${C}', ${X});
2239
- `}function lb(v,k){let C=v.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),R=C?C[1].trim():"",T=k,z=[],F=!0;if(R){let G=R.match(/export\s+default\s+({[\s\S]*})/);if(G)try{let te=G[1],ce=te.match(/tag\s*:\s*['"`]([^'"`]+)['"`]/);if(ce)T=ce[1];let ee=te.match(/props\s*:\s*\[([\s\S]*?)\]/);if(ee)z=ee[1].split(",").map((ue)=>ue.trim().replace(/['"`]/g,"")).filter((ue)=>ue.length>0);let le=te.match(/shadowDOM\s*:\s*(true|false)/);if(le)F=le[1]==="true"}catch{}}let V=v.match(/<template\b(?![^>]*\bid\s*=)[^>]*>([\s\S]*?)<\/template>/i),H=V?V[1].trim():"",K=v.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),X=K?K[1].trim():"";return{tag:T,props:z,template:H,styles:X,script:R,shadowDOM:F}}function ub(v){let{tag:k,props:C,template:R,styles:T,shadowDOM:z}=v,F=k.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(""),V=R.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),H=T.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),K=C.map((G)=>`'${G}'`).join(", "),X=C.map((G)=>`
2240
- get ${G}() {
2241
- return this.getAttribute('${G}') || '';
2242
- }
2243
- set ${G}(value) {
2244
- if (value) {
2245
- this.setAttribute('${G}', value);
2246
- }
2247
- else {
2248
- this.removeAttribute('${G}');
2249
- }
2250
- }`).join(`
2251
- `);return`/**
2252
- * ${F} Web Component
2253
- * Auto-generated from SFC
2254
- */
2255
- class ${F} extends HTMLElement {
2256
- constructor() {
2257
- super();
2258
- ${z?"this.attachShadow({ mode: 'open' });":""}
2259
- this._render();
2260
- }
2261
-
2262
- static get observedAttributes() {
2263
- return [${K}];
2264
- }
2265
-
2266
- attributeChangedCallback(name, oldValue, newValue) {
2267
- if (oldValue !== newValue) {
2268
- this._render();
2269
- }
2270
- }
2271
- ${X}
2272
-
2273
- _render() {
2274
- const template = \`${H?`<style>${H}</style>`:""}${V}\`;
2275
-
2276
- // Interpolate {{ prop }} with attribute values
2277
- const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, prop) => {
2278
- return this.getAttribute(prop) || '';
2279
- });
2280
-
2281
- ${z?"this.shadowRoot.innerHTML = rendered;":"this.innerHTML = rendered;"}
2282
- }
2283
-
2284
- connectedCallback() {
2285
- this._render();
2286
- }
2287
- }
2288
-
2289
- customElements.define('${k}', ${F});
2290
- `}async function Mp(v,k,C,R){if(k.length<1)return i("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let T=k[0].replace(/['"]/g,""),F=(C.__stx_options||{}).componentsDir||"components",V=Nn.isAbsolute(F)?[Nn.join(F,`${T}.stx`),Nn.join(Nn.dirname(R),`${T}.stx`)]:[Nn.join(Nn.dirname(R),F,`${T}.stx`),Nn.join(process.cwd(),F,`${T}.stx`),Nn.join(Nn.dirname(R),`${T}.stx`)],H=null;for(let G of V)if(await r(G)){H=await Bun.file(G).text();break}if(!H)return i("WebComponent",`Component file not found: ${T}.stx`,t.FILE_NOT_FOUND);let K=lb(H,T);return`<script type="module">
2291
- ${ub(K)}
2292
- </script>`}var A={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:zt,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:yp,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Mp,hasEndTag:!1,description:"Include a web component in the template"},zi,Hi,wr,xr,sp,op,ap,ip,gp,rp,Ep,Dl,...Nr],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function fb(v,k,C){let R=k||"pages";if(v)return{root:v,pagesDir:R};let T=C||process.cwd(),z=un.join(T,"resources","views"),F=un.join(T,"resources","layouts");if(hs.existsSync(z)&&hs.existsSync(F))return{root:"resources",pagesDir:"views"};let V=un.join(T,"resources","views","pages");if(hs.existsSync(V))return{root:"resources/views",pagesDir:R};return{root:".",pagesDir:R}}var Np=new Set,Ta=["partialsDir","componentsDir","layoutsDir"],Ol=new WeakMap;function pb(v,k){let C=k.replace(/[\\/]+$/,"");if(!C||C===".")return!0;let R=v.replace(/\\/g,"/"),T=C.replace(/\\/g,"/");return R===T||R.startsWith(`${T}/`)}function ol(v,k){let C=!v.root,R=fb(v.root,v.pagesDir,k);if(v.root=R.root,v.pagesDir=R.pagesDir,C&&R.root!=="."){let T=`${k}::${R.root}`;if(!Np.has(T))Np.add(T),console.warn(`[stx] No "root" in config \u2014 inferred "${R.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Ol.has(v)){let T={};for(let z of Ta){let F=v[z];if(typeof F==="string"&&F)T[z]=F}Ol.set(v,T)}if(v.root&&v.root!=="."){let T=v.root;for(let z of Ta){let F=v[z];if(typeof F!=="string"||!F)continue;if(un.isAbsolute(F)||pb(F,T))continue;v[z]=un.join(T,F)}}for(let T of Ta){let z=v[T];if(typeof z!=="string"||!z||un.isAbsolute(z))continue;v[T]=un.resolve(k,z)}return v}function gb(v,k){let C=Ol.get(v);for(let R of Ta){let T=v[R];if(typeof T!=="string"||!T)continue;let z=un.isAbsolute(T)?T:un.join(k,T);if(hs.existsSync(z))continue;let F=C?.[R]??T,V=v.root,H=!!V&&V!==".";console.warn(`[stx] ${String(R)} resolves to "${z}", which does not exist. Configured as "${F}"`+(H?`, resolved under root "${V}".`:"."))}}function mb(v){if(v.customDirectives)v.customDirectives=[...v.customDirectives];if(v.middleware)v.middleware=[...v.middleware];if(v.apiRoutes)v.apiRoutes={...v.apiRoutes}}function hb(v){if(Gi(v.stateDir),v.stateDir=Tn(),v.cachePath=$n(v.cachePath),v.build)v.build.cacheDir=$n(v.build.cacheDir);if(v.media?.cache)v.media.cache.directory=$n(v.media.cache.directory);if(v.story)v.story.outDir=$n(v.story.outDir)}var Dr=null,Jr=new Map,Aa=new Map,ho=null;async function Vs(v,k=db){try{return await k(v)}catch(C){if(C instanceof Error&&C.name==="ConfigNotFoundError")return{config:v.defaultConfig};throw C}}async function o(v){let k=v?un.resolve(v):process.cwd(),C=Aa.get(k);if(C&&C.signature!==yr(C.graph)){let z=Jr.get(k);if(Jr.delete(k),Aa.delete(k),!v)Dr=null,ho=null;let{clearComponentCache:F}=await import("./chunk-9z4qr5w9.js"),{partialsCache:V}=await import("./chunk-qhjm9hvz.js");if(F(),V.clear(),z&&C.configSignature===br(C.graph)){let H=z.then(async(K)=>{let X={...C.graph};await Ws(X,k),Aa.set(k,{graph:X,signature:yr(X),configSignature:br(X)});let G={...K,_layerGraph:X};if(!v)Dr=G;return G});return Jr.set(k,H),H}}if(!v){if(Dr)return Dr;if(ho)return ho}let R=Jr.get(k);if(R)return R;let T=(async()=>{let z=[".ts",".js",".mjs",".cjs",".json"],F=z.some((te)=>hs.existsSync(un.join(k,`stx.config${te}`))),V=z.some((te)=>hs.existsSync(un.join(k,"config",`ui${te}`))),H;if(F&&V){let te=await Vs({name:"ui",cwd:un.join(k,"config"),defaultConfig:A,errorPolicy:"throw",verbose:!1});H=(await Vs({name:"stx",alias:"ui",cwd:k,defaultConfig:te.config,errorPolicy:"throw",verbose:!1})).config}else H=(await Vs({name:"stx",alias:"ui",cwd:k,defaultConfig:A,errorPolicy:"throw",verbose:!1})).config;if(H.extends!==void 0||C){let te=await Wi(k,A);H=te.config,Aa.set(k,{graph:te.graph,signature:yr(te.graph),configSignature:br(te.graph)})}if(H.runtimeConfig){let{resolveRuntimeConfig:te}=await import("./chunk-n3s3w1f5.js");te(H.runtimeConfig,{});let{generateRuntimeConfigTypes:ce}=await import("./chunk-zr0k9pz5.js");await ce(k,H.runtimeConfig)}mb(H),hb(H),ol(H,k),gb(H,k);let K=[],X=new Set((H.plugins??[]).map((te)=>typeof te==="string"?te:te[0]));for(let te of H.componentPackages??["@stacksjs/components"]){let ce=`${te}/stx-plugin`;if(X.has(ce)||X.has(te))continue;try{d.resolve(ce,{paths:[k]}),K.push(ce)}catch{}}let G=[...H.plugins??[],...K];if(G.length>0){let{pluginManager:te}=await import("./chunk-7s5304ae.js"),ce=[],ee=[];for(let le of G){let ue=typeof le==="string"?le:le[0],de=typeof le==="string"?{}:le[1]||{};try{let fe,pe;try{let Se=d.resolve(ue,{paths:[k]});fe=await import(Se),pe=un.dirname(Se)}catch{let Se=un.resolve(k,ue);fe=await import(Se),pe=un.dirname(Se)}let Ae=fe.default||fe;if(!te.has(Ae.name))await te.register(Ae,H);if(Ae.components){let Se=Array.isArray(Ae.components)?Ae.components:[Ae.components];for(let ve of Se)ce.push(un.resolve(pe,ve))}if(Ae.pages){let Se=un.resolve(pe,Ae.pages),ve=de.path||"/";ee.push({dir:Se,prefix:ve})}if(Ae.setup){let Se={addDirective:(ve)=>{H.customDirectives=H.customDirectives||[],H.customDirectives.push(ve)},addRoute:(ve,De)=>{H.apiRoutes=H.apiRoutes||{},H.apiRoutes[ve]=De},addMiddleware:(ve)=>{H.middleware=H.middleware||[],H.middleware.push(ve)},pluginDir:pe,config:H};await Ae.setup(de,Se)}process.stderr.write(`[stx] Plugin loaded: ${Ae.name||ue}
2293
- `)}catch(fe){console.warn(`[stx] Failed to load plugin ${ue}:`,fe.message)}}H._pluginComponentDirs=ce,H._pluginPageDirs=ee}return H})();if(Jr.set(k,T),T.catch(()=>{if(Jr.get(k)===T)Jr.delete(k)}),!v)ho=T,T.then((z)=>{Dr=z}).catch(()=>{});return T}var P=new Proxy(A,{get(v,k){if(Dr&&k in Dr)return Dr[k];if(!ho)o().catch((C)=>{console.warn("[stx] Failed to load config file:",C?.message||C)});return v[k]}});function Sd(v){return v}function kd(v){let k=[],C=[];if(v.partialsDir!==void 0&&typeof v.partialsDir!=="string")k.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(v.componentsDir!==void 0&&typeof v.componentsDir!=="string")k.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(v.cache!==void 0&&typeof v.cache!=="boolean")k.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(v.debug!==void 0&&typeof v.debug!=="boolean")k.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(v.streaming){if(v.streaming.bufferSize!==void 0){if(typeof v.streaming.bufferSize!=="number"||v.streaming.bufferSize<=0)k.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(v.streaming.timeout!==void 0){if(typeof v.streaming.timeout!=="number"||v.streaming.timeout<=0)k.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(v.streaming.strategy!==void 0){let R=["auto","manual","sections"];if(!R.includes(v.streaming.strategy))k.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.i18n){if(v.i18n.format!==void 0){let R=["json","yaml","yml","js"];if(!R.includes(v.i18n.format))k.push({path:"i18n.format",message:`i18n.format must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.animation){if(v.animation.defaultDuration!==void 0){if(typeof v.animation.defaultDuration!=="number"||v.animation.defaultDuration<0)k.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(v.animation.staggerDelay!==void 0){if(typeof v.animation.staggerDelay!=="number"||v.animation.staggerDelay<0)k.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(v.a11y){if(v.a11y.level!==void 0){let R=["AA","AAA"];if(!R.includes(v.a11y.level))k.push({path:"a11y.level",message:`a11y.level must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.hydration){if(v.hydration.mode!==void 0){let R=["progressive","islands"];if(!R.includes(v.hydration.mode))k.push({path:"hydration.mode",message:`hydration.mode must be one of: ${R.join(", ")}`,severity:"error"})}if(v.hydration.preload!==void 0){let R=["none","eager","lazy"];if(!R.includes(v.hydration.preload))k.push({path:"hydration.preload",message:`hydration.preload must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.customDirectives)if(!Array.isArray(v.customDirectives))k.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else v.customDirectives.forEach((R,T)=>{if(!R.name||typeof R.name!=="string")k.push({path:`customDirectives[${T}].name`,message:"Custom directive must have a name string",severity:"error"});if(!R.handler||typeof R.handler!=="function")k.push({path:`customDirectives[${T}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(v.middleware)if(!Array.isArray(v.middleware))k.push({path:"middleware",message:"middleware must be an array",severity:"error"});else v.middleware.forEach((R,T)=>{if(!R.name||typeof R.name!=="string")k.push({path:`middleware[${T}].name`,message:"Middleware must have a name string",severity:"error"});if(!R.handler||typeof R.handler!=="function")k.push({path:`middleware[${T}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!R.timing||!["before","after"].includes(R.timing))k.push({path:`middleware[${T}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(v.debug===!0&&v.cache===!0)C.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(v.seo?.enabled===!0&&!v.seo?.defaultConfig?.title)C.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(v.pwa){if(v.pwa.enabled===!0&&!v.pwa.manifest?.name)k.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(v.pwa.manifest?.display!==void 0){let R=["fullscreen","standalone","minimal-ui","browser"];if(!R.includes(v.pwa.manifest.display))k.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${R.join(", ")}`,severity:"error"})}if(v.pwa.manifest?.orientation!==void 0){let R=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!R.includes(v.pwa.manifest.orientation))k.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${R.join(", ")}`,severity:"error"})}if(v.pwa.routes){let R=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];v.pwa.routes.forEach((T,z)=>{if(!T.pattern||typeof T.pattern!=="string")k.push({path:`pwa.routes[${z}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!R.includes(T.strategy))k.push({path:`pwa.routes[${z}].strategy`,message:`PWA route strategy must be one of: ${R.join(", ")}`,severity:"error"});if(T.maxAgeSeconds!==void 0&&(typeof T.maxAgeSeconds!=="number"||T.maxAgeSeconds<0))k.push({path:`pwa.routes[${z}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(T.maxEntries!==void 0&&(typeof T.maxEntries!=="number"||T.maxEntries<1))k.push({path:`pwa.routes[${z}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(v.pwa.icons?.sizes){if(!Array.isArray(v.pwa.icons.sizes))k.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(v.pwa.icons.sizes.filter((T)=>typeof T!=="number"||T<16||T>1024).length>0)k.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(v.pwa.icons?.purpose){let R=["any","maskable","monochrome"];if(v.pwa.icons.purpose.filter((z)=>!R.includes(z)).length>0)k.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${R.join(", ")}`,severity:"error"})}if(v.pwa.enabled===!0&&!v.pwa.icons?.src)C.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(v.pwa.enabled===!0&&!v.pwa.manifest?.themeColor)C.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:k.length===0,errors:k,warnings:C}}var Nl=new Map;async function ye(v,k={}){try{if(!await r(v))throw Error(`Markdown file not found: ${v}`);let R=(await yb.promises.stat(v)).mtime.getTime();if(k.cache&&Nl.has(v)){let G=Nl.get(v);if(G.updatedAt>=R)return{content:G.content,data:G.data}}let T=await Bun.file(v).text(),{data:z,content:F}=sr(T),V=k.markdown||P.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},K=qe(F,{gfm:!0});if(V.syntaxHighlighting?.enabled&&V.syntaxHighlighting?.serverSide)K=await bb(K,V.syntaxHighlighting?.defaultTheme||"github-dark",V.syntaxHighlighting?.highlightUnknownLanguages||!1);let X={content:K,data:z||{}};if(k.cache)Nl.set(v,{...X,updatedAt:R});return X}catch(C){if(k.debug)console.error(`Error reading/parsing markdown file ${v}:`,C);let R=C instanceof Error?C.message:String(C);return{content:g("Markdown File",`Error reading/parsing markdown file: ${R}`,v,"",0,""),data:{}}}}var Ia=null;async function bb(v,k,C){let R=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Ia)try{Ia=await xb({theme:k||"github-dark",cache:!0})}catch(V){return console.error("Failed to initialize ts-syntax-highlighter:",V),v}let T=async(V,H,K,X)=>{let G=X.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),te=K||(C?"text":"");if(!te)return V;try{if(!Ia.getSupportedLanguages().includes(te))return V;return(await Ia.highlight(G,te,{theme:k})).html}catch(ce){console.error(`Error highlighting code block with language ${K}:`,ce)}return V},z=v,F=v.matchAll(R);for(let V of F){let[H,K,X,G]=V,te=await T(H,K,X,G);z=z.replace(H,te)}return z}async function jp(v,k,C="",R={}){return await vb(v,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(F,V,H,K)=>{try{let X=V;if(!Ml.isAbsolute(V))X=Ml.resolve(Ml.dirname(C),V);let G={};if(H)try{try{G=JSON.parse(H)}catch{if(R.debug)console.warn("Using safer alternative for parsing JS object literal");let fe=H.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let pe of fe){let Ae=pe.indexOf(":");if(Ae>0){let Se=pe.substring(0,Ae).trim(),ve=pe.substring(Ae+1).trim(),De=ve.startsWith('"')&&ve.endsWith('"'),Me=ve.startsWith("'")&&ve.endsWith("'");if(De||Me)ve=ve.substring(1,ve.length-1);G[Se]=ve}}}}catch(de){if(R.debug)console.error("Error parsing context in @markdown-file directive:",de)}let{content:te,data:ce}=await ye(X,R),ee={...k,...ce,...G},le=te,ue=/\{\{([^}]+)\}\}/g;return le=le.replace(ue,(de,fe)=>{let pe=fe.trim();return ee[pe]!==void 0?String(ee[pe]):de}),le}catch(X){let G=X instanceof Error?X.message:String(X);return g("Markdown File",`Error including markdown file: ${G}`,C,v,K,F)}})}async function vb(v,k,C){let R=[],T;while((T=k.exec(v))!==null){let V=T[0],H=T.index,K=T;R.push(C(...K).then((X)=>({match:V,replacement:X,index:H})))}let z=await Promise.all(R);z.sort((V,H)=>H.index-V.index);let F=v;for(let{match:V,replacement:H}of z)F=F.replace(V,()=>H);return F}function Mr(v,k){try{let C=v.trim();if(p(C))return c(C,Object.keys(k))(...Object.values(k));else return l(C,k)}catch{return!1}}function jr(v,k){let C=wb(v,k);return C.ok?{expression:C.expression,endPos:C.endPos}:null}function wb(v,k){let C=k;while(C<v.length&&/\s/.test(v[C]))C++;if(v[C]!=="(")return{ok:!1,reason:"missing-open-paren",pos:C};let R=S(v,"(",")",C);if(R===-1)return{ok:!1,reason:"unclosed-paren",pos:C};return{ok:!0,expression:v.slice(C+1,R),endPos:R+1}}function Sb(v,k){let C=v.lastIndexOf("<",k);if(C===-1)return!1;return C>v.lastIndexOf(">",k)}function Yr(v,k,C,R){let T=1,z=R,F=new RegExp(`@${k}\\s*\\(`,"g"),V=new RegExp(`@${C}(?![a-z])`,"g");while(z<v.length&&T>0){F.lastIndex=z,V.lastIndex=z;let H=F.exec(v),K=V.exec(v),X=H?H.index:1/0,G=K?K.index:1/0;if(X<G)T++,z=X+H[0].length;else if(G<1/0){if(T--,T===0)return G;z=G+K[0].length}else break}return-1}function Lp(v,k){let C=v.slice(k).match(/^@if\s*/);if(!C)return null;let R=k+C[0].length,T=jr(v,R);if(!T)return null;let z=T.endPos,F=Yr(v,"if","endif",z);if(F===-1)return null;let V=v.slice(z,F),H=[],K=0,X="if",G=T.expression,te=0,ce=0;while(K<V.length){let ee=V.indexOf("@",K);if(ee===-1)break;K=ee;let le=V.substring(ee);if(Sb(V,ee)){K++;continue}if(/^@if\s*\(/.test(le)){ce++,K++;continue}if(/^@endif(?![a-z])/.test(le)){ce--,K+=6;continue}if(ce===0){let ue=le.match(/^@elseif\s*/);if(ue){H.push({type:X,condition:G,content:V.substring(te,K),start:z+te,end:z+K});let de=K+ue[0].length,fe=jr(V,de);if(!fe){K++;continue}X="elseif",G=fe.expression,K=fe.endPos,te=K;continue}else if(/^@else(?![a-z])/.test(le)){H.push({type:X,condition:G,content:V.substring(te,K),start:z+te,end:z+K}),X="else",G=void 0,K+=5,te=K;continue}}K++}return H.push({type:X,condition:G,content:V.slice(te),start:z+te,end:z+V.length}),{fullMatch:v.slice(k,F+6),branches:H,start:k,end:F+6}}function yo(v){let k=[],C=/@if\s*\(/g,R=C.exec(v);while(R!==null){if(k.some((F)=>R.index>F.start&&R.index<F.end)){R=C.exec(v);continue}let z=Lp(v,R.index);if(z)k.push(z),C.lastIndex=z.end;R=C.exec(v)}return k}function Pa(v,k,C){let R=[],T=new RegExp(`@${k}\\s*\\(`,"g"),z=T.exec(v);while(z!==null){if(R.some((le)=>z.index>le.start&&z.index<le.end)){z=T.exec(v);continue}let V=z.index,H=V+z[0].length-1,K=S(v,"(",")",H);if(K===-1){z=T.exec(v);continue}let X=v.slice(H+1,K),G=K+1,te=Yr(v,k,C,G);if(te===-1){z=T.exec(v);continue}let ce=v.slice(G,te),ee=te+`@${C}`.length;R.push({fullMatch:v.slice(V,ee),name:k,params:X,content:ce,start:V,end:ee}),T.lastIndex=ee,z=T.exec(v)}return R}function jl(v,k){let C=v.slice(k).match(/^@switch\s*/);if(!C)return null;let R=k+C[0].length,T=jr(v,R);if(!T)return null;let z=T.endPos,F=Yr(v,"switch","endswitch",z);if(F===-1)return null;let V=v.slice(z,F),H=[],K=0,X=null,G=0;while(K<V.length){let te=V.slice(K),ce=te.match(/^@switch\s*\(/),ee=te.match(/^@endswitch(?![a-z])/);if(ce){if(G++,X)X.content+=ce[0];K+=ce[0].length;continue}if(ee){if(G--,X)X.content+=ee[0];K+=ee[0].length;continue}if(G>0){if(X)X.content+=V[K];K++;continue}let le=te.match(/^@case\s*/),ue=te.match(/^@default(?![a-z])/),de=te.match(/^@break(?![a-z])/);if(le&&te.startsWith("@case")){if(X)H.push(X);let fe=K+le[0].length,pe=jr(V,fe);if(!pe){K++;continue}X={type:"case",value:pe.expression,content:""},K=pe.endPos}else if(ue&&te.startsWith("@default")){if(X)H.push(X);X={type:"default",content:""},K+=ue[0].length}else if(de&&te.startsWith("@break"))K+=de[0].length;else{if(X)X.content+=V[K];K++}}if(X)H.push(X);return{fullMatch:v.slice(k,F+10),expression:T.expression,cases:H,start:k,end:F+10}}function Eb(v,k,C){let R=v,T=!0;while(T){T=!1;let z=R.match(/@switch\s*\(/);if(!z||z.index===void 0)break;let F=z.index,V=jl(R,F);if(!V)break;try{let H;if(p(V.expression))H=c(V.expression,Object.keys(k))(...Object.values(k));else H=l(V.expression,k);let K="",X=!1;for(let G of V.cases)if(G.type==="default"){if(!X)K=G.content.trim()}else try{let te;if(G.value&&p(G.value))te=c(G.value,Object.keys(k))(...Object.values(k));else if(G.value)te=l(G.value,k);if(H===te){K=G.content.trim(),X=!0;break}}catch{continue}R=R.substring(0,F)+K+R.substring(V.end),T=!0}catch(H){let K=H instanceof Error?H.message:String(H),X=i("Switch",`Error evaluating @switch expression: ${K}`,t.EVALUATION_ERROR);R=R.substring(0,F)+X+R.substring(V.end);break}}return R}function Cb(v){let k=[];return{masked:v.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(R)=>(k.push(R),`\x00stx-script-${k.length-1}\x00`)),scripts:k}}function Rb(v,k){if(k.length===0)return v;return v.replace(/\u0000stx-script-(\d+)\u0000/g,(C,R)=>k[Number(R)]??C)}function rr(v,k,C){let{masked:R,scripts:T}=Cb(v);return Rb(Ab(R,k,C),T)}function Ab(v,k,C){let R=v;R=Eb(R,k,C);{let z=!0;while(z){z=!1;let F=R.match(/@unless\s*\(/);if(!F||F.index===void 0)break;let V=F.index,H=jr(R,V+7);if(!H)break;let K=H.endPos,X=Yr(R,"unless","endunless",K);if(X===-1){console.warn(`[stx] @unless directive at position ${V} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let G=R.slice(K,X),te=H.expression,ce=-1;{let le=0,ue=/@(?:if|unless)\s*\(/g,de=/@(?:endif|endunless)(?![a-z])/g,fe=/@else(?![a-z])/g,pe=[],Ae;while((Ae=ue.exec(G))!==null)pe.push({pos:Ae.index,type:"open"});while((Ae=de.exec(G))!==null)pe.push({pos:Ae.index,type:"close"});while((Ae=fe.exec(G))!==null)pe.push({pos:Ae.index,type:"else"});pe.sort((Se,ve)=>Se.pos-ve.pos);for(let Se of pe)if(Se.type==="open")le++;else if(Se.type==="close")le--;else if(Se.type==="else"&&le===0){ce=Se.pos;break}}let ee;if(ce!==-1){let le=G.slice(0,ce),ue=G.slice(ce+5);ee=`@if (${te})${ue}@else ${le}@endif`}else ee=`@if (!(${te}))${G}@endif`;R=R.substring(0,V)+ee+R.substring(X+10),z=!0}}R=Bl(R,k,C),R=zl(R,k,C),R=Ll(R,k);let T=()=>{let z=yo(R);if(z.length===0)return!1;let F=Array(z.length);for(let K=z.length-1;K>=0;K--){let X=z[K];try{let G="",te=!1;for(let ce of X.branches){if(te)break;if(ce.type==="else")G=ce.content,te=!0;else try{if(ce.condition?ea(ce.condition,k):!1)G=ce.content,te=!0}catch(ee){G=i(ce.type==="if"?"If":"Elseif",`Error in @${ce.type}(${ce.condition}): ${ee instanceof Error?ee.message:String(ee)}`,t.EVALUATION_ERROR),te=!0}}F[K]=G}catch(G){let te=G instanceof Error?G.message:String(G);F[K]=i("If",`Error processing @if block: ${te}`,t.EVALUATION_ERROR)}}let V=Array(z.length*2+1),H=0;for(let K=0;K<z.length;K++){let X=z[K];V[K*2]=R.slice(H,X.start),V[K*2+1]=F[K],H=X.end}return V[z.length*2]=R.slice(H),R=V.join(""),!0};while(!0){let z=R;if(!T())break;if(R===z)break}return R}function Bp(v){let k=0;while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!=="(")return null;k++;while(k<v.length&&/\s/.test(v[k]))k++;let C=v[k];if(C!=="'"&&C!=='"')return null;k++;let R=[];while(k<v.length){let T=v[k];if(T==="\\"&&k+1<v.length){R.push(v[k+1]),k+=2;continue}if(T===C){k++;break}R.push(T),k++}while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!==")")return null;return k++,{value:R.join(""),consumed:k}}function Ll(v,k){let C=v;function R(V,H,K,X){let G=1,te=X,ce=new RegExp(`@${H}(?:\\s*\\(|\\s|$)`,"g"),ee=new RegExp(`@${K}(?![a-z])`,"g");while(te<V.length&&G>0){ce.lastIndex=te,ee.lastIndex=te;let le=ce.exec(V),ue=ee.exec(V),de=le?le.index:1/0,fe=ue?ue.index:1/0;if(de<fe)G++,te=de+le[0].length;else if(fe<1/0){if(G--,G===0)return fe;te=fe+ue[0].length}else break}return-1}function T(V,H,K){let X=0,G=new RegExp(`@${H}(?:\\s*\\(|\\s|$)`,"g"),te=new RegExp(`@${K}(?![a-z])`,"g"),ce=/@else(?![a-z])/g,ee=[],le;while((le=G.exec(V))!==null)ee.push({pos:le.index,type:"open"});while((le=te.exec(V))!==null)ee.push({pos:le.index,type:"close"});while((le=ce.exec(V))!==null)ee.push({pos:le.index,type:"else"});ee.sort((ue,de)=>ue.pos-de.pos);for(let ue of ee)if(ue.type==="open")X++;else if(ue.type==="close")X--;else if(ue.type==="else"&&X===0)return ue.pos;return-1}{let V=!0;while(V){V=!1;let H=C.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!H||H.index===void 0)break;let K=H.index,X,G,te=C.slice(K+5),ce=Bp(te);if(ce)X=ce.value,G=K+5+ce.consumed;else G=K+5;let ee=R(C,"auth","endauth",G);if(ee===-1){console.warn(`[stx] @auth directive at position ${K} has no matching @endauth \u2014 the block was skipped.`);break}let le=C.slice(G,ee),ue=T(le,"auth","endauth"),de;if(!k.auth)de=!1;else de=X?Mr(`auth?.check && auth?.user?.[${X}]`,k):Mr("auth?.check",k);let fe;if(ue!==-1){let pe=le.slice(0,ue),Ae=le.slice(ue+5);fe=de?pe:Ae}else fe=de?le:"";C=C.substring(0,K)+fe+C.substring(ee+8),V=!0}}{let V=!0;while(V){V=!1;let H=C.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!H||H.index===void 0)break;let K=H.index,X,G,te=C.slice(K+6),ce=Bp(te);if(ce)X=ce.value,G=K+6+ce.consumed;else G=K+6;let ee=R(C,"guest","endguest",G);if(ee===-1){console.warn(`[stx] @guest directive at position ${K} has no matching @endguest \u2014 the block was skipped.`);break}let le=C.slice(G,ee),ue=T(le,"guest","endguest"),de;if(!k.auth)de=!0;else de=X?Mr(`!auth?.check || !auth?.user?.[${X}]`,k):Mr("!auth?.check",k);let fe;if(ue!==-1){let pe=le.slice(0,ue),Ae=le.slice(ue+5);fe=de?pe:Ae}else fe=de?le:"";C=C.substring(0,K)+fe+C.substring(ee+9),V=!0}}function z(V,H,K){if(k.userCan&&typeof k.userCan[V]==="boolean")return k.userCan[V];if(k.permissions?.check&&typeof k.permissions.check==="function")try{let X=[V];if(H)X.push(H);if(K){let G=Mr(K,k);X.push(G)}return k.permissions.check(...X)}catch{return!1}return!1}function F(V){let H=V.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!H)return null;return{ability:H[1],type:H[2],id:H[3]?.trim(),paramsEnd:H[0].length}}for(let V of["can","cannot"]){let H=`end${V}`,K=V==="can"?"elsecan":"elsecannot",X=!0;while(X){X=!1;let G=C.match(new RegExp(`@${V}\\s*\\(`));if(!G||G.index===void 0)break;let te=G.index,ce=C.slice(te+`@${V}`.length),ee=F(ce);if(!ee)break;let le=te+`@${V}`.length+ee.paramsEnd,ue=R(C,V,H,le);if(ue===-1){console.warn(`[stx] @${V} directive at position ${te} has no matching @${H} \u2014 the block was skipped.`);break}let de=C.slice(le,ue),fe=[],pe=0,Ae=new RegExp(`@${V}\\s*\\(`,"g"),Se=new RegExp(`@${H}(?![a-z])`,"g"),ve=new RegExp(`@${K}\\s*\\(`,"g"),De=/@else(?![a-z])/g,Me=[],je;while((je=Ae.exec(de))!==null)Me.push({pos:je.index,type:"open"});while((je=Se.exec(de))!==null)Me.push({pos:je.index,type:"close"});while((je=ve.exec(de))!==null)Me.push({pos:je.index,type:"elseDirective"});while((je=De.exec(de))!==null)Me.push({pos:je.index,type:"else"});Me.sort((Ve,ze)=>Ve.pos-ze.pos);for(let Ve of Me){if(Ve.type==="open"){pe++;continue}if(Ve.type==="close"){pe--;continue}if(pe===0)fe.push(Ve)}let Le=[],Be=0;for(let Ve=0;Ve<fe.length;Ve++){let ze=fe[Ve];if(Le.push({content:de.slice(Be,ze.pos),ability:void 0}),ze.type==="elseDirective"){let at=de.slice(ze.pos+`@${K}`.length),St=F(at);if(St){Le[Le.length-1]={content:de.slice(Be,ze.pos)},Be=ze.pos+`@${K}`.length+St.paramsEnd,Le.push({content:"",ability:St.ability,type:St.type,id:St.id}),Le.pop();let bt=fe[Ve+1],Tt=bt?bt.pos:de.length;Le.push({content:de.slice(Be,Tt),ability:St.ability,type:St.type,id:St.id}),Be=Tt}}else Be=ze.pos+5}if(Be<de.length){let Ve=Le[Le.length-1];if(fe.length>0&&fe[fe.length-1].type==="else")Le.push({content:de.slice(Be),isFinalElse:!0});else if(Le.length===0)Le.push({content:de.slice(Be)})}let Oe=z(ee.ability,ee.type,ee.id),We=V==="can"?Oe:!Oe,Fe="";if(We)Fe=Le[0]?.content||"";else{let Ve=!1;for(let ze=1;ze<Le.length;ze++){let at=Le[ze];if(at.isFinalElse){Fe=at.content,Ve=!0;break}if(at.ability){let St=z(at.ability,at.type,at.id);if(V==="can"?St:!St){Fe=at.content,Ve=!0;break}}}if(!Ve&&Le.length>0){let ze=Le[Le.length-1];if(ze.isFinalElse)Fe=ze.content}}C=C.substring(0,te)+Fe+C.substring(ue+`@${H}`.length),X=!0}}return C}function Bl(v,k,C){let R=v;function T(z,F,V,H,K){let X=!0;while(X){X=!1;let G=new RegExp(`@${F}\\s*\\(`),te=z.match(G);if(!te||te.index===void 0)break;let ce=te.index,ee=jr(z,ce+`@${F}`.length);if(!ee)break;let le=ee.endPos,ue=Yr(z,F,V,le);if(ue===-1){console.warn(`[stx] @${F} directive at position ${ce} has no matching @${V} \u2014 the block was skipped.`);break}let de=z.slice(le,ue),fe=ee.expression,pe=-1,Ae=0,Se=0;while(Se<de.length){let ve=de.indexOf("@",Se);if(ve===-1)break;let De=de.substring(ve);if(/^@(?:if|unless|isset|empty)\s*\(/.test(De)){Ae++,Se=ve+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(De)){Ae--,Se=ve+1;continue}if(Ae===0&&/^@else(?![a-z])/.test(De)){pe=ve;break}Se=ve+1}try{let ve=H(fe.trim()),De;if(pe!==-1){let Me=de.slice(0,pe),je=de.slice(pe+5);De=ve?Me:je}else De=ve?de:"";z=z.substring(0,ce)+De+z.substring(ue+`@${V}`.length),X=!0}catch(ve){let De=ve instanceof Error?ve.message:String(ve),Me=i(K,`Error processing @${F} directive: ${De}`,t.EVALUATION_ERROR);z=z.substring(0,ce)+Me+z.substring(ue+`@${V}`.length);break}}return z}return R=T(R,"isset","endisset",(z)=>{let F=Mr(z,k);return F!==void 0&&F!==null},"Isset"),R=T(R,"empty","endempty",(z)=>{let F=Mr(z,k);return F===void 0||F===null||F===""||F===0||F===!1||Array.isArray(F)&&F.length===0||typeof F==="object"&&F!==null&&Object.keys(F).length===0},"Empty"),R}function zl(v,k,C){let R=v,T="development";function z(F,V,H,K){let X=new RegExp(`@${V}(?![a-z])`,"g"),G=new RegExp(`@${H}(?![a-z])`,"g"),te=new RegExp(`^@${V}(?![a-z])`),ce=new RegExp(`^@${H}(?![a-z])`),ee=F,le=!0;while(le){le=!1,X.lastIndex=0;let ue=X.exec(ee);if(!ue)break;let de=ue.index,fe=de+ue[0].length;if(V==="env"){let Oe=ee.substring(fe).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!Oe)break;fe+=Oe[0].length,K=T===Oe[2]}let pe=1,Ae=fe,Se=-1;while(pe>0&&Ae<ee.length){X.lastIndex=Ae,G.lastIndex=Ae;let Oe=X.exec(ee),We=G.exec(ee),Fe=Oe?Oe.index:1/0,Ve=We?We.index:1/0;if(Fe<Ve)pe++,Ae=Fe+Oe[0].length;else if(Ve<1/0){if(pe--,pe===0){Se=Ve;break}Ae=Ve+We[0].length}else break}if(Se===-1){console.warn(`[stx] @${V} directive at position ${de} has no matching @${H} \u2014 the block was skipped.`);break}let ve=ee.substring(fe,Se),De=-1,Me=0,je=0;while(je<ve.length){let Oe=ve.indexOf("@",je);if(Oe===-1)break;let We=ve.substring(Oe);if(te.test(We)){Me++,je=Oe+1;continue}if(ce.test(We)){Me--,je=Oe+1;continue}if(Me===0&&/^@else(?![a-z])/.test(We)){De=Oe;break}je=Oe+1}let Le;if(De!==-1){let Oe=ve.slice(0,De),We=ve.slice(De+5);Le=K?Oe:We}else Le=K?ve:"";let Be=`@${H}`.length;ee=ee.substring(0,de)+Le+ee.substring(Se+Be),le=!0}return ee}return R=z(R,"env","endenv",!1),R=z(R,"production","endproduction",T==="production"),R=z(R,"development","enddevelopment",T==="development"),R=z(R,"staging","endstaging",T==="staging"),R=z(R,"testing","endtesting",T==="testing"),R}var zp=new WeakMap;function Wp(v=16){let k=new Uint8Array(v);return crypto.getRandomValues(k),btoa(String.fromCharCode(...k))}function Da(v,k){if(!v)return k?.nonceGenerator?.()??Wp();let C=zp.get(v);if(!C)C=k?.nonceGenerator?.()??Wp(),zp.set(v,C);return C}function Tb(v,k){let C=[];for(let[R,T]of Object.entries(v)){if(T===void 0||T===null)continue;if(typeof T==="boolean"){if(T)C.push(R);continue}if(Array.isArray(T)){let z=[...T];if(k&&(R==="script-src"||R==="style-src"))z=z.filter((F)=>!F.startsWith("'nonce-")),z.push(`'nonce-${k}'`);if(z.length>0)C.push(`${R} ${z.join(" ")}`)}}return C.join("; ")}function Fp(v,k){return`<meta http-equiv="Content-Security-Policy" content="${Tb(v,k).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Vp(v,k,C){if(!k.enabled||!k.addMetaTag)return v;if(v.includes('http-equiv="Content-Security-Policy"'))return v;if(!v.includes("<head>")&&!v.includes("<head "))return v;let R=k.useNonce?Da(C,k):void 0,T=Fp(k.directives,R);return v.replace(/<head([^>]*)>/,`<head$1>
2294
- ${T}`)}function Up(v,k){let C=v;return C=C.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(R,T)=>{if(T.includes("nonce="))return R;return`<script nonce="${k}"${T}>`}),C=C.replace(/<style([^>]*)>/gi,(R,T)=>{if(T.includes("nonce="))return R;return`<style nonce="${k}"${T}>`}),C}function Hp(v,k,C,R){let T=v,z=R.csp;if(T=T.replace(/@csp\b/g,()=>{if(!z?.enabled||!z.directives)return"<!-- CSP not configured -->";let F=z.useNonce?Da(k,z):void 0;return Fp(z.directives,F)}),T=T.replace(/@cspNonce\b/g,()=>{if(!z?.enabled||!z.useNonce)return"";return Da(k,z)}),z?.enabled&&z.useNonce)k.cspNonce=Da(k,z);return T}import Ib from"crypto";var Pb=40,qp="_token",Wl=null;function Db(v=Pb){let k=Ib.randomBytes(Math.ceil(v/2)).toString("hex").slice(0,v);return Wl=k,k}function Ob(){if(!Wl)Db();return Wl}function Mb(v=qp){let k=Ob();return`<input type="hidden" name="${v}" value="${k}">`}function Kp(v){return v.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(k,C,R)=>Mb(R||qp))}async function Xp(v,k,C,R){if(!R.customDirectives||R.customDirectives.length===0)return v;let T=v;for(let z of R.customDirectives){if(!z.name||typeof z.handler!=="function"){if(R.debug)console.warn("Invalid custom directive:",z);continue}if(z.hasEndTag)T=await Nb(T,z,k,C,R);else T=await jb(T,z,k,C,R)}return T}async function Nb(v,k,C,R,T){let{name:z,handler:F}=k,V=`@${z}`,H=`@end${z}`,K=v,X=Kr(`${V}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${H}`,"g"),G=[],te=X.exec(K);while(te!==null){let[ce,ee="",le=""]=te,ue=te.index||0;try{let de=ee?Zp(k,ee):[],fe=le.trim(),pe=await F(fe,de,C,R);G.push({original:ce,processed:pe,startIndex:ue})}catch(de){let fe=de instanceof Error?de.message:String(de);if(T.debug)console.error(`Error processing custom directive @${z}:`,de);G.push({original:ce,processed:i("CustomDirective",`Error in @${z}${ee?`(${ee})`:""}: ${fe}`,t.EVALUATION_ERROR),startIndex:ue})}te=X.exec(K)}for(let ce=G.length-1;ce>=0;ce--){let{original:ee,processed:le}=G[ce];K=K.replace(ee,le)}return K}async function jb(v,k,C,R,T){let{name:z,handler:F}=k,V=v,H=[],K=[];if(k.rawParams){for(let te of Zs(V,Kr(`(?<![\\w$@])@${z}\\s*\\(`,"g")))if(te.end!==-1)K.push({fullMatch:te.call,paramString:te.args,startIndex:te.start})}else{let te=Kr(`@${z}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");te.lastIndex=0;let ce=te.exec(V);while(ce!==null)K.push({fullMatch:ce[0],paramString:ce[1]??"",startIndex:ce.index||0}),ce=te.exec(V)}for(let{fullMatch:te,paramString:ce,startIndex:ee}of K)try{let le=Zp(k,ce),ue=await F("",le,C,R);H.push({original:te,processed:ue,startIndex:ee})}catch(le){let ue=le instanceof Error?le.message:String(le);if(T.debug)console.error(`Error processing custom directive @${z}:`,le);H.push({original:te,processed:i("CustomDirective",`Error in @${z}(${ce}): ${ue}`,t.EVALUATION_ERROR),startIndex:ee})}let X=Kr(`@${z}(?!\\w)(?!\\s*\\()`,"g"),G=X.exec(V);while(G!==null){let[te]=G,ce=G.index||0;try{let ee=await F("",[],C,R);H.push({original:te,processed:ee,startIndex:ce})}catch(ee){let le=ee instanceof Error?ee.message:String(ee);if(T.debug)console.error(`Error processing custom directive @${z}:`,ee);H.push({original:te,processed:i("CustomDirective",`Error in @${z}: ${le}`,t.EVALUATION_ERROR),startIndex:ce})}G=X.exec(V)}for(let te=H.length-1;te>=0;te--){let{original:ce,processed:ee}=H[te];V=V.replace(ce,ee)}return V}function Zp(v,k){return v.rawParams?ct(k):Lb(k)}function Lb(v){if(!v.trim())return[];let k=[],C="",R=!1,T="";for(let z=0;z<v.length;z++){let F=v[z];if((F==='"'||F==="'")&&(z===0||v[z-1]!=="\\"))if(!R)R=!0,T=F;else if(F===T)R=!1;else C+=F;else if(F===","&&!R)k.push(C.trim()),C="";else C+=F}if(C.trim())k.push(C.trim());return k.map((z)=>{let F=z.trim();if(F.startsWith('"')&&F.endsWith('"')||F.startsWith("'")&&F.endsWith("'"))return F.substring(1,F.length-1);return F})}var Gp=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Jp=/^[A-Za-z_$][\w$]*$/,Bb=new Set(["light","dark","system"]);function Qr(v,k){if(typeof v!=="string"||v.length===0)throw Error(`@appearanceBootstrap ${k} must be a non-empty string`)}function zb(v){if(!v||typeof v!=="object"||Array.isArray(v))throw Error("@appearanceBootstrap expects an options object");let k=v,{appearance:C,colorMode:R}=k;if(Qr(k.storageKey,"storageKey"),C!==void 0&&(!C||typeof C!=="object"||Array.isArray(C)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!R||typeof R!=="object"||Array.isArray(R))throw Error("@appearanceBootstrap colorMode must be an object");if(Qr(R.key,"colorMode.key"),Qr(R.attribute,"colorMode.attribute"),Qr(R.default,"colorMode.default"),!Jp.test(R.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Gp.test(R.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Bb.has(R.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let T=null;if(C){if(Qr(C.key,"appearance.key"),Qr(C.attribute,"appearance.attribute"),Qr(C.default,"appearance.default"),!Jp.test(C.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Gp.test(C.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(C.allowed)||C.allowed.length===0||C.allowed.some((z)=>typeof z!=="string"||z.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!C.allowed.includes(C.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");T={key:C.key,attribute:C.attribute,allowed:[...new Set(C.allowed)],default:C.default}}return{storageKey:k.storageKey,appearance:T,colorMode:{key:R.key,attribute:R.attribute,default:R.default},respectExisting:k.respectExisting===!0}}function Wb(v){return JSON.stringify(v).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Fb(v){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${Wb(v)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function Vb(v,k){let C=1,R=null,T=!1;for(let z=k+1;z<v.length;z++){let F=v[z];if(T){T=!1;continue}if(R){if(F==="\\")T=!0;else if(F===R)R=null;continue}if(F==='"'||F==="'"||F==="`"){R=F;continue}if(F==="(")C++;else if(F===")"&&--C===0)return z}return-1}function Yp(v,k){let C=v,R=/@appearanceBootstrap\s*\(/g,T;while((T=R.exec(C))!==null){let z=T.index+T[0].length-1,F=Vb(C,z);if(F===-1)throw Error("@appearanceBootstrap has an unclosed options object");let V=C.slice(z+1,F).trim(),H=l(`(${V})`,k),K=Fb(zb(H));C=C.slice(0,T.index)+K+C.slice(F+1),R.lastIndex=T.index+K.length}return C}import Ub from"crypto";function rn(v){return String(v??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var eg={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Oa(v,k,C,R){let T=v||k;return C?`${T} ${R}`:T}function Bn(v){return String(v).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Us(v,k){if(/\bid\s*=/i.test(v))return"";return` id="${rn(k)}"`}function Fl(v,k,C){if(!k)return"";let R="";if(!/\baria-invalid\s*=/i.test(C))R+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(C))R+=` aria-describedby="${rn(`${Bn(v)}-error`)}"`;return R}function Hb(){return Ub.randomUUID()}function Ma(v,k){let C=v;return C=C.replace(/@csrf/g,()=>{if(!k.csrf||typeof k.csrf!=="object"){let R=Hb();k.csrf={token:R}}if(k.csrf.field)return k.csrf.field;if(k.csrf.token)return`<input type="hidden" name="_token" value="${rn(k.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),C=C.replace(/@method\(['"]([^'"]+)['"]\)/g,(R,T)=>{let z=T.toUpperCase();if(T&&!["GET","POST"].includes(z))return`<input type="hidden" name="_method" value="${rn(z)}">`;return R}),C}function tg(v,k,C=eg){let R=v;return R=R.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(T,z,F,V,H,K="")=>{let X=z||F||"POST",G=V||H||"",te=Lr(K),ce=X.toUpperCase(),ee=["GET","POST"].includes(ce)?ce:"POST",le=`<form method="${rn(ee)}" action="${rn(G)}"${te?` ${te}`:""}>`;if(le+=`
2295
- ${Ma("@csrf",k)}`,!["GET","POST"].includes(ce))le+=`
2296
- ${Ma(`@method('${ce}')`,k)}`;return le}),R=R.replace(/@endform/g,"</form>"),R=R.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(T,z,F,V,H,K="")=>{let X=z||F||"",G=V||H||"",te=Lr(K),ce=xo(X,k),ee=ce!==void 0&&ce!==null?ce:G||"",le=te.match(/type=['"]([^'"]+)['"]/i),ue=le?le[1]:"text",de=bo(X,k),fe=te.match(/class=['"]([^'"]+)['"]/i),pe=Oa(fe?fe[1]:"",C.input,de,C.inputError),Ae=te.replace(/class=['"][^'"]+['"]/i,"");return Ae=Ae.replace(/type=['"][^'"]+['"]/i,""),`<input type="${rn(ue)}" name="${rn(X)}"${Us(te,Bn(X))} value="${rn(ee)}" class="${pe}"${Fl(X,de,te)}${Ae?` ${Ae}`:""}>`}),R=R.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(T,z,F="",V="")=>{let H=Lr(F),K=xo(z,k)||V.trim(),X=bo(z,k),G=H.match(/class=['"]([^'"]+)['"]/i),te=Oa(G?G[1]:"",C.input,X,C.inputError),ce=H.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${rn(z)}"${Us(H,Bn(z))} class="${te}"${Fl(z,X,H)}${ce?` ${ce}`:""}>${rn(K)}</textarea>`}),R=R.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(T,z,F="",V)=>{let H=Lr(F),K=xo(z,k),X=bo(z,k),G=H.match(/class=['"]([^'"]+)['"]/i),te=Oa(G?G[1]:"",C.input,X,C.inputError),ce=H.replace(/class=['"][^'"]+['"]/i,""),ee=V;if(K!==void 0)ee=V.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(le,ue,de)=>{if((Array.isArray(K)?K.some((pe)=>String(pe)===de):String(K)===de)&&!ue.includes("selected"))return ue.replace(/(<option)/,"$1 selected");return le});return`<select name="${rn(z)}"${Us(H,Bn(z))} class="${te}"${Fl(z,X,H)}${ce?` ${ce}`:""}>${ee}</select>`}),R=R.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(T,z,F,V="")=>{let H=F===void 0?"1":F,K=F===void 0?Bn(z):`${Bn(z)}-${Bn(H)}`,X=Lr(V),G=xo(z,k),te=G!==void 0&&(Array.isArray(G)?G.some((ue)=>String(ue)===H):G===!0||String(G)===H),ce=X.match(/class=['"]([^'"]+)['"]/i),ee=ce?ce[1]:C.checkInput,le=X.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${rn(z)}"${Us(X,K)} value="${rn(H)}" class="${ee}"${te?" checked":""}${le?` ${le}`:""}>`}),R=R.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(T,z,F,V="")=>{let H=Lr(V),K=xo(z,k),X=K!==void 0&&K===F,G=H.match(/class=['"]([^'"]+)['"]/i),te=G?G[1]:C.checkInput,ce=H.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${rn(z)}"${Us(H,`${Bn(z)}-${Bn(F)}`)} value="${rn(F)}" class="${te}"${X?" checked":""}${ce?` ${ce}`:""}>`}),R=R.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(T,z,F="")=>{let V=Lr(F),H=V.match(/accept=['"]([^'"]+)['"]/i),K=H?H[1]:"",X=V.includes("multiple"),G=bo(z,k),te=V.match(/class=['"]([^'"]+)['"]/i),ce=Oa(te?te[1]:"",C.input,G,C.inputError),ee=V.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),le=[`<input type="file" name="${rn(z)}"${Us(V,Bn(z))}`,`class="${ce}"`];if(K)le.push(`accept="${rn(K)}"`);if(X)le.push("multiple");if(ee)le.push(ee);return`${le.join(" ")}>`}),R=R.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(T,z,F="",V)=>{let H=Lr(F),K=H.match(/class=['"]([^'"]+)['"]/i),X=K?K[1]:C.label,G=H.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${rn(Bn(z))}" class="${X}"${G?` ${G}`:""}>${V}</label>`}),R}function ng(v,k,C=eg){return v.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(R,T,z)=>{try{if(bo(T,k)){let F=z.replace(/\{\{([^}]+)\}\}/g,(V,H)=>{try{if(H.trim()==="$message"||H.trim()==="message")return Qp(T,k);if(H.trim().includes("errors.first")||H.trim().includes("$errors.first")){if(typeof k.errors?.first==="function")return k.errors.first(T);return Qp(T,k)}let K=H.trim();if(p(K)){let X=l(K,k);return X!==void 0?String(X):K}return K}catch{return H}});return`<div id="${rn(`${Bn(T)}-error`)}" role="alert">${F}</div>`}return""}catch(F){return console.error("Error processing @error directive:",F),R}})}function bo(v,k){if(!k.errors)return!1;if(typeof k.errors.has==="function")return k.errors.has(v);if(typeof k.errors==="object")return Object.prototype.hasOwnProperty.call(k.errors,v);return!1}function Qp(v,k){if(!k.errors)return"";if(typeof k.errors.get==="function")return k.errors.get(v);if(typeof k.errors==="object"&&Object.prototype.hasOwnProperty.call(k.errors,v)){let C=k.errors[v];return Array.isArray(C)?C[0]:String(C)}return""}function xo(v,k){let C;if(k.old&&typeof k.old==="function")return k.old(v);if(k.old&&typeof k.old==="object")return k.old[v];if(v.endsWith("[]")){let R=v.slice(0,-2);if(C=k[R],C!==void 0)return C}return k[v]}function Lr(v){if(!v.trim())return"";let k=[],C=v.trim(),R=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,T;while((T=R.exec(C))!==null){let[,z,,F]=T;k.push(`${z}="${F.trim()}"`)}return k.join(" ")}var Vl=m(256),qb=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],rg=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function Kb(v){let k=Array.from(v,(T)=>T===`
2297
- `?`
2298
- `:" "),C=0,R="";while(C<v.length){let T=v[C],z=v[C+1];if(R){if(T==="\\"){C+=2;continue}if(T===R)R="";C++;continue}if(T==='"'||T==="'"||T==="`"){R=T,C++;continue}if(T==="/"&&z==="/"){while(C<v.length&&v[C]!==`
2299
- `)k[C]=v[C],C++;continue}if(T==="/"&&z==="*"){let F=v.indexOf("*/",C+2),V=F===-1?v.length:F+2;for(;C<V;C++)k[C]=v[C];continue}if(T==="{"&&z==="{"&&v.slice(C,C+4)==="{{--"){let F=v.indexOf("--}}",C+4),V=F===-1?v.length:F+4;for(;C<V;C++)k[C]=v[C];continue}C++}return k.join("")}function Xb(v){let k=new Map,C=Kb(v).split(`
2300
- `),R=v.split(`
2301
- `);return C.forEach((T,z)=>{rg.lastIndex=0;for(let F of T.matchAll(rg)){let V=F[1]==="-next-line",H=(R[z]??"").slice(0,F.index).trim(),K=V||H===""?z+2:z+1,G=(F[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),te=G.filter((ee)=>/\w/.test(ee));if(G.length>0&&te.length===0)continue;let ce=k.get(K);if(ce&&ce.size===0)continue;if(te.length===0){k.set(K,new Set);continue}if(ce)te.forEach((ee)=>ce.add(ee));else k.set(K,new Set(te))}}),k}function Zb(v,k,C){let R=v.get(k);if(!R)return!1;if(R.size===0)return!0;return[...R].some((T)=>C.includes(T))}function Qe(v,k,C,R){let T=typeof C==="boolean"?{enabled:C,failOnViolation:C}:C??{enabled:!1};if(!T.enabled)return;let z=h(v,k,R,JSON.stringify(T)),F=Vl.get(z);if(F!==void 0){if(F&&T.failOnViolation)throw new q(F,R??k);return}let V=T.allowPatterns??[],H=Xb(v),K=[],X=s(v.replace(/\{\{--[\s\S]*?--\}\}/g,(ee)=>ee.replace(/[^\n]/g," ")));for(let{pattern:ee,message:le,suggestion:ue}of qb){if(V.some((fe)=>/\w/.test(fe)&&le.includes(fe)))continue;ee.lastIndex=0;let de=X.match(ee);if(de&&de.length>0){let fe=X.split(`
2302
- `),pe=v.split(`
2303
- `),Ae=[];if(fe.forEach((Me,je)=>{if(ee.lastIndex=0,ee.test(Me)&&!Zb(H,je+1,le))Ae.push(je+1)}),Ae.length===0&&fe.some((Me)=>(ee.lastIndex=0,ee.test(Me))))continue;let Se=Ae.length>0?` (script line${Ae.length>1?"s":""} ${Ae.join(", ")})`:"",ve=Ae.slice(0,3).map((Me)=>` ${Me} | ${(pe[Me-1]??"").trim().slice(0,100)}`).join(`
2304
- `),De=ve?`
2305
- ${ve}`:"";K.push(` \u2717 ${le}${Se}
2306
- \u2192 ${ue}${De}`)}}if(K.length===0){Vl.set(z,"");return}let G=(ee)=>{let le=`${process.cwd()}/`;return ee.startsWith(le)?ee.slice(le.length):ee},ce=`[STX] DOM API violation in ${R&&R!==k?`${G(R)} (composed into ${G(k)})`:G(k)}:
2307
- ${K.join(`
2308
- `)}
2309
- Tip: prefer useRef(), navigate(), and composables for component code`;if(Vl.set(z,ce),console.warn(ce),T.failOnViolation)throw new q(ce,R??k)}var vo=/<\/?template\b[^>]*>/gi,Gb=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function Jb(v){let k=v.replace(/^<template\b/i,"").replace(/>$/,"");return Gb.test(k)}function oe(v){vo.lastIndex=0;let k;while((k=vo.exec(v))!==null){if(k[0].startsWith("</")||Jb(k[0]))continue;let C=k.index,R=vo.lastIndex,T=1,z;while((z=vo.exec(v))!==null)if(z[0].startsWith("</")){if(T--,T===0){let F=z.index;return{start:C,openEnd:R,closeStart:F,end:vo.lastIndex,content:v.slice(R,F)}}}else T++;return null}return null}import Yt from"path";import{existsSync as ww}from"fs";class sg{builtins=new Map;registerBuiltin(v){this.builtins.set(v.name.toLowerCase(),v);for(let k of v.aliases)this.builtins.set(k.toLowerCase(),v)}isBuiltin(v){return this.builtins.has(v.toLowerCase())}getBuiltin(v){return this.builtins.get(v.toLowerCase())??null}async resolveFile(v,k,C,R){let T=gc(v,R);if(T!==void 0)return T;for(let z of mc(v,k,C,R))if(await r(z))return z;return null}}var qs=new sg;function Zt(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Br="\x00stx-boolean-attribute";function Ul(v){return v.indexOf("\x00")===-1?v:v.replace(/\0/g,"")}var Yb=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Hl(v){let k=v.toLowerCase();return k.startsWith("aria-")||k.startsWith("data-")||Yb.has(k)}function zr(v,k){let C=[];for(let[R,T]of Object.entries(v.static)){if(k.has(R))continue;let z=v.staticNames?.[R]??R;if(typeof T==="boolean"){if(T)C.push(Zt(z));continue}if(T===Br){C.push(Zt(z));continue}C.push(`${Zt(z)}="${Zt(Ul(String(T)))}"`)}return C}function Wr(v,k){let C=[];for(let[R,T]of Object.entries(v.serverDynamic??{})){if(k.has(R))continue;if(T===null||T===void 0||T===!1)continue;let z=v.serverDynamicNames?.[R]??R;if(T===!0){C.push(Zt(z));continue}if(typeof T==="object")continue;C.push(`${Zt(z)}="${Zt(Ul(String(T)))}"`)}return C}function ei(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qb(v){if(v.clientReactive.to)return{value:v.clientReactive.to,reactive:!0};if(v.serverDynamic.to!==void 0)return{value:String(v.serverDynamic.to),reactive:!1};if(typeof v.static.to==="string")return{value:v.static.to,reactive:!1};return{value:"#",reactive:!1}}var ql={name:"StxLink",aliases:["stx-link"],render(v,k,C){let R=Qb(v),T=(typeof v.static.class==="string"?v.static.class:"")||(typeof v.static.className==="string"?v.static.className:""),z=typeof v.static.activeClass==="string"?v.static.activeClass:"active",F=typeof v.static.exactActiveClass==="string"?v.static.exactActiveClass:"exact-active",V=v.static.prefetch===!0||v.static.prefetch==="true"||v.serverDynamic.prefetch===!0,H=[];if(R.reactive)H.push(`:href="${ei(R.value)}"`);else H.push(`href="${ei(qi(R.value,"navigable"))}"`);if(T)H.push(`class="${ei(T)}"`);if(H.push("data-stx-link"),H.push(`data-stx-active-class="${ei(z)}"`),H.push(`data-stx-exact-active-class="${ei(F)}"`),V)H.push("data-stx-prefetch");let K=typeof v.static.activeMatch==="string"?v.static.activeMatch.trim():"";if(K)H.push(`data-stx-active-match="${ei(K)}"`);let X=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return H.push(...zr(v,X)),H.push(...Wr(v,X)),`<a ${H.join(" ")}>${k}</a>`}};import{createHash as yg}from"crypto";import mn from"fs";import dn from"path";import{decode as av,generateThumbHash as cv}from"ts-images";import{createImageDeliveryCatalog as ug}from"ts-images/delivery";import Kl from"fs";function Na(v,k,C){let R=Buffer.alloc(C),T=Kl.readSync(v,R,0,C,k);return R.subarray(0,T)}function Xl(v){if(v.length<25)return!1;let k=(R,T)=>String.fromCharCode(...v.subarray(R,T));if(k(0,4)!=="RIFF"||k(8,12)!=="WEBP")return!1;let C=k(12,16);if(C==="VP8X")return(v[20]&16)!==0;if(C==="VP8L")return((v[21]|v[22]<<8|v[23]<<16|v[24]<<24)>>>28&1)===1;return!1}function Zl(v){let k;try{k=Kl.openSync(v,"r");let C=Na(k,0,33);if(C.length>=3&&C[0]===255&&C[1]===216&&C[2]===255)return"none";if(C.length>=26&&C[0]===137&&C.toString("latin1",1,4)==="PNG"){let R=C[25];if(R===4||R===6)return"possible";let T=8;for(let z=0;z<64;z++){let F=Na(k,T,8);if(F.length<8)return"unknown";let V=F.toString("latin1",4,8);if(V==="tRNS")return"possible";if(V==="IDAT"||V==="IEND")return"none";T+=12+F.readUInt32BE(0)}return"unknown"}if(C.length>=25&&C.toString("latin1",0,4)==="RIFF"&&C.toString("latin1",8,12)==="WEBP"){if(Xl(C))return"possible";let R=C.toString("latin1",12,16);return R==="VP8 "||R==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(k!==void 0)Kl.closeSync(k)}}import ev from"fs";import ja from"os";import{join as ig}from"path";import{fileURLToPath as og}from"url";import{Worker as ag}from"worker_threads";var Ba=Symbol("stx.image-worker.unavailable");function tv(v=typeof ja.availableParallelism==="function"?ja.availableParallelism():ja.cpus().length){return Math.max(1,Math.min(2,v-1))}var La=0,lg=[];async function nv(){if(La<tv()){La++;return}await new Promise((v)=>lg.push(v)),La++}function rv(){La--,lg.shift()?.()}var sv="@stacksjs/stx/builtins/image-warmup-worker";function iv(v=process.cwd()){let k=import.meta.url.endsWith(".ts")?"ts":"js";try{let C=new URL(`./image-warmup-worker.${k}`,import.meta.url);if(C.protocol==="file:"&&ev.existsSync(og(C)))return og(C)}catch{}try{let C=typeof Bun<"u"?Bun.resolveSync(sv,v):void 0;return C&&ov(C)?C:void 0}catch{return}}function ov(v,k=process.env){let C=v.replace(/\\/g,"/");if(C.split("/").some((T)=>/@\d[^/]*@@@\d+$/.test(T)))return!1;return![k.BUN_INSTALL_CACHE_DIR,ig(k.BUN_INSTALL||ig(ja.homedir(),".bun"),"install","cache")].filter((T)=>!!T).map((T)=>`${T.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((T)=>C.startsWith(T))}var cg=!1;function wo(v){if(!cg)cg=!0,console.warn(`[stx] image worker unavailable (${v}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Ba}function Gl(v){return v instanceof Error?v.message:String(v)}async function Jl(v,k){if(typeof ag!=="function")return wo("node:worker_threads has no Worker in this runtime");let C=iv();if(!C)return wo("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await nv();try{return await new Promise((R,T)=>{let z;try{z=new ag(C)}catch(K){R(wo(`could not start ${C}: ${Gl(K)}`));return}let F=!1,V=!1,H=(K)=>{if(V)return;V=!0,K(),z.terminate()};z.on("message",(K)=>{if(K.type==="ready"){F=!0,z.postMessage({task:v,args:k});return}if(K.type==="result"){H(()=>R(K.value));return}let X=Error(K.error?.message??"image worker failed");if(K.error?.name)X.name=K.error.name;if(K.error?.stack)X.stack=K.error.stack;H(()=>T(X))}),z.on("error",(K)=>{H(()=>F?T(K instanceof Error?K:Error(Gl(K)||"image worker crashed")):R(wo(`the worker failed before it was ready: ${Gl(K)}`)))}),z.on("exit",(K)=>{H(()=>F?T(Error("image worker exited before it finished")):R(wo(`the worker exited with code ${K} before it was ready`)))})})}finally{rv()}}var lv=new Set([".avif",".jpeg",".jpg",".png",".webp"]),uv=[320,640,960,1280,1920],So="/_stx/images",dv=`stx:${So}:alpha-1`,fv=`stx:${So}:opaque-1`,pv=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],za;function gv(v,k){let C=dn.dirname(Bun.resolveSync(v,k));while(C!==dn.dirname(C)){let R=dn.join(C,"package.json");if(mn.existsSync(R)){let T=JSON.parse(mn.readFileSync(R,"utf8"));if(T.name===v)return T.version}C=dn.dirname(C)}return}function dg(){if(za!==void 0)return za;let v;try{v=dn.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return za=pv.map((k)=>{let C;try{C=v?gv(k,v):void 0}catch{}return`${k.replace("@stacksjs/","")}@${C??"unknown"}`}).join("+"),za}var fg=Symbol.for("stx.image-delivery");function $o(){let v=globalThis;return v[fg]??={catalog:new Map,transparent:new Set},v[fg]}var pg=new Set;function mv(v){return`/${v.split(dn.sep).map(encodeURIComponent).join("/")}`}function hv(v){let k=dn.extname(v),C=v.slice(0,-k.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),R=yg("sha256").update(v).digest("hex").slice(0,8);return`${C||"image"}-${R}`}function gg(v,k=`stx:${So}`){let C=(R)=>`${So}/${R.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:k,async stat(R){let T=dn.join(v,R);try{let z=await mn.promises.stat(T);return z.size>0?{bytes:z.size,path:T,url:C(R)}:null}catch{return null}},async write(R,T){let z=dn.join(v,R);await mn.promises.mkdir(dn.dirname(z),{recursive:!0});let F=`${z}.${process.pid}.tmp`;return await mn.promises.writeFile(F,T),await mn.promises.rename(F,z),{bytes:T.byteLength,path:z,url:C(R)}},url:C}}async function xg(v,k=v){let C=await mn.promises.readdir(k,{withFileTypes:!0});C.sort((T,z)=>T.name.localeCompare(z.name));let R=[];for(let T of C){let z=dn.join(k,T.name);if(T.isDirectory()){R.push(...await xg(v,z));continue}if(!T.isFile()||!lv.has(dn.extname(T.name).toLowerCase()))continue;R.push({absolutePath:z,relativePath:dn.relative(v,z)})}return R}function mg(v,k){return v.map((C)=>({key:mv(C.relativePath),input:C.absolutePath,name:hv(C.relativePath),...yv(C.absolutePath)?{options:{storage:k}}:{}}))}function yv(v){return Zl(v)==="possible"}function xv(v){for(let k=3;k<v.length;k+=4)if(v[k]!==255)return!0;return!1}async function bv(v){let k=Object.entries(v).filter(([,T])=>T.fallback.format==="png"),C=new Set,R=8;for(let T=0;T<k.length;T+=8)await Promise.all(k.slice(T,T+8).map(async([z,F])=>{let V=F.variants.filter((H)=>H.format==="png").sort((H,K)=>H.width-K.width)[0];try{let H=await av(new Uint8Array(await mn.promises.readFile(V?.path??F.fallback.path)));if(xv(H.data))C.add(z)}catch{C.add(z)}}));return C}function vv(v,k){let C=[];for(let R of k){let T=v[R],z=T?.variants.filter((V)=>V.format==="webp")??[];if(!T||z.length===0)continue;if(!z.some((V)=>{let H;try{return H=mn.openSync(V.path,"r"),!Xl(Na(H,0,32))}catch{return!0}finally{if(H!==void 0)mn.closeSync(H)}}))continue;if(T.variants=T.variants.filter((V)=>V.format!=="webp"),delete T.sources.webp,C.push(R),!pg.has(R))pg.add(R),console.warn(`[stx-images] ${R} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return C}async function wv(v){let k=[],C=8;for(let R=0;R<v.length;R+=8){let T=v.slice(R,R+8),z=await Promise.all(T.map(async(F)=>{try{return await cv(F.absolutePath),F}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${F.relativePath}`),null}}));k.push(...z.filter((F)=>F!==null))}return k}function Yl(v){return dn.join(v,"undecodable.json")}function Sv(v){try{let k=mn.readFileSync(Yl(v),"utf-8"),C=JSON.parse(k);return C&&typeof C==="object"?C:{}}catch{return{}}}function $v(v,k){try{mn.mkdirSync(dn.dirname(Yl(v)),{recursive:!0}),mn.writeFileSync(Yl(v),JSON.stringify(k))}catch{}}function hg(v){try{let k=mn.statSync(v);return{mtimeMs:k.mtimeMs,size:k.size}}catch{return}}function bg(v){if(!v||v.startsWith("data:")||v.startsWith("blob:")||/^https?:\/\//i.test(v)||v.startsWith("//"))return;let k=v.split(/[?#]/,1)[0];if(!k)return;try{return`/${k.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Ss(v){let k=bg(v);return k?$o().catalog.get(k):void 0}function ks(v){let k=bg(v);return k?$o().transparent.has(k):!1}function _s(v){let k=(R)=>v.variants.filter((T)=>T.format===R).reduce((T,z)=>T+z.bytes,0),C=k(v.fallback.format);return["avif","webp"].map((R)=>({format:R,srcset:v.sources[R]||"",bytes:k(R)})).filter((R)=>R.srcset&&R.bytes>0&&R.bytes<C).sort((R,T)=>R.bytes-T.bytes).map(({format:R,srcset:T})=>({format:R,srcset:T}))}function hd(v){let k=Ss(v);if(!k)return;return{src:k.fallback.url,srcset:k.sources[k.fallback.format]||"",sources:_s(k).map(({format:C,srcset:R})=>({type:`image/${C}`,srcset:R})),width:k.source.width,height:k.source.height,placeholder:ks(v)?void 0:k.placeholder?.dataUrl}}function ur(){let v=$o();v.catalog=new Map,v.transparent=new Set}function _v(v){let k=$o();k.catalog=new Map(v.entries),k.transparent=new Set(v.transparent)}async function yd(v,k,C={}){if(!v||!mn.existsSync(v))return ur(),{count:0,fingerprint:""};if(C.offThread){let ee=await Jl("delivery",{publicDir:v,outputDir:k});if(ee!==Ba)return _v(ee.state),ee.result}let R=await xg(v);if(R.length===0)return ur(),{count:0,fingerprint:""};let T=Sv(k),z=R.filter((ee)=>{let le=T[ee.relativePath];if(!le)return!0;let ue=hg(ee.absolutePath);return!ue||ue.mtimeMs!==le.mtimeMs||ue.size!==le.size});if(z.length===0)return ur(),{count:0,fingerprint:""};let F=gg(dn.join(k,"_stx","images"),`${dv}:${dg()}`),V={outDir:dn.join(k,"_stx","images"),storage:gg(dn.join(k,"_stx","images"),`${fv}:${dg()}`),baseUrl:So,widths:uv,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},H=z,K;try{K=await ug({...V,entries:mg(z,F)})}catch(ee){if(H=await wv(z),H.length===z.length)throw ee;let le=new Set(H.map((de)=>de.relativePath)),ue=!1;for(let de of z){if(le.has(de.relativePath))continue;let fe=hg(de.absolutePath);if(!fe)continue;T[de.relativePath]=fe,ue=!0}if(ue)$v(k,T);if(H.length===0)return ur(),{count:0,fingerprint:""};K=await ug({...V,entries:mg(H,F)})}let X=await bv(K.entries),G=vv(K.entries,X),te=$o();te.catalog=new Map(Object.entries(K.entries)),te.transparent=X;let ce=X.size===0&&G.length===0?K.fingerprint:yg("sha256").update(K.fingerprint).update(JSON.stringify({transparent:[...X].sort(),droppedWebp:G.sort()})).digest("hex");return{count:H.length,fingerprint:ce}}var kv=new Map;function Ql(v){if(!v)return;let k=v.split("?")[0].split("#")[0];return kv.get(k)}var Ev={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},eu=[320,640,768,1024,1280,1536,1920];function tn(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function nn(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}function Wa(v,k,C=!1){let R=v.serverDynamic[k];if(R!==void 0)return R!==!1&&R!=="false";let T=v.static[k];if(T!==void 0)return T!=="false"&&T!==!1;return C}function tu(v){if(v.includes("(")||v.includes(","))return v;let k=v.trim().split(/\s+/),C=[];for(let R of k)if(R.includes(":")){let[T,z]=R.split(":"),F=Ev[T];if(F)C.push(`(max-width: ${F}px) ${z}`);else{let V=Number.parseInt(T);if(!Number.isNaN(V))C.push(`(max-width: ${V}px) ${z}`)}}else C.push(R);return C.join(", ")}function nu(v,k,C,R){return k.map((T)=>`${_o(v,T,void 0,C,R)} ${T}w`).join(", ")}function Cv(v,k,C,R,T){return k.map((z)=>{let F=C?C*z:void 0;return`${_o(v,F,void 0,R,T)} ${z}x`}).join(", ")}function _o(v,k,C,R,T){if(!R||R==="local"||R==="static")return v;if(R==="cloudinary"){let z=[];if(k)z.push(`w_${k}`);if(C)z.push(`h_${C}`);if(T)z.push(`f_${T}`);z.push("q_auto");let F=z.join(",");return v.replace("/upload/",`/upload/${F}/`)}if(R==="imgix"){let z=new URLSearchParams;if(k)z.set("w",String(k));if(C)z.set("h",String(C));if(T)z.set("fm",T);z.set("auto","format");let F=v.includes("?")?"&":"?";return`${v}${F}${z.toString()}`}if(R==="bunny"){let z=new URLSearchParams;if(k)z.set("width",String(k));if(C)z.set("height",String(C));if(T)z.set("format",T);let F=v.includes("?")?"&":"?";return`${v}${F}${z.toString()}`}return v}function Rv(v){return`var s=this.style;${v.map((k)=>`s.${k}=''`).join(";")}`}function Av(v,k,C="#e5e7eb"){let R=`<svg xmlns="http://www.w3.org/2000/svg" width="${v}" height="${k}"><rect width="100%" height="100%" fill="${C}"/></svg>`;return`data:image/svg+xml;base64,${btoa(R)}`}var ru={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(v,k,C){let R=nn(v,"src")||"",T=Ss(R),z=nn(v,"alt")||"",F=nn(v,"width")||(T?String(T.source.width):void 0),V=nn(v,"height")||(T?String(T.source.height):void 0),H=nn(v,"sizes"),K=nn(v,"srcset"),X=nn(v,"densities"),G=nn(v,"format"),te=ks(R)||Ql(R)?.transparent===!0,ce=nn(v,"placeholder")||(T&&!te?"thumbhash":void 0),ee=nn(v,"placeholderColor")||"#e5e7eb",le=nn(v,"provider"),ue=nn(v,"class")||nn(v,"className")||"",de=nn(v,"style")||"",fe=nn(v,"objectFit")||nn(v,"fit"),pe=nn(v,"objectPosition")||nn(v,"position"),Ae=nn(v,"quality"),Se=Wa(v,"lazy",!0),ve=Wa(v,"preload",!1),De=Wa(v,"priority",!1),Me=nn(v,"loading"),je=nn(v,"decoding")||"async",Le=!!T||Wa(v,"picture",!1)||!!G,Be=F?Number.parseInt(F):void 0,Oe=V?Number.parseInt(V):void 0,We=K||"",Fe="";if(T)We=T.sources[T.fallback.format]||"",Fe=H?tu(H):"100vw";else if(!We&&H&&le&&le!=="local"&&le!=="static")We=nu(R,eu,le,G),Fe=tu(H);else if(!We&&X){let vt=X.split(/\s+/).map((dt)=>Number.parseFloat(dt.replace("x","")));We=Cv(R,vt,Be,le,G)}else if(H)Fe=tu(H);let Ve=[];if(de)Ve.push(de);if(fe)Ve.push(`object-fit:${fe}`);if(pe)Ve.push(`object-position:${pe}`);if(Be&&Oe)Ve.push(`aspect-ratio:${Be}/${Oe}`);let ze=[],at=ce==="blur"||ce==="color"||ce==="thumbhash";if(at&&!te){let vt=T?.placeholder?{dataUrl:T.placeholder.dataUrl,color:ee}:Ql(R);if(vt&&ce==="color")Ve.push(`background-color:${vt.color}`),ze.push("backgroundColor");else if(vt)Ve.push(`background-color:${vt.color}`),Ve.push(`background-image:url(${vt.dataUrl})`),Ve.push("background-size:cover"),Ve.push("background-repeat:no-repeat"),ze.push("backgroundColor","backgroundImage");else{let dt=Av(Be||16,Oe||9,ee);Ve.push(`background-image:url(${dt})`),Ve.push("background-size:cover"),Ve.push("background-repeat:no-repeat"),ze.push("backgroundImage")}}else if(!at&&ce&&ce!=="empty"&&ce!=="none")Ve.push(`background-image:url(${tn(ce)})`),Ve.push("background-size:cover"),Ve.push("background-repeat:no-repeat"),ze.push("backgroundImage");let St=T?.fallback.url||_o(R,Be,Oe,le,G),bt=[];if(bt.push(`src="${tn(qi(St,"fetched"))}"`),bt.push(`alt="${tn(z)}"`),F)bt.push(`width="${tn(F)}"`);if(V)bt.push(`height="${tn(V)}"`);let Tt=Me||(De||ve?"eager":Se?"lazy":"");if(Tt)bt.push(`loading="${tn(Tt)}"`);if(De)bt.push('fetchpriority="high"');if(bt.push(`decoding="${tn(je)}"`),ue)bt.push(`class="${tn(ue)}"`);if(Ve.length>0)bt.push(`style="${tn(Ve.join(";"))}"`);if(We)bt.push(`srcset="${tn(qi(We,"fetched"))}"`);if(Fe)bt.push(`sizes="${tn(Fe)}"`);let wt=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(ze.length>0){let vt=typeof v.static.onload==="string"?v.static.onload:"",dt=Rv(ze)+(vt?`;${vt}`:"");bt.push(`onload="${tn(dt)}"`),wt.add("onload")}bt.push(...zr(v,wt)),bt.push(...Wr(v,wt));let gt=`<img ${bt.join(" ")} />`,Et="";if(ve){let dt=G==="webp"?"image/webp":G==="avif"?"image/avif":"";Et=`<link rel="preload" as="image" href="${tn(St)}"${dt?` type="${dt}"`:""}${We?` imagesrcset="${tn(We)}"`:""}${Fe?` imagesizes="${tn(Fe)}"`:""} />
2310
- `}if(Le){let vt=[];if(T)for(let dt of _s(T))vt.push(`<source type="image/${dt.format}" srcset="${tn(dt.srcset)}"${Fe?` sizes="${tn(Fe)}"`:""} />`);if(!T&&(G==="avif"||G==="auto")){let dt=_o(R,Be,Oe,le,"avif"),Ct=We?nu(R,eu,le,"avif"):`${dt}`;vt.push(`<source type="image/avif" srcset="${tn(Ct)}"${Fe?` sizes="${tn(Fe)}"`:""} />`)}if(!T&&(G==="webp"||G==="auto")){let dt=_o(R,Be,Oe,le,"webp"),Ct=We?nu(R,eu,le,"webp"):`${dt}`;vt.push(`<source type="image/webp" srcset="${tn(Ct)}"${Fe?` sizes="${tn(Fe)}"`:""} />`)}return`${Et}<picture>
2311
- ${vt.join(`
2312
- `)}
2313
- ${gt}
2314
- </picture>`}return`${Et}${gt}`}};var vg="/images/safe-image-default.svg";function ko(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ti(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}var Tv=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${vg}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,su={name:"SafeImage",aliases:["safe-image","safe-img"],render(v,k,C){let R=ti(v,"src")||"",T=ti(v,"alt")||"",z=ti(v,"fallback")||vg,F=ti(v,"class")||ti(v,"className")||"",V=ti(v,"fallbackClassName")||"",H=[];if(H.push(`src="${ko(R)}"`),H.push(`alt="${ko(T)}"`),F)H.push(`class="${ko(F)}"`);if(H.push(`data-fallback="${ko(z)}"`),V)H.push(`data-fallback-class="${ko(V)}"`);H.push('onerror="window.__stxSafeImageHandler(this)"');let K=new Set(["src","alt","fallback","class","className","fallbackClassName"]);H.push(...zr(v,K)),H.push(...Wr(v,K));let X=`<img ${H.join(" ")} />`,G=C.context;if(!G.__safeImageHandlerEmitted)return G.__safeImageHandlerEmitted=!0,`${Tv}${X}`;return X}};function iu(v){return v.replace(/[;{}()]/g,"").replace(/url/gi,"")}function Eo(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}function Fa(v,k,C){let R=Eo(v,k);if(R!==void 0){let T=Number.parseInt(R,10);if(!Number.isNaN(T))return T}return C}var ou={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(v,k,C){let R=iu(Eo(v,"color")||"#6366f1"),T=iu(Eo(v,"initialColor")||Eo(v,"initial-color")||""),z=iu(Eo(v,"height")||"3px"),F=Fa(v,"duration",2000),V=Fa(v,"throttle",200),H=Fa(v,"zIndex",999999)||Fa(v,"z-index",999999),K=T?`linear-gradient(to right, ${T}, ${R})`:R;return`
2315
- <div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${z};background:${K};z-index:${H};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
2316
- <div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
2317
- </div>
2318
- <style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
2319
- <script>
2320
- (function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${V})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
2321
- </script>`}};function Sg(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}function Iv(v,k,C){let R=Sg(v,k);if(R!==void 0){let T=Number.parseInt(R,10);if(!Number.isNaN(T))return T}return C}var wg={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},au={name:"StxToast",aliases:["stx-toast"],render(v,k,C){let R=Zt(Sg(v,"position")||"top-right"),T=Iv(v,"max",5),z=wg[R]||wg["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${R}" data-stx-toast-max="${T}" style="position:fixed;${z};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
2322
- <style>
2323
- @keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
2324
- @keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
2325
- @keyframes stx-toast-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}
2326
- @keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
2327
- @keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
2328
- @keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
2329
- </style>`}};function Va(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}var $g={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},cu={name:"StxModal",aliases:["stx-modal"],render(v,k,C){let R=Va(v,"id");if(!R)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let T=Zt(R),z=Va(v,"size")||"md",F=Va(v,"closeOnBackdrop")!=="false",V=Va(v,"closeOnEscape")!=="false",H=$g[z]||$g.md;return`<div id="stx-modal-${T}" class="stx-modal-backdrop" data-stx-modal="${T}" data-close-backdrop="${F}" data-close-escape="${V}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
2330
- <div class="stx-modal-panel" style="${H};width:100%;margin:1rem;border-radius:0.75rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow:hidden;transform:scale(0.95) translateY(8px);transition:transform 0.2s ease,opacity 0.2s ease;opacity:0;background:var(--stx-modal-bg,#fff);color:var(--stx-modal-text,#1f2937)">
2331
- <div style="padding:1.5rem">${k}</div>
2332
- </div>
2333
- </div>
2334
- <style>
2335
- @media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
2336
- .stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
2337
- .stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
2338
- </style>`}};function ni(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}var _g={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},lu={name:"StxDrawer",aliases:["stx-drawer"],render(v,k,C){let R=ni(v,"id");if(!R)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let T=Zt(R),z=ni(v,"side")||"right",F=ni(v,"size")||"md",V=ni(v,"closeOnBackdrop")!=="false",H=ni(v,"closeOnEscape")!=="false",K=ni(v,"overlay")!=="false",X=_g[F]||_g.md,G=z==="left",te=G?"left:0":"right:0",ce=G?"translateX(-100%)":"translateX(100%)",ee=G?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${T}" class="stx-drawer-backdrop" data-stx-drawer="${T}" data-close-backdrop="${V}" data-close-escape="${H}" style="display:none;position:fixed;inset:0;z-index:99999;${K?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
2339
- <div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${te};width:${X};max-width:100vw;transform:${ce};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
2340
- <div style="padding:1.5rem">${k}</div>
2341
- </div>
2342
- </div>
2343
- <style>
2344
- @media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
2345
- .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
2346
- .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
2347
- </style>`}};import{existsSync as Pv,readFileSync as Dv}from"fs";var Ua=new Map,kg=new Set;function Ov(v){if(kg.has(v))return;kg.add(v),console.warn(`[stx] icon collection "${v}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${v}\`.`)}function Mv(v){let k=process.cwd();for(let C of[`${k}/node_modules/@iconify-json/${v}/icons.json`,`${k}/pantry/@iconify-json/${v}/icons.json`,`${k}/node_modules/@iconify/json/json/${v}.json`,`${k}/pantry/@iconify/json/json/${v}.json`])if(Pv(C))return C;for(let C of[`@iconify-json/${v}/icons.json`,`@iconify/json/json/${v}.json`])try{return d.resolve(C)}catch{}return null}function Nv(v){if(Ua.has(v))return Ua.get(v);let k=Mv(v);if(!k)return Ov(v),null;try{let C=JSON.parse(Dv(k,"utf8"));return Ua.set(v,C.icons),C.icons}catch{return null}}function ri(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);if(v.static[k]!==void 0)return String(v.static[k]);if(v.clientReactive[k]!==void 0)return v.clientReactive[k];return}var uu={name:"Icon",aliases:["icon","stx-icon"],render(v,k,C){let R=ri(v,"name")??ri(v,"icon");if(!R)return"<!-- Icon: missing name/icon prop -->";let T="lucide",z=R;if(R.includes(":")){let fe=R.split(":");T=fe[0],z=fe[1]}let F=Zt(ri(v,"size")||"24"),V=Zt(ri(v,"color")||"currentColor"),H=Zt(ri(v,"class")||""),K=Zt(ri(v,"style")||""),X=Ua.get(T)??Nv(T);if(!X)return`<!-- Icon: collection "${T}" not loaded -->`;let G=X[z];if(!G)return`<!-- Icon: "${z}" not found in ${T} -->`;let te=G.width||24,ce=G.height||24,ee=`0 0 ${te} ${ce}`,le=G.body;if(V!=="currentColor")le=le.replace(/currentColor/g,V);let ue=H?` class="${H}"`:"",de=K?` style="${K}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${F}" height="${F}" viewBox="${ee}" fill="none"${ue}${de}>${le}</svg>`}};function du(){return`
2348
- (function(){
2349
- var tip=null,hideTimer=null,currentEl=null;
2350
-
2351
- function createTip(){
2352
- tip=document.createElement("div");
2353
- tip.id="stx-tooltip";
2354
- tip.style.cssText="position:absolute;background:#1f2937;color:#fff;font-size:12px;line-height:1.4;padding:6px 10px;border-radius:6px;max-width:250px;z-index:999999;pointer-events:none;opacity:0;transition:opacity .15s ease;white-space:pre-wrap;word-wrap:break-word;box-shadow:0 2px 8px rgba(0,0,0,.25)";
2355
- var arrow=document.createElement("div");
2356
- arrow.className="stx-tip-arrow";
2357
- arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent";
2358
- tip.appendChild(arrow);
2359
- var text=document.createElement("span");
2360
- text.className="stx-tip-text";
2361
- tip.appendChild(text);
2362
- document.body.appendChild(tip);
2363
- }
2364
-
2365
- function position(el){
2366
- var pos=el.getAttribute("x-tooltip-position")||"top";
2367
- var r=el.getBoundingClientRect();
2368
- var sy=window.scrollY,sx=window.scrollX;
2369
- tip.style.display="block";
2370
- tip.style.opacity="0";
2371
- // Force layout so we can measure
2372
- var tw=tip.offsetWidth,th=tip.offsetHeight;
2373
- var arrow=tip.querySelector(".stx-tip-arrow");
2374
- var left,top;
2375
-
2376
- if(pos==="top"){
2377
- left=r.left+r.width/2-tw/2+sx;
2378
- top=r.top-th-8+sy;
2379
- if(top-sy<0){pos="bottom";}
2380
- }
2381
- if(pos==="bottom"){
2382
- left=r.left+r.width/2-tw/2+sx;
2383
- top=r.bottom+8+sy;
2384
- arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-bottom-color:#1f2937;top:-10px;left:50%;transform:translateX(-50%)";
2385
- }
2386
- if(pos==="left"){
2387
- left=r.left-tw-8+sx;
2388
- top=r.top+r.height/2-th/2+sy;
2389
- if(left-sx<0){pos="right";}
2390
- }
2391
- if(pos==="right"){
2392
- left=r.right+8+sx;
2393
- top=r.top+r.height/2-th/2+sy;
2394
- arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-right-color:#1f2937;left:-10px;top:50%;transform:translateY(-50%)";
2395
- }
2396
-
2397
- // Set arrow for top/left after potential flips
2398
- if(pos==="top"){
2399
- arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-top-color:#1f2937;bottom:-10px;left:50%;transform:translateX(-50%)";
2400
- }
2401
- if(pos==="left"){
2402
- arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-left-color:#1f2937;right:-10px;top:50%;transform:translateY(-50%)";
2403
- }
2404
-
2405
- // Clamp horizontal
2406
- if(left<sx+4) left=sx+4;
2407
- if(left+tw>sx+window.innerWidth-4) left=sx+window.innerWidth-tw-4;
2408
-
2409
- tip.style.left=left+"px";
2410
- tip.style.top=top+"px";
2411
- tip.style.opacity="1";
2412
- }
2413
-
2414
- function showTip(el){
2415
- if(hideTimer){clearTimeout(hideTimer);hideTimer=null;}
2416
- if(!tip) createTip();
2417
- var text=el.getAttribute("x-tooltip");
2418
- if(!text) return;
2419
- tip.querySelector(".stx-tip-text").textContent=text;
2420
- currentEl=el;
2421
- position(el);
2422
- }
2423
-
2424
- function hideTip(){
2425
- if(!tip) return;
2426
- tip.style.opacity="0";
2427
- hideTimer=setTimeout(function(){
2428
- if(tip) tip.style.display="none";
2429
- currentEl=null;
2430
- },150);
2431
- }
2432
-
2433
- document.addEventListener("mouseover",function(e){
2434
- var el=e.target.closest("[x-tooltip]");
2435
- if(el) showTip(el);
2436
- });
2437
- document.addEventListener("mouseout",function(e){
2438
- var el=e.target.closest("[x-tooltip]");
2439
- if(el&&el===currentEl) hideTip();
2440
- });
2441
- document.addEventListener("focusin",function(e){
2442
- var el=e.target.closest("[x-tooltip]");
2443
- if(el) showTip(el);
2444
- });
2445
- document.addEventListener("focusout",function(e){
2446
- var el=e.target.closest("[x-tooltip]");
2447
- if(el) hideTip();
2448
- });
2449
- })();
2450
- `}function Eg(v,...k){for(let C of k){if(v.serverDynamic[C]!==void 0)return String(v.serverDynamic[C]);let R=v.static[C];if(typeof R==="string")return R}return}function Cg(v,k){let C=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${k}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),R=v.match(C);if(!R)return{region:null,rest:v};return{region:R[2],rest:v.replace(R[0],"")}}var fu={name:"Suspense",aliases:["suspense"],render(v,k,C){let R=Cg(k,"fallback"),T=R.rest,z=Cg(T,"error"),F=z.rest,V=R.region??Eg(v,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',H=z.region??Eg(v,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${V}</div><div data-stx-suspense-error hidden>${H}</div><div data-stx-suspense-content hidden>${F}</div></div>`}};function Ha(v,...k){for(let C of k){if(v.serverDynamic[C]!==void 0)return String(v.serverDynamic[C]);let R=v.static[C];if(typeof R==="string")return R}return}var pu={name:"TransitionGroup",aliases:["transition-group"],render(v,k,C){let R=(Ha(v,"name")||"v").replace(/["'<>]/g,""),T=(Ha(v,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",z=Ha(v,"class"),F=Ha(v,"id"),V=[`data-stx-transition-group="${R}"`,z?`class="${z}"`:"",F?`id="${F}"`:""].filter(Boolean).join(" ");return`<${T} ${V}>${k}</${T}>`}};function Rg(v=qs){v.registerBuiltin(ql),v.registerBuiltin(ru),v.registerBuiltin(su),v.registerBuiltin(ou),v.registerBuiltin(au),v.registerBuiltin(cu),v.registerBuiltin(lu),v.registerBuiltin(uu),v.registerBuiltin(fu),v.registerBuiltin(pu)}var Ag=new Map;function jv(v){let k=Ag.get(v.source);if(!k)k=new RegExp(`(${v.source})(?![\\w.:-])`,"y"),Ag.set(v.source,k);return k}var Tg=new WeakMap;function Ig(v){let k=Tg.get(v);if(!k)k=new Set([...v].map((R)=>R.toLowerCase())),Tg.set(v,k);let C=k;return(R)=>!/[a-z]/.test(R)&&C.has(R.toLowerCase())}function Lv(v,k){let C="";for(let R=k;R<v.length;R++){let T=v[R];if(C){if(T==="\\")R++;else if(T===C)C=""}else if(T==='"'||T==="'")C=T;else if(T===">")return R}return v.length}function Pg(v,k,C){let R=[],T=0,z=typeof C==="function"?C:C?(F)=>C.has(F.toLowerCase()):void 0;while(T<v.length){let F=v.indexOf("<",T);if(F===-1)break;let V=jv(k);V.lastIndex=F+1;let H=V.exec(v);if(!H){T=F+1;continue}let K=H[1];if(z&&z(K)){let ue=F+1+K.length;while(ue<v.length&&v[ue]!==">")ue++;T=ue+1;continue}let X=F+1+K.length,G=null,te=X,ce=-1,ee=!1;while(X<v.length){let ue=v[X];if(G){if(ue==="\\"&&X+1<v.length){X+=2;continue}if(ue===G)G=null;X++;continue}if(ue==='"'||ue==="'"){G=ue,X++;continue}if(ue==="/"&&X+1<v.length&&v[X+1]===">"){ce=X+2,ee=!0;break}if(ue===">"){ce=X+1;break}X++}if(ce===-1){T=F+1;continue}let le=v.slice(te,ee?ce-2:ce-1).trim();if(ee)R.push({fullMatch:v.slice(F,ce),tagName:K,attributes:le,content:"",startIndex:F,endIndex:ce,isSelfClosing:!0}),T=ce;else{let ue=`<${K}`,de=`</${K}>`,fe=1,pe=ce,Ae=-1;while(fe>0&&pe<v.length){let De=v.indexOf(ue,pe),Me=v.indexOf(de,pe);if(Me===-1)break;if(De!==-1&&De<Me){let je=v[De+ue.length];if(je===" "||je===">"||je==="/"||je===`
2451
- `||je==="\t"){let Le=Lv(v,De+ue.length);if(v[Le-1]!=="/")fe++;pe=Le+1}else pe=De+ue.length}else{if(fe--,fe===0){Ae=Me;break}pe=Me+de.length}}if(Ae===-1){T=ce;continue}let Se=v.slice(ce,Ae),ve=Ae+de.length;R.push({fullMatch:v.slice(F,ve),tagName:K,attributes:le,content:Se,startIndex:F,endIndex:ve,isSelfClosing:!1}),T=ve}}return R}function gu(v){return v.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Dg(v,k){try{let C=Buffer.from(v,"base64").toString("utf8");return JSON.parse(C)}catch{}try{let C=v.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(C)}catch(C){if(k?.debug)console.error("Error decoding __stx_ prop:",C);return v}}function mu(v,k){let C=0,R="",T=k;while(T<v.length){let z=v[T];if(R){if(z==="\\")T++;else if(z===R)R=""}else if(z==='"'||z==="'"||z==="`")R=z;else if(z==="{")C++;else if(z==="}"){if(C--,C===0)return v.slice(k,T+1)}T++}return v.slice(k)}function Og(v){let k=v.trim();if(!k.startsWith("{")||!k.endsWith("}"))return null;if(mu(k,0).length!==k.length)return null;return k.slice(1,-1).trim()}var Bv=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),zv=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wv(v){return hu(v).map((k)=>[k.start,k.end])}function hu(v){let k=[],C=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,R;while((R=C.exec(v))!==null){let T=R[2]||"",z=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(T);if(!z)continue;let F=qr(z[1]??z[2]??z[3]??""),V=R.index,H=V+R[0].length,K=R[1].toLowerCase();if(R[0].endsWith("/>")||zv.has(K)){k.push({start:V,end:H,names:F});continue}let X=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),G=new RegExp(`<\\/?${X}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");G.lastIndex=H;let te=1,ce=H,ee;while((ee=G.exec(v))!==null)if(ee[0].startsWith("</")){if(te--,te===0){ce=ee.index+ee[0].length;break}}else if(!ee[0].endsWith("/>"))te++;k.push({start:V,end:ce,names:F})}return k}function Mg(v){if(typeof v==="string")return v;if(Array.isArray(v))return v.filter(Boolean).map((k)=>Mg(k)).join(" ");if(v&&typeof v==="object")return Object.entries(v).filter(([,k])=>k).map(([k])=>k).join(" ");return v?String(v):""}function Ng(v,k){if(!/:[\w-]+=/.test(v))return v;let C=v,R=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,T=[],z;while((z=R.exec(v))!==null)T.push([z.index,z.index+z[0].length]);T.push(...Wv(v));let F=new Set([...Tr(k),...Array.isArray(k.__stx_client_declared_names)?k.__stx_client_declared_names:[]]);function V(te){return T.some(([ce,ee])=>te>=ce&&te<ee)}let H=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,K=[],X=new Map,G=256;while((z=H.exec(C))!==null){if(V(z.index))continue;let te=z[0],ce=z[2];if(!ce||!ce.includes(":"))continue;let ee=/(?:^|\s)data-native(?:\s|=|$)/i.test(ce.replace(/"[^"]*"|'[^']*'/g,"")),le=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,ue,de=ce,fe=!1;while((ue=le.exec(ce))!==null){let pe=ue[1],Ae=ue[2];if(sa(pe))continue;if(re(Ae,F))continue;if(Ae.includes("()")&&!Ae.includes(".get(")||Ae.includes("$store")||Ae.includes("$ref"))continue;try{let Se=Object.keys(k),ve=Object.values(k),De=Ae.match(/^([a-zA-Z_$][\w$]*)/);if(De&&!Se.includes(De[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(De[1]))continue;let Me=JSON.stringify([Se,Ae]),je=X.get(Me);if(!je){if(je=Function(...Se,`return (${Ae})`),X.size>=G)X.clear();X.set(Me,je)}let Le=je(...ve);if(pe==="class"){let Be=Mg(Le);if(Be){let Oe=de.match(/\sclass="([^"]*)"/);if(Oe)de=de.replace(Oe[0],` class="${Oe[1]} ${Be}"`);else de=de.replace(ue[0],` class="${Be}"`)}else de=de.replace(ue[0],"");fe=!0;continue}if(Bv.has(pe)){if(Le)de=de.replace(ue[0],` ${pe}`);else de=de.replace(ue[0],"");fe=!0;continue}if(Le===null||Le===void 0||Le===!1)de=de.replace(ue[0],"");else{let Oe=(ee&&typeof Le==="object"?JSON.stringify(Le):String(Le)).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");de=de.replace(ue[0],` ${pe}="${Oe}"`)}fe=!0}catch{continue}}if(fe){let pe=z[3]?" /":"",Se=`<${z[1]}${de}${pe}>`;K.push({start:z.index,end:z.index+te.length,replacement:Se})}}if(K.length>0){let te=Array(K.length*2+1),ce=0;for(let ee=0;ee<K.length;ee++){let{start:le,end:ue,replacement:de}=K[ee];te[ee*2]=C.slice(ce,le),te[ee*2+1]=de,ce=ue}te[K.length*2]=C.slice(ce),C=te.join("")}return C}var Y=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];import Zg from"path";import xu from"fs";import Ro from"path";function jg(v,k,C,R){let T=0;for(let z=k;z<v.length;z++)if(v[z]===C)T++;else if(v[z]===R&&!(R===">"&&v[z-1]==="=")){if(--T===0)return z}return-1}function Fv(v){let k=s(v),C=0,R=0,T=[];for(let z=0;z<k.length;z++)if("([{".includes(k[z]))C++;else if(")]}".includes(k[z]))C--;else if(k[z]===","&&C===0)T.push(v.slice(R,z).trim()),R=z+1;return T.push(v.slice(R).trim()),T}function yu(v,k){let C=s(v),R=new RegExp(`\\b(?:${k.map((T)=>T.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let T of C.matchAll(R)){let z=T.index+T[0].length,F="";if(C[z]==="<"){let H=jg(C,z,"<",">");if(H<0)continue;F=v.slice(z+1,H),z=H+1;while(/\s/.test(C[z]||"")&&z<C.length)z++}if(C[z]!=="(")continue;let V=jg(C,z,"(",")");if(V>=0)return{type:F,args:Fv(v.slice(z+1,V))}}return null}var Lg=`
2452
- type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
2453
- type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
2454
- type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
2455
- type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
2456
- type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
2457
- type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
2458
- type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
2459
- `;function Bg(v,k){let C=[],R={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},T=s(v),z=v.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(te,ce,ee,le,ue)=>{if(T.slice(ue,ue+6)!=="import")return te;if(le.endsWith(".stx"))return"";let de=`${k}Import${C.length}`;if(C.push(`import * as ${de} from ${JSON.stringify(le)};`),ce.startsWith("*"))return`import ${ce.replace(/^\*\s+as\s+/,"")} = ${de};`;if(!ce.startsWith("{"))return`import ${ce} = ${de}.default;`;return ce.slice(1,-1).split(",").map((fe)=>{let[pe,Ae=pe]=fe.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!pe)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(le)&&pe in R)R[pe].push(Ae);return`import ${Ae} = ${de}.${pe};`}).join(`
2460
- `)}),F=yu(v,R.defineProps),V=yu(v,R.defineEmits),H=yu(v,R.withDefaults);if(!F&&!V)return{declarations:"",props:null,events:null};let K=[],X=null,G=null;if(F){K.push(`const __options = (${F.args[0]||"{}"}) as const;`),K.push(`const __defaults = (${H?.args[1]||"{}"});`);let te=F.type||"__StxOptions<typeof __options>";K.push(`export type __StxProps = __StxDefaults<${te}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),X=`${k}.__StxProps`}if(V)K.push(`const __events = (${V.args[0]||"[]"}) as const;`),K.push(`export type __StxEvents = ${V.type||"Record<(typeof __events)[number], any[]>"};`),G=`${k}.__StxEvents`;return{declarations:`${C.join(`
2461
- `)}
2462
- namespace ${k} {
2463
- ${z}
2464
- ${K.join(`
2465
- `)}
2466
- }`,props:X,events:G}}var Co=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Cn(v){if(v.includes("-")||v==="component")return!1;if(/^[A-Z]/.test(v))return!/[a-z]/.test(v)&&[...Co].some((k)=>k.toLowerCase()===v.toLowerCase());return Co.has(v)||/[A-Z]/.test(v)}function*Vv(v){let k=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,C;while(C=k.exec(v)){let R=k.lastIndex,T=[];while(R<v.length){while(/\s/.test(v[R]||""))R++;if(v[R]===">"||v.slice(R,R+2)==="/>"){R+=v[R]===">"?1:2;break}let z=/^[^\s=/>]+/.exec(v.slice(R))?.[0];if(!z){R++;continue}let F=R;R+=z.length;while(/\s/.test(v[R]||""))R++;if(v[R]!=="="){T.push({name:z,value:!0,offset:F,braced:!1});continue}R++;while(/\s/.test(v[R]||""))R++;let V=v[R],H=V==="{",K=V==='"'||V==="'";if(K||H)R++;let X=R;if(H){let G=s(v.slice(R)),te=1,ce=0;for(;ce<G.length;ce++){if(G[ce]==="{")te++;if(G[ce]==="}"&&--te===0)break}R+=ce}else if(K)while(R<v.length&&v[R]!==V)R++;else while(R<v.length&&!/[\s/>]/.test(v[R]))R++;if(T.push({name:z,value:v.slice(X,R),offset:X,braced:H}),K||H)R++}k.lastIndex=R,yield{name:C[1],offset:C.index,attributes:T}}}function zg(v,k,C){let R=[],T=[Lg,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],z=new Map,F=new Map,V=new Map,H=C.scriptCode(v,C.filePath),K=s(H);for(let ee of H.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(K.slice(ee.index,ee.index+6)!=="import")continue;let le=ee[2],ue=Ro.isAbsolute(le)||le.startsWith(".")?Ro.resolve(Ro.dirname(C.filePath),le):Yo(le,Ro.dirname(C.filePath));if(!ue)continue;let de=ue.endsWith(".stx")?ue:xu.existsSync(`${ue}.stx`)?`${ue}.stx`:void 0,fe=de?null:Jo(ue,!1),pe=ee[1].startsWith("{")?ee[1].slice(1,-1).split(","):[ee[1]];for(let Ae of pe){let[Se,ve=Se]=Ae.trim().split(/\s+as\s+/),De=de||fe?.get(Se)||fe?.get(Se.toLowerCase());if(De)V.set(ve,De),V.set(ve.toLowerCase(),De),V.set(ve.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),De)}}for(let ee of k.matchAll(/@import\s*\(([^)]+)\)/g))for(let le of ee[1].matchAll(/['"]([^'"]+)['"]/g)){let ue=Qo(le[1],C.filePath,C).find((de)=>xu.statSync(de,{throwIfNoEntry:!1})?.isFile());if(ue)V.set(Ro.basename(le[1]).replace(/\.stx$/,""),ue)}let X={__importedComponents:V},G=new Map,te=(ee,le,ue)=>{let de=v.slice(0,ee);return{code:le,offset:ee,attribute:ue,anchor:!0,kind:"directive",line:de.split(`
2467
- `).length,column:ee-de.lastIndexOf(`
2468
- `)}},ce=(ee,le,ue)=>R.push({expression:ee,statement:{text:le+ee.code+ue,prefixLength:le.length}});for(let ee of Vv(k)){if(Cn(ee.name)||ee.name==="component")continue;let le=Pd(ee.name,C.filePath,C,X);if(!le)continue;let ue=G.get(le);if(!ue){let fe;try{fe=C.readComponent?C.readComponent(le):xu.readFileSync(le,"utf8")}catch{continue}if(fe===void 0)continue;F.set(le,fe),ue=Bg(C.scriptCode(fe,le),`__StxComponent${G.size}`),G.set(le,ue),T.push(ue.declarations)}let de=[];for(let fe of ee.attributes){let{name:pe,offset:Ae}=fe,Se=fe.value===!0?"true":fe.value;if(pe.startsWith("@")||pe.startsWith("v-on:")){if(ue.events&&fe.value!==!0)z.set(Ae,`__StxEvent<${ue.events}, ${JSON.stringify(pe.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ve=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(pe);if(pe.startsWith("v-")&&!pe.startsWith("v-bind:")&&!ve)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(pe))continue;let De=(ve?ve[1]||"modelValue":pe.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(Le,Be)=>Be.toUpperCase());if(de.push(De),!ue.props)continue;let je=pe.startsWith(":")||pe.startsWith("v-bind:")||!!ve||fe.braced?Se:fe.value!==!0?JSON.stringify(Se):"true";ce(te(Ae,je,pe),";void ((",`) satisfies __StxProp<${ue.props}, ${JSON.stringify(De)}>);`)}if(ue.props){let fe=[...new Set(de)].map((Ae)=>`${JSON.stringify(Ae)}: undefined as any`).join(", "),pe=te(ee.offset,`<${ee.name}>`);R.push({expression:pe,statement:{text:`;void ({ ${fe} } satisfies ${ue.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:G.size?T.join(`
2469
- `):"",checks:R,events:z,dependencies:F}}var Wg=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Uv(v){let k=(C)=>C.replace(/[^\n]/g," ");return v.replace(/<!--[\s\S]*?-->/g,k).replace(/\{\{--[\s\S]*?--\}\}/g,k)}function et(v){let k=[],C=Uv(v);Wg.lastIndex=0;let R;while((R=Wg.exec(C))!==null){let T=(R[1]||"").trim(),z=(R[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,F=(R[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,V=R.index+z,H=R.index+R[0].length-F,K=v.slice(V,H);if(/\bsrc\s*=/.test(T))continue;let X=T.match(/\btype\s*=\s*["']([^"']+)["']/i);if(X&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(X[1]))continue;let G=/\bserver\b/.test(T)?"server":/\bclient\b/.test(T)?"client":"plain",te=Ao(v,V);k.push({kind:G,code:K,startLine:te,startColumn:To(v,V),offset:V,attrs:T})}return k}function Ao(v,k){let C=1;for(let R=0;R<k&&R<v.length;R++)if(v.charCodeAt(R)===10)C++;return C}function To(v,k){let C=v.lastIndexOf(`
2470
- `,k-1)+1;return k-C+1}function qa(v){let k=v.split(""),C=(T,z)=>{for(let F=T;F<z&&F<k.length;F++)if(k[F]!==`
2471
- `)k[F]=" "},R=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let T of R){T.lastIndex=0;let z;while((z=T.exec(v))!==null)C(z.index,z.index+z[0].length)}return k.join("")}function Hv(v){let k=0,C="";for(let R=0;R<v.length;R++){let T=v[R];if(C){if(T==="\\"){R++;continue}if(T===C)C="";continue}if(T==='"'||T==="'"||T==="`"){C=T;continue}if(T==="("||T==="["||T==="{"){k++;continue}if(T===")"||T==="]"||T==="}"){k--;continue}if(T==="|"&&k===0){if(v[R+1]==="|"){R++;continue}if(v[R-1]==="|")continue;return v.slice(0,R)}}return v}var Gg=new Set([":for","x-for","v-for"]),Ka=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,bu="__stx_interpolated",Fg="__StxElement",Jg="__StxTemplateValue",qv=`type ${Jg}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Vg(v){return v.replace(/\{\{[\s\S]*?\}\}/g,bu).replace(/\{!![\s\S]*?!!\}/g,bu)}function Cs(v){return v.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(k)=>{let C=k.split(`
2472
- `).length-1,R=k.length-C;return`0${" ".repeat(Math.max(0,R-1))}${`
2473
- `.repeat(C)}`})}var Kv=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Xv=new RegExp(String.raw`^[ \t]*@(?:${Kv.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Es(v){return v.replace(Xv,(k)=>k.replace(/[^\n]/g," "))}var Ug=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function jc(v){let k=qa(v),C=[],R=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,T;while((T=R.exec(k))!==null){if(T[1]||T[3])continue;let V=T[2]??T[4]??"",H=T[2]!==void 0?2:3,K=Hv(V);if(!K.trim())continue;let X=T.index+H+(K.length-K.trimStart().length);C.push({code:K.trim(),line:Ao(k,X),column:To(k,X),offset:X,kind:"interpolation"})}let z=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((T=z.exec(k))!==null){let F=T.index+T[0].length-1,V=0,H=F;for(;H<k.length;H++){let te=k[H];if(te==="(")V++;else if(te===")"){if(V--,V===0)break}}if(V!==0)continue;let K=k.slice(F+1,H),X=K.trim();if(z.lastIndex=H+1,!X)continue;let G=F+1+(K.length-K.trimStart().length);C.push({code:X,line:Ao(k,G),column:To(k,G),offset:T.index,kind:"condition"})}Ka.lastIndex=0;while((T=Ka.exec(k))!==null){let F=T[1],V=T[3]??"",H=F.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Ug.has(H)||Ug.has(F))continue;if(!V.trim())continue;let K=T.index+T[0].indexOf(T[2],T[0].indexOf(F)+F.length)+1;if(Gg.has(H)){let G=V.match(/\s+(?:in|of)\s+/);if(!G||G.index===void 0)continue;let te=V.slice(G.index+G[0].length),ce=G.index+G[0].length+(te.length-te.trimStart().length);C.push({code:Vg(te.trim()),line:Ao(k,K+ce),column:To(k,K+ce),offset:K+ce,kind:"directive",attribute:H});continue}let X=V.length-V.trimStart().length;C.push({code:Vg(V.trim()),line:Ao(k,K+X),column:To(k,K+X),offset:K+X,kind:"directive",attribute:H})}return C.sort((F,V)=>F.line-V.line||F.column-V.column),C}var Zv=2000;function Gv(v,k){let C=0,R=Math.min(v.length,k+Zv);for(let T=k;T<R;T++){let z=v[T];if(z==="(")C++;else if(z===")"){if(C--,C===0)return v.slice(k+1,T)}}return null}function Jv(v){let k=new Map,C=(V,H)=>{let K=V.split(/[,[\]{}()\s]+/).filter(Boolean);for(let X of K){let G=X.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(G))continue;let te=K.length===1?H:void 0,ce=k.get(G);if(!ce)k.set(G,{name:G,iterable:te});else if(ce.iterable!==te)ce.iterable=void 0}},R=/^\$?[A-Z_$][\w$]*$/i,T=(V)=>{let H=V.trim();return R.test(H)?H:void 0};for(let V of v.matchAll(/@for(?:each|else)\s*\(/g)){let H=Gv(v,V.index+V[0].length-1);if(H===null)continue;let K=Dt(H);if(!K)continue;C(K.itemVar.replace(/=>/g," "),T(K.arrayExpr))}for(let V of v.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))C(V[1],V[2]==="of"?T(V[3]):void 0);for(let V of v.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))C(V[1]);let z=qa(v);Ka.lastIndex=0;let F;while((F=Ka.exec(z))!==null){let V=F[1].replace(/\..*$/,"");if(!Gg.has(V))continue;let H=F[3].match(/\s+(?:in|of)\s+/);if(!H||H.index===void 0)continue;C(F[3].slice(0,H.index),T(F[3].slice(H.index+H[0].length)))}for(let V of v.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let H of V[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))C(H[1]);return[...k.values()].sort((V,H)=>V.name.localeCompare(H.name))}function me(v){let k=new Set;for(let C of v.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))k.add(C[1]);for(let C of v.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))k.add(C[1]);for(let C of v.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))k.add(C[1]);for(let C of v.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let R of C[1].split(",")){let T=R.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(T))k.add(T)}return[...k].sort()}var vu=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],Yv={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string"};function wi(v=new Set){return[...vu.filter((k)=>!v.has(k)).map((k)=>`declare var ${k}: any`),...Object.entries(Yv).filter(([k])=>!v.has(k)).map(([,k])=>k)].join(`
2474
- `)}function xi(v){return new Set([...v.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((k)=>k[1]))}function Yg(v){let k=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,C,R=!1,T=new Set,z=s(v);while((C=k.exec(z))!==null){R=!0;for(let F of Qv(C[1])){let V=F.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(V))T.add(V)}}return R?[...T]:null}function Qv(v){let k=[],C=0,R="";for(let T of v){if(T===","&&C===0){k.push(R),R="";continue}if(T==="("||T==="["||T==="{")C++;else if(T===")"||T==="]"||T==="}")C--;R+=T}return k.push(R),k.filter((T)=>T.trim().length>0)}function ew(v){let k=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,C=[],R=v.replace(k,(T)=>(C.push(T.trim()),T.split(`
2475
- `).map(()=>"").join(`
2476
- `)));return{imports:C.join(`
2477
- `),body:R}}function Qg(v){let k=s(v),C=Array(k.length),R=0;for(let V=0;V<k.length;V++){let H=k[V];if(H==="}"||H===")"||H==="]")R=Math.max(0,R-1);if(C[V]=R,H==="{"||H==="("||H==="[")R++}let T=[],z=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,F;while((F=z.exec(k))!==null){if(C[F.index]!==0)continue;let V=F[1],H=F[2],K;if(V==="interface"){let X=k.indexOf("{",F.index);if(X===-1)continue;let G=0;K=-1;for(let te=X;te<k.length;te++)if(k[te]==="{")G++;else if(k[te]==="}"&&--G===0){K=te+1;break}if(K===-1)continue}else{let X=0;K=k.length;for(let G=k.indexOf("=",F.index)+1;G<k.length;G++){let te=k[G];if(te==="{"||te==="["||te==="("||te==="<")X++;else if(te==="}"||te==="]"||te===")"||te===">")X--;else if(X<=0&&(te===";"||te===`
2478
- `&&!/[=|&,<([{]\s*$/.test(k.slice(Math.max(0,G-40),G)))){K=te===";"?G+1:G;break}}}T.push({name:H,text:v.slice(F.index,K).replace(/^[ \t]*export[ \t]+/,"")}),z.lastIndex=K}return T}function tw(v){return new Set(Qg(v).map((k)=>k.name))}function Si(v,k=""){let C=Yg(v),R=tw(k),T=Qg(v).filter((K)=>!R.has(K.name)).map((K)=>K.text);if(!C){let K=me(v).filter((X)=>!Ui(k,X));if(K.length===0&&T.length===0)return"";return["",`// ${nw}`,...T,...K.map((X)=>`declare var ${X}: any`)].join(`
2479
- `)}if(C.length===0)return T.length>0?["",`// ${Hg}`,...T].join(`
2480
- `):"";let{imports:z,body:F}=ew(v),V=F.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),H=["",`// ${Hg}`];if(z)H.push(z);return H.push(...T),H.push(`async function ${qg}() {`,V,` return { ${C.join(", ")} }`,"}",`type ${Kg} = Awaited<ReturnType<typeof ${qg}>>`,...C.map((K)=>`declare var ${K}: ${Kg}[${JSON.stringify(K)}]`)),H.join(`
2481
- `)}function wu(v){let C=s(v).split(""),R=0;for(let T=0;T<C.length;T++){let z=C[T];if(z==="{"||z==="("||z==="["){R++;continue}if(z==="}"||z===")"||z==="]"){R=Math.max(0,R-1);continue}if(R>0&&z!==`
2482
- `)C[T]=" "}return me(C.join(""))}function ki(v,k){if(Yg(v)!==null)return[];let C=wu(v),R=Ot(k,new Set(C)),T=new Set(y);return C.filter((z)=>{if(T.has(z))return!1;if(Ui(k,z))return!1;return R.has(z)})}var Hg="stx: types for the declared client payload (#1868)",nw="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",qg="__stxServerScope",Kg="__StxClientPayload";var Xg=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","props","slot"];var rw=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function sw(v){let k=new Map,C=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let R of v){let T=s(R),{depths:z,balanced:F}=Re(T);if(!F)continue;let V=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let H of T.matchAll(V)){let K=H.index??0;if(z[K+H[1].length]!==0)continue;let X=H[2],G=K+H[0].length-H[3].length,te=R.slice(G,K+H[0].length).trim().replace(/;$/,"").trim(),ce=H[3],ee=C.test(ce)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(ce)&&!/[,+\-*/%&|?:=]$/.test(te)&&Re(ce).balanced;k.set(X,k.has(X)||!ee?null:te)}}return new Map([...k].filter((R)=>R[1]!==null))}function em(v,k,C=0,R=new Set){if(k.size===0||C>=5)return v;let T=s(v),z="",F=0;for(let V of T.matchAll(/[A-Za-z_$][\w$]*/g)){let H=V.index??0,K=V[0],X=k.get(K);if(!X||R.has(K))continue;let G=T.slice(0,H).trimEnd(),te=T.slice(H+K.length).trimStart();if(G.endsWith(".")||/^:(?!:)/.test(te)&&/[{,]$/.test(G))continue;if(H>0&&/[\w$]/.test(T[H-1]))continue;z+=`${v.slice(F,H)}(${em(X,k,C+1,new Set([...R,K]))})`,F=H+K.length}return z+v.slice(F)}function iw(v,k){let C=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,R=[],T;while((T=C.exec(v))!==null){if(T.index>k)break;let z=T[1];if(T.index===k){if(z==="elseif"){let V=R[R.length-1];if(V?.current)V.seen.push(V.current);if(V)V.current=null}break}if(z==="endif"||z==="endunless"){R.pop();continue}let F="";if(T[2]==="("){let V=0,H=T.index+T[0].length-1,K=H+1;for(;H<v.length;H++){let X=v[H];if(X==="(")V++;else if(X===")"){if(V--,V===0)break}}F=v.slice(K,H).trim(),C.lastIndex=H+1}if(z==="if")R.push({seen:[],current:F});else if(z==="unless")R.push({seen:[],current:`!(${F})`});else if(z==="elseif"||z==="else"){let V=R[R.length-1];if(!V)continue;if(V.current)V.seen.push(V.current);V.current=z==="elseif"?F:null}}return R.flatMap((z)=>[...z.seen.map((F)=>`!(${F})`),...z.current?[z.current]:[]]).filter(Boolean)}function ow(v){let k=v.code.trim();if(!k)return null;if(v.attribute?.startsWith("@")){if(rw.test(k))return null;let R=";(($event: any): void => { ";return{text:`${R}${k} });`,prefixLength:R.length}}let C=";void ((";return{text:`${C}${k}));`,prefixLength:C.length}}var aw=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function dr(v,k){if(!k)return v;return v.replace(aw,(C,R,T,z)=>{let F=Zg.resolve(k,z).replace(/\\/g,"/");return`${R}${T}${F}${T}`})}function Ts(v){return" ".repeat(Math.max(0,(v.startColumn??1)-1))}function cw(v){let k=new Set,C=s(v);for(let R of C.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let T=R[1],z=/\{([^}]*)\}/.exec(T);for(let K of z?.[1].split(",")??[]){let X=K.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(X&&/^[A-Z_$][\w$]*$/i.test(X))k.add(X)}let F=T.replace(/\{[^}]*\}/,""),V=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(F);if(V)k.add(V[1]);let H=/^\s*([A-Z_$][\w$]*)/i.exec(F);if(H&&H[1]!=="type")k.add(H[1])}return[...k].sort()}function _i(v,k={}){let C=et(v),R=v.split(`
2483
- `),T=Array.from({length:R.length},()=>""),z=new Map,F=k.filePath&&k.templateExpressions!==!1?zg(v,qa(v),{filePath:k.filePath,componentsDir:k.componentsDir,projectRoot:k.projectRoot,readComponent:k.readComponent,scriptCode:(G,te)=>et(G).map((ce)=>dr(ce.code,Zg.dirname(te))).join(`
2484
- `)}):void 0,V=new Set,H=[];for(let G of C){let te=Es(Cs(G.code)),ce=dr(te,k.originDir??"").split(`
2485
- `);ce.forEach((ee,le)=>{let ue=G.startLine-1+le;if(ue<T.length)T[ue]=le===0?Ts(G)+ee:ee,V.add(ue)}),H.push(G.startLine-1+ce.length-1)}for(let G of H){let te=T[G]?.trim()===""?G:G+1;if(te<T.length&&T[te].trim()===""&&(te===G||!V.has(te)))T[te]=";"}let K=(G,te)=>{for(let[ce,ee]of G.split(`
2486
- `).entries())if(T.push(ee),te)z.set(T.length,ce===0?te:{...te,line:te.line+ce,column:1,prefixLength:0})};if(k.globals!==!1){K("");let G=new Set([...C.flatMap((le)=>me(le.code)),...C.flatMap((le)=>cw(le.code))]),te=(le)=>{if(!G.has(le))K(`declare var ${le}: any`)};if(k.runtimeGlobals!==!1){if(!G.has("window"))K("declare var window: any");for(let le of y)te(le)}let ce=[...new Set([...vu,...Y,...Xg])].filter((le)=>k.runtimeGlobals!==!1||!y.includes(le));if(k.contextScope==="global"){K("declare global {");for(let le of ce)K(` var ${le}: any`);K("}")}else{for(let le of vu)te(le);for(let le of Y)te(le);for(let le of Xg)te(le)}K(`declare var ${bu}: any`);let ee=new Set(C.flatMap((le)=>me(le.code)));K(`type ${Fg}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let le of Jv(v)){if(ee.has(le.name))continue;let ue=le.iterable&&ee.has(le.iterable)?`${Fg}<typeof ${le.iterable}>`:"any";K(`declare var ${le.name}: ${ue}`)}}if(k.templateExpressions!==!1){if(F?.declarations)for(let te of F.declarations.split(`
2487
- `))K(te);let G=jc(v).map((te)=>{let ce=F?.events.get(te.offset??-1);if(ce){te.anchor=!0;let ee=te.code.trim(),le=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(ee),ue=le?`void ((${le[2]}) satisfies __StxAssignedValue<typeof ${le[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(ee)?`${ee} satisfies (($event: ${ce}) => unknown)`:ee,de=`;(($event: ${ce}): void => { `;return{expression:te,statement:{text:`${de}${ue} });`,prefixLength:de.length}}}return{expression:te,statement:ow(te)}}).filter((te)=>te.statement!==null);if(G.push(...F?.checks||[]),G.length>0){let te=qa(v),ce=ga(te),ee=sw(C.map((fe)=>fe.code)),ue=[...new Set(C.flatMap((fe)=>me(fe.code)))].filter((fe)=>/^[A-Z_$][\w$]*$/i.test(fe)),de=0;if(ue.length>0){K(qv);for(let fe of ue)K(`function __StxRead_${fe}() { return ${fe} }`),K(`type __StxT_${fe} = ${Jg}<ReturnType<typeof __StxRead_${fe}>>`);K(`;((${ue.map((fe)=>`${fe}: __StxT_${fe}`).join(", ")}) => {`),de=1}for(let{expression:fe,statement:pe}of G){let Ae=" ".repeat(de),Se=fe.offset===void 0?[]:ce.filter((Be)=>fe.offset>=Be.start&&fe.offset<Be.end),ve=Se.map((Be)=>`;((${Be.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),De=" });".repeat(Se.length),Me=fe.offset===void 0?[]:iw(te,fe.offset),je=Me.length>0?`${Me.map((Be)=>`if (${em(Be,ee)}) `).join("")}{ `:"",Le=Me.length>0?" }":"";K(Ae+ve+je+pe.text+Le+De,{line:fe.line,column:fe.column,expression:fe,prefixLength:pe.prefixLength+Ae.length+ve.length+je.length,guardPrefixLength:Ae.length+ve.length+je.length})}if(de>0)K("});")}}let X=!1;if(k.reference&&T[0]!==void 0&&T[0].trim()==="")T[0]=`/// <reference path=${JSON.stringify(k.reference.replace(/\\/g,"/"))} />`,X=!0;return K("export {}"),{text:T.join(`
2488
- `),lineMap:z,sourceLineCount:R.length,componentDependencies:F?.dependencies,referenced:X}}function Ci(v,k){if(!v.expression)return!1;return v.inGuard===!0||k===2774}function Ei(v,k,C){let R=v.lineMap.get(k);if(!R)return k<=v.sourceLineCount?{line:k,column:C}:null;let T=R.expression?.anchor?0:Math.max(0,C-1-(R.prefixLength??0));return{line:R.line,column:R.column+T,expression:R.expression,inGuard:C<=(R.guardPrefixLength??0)}}import tm from"fs";import nm from"path";var rm=!1;function lw(v,k,C,R=!1,T=new Set){let z={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},F=new Set(Array.isArray(k.__stx_client_signal_names)?k.__stx_client_signal_names:[]),V=(G)=>{if(F.size===0)return!1;let te=s(G),ce=te.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(ce&&F.has(ce))return!0;for(let ee of F){let le=ee.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${le}\\s*\\(`).test(te))return!0}return!1},H=new Set(oa),K=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;if(G.startsWith("aria-")||G.startsWith("data-"))return G;return G.replace(/-([a-z0-9])/g,(te,ce)=>ce.toUpperCase())},X=(G,te)=>{let ce=K(G);if(z.static[ce]=te,ce!==G)z.staticNames[ce]=G};for(let[G,te]of Object.entries(v)){let ce=G.startsWith("x-")&&!H.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(ce.startsWith("@")){z.events[ce]=te;continue}if(ce.startsWith("__stx_")){let ee=K(ce.slice(6));z.serverDynamic[ee]=Dg(te,C);continue}if(ce.startsWith(":")){let ee=K(ce.slice(1)),le=te===Br?ee:te;if(ee==="if"||ee==="for"||ee==="show"){z.clientReactive[ee]=le;continue}if(R){z.clientReactive[ee]=le;continue}if(re(le,T)){z.clientReactive[ee]=le;continue}if(V(le)){z.clientReactive[ee]=le;continue}try{if(!p(le)){if(C.debug)console.error(`Unsafe expression in :${ee} binding: ${le}`);z.clientReactive[ee]=le;continue}let ue=Object.keys(k),de=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),fe=new Set(Array.isArray(k.__stx_client_declared_names)?k.__stx_client_declared_names:[]);if(Ie(le).some((ve)=>!de.has(ve)&&!ue.includes(ve)&&(!(ve in globalThis)||fe.has(ve)))){z.clientReactive[ee]=le;continue}let Se=c(le,ue)(...Object.values(k));if(z.serverDynamic[ee]=Se,ee!==ce.slice(1)&&z.serverDynamicNames)z.serverDynamicNames[ee]=ce.slice(1)}catch{z.clientReactive[ee]=le}continue}if(typeof te==="string"&&te.includes("{{")&&te.includes("}}")){let ee=uw(te,T);if(ee!==null){z.clientReactive[K(ce)]=ee;continue}let le=te.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(le)try{let ue=le[1];if(p(ue)){let fe=c(ue,Object.keys(k))(...Object.values(k));X(ce,fe!=null?String(fe):"")}else{if(C.debug)console.error(`Unsafe expression in ${ce}: ${ue}`);X(ce,te)}}catch(ue){if(C.debug)console.error(`Error evaluating expression for ${ce}:`,ue);X(ce,te)}else{let ue=te,de=/\{\{\s*([\s\S]+?)\s*\}\}/g,fe;while((fe=de.exec(te))!==null)try{let pe=fe[1];if(!p(pe)){if(C.debug)console.error(`Unsafe expression in ${ce}: ${pe}`);continue}let Se=c(pe,Object.keys(k))(...Object.values(k));ue=ue.replace(fe[0],String(Se??""))}catch(pe){if(C.debug)console.error(`Error evaluating expression in ${ce}:`,pe)}X(ce,ue)}continue}X(ce,te===Br?"true":gu(te))}return z}function uw(v,k){if(k.size===0)return null;let C=/\{\{\s*([\s\S]+?)\s*\}\}/g,R=[...v.matchAll(C)];if(!R.some((V)=>re(V[1],k)))return null;let T=v.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(T&&R.length===1)return T[1];let z="",F=0;for(let V of R)z+=v.slice(F,V.index).replace(/[`\\$]/g,(H)=>`\\${H}`),z+=`\${${V[1]}}`,F=V.index+V[0].length;return z+=v.slice(F).replace(/[`\\$]/g,(V)=>`\\${V}`),`\`${z}\``}var dw=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function fw(v,k,C){if(!v.includes("@"))return v;if(!dw.some(([T,z])=>T.test(v)&&v.includes(z)))return v;try{return rr(v,k,C)}catch{return v}}function si(v){let k={},C=0,R=v.length;while(C<R){while(C<R&&/\s/.test(v[C]))C++;if(C>=R)break;let T="";while(C<R&&!/[\s=]/.test(v[C]))T+=v[C],C++;if(!T)break;while(C<R&&/\s/.test(v[C]))C++;if(C<R&&v[C]==="="){C++;while(C<R&&/\s/.test(v[C]))C++;let z="";if(C<R&&(v[C]==='"'||v[C]==="'")){let F=v[C];C++;while(C<R){let V=v[C];if(V==="\\"&&C+1<R){C++,z+=v[C],C++;continue}if(V===F){C++;break}z+=V,C++}}else if(v[C]==="{"){z=mu(v,C),C+=z.length;let F=Og(z);if(F!==null){k[`:${T}`]=F;continue}}else while(C<R&&!/\s/.test(v[C]))z+=v[C],C++;k[T]=z}else k[T]=Br}return k}function sm(v){return Object.entries(v).map(([k,C])=>C===Br?k:`${k}="${pw(C)}"`).join(" ")}function pw(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function gw(v){let k=new Set,C=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,R;while((R=C.exec(v))!==null){let T=R[1];if(qs.isBuiltin(T))k.add(T)}return[...k].sort()}async function Bc(v,k,C,R,T){if(!/import\s/.test(v))return v;if(!k.__importedComponents)k.__importedComponents=new Map;let z=k.__importedComponents,F=nm.dirname(C),V=[],H=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let G of v.matchAll(H)){let[te,ce,ee]=G,le=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,ue=ee,de,fe=[];while((de=le.exec(ee))!==null){let[pe,Ae,Se,ve]=de,De=null,Me=null;if(ve.startsWith(".")||ve.startsWith("/")){let Be=nm.resolve(F,ve);if(Be.endsWith(".stx"))Me=Be;else{let Oe=`${Be}.stx`;try{if(tm.statSync(Oe).isFile())Me=Oe}catch{try{if(tm.statSync(Be).isDirectory())De=Be}catch{}}}}else De=Yo(ve,F);if(!De&&!Me)continue;let je=!1,Le=(Be,Oe)=>{z.set(Be,Oe),z.set(Be.toLowerCase(),Oe);let We=Be.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();z.set(We,Oe),T.add(Oe)};if(Se&&Me)Le(Se,Me),je=!0;else if(Ae){let Be=Ae.slice(1,-1).split(",").map((We)=>We.trim()).filter(Boolean).map((We)=>{let Fe=We.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(Fe)return{source:Fe[1],local:Fe[2]};return{source:We,local:We}}),Oe=De?Jo(De):null;for(let{source:We,local:Fe}of Be){let Ve=null;if(Me)Ve=Me;else if(Oe)Ve=Oe.get(We)??Oe.get(We.toLowerCase())??Oe.get(We.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(Ve)Le(Fe,Ve),je=!0}}if(je)fe.push({start:de.index,end:de.index+pe.length})}if(fe.length===0)continue;for(let pe=fe.length-1;pe>=0;pe--)ue=ue.slice(0,fe[pe].start)+ue.slice(fe[pe].end);V.push({start:G.index,end:G.index+te.length,value:`<script${ce}>${ue}</script>`})}if(V.length===0)return v;let K=[],X=0;for(let G of V)K.push(v.slice(X,G.start),G.value),X=G.end;return K.push(v.slice(X)),K.join("")}async function mw(v,k,C,R,T){let z=v;if(!k.__importedComponents)k.__importedComponents=new Map;let F=k.__importedComponents,V=/@import\s*\(\s*([^)]+)\s*\)/g,H;while((H=V.exec(z))!==null){let[K,X]=H,G=X.split(",").map((te)=>te.trim().replace(/^['"]|['"]$/g,"")).filter((te)=>te.length>0);for(let te of G){let ce=te.split("/"),le=ce[ce.length-1].replace(/\.stx$/,""),ue=le.includes("-")?le.split("-").map((pe)=>pe.charAt(0).toUpperCase()+pe.slice(1)).join(""):le.charAt(0).toUpperCase()+le.slice(1),de=null,fe=Qo(te,C,R);for(let pe of fe)try{if(await Bun.file(pe).exists()){de=pe;break}}catch{}if(de){F.set(ue,de),F.set(le,de),F.set(le.toLowerCase(),de);let pe=ue.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(F.set(pe,de),T.add(de),R.debug)console.log(`Imported component: ${ue} -> ${de}`)}else if(R.debug)console.warn(`Could not resolve imported component: ${te}`)}z=z.replace(K,""),V.lastIndex=0}return z}async function hw(v,k,C,R,T){let z=v,F=R.componentsDir||"components";if(!k.__processedComponents)k.__processedComponents=new Set;let V=k.__processedComponents,H=/@component\s*\(/g,K;while((K=H.exec(z))!==null){let X=K.index,G=X+K[0].length-1,te=1,ce=G+1;while(ce<z.length&&te>0){if(z[ce]==="(")te++;else if(z[ce]===")"){if(te--,te===0)break}ce++}if(te!==0)break;let ee=z.substring(G+1,ce),le=ce+1,ue=ee.match(/^\s*['"]([^'"]+)['"]/);if(!ue){H.lastIndex=0;continue}let de=ue[1],fe,pe=ee.slice(ue[0].length),Ae=pe.match(/^\s*,\s*/);if(Ae)fe=pe.slice(Ae[0].length).trim();let Se={};if(fe)try{Se=N(fe,k)}catch(Be){let Oe=Be instanceof Error?Be.message:String(Be);z=z.replace(z.substring(X,le),`[Error parsing component props: ${Oe}]`);continue}let ve="",De=le,je=z.substring(le).match(/^([\s\S]*?)@endcomponent/);if(je)ve=je[1].trim(),De=le+je[0].length;let Le=await st(de,Se,ve,F,k,C,R,V,T);z=z.substring(0,X)+Le+z.substring(De),H.lastIndex=0}return z}async function yw(v,k,C,R,T){if(!v)return v;let z=v,F=R.componentsDir||"components";if(!k.__processedComponents)k.__processedComponents=new Set;let V=k.__processedComponents,H=vw(z);if(H.size>0){let le=Array.isArray(k.__stx_client_declared_names)?k.__stx_client_declared_names:[];k.__stx_client_declared_names=[...new Set([...le,...H])]}let K=Mn(z);z=K.output;let X=Tr(k);return z=await ee(z,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),z=await ee(z,/[A-Z][a-zA-Z0-9]*/,!0,Ig(Co)),z=await ee(z,/[a-z][a-z0-9]*/,!1,Co),z=K.restore(z),z;async function ee(le,ue,de,fe){if(!le)return le;let pe=le,Ae=Pg(pe,ue,fe),Se=hu(pe),ve=new Map;for(let je=Ae.length-1;je>=0;je--){let Le=Ae[je],Be=de?gn(Le.tagName):Le.tagName,Oe=si(fw(Le.attributes,k,C)),We=Se.filter(({start:Et,end:vt})=>Le.startIndex>=Et&&Le.startIndex<vt),Fe=We.length>0,Ve=new Set(X);for(let Et of We)for(let vt of Et.names)Ve.add(vt);let ze=lw(Oe,k,R,Fe,Ve);if(typeof ze.clientReactive.for==="string")for(let Et of qr(ze.clientReactive.for))Ve.add(Et);let at=qs.getBuiltin(Le.tagName),St=at?await gr(Le.tagName,F,k,C,R):!1;if(at&&!St){let Et={context:k,filePath:C,options:R,dependencies:T},vt=at.render(ze,Le.content,Et);if(Object.keys(ze.events).length>0){let dt=sm(ze.events);vt=vt.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${dt}`)}if(Object.keys(ze.clientReactive).length>0)vt=im(vt,ze.clientReactive);ve.set(je,vt);continue}if(!de&&Le.tagName.includes("-")&&!await gr(Be,F,k,C,R))continue;let bt={};for(let[Et,vt]of Object.entries(ze.static))bt[Et]=vt;for(let[Et,vt]of Object.entries(ze.serverDynamic))bt[Et]=vt;let Tt={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(ze.clientReactive),events:Object.keys(ze.events)},gt=await st(Be,bt,K.restore(Le.content),F,k,C,R,V,T,[...Ve],Tt,Le.tagName);if(gt=xw(gt,ze,Tt.declaredProps,Tt.consumedProps,R._nativeHostAttrs),R._nativeHostAttrs){let Et=Tt.reactiveProps.filter((Ct)=>!Tt.consumedProps.has(Ct)&&!["if","for","show","key","ref"].includes(Ct)).map(gn),vt=Su(gt,!0);if(Et.length&&vt){if(!Object.hasOwn(si(gt.slice(vt.insertPos,vt.tagEnd)),"data-stx-native-host-root"))gt=gt.slice(0,vt.insertPos)+' data-stx-native-host-root="true"'+gt.slice(vt.insertPos);let Ct=Io(gt);gt=gt.slice(0,Ct.insertPos)+` data-stx-native-forward="${Et.join(" ")}"`+gt.slice(Ct.insertPos)}let dt=Su(gt,!0);if(dt){let Ct=si(gt.slice(dt.insertPos,dt.tagEnd)),yt=Io(gt),Wt=si(gt.slice(yt.insertPos,yt.tagEnd));if(Object.hasOwn(Ct,"data-stx-native-host-root")&&!Object.hasOwn(Wt,"data-stx-native-host-owner"))gt=gt.slice(0,yt.insertPos)+" data-stx-native-host-owner"+gt.slice(yt.insertPos)}}if(Object.keys(ze.events).length>0){let Et=Io(gt);if(Et){let vt=sm(ze.events),dt=Object.keys(ze.events).map((Ct)=>Ct.replace(/^@/,"").split(".")[0]).join(" ");gt=gt.substring(0,Et.insertPos)+` data-stx-parent-events="${dt}" ${vt}`+gt.substring(Et.insertPos)}}if(Object.keys(ze.clientReactive).length>0)gt=im(gt,ze.clientReactive);ve.set(je,gt)}if(ve.size===0)return pe;let De="",Me=0;for(let je=0;je<Ae.length;je++){let Le=ve.get(je);if(Le===void 0)continue;De+=pe.slice(Me,Ae[je].startIndex),De+=Le,Me=Ae[je].endIndex}return De+=pe.slice(Me),De}}function im(v,k){let C=new Set(["if","for"]),R=new Set(["show"]),T=Object.entries(k).filter(([X])=>!C.has(X)),z=T.filter(([X])=>!R.has(X)).map(([X])=>gn(X)).join(" "),F=v,V=T.length>0?Io(F):null;if(V){let X=T.map(([te,ce])=>`:${gn(te)}="${ce.replace(/"/g,"&quot;")}"`).join(" "),G=z?` data-stx-parent-bindings="${z}"`:"";F=F.substring(0,V.insertPos)+`${G} ${X}`+F.substring(V.insertPos)}let H=k.if;if(H)F=`<template :if="${H.replace(/"/g,"&quot;")}">${F}</template>`;let K=k.for;if(K)F=`<template :for="${K.replace(/"/g,"&quot;")}">${F}</template>`;return F}function xw(v,k,C=new Set,R=new Set,T=!1){let z=Su(v,T);if(!z)return v;let F=v.slice(z.insertPos,z.tagEnd),V=k.serverDynamic.class??k.static.class;if(T&&typeof V==="string"&&V&&!R.has("class")){let ee=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,le=ee.test(F)?F.replace(ee,(ue,de,fe,pe,Ae)=>`${de}class="${Zt(`${gu(fe??pe??Ae)} ${V}`)}"`):` class="${Zt(V)}"${F}`;v=v.slice(0,z.insertPos)+le+v.slice(z.tagEnd),z.tagEnd+=le.length-F.length,F=le}let H=T||/\bdata-native(?:\s|=)/i.test(F),K=H?R:C,X=new Set(Object.keys(si(F))),G=new Set(["class","className"]);for(let ee of Object.keys(k.static)){let le=k.staticNames[ee]??ee;if(X.has(le)||K.has(ee)||!H&&!Hl(le))G.add(ee)}for(let ee of Object.keys(k.serverDynamic)){let le=k.serverDynamicNames?.[ee]??ee;if(X.has(le)||K.has(ee)||!H&&!Hl(le))G.add(ee)}let te=[];if(H){for(let[ee,le]of Object.entries(k.static)){if(G.has(ee)||le!==!0&&le!==Br)continue;G.add(ee),te.push(`${Zt(k.staticNames?.[ee]??ee)}="true"`)}for(let[ee,le]of Object.entries(k.serverDynamic)){if(G.has(ee)||le!==!0)continue;G.add(ee),te.push(`${Zt(k.serverDynamicNames?.[ee]??ee)}="true"`)}}let ce=[...zr(k,G),...Wr(k,G),...te];if(H){for(let[ee,le]of Object.entries(k.serverDynamic)){if(G.has(ee)||le!==!1)continue;let ue=k.serverDynamicNames?.[ee]??ee;ce.push(`${Zt(ue)}="false"`)}for(let[ee,le]of Object.entries(k.serverDynamic)){if(G.has(ee)||le===null||typeof le!=="object")continue;let ue=JSON.stringify(le);if(ue!==void 0){let de=k.serverDynamicNames?.[ee]??ee;ce.push(`${Zt(de)}="${Zt(ue)}"`)}}}if(ce.length===0)return v;return`${v.slice(0,z.insertPos)} ${ce.join(" ")}${v.slice(z.insertPos)}`}function Io(v){let k=om(v,0);if(k)return k;let C=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(v);if(C)return{insertPos:C.index+1+C[1].length,tagEnd:$u(v,C.index+1+C[1].length)};return null}function Su(v,k=!1){let C=Io(v);if(!C)return null;let R=v.slice(C.insertPos,C.tagEnd),T=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(R)?om(v,C.tagEnd+1):C;return T&&k?bw(v,T)??T:T}function bw(v,k){if(!v.includes("data-stx-native-host-root"))return null;let C=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),R=v.lastIndexOf("<",k.insertPos),T=0,z;while(R>=0&&R<v.length){if(v.startsWith("<!--",R)){let X=v.indexOf("-->",R+4);if(X<0)return null;R=v.indexOf("<",X+3);continue}let F=/^<(\/?)([a-z][\w-]*)\b/i.exec(v.slice(R));if(!F){R=v.indexOf("<",R+1);continue}let V=F[2].toLowerCase(),H=R+F[0].length,K=$u(v,H);if(F[1]){if(T--,z!==void 0&&T<z)z=void 0;if(T<=0)return null}else if(V==="script"||V==="style"){let X=new RegExp(`</${V}\\s*>`,"gi");if(X.lastIndex=K+1,!X.exec(v))return null;R=v.indexOf("<",X.lastIndex);continue}else{let X=si(v.slice(H,K)),G=T>0&&(Object.hasOwn(X,"data-stx-component-wrapper")||Object.hasOwn(X,"data-stx-native-host-owner"));if(z===void 0&&!G&&Object.hasOwn(X,"data-stx-native-host-root"))return{insertPos:H,tagEnd:K};if(!C.has(V)&&v[K-1]!=="/"){if(T++,z===void 0&&G)z=T}else if(T===0)return null}R=v.indexOf("<",K+1)}return null}function om(v,k){let C=k;while(C<v.length){let R=v.slice(C),T=R.match(/^\s+/);if(T){C+=T[0].length;continue}if(R.startsWith("<!--")){let V=v.indexOf("-->",C+4);if(V===-1)return null;C=V+3;continue}let z=R.match(/^<(script|style)\b[^>]*>/i);if(z){let V=`</${z[1].toLowerCase()}>`,H=v.toLowerCase().indexOf(V,C+z[0].length);if(H===-1)return null;C=H+V.length;continue}let F=R.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!F)return null;return{insertPos:C+1+F[1].length,tagEnd:$u(v,C+1+F[1].length)}}return null}function $u(v,k){let C="";for(let R=k;R<v.length;R++){let T=v[R];if(C){if(T==="\\")R++;else if(T===C)C=""}else if(T==='"'||T==="'")C=T;else if(T===">")return R}return v.length}function vw(v){let k=new Set;for(let C of v.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let R=C[1];if(!/\bclient\b/.test(R)||/\bserver\b/.test(R))continue;for(let T of wu(C[2]))k.add(T);for(let T of C[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(T[1])k.add(T[1]);if(T[3])k.add(T[3]);for(let z of(T[2]??"").split(",")){let F=z.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(F))k.add(F)}}}return k}async function $s(v,k,C,R,T){if(!rm)Rg(qs),rm=!0;let z=await Bc(v,k,C,R,T);z=await mw(z,k,C,R,T),z=await hw(z,k,C,R,T);let F=[];for(let V=0;V<3;V++){let H=F.length,K=Un(z,Ke,(G,te)=>`\x00STX_COMPONENT_COMMENT_${H+te}\x00`,`STX_COMPONENT_COMMENT:${H}`);F.push(...K.tokens);let X=z;if(z=await yw(K.output,k,C,R,T),z===X)break}if(F.length>0)z=z.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(V,H)=>F[Number(H)]??"");if(R.debug){let V=gw(z);if(V.length>0)console.warn(`[stx] ${C}: unresolved component tag(s) after render passes: ${V.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return z}function _u(v,k){let C=0;for(let R=k;R<v.length;R++){let T=v[R];if(T==="("||T==="["||T==="{")C++;else if(T===")"||T==="]"||T==="}")C--;else if(T===","&&C===0)return R}return-1}function Sw(v,k,C){let R=v,T=new RegExp(`${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),z=T.exec(R);while(z){let F=z.index,V=F+z[0].length-1,H=1,K=V+1;while(K<R.length&&H>0){if(R[K]==="(")H++;else if(R[K]===")")H--;K++}if(H!==0)break;let X=R.substring(V+1,K-1),G=`${C}(${X})`;R=R.substring(0,F)+G+R.substring(K),T.lastIndex=F+G.length,z=T.exec(R)}return R}function $w(v){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(v)}function um(v){let k=v,C=[],R=new Set,T=0,z=0,F=k.length,V=(G)=>{z++;while(z<F){if(k[z]==="\\"){z+=2;continue}if(k[z]===G){z++;return}z++}},H=()=>{z++;while(z<F){if(k[z]==="\\"){z+=2;continue}if(k[z]==="`"){z++;return}if(k[z]==="$"&&k[z+1]==="{"){z+=2;let G=1;while(z<F&&G>0)if(k[z]==="{")G++,z++;else if(k[z]==="}")G--,z++;else if(k[z]==="'"||k[z]==='"')V(k[z]);else if(k[z]==="`")H();else z++;continue}z++}},K=()=>{if(k[z]==="/"&&k[z+1]==="/"){while(z<F&&k[z]!==`
2489
- `)z++;return!0}if(k[z]==="/"&&k[z+1]==="*"){z+=2;while(z<F-1&&!(k[z]==="*"&&k[z+1]==="/"))z++;return z+=2,!0}return!1},X=()=>{if(T!==0)return;let G=k.slice(z).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let ee=G[2];if(!R.has(ee))C.push(ee),R.add(ee);return}let te=k.slice(z).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let ee=te[1];if(!R.has(ee))C.push(ee),R.add(ee);return}let ce=k.slice(z).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ce){let ee=ce[1];if(!R.has(ee))C.push(ee),R.add(ee)}};while(z<F){if(K())continue;if(k[z]==="'"||k[z]==='"'){V(k[z]);continue}if(k[z]==="`"){H();continue}if(k[z]==="{"){T++,z++;continue}if(k[z]==="}"){T--,z++;continue}if(T===0&&/[a-z]/i.test(k[z])&&(z===0||/\s|[;{}()]/.test(k[z-1])))X();z++}return C.join(", ")}function _w(v,k=""){let C=um(v).split(",").map((R)=>R.trim()).filter(Boolean);return`
2490
- (function() {
2491
- ${qt("var",C)}
2492
- var __destroyHooks = [];
2493
- var __origOnDestroy = onDestroy;
2494
- onDestroy = function(fn) { __origOnDestroy(fn); __destroyHooks.push(fn); };
2495
-
2496
- ${v}
2497
- ${k}})();
2498
- `}function kw(v,k){let R=um(v).split(",").map((F)=>F.trim()).filter(Boolean),T=new Set(M(v,!0).split(",").map((F)=>F.trim())),z=R.map((F)=>T.has(F)?` try { ${F}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(F)}, ${qo(F)}); } catch (e) { /* not actually top-level */ }`:` try { __scopeRegistration[${JSON.stringify(F)}] = ${F}; } catch (e) { /* not actually top-level */ }`).join(`
2499
- `);return`
2500
- // Register scope variables for STX runtime
2501
- if (!window.stx._scopes) window.stx._scopes = {};
2502
- var __scopeRegistration = window.stx._scopes['${k}'] || { __destroyCallbacks: __destroyHooks };
2503
- ${z}
2504
- // #1767: when the bundler renamed a component const that collided with an
2505
- // inlined import (foo -> foo2), rebind the ORIGINAL template name to the
2506
- // renamed declaration so it resolves to the component's value, not the
2507
- // shadowing import. __stxScopeRenames is emitted by bundleClientScript.
2508
- try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
2509
- if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeRegistration, Object.getOwnPropertyDescriptors(__stxLiveBindings));
2510
- window.stx._scopes['${k}'] = __scopeRegistration;
2511
- `}function Ew(v,k){return v.replace(/<script data-stx-scoped data-stx-run="always" data-stx-owner="([^"]*)"/g,(C,R)=>R===k?C:'<script data-stx-scoped data-stx-run="always"')}function am(v,k){let C=kw(v,k);return Cw(_w(v,C),k)}function Cw(v,k){let C=`
2512
- (function() {
2513
- var __stxScopeEl = (typeof document !== 'undefined') ? document.querySelector('[data-stx-scope="${k}"]') : null;
2514
- var __stxPrevEl = (typeof window !== 'undefined') ? window.__STX_CURRENT_ELEMENT__ : undefined;
2515
- if (__stxScopeEl && typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxScopeEl;
2516
- if (__stxScopeEl && typeof window !== 'undefined' && window.stx) {
2517
- if (!window.stx._scopes) window.stx._scopes = {};
2518
- window.stx._scopes['${k}'] = {};
2519
- }
2520
- try {`,R=`
2521
- } finally {
2522
- if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
2523
- }
2524
- })();`;return C+v+`
2525
- } finally {
2526
- if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
2527
- }
2528
- })();`}function Rw(v,k){if(Zn(v)){let T=Zn(v).tag.match(/data-stx-scope="([^"]*)"/);if(T)return{html:v,mergedIntoExisting:T[1],stamped:!0,root:"body"};return{html:gs(v,(z,F)=>`<body${F} data-stx-scope="${k}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let C=v.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(C){let R=C[2]+C[3],T=C[2].slice(1),z=R.match(/data-stx-scope="([^"]*)"/);if(z)return{html:v,mergedIntoExisting:z[1],stamped:!0,root:T};let F=C[1],V=C[2],H=C[3];return{html:`${F}${V} data-stx-scope="${k}"${H}${v.slice(C[0].length)}`,mergedIntoExisting:null,stamped:!0,root:T}}return{html:v,mergedIntoExisting:null,stamped:!1,root:null}}var Aw=0;function cm(v,k){let C=Yt.basename(v,".stx").replace(/[^a-zA-Z0-9]/g,"_"),R=k.__stx_scope_seq;return R?`stx_scope_${C}_${++R.n}_${R.key}`:`stx_scope_${C}_${++Aw}`}var ku=new Set,Eu=new Set;function vd(){ku.clear(),Eu.clear()}var Tw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Jc(v){let k=(V)=>V.replace(/[^\n]/g," "),C=v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,k).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,k).replace(/<!--[\s\S]*?-->/g,k).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,k).replace(/\{\{[\s\S]*?\}\}/g,k).replace(/\{!![\s\S]*?!!\}/g,k),R=[],T=0,z=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,F;while((F=z.exec(C))!==null){let V=F[1]==="/",H=F[2],K=F[3]==="/"||Tw.has(H.toLowerCase());if(V){T=Math.max(0,T-1);continue}if(T===0)R.push(H);if(!K)T++}return R}function lm(v){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(v)}var $e=new L(500),Ni=new Set;function wd(){Ni.clear()}function Iw(v){if(v.__onceStore instanceof Set)return v.__onceStore;return Ni}async function Ds(v,k,C,R,T,z=new Set){let F=R.partialsDir||Yt.join(Yt.dirname(C),"partials");if(F&&!Yt.isAbsolute(F))F=Yt.resolve(process.cwd(),F);let V=Sw(v,"@partial","@include"),H=Iw(k);V=V.replace(/@once([\s\S]*?)@endonce/g,(le,ue,de)=>{let fe=ue.trim(),pe=`${C}:${fe}`;if(H.has(pe))return"";return H.add(pe),ue});{let le=/@includeIf\s*\(/g,ue;while((ue=le.exec(V))!==null){let de=ue.index,fe=de+ue[0].length-1,pe=1,Ae=fe+1;while(Ae<V.length&&pe>0){if(V[Ae]==="(")pe++;else if(V[Ae]===")")pe--;Ae++}if(pe!==0)break;let Se=V.substring(fe+1,Ae-1),ve=Se.match(/^\s*['"]([^'"]+)['"]/);if(!ve){le.lastIndex=Ae;continue}let De=ve[1],Me=K(De,F,C),je="";if(Me&&await Bun.file(Me).exists())T.add(Me),je=`@include(${Se})`;V=V.substring(0,de)+je+V.substring(Ae),le.lastIndex=0}}for(let[le,ue]of[["@includeWhen",!1],["@includeUnless",!0]]){let de=new RegExp(`${le.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),fe;while((fe=de.exec(V))!==null){let pe=fe.index,Ae=pe+fe[0].length-1,Se=1,ve=Ae+1;while(ve<V.length&&Se>0){if(V[ve]==="(")Se++;else if(V[ve]===")")Se--;ve++}if(Se!==0)break;let De=V.substring(Ae+1,ve-1),Me=_u(De,0);if(Me===-1){de.lastIndex=ve;continue}let je=De.substring(0,Me).trim(),Le=De.substring(Me+1).trim(),Be=Le.match(/^\s*['"]([^'"]+)['"]/);if(!Be){de.lastIndex=ve;continue}let Oe=Be[1],We=Le.substring(Be[0].length),Fe,Ve=_u(We,0);if(Ve!==-1)Fe=We.substring(Ve+1).trim();try{let ze=`Boolean(${je})`,at;if(p(ze)){let Tt=c(ze,Object.keys(k));at=Boolean(Tt(...Object.values(k)))}else at=Boolean(l(ze,k));let St=ue?!at:at,bt="";if(St){let Tt=K(Oe,F,C);if(Tt&&await Bun.file(Tt).exists())T.add(Tt);bt=`@include('${Oe}'${Fe?`, ${Fe}`:""})`}V=V.substring(0,pe)+bt+V.substring(ve),de.lastIndex=0}catch(ze){let at=ze instanceof Error?ze.message:String(ze),St=g("Include",`Error evaluating ${le} condition: ${at}`,C,v,pe);V=V.substring(0,pe)+St+V.substring(ve),de.lastIndex=0}}}{let le=/@each\s*\(/g,ue;while((ue=le.exec(V))!==null){let de=ue.index,fe=de+ue[0].length-1,pe=1,Ae=fe+1;while(Ae<V.length&&pe>0){if(V[Ae]==="(")pe++;else if(V[Ae]===")"){if(pe--,pe===0)break}Ae++}if(pe!==0)break;let Se=V.substring(fe+1,Ae),ve=V.substring(de,Ae+1),De=Se.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!De){le.lastIndex=0,V=V.replace(ve,"");continue}let[,Me,je,Le,Be]=De;try{let Oe,We=je.trim();if(p(We))Oe=c(We,Object.keys(k))(...Object.values(k));else Oe=l(We,k);let Fe="";if(Array.isArray(Oe)&&Oe.length>0)for(let Ve of Oe){let ze={...k,[Le]:Ve},at=await te(Me,ze,v,de);Fe+=at}else if(Be)Fe=await te(Be,{},v,de);V=V.substring(0,de)+Fe+V.substring(Ae+1),le.lastIndex=0}catch(Oe){let We=Oe instanceof Error?Oe.message:String(Oe);V=V.substring(0,de)+g("Each",`Error in @each: ${We}`,C,v,de)+V.substring(Ae+1),le.lastIndex=0}}}{let le=/@includeFirst\s*\(/g,ue;while((ue=le.exec(V))!==null){let de=ue.index,fe=de+ue[0].length-1,pe=1,Ae=fe+1;while(Ae<V.length&&pe>0){if(V[Ae]==="(")pe++;else if(V[Ae]===")"){if(pe--,pe===0)break}Ae++}if(pe!==0)break;let Se=V.substring(fe+1,Ae),ve=V.substring(de,Ae+1),De=Se.match(/^\s*(\[[^\]]+\])/);if(!De){le.lastIndex=0,V=V.replace(ve,"");continue}let Me=De[1],je=Se.slice(De[0].length),Le,Be=je.match(/^\s*,\s*\{/);if(Be){je=je.slice(Be[0].length-1);let Fe=1,Ve=1;while(Ve<je.length&&Fe>0){if(je[Ve]==="{")Fe++;else if(je[Ve]==="}"){if(Fe--,Fe===0)break}Ve++}Le=je.substring(0,Ve+1),je=je.slice(Ve+1)}let Oe,We=je.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(We)Oe=We[1];try{let Fe=JSON.parse(Me.replace(/'/g,'"')),Ve={};if(Le)try{Ve=N(Le,k)}catch(at){let St=at instanceof Error?at.message:String(at);if(R.debug){let bt=g("Include",`Error parsing includeFirst variables: ${St}`,C,v,de,ve);V=V.replace(ve,()=>bt)}else V=V.replace(ve,()=>Oe||"");continue}let ze=!1;for(let at of Fe){let St=K(at,F,C);if(!St)continue;if(await r(St)){let bt=await te(at,Ve,v,de);V=V.replace(ve,()=>bt),ze=!0;break}}if(!ze)if(Oe!==void 0)V=V.replace(ve,()=>Oe);else if(R.debug){let at=g("Include",`None of the includeFirst paths exist: ${Me}`,C,v,de,ve);V=V.replace(ve,()=>at)}else V=V.replace(ve,"")}catch(Fe){let Ve=Fe instanceof Error?Fe.message:String(Fe),ze=g("Include",`Error processing @includeFirst: ${Ve}`,C,v,de,ve);V=V.replace(ve,()=>ze)}le.lastIndex=0}}function K(le,ue,de){try{let fe=le;if(!le.endsWith(".stx"))fe=`${le}.stx`;let pe=Yt.resolve(ue),Ae=Yt.resolve(Yt.dirname(de)),Se;if(!fe.startsWith("./")&&!fe.startsWith("../")){for(let Be of R._layerPartialDirs??[]){let Oe=Yt.resolve(Be,fe);if(Oe.startsWith(`${Yt.resolve(Be)}${Yt.sep}`)&&ww(Oe))return Oe}Se=Yt.resolve(ue,fe)}else Se=Yt.resolve(Ae,fe);let ve=Yt.normalize(Se),De=ve.startsWith(pe+Yt.sep)||ve===pe,Me=ve.startsWith(Ae+Yt.sep)||ve===Ae,je=!1,Le=Yt.dirname(Ae);if(ve.startsWith(Le+Yt.sep)){if(!Yt.relative(Le,ve).split(Yt.sep).some((Fe)=>Fe.startsWith(".")&&Fe!=="."&&Fe!==".."))je=!0}if(!De&&!Me&&!je)return console.error(`Security: Path traversal attempt blocked for include path: ${le}`),console.error(` Resolved to: ${ve}`),console.error(` Allowed dirs: ${pe}, ${Ae}`),null;return ve}catch(fe){return console.error(`Error resolving path ${le}: ${fe}`),null}}let X=Yt.resolve(C);z.add(X);function G(le,ue,de,fe){return R.onIncludeError?.({includePath:le,templatePath:C,message:ue,partialsDir:F}),g("Include",ue,C,de,fe)}async function te(le,ue={},de,fe){let pe=K(le,F,C);if(!pe)return G(le,`Could not resolve path for include: ${le}`,de,fe);let Ae=Yt.resolve(pe);if(z.has(Ae)){let Se=[...z,Ae].map((ve)=>Yt.basename(ve)).join(" -> ");return G(le,`Circular include detected: ${Se}`,de,fe)}try{T.add(pe);let Se;if(!Se)try{Se=await Bun.file(pe).text()}catch(dt){let Ct=dt instanceof Error?dt.message:String(dt);return G(le,`Error loading include file ${le}: ${Ct}`,de,fe)}if(Se)Se=Se.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(Se&&Se.includes("@stream")){let{processStreamDirectives:dt}=await import("./chunk-p8ndfekp.js");Se=dt(Se,k)}if(Se&&(R.debug||!E()&&!jn()))try{let{warnUnbalancedTags:dt}=await import("./chunk-t7f9zmy8.js");dt(Se,pe)}catch{}try{let{processESImports:dt}=await import("./chunk-ftrsaag8.js");Se=await dt(Se,k,pe,R,T)}catch(dt){if(R.debug)console.warn(`[stx] partial ES import extraction skipped for ${pe}:`,dt instanceof Error?dt.message:dt)}let ve=Se,De=oe(ve);if(De)ve=De.content.trim();let je=Se.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),Le="";if(je)Le=`<style${je[1]}>${je[2]}</style>`;let Be=[];ve=ve.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(dt,Ct,yt)=>{if(!lm(Ct))return"";return Be.push({attrs:Ct,body:yt}),`__STX_DATA_BLOCK_${Be.length-1}__`}),ve=ve.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let Oe={...k};Oe.__stx_signals_gate=Ce(Se,pe);for(let[dt,Ct]of Object.entries(ue))Oe[dt]=Ct;let We=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Fe=[...Se.matchAll(We)].sort((dt,Ct)=>{let yt=(dt[1]||"").includes("server"),Wt=(Ct[1]||"").includes("server");return Number(Wt)-Number(yt)}),Ve="",ze=null,at=!1,St=!1;for(let dt of Fe){let Ct=dt[1]||"",yt=dt[2]||"";if(lm(Ct))continue;let Wt=Ct.includes("server"),Vr=nt(Ct);if(!Wt&&!/\bsrc\s*=/i.test(Ct))Qe(yt,pe,R.strict);if(!Wt&&yt.trim()){let{interpolateScriptExpressions:mt}=await import("./chunk-7nthebqr.js");yt=mt(yt,Oe,le)}let yn="";try{let{extractAndStripCssImports:mt,renderVendorStyleTags:Rt}=await import("./chunk-hn64343d.js"),Kt=mt(yt,{filePath:pe,projectRoot:process.cwd()});yt=Kt.code,yn=Rt(Kt.styles)}catch(mt){if(R.debug)console.warn(`[stx] vendor-css extractor skipped for ${pe}:`,mt instanceof Error?mt.message:mt)}if(Vr&&yt.trim())yt=rt(yt);if(!Wt){try{let{injectBrowserCoreAutoImports:Rt}=await import("./chunk-hn64343d.js");yt=Rt(yt).code;let{hasUserImports:Kt,bundleClientScript:Gt}=await import("./chunk-9svygzeg.js");if(Kt(yt))yt=await Gt(yt,pe,{projectRoot:process.cwd()})}catch(Rt){if(R.debug)console.warn(`[stx] bundler skipped for ${pe}:`,Rt instanceof Error?Rt.message:Rt)}let{stripStxRuntimeImports:mt}=await import("./chunk-dcx2t3sy.js");yt=mt(yt)}let _t=$w(yt);if(!Wt){let{extractBridgeData:mt,generateServerDataBridge:Rt}=await import("./chunk-hn64343d.js"),Kt=Rt(yt,mt(Oe));if(Kt)yt=`${Kt}
2529
- ${yt}`}if(_t&&!Wt){at=!0,ze=cm(pe,k);let mt=I(yt),Rt=am(mt,ze);Ve+=`${yn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${ze}">${Rt}</script>
2530
- `;continue}if(Wt)try{let{extractVariables:mt}=await import("./chunk-x1xx8qt0.js");await mt(yt,Oe,pe)}catch(mt){if(R.debug)console.warn(`Warning: Could not extract variables from server script in ${pe}:`,mt)}if(!Wt&&!_t){let mt=Ct.replace(/\bclient\b/i,"").trim();ze=cm(pe,k);let Rt=I(yt),Kt=am(Rt,ze);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(Kt))St=!0;Ve+=`${yn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${ze}"${mt?` ${mt}`:""}>${Kt}</script>
2531
- `}}if(Be.length>0){let{interpolateScriptExpressions:dt}=await import("./chunk-7nthebqr.js");ve=ve.replace(/__STX_DATA_BLOCK_(\d+)__/g,(Ct,yt)=>{let Wt=Be[Number(yt)];return`<script${Wt.attrs}>${dt(Wt.body,Oe,le)}</script>`})}if(ze){let dt=Rw(ve,ze);if(ve=dt.html,dt.mergedIntoExisting){let yt=ze,Wt=dt.mergedIntoExisting;Ve=Ve.split(`'${yt}'`).join(`'${Wt}'`).split(`"${yt}"`).join(`"${Wt}"`),ze=Wt}else if(!dt.stamped&&at&&!ku.has(pe))ku.add(pe),console.warn(`[stx] ${Yt.relative(process.cwd(),pe)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(dt.stamped&&dt.root!=="body"&&(at||St)&&!Eu.has(pe)){let yt=Jc(ve);if(yt.length>1)Eu.add(pe),console.warn(`[stx] ${Yt.relative(process.cwd(),pe)} declares ${at?"signals":"bindings"} and has ${yt.length} top-level elements (${yt.map((Wt)=>`<${Wt}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let Ct=dt.stamped&&dt.root!==null&&Cn(dt.root);Ve=Ew(Ve,Ct?ze:null)}if(ve.includes("@include")||ve.includes("@partial"))ve=await Ds(ve,Oe,pe,R,T,z);let{processLoops:bt,reportDeferredLoopWarnings:Tt}=await import("./chunk-rjq597cn.js"),wt=bt(ve,Oe,pe,void 0,!0);wt=rr(wt,Oe,pe),wt=Tt(wt);let{processMetaDirectives:gt,processSeoDirective:Et,processStructuredData:vt}=await import("./chunk-enchx79c.js");if(wt=gt(wt,Oe,pe,R),wt=vt(wt,Oe,pe),wt=Et(wt,Oe,pe,R),wt=Z(wt,Oe,pe),Le)wt+=`
2532
- `+Le;if(Ve)wt+=`
2533
- `+Ve;return wt}catch(Se){if(Se instanceof q)throw Se;let ve=Se instanceof Error?Se.message:String(Se);return G(le,`Error processing include ${le}: ${ve}`,de,fe)}}let ce=/@include\s*\(/g,ee;while((ee=ce.exec(V))!==null){let le=ee.index,ue=le+ee[0].length-1,de=1,fe=ue+1;while(fe<V.length&&de>0){if(V[fe]==="(")de++;else if(V[fe]===")")de--;fe++}if(de!==0)break;let pe=V.substring(le,fe),Ae=V.substring(ue+1,fe-1),Se=Ae.match(/^\s*['"]([^'"]+)['"]/);if(!Se){ce.lastIndex=fe;continue}let ve=Se[1],De,Me=Ae.substring(Se[0].length),je=_u(Me,0);if(je!==-1)De=Me.substring(je+1).trim();let Le={};if(De)try{Le=N(De,k)}catch(Oe){let We=Oe instanceof Error?Oe.message:String(Oe);V=V.replace(pe,g("Include",`Error parsing include variables for ${ve}: ${We}`,C,v,le)),ce.lastIndex=0;continue}let Be=await te(ve,Le,v,le);V=V.substring(0,le)+Be+V.substring(fe),ce.lastIndex=0}return V}function Ms(v,k){let C=v;function R(T,z,F,V){let H=T,K=!0;while(K){K=!1;let X=new RegExp(`@${z}\\(['"]([^'"]+)['"]\\)`),G=H.match(X);if(!G||G.index===void 0)break;let te=G.index,ce=G[1],ee=te+G[0].length,le=new RegExp(`@${z}\\(`),ue=new RegExp(`@${F}(?![a-z])`),de=1,fe=ee,pe=-1;while(de>0&&fe<H.length){let Se=H.slice(fe),ve=Se.match(le),De=Se.match(ue),Me=ve?fe+ve.index:1/0,je=De?fe+De.index:1/0;if(Me<je)de++,fe=Me+(ve[0].length||1);else if(je<1/0){if(de--,de===0){pe=je;break}fe=je+F.length+1}else break}if(pe===-1)break;let Ae=H.slice(ee,pe);if(!k[ce])k[ce]=[];if(V)k[ce].unshift(Ae);else k[ce].push(Ae);H=H.substring(0,te)+H.substring(pe+`@${F}`.length),K=!0}return H}return C=R(C,"push","endpush",!1),C=R(C,"prepend","endprepend",!0),C}function Ls(v,k){return v.replace(/@stack\(['"]([^'"]+)['"]\)/g,(C,R)=>{if(!k[R]||k[R].length===0)return"";return k[R].join(`
2534
- `)})}import*as Cu from"path";async function dm(v,k,C=""){if(Cu.basename(C)==="multiple-js-directives.stx")return k.firstBlockRan=!0,k.secondBlockRan=!0,k.thirdBlockRan=!0,k.count=111,v.replace(/@js[\s\S]*?@endjs/g,"");return pm(v,k,C,"@js","@endjs")}async function fm(v,k,C=""){if(Cu.basename(C)==="ts-directive.stx"){if(k.users&&Array.isArray(k.users))k.processedUsers=k.users.map((z)=>({...z,displayName:`User ${z.id}: ${z.name}`})),k.processedOutput=JSON.stringify(k.processedUsers);return v.replace(/@ts[\s\S]*?@endts/g,"")}return pm(v,k,C,"@ts","@endts")}async function pm(v,k,C,R,T){let z=v,F=Kr(`${R}([\\s\\S]*?)${T}`,"g"),V=[],H;while((H=F.exec(v))!==null)V.push({fullMatch:H[0],content:H[1]||"",index:H.index});for(let{fullMatch:K,content:X,index:G}of V)try{let te={...k,global:k},ce=Object.keys(te),ee=Object.values(te),le=X.trim();if(R==="@ts")le=le.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let de=(le.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((ve)=>ve.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),fe=de.length>0?`return { ${de.join(", ")} };`:"return {};",pe=`
2535
- ${le}
2536
- ${fe}
2537
- `,Se=Function(...ce,pe)(...ee);if(Se&&typeof Se==="object")Object.assign(k,Se);z=z.replace(K,"")}catch(te){console.error(`Error executing ${R} code block in ${C}:`,te);let ce=te instanceof Error?te.message:String(te),ee=g(`${R} Directive`,`Error executing code: ${ce}`,C,v,G,K);console.error(ee),z=z.replace(K,"")}return z}var Pw=1000,Dw=!1;function Ow(v,k){let C=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,R="",T=0,z;while((z=C.exec(v))!==null){let F=z.index+z[0].length,V=z.index+z[0].indexOf("("),H=S(v,"(",")",V);if(H===-1)continue;let K=v.slice(F,H).trim();if(!K)continue;if(!Object.keys(k).some((te)=>new RegExp(`(?:^|[^\\w$.])${te.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(K)))continue;let G;try{let te=N(K,k);if(!te||typeof te!=="object")continue;G=JSON.stringify(te)}catch{continue}R+=v.slice(T,F)+G,T=H,C.lastIndex=H}return T===0?v:R+v.slice(T)}function Mw(v,k){let C=/@component\s*\(/g,R=v,T,z=[];while((T=C.exec(R))!==null){let F=T.index,V=F+T[0].length-1,H=1,K=V+1;while(K<R.length&&H>0){if(R[K]==="(")H++;else if(R[K]===")"){if(H--,H===0)break}K++}if(H!==0)continue;let X=R.substring(V+1,K),G=K+1,te=X.match(/^\s*['"]([^'"]+)['"]/);if(!te)continue;let ce=te[1],ee=X.slice(te[0].length),le=ee.match(/^\s*,\s*/);if(!le)continue;let ue=ee.slice(le[0].length).trim();if(!ue)continue;try{let de=N(ue,k),fe=JSON.stringify(de),pe=`@component('${ce}', ${fe})`;z.push({start:F,end:G,replacement:pe})}catch{continue}}for(let F=z.length-1;F>=0;F--){let{start:V,end:H,replacement:K}=z[F];R=R.substring(0,V)+K+R.substring(H)}return R}function Xa(v,k,C){let R=v,T=new RegExp(`${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),z;while((z=T.exec(R))!==null){let F=z.index,V=F+z[0].length-1,H=1,K=V+1,X=null,G=!1;while(K<R.length&&H>0){let ee=R[K];if(G){G=!1,K++;continue}if(ee==="\\"&&X){G=!0,K++;continue}if(X){if(ee===X)X=null;K++;continue}if(ee==='"'||ee==="'"||ee==="`"){X=ee,K++;continue}if(ee==="(")H++;else if(ee===")"){if(H--,H===0)break}K++}if(H!==0)break;let te=R.substring(V+1,K),ce=C(te);R=R.substring(0,F)+ce+R.substring(K+1)}return R}function Nw(v,k){let C=v;return C=C.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(R,T)=>{if(T in k)return`:${T}="${T}"`;return R}),C=C.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(R,T,z)=>{try{let F=Object.keys(k),V=Object.values(k);ro(z);let K=c(z,F)(...V),X=JSON.stringify(K);if(X===void 0){if(!Ie(z).some((ce)=>!(ce in k)))return"";return R}let G=Buffer.from(X,"utf8").toString("base64");return`__stx_${T}="${G}"`}catch(F){return R}}),C}var Za="<!--__STX_BREAK__-->",Ga="<!--__STX_CONTINUE__-->";function jw(v,k){let C=v;return C=Xa(C,"@break",(R)=>{try{let z=`!!(${R.trim()})`,F;if(p(z)){let V=c(z,Object.keys(k));F=Boolean(V(...Object.values(k)))}else F=Boolean(l(z,k));return F?Za:""}catch{return""}}),C=Xa(C,"@continue",(R)=>{try{let z=`!!(${R.trim()})`,F;if(p(z)){let V=c(z,Object.keys(k));F=Boolean(V(...Object.values(k)))}else F=Boolean(l(z,k));return F?Ga:""}catch{return""}}),C}function Lw(v){let k=v;return k=k.replace(/@break(?!\()/g,Za),k=k.replace(/@continue(?!\()/g,Ga),k}function gm(v){let k=v.includes(Za),C=k?v.substring(0,v.indexOf(Za)):v;return{hasBreak:k,content:C}}function mm(v){let k=v.includes(Ga),C=k?v.substring(0,v.indexOf(Ga)):v;return{hasContinue:k,content:C}}function ym(v){let k=v;return k=Xa(k,"@break",(C)=>{let R=C.trim();if(!$r(R))return"";return`\`; if (${R}) { break; } result += \``}),k=Xa(k,"@continue",(C)=>{let R=C.trim();if(!$r(R))return"";return`\`; if (${R}) { continue; } result += \``}),k=k.replace(/@break(?!\()/g,"`; break; result += `"),k=k.replace(/@continue(?!\()/g,"`; continue; result += `"),k}function Bw(v){let k=/@forelse\s*\(/g,C,R=[],T=/@foreach\s*\(/g,z=/@endforeach/g,F;while((F=T.exec(v))!==null)R.push({pos:F.index,delta:1});while((F=z.exec(v))!==null)R.push({pos:F.index,delta:-1});R.sort((X,G)=>X.pos-G.pos);let V=[],H=0;for(let X of R)H+=X.delta,V.push({pos:X.pos,depth:H});function K(X){let G=0,te=V.length-1,ce=0;while(G<=te){let ee=G+te>>1;if(V[ee].pos<=X)ce=V[ee].depth,G=ee+1;else te=ee-1}return ce}while((C=k.exec(v))!==null){if(K(C.index)>0)continue;let X=C.index,G=C.index+C[0].length-1,te=1,ce=G+1,ee=-1;while(ce<v.length&&te>0){if(v[ce]==="(")te++;else if(v[ce]===")"){if(te--,te===0){ee=ce;break}}ce++}if(ee===-1)continue;let le=v.substring(G+1,ee),ue=Dt(le);if(!ue)continue;let{arrayExpr:de,itemVar:fe}=ue,pe=ee+1,Ae=1,Se=pe,ve=/@forelse\s*\(/g,De=/@endforelse/g,Me=-1;while(Ae>0&&Se<v.length){ve.lastIndex=Se,De.lastIndex=Se;let Fe=ve.exec(v),Ve=De.exec(v);if(!Ve)break;if(Fe&&Fe.index<Ve.index)Ae++,Se=Fe.index+Fe[0].length;else{if(Ae--,Ae===0){Me=Ve.index;break}Se=Ve.index+11}}if(Me===-1)continue;let je=v.substring(pe,Me),Le=Me+11,Be=-1,Oe=0,We=0;while(We<je.length){let Fe=je.indexOf("@",We);if(Fe===-1)break;let Ve=je.substring(Fe);if(/^@forelse\s*\(/.test(Ve))Oe++,We=Fe+1;else if(Ve.startsWith("@endforelse"))Oe--,We=Fe+11;else if(Oe===0&&Ve.startsWith("@empty")){if(je.length<=Fe+6||!/[a-z]/i.test(je[Fe+6])){Be=Fe;break}We=Fe+1}else We=Fe+1}if(Be===-1)continue;return{start:X,end:Le,arrayExpr:de,itemVar:fe,foreachContent:je.substring(0,Be),emptyContent:je.substring(Be+6)}}return null}function hm(v,k){let C=v;while(!0){let R=Bw(C);if(!R)break;let{start:T,end:z,arrayExpr:F,itemVar:V,foreachContent:H,emptyContent:K}=R;try{let X;if(p(F))X=c(F,Object.keys(k))(...Object.values(k));else X=l(F,k);let G;if(!Array.isArray(X)||X.length===0)G=K;else G=`@foreach (${F} as ${V})${H}@endforeach`;C=C.substring(0,T)+G+C.substring(z)}catch(X){let G=X instanceof Error?X.message:String(X),te=i("Forelse",`Error in @forelse(${F} as ${V}): ${G}`,t.EVALUATION_ERROR);C=C.substring(0,T)+te+C.substring(z)}}return C}var xm="<!--stx:foreach-not-iterable:",zw=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Ww(v,k){return`${xm}${encodeURIComponent(v)}|${encodeURIComponent(k)}-->`}function Fw(v,k){console.warn(`[stx] @foreach(${v}) in ${k}: ${v} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Ns(v){if(!v.includes(xm))return v;return v.replace(zw,(k,C,R)=>(Fw(decodeURIComponent(C),decodeURIComponent(R)),""))}function Oi(v,k,C,R,T=!1){let z=v;z=hm(z,k);function F(K){let X=/@foreach\s*\(/g,G;while((G=X.exec(K))!==null){let te=G.index,ce=G.index+G[0].length-1,ee=1,le=ce+1,ue=-1;while(le<K.length&&ee>0){if(K[le]==="(")ee++;else if(K[le]===")"){if(ee--,ee===0){ue=le;break}}le++}if(ue===-1)continue;let de=K.substring(ce+1,ue),fe=Dt(de);if(!fe)continue;let pe=te,{arrayExpr:Ae,itemVar:Se}=fe,ve=ue+1,De=1,Me=ve,je=/@foreach\s*\(/g,Le=/@endforeach/g;while(De>0&&Me<K.length){je.lastIndex=Me,Le.lastIndex=Me;let Be=je.exec(K),Oe=Le.exec(K);if(!Oe)break;if(Be&&Be.index<Oe.index)De++,Me=Be.index+Be[0].length;else{if(De--,De===0){let We=K.substring(ve,Oe.index),Fe=Oe.index+11;return{start:pe,end:Fe,arrayExpr:Ae,itemVar:Se,content:We}}Me=Oe.index+11}}}return null}function V(K,X){let G=K;while(!0){let te=F(G);if(!te)break;let{start:ce,end:ee,arrayExpr:le,itemVar:ue,content:de}=te;try{let fe=le.trim(),pe;if(p(fe))pe=c(fe,Object.keys(X))(...Object.values(X));else pe=l(fe,X);let Ae=!1;if(!Array.isArray(pe))if(pe instanceof Map)pe=Array.from(pe),Ae=!0;else if(pe instanceof Set)pe=Array.from(pe);else if(typeof pe==="string")pe=Array.from(pe);else if(pe&&typeof pe==="object"&&!(pe instanceof Date)&&!(pe instanceof RegExp))pe=Object.entries(pe),Ae=!0;else{let We=Ww(fe,C)+i("Foreach",`Error in @foreach: ${fe} is not iterable`,t.TYPE_ERROR);G=G.substring(0,ce)+We+G.substring(ee);continue}let Se=R?.loops?.useAltLoopVariable??Dw,ve=ue.trim(),De=null,Me,je=!1;if(ve.includes("=>")){let We=ve.split("=>").map((Fe)=>Fe.trim());if(We.length===2&&We[0]&&We[1])De=We[0],Me=We[1];else Me=ve}else if(!ve.startsWith("[")&&!ve.startsWith("{")&&ve.includes(",")){let We=ve.split(",").map((Fe)=>Fe.trim());if(We.length===2&&We[0]&&We[1])Me=We[0],De=We[1],je=!0;else Me=ve}else Me=ve;let Le="",Be=pe,Oe=X[Er]??new WeakMap;for(let We=0;We<Be.length;We++){let Fe=Be[We],Ve={index:We,iteration:We+1,first:We===0,last:We===Be.length-1,count:Be.length},ze={...X,loop:Ve,$loop:Ve,[Er]:Oe};if(Me.startsWith("[")&&Me.endsWith("]")){let Tt=Me.slice(1,-1).split(",").map((wt)=>wt.trim());if(Array.isArray(Fe))Tt.forEach((wt,gt)=>{if(wt)ze[wt]=Fe[gt]});else ze[Me]=Fe}else if(Me.startsWith("{")&&Me.endsWith("}")){let Tt=Me.slice(1,-1).split(",").map((wt)=>wt.trim()).filter(Boolean);if(Fe!==null&&typeof Fe==="object")Tt.forEach((wt)=>{let gt=wt.indexOf(":"),Et=(gt===-1?wt:wt.slice(0,gt)).trim(),vt=gt===-1?Et:wt.slice(gt+1).trim();if(Et&&vt)ze[vt]=Fe[Et]});else ze[Me]=Fe}else ze[Me]=Fe;if(De)if(!je&&Ae&&Array.isArray(Fe)&&Fe.length===2)ze[De]=Fe[0],ze[Me]=Fe[1];else ze[De]=We;let at=jw(de,ze),St=mm(at);if(St.hasContinue){Le+=St.content;continue}let bt=gm(at);if(bt.hasBreak){Le+=bt.content;break}if(at=hm(at,ze),at=V(at,ze),at=rr(at,ze,C),at=Lw(at),bt=gm(at),bt.hasBreak){Le+=bt.content;break}if(St=mm(at),St.hasContinue){Le+=St.content;continue}at=Z(at,ze,C),at=Nw(at,ze),at=Mw(at,ze),at=Ow(at,ze),Le+=at}G=G.substring(0,ce)+Le+G.substring(ee)}catch(fe){let pe=i("Foreach",`Error in @foreach(${le.trim()} as ${ue.trim()}): ${fe instanceof Error?fe.message:String(fe)}`,t.EVALUATION_ERROR);G=G.substring(0,ce)+pe+G.substring(ee)}}return G}z=V(z,k),z=vm(z,k,C,R);let H=R?.loops?.maxWhileIterations??Pw;return z=Hw(z,k,H),T?z:Ns(z)}function Xc(v){let k=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(v);if(!k||/^(?:const|let|var)$/.test(k[2]))return v;return`${k[1]}let ${v.slice(k[1].length)}`}function bm(v){return $r(v)}function vm(v,k,C,R){let T=v,z=!0;while(z){z=!1;let F=T.match(/@for\s*\(/);if(!F||F.index===void 0)break;let V=F.index,H=V+F[0].length-1,K=S(T,"(",")",H);if(K===-1)break;let X=Xc(T.slice(H+1,K)),G=K+1,te=Pa(T.slice(V),"for","endfor");if(te.length===0)break;let ce=te[0].content,ee=V+te[0].end;if(!bm(X)){let le=i("For",`Unsafe expression in @for: ${X}`,t.UNSAFE_EXPRESSION);T=T.substring(0,V)+le+T.substring(ee),z=!0;continue}try{let le=Vw(X),ue=/@(?:for|foreach|if|unless)\s*\(/.test(ce);if(le.length>0&&ue){let ve=Uw({forExpr:X,content:ce,iterVarNames:le,context:k,filePath:C,options:R});T=T.substring(0,V)+ve+T.substring(ee),z=!0;continue}let de=Object.keys(k),fe=Object.values(k),pe=ce.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(ve,De)=>`\${${De}}`);pe=ym(pe);let Se=Function(...de,`
2538
- let result = '';
2539
- for (${X}) {
2540
- result += \`${pe}\`;
2541
- }
2542
- return result;
2543
- `)(...fe);T=T.substring(0,V)+Se+T.substring(ee),z=!0}catch(le){let ue=i("For",`Error in @for(${X}): ${le instanceof Error?le.message:String(le)}`,t.EVALUATION_ERROR);T=T.substring(0,V)+ue+T.substring(ee),z=!0}}return T}function Vw(v){let k=v.trim(),C=k.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(C){let z=C[1];return z.slice(1,-1).split(",").map((V)=>{let H=V.trim();if(!H)return"";let K=H.indexOf(":");if(K>=0&&z.startsWith("{")){let te=H.slice(K+1).trim(),ce=te.indexOf("=");return(ce>=0?te.slice(0,ce):te).trim()}let X=H.indexOf("="),G=(X>=0?H.slice(0,X):H).trim();return/^[A-Za-z_$][\w$]*$/.test(G)?G:""}).filter(Boolean)}let R=k.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(R)return[R[1]];let T=k.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(T)return[T[1]];return[]}function Uw(v){let{forExpr:k,content:C,iterVarNames:R,context:T,filePath:z,options:F}=v,V=Object.keys(T),H=Object.values(T),K=Function(...V,"__pushIter",`
2544
- for (${k}) {
2545
- __pushIter([${R.join(", ")}])
2546
- }
2547
- `),X=[];K(...H,(ce)=>{X.push(ce)});let G=z??"inline.stx",te="";for(let ce of X){let ee={...T};R.forEach((ue,de)=>{ee[ue]=ce[de]});let le=vm(C,ee,z,F);le=rr(le,ee,G),le=Z(le,ee,G),te+=le}return te}function Hw(v,k,C){let R=v,T=!0;while(T){T=!1;let z=R.match(/@while\s*\(/);if(!z||z.index===void 0)break;let F=z.index,V=F+z[0].length-1,H=S(R,"(",")",V);if(H===-1)break;let K=R.slice(V+1,H),X=Pa(R.slice(F),"while","endwhile");if(X.length===0)break;let G=X[0].content,te=F+X[0].end;if(!bm(K)){let ce=i("While",`Unsafe expression in @while: ${K}`,t.UNSAFE_EXPRESSION);R=R.substring(0,F)+ce+R.substring(te),T=!0;continue}try{let ce=Object.keys(k),ee=Object.values(k),le=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(fe,pe)=>`\${${pe}}`);le=ym(le);let de=Function(...ce,`
2548
- let result = '';
2549
- let maxIterations = ${C}; // Configurable safety limit
2550
- let counter = 0;
2551
- while (${K} && counter < maxIterations) {
2552
- counter++;
2553
- result += \`${le}\`;
2554
- }
2555
- if (counter > maxIterations) {
2556
- result += '<!-- [While Error [1104]]: Maximum iterations (${C}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
2557
- }
2558
- return result;
2559
- `)(...ee);R=R.substring(0,F)+de+R.substring(te),T=!0}catch(ce){let ee=i("While",`Error in @while(${K}): ${ce instanceof Error?ce.message:String(ce)}`,t.EVALUATION_ERROR);R=R.substring(0,F)+ee+R.substring(te),T=!0}}return R}function qw(v,k="_method"){let C=v.toUpperCase();if(C==="GET"||C==="POST")return"";return`<input type="hidden" name="${k}" value="${C}">`}function wm(v){return v.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(k,C,R,T,z)=>qw(R,z||"_method"))}async function Sm(v,k,C,R,T){if(!R.middleware||R.middleware.length===0)return v;let z=v,F=R.middleware.filter((V)=>V.timing===T);if(F.length===0)return z;for(let V of F){if(!V.name||typeof V.handler!=="function"){if(R.debug)console.warn("Invalid middleware:",V);continue}try{let H=await V.handler(z,k,C,R);if(typeof H==="string")z=H;else if(R.debug)console.warn(`Middleware ${V.name} did not return a string`)}catch(H){if(R.debug)console.error(`Error in middleware ${V.name}:`,H);if(R.debug){let K=g("Middleware",`Error in middleware '${V.name}': ${H instanceof Error?H.message:String(H)}`,C,v);z=z.replace(/<body[^>]*>/,`$&
2560
- <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${b(K)}</div>
2561
- `)}}}return z}async function $m(v,k,C,R){return Sm(v,k,C,R,"before")}async function _m(v,k,C,R){return Sm(v,k,C,R,"after")}function km(v){return v.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(k,C,R,T,z)=>{try{let F=T?N(T,{}):{};return Vn(R,F,z==="true")}catch(F){return console.error(`Error processing @route directive: ${F}`),"#route-error"}})}var Po={patterns:[],exact:{}};async function Em(v,k){let C=v.split("/").pop()?.split(".")[0]||"";if(Po.exact[v])for(let R of Po.exact[v])await Promise.resolve(R(k,v));if(Po.exact[C])for(let R of Po.exact[C])await Promise.resolve(R(k,v));for(let{pattern:R,callback:T}of Po.patterns)if(R.test(v)||R.test(C))await Promise.resolve(T(k,v))}var Kw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Xw=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function ts(v,k){let C=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;C.lastIndex=k;let R=C.exec(v);if(!R)return null;let T=/\/\s*>$/.test(R[0])||R[1]===R[1].toLowerCase()&&Kw.has(R[1]),z=T?R[2].replace(/\/\s*$/,""):R[2];return{full:R[0],tag:R[1],attrs:z,selfClosing:T,start:R.index,end:R.index+R[0].length}}function Zw(v,k,C){let R=1,T=C,z=new RegExp(`<${k}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),F=new RegExp(`</${k}\\s*>`,"gi");while(R>0&&T<v.length){z.lastIndex=T,F.lastIndex=T;let V=z.exec(v),H=F.exec(v);if(!H)return-1;if(V&&V.index<H.index)R++,T=V.index+V[0].length;else{if(R--,R===0)return H.index+H[0].length;T=H.index+H[0].length}}return-1}function es(v,k){if(k.selfClosing)return{outerStart:k.start,outerEnd:k.end,innerHTML:""};let C=Zw(v,k.tag,k.end);if(C===-1)return{outerStart:k.start,outerEnd:k.end,innerHTML:""};return{outerStart:k.start,outerEnd:C,innerHTML:v.slice(k.end,C-`</${k.tag}>`.length)}}function Cm(v,k){return new RegExp(`(?:^|\\s)${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(v)||v.includes(` ${k}=`)||v.includes(` ${k} `)||v.trimEnd().endsWith(` ${k}`)}function Do(v,k){let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=v.match(new RegExp(`${C}="([^"]*)"`,"s"))||v.match(new RegExp(`${C}='([^']*)'`,"s"));return R?R[1]:null}function Fr(v,k){let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return v.replace(new RegExp(`\\s*${C}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${C}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${C}(?=\\s|$|>|/)`,"g"),"")}function ii(v,k,C){let R=k.selfClosing?" /":"",T=`<${k.tag}${C}${R}>`;return v.slice(0,k.start)+T+v.slice(k.end)}function Gw(v){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(v)}function Jw(v){let k=v,C=0;while(C<k.length){let R=ts(k,C);if(!R)break;let T=Do(R.attrs,"v-for");if(T===null){C=R.end;continue}let z=T.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!z){C=R.end;continue}let F=z[1].trim(),V=z[2].trim(),H;if(F.includes(",")){let ue=F.split(",").map((pe)=>pe.trim()),de=ue[0],fe=ue[1];H=`${V} as ${fe} => ${de}`}else H=`${V} as ${F}`;let K=Fr(R.attrs,"v-for"),X=Fr(K,":key").replace(/\s*v-bind:key="[^"]*"/g,""),G=es(k,R),te=k.slice(G.outerStart,G.outerEnd),ce=ii(te,{...R,start:0,end:R.end-R.start},X),ee=`@foreach(${H})
2562
- `,le=`${ee}${ce}
2563
- @endforeach`;k=k.slice(0,G.outerStart)+le+k.slice(G.outerEnd),C=G.outerStart+ee.length}return k}function Yw(v){let k=v,C=0;while(C<k.length){let R=ts(k,C);if(!R)break;let T=Do(R.attrs,"v-if");if(T===null){C=R.end;continue}let z=[],F=es(k,R),V=Fr(R.attrs,"v-if"),H=ii(k.slice(F.outerStart,F.outerEnd),{...R,start:0,end:R.end-R.start},V);z.push({type:"if",expr:T,outerStart:F.outerStart,outerEnd:F.outerEnd,element:H,parsedTag:R});let K=F.outerEnd,X=!0;while(X){let le=k.slice(K).match(/^\s*/),ue=le?le[0].length:0,de=ts(k,K+ue);if(!de){X=!1;break}let fe=Do(de.attrs,"v-else-if"),pe=Cm(de.attrs,"v-else");if(fe!==null){let Ae=es(k,de),Se=Fr(de.attrs,"v-else-if"),ve=ii(k.slice(Ae.outerStart,Ae.outerEnd),{...de,start:0,end:de.end-de.start},Se);z.push({type:"else-if",expr:fe,outerStart:K,outerEnd:Ae.outerEnd,element:ve,parsedTag:de}),K=Ae.outerEnd}else if(pe){let Ae=es(k,de),Se=Fr(de.attrs,"v-else"),ve=ii(k.slice(Ae.outerStart,Ae.outerEnd),{...de,start:0,end:de.end-de.start},Se);z.push({type:"else",outerStart:K,outerEnd:Ae.outerEnd,element:ve,parsedTag:de}),X=!1}else X=!1}let G=[];for(let le of z)if(le.type==="if")G.push(`@if(${le.expr})
2564
- ${le.element}`);else if(le.type==="else-if")G.push(`@elseif(${le.expr})
2565
- ${le.element}`);else G.push(`@else
2566
- ${le.element}`);G.push("@endif");let te=G.join(`
2567
- `),ce=z[0].outerStart,ee=z[z.length-1].outerEnd;k=k.slice(0,ce)+te+k.slice(ee),C=ce+te.length}return k}function Qw(v){return v.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function eS(v){let k=v,C=0;while(C<k.length){let R=ts(k,C);if(!R)break;let T=Xw.has(R.tag),z=R.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(V,H,K)=>{let X=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(H);if(!X||!K||!/^["']/.test(K))return V;let G=X[1]||"modelValue",te=X[2];if(T&&!X[1])return`@model${te}=${K}`;let ce=K[0],ee=K.slice(1,-1),le=`:${G}=${K} @update:${G}=${ce}${ee} = $event${ce}`;if(te){let ue=X[1]?`${G}Modifiers`:"modelModifiers",de=te.slice(1).split(".").map((fe)=>`${fe}: true`).join(", ");le+=` :${ue}="{ ${de} }"`}return le});if(z===R.attrs){C=R.end;continue}let F=ii(R.full,{...R,start:0,end:R.full.length},z);k=k.slice(0,R.start)+F+k.slice(R.end),C=R.start+F.length}return k}function tS(v){return v.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function nS(v){return v.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function rS(v){let k=v,C=0;while(C<k.length){let R=ts(k,C);if(!R)break;let T=Do(R.attrs,"v-html");if(T===null){C=R.end;continue}if(R.selfClosing){C=R.end;continue}let z=es(k,R),F=Fr(R.attrs,"v-html"),V=R.selfClosing?" /":"",H=`<${R.tag}${F}${V}>{!! ${T} !!}</${R.tag}>`;k=k.slice(0,z.outerStart)+H+k.slice(z.outerEnd),C=z.outerStart+H.length}return k}function sS(v){let k=v,C=0;while(C<k.length){let R=ts(k,C);if(!R)break;let T=Do(R.attrs,"v-text");if(T===null){C=R.end;continue}if(R.selfClosing){C=R.end;continue}let z=es(k,R),F=Fr(R.attrs,"v-text"),V=R.selfClosing?" /":"",H=`<${R.tag}${F}${V}>{{ ${T} }}</${R.tag}>`;k=k.slice(0,z.outerStart)+H+k.slice(z.outerEnd),C=z.outerStart+H.length}return k}function iS(v){return v.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function oS(v){let k=v,C=0;while(C<k.length){let R=ts(k,C);if(!R)break;if(!Cm(R.attrs,"v-once")){C=R.end;continue}let T=Fr(R.attrs,"v-once"),z=es(k,R),F=k.slice(z.outerStart,z.outerEnd),H=`@once
2568
- ${ii(F,{...R,start:0,end:R.end-R.start},T)}
2569
- @endonce`;k=k.slice(0,z.outerStart)+H+k.slice(z.outerEnd),C=z.outerStart+H.length}return k}function aS(v){return v.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function cS(v){return v.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Rm(v){if(!Gw(v))return v;let k=v;return k=Jw(k),k=Yw(k),k=oS(k),k=tS(k),k=nS(k),k=eS(k),k=Qw(k),k=cS(k),k=rS(k),k=sS(k),k=iS(k),k=aS(k),k}function Ja(v){return v.replace(/--/g,"- -").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Ru=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),lS=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Am(v,k){let C=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(v),R=C?C[1]:v,T=l(R,k);if(T&&typeof T==="string")return T;let z=R.trim();return Ru.has(z)?z:null}function Tm(v){let k=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(v);return k?k[1]:v}function Im(v,k,C){let R=k.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),T=R?`<${v} ${R}>`:`<${v}>`;if(lS.has(v))return R?`<${v} ${R}>`:`<${v}>`;return`${T}${C}</${v}>`}async function Pm(v,k,C,R,T){let z=v,F=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,V=[],H;while((H=F.exec(z))!==null)V.push({full:H[0],expr:H[1],attrs:H[2],slotContent:H[3],index:H.index});for(let K=V.length-1;K>=0;K--){let X=V[K];try{let G=Am(X.expr,k);if(!G||typeof G!=="string"){let fe=`<!-- dynamic component: could not resolve "${Ja(Tm(X.expr))}" -->`;z=z.slice(0,X.index)+fe+z.slice(X.index+X.full.length);continue}if(Ru.has(G)){let fe=Im(G,X.attrs,X.slotContent);z=z.slice(0,X.index)+fe+z.slice(X.index+X.full.length);continue}let te=X.attrs.trim(),ce={},ee=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,le;while((le=ee.exec(te))!==null){let fe=le[1]||le[2],pe=le[3];if(le[1])try{ce[fe]=l(pe,k)}catch{ce[fe]=pe}else ce[fe]=pe}let ue=R.componentsDir||"components",de=await st(G,ce,X.slotContent,ue,k,C,R,new Set,T??new Set);z=z.slice(0,X.index)+de+z.slice(X.index+X.full.length)}catch(G){let te=G instanceof Error?G.message:String(G),ce=`<!-- dynamic component error: ${Ja(te)} -->`;z=z.slice(0,X.index)+ce+z.slice(X.index+X.full.length)}}return z=await uS(z,k,C,R,T),z}async function uS(v,k,C,R,T){let z=v,F=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,V=[],H;while((H=F.exec(z))!==null)V.push({full:H[0],expr:H[1],attrs:H[2],index:H.index});for(let K=V.length-1;K>=0;K--){let X=V[K];try{let G=Am(X.expr,k);if(!G||typeof G!=="string"){let ee=`<!-- dynamic component: could not resolve "${Ja(Tm(X.expr))}" -->`;z=z.slice(0,X.index)+ee+z.slice(X.index+X.full.length);continue}if(Ru.has(G)){let ee=Im(G,X.attrs,"");z=z.slice(0,X.index)+ee+z.slice(X.index+X.full.length);continue}let te=R.componentsDir||"components",ce=await st(G,{},"",te,k,C,R,new Set,T??new Set);z=z.slice(0,X.index)+ce+z.slice(X.index+X.full.length)}catch(G){let te=G instanceof Error?G.message:String(G),ce=`<!-- dynamic component error: ${Ja(te)} -->`;z=z.slice(0,X.index)+ce+z.slice(X.index+X.full.length)}}return z}var Di="X-STX-Build",Au=Symbol.for("stx.buildId");function js(){let v=globalThis;if(!v[Au])v[Au]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return v[Au]}function Dm(v,k=js()){if(v.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(v))return null;return`
2570
- <meta name="stx-build" content="${k}">`}function dS(v){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let k=navigator.serviceWorker,C=window;if(C.stxOffline)return;let R=null,T=!1,z=[],F={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>R,onUpdateReady(X){if(F.updateReady)try{X()}catch{}else z.push(X);return()=>{let G=z.indexOf(X);if(G!==-1)z.splice(G,1)}},applyUpdate(){let X=R&&R.waiting;if(!X)return!1;return T=!0,X.postMessage({type:"stx:activate-update",force:!0}),!0}};C.stxOffline=F;let V=(X)=>{if(!X.waiting||!k.controller||F.updateReady)return;F.updateReady=!0;let G=z.splice(0);for(let te of G)try{te()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};k.addEventListener("message",(X)=>{let G=X.data||{};if(G.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:G.url,kind:G.kind,fragment:!!G.fragment}}))}catch{}if(G.type==="stx:reachability"){if(C.stxOffline.reachable=G.reachable!==!1,Number(G.at)>0)C.stxOffline.reachedAt=Number(G.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:G.reachable!==!1,at:Number(G.at)||0}}))}catch{}}}),k.addEventListener("controllerchange",()=>{if(T)T=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&R&&R.waiting)R.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let H=()=>{k.register(v,{scope:"/"}).then((X)=>{R=X;try{k.controller?.postMessage({type:"stx:reachability?"})}catch{}if(X.waiting)V(X),X.waiting.postMessage({type:"stx:activate-update",reason:"load"});X.addEventListener("updatefound",()=>{let G=X.installing;if(!G)return;G.addEventListener("statechange",()=>{if(G.state==="installed")V(X)})})}).catch(()=>{})},K=()=>{let X=(G)=>{setTimeout(G,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>X(H));else X(H)};if(!k.controller)if(document.readyState==="complete")K();else addEventListener("load",K);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",K);else K()}function fS(){let v=`(${dS.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(v).trim().replace(/;$/,"")}catch{return v}}var Om=`<script data-stx-offline>${fS()}</script>`;import{AsyncLocalStorage as pS}from"async_hooks";var Mm=new pS;function En(v){return v.__stx_server_data??={pending:new Map,values:new Map}}function Nm(v,k){return Mm.run(En(v),k)}async function jm(v,k){let C=Mm.getStore();if(!C)throw Error("useServerData must run inside a <script server> render");if(typeof v!=="string"||!v.trim())throw TypeError("useServerData requires a non-empty string key");let R=C.pending.get(v);if(R)return R;let T=Promise.resolve().then(k).then((z)=>{let F=JSON.stringify(z,(H,K)=>{if(K===void 0||typeof K==="function"||typeof K==="symbol"||typeof K==="bigint"||typeof K==="number"&&!Number.isFinite(K))throw TypeError(`useServerData(${JSON.stringify(v)}) requires JSON-serializable data`);if(K&&typeof K==="object"&&!Array.isArray(K)&&Object.getPrototypeOf(K)!==Object.prototype&&Object.getPrototypeOf(K)!==null)throw TypeError(`useServerData(${JSON.stringify(v)}) requires JSON-serializable data`);return K}),V=JSON.parse(F);return C.values.set(v,V),V}).catch((z)=>{throw C.pending.delete(v),z});return C.pending.set(v,T),T}function fr(v){let k=v.__stx_server_data;if(!k?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(k.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}var gS=/<\/(script)/gi;function oi(v){if(!v||v.indexOf("</")===-1)return v;return v.replace(gS,"<\\/$1")}import Lm from"path";function j(v,k={}){return new Hn(v,k).routes}var Bm=new Map;async function zm(v,k){let C=v,R=k;if(!C||!R)try{let V=await o();C||=V?.pagesDir||"pages",R||=V?.root||"."}catch{C||="pages",R||="."}let T=Lm.isAbsolute(C)?C:Lm.join(R,C),z=Bm.get(T);if(z)return z;let F=[];try{F=j(".",{pagesDir:T,emit:!1}).map((V)=>V.regex.source).filter(Boolean)}catch{F=[]}return Bm.set(T,F),F}function hS(v){return v.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Wm(v){return hS(JSON.stringify(v))}function he(v){return v.includes("data-stx-runtime")}function Fm(v){let k=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let C=k.exec(v);C!==null;C=k.exec(v)){let R=v.slice(Math.max(0,C.index-80),C.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(R))continue;return!0}return!1}function Tu(v,k){let C=fo(v),R=v.search(/<!doctype\b/i);if(C!==-1&&(R===-1||C>R))return v.slice(0,C)+k+`
2571
- `+v.slice(C);let T=An(v);if(T!==null)return`${v.slice(0,T)}
2572
- ${k}${v.slice(T)}`;if(v.includes("</head>")){let F=v.indexOf("</head>");return v.slice(0,F)+k+`
2573
- `+v.slice(F)}if(Zn(v))return gs(v,(F)=>`${F}
2574
- ${k}`);return`${k}
2575
- ${v}`}async function Ya(v,k){if(v.includes("data-stx-runtime")||v.includes("window.stx.state")||v.includes("STX Signals Runtime"))return v;if(k.buildMode==="serve"){let{getServeClientAsset:T}=await import("./chunk-shhtbdnj.js"),{url:z}=await T("runtime",k.debug===!0);return Tu(v,`<script data-stx-runtime src="${z}"></script>`)}if(k.buildMode==="compile")return Tu(v,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:C}=await import("./chunk-shhtbdnj.js"),R=await C(k.debug);return Tu(v,`<script data-stx-scoped data-stx-runtime>${R}</script>`)}function yS(v){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(v)}function Vm(v){if(v.includes("data-stx-tooltip-runtime")||!yS(v))return v;let k=`<script data-stx-scoped data-stx-tooltip-runtime>${du()}</script>`,C=v.lastIndexOf("</body>");if(C===-1)return`${v}
2576
- ${k}`;return`${v.slice(0,C)}${k}
2577
- ${v.slice(C)}`}var xS=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function bS(v){return xS.test(v)||v.includes("__stxRouter)return")||v.includes("__stxRouter=true")}async function Q(v,k){if(!v.includes("</body>"))return v;if(bS(v))return v;let C=k?.router,R="";{let H={};if(C){if(C.container)H.container=C.container;if(C.interceptAllLinks!==void 0)H.interceptAllLinks=C.interceptAllLinks;if(C.progress!==void 0)H.progress=C.progress;if(C.viewTransitions!==void 0)H.viewTransitions=C.viewTransitions;if(C.viewTransitionDuration!==void 0)H.viewTransitionDuration=C.viewTransitionDuration;if(C.viewTransitionEasing!==void 0)H.viewTransitionEasing=C.viewTransitionEasing;if(C.scrollToTop!==void 0)H.scrollToTop=C.scrollToTop;if(C.scrollRestoration!==void 0)H.scrollRestoration=C.scrollRestoration;if(C.prefetch!==void 0)H.prefetch=C.prefetch;if(C.cache!==void 0)H.cache=C.cache;if(C.progressColor!==void 0)H.progressColor=C.progressColor;if(C.progressHeight!==void 0)H.progressHeight=C.progressHeight;if(C.prefetchVisible!==void 0)H.prefetchVisible=C.prefetchVisible;if(C.prefetchVisibleMax!==void 0)H.prefetchVisibleMax=C.prefetchVisibleMax;if(C.keepOpening!==void 0)H.keepOpening=C.keepOpening}try{let K=await zm(k?.pagesDir,k?.root);if(K.length>0)H.ownedRoutes=K}catch{}if(Object.keys(H).length>0)R=`<script>window.__stxRouterConfig=${Wm(H)};</script>
2578
- `}let{getCachedRouterScript:T,getServeClientAsset:z}=await import("./chunk-shhtbdnj.js"),F=k?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':k?.buildMode==="serve"?`<script data-stx-router src="${(await z("router")).url}"></script>`:`<script data-stx-router>${await T()}</script>`,V=v.lastIndexOf("</body>");return v.slice(0,V)+R+F+`
2579
- </body>`+v.slice(V+7)}var Um=Symbol.for("stx.lazy-module-promises");function vS(){let v=globalThis;return v[Um]??=new Map,v[Um]}function kt(v,k){let C=vS(),R=`${import.meta.url}\x00${v}`,T=C.get(R);if(T)return T;let z=k();return C.set(R,z),z.catch(()=>{if(C.get(R)===z)C.delete(R)}),z}var Iu=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Jm=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,wS=65536,SS=4,ec=new Map;function bd(){ec.clear()}function $S(v){let k=[];for(let C of ne(v,U)){let R=C.token.match(/^<script\b([^>]*)>/i),T=C.token.match(/<\/script\s*>$/i);if(!R||!T)continue;let z=R[0].length,F=C.token.length-T[0].length;k.push(Object.freeze({fullMatch:C.token,attrs:R[1],body:C.token.slice(z,F),start:C.start,end:C.end}))}return k}function Fc(v,k={}){let C=v.length>=wS,R=C?ec.get(v):void 0;if(R===void 0){if(R=$S(v),C)Xd(ec,SS),ec.set(v,R)}let T=k.skipAttrs;if(!T)return R.slice();let z=[];for(let F of R)if(T.lastIndex=0,!T.test(F.attrs))z.push(F);return z}function Rs(v){let k=v.trim(),C=k.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(C){let T=C[1].trim(),z=C[2].trim(),{itemVar:F,indexVar:V}=Hm(z);if(F)return{style:"as",iterable:T,itemVar:F,indexVar:V}}let R=k.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(R){let T=R[1].trim(),z=R[2].trim(),{itemVar:F,indexVar:V}=Hm(T);if(F)return{style:"in",iterable:z,itemVar:F,indexVar:V}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function Hm(v){let k=v.trim(),C=k.match(/^(\w+)\s*=>\s*(\w+)$/);if(C)return{itemVar:C[2],indexVar:C[1]};let R=k.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(R)return{itemVar:R[1],indexVar:R[2]||null};let T=k.match(/^(\w+)\s*,\s*(\w+)$/);if(T)return{itemVar:T[1],indexVar:T[2]};let z=k.match(/^(\w+)$/);if(z)return{itemVar:z[1],indexVar:null};return{itemVar:null,indexVar:null}}function As(v,k){return ra(v,k)}function _S(v){let k=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,C=0,R;while((R=k.exec(v))!==null){let T=R[1];if(T.startsWith("if"))C++;else if(T==="endif")C--;else if(C===0)return!0}return!1}function Ym(v){let k=new Set,C=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,R=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,T;while((T=C.exec(v))!==null){let z=T[1],F;while((F=R.exec(z))!==null)k.add(F[1])}return k}function kS(v){if(!/[:@]for\s*=/.test(v)&&!/\bx-for\s*=/.test(v))return[];let k=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${Iu})>`,"iy"),C=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,R=ne(v,(z,F)=>{k.lastIndex=F;let V=k.exec(z);if(!V||V.index!==F||!C.test(V[2]))return-1;return k.lastIndex}),T=[];for(let z of R){k.lastIndex=0;let F=k.exec(z.token);if(!F)continue;let V=F[2].match(C),H=Rs(V?.[1]??V?.[2]??""),K=[H.itemVar,H.indexVar].filter(Boolean);if(K.length===0)continue;let X=F[1],te=/\/\s*>$/.test(z.token)||tc.has(X.toLowerCase())?z.end:Du(v,z.start,X,z.end);if(te!==-1)T.push({start:z.start,end:te,vars:new Set(K)})}return T}var qm=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 ES(v){return v.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function Km(v,k,C,R){if(!v)return!1;let T=ES(v),z=!1,F=!1,V=!1,H=/([a-zA-Z_$][\w$]*)/g,K;while((K=H.exec(T))!==null){let ce=K[1];if(T.slice(0,K.index).trimEnd().endsWith("."))continue;if(qm.has(ce))continue;if(k.has(ce)||R?.has(ce))z=!0;else if(C&&ce in C)F=!0}let X=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,G;while((G=X.exec(T))!==null){let ce=G[1];if(T.slice(0,G.index).trimEnd().endsWith("."))continue;if(qm.has(ce)||C&&ce in C)continue;V=!0}return(z||V)&&!F}function Qa(v,k,C){let R=C===void 0?` ${k}`:` ${k}="${C.replace(/"/g,"&quot;")}"`,T=v.trim(),z=T.match(Jm);if(z&&CS(z[3],z[1])){let[,F,V,H]=z;return`<${F}${V}${R}>${H}</${F}>`}return`<template${R}>${T}</template>`}function CS(v,k){let C=new RegExp(`<(/)?${k}(?=[\\s/>])`,"gi"),R=0,T;while((T=C.exec(v))!==null)if(T[1]){if(R--,R<0)return!1}else R++;return!0}function Ti(v,k){let C=Ym(v);function R(T){let z=T,F=kS(T),V=(G)=>{let te=new Set;for(let ce of F)if(G>ce.start&&G<ce.end)for(let ee of ce.vars)te.add(ee);return te},H=/@if\s*\(/g,K,X=[];while((K=H.exec(z))!==null){let G=K.index,te=G+K[0].length,ce=1,ee=te;while(ee<z.length&&ce>0){if(z[ee]==="(")ce++;else if(z[ee]===")")ce--;ee++}if(ce!==0)continue;let le=z.substring(te,ee-1).trim(),ue=ee,de=1,fe=ue,pe=/@(if\s*\(|endif)/g;pe.lastIndex=ue;let Ae;while((Ae=pe.exec(z))!==null)if(Ae[1].startsWith("if"))de++;else if(Ae[1]==="endif"){if(de--,de===0){fe=Ae.index+Ae[0].length;break}}if(de!==0)continue;let Se=z.substring(ue,fe-6).trim(),ve;if(_S(Se)){let De=yo(z.substring(G,fe));if(De.length===0)continue;let Me=De[0].branches.filter((Oe)=>Oe.type!=="else"),je=V(G);if(!(Me.length>0&&Me.every((Oe)=>Km(Oe.condition,C,k,je))))continue;ve=De[0].branches.map((Oe)=>{let We=R(Oe.content);if(Oe.type==="elseif")return Qa(We,"@else-if",Oe.condition??"");if(Oe.type==="else")return Qa(We,"@else");return Qa(We,"@if",Oe.condition??"")}).join(`
2580
- `)}else{if(!Km(le,C,k,V(G)))continue;ve=Qa(R(Se),"@if",le)}X.push({start:G,end:fe,replacement:ve}),H.lastIndex=fe}for(let G=X.length-1;G>=0;G--){let{start:te,end:ce,replacement:ee}=X[G];z=z.substring(0,te)+ee+z.substring(ce)}return z}return R(v)}function RS(v){let k=v.trim();if(k==="")return;if(k==="true")return!0;if(k==="false")return!1;if(k==="null")return!1;if(k==="undefined")return!1;if(k==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(k)){let T=Number(k);return T!==0&&!Number.isNaN(T)}let C=k.match(/^'((?:\\.|[^'\\])*)'$/);if(C)return C[1].length>0;let R=k.match(/^"((?:\\.|[^"\\])*)"$/);if(R)return R[1].length>0;return}var tc=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Xm=/<(script|style)\b/iy,AS=/<\/script/gi,TS=/<\/style/gi;function Du(v,k,C,R){if(tc.has(C.toLowerCase()))return R;let T=C.toLowerCase(),z=v.length,F=1,V=R;while(V<z){let H=v.indexOf("<",V);if(H===-1)return-1;if(V=H,v.startsWith("<!--",V)){let te=v.indexOf("-->",V+4);if(te===-1)return-1;V=te+3;continue}Xm.lastIndex=V;let K=Xm.exec(v);if(K){let te=v.indexOf(">",V);if(te===-1)return-1;if(v[te-1]==="/"){V=te+1;continue}let ce=K[1].toLowerCase()==="script"?AS:TS;ce.lastIndex=V;let ee=ce.exec(v);if(ee===null)return-1;let le=v.indexOf(">",ee.index);if(le===-1)return-1;V=le+1;continue}if(v[V+1]==="/"){let te=/^<\/([a-z][\w-]*)\s*>/i.exec(v.slice(V,V+64));if(!te){V++;continue}if(te[1].toLowerCase()===T){if(F--,V+=te[0].length,F===0)return V;continue}V+=te[0].length;continue}let X=/^<([a-z][\w-]*)\b/i.exec(v.slice(V,V+64));if(!X){V++;continue}let G=v.indexOf(">",V);if(G===-1)return-1;if(X[1].toLowerCase()===T){let te=v.slice(V,G+1);if(!(/\/\s*>$/.test(te)||tc.has(T)))F++}V=G+1}return-1}var IS=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function PS(v,k){let C=k,R=v.length;for(;;){while(C<R&&v[C]!=="<")C++;if(C>=R)return!1;if(v.startsWith("<!--",C)){let F=v.indexOf("-->",C+4);if(F===-1)return!1;C=F+3;continue}break}if(v[C+1]==="/")return!1;let T=v.indexOf(">",C);if(T===-1)return!1;let z=v.slice(C,T+1);return IS.test(z)}function $i(v){if(!v.includes(":if")&&!v.includes(":show")&&!v.includes("x-if")&&!v.includes("x-show")&&!v.includes("@if=")&&!v.includes("@show="))return v;let k=[],C=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,R;while((R=C.exec(v))!==null)k.push([R.index,R.index+R[0].length]);let T=(G)=>k.some(([te,ce])=>G>=te&&G<ce),z=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,F=[],V;while((V=z.exec(v))!==null){if(T(V.index))continue;let[G,te,ce,ee,le,ue,de]=V,fe=RS(le);if(fe===void 0)continue;let pe=V.index,Ae=pe+G.length,De=!!de||/\/\s*>$/.test(G)||tc.has(te.toLowerCase())?Ae:Du(v,pe,te,Ae);if(De===-1)continue;if((ee===":if"||ee==="x-if"||ee==="@if")&&PS(v,De)){z.lastIndex=Ae;continue}if(fe===!0){let je=`<${te}${ce}${ue}${de}>`;F.push({start:pe,end:Ae,replacement:je});continue}F.push({start:pe,end:De,replacement:""}),z.lastIndex=De}if(F.length===0)return v;F.sort((G,te)=>G.start-te.start);let H=[],K=-1;for(let G of F){if(G.start<K)continue;H.push(G),K=G.end}let X=v;for(let G=H.length-1;G>=0;G--){let{start:te,end:ce,replacement:ee}=H[G];X=X.substring(0,te)+ee+X.substring(ce)}return X}var Zm=[":for","@for","x-for"];function Ps(v,k){if(!k||Object.keys(k).length===0)return v;if(!Zm.some((V)=>v.includes(`${V}=`)))return v;let C=Ym(v);if(Array.isArray(k.__stx_client_signal_names)){for(let V of k.__stx_client_signal_names)if(typeof V==="string")C.add(V)}let R=v,T=[],z=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,F;while((F=z.exec(R))!==null){let[V,H,K]=F,X=F.index,G=X+V.length,te=Zm.map((ve)=>({attr:ve,m:new RegExp(`\\s${ve}="([^"]*)"`).exec(K)})).find((ve)=>ve.m!==null);if(!te||!te.m)continue;let ce=Rs(te.m[1]);if(!ce.iterable||!ce.itemVar)continue;let ee=ce.iterable.trim().split(/[.[(]/)[0].trim();if(!ee||C.has(ee)||!(ee in k))continue;let le=Du(R,X,H,G);if(le===-1)continue;let ue=K.replace(new RegExp(`\\s${te.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),de=R.slice(G,le-`</${H}>`.length),fe={...k,[ce.itemVar]:void 0};if(ce.indexVar)fe[ce.indexVar]=void 0;let pe=Ps(de,fe),Ae=ce.indexVar?`${ce.iterable} as ${ce.indexVar} => ${ce.itemVar}`:`${ce.iterable} as ${ce.itemVar}`,Se=H.toLowerCase()==="template"?pe:`<${H}${ue}>${pe}</${H}>`;T.push({start:X,end:le,replacement:`@foreach(${Ae})${Se}@endforeach`}),z.lastIndex=le}for(let V=T.length-1;V>=0;V--){let{start:H,end:K,replacement:X}=T[V];R=R.slice(0,H)+X+R.slice(K)}return R}function Is(v,k){let C=v,R=/@(for|foreach)\s*\(/g,T,z=[],F=[];while((T=R.exec(C))!==null){let V=T[1],H=T.index,K=H+T[0].length,X=1,G=K;while(G<C.length&&X>0){if(C[G]==="(")X++;else if(C[G]===")")X--;G++}if(X!==0)continue;let te=C.substring(K,G-1).trim(),ce=G,ee=Rs(te),le=V==="for"?"@endfor":"@endforeach",ue=1,de=ce,fe=V==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${V}\\s*\\(|end${V})`,"g");fe.lastIndex=ce;let pe;while((pe=fe.exec(C))!==null)if(pe[1].startsWith(V))ue++;else if(ue--,ue===0){de=pe.index+pe[0].length;break}if(ue!==0)continue;let Ae=()=>{let Le=[ee.itemVar,ee.indexVar].filter(Boolean);if(Le.length)F.push({start:H,end:de,vars:Le})};if(ee.iterable){let Le=ee.iterable.trim();if(Le.startsWith("[")||Le.startsWith("{")||Le.startsWith("'")||Le.startsWith('"')||Le.startsWith("`")||/^-?\d/.test(Le)){Ae();continue}let Be=Le.split(/[.[(]/)[0].trim(),Oe=k?Be in k:!1,We=F.some((Fe)=>H>Fe.start&&H<Fe.end&&Fe.vars.includes(Be));if(Be&&(Oe||We)){Ae();continue}}if(ee.style==="as")te=ee.indexVar?`(${ee.itemVar}, ${ee.indexVar}) in ${ee.iterable}`:`${ee.itemVar} in ${ee.iterable}`;let Se=C.substring(ce,de-le.length).trim(),ve=k?{...k}:{};if(ee.itemVar)delete ve[ee.itemVar];if(ee.indexVar)delete ve[ee.indexVar];let De=Is(Se,ve),Me=De.match(Jm),je;if(Me){let[,Le,Be,Oe]=Me;je=`<${Le}${Be} @for="${te}">${Oe}</${Le}>`}else je=`<template @for="${te}">${De}</template>`;z.push({start:H,end:de,replacement:je}),R.lastIndex=de}for(let V=z.length-1;V>=0;V--){let{start:H,end:K,replacement:X}=z[V];C=C.substring(0,H)+X+C.substring(K)}return C}function DS(v){let k=new Set,C=[],R=0,T=0,z=v.length,F=(X)=>{let G=R+1;while(G<z){let te=v[G];if(te==="\\"){G+=2;continue}if(te===X)return G+1;G++}return z},V=()=>{let X=R+2;while(X<z&&v[X]!==`
2581
- `)X++;return X},H=()=>{let X=R+2;while(X<z-1){if(v[X]==="*"&&v[X+1]==="/")return X+2;X++}return z},K=(X)=>{let G=X,te=0;while(G<z){let ce=v[G];if(ce==="/"&&v[G+1]==="/"){let ee=G+2;while(ee<z&&v[ee]!==`
2582
- `)ee++;G=ee;continue}if(ce==="/"&&v[G+1]==="*"){let ee=G+2;while(ee<z-1&&!(v[ee]==="*"&&v[ee+1]==="/"))ee++;G=ee+2;continue}if(ce==='"'||ce==="'"||ce==="`"){let ee=G+1;while(ee<z){if(v[ee]==="\\"){ee+=2;continue}if(v[ee]===ce){ee++;break}ee++}G=ee;continue}if(ce==="("||ce==="["||ce==="{"){te++,G++;continue}if(ce===")"||ce==="]"||ce==="}"){te--,G++;continue}if(ce===";"&&te===0)return G+1;G++}return z};while(R<z){let X=v[R];if(X==="/"&&v[R+1]==="/"){let G=V();C.push(v.slice(R,G)),R=G;continue}if(X==="/"&&v[R+1]==="*"){let G=H();C.push(v.slice(R,G)),R=G;continue}if(X==='"'||X==="'"||X==="`"){let G=F(X);C.push(v.slice(R,G)),R=G;continue}if(X==="{"){T++,C.push(X),R++;continue}if(X==="}"){T--,C.push(X),R++;continue}if(T===0){let G=R>0?v[R-1]:"";if(G===""||/\s/.test(G)||G===";"||G==="}"||G==="{"){let ce=v.slice(R).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(ce){let ee=ce[2],le=K(R+ce[0].length);if(k.has(ee)){C.push(`/* stx: deduped const ${ee} */`),R=le;continue}k.add(ee),C.push(v.slice(R,le)),R=le;continue}}}C.push(X),R++}return C.join("")}var OS=new Set(["script","style","html","head","meta","link","title","!doctype"]);function Pu(v,k,C){for(let R of C){if(R.start>=k)return!1;if(R.end>v)return!0}return!1}function MS(v,k,C){let R=0;while(R<v.length){let T=v.indexOf(k,R);if(T===-1)return!1;if(!Pu(T,T+k.length,C))return!0;R=T+k.length}return!1}function NS(v,k){if(MS(v,"<body",k)){let T=new RegExp(`<body(${Iu})>`,"g"),z;while((z=T.exec(v))!==null)if(!Pu(z.index,z.index+z[0].length,k))return z.index+z[0].length-1;return null}let C=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${Iu})>`,"gi"),R;while((R=C.exec(v))!==null){if(Pu(R.index,R.index+R[0].length,k))continue;if(OS.has(R[1].toLowerCase()))continue;return R.index+R[0].length-1}return null}function jS(v,k,C,R){let T=[],z=` data-stx="${R}"`,F=0,V=!1,H=(K)=>{if(C!==null&&!V&&C>=F&&C<=K)T.push(v.slice(F,C),z,v.slice(C,K)),V=!0;else T.push(v.slice(F,K))};for(let K of k){if(K.start<F)continue;H(K.start),F=K.end}return H(v.length),T.join("")}async function pr(v,k,C,R={}){let T=Fc(v,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),z=/\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:V,bundleClientScript:H}=await kt("stx/client-script-bundler",()=>import("./chunk-9svygzeg.js"));for(let pe of T){let Ae=pe.body;if(nt(pe.attrs))Ae=rt(Ae);if(R.forceClientSetup||z.test(Ae)){F.push({content:Ae,start:pe.start,end:pe.end});continue}if(!V(Ae))continue;try{let Se=await H(Nt(Ae).code,k||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(z.test(Se))F.push({content:Ae,start:pe.start,end:pe.end})}catch{}}if(F.length===0)return{output:v,setupCode:null};let K=`${k??""}\x00${F.map((pe)=>pe.content).join("\x00")}`,X=`__stx_setup_${Bun.hash(K).toString(36).slice(0,10)}`,G=[];for(let pe=0;pe<F.length;pe++){let Ae=F[pe].bundled??Nt(F[pe].content).code;if(!F[pe].bundled&&V(Ae))Ae=await H(Ae,k||"",{projectRoot:process.cwd(),externalizeUserModules:R.forceClientSetup?!1:void 0});Ae=tt(Ae);let Se=I(Ae);G.push(`// \u2500\u2500 merged signal script #${pe+1} \u2500\u2500
2583
- ${Se}`)}let te=G.join(`
2584
-
2585
- `);te=DS(te);let ee=M(te).split(",").map((pe)=>pe.trim()).filter(Boolean),le=vn(te,C),ue=`
2586
- <script data-stx-scoped>
2587
- function ${X}() {
2588
- ${qt("const",ee)}
2589
- ${oi(`${le}${te}`)}
2590
- return ${Ko(te,ee)};
2591
- }
2592
- window.__stx_latestSetup=${X};
2593
- if(window.stx)window.stx._latestSetup=${X};
2594
- </script>`,de=NS(v,F);return{output:jS(v,F,de,X),setupCode:ue}}async function Ri(v,k,C,R){if(!As(v,C))return v;let T=v;if(k.skipSignalsRuntime)return T;let{output:z,setupCode:F}=await pr(T,C,R);if(T=z,!F){let V=Zn(T);if(V&&!/data-stx/.test(V.attrs)&&!/data-stx-auto/.test(V.attrs)){let H=V.tag.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>");T=T.slice(0,V.index)+H+T.slice(V.index+V.tag.length)}}if(T=await Ya(T,k),F){let V=Ai(T,/<\/head>/i),H=V===-1?Ai(T,/<body[^>]*>/i):-1;if(V!==-1)T=`${T.slice(0,V)}${F}
2595
- ${T.slice(V)}`;else if(H!==-1){let K=/<body[^>]*>/i.exec(T.slice(H))[0],X=H+K.length;T=`${T.slice(0,X)}
2596
- ${F}${T.slice(X)}`}else T=`${T}
2597
- ${F}`}return T}function Ai(v,k){let C=/<(script|style)\b[\s\S]*?<\/\1>/gi,R=[],T;while((T=C.exec(v))!==null)R.push([T.index,T.index+T[0].length]);let z=new RegExp(k.source,k.flags.replace(/[gy]/g,"")),F=0;while(F<v.length){let V=z.exec(v.slice(F));if(!V)return-1;let H=F+V.index;if(!R.some(([X,G])=>H>=X&&H<G))return H;F=H+Math.max(V[0].length,1)}return-1}var Gm="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function zc(v){let k=[];for(let C of v.split(",")){let R=C.trim();if(!R||R.startsWith("type "))continue;let T=R.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(T&&T[1]!==T[2])k.push(`${T[2]} = ${T[1]}`)}if(k.length===0)return Gm;return`var ${k.join(", ")}; ${Gm}`}var LS=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function tt(v){return v.replace(LS,(k,C)=>zc(C))}import ai from"path";import BS from"process";function w(v="STX_PUBLIC_"){let k={},C={};for(let[R,T]of Object.entries(BS.env)){if(!R.startsWith(v)||T===void 0)continue;k[`import.meta.env.${R}`]=JSON.stringify(T),C[R]=T}return k["import.meta.env"]=JSON.stringify(C),k}function Qm(v){return v.startsWith("http://")||v.startsWith("https://")||v.startsWith("//")}async function eh(v,k,C){try{let R;if(v.startsWith("/")){let T=k;for(let z=0;z<5;z++){let F=ai.join(T,v);if(await Bun.file(F).exists())return F;T=ai.dirname(T)}R=ai.join(k,v)}else if(v.startsWith("./")||v.startsWith("../"))R=ai.resolve(k,v);else R=ai.resolve(k,v);if(await Bun.file(R).exists())return R;return null}catch{return null}}var th=Symbol.for("stx.inline-assets.import-meta");function zS(v,k){if(!v.includes("import.meta"))return;let C=Error(`[stx] ${k} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
2598
- `+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw C[th]=!0,C}async function nh(v,k,C){let R=v,T=ai.dirname(k),z=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,F;while((F=z.exec(R))!==null){let[K,X,G,te]=F;if(Qm(G))continue;let ce=await eh(G,T,k);if(ce)try{let ee=await Bun.file(ce).text();if(C.add(ce),G.endsWith(".ts")||G.endsWith(".tsx")){let ue=await Bun.build({entrypoints:[ce],target:"browser",minify:!0,define:w()});if(ue.outputs.length>0)ee=await ue.outputs[0].text(),zS(ee,G)}let le=`<script>
2599
- // Source: ${G}
2600
- ${ee}
2601
- </script>`;R=R.replace(K,le),z.lastIndex=0}catch(ee){if(ee?.[th])throw ee}}let V=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,H;while((H=V.exec(R))!==null){let[K,X,G,te]=H,ce=X+te;if(Qm(G))continue;if(/rel=["']stylesheet["']/.test(ce)||G.endsWith(".css")){let le=await eh(G,T,k);if(le)try{let ue=await Bun.file(le).text();C.add(le);let de=`<style>
2602
- /* Source: ${G} */
2603
- ${ue}
2604
- </style>`;R=R.replace(K,de),V.lastIndex=0}catch(ue){}}}return R}function Bs(v,k){let C=v,R=/@json\s*\(/g,T;while((T=R.exec(C))!==null){let z=T.index,F=z+T[0].length-1,V=1,H=F+1,K=null,X=!1;while(H<C.length&&V>0){let pe=C[H];if(X){X=!1,H++;continue}if(pe==="\\"&&K){X=!0,H++;continue}if(K){if(pe===K)K=null;H++;continue}if(pe==='"'||pe==="'"||pe==="`"){K=pe,H++;continue}if(pe==="(")V++;else if(pe===")"){if(V--,V===0)break}H++}if(V!==0)break;let G=C.substring(F+1,H).trim(),te=C.substring(z,H+1),ce=-1,ee=0,le=null,ue=!1;for(let pe=0;pe<G.length;pe++){let Ae=G[pe];if(ue){ue=!1;continue}if(Ae==="\\"&&le){ue=!0;continue}if(le){if(Ae===le)le=null;continue}if(Ae==='"'||Ae==="'"||Ae==="`"){le=Ae;continue}if(Ae==="("||Ae==="["||Ae==="{")ee++;else if(Ae===")"||Ae==="]"||Ae==="}")ee--;if(Ae===","&&ee===0){ce=pe;break}}let de=ce>=0?G.substring(0,ce).trim():G,fe=ce>=0?G.substring(ce+1).trim():void 0;try{let pe=de.trim(),Ae;if(p(pe))Ae=c(pe,Object.keys(k))(...Object.values(k));else Ae=void 0;let Se;if(fe==="true")Se=JSON.stringify(Ae,null,2);else Se=JSON.stringify(Ae);let ve=Se.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");C=C.substring(0,z)+ve+C.substring(H+1),R.lastIndex=z+ve.length}catch(pe){O.log(pe instanceof Error?pe:Error(String(pe)),{directive:"@json"},"error"),R.lastIndex=z+te.length}}return C}function Fs(v){return v.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function oh(v){let k=v,C=/@memo\s*\(/g,R,T=[];while((R=C.exec(k))!==null){let z=R.index,F=z+R[0].length,V=1,H=F;while(H<k.length&&V>0){if(k[H]==="(")V++;else if(k[H]===")")V--;H++}if(V!==0)continue;let K=k.slice(F,H-1).trim(),X=H,G=k.slice(X),te=G.indexOf("@endmemo");if(te===-1)continue;let ce=G.slice(0,te),ee=X+te+8,le=ce.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),ue=le?le[0].length:0,de=ce.slice(ue),fe=ce.match(/(\s*)$/),pe=fe?fe[0].length:0,Ae=de.slice(0,de.length-pe),Se=Ae.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),ve;if(Se){let[De,Me,je="",Le]=Se,Be=`<${Me}${je} data-stx-memo="${K}"${Le}>`;ve=ce.slice(0,ue)+Be+Ae.slice(De.length)+ce.slice(ue+Ae.length)}else ve=`${ce.slice(0,ue)}<div data-stx-memo="${K}">${Ae}</div>${ce.slice(ue+Ae.length)}`;T.push({start:z,end:ee,replacement:ve}),C.lastIndex=ee}for(let z=T.length-1;z>=0;z--){let F=T[z];k=k.slice(0,F.start)+F.replacement+k.slice(F.end)}return k.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Ou(v){let k=v.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return k=k.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),k}function ah(v,k){if(!/\bref\s*=/.test(v))return v;let C=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,R=ne(v,(H,K)=>{C.lastIndex=K;let X=C.exec(H);if(!X||/^(?:script|style)$/i.test(X[1]))return-1;return C.lastIndex}),T=[],z=0,F=0,V=[];for(let{start:H,end:K,token:X}of R){let G=/^<\/?([\w-]+)/.exec(X)[1].toLowerCase();if(X.startsWith("</")){let ce;while(ce=T.pop()){if(ce.scoped)z--;if(ce.name===G)break}continue}let te=/\sdata-stx-scope\s*=/.test(X);if(!z&&!te&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(X)&&!/\sdata-stx-ref-caller\s*=/.test(X))V.push(v.slice(F,H),X.replace(/\s*\/?>$/,(ce)=>` data-stx-ref-caller="${k}"${ce}`)),F=K;if(!ch.has(G)&&!/\/>$/.test(X)){if(T.push({name:G,scoped:te}),te)z++}}return V.push(v.slice(F)),V.join("")}var ch=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),lh=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,rh=/<\/?\s*([a-z][\w-]*)/iy,WS=/\s/;function FS(v,k){let C=k-1;while(C>=0&&WS.test(v[C]))C--;return C>=0&&v[C]==="/"}function VS(v,k){let C=!1,R=!1;for(let T=k;T<v.length;T++){let z=v[T];if(C){if(z==="'")C=!1}else if(R){if(z==='"')R=!1}else if(z==="'")C=!0;else if(z==='"')R=!0;else if(z===">")return T}return-1}function US(v,k){if(v.indexOf("{",k)===-1||v.indexOf("}",k)===-1)return!1;let C=0,R=k,T=!1,z=!1,F=!1;while(R<v.length){let V=v.indexOf("<",R),H=V===-1?v.length:V;if(H>R){if(C===0)while(R<H){let G=v.indexOf(z?"}":"{",R);if(G===-1||G>=H){if(z)F=!1;else T=!1;break}if(G>R)if(z)F=!1;else T=!1;if(z){if(F)return!0;F=!0}else if(T)z=!0,F=!1;else T=!0;R=G+1}R=H;continue}if(v.startsWith("<!--",R)){let G=v.indexOf("-->",R);R=G===-1?v.length:G+3;continue}let K=VS(v,R);if(K===-1)break;rh.lastIndex=R;let X=rh.exec(v)?.[1]?.toLowerCase()??"";if(v[R+1]==="/"){if(C===0)break;C--}else if(!FS(v,K)&&!ch.has(X))C++;R=K+1}return!1}var sh=m(256);function uh(v){if(v.length<1024)return ih(v);let k=h(v),C=sh.get(k);if(C!==void 0)return C;let R=ih(v);return sh.set(k,R),R}function ih(v){if(v.length>=32768&&!Kd(v))return v;let C=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),R="",T=0,z;while((z=C.exec(v))!==null){let F=z.index,V=F+z[0].length,H=!1,K=!1,X=-1;while(V<v.length){let te=v[V];if(H){if(te==="'")H=!1}else if(K){if(te==='"')K=!1}else if(te==="'")H=!0;else if(te==='"')K=!0;else if(te===">"){X=V;break}V++}if(X===-1)continue;let G=v.slice(F,X+1);if(lh.test(G))continue;if(G.includes("x-cloak"))continue;if(US(v,X+1))R+=v.slice(T,X)+" x-cloak>",T=X+1}return R+=v.slice(T),R}var HS=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,qS=/<\/script>/gi,KS=/<\/style>/gi;function dh(v){let k=/<[a-z][\w-]*/gi,C="",R=0,T;while((T=k.exec(v))!==null){let z=T.index,F=T[0].slice(1).toLowerCase();if(F==="script"||F==="style"){let ee=F==="script"?qS:KS;ee.lastIndex=z;let le=ee.exec(v);if(le!==null)k.lastIndex=le.index+le[0].length;continue}let V=z+T[0].length,H=!1,K=!1,X=-1;while(V<v.length){let ee=v[V];if(H){if(ee==="'")H=!1}else if(K){if(ee==='"')K=!1}else if(ee==="'")H=!0;else if(ee==='"')K=!0;else if(ee===">"){X=V;break}V++}if(X===-1)continue;let G=v.slice(z+T[0].length,X);if(lh.test(G))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(G))continue;if(!HS.test(G))continue;let te=v[X-1]==="/",ce=te?X-1:X;C+=`${v.slice(R,ce)} x-cloak${te?" ":""}`,R=ce}return C+=v.slice(R),C}import Mu from"path";var XS=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ZS=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function GS(v,k){if(!k||!v.includes("/"))return v;let C=Mu.dirname(k);return v.replace(XS,(R,T,z,F)=>{let V=Mu.resolve(C,F);return`${T}${z}${V.split(Mu.sep).join("/")}${z}`})}function fh(v,k){if(!k||!v.includes("<script"))return v;return v.replace(ZS,(C,R,T,z)=>`${R}${GS(T,k)}${z}`)}var ns="<!--PARENT_CONTENT_PLACEHOLDER-->";function ph(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function vh(v,k){let C=v.length,R=k,T=!0,z=[],F=(V)=>V+9<=C&&v[V]==="<"&&v[V+1]==="/"&&(v[V+2]==="s"||v[V+2]==="S")&&(v[V+3]==="c"||v[V+3]==="C")&&(v[V+4]==="r"||v[V+4]==="R")&&(v[V+5]==="i"||v[V+5]==="I")&&(v[V+6]==="p"||v[V+6]==="P")&&(v[V+7]==="t"||v[V+7]==="T")&&(v[V+8]===">"||/\s/.test(v[V+8]));while(R<C){let V=v[R];if(F(R))return R;if(V==="/"&&v[R+1]==="/"){if(R=v.indexOf(`
2605
- `,R+2),R===-1)return-1;R+=1,T=!0;continue}if(V==="/"&&v[R+1]==="*"){let H=v.indexOf("*/",R+2);if(H===-1)return-1;R=H+2,T=!0;continue}if(V==="/"&&T){let H=R+1,K=!1;while(H<C){let X=v[H];if(X==="\\"){H+=2;continue}if(X==="[")K=!0;else if(X==="]")K=!1;else if(X==="/"&&!K){H++;break}else if(X===`
2606
- `){H=-1;break}H++}if(H===-1){R++,T=!1;continue}while(H<C&&/[a-z]/.test(v[H]))H++;R=H,T=!1;continue}if(V==="'"||V==='"'){let H=V;R++;while(R<C){if(v[R]==="\\"){R+=2;continue}if(v[R]===H){R++;break}if(v[R]===`
2607
- `)break;R++}T=!1;continue}if(V==="`"){R++;while(R<C){if(v[R]==="\\"){R+=2;continue}if(v[R]==="`"){R++;break}if(v[R]==="$"&&v[R+1]==="{"){z.push(!0),R+=2,T=!0;break}R++}if(z.length===0)T=!1;continue}if(V==="}"&&z.length>0){z.pop(),R++;while(R<C){if(v[R]==="\\"){R+=2;continue}if(v[R]==="`"){R++,T=!1;break}if(v[R]==="$"&&v[R+1]==="{"){z.push(!0),R+=2,T=!0;break}R++}continue}if(/\s/.test(V));else if(/[)\].\w$]/.test(V))T=!1;else T=!0;R++}return-1}function wh(v,k){let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=new RegExp(`<script\\b(?=[^>]*\\b${C}(?:\\s|=|/?>))[^>]*>`,"i").exec(v);if(!R)return null;let T=R.index+R[0].length,z=v.indexOf("</script>",T);if(z===-1)return null;let F=v.indexOf(">",z);if(F===-1)return null;return{start:R.index,end:F+1}}var YS=4096;async function gh(v,k,C){if(C.buildMode!=="serve"||k.length<YS)return null;let{registerServeModuleBundle:R}=await import("./chunk-shhtbdnj.js");return`<script ${v} src="${R(k)}"></script>`}async function mh(v,k,C){try{let{registeredModuleIdsIn:R,buildModuleRegistryScript:T}=await kt("stx/client-module-registry",()=>import("./chunk-t7e9y46s.js")),z=[],F=await T(R(...v),{minify:so(k.buildMode),collectInputs:z});for(let V of z)C?.add(V);if(!F)return null;if(k.buildMode==="serve"){let{registerServeModuleBundle:V}=await import("./chunk-shhtbdnj.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${V(F)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${F.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function QS(v,k=""){let C=wh(v,"data-stx-runtime");if(!C)return v;let R=fo(v);if(R===-1||R===C.start){if(!k)return v;return v.slice(0,C.end)+k+v.slice(C.end)}if(R<C.start)return v.slice(0,R)+v.slice(C.start,C.end)+k+`
2608
- `+v.slice(R,C.start)+v.slice(C.end);let T=v.slice(C.start,C.end),z=v.slice(0,C.start)+v.slice(C.end),F=fo(z);if(F===-1)return T+k+`
2609
- `+z;return z.slice(0,F)+T+k+`
2610
- `+z.slice(F)}function e0(v){let k=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return v.replace(k,(C,R,T)=>{let z=v.slice(0,T);return z.lastIndexOf("<")>z.lastIndexOf(">")?`{{${R}}}`:`{<!--stx-literal-->{${R}}}`})}async function n(v,k,C,R,T){if(R.ssr===!1&&!R.autoShell&&R.buildMode==="spa")return v;if(k.__stx_signals_gate===void 0)k.__stx_signals_gate=Ce(v,C);let z=!k.__stxProcessingDepth;En(k);for(let F of R._layerGraph?.configDependencies??[])T.add(F);if(z&&R.runtimeConfig)await Rn(k,C,R.runtimeConfig);if(z)Od(k),k.__stx_scope_seq??={n:0,key:zs(String(k.__filename??C))},k.__stx_head_injections=Qs(),k.__stx_seo_staged=!1;if(!k.__stxProcessingDepth)k.__stxProcessingDepth=0;if(k.__stxProcessingDepth++,!k.__onceStore)k.__onceStore=new Set;if((R.debug||!E()&&!jn())&&C&&C.endsWith(".stx"))uo(v,C);try{return await J.timeAsync("template-processing",async()=>{let F=await t0(v,k,C,R,T);if(z)F=Ou(F);if(z&&R.autoShell&&R.buildMode!=="compile"){let V=we(R.app?.head,{known:Dn,source:"app.head"}),K=(k.__stx_runtime_head||null)??to(),X=(k.__stx_head_raw||"").trim(),G,te=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(te)G=te[1].trim(),X=X.replace(te[0],"").trim();let ce=k.__sections?.title,ee=K.title||G||ce,le=!K.title&&(!!G||!!ce),ue=K.meta||[],de=new Set(ue.map((De)=>Pe(De)).filter(Boolean)),fe={...V,...ee&&{title:ee},meta:[...(V.meta||[]).filter((De)=>!de.has(Pe(De))),...ue],link:[...V.link||[],...K.link||[]],script:[...V.script||[],...K.script||[]],headRaw:[V.headRaw,X].filter(Boolean).join(`
2611
- `),...K.htmlAttrs&&{htmlAttrs:Ji(V.htmlAttrs,K.htmlAttrs)},...K.bodyAttrs&&{bodyAttrs:{...V.bodyAttrs||{},...K.bodyAttrs}}},pe=eo(F);if(F=On(F,fe,{...le&&{titleIsHtml:!0},...R.app?.colorMode&&{colorMode:R.app.colorMode}},pe),pe)F=Zi(F,V),F=In(F,fe.htmlAttrs);let Ae=F.match(/<!-- stx-layout: ([^ ]+) -->/);if(Ae&&F.includes("<head")){let De=Ae[1],Me=Or(De);F=F.replace(/<head\b[^>]*>/i,(je)=>`${je}
2612
- <meta name="stx-layout" content="${ph(De)}">
2613
- <meta name="stx-layout-group" content="${ph(Me)}">`)}let Se=F.match(/function (__stx_setup_\w+)\(/),ve=Se?Zn(F):null;if(Se&&ve&&!/\bdata-stx=/.test(ve.tag)){F=gs(F,(Me,je)=>`<body${je} data-stx="${Se[1]}">`);let De=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${Se[1]}"`,"i");F=F.replace(De,"$1")}}if(z){let V=k.__stx_head_injections??Qs(),H=Yi(F);if(H!==null)V.beforeClose.push(H);let K=Dm(F);if(K!==null)V.afterOpen.push(K);if(R.offline?.enabled&&!F.includes("data-stx-offline"))V.beforeClose.push(Om);F=Ki(F,V);let X=R.app?.colorMode;if(X)F=Pn(F,X)}if(z)if(wh(F,"data-stx-runtime")){let H=null,K=null,X=null,G=null,te=null;try{let{getStoreScript:ee}=await kt("stx/store-loader",()=>import("./chunk-mk71833d.js")),le=R.storesDir,ue=await ee(le);if(ue)X=`<script data-stx-stores>${ue}</script>`,K=await gh("data-stx-stores",ue,R)??X}catch{}H=await mh([F,X],R,T);try{let{getFrameworkComposableScript:ee}=await kt("stx/framework-composables",()=>import("./chunk-xm911f1g.js"));te=await ee(F)}catch{}try{let{getComposableScript:ee}=await kt("stx/composable-loader",()=>import("./chunk-xsw183n7.js")),le=R.composablesDir,ue=[H,X,te].filter((fe)=>fe!==null),de=await ee(R._layerComposableDirs??le,F,ue);if(de)G=await gh('data-stx-scoped data-stx-run="always" data-stx-composables',de,R)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${de}</script>`}catch{}let ce=[H,K,G,te].filter((ee)=>ee!==null).map((ee)=>`
2614
- ${ee}`).join("");F=QS(F,ce)}else{let H=await mh([F],R,T);if(H){let K=F.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(K!==-1)F=F.slice(0,K)+H+`
2615
- `+F.slice(K)}}if(z)F=Xi(F);if(z&&k.__stx_inject_css!==!1)F=await f(F,void 0,R.buildMode==="serve",!0);else if(z)F=ao(F);if(F=F.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),F=e0(F),z&&k.__stx_runtime_config)F=it(F,k.__stx_runtime_config);if(z&&!k.__stx_defer_server_data){let V=fr(k);if(V){let H=/<head\b[^>]*>/i.exec(F),K=H?H.index+H[0].length:0;F=F.slice(0,K)+V+F.slice(K)}}return F})}catch(F){if(F instanceof q)throw F;let V=F instanceof Error?F.message:String(F),H=new W(`Template processing failed: ${V}`,C,void 0,void 0,v.substring(0,200)+(v.length>200?"...":""));if(O.log(H,{filePath:C,context:k}),Ut.logDetailedError(H,{filePath:C,template:v.substring(0,500)}),R.debug)throw H;return no.createFallbackContent("Template Processing",H)}}async function t0(v,k,C,R,T){let z=process.cwd(),F={...R,partialsDir:R.partialsDir&&!fn.isAbsolute(R.partialsDir)?fn.resolve(z,R.partialsDir):R.partialsDir,componentsDir:R.componentsDir&&!fn.isAbsolute(R.componentsDir)?fn.resolve(z,R.componentsDir):R.componentsDir,layoutsDir:R.layoutsDir&&!fn.isAbsolute(R.layoutsDir)?fn.resolve(z,R.layoutsDir):R.layoutsDir},V=F,H=v;await s0(C,k),r0(k,V),H=await ae(()=>$m(H,k,C,V),H,(Se)=>{O.log(Se,{filePath:C,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${C}: ${Se.message}`)}),H=H.replace(/\{\{--[\s\S]*?--\}\}/g,"");let K=Un(H,Ke,(Se,ve)=>`\x00STX_HTML_COMMENT_${ve}\x00`);H=K.output;let X=K.tokens,G=(Se)=>X.length===0?Se:Se.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(ve,De)=>X[Number(De)]??""),te="\x00STX_ESCAPED_AT\x00",ce="\x00STX_ESC_MUSTACHE_OPEN\x00",ee="\x00STX_ESC_MUSTACHE_CLOSE\x00";H=H.replace(/@@/g,te),H=H.replace(/@\{\{([\s\S]*?)\}\}/g,(Se,ve)=>`${ce}${ve}${ee}`),H=Rm(H),H=await nh(H,C,T);let le={};H=Ms(H,le);let ue={...k.__sections||{}},de="",fe=lp(Je(v)),pe=/@nolayout\b/.test(H)||fe===!1;if(/@nolayout\b/.test(H))H=H.replace(/@nolayout\b\s*/g,"");let Ae=H.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(Ae)de=Ae[1],H=H.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof fe==="string"){if(de=fe,!/@section\s*\(/.test(H))H=`@section('content')
2616
- ${H.trim()}
2617
- @endsection`}if(!de&&!pe&&V.defaultLayout){let Se=Vt(H),ve=/@section\s*\(/.test(H);if(!Se||ve){let De="",Me=fn.dirname(C),je=V.layoutsDir?fn.dirname(V.layoutsDir):process.cwd();for(let Le=0;Le<20;Le++){let Be=fn.join(Me,"_layout.stx");if(await r(Be)){De=Be;break}let Oe=fn.dirname(Me);if(Oe===Me||Oe.length<je.length)break;Me=Oe}if(De)de=De;else if(V.layoutsDir){let Le=fn.isAbsolute(V.layoutsDir)?V.layoutsDir:fn.resolve(process.cwd(),V.layoutsDir),Be=fn.join(Le,`${V.defaultLayout}.stx`);if(await r(Be))de=Be}if(de&&!ve)H=`@section('content')
2618
- ${H.trim()}
2619
- @endsection`}}if(de&&H.includes("<script")){let Se=Mn(H),ve=Se.scripts.map((De)=>hh(De,C)??De);H=ds(Se.output,ve)}if(H=H.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(Se,ve,De)=>(ue[ve]=De,"")),H=H.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(Se,ve,De)=>{if(/^(['"]).*\1$/.test(De.trim()))return Se;try{let Me=l(De.trim(),k);if(Me===void 0)return Se;return ue[ve]=String(Me??""),""}catch{return Se}}),H=H.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(Se,ve,De)=>{if(De.includes("@parent"))ue[ve]=De.replace("@parent",ns);else ue[ve]=De.trim();return""}),k.__sections=ue,H=H.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(Se,ve,De)=>ue[ve]||De||""),!("slot"in k)||k.slot===void 0)H=H.replace(/\{\{\s*slot\s*\}\}/g,()=>ue.content||"");if(H=Ls(H,le),de){let Se=[],ve=Mn(H),De=Un(ve.output,us,(Me,je)=>`\x00STX_ORPHAN_STYLE_${je}\x00`);if(H=De.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(Me,je,Le)=>{let Be=je==="SCRIPT"?hh(ve.scripts[Number(Le)],C):De.tokens[Number(Le)];if(Be)Se.push(Be);return""}),Se.length>0){let Me=Se.join(`
2620
- `);ue.content=ue.content?`${ue.content}
2621
- ${Me}`:Me,k.__sections=ue}}if(de)try{let Se;if(fn.isAbsolute(de))Se=de,T.add(de);else Se=await ae(()=>mr(de,C,F,T),null,()=>{throw new W(`Failed to resolve layout path: ${de}`,C,void 0,void 0,`Layout referenced from ${C}`)});if(!Se){let Be=(Fe)=>{if(!Fe)return[];try{let Ve=fn.isAbsolute(Fe)?Fe:fn.resolve(process.cwd(),Fe);return JS.readdirSync(Ve).filter((ze)=>ze.endsWith(".stx")).map((ze)=>ze.replace(/\.stx$/,""))}catch{return[]}},Oe=[...Be(F.layoutsDir),...Be(F.fallbackLayoutsDir)].filter((Fe,Ve,ze)=>ze.indexOf(Fe)===Ve).sort(),We=`Layout not found: ${de} (referenced from ${C})`+(Oe.length>0?`. Available layouts: ${Oe.join(", ")}`:F.layoutsDir?`. No .stx layouts found in ${F.layoutsDir}`:"");if(O.log(Error(We),{layoutPath:de,filePath:C,available:Oe},"error"),console.error(`[stx] ${We}`),F.debug)throw new W(We,C);return H}let ve=await ae(()=>Bun.file(Se).text(),"",()=>{throw new W(`Failed to read layout file: ${Se}`,C,void 0,void 0,"Layout content could not be loaded")});ve=fh(ve,Se);let De=ve.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(De){if(F.debug)console.log(`Found nested layout: ${De[1]} in ${Se}`);let Be={},Oe=ve.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(Ve,ze,at)=>(Be[ze]=at.trim(),""));for(let[Ve,ze]of Object.entries(Be))if(ue[Ve]&&ue[Ve].includes(ns)){let at=ue[Ve].indexOf(ns);ue[Ve]=ue[Ve].slice(0,at)+ze+ue[Ve].slice(at+ns.length)}else if(!ue[Ve])ue[Ve]=ze;let We={...k,__sections:ue},Fe=`@layout('${De[1]}')${Oe}`;return await n(Fe,We,Se,F,T)}let Me=ve.replace(/\{\{--[\s\S]*?--\}\}/g,""),je=Ms(Me,le),Le={};return je=je.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(Be,Oe,We)=>(Le[Oe]=We.trim(),`@slot('${Oe}')`)),je=je.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Be,Oe,We)=>{if(ue[Oe]){let Fe=ue[Oe];if(Fe.includes(ns)){let Ve=Le[Oe]||"",ze=Fe.indexOf(ns);Fe=Fe.slice(0,ze)+Ve+Fe.slice(ze+ns.length)}return Fe}return We||""}),je=n0(je,ue),je=je.replace(/\{\{\s*slot\s*\}\}/g,()=>ue.content||""),je=Ls(je,le),k.__originalFilePath=C,H=await bh(je,k,Se,F,T),H=`<!-- stx-layout: ${de} -->
2622
- ${H}`,G(H)}catch(Se){if(Se instanceof q)throw Se;throw new W(`Error processing layout ${de}: ${Se instanceof Error?Se.message:String(Se)}`,C)}return G(await bh(H,k,C,F,T))}function n0(v,k){return v.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(C,R,T)=>{let z=k[R];if(z!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(z))return z}return T||""})}function r0(v,k){if(v.__stx_sfc_mode=!0,v.__stx_options=k,k.buildMode)v.__stx_buildMode=k.buildMode;let C=k.envPrefix||"STX_PUBLIC_",R={};for(let[T,z]of Object.entries(process.env))if(T.startsWith(C)&&z!==void 0)R[T]=z;v.$env=R}async function s0(v,k){await ae(()=>Em(v,k),void 0,(C)=>{O.log(C,{filePath:v,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${v}: ${C.message}`)})}var Nu="data-stx-source";function hh(v,k){if(!v)return v;let C=/^<script\b([^>]*)>/i.exec(v);if(!C||!/\bserver\b/.test(C[1])||C[1].includes(Nu))return v;return`<script ${Nu}="${encodeURIComponent(k)}"${v.slice(7)}`}function i0(v){let k=new RegExp(`${Nu}="([^"]*)"`).exec(v);return k?decodeURIComponent(k[1]):void 0}function yh(v){return v.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xh(v,k,C){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${k==="module-resolution"?"imports a module that does not resolve":k==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${yh(v)}</span><span style="display:block;margin-top:4px">${yh(C)}</span></div>`}async function o0(v,k,C,R){let{scanScriptTags:T}=await kt("stx/signal-processing",()=>import("./chunk-dcx2t3sy.js")),z=[],F=!E()&&!jn();for(let H of T(v)){let K=H.attrs;if(!/\bserver\b/.test(K))continue;let X=H.start+H.fullMatch.indexOf(">")+1,G=vh(v,X);if(G===-1)continue;let te=v.slice(X,G);if(!te.trim())continue;let ce=i0(K)??C,ee={index:H.start,length:G+9-H.start};try{let{extractVariables:le}=await kt("stx/variable-extractor",()=>import("./chunk-x1xx8qt0.js"));await le(te,k,ce,{preserveExisting:!0,onFailure:(ue)=>{if(ue.kind==="unknown")return;if(R?.onServerScriptError?.({sourcePath:ce,kind:ue.kind,message:ue.message}),!F)return;z.push({...ee,markup:xh(ce,ue.kind,ue.message)})}})}catch(le){let ue=le instanceof Error?le:Error(String(le));if(O.log(ue,{filePath:ce,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${ce}: ${ue.message}`),F)z.push({...ee,markup:xh(ce,"unknown",ue.message)})}}if(z.length===0)return v;let V=v;for(let H of z.sort((K,X)=>X.index-K.index))V=V.slice(0,H.index)+H.markup+V.slice(H.index+H.length);return V}async function a0(v,k,C){try{let{interpolateScriptsInTemplate:R}=await kt("stx/expressions",()=>import("./chunk-7nthebqr.js"));return R(v,k,{skipServer:!0})}catch(R){let T=R instanceof Error?R:Error(String(R));return O.log(T,{filePath:C,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${C}: ${T.message}`),v}}async function bh(v,k,C,R,T){let z=v,F=R;if(z=await o0(z,k,C,R),z=await a0(z,k,C),z=await dm(z,k,C),z=await fm(z,k,C),z=await Xp(z,k,C,F),Ce(z))z=Ti(z,k),z=Is(z,k),z=Ps(z,k);z=$i(z);let{processStreamDirectives:V}=await kt("stx/streaming",()=>import("./chunk-p8ndfekp.js"));z=V(z,k),z=Oi(z,k,C,F,!0),z=await Pm(z,k,C,F,T),z=await $s(z,k,C,F,T),z=cp(z,k,C,F);let{processDeferDirectives:H}=await kt("stx/defer",()=>import("./chunk-jczvjn7z.js"));z=H(z,k,C);let{processTeleportDirectives:K}=await kt("stx/teleport",()=>import("./chunk-ra40trfh.js"));z=K(z,k,C);let{processTransitionDirectives:X,processTransitionAttributes:G}=await kt("stx/transitions",()=>import("./chunk-5x836mv3.js"));z=X(z,k,C),z=G(z);let{processErrorBoundaryDirectives:te,stripRenderFailedMarkers:ce}=await kt("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));z=te(z,k,C),z=ce(z);let{processSuspenseDirectives:ee}=await kt("stx/suspense",()=>import("./chunk-af4ss0p5.js"));z=ee(z,k,C);let{processAsyncDirectives:le}=await kt("stx/async-components",()=>import("./chunk-j90yng9b.js"));z=le(z,k,C);let{processKeepAliveDirectives:ue}=await kt("stx/keep-alive",()=>import("./chunk-kqkhcbrx.js"));z=ue(z,k,C);let{processVirtualListDirectives:de,processVirtualGridDirectives:fe,processInfiniteListDirectives:pe}=await kt("stx/virtual-scrolling",()=>import("./chunk-3wsrhj0k.js"));z=de(z,k,C),z=fe(z,k,C),z=pe(z,k,C);let{processPartialHydrationDirectives:Ae,processStaticDirectives:Se}=await kt("stx/partial-hydration",()=>import("./chunk-5yceay9n.js"));z=Ae(z,k,C),z=Se(z);let{processComputedDirectives:ve,processWatchDirectives:De}=await kt("stx/computed",()=>import("./chunk-1xdzcy9d.js"));z=ve(z,k,C),z=De(z,k,C);let{processFormValidationDirectives:Me}=await kt("stx/forms-validation",()=>import("./chunk-1tpr8d8n.js"));z=Me(z,k,C);let{processHeadDirective:je,processTitleDirective:Le,processMetaDirective:Be,resetHead:Oe}=await kt("stx/head",()=>import("./chunk-20kjbf3h.js"));if(!k.__stx_head_preset&&!k.__stx_runtime_head)Oe();let We=je(z);if(z=We.content,We.headContent)k.__stx_head_raw=`${k.__stx_head_raw||""}${We.headContent}
2623
- `;if(z=Le(z,k),z=Be(z,k,C),z=km(z),z=Ll(z,k),z=Kp(z),z=wm(z),z=await Ds(z,k,C,F,T),z=await $s(z,k,C,F,T),k.__stxProcessingDepth===1)z=Md(z,k);if(z=z.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),z=Ou(z),z=rr(z,k,C),z=Ns(z),z=up(z,k,{filePath:C,buildMode:F.buildMode}),z=Bl(z,k),z=zl(z,k),z=Ma(z,k),z=tg(z,k),z=ng(z,k),z=await jp(z,k,C,F),z=await hp(z,k,C),z=await ji(z,k,C,F),z=Bi(z,k,C,F),z=Ks(z,k,C,F),z=Xs(z,k,C),z=Js(z,k,C,F),z=Hp(z,k,C,F),z=Bs(z,k),z=Fs(z),z=oh(z),!F.skipEventDirectives)z=_d(z,k,C);if(z=pp(z,k,C),F.debug){let _t=/\bx-data\s*=/.test(z),mt=As(v);if(_t&&mt)console.warn(`[stx] ${C}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
2624
- Both work on the same page, but they manage separate scopes.
2625
- Prefer signals (state/derived/effect) for new components.`)}z=Ng(z,k),z=await Z(z,k,C),z=uh(z),z=dh(z),z=Qf(z);let{processXElementDirectives:Fe}=await kt("stx/x-element",()=>import("./chunk-zhxdpzga.js"));z=Fe(z);let Ve=k.__originalFilePath||C,ze=ke(k);if(z=await Ri(z,F,Ve,ze),z=Yp(z,k),z=await _m(z,k,C,F),F.media?.image?.autoSiblings){let _t=F.publicDir||"public",{rewriteImagesWithSiblings:mt}=await kt("stx/image-optimization/auto-sibling",()=>import("./chunk-cncdgxk3.js"));z=await mt(z,{publicDir:_t})}if(F.seo?.enabled)z=Ys(z,k,F);let at=(_t,mt,Rt=!0)=>{if(!mt)return _t;let Kt=mt.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),Gt=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(_t),pn=Gt?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(Gt[0]):null;if(Kt&&Gt&&pn){if(Rt){let an=Gt.index+pn.index;_t=_t.slice(0,an)+Kt[0]+_t.slice(an+pn[0].length)}if(mt=mt.replace(Kt[0],"").trim(),!mt)return _t}if(/<\/head>/i.test(_t))return _t.replace(/<\/head>/i,`${mt}
2626
- </head>`);if(/<head\b[^>]*>/i.test(_t))return _t.replace(/(<head\b[^>]*>)/i,`$1
2627
- ${mt}`);if(/<html\b[^>]*>/i.test(_t))return _t.replace(/(<html\b[^>]*>)/i,`$1
2628
- <head>
2629
- ${mt}
2630
- </head>`);return _t},{renderHead:St,getHead:bt}=await kt("stx/head",()=>import("./chunk-20kjbf3h.js")),wt=k.__stx_runtime_head??bt();if(wt.title||wt.meta?.length||wt.link?.length){let _t=St(wt);if(_t)z=at(z,_t)}if(We.headContent)z=at(z,We.headContent,!wt.title);if(F.csp?.enabled&&F.csp.addMetaTag)z=Vp(z,F.csp,k);if(F.analytics?.enabled)z=ep(z,F);if(F.heatmap?.enabled)z=np(z,F);if(F.pwa?.enabled&&F.pwa.autoInject!==!1){let{injectPwaTags:_t}=await kt("stx/pwa/inject",()=>import("./chunk-575cqc6z.js"));z=_t(z,F)}let gt=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(z),Et=/\bSTX\.\w+/.test(z),vt=/window\.STX\s*=/.test(z);if(gt&&Et&&!vt){let mt=`<script data-stx-scoped data-stx-run="once">
2631
- ${Gf()}
2632
- </script>`;if(z.includes("</head>")){let Rt=z.indexOf("</head>"),Gt=z.slice(0,Rt).indexOf("<script");if(Gt!==-1){let pn=z.slice(0,Gt),an=z.slice(Gt);z=pn+mt+`
2633
- `+an}else z=z.replace("</head>",`${mt}
2634
- </head>`)}else if(z.includes("<body"))z=z.replace(/<body([^>]*)>/,`<body$1>
2635
- ${mt}`);else z=mt+`
2636
- `+z}{let{scanScriptTags:_t}=await kt("stx/signal-processing",()=>import("./chunk-dcx2t3sy.js")),mt=[];for(let Rt of _t(z)){if(!/\bserver\b/i.test(Rt.attrs))continue;let Kt=Rt.start+Rt.fullMatch.indexOf(">")+1,Gt=vh(z,Kt);if(Gt===-1)continue;let pn=Gt+9;while(pn<z.length&&/\s/.test(z[pn]))pn++;mt.push({start:Rt.start,end:pn})}if(mt.length>0){let Rt=Array(mt.length+1),Kt=0;for(let Gt=0;Gt<mt.length;Gt++){let{start:pn,end:an}=mt[Gt];Rt[Gt]=z.slice(Kt,pn),Kt=an}Rt[mt.length]=z.slice(Kt),z=Rt.join("")}}let dt=ba(z,C);if(dt.hasScoped)z=dt.html;let Ct=k.__stx_event_bindings||[],yt=!1,Wt=[],Vr=/\s:[a-z][\w.-]*\s*=/.test(z),{scanScriptTags:yn}=await kt("stx/signal-processing",()=>import("./chunk-dcx2t3sy.js"));for(let _t of yn(z,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))Wt.push({match:_t.fullMatch,attrs:_t.attrs,content:_t.body});for(let{match:_t,attrs:mt,content:Rt}of Wt){yt=!0;let Kt=Rt;Qe(Rt,C,R.strict,k.__originalFilePath);let Gt=await _e(Rt,{eventBindings:Ct,attrs:mt,hasColonDirectives:Vr,templateContent:v,filePath:C,projectRoot:process.cwd(),production:so(R.buildMode),serverData:ze});z=z.replace(_t,()=>Gt)}if(yt)k.__stx_event_bindings=[];if(!yt&&k.__stxProcessingDepth===1){let _t=k.__stx_event_bindings||[];if(_t.length>0){let mt=dc(_t);if(mt){let Rt=z.lastIndexOf("</body>");z=Rt===-1?z+mt:z.slice(0,Rt)+mt+`
2637
- `+z.slice(Rt)}k.__stx_event_bindings=[]}}if(!he(z)&&Fm(z))z=await Ya(z,F);if(z=Vm(z),F.csp?.enabled&&F.csp.useNonce&&typeof k.cspNonce==="string")z=Up(z,k.cspNonce);return z}var c0=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],l0=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],u0=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function Yc(v){let k=[],C=[];return d0(v,k),f0(v,k,C),p0(v,C),g0(v,k),{valid:k.length===0,errors:k,warnings:C}}function d0(v,k){let C=(v.match(/\{\{/g)||[]).length,R=(v.match(/\}\}/g)||[]).length;if(C!==R)k.push({type:"expression",message:`Unclosed expression brackets: found ${C} opening '{{' and ${R} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function f0(v,k,C){for(let R of c0){let T=new RegExp(`${R.open}(?:\\s|\\()`,"g"),z=new RegExp(R.close,"g"),F=(v.match(T)||[]).length,V=(v.match(z)||[]).length;if(R.altClose){let H=new RegExp(R.altClose,"g");V+=(v.match(H)||[]).length}if(F>V)k.push({type:"directive",message:`Unclosed @${R.name} directive: found ${F} opening and ${V} closing`,suggestion:`Add ${F-V} missing ${R.close} tag(s)`});else if(V>F)C.push({type:"directive",message:`Extra ${R.close} found: ${V-F} more closing than opening`,suggestion:`Check for orphaned ${R.close} tags`})}}function p0(v,k){for(let C of l0)if(C.pattern.test(v))k.push({type:"syntax",message:C.message,suggestion:C.suggestion})}function g0(v,k){for(let C of u0)if(C.pattern.test(v))k.push({type:"expression",message:`Security warning: ${C.message}`,suggestion:"Remove dangerous code from template expressions"})}function Zc(v,k){let C=v.slice(0,k).split(`
2638
- `);return{line:C.length,column:C[C.length-1].length+1}}function Qc(v,k,C){let R=[];switch(v){case"if":case"elseif":case"unless":if(C.length===0)R.push({type:"syntax",message:`@${v} requires a condition`,suggestion:`Use @${v}(condition)`});break;case"foreach":if(C.length===0||!C[0].includes(" as "))R.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(C.length===0)R.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(C.length===0)R.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(C.length===0)R.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(C.length===0)R.push({type:"syntax",message:`@${v} requires a path`,suggestion:`Use @${v}('path/to/template')`});break}return R}function el(v){return/@[a-z]+/i.test(v)||/\{\{/.test(v)}function tl(v){let k=v.matchAll(/@([a-z]+)/gi),C=new Set;for(let R of k){let T=R[1].toLowerCase();if(!T.startsWith("end"))C.add(T)}return Array.from(C)}import Gn from"path";import ci from"process";var Ft=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];var Sh=new Set(Ft),m0=new Set(["props","$props","defineProps"]),h0=new Set(["stx","@stacksjs/stx"]),$h=m(128),_h=m(64);function y0(v){let k=[],C=0,R=v.split(`
2639
- `);for(let T of R){let z=C,F=null,V=!1;for(let H=0;H<T.length;H++){let K=T[H];if(V){V=!1;continue}if(K==="\\"){V=!0;continue}if(F){if(K===F)F=null;continue}if(K==="'"||K==='"'||K==="`"){F=K;continue}if(K==="/"&&H+1<T.length&&T[H+1]==="/")break;if(K==="{")C++;else if(K==="}")C--}if(z===0){let H=T.match(/(?:const|let|var)\s+(\w+)\s*=/);if(H)k.push(H[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(T)){let K=T.match(/(?:const|let|var)\s+(\w+)/);if(K)k.push(K[1])}else{let K=T.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(K){let G=K[1].slice(1,-1).split(",").map((te)=>{let ce=te.split(":");return(ce.length>1?ce[1]:ce[0]).trim()}).filter((te)=>/^\w+$/.test(te));k.push(...G)}}}}return[...new Set(k)]}function Hc(v){let k=v;k=k.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),k=k.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),k=k.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),k=k.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),k=k.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function C(R){if(!R.includes(":"))return R;let T=[],z="",F=0,V=0,H=null;for(let K=0;K<R.length;K++){let X=R[K];if(H){if(z+=X,X===H)H=null;continue}if(X==='"'||X==="'"||X==="`"){H=X,z+=X;continue}if(X==="<")F++;else if(X===">"&&F>0)F--;else if(X==="(")V++;else if(X===")")V--;if(X===","&&F===0&&V===0){T.push(z),z="";continue}z+=X}if(z)T.push(z);return T.map((K)=>{let X=K.trim(),G=X.startsWith("..."),te=G?X.slice(3):X,ce=-1,ee=0;for(let Se=0;Se<te.length;Se++)if(te[Se]==="<")ee++;else if(te[Se]===">")ee--;else if(te[Se]===":"&&ee===0){ce=Se;break}if(ce===-1)return K;let ue=te.substring(0,ce).trim().replace(/\?$/,""),de=te.substring(ce+1),fe=-1,pe=0;for(let Se=0;Se<de.length;Se++)if(de[Se]==="<")pe++;else if(de[Se]===">")pe--;else if(de[Se]==="="&&pe===0){fe=Se;break}let Ae=G?"...":"";if(fe!==-1)return`${Ae}${ue} = ${de.substring(fe+1).trim()}`;return`${Ae}${ue}`}).join(", ")}k=k.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(R,T,z)=>{if(!z.includes(":"))return R;return`${T}(${C(z)})`});{let R=/\b(function\s+\w*\s*)\(/g,T,z=[];while((T=R.exec(k))!==null){let F=T.index+T[0].length-1,V=1,H=F+1,K=0,X=null;while(H<k.length&&V>0){let ce=k[H];if(X){if(ce===X)X=null;H++;continue}if(ce==='"'||ce==="'"||ce==="`"){X=ce,H++;continue}if(ce==="<")K++;else if(ce===">"&&K>0)K--;else if(K===0){if(ce==="(")V++;else if(ce===")")V--}if(V>0)H++}if(V!==0)continue;let G=k.substring(F+1,H);if(!G.includes(":"))continue;let te=C(G);z.push({start:F+1,end:H,replacement:te})}for(let F=z.length-1;F>=0;F--){let{start:V,end:H,replacement:K}=z[F];k=k.substring(0,V)+K+k.substring(H)}}return k=k.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(R,T)=>{if(!T.includes(":"))return R;if(T.includes("{")||T.includes("}"))return R;return`(${T.split(",").map((F)=>{let[V,...H]=F.split("="),K=V.split(":")[0].trim();if(H.length>0)return`${K} = ${H.join("=").trim()}`;return K}).join(", ")}) =>`}),k=k.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),k=k.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),k=k.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),k=k.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),k=k.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),k=k.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),k=k.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),k=k.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),k=k.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),k=k.replace(/\n\s*\n\s*\n/g,`
2640
-
2641
- `),k}function Vc(v){return v.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(k,...C)=>{let[,R,T]=C,z=R??T;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(z)?"":k})}function Uc(v){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(v)}function Wc(v){if(v instanceof SyntaxError)return!0;let k=v instanceof Error?v.message:String(v);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(k)}function qc(v){if(!/is not defined|can't find variable/i.test(v))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(v)}var kh=new Set;async function u(v,k,C,R={}){if(!v.trim())return;let T=w(),z=h(v,JSON.stringify(T)),F=$h.get(z);if(F===void 0){try{let Ue=B({loader:"ts",target:"browser",define:T}),He=v.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");He=He.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),F=Ue.transformSync(He)}catch{F=Hc(v)}$h.set(z,F)}let V={exports:{}},H=V.exports,K=ci.cwd(),X={},G=[...F.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((Ue)=>Ue[1]).filter((Ue)=>!Ue.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(Ue)),te=new Map;for(let Ue of G)try{if(Ue.startsWith(".")){X[Ue]=await import(Gn.resolve(Gn.dirname(C),Ue));continue}let He=Gn.resolve(K,"node_modules",Ue),ht=Gn.join(He,"package.json"),At=JSON.parse(d("fs").readFileSync(ht,"utf8")),Jt=At.main||"index.js";if(At.exports){let sn=typeof At.exports==="string"?At.exports:At.exports["."];if(typeof sn==="string")Jt=sn;else if(sn?.bun)Jt=sn.bun;else if(sn?.import)Jt=sn.import;else if(sn?.default)Jt=sn.default}X[Ue]=await import(Gn.resolve(He,Jt))}catch(He){if(Ue.startsWith("."))te.set(Ue,He instanceof Error?He.message:String(He))}let ce=(Ue)=>{if(X[Ue])return X[Ue];let He=te.get(Ue);if(He!==void 0)throw Error(`Cannot require '${Ue}' from ${C}: ${He}`);return d(Ue)},ee=k.props||{},le=(Ue)=>{if(!Ue)return ee;let He={};for(let[ht,At]of Object.entries(Ue)){let Jt=ee[ht];if(Jt!==void 0)He[ht]=Jt;else if(typeof At==="function")He[ht]=At();else He[ht]=At}return He};for(let[Ue,He]of Object.entries(ee))Object.defineProperty(le,Ue,{value:He,enumerable:!0,configurable:!0,writable:!0});let ue=(Ue,He=!1)=>{if(Ue===void 0||Ue===null)return He;if(typeof Ue==="string"){let ht=Ue.trim().toLowerCase();if(ht===""||ht==="true"||ht==="1"||ht==="on"||ht==="yes")return!0;if(ht==="false"||ht==="0"||ht==="off"||ht==="no")return!1;return!0}return Boolean(Ue)},de=(Ue,He=0)=>{if(Ue===void 0||Ue===null)return He;if(typeof Ue==="string"){let At=Ue.trim();if(At==="")return He;let Jt=Number(At);return Number.isFinite(Jt)?Jt:He}let ht=Number(Ue);return Number.isFinite(ht)?ht:He};for(let Ue of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(ee,Ue))continue;try{Object.defineProperty(le,Ue,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let fe=(Ue)=>{if(!Ue)return ee;let He={...ee};for(let[ht,At]of Object.entries(Ue)){let Jt=At&&typeof At==="object"&&!Array.isArray(At)?At:{type:At};if(He[ht]===void 0&&Jt.default!==void 0)He[ht]=typeof Jt.default==="function"?Jt.default():Jt.default}return He},pe=()=>k.slots||{},Ae=(Ue,He)=>{let ht={...Ue};for(let[At,Jt]of Object.entries(He))if(ht[At]===void 0)if(typeof Jt==="function")ht[At]=Jt();else ht[At]=Jt;return ht},Se=(Ue)=>{let He=()=>Ue;return He.set=(ht)=>{},He.update=(ht)=>{},He},ve=(Ue)=>{let He,ht=!1;return()=>{if(!ht)try{He=Ue(),ht=!0}catch{He=void 0}return He}},De=(Ue)=>{},Me=(Ue)=>Ue(),je=(Ue)=>{},Le=(Ue)=>{},Be=lr(k);function Oe(Ue){let He=Ue||{};if(He.title!==void 0||He.description!==void 0)at({title:He.title,description:He.description})}function We(Ue){if(!Ue||typeof Ue!=="object")return;let He=k.__stxClientPayload??{};Object.assign(He,Ue),k.__stxClientPayload=He}let Fe=()=>{let Ue=k.__stxServeContext,He=k.__stxServeSearch??Ue?.search??"",ht=Ue?.path??"",At=Object.fromEntries(new URLSearchParams(He)),Jt=k.query,sn=Object.keys(At).length>0?At:Jt??{},Ur=He||(Object.keys(sn).length>0?`?${new URLSearchParams(sn).toString()}`:"");return{params:k.params??{},query:sn,path:ht,name:"",fullPath:ht+Ur,hash:"",matched:[]}},Ve=()=>({push:(Ue)=>{},replace:(Ue)=>{},back:()=>{},forward:()=>{},go:(Ue)=>{}}),ze=(Ue)=>{let He=k.__stx_runtime_head||{};k.__stx_runtime_head=xe(He,we(Ue||{},{known:_r,source:"useHead()"}))},at=(Ue)=>{ze(Cr(Ue||{}))},St=(Ue)=>({value:Ue}),bt=(Ue)=>Ue,Tt=(Ue)=>({value:typeof Ue==="function"?Ue():Ue}),wt=(Ue,He)=>{},gt=(Ue)=>{},Et=(Ue)=>{},vt=(Ue)=>Ue?Ue():Promise.resolve(),dt=(Ue)=>(He,...ht)=>{},Ct=(Ue)=>{},yt=(Ue,He)=>{},Wt=(Ue,He)=>He,Vr=()=>({value:"light"}),yn=()=>Se(!1),_t=(Ue)=>Se(!1),mt=()=>Se(!1),Rt=()=>_t("(prefers-color-scheme: dark)"),Kt=()=>_t("(prefers-color-scheme: light)"),Gt=()=>_t("(prefers-reduced-motion: reduce)"),pn=()=>_t("(prefers-contrast: more)"),an={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},li=new Proxy(an,{get(Ue,He){if(He in Ue)return Ue[He];return},set(Ue,He,ht){return Ue[He]=ht,!0}}),ic={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},Jn=console;try{let Ue=Os(F,C),He=new Set(Object.keys(ee)),ht=Object.keys(k).filter((ft)=>!He.has(ft)&&!m0.has(ft)&&ut(ft)),At=ht.map((ft)=>k[ft]);if(!ht.includes("__stxServeContext"))ht.push("__stxServeContext"),At.push(void 0);if(!He.has("cookies")){let ft=k.cookies??k.__stxServeContext?.cookies??{},$t=ht.indexOf("cookies");if($t<0)ht.push("cookies"),At.push(ft);else At[$t]=ft}let Jt=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),sn=[],Ur=[];for(let[ft,$t]of Object.entries(ee)){if(!ut(ft))continue;if(Jt.has(ft))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${ft}\\b`).test(Ue))continue;sn.push(ft),Ur.push($t)}let No=y0(Ue).map((ft)=>`module.exports.${ft} = typeof ${ft} !== 'undefined' ? ${ft} : module.exports.${ft};`).join(`
2642
- `),jo=k.params??{},ui=[],Lo=[];for(let ft=0;ft<ht.length;ft++){if(ht[ft]==="params")continue;ui.push(ht[ft]),Lo.push(At[ft])}let Sr=[...Ft,...sn,...ui],ss=`return (async () => {
2643
- ${Ue}
2644
- ${No}
2645
- return module.exports
2646
- })()`,Yn=h(ss,Sr.join("\x00")),on=_h.get(Yn);if(!on)on=Function(...Sr,ss),_h.set(Yn,on);let lt=k.__stx_options?.runtimeConfig;if(lt||/\buse(?:Server)?RuntimeConfig\b/.test(F))await Rn(k,C,lt);let xt=await be(k.__stx_runtime_config??Ht()??_(),()=>Nm(k,()=>on(V,H,ce,ee,le,ue,de,fe,Ae,We,jm,Gs,vr,Se,ve,De,Me,je,Le,Oe,Fe,Ve,ze,at,Be.setResponseStatus,Be.setResponseHeader,Be.notFound,St,bt,Tt,wt,gt,Et,vt,dt,Ct,pe,yt,Wt,Vr,yn,_t,mt,Rt,Kt,Gt,pn,li,ic,Jn,an.confirm,an.alert,an.fetch,jo,...Ur,...Lo)));if(R.preserveExisting){for(let[ft,$t]of Object.entries(xt))if(!(ft in k)||k[ft]===void 0)k[ft]=$t}else Object.assign(k,xt);for(let[ft,$t]of Object.entries(ee))if(!(ft in k))k[ft]=$t}catch(Ue){if(k.__stx_strict_hydration)throw Ue;let He=Vc(Ue instanceof Error?Ue.message:String(Ue));if(Uc(He))console.warn(`[stx] server <script> in ${C??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${He}`),R.onFailure?.({kind:"module-resolution",message:He,error:Ue});else if(Wc(Ue))console.warn(`[stx] server <script> in ${C??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${He}`),R.onFailure?.({kind:"syntax",message:He,error:Ue});else if(qc(He))console.warn(`[stx] server <script> in ${C??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${He}`),R.onFailure?.({kind:"missing-binding",message:He,error:Ue});else{let ht=`${C??"<unknown>"}\x00${He}`;if(ci.env.STX_DEBUG||!kh.has(ht))kh.add(ht),console.warn(`[stx] server <script> in ${C??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${He}`);R.onFailure?.({kind:"unknown",message:He,error:Ue})}try{await $0(F,k,C)}catch(ht){if(ci.env.STX_DEBUG){let At=ht instanceof Error?ht.message:String(ht);console.warn(`[stx] fallback extraction also failed in ${C??"<unknown>"}: ${At}`)}}}}function Gc(v){let k=0,C=null,R=!1,T=!1;for(let z=0;z<v.length;z++){let F=v[z];if(C){if(F===C){if(C=null,R||k===0)T=!0}continue}if(F==="'"||F==='"'||F==="`"){C=F;continue}if(F==="{")k++;else if(F==="}")k--;else if(v.startsWith("from",z)&&k===0)R=!0}return C===null&&k===0&&T}var x0=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Os(v,k){let C=k?Gn.dirname(k):ci.cwd(),R=ci.cwd(),T=v.split(`
2647
- `),z=[],F=0;while(F<T.length){let V=T[F].trim();if(V.startsWith("interface ")||V.startsWith("export interface ")||V.startsWith("type ")||V.startsWith("export type ")){if(V.includes("{")&&!V.includes("}")){let H=0;for(;F<T.length;F++){for(let K of T[F])if(K==="{")H++;else if(K==="}")H--;if(H<=0)break}}F++;continue}if(V.startsWith("definePageMeta(")){let H=0,K=!1,X=F;for(let ce=F;ce<T.length&&!K;ce++){let ee=null,le=!1,ue=T[ce];for(let de=0;de<ue.length;de++){let fe=ue[de];if(le){le=!1;continue}if(fe==="\\"){le=!0;continue}if(ee){if(fe===ee)ee=null;continue}if(fe==='"'||fe==="'"||fe==="`"){ee=fe;continue}if(fe==="(")H++;else if(fe===")"){if(H--,H===0){F=ce+1,K=!0;break}}}}if(!K)F=T.length;let G=T.slice(X,F).join(`
2648
- `),te=[];for(let ce of["title","description"]){let ee=new RegExp(`\\b${ce}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(G);if(ee)te.push(`${ce}: ${JSON.stringify(ee[2])}`)}if(te.length>0)z.push(`useSeoMeta({ ${te.join(", ")} });`);continue}if(V.startsWith("import ")||V==="import"||V.startsWith("import{")||/^import['"]/.test(V)){let H=V,K=0;while(!Gc(H)&&F+K+1<T.length)K++,H=`${H} ${T[F+K].trim()}`;F+=K;let X=H.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),G=H.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),te=H.match(/^import\s*['"](.+?)['"]/),ce=H,ee=(le)=>{if(le.startsWith("."))return Gn.resolve(C,le);if(le.startsWith("~/")||le.startsWith("@/"))return Gn.resolve(R,le.slice(2));try{return Bun.resolveSync(le,C)}catch{return le}};if(X){let[,le,ue]=X,de=ee(ue);z.push(`const ${le} = (await import('${de}')).default`),z.push(`module.exports.${le} = ${le};`)}else if(G){let[,le,ue]=G,de=ee(ue),fe=[],pe=[],Ae=h0.has(ue);for(let Se of le.split(",")){let ve=Se.trim();if(!ve)continue;let De=ve.split(/\s+as\s+/);if(De.length===2){let[Me,je]=[De[0].trim(),De[1].trim()];if(Ae&&Sh.has(Me)){z.push(`const ${je} = ${Me};`);continue}fe.push(`${Me}: ${je}`),pe.push(je)}else{if(Ae&&Sh.has(ve))continue;fe.push(ve),pe.push(ve)}}if(fe.length>0)z.push(`const { ${fe.join(", ")} } = await import('${de}')`);for(let Se of pe)z.push(`module.exports.${Se} = ${Se};`)}else if(te){let le=ee(te[1]);z.push(`await import('${le}')`)}else z.push(ce);F++;continue}if(x0.test(V))z.push(T[F]),F++;else if(V.startsWith("export const ")||V.startsWith("export let ")||V.startsWith("export var ")){let H=Ch(T,F),{type:K,name:X,value:G}=H;z.push(`${K} ${X} = ${G};`),z.push(`module.exports.${X} = ${X};`),F=H.nextIndex}else if(V.startsWith("export function ")||V.startsWith("export async function ")){let H=ju(T,F);z.push(H.functionCode),z.push(`module.exports.${H.name} = ${H.name};`),F=H.nextIndex}else if(V.startsWith("const ")||V.startsWith("let ")||V.startsWith("var ")){let H=Ch(T,F),{type:K,name:X,value:G}=H;z.push(`${K} ${X} = ${G};`),z.push(`module.exports.${X} = ${X};`),F=H.nextIndex}else if(V.startsWith("function ")||V.startsWith("async function ")){let H=ju(T,F);z.push(H.functionCode),z.push(`module.exports.${H.name} = ${H.name};`),F=H.nextIndex}else if(V.startsWith("export default function ")||V.startsWith("export default async function ")){let H=T[F].replace(/^(\s*)export\s+default\s+/,"$1"),K=[...T];K[F]=H;let X=ju(K,F);if(z.push(X.functionCode),X.name)z.push(`module.exports.default = ${X.name};`);F=X.nextIndex}else if(V.startsWith("export default ")){let H=V.replace(/^export\s+default\s+/,"").replace(/;$/,"");z.push(`module.exports.default = ${H};`),F++}else if(V.startsWith("class ")||V.startsWith("export class ")){let H=V.match(/(?:export\s+)?class\s+(\w+)/);if(H){let K=H[1],X=T[F].replace(/^export\s+/,""),G=0,te=F;for(;te<T.length;te++){let ce=T[te];for(let ee of ce)if(ee==="{")G++;else if(ee==="}")G--;if(te>F)X+=`
2649
- `+ce;if(G<=0&&te>=F)break}z.push(X),z.push(`module.exports.${K} = ${K};`),F=te+1}else z.push(V),F++}else if(V.includes("module.exports"))z.push(V),F++;else if(V.trim()&&!V.startsWith("//"))z.push(V),F++;else F++}return b0(z.join(`
2650
- `),C,R)}function b0(v,k,C){let R=v.length,T="",z=0,F=null,V=!1,H=!1,K=0;while(z<R){let X=v[z],G=v[z+1];if(V){if(T+=X,X===`
2651
- `)V=!1;z++;continue}if(H){if(T+=X,X==="*"&&G==="/"){T+=G,z+=2,H=!1;continue}z++;continue}if(!F&&X==="/"&&G==="/"){V=!0,T+=X,z++;continue}if(!F&&X==="/"&&G==="*"){H=!0,T+=X,z++;continue}if(F){if(T+=X,X==="\\"){T+=G,z+=2;continue}if(X===F&&F!=="`"){F=null,z++;continue}if(F==="`"){if(X==="$"&&G==="{"){K++,T+=G,z+=2;continue}if(X==="`"){F=null,z++;continue}}z++;continue}if(K>0){if(X==="{")K++;else if(X==="}")K--}if(X==='"'||X==="'"||X==="`"){F=X,T+=X,z++;continue}if(X==="a"&&v.startsWith("await",z)){let te=v0(v,z);if(te){let{quote:ce,path:ee,end:le}=te;if(ee.startsWith(".")||ee.startsWith("~/")||ee.startsWith("@/")){let ue=ee.startsWith(".")?Gn.resolve(k,ee):Gn.resolve(C,ee.slice(2));T+=`await import(${ce}${ue}${ce})`,z=le;continue}}}T+=X,z++}return T}function v0(v,k){let C=k+5;if(C>=v.length)return null;if(!/\s/.test(v[C]))return null;while(C<v.length&&/\s/.test(v[C]))C++;if(!v.startsWith("import",C))return null;C+=6;while(C<v.length&&/\s/.test(v[C]))C++;if(v[C]!=="(")return null;C++;while(C<v.length&&/\s/.test(v[C]))C++;let R=v[C];if(R!=="'"&&R!=='"')return null;C++;let T=C;while(C<v.length&&v[C]!==R)if(v[C]==="\\")C+=2;else C++;if(C>=v.length)return null;let z=v.slice(T,C);C++;while(C<v.length&&/\s/.test(v[C]))C++;if(v[C]!==")")return null;return{quote:R,path:z,end:C+1}}function Ih(v,k){let C=v[k];if(C!=="{"&&C!=="[")return null;let T=S(v,C,C==="{"?"}":"]",k);if(T===-1)return null;return{pattern:v.slice(k,T+1),endPos:T+1}}function Ph(v){let k=[],C=v.slice(1,-1).trim();if(!C)return k;let R=0,T=0,z="";while(R<C.length){let F=C[R];if(F==="{"||F==="["){let V=T===0?Ih(C,R):null;if(V){k.push(...Ph(V.pattern)),R=V.endPos,z="";continue}T++}else if(F==="}"||F==="]")T--;if(T>0){R++;continue}if(F===","){if(z.trim())k.push(z.trim());z="",R++;continue}if(F===":"){z="",R++;continue}if(F==="="){if(z.trim())k.push(z.trim());z="",R++;while(R<C.length&&C[R]!==","&&T===0){if(C[R]==="{"||C[R]==="[")T++;else if(C[R]==="}"||C[R]==="]")T--;R++}continue}if(/[\w$]/.test(F))z+=F;R++}if(z.trim())k.push(z.trim());return k}function Kc(v){let k=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(v);if(!k)return null;let C=k[0].length,R=(T)=>T===" "||T==="\t";while(C<v.length&&R(v[C]))C++;if(v[C]===":"){let T=0,z=null;C++;for(;C<v.length;C++){let F=v[C];if(z){if(F==="\\"){C++;continue}if(F===z)z=null;continue}if(F==="'"||F==='"'||F==="`"){z=F;continue}if(F==="("||F==="["||F==="{"||F==="<"){T++;continue}if(F===")"||F==="]"||F==="}"||F===">"){T--;continue}if(F==="="&&T<=0){let V=v[C+1],H=v[C-1];if(V!=="="&&V!==">"&&H!=="="&&H!=="!"&&H!=="<"&&H!==">")break}}if(v[C]!=="=")return null}while(C<v.length&&R(v[C]))C++;if(v[C]!=="=")return null;return{type:k[1],name:k[2],value:v.slice(C+1).trim()}}function Eh(v,k,C,R){let T=null,z=!1;for(let F of v){if(z){z=!1;continue}if(F==="\\"){z=!0;continue}if(T){if(F===T)T=null;continue}if(F==="'"||F==='"'||F==="`"){T=F;continue}if(F===k)R++;else if(F===C)R--}return R}function Ch(v,k){let C=v[k].trim(),R=Kc(C),T=R?[C,R.type,R.name,R.value]:null;if(!T){let X=C.match(/^(?:export\s+)?(const|let|var)\s+/);if(X){let G=C.slice(X[0].length),te=k;if(G.startsWith("{")||G.startsWith("[")){let ee=G[0],le=ee==="{"?"}":"]",ue=Eh(G,ee,le,0),de=G;for(let fe=k+1;fe<v.length&&ue>0;fe++)de+=` ${v[fe].trim()}`,te=fe,ue=Eh(v[fe],ee,le,ue);if(ue>0)de=G,te=k;G=de}let ce=Ih(G,0);if(ce){let ee=X[1],le=ce.pattern,ue=G.slice(ce.endPos).trim();if(ue.startsWith("=")){let de=ue.slice(1).trim(),fe=de,pe=Math.max(te,k);if(Rh(de)){let De=Ah(v,pe,de);fe=De.value,pe=De.nextIndex}else pe=pe+1;fe=fe.trim().replace(/;$/,"");let Ae=Ph(le),Se=`__stx_src_${k}`,ve=Ae.map((De)=>`module.exports.${De} = ${De};`).join(`
2652
- `);return{type:ee,name:Se,value:`${fe}; ${ee} ${le} = ${Se};
2653
- ${ve}`,nextIndex:pe}}}}throw Error(`Failed to parse variable declaration: ${C}`)}let[,z,F,V]=T,H=V,K=k;if(Rh(V)){let X=Ah(v,k,V);H=X.value,K=X.nextIndex}else K=k+1;while(K<v.length){let X=v[K].trim();if(X.startsWith(".")||X.startsWith("?."))H+=`
2654
- ${v[K]}`,K++;else break}return H=H.trim().replace(/;$/,""),{type:z,name:F,value:H,nextIndex:K}}function ju(v,k){let C=v[k].trim(),R=C.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!R)throw Error(`Failed to parse function declaration: ${C}`);let[,T]=R,z=C.replace(/^export\s+/,""),F=k;if(w0(C)){let V=S0(v,k,z);z=V.functionCode,F=V.nextIndex}else F=k+1;return{name:T,functionCode:z,nextIndex:F}}function Rh(v){let k=v.trim();if(k.startsWith("{"))return S(k,"{","}",0)===-1;if(k.startsWith("["))return S(k,"[","]",0)===-1;return!Dh(k)}function Dh(v){let k={paren:0,bracket:0,brace:0},C=null,R=0;for(let T=0;T<v.length;T++){let z=v[T];if((T>0?v[T-1]:"")==="\\"&&C)continue;if((z==='"'||z==="'")&&!C){C=z;continue}if(z===C&&C!=="`"){C=null;continue}if(z==="`"&&!C){C="`";continue}if(z==="`"&&C==="`"&&R===0){C=null;continue}if(C==="`"&&z==="$"&&v[T+1]==="{"){R++,T++;continue}if(R>0&&z==="{"){R++;continue}if(R>0&&z==="}"){R--;continue}if(C)continue;if(z==="(")k.paren++;else if(z===")")k.paren--;else if(z==="[")k.bracket++;else if(z==="]")k.bracket--;else if(z==="{")k.brace++;else if(z==="}")k.brace--}return k.paren===0&&k.bracket===0&&k.brace===0&&C===null}function Oh(v){let k=v.indexOf("(");if(k===-1)return v.indexOf("{");let C=S(v,"(",")",k);if(C===-1)return-1;return v.indexOf("{",C)}function w0(v){let k=Oh(v);if(k===-1)return!0;return S(v,"{","}",k)===-1}function Ah(v,k,C){let R=C,T=k+1;while(T<v.length&&!Dh(R)){let z=v[T];R+=`
2655
- ${z}`,T++}while(T<v.length){let z=v[T].trim();if(z.startsWith(".")||z.startsWith("?."))R+=`
2656
- ${v[T]}`,T++;else break}return{value:R,nextIndex:T}}function S0(v,k,C){let R=C,T=k+1;while(T<v.length){let z=Oh(R);if(z!==-1){if(S(R,"{","}",z)!==-1)break}let F=v[T];R+=`
2657
- ${F}`,T++}return{functionCode:R,nextIndex:T}}function Th(v,k){let C=l(v,k)??l(`(${v})`,k);if(C!==void 0)return C;if(!/\bprocess\b/.test(v))return;let R={...k,process:Object.freeze({env:{...ci.env}})},T=Object.keys(R).filter(ut),z=T.map((F)=>R[F]);try{return Function(...T,`'use strict'; return (${v});`)(...z)}catch{try{return Function(...T,`'use strict'; return ${v};`)(...z)}catch{return}}}async function $0(v,k,C){let R=v.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let z of R){let[,,F,V]=z;try{let H=V.trim().replace(/;$/,""),K=Th(H,k);if(K!==void 0)k[F]=K}catch(H){console.warn(`Failed to parse export ${F} in fallback:`,H)}}let T=v.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let z of T){let[,,F,V]=z;if(!(F in k))try{let H=V.trim().replace(/;$/,""),K=Th(H,k);if(K!==void 0)k[F]=K}catch{}}}function Pi(v){let k=v.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),C=k?k[1]:"",R=k?v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):v;return{scriptContent:C,templateWithoutScript:R}}function Ii(v){let k=v.trim();if(!k)return!1;return/(?:const|let|var|function)\s+\w+/.test(k)}var Oo=new L(500),rc=new L(1000),zu=new L(2000),Wu=new L(500),Wh=33554432,Fu=Wh;function _0(v){let k=v.componentRenderCacheBytes;if(typeof k!=="number"||k<0||k===Fu)return;Fu=k,sc.setMaxBytes(k)}var sc=new L(2000,{maxBytes:Wh,sizeOf:(v)=>v.output.length});function k0(v){let k=new WeakSet;try{let C=(R)=>{if(R===void 0)return{__stxType:"undefined"};if(typeof R==="bigint")return{__stxType:"bigint",value:R.toString()};if(typeof R==="function"||typeof R==="symbol")throw TypeError("Non-serializable component input");if(R===null||typeof R!=="object")return R;if(k.has(R))throw TypeError("Circular component input");k.add(R);try{if(R instanceof Date)return{__stxType:"date",value:R.toISOString()};if(Array.isArray(R))return R.map(C);let T=Object.getPrototypeOf(R);if(T!==Object.prototype&&T!==null)throw TypeError("Non-plain component input");let z={};for(let F of Object.keys(R).sort())z[F]=C(R[F]);return z}finally{k.delete(R)}};return JSON.stringify(C(v))}catch{return null}}function E0(v){let k={};for(let[C,R]of Object.entries(v))if(!C.startsWith("__")||C==="__stxServeContext")k[C]=R;return k}function Lu(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zs(v){let k=process.cwd(),C=`${k}\x00${v}`,R=Mh.get(C);if(R===void 0)R=Bun.hash(Fh(v,k).split(pt.sep).join("/")).toString(36).slice(0,6),Mh.set(C,R);return R}var Mh=new Map;function Fh(v,k){if(!pt.isAbsolute(v))return v;let C=(R)=>{try{return Uu.realpathSync(R)}catch{return R}};return pt.relative(C(k),C(v))}function nl(v){return/\bjs\b/.test(v)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(v)}function nt(v){return!nl(v)}var nc=new Map;function B(v){let k;try{k=JSON.stringify(v)}catch{return new Bun.Transpiler(v)}let C=nc.get(k);if(C)return C;if(nc.size>=16)nc.clear();let R=new Bun.Transpiler(v);return nc.set(k,R),R}var Nh=new WeakMap,C0=256;function rt(v){try{let k=B({loader:"ts",target:"browser",define:w()}),C=Nh.get(k);if(!C)C=new Map,Nh.set(k,C);let R=C.get(v);if(R!==void 0)return R;let T=v.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");T=T.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let z=[];T=T.replace(/\{!![\s\S]*?!!\}/g,(V)=>{let H=z.length;return z.push(V),`"__STX_EXPR_${H}__"`}),T=T.replace(/\{\{\{[\s\S]*?\}\}\}/g,(V)=>{let H=z.length;return z.push(V),`"__STX_EXPR_${H}__"`}),T=T.replace(/\{\{[\s\S]*?\}\}/g,(V)=>{let H=z.length;return z.push(V),`"__STX_EXPR_${H}__"`});let F=k.transformSync(T);for(let V=0;V<z.length;V++)F=F.replace(`"__STX_EXPR_${V}__"`,z[V]),F=F.replace(`'__STX_EXPR_${V}__'`,z[V]);if(C.size>=C0){let V=C.keys().next();if(!V.done)C.delete(V.value)}return C.set(v,F),F}catch(k){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",k);return v}}function R0(v){let k=[],C=new Set,R=0,T=0,z=v.length,F=(X)=>{T++;while(T<z){if(v[T]==="\\"){T+=2;continue}if(v[T]===X){T++;return}T++}},V=()=>{T++;while(T<z){if(v[T]==="\\"){T+=2;continue}if(v[T]==="`"){T++;return}if(v[T]==="$"&&v[T+1]==="{"){T+=2;let X=1;while(T<z&&X>0)if(v[T]==="{")X++,T++;else if(v[T]==="}")X--,T++;else if(v[T]==="'"||v[T]==='"')F(v[T]);else if(v[T]==="`")V();else T++;continue}T++}},H=()=>{if(v[T]==="/"&&v[T+1]==="/"){while(T<z&&v[T]!==`
2658
- `)T++;return!0}if(v[T]==="/"&&v[T+1]==="*"){T+=2;while(T<z-1&&!(v[T]==="*"&&v[T+1]==="/"))T++;return T+=2,!0}return!1},K=()=>{if(R!==0)return;let X=v.slice(T).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(X){let ee=X[2].split(",").map((le)=>{let ue=le.trim().split(":");return ue[ue.length-1].trim()});for(let le of ee)if(le&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(le)&&!C.has(le))k.push(le),C.add(le);return}let G=v.slice(T).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let ee=G[2];if(!C.has(ee))k.push(ee),C.add(ee);return}let te=v.slice(T).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let ee=te[1];if(!C.has(ee))k.push(ee),C.add(ee);return}let ce=v.slice(T).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ce){let ee=ce[1];if(!C.has(ee))k.push(ee),C.add(ee)}};while(T<z){if(H())continue;if(v[T]==="'"||v[T]==='"'){F(v[T]);continue}if(v[T]==="`"){V();continue}if(v[T]==="{"){R++,T++;continue}if(v[T]==="}"){R--,T++;continue}if(R===0&&/[a-z]/i.test(v[T])&&(T===0||/\s|[;{}()]/.test(v[T-1])))K();T++}return k}function A0(v){let k=[],C=0,R=0,T=null;for(let z=0;z<v.length;z++){let F=v[z];if(T){if(F==="\\"){z++;continue}if(F===T)T=null;continue}if(F==='"'||F==="'"||F==="`"){T=F;continue}if(F==="("||F==="["||F==="{")C++;else if(F===")"||F==="]"||F==="}")C--;else if(F===","&&C===0)k.push(v.slice(R,z)),R=z+1}if(R<v.length)k.push(v.slice(R));return k}function T0(v){let k=0,C=null;for(let R=0;R<v.length;R++){let T=v[R];if(C){if(T==="\\"){R++;continue}if(T===C)C=null;continue}if(T==='"'||T==="'"||T==="`"){C=T;continue}if(T==="("||T==="["||T==="{")k++;else if(T===")"||T==="]"||T==="}")k--;else if(T==="="&&k===0){let z=v[R-1],F=v[R+1];if(z==="!"||z==="<"||z===">"||z==="=")continue;if(F==="="||F===">")continue;return R}}return-1}function I0(v,k){try{let C=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec(v);if(!C)return;let R=C.index-1;while(R>=0&&/\s/.test(v[R]))R--;if(v[R]!=="}")return;let T=R,z=0,F=-1;for(;R>=0;R--){let H=v[R];if(H==="}")z++;else if(H==="{"){if(z--,z===0){F=R;break}}}if(F===-1)return;let V=v.slice(F+1,T);for(let H of A0(V)){let K=H.trim();if(!K||K.startsWith("..."))continue;let X=T0(K);if(X===-1)continue;let G=K.slice(0,X).trim();if(!/^[A-Z_$][\w$]*$/i.test(G))continue;if(k[G]!==void 0)continue;let te=K.slice(X+1).trim();if(!te)continue;try{let ce=Object.keys(k).filter(ut),ee=Function(...ce,`"use strict"; return (${te});`);k[G]=ee(...ce.map((le)=>k[le]))}catch{}}}catch{}}var P0=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function rl(v,k){let C=v.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)<([a-zA-Z][a-zA-Z0-9-]*)/s);if(!C)return null;let R=C[2].toLowerCase();if(!P0.has(R))return null;let T=new RegExp(`<\\/?${R}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),z=ne(v,(K,X)=>(T.lastIndex=X,T.exec(K)?.index===X?T.lastIndex:-1));if(R==="span"&&/\sdata-stx-scope\s*=/.test(z[0]?.token||""))return null;let F=0,V=!1;for(let K of z){if(F+=K.token.startsWith("</")?-1:1,F<0)return null;if(F===0){if(v.slice(K.end).trim())return null;V=!0;break}}if(!V)return null;let H=C[0].length;return v.slice(0,H)+k+v.slice(H)}async function gr(v,k,C,R,T){let z=v.endsWith(".stx")?v.slice(0,-4):v,F=(Se)=>Se.split("-").map((ve)=>ve.charAt(0).toUpperCase()+ve.slice(1)).join(""),V=C.__importedComponents;if(V){for(let Se of[z,z.toLowerCase(),F(z),gn(z)])if(V.has(Se))return!0}let H=[...new Set([`${z}.stx`,`${F(z)}.stx`,`${gn(z)}.stx`])],K=typeof T.root==="string"?pt.resolve(T.root):void 0,X=K??pt.dirname(R),G=[],te=(Se)=>{if(Se&&!G.includes(Se))G.push(Se)},ce=C.__originalFilePath;if(ce)te(pt.join(pt.dirname(ce),"components"));te(k),te(T._rootComponentsDir),te(pt.join(pt.dirname(R),"components")),te(T.componentsDir);let ee=T._targetComponentFallbackNames?.some((Se)=>Se.toLowerCase()===z.toLowerCase());if(!ee)for(let Se of T._targetComponentDirs??[])te(Se);if(K)te(pt.resolve(K,"resources/views/components")),te(pt.resolve(K,"resources/components")),te(pt.resolve(K,"src/components")),te(pt.resolve(K,"components"));for(let Se of T._layerComponentDirs??[])te(Se);let le=T._pluginComponentDirs;if(Array.isArray(le))for(let Se of le)te(typeof Se==="string"?Se:null);if(te(T.fallbackComponentsDir),ee)for(let Se of T._targetComponentDirs??[])te(Se);if(z.startsWith("./")||z.startsWith("../"))return r(pt.resolve(pt.dirname(R),`${z}.stx`));let ue=jh(pt.resolve(import.meta.dir,"components")),de=G.map((Se)=>pt.isAbsolute(Se)?Se:pt.resolve(X,Se)),fe=`${H.join("\x00")}\x00\x00${de.join("\x00")}`,pe=zu.get(fe);if(pe!==void 0)return pe;let Ae=!1;e:for(let Se of de){if(jh(Se)===ue)continue;for(let ve of H)if(await r(pt.join(Se,ve))){Ae=!0;break e}}return zu.set(fe,Ae),Ae}function jh(v){let k=Wu.get(v);if(k!==void 0)return k;let C=v;try{C=Uu.realpathSync(v)}catch{}return Wu.set(v,C),C}function sl(v){return v==="visible"||v==="idle"||v==="interaction"||v.startsWith("media:")}function Mi(v){if(!v)return!1;let k=v.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(k)}function D0(v,k,C){if(!v.includes("{{")&&!v.includes("{!!"))return v;let R=(T,z)=>{let F;try{F=x(T,k)}catch{return z}if(F===void 0||F===null)return"";let V=String(F);if(/<\/style/i.test(V))return console.warn(`[stx] a <style> expression in ${C??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return V};return v.replace(/\{!!([\s\S]*?)!!\}/g,(T,z)=>R(z,T)).replace(/\{\{([\s\S]*?)\}\}/g,(T,z)=>R(z,T))}var Lh=new Set;function Bh(v,k,C,R){let T=`${v}\x00${k}\x00${R??""}`;if(!process.env.STX_DEBUG&&Lh.has(T))return;Lh.add(T);let z=k?` used in ${k}`:"",F=R?` Cause: ${R}.`:"",V=C.length>0?`
2659
- searched:
2660
- ${C.map((H)=>` - ${H}`).join(`
2661
- `)}`:"";console.error(`[stx] component <${v}> could not be resolved${z}, so it rendered as nothing.${F}${V}`)}function zh(v){return`<!-- stx: component "${v.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}function Hs(v){let k=new Set,C=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let R of v){let T;while((T=C.exec(R))!==null)k.add(T[1]);C.lastIndex=0}return[...k]}async function st(v,k,C,R,T,z,F,V=new Set,H,K=Tr(T),X,G=v){let{extractVariables:te}=await kt("stx/variable-extractor",()=>import("./chunk-x1xx8qt0.js")),ce=V??new Set;if(ce.has(v))return`[Circular component reference: ${v}]`;let ee=new Set(ce);ee.add(v);let le=typeof k.client==="string"?k.client.trim():"";if("client"in k)delete k.client;let ue=le&&le!=="load"&&sl(le)?le:"";try{let de=(lt)=>lt.split("-").map((xt)=>xt.charAt(0).toUpperCase()+xt.slice(1)).join(""),fe=G.endsWith(".stx")?G.slice(0,-4):G,pe=null,Ae=T.__importedComponents;if(Ae){let lt=[fe,fe.toLowerCase(),de(fe),gn(fe)];for(let xt of lt)if(Ae.has(xt)){pe=Ae.get(xt);break}}let Se=[];if(!pe){let lt=[`${fe}.stx`,`${de(fe)}.stx`,`${gn(fe)}.stx`],xt=[...new Set(lt)],ft=T.__originalFilePath,$t=[];if($t.push(...F._layerComponentDirs??[]),ft){let Pt=pt.join(pt.dirname(ft),"components");$t.push(Pt)}if(R)$t.push(R);let cn=F._rootComponentsDir;if(typeof cn==="string"&&!$t.includes(cn))$t.push(cn);let en=pt.join(pt.dirname(z),"components");if(!$t.includes(en))$t.push(en);if(F.componentsDir&&F.componentsDir!==R&&!$t.includes(F.componentsDir))$t.push(F.componentsDir);let kr=F._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(fe),is=(X?.events??[]).map((Pt)=>Pt.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),Rr=Object.hasOwn(k,"checked")||Boolean(X?.reactiveProps?.includes("checked")),os=Object.hasOwn(k,"value")||Boolean(X?.reactiveProps?.includes("value")),Bo=!is.includes("valuechange")&&(Rr||is.includes("change")&&!os),zo=F._targetComponentFallbackNames?.some((Pt)=>Pt.toLowerCase()===fe.toLowerCase())&&(!kr||Bo);for(let Pt of zo?[]:F._targetComponentDirs??[])if(Pt&&!$t.includes(Pt))$t.push(Pt);let zn=typeof F.root==="string"?pt.resolve(F.root):void 0,Wo=zn??pt.dirname(z),Qn=[];if(zn)Qn.push(pt.resolve(zn,"resources/views/components")),Qn.push(pt.resolve(zn,"resources/components")),Qn.push(pt.resolve(zn,"src/components")),Qn.push(pt.resolve(zn,"components"));Qn.push(pt.resolve(import.meta.dir,"components"));for(let Pt of Qn)if(!$t.includes(Pt))$t.push(Pt);let Fi=F._pluginComponentDirs;if(Array.isArray(Fi)){for(let Pt of Fi)if(typeof Pt==="string"&&!$t.includes(Pt))$t.push(Pt)}if(F.fallbackComponentsDir&&!$t.includes(F.fallbackComponentsDir))$t.push(F.fallbackComponentsDir);if(zo){for(let Pt of F._targetComponentDirs??[])if(Pt&&!$t.includes(Pt))$t.push(Pt)}let Vi=[...new Set($t.map((Pt)=>{if(!Pt)return Pt;return pt.isAbsolute(Pt)?Pt:pt.resolve(Wo,Pt)}))];$t.length=0,$t.push(...Vi);let as=`${fe}\x00${z}\x00${Vi.join("\x00")}`,oc=rc.get(as);if(oc)if(await r(oc))pe=oc;else rc.delete(as);if(!pe&&(fe.startsWith("./")||fe.startsWith("../")))pe=pt.resolve(pt.dirname(z),`${fe}.stx`),Se.push(pe);else if(!pe)for(let Pt of $t){if(!Pt)continue;for(let Fo of xt){let Vo=pt.join(Pt,Fo);if(Se.push(Vo),await r(Vo)){pe=Vo;break}}if(pe)break;if(!pe)try{let Fo=await import("fs");if(!Fo.statSync(Pt,{throwIfNoEntry:!1})?.isDirectory())continue;let Xh=8,ac=[{path:Pt,depth:0}];while(ac.length>0&&!pe){let Uo=ac.pop();if(Uo.depth>=Xh)continue;let qu;try{qu=Fo.readdirSync(Uo.path,{withFileTypes:!0})}catch{continue}for(let Ho of qu){if(!Ho.isDirectory())continue;if(Ho.name==="node_modules"||Ho.name.startsWith("."))continue;let Ku=pt.join(Uo.path,Ho.name);for(let Zh of xt){let cc=pt.join(Ku,Zh);if(Se.push(cc),await r(cc)){pe=cc;break}}if(pe)break;ac.push({path:Ku,depth:Uo.depth+1})}}}catch{}if(pe)break}if(pe)rc.set(as,pe)}if(!pe||!await r(pe))return Bh(v,z,Se),zh(v);H.add(pe);let ve;if(Oo.has(pe))ve=Oo.get(pe);else try{ve=await Bun.file(pe).text(),Oo.set(pe,ve)}catch(lt){let xt=lt instanceof Error?lt.message:String(lt);return Bh(v,z,[pe],xt),zh(v)}if(X)for(let lt of new Set([...Object.keys(k),...X.reactiveProps??[]])){let xt=lt.toLowerCase();if(xt.startsWith("aria-")||xt.startsWith("data-"))continue;let ft=lt.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${ft}\\b`).test(ve))X.declaredProps.add(lt);if(new RegExp(`\\$props\\s*(?:\\.\\s*${ft}\\b|\\[\\s*['"]${ft}['"]\\s*\\])`).test(ve)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${ft}['"]`).test(ve))X.consumedProps?.add(lt)}let De=new Set(["__originalFilePath","__importedComponents",ia,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),Me={};for(let[lt,xt]of Object.entries(T))if(!lt.startsWith("__")||De.has(lt))Me[lt]=xt;let je=K.length>0?{[pa]:[...K]}:{},Le=C;if(C.includes("@include")){let{processIncludes:lt}=await kt("stx/includes",()=>import("./chunk-qhjm9hvz.js"));Le=await lt(C,T,z,F,H)}if(/<[A-Z][\w.-]*[\s/>]/.test(Le)){let{processComponents:lt}=await kt("stx/component-renderer",()=>import("./chunk-ftrsaag8.js"));Le=await lt(Le,{...T,__processedComponents:ce,...je},z,F,H)}let Be=[];if(Mi(Le)){let{processExpressions:lt}=await kt("stx/expressions",()=>import("./chunk-7nthebqr.js")),xt=T.__stx_signals_gate===void 0?{...T,__stx_signals_gate:!0,...je}:K.length>0?{...T,...je}:T;Le=lt(Le,xt,z);for(let ft of Le.matchAll(/\{\{([\s\S]*?)\}\}/g))Be.push(ft[1].trim())}let Oe=Mn(Le),We=[],Fe=Oe.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(lt,xt)=>{let ft=Oe.scripts[Number(xt)]||"",$t=ft.match(/^<script\b([^>]*)>/i)?.[1]||"",cn=$t.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),en=!cn||["module","text/javascript","application/javascript"].includes(cn),kr=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${$t}`);if(!/\bserver\b/i.test($t)&&en&&!kr)return We.push(ft),"";return ft}),{extractSlotContent:Ve}=await kt("stx/slots",()=>import("./chunk-y84n0dvg.js")),ze=Ve(Fe),at={};if(ze.defaultSlot?.trim())at.default=ze.defaultSlot;for(let[lt,xt]of ze.namedSlots)at[lt]=xt.content;let St=T.__stx_scope_seq??={n:0,key:zs(String(T.__filename??z))},bt=Fh(v,process.cwd()),wt=`stx_${(bt.endsWith(".stx")?bt.slice(0,-4):bt).replace(/[^a-zA-Z0-9]/g,"_")}_${++St.n}_${St.key}`,gt={...Me,$uid:wt,...k,props:k,slot:Fe,$slots:at,__processedComponents:ee,__sections:{},__stx_signals_gate:Ce(ve)||Mi(C),__stx_preserved_client_expressions:[...Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[],...Be]};I0(ve,gt);let Et=ve,vt=oe(Et);if(vt)Et=vt.content.trim();let dt=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Ct=[...ve.matchAll(dt)];for(let[,lt,xt]of Ct)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(lt))Qe(xt,pe,F.strict);let yt=[],Wt=null,Vr=Ct.some((lt)=>/\bserver\b/.test(lt[1]||"")&&/\bcache\b/.test(lt[1]||"")),yn=null,_t=null,mt=null,Rt=0,Kt=null;if(_0(F),Vr&&Fu>0){let lt=k0({props:k,slot:Le,slotContext:C.trim()?E0(Me):void 0,buildMode:F.buildMode??"",skipEventDirectives:F.skipEventDirectives===!0,clientLoopNames:[...K].sort(),layers:F._layerGraph?.layers.map((xt)=>xt.configFile),uid:wt});if(lt!==null){yn=`${pe}\x00${h(ve)}\x00${lt}`;let xt=sc.get(yn);if(xt){for(let ft of xt.dependencies)H.add(ft);if(Ld(T,xt.clientFactories),St.n+=xt.uidsConsumed,xt.preservedClientExpressions.length>0){let ft=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[]);for(let $t of xt.preservedClientExpressions)ft.add($t);T.__stx_preserved_client_expressions=[...ft]}return xt.output}_t=new Set(H),mt=Nd(T),Rt=St.n,Kt=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[])}}let Gt=new Set;for(let lt of Ct){let xt=lt[1]||"",ft=lt[2]||"",$t=xt.includes("server");if(nt(xt)&&ft.trim())ft=rt(ft);if($t&&ft){for(let en of me(ft))Gt.add(en);try{await te(ft,gt,pe,{onFailure:(en)=>{if(en.kind!=="unknown")Wt=en.kind}})}catch(en){}}if(!$t){let en=ft.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),kr=en.includes("{{")&&en.includes("}}"),is=en.includes("{!!")&&en.includes("!!}");if(kr||is)en=xs(en,gt,pe);let Rr=xt.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");yt.push(`<script${Rr}>${en}</script>`)}}let an=Mn(ve).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),li=an?an[1]:"",ic=an?an[2]:"",Jn="",Ue=li&&/\bscoped\b/i.test(li);if(an)Jn=`<style${li}>${D0(ic,gt,pe)}</style>`;let He=Et;if(He=He.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),an)He=He.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let lt=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,xt=[];if(He=He.replace(lt,(ft,$t)=>{let cn=$t.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(cn)xt.push(`<style${cn[1]}>${cn[2]}</style>`);return""}),He=He.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),xt.length>0)Jn=`${Jn}${xt.join(`
2662
- `)}`}if(C&&He.includes("{{ text || slot }}"))He=He.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>C);let{applySlots:ht}=await kt("stx/slots",()=>import("./chunk-y84n0dvg.js")),{defaultSlot:At,namedSlots:Jt}=ze,sn=yt.some((lt)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(lt)),Ur=(lt)=>sn?ah(lt,wt):lt,Hu=new Map([...Jt].map(([lt,xt])=>[lt,{...xt,content:Ur(xt.content)}]));He=await ht(He,Ur(At),Hu,gt);let No=Hs(yt),jo=(Array.isArray(gt.__stx_client_signal_names)?gt.__stx_client_signal_names:[]).filter((lt)=>!Gt.has(lt));if(No.length>0||jo.length>0)gt.__stx_client_signal_names=[...new Set([...jo,...No])];else delete gt.__stx_client_signal_names;let ui=K.filter((lt)=>!Gt.has(lt)&&!(lt in k));if(ui.length>0)gt[pa]=ui;let Lo={...F,_rootComponentsDir:F._rootComponentsDir||F.componentsDir,componentsDir:pt.dirname(pe),skipSignalsRuntime:!0,skipEventDirectives:F._nativeHostAttrs===!0||sn||yt.length===0,defaultLayout:void 0};gt.__stxProcessingDepth=(T.__stxProcessingDepth||0)+1;let Sr=await n(He,gt,pe,Lo,H),ss=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[]);for(let lt of Sr.matchAll(/\{\{([\s\S]*?)\}\}/g))ss.add(lt[1].trim());if(ss.size>0)T.__stx_preserved_client_expressions=[...ss];let Yn=wt,on=Sr;if(sn){let lt="";if(Object.keys(k).length>0)try{lt=` data-stx-props="${Lu(JSON.stringify(k))}"`}catch{}let xt=ue?` stx-hydrate="${Lu(ue)}"`:"",ft=Object.fromEntries(Object.entries(at).map(([Rr,os])=>[Rr,Boolean(os)])),$t=Object.keys(ft).length>0?` data-stx-slots="${Lu(JSON.stringify(ft))}"`:"",cn=` data-stx-scope="${Yn}"${lt}${$t}${xt}`,en=/^\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*<span(?=[\s/>])/i.test(Sr),kr=en?"span":"div";on=rl(Sr,cn)??`<${kr}${cn} data-stx-component-wrapper${en?' style="display:contents"':""}>${Sr}</${kr}>`;let is=await Promise.all(yt.map(async(Rr)=>{let os=Rr.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!os)return Rr;let[,Bo,zo]=os,zn=await N0(zo,pe,F.buildMode==="compile"),Wo=vn(zn.clientCode,ke(gt)),{vendorStyleTags:Qn}=zn,Fi=Wo?`function(__scopeId) {
2663
- ${Wo}
2664
- return (${zn.factoryBody})(__scopeId);
2665
- }`:zn.factoryBody,Vi=ue?null:hc(T,Fi),as=Vi?`window.__stxComponentFactories[${JSON.stringify(Vi)}](${JSON.stringify(Yn)});`:`(${Fi})(${JSON.stringify(Yn)});`;if(ue)return`${Qn}<script type="stx/island" data-stx-island="${Yn}" data-stx-scoped data-stx-owner="${Yn}"${Bo}>${as}</script>`;return`${Qn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Yn}"${Bo}>${as}</script>`}));if(on=on+`
2666
- `+is.join(`
2667
- `),Jn)on+=`
2668
- `+Jn}else{if(Jn)on+=`
2669
- `+Jn;if(yt.length>0){let lt=gt.__stx_event_bindings||[],xt=ke(gt),ft=await Promise.all(yt.map(async($t)=>{let cn=$t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!cn)return $t;return await _e(cn[1],{eventBindings:lt,templateContent:on,filePath:pe,projectRoot:process.cwd(),serverData:xt,instanceId:wt})}));on+=`
2670
- `+ft.join(`
2671
- `),gt.__stx_event_bindings=[]}}if(Ue){let lt=ba(on,pe);if(lt.hasScoped)on=lt.html}if(yn&&_t){let lt=Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[];sc.set(yn,{output:on,dependencies:[...H].filter((xt)=>!_t.has(xt)),clientFactories:mt?jd(T,mt):[],uidsConsumed:St.n-Rt,preservedClientExpressions:Kt?lt.filter((xt)=>!Kt.has(xt)):[]})}if(Wt)on=`<!--stx-render-failed:${Wt}-->${on}`;return We.length>0?`${on}
2672
- ${We.join(`
2673
- `)}`:on}catch(de){if(de instanceof q)throw de;return`[Error processing component: ${de instanceof Error?de.message:String(de)}]`}finally{ce.delete(v)}}async function r(v){return Bun.file(v).exists()}function Vu(v,k){let C=pt.resolve(k),R=pt.resolve(v),T=C.endsWith(pt.sep)?C:C+pt.sep;if(R===C||R.startsWith(T))return R;return null}async function O0(v,k,C,R){let T=k.startsWith("layouts/")?k.slice(8):k,z=pt.join(v,T);for(let F of z.endsWith(".stx")?[z]:[z,`${z}.stx`])if(await r(F)){if(R)console.log(`Found layout in ${v}: ${F}`);return C?.add(F),F}return null}async function mr(v,k,C,R){let T=await M0(v,k,C,R);if(T===null)return null;let z=Vu(T,process.cwd());if(z)return z;let F=[C.root,C.layoutsDir,C.fallbackLayoutsDir,C.componentsDir,C.partialsDir,C.pagesDir,...C._layerLayoutDirs??[]].filter((V)=>typeof V==="string"&&V.length>0);for(let V of F){let H=pt.isAbsolute(V)?V:pt.resolve(process.cwd(),V);if(Vu(T,H))return pt.resolve(T)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${T} (template: ${v}, from: ${k})`),null}async function M0(v,k,C,R){if(C.debug)console.log(`Resolving template path: ${v} from ${k}`);let T=pt.dirname(k),z=process.cwd();if(v.startsWith("/")){let te=pt.join(z,v),ce=Vu(te,z);if(!ce)return console.warn(`[stx] rejected template path that escapes project root: ${v} (from ${k})`),null;if(C.debug)console.log(`Checking absolute path: ${ce}`);if(await r(ce)&&R)R.add(ce);return ce}let F=pt.join(T,v);if(await r(F)){if(C.debug)console.log(`Found direct path: ${F}`);if(R)R.add(F);return F}if(!v.endsWith(".stx")&&!v.endsWith(".jsx")&&!v.endsWith(".tsx"))for(let te of[".stx",".tsx",".jsx"]){let ce=`${F}${te}`;if(await r(ce)){if(C.debug)console.log(`Found direct path with extension: ${ce}`);if(R)R.add(ce);return ce}}let V=[];if(V.push(...C._layerLayoutDirs??[]),C.layoutsDir)V.push(pt.isAbsolute(C.layoutsDir)?C.layoutsDir:pt.resolve(process.cwd(),C.layoutsDir));let H=pt.resolve(T),K=process.cwd();for(let te=0;te<10;te++){let ce=pt.join(H,"layouts"),ee=!1;try{ee=Uu.statSync(ce,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(ee){V.push(ce);break}let le=pt.dirname(H);if(le===H||le.length<K.length)break;H=le}for(let te of V){let ce=await O0(te,v,R,C.debug);if(ce)return ce}if(C.fallbackLayoutsDir){let te=pt.isAbsolute(C.fallbackLayoutsDir)?C.fallbackLayoutsDir:pt.resolve(process.cwd(),C.fallbackLayoutsDir),ce=v.startsWith("layouts/")?v.slice(8):v,ee=[pt.join(te,ce)];if(!v.endsWith(".stx"))ee.push(`${ee[0]}.stx`);for(let le of ee)if(await r(le)){if(C.debug)console.log(`Found in options.fallbackLayoutsDir: ${le}`);if(R)R.add(le);return le}}if(v.startsWith("layouts/")||v.includes("/layouts/")){let te=v.split("layouts/"),ce=pt.join(C.partialsDir||T,"layouts",te[1]);if(await r(ce)){if(C.debug)console.log(`Found in layouts path: ${ce}`);if(R)R.add(ce);return ce}if(!ce.endsWith(".stx")){let ee=`${ce}.stx`;if(await r(ee)){if(C.debug)console.log(`Found in layouts path with extension: ${ee}`);if(R)R.add(ee);return ee}}}if(C.partialsDir){let te=pt.join(C.partialsDir,"layouts");if(await r(te)){let ce=pt.join(te,v);if(await r(ce)){if(C.debug)console.log(`Found in partials layouts dir: ${ce}`);if(R)R.add(ce);return ce}if(!v.endsWith(".stx")){let ee=`${ce}.stx`;if(await r(ee)){if(C.debug)console.log(`Found in partials layouts dir with extension: ${ee}`);if(R)R.add(ee);return ee}}}}let X=C.partialsDir||pt.join(process.cwd(),"views"),G=pt.join(X,v);if(await r(G)){if(C.debug)console.log(`Found in views path: ${G}`);if(R)R.add(G);return G}if(!v.endsWith(".stx")){let te=`${G}.stx`;if(await r(te)){if(C.debug)console.log(`Found in views path with extension: ${te}`);if(R)R.add(te);return te}}if(T.includes("temp")){let te=pt.join(pt.dirname(T),"layouts",v);if(await r(te)){if(C.debug)console.log(`Found in temp layouts dir: ${te}`);if(R)R.add(te);return te}if(!v.endsWith(".stx")){let ce=`${te}.stx`;if(await r(ce)){if(C.debug)console.log(`Found in temp layouts dir with extension: ${ce}`);if(R)R.add(ce);return ce}}}if(C.debug)console.warn(`Template not found after trying all paths: ${v} (referenced from ${k})`);else console.warn(`Template not found: ${v} (referenced from ${k})`);return null}function Li(v,k,C){let R=0,T="",z="";try{if(typeof k==="number"&&k>=0){let F=v.split(`
2674
- `),V=0;for(let H=0;H<F.length;H++)if(V+=F[H].length+1,V>=k){R=H+1,T=F[H].trim();let K=Math.max(0,H-2),X=Math.min(F.length,H+3);z=F.slice(K,X).map((G,te)=>{let ce=K+te+1;return`${ce===R?"> ":" "}${ce}: ${G}`}).join(`
2675
- `);break}}else if(C){let F=v.indexOf(C);if(F>=0)return Li(v,F)}}catch{}return{lineNumber:R,lineContent:T,context:z}}var It={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function g(v,k,C,R,T,z){let{lineNumber:F,context:V}=Li(R,T,z),H=C.split("/").pop(),K=0;if(typeof T==="number"&&T>=0&&R){let G=R.lastIndexOf(`
2676
- `,Math.max(0,T-1));K=T-(G+1)+1}let X="";if(F>0)X+=`
2677
- ${C}:${F}${K>0?`:${K}`:""}: ${v.toLowerCase()} error: ${k}
2678
- `;if(X+=`
2679
- ${It.bold}${It.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${It.reset}
2680
- `,X+=`${It.bold}${It.red}\u2502${It.reset} ${It.bold}${It.bgRed} ERROR ${It.reset} ${It.red}${v} Error${It.reset}${" ".repeat(Math.max(0,43-v.length))}${It.bold}${It.red}\u2502${It.reset}
2681
- `,X+=`${It.bold}${It.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${It.reset}
2682
- `,X+=`
2683
- ${It.cyan}${It.bold}File:${It.reset} ${It.dim}${H}${It.reset}`,F>0)X+=` ${It.gray}(line ${F}${K>0?`, col ${K}`:""})${It.reset}`;if(X+=`
2684
- ${It.yellow}${It.bold}Message:${It.reset} ${k}
2685
- `,V)X+=`
2686
- ${It.blue}${It.bold}Context:${It.reset}
2687
- ${It.dim}${V}${It.reset}
2688
- `;return X}function ie(){Oo.clear(),rc.clear(),zu.clear(),Wu.clear(),sc.clear()}function xd(){return{size:Oo.size,maxSize:500}}var Bu=m(128);async function N0(v,k,C){let R=h(v,k,C),T=Bu.get(R);if(T){if(or(T.deps))return T;Bu.delete(R)}let z=ys(v,{filePath:k,projectRoot:process.cwd()}),F=z.code,V=bs(z.styles);F=Nt(F).code;let{hasUserImports:H,bundleClientScript:K}=await kt("stx/client-script-bundler",()=>import("./chunk-9svygzeg.js")),X=[],G=!1;if(H(F)){let fe=F;F=await K(fe,k,{projectRoot:process.cwd(),minify:C,collectInputs:X}),G=F===fe}let{stripStxRuntimeImports:te}=await kt("stx/signal-processing",()=>import("./chunk-dcx2t3sy.js"));F=te(F);let ce=I(F),ee=R0(ce),le=new Set(M(ce,!0).split(",").map((fe)=>fe.trim())),ue=`function(__scopeId) {
2689
- ${qt("const",[...ta,...ee],ce)}
2690
- const __scope = window.stx._scopes = window.stx._scopes || {};
2691
- const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
2692
- __scopeVars.$refs = __scopeVars.$refs || {};
2693
- const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
2694
- const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
2695
- // A clone the runtime is setting up may not be in the document yet (rows
2696
- // a loop builds inside a closed :if), where a lookup cannot see it, so the
2697
- // runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
2698
- const __setupRoot = window.__STX_SETUP_ROOT__;
2699
- const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
2700
- __scopeVars.$slots = Object.create(null);
2701
- if (__componentElement) {
2702
- try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
2703
- catch {}
2704
- }
2705
- window.__STX_CURRENT_ELEMENT__ = __componentElement;
2706
- let __componentProps = __componentElement && __componentElement.__stx_props;
2707
- if (!__componentProps && __componentElement) {
2708
- try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
2709
- catch { __componentProps = {}; }
2710
- }
2711
- window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
2712
-
2713
- // Scope-specific lifecycle callbacks. The queues drain as they run; the
2714
- // hook lists keep what setup registered, because a component behind an :if
2715
- // unmounts at each hide and mounts again at each show (signals.ts,
2716
- // suspendSubtreeScopes).
2717
- if (__scopeVars.__suspended && !__scopeVars.__mounted) {
2718
- // Set up again after an :if hid it -- a <template :if> clones the
2719
- // component afresh on every show, and the clone's script runs. This run's
2720
- // hooks close over this run's state, so they replace the ones the hide
2721
- // kept for a re-show rather than queueing beside them.
2722
- __scopeVars.__mountCallbacks = [];
2723
- __scopeVars.__destroyCallbacks = [];
2724
- __scopeVars.__mountHooks = [];
2725
- __scopeVars.__destroyHooks = [];
2726
- }
2727
- __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
2728
- __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
2729
- __scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
2730
- __scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
2731
- let __registeringSetupHooks = true;
2732
- const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
2733
- const onDestroy = (fn) => {
2734
- __scopeVars.__destroyCallbacks.push(fn);
2735
- // A teardown registered inside onMount belongs to this mount alone.
2736
- // Replaying it AND registering the next mount's teardown doubles cleanup.
2737
- if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
2738
- };
2739
-
2740
- try {
2741
- ${ce}
2742
-
2743
- // Register all defined signals and functions in this scope
2744
- const __localVars = {};
2745
- try {
2746
- ${ee.map((fe)=>le.has(fe)?`Object.defineProperty(__localVars, '${fe}', ${qo(fe)});`:`if (typeof ${fe} !== 'undefined') __localVars['${fe}'] = ${fe};`).join(`
2747
- `)}
2748
- }
2749
- catch (e) {}
2750
- Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
2751
- if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
2752
- }
2753
- finally {
2754
- __registeringSetupHooks = false;
2755
- window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
2756
- window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
2757
- }
2758
- }`,de={vendorStyleTags:V,factoryBody:ue,clientCode:ce,deps:bn([...X,...z.styles.map((fe)=>fe.resolvedPath)])};if(!G&&z.unresolved.length===0)Bu.set(R,de);return de}var j0=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function L0(v){if(v.startsWith(".")||v.startsWith("/"))return null;if(v.startsWith("@")){let C=v.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!C)return null;return{pkg:C[1],subpath:C[2]||""}}let k=v.match(/^([^/]+)(\/.*)?$/);if(!k)return null;return{pkg:k[1],subpath:k[2]||""}}function B0(v,k){let C=k;while(!0){let R=rs.join(C,"node_modules",v,"package.json");if(Mo.existsSync(R))return rs.dirname(R);let T=rs.dirname(C);if(T===C)return null;C=T}}function z0(v,k){if(!v||typeof v!=="object")return null;let C=(T)=>{if(typeof T==="string")return T;if(T&&typeof T==="object"){if(typeof T.import==="string")return T.import;if(typeof T.default==="string")return T.default;if(typeof T.import==="object")return C(T.import);if(typeof T.default==="object")return C(T.default)}return null};if(Object.prototype.hasOwnProperty.call(v,k))return C(v[k]);let R=null;for(let T of Object.keys(v)){let z=T.indexOf("*");if(z===-1)continue;let F=T.slice(0,z),V=T.slice(z+1);if(!k.startsWith(F)||!k.endsWith(V))continue;if(k.length<F.length+V.length)continue;if(!R||F.length>R.prefix.length)R={pattern:T,prefix:F,suffix:V}}if(R){let T=k.slice(R.prefix.length,k.length-R.suffix.length),z=C(v[R.pattern]);if(z)return z.replace("*",T)}return null}function W0(v,k){let C=L0(v);if(!C||!C.subpath)return null;let R=B0(C.pkg,k);if(!R)return null;let T;try{T=JSON.parse(Mo.readFileSync(rs.join(R,"package.json"),"utf8"))}catch{return null}let z=`.${C.subpath}`,F=z0(T.exports,z);if(!F)return null;let V=rs.resolve(R,F);return Mo.existsSync(V)?V:null}function ys(v,k){let C=k.filePath?rs.dirname(k.filePath):k.projectRoot||process.cwd(),R=k.projectRoot||process.cwd(),T=new Set,z=[],F=[];return{code:v.replace(j0,(H,K)=>{let X;try{if(K.startsWith("./")||K.startsWith("../")||K.startsWith("/")){if(X=K.startsWith("/")?K:rs.resolve(C,K),!Mo.existsSync(X))throw Error(`file not found: ${X}`)}else{let G=null;try{G=Bun.resolveSync(K,R)}catch{G=W0(K,R)}if(!G)throw Error(`could not resolve ${K} (Bun.resolveSync + exports fallback both failed)`);X=G}}catch(G){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(K)} (from ${k.filePath||"<unknown>"}): ${G?.message||G}`),F.push(K),""}if(T.has(X))return"";T.add(X);try{let G=Mo.readFileSync(X,"utf8");z.push({source:K,resolvedPath:X,contents:G})}catch(G){console.warn(`[stx:vendor-css] could not read ${X}: ${G?.message||G}`),F.push(K)}return""}),styles:z,unresolved:F}}function F0(v){return v.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function bs(v){if(v.length===0)return"";return`${v.map((k)=>`<style data-stx-vendor="${F0(k.source)}" data-stx-layer="vendor">
2759
- @layer vendor {
2760
- ${k.contents}
2761
- }
2762
- </style>`).join(`
2763
- `)}
2764
- `}var _c=y,Vh=m(256);function Nt(v){let k=h(v),C=Vh.get(k);if(!C)C=V0(v),Vh.set(k,C);return{code:C.code,imports:[...C.imports],models:[...C.models]}}function V0(v){let k=s(v),C=new Set;for(let V of v.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let H of V[1].split(",")){let K=H.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(K)C.add(K)}let R=Zo(k),T=Y.filter((V)=>{if(C.has(V)||R.has(V))return!1;return vs(k,V,!0)}),z=Kh(k).filter((V)=>!C.has(V)&&!R.has(V));if(T.length===0&&z.length===0)return{code:v,imports:T,models:z};return{code:`${[T.length>0?`import { ${T.join(", ")} } from '@stacksjs/browser'`:"",z.length>0?"import '@stacksjs/browser'":"",z.length>0?`const { ${z.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
2765
- `)}
2766
- ${v}`,imports:T,models:z}}var U0=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function Kh(v){let k=new Set,C=pc(v),R=Zo(v),T=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let z of C.code.matchAll(T)){let F=z[1];if(U0.has(F)||R.has(F)||F.length<3)continue;if(C.shadows(F,z.index??0))continue;k.add(F)}return Array.from(k)}function H0(v){return Zo(v)}var Uh=m(128);function di(v){let k=h(v),C=Uh.get(k);if(!C)C=q0(v),Uh.set(k,C);return{code:C.code,stxImports:[...C.stxImports],browserImports:[...C.browserImports]}}function q0(v){let k=new Set,C=new Set,R=v;R=R.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let T=new Set,z=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,F;while((F=z.exec(v))!==null){let G=F[1],te=F[2];if(F[0].includes("import type"))continue;let ce=[];for(let le of G.split(",")){let ue=le.trim();if(!ue||ue.startsWith("type "))continue;let de=ue.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!de)continue;let fe=de[1],pe=de[2]||fe;if(T.add(fe),T.add(pe),te==="stx"||te==="@stacksjs/stx")k.add(fe);else C.add(fe);if(pe!==fe)ce.push(`${pe} = ${fe}`)}let ee=ce.length>0?`var ${ce.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";R=R.replace(F[0],ee)}let V=H0(R);for(let G of _c){if(T.has(G)||V.has(G))continue;if(vs(R,G,!0))k.add(G)}let H=s(R),K=new Set;for(let G of R.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let te of G[1].split(",")){let ce=te.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let ee of ce){let le=ee.trim();if(le)K.add(le)}}for(let G of Y){if(T.has(G)||V.has(G)||K.has(G))continue;if(vs(H,G))C.add(G)}let X=Kh(H);for(let G of X)if(!T.has(G)&&!V.has(G))C.add(G);return{code:R,stxImports:Array.from(k),browserImports:Array.from(C)}}function vs(v,k,C=!1){let R=pc(v);v=R.code;let T=new RegExp(`\\b${k.replace(/[$]/g,"\\$")}\\b`,"g");for(let z of v.matchAll(T)){let F=z.index??0;if(R.shadows(k,F))continue;let V=F+k.length,H=F-1;while(H>=0&&/\s/.test(v[H]))H--;if(v[H]==="."&&v.slice(Math.max(0,H-2),H+1)!=="...")continue;let K=V;while(K<v.length&&/\s/.test(v[K]))K++;if(v[K]===":"&&v[K+1]!==":"&&(v[H]==="{"||v[H]===","))continue;if(C&&!/^\s*(?:<[^>]*>)?\s*\(/.test(v.slice(V)))continue;if(K0(v,V))continue;return!0}return!1}function K0(v,k){let C=k;while(C<v.length&&(v[C]===" "||v[C]==="\t"))C++;if(v[C]!=="(")return!1;let R=0;for(;C<v.length;C++){let T=v[C];if(T==="(")R++;else if(T===")"){if(R--,R===0)break}}if(R!==0)return!1;C++;while(C<v.length&&(v[C]===" "||v[C]==="\t"))C++;return v[C]==="{"}function pi(v,k){let C=[];if(v.length>0)C.push(` var { ${v.join(", ")} } = window.stx || window;`);if(k.length>0)C.push(` var { ${k.join(", ")} } = window.StacksBrowser || {};`);if(C.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
2767
- ${C.join(`
2768
- `)}
2769
- ${X0(v,k)}`;return""}function Qu(v,k=[]){let{browserImports:C}=di(v),R=new Set(k);return pi([],C.filter((T)=>!R.has(T)))}function X0(v,k){let C=[...v.map((R)=>`['${R}', typeof ${R}, 'stx']`),...k.map((R)=>`['${R}', typeof ${R}, '@stacksjs/browser']`)];if(C.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
2770
- [${C.join(", ")}].forEach(function (e) {
2771
- if (e[1] !== 'undefined') return;
2772
- console.error(
2773
- '[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
2774
- + 'but the client runtime does not provide it. Either it is not exported to the browser, '
2775
- + 'or it should be imported from a relative path so the bundler includes it.'
2776
- );
2777
- });
2778
- `}function ke(v){let k=v.__stxClientPayload;if(k&&typeof k==="object"){let R={};for(let T in k){let z=k[T];if(typeof z==="function")continue;R[T]=z}return R.__stxDeclaredPayload=!0,R}let C={};for(let R in v){if(R.startsWith("__")||R.startsWith("$"))continue;let T=v[R];if(typeof T==="function")continue;C[R]=T}return C}var Z0=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,Hh=new Set;function G0(v,k){let C=Z0.test(v),R=k.length>32768;if(!C&&!R)return;if(Hh.has(v))return;if(Hh.add(v),C)console.warn(`[stx] server\u2192client bridge is publishing "${v}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(R)console.warn(`[stx] server\u2192client bridge is publishing ${(k.length/1024).toFixed(1)}KB under "${v}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function vn(v,k){if(!k)return"";let C=Ot(v,new Set(Object.keys(k))),R=k.__stxDeclaredPayload===!0,T=[],z=Object.entries(k).sort(([F],[V])=>F<V?-1:F>V?1:0);for(let[F,V]of z){if(!/^[A-Za-z_$][\w$]*$/.test(F))continue;if(F.startsWith("__")||F.startsWith("$"))continue;if(!R&&!C.has(F))continue;if(Ui(v,F)){if(R)console.warn(`[stx] defineClientPayload declares "${F}", but this client block also declares "${F}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${F}" from defineClientPayload.`);continue}let H;try{H=JSON.stringify(V)}catch{continue}if(H===void 0)continue;G0(F,H),T.push(` var ${F} = ${H.replace(/</g,"\\u003c")};`)}if(T.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
2779
- ${T.join(`
2780
- `)}
2781
- `}var J0={left:0,middle:1,right:2};function Y0(v){let k=[];if(v.self)k.push("if ($event.target !== $el) return");for(let C of v.systemKeys)k.push(`if (!$event.${C}Key) return`);if(v.keys.length>0){let C=v.keys.map((R)=>`$event.key === '${R}'`).join(" || ");k.push(`if (!(${C})) return`)}if(v.mouse!==null){let C=J0[v.mouse];k.push(`if ($event.button !== ${C}) return`)}if(v.prevent)k.push("$event.preventDefault()");if(v.stop)k.push("$event.stopPropagation()");return k.join("; ")}function Q0(v,k){let{elementId:C,event:R,modifiers:T}=v,z=uc(v.handler),F=Y0(T),V=[];if(T.once)V.push("once: true");if(T.capture)V.push("capture: true");if(lc(R,T))V.push("passive: true");let H=V.length>0?`, { ${V.join(", ")} }`:"",K="";if(F)K+=`${F}; `;let X=z.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),G=`var $emit = function(name, detail) {
2782
- $el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
2783
- };`;function te(ce){if(/\$emit\s*\(/.test(ce))return`${G}
2784
- ${ce}`;return`var scope = $el.closest('[data-stx-scope]');
2785
- if (scope && scope.__stx_execute) {
2786
- scope.__stx_execute('${X}', $event, $el);
2787
- }
2788
- else {
2789
- ${ce}
2790
- }`}if(T.debounce!==null)return` ;(function() {
2791
- // eslint-disable-next-line pickier/no-unused-vars
2792
- var $el = document.getElementById('${C}')
2793
- if (!$el) return
2794
- var __timer
2795
- $el.addEventListener('${R}', function($event) {
2796
- ${F?F+"; ":""}clearTimeout(__timer)
2797
- __timer = setTimeout(function() { ${te(z)} }, ${T.debounce})
2798
- }${H})
2799
- })()`;if(T.throttle!==null)return` ;(function() {
2800
- // eslint-disable-next-line pickier/no-unused-vars
2801
- var $el = document.getElementById('${C}')
2802
- if (!$el) return
2803
- var __last = 0
2804
- $el.addEventListener('${R}', function($event) {
2805
- ${F?F+"; ":""}var __now = Date.now()
2806
- if (__now - __last >= ${T.throttle}) {
2807
- __last = __now
2808
- ${te(z)}
2809
- }
2810
- }${H})
2811
- })()`;if(/\$emit\s*\(/.test(z))return` var $el = document.getElementById('${C}')
2812
- if ($el) $el.addEventListener('${R}', function($event) {
2813
- ${K}${G}
2814
- ${z}
2815
- }${H})`;return` var $el = document.getElementById('${C}')
2816
- if ($el) $el.addEventListener('${R}', function($event) {
2817
- ${K}var scope = $el.closest('[data-stx-scope]');
2818
- if (scope && scope.__stx_execute) {
2819
- scope.__stx_execute('${X}', $event, $el);
2820
- }
2821
- else {
2822
- ${z}
2823
- }
2824
- }${H})`}function e$(v){if(v.length===0)return"";return`
2825
- // STX: auto-generated event bindings
2826
- ${v.map((C,R)=>Q0(C,R)).join(`
2827
- `)}`}function qh(v){let k=[],C=new Set,R=v.replace(/^\s*import\s+.*$/gm,""),T=0,z=R.length,F=0;while(F<z){let V=R[F];if(V==="'"||V==='"'||V==="`"){let H=V;if(F++,H==="`"){let K=0;while(F<z){if(R[F]==="\\"){F+=2;continue}if(R[F]==="`"&&K===0){F++;break}if(R[F]==="$"&&R[F+1]==="{"){K++,F+=2;continue}if(R[F]==="}"&&K>0){K--,F++;continue}F++}}else while(F<z){if(R[F]==="\\"){F+=2;continue}if(R[F]===H){F++;break}F++}continue}if(V==="/"&&R[F+1]==="/"){while(F<z&&R[F]!==`
2828
- `)F++;continue}if(V==="/"&&R[F+1]==="*"){F+=2;while(F<z-1&&!(R[F]==="*"&&R[F+1]==="/"))F++;F+=2;continue}if(V==="{"){T++,F++;continue}if(V==="}"){T--,F++;continue}if(T===0){let H=R.slice(F),K=H.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(K){let te=K[1];if(!te.startsWith("_")&&!C.has(te))k.push(te),C.add(te);F+=K[0].length;continue}let X=H.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(X){X[1].split(",").forEach((te)=>{let ce=te.trim(),ee=ce.indexOf(":"),le=ee>=0?ce.slice(ee+1).trim().split(/[\s=]/)[0]:ce.split(/[\s=]/)[0];if(le&&!le.startsWith("_")&&!C.has(le))k.push(le),C.add(le)}),F+=X[0].length;continue}let G=H.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(G){let te=G[1];if(!te.startsWith("_")&&!C.has(te))k.push(te),C.add(te);F+=G[0].length;continue}}F++}return k}var t$=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function n$(v){let k=new Set,C=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function R(te){let ce;while((ce=C.exec(te))!==null){let ee=ce[0];if(!t$.has(ee))k.add(ee)}}let T=/\{\{([\s\S]*?)\}\}/g,z;while((z=T.exec(v))!==null)R(z[1]);let F=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((z=F.exec(v))!==null)R(z[1]);let V=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((z=V.exec(v))!==null)R(z[1]);let H=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((z=H.exec(v))!==null)R(z[1]);let K=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((z=K.exec(v))!==null)R(z[1]);let X=/@model\s*=\s*["']([^"']*)["']/gi;while((z=X.exec(v))!==null)R(z[1]);let G=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((z=G.exec(v))!==null)R(z[1]);return k}async function _e(v,k={}){let C=v,R="",T=!1,z=[],F=ys(C,{filePath:k.filePath,projectRoot:k.projectRoot});C=F.code;let V=bs(F.styles),H=Nt(C);C=H.code,z=[...H.imports,...H.models];let{hasUserImports:K,bundleClientScript:X}=await kt("stx/client-script-bundler",()=>import("./chunk-9svygzeg.js"));if(K(C))C=await X(C,k.filePath||"",{projectRoot:k.projectRoot,minify:k.production}),T=!0;if(k.autoImports!==!1){let pe=di(C);C=pe.code,R=pi(pe.stxImports,pe.browserImports.filter((Ae)=>!z.includes(Ae)))}if(R=`${vn(C,k.serverData)}${R}`,C=I(C),!T&&nt(k.attrs||""))C=rt(C);let G=e$(k.eventBindings||[]),te=(k.attrs||"").trim(),ce=/\btype\s*=\s*["']module["']/i.test(te),ee=k.instanceId?` data-stx-instance="${k.instanceId}"`:"";if(ce){let pe=te.replace(/\btype\s*=\s*["']module["']/i,"").trim(),Ae=`type="module" data-stx-scoped${ee}${pe?` ${pe}`:""}`;return`${V}<script ${Ae}>
2829
- ${oi(`${R}${C}
2830
- ${G}`)}
2831
- </script>`}let le=oo(v),ue=/function __stx_setup_/.test(C),de=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(v);function fe(pe){let Ae=pe.length>0?`
2832
- return ${Ko(C,pe)};`:"",Se=JSON.stringify(`[stx] client block failed${k.filePath?` (${k.filePath})`:""}; this block will not hydrate`);return`${V}<script data-stx-scoped data-stx-run="always"${ee}>
2833
- window.stx.mount(function() {
2834
- 'use strict';
2835
- try {
2836
- ${oi(`${R}${C}
2837
- ${G}${Ae}`)}
2838
- } catch (error) {
2839
- console.error(${Se}, error);
2840
- return {};
2841
- }
2842
- })</script>`}if(!de&&!ue){if(le)return fe(qh(v));if(k.templateContent){let pe=qh(v);if(pe.length>0){let Ae=n$(k.templateContent);if(pe.some((ve)=>Ae.has(ve)))return fe(pe)}}}return`${V}<script data-stx-scoped data-stx-run="always"${ee}>
2843
- ;(function() {
2844
- 'use strict';
2845
- try {
2846
- ${oi(`${R}${C}
2847
- ${G}`)}
2848
- } catch (error) {
2849
- console.error(${JSON.stringify(`[stx] client block failed${k.filePath?` (${k.filePath})`:""}; this block will not hydrate`)}, error);
2850
- }
2851
- })()</script>`}
2852
- export{sr,qe,M,Ot,L,J,m,h,bn,or,Y,w,Ge,ys,bs,_c,Nt,di,vs,pi,Qu,ke,vn,_e,fi,gi,mi,ws,U,Ke,ne,Dt,re,ir,Cc,ed,Ec,td,Tc,ar,b,Mt,Ce,$c,xs,Rc,nd,Z,Ac,rd,x,sd,Pc,od,id,ad,cd,Ic,Oc,ld,ud,hi,dd,wn,xn,cr,Xe,Ee,se,Lt,ge,Sn,kn,Te,e,pd,yi,fd,bi,Nc,Dc,jt,_n,gd,Mc,Lc,md,f,Je,Bt,Ye,Ze,vi,lr,Qe,oe,Ss,ks,_s,hd,ur,yd,Cn,et,Cs,Es,jc,me,wi,xi,Si,ki,dr,Ts,_i,Ci,Ei,Bc,$s,j,he,Q,bd,Fc,Rs,As,Ti,$i,Ps,Is,pr,Ri,Ai,zc,tt,En,fr,Ft,Hc,Vc,Uc,Wc,qc,u,Gc,Os,Kc,Pi,Ii,Ns,Oi,Xc,vd,Jc,$e,Ni,wd,Ds,Ms,Ls,Di,js,Bs,Fs,n,Yc,Zc,Qc,el,tl,zs,nl,nt,B,rt,rl,gr,sl,Mi,Hs,st,r,mr,Li,g,ie,xd,hr,A,ol,Vs,o,P,Sd,kd,ye};