@stacksjs/stx 0.2.825 → 0.2.827

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 (236) hide show
  1. package/dist/chunk-02zvytqx.js +2 -0
  2. package/dist/{chunk-bt0amey5.js → chunk-04z1xyrb.js} +2 -2
  3. package/dist/chunk-0jhq2kza.js +2 -0
  4. package/dist/{chunk-f0txsdpa.js → chunk-0rvntfhj.js} +3 -3
  5. package/dist/chunk-12m1qwzd.js +2 -0
  6. package/dist/chunk-17zrprh0.js +2 -0
  7. package/dist/chunk-1bpx9b0m.js +2 -0
  8. package/dist/{chunk-wy0gghvh.js → chunk-1vzncfka.js} +2 -2
  9. package/dist/chunk-2b1w7py1.js +2 -0
  10. package/dist/chunk-2mrdtxfy.js +2 -0
  11. package/dist/{chunk-2vqpz4qv.js → chunk-2qngyyaz.js} +2 -2
  12. package/dist/{chunk-7yb82rm6.js → chunk-2x9zhezb.js} +2 -2
  13. package/dist/{chunk-9fm8khcc.js → chunk-3esj6tb8.js} +5 -5
  14. package/dist/{chunk-3fwhb1q4.js → chunk-3g7bjpj6.js} +3 -3
  15. package/dist/{chunk-981z8va1.js → chunk-3p7r3ajd.js} +2 -2
  16. package/dist/chunk-3qx7whh5.js +2 -0
  17. package/dist/chunk-3vsz0vrk.js +2 -0
  18. package/dist/{chunk-en390342.js → chunk-3x3zcfxp.js} +48 -48
  19. package/dist/chunk-3zfras5s.js +2 -0
  20. package/dist/chunk-42c92rp3.js +2 -0
  21. package/dist/{chunk-0wgjhyb8.js → chunk-48z7tg83.js} +3 -3
  22. package/dist/chunk-4a3r1kh1.js +43 -0
  23. package/dist/{chunk-24d3yy27.js → chunk-4d8ep00w.js} +49 -49
  24. package/dist/chunk-4z0jpzdq.js +3 -0
  25. package/dist/{chunk-6qvn1h09.js → chunk-5201w0f1.js} +3 -3
  26. package/dist/{chunk-xmdcjyyx.js → chunk-543yvntm.js} +2 -2
  27. package/dist/{chunk-e99szqws.js → chunk-5phdmpa7.js} +6 -6
  28. package/dist/{chunk-06y0da27.js → chunk-5r63bv4g.js} +3 -3
  29. package/dist/chunk-67nq6csk.js +2 -0
  30. package/dist/chunk-6aak0b7c.js +2 -0
  31. package/dist/{chunk-7sh9fa3q.js → chunk-6k26n0sj.js} +2 -2
  32. package/dist/chunk-6r4teng3.js +2 -0
  33. package/dist/{chunk-d6d2s7n6.js → chunk-6tjm38e4.js} +2 -2
  34. package/dist/{chunk-06hc6rs6.js → chunk-716jrdcg.js} +1 -1
  35. package/dist/{chunk-ac2vz9c3.js → chunk-717qsbap.js} +10 -10
  36. package/dist/chunk-72n804gy.js +2 -0
  37. package/dist/chunk-7amk61bt.js +2 -0
  38. package/dist/{chunk-3yh6y00f.js → chunk-7k9yahng.js} +6 -6
  39. package/dist/{chunk-wf0n9gpj.js → chunk-7p8m82pj.js} +4 -4
  40. package/dist/{chunk-rzt51r2b.js → chunk-7z2ygy9p.js} +7 -7
  41. package/dist/chunk-8n8vj099.js +2 -0
  42. package/dist/chunk-8ta7f5en.js +2 -0
  43. package/dist/{chunk-r9e0r6jx.js → chunk-8y8kgw9s.js} +3 -3
  44. package/dist/{chunk-cnh6tcdj.js → chunk-8yy8qrcv.js} +10 -10
  45. package/dist/chunk-a7ewznxk.js +2 -0
  46. package/dist/{chunk-gjf8cjdt.js → chunk-ac9ncbfw.js} +3 -3
  47. package/dist/chunk-ahd8jdzx.js +2 -0
  48. package/dist/chunk-ay7ggc4k.js +2 -0
  49. package/dist/chunk-ayk94a19.js +2 -0
  50. package/dist/{chunk-mv3yhspn.js → chunk-b1q40vq4.js} +2 -2
  51. package/dist/{chunk-dsfdgqmd.js → chunk-b3nv89wq.js} +2 -2
  52. package/dist/{chunk-3axb6t08.js → chunk-b7tb00nz.js} +2 -2
  53. package/dist/chunk-b92vzax2.js +2 -0
  54. package/dist/{chunk-pbpr3bdy.js → chunk-bh35v908.js} +1 -1
  55. package/dist/chunk-bh7v78je.js +2 -0
  56. package/dist/{chunk-vfy3b7gm.js → chunk-bjvmmsvp.js} +6 -6
  57. package/dist/{chunk-djpmrctd.js → chunk-bwnwv91e.js} +8 -8
  58. package/dist/chunk-c7ybxv8x.js +2 -0
  59. package/dist/{chunk-3dz29mpg.js → chunk-c8vza3p0.js} +22 -22
  60. package/dist/{chunk-8ttmzcxb.js → chunk-c9mdvpf5.js} +29 -29
  61. package/dist/{chunk-5emrarpf.js → chunk-car6nhfe.js} +2 -2
  62. package/dist/{chunk-e4jwhmpb.js → chunk-cca18z35.js} +31 -31
  63. package/dist/chunk-cfrgrnej.js +2 -0
  64. package/dist/{chunk-vzbyn4nh.js → chunk-ckg6q98b.js} +5 -5
  65. package/dist/{chunk-k81trehg.js → chunk-cv1zc9dg.js} +2 -2
  66. package/dist/chunk-cw8vpk41.js +2 -0
  67. package/dist/chunk-d2n2zrdg.js +2 -0
  68. package/dist/{chunk-0scyzg9r.js → chunk-d9s37xm5.js} +19 -19
  69. package/dist/chunk-db1c0c3c.js +2 -0
  70. package/dist/{chunk-cxz4cdcn.js → chunk-e75dntfb.js} +2 -2
  71. package/dist/chunk-e8a6s6xs.js +25 -0
  72. package/dist/{chunk-wceg59n0.js → chunk-ekh3mxyp.js} +2 -2
  73. package/dist/{chunk-4mj9dem1.js → chunk-em8tv6nz.js} +2 -2
  74. package/dist/{chunk-7qk4exw1.js → chunk-ema1c29k.js} +2 -2
  75. package/dist/{chunk-z23arg8m.js → chunk-f49x34sr.js} +2 -2
  76. package/dist/{chunk-8w9spdbn.js → chunk-f6b7av6b.js} +9 -9
  77. package/dist/{chunk-9gmceny5.js → chunk-f7jgda7x.js} +5 -5
  78. package/dist/chunk-fb90n0by.js +2 -0
  79. package/dist/chunk-fevyb337.js +3 -0
  80. package/dist/chunk-fqq5qzm0.js +2 -0
  81. package/dist/chunk-fr9e8kb9.js +2 -0
  82. package/dist/{chunk-ge0k6c49.js → chunk-ftw0a5dm.js} +6 -6
  83. package/dist/{chunk-b4x5ndt9.js → chunk-fwktw49p.js} +4 -4
  84. package/dist/chunk-g4qzy5hv.js +2 -0
  85. package/dist/{chunk-tksjakyv.js → chunk-gcf97wgx.js} +1 -1
  86. package/dist/chunk-gg48cgx3.js +2 -0
  87. package/dist/{chunk-076fj387.js → chunk-hd378dgy.js} +1 -1
  88. package/dist/chunk-j9aftb7p.js +2 -0
  89. package/dist/chunk-jp6sbk05.js +2 -0
  90. package/dist/chunk-k6ye0159.js +3 -0
  91. package/dist/{chunk-vyj9xddw.js → chunk-kfkbqwyf.js} +2 -2
  92. package/dist/{chunk-ap2t6fdt.js → chunk-kh2n3zqa.js} +1 -1
  93. package/dist/{chunk-b1n2tq8f.js → chunk-kmqcvpz2.js} +5 -5
  94. package/dist/chunk-kshem79d.js +2 -0
  95. package/dist/chunk-kve27dy3.js +2 -0
  96. package/dist/chunk-m3tnxk01.js +2 -0
  97. package/dist/chunk-m716f2ga.js +2 -0
  98. package/dist/{chunk-3wjh3aw8.js → chunk-m973xh3a.js} +13 -13
  99. package/dist/chunk-m9bbhg46.js +3 -0
  100. package/dist/chunk-m9dj8pgb.js +2 -0
  101. package/dist/{chunk-gp37b8vw.js → chunk-mfebs2s2.js} +2 -2
  102. package/dist/{chunk-qj4r08jb.js → chunk-mxvevxb8.js} +4 -4
  103. package/dist/{chunk-btxnrqxf.js → chunk-myje6fhm.js} +5 -5
  104. package/dist/{chunk-1f7d1c0y.js → chunk-mypygxdm.js} +2 -2
  105. package/dist/{chunk-76eh43e9.js → chunk-nfpsaaqm.js} +2 -2
  106. package/dist/{chunk-zen28e3p.js → chunk-ng5revck.js} +29 -29
  107. package/dist/chunk-nxnkd48v.js +2 -0
  108. package/dist/chunk-pe5qqem0.js +2 -0
  109. package/dist/chunk-pg146fc5.js +2 -0
  110. package/dist/{chunk-67kbsav0.js → chunk-q5pwvr98.js} +1 -1
  111. package/dist/{chunk-2nj9aewf.js → chunk-qadce16v.js} +1 -1
  112. package/dist/chunk-qg2tpvdw.js +2 -0
  113. package/dist/chunk-qm6epp9h.js +2 -0
  114. package/dist/{chunk-faxbznng.js → chunk-qn06sy9j.js} +5 -5
  115. package/dist/{chunk-q7zwv88b.js → chunk-qnrgfm9v.js} +2 -2
  116. package/dist/{chunk-0kbzs147.js → chunk-qz82cpyv.js} +9 -9
  117. package/dist/chunk-rbq4dn2a.js +2 -0
  118. package/dist/{chunk-kvgxmb0s.js → chunk-ret52ds0.js} +6 -6
  119. package/dist/{chunk-xpy9yjyx.js → chunk-rkdsgfhd.js} +13 -13
  120. package/dist/{chunk-bfbh0hfn.js → chunk-rmygv0n0.js} +6 -6
  121. package/dist/{chunk-n7arptzc.js → chunk-s53wjw7y.js} +3 -3
  122. package/dist/{chunk-p1fpferp.js → chunk-s5dhvnnd.js} +6 -6
  123. package/dist/chunk-s5ejh2yx.js +2 -0
  124. package/dist/chunk-s6399qe7.js +2 -0
  125. package/dist/chunk-se3fqsxk.js +2 -0
  126. package/dist/chunk-t59bc7na.js +3 -0
  127. package/dist/{chunk-yr3ped5m.js → chunk-t96229jm.js} +2 -2
  128. package/dist/{chunk-z5hmwq1z.js → chunk-tngj0fp6.js} +8 -8
  129. package/dist/chunk-txzap6yn.js +2 -0
  130. package/dist/{chunk-g0zxp9qh.js → chunk-tzhs7drk.js} +11 -11
  131. package/dist/chunk-v1mwhvf8.js +2 -0
  132. package/dist/chunk-vb4xzz5c.js +2 -0
  133. package/dist/{chunk-me6kgvsm.js → chunk-vpnyqf0h.js} +1 -1
  134. package/dist/chunk-vxhq8n8y.js +2 -0
  135. package/dist/{chunk-mwxbdpb1.js → chunk-vyv76w55.js} +2 -2
  136. package/dist/chunk-w39cfxa6.js +2 -0
  137. package/dist/chunk-w9gpscjf.js +2 -0
  138. package/dist/chunk-wb6w807m.js +2 -0
  139. package/dist/chunk-wpyhavjy.js +2 -0
  140. package/dist/{chunk-j3st59hv.js → chunk-wr7bmkne.js} +2 -2
  141. package/dist/chunk-wt7qhv5b.js +2 -0
  142. package/dist/{chunk-y8p85kcj.js → chunk-wvds0s9m.js} +2 -2
  143. package/dist/chunk-x742wppj.js +2 -0
  144. package/dist/chunk-xdwnbr9b.js +4 -0
  145. package/dist/{chunk-a1htb5r5.js → chunk-xj3my6b9.js} +105 -105
  146. package/dist/{chunk-qz3fdmrc.js → chunk-xn9jg1q5.js} +3 -3
  147. package/dist/chunk-xrspzeqx.js +2 -0
  148. package/dist/{chunk-xegj9wqj.js → chunk-xtn0hnmz.js} +6 -6
  149. package/dist/{chunk-jb2rvsf4.js → chunk-y6nz6bk2.js} +3 -3
  150. package/dist/{chunk-cmnze7at.js → chunk-ybq56wam.js} +2 -2
  151. package/dist/{chunk-y9bj3566.js → chunk-yrw5ensv.js} +3 -3
  152. package/dist/{chunk-axwa3s1m.js → chunk-yv1vw0kx.js} +2 -2
  153. package/dist/{chunk-pvj0bpqg.js → chunk-z25w7kmr.js} +4 -4
  154. package/dist/chunk-zty254tw.js +2 -0
  155. package/dist/{chunk-j737tnvt.js → chunk-zvvv6x8c.js} +4 -4
  156. package/dist/cli.js +23 -23
  157. package/dist/craft-entry.js +2 -2
  158. package/dist/craft.js +2 -2
  159. package/dist/loops.d.ts +2 -0
  160. package/dist/loops.js +22 -3
  161. package/dist/performance-utils.d.ts +2 -0
  162. package/dist/performance-utils.js +7 -0
  163. package/dist/process.js +17 -3
  164. package/dist/pwa.js +3 -3
  165. package/dist/ssg.js +11 -11
  166. package/package.json +5 -5
  167. package/dist/chunk-030tgwve.js +0 -2
  168. package/dist/chunk-09285y4b.js +0 -2
  169. package/dist/chunk-0jvrzpfs.js +0 -2
  170. package/dist/chunk-1qwb0pyb.js +0 -2
  171. package/dist/chunk-30rpspzt.js +0 -43
  172. package/dist/chunk-3bf48zrh.js +0 -2
  173. package/dist/chunk-3bny2583.js +0 -2
  174. package/dist/chunk-3e7t4qzd.js +0 -2
  175. package/dist/chunk-40rzr6qj.js +0 -2
  176. package/dist/chunk-4sev2jfs.js +0 -2
  177. package/dist/chunk-5e5jschg.js +0 -3
  178. package/dist/chunk-5ea3zebc.js +0 -2
  179. package/dist/chunk-6h1qa3hw.js +0 -2
  180. package/dist/chunk-6tfhx4zw.js +0 -2
  181. package/dist/chunk-716qmx26.js +0 -2
  182. package/dist/chunk-7bjxmzre.js +0 -2
  183. package/dist/chunk-7mw1yc6j.js +0 -2
  184. package/dist/chunk-7pz76f28.js +0 -2
  185. package/dist/chunk-7vfq8t4x.js +0 -2
  186. package/dist/chunk-9w9vr35m.js +0 -2
  187. package/dist/chunk-a8fy7jv8.js +0 -2
  188. package/dist/chunk-akj26p4b.js +0 -3
  189. package/dist/chunk-an1cc36z.js +0 -2
  190. package/dist/chunk-b22yj5j5.js +0 -2
  191. package/dist/chunk-brhas9mp.js +0 -3
  192. package/dist/chunk-c1e45rtv.js +0 -2
  193. package/dist/chunk-cgamtmxv.js +0 -2
  194. package/dist/chunk-d30p1zvd.js +0 -2
  195. package/dist/chunk-dfy5g8cb.js +0 -2
  196. package/dist/chunk-e38gkp8q.js +0 -2
  197. package/dist/chunk-fm8hq9y2.js +0 -2
  198. package/dist/chunk-g4sdthck.js +0 -2
  199. package/dist/chunk-g8nqmnb7.js +0 -2
  200. package/dist/chunk-h67pm636.js +0 -2
  201. package/dist/chunk-hb8jxg45.js +0 -2
  202. package/dist/chunk-hfgzqapw.js +0 -2
  203. package/dist/chunk-hras294c.js +0 -25
  204. package/dist/chunk-j0hrk24j.js +0 -2
  205. package/dist/chunk-jjbdtj4w.js +0 -2
  206. package/dist/chunk-jzgyrxye.js +0 -2
  207. package/dist/chunk-k0xdvegc.js +0 -2
  208. package/dist/chunk-kg9gnar1.js +0 -2
  209. package/dist/chunk-kq5k2qbz.js +0 -2
  210. package/dist/chunk-m934bzg2.js +0 -2
  211. package/dist/chunk-mmeck545.js +0 -2
  212. package/dist/chunk-mz6qjee1.js +0 -2
  213. package/dist/chunk-ndjmt3vg.js +0 -3
  214. package/dist/chunk-pgpkrf6g.js +0 -2
  215. package/dist/chunk-prt4ntb0.js +0 -2
  216. package/dist/chunk-px6336z8.js +0 -2
  217. package/dist/chunk-q5bct2ks.js +0 -2
  218. package/dist/chunk-r2hjn9ds.js +0 -2
  219. package/dist/chunk-rqdnzbq0.js +0 -2
  220. package/dist/chunk-rrkn40eq.js +0 -2
  221. package/dist/chunk-s2zsa16d.js +0 -2
  222. package/dist/chunk-sddp2398.js +0 -2
  223. package/dist/chunk-sfr0767s.js +0 -2
  224. package/dist/chunk-sv4emtcj.js +0 -2
  225. package/dist/chunk-sx8j2e58.js +0 -2
  226. package/dist/chunk-t2tv5ezg.js +0 -2
  227. package/dist/chunk-tcyvwy8p.js +0 -2
  228. package/dist/chunk-tg18j1yf.js +0 -2
  229. package/dist/chunk-tj7dh2dz.js +0 -2
  230. package/dist/chunk-tsvnhc0c.js +0 -4
  231. package/dist/chunk-vafxrky2.js +0 -2
  232. package/dist/chunk-vvjp9xp0.js +0 -2
  233. package/dist/chunk-wpendr22.js +0 -3
  234. package/dist/chunk-x30gh7vt.js +0 -2
  235. package/dist/chunk-y3trpdp9.js +0 -2
  236. package/dist/chunk-zqsygwa0.js +0 -2
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{gl,ml}from"./chunk-bt0amey5.js";import{f,A,st,d}from"./chunk-8ttmzcxb.js";import{V,yr,Os,Ns,oi,ii,Ms,wr,ci,Ne,pe,G,xr,oe,J,O,rt,Sr,ui,Cr,Fe,s,p,U,wn}from"./chunk-a1htb5r5.js";import{n}from"./chunk-5e5jschg.js";import{se}from"./chunk-wceg59n0.js";import{r}from"./chunk-b4x5ndt9.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import Z from"path";import{decode as an,generateThumbHash as cn}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import je from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=je.readSync(e,o,0,t,i);return o.subarray(0,a)}function Me(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Le(e){let i;try{i=je.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(Me(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)je.closeSync(i)}}import Qt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function en(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function tn(){if(Ae<en()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function nn(){Ae--,yt.shift()?.()}var rn="@stacksjs/stx/builtins/image-warmup-worker";function sn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Qt.existsSync(mt(t)))return mt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(rn,e):void 0;return t&&on(t)?t:void 0}catch{return}}function on(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,gt(i.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function ze(e){return e instanceof Error?e.message:String(e)}async function Ue(e,i){if(typeof pt!=="function")return he("node:worker_threads has no Worker in this runtime");let t=sn();if(!t)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await tn();try{return await new Promise((o,a)=>{let c;try{c=new pt(t)}catch(y){o(he(`could not start ${t}: ${ze(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:i});return}if(y.type==="result"){u(()=>o(y.value));return}let S=Error(y.error?.message??"image worker failed");if(y.error?.name)S.name=y.error.name;if(y.error?.stack)S.stack=y.error.stack;u(()=>a(S))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(ze(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${ze(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{nn()}}var ln=new Set([".avif",".jpeg",".jpg",".png",".webp"]),un=[320,640,960,1280,1920],ye="/_stx/images",fn=`stx:${ye}:alpha-1`,dn=`stx:${ye}:opaque-1`,gn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function mn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function vt(){if(Pe!==void 0)return Pe;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=gn.map((i)=>{let t;try{t=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var wt=new Set;function pn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function hn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function $t(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function At(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!ln.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function St(e,i){return e.map((t)=>({key:pn(t.relativePath),input:t.absolutePath,name:hn(t.relativePath),...yn(t.absolutePath)?{options:{storage:i}}:{}}))}function yn(e){return Le(e)==="possible"}function bn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function vn(e){let i=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),t=new Set,o=8;for(let a=0;a<i.length;a+=8)await Promise.all(i.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await an(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(bn(u.data))t.add(c)}catch{t.add(c)}}));return t}function xn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!Me(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,t.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function $n(e){let i=[],t=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await cn(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));i.push(...c.filter((l)=>l!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function Sn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function Cn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function Ct(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Lo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function jo(e){let i=kt(e);return i?be().transparent.has(i):!1}function Bo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Ih(e){let i=Lo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:Bo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:jo(e)?void 0:i.placeholder?.dataUrl}}function ls(){let e=be();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Oh(e,i,t={}){if(!e||!Q.existsSync(e))return ls(),{count:0,fingerprint:""};if(t.offThread){let v=await Ue("delivery",{publicDir:e,outputDir:i});if(v!==ke)return Rn(v.state),v.result}let o=await At(e);if(o.length===0)return ls(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((v)=>{let b=a[v.relativePath];if(!b)return!0;let w=Ct(v.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(c.length===0)return ls(),{count:0,fingerprint:""};let l=$t(Z.join(i,"_stx","images"),`${fn}:${vt()}`),m={outDir:Z.join(i,"_stx","images"),storage:$t(Z.join(i,"_stx","images"),`${dn}:${vt()}`),baseUrl:ye,widths:un,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(v){if(u=await $n(c),u.length===c.length)throw v;let b=new Set(u.map((k)=>k.relativePath)),w=!1;for(let k of c){if(b.has(k.relativePath))continue;let P=Ct(k.absolutePath);if(!P)continue;a[k.relativePath]=P,w=!0}if(w)Cn(i,a);if(u.length===0)return ls(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let S=await vn(y.entries),h=xn(y.entries,S),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=S;let x=S.size===0&&h.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...S].sort(),droppedWebp:h.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=oi(e,o);if(a!==void 0)return a;for(let c of ii(e,i,t,o))if(await s(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var An=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||An.has(i)}function ie(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${wn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${wn(c,He(String(a)))}"`)}return t}function kn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=kn(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(wr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let S=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...ie(e,S)),u.push(...ae(e,S)),`<a ${u.join(" ")}>${i}</a>`}};var Pn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var In={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function X(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Ie(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=In[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))t.push(`(max-width: ${m}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function _n(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function En(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Nn(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=X(e,"src")||"",a=Lo(o),c=X(e,"alt")||"",l=X(e,"width")||(a?String(a.source.width):void 0),m=X(e,"height")||(a?String(a.source.height):void 0),u=X(e,"sizes"),y=X(e,"srcset"),S=X(e,"densities"),h=X(e,"format"),C=jo(o)||Ve(o)?.transparent===!0,x=X(e,"placeholder")||(a&&!C?"thumbhash":void 0),v=X(e,"placeholderColor")||"#e5e7eb",b=X(e,"provider"),w=X(e,"class")||X(e,"className")||"",k=X(e,"style")||"",P=X(e,"objectFit")||X(e,"fit"),R=X(e,"objectPosition")||X(e,"position"),B=X(e,"quality"),K=Ie(e,"lazy",!0),M=Ie(e,"preload",!1),F=Ie(e,"priority",!1),W=X(e,"loading"),E=X(e,"decoding")||"async",T=!!a||Ie(e,"picture",!1)||!!h,N=l?Number.parseInt(l):void 0,H=m?Number.parseInt(m):void 0,z=y||"",q="";if(a)z=a.sources[a.fallback.format]||"",q=u?Ge(u):"100vw";else if(!z&&u&&b&&b!=="local"&&b!=="static")z=Ke(o,Ze,b,h),q=Ge(u);else if(!z&&S){let I=S.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));z=_n(o,I,N,b,h)}else if(u)q=Ge(u);let L=[];if(k)L.push(k);if(P)L.push(`object-fit:${P}`);if(R)L.push(`object-position:${R}`);if(N&&H)L.push(`aspect-ratio:${N}/${H}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:v}:Ve(o);if(I&&x==="color")L.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)L.push(`background-color:${I.color}`),L.push(`background-image:url(${I.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=Nn(N||16,H||9,v);L.push(`background-image:url(${_})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,N,H,b,h),Y=[];if(Y.push(`src="${n(wr($e,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let le=W||(F||M?"eager":K?"lazy":"");if(le)Y.push(`loading="${n(le)}"`);if(F)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(E)}"`),w)Y.push(`class="${n(w)}"`);if(L.length>0)Y.push(`style="${n(L.join(";"))}"`);if(z)Y.push(`srcset="${n(wr(z,"fetched"))}"`);if(q)Y.push(`sizes="${n(q)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=En(D)+(I?`;${I}`:"");Y.push(`onload="${n(_)}"`),te.add("onload")}Y.push(...ie(e,te)),Y.push(...ae(e,te));let De=`<img ${Y.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${z?` imagesrcset="${n(z)}"`:""}${q?` imagesizes="${n(q)}"`:""} />
3
- `}if(T){let I=[];if(a)for(let _ of Bo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${q?` sizes="${n(q)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,N,H,b,"avif"),ee=z?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${q?` sizes="${n(q)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,N,H,b,"webp"),ee=z?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${q?` sizes="${n(q)}"`:""} />`)}return`${j}<picture>
2
+ import{ml,hl}from"./chunk-04z1xyrb.js";import{f,P,ot,d}from"./chunk-c9mdvpf5.js";import{U,yr,Os,Ns,ii,ai,Ms,wr,li,Me,fe,J,xr,ie,Y,N,st,Sr,di,Cr,ze,s,p,W,vn}from"./chunk-xj3my6b9.js";import{n}from"./chunk-fevyb337.js";import{oe}from"./chunk-ekh3mxyp.js";import{r}from"./chunk-fwktw49p.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Rt}from"crypto";import Q from"fs";import Z from"path";import{decode as an,generateThumbHash as cn}from"ts-images";import{createImageDeliveryCatalog as bt}from"ts-images/delivery";import De from"fs";function Ce(e,i,t){let o=Buffer.alloc(t),a=De.readSync(e,o,0,t,i);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let t=i(12,16);if(t==="VP8X")return(e[20]&16)!==0;if(t==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Le(e){let i;try{i=De.openSync(e,"r");let t=Ce(i,0,33);if(t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255)return"none";if(t.length>=26&&t[0]===137&&t.toString("latin1",1,4)==="PNG"){let o=t[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(i,a,8);if(l.length<8)return"unknown";let m=l.toString("latin1",4,8);if(m==="tRNS")return"possible";if(m==="IDAT"||m==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(t.length>=25&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){if(je(t))return"possible";let o=t.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)De.closeSync(i)}}import Qt from"fs";import Re from"os";import{join as gt}from"path";import{fileURLToPath as mt}from"url";import{Worker as pt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function en(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,yt=[];async function tn(){if(Ae<en()){Ae++;return}await new Promise((e)=>yt.push(e)),Ae++}function nn(){Ae--,yt.shift()?.()}var rn="@stacksjs/stx/builtins/image-warmup-worker";function sn(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let t=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(t.protocol==="file:"&&Qt.existsSync(mt(t)))return mt(t)}catch{}try{let t=typeof Bun<"u"?Bun.resolveSync(rn,e):void 0;return t&&on(t)?t:void 0}catch{return}}function on(e,i=process.env){let t=e.replace(/\\/g,"/");if(t.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![i.BUN_INSTALL_CACHE_DIR,gt(i.BUN_INSTALL||gt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>t.startsWith(a))}var ht=!1;function he(e){if(!ht)ht=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Ue(e){return e instanceof Error?e.message:String(e)}async function Fe(e,i){if(typeof pt!=="function")return he("node:worker_threads has no Worker in this runtime");let t=sn();if(!t)return he("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await tn();try{return await new Promise((o,a)=>{let c;try{c=new pt(t)}catch(y){o(he(`could not start ${t}: ${Ue(y)}`));return}let l=!1,m=!1,u=(y)=>{if(m)return;m=!0,y(),c.terminate()};c.on("message",(y)=>{if(y.type==="ready"){l=!0,c.postMessage({task:e,args:i});return}if(y.type==="result"){u(()=>o(y.value));return}let S=Error(y.error?.message??"image worker failed");if(y.error?.name)S.name=y.error.name;if(y.error?.stack)S.stack=y.error.stack;u(()=>a(S))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Ue(y)||"image worker crashed")):o(he(`the worker failed before it was ready: ${Ue(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(he(`the worker exited with code ${y} before it was ready`)))})})}finally{nn()}}var ln=new Set([".avif",".jpeg",".jpg",".png",".webp"]),un=[320,640,960,1280,1920],ye="/_stx/images",fn=`stx:${ye}:alpha-1`,dn=`stx:${ye}:opaque-1`,gn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function mn(e,i){let t=Z.dirname(Bun.resolveSync(e,i));while(t!==Z.dirname(t)){let o=Z.join(t,"package.json");if(Q.existsSync(o)){let a=JSON.parse(Q.readFileSync(o,"utf8"));if(a.name===e)return a.version}t=Z.dirname(t)}return}function vt(){if(Pe!==void 0)return Pe;let e;try{e=Z.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=gn.map((i)=>{let t;try{t=e?mn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${t??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function be(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var wt=new Set;function pn(e){return`/${e.split(Z.sep).map(encodeURIComponent).join("/")}`}function hn(e){let i=Z.extname(e),t=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Rt("sha256").update(e).digest("hex").slice(0,8);return`${t||"image"}-${o}`}function $t(e,i=`stx:${ye}`){let t=(o)=>`${ye}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=Z.join(e,o);try{let c=await Q.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:t(o)}:null}catch{return null}},async write(o,a){let c=Z.join(e,o);await Q.promises.mkdir(Z.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await Q.promises.writeFile(l,a),await Q.promises.rename(l,c),{bytes:a.byteLength,path:c,url:t(o)}},url:t}}async function At(e,i=e){let t=await Q.promises.readdir(i,{withFileTypes:!0});t.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of t){let c=Z.join(i,a.name);if(a.isDirectory()){o.push(...await At(e,c));continue}if(!a.isFile()||!ln.has(Z.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Z.relative(e,c)})}return o}function St(e,i){return e.map((t)=>({key:pn(t.relativePath),input:t.absolutePath,name:hn(t.relativePath),...yn(t.absolutePath)?{options:{storage:i}}:{}}))}function yn(e){return Le(e)==="possible"}function bn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function xn(e){let i=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),t=new Set,o=8;for(let a=0;a<i.length;a+=8)await Promise.all(i.slice(a,a+8).map(async([c,l])=>{let m=l.variants.filter((u)=>u.format==="png").sort((u,y)=>u.width-y.width)[0];try{let u=await an(new Uint8Array(await Q.promises.readFile(m?.path??l.fallback.path)));if(bn(u.data))t.add(c)}catch{t.add(c)}}));return t}function wn(e,i){let t=[];for(let o of i){let a=e[o],c=a?.variants.filter((m)=>m.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((m)=>{let u;try{return u=Q.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)Q.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,t.push(o),!wt.has(o))wt.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return t}async function $n(e){let i=[],t=8;for(let o=0;o<e.length;o+=8){let a=e.slice(o,o+8),c=await Promise.all(a.map(async(l)=>{try{return await cn(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));i.push(...c.filter((l)=>l!==null))}return i}function We(e){return Z.join(e,"undecodable.json")}function Sn(e){try{let i=Q.readFileSync(We(e),"utf-8"),t=JSON.parse(i);return t&&typeof t==="object"?t:{}}catch{return{}}}function Cn(e,i){try{Q.mkdirSync(Z.dirname(We(e)),{recursive:!0}),Q.writeFileSync(We(e),JSON.stringify(i))}catch{}}function Ct(e){try{let i=Q.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function kt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Lo(e){let i=kt(e);return i?be().catalog.get(i):void 0}function jo(e){let i=kt(e);return i?be().transparent.has(i):!1}function Bo(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),t=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<t).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function Nh(e){let i=Lo(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:Bo(i).map(({format:t,srcset:o})=>({type:`image/${t}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:jo(e)?void 0:i.placeholder?.dataUrl}}function ls(){let e=be();e.catalog=new Map,e.transparent=new Set}function Rn(e){let i=be();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function Mh(e,i,t={}){if(!e||!Q.existsSync(e))return ls(),{count:0,fingerprint:""};if(t.offThread){let v=await Fe("delivery",{publicDir:e,outputDir:i});if(v!==ke)return Rn(v.state),v.result}let o=await At(e);if(o.length===0)return ls(),{count:0,fingerprint:""};let a=Sn(i),c=o.filter((v)=>{let b=a[v.relativePath];if(!b)return!0;let w=Ct(v.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(c.length===0)return ls(),{count:0,fingerprint:""};let l=$t(Z.join(i,"_stx","images"),`${fn}:${vt()}`),m={outDir:Z.join(i,"_stx","images"),storage:$t(Z.join(i,"_stx","images"),`${dn}:${vt()}`),baseUrl:ye,widths:un,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},u=c,y;try{y=await bt({...m,entries:St(c,l)})}catch(v){if(u=await $n(c),u.length===c.length)throw v;let b=new Set(u.map((A)=>A.relativePath)),w=!1;for(let A of c){if(b.has(A.relativePath))continue;let k=Ct(A.absolutePath);if(!k)continue;a[A.relativePath]=k,w=!0}if(w)Cn(i,a);if(u.length===0)return ls(),{count:0,fingerprint:""};y=await bt({...m,entries:St(u,l)})}let S=await xn(y.entries),h=wn(y.entries,S),C=be();C.catalog=new Map(Object.entries(y.entries)),C.transparent=S;let x=S.size===0&&h.length===0?y.fingerprint:Rt("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...S].sort(),droppedWebp:h.sort()})).digest("hex");return{count:u.length,fingerprint:x}}class Pt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,t,o){let a=ii(e,o);if(a!==void 0)return a;for(let c of ai(e,i,t,o))if(await s(c))return c;return null}}var ue=new Pt;var re="\x00stx-boolean-attribute";function He(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var An=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function qe(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||An.has(i)}function se(e,i){let t=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)t.push(p(c));continue}if(a===re){t.push(p(c));continue}t.push(`${p(c)}="${vn(c,He(String(a)))}"`)}return t}function ae(e,i){let t=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){t.push(p(c));continue}if(typeof a==="object")continue;t.push(`${p(c)}="${vn(c,He(String(a)))}"`)}return t}function kn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Xe={name:"StxLink",aliases:["stx-link"],render(e,i,t){let o=kn(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",m=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,u=[];if(o.reactive)u.push(`:href="${n(o.value)}"`);else u.push(`href="${n(wr(o.value,"navigable"))}"`);if(a)u.push(`class="${n(a)}"`);if(u.push("data-stx-link"),u.push(`data-stx-active-class="${n(c)}"`),u.push(`data-stx-exact-active-class="${n(l)}"`),m)u.push("data-stx-prefetch");let y=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(y)u.push(`data-stx-active-match="${n(y)}"`);let S=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...se(e,S)),u.push(...ae(e,S)),`<a ${u.join(" ")}>${i}</a>`}};var Pn=new Map;function Ve(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return Pn.get(i)}var In={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ze=[320,640,768,1024,1280,1536,1920];function V(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function Ie(e,i,t=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return t}function Ge(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),t=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=In[a];if(l)t.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))t.push(`(max-width: ${m}px) ${c}`)}}else t.push(o);return t.join(", ")}function Ke(e,i,t,o){return i.map((a)=>`${ve(e,a,void 0,t,o)} ${a}w`).join(", ")}function _n(e,i,t,o,a){return i.map((c)=>{let l=t?t*c:void 0;return`${ve(e,l,void 0,o,a)} ${c}x`}).join(", ")}function ve(e,i,t,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(t)c.push(`h_${t}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(t)c.set("h",String(t));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(t)c.set("height",String(t));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function En(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Nn(e,i,t="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${t}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Je={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,t){let o=V(e,"src")||"",a=Lo(o),c=V(e,"alt")||"",l=V(e,"width")||(a?String(a.source.width):void 0),m=V(e,"height")||(a?String(a.source.height):void 0),u=V(e,"sizes"),y=V(e,"srcset"),S=V(e,"densities"),h=V(e,"format"),C=jo(o)||Ve(o)?.transparent===!0,x=V(e,"placeholder")||(a&&!C?"thumbhash":void 0),v=V(e,"placeholderColor")||"#e5e7eb",b=V(e,"provider"),w=V(e,"class")||V(e,"className")||"",A=V(e,"style")||"",k=V(e,"objectFit")||V(e,"fit"),R=V(e,"objectPosition")||V(e,"position"),B=V(e,"quality"),G=Ie(e,"lazy",!0),M=Ie(e,"preload",!1),F=Ie(e,"priority",!1),H=V(e,"loading"),E=V(e,"decoding")||"async",T=!!a||Ie(e,"picture",!1)||!!h,O=l?Number.parseInt(l):void 0,q=m?Number.parseInt(m):void 0,z=y||"",X="";if(a)z=a.sources[a.fallback.format]||"",X=u?Ge(u):"100vw";else if(!z&&u&&b&&b!=="local"&&b!=="static")z=Ke(o,Ze,b,h),X=Ge(u);else if(!z&&S){let I=S.split(/\s+/).map((_)=>Number.parseFloat(_.replace("x","")));z=_n(o,I,O,b,h)}else if(u)X=Ge(u);let L=[];if(A)L.push(A);if(k)L.push(`object-fit:${k}`);if(R)L.push(`object-position:${R}`);if(O&&q)L.push(`aspect-ratio:${O}/${q}`);let D=[],ce=x==="blur"||x==="color"||x==="thumbhash";if(ce&&!C){let I=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:v}:Ve(o);if(I&&x==="color")L.push(`background-color:${I.color}`),D.push("backgroundColor");else if(I)L.push(`background-color:${I.color}`),L.push(`background-image:url(${I.dataUrl})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundColor","backgroundImage");else{let _=Nn(O||16,q||9,v);L.push(`background-image:url(${_})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage")}}else if(!ce&&x&&x!=="empty"&&x!=="none")L.push(`background-image:url(${n(x)})`),L.push("background-size:cover"),L.push("background-repeat:no-repeat"),D.push("backgroundImage");let $e=a?.fallback.url||ve(o,O,q,b,h),K=[];if(K.push(`src="${n(wr($e,"fetched"))}"`),K.push(`alt="${n(c)}"`),l)K.push(`width="${n(l)}"`);if(m)K.push(`height="${n(m)}"`);let le=H||(F||M?"eager":G?"lazy":"");if(le)K.push(`loading="${n(le)}"`);if(F)K.push('fetchpriority="high"');if(K.push(`decoding="${n(E)}"`),w)K.push(`class="${n(w)}"`);if(L.length>0)K.push(`style="${n(L.join(";"))}"`);if(z)K.push(`srcset="${n(wr(z,"fetched"))}"`);if(X)K.push(`sizes="${n(X)}"`);let te=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(D.length>0){let I=typeof e.static.onload==="string"?e.static.onload:"",_=En(D)+(I?`;${I}`:"");K.push(`onload="${n(_)}"`),te.add("onload")}K.push(...se(e,te)),K.push(...ae(e,te));let Te=`<img ${K.join(" ")} />`,j="";if(M){let _=h==="webp"?"image/webp":h==="avif"?"image/avif":"";j=`<link rel="preload" as="image" href="${n($e)}"${_?` type="${_}"`:""}${z?` imagesrcset="${n(z)}"`:""}${X?` imagesizes="${n(X)}"`:""} />
3
+ `}if(T){let I=[];if(a)for(let _ of Bo(a))I.push(`<source type="image/${_.format}" srcset="${n(_.srcset)}"${X?` sizes="${n(X)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let _=ve(o,O,q,b,"avif"),ee=z?Ke(o,Ze,b,"avif"):`${_}`;I.push(`<source type="image/avif" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let _=ve(o,O,q,b,"webp"),ee=z?Ke(o,Ze,b,"webp"):`${_}`;I.push(`<source type="image/webp" srcset="${n(ee)}"${X?` sizes="${n(X)}"`:""} />`)}return`${j}<picture>
4
4
  ${I.join(`
5
5
  `)}
6
- ${De}
7
- </picture>`}return`${j}${De}`}};var It="/images/safe-image-default.svg";function fe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var On=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${It}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Ye={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,t){let o=fe(e,"src")||"",a=fe(e,"alt")||"",c=fe(e,"fallback")||It,l=fe(e,"class")||fe(e,"className")||"",m=fe(e,"fallbackClassName")||"",u=[];if(u.push(`src="${n(o)}"`),u.push(`alt="${n(a)}"`),l)u.push(`class="${n(l)}"`);if(u.push(`data-fallback="${n(c)}"`),m)u.push(`data-fallback-class="${n(m)}"`);u.push('onerror="window.__stxSafeImageHandler(this)"');let y=new Set(["src","alt","fallback","class","className","fallbackClassName"]);u.push(...ie(e,y)),u.push(...ae(e,y));let S=`<img ${u.join(" ")} />`,h=t.context;if(!h.__safeImageHandlerEmitted)return h.__safeImageHandlerEmitted=!0,`${On}${S}`;return S}};function Qe(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function xe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t){let o=xe(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var et={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,t){let o=Qe(xe(e,"color")||"#6366f1"),a=Qe(xe(e,"initialColor")||xe(e,"initial-color")||""),c=Qe(xe(e,"height")||"3px"),l=_e(e,"duration",2000),m=_e(e,"throttle",200),u=_e(e,"zIndex",999999)||_e(e,"z-index",999999),y=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
6
+ ${Te}
7
+ </picture>`}return`${j}${Te}`}};var It="/images/safe-image-default.svg";function de(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var On=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${It}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Ye={name:"SafeImage",aliases:["safe-image","safe-img"],render(e,i,t){let o=de(e,"src")||"",a=de(e,"alt")||"",c=de(e,"fallback")||It,l=de(e,"class")||de(e,"className")||"",m=de(e,"fallbackClassName")||"",u=[];if(u.push(`src="${n(o)}"`),u.push(`alt="${n(a)}"`),l)u.push(`class="${n(l)}"`);if(u.push(`data-fallback="${n(c)}"`),m)u.push(`data-fallback-class="${n(m)}"`);u.push('onerror="window.__stxSafeImageHandler(this)"');let y=new Set(["src","alt","fallback","class","className","fallbackClassName"]);u.push(...se(e,y)),u.push(...ae(e,y));let S=`<img ${u.join(" ")} />`,h=t.context;if(!h.__safeImageHandlerEmitted)return h.__safeImageHandlerEmitted=!0,`${On}${S}`;return S}};function Qe(e){return e.replace(/[;{}()]/g,"").replace(/url/gi,"")}function xe(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}function _e(e,i,t){let o=xe(e,i);if(o!==void 0){let a=Number.parseInt(o,10);if(!Number.isNaN(a))return a}return t}var et={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(e,i,t){let o=Qe(xe(e,"color")||"#6366f1"),a=Qe(xe(e,"initialColor")||xe(e,"initial-color")||""),c=Qe(xe(e,"height")||"3px"),l=_e(e,"duration",2000),m=_e(e,"throttle",200),u=_e(e,"zIndex",999999)||_e(e,"z-index",999999),y=a?`linear-gradient(to right, ${a}, ${o})`:o;return`
8
8
  <div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${c};background:${y};z-index:${u};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
9
9
  <div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
10
10
  </div>
@@ -28,7 +28,7 @@ ${De}
28
28
  @media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
29
29
  .stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
30
30
  .stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
31
- </style>`}};function de(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Ot={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},it={name:"StxDrawer",aliases:["stx-drawer"],render(e,i,t){let o=de(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=de(e,"side")||"right",l=de(e,"size")||"md",m=de(e,"closeOnBackdrop")!=="false",u=de(e,"closeOnEscape")!=="false",y=de(e,"overlay")!=="false",S=Ot[l]||Ot.md,h=c==="left",C=h?"left:0":"right:0",x=h?"translateX(-100%)":"translateX(100%)",v=h?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${m}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;${y?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
31
+ </style>`}};function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let t=e.static[i];if(typeof t==="string")return t;return}var Ot={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},rt={name:"StxDrawer",aliases:["stx-drawer"],render(e,i,t){let o=ge(e,"id");if(!o)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let a=n(o),c=ge(e,"side")||"right",l=ge(e,"size")||"md",m=ge(e,"closeOnBackdrop")!=="false",u=ge(e,"closeOnEscape")!=="false",y=ge(e,"overlay")!=="false",S=Ot[l]||Ot.md,h=c==="left",C=h?"left:0":"right:0",x=h?"translateX(-100%)":"translateX(100%)",v=h?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${a}" class="stx-drawer-backdrop" data-stx-drawer="${a}" data-close-backdrop="${m}" data-close-escape="${u}" style="display:none;position:fixed;inset:0;z-index:99999;${y?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
32
32
  <div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${C};width:${S};max-width:100vw;transform:${x};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
33
33
  <div style="padding:1.5rem">${i}</div>
34
34
  </div>
@@ -37,6 +37,6 @@ ${De}
37
37
  @media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
38
38
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
39
39
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
40
- </style>`}};import{existsSync as Tn,readFileSync as Dn}from"fs";var Oe=new Map,Bt=new Set;function jn(e){if(Bt.has(e))return;Bt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Mn(e){let i=process.cwd();for(let t of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(Tn(t))return t;for(let t of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(t)}catch{}return null}function Ln(e){if(Oe.has(e))return Oe.get(e);let i=Mn(e);if(!i)return jn(e),null;try{let t=JSON.parse(Dn(i,"utf8"));return Oe.set(e,t),t}catch{return null}}function zn(e,i,t,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${t/2} ${o/2})`);if(i.hFlip)a.push(`translate(${t} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function Un(e,i){let t=i,o=e.icons[t],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[t];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;t=u.parent,o=e.icons[t]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:zn(o.body,a,c,l),width:c,height:l}}function ge(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var ot={name:"Icon",aliases:["icon","stx-icon"],render(e,i,t){let o=ge(e,"name")??ge(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let w=o.split(":");a=w[0],c=w[1]}let l=n(ge(e,"size")||"24"),m=n(ge(e,"color")||"currentColor"),u=n(ge(e,"class")||""),y=n(ge(e,"style")||""),S=Oe.get(a)??Ln(a);if(!S)return`<!-- Icon: collection "${a}" not loaded -->`;let h=Un(S,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,x=h.body;if(m!=="currentColor")x=x.replace(/currentColor/g,m);let v=u?` class="${u}"`:"",b=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${v}${b}>${x}</svg>`}};function Tt(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}function Dt(e,i){let t=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(t);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var at={name:"Suspense",aliases:["suspense"],render(e,i,t){let o=Dt(i,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Tt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Tt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Be(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}var ct={name:"TransitionGroup",aliases:["transition-group"],render(e,i,t){let o=(Be(e,"name")||"v").replace(/["'<>]/g,""),a=(Be(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Be(e,"class"),l=Be(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${i}</${a}>`}};function jt(e=ue){e.registerBuiltin(Xe),e.registerBuiltin(Je),e.registerBuiltin(Ye),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at),e.registerBuiltin(ct)}var Mt=new Map;function Fn(e){let i=Mt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Mt.set(e.source,i);return i}var Lt=new WeakMap;function zt(e){let i=Lt.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Lt.set(e,i);let t=i;return(o)=>!/[a-z]/.test(o)&&t.has(o.toLowerCase())}function Wn(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function Ut(e,i,t){let o=[],a=0,c=typeof t==="function"?t:t?(l)=>t.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Fn(i);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let w=l+1+y.length;while(w<e.length&&e[w]!==">")w++;a=w+1;continue}let S=l+1+y.length,h=null,C=S,x=-1,v=!1;while(S<e.length){let w=e[S];if(h){if(w==="\\"&&S+1<e.length){S+=2;continue}if(w===h)h=null;S++;continue}if(w==='"'||w==="'"){h=w,S++;continue}if(w==="/"&&S+1<e.length&&e[S+1]===">"){x=S+2,v=!0;break}if(w===">"){x=S+1;break}S++}if(x===-1){a=l+1;continue}let b=e.slice(C,v?x-2:x-1).trim();if(v)o.push({fullMatch:e.slice(l,x),tagName:y,attributes:b,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let w=`<${y}`,k=`</${y}>`,P=1,R=x,B=-1;while(P>0&&R<e.length){let F=e.indexOf(w,R),W=e.indexOf(k,R);if(W===-1)break;if(F!==-1&&F<W){let E=e[F+w.length];if(E===" "||E===">"||E==="/"||E===`
41
- `||E==="\t"){let T=Wn(e,F+w.length);if(e[T-1]!=="/")P++;R=T+1}else R=F+w.length}else{if(P--,P===0){B=W;break}R=W+k.length}}if(B===-1){a=x;continue}let K=e.slice(x,B),M=B+k.length;o.push({fullMatch:e.slice(l,M),tagName:y,attributes:b,content:K,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function lt(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ft(e,i){try{let t=Buffer.from(e,"base64").toString("utf8");return JSON.parse(t)}catch{}try{let t=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(t)}catch(t){if(i?.debug)console.error("Error decoding __stx_ prop:",t);return e}}function Te(e,i){let t=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")t++;else if(c==="}"){if(t--,t===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Wt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Te(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Ht(e){let i=[],t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o&&e[t]!==l){if(e[t]==="\\"&&t+1<o)t++,c+=e[t];else c+=e[t];t++}if(t<o)t++}else if(e[t]==="{")c=Te(e,t),t+=c.length;else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Hn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),qn=new Set([":for","x-for","v-for","@for"]),Xn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Vn(e){return ut(e).map((i)=>[i.start,i.end])}function ut(e){let i=[],t=new Map;for(let o of ci(e)){let a=o.name.toLowerCase();if(o.closing){let y=t.get(a)?.pop();if(y)y.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Ht(o.attributes).find((y)=>qn.has(y.name)):void 0,m=typeof l?.value==="string"?l.value:null,u=m!==null?{start:o.start,end:o.end,names:J(m)}:null;if(u)i.push(u);if(!o.selfClosing&&!Xn.has(a)){let y=t.get(a);if(!y)y=[],t.set(a,y);y.push(u)}}return i}function qt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>qt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function cc(e,i){if(!/:[\w-]+=/.test(e))return e;let t=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Vn(e));let l=new Set([...rt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function m(h){return a.some(([C,x])=>h>=C&&h<x)}let u=[],y=new Map,S=256;for(let h of ci(t)){if(h.closing||m(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let x=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),v=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,b,w=C,k=!1;while((b=v.exec(C))!==null){if(xr(C,b.index,!0)?.kind==="attribute")continue;let P=b[1],R=b[2];if(gl(P))continue;if(O(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let B=Object.keys(i),K=Object.values(i),M=R.match(/^([a-zA-Z_$][\w$]*)/);if(M&&!B.includes(M[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(M[1]))continue;let F=JSON.stringify([B,R]),W=y.get(F);if(!W){if(W=Function(...B,`return (${R})`),y.size>=S)y.clear();y.set(F,W)}let E=W(...K);if(P==="class"){let T=U(qt(E));if(T){let N=w.match(/\sclass="([^"]*)"/);if(N)w=w.replace(N[0],()=>` class="${N[1]} ${T}"`);else w=w.replace(b[0],()=>` class="${T}"`)}else w=w.replace(b[0],"");k=!0;continue}if(Hn.has(P)){if(E)w=w.replace(b[0],` ${P}`);else w=w.replace(b[0],"");k=!0;continue}if(E===null||E===void 0||E===!1)w=w.replace(b[0],"");else{let T=x&&typeof E==="object"?JSON.stringify(E):String(E),N=wn(P,T);w=w.replace(b[0],()=>` ${P}="${N}"`)}k=!0}catch(B){if(B instanceof oe)throw B;continue}}if(k){let P=h.selfClosing?" /":"",B=`<${h.name}${w}${P}>`;u.push({start:h.start,end:h.end,replacement:B})}}if(u.length>0){let h=Array(u.length*2+1),C=0;for(let x=0;x<u.length;x++){let{start:v,end:b,replacement:w}=u[x];h[x*2]=t.slice(C,v),h[x*2+1]=w,C=b}h[u.length*2]=t.slice(C),t=h.join("")}return t}import Xt from"fs";import Vt from"path";var Zt=!1;function Zn(e,i,t,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),m=(h)=>{if(l.size===0)return!1;let C=r(h),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let v of l){let b=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(C))return!0}return!1},u=new Set(ml),y=(h)=>{if(!h.includes("-")||h.startsWith("@")||h.startsWith(":")||h.startsWith("x-")||h.startsWith("__"))return h;if(h.startsWith("aria-")||h.startsWith("data-"))return h;return h.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},S=(h,C)=>{let x=y(h);if(c.static[x]=C,x!==h)c.staticNames[x]=h};for(let[h,C]of Object.entries(e)){let x=h.startsWith("x-")&&!u.has(h)&&!h.startsWith("x-bind:")&&!h.startsWith("x-on:")?`:${h.slice(2)}`:h;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let v=y(x.slice(6));c.serverDynamic[v]=Ft(C,t);continue}if(x.startsWith(":")){let v=y(x.slice(1)),b=C===re?v:C;if(v==="if"||v==="for"||v==="show"){c.clientReactive[v]=b;continue}if(o){c.clientReactive[v]=b;continue}if(O(b,a)){c.clientReactive[v]=b;continue}if(m(b)){c.clientReactive[v]=b;continue}try{if(!f(b)){if(t.debug)console.error(`Unsafe expression in :${v} binding: ${b}`);c.clientReactive[v]=b;continue}let w=Object.keys(i),k=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(st(b).some((M)=>!k.has(M)&&!w.includes(M)&&(!(M in globalThis)||P.has(M)))){c.clientReactive[v]=b;continue}let K=d(b,w)(...Object.values(i));if(c.serverDynamic[v]=K,v!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[v]=x.slice(1)}catch{c.clientReactive[v]=b}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let v=Gn(C,a);if(v!==null){c.clientReactive[y(x)]=v;continue}let b=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(f(w)){let P=d(w,Object.keys(i))(...Object.values(i));S(x,P!=null?String(P):"")}else{if(t.debug)console.error(`Unsafe expression in ${x}: ${w}`);S(x,C)}}catch(w){if(t.debug)console.error(`Error evaluating expression for ${x}:`,w);S(x,C)}else{let w=C,k=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=k.exec(C))!==null)try{let R=P[1];if(!f(R)){if(t.debug)console.error(`Unsafe expression in ${x}: ${R}`);continue}let K=d(R,Object.keys(i))(...Object.values(i));w=w.replace(P[0],String(K??""))}catch(R){if(t.debug)console.error(`Error evaluating expression in ${x}:`,R)}S(x,w)}continue}S(x,C===re?"true":lt(C))}return c}function Gn(e,i){if(i.size===0)return null;let t=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(t)];if(!o.some((m)=>O(m[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Kn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Jn(e,i,t){if(!e.includes("@"))return e;if(!Kn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,i,t)}catch{return e}}function me(e){let i={},t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o){let m=e[t];if(m==="\\"&&t+1<o){t++,c+=e[t],t++;continue}if(m===l){t++;break}c+=m,t++}}else if(e[t]==="{"){c=Te(e,t),t+=c.length;let l=Wt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i[a]=c}else i[a]=re}return i}function Gt(e){return Object.entries(e).map(([i,t])=>t===re?i:`${i}="${Yn(t)}"`).join(" ")}function Yn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qn(e){let i=new Set,t=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=t.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))i.add(a)}return[...i].sort()}async function Nf(e,i,t,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Vt.dirname(t),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(u)){let[C,x,v]=h,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=v,k,P=[];while((k=b.exec(v))!==null){let[R,B,K,M]=k,F=null,W=null;if(M.startsWith(".")||M.startsWith("/")){let N=Vt.resolve(l,M);if(N.endsWith(".stx"))W=N;else{let H=`${N}.stx`;try{if(Xt.statSync(H).isFile())W=H}catch{try{if(Xt.statSync(N).isDirectory())F=N}catch{}}}}else F=Os(M,l);if(!F&&!W)continue;let E=!1,T=(N,H)=>{c.set(N,H),c.set(N.toLowerCase(),H);let z=N.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(z,H),a.add(H)};if(K&&W)T(K,W),E=!0;else if(B){let N=B.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let q=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(q)return{source:q[1],local:q[2]};return{source:z,local:z}}),H=F?yr(F):null;for(let{source:z,local:q}of N){let L=null;if(W)L=W;else if(H)L=H.get(z)??H.get(z.toLowerCase())??H.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)T(q,L),E=!0}}if(E)P.push({start:k.index,end:k.index+R.length})}if(P.length===0)continue;for(let R=P.length-1;R>=0;R--)w=w.slice(0,P[R].start)+w.slice(P[R].end);m.push({start:h.index,end:h.index+C.length,value:`<script${x}>${w}</script>`})}if(m.length===0)return e;let y=[],S=0;for(let h of m)y.push(e.slice(S,h.start),h.value),S=h.end;return y.push(e.slice(S)),y.join("")}async function er(e,i,t,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,S]=u,h=S.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let x=C.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),k=null,P=Ns(C,t,o);for(let R of P)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(w,k),l.set(b,k),l.set(b.toLowerCase(),k);let R=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${w} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function tr(e,i,t,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let S=y.index,h=S+y[0].length-1,C=1,x=h+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let v=c.substring(h+1,x),b=x+1,w=v.match(/^\s*['"]([^'"]+)['"]/);if(!w){u.lastIndex=0;continue}let k=w[1],P,R=v.slice(w[0].length),B=R.match(/^\s*,\s*/);if(B)P=R.slice(B[0].length).trim();let K={};if(P)try{K=A(P,i)}catch(N){let H=N instanceof Error?N.message:String(N);c=c.replace(c.substring(S,b),`[Error parsing component props: ${H}]`);continue}let M="",F=b,E=c.substring(b).match(/^([\s\S]*?)@endcomponent/);if(E)M=E[1].trim(),F=b+E[0].length;let T=await Fe(k,K,M,l,i,t,o,m,a);c=c.substring(0,S)+T+c.substring(F),u.lastIndex=0}return c}async function nr(e,i,t,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=ir(c);if(u.size>0){let b=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...b,...u])]}let y=G(c);c=y.output;let S=rt(i);return c=await v(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await v(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(Sr)),c=await v(c,/[a-z][a-z0-9]*/,!1,Sr),c=y.restore(c),c;async function v(b,w,k,P){if(!b)return b;let R=b,B=Ut(R,w,P),K=ut(R),M=new Map;for(let E=B.length-1;E>=0;E--){let T=B[E],N=k?V(T.tagName):T.tagName,H=me(Jn(T.attributes,i,t)),z=K.filter(({start:I,end:_})=>T.startIndex>=I&&T.startIndex<_),q=z.length>0,L=new Set(S);for(let I of z)for(let _ of I.names)L.add(_);let D=Zn(H,i,o,q,L);if(typeof D.clientReactive.for==="string")for(let I of J(D.clientReactive.for))L.add(I);let ce=ue.getBuiltin(T.tagName),$e=ce?await Cr(T.tagName,l,i,t,o):!1,Y=T.tagName==="Image"&&Ms([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>yr(I).has("Image"));if(ce&&!$e&&!Y){let I={context:i,filePath:t,options:o,dependencies:a},_=ce.render(D,T.content,I);if(Object.keys(D.events).length>0){let ee=Gt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Kt(_,D.clientReactive);M.set(E,_);continue}if(!k&&T.tagName.includes("-")&&!await Cr(N,l,i,t,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},j=await Fe(N,le,y.restore(T.content),l,i,t,o,m,a,[...L],te,T.tagName);if(j=rr(j,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(V),_=ft(j,!0);if(I.length&&_){if(!Object.hasOwn(me(j.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))j=j.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+j.slice(_.insertPos);let ne=we(j);j=j.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+j.slice(ne.insertPos)}let ee=ft(j,!0);if(ee){let ne=me(j.slice(ee.insertPos,ee.tagEnd)),Se=we(j),Yt=me(j.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Yt,"data-stx-native-host-owner"))j=j.slice(0,Se.insertPos)+" data-stx-native-host-owner"+j.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(j);if(I){let _=Gt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");j=j.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+j.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)j=Kt(j,D.clientReactive);M.set(E,j)}if(M.size===0)return R;let F="",W=0;for(let E=0;E<B.length;E++){let T=M.get(E);if(T===void 0)continue;F+=R.slice(W,B[E].startIndex),F+=T,W=B[E].endIndex}return F+=R.slice(W),F}}function Kt(e,i){let t=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([S])=>!t.has(S)),c=a.filter(([S])=>!o.has(S)).map(([S])=>V(S)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let S=a.map(([C,x])=>`:${V(C)}="${x.replace(/"/g,"&quot;")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${h} ${S}`+l.substring(m.insertPos)}let u=i.if;if(u)l=`<template :if="${u.replace(/"/g,"&quot;")}">${l}</template>`;let y=i.for;if(y){let S=i.key,h=S?` :key="${S.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${y.replace(/"/g,"&quot;")}"${h}>${l}</template>`}return l}function rr(e,i,t=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=i.serverDynamic.class??i.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let v=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=v.test(l)?l.replace(v,(w,k,P,R,B)=>`${k}class="${n(`${lt(P??R??B)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+b+e.slice(c.tagEnd),c.tagEnd+=b.length-l.length,l=b}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:t,S=new Set(Object.keys(me(l))),h=new Set(["class","className"]);for(let v of Object.keys(i.static)){let b=i.staticNames[v]??v;if(S.has(b)||y.has(v)||!u&&!qe(b))h.add(v)}for(let v of Object.keys(i.serverDynamic)){let b=i.serverDynamicNames?.[v]??v;if(S.has(b)||y.has(v)||!u&&!qe(b))h.add(v)}let C=[];if(u){for(let[v,b]of Object.entries(i.static)){if(h.has(v)||b!==!0&&b!==re)continue;h.add(v),C.push(`${n(i.staticNames?.[v]??v)}="true"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!0)continue;h.add(v),C.push(`${n(i.serverDynamicNames?.[v]??v)}="true"`)}}let x=[...ie(i,h),...ae(i,h),...C];if(u){for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!1)continue;let w=i.serverDynamicNames?.[v]??v;x.push(`${n(w)}="false"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let k=i.serverDynamicNames?.[v]??v;x.push(`${n(k)}="${n(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let i=Jt(e,0);if(i)return i;let t=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(t)return{insertPos:t.index+1+t[1].length,tagEnd:dt(e,t.index+1+t[1].length)};return null}function ft(e,i=!1){let t=we(e);if(!t)return null;let o=e.slice(t.insertPos,t.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Jt(e,t.tagEnd+1):t;return a&&i?sr(e,a)??a:a}function sr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",i.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let S=e.indexOf("-->",o+4);if(S<0)return null;o=e.indexOf("<",S+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let S=new RegExp(`</${m}\\s*>`,"gi");if(S.lastIndex=y+1,!S.exec(e))return null;o=e.indexOf("<",S.lastIndex);continue}else{let S=me(e.slice(u,y)),h=a>0&&(Object.hasOwn(S,"data-stx-component-wrapper")||Object.hasOwn(S,"data-stx-native-host-owner"));if(c===void 0&&!h&&Object.hasOwn(S,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!t.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&h)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Jt(e,i){let t=i;while(t<e.length){let o=e.slice(t),a=o.match(/^\s+/);if(a){t+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",t+4);if(m===-1)return null;t=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,t+c[0].length);if(u===-1)return null;t=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:t+1+l[1].length,tagEnd:dt(e,t+1+l[1].length)}}return null}function dt(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function ir(e){let i=new Set;for(let t of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=t[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of ui(t[2]))i.add(a);for(let a of t[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function us(e,i,t,o,a){if(!Zt)jt(ue),Zt=!0;let c=await Nf(e,i,t,o,a);c=await er(c,i,t,o,a),c=await tr(c,i,t,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Ne,(h,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let S=c;if(c=await nr(y.output,i,t,o,a),c===S)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Qn(c);if(m.length>0)console.warn(`[stx] ${t}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
- export{Lo,jo,Bo,Ih,ls,Oh,cc,Nf,us};
40
+ </style>`}};import{existsSync as Tn,readFileSync as Dn}from"fs";var Ne=new Map,Bt=new Set;function jn(e){if(Bt.has(e))return;Bt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Mn(e){let i=process.cwd();for(let t of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(Tn(t))return t;for(let t of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(t)}catch{}return null}function Ln(e){if(Ne.has(e))return Ne.get(e);let i=Mn(e);if(!i)return jn(e),null;try{let t=JSON.parse(Dn(i,"utf8"));return Ne.set(e,t),t}catch{return null}}function zn(e,i,t,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${t/2} ${o/2})`);if(i.hFlip)a.push(`translate(${t} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function Un(e,i){let t=i,o=e.icons[t],a={hFlip:!1,vFlip:!1,rotate:0};for(let m=0;!o&&m<8;m++){let u=e.aliases?.[t];if(!u)return null;if(u.hFlip)a.hFlip=!a.hFlip;if(u.vFlip)a.vFlip=!a.vFlip;if(u.rotate)a.rotate=((a.rotate+u.rotate)%4+4)%4;t=u.parent,o=e.icons[t]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:zn(o.body,a,c,l),width:c,height:l}}function me(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var it={name:"Icon",aliases:["icon","stx-icon"],render(e,i,t){let o=me(e,"name")??me(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let w=o.split(":");a=w[0],c=w[1]}let l=n(me(e,"size")||"24"),m=n(me(e,"color")||"currentColor"),u=n(me(e,"class")||""),y=n(me(e,"style")||""),S=Ne.get(a)??Ln(a);if(!S)return`<!-- Icon: collection "${a}" not loaded -->`;let h=Un(S,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,x=h.body;if(m!=="currentColor")x=x.replace(/currentColor/g,m);let v=u?` class="${u}"`:"",b=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${v}${b}>${x}</svg>`}};function Tt(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}function Dt(e,i){let t=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(t);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var at={name:"Suspense",aliases:["suspense"],render(e,i,t){let o=Dt(i,"fallback"),a=o.rest,c=Dt(a,"error"),l=c.rest,m=o.region??Tt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Tt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${m}</div><div data-stx-suspense-error hidden>${u}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function Oe(e,...i){for(let t of i){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let o=e.static[t];if(typeof o==="string")return o}return}var ct={name:"TransitionGroup",aliases:["transition-group"],render(e,i,t){let o=(Oe(e,"name")||"v").replace(/["'<>]/g,""),a=(Oe(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Oe(e,"class"),l=Oe(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${i}</${a}>`}};function jt(e=ue){e.registerBuiltin(Xe),e.registerBuiltin(Je),e.registerBuiltin(Ye),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(it),e.registerBuiltin(at),e.registerBuiltin(ct)}var Mt=new Map;function Fn(e){let i=Mt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),Mt.set(e.source,i);return i}var Lt=new WeakMap;function zt(e){let i=Lt.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Lt.set(e,i);let t=i;return(o)=>!/[a-z]/.test(o)&&t.has(o.toLowerCase())}function Wn(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function Ut(e,i,t){let o=[],a=0,c=typeof t==="function"?t:t?(l)=>t.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Fn(i);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let w=l+1+y.length;while(w<e.length&&e[w]!==">")w++;a=w+1;continue}let S=l+1+y.length,h=null,C=S,x=-1,v=!1;while(S<e.length){let w=e[S];if(h){if(w==="\\"&&S+1<e.length){S+=2;continue}if(w===h)h=null;S++;continue}if(w==='"'||w==="'"){h=w,S++;continue}if(w==="/"&&S+1<e.length&&e[S+1]===">"){x=S+2,v=!0;break}if(w===">"){x=S+1;break}S++}if(x===-1){a=l+1;continue}let b=e.slice(C,v?x-2:x-1).trim();if(v)o.push({fullMatch:e.slice(l,x),tagName:y,attributes:b,content:"",startIndex:l,endIndex:x,isSelfClosing:!0}),a=x;else{let w=`<${y}`,A=`</${y}>`,k=1,R=x,B=-1;while(k>0&&R<e.length){let F=e.indexOf(w,R),H=e.indexOf(A,R);if(H===-1)break;if(F!==-1&&F<H){let E=e[F+w.length];if(E===" "||E===">"||E==="/"||E===`
41
+ `||E==="\t"){let T=Wn(e,F+w.length);if(e[T-1]!=="/")k++;R=T+1}else R=F+w.length}else{if(k--,k===0){B=H;break}R=H+A.length}}if(B===-1){a=x;continue}let G=e.slice(x,B),M=B+A.length;o.push({fullMatch:e.slice(l,M),tagName:y,attributes:b,content:G,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function lt(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ft(e,i){try{let t=Buffer.from(e,"base64").toString("utf8");return JSON.parse(t)}catch{}try{let t=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(t)}catch(t){if(i?.debug)console.error("Error decoding __stx_ prop:",t);return e}}function Be(e,i){let t=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")t++;else if(c==="}"){if(t--,t===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Wt(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Be(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function Ht(e){let i=[],t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o&&e[t]!==l){if(e[t]==="\\"&&t+1<o)t++,c+=e[t];else c+=e[t];t++}if(t<o)t++}else if(e[t]==="{")c=Be(e,t),t+=c.length;else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Hn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),qn=new Set([":for","x-for","v-for","@for"]),Xn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Vn(e){return ut(e).map((i)=>[i.start,i.end])}function ut(e){let i=[],t=new Map;for(let o of li(e)){let a=o.name.toLowerCase();if(o.closing){let y=t.get(a)?.pop();if(y)y.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?Ht(o.attributes).find((y)=>qn.has(y.name)):void 0,m=typeof l?.value==="string"?l.value:null,u=m!==null?{start:o.start,end:o.end,names:Y(m)}:null;if(u)i.push(u);if(!o.selfClosing&&!Xn.has(a)){let y=t.get(a);if(!y)y=[],t.set(a,y);y.push(u)}}return i}function qt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>qt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function lc(e,i){if(!/:[\w-]+=/.test(e))return e;let t=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Vn(e));let l=new Set([...st(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function m(h){return a.some(([C,x])=>h>=C&&h<x)}let u=[],y=new Map,S=256;for(let h of li(t)){if(h.closing||m(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let x=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),v=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,b,w=C,A=!1;while((b=v.exec(C))!==null){if(xr(C,b.index,!0)?.kind==="attribute")continue;let k=b[1],R=b[2];if(ml(k))continue;if(N(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let B=Object.keys(i),G=Object.values(i),M=R.match(/^([a-zA-Z_$][\w$]*)/);if(M&&!B.includes(M[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(M[1]))continue;let F=JSON.stringify([B,R]),H=y.get(F);if(!H){if(H=Function(...B,`return (${R})`),y.size>=S)y.clear();y.set(F,H)}let E=H(...G);if(k==="class"){let T=W(qt(E));if(T){let O=w.match(/\sclass="([^"]*)"/);if(O)w=w.replace(O[0],()=>` class="${O[1]} ${T}"`);else w=w.replace(b[0],()=>` class="${T}"`)}else w=w.replace(b[0],"");A=!0;continue}if(Hn.has(k)){if(E)w=w.replace(b[0],` ${k}`);else w=w.replace(b[0],"");A=!0;continue}if(E===null||E===void 0||E===!1)w=w.replace(b[0],"");else{let T=x&&typeof E==="object"?JSON.stringify(E):String(E),O=vn(k,T);w=w.replace(b[0],()=>` ${k}="${O}"`)}A=!0}catch(B){if(B instanceof ie)throw B;continue}}if(A){let k=h.selfClosing?" /":"",B=`<${h.name}${w}${k}>`;u.push({start:h.start,end:h.end,replacement:B})}}if(u.length>0){let h=Array(u.length*2+1),C=0;for(let x=0;x<u.length;x++){let{start:v,end:b,replacement:w}=u[x];h[x*2]=t.slice(C,v),h[x*2+1]=w,C=b}h[u.length*2]=t.slice(C),t=h.join("")}return t}import Xt from"fs";import Vt from"path";var Zt=!1;function Zn(e,i,t,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),m=(h)=>{if(l.size===0)return!1;let C=r(h),x=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&l.has(x))return!0;for(let v of l){let b=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(C))return!0}return!1},u=new Set(hl),y=(h)=>{if(!h.includes("-")||h.startsWith("@")||h.startsWith(":")||h.startsWith("x-")||h.startsWith("__"))return h;if(h.startsWith("aria-")||h.startsWith("data-"))return h;return h.replace(/-([a-z0-9])/g,(C,x)=>x.toUpperCase())},S=(h,C)=>{let x=y(h);if(c.static[x]=C,x!==h)c.staticNames[x]=h};for(let[h,C]of Object.entries(e)){let x=h.startsWith("x-")&&!u.has(h)&&!h.startsWith("x-bind:")&&!h.startsWith("x-on:")?`:${h.slice(2)}`:h;if(x.startsWith("@")){c.events[x]=C;continue}if(x.startsWith("__stx_")){let v=y(x.slice(6));c.serverDynamic[v]=Ft(C,t);continue}if(x.startsWith(":")){let v=y(x.slice(1)),b=C===re?v:C;if(v==="if"||v==="for"||v==="show"){c.clientReactive[v]=b;continue}if(o){c.clientReactive[v]=b;continue}if(N(b,a)){c.clientReactive[v]=b;continue}if(m(b)){c.clientReactive[v]=b;continue}try{if(!f(b)){if(t.debug)console.error(`Unsafe expression in :${v} binding: ${b}`);c.clientReactive[v]=b;continue}let w=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),k=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(ot(b).some((M)=>!A.has(M)&&!w.includes(M)&&(!(M in globalThis)||k.has(M)))){c.clientReactive[v]=b;continue}let G=d(b,w)(...Object.values(i));if(c.serverDynamic[v]=G,v!==x.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[v]=x.slice(1)}catch{c.clientReactive[v]=b}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let v=Gn(C,a);if(v!==null){c.clientReactive[y(x)]=v;continue}let b=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(f(w)){let k=d(w,Object.keys(i))(...Object.values(i));S(x,k!=null?String(k):"")}else{if(t.debug)console.error(`Unsafe expression in ${x}: ${w}`);S(x,C)}}catch(w){if(t.debug)console.error(`Error evaluating expression for ${x}:`,w);S(x,C)}else{let w=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,k;while((k=A.exec(C))!==null)try{let R=k[1];if(!f(R)){if(t.debug)console.error(`Unsafe expression in ${x}: ${R}`);continue}let G=d(R,Object.keys(i))(...Object.values(i));w=w.replace(k[0],String(G??""))}catch(R){if(t.debug)console.error(`Error evaluating expression in ${x}:`,R)}S(x,w)}continue}S(x,C===re?"true":lt(C))}return c}function Gn(e,i){if(i.size===0)return null;let t=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(t)];if(!o.some((m)=>N(m[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let m of o)c+=e.slice(l,m.index).replace(/[`\\$]/g,(u)=>`\\${u}`),c+=`\${${m[1]}}`,l=m.index+m[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(m)=>`\\${m}`),`\`${c}\``}var Kn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Jn(e,i,t){if(!e.includes("@"))return e;if(!Kn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return oe(e,i,t)}catch{return e}}function pe(e){let i={},t=0,o=e.length;while(t<o){while(t<o&&/\s/.test(e[t]))t++;if(t>=o)break;let a="";while(t<o&&!/[\s=]/.test(e[t]))a+=e[t],t++;if(!a)break;while(t<o&&/\s/.test(e[t]))t++;if(t<o&&e[t]==="="){t++;while(t<o&&/\s/.test(e[t]))t++;let c="";if(t<o&&(e[t]==='"'||e[t]==="'")){let l=e[t];t++;while(t<o){let m=e[t];if(m==="\\"&&t+1<o){t++,c+=e[t],t++;continue}if(m===l){t++;break}c+=m,t++}}else if(e[t]==="{"){c=Be(e,t),t+=c.length;let l=Wt(c);if(l!==null){i[`:${a}`]=l;continue}}else while(t<o&&!/\s/.test(e[t]))c+=e[t],t++;i[a]=c}else i[a]=re}return i}function Gt(e){return Object.entries(e).map(([i,t])=>t===re?i:`${i}="${Yn(t)}"`).join(" ")}function Yn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qn(e){let i=new Set,t=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=t.exec(e))!==null){let a=o[1];if(ue.isBuiltin(a))i.add(a)}return[...i].sort()}async function Mf(e,i,t,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Vt.dirname(t),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(u)){let[C,x,v]=h,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=v,A,k=[];while((A=b.exec(v))!==null){let[R,B,G,M]=A,F=null,H=null;if(M.startsWith(".")||M.startsWith("/")){let O=Vt.resolve(l,M);if(O.endsWith(".stx"))H=O;else{let q=`${O}.stx`;try{if(Xt.statSync(q).isFile())H=q}catch{try{if(Xt.statSync(O).isDirectory())F=O}catch{}}}}else F=Os(M,l);if(!F&&!H)continue;let E=!1,T=(O,q)=>{c.set(O,q),c.set(O.toLowerCase(),q);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(z,q),a.add(q)};if(G&&H)T(G,H),E=!0;else if(B){let O=B.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let X=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X)return{source:X[1],local:X[2]};return{source:z,local:z}}),q=F?yr(F):null;for(let{source:z,local:X}of O){let L=null;if(H)L=H;else if(q)L=q.get(z)??q.get(z.toLowerCase())??q.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(L)T(X,L),E=!0}}if(E)k.push({start:A.index,end:A.index+R.length})}if(k.length===0)continue;for(let R=k.length-1;R>=0;R--)w=w.slice(0,k[R].start)+w.slice(k[R].end);m.push({start:h.index,end:h.index+C.length,value:`<script${x}>${w}</script>`})}if(m.length===0)return e;let y=[],S=0;for(let h of m)y.push(e.slice(S,h.start),h.value),S=h.end;return y.push(e.slice(S)),y.join("")}async function er(e,i,t,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,S]=u,h=S.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let x=C.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),A=null,k=Ns(C,t,o);for(let R of k)try{if(await Bun.file(R).exists()){A=R;break}}catch{}if(A){l.set(w,A),l.set(b,A),l.set(b.toLowerCase(),A);let R=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,A),a.add(A),o.debug)console.log(`Imported component: ${w} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function tr(e,i,t,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let S=y.index,h=S+y[0].length-1,C=1,x=h+1;while(x<c.length&&C>0){if(c[x]==="(")C++;else if(c[x]===")"){if(C--,C===0)break}x++}if(C!==0)break;let v=c.substring(h+1,x),b=x+1,w=v.match(/^\s*['"]([^'"]+)['"]/);if(!w){u.lastIndex=0;continue}let A=w[1],k,R=v.slice(w[0].length),B=R.match(/^\s*,\s*/);if(B)k=R.slice(B[0].length).trim();let G={};if(k)try{G=P(k,i)}catch(O){let q=O instanceof Error?O.message:String(O);c=c.replace(c.substring(S,b),`[Error parsing component props: ${q}]`);continue}let M="",F=b,E=c.substring(b).match(/^([\s\S]*?)@endcomponent/);if(E)M=E[1].trim(),F=b+E[0].length;let T=await ze(A,G,M,l,i,t,o,m,a);c=c.substring(0,S)+T+c.substring(F),u.lastIndex=0}return c}async function nr(e,i,t,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let m=i.__processedComponents,u=ir(c);if(u.size>0){let b=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...b,...u])]}let y=J(c);c=y.output;let S=st(i);return c=await v(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await v(c,/[A-Z][a-zA-Z0-9]*/,!0,zt(Sr)),c=await v(c,/[a-z][a-z0-9]*/,!1,Sr),c=y.restore(c),c;async function v(b,w,A,k){if(!b)return b;let R=b,B=Ut(R,w,k),G=ut(R),M=new Map;for(let E=B.length-1;E>=0;E--){let T=B[E],O=A?U(T.tagName):T.tagName,q=pe(Jn(T.attributes,i,t)),z=G.filter(({start:I,end:_})=>T.startIndex>=I&&T.startIndex<_),X=z.length>0,L=new Set(S);for(let I of z)for(let _ of I.names)L.add(_);let D=Zn(q,i,o,X,L);if(typeof D.clientReactive.for==="string")for(let I of Y(D.clientReactive.for))L.add(I);let ce=ue.getBuiltin(T.tagName),$e=ce?await Cr(T.tagName,l,i,t,o):!1,K=T.tagName==="Image"&&Ms([...Object.keys(D.static),...Object.keys(D.serverDynamic),...Object.keys(D.clientReactive)],Object.keys(D.events),{...D.static,...D.serverDynamic})&&(o._pluginComponentDirs??[]).some((I)=>yr(I).has("Image"));if(ce&&!$e&&!K){let I={context:i,filePath:t,options:o,dependencies:a},_=ce.render(D,T.content,I);if(Object.keys(D.events).length>0){let ee=Gt(D.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ee}`)}if(Object.keys(D.clientReactive).length>0)_=Kt(_,D.clientReactive);M.set(E,_);continue}if(!A&&T.tagName.includes("-")&&!await Cr(O,l,i,t,o))continue;let le={};for(let[I,_]of Object.entries(D.static))le[I]=_;for(let[I,_]of Object.entries(D.serverDynamic))le[I]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(D.clientReactive),events:Object.keys(D.events)},j=await ze(O,le,y.restore(T.content),l,i,t,o,m,a,[...L],te,T.tagName);if(j=rr(j,D,te.declaredProps,te.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let I=te.reactiveProps.filter((ne)=>!te.consumedProps.has(ne)&&!["if","for","show","key","ref"].includes(ne)).map(U),_=ft(j,!0);if(I.length&&_){if(!Object.hasOwn(pe(j.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))j=j.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+j.slice(_.insertPos);let ne=we(j);j=j.slice(0,ne.insertPos)+` data-stx-native-forward="${I.join(" ")}"`+j.slice(ne.insertPos)}let ee=ft(j,!0);if(ee){let ne=pe(j.slice(ee.insertPos,ee.tagEnd)),Se=we(j),Yt=pe(j.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(ne,"data-stx-native-host-root")&&!Object.hasOwn(Yt,"data-stx-native-host-owner"))j=j.slice(0,Se.insertPos)+" data-stx-native-host-owner"+j.slice(Se.insertPos)}}if(Object.keys(D.events).length>0){let I=we(j);if(I){let _=Gt(D.events),ee=Object.keys(D.events).map((ne)=>ne.replace(/^@/,"").split(".")[0]).join(" ");j=j.substring(0,I.insertPos)+` data-stx-parent-events="${ee}" ${_}`+j.substring(I.insertPos)}}if(Object.keys(D.clientReactive).length>0)j=Kt(j,D.clientReactive);M.set(E,j)}if(M.size===0)return R;let F="",H=0;for(let E=0;E<B.length;E++){let T=M.get(E);if(T===void 0)continue;F+=R.slice(H,B[E].startIndex),F+=T,H=B[E].endIndex}return F+=R.slice(H),F}}function Kt(e,i){let t=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([S])=>!t.has(S)),c=a.filter(([S])=>!o.has(S)).map(([S])=>U(S)).join(" "),l=e,m=a.length>0?we(l):null;if(m){let S=a.map(([C,x])=>`:${U(C)}="${x.replace(/"/g,"&quot;")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${h} ${S}`+l.substring(m.insertPos)}let u=i.if;if(u)l=`<template :if="${u.replace(/"/g,"&quot;")}">${l}</template>`;let y=i.for;if(y){let S=i.key,h=S?` :key="${S.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${y.replace(/"/g,"&quot;")}"${h}>${l}</template>`}return l}function rr(e,i,t=new Set,o=new Set,a=!1){let c=ft(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=i.serverDynamic.class??i.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let v=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=v.test(l)?l.replace(v,(w,A,k,R,B)=>`${A}class="${n(`${lt(k??R??B)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+b+e.slice(c.tagEnd),c.tagEnd+=b.length-l.length,l=b}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:t,S=new Set(Object.keys(pe(l))),h=new Set(["class","className"]);for(let v of Object.keys(i.static)){let b=i.staticNames[v]??v;if(S.has(b)||y.has(v)||!u&&!qe(b))h.add(v)}for(let v of Object.keys(i.serverDynamic)){let b=i.serverDynamicNames?.[v]??v;if(S.has(b)||y.has(v)||!u&&!qe(b))h.add(v)}let C=[];if(u){for(let[v,b]of Object.entries(i.static)){if(h.has(v)||b!==!0&&b!==re)continue;h.add(v),C.push(`${n(i.staticNames?.[v]??v)}="true"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!0)continue;h.add(v),C.push(`${n(i.serverDynamicNames?.[v]??v)}="true"`)}}let x=[...se(i,h),...ae(i,h),...C];if(u){for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b!==!1)continue;let w=i.serverDynamicNames?.[v]??v;x.push(`${n(w)}="false"`)}for(let[v,b]of Object.entries(i.serverDynamic)){if(h.has(v)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let A=i.serverDynamicNames?.[v]??v;x.push(`${n(A)}="${n(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,c.insertPos)} ${x.join(" ")}${e.slice(c.insertPos)}`}function we(e){let i=Jt(e,0);if(i)return i;let t=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(t)return{insertPos:t.index+1+t[1].length,tagEnd:dt(e,t.index+1+t[1].length)};return null}function ft(e,i=!1){let t=we(e);if(!t)return null;let o=e.slice(t.insertPos,t.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Jt(e,t.tagEnd+1):t;return a&&i?sr(e,a)??a:a}function sr(e,i){if(!e.includes("data-stx-native-host-root"))return null;let t=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",i.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let S=e.indexOf("-->",o+4);if(S<0)return null;o=e.indexOf("<",S+3);continue}let l=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(o));if(!l){o=e.indexOf("<",o+1);continue}let m=l[2].toLowerCase(),u=o+l[0].length,y=dt(e,u);if(l[1]){if(a--,c!==void 0&&a<c)c=void 0;if(a<=0)return null}else if(m==="script"||m==="style"){let S=new RegExp(`</${m}\\s*>`,"gi");if(S.lastIndex=y+1,!S.exec(e))return null;o=e.indexOf("<",S.lastIndex);continue}else{let S=pe(e.slice(u,y)),h=a>0&&(Object.hasOwn(S,"data-stx-component-wrapper")||Object.hasOwn(S,"data-stx-native-host-owner"));if(c===void 0&&!h&&Object.hasOwn(S,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!t.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&h)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Jt(e,i){let t=i;while(t<e.length){let o=e.slice(t),a=o.match(/^\s+/);if(a){t+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",t+4);if(m===-1)return null;t=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,t+c[0].length);if(u===-1)return null;t=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:t+1+l[1].length,tagEnd:dt(e,t+1+l[1].length)}}return null}function dt(e,i){let t="";for(let o=i;o<e.length;o++){let a=e[o];if(t){if(a==="\\")o++;else if(a===t)t=""}else if(a==='"'||a==="'")t=a;else if(a===">")return o}return e.length}function ir(e){let i=new Set;for(let t of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=t[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of di(t[2]))i.add(a);for(let a of t[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function us(e,i,t,o,a){if(!Zt)jt(ue),Zt=!0;let c=await Mf(e,i,t,o,a);c=await er(c,i,t,o,a),c=await tr(c,i,t,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=fe(c,Me,(h,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let S=c;if(c=await nr(y.output,i,t,o,a),c===S)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Qn(c);if(m.length>0)console.warn(`[stx] ${t}: unresolved component tag(s) after render passes: ${m.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
+ export{Lo,jo,Bo,Nh,ls,Mh,lc,Mf,us};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Se,yi,bi,cg,Mt,Gc,lg,Jc,Yh,Le,bn,je}from"./chunk-xj3my6b9.js";import{rl,r}from"./chunk-fwktw49p.js";import"./chunk-yv1vw0kx.js";import"./chunk-2qngyyaz.js";import"./chunk-c9mdvpf5.js";import"./chunk-8y8kgw9s.js";import"./chunk-04z1xyrb.js";export{Se as BROWSER_CORE_IMPORTS,cg as STX_AUTO_IMPORTS,yi as extractAndStripCssImports,Le as extractBridgeData,rl as findInterpolationEnd,Jc as generateAutoImportDestructuring,Yh as generateBrowserAutoImportDestructuring,bn as generateServerDataBridge,Mt as injectBrowserCoreAutoImports,je as processClientScript,lg as referencesName,bi as renderVendorStyleTags,r as stripCommentsAndLiterals,Gc as transformAutoImports};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Qr,es}from"./chunk-e4jwhmpb.js";import{y}from"./chunk-a1htb5r5.js";import{a}from"./chunk-zen28e3p.js";import{Ke,re}from"./chunk-n7arptzc.js";import{Ja}from"./chunk-9fm8khcc.js";import{j}from"./chunk-cmnze7at.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as F,mkdirSync as S,copyFileSync as P,chmodSync as I,rmSync as ve}from"fs";import{join as c,basename as xe,resolve as X}from"path";import{spawn as z}from"child_process";import{platform as ye}from"os";function E(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=y(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var gu=`
2
+ import{Qr,es}from"./chunk-cca18z35.js";import{y}from"./chunk-xj3my6b9.js";import{a}from"./chunk-ng5revck.js";import{Xe,se}from"./chunk-s53wjw7y.js";import{Ya}from"./chunk-3esj6tb8.js";import{B}from"./chunk-ybq56wam.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as z,mkdirSync as S,copyFileSync as P,chmodSync as I,rmSync as ve}from"fs";import{join as c,basename as xe,resolve as X}from"path";import{spawn as _}from"child_process";import{platform as ye}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=y(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var mu=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -468,8 +468,8 @@ else if (data.type === 'event' && data.method) {
468
468
  }
469
469
  })();
470
470
  </script>
471
- `;function Sa(e={}){let{debug:r=!1,timeout:i=30000}=e;return gu.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${i}`)}function wh(){return!1}function vh(e,r={}){let i=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(i,(n,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return Sa(t)})}function ka(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let i=Sa(r),n=E(e,"head",`${i}
472
- `);if(n!==null)return n;let s=j(e);if(s){let t=s.index+s.tag.length;return e.slice(0,t)+`
471
+ `;function ka(e={}){let{debug:r=!1,timeout:i=30000}=e;return mu.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${i}`)}function xh(){return!1}function Sh(e,r={}){let i=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(i,(n,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return ka(t)})}function _a(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let i=ka(r),n=O(e,"head",`${i}
472
+ `);if(n!==null)return n;let s=B(e);if(s){let t=s.index+s.tag.length;return e.slice(0,t)+`
473
473
  ${i}`+e.slice(t)}return i+e}var ko={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(e,r)=>{let i=e.checked?"checked":"",n=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
474
474
  <input type="checkbox" class="craft-checkbox" ${i} ${n}>
475
475
  <span class="craft-checkbox-label">${r||e.label||""}</span>
@@ -484,7 +484,7 @@ ${i}`+e.slice(t)}return i+e}var ko={button:{nativeType:"craft-button",fallbackTa
484
484
  </details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:(e,r)=>{let i=e.variant||"info",n=e.title||"";return`<div class="craft-alert craft-alert-${i}" role="alert">
485
485
  ${n?`<div class="craft-alert-title">${n}</div>`:""}
486
486
  <div class="craft-alert-content">${r}</div>
487
- </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(e,r)=>{let i=e.content||"",n=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${i}" data-position="${n}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:te},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:ae},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:ie},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:ne},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let i=e.value||"",n=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${i}" min="${n}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},Zr=`
487
+ </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(e,r)=>{let i=e.content||"",n=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${i}" data-position="${n}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:te},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:re},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:ae},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:ie},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let i=e.value||"",n=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${i}" min="${n}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},Zr=`
488
488
  <style id="craft-component-styles">
489
489
  /* Craft Component Base Styles */
490
490
  .craft-button {
@@ -902,7 +902,7 @@ ${i}`+e.slice(t)}return i+e}var ko={button:{nativeType:"craft-button",fallbackTa
902
902
  }
903
903
  }
904
904
  </style>
905
- `,_a=`
905
+ `,Ca=`
906
906
  <script id="craft-component-runtime">
907
907
  (function() {
908
908
  if (window.__stxCraftComponentRuntime) return;
@@ -1006,19 +1006,19 @@ ${i}`+e.slice(t)}return i+e}var ko={button:{nativeType:"craft-button",fallbackTa
1006
1006
  document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
1007
1007
  })();
1008
1008
  </script>
1009
- `;function Ca(e,r={}){let{classPrefix:i="craft"}=r;if(!e.includes("craft-component-styles"))e=E(e,"head",`${Zr}
1010
- `)??Zr+e;if(!e.includes("craft-component-runtime"))e=E(e,"body",`${_a}
1011
- `)??e+_a;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(n,s,t)=>A("sidebar",s,t.trim(),r,i)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(n,s)=>A("sidebar",s,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(n,s,t)=>A(s,t,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(n,s,t,o)=>A(s,t,o.trim(),r,i)),e}function A(e,r,i,n,s){let t=n.components?.[e]||ko[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${i}</div>`;let o=N(r),d=[t.fallbackClasses||`${s}-${e}`];if(o.class)d.push(o.class),delete o.class;if(t.render)return o.__fallbackClasses=d.join(" "),t.render(o,i);let f=ue(o,t,d);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${f}>`;return`<${t.fallbackTag} ${f}>${i}</${t.fallbackTag}>`}function N(e){let r={},i=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,n;while((n=i.exec(e))!==null){let[s,t,o,d]=n,f=o??d;if(s.startsWith(":"))r[t]=f;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=f;else if(f===void 0)r[t]=!0;else r[t]=f}return r}function te(e,r){let i=B(String(e.id||`craft-sidebar-${fe(r||JSON.stringify(e))}`)),n=ce(e.spaces)||oe(r),s=n.length?[]:le(e.sections)||M(r),t=String(e.selectedSpace||n[0]?.id||""),o=n.find((v)=>v.id===t)||n[0],d=String(e.selectedItem||e.selected||(n.length?o?.sections[0]?.items[0]?.id:s[0]?.items[0]?.id)||""),f={id:i,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:d,sections:s,spaces:n,selectedSpace:t||void 0},p=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),l=Number(e.width||e.sidebarWidth||286),u=e.native===!1||e.native==="false"?"false":"true",b=f.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${T(f.searchPlaceholder)}"></div>`:"",m;if(n.length)m=de(n,t,d);else if(s.length)m=s.map((v)=>L(v,d)).join("");else m=r;return`<aside class="${x(p)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${x(i)}" data-native="${u}" style="--craft-sidebar-width:${l}px">
1009
+ `;function Ea(e,r={}){let{classPrefix:i="craft"}=r;if(!e.includes("craft-component-styles"))e=O(e,"head",`${Zr}
1010
+ `)??Zr+e;if(!e.includes("craft-component-runtime"))e=O(e,"body",`${Ca}
1011
+ `)??e+Ca;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(n,s,t)=>N("sidebar",s,t.trim(),r,i)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(n,s)=>N("sidebar",s,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(n,s,t)=>N(s,t,"",r,i)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(n,s,t,o)=>N(s,t,o.trim(),r,i)),e}function N(e,r,i,n,s){let t=n.components?.[e]||ko[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${i}</div>`;let o=F(r),d=[t.fallbackClasses||`${s}-${e}`];if(o.class)d.push(o.class),delete o.class;if(t.render)return o.__fallbackClasses=d.join(" "),t.render(o,i);let f=ue(o,t,d);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${f}>`;return`<${t.fallbackTag} ${f}>${i}</${t.fallbackTag}>`}function F(e){let r={},i=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,n;while((n=i.exec(e))!==null){let[s,t,o,d]=n,f=o??d;if(s.startsWith(":"))r[t]=f;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=f;else if(f===void 0)r[t]=!0;else r[t]=f}return r}function te(e,r){let i=R(String(e.id||`craft-sidebar-${fe(r||JSON.stringify(e))}`)),n=ce(e.spaces)||oe(r),s=n.length?[]:le(e.sections)||j(r),t=String(e.selectedSpace||n[0]?.id||""),o=n.find((v)=>v.id===t)||n[0],d=String(e.selectedItem||e.selected||(n.length?o?.sections[0]?.items[0]?.id:s[0]?.items[0]?.id)||""),f={id:i,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:d,sections:s,spaces:n,selectedSpace:t||void 0},p=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),l=Number(e.width||e.sidebarWidth||286),u=e.native===!1||e.native==="false"?"false":"true",b=f.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${T(f.searchPlaceholder)}"></div>`:"",m;if(n.length)m=de(n,t,d);else if(s.length)m=s.map((v)=>L(v,d)).join("");else m=r;return`<aside class="${x(p)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${x(i)}" data-native="${u}" style="--craft-sidebar-width:${l}px">
1012
1012
  ${b}
1013
1013
  ${m}
1014
1014
  </aside>
1015
- <script type="application/json" data-craft-sidebar-config="${x(i)}">${pe(f)}</script>`}function ae(e,r){let i=B(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${x(i)}">
1015
+ <script type="application/json" data-craft-sidebar-config="${x(i)}">${pe(f)}</script>`}function re(e,r){let i=R(String(e.id||e.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${x(i)}">
1016
1016
  ${e.label?`<div class="craft-sidebar-space-title">${T(String(e.label))}</div>`:""}
1017
1017
  ${r}
1018
- </section>`}function ie(e,r){let i=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${x(String(e.id||"section"))}">
1018
+ </section>`}function ae(e,r){let i=String(e.header||e.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${x(String(e.id||"section"))}">
1019
1019
  ${i?`<div class="craft-sidebar-section-title">${T(i)}</div>`:""}
1020
1020
  ${r}
1021
- </section>`}function ne(e,r){let i={id:String(e.id||B(String(e.label||r||"item"))),label:String(e.label||r||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return H(i,String(e.selected||"")==="true")}function M(e){let r=[],i=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,n;while((n=i.exec(e))!==null){let s=N(n[1]||""),t=n[2]||"",o=String(s.id||B(String(s.header||s.title||`section-${r.length+1}`))),d=String(s.header||s.title||o),f=se(t);r.push({id:o,header:d,title:d,items:f})}return r}function se(e){let r=[],i=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,n;while((n=i.exec(e))!==null){let s=N(n[1]||""),t=String(s.label||(n[2]||"").replace(/<[^>]*>/g,"").trim()),o=String(s.id||B(t||`item-${r.length+1}`));r.push({id:o,label:t,icon:s.icon?String(s.icon):void 0,badge:s.badge?String(s.badge):void 0,tintColor:s.tintColor?String(s.tintColor):void 0})}return r}function oe(e){let r=[],i=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,n;while((n=i.exec(e))!==null){let s=N(n[1]||""),t=n[2]||"",o=String(s.label||s.title||`Space ${r.length+1}`);r.push({id:String(s.id||B(o)),label:o,icon:s.icon?String(s.icon):void 0,tint:s.tint?String(s.tint):void 0,sections:M(t)})}return r}function ce(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function de(e,r,i){let n=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${x(t.id)}" data-selected="${t.id===r?"true":"false"}" title="${x(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${x(t.icon)}"></span>`:T((t.label||t.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${e.map((t)=>`<section class="craft-sidebar-space" data-space-id="${x(t.id)}" data-selected="${t.id===r?"true":"false"}">
1021
+ </section>`}function ie(e,r){let i={id:String(e.id||R(String(e.label||r||"item"))),label:String(e.label||r||""),icon:e.icon?String(e.icon):void 0,badge:e.badge?String(e.badge):void 0,tintColor:e.tintColor?String(e.tintColor):void 0};return H(i,String(e.selected||"")==="true")}function j(e){let r=[],i=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,n;while((n=i.exec(e))!==null){let s=F(n[1]||""),t=n[2]||"",o=String(s.id||R(String(s.header||s.title||`section-${r.length+1}`))),d=String(s.header||s.title||o),f=ne(t);r.push({id:o,header:d,title:d,items:f})}return r}function ne(e){let r=[],i=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,n;while((n=i.exec(e))!==null){let s=F(n[1]||""),t=String(s.label||(n[2]||"").replace(/<[^>]*>/g,"").trim()),o=String(s.id||R(t||`item-${r.length+1}`));r.push({id:o,label:t,icon:s.icon?String(s.icon):void 0,badge:s.badge?String(s.badge):void 0,tintColor:s.tintColor?String(s.tintColor):void 0})}return r}function oe(e){let r=[],i=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,n;while((n=i.exec(e))!==null){let s=F(n[1]||""),t=n[2]||"",o=String(s.label||s.title||`Space ${r.length+1}`);r.push({id:String(s.id||R(o)),label:o,icon:s.icon?String(s.icon):void 0,tint:s.tint?String(s.tint):void 0,sections:j(t)})}return r}function ce(e){if(!e)return;if(Array.isArray(e))return e;if(typeof e!=="string")return;try{let r=JSON.parse(e);return Array.isArray(r)?r:void 0}catch{return}}function de(e,r,i){let n=e.map((t)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${x(t.id)}" data-selected="${t.id===r?"true":"false"}" title="${x(t.label||t.id)}">${t.icon?`<span class="craft-sidebar-item-icon" data-icon="${x(t.icon)}"></span>`:T((t.label||t.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${e.map((t)=>`<section class="craft-sidebar-space" data-space-id="${x(t.id)}" data-selected="${t.id===r?"true":"false"}">
1022
1022
  ${t.label?`<div class="craft-sidebar-space-title">${T(t.label)}</div>`:""}
1023
1023
  ${t.sections.map((o)=>L(o,i)).join("")}
1024
1024
  </section>`).join("")}</div>
@@ -1029,7 +1029,7 @@ ${i}`+e.slice(t)}return i+e}var ko={button:{nativeType:"craft-button",fallbackTa
1029
1029
  ${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${x(e.icon)}"${i}></span>`:""}
1030
1030
  <span class="craft-sidebar-item-label">${T(e.label)}</span>
1031
1031
  ${e.badge?`<span class="craft-sidebar-item-badge">${T(e.badge)}</span>`:""}
1032
- </button>`}function B(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function fe(e){let r=5381;for(let i=0;i<e.length;i++)r=r*33^e.charCodeAt(i);return(r>>>0).toString(36)}function T(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function x(e){return T(e).replace(/`/g,"&#96;")}function pe(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ue(e,r,i){let n=[];n.push(`class="${i.join(" ")}"`),n.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)n.push(s);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,"&quot;");n.push(`${s}="${o}"`)}return n.join(" ")}function xh(e,r){ko[e]=r}function Sh(){return{...ko}}import{chmodSync as be,copyFileSync as ge,mkdtempSync as V,rmSync as me,writeFileSync as J}from"fs";import{tmpdir as W}from"os";import{join as O}from"path";function we(e){let r=Bun.spawnSync(["/usr/bin/plutil","-extract","Entitlements","xml1","-o","-","-"],{stdin:e});if(r.exitCode!==0)throw Error(`Could not extract the macOS profile entitlements: ${r.stderr.toString().trim()||r.stdout.toString().trim()}`);let i=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-","-"],{stdin:r.stdout});if(i.exitCode!==0)throw Error(`Could not convert the macOS profile entitlements: ${i.stderr.toString().trim()||i.stdout.toString().trim()}`);let n=JSON.parse(i.stdout.toString());if(!n||typeof n!=="object"||Array.isArray(n))throw Error("The macOS profile entitlements must be a dictionary.");return n}function he(e,r){let i=O(r,"Contents","embedded.provisionprofile");ge(e,i),be(i,420)}async function Q(e,r=[],i={}){if(process.platform!=="darwin")return;let n=i.entitlements,s;try{if(i.provisioningProfile){if(!i.identity||i.identity==="-")throw Error("A provisioning profile requires a signing identity.");let p=Bun.spawnSync(["/usr/bin/security","cms","-D","-i",i.provisioningProfile]);if(p.exitCode!==0)throw Error("Could not decode the macOS provisioning profile.");let l=we(p.stdout),u={};if(i.entitlements){let b=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",i.entitlements]);if(b.exitCode!==0)throw Error("Could not read the app entitlements plist.");u=JSON.parse(b.stdout.toString())}for(let b of["com.apple.application-identifier","com.apple.developer.team-identifier"])if(l[b])u[b]=l[b];if(s=V(O(W(),"stx-entitlements-")),n=O(s,"entitlements.plist"),J(n,JSON.stringify(u)),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",n]).exitCode!==0)throw Error("Could not generate the provisioned app entitlements.");he(i.provisioningProfile,e)}let t;if(r.length){let p=!1;if(n){let l=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",n]);if(l.exitCode!==0)throw Error("Could not read native parent entitlements.");p=JSON.parse(l.stdout.toString())["com.apple.security.app-sandbox"]===!0}if(s??=V(O(W(),"stx-entitlements-")),t=O(s,"helper.entitlements.plist"),J(t,JSON.stringify({"com.apple.security.cs.allow-jit":!0,...p?{"com.apple.security.app-sandbox":!0,"com.apple.security.inherit":!0}:{}})),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",t]).exitCode!==0)throw Error("Could not generate native helper entitlements.")}for(let p of[...r,e]){let l=i.hardenedRuntime?["--options","runtime"]:[];if(p===e&&n)l.push("--entitlements",n);if(p!==e&&t)l.push("--entitlements",t);let u=i.identity&&i.identity!=="-"?"--timestamp":"--timestamp=none",b=Bun.spawn(["/usr/bin/codesign","--force","--sign",i.identity||"-",u,...l,p],{stdout:"pipe",stderr:"pipe"}),[m,v]=await Promise.all([new Response(b.stderr).text(),b.exited]);if(v!==0)throw Error(`Could not sign native bundle ${p}: ${m.trim()}`)}let o=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[d,f]=await Promise.all([new Response(o.stderr).text(),o.exited]);if(f!==0)throw Error(`Invalid native bundle signature: ${d.trim()}`)}finally{if(s)me(s,{recursive:!0,force:!0})}}var Y=(e)=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function G(e){let r=new Set,i=(n,s,t)=>{if(typeof n==="string")return`${s}<string>${Y(n)}</string>`;if(typeof n==="boolean")return`${s}<${n}/>`;if(typeof n==="number"){if(!Number.isFinite(n))throw TypeError(`Non-finite Info.plist number at ${t}`);let o=Number.isSafeInteger(n)?"integer":"real";return`${s}<${o}>${n}</${o}>`}if(n!==null&&typeof n==="object"){let o=Array.isArray(n);if(!o&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw TypeError(`Unsupported Info.plist value at ${t}`);if(r.has(n))throw TypeError(`Cyclic Info.plist value at ${t}`);r.add(n);try{let d=o?"array":"dict",f=`${s} `,p=o?Array.from(n,(l,u)=>i(l,f,`${t}[${u}]`)):Object.entries(n).map(([l,u])=>`${f}<key>${Y(l)}</key>
1032
+ </button>`}function R(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function fe(e){let r=5381;for(let i=0;i<e.length;i++)r=r*33^e.charCodeAt(i);return(r>>>0).toString(36)}function T(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function x(e){return T(e).replace(/`/g,"&#96;")}function pe(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ue(e,r,i){let n=[];n.push(`class="${i.join(" ")}"`),n.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)n.push(s);else if(t!==!1&&t!==void 0&&t!==null){let o=String(t).replace(/"/g,"&quot;");n.push(`${s}="${o}"`)}return n.join(" ")}function kh(e,r){ko[e]=r}function _h(){return{...ko}}import{chmodSync as be,copyFileSync as ge,mkdtempSync as V,rmSync as me,writeFileSync as J}from"fs";import{tmpdir as W}from"os";import{join as D}from"path";function we(e){let r=Bun.spawnSync(["/usr/bin/plutil","-extract","Entitlements","xml1","-o","-","-"],{stdin:e});if(r.exitCode!==0)throw Error(`Could not extract the macOS profile entitlements: ${r.stderr.toString().trim()||r.stdout.toString().trim()}`);let i=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-","-"],{stdin:r.stdout});if(i.exitCode!==0)throw Error(`Could not convert the macOS profile entitlements: ${i.stderr.toString().trim()||i.stdout.toString().trim()}`);let n=JSON.parse(i.stdout.toString());if(!n||typeof n!=="object"||Array.isArray(n))throw Error("The macOS profile entitlements must be a dictionary.");return n}function he(e,r){let i=D(r,"Contents","embedded.provisionprofile");ge(e,i),be(i,420)}async function Q(e,r=[],i={}){if(process.platform!=="darwin")return;let n=i.entitlements,s;try{if(i.provisioningProfile){if(!i.identity||i.identity==="-")throw Error("A provisioning profile requires a signing identity.");let p=Bun.spawnSync(["/usr/bin/security","cms","-D","-i",i.provisioningProfile]);if(p.exitCode!==0)throw Error("Could not decode the macOS provisioning profile.");let l=we(p.stdout),u={};if(i.entitlements){let b=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",i.entitlements]);if(b.exitCode!==0)throw Error("Could not read the app entitlements plist.");u=JSON.parse(b.stdout.toString())}for(let b of["com.apple.application-identifier","com.apple.developer.team-identifier"])if(l[b])u[b]=l[b];if(s=V(D(W(),"stx-entitlements-")),n=D(s,"entitlements.plist"),J(n,JSON.stringify(u)),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",n]).exitCode!==0)throw Error("Could not generate the provisioned app entitlements.");he(i.provisioningProfile,e)}let t;if(r.length){let p=!1;if(n){let l=Bun.spawnSync(["/usr/bin/plutil","-convert","json","-o","-",n]);if(l.exitCode!==0)throw Error("Could not read native parent entitlements.");p=JSON.parse(l.stdout.toString())["com.apple.security.app-sandbox"]===!0}if(s??=V(D(W(),"stx-entitlements-")),t=D(s,"helper.entitlements.plist"),J(t,JSON.stringify({"com.apple.security.cs.allow-jit":!0,...p?{"com.apple.security.app-sandbox":!0,"com.apple.security.inherit":!0}:{}})),Bun.spawnSync(["/usr/bin/plutil","-convert","xml1",t]).exitCode!==0)throw Error("Could not generate native helper entitlements.")}for(let p of[...r,e]){let l=i.hardenedRuntime?["--options","runtime"]:[];if(p===e&&n)l.push("--entitlements",n);if(p!==e&&t)l.push("--entitlements",t);let u=i.identity&&i.identity!=="-"?"--timestamp":"--timestamp=none",b=Bun.spawn(["/usr/bin/codesign","--force","--sign",i.identity||"-",u,...l,p],{stdout:"pipe",stderr:"pipe"}),[m,v]=await Promise.all([new Response(b.stderr).text(),b.exited]);if(v!==0)throw Error(`Could not sign native bundle ${p}: ${m.trim()}`)}let o=Bun.spawn(["/usr/bin/codesign","--verify","--strict",e],{stdout:"pipe",stderr:"pipe"}),[d,f]=await Promise.all([new Response(o.stderr).text(),o.exited]);if(f!==0)throw Error(`Invalid native bundle signature: ${d.trim()}`)}finally{if(s)me(s,{recursive:!0,force:!0})}}var Y=(e)=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function G(e){let r=new Set,i=(n,s,t)=>{if(typeof n==="string")return`${s}<string>${Y(n)}</string>`;if(typeof n==="boolean")return`${s}<${n}/>`;if(typeof n==="number"){if(!Number.isFinite(n))throw TypeError(`Non-finite Info.plist number at ${t}`);let o=Number.isSafeInteger(n)?"integer":"real";return`${s}<${o}>${n}</${o}>`}if(n!==null&&typeof n==="object"){let o=Array.isArray(n);if(!o&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw TypeError(`Unsupported Info.plist value at ${t}`);if(r.has(n))throw TypeError(`Cyclic Info.plist value at ${t}`);r.add(n);try{let d=o?"array":"dict",f=`${s} `,p=o?Array.from(n,(l,u)=>i(l,f,`${t}[${u}]`)):Object.entries(n).map(([l,u])=>`${f}<key>${Y(l)}</key>
1033
1033
  ${i(u,f,`${t}.${l}`)}`);return p.length?`${s}<${d}>
1034
1034
  ${p.join(`
1035
1035
  `)}
@@ -1038,21 +1038,21 @@ ${s}</${d}>`:`${s}<${d}/>`}finally{r.delete(n)}}throw TypeError(`Unsupported Inf
1038
1038
  <plist version="1.0">
1039
1039
  ${i(e,"","infoPlist")}
1040
1040
  </plist>
1041
- `}async function Ea(e){if(e.window?.cornerRadius!==void 0&&(!Number.isFinite(e.window.cornerRadius)||e.window.cornerRadius<0||e.window.cornerRadius>128))throw Error("Native window cornerRadius must be between 0 and 128");let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||D(),format:e.format||"app",error:`Input file not found: ${e.input}`};let i=e.target||D(),n=e.format||Be(i);if(e.backend&&i!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!F(X(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let s=e.output||c(process.cwd(),"dist","native");if(!F(s))S(s,{recursive:!0});let t=await a(process.cwd()),o=await Ja(e.input,{context:e.context,options:{...t,isDev:!1},injectCSS:!0});if(o=ka(o,{debug:e.verbose}),o=Ca(o),!o.includes("craft-component-styles")){if(o.includes("</head>"))o=o.replace("</head>",`${Zr}
1042
- </head>`)}let d=e.name||xe(e.input,".stx"),f=e.version||"1.0.0",p=e.craftPath||Ta(e.runtimeProfile);if(!p)return{success:!1,target:i,format:n,error:"Craft native binary not found on PATH. Run pantry install craft, or specify craftPath for framework development."};if(e.runtimeProfile==="webview"){if(i!=="macos")throw Error("The webview runtime profile is currently available on macOS only.");let u=Bun.spawnSync([p,"--runtime-profile"],{stdout:"pipe",stderr:"pipe",timeout:1e4});if(u.exitCode!==0||u.stdout.toString().trim()!=="webview")throw Error("The requested Craft webview runtime is unavailable. Upgrade Craft with Pantry before building.")}if(p=Qr(e.craftPath,e.runtimeProfile),e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${i}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${p}`);let l;switch(i){case"macos":l=await Se(o,d,f,s,n,e,p);break;case"windows":l=await $e(o,d,f,s,n,e,p);break;case"linux":l=await Te(o,d,f,s,n,e,p);break;case"ios":l=await Pe(o,d,f,s,e,p);break;case"android":l=await Ie(o,d,f,s,e,p);break;default:l={success:!1,target:i,format:n,error:`Unsupported target: ${i}`}}return l.duration=Date.now()-r,l}catch(i){return{success:!1,target:e.target||D(),format:e.format||"app",error:i.message,duration:Date.now()-r}}}async function Se(e,r,i,n,s,t,o){let d=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,f=c(n,`${r}.app`),p=c(f,"Contents"),l=c(p,"MacOS"),u=c(p,"Resources");ve(f,{recursive:!0,force:!0}),S(l,{recursive:!0}),S(u,{recursive:!0});let b=c(u,"index.html");await Bun.write(b,e);let m="";if(t.sidebar?.enabled&&t.sidebar?.config)m=c(u,"sidebar-config.json"),await Bun.write(m,JSON.stringify(t.sidebar.config));let v=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",k=t.menubarOnly??t.systemTray,h=t.bundleStyle||(await ke(o)?"executable":"launcher");if(t.backend){if(!await Ce(o))throw Error("This Craft runtime does not support bundled backends. Upgrade Craft before building this app.");P(o,c(l,r)),I(c(l,r),493);let C=Ke("native-backend");try{let w=c(C,"launcher.ts"),U=c(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(w,`import { runNativeBackend } from ${JSON.stringify(U)}
1041
+ `}async function Ta(e){if(e.window?.cornerRadius!==void 0&&(!Number.isFinite(e.window.cornerRadius)||e.window.cornerRadius<0||e.window.cornerRadius>128))throw Error("Native window cornerRadius must be between 0 and 128");let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||q(),format:e.format||"app",error:`Input file not found: ${e.input}`};let i=e.target||q(),n=e.format||Be(i);if(e.backend&&i!=="macos")throw Error("Native backend bundles currently support macOS only.");if(e.backend&&!z(X(e.backend.entry)))throw Error(`Native backend not found: ${e.backend.entry}`);let s=e.output||c(process.cwd(),"dist","native");if(!z(s))S(s,{recursive:!0});let t=await a(process.cwd()),o=await Ya(e.input,{context:e.context,options:{...t,isDev:!1},injectCSS:!0});if(o=_a(o,{debug:e.verbose}),o=Ea(o),!o.includes("craft-component-styles")){if(o.includes("</head>"))o=o.replace("</head>",`${Zr}
1042
+ </head>`)}let d=e.name||xe(e.input,".stx"),f=e.version||"1.0.0",p=e.craftPath||$a(e.runtimeProfile);if(!p)return{success:!1,target:i,format:n,error:"Craft native binary not found on PATH. Run pantry install craft, or specify craftPath for framework development."};if(e.runtimeProfile==="webview"){if(i!=="macos")throw Error("The webview runtime profile is currently available on macOS only.");let u=Bun.spawnSync([p,"--runtime-profile"],{stdout:"pipe",stderr:"pipe",timeout:1e4});if(u.exitCode!==0||u.stdout.toString().trim()!=="webview")throw Error("The requested Craft webview runtime is unavailable. Upgrade Craft with Pantry before building.")}if(p=Qr(e.craftPath,e.runtimeProfile),e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${i}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${p}`);let l;switch(i){case"macos":l=await Se(o,d,f,s,n,e,p);break;case"windows":l=await $e(o,d,f,s,n,e,p);break;case"linux":l=await Te(o,d,f,s,n,e,p);break;case"ios":l=await Pe(o,d,f,s,e,p);break;case"android":l=await Ie(o,d,f,s,e,p);break;default:l={success:!1,target:i,format:n,error:`Unsupported target: ${i}`}}return l.duration=Date.now()-r,l}catch(i){return{success:!1,target:e.target||q(),format:e.format||"app",error:i.message,duration:Date.now()-r}}}async function Se(e,r,i,n,s,t,o){let d=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,f=c(n,`${r}.app`),p=c(f,"Contents"),l=c(p,"MacOS"),u=c(p,"Resources");ve(f,{recursive:!0,force:!0}),S(l,{recursive:!0}),S(u,{recursive:!0});let b=c(u,"index.html");await Bun.write(b,e);let m="";if(t.sidebar?.enabled&&t.sidebar?.config)m=c(u,"sidebar-config.json"),await Bun.write(m,JSON.stringify(t.sidebar.config));let v=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",k=t.menubarOnly??t.systemTray,h=t.bundleStyle||(await ke(o)?"executable":"launcher");if(t.backend){if(!await Ce(o))throw Error("This Craft runtime does not support bundled backends. Upgrade Craft before building this app.");P(o,c(l,r)),I(c(l,r),493);let C=Xe("native-backend");try{let w=c(C,"launcher.ts"),M=c(import.meta.dir,"native-backend"+(import.meta.path.endsWith(".ts")?".ts":".js"));await Bun.write(w,`import { runNativeBackend } from ${JSON.stringify(M)}
1043
1043
  import * as backend from ${JSON.stringify(X(t.backend.entry))}
1044
1044
  await runNativeBackend({ html: ${JSON.stringify(e)}, fetch: backend.default, shutdown: Reflect.get(backend, "shutdown"),
1045
1045
  maxRequestBodySize: ${t.backend.maxRequestBodySize??33554432} })
1046
- `);let R=Bun.spawn([process.execPath,"build",w,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",c(l,"stx-backend")],{stdout:"pipe",stderr:"pipe"}),[q,Z,ee]=await Promise.all([new Response(R.stdout).text(),new Response(R.stderr).text(),R.exited]);if(ee!==0)throw Error(`Native backend compilation failed: ${q}
1047
- ${Z}`)}finally{re(C)}await Bun.write(c(u,"craft.json"),`${JSON.stringify({backend:{executable:"stx-backend"},runtimeProfile:t.runtimeProfile||"full",title:t.window?.title||r,appName:r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools),frameless:Boolean(t.window?.frameless),transparent:Boolean(t.window?.transparent),cornerRadius:t.window?.cornerRadius??0,alwaysOnTop:Boolean(t.window?.alwaysOnTop),resizable:t.window?.resizable!==!1,hideDockIcon:Boolean(t.hideDockIcon),headless:Boolean(t.window?.startHidden),...t.trayPopover?{trayPopover:!0}:k?{menubarOnly:!0}:t.systemTray?{systemTray:!0}:{}},null,2)}
1046
+ `);let E=Bun.spawn([process.execPath,"build",w,"--compile","--minify","--no-compile-autoload-bunfig","--no-compile-autoload-dotenv","--outfile",c(l,"stx-backend")],{stdout:"pipe",stderr:"pipe"}),[A,Z,ee]=await Promise.all([new Response(E.stdout).text(),new Response(E.stderr).text(),E.exited]);if(ee!==0)throw Error(`Native backend compilation failed: ${A}
1047
+ ${Z}`)}finally{se(C)}await Bun.write(c(u,"craft.json"),`${JSON.stringify({backend:{executable:"stx-backend"},runtimeProfile:t.runtimeProfile||"full",title:t.window?.title||r,appName:r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools),frameless:Boolean(t.window?.frameless),transparent:Boolean(t.window?.transparent),cornerRadius:t.window?.cornerRadius??0,alwaysOnTop:Boolean(t.window?.alwaysOnTop),resizable:t.window?.resizable!==!1,hideDockIcon:Boolean(t.hideDockIcon),headless:Boolean(t.window?.startHidden),...t.trayPopover?{trayPopover:!0}:k?{menubarOnly:!0}:t.systemTray?{systemTray:!0}:{}},null,2)}
1048
1048
  `)}else if(h==="executable"){let C=c(l,r);P(o,C),I(C,493);let w={html:"index.html",title:t.window?.title||r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(t.trayPopover)w.trayPopover=!0;else if(k)w.menubarOnly=!0;else if(t.systemTray)w.systemTray=!0;if(t.window?.frameless)w.frameless=!0;if(t.window?.transparent)w.transparent=!0;if(t.window?.cornerRadius)w.cornerRadius=t.window.cornerRadius;if(t.window?.alwaysOnTop)w.alwaysOnTop=!0;if(t.window?.resizable===!1)w.resizable=!1;if(t.hideDockIcon)w.hideDockIcon=!0;if(t.window?.startHidden)w.headless=!0;await Bun.write(c(u,"craft.json"),`${JSON.stringify(w,null,2)}
1049
- `)}else{let C=c(l,"craft");P(o,C),I(C,493);let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",R=`#!/bin/bash
1049
+ `)}else{let C=c(l,"craft");P(o,C),I(C,493);let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",E=`#!/bin/bash
1050
1050
  set -euo pipefail
1051
1051
  DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
1052
1052
  RESOURCES="$DIR/../Resources"
1053
1053
  exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
1054
1054
  ${[`--title "${t.window?.title||r}"`,`--width ${t.window?.width||1200}`,`--height ${t.window?.height||800}`,t.trayPopover?"--tray-popover":k?"--menubar-only":t.systemTray?"--system-tray":"",t.devTools?"":"--no-devtools",t.window?.frameless?"--frameless":"",t.window?.transparent?"--transparent":"",t.window?.cornerRadius?`--corner-radius ${t.window.cornerRadius}`:"",t.window?.alwaysOnTop?"--always-on-top":"",t.window?.resizable===!1?"--no-resize":"",t.hideDockIcon?"--hide-dock-icon":"",t.window?.startHidden?"--headless":"",w].filter(Boolean).join(" \\\n ")}
1055
- `,q=c(l,r);await Bun.write(q,R),I(q,493)}let _=Boolean(t.icon&&await Bun.file(t.icon).exists());if(_)P(t.icon,c(u,"AppIcon.icns"));let K={CFBundleInfoDictionaryVersion:"6.0",CFBundleExecutable:r,CFBundleIdentifier:d,CFBundleName:r,CFBundleDisplayName:r,CFBundleShortVersionString:i,CFBundleVersion:i,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.hideDockIcon||t.trayPopover||(t.menubarOnly??Boolean(t.systemTray)),..._?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(c(p,"Info.plist"),G(K)),await Q(f,t.backend?[c(l,"stx-backend")]:h==="launcher"?[c(l,"craft")]:[],t.macosSigning),s==="dmg"){let C=c(n,`${r}-${i}.dmg`),w=await Re(f,C,r);if(!w.success)return{success:!1,target:"macos",format:"dmg",error:w.error};return{success:!0,target:"macos",format:"dmg",outputPath:C}}return{success:!0,target:"macos",format:"app",outputPath:f}}async function Ce(e){let r=Bun.spawn([e,"--capabilities"],{stdout:"pipe",stderr:"pipe"}),i=setTimeout(()=>r.kill(),5000);try{let[n,s,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text(),r.exited]);if(t!==0)return!1;return JSON.parse(`${n}${s}`.trim()).bundleBackend===!0}catch{return!1}finally{clearTimeout(i)}}async function ke(e){try{let r=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[i,n]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]);await r.exited;let t=`${i}
1055
+ `,A=c(l,r);await Bun.write(A,E),I(A,493)}let U=Boolean(t.icon&&await Bun.file(t.icon).exists());if(U)P(t.icon,c(u,"AppIcon.icns"));let K={CFBundleInfoDictionaryVersion:"6.0",CFBundleExecutable:r,CFBundleIdentifier:d,CFBundleName:r,CFBundleDisplayName:r,CFBundleShortVersionString:i,CFBundleVersion:i,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:t.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:t.hideDockIcon||t.trayPopover||(t.menubarOnly??Boolean(t.systemTray)),...U?{CFBundleIconFile:"AppIcon"}:{},...t.category?{LSApplicationCategoryType:t.category}:{},...t.copyright?{NSHumanReadableCopyright:t.copyright}:{},...t.infoPlist||{}};if(await Bun.write(c(p,"Info.plist"),G(K)),await Q(f,t.backend?[c(l,"stx-backend")]:h==="launcher"?[c(l,"craft")]:[],t.macosSigning),s==="dmg"){let C=c(n,`${r}-${i}.dmg`),w=await Re(f,C,r);if(!w.success)return{success:!1,target:"macos",format:"dmg",error:w.error};return{success:!0,target:"macos",format:"dmg",outputPath:C}}return{success:!0,target:"macos",format:"app",outputPath:f}}async function Ce(e){let r=Bun.spawn([e,"--capabilities"],{stdout:"pipe",stderr:"pipe"}),i=setTimeout(()=>r.kill(),5000);try{let[n,s,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text(),r.exited]);if(t!==0)return!1;return JSON.parse(`${n}${s}`.trim()).bundleBackend===!0}catch{return!1}finally{clearTimeout(i)}}async function ke(e){try{let r=Bun.spawn([e,"--version"],{stdout:"pipe",stderr:"pipe"}),[i,n]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]);await r.exited;let t=`${i}
1056
1056
  ${n}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;let[o,d,f]=t.slice(1).map(Number);if(o>0||d>0)return!0;return f>=57}catch{return!1}}async function $e(e,r,i,n,s,t,o){let d=c(n,r);S(d,{recursive:!0});let f=c(d,"index.html");await Bun.write(f,e),P(o,c(d,"craft.exe"));let p=`@echo off
1057
1057
  set DIR=%~dp0
1058
1058
  "%DIR%craft.exe" --html-file "%DIR%index.html" ^
@@ -1076,7 +1076,7 @@ Name=${r}
1076
1076
  Exec=${u}
1077
1077
  Terminal=false
1078
1078
  Categories=Utility;
1079
- `;if(await Bun.write(c(d,`${r.toLowerCase()}.desktop`),b),s==="deb"){let m=c(n,`${r.toLowerCase()}_${i}_amd64.deb`),v=await Oe(d,m,r,i,t);if(!v.success)return{success:!1,target:"linux",format:"deb",error:v.error};return{success:!0,target:"linux",format:"deb",outputPath:m}}if(s==="appimage"){let m=c(n,`${r}-${i}-x86_64.AppImage`),v=await De(d,m,r,t);if(!v.success)return{success:!1,target:"linux",format:"appimage",error:v.error};return{success:!0,target:"linux",format:"appimage",outputPath:m}}return{success:!0,target:"linux",format:"app",outputPath:d}}async function Pe(e,r,i,n,s,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${r}' to create an iOS project.`}}async function Ie(e,r,i,n,s,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${r}' to create an Android project.`}}function Ta(e="full"){let r=process.env.CRAFT_BIN;if(r){if(!F(r))throw Error(`CRAFT_BIN points to a missing file: ${r}`);return r}return Bun.which(e==="webview"?"craft-webview":"craft",{PATH:process.env.PATH??"",cwd:process.cwd()})}function D(){switch(ye()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function Be(e){switch(e){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function Re(e,r,i){return es({appBundlePath:e,outputPath:r,volumeName:i})}async function Ee(e,r){return new Promise((i)=>{let n=z("zip",["-r",r,"."],{cwd:e});n.on("close",(s)=>{if(s===0)i({success:!0});else i({success:!1,error:`zip exited with code ${s}`})}),n.on("error",(s)=>{i({success:!1,error:s.message})})})}async function Oe(e,r,i,n,s){return new Promise((t)=>{let o=Ke("deb");try{let d=c(o,"pkg"),f=c(d,"DEBIAN"),p=c(d,"usr","bin"),l=c(d,"usr","share","applications"),u=c(d,"usr","share",i.toLowerCase());S(f,{recursive:!0}),S(p,{recursive:!0}),S(l,{recursive:!0}),S(u,{recursive:!0});let b=g("fs").readdirSync(e);for(let h of b)P(c(e,h),c(u,h));let m=`#!/bin/bash
1079
+ `;if(await Bun.write(c(d,`${r.toLowerCase()}.desktop`),b),s==="deb"){let m=c(n,`${r.toLowerCase()}_${i}_amd64.deb`),v=await Oe(d,m,r,i,t);if(!v.success)return{success:!1,target:"linux",format:"deb",error:v.error};return{success:!0,target:"linux",format:"deb",outputPath:m}}if(s==="appimage"){let m=c(n,`${r}-${i}-x86_64.AppImage`),v=await De(d,m,r,t);if(!v.success)return{success:!1,target:"linux",format:"appimage",error:v.error};return{success:!0,target:"linux",format:"appimage",outputPath:m}}return{success:!0,target:"linux",format:"app",outputPath:d}}async function Pe(e,r,i,n,s,t){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${r}' to create an iOS project.`}}async function Ie(e,r,i,n,s,t){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${r}' to create an Android project.`}}function $a(e="full"){let r=process.env.CRAFT_BIN;if(r){if(!z(r))throw Error(`CRAFT_BIN points to a missing file: ${r}`);return r}return Bun.which(e==="webview"?"craft-webview":"craft",{PATH:process.env.PATH??"",cwd:process.cwd()})}function q(){switch(ye()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function Be(e){switch(e){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function Re(e,r,i){return es({appBundlePath:e,outputPath:r,volumeName:i})}async function Ee(e,r){return new Promise((i)=>{let n=_("zip",["-r",r,"."],{cwd:e});n.on("close",(s)=>{if(s===0)i({success:!0});else i({success:!1,error:`zip exited with code ${s}`})}),n.on("error",(s)=>{i({success:!1,error:s.message})})})}async function Oe(e,r,i,n,s){return new Promise((t)=>{let o=Xe("deb");try{let d=c(o,"pkg"),f=c(d,"DEBIAN"),p=c(d,"usr","bin"),l=c(d,"usr","share","applications"),u=c(d,"usr","share",i.toLowerCase());S(f,{recursive:!0}),S(p,{recursive:!0}),S(l,{recursive:!0}),S(u,{recursive:!0});let b=g("fs").readdirSync(e);for(let h of b)P(c(e,h),c(u,h));let m=`#!/bin/bash
1080
1080
  exec /usr/share/${i.toLowerCase()}/${i.toLowerCase()} "$@"`;g("fs").writeFileSync(c(p,i.toLowerCase()),m),I(c(p,i.toLowerCase()),493);let v=`Package: ${i.toLowerCase()}
1081
1081
  Version: ${n}
1082
1082
  Section: utils
@@ -1085,7 +1085,7 @@ Architecture: amd64
1085
1085
  Depends: libgtk-3-0, libwebkit2gtk-4.0-37
1086
1086
  Maintainer: ${s.author||"Unknown"}
1087
1087
  Description: ${s.description||i}
1088
- `;g("fs").writeFileSync(c(f,"control"),v);let k=z("dpkg-deb",["--build",d,r]);k.on("close",(h)=>{if(re(o),h===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${h}`})}),k.on("error",(h)=>{re(o),t({success:!1,error:h.message})})}catch(d){re(o),t({success:!1,error:d.message})}})}async function De(e,r,i,n){return new Promise((s)=>{let t=Ke("appimage");try{let o=c(t,`${i}.AppDir`),d=c(o,"usr"),f=c(d,"bin"),p=c(d,"share");S(f,{recursive:!0}),S(p,{recursive:!0});let l=c(p,i.toLowerCase());S(l,{recursive:!0});let u=g("fs").readdirSync(e);for(let h of u)P(c(e,h),c(l,h));let b=`#!/bin/bash
1088
+ `;g("fs").writeFileSync(c(f,"control"),v);let k=_("dpkg-deb",["--build",d,r]);k.on("close",(h)=>{if(se(o),h===0)t({success:!0});else t({success:!1,error:`dpkg-deb exited with code ${h}`})}),k.on("error",(h)=>{se(o),t({success:!1,error:h.message})})}catch(d){se(o),t({success:!1,error:d.message})}})}async function De(e,r,i,n){return new Promise((s)=>{let t=Xe("appimage");try{let o=c(t,`${i}.AppDir`),d=c(o,"usr"),f=c(d,"bin"),p=c(d,"share");S(f,{recursive:!0}),S(p,{recursive:!0});let l=c(p,i.toLowerCase());S(l,{recursive:!0});let u=g("fs").readdirSync(e);for(let h of u)P(c(e,h),c(l,h));let b=`#!/bin/bash
1089
1089
  SELF=$(readlink -f "$0")
1090
1090
  HERE=\${SELF%/*}
1091
1091
  export PATH="\${HERE}/usr/bin:\${PATH}"
@@ -1097,5 +1097,5 @@ Exec=${i.toLowerCase()}
1097
1097
  Terminal=false
1098
1098
  Categories=Utility;
1099
1099
  Icon=${i.toLowerCase()}
1100
- `;g("fs").writeFileSync(c(o,`${i.toLowerCase()}.desktop`),m);let v=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(g("fs").writeFileSync(c(o,`${i.toLowerCase()}.png`),v),n.icon&&F(n.icon))P(n.icon,c(o,`${i.toLowerCase()}.png`));let k=z("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});k.on("close",(h)=>{if(re(t),h===0)I(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${h}. Install from https://appimage.github.io/appimagetool/`})}),k.on("error",(h)=>{re(t),s({success:!1,error:`appimagetool not found: ${h.message}`})})}catch(o){re(t),s({success:!1,error:o.message})}})}function $a(){return[D()]}function Ra(e){switch(e){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var qe={buildNative:Ea,getAvailableTargets:$a,getAvailableFormats:Ra,detectPlatform:D},kh=qe;
1101
- export{gu,Sa,wh,vh,ka,ko,Zr,_a,Ca,xh,Sh,Ea,Ta,$a,Ra,kh};
1100
+ `;g("fs").writeFileSync(c(o,`${i.toLowerCase()}.desktop`),m);let v=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(g("fs").writeFileSync(c(o,`${i.toLowerCase()}.png`),v),n.icon&&z(n.icon))P(n.icon,c(o,`${i.toLowerCase()}.png`));let k=_("appimagetool",[o,r],{env:{...process.env,ARCH:"x86_64"}});k.on("close",(h)=>{if(se(t),h===0)I(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${h}. Install from https://appimage.github.io/appimagetool/`})}),k.on("error",(h)=>{se(t),s({success:!1,error:`appimagetool not found: ${h.message}`})})}catch(o){se(t),s({success:!1,error:o.message})}})}function Ra(){return[q()]}function Aa(e){switch(e){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var qe={buildNative:Ta,getAvailableTargets:Ra,getAvailableFormats:Aa,detectPlatform:q},Ch=qe;
1101
+ export{mu,ka,xh,Sh,_a,ko,Zr,Ca,Ea,kh,_h,Ta,$a,Ra,Aa,Ch};