@stacksjs/stx 0.2.576 → 0.2.578

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 (209) hide show
  1. package/dist/chunk-0047meje.js +2 -0
  2. package/dist/chunk-00p22wzr.js +3 -0
  3. package/dist/{chunk-z33z3rr4.js → chunk-0k5faspy.js} +6 -6
  4. package/dist/{chunk-wwhxgvr8.js → chunk-0vnngvy1.js} +4 -4
  5. package/dist/{chunk-7a0ewpz0.js → chunk-101ekf6y.js} +2 -2
  6. package/dist/{chunk-t79xnvzr.js → chunk-117xss52.js} +2 -2
  7. package/dist/chunk-1cat8kdj.js +2 -0
  8. package/dist/chunk-1dwnp35v.js +2 -0
  9. package/dist/{chunk-5vw8493b.js → chunk-1r1maqep.js} +3 -3
  10. package/dist/{chunk-zak5xare.js → chunk-1v1mew46.js} +1 -1
  11. package/dist/chunk-2dnr5qfk.js +2 -0
  12. package/dist/{chunk-1swmxkdt.js → chunk-2rx9d75e.js} +2 -2
  13. package/dist/chunk-2v73cjbc.js +2 -0
  14. package/dist/chunk-3akgppsy.js +2 -0
  15. package/dist/{chunk-8efe5vpm.js → chunk-3e3dpp7w.js} +3 -3
  16. package/dist/{chunk-vnsby98n.js → chunk-3qrrv6af.js} +1 -1
  17. package/dist/{chunk-fkbthywg.js → chunk-3wy8q3aq.js} +5 -5
  18. package/dist/chunk-3x6p9me0.js +2 -0
  19. package/dist/{chunk-tybk9hw9.js → chunk-43h8q2cm.js} +9 -9
  20. package/dist/{chunk-pqkb1m5x.js → chunk-4rkvwm6v.js} +5 -5
  21. package/dist/{chunk-bks1fe5e.js → chunk-4srg0qbv.js} +1 -1
  22. package/dist/chunk-4t67wmcg.js +2 -0
  23. package/dist/chunk-51zn42jy.js +2 -0
  24. package/dist/chunk-5702x95v.js +2 -0
  25. package/dist/{chunk-4z21afpp.js → chunk-5db5sxy3.js} +2 -2
  26. package/dist/{chunk-r4w1cye7.js → chunk-5kh5ehfh.js} +2 -2
  27. package/dist/chunk-5pgbsc3a.js +2 -0
  28. package/dist/chunk-60c2bsh9.js +2 -0
  29. package/dist/{chunk-vw1rmevt.js → chunk-620szfcp.js} +3 -3
  30. package/dist/{chunk-6rfm6b1c.js → chunk-6w2yqtrd.js} +2 -2
  31. package/dist/{chunk-37d52q0d.js → chunk-6z3e1tyz.js} +1 -1
  32. package/dist/{chunk-nskvepjv.js → chunk-71sdgv7e.js} +5 -5
  33. package/dist/chunk-79v4d9qh.js +2 -0
  34. package/dist/{chunk-qfb34r6k.js → chunk-7hkc96de.js} +6 -6
  35. package/dist/chunk-7pp2vx1g.js +2 -0
  36. package/dist/chunk-84f9dnq5.js +2 -0
  37. package/dist/chunk-8tq5x4z8.js +2 -0
  38. package/dist/{chunk-gjp2jxrp.js → chunk-8v19753h.js} +1 -1
  39. package/dist/chunk-8zm6tkqb.js +2 -0
  40. package/dist/{chunk-1dg5qxg9.js → chunk-9jh2ake5.js} +5 -5
  41. package/dist/chunk-a1z36dt5.js +2 -0
  42. package/dist/{chunk-7hr63cp5.js → chunk-ah9xyss2.js} +2 -2
  43. package/dist/chunk-atsf1fe0.js +2 -0
  44. package/dist/{chunk-x5xwe5nr.js → chunk-ayy9mmrw.js} +7 -7
  45. package/dist/chunk-b8qd6h1q.js +2 -0
  46. package/dist/{chunk-vde4mtfr.js → chunk-be2ba3hj.js} +2 -2
  47. package/dist/{chunk-pxk0tpw2.js → chunk-bj29pwm0.js} +3 -3
  48. package/dist/{chunk-gpb22a8n.js → chunk-c0h2eqe0.js} +2 -2
  49. package/dist/{chunk-agk478t4.js → chunk-c0s3k64c.js} +2 -2
  50. package/dist/{chunk-bctjmaxg.js → chunk-c1r7zq0q.js} +41 -41
  51. package/dist/{chunk-32gycb72.js → chunk-cb2pyg5t.js} +2 -2
  52. package/dist/chunk-ccxs40xy.js +2 -0
  53. package/dist/{chunk-7j9m4d7x.js → chunk-cdgwkzms.js} +3 -3
  54. package/dist/{chunk-6c2y9h5h.js → chunk-cnknvvwm.js} +1 -1
  55. package/dist/chunk-cp442y7a.js +2 -0
  56. package/dist/chunk-d4en5d3s.js +2 -0
  57. package/dist/chunk-dh80d57p.js +2 -0
  58. package/dist/{chunk-je0cttam.js → chunk-djft0m5h.js} +2 -2
  59. package/dist/chunk-dpn1pmxj.js +2 -0
  60. package/dist/chunk-dtcc09x1.js +2 -0
  61. package/dist/{chunk-sf7z2ar9.js → chunk-dvgvvy5b.js} +3 -3
  62. package/dist/chunk-dyqte1xq.js +2 -0
  63. package/dist/chunk-e4n4v022.js +2 -0
  64. package/dist/chunk-efgk2xv1.js +2 -0
  65. package/dist/{chunk-h1n43e5n.js → chunk-ev5f79mg.js} +5 -5
  66. package/dist/{chunk-1wkpxa58.js → chunk-eww6sdzz.js} +2 -2
  67. package/dist/{chunk-34fajf1n.js → chunk-faghmmrs.js} +139 -139
  68. package/dist/chunk-fj70wq7k.js +2 -0
  69. package/dist/chunk-g2fw68zm.js +2 -0
  70. package/dist/{chunk-szfkkbve.js → chunk-g4crr86j.js} +3 -3
  71. package/dist/{chunk-xh0808cd.js → chunk-h0a2s340.js} +2 -2
  72. package/dist/chunk-hcgm37dy.js +2 -0
  73. package/dist/chunk-hd2bn5q7.js +2 -0
  74. package/dist/{chunk-5dm4k229.js → chunk-hzfhn2vr.js} +2 -2
  75. package/dist/{chunk-6wz6f8d5.js → chunk-j1nqnmcd.js} +4 -4
  76. package/dist/{chunk-1c8sdf9a.js → chunk-jpqkm8tm.js} +2 -2
  77. package/dist/{chunk-550q827h.js → chunk-jtbzmbzz.js} +4 -4
  78. package/dist/chunk-k7jqkt93.js +2 -0
  79. package/dist/{chunk-wvk932dp.js → chunk-k9th7hc4.js} +4 -4
  80. package/dist/chunk-kp0hg06s.js +15 -0
  81. package/dist/{chunk-kskyfss0.js → chunk-ktyctev3.js} +2 -2
  82. package/dist/{chunk-xk2v20xe.js → chunk-m8tm44rq.js} +2 -2
  83. package/dist/chunk-mhjwtkx9.js +2 -0
  84. package/dist/chunk-mqy7g74k.js +2 -0
  85. package/dist/chunk-mxe21m6q.js +2 -0
  86. package/dist/chunk-ne03tfje.js +2 -0
  87. package/dist/{chunk-3gqrv02t.js → chunk-nrfh7gaa.js} +3 -3
  88. package/dist/chunk-p2sns0bn.js +2 -0
  89. package/dist/chunk-pjrh71sn.js +122 -0
  90. package/dist/{chunk-jgrtvs81.js → chunk-pmpb34md.js} +5 -5
  91. package/dist/chunk-q2a58n2a.js +2 -0
  92. package/dist/{chunk-5xwmkxkk.js → chunk-qazn64pm.js} +1 -1
  93. package/dist/{chunk-7bwkeake.js → chunk-qccgncp2.js} +6 -6
  94. package/dist/{chunk-1edvsndv.js → chunk-qdyp2zqf.js} +2 -2
  95. package/dist/chunk-rr8a7d4q.js +11 -0
  96. package/dist/{chunk-mr9c2ej6.js → chunk-s12bnv32.js} +2 -2
  97. package/dist/chunk-s1sycp43.js +2 -0
  98. package/dist/chunk-s932zfjz.js +2 -0
  99. package/dist/chunk-sp46w7z9.js +2 -0
  100. package/dist/{chunk-tasjpnbf.js → chunk-sv5nvfmb.js} +2 -2
  101. package/dist/chunk-sy1bk1ry.js +2 -0
  102. package/dist/chunk-t48ws5j0.js +2 -0
  103. package/dist/{chunk-sn3htx1z.js → chunk-t4g2fptt.js} +6 -6
  104. package/dist/{chunk-d8ek63nc.js → chunk-t8wpzqs4.js} +1 -1
  105. package/dist/{chunk-bpdsdbvg.js → chunk-ta3wn842.js} +2 -2
  106. package/dist/chunk-thbc9gtj.js +2 -0
  107. package/dist/chunk-tn9v10q2.js +2 -0
  108. package/dist/chunk-tpd5nwa3.js +2 -0
  109. package/dist/chunk-tpt4bgs5.js +2 -0
  110. package/dist/{chunk-n829xbbq.js → chunk-tszkg6sj.js} +2 -2
  111. package/dist/chunk-v8p5p2kp.js +2 -0
  112. package/dist/chunk-v9jd283e.js +2 -0
  113. package/dist/{chunk-4xvbc0mb.js → chunk-vpdx7qr3.js} +2 -2
  114. package/dist/chunk-vq0cb1m9.js +2 -0
  115. package/dist/chunk-vx75fb0d.js +33 -0
  116. package/dist/{chunk-pveafhzg.js → chunk-w3rmepwy.js} +2 -2
  117. package/dist/{chunk-xsxh7h8z.js → chunk-wg2w7zmt.js} +2 -2
  118. package/dist/chunk-wgkxgsqx.js +2 -0
  119. package/dist/{chunk-707n4pbz.js → chunk-wwj8zbzc.js} +5 -5
  120. package/dist/{chunk-p3xkj7pm.js → chunk-xpnpg967.js} +2 -2
  121. package/dist/chunk-y1bppxgw.js +2 -0
  122. package/dist/{chunk-1w9ngqpv.js → chunk-y8q1n7hx.js} +10 -10
  123. package/dist/{chunk-vmetcczm.js → chunk-yfq2v7x5.js} +6 -6
  124. package/dist/{chunk-h72befy4.js → chunk-yhpyqsbr.js} +4 -4
  125. package/dist/{chunk-n0kw3q6p.js → chunk-yk3fbzx5.js} +4 -4
  126. package/dist/chunk-yv5rwthv.js +2 -0
  127. package/dist/{chunk-mp99h8wh.js → chunk-yy3ser06.js} +5 -5
  128. package/dist/chunk-yygze2s0.js +2 -0
  129. package/dist/chunk-z1r4tdqy.js +2 -0
  130. package/dist/chunk-z732tf98.js +2 -0
  131. package/dist/{chunk-haeb904b.js → chunk-zk2xk0wd.js} +2 -2
  132. package/dist/chunk-zv288w4e.js +2 -0
  133. package/dist/{chunk-j4zyq2ap.js → chunk-zz02hwec.js} +11 -11
  134. package/dist/cli.js +19 -19
  135. package/dist/client-script-bundler.d.ts +12 -0
  136. package/dist/client-script-bundler.js +19 -5
  137. package/dist/composable-loader.js +2 -2
  138. package/dist/craft-entry.js +2 -2
  139. package/dist/craft.js +2 -2
  140. package/dist/native/compiler/bundle.d.ts +22 -0
  141. package/dist/native/compiler/bundle.js +164 -20
  142. package/dist/pwa.js +3 -3
  143. package/dist/ssg.js +3 -3
  144. package/dist/store-loader.js +7 -7
  145. package/package.json +5 -5
  146. package/dist/chunk-08a98yqt.js +0 -2
  147. package/dist/chunk-0q5s55km.js +0 -2
  148. package/dist/chunk-181m21rg.js +0 -2
  149. package/dist/chunk-194qgkc9.js +0 -2
  150. package/dist/chunk-1nbn56jw.js +0 -2
  151. package/dist/chunk-2ry2pfpe.js +0 -2
  152. package/dist/chunk-3bj1w990.js +0 -2
  153. package/dist/chunk-4a12azrb.js +0 -2
  154. package/dist/chunk-6aq3sm83.js +0 -2
  155. package/dist/chunk-6fpynp8q.js +0 -2
  156. package/dist/chunk-6q3yszw9.js +0 -74
  157. package/dist/chunk-6ryab0yy.js +0 -2
  158. package/dist/chunk-6sasxbv9.js +0 -2
  159. package/dist/chunk-6w9km7qb.js +0 -2
  160. package/dist/chunk-7kh4p06d.js +0 -2
  161. package/dist/chunk-7xrrzqh7.js +0 -2
  162. package/dist/chunk-7y73q42g.js +0 -11
  163. package/dist/chunk-8jaw6exk.js +0 -2
  164. package/dist/chunk-98r9jk2b.js +0 -2
  165. package/dist/chunk-9dgygz8d.js +0 -2
  166. package/dist/chunk-a51f04an.js +0 -2
  167. package/dist/chunk-aa52jhak.js +0 -2
  168. package/dist/chunk-ambynnzb.js +0 -2
  169. package/dist/chunk-ampr3fpv.js +0 -2
  170. package/dist/chunk-asbq9cgs.js +0 -2
  171. package/dist/chunk-bbdg3sqq.js +0 -33
  172. package/dist/chunk-bmtsb5mr.js +0 -2
  173. package/dist/chunk-c8rd3573.js +0 -2
  174. package/dist/chunk-d4b8cgvt.js +0 -2
  175. package/dist/chunk-d7skqhrc.js +0 -2
  176. package/dist/chunk-ensp20xk.js +0 -2
  177. package/dist/chunk-f1zyc84x.js +0 -2
  178. package/dist/chunk-f2y8bwdd.js +0 -2
  179. package/dist/chunk-g9vtny6q.js +0 -2
  180. package/dist/chunk-hcsrj8z6.js +0 -3
  181. package/dist/chunk-hj1bntaa.js +0 -2
  182. package/dist/chunk-hwy3aw5v.js +0 -2
  183. package/dist/chunk-hyafyqy6.js +0 -2
  184. package/dist/chunk-j75hqvgt.js +0 -2
  185. package/dist/chunk-j83ax407.js +0 -2
  186. package/dist/chunk-k3hfwve1.js +0 -2
  187. package/dist/chunk-ktc1ecsm.js +0 -2
  188. package/dist/chunk-mbmbaj0m.js +0 -2
  189. package/dist/chunk-nd3qttxh.js +0 -2
  190. package/dist/chunk-ndc1bmj7.js +0 -2
  191. package/dist/chunk-nn462qm9.js +0 -2
  192. package/dist/chunk-nr07vxm2.js +0 -2
  193. package/dist/chunk-q7a5pwaz.js +0 -2
  194. package/dist/chunk-qx6tr8mr.js +0 -2
  195. package/dist/chunk-r51vyhms.js +0 -2
  196. package/dist/chunk-s68bqf62.js +0 -2
  197. package/dist/chunk-s6sf70ty.js +0 -2
  198. package/dist/chunk-svavrmxb.js +0 -2
  199. package/dist/chunk-sw7mvg9p.js +0 -2
  200. package/dist/chunk-tz40t18m.js +0 -2
  201. package/dist/chunk-v1k0bdsg.js +0 -2
  202. package/dist/chunk-vd10tty0.js +0 -2
  203. package/dist/chunk-vqkzhd19.js +0 -2
  204. package/dist/chunk-w1yft5gg.js +0 -2
  205. package/dist/chunk-w6sa921x.js +0 -2
  206. package/dist/chunk-y120qq1a.js +0 -15
  207. package/dist/chunk-zcw74jmk.js +0 -2
  208. package/dist/chunk-zxvndwaz.js +0 -2
  209. package/dist/chunk-zzr0p4bb.js +0 -2
@@ -0,0 +1,122 @@
1
+ // @bun
2
+ import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import{hr,Gs,Ji}from"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import{Xn,Qn,n,o}from"./chunk-faghmmrs.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import"./chunk-jtbzmbzz.js";import{Ne}from"./chunk-71sdgv7e.js";import"./chunk-ktyctev3.js";import"./chunk-yy3ser06.js";import{Qr}from"./chunk-kp0hg06s.js";import"./chunk-cdgwkzms.js";import{existsSync as oe,mkdirSync as bn,readFileSync as wn}from"fs";import j from"path";import{existsSync as Re,mkdirSync as rt,realpathSync as cn,rmSync as it}from"fs";import O from"path";import{existsSync as sn}from"fs";import Q from"path";var lt="data-stx-b",Ie=new Set(Gs),dt=new Set(hr);function ut(r){if(r==="ref"||r==="data-stx-ref")return"ref";if(r.startsWith("::"))return null;if(r.startsWith("@bind:")||r.startsWith("x-bind:"))return"attr";if(r.startsWith("@")||r.startsWith(":")){let e=r.slice(1).split(".")[0];if(Ie.has(e))return e==="if"?"if":e;if(e==="for"||e==="else"||e==="else-if"||e==="elseif")return"for";if(Ji(e))return"event";if(r.startsWith("@"))return"event";return"attr"}if(r.startsWith("x-")){let e=r.split(".")[0];if(!dt.has(e))return"attr";let t=e.slice(2);if(t==="cloak"||t==="data"||t==="bind")return null;if(t==="tooltip"||t==="tooltip-position")return null;return Ie.has(t)?t==="if"?"if":t:"attr"}return null}function ft(r){let e=[];for(let[t,i]of r){let s=ut(t);if(s)e.push({name:t,value:i,kind:s})}return e}var pt=/<([a-z][\w-]*)((?:\s+[^\s"'=<>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*\/?>/gi,le=/([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function Pe(r){let e=[],t=0;return{html:r.replace(pt,(s,a,c)=>{if(!c||!/[:@]|x-/.test(c))return s;let d=[];le.lastIndex=0;for(let f=le.exec(c);f;f=le.exec(c))d.push([f[1],f[2]??f[3]??f[4]??""]);let l=ft(d);if(!l.length)return s;let g={id:t++,bindings:l};if(l.some((f)=>f.kind==="for"))g.template=!0;e.push(g);let h=s.endsWith("/>");return`${s.slice(0,h?-2:-1).trimEnd()} ${lt}="${g.id}"${h?"/>":">"}`}),manifest:{entries:e}}}var de={"region-change-complete":"onRegionChangeComplete",regionchangecomplete:"onRegionChangeComplete",click:"onPress",press:"onPress","press-in":"onPressIn",pressin:"onPressIn","press-out":"onPressOut",pressout:"onPressOut",longpress:"onLongPress",contextmenu:"onLongPress",input:"onChangeText",change:"onValueChange","value-change":"onValueChange",valuechange:"onValueChange",focus:"onFocus",focusin:"onFocus",blur:"onBlur",focusout:"onBlur",submit:"onSubmitEditing","submit-editing":"onSubmitEditing",submitediting:"onSubmitEditing","end-editing":"onEndEditing",endediting:"onEndEditing",scroll:"onScroll","scroll-begin-drag":"onScrollBeginDrag",scrollbegindrag:"onScrollBeginDrag","scroll-end-drag":"onScrollEndDrag",scrollenddrag:"onScrollEndDrag","momentum-scroll-begin":"onMomentumScrollBegin",momentumscrollbegin:"onMomentumScrollBegin","momentum-scroll-end":"onMomentumScrollEnd",momentumscrollend:"onMomentumScrollEnd",refresh:"onRefresh",layout:"onLayout","end-reached":"onEndReached",endreached:"onEndReached",close:"onRequestClose","request-close":"onRequestClose",requestclose:"onRequestClose",show:"onShow",dismiss:"onDismiss","sliding-complete":"onSlidingComplete",slidingcomplete:"onSlidingComplete","load-start":"onLoadStart",loadstart:"onLoadStart",load:"onLoad","load-end":"onLoadEnd",loadend:"onLoadEnd",error:"onError",play:"onPlay",playing:"onPlay",pause:"onPause",ended:"onEnd",end:"onEnd",timeupdate:"onProgress",progress:"onProgress",loadedmetadata:"onLoad",enterpictureinpicture:"onPictureInPictureStart",leavepictureinpicture:"onPictureInPictureStop"};var fe={svg:"Svg",g:"G",path:"Path",line:"Line",rect:"Rect",circle:"Circle",ellipse:"Ellipse",polyline:"Polyline",polygon:"Polygon",text:"SvgText",tspan:"SvgText"},pe=new Set(Object.values(fe));var Be=new Set(["defs","title","desc","metadata","style","symbol","use","clippath","mask","lineargradient","radialgradient","stop","pattern","marker","filter","foreignobject"]),Me=["viewBox","preserveAspectRatio","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","fillOpacity","fillRule","vectorEffect","textAnchor","dominantBaseline","fontSize","fontWeight"];function C(r){let e=typeof r==="number"?r:Number.parseFloat(String(r??""));return Number.isFinite(e)?e:0}function q(r){return Math.round(r*1000)/1000}function ge(r){if(Array.isArray(r)&&r.length===4&&r.every((t)=>Number.isFinite(Number(t))))return r.map(Number);let e=String(r??"").trim().split(/[\s,]+/).map(Number);if(e.length!==4||e.some((t)=>!Number.isFinite(t))||e[2]<=0||e[3]<=0)return null;return e}function gt(r){let e=String(r??"").trim().split(/[\s,]+/).filter(Boolean).map(Number).filter(Number.isFinite);return e.length%2?e.slice(0,-1):e}var Ce=/[MLHVCSQTAZ]/i,ue=/[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi;function ht(r){let e=[],t=r,i=Ce.exec(t);while(i){let s=i.index;t=t.slice(s);let a=t[0];t=t.slice(1);let c=Ce.exec(t),d=c?t.slice(0,c.index):t,l;if(a==="A"||a==="a"){l=[];let g=0,h=d.trim(),u=0;while(u<h.length){let f=g%7,y=h.slice(u).replace(/^[\s,]+/,"");if(u=h.length-y.length,!y)break;if(f===3||f===4)l.push(y[0]==="1"?1:0),u+=1;else{ue.lastIndex=0;let b=ue.exec(y);if(!b||b.index!==0)break;l.push(Number.parseFloat(b[0])),u+=b[0].length}g++}}else l=(d.match(ue)||[]).map(Number.parseFloat);e.push({command:a,args:l}),i=c}return e}function mt(r,e,t,i,s,a,c,d,l){if(r===d&&e===l)return[];let g=Math.abs(t),h=Math.abs(i);if(!g||!h)return[1,d,l];let u=s*Math.PI/180,f=Math.cos(u),y=Math.sin(u),b=(r-d)/2,w=(e-l)/2,p=f*b+y*w,v=-y*b+f*w,R=p*p/(g*g)+v*v/(h*h);if(R>1)g*=Math.sqrt(R),h*=Math.sqrt(R);let I=g*g*h*h-g*g*v*v-h*h*p*p,m=g*g*v*v+h*h*p*p,N=Math.sqrt(Math.max(0,I/m));if(a===c)N=-N;let k=N*(g*v)/h,x=N*-(h*p)/g,S=f*k-y*x+(r+d)/2,T=y*k+f*x+(e+l)/2,A=(P,M,D,K)=>{let ae=P*K-M*D<0?-1:1,ce=(P*D+M*K)/(Math.hypot(P,M)*Math.hypot(D,K));return ae*Math.acos(Math.min(1,Math.max(-1,ce)))},V=A(1,0,(p-k)/g,(v-x)/h),L=A((p-k)/g,(v-x)/h,(-p-k)/g,(-v-x)/h);if(!c&&L>0)L-=2*Math.PI;if(c&&L<0)L+=2*Math.PI;let W=Math.max(1,Math.ceil(Math.abs(L)/(Math.PI/2))),H=L/W,E=1.3333333333333333*Math.tan(H/4),B=[],z=(P)=>{let M=g*Math.cos(P),D=h*Math.sin(P);return[f*M-y*D+S,y*M+f*D+T]},U=(P)=>{let M=-g*Math.sin(P),D=h*Math.cos(P);return[f*M-y*D,y*M+f*D]},F=V;for(let P=0;P<W;P++){let M=F+H,[D,K]=z(F),[ae,ce]=U(F),[Ee,_e]=z(M),[at,ct]=U(M);B.push(2,D+E*ae,K+E*ce,Ee-E*at,_e-E*ct,P===W-1?d:Ee,P===W-1?l:_e),F=M}return B}function yt(r){let e=[],t=0,i=0,s=0,a=0,c=0,d=0,l=0,g=0,h="";for(let{command:u,args:f}of ht(String(r??""))){let y=u===u.toLowerCase(),b=u.toUpperCase(),w=()=>y?t:0,p=()=>y?i:0,v=0,R=(m)=>{if(v+m>f.length)return null;let N=f.slice(v,v+m);return v+=m,N};if(b==="Z"){e.push(4),t=s,i=a,h="Z";continue}let I=!0;while(v<f.length||I&&b==="Z"){switch(b){case"M":{let m=R(2);if(!m)return e;if(t=m[0]+w(),i=m[1]+p(),I)e.push(0,t,i),s=t,a=i;else e.push(1,t,i);h=I?"M":"L";break}case"L":{let m=R(2);if(!m)return e;t=m[0]+w(),i=m[1]+p(),e.push(1,t,i),h="L";break}case"H":{let m=R(1);if(!m)return e;t=m[0]+w(),e.push(1,t,i),h="L";break}case"V":{let m=R(1);if(!m)return e;i=m[0]+p(),e.push(1,t,i),h="L";break}case"C":{let m=R(6);if(!m)return e;let N=m[0]+w(),k=m[1]+p();c=m[2]+w(),d=m[3]+p(),t=m[4]+w(),i=m[5]+p(),e.push(2,N,k,c,d,t,i),h="C";break}case"S":{let m=R(4);if(!m)return e;let N=h==="C"?2*t-c:t,k=h==="C"?2*i-d:i;c=m[0]+w(),d=m[1]+p(),t=m[2]+w(),i=m[3]+p(),e.push(2,N,k,c,d,t,i),h="C";break}case"Q":{let m=R(4);if(!m)return e;l=m[0]+w(),g=m[1]+p(),t=m[2]+w(),i=m[3]+p(),e.push(3,l,g,t,i),h="Q";break}case"T":{let m=R(2);if(!m)return e;l=h==="Q"?2*t-l:t,g=h==="Q"?2*i-g:i,t=m[0]+w(),i=m[1]+p(),e.push(3,l,g,t,i),h="Q";break}case"A":{let m=R(7);if(!m)return e;let N=m[5]+w(),k=m[6]+p();e.push(...mt(t,i,m[0],m[1],m[2],m[3],m[4],N,k)),t=N,i=k,h="A";break}default:return e}I=!1}}return e.map((u)=>q(u))}function Oe(r,e,t,i){if(t<=0||i<=0)return[];let s=0.5522847498;return[0,r+t,e,2,r+t,e+s*i,r+s*t,e+i,r,e+i,2,r-s*t,e+i,r-t,e+s*i,r-t,e,2,r-t,e-s*i,r-s*t,e-i,r,e-i,2,r+s*t,e-i,r+t,e-s*i,r+t,e,4].map(q)}function he(r,e){switch(r){case"Path":return yt(String(e.d??""));case"Line":return[0,C(e.x1),C(e.y1),1,C(e.x2),C(e.y2)].map(q);case"Rect":{let t=C(e.x),i=C(e.y),s=C(e.width),a=C(e.height);if(s<=0||a<=0)return[];let c=e.rx===void 0?C(e.ry):C(e.rx),d=e.ry===void 0?c:C(e.ry);if(c=Math.min(Math.max(0,c),s/2),d=Math.min(Math.max(0,d),a/2),!c||!d)return[0,t,i,1,t+s,i,1,t+s,i+a,1,t,i+a,4].map(q);let l=0.5522847498;return[0,t+c,i,1,t+s-c,i,2,t+s-c+l*c,i,t+s,i+d-l*d,t+s,i+d,1,t+s,i+a-d,2,t+s,i+a-d+l*d,t+s-c+l*c,i+a,t+s-c,i+a,1,t+c,i+a,2,t+c-l*c,i+a,t,i+a-d+l*d,t,i+a-d,1,t,i+d,2,t,i+d-l*d,t+c-l*c,i,t+c,i,4].map(q)}case"Circle":return Oe(C(e.cx),C(e.cy),C(e.r),C(e.r));case"Ellipse":return Oe(C(e.cx),C(e.cy),C(e.rx),C(e.ry));case"Polyline":case"Polygon":{let t=gt(e.points);if(t.length<4)return[];let i=[0,t[0],t[1]];for(let s=2;s<t.length;s+=2)i.push(1,t[s],t[s+1]);if(r==="Polygon")i.push(4);return i.map(q)}default:return null}}var bt=[...Me,"accessibilityHint","accessibilityLabel","accessibilityRole","accessibilityState","accessibilityValue","activeOpacity","alwaysBounceHorizontal","alwaysBounceVertical","animationType","autoCapitalize","autoComplete","autoCorrect","autoFocus","blurRadius","contentContainerStyle","defaultSource","defaultValue","ellipsizeMode","fadeDuration","hidesWhenStopped","hitSlop","imageStyle","initialNumToRender","iosBackgroundColor","keyboardDismissMode","keyboardShouldPersistTaps","keyboardType","keyboardVerticalOffset","keyExtractor","maxLength","maximumDate","maximumTrackTintColor","maximumValue","maxToRenderPerBatch","minimumDate","minimumTrackTintColor","minimumValue","minuteInterval","numberOfLines","numColumns","onEndReachedThreshold","pagingEnabled","passwordRules","placeholderTextColor","pointerEvents","presentationStyle","pressRetentionOffset","progressBackgroundColor","progressViewOffset","refreshControl","resizeMode","returnKeyType","scrollEnabled","scrollTarget","secureTextEntry","selectedValue","selectionColor","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","statusBarTranslucent","stickyHeaderIndices","testID","textContentType","thumbColor","thumbTintColor","titleColor","trackColor","underlayColor","windowSize","initialRegion","tileOverlay","edgePadding","fitToBounds","showsUserLocation","zoomEnabled","rotateEnabled","pitchEnabled","mapType","strokeColor","pinColor","showsCompass","showsScale","cameraPitch","cameraHeading","autoScrollBottom","scrollKey","pictureInPicture","transitionID"],De=new Set(["animating","autoCorrect","autoFocus","autoplay","autoPlay","bounces","controls","disabled","editable","hidesWhenStopped","horizontal","loop","multiline","muted","pagingEnabled","paused","refreshing","scrollEnabled","secureTextEntry","selectTextOnFocus","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","transparent","visible","fitToBounds","showsUserLocation","zoomEnabled","rotateEnabled","pitchEnabled","showsCompass","showsScale","pictureInPicture"]),wt=new Map(bt.map((r)=>[Le(r),r]));function Le(r){return r.replace(/[-_]/g,"").toLowerCase()}function me(r){return wt.get(Le(r))??r}var St={view:"View",sidebar:"Sidebar",splitview:"SplitView",textinput:"TextInput",pressable:"Pressable",icon:"Icon",text:"Text",button:"Button",image:"Image",img:"Image",video:"Video",map:"Map",mappolyline:"MapPolyline",mapmarker:"MapMarker",input:"TextInput",textarea:"TextInput",scroll:"ScrollView",scrollview:"ScrollView",list:"FlatList",flatlist:"FlatList",modal:"Modal",switch:"Switch",checkbox:"Checkbox",slider:"Slider",picker:"Picker",select:"Picker",loading:"ActivityIndicator",spinner:"ActivityIndicator",div:"View",span:"Text",p:"Text",h1:"Text",h2:"Text",h3:"Text",h4:"Text",h5:"Text",h6:"Text",a:"TouchableOpacity",section:"View",article:"View",header:"SafeAreaView",footer:"View",main:"View",nav:"View",aside:"View",form:"View",label:"Text",fieldset:"View",legend:"Text",option:"Text",dialog:"Modal",figure:"View",figcaption:"Text",picture:"View",hr:"View",ul:"View",ol:"View",li:"View",dl:"View",dt:"Text",dd:"Text",table:"View",thead:"View",tbody:"View",tfoot:"View",tr:"View",th:"Text",td:"Text",caption:"Text",strong:"Text",b:"Text",em:"Text",i:"Text",u:"Text",s:"Text",small:"Text",mark:"Text",abbr:"Text",time:"Text",code:"Text",kbd:"Text",samp:"Text",pre:"Text",blockquote:"Text",cite:"Text",q:"Text",sub:"Text",sup:"Text"};function $e(r){return St[r.toLowerCase()]||r}var vt={activity:"waveform.path.ecg","alarm-clock":"alarm","alert-circle":"exclamationmark.circle","alert-triangle":"exclamationmark.triangle",archive:"archivebox",armchair:"sofa","arrow-down":"arrow.down","arrow-left":"arrow.left","arrow-right":"arrow.right","arrow-up":"arrow.up","arrow-up-right":"arrow.up.right","at-sign":"at","audio-lines":"waveform",award:"rosette",backpack:"backpack","badge-check":"checkmark.seal","badge-x":"xmark.seal",ban:"nosign","bar-chart":"chart.bar","bar-chart-2":"chart.bar","bar-chart-3":"chart.bar",battery:"battery.100","battery-charging":"battery.100.bolt",bed:"bed.double",bell:"bell","bell-off":"bell.slash","bell-ring":"bell.and.waves.left.and.right",bike:"figure.outdoor.cycle",blocks:"square.grid.2x2",bluetooth:"antenna.radiowaves.left.and.right",book:"book","book-open":"book",bookmark:"bookmark",box:"shippingbox",brain:"brain",building:"building","building-2":"building.2",cable:"cable.connector",calendar:"calendar","calendar-check":"calendar.badge.checkmark","calendar-clock":"calendar.badge.clock","calendar-days":"calendar","calendar-minus":"calendar.badge.minus","calendar-minus-2":"calendar.badge.minus","calendar-off":"calendar.badge.exclamationmark","calendar-plus":"calendar.badge.plus","calendar-range":"calendar","calendar-sync":"arrow.triangle.2.circlepath","calendar-x":"calendar.badge.exclamationmark","calendar-x-2":"calendar.badge.exclamationmark",camera:"camera","chart-bar":"chart.bar","chart-column":"chart.bar","chart-line":"chart.xyaxis.line","chart-no-axes-gantt":"chart.bar.doc.horizontal",check:"checkmark","check-circle":"checkmark.circle","check-circle-2":"checkmark.circle","chevron-down":"chevron.down","chevron-left":"chevron.left","chevron-right":"chevron.right","chevron-up":"chevron.up",circle:"circle","circle-alert":"exclamationmark.circle","circle-arrow-out-up-left":"arrow.uturn.backward.circle","circle-minus":"minus.circle","circle-arrow-down":"arrow.down.circle","circle-check":"checkmark.circle","circle-check-big":"checkmark.circle","circle-dot":"smallcircle.filled.circle","circle-help":"questionmark.circle","circle-play":"play.circle","circle-plus":"plus.circle","circle-user":"person.crop.circle","circle-x":"xmark.circle",clapperboard:"film",clipboard:"clipboard","clipboard-list":"list.clipboard",clock:"clock","clock-12":"clock","clock-2":"clock","clock-3":"clock","clock-4":"clock","clock-8":"clock",cloud:"cloud","cloud-off":"icloud.slash",coffee:"cup.and.saucer",copy:"doc.on.doc","credit-card":"creditcard",cylinder:"cylinder",disc:"opticaldisc",download:"arrow.down.circle",droplet:"drop",droplets:"drop",dumbbell:"dumbbell",edit:"pencil","external-link":"arrow.up.right.square",eye:"eye","eye-off":"eye.slash",file:"doc","file-text":"doc.text",filter:"line.3.horizontal.decrease",flag:"flag",flame:"flame","flower-2":"camera.macro",footprints:"figure.run",gauge:"gauge",gift:"gift",globe:"globe","graduation-cap":"graduationcap","grip-vertical":"line.3.horizontal","hand-fist":"hand.raised",heart:"heart","heart-off":"heart.slash","heart-pulse":"heart.text.square","help-circle":"questionmark.circle",history:"clock.arrow.circlepath",home:"house",hourglass:"hourglass",house:"house","id-card":"person.text.rectangle",image:"photo",inbox:"tray",info:"info.circle",layers:"square.3.layers.3d","layout-dashboard":"rectangle.3.group","layout-grid":"square.grid.2x2",leaf:"leaf",library:"books.vertical",link:"link",list:"list.bullet","list-checks":"checklist",loader:"arrow.triangle.2.circlepath","loader-2":"arrow.triangle.2.circlepath","loader-circle":"arrow.triangle.2.circlepath",lock:"lock","log-in":"arrow.right.to.line","log-out":"rectangle.portrait.and.arrow.right",mail:"envelope",map:"map","map-pin":"mappin.and.ellipse",medal:"medal",megaphone:"megaphone",menu:"line.3.horizontal","message-circle":"bubble.left","message-square":"text.bubble","message-square-quote":"quote.bubble",mic:"mic",minus:"minus",moon:"moon","more-horizontal":"ellipsis","more-vertical":"ellipsis",mountain:"mountain.2",music:"music.note","music-2":"music.note",package:"shippingbox",pause:"pause","pause-circle":"pause.circle",pencil:"pencil","person-standing":"figure.walk",phone:"phone",play:"play.fill",plug:"powerplug",plus:"plus","plus-circle":"plus.circle","rectangle-horizontal":"rectangle","refresh-cw":"arrow.clockwise",repeat:"repeat","rotate-ccw":"arrow.counterclockwise",route:"point.topleft.down.to.point.bottomright.curvepath",ruler:"ruler",sailboat:"sailboat",satellite:"antenna.radiowaves.left.and.right",save:"square.and.arrow.down",scale:"scalemass","scan-line":"barcode.viewfinder",search:"magnifyingglass",send:"paperplane",settings:"gearshape","settings-2":"slider.horizontal.3",share:"square.and.arrow.up","share-2":"square.and.arrow.up",shield:"shield","shield-check":"checkmark.shield","shopping-bag":"bag","shopping-cart":"cart",shuffle:"shuffle","skip-back":"backward.end","skip-forward":"forward.end",sliders:"slider.horizontal.3","sliders-horizontal":"slider.horizontal.3",smartphone:"iphone",snowflake:"snowflake",sparkles:"sparkles",sprout:"leaf",square:"square",star:"star",stopwatch:"stopwatch",store:"storefront","stretch-horizontal":"rectangle.split.1x2",sun:"sun.max",sunrise:"sunrise",sunset:"sunset",tag:"tag",target:"scope",thermometer:"thermometer.medium","thumbs-up":"hand.thumbsup",timer:"timer",trash:"trash","trash-2":"trash","trending-down":"chart.line.downtrend.xyaxis","trending-up":"chart.line.uptrend.xyaxis","triangle-alert":"exclamationmark.triangle",trophy:"trophy",unlink:"personalhotspot.slash",upload:"arrow.up.circle",user:"person","user-check":"person.crop.circle.badge.checkmark","user-minus":"person.badge.minus","user-plus":"person.badge.plus","user-round":"person","user-round-check":"person.crop.circle.badge.checkmark","user-round-minus":"person.crop.circle.badge.minus","user-round-plus":"person.crop.circle.badge.plus","user-round-x":"person.crop.circle.badge.xmark","user-x":"person.crop.circle.badge.xmark",users:"person.2","users-round":"person.2",video:"video","volume-2":"speaker.wave.2",warehouse:"building.2",watch:"applewatch",waves:"figure.pool.swim",weight:"scalemass",wifi:"wifi","wifi-off":"wifi.slash",wind:"wind",x:"xmark","x-circle":"xmark.circle",zap:"bolt"};function ye(r,e=!1){let t=String(r??"").trim();if(!t)return{symbol:"circle",known:!1};if(e)return{symbol:t,known:!0};let i=/^i-([a-z0-9]+)-(.+)$/.exec(t)??/^([a-z0-9]+):(.+)$/.exec(t),s=i?i[1]:"lucide",a=i?i[2]:t;if(s==="lucide"){let c=vt[a];if(c)return{symbol:c,iconify:`i-lucide-${a}`,known:!0};if(!i&&t.includes("."))return{symbol:t,known:!0}}return{symbol:"circle",iconify:i?t:`i-lucide-${a}`,known:!1}}var xt={transparent:"transparent",current:"currentColor",black:"#000000",white:"#ffffff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},je={px:1,0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},Ve={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48,"6xl":60,"7xl":72,"8xl":96,"9xl":128},X={none:0,sm:2,DEFAULT:4,md:6,lg:8,xl:12,"2xl":16,"3xl":24,full:9999};function G(r){let e=r.lastIndexOf("/");if(e>0&&!r.endsWith("]")){let i=G(r.slice(0,e)),s=r.slice(e+1),a=/^\[(.+)\]$/.test(s)?Number.parseFloat(s.slice(1,-1))*(s.includes("%")?1:100):Number.parseFloat(s);if(!i||!Number.isFinite(a))return;return Nt(i,a/100)}if(r==="transparent")return"transparent";if(r==="current")return"currentColor";if(r==="black")return"#000000";if(r==="white")return"#ffffff";let t=r.split("-");if(t.length===2){let[i,s]=t,a=xt[i];if(a&&typeof a==="object")return a[s]}if(r.startsWith("[")&&r.endsWith("]")){let i=r.slice(1,-1);return/^(#|rgba?\(|hsla?\(|[a-z]+$)/i.test(i)?i:void 0}return}function Nt(r,e){if(r==="transparent")return r;let t=r.startsWith("#")?r.slice(1):"";if(t.length===3)t=t.split("").map((s)=>s+s).join("");if(t.length===8)t=t.slice(0,6);if(t.length!==6)return;let i=Math.round(Math.min(1,Math.max(0,e))*255);return`#${t}${i.toString(16).padStart(2,"0")}`}function be(r,e=16){if(!r.startsWith("[")||!r.endsWith("]"))return;let t=r.slice(1,-1),i=Number.parseFloat(t);if(!Number.isFinite(i))return;if(t.endsWith("rem"))return i*16;if(t.endsWith("em"))return i*e;return i}function _(r){if(r.startsWith("[")&&r.endsWith("]")){let e=r.slice(1,-1);if(e.endsWith("%"))return;let t=e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e);return Number.isFinite(t)?t:void 0}return je[r]}function ee(r){let e=/^\[(-?\d*\.?\d+)%\]$/.exec(r);if(e)return`${Number.parseFloat(e[1])}%`;return _(r)}var kt={flex:(r,e)=>(e.display="flex",!0),hidden:(r,e)=>(e.display="none",!0),grid:(r,e)=>(e.display="grid",!0),"flex-row":(r,e)=>(e.flexDirection="row",!0),"flex-col":(r,e)=>(e.flexDirection="column",!0),"flex-row-reverse":(r,e)=>(e.flexDirection="row-reverse",!0),"flex-col-reverse":(r,e)=>(e.flexDirection="column-reverse",!0),"flex-wrap":(r,e)=>(e.flexWrap="wrap",!0),"flex-nowrap":(r,e)=>(e.flexWrap="nowrap",!0),"flex-wrap-reverse":(r,e)=>(e.flexWrap="wrap-reverse",!0),"flex-1":(r,e)=>(e.flex=1,e.flexGrow=1,e.flexShrink=1,e.flexBasis=0,!0),"flex-auto":(r,e)=>(e.flexGrow=1,e.flexShrink=1,!0),"flex-initial":(r,e)=>(e.flexGrow=0,e.flexShrink=1,!0),"flex-none":(r,e)=>(e.flexGrow=0,e.flexShrink=0,!0),grow:(r,e)=>(e.flexGrow=1,!0),"grow-0":(r,e)=>(e.flexGrow=0,!0),shrink:(r,e)=>(e.flexShrink=1,!0),"shrink-0":(r,e)=>(e.flexShrink=0,!0),"justify-start":(r,e)=>(e.justifyContent="flex-start",!0),"justify-center":(r,e)=>(e.justifyContent="center",!0),"justify-end":(r,e)=>(e.justifyContent="flex-end",!0),"justify-between":(r,e)=>(e.justifyContent="space-between",!0),"justify-around":(r,e)=>(e.justifyContent="space-around",!0),"justify-evenly":(r,e)=>(e.justifyContent="space-evenly",!0),"items-start":(r,e)=>(e.alignItems="flex-start",!0),"items-center":(r,e)=>(e.alignItems="center",!0),"items-end":(r,e)=>(e.alignItems="flex-end",!0),"items-stretch":(r,e)=>(e.alignItems="stretch",!0),"items-baseline":(r,e)=>(e.alignItems="baseline",!0),"self-auto":(r,e)=>(e.alignSelf="auto",!0),"self-start":(r,e)=>(e.alignSelf="flex-start",!0),"self-center":(r,e)=>(e.alignSelf="center",!0),"self-end":(r,e)=>(e.alignSelf="flex-end",!0),"self-stretch":(r,e)=>(e.alignSelf="stretch",!0),"self-baseline":(r,e)=>(e.alignSelf="baseline",!0),"min-w-0":(r,e)=>(e.minWidth=0,!0),"aspect-square":(r,e)=>(e.aspectRatio=1,!0),"inset-0":(r,e)=>(e.top=0,e.right=0,e.bottom=0,e.left=0,!0),"tracking-tighter":(r,e)=>(e.letterSpacing=-0.8,!0),"tracking-tight":(r,e)=>(e.letterSpacing=-0.4,!0),"tracking-normal":(r,e)=>(e.letterSpacing=0,!0),"tracking-wide":(r,e)=>(e.letterSpacing=0.4,!0),"tracking-wider":(r,e)=>(e.letterSpacing=0.8,!0),"tracking-widest":(r,e)=>(e.letterSpacing=1.6,!0),"tabular-nums":()=>!0,block:()=>!0,"inline-flex":(r,e)=>(e.display="flex",!0),truncate:()=>!0,relative:(r,e)=>(e.position="relative",!0),absolute:(r,e)=>(e.position="absolute",!0),"overflow-visible":(r,e)=>(e.overflow="visible",!0),"overflow-hidden":(r,e)=>(e.overflow="hidden",!0),"overflow-scroll":(r,e)=>(e.overflow="scroll",!0),"font-thin":(r,e)=>(e.fontWeight="100",!0),"font-extralight":(r,e)=>(e.fontWeight="200",!0),"font-light":(r,e)=>(e.fontWeight="300",!0),"font-normal":(r,e)=>(e.fontWeight="400",!0),"font-medium":(r,e)=>(e.fontWeight="500",!0),"font-semibold":(r,e)=>(e.fontWeight="600",!0),"font-bold":(r,e)=>(e.fontWeight="bold",!0),"font-extrabold":(r,e)=>(e.fontWeight="800",!0),"font-black":(r,e)=>(e.fontWeight="900",!0),italic:(r,e)=>(e.fontStyle="italic",!0),"not-italic":(r,e)=>(e.fontStyle="normal",!0),"text-left":(r,e)=>(e.textAlign="left",!0),"text-center":(r,e)=>(e.textAlign="center",!0),"text-right":(r,e)=>(e.textAlign="right",!0),"text-justify":(r,e)=>(e.textAlign="justify",!0),uppercase:(r,e)=>(e.textTransform="uppercase",!0),lowercase:(r,e)=>(e.textTransform="lowercase",!0),capitalize:(r,e)=>(e.textTransform="capitalize",!0),"normal-case":(r,e)=>(e.textTransform="none",!0),underline:(r,e)=>(e.textDecorationLine="underline",!0),"line-through":(r,e)=>(e.textDecorationLine="line-through",!0),"no-underline":(r,e)=>(e.textDecorationLine="none",!0)};function Tt(r,e){if(!r.startsWith("bg-"))return!1;let t=r.slice(3),i=G(t);if(i)return e.backgroundColor=i,!0;return!1}function Rt(r,e){if(!r.startsWith("text-"))return!1;let t=r.slice(5);if(Ve[t])return e.fontSize=Ve[t],!0;if(t.startsWith("[")&&t.endsWith("]")){let s=t.slice(1,-1);if(/^-?[\d.]+(?:px|r?em)?$/.test(s)){let a=s.endsWith("rem")||s.endsWith("em")?Number.parseFloat(s)*16:Number.parseFloat(s);if(Number.isFinite(a))return e.fontSize=a,!0}}let i=G(t);if(i)return e.color=i,!0;return!1}var At=new Set(["t","tr","r","br","b","bl","l","tl"]);function Et(r,e){let t=/^bg-(?:gradient|linear)-to-([a-z]+)$/.exec(r);if(t&&At.has(t[1]))return e.gradientDirection=`to-${t[1]}`,!0;let i=/^(from|via|to)-(.+)$/.exec(r);if(!i)return!1;let s=G(i[2]);if(!s)return!1;if(i[1]==="from")e.gradientFrom=s;else if(i[1]==="via")e.gradientVia=s;else e.gradientTo=s;return!0}function _t(r,e){for(let t of["fill","stroke"]){let i=`${t}-`;if(!r.startsWith(i))continue;let s=r.slice(i.length);if(s==="none")return e[t]="none",!0;if(t==="stroke"&&/^\d+(?:\.\d+)?$/.test(s))return e.strokeWidth=Number.parseFloat(s),!0;if(t==="stroke"&&/^\[\d+(?:\.\d+)?(?:px)?\]$/.test(s))return e.strokeWidth=Number.parseFloat(s.slice(1)),!0;let a=G(s);if(a)return e[t]=a,!0}return!1}function It(r,e){if(r.startsWith("p-")){let t=_(r.slice(2));if(t!==void 0)return e.padding=t,!0}if(r.startsWith("px-")){let t=_(r.slice(3));if(t!==void 0)return e.paddingHorizontal=t,!0}if(r.startsWith("py-")){let t=_(r.slice(3));if(t!==void 0)return e.paddingVertical=t,!0}if(r.startsWith("pt-")){let t=_(r.slice(3));if(t!==void 0)return e.paddingTop=t,!0}if(r.startsWith("pr-")){let t=_(r.slice(3));if(t!==void 0)return e.paddingRight=t,!0}if(r.startsWith("pb-")){let t=_(r.slice(3));if(t!==void 0)return e.paddingBottom=t,!0}if(r.startsWith("pl-")){let t=_(r.slice(3));if(t!==void 0)return e.paddingLeft=t,!0}return!1}function We(r,e){if(/^-(?:m|mx|my|mt|mr|mb|ml)-/.test(r)){let t={};if(!We(r.slice(1),t))return!1;let i=Object.entries(t);if(i.some(([,s])=>typeof s!=="number"))return!1;for(let[s,a]of i)e[s]=-a;return!0}if(r.startsWith("m-")){let t=_(r.slice(2));if(t!==void 0)return e.margin=t,!0}if(r.startsWith("mx-")){let t=_(r.slice(3));if(t!==void 0)return e.marginHorizontal=t,!0}if(r.startsWith("my-")){let t=_(r.slice(3));if(t!==void 0)return e.marginVertical=t,!0}if(r.startsWith("mt-")){let t=_(r.slice(3));if(t!==void 0)return e.marginTop=t,!0}if(r.startsWith("mr-")){let t=_(r.slice(3));if(t!==void 0)return e.marginRight=t,!0}if(r.startsWith("mb-")){let t=_(r.slice(3));if(t!==void 0)return e.marginBottom=t,!0}if(r.startsWith("ml-")){let t=_(r.slice(3));if(t!==void 0)return e.marginLeft=t,!0}return!1}function Pt(r,e){if(!r.startsWith("w-"))return!1;let t=r.slice(2);if(t==="full")return e.width="100%",!0;if(t==="screen")return e.width="100%",!0;if(t==="auto")return e.width="auto",!0;if(t.includes("/")){let[s,a]=t.split("/"),c=Number.parseInt(s)/Number.parseInt(a)*100;return e.width=`${c}%`,!0}let i=ee(t);if(i!==void 0)return e.width=i,!0;return!1}function Ct(r,e){if(!r.startsWith("h-"))return!1;let t=r.slice(2);if(t==="full")return e.height="100%",!0;if(t==="screen")return e.height="100%",!0;if(t==="auto")return e.height="auto",!0;let i=ee(t);if(i!==void 0)return e.height=i,!0;return!1}function Ot(r,e){if(!r.startsWith("rounded"))return!1;if(r==="rounded")return e.borderRadius=X.DEFAULT,!0;let t=r.slice(8);if(t==="")return!1;let i=/^(?:(t|b|l|r)-)?(\[[^\]]+\])$/.exec(t);if(i){let a=be(i[2]);if(a===void 0)return!1;let c={t:["borderTopLeftRadius","borderTopRightRadius"],b:["borderBottomLeftRadius","borderBottomRightRadius"],l:["borderTopLeftRadius","borderBottomLeftRadius"],r:["borderTopRightRadius","borderBottomRightRadius"]};for(let d of i[1]?c[i[1]]:["borderRadius"])e[d]=a;return!0}if(t.startsWith("t-")){let a=X[t.slice(2)]??X.DEFAULT;return e.borderTopLeftRadius=a,e.borderTopRightRadius=a,!0}if(t.startsWith("b-")){let a=X[t.slice(2)]??X.DEFAULT;return e.borderBottomLeftRadius=a,e.borderBottomRightRadius=a,!0}if(t.startsWith("l-")){let a=X[t.slice(2)]??X.DEFAULT;return e.borderTopLeftRadius=a,e.borderBottomLeftRadius=a,!0}if(t.startsWith("r-")){let a=X[t.slice(2)]??X.DEFAULT;return e.borderTopRightRadius=a,e.borderBottomRightRadius=a,!0}let s=X[t];if(s!==void 0)return e.borderRadius=s,!0;return!1}function Bt(r,e){if(!r.startsWith("border"))return!1;if(r==="border")return e.borderWidth=1,!0;let t=r.match(/^border-(\d+)$/);if(t)return e.borderWidth=Number.parseInt(t[1]),!0;let i=r.match(/^border-(t|r|b|l)-?(\d*)$/);if(i){let[,s,a]=i,c=a?Number.parseInt(a):1;switch(s){case"t":e.borderTopWidth=c;break;case"r":e.borderRightWidth=c;break;case"b":e.borderBottomWidth=c;break;case"l":e.borderLeftWidth=c;break}return!0}return!1}function Mt(r,e){if(!r.startsWith("border-"))return!1;let t=r.slice(7),i=G(t);if(i)return e.borderColor=i,!0;return!1}function Dt(r,e){if(!r.startsWith("opacity-"))return!1;let t=Number.parseInt(r.slice(8));if(!Number.isNaN(t))return e.opacity=t/100,!0;return!1}function Lt(r,e){if(r.startsWith("tracking-[")){let t=be(r.slice(9),typeof e.fontSize==="number"?e.fontSize:16);if(t===void 0)return!1;return e.letterSpacing=t,!0}if(r.startsWith("leading-")){let t=r.slice(8),i=typeof e.fontSize==="number"?e.fontSize:16,s={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},a=t.startsWith("[")?/^\[[\d.]+\]$/.test(t)?Number.parseFloat(t.slice(1,-1))*i:be(t,i):s[t]!==void 0?s[t]*i:je[t];if(a===void 0||!Number.isFinite(a))return!1;return e.lineHeight=a,!0}return!1}function $t(r,e){let t=/^grid-cols-(\d+)$/.exec(r);if(!t)return!1;return e.gridColumns=Number(t[1]),!0}function Vt(r,e){if(!r.startsWith("size-"))return!1;let t=r.slice(5),i=t==="full"?"100%":ee(t);if(i===void 0)return!1;return e.width=i,e.height=i,!0}var Ft={xs:320,sm:384,md:448,lg:512,xl:576,"2xl":672,"3xl":768,"4xl":896,"5xl":1024,"6xl":1152,"7xl":1280};function jt(r,e){let t=/^(min|max)-(w|h)-(.+)$/.exec(r);if(!t)return!1;let[,i,s,a]=t,c=a==="full"||a==="screen"?"100%":a==="none"?void 0:s==="w"&&i==="max"&&Ft[a]||ee(a);if(c===void 0&&a!=="none")return!1;let d=`${i}${s==="w"?"Width":"Height"}`;if(c===void 0)delete e[d];else e[d]=c;return!0}function Wt(r,e){let t=/^(-?)(top|right|bottom|left)-(.+)$/.exec(r);if(!t)return!1;let i=t[3]==="full"?"100%":_(t[3]);if(i===void 0)return!1;return e[t[2]]=typeof i==="number"&&t[1]?-i:i,!0}function Xt(r,e){let t=/^space-(x|y)-(.+)$/.exec(r);if(!t)return!1;let i=_(t[2]);if(i===void 0)return!1;return e.gap=i,!0}function zt(r,e){if(r.startsWith("gap-")){let t=_(r.slice(4));if(t!==void 0)return e.gap=t,!0}if(r.startsWith("gap-x-")){let t=_(r.slice(6));if(t!==void 0)return e.columnGap=t,!0}if(r.startsWith("gap-y-")){let t=_(r.slice(6));if(t!==void 0)return e.rowGap=t,!0}return!1}function Ut(r,e){let i={"shadow-none":[0,0,0,0],"shadow-xs":[1,1,0.05,1],"shadow-sm":[2,1,0.1,2],shadow:[3,2,0.12,3],"shadow-md":[6,4,0.15,4],"shadow-lg":[10,6,0.18,8],"shadow-xl":[16,10,0.2,12],"shadow-2xl":[24,16,0.25,18]}[r];if(!i)return!1;let[s,a,c,d]=i;return Object.assign(e,{shadowColor:"#000000",shadowOpacity:c,shadowRadius:s,shadowOffset:{width:0,height:a},elevation:d}),!0}function te(r){let e=[],t=[],i=[];function s(l,g){let h=/^(text|bg|border|ring)-([a-z-]+)(\/[^\s]+)?$/.exec(l),u=h&&Xn[h[2]];return u?`${h[1]}-${u[g]}${h[3]||""}`:l}for(let l of r.split(/\s+/).filter(Boolean))if(l.startsWith("dark:"))t.push(s(l.slice(5),"dark"));else if(!l.includes(":")||l.startsWith("[")){if(e.push(s(l,"light")),s(l,"dark")!==l)i.push(s(l,"dark"))}let a=[],d={style:Fe(e.join(" "),a),unknown:a};if(t.length||i.length)d.dark=Fe([...i,...t].join(" "),a);for(let l of e){if(l==="truncate")d.numberOfLines=1;let g=/^line-clamp-(\d+)$/.exec(l);if(g)d.numberOfLines=Number(g[1]);if(!d.icon&&/^i-[a-z0-9]+-[a-z0-9-]+$/.test(l))d.icon=l}return d.unknown=a.filter((l)=>!/^line-clamp-\d+$/.test(l)),d}function Fe(r,e){let t={},i=r.split(/\s+/).filter(Boolean);for(let s of i){if(/^i-[a-z0-9]+-/.test(s))continue;let a=kt[s];if(a){a("",t);continue}if(Ut(s,t))continue;if(Et(s,t))continue;if(Tt(s,t))continue;if(_t(s,t))continue;if(Rt(s,t))continue;if(It(s,t))continue;if(We(s,t))continue;if(Pt(s,t))continue;if(Ct(s,t))continue;if(Ot(s,t))continue;if(Bt(s,t))continue;if(Mt(s,t))continue;if(Dt(s,t))continue;if(zt(s,t))continue;if(Lt(s,t))continue;if(Vt(s,t))continue;if(jt(s,t))continue;if($t(s,t))continue;if(Wt(s,t))continue;if(Xt(s,t))continue;if(e?.push(s),typeof process<"u"&&process.env?.NODE_ENV==="development")console.warn(`[STX Native] Unknown Headwind class: ${s}`)}return t}function J(r,e={},t={},i={},s=[]){return{type:r,props:e,style:t,events:i,children:s}}function Xe(r,e,t={}){return{version:"1.0.0",root:r,script:e,meta:{source:t.source||"unknown",compiledAt:t.compiledAt||Date.now(),headwindConfig:t.headwindConfig}}}var ze=new Set(["script","style","head","meta","link","title","base","noscript"]),Ue=new Set(["template","body","html","main","fragment"]),ne=new Set,Ht=new Set(["onBlur","onChangeText","onDismiss","onEnd","onEndEditing","onEndReached","onError","onFocus","onLayout","onLoad","onLoadEnd","onLoadStart","onLongPress","onMomentumScrollBegin","onMomentumScrollEnd","onPause","onPictureInPictureStart","onPictureInPictureStop","onPlay","onPress","onPressIn","onPressOut","onProgress","onRequestClose","onRegionChangeComplete","onRefresh","onScroll","onScrollBeginDrag","onScrollEndDrag","onShow","onSlidingComplete","onSubmitEditing","onValueChange"]),we=new Set(["display","gridColumns","gridTemplateColumns","gridAutoRows","flex","flexGrow","flexShrink","flexBasis","flexDirection","flexWrap","justifyContent","alignItems","alignSelf","alignContent","position","top","right","bottom","left","zIndex","width","height","minWidth","maxWidth","minHeight","maxHeight","aspectRatio","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderStyle","backgroundColor","backgroundImage","opacity","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","color","fontSize","fontWeight","fontStyle","fontFamily","lineHeight","letterSpacing","textAlign","textDecorationLine","textDecorationColor","textTransform","resizeMode","tintColor","transform","overflow","fill","stroke","strokeWidth","gradientDirection","gradientFrom","gradientVia","gradientTo"]),qt=new Set(["gridColumns","gridAutoRows","flex","flexGrow","flexShrink","zIndex","aspectRatio","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","opacity","shadowOpacity","shadowRadius","elevation","fontSize","lineHeight","letterSpacing","strokeWidth"]),Gt=new Set(["top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical"]),He=new Set(["Sidebar","SplitView","View","ScrollView","SafeAreaView","KeyboardAvoidingView","Text","TextInput","Button","TouchableOpacity","TouchableHighlight","Pressable","Icon","Image","ImageBackground","Video","Map","MapPolyline","MapMarker","FlatList","SectionList","Switch","Checkbox","Slider","Picker","DatePicker","Modal","ActivityIndicator","StatusBar","RefreshControl",...pe]),Jt=new Map([["data","data"],["sections","sections"],["renderitem","renderItem"],["rendersectionheader","renderSectionHeader"],["keyextractor","keyExtractor"],["listrole","listRole"]]),qe=new Set(["View","SafeAreaView","ScrollView","KeyboardAvoidingView"]),Kt={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ","#39":"'","#x27":"'"};function Y(r){return r.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,t)=>{let i=Kt[t.toLowerCase()];if(i!==void 0)return i;if(t[0]==="#"){let s=t[1]==="x"||t[1]==="X"?Number.parseInt(t.slice(2),16):Number.parseInt(t.slice(1),10);return Number.isFinite(s)?String.fromCodePoint(s):e}return e})}function Ge(r){return r.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Je(r){let e=/^(-?[\d.]+)px$/.exec(r);if(e)return Number.parseFloat(e[1]);let t=/^(-?[\d.]+)r?em$/.exec(r);if(t)return Number.parseFloat(t[1])*16;if(/^-?[\d.]+$/.test(r))return Number.parseFloat(r);return r}function Ke(r,e,t){let i={},s={},a={},c="",d={};for(let[h,u]of e){let f=h.toLowerCase();if(f==="class"||f==="classname"){c=c?`${c} ${u}`:u;continue}if(f==="style"){d={...d,...Qt(r,u,t)};continue}if(f.startsWith(":")||f.startsWith("x-")&&f!=="x-cloak"){a[f.startsWith(":")?f.slice(1):f.slice(2)]=Y(u);continue}if(f==="x-cloak")continue;if(f.startsWith("@")||f.startsWith("v-on:")){let w=f.startsWith("@")?f.slice(1):f.slice(5),[p]=w.split("."),v=de[p]??(p.startsWith("on")?p:"");if(!v||!Ht.has(v)){t.push({kind:"unread-event",tag:r,name:h});continue}s[v]=Y(u);continue}if(f==="key"){i.key=u;continue}let y=Y(u),b=me(h);if(y===""&&De.has(b)){i[b]=!0;continue}try{i[b]=JSON.parse(y)}catch{i[b]=y}}let l=c?te(c):void 0;for(let h of new Set(l?.unknown??[]))t.push({kind:"unknown-class",tag:r,name:h});let g={...l?.style,...d};return{props:i,style:g,events:s,bindings:a,classes:c,inline:d}}function Yt(r,e){if(r==="shadowOffset"){if(!e||typeof e!=="object"||Array.isArray(e))return;let{width:t,height:i}=e;return typeof t==="number"&&typeof i==="number"?{width:t,height:i}:void 0}if(r==="transform"){if(!Array.isArray(e))return;let t=e.filter((i)=>Boolean(i)&&typeof i==="object"&&!Array.isArray(i)&&Object.keys(i).length===1).filter((i)=>["number","string"].includes(typeof Object.values(i)[0]));return t.length?t:void 0}return}function Ye(r,e){if(qt.has(r))return!1;if(Gt.has(r))return/^-?[\d.]+%$/.test(e);return!0}function Qt(r,e,t){let i={},s=Y(e);try{let a=JSON.parse(s);if(a&&typeof a==="object"&&!Array.isArray(a)){for(let[c,d]of Object.entries(a)){let l=we.has(c)?c:Ge(c.trim().toLowerCase());if(!we.has(l)){t.push({kind:"unknown-style",tag:r,name:l});continue}if(d===null||d===void 0)continue;let g=typeof d==="string"?Je(d):d;if(typeof g==="object"){let h=Yt(l,g);if(h===void 0)t.push({kind:"non-numeric-style",tag:r,name:l});else i[l]=h;continue}if(typeof g!=="string"&&typeof g!=="number")continue;if(typeof g==="string"&&!Ye(l,g)){t.push({kind:"non-numeric-style",tag:r,name:l});continue}i[l]=g}return i}}catch{}for(let a of s.split(";")){let c=a.indexOf(":");if(c===-1)continue;let d=Ge(a.slice(0,c).trim().toLowerCase()),l=a.slice(c+1).trim();if(!d||!l)continue;if(!we.has(d)){t.push({kind:"unknown-style",tag:r,name:d});continue}let g=Je(l);if(typeof g==="string"&&!Ye(d,g)){t.push({kind:"non-numeric-style",tag:r,name:d});continue}i[d]=g}return i}function Se(r){return r.children.map((e)=>typeof e==="string"?e:Se(e)).join("").replace(/\s+/g," ").trim()}function Zt(r,e){let t=r.node,i=t.children.filter((a)=>typeof a!=="string"),s=t.children.filter((a)=>typeof a==="string").join("").trim();if(t.type==="Svg"||t.type==="G")return t.children=i,t;if(t.type==="SvgText"){let a=Se(t);return t.children=a?[a]:[],t}if(qe.has(t.type)&&i.length===0&&s)return t.type="Text",t.children=[s],t;if(t.type==="Text"&&!s&&i.length===0&&typeof t.props.text==="string")return t.children=t.props.text?[t.props.text]:[],delete t.props.text,t;if(t.type==="Text"&&i.length>0){let a=Se(t);return e.push({kind:"flattened-text",tag:r.tag}),t.children=a?[a]:[],t}if(qe.has(t.type)&&i.length>0)t.children=i;return t}async function en(r,e={}){let t=[],i=[],s=[],a=new Set;function c(u){let f=s[s.length-1];if(!f)i.push(u);else if(!f.dropped)f.node.children.push(u)}function d(u){if(u.node.bindings&&Object.keys(u.node.bindings).length>0){let y=u.node.children,b=y.filter((p)=>typeof p!=="string"),w=b.length===1&&b.length===y.length?b[0]:J("View",{},{},{},y);if(w.bindings={...u.node.bindings,...w.bindings},w.bindingId===void 0&&u.node.bindingId!==void 0)w.bindingId=u.node.bindingId;c(w);return}let f=s[s.length-1];for(let y of u.node.children){if(typeof y==="string"){if(f&&!f.dropped)f.node.children.push(y);continue}if(!f)i.push(y);else if(!f.dropped)f.node.children.push(y)}}function l(u,f){let y=s[s.length-1];if(u==="svg"||y?.svg)return g(u,f,y);let b=ze.has(u)&&!ne.has(u),w=s[s.length-1]?.dropped??!1,{props:p,style:v,events:R,bindings:I,classes:m,inline:N}=b||w?{props:{},style:{},events:{},bindings:{},classes:"",inline:{}}:Ke(u,f,t),k=p["data-native"],x;if(typeof k==="string"&&He.has(k))x=k,delete p["data-native"];else x=ne.has(u)?"View":$e(u);if(x===u&&!He.has(x)&&!ze.has(u)&&!Ue.has(u)&&!a.has(u))a.add(u),t.push({kind:"unmapped-tag",tag:u});if((b||ne.has(u))&&!a.has(`drop:${u}`))a.add(`drop:${u}`),t.push({kind:"dropped-subtree",tag:u});if(x==="Video"&&p.source===void 0&&p.src!==void 0)p.source=p.src,delete p.src;if(x==="Icon"){let A=te(m).icon,V=ye(String(p.symbol||p.name||A||""),Boolean(p.symbol));if(p.symbol=V.symbol,V.iconify)p.iconify=V.iconify}if(x==="FlatList"||x==="SectionList"){let A=new Set([...Object.keys(p),...Object.keys(I)].map((V)=>V.toLowerCase()));for(let[V,L]of Jt)if(A.has(V))t.push({kind:"unsupported-list-prop",tag:x,name:L})}let S=J(x,p,v,R);S._inlineStyle=N;let T=p["data-stx-b"];if(typeof T==="number"&&Number.isInteger(T))S.bindingId=T;if(delete p["data-stx-b"],m)S._classes=m;if(Object.keys(I).length>0)S.bindings=I;if(typeof p.key==="string")S.key=p.key,delete p.key;return{tag:u,node:S,dropped:b||w||ne.has(u),discard:b||w,unwrap:Ue.has(u)}}function g(u,f,y){let b=y?.dropped??!1,w=fe[u];if(b||!w){if(!b&&!a.has(`drop:${u}`))a.add(`drop:${u}`),t.push({kind:Be.has(u)?"dropped-subtree":"unmapped-tag",tag:u});return{tag:u,node:J("G",{},{},{}),svg:!0,dropped:!0,discard:!0,unwrap:!1}}let{props:p,style:v,events:R,bindings:I,classes:m,inline:N}=Ke(u,f,t);if(w==="Svg"){let T=ge(p.viewBox);if(T)p.viewBox=T;else delete p.viewBox;for(let A of["width","height"]){if(typeof p[A]==="number"&&v[A]===void 0)v[A]=p[A];delete p[A]}}if(typeof p.strokeDasharray==="string"||typeof p.strokeDasharray==="number"){let T=String(p.strokeDasharray).split(/[\s,]+/).map(Number).filter(Number.isFinite);p.strokeDasharray=T}let k=he(w,p);if(k)p.geometry=k;let x=J(w,p,v,R);x._inlineStyle=N;let S=p["data-stx-b"];if(typeof S==="number"&&Number.isInteger(S))x.bindingId=S;if(delete p["data-stx-b"],m)x._classes=m;if(Object.keys(I).length>0)x.bindings=I;if(typeof p.key==="string")x.key=p.key,delete p.key;return{tag:u,node:x,svg:!0,dropped:!1,discard:!1,unwrap:!1}}if(await new HTMLRewriter().on("*",{element(u){let f=u.tagName.toLowerCase(),y=l(f,[...u.attributes]),b=!0;try{u.onEndTag(()=>{if(s.pop(),y.discard)return;if(y.unwrap)d(y);else c(Zt(y,t))})}catch{b=!1}if(b)s.push(y);else if(!y.discard)c(y.node)},text(u){let f=s[s.length-1];if(!f||f.dropped)return;let y=Y(u.text).replace(/\s+/g," ");if(!y.trim())return;f.node.children.push(y)}}).transform(new Response(r)).text(),i.length===0)throw Error(`No element to translate in the rendered output of ${e.source??"unknown"}`);return{root:i.length===1?i[0]:J("View",{},{},{},i),diagnostics:t}}async function Qe(r,e={}){let{root:t,diagnostics:i}=await en(r,e),s=e.script??{exports:{},functions:[],code:""};return{document:Xe(t,s,{source:e.source??"unknown"}),diagnostics:i}}var Ze=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,tn=/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([$\w]+)\s*\(/g,nn=/(?:^|\n)\s*(?:export\s+)?(?:const|let|var)\s+([$\w]+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[$\w]+)\s*=>/g,et=/(?:^|\n)\s*(?:export\s+)?const\s+([$\w]+)\s*=\s*(-?[\d.]+|true|false|'[^']*'|"[^"]*")\s*(?=;|\n|$)/g;function ve(r){let e=[];Ze.lastIndex=0;for(let a of r.matchAll(Ze)){let c=a[1]??"";if(/\bserver\b/.test(c))continue;e.push(a[2].trim())}let t=e.filter(Boolean).join(`
3
+
4
+ `),i=[];for(let a of[tn,nn]){a.lastIndex=0;for(let c of t.matchAll(a))if(!i.includes(c[1]))i.push(c[1])}let s={};et.lastIndex=0;for(let a of t.matchAll(et)){let c=a[2];try{s[a[1]]=JSON.parse(c.replace(/^'(.*)'$/,'"$1"'))}catch{s[a[1]]=c}}return{exports:s,functions:i,code:t}}var re=/<script\b([^>]*\bdata-stx-scoped\b[^>]*)>([\s\S]*?)<\/script>/gi,tt=/function\s+(__stx_setup_[\w$]+)\s*\(/,rn=/\bdata-stx-owner\s*=\s*["']([^"']+)["']/i;function xe(r){re.lastIndex=0;for(let e of r.matchAll(re)){let t=e[2].trim(),i=tt.exec(t)?.[1];if(i)return{name:i,code:t}}return null}function nt(r){let e=[];re.lastIndex=0;for(let t of r.matchAll(re)){let i=t[1],s=t[2].trim(),a=rn.exec(i)?.[1],c=/\bdata-stx-component-factories\b/i.test(i);if(!s||!a&&!c&&!tt.test(s))continue;e.push(a?{code:s,owner:a}:{code:s})}return e}function on(){let r=[Q.join(import.meta.dir,"..","primitives"),Q.join(import.meta.dir,"native","primitives")];for(let e of r)if(sn(Q.join(e,"View.stx")))return e;return r[0]}async function an(r,e,t={}){let i=t.root??Q.dirname(e),s=await o(i),a={root:i,componentsDir:t.componentsDir??Q.join(i,"components"),buildMode:"serve",cache:!1,_targetComponentDirs:[on()],_pluginComponentDirs:s._pluginComponentDirs??[]},c={...t.context??{},__stx_inject_css:!1},d=new Set([e]),l=await n(r,c,e,a,d),{html:g,manifest:h}=Pe(l),{document:u,diagnostics:f}=await Qe(g,{source:e,script:ve(r)}),y=xe(g),b=nt(g);if(ve(r).code.trim()){let w=await Qn(r,e,t.context,{forceClientSetup:!0}),p=xe(w.setupCode??"");if(y=p??y,p&&!b.some((v)=>v.code===p.code))b.push({code:p.code})}return{document:u,manifest:h,setup:y,scripts:b,diagnostics:f,html:g,dependencies:[...d]}}async function ie(r,e={}){return an(await Bun.file(r).text(),r,e)}var Z="__app";var se="__runtime",ln="__messages";function ke(r){let t=[O.join(import.meta.dir,"..","runtime",`${r}.ts`),O.join(import.meta.dir,"..","runtime",`${r}.js`),O.join(import.meta.dir,"native","runtime",`${r}.js`)].find((i)=>Re(i));if(!t)throw Error(`Native runtime module ${r} is missing`);return t}async function Te(r,e,t,i,s){let a={name:"stx-screen-inputs",setup(d){d.onLoad({filter:/.*/,namespace:"file"},({path:l})=>{i.add(l);let g=s?.get(l);return g===void 0?void 0:{contents:g,loader:"js"}})}},c=await Bun.build({entrypoints:[r],target:"browser",format:"iife",minify:t,plugins:[a,...e],define:{"process.env.NODE_ENV":JSON.stringify(t?"production":"development")}});if(!c.success){let d=c.logs.map((l)=>String(l.message??l)).join(`
5
+ `);throw Error(`Could not bundle ${r}:
6
+ ${d}`)}return(await c.outputs[0].text()).trim()}var dn=/^[\w-]+(?:\/[\w-]+)*$/,un=/^[\w-]+$/;async function fn(r,e){let t=O.resolve(r,e.dir);if(!e.languages?.length)throw Error("messages.languages must name at least one language");let i=new Map,s=new Map;for(let a of e.languages){if(!un.test(a))throw Error(`messages: "${a}" is not a language directory name`);let c=O.join(t,a);if(!Re(c))throw Error(`messages: ${O.relative(r,c)} does not exist`);let d=new Map;for(let l of[...new Bun.Glob("**/*.{ts,js,mjs,json}").scanSync({cwd:c})].sort()){if(/\.(?:test|spec|d)\.[^.]+$/.test(l))continue;let g=l.replace(/\.[^./]+$/,"").split(O.sep).join("/");if(!dn.test(g))throw Error(`messages: ${a}/${l} is not an area name`);if(d.has(g))throw Error(`messages: ${a}/${g} is defined twice`);let h=O.join(c,l),u=await import(h),f=Object.keys(u).filter((w)=>w!=="default");if(f.length)throw Error(`messages: ${a}/${l} exports ${f.join(", ")}; a message module exports its messages as default, and nothing else`);let y=u.default,b=y!==null&&typeof y==="object"&&!Array.isArray(y)?JSON.stringify(y):void 0;if(b===void 0||!Bun.deepEquals(JSON.parse(b),y,!0))throw Error(`messages: ${a}/${l} must export plain data (an object JSON can hold) as default`);d.set(g,b),i.set(h,{language:a,area:g})}s.set(a,d)}return{files:i,data:s}}function pn(r,e){return`export default globalThis.__stxNativeRuntime.messages(${JSON.stringify(r)}, ${JSON.stringify(e)});`}function gn(r){let e=new Map;for(let[t,{language:i,area:s}]of r.files){let a=pn(i,s);e.set(t,a),e.set(cn(t),a)}return e}function hn(r){let e=new Set;for(let t of r.matchAll(/__stxNativeRuntime\.messages\(\s*"[\w-]+"\s*,\s*"([\w/-]+)"\s*\)/g))e.add(t[1]);return[...e].sort()}function mn(r){return{...r,script:{exports:r.script.exports,functions:[],code:""}}}async function Ae(r){let e=Object.keys(r.screens);if(e.length===0)throw Error("screens must name at least one .stx file");let t=r.routed??!0,i=r.initialScreen??e[0];if(!r.screens[i])throw Error(`Initial screen ${i} is not in screens`);let s=O.resolve(r.root??process.cwd());if(r.messages&&!r.routesDir)throw Error("messages ship a language at a time beside route files: they need routesDir");if(r.sharedRuntime&&!r.routesDir)throw Error("sharedRuntime is the route files' runtime: it needs routesDir");if(r.messages&&!r.sharedRuntime)throw Error("messages are read by the shared runtime: they need sharedRuntime");if(r.messages&&r.outFile)throw Error("messages leave the languages out of the screens' code, which the one-file bundle cannot read: build it without messages");let a=r.messages?await fn(s,r.messages):null,c=a?gn(a):null,d=[],l=async()=>{for(let S of e){let T=O.resolve(s,r.screens[S]);if(!T.endsWith(".stx"))throw Error(`Screen ${S} must name a .stx file`);d.push({name:S,file:T,compiled:await ie(T,{root:s})})}};if(c)await Qr(c,l);else await l();let g=ke("jsc-globals"),h=ke("shared-screen"),u=r.app?O.resolve(s,r.app):null;if(u&&!Re(u))throw Error(`The app script ${r.app} does not exist`);if(u&&!t)throw Error("An app script needs a routed bundle");if(u&&r.screens[Z])throw Error(`${Z} is the app script's route, not a screen name`);let f=r.browser;if(r.screens[se])throw Error(`${se} is the runtime prelude's file, not a screen name`);let y=Ne();if(f&&r.routesDir)throw Error("A browser screen is one route; routesDir is for device hosts");let b=(S,T,A)=>{let V=t?`var routeName = g.__stxNativeRoute || ${JSON.stringify(i)};
7
+ var isApp = ${u?`routeName === ${JSON.stringify(Z)}`:"false"};
8
+ if (!isApp && routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));
9
+ if (isApp ? ${!T} : ${JSON.stringify(S.map(({name:F})=>F))}.indexOf(routeName) === -1) throw new Error(['This bundle does not hold the native screen', routeName].join(' '));`:`var routeName = 'main';
10
+ var isApp = false;`,L=S.map(({name:F,compiled:P},M)=>`${M===0?"if":"else if"} (routeName === ${JSON.stringify(t?F:"main")}) {
11
+ nativeDocument = ${JSON.stringify(mn(P.document))};
12
+ manifest = ${JSON.stringify(P.manifest)};
13
+ }`).join(`
14
+ `),W=S.map(({name:F,compiled:P},M)=>`${M===0?"if":"else if"} (routeName === ${JSON.stringify(t?F:"main")}) {
15
+ g.__stx_latestSetup = null;
16
+ ${P.scripts.map((D)=>D.owner?` g.__STX_SETUP_ROOT__ = screen && screen.scopeRoot(${JSON.stringify(D.owner)});
17
+ try {
18
+ ${D.code}
19
+ }
20
+ finally { g.__STX_SETUP_ROOT__ = null; }`:D.code).join(`
21
+ `)}
22
+ }`).join(`
23
+ `),H=T&&u,E=f?ke("browser-screen"):null,B=f?Bun.resolveSync(f.platformModule,s):null;return`
24
+ ${A?`var runtime = globalThis.__stxNativeRuntime;
25
+ if (!runtime || runtime.version !== ${JSON.stringify(A)}) throw new Error('This screen needs the stx native runtime it was built with: evaluate ${se}.js from the same build first');
26
+ var installJSCGlobals = runtime.installJSCGlobals;
27
+ var prepareNativeApp = runtime.prepareNativeApp;
28
+ var prepareSharedNativeScreen = runtime.prepareSharedNativeScreen;`:`import { installJSCGlobals } from ${JSON.stringify(g)};
29
+ import { prepareNativeApp, prepareSharedNativeScreen } from ${JSON.stringify(h)};`}
30
+ ${f?`import { createBrowserScreenBridge } from ${JSON.stringify(E)};
31
+ import { createBrowserPlatform } from ${JSON.stringify(B)};`:""}
32
+ ${H?`import * as nativeAppModule from ${JSON.stringify(u)};`:"var nativeAppModule = null;"}
33
+ ${f?"(async function() {":""}
34
+ var g = globalThis;
35
+ installJSCGlobals(g);
36
+ ${f?`var browserPlatform = await createBrowserPlatform(${JSON.stringify(f.platformOptions??{})});
37
+ var browserBridge = createBrowserScreenBridge(browserPlatform, ${JSON.stringify(f)});
38
+ var bridge = browserBridge;
39
+ g.__stxNativeRoute = ${JSON.stringify(i)};`:"var bridge = g.__stxNativeBridge;"}
40
+ if (!bridge) throw new Error('Missing __stxNativeBridge');
41
+ var routeNames = ${JSON.stringify(t?e:["main"])};
42
+ ${V}
43
+ g.__stxNativeRoute = routeName;
44
+ var nativeDocument;
45
+ var manifest;
46
+ ${L}
47
+ var screen = null;
48
+ var app = null;
49
+ if (isApp) {
50
+ app = prepareNativeApp(bridge, { routeName: routeName, routeNames: routeNames });
51
+ g.__stxNativeUnmount = function() { app.unmount(); };
52
+ }
53
+ else {
54
+ screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
55
+ g.__stx_host = screen.host;
56
+ g.__stxNativeUnmount = function() { screen.unmount(); };
57
+ }
58
+ ${A?"runtime.startSignals();":y}
59
+ var pageSetup = g.__stx_latestSetup;
60
+ var pageRuntimeSetup = g.stx && g.stx._latestSetup;
61
+ ${W}
62
+ // The screen's setup is the native host's to run. A screen script publishes
63
+ // it where a page's document runtime adopts its own, and in a browser that
64
+ // runtime's DOMContentLoaded and stx:load ran it a second time: another copy
65
+ // of the screen, mounted beside this one. Take it, and hand the page back
66
+ // whatever setup it had.
67
+ var screenSetup = g.__stx_latestSetup || null;
68
+ g.__stx_latestSetup = pageSetup;
69
+ if (g.stx) g.stx._latestSetup = pageRuntimeSetup || null;
70
+ if (isApp) app.start(nativeAppModule);
71
+ else screen.mount(g.stx, screenSetup);
72
+ ${f?`var stopApp = nativeAppModule && typeof nativeAppModule.default === 'function' ? nativeAppModule.default(g.craft) : null;
73
+ var unmount = g.__stxNativeUnmount;
74
+ var ended = false;
75
+ g.__stxNativeUnmount = function() { if (ended) return; ended = true; if (typeof stopApp === 'function') stopApp(); unmount(); browserBridge.dispose(); };
76
+ g.addEventListener('pagehide', function(event) { if (!event.persisted) g.__stxNativeUnmount(); });
77
+ })().catch(function(error) { console.error('[stx browser screen]', error); var node = document.querySelector(${JSON.stringify(f.container)}); if (node) { node.textContent = 'This screen could not start. Reload to try again.'; node.setAttribute('role', 'alert'); } });`:""}
78
+ `},w=(S)=>({name:"stx-native-shared-screens",setup(T){T.onResolve({filter:/^stx:native-shared-screens$/},()=>({path:"entry",namespace:"stx-native-shared-screens"})),T.onLoad({filter:/.*/,namespace:"stx-native-shared-screens"},()=>({contents:S,loader:"js"}))}}),p=new Set(d.flatMap(({compiled:S})=>S.dependencies)),v=d.flatMap(({compiled:S})=>S.diagnostics).map((S)=>({level:"warning",message:[S.kind,S.tag,S.name].filter(Boolean).join(": ")})),R=r.minify??!1,I,m,N;if(r.routesDir){let S=O.resolve(s,r.routesDir);rt(S,{recursive:!0});let T=`
79
+ import { installJSCGlobals } from ${JSON.stringify(g)};
80
+ import { prepareNativeApp, prepareSharedNativeScreen } from ${JSON.stringify(h)};
81
+ globalThis.__stxNativeRuntime = {
82
+ version: '__STX_NATIVE_RUNTIME_VERSION__',
83
+ installJSCGlobals: installJSCGlobals,
84
+ prepareNativeApp: prepareNativeApp,
85
+ prepareSharedNativeScreen: prepareSharedNativeScreen,
86
+ // Each screen starts its own signals runtime, after its host is in place.
87
+ startSignals: function() {
88
+ ${y}
89
+ },
90
+ // A language's messages for an area (the compile's \`messages\`), read the
91
+ // first time they are looked into: a screen never parses a language it
92
+ // is not shown in, nor an area it does not use.
93
+ messages: function(language, area) {
94
+ var g = globalThis;
95
+ var loaded = g.__stxNativeMessages || (g.__stxNativeMessages = {});
96
+ function table() {
97
+ var forLanguage = loaded[language] || (loaded[language] = {});
98
+ if (Object.prototype.hasOwnProperty.call(forLanguage, area)) return forLanguage[area];
99
+ var value = null;
100
+ if (typeof g.__stxNativeReadMessages === 'function') {
101
+ try {
102
+ var text = g.__stxNativeReadMessages(language, area);
103
+ if (typeof text === 'string') value = JSON.parse(text);
104
+ }
105
+ catch (error) { console.error('[stx native] could not read the ' + language + ' messages for ' + area, error); }
106
+ }
107
+ forLanguage[area] = value;
108
+ return value;
109
+ }
110
+ var own = Object.prototype.hasOwnProperty;
111
+ return new Proxy({}, {
112
+ get: function(target, name) { var messages = table(); return messages && own.call(messages, name) ? messages[name] : undefined; },
113
+ has: function(target, name) { var messages = table(); return !!messages && own.call(messages, name); },
114
+ ownKeys: function() { var messages = table(); return messages ? Object.keys(messages) : []; },
115
+ getOwnPropertyDescriptor: function(target, name) {
116
+ var messages = table();
117
+ return messages && own.call(messages, name) ? { value: messages[name], writable: false, enumerable: true, configurable: true } : undefined;
118
+ },
119
+ });
120
+ },
121
+ };
122
+ `,A,V=O.join(S,`${se}.js`);if(r.sharedRuntime){let E=await Te("stx:native-shared-screens",[w(T)],R,p);A=Bun.hash(E).toString(36),m=V,await Bun.write(m,E.replace("__STX_NATIVE_RUNTIME_VERSION__",A))}else it(V,{force:!0});let L=O.join(S,ln);it(L,{recursive:!0,force:!0});let W={},H=[...d.map((E)=>({name:E.name,screens:[E],app:!1})),...u?[{name:Z,screens:[],app:!0}]:[]];I={};for(let E=0;E<H.length;E+=6)await Promise.all(H.slice(E,E+6).map(async(B)=>{let z=O.join(S,`${B.name}.js`),U=await Te("stx:native-shared-screens",[w(b(B.screens,B.app,A))],R,p,c??void 0);if(await Bun.write(z,U),I[B.name]=z,a)W[B.name]=hn(U)}));if(a){for(let[B,z]of a.data)for(let[U,F]of z)await Bun.write(O.join(L,B,`${U}.json`),F);let E=Object.fromEntries(Object.keys(W).sort().map((B)=>[B,W[B]]));await Bun.write(O.join(L,"routes.json"),JSON.stringify(E));for(let B of a.files.keys())p.add(B);N={dir:L,languages:[...a.data.keys()],routes:E}}if(!r.outFile)return{code:"",routes:I,runtime:m,...N?{messages:N}:{},diagnostics:v,dependencies:[...p]}}let k=await Te("stx:native-shared-screens",[w(b(d,!0))],R,p);if(!r.outFile)return{code:k,diagnostics:v,dependencies:[...p]};let x=O.resolve(s,r.outFile);return rt(O.dirname(x),{recursive:!0}),await Bun.write(x,k),{code:k,outFile:x,...I?{routes:I,runtime:m}:{},...N?{messages:N}:{},diagnostics:v,dependencies:[...p]}}async function yn(r,e={}){return Ae({...e,screens:{main:r},routed:!1})}function st(r,e={}){return yn(r,e)}var ot=["native.config.json","stx-native.config.json"];function Sn(r=process.cwd(),e){let t=e?j.resolve(r,e):ot.map((l)=>j.join(r,l)).find((l)=>oe(l));if(!t)return null;if(!oe(t))throw Error(`Native config not found: ${t}`);let i=JSON.parse(wn(t,"utf8")),s=Object.entries(i.screens??{});if(s.length===0)throw Error(`${j.basename(t)} must name at least one screen in "screens"`);let a={};for(let[l,g]of s){if(!/^[A-Z][\w-]*$/i.test(l))throw Error(`Invalid native screen name: ${l}`);if(typeof g!=="string"||!g.endsWith(".stx"))throw Error(`Screen ${l} must name a .stx file`);if(a[l]=j.resolve(j.dirname(t),g),!oe(a[l]))throw Error(`Screen ${l} not found: ${a[l]}`)}let c=i.initialScreen||s[0][0];if(!a[c])throw Error(`Initial screen ${c} is not in screens`);if(i.app!==void 0&&typeof i.app!=="string")throw Error(`"app" must name the app script's file`);let d=i.app?j.resolve(j.dirname(t),i.app):void 0;if(d&&!oe(d))throw Error(`App script not found: ${d}`);return{initialScreen:c,screens:a,file:t,...d?{app:d}:{}}}async function Xr(r,e={}){let t=j.resolve(e.cwd??process.cwd()),i=e.format??"ir";if(i!=="ir"&&i!=="bundle")throw Error(`Unknown compile format: ${i}. Expected ir or bundle.`);let s=r?null:Sn(t,e.config);if(!r&&!s)throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${ot[0]}`);let a,c=[];if(i==="bundle"){let l=s?await Ae({screens:s.screens,initialScreen:s.initialScreen,minify:e.minify,root:t,...s.app?{app:s.app}:{}}):await st(j.resolve(t,r),{minify:e.minify});a=l.code,c=l.diagnostics}else{let l=async(h)=>{let u=await ie(h);return c.push(...u.diagnostics.map((f)=>({level:"warning",message:[f.kind,f.tag,f.name].filter(Boolean).join(": ")}))),u.document},g=s?{initialScreen:s.initialScreen,screens:Object.fromEntries(await Promise.all(Object.entries(s.screens).map(async([h,u])=>[h,await l(u)])))}:await l(j.resolve(t,r));a=JSON.stringify(g,null,2)}if(!e.output)return{output:a,diagnostics:c};let d=j.resolve(t,e.output);return bn(j.dirname(d),{recursive:!0}),await Bun.write(d,a),{output:a,written:d,diagnostics:c}}export{Xr as runNativeCompile};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Re,Ae,Pe}from"./chunk-30acme5g.js";import"./chunk-haeb904b.js";import"./chunk-4xvbc0mb.js";import{d}from"./chunk-34fajf1n.js";import"./chunk-qfb34r6k.js";import"./chunk-7hr63cp5.js";import"./chunk-h72befy4.js";import"./chunk-tybk9hw9.js";import"./chunk-x5xwe5nr.js";import"./chunk-550q827h.js";import"./chunk-vde4mtfr.js";import"./chunk-1wkpxa58.js";import"./chunk-1edvsndv.js";import{lt,xr,dt,Js,$e,Ys,Sr,ut,Qs,pt}from"./chunk-7a0ewpz0.js";import"./chunk-7j9m4d7x.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Ys("Config file changed, restarting...");try{await e.onChange()}catch(l){$e(`Failed to restart: ${l}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{Re,Ae,Pe}from"./chunk-30acme5g.js";import"./chunk-zk2xk0wd.js";import"./chunk-vpdx7qr3.js";import{d}from"./chunk-faghmmrs.js";import"./chunk-7hkc96de.js";import"./chunk-ah9xyss2.js";import"./chunk-yhpyqsbr.js";import"./chunk-43h8q2cm.js";import"./chunk-ayy9mmrw.js";import"./chunk-jtbzmbzz.js";import"./chunk-be2ba3hj.js";import"./chunk-eww6sdzz.js";import"./chunk-qdyp2zqf.js";import{lt,Sr,dt,Zs,$e,Qs,kr,ut,to,pt}from"./chunk-101ekf6y.js";import"./chunk-cdgwkzms.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Qs("Config file changed, restarting...");try{await e.onChange()}catch(l){$e(`Failed to restart: ${l}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,9 +556,9 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:p}=await import("./chunk-6ryab0yy.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await d(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-6ryab0yy.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:p}=await import("./chunk-sy1bk1ry.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await d(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-sy1bk1ry.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
- `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await ut(t);Ae(t,r);let s=pt(t.config,r);Pe(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=Qs(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await ut(t);Ae(t,u);let f=pt(t.config,u);if(Pe(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
561
+ `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await ut(t);Ae(t,r);let s=pt(t.config,r);Pe(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=to(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await ut(t);Ae(t,u);let f=pt(t.config,u);if(Pe(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
563
563
  <head>
564
564
  <meta charset="UTF-8">
@@ -1276,5 +1276,5 @@ else {
1276
1276
  <style>${W()}</style>
1277
1277
  ${D()}
1278
1278
  </body>
1279
- </html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){lt();let e=await Re({mode:"dev"});if(!e.config.enabled){$e("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),dt(e.storyFiles.length),xr(s.url),Sr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Re({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
1280
- `),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":Sr();break;case"o":try{let{exec:l}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";l(`${g} ${s.url}`)}catch{Js("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),lt(),dt(e.storyFiles.length),xr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
1279
+ </html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function he(t={}){lt();let e=await Re({mode:"dev"});if(!e.config.enabled){$e("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),dt(e.storyFiles.length),Sr(s.url),kr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Re({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
1280
+ `),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":kr();break;case"o":try{let{exec:l}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";l(`${g} ${s.url}`)}catch{Zs("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),lt(),dt(e.storyFiles.length),Sr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ao,Ua,Jt,Ul,Va,Wa,qa,Vl}from"./chunk-nrfh7gaa.js";export{Jt as Validator,Ua as defineForm,Va as processErrorDirective,Wa as processErrorsDirective,Vl as processFormValidationDirectives,qa as processHasErrorsDirective,Ao as useForm,Ul as v};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Re,Ae,Pe}from"./chunk-30acme5g.js";import{lt,dt,$e,Zs,ut,pt}from"./chunk-7a0ewpz0.js";import o from"fs";import i from"path";var c=[];function m(a){c=[];for(let e of a.storyFiles)if(c.push({text:e.fileName.toLowerCase(),original:e.fileName,type:"story",storyId:e.id}),c.push({text:e.relativePath.toLowerCase(),original:e.relativePath,type:"story",storyId:e.id}),e.story)for(let t of e.story.variants)c.push({text:t.title.toLowerCase(),original:t.title,type:"story",storyId:e.id,variantId:t.id})}function f(){return JSON.stringify(c)}async function F(a={}){let e=Date.now();lt();let t=await Re({mode:"build"});if(!t.config.enabled){$e("Story feature is disabled in config.");return}let n=await ut(t);Ae(t,n);let l=pt(t.config,n);Pe(t,l),dt(n.length);let d=a.outDir??t.config.outDir,s=i.resolve(t.root,d);await o.promises.mkdir(s,{recursive:!0}),console.log(` Building to ${d}...`);let g=v(t);await o.promises.writeFile(i.join(s,"index.html"),g);let y={files:n.map((r)=>({id:r.id,fileName:r.fileName,relativePath:r.relativePath,treePath:r.treePath})),tree:l};await o.promises.writeFile(i.join(s,"stories.json"),JSON.stringify(y,null,2));let u={theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets};await o.promises.writeFile(i.join(s,"config.json"),JSON.stringify(u,null,2));let p=i.join(s,"stories");await o.promises.mkdir(p,{recursive:!0});for(let r of n){let b=await o.promises.readFile(r.path,"utf-8");await o.promises.writeFile(i.join(p,`${r.id}.stx`),b)}m(t);let h=f();await o.promises.writeFile(i.join(s,"search-index.json"),h);let x=Date.now()-e;Zs(n.length,d,x)}function v(a){let{theme:e}=a.config,t=e.title||"STX Story";return`<!DOCTYPE html>
2
+ import{Re,Ae,Pe}from"./chunk-30acme5g.js";import{lt,dt,$e,eo,ut,pt}from"./chunk-101ekf6y.js";import o from"fs";import i from"path";var c=[];function m(a){c=[];for(let e of a.storyFiles)if(c.push({text:e.fileName.toLowerCase(),original:e.fileName,type:"story",storyId:e.id}),c.push({text:e.relativePath.toLowerCase(),original:e.relativePath,type:"story",storyId:e.id}),e.story)for(let t of e.story.variants)c.push({text:t.title.toLowerCase(),original:t.title,type:"story",storyId:e.id,variantId:t.id})}function f(){return JSON.stringify(c)}async function F(a={}){let e=Date.now();lt();let t=await Re({mode:"build"});if(!t.config.enabled){$e("Story feature is disabled in config.");return}let n=await ut(t);Ae(t,n);let l=pt(t.config,n);Pe(t,l),dt(n.length);let d=a.outDir??t.config.outDir,s=i.resolve(t.root,d);await o.promises.mkdir(s,{recursive:!0}),console.log(` Building to ${d}...`);let g=v(t);await o.promises.writeFile(i.join(s,"index.html"),g);let y={files:n.map((r)=>({id:r.id,fileName:r.fileName,relativePath:r.relativePath,treePath:r.treePath})),tree:l};await o.promises.writeFile(i.join(s,"stories.json"),JSON.stringify(y,null,2));let u={theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets};await o.promises.writeFile(i.join(s,"config.json"),JSON.stringify(u,null,2));let p=i.join(s,"stories");await o.promises.mkdir(p,{recursive:!0});for(let r of n){let b=await o.promises.readFile(r.path,"utf-8");await o.promises.writeFile(i.join(p,`${r.id}.stx`),b)}m(t);let h=f();await o.promises.writeFile(i.join(s,"search-index.json"),h);let x=Date.now()-e;eo(n.length,d,x)}function v(a){let{theme:e}=a.config,t=e.title||"STX Story";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -159,7 +159,7 @@ else {
159
159
  stxIslands.initIslands();
160
160
  }
161
161
  })();
162
- </script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function Pa(){let e=new Map;return{islands:e,register(t){e.set(t.id,t)},get(t){return e.get(t)},async hydrate(t){let n=e.get(t);if(!n||n.hydrated)return;if(n.hydrated=!0,typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hydrate",{detail:{id:t,component:n.component}}))},async hydrateAll(){let t=Array.from(e.values()).filter((n)=>!n.hydrated).map((n)=>this.hydrate(n.id));await Promise.all(t)}}}function I(e){return`
162
+ </script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function Oa(){let e=new Map;return{islands:e,register(t){e.set(t.id,t)},get(t){return e.get(t)},async hydrate(t){let n=e.get(t);if(!n||n.hydrated)return;if(n.hydrated=!0,typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hydrate",{detail:{id:t,component:n.component}}))},async hydrateAll(){let t=Array.from(e.values()).filter((n)=>!n.hydrated).map((n)=>this.hydrate(n.id));await Promise.all(t)}}}function I(e){return`
163
163
  <script data-hydrate="${e}">
164
164
  (function() {
165
165
  const island = document.querySelector('[data-island="${e}"]');
@@ -311,7 +311,7 @@ else {
311
311
  });
312
312
  })();
313
313
  </script>
314
- `}function Ia(e,t={},n){let r=e,i=!1,d=/@client:(load|idle|visible|media|only|hover|event)/i.test(e);if(r=u(r,"load",t),r=u(r,"idle",t),r=u(r,"visible",t),r=u(r,"media",t),r=M(r),r=u(r,"hover",t),r=u(r,"event",t),i=d&&r!==e,i)r+=`
314
+ `}function Da(e,t={},n){let r=e,i=!1,d=/@client:(load|idle|visible|media|only|hover|event)/i.test(e);if(r=u(r,"load",t),r=u(r,"idle",t),r=u(r,"visible",t),r=u(r,"media",t),r=M(r),r=u(r,"hover",t),r=u(r,"event",t),i=d&&r!==e,i)r+=`
315
315
  `+v();return r}function u(e,t,n){let r=new RegExp(`@client:${t}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return e.replace(r,(i,d,o)=>{let a={strategy:t};if(d)try{let E=d.split(",").map((h)=>h.trim());for(let h of E){let[m,g]=h.split(":").map((p)=>p.trim());if(m&&g){let p=g.replace(/^['"]|['"]$/g,"");a[m]=p}}}catch{}let s=`island-${Math.random().toString(36).substring(2,9)}`,y=b(o.trim()),f=w(o.trim(),n),c=[];if(a.rootMargin)c.push(`data-root-margin="${a.rootMargin}"`);if(a.threshold!==void 0)c.push(`data-threshold="${a.threshold}"`);if(a.media)c.push(`data-media="${a.media}"`);if(a.event)c.push(`data-event="${a.event}"`);if(y)c.push(`data-component="${y}"`);let x=Object.keys(f).length>0?`
316
316
  <script type="application/json" data-island-props="${s}">${JSON.stringify(f)}</script>`:"",l="";switch(t){case"load":l=I(s);break;case"idle":l=L(s,a);break;case"visible":l=C(s,a);break;case"media":l=S(s,a);break;case"hover":l=k(s);break;case"event":l=H(s,a);break}return`
317
317
  <div data-island="${s}"
@@ -342,7 +342,7 @@ else {
342
342
  }
343
343
  })();
344
344
  </script>
345
- `})}function Oa(){return`
345
+ `})}function Ma(){return`
346
346
  /* Island base styles */
347
347
  .stx-island {
348
348
  display: contents;
@@ -383,9 +383,9 @@ else {
383
383
  .stx-island.hydrated {
384
384
  opacity: 1;
385
385
  }
386
- `}function Da(e){if(typeof window>"u")return;let t=document.querySelector(`[data-island="${e}"]`);if(!t||t.classList.contains("hydrated"))return;t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))}function Ma(e){if(typeof window>"u")return;document.querySelectorAll(`[data-strategy="${e}"]:not(.hydrated)`).forEach((n)=>{n.classList.add("hydrated"),n.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function Na(){if(typeof window>"u")return;document.querySelectorAll(".stx-island:not(.hydrated)").forEach((t)=>{t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function La(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function ja(e){return new Promise((t)=>{if(typeof window>"u"){t();return}let n=document.querySelector(`[data-island="${e}"]`);if(!n){t();return}if(n.classList.contains("hydrated")){t();return}n.addEventListener("stx:hydrated",()=>t(),{once:!0})})}function Ba(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function Fa(e){let t=e.map((n)=>({id:n.id,component:n.component,strategy:n.options.strategy,props:n.props}));return`
386
+ `}function Na(e){if(typeof window>"u")return;let t=document.querySelector(`[data-island="${e}"]`);if(!t||t.classList.contains("hydrated"))return;t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))}function La(e){if(typeof window>"u")return;document.querySelectorAll(`[data-strategy="${e}"]:not(.hydrated)`).forEach((n)=>{n.classList.add("hydrated"),n.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function ja(){if(typeof window>"u")return;document.querySelectorAll(".stx-island:not(.hydrated)").forEach((t)=>{t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function Ba(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function Fa(e){return new Promise((t)=>{if(typeof window>"u"){t();return}let n=document.querySelector(`[data-island="${e}"]`);if(!n){t();return}if(n.classList.contains("hydrated")){t();return}n.addEventListener("stx:hydrated",()=>t(),{once:!0})})}function za(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function Ha(e){let t=e.map((n)=>({id:n.id,component:n.component,strategy:n.options.strategy,props:n.props}));return`
387
387
  <script type="application/json" id="stx-island-manifest">
388
388
  ${JSON.stringify(t)}
389
389
  </script>
390
- `}var Fl={processPartialHydrationDirectives:Ia,processStaticDirectives:Ba,generatePartialHydrationCSS:Oa,generateIslandManifest:Fa,createIslandRegistry:Pa,hydrateIsland:Da,hydrateByStrategy:Ma,hydrateAll:Na,isHydrated:La,onHydrated:ja};
391
- export{Pa,Ia,Oa,Da,Ma,Na,La,ja,Ba,Fa,Fl};
390
+ `}var Hl={processPartialHydrationDirectives:Da,processStaticDirectives:za,generatePartialHydrationCSS:Ma,generateIslandManifest:Ha,createIslandRegistry:Oa,hydrateIsland:Na,hydrateByStrategy:La,hydrateAll:ja,isHydrated:Ba,onHydrated:Fa};
391
+ export{Oa,Da,Ma,Na,La,ja,Ba,Fa,za,Ha,Hl};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
2
  var f=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),b=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);function l(i){return i.replace(/[^\n]/g," ")}function w(i){let o=i.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,l).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,l).replace(/<!--[\s\S]*?-->/g,l).replace(/\{\{\{[\s\S]*?\}\}\}/g,l).replace(/\{\{[\s\S]*?\}\}/g,l).replace(/\{!![\s\S]*?!!\}/g,l),s=new Map,r=new Map,p=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,t;while((t=p.exec(o))!==null){let e=t[1]==="/",n=t[2],a=t[3]==="/";if(f.has(n.toLowerCase()))continue;if(a)continue;if(e)r.set(n,(r.get(n)??0)+1);else{let g=s.get(n);if(g)g.count++;else{let d=o.slice(0,t.index).split(`
3
- `).length;s.set(n,{count:1,firstLine:d})}}}let c=[];for(let e of new Set([...s.keys(),...r.keys()])){if(b.has(e.toLowerCase()))continue;let n=s.get(e)?.count??0,a=r.get(e)??0;if(n!==a)c.push({tag:e,opened:n,closed:a,firstOpenLine:s.get(e)?.firstLine??0})}return c}var u=new Set;function Xs(i,o){let s;try{s=w(i)}catch{return}if(s.length===0)return;let r=`${o}:${i.length}`;if(u.has(r))return;u.add(r);let p=o?o.split(/[/\\]/).pop()||o:"template";for(let{tag:t,opened:c,closed:e,firstOpenLine:n}of s)if(c>e){let a=n?` (first opened at line ${n})`:"";console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 an unclosed <${t}>${a} may swallow the content that follows it.`)}else console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 ${e-c} stray </${t}>.`)}
4
- export{Xs};
3
+ `).length;s.set(n,{count:1,firstLine:d})}}}let c=[];for(let e of new Set([...s.keys(),...r.keys()])){if(b.has(e.toLowerCase()))continue;let n=s.get(e)?.count??0,a=r.get(e)??0;if(n!==a)c.push({tag:e,opened:n,closed:a,firstOpenLine:s.get(e)?.firstLine??0})}return c}var u=new Set;function Ys(i,o){let s;try{s=w(i)}catch{return}if(s.length===0)return;let r=`${o}:${i.length}`;if(u.has(r))return;u.add(r);let p=o?o.split(/[/\\]/).pop()||o:"template";for(let{tag:t,opened:c,closed:e,firstOpenLine:n}of s)if(c>e){let a=n?` (first opened at line ${n})`:"";console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 an unclosed <${t}>${a} may swallow the content that follows it.`)}else console.warn(`[stx] ${p}: <${t}> ${c} opened, ${e} closed \u2014 ${e-c} stray </${t}>.`)}
4
+ export{Ys};
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import{y}from"./chunk-zk2xk0wd.js";import{O,Mt}from"./chunk-vpdx7qr3.js";import{w,qe,j,o}from"./chunk-faghmmrs.js";import{ce,vt,xt,St}from"./chunk-kp0hg06s.js";import{Me,Yt,mt,V}from"./chunk-2rx9d75e.js";import{E,Tn}from"./chunk-5db5sxy3.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let i of(s[1]??"").split(",")){let l=((i.includes(":")?i.split(":").pop():i)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let i of(s[1]??"").split(",")){let r=i.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function pd(c){let n;if(c)n=p.resolve(c);else{let t=await o();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${xt()}`,i=new Bun.Glob("*.ts"),r=[];try{for await(let t of i.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return V(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>ce(t))])],f=Me(l()),d=mt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return V(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let x=u.map((t)=>t.file),m=[],g=new Set,v=j({loader:"ts",target:"browser",define:w()});for(let t of x)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),vt(e))e=await St(e,t,{projectRoot:process.cwd(),externalizeUserModules:E()});e=qe(e),e=O(e),e=Mt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
3
+ ${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return V(a,s,f,""),null;let S=m.join(`
4
+
5
+ `),h=`;(function(){
6
+ var __stx = window.stx || {};
7
+ ${y.filter((t)=>!g.has(t)&&new RegExp(`\\b${t}\\b`).test(S)).map((t)=>`var ${t} = __stx[${JSON.stringify(t)}];`).join(`
8
+ `)}
9
+ ${S}
10
+ })();`,b=E()?Tn(h):h;return f=Me(l()),V(a,s,f,b),b}function fd(){a.clear(),Yt()}
11
+ export{pd,fd};
@@ -72,7 +72,7 @@ else {
72
72
  ${t}
73
73
  })();
74
74
  </script>
75
- `}function Wl(i,n,o){f=0;let l=/@defer\s*\(([^)]*)\)\s*([\s\S]*?)@enddefer/g;return i.replace(l,(t,e,s)=>{let a=v(),r=p(t,e,s),d=r.placeholder?`<div data-defer-placeholder>${r.placeholder}</div>`:"",c=r.loading?`<div data-defer-loading style="display: none;">${r.loading}</div>`:'<div data-defer-loading style="display: none;"></div>',g=r.error?`<div data-defer-error style="display: none;">${r.error}</div>`:"",u=`<div data-defer-content style="display: none;">${r.content}</div>`,h=E(a,r);return`
75
+ `}function Gl(i,n,o){f=0;let l=/@defer\s*\(([^)]*)\)\s*([\s\S]*?)@enddefer/g;return i.replace(l,(t,e,s)=>{let a=v(),r=p(t,e,s),d=r.placeholder?`<div data-defer-placeholder>${r.placeholder}</div>`:"",c=r.loading?`<div data-defer-loading style="display: none;">${r.loading}</div>`:'<div data-defer-loading style="display: none;"></div>',g=r.error?`<div data-defer-error style="display: none;">${r.error}</div>`:"",u=`<div data-defer-content style="display: none;">${r.content}</div>`,h=E(a,r);return`
76
76
  <div id="${a}" class="stx-defer" data-defer-trigger="${r.trigger}">
77
77
  ${d}
78
78
  ${c}
@@ -81,4 +81,4 @@ else {
81
81
  </div>
82
82
  ${h}
83
83
  `})}
84
- export{Wl};
84
+ export{Gl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Jr,Bo,Fo,Ld}from"./chunk-620szfcp.js";export{Jr as NATIVE_COMPONENTS,Bo as compileToNative,Fo as createHotReloadServer,Ld as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Gc,Ps}from"./chunk-ah9xyss2.js";export{Gc as looksLikeGlob,Ps as resolveStxTargets};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{fn,Cc,hs}from"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import{_e}from"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{_e as freeIdentifiers,hs as processComponents,Cc as processESImports,fn as rendersAsElement};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Le,q,Fo}from"./chunk-t79xnvzr.js";import L from"fs";import g from"path";import D from"crypto";import{generatePlaceholder as R,processImage as k}from"ts-images";var B=[320,640,768,1024,1280,1536,1920],F=["webp","jpeg"],z=80,C=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],A={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},I=null,j=!1;async function d(){if(j)return I;j=!0;try{let t=await import("sharp");return I=t.default||t,I}catch{return null}}async function Ft(){return await d()!==null}async function Q(){return!0}async function ie(t,e={}){let{widths:a=B,formats:r=F,quality:n=z,fit:c="cover",placeholder:i="none",outputDir:m=".stx/images",baseUrl:s="/images"}=e,h,l;if(typeof t==="string"){if(l=t,!await Bun.file(t).exists())throw new Bn(`Image not found: ${t}`,"NOT_FOUND");h=await Bun.file(t).arrayBuffer().then((o)=>Buffer.from(o))}else l="buffer-input",h=t;let b=D.createHash("sha256").update(h).digest("hex").slice(0,12),v=await jn(h),{width:u,height:x}=v,y=u/x;await L.promises.mkdir(m,{recursive:!0});let S=[],V=g.basename(l,g.extname(l)),f=a.filter((o)=>o<=u);if(!f.includes(u)&&u<=Math.max(...a))f.push(u);f.sort((o,p)=>o-p);for(let o of f){let p=Math.round(o/y);for(let w of r){let E=`${V}-${o}w-${b}.${w}`,M=g.join(m,E),T=`${s}/${E}`,U=await ma(h,{width:o,height:p,format:w,quality:n,fit:c});await Bun.write(M,U),S.push({path:M,url:T,width:o,height:p,format:w,size:U.length})}}let P;if(i!=="none")P=await N(h,i);return{src:l,variants:S,placeholder:P,width:u,height:x,aspectRatio:y,hash:b}}async function jn(t){let e=typeof t==="string"?Buffer.from(await Bun.file(t).arrayBuffer()):t,a=await d();if(a){let n=await a(e).metadata();return{width:n.width||0,height:n.height||0,format:n.format||"unknown",hasAlpha:n.hasAlpha}}return O(e)}function O(t){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let e=t.readUInt32BE(16),a=t.readUInt32BE(20);return{width:e,height:a,format:"png",hasAlpha:!0}}if(t[0]===255&&t[1]===216){let e=2;while(e<t.length){if(t[e]!==255)break;let a=t[e+1];if(a>=192&&a<=207&&a!==196&&a!==200&&a!==204){let n=t.readUInt16BE(e+5);return{width:t.readUInt16BE(e+7),height:n,format:"jpeg",hasAlpha:!1}}let r=t.readUInt16BE(e+2);e+=2+r}}if(t.toString("utf8",0,4)==="RIFF"&&t.toString("utf8",8,12)==="WEBP"){let e=t.toString("utf8",12,16);if(e==="VP8 "){let a=t.readUInt16LE(26)&16383,r=t.readUInt16LE(28)&16383;return{width:a,height:r,format:"webp",hasAlpha:!1}}if(e==="VP8L"){let a=t.readUInt32LE(21),r=(a&16383)+1,n=(a>>14&16383)+1;return{width:r,height:n,format:"webp",hasAlpha:!0}}}if(t.toString("utf8",0,3)==="GIF"){let e=t.readUInt16LE(6),a=t.readUInt16LE(8);return{width:e,height:a,format:"gif",hasAlpha:!0}}throw new Bn("Unable to parse image dimensions","PARSE_ERROR")}async function ma(t,e){let a=await d();if(a){let r=a(t).resize(e.width,e.height,{fit:e.fit});switch(e.format){case"webp":r=r.webp({quality:e.quality});break;case"avif":r=r.avif({quality:e.quality});break;case"jpeg":r=r.jpeg({quality:e.quality});break;case"png":r=r.png({quality:e.quality});break}return r.toBuffer()}return await Fo("img",async(r)=>{let n=g.join(r,`out.${e.format}`);return await k({input:t,output:n,format:e.format,quality:e.quality,resize:{width:e.width,height:e.height,fit:e.fit}}),Buffer.from(await Bun.file(n).arrayBuffer())})}async function N(t,e){let a=await d();if(e==="blur"&&a){let m=(await a(t).resize(20).blur(10).toBuffer()).toString("base64"),s=await jn(t);return`data:${A[s.format]||"image/jpeg"};base64,${m}`}if(e==="dominant-color"&&a){let{dominant:i}=await a(t).resize(1,1).toBuffer().then(async(m)=>{let s=await a(m).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${i.r}, ${i.g}, ${i.b})`}let r=await jn(t),n=Le("ph"),c=g.join(n,`in.${r.format==="unknown"?"bin":r.format}`);try{await Bun.write(c,t);let i=e==="blur"?"blur":e==="thumbhash"?"thumbhash":"dominant-color",s=await R(c,{strategy:i,width:i==="thumbhash"?void 0:32});if(e==="dominant-color"&&s.dominantColor)return s.dominantColor;if(s.dataURL)return s.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{q(n)}}function De(t,e){return(e?t.filter((r)=>r.format===e):t).sort((r,n)=>r.width-n.width).map((r)=>`${r.url} ${r.width}w`).join(", ")}function gt(t){if(!t||Object.keys(t).length===0)return"100vw";return Object.entries(t).sort((a,r)=>{let n=Number.parseInt(a[0].replace(/\D/g,""))||0;return(Number.parseInt(r[0].replace(/\D/g,""))||0)-n}).map(([a,r])=>`(max-width: ${a}) ${r}`).join(", ")+", 100vw"}function zt(t){let e=t.filter((r)=>r.format==="jpeg");if(e.length===0)return t[Math.floor(t.length/2)];let a=e.sort((r,n)=>r.width-n.width);return a[Math.floor(a.length/2)]}function Ht(t){let e=new Map;for(let a of t){let r=e.get(a.format)||[];r.push(a),e.set(a.format,r)}return e}function Ut(t){let e=g.extname(t).toLowerCase();return C.includes(e)}function H(t){return A[t]||"application/octet-stream"}function Vt(t){return t.reduce((e,a)=>e+a.size,0)}function Wt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;return`${(t/1048576).toFixed(2)} MB`}class Bn extends Error{code;constructor(t,e){super(t);this.name="ImageProcessingError",this.code=e}}
3
- export{B,F,z,Ft,Q,ie,jn,ma,De,gt,zt,Ht,Ut,H,Vt,Wt,Bn};
2
+ import{Le,q,Ho}from"./chunk-117xss52.js";import L from"fs";import g from"path";import D from"crypto";import{generatePlaceholder as R,processImage as k}from"ts-images";var B=[320,640,768,1024,1280,1536,1920],F=["webp","jpeg"],z=80,C=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],A={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},I=null,j=!1;async function d(){if(j)return I;j=!0;try{let t=await import("sharp");return I=t.default||t,I}catch{return null}}async function zt(){return await d()!==null}async function Q(){return!0}async function ie(t,e={}){let{widths:a=B,formats:r=F,quality:n=z,fit:c="cover",placeholder:i="none",outputDir:m=".stx/images",baseUrl:s="/images"}=e,h,l;if(typeof t==="string"){if(l=t,!await Bun.file(t).exists())throw new Fn(`Image not found: ${t}`,"NOT_FOUND");h=await Bun.file(t).arrayBuffer().then((o)=>Buffer.from(o))}else l="buffer-input",h=t;let b=D.createHash("sha256").update(h).digest("hex").slice(0,12),v=await Bn(h),{width:u,height:x}=v,y=u/x;await L.promises.mkdir(m,{recursive:!0});let S=[],V=g.basename(l,g.extname(l)),f=a.filter((o)=>o<=u);if(!f.includes(u)&&u<=Math.max(...a))f.push(u);f.sort((o,p)=>o-p);for(let o of f){let p=Math.round(o/y);for(let w of r){let E=`${V}-${o}w-${b}.${w}`,M=g.join(m,E),T=`${s}/${E}`,U=await ya(h,{width:o,height:p,format:w,quality:n,fit:c});await Bun.write(M,U),S.push({path:M,url:T,width:o,height:p,format:w,size:U.length})}}let P;if(i!=="none")P=await N(h,i);return{src:l,variants:S,placeholder:P,width:u,height:x,aspectRatio:y,hash:b}}async function Bn(t){let e=typeof t==="string"?Buffer.from(await Bun.file(t).arrayBuffer()):t,a=await d();if(a){let n=await a(e).metadata();return{width:n.width||0,height:n.height||0,format:n.format||"unknown",hasAlpha:n.hasAlpha}}return O(e)}function O(t){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let e=t.readUInt32BE(16),a=t.readUInt32BE(20);return{width:e,height:a,format:"png",hasAlpha:!0}}if(t[0]===255&&t[1]===216){let e=2;while(e<t.length){if(t[e]!==255)break;let a=t[e+1];if(a>=192&&a<=207&&a!==196&&a!==200&&a!==204){let n=t.readUInt16BE(e+5);return{width:t.readUInt16BE(e+7),height:n,format:"jpeg",hasAlpha:!1}}let r=t.readUInt16BE(e+2);e+=2+r}}if(t.toString("utf8",0,4)==="RIFF"&&t.toString("utf8",8,12)==="WEBP"){let e=t.toString("utf8",12,16);if(e==="VP8 "){let a=t.readUInt16LE(26)&16383,r=t.readUInt16LE(28)&16383;return{width:a,height:r,format:"webp",hasAlpha:!1}}if(e==="VP8L"){let a=t.readUInt32LE(21),r=(a&16383)+1,n=(a>>14&16383)+1;return{width:r,height:n,format:"webp",hasAlpha:!0}}}if(t.toString("utf8",0,3)==="GIF"){let e=t.readUInt16LE(6),a=t.readUInt16LE(8);return{width:e,height:a,format:"gif",hasAlpha:!0}}throw new Fn("Unable to parse image dimensions","PARSE_ERROR")}async function ya(t,e){let a=await d();if(a){let r=a(t).resize(e.width,e.height,{fit:e.fit});switch(e.format){case"webp":r=r.webp({quality:e.quality});break;case"avif":r=r.avif({quality:e.quality});break;case"jpeg":r=r.jpeg({quality:e.quality});break;case"png":r=r.png({quality:e.quality});break}return r.toBuffer()}return await Ho("img",async(r)=>{let n=g.join(r,`out.${e.format}`);return await k({input:t,output:n,format:e.format,quality:e.quality,resize:{width:e.width,height:e.height,fit:e.fit}}),Buffer.from(await Bun.file(n).arrayBuffer())})}async function N(t,e){let a=await d();if(e==="blur"&&a){let m=(await a(t).resize(20).blur(10).toBuffer()).toString("base64"),s=await Bn(t);return`data:${A[s.format]||"image/jpeg"};base64,${m}`}if(e==="dominant-color"&&a){let{dominant:i}=await a(t).resize(1,1).toBuffer().then(async(m)=>{let s=await a(m).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${i.r}, ${i.g}, ${i.b})`}let r=await Bn(t),n=Le("ph"),c=g.join(n,`in.${r.format==="unknown"?"bin":r.format}`);try{await Bun.write(c,t);let i=e==="blur"?"blur":e==="thumbhash"?"thumbhash":"dominant-color",s=await R(c,{strategy:i,width:i==="thumbhash"?void 0:32});if(e==="dominant-color"&&s.dominantColor)return s.dominantColor;if(s.dataURL)return s.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{q(n)}}function De(t,e){return(e?t.filter((r)=>r.format===e):t).sort((r,n)=>r.width-n.width).map((r)=>`${r.url} ${r.width}w`).join(", ")}function gt(t){if(!t||Object.keys(t).length===0)return"100vw";return Object.entries(t).sort((a,r)=>{let n=Number.parseInt(a[0].replace(/\D/g,""))||0;return(Number.parseInt(r[0].replace(/\D/g,""))||0)-n}).map(([a,r])=>`(max-width: ${a}) ${r}`).join(", ")+", 100vw"}function Ht(t){let e=t.filter((r)=>r.format==="jpeg");if(e.length===0)return t[Math.floor(t.length/2)];let a=e.sort((r,n)=>r.width-n.width);return a[Math.floor(a.length/2)]}function Ut(t){let e=new Map;for(let a of t){let r=e.get(a.format)||[];r.push(a),e.set(a.format,r)}return e}function Vt(t){let e=g.extname(t).toLowerCase();return C.includes(e)}function H(t){return A[t]||"application/octet-stream"}function Wt(t){return t.reduce((e,a)=>e+a.size,0)}function qt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;return`${(t/1048576).toFixed(2)} MB`}class Fn extends Error{code;constructor(t,e){super(t);this.name="ImageProcessingError",this.code=e}}
3
+ export{B,F,z,zt,Q,ie,Bn,ya,De,gt,Ht,Ut,Vt,H,Wt,qt,Fn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{J,Ts,$s,Rs,n}from"./chunk-faghmmrs.js";import"./chunk-cdgwkzms.js";import"./chunk-ah9xyss2.js";import"./chunk-jtbzmbzz.js";import"./chunk-eww6sdzz.js";import"./chunk-be2ba3hj.js";import"./chunk-ayy9mmrw.js";import"./chunk-43h8q2cm.js";import"./chunk-7hkc96de.js";import"./chunk-vpdx7qr3.js";import"./chunk-zk2xk0wd.js";import"./chunk-yhpyqsbr.js";import"./chunk-qdyp2zqf.js";export{J as injectRouterScript,n as processDirectives,Ts as processJsonDirective,$s as processOnceDirective,Rs as validateClientScript};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$o,Ro,Ra,Aa,Pa,Ia,zl}from"./chunk-0k5faspy.js";export{$o as createVirtualList,zl as default,Ra as generateVirtualListCSS,Pa as processInfiniteListDirectives,Ia as processVirtualGridDirectives,Ro as processVirtualListDirectives,Aa as useVirtualList};