@stacksjs/stx 0.2.739 → 0.2.740

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 (184) hide show
  1. package/dist/{chunk-373nfr24.js → chunk-06jys4zk.js} +4 -4
  2. package/dist/{chunk-2t00wxz0.js → chunk-0ckh7cy1.js} +1 -1
  3. package/dist/{chunk-rsdb4xj8.js → chunk-0yewaggn.js} +6 -6
  4. package/dist/{chunk-0cs8apdb.js → chunk-13tac9ac.js} +5 -5
  5. package/dist/chunk-1wak0s76.js +2 -0
  6. package/dist/{chunk-hmsy1x01.js → chunk-26wrcfr7.js} +1 -1
  7. package/dist/{chunk-ez35607j.js → chunk-27agaezn.js} +2 -2
  8. package/dist/{chunk-nqfpvejh.js → chunk-2hrdh72h.js} +1 -1
  9. package/dist/chunk-2tt2whvk.js +2 -0
  10. package/dist/{chunk-4fydrjq9.js → chunk-3f25fntg.js} +2 -2
  11. package/dist/chunk-3f4kf3fe.js +2 -0
  12. package/dist/{chunk-dnqzrktd.js → chunk-3kw9m62d.js} +2 -2
  13. package/dist/chunk-4yz476ss.js +2 -0
  14. package/dist/chunk-4z7bnc9j.js +2 -0
  15. package/dist/{chunk-7af3dwx9.js → chunk-55qv90h9.js} +9 -9
  16. package/dist/{chunk-3fwdxxh1.js → chunk-5f6x6fyp.js} +4 -4
  17. package/dist/chunk-67xtpw2q.js +2 -0
  18. package/dist/chunk-6dz075xn.js +2 -0
  19. package/dist/{chunk-4c86wr9a.js → chunk-6ew10ptg.js} +2 -2
  20. package/dist/chunk-6vajjyj8.js +2 -0
  21. package/dist/chunk-75wdm7kd.js +2 -0
  22. package/dist/{chunk-jq18vvgv.js → chunk-7emrpfha.js} +6 -6
  23. package/dist/chunk-7vt4k3jv.js +2 -0
  24. package/dist/chunk-840t4gws.js +2 -0
  25. package/dist/{chunk-74fepz6h.js → chunk-888xnaex.js} +2 -2
  26. package/dist/{chunk-c3nwrp52.js → chunk-88kpnrgj.js} +1 -1
  27. package/dist/chunk-8bw9yd5m.js +2 -0
  28. package/dist/chunk-8nq4879f.js +2 -0
  29. package/dist/chunk-8qdrv49k.js +2 -0
  30. package/dist/{chunk-x9wwd2ee.js → chunk-91pycazt.js} +2 -2
  31. package/dist/{chunk-dhy6n39n.js → chunk-9bbs9d9q.js} +2 -2
  32. package/dist/{chunk-qf2aa8qe.js → chunk-9v98dzxt.js} +4 -4
  33. package/dist/{chunk-62awa752.js → chunk-9zrbhs3p.js} +1 -1
  34. package/dist/chunk-a0mze6dz.js +2 -0
  35. package/dist/chunk-af9ptz0x.js +2 -0
  36. package/dist/{chunk-z3kbjsqw.js → chunk-agxvydxe.js} +1 -1
  37. package/dist/chunk-aj6m4pqt.js +2 -0
  38. package/dist/{chunk-4hv1camf.js → chunk-amsbfc3y.js} +30 -30
  39. package/dist/{chunk-rj4j7qcj.js → chunk-amyxgejb.js} +1 -1
  40. package/dist/chunk-ascwd65c.js +2 -0
  41. package/dist/chunk-at0k9j3q.js +3 -0
  42. package/dist/{chunk-narz7105.js → chunk-b107z777.js} +2 -2
  43. package/dist/{chunk-w6gzkcm4.js → chunk-b4ejzx20.js} +18 -18
  44. package/dist/{chunk-agjysd2b.js → chunk-b8ryfxay.js} +1 -1
  45. package/dist/{chunk-xaddgvkx.js → chunk-byaasw3f.js} +2 -2
  46. package/dist/{chunk-630yrhzv.js → chunk-cka9p9v5.js} +2 -2
  47. package/dist/chunk-cmm2mkr1.js +2 -0
  48. package/dist/{chunk-3e40sm05.js → chunk-crk5dzxb.js} +4 -4
  49. package/dist/chunk-d4ahp771.js +2 -0
  50. package/dist/chunk-dw7ajrvf.js +2 -0
  51. package/dist/chunk-e2ar36jw.js +2 -0
  52. package/dist/{chunk-hez09ssh.js → chunk-e43cxztn.js} +2 -2
  53. package/dist/chunk-ejhd435r.js +2 -0
  54. package/dist/{chunk-r3j4m04w.js → chunk-eks1mjr3.js} +2 -2
  55. package/dist/chunk-eyekxtjn.js +2 -0
  56. package/dist/{chunk-trpvddrv.js → chunk-f17tdyp3.js} +5 -5
  57. package/dist/{chunk-dbdgfkyc.js → chunk-f2yfe5e2.js} +1 -1
  58. package/dist/{chunk-7sqnts69.js → chunk-f6bpxqj9.js} +5 -5
  59. package/dist/{chunk-hws0g4w8.js → chunk-fveqk208.js} +1 -1
  60. package/dist/{chunk-dghy97z8.js → chunk-gwes6c9v.js} +1 -1
  61. package/dist/{chunk-g2d41h5e.js → chunk-gyvaz4cb.js} +1 -1
  62. package/dist/{chunk-qc93ce5h.js → chunk-h2y36t58.js} +2 -2
  63. package/dist/chunk-h4ab99hb.js +2 -0
  64. package/dist/{chunk-5j9h42bf.js → chunk-h58sctng.js} +4 -4
  65. package/dist/{chunk-79sjdpfy.js → chunk-h6jba844.js} +1 -1
  66. package/dist/chunk-h75rev1h.js +2 -0
  67. package/dist/chunk-h9140mn0.js +2 -0
  68. package/dist/chunk-hjatgram.js +2 -0
  69. package/dist/{chunk-mhx8qba9.js → chunk-hq00hf2e.js} +3 -3
  70. package/dist/{chunk-r3hden6p.js → chunk-j3cbj356.js} +2 -2
  71. package/dist/chunk-j4gxcnd5.js +2 -0
  72. package/dist/{chunk-m5nzpjej.js → chunk-jeh671tw.js} +1 -1
  73. package/dist/chunk-jka3p99a.js +2 -0
  74. package/dist/{chunk-mnyy63gy.js → chunk-jydd8cdc.js} +5 -5
  75. package/dist/chunk-k38vsxt8.js +2 -0
  76. package/dist/{chunk-88rftjjk.js → chunk-k8gxa1jf.js} +4 -4
  77. package/dist/chunk-kgxqj66x.js +2 -0
  78. package/dist/{chunk-48b5fwp2.js → chunk-kjh118s3.js} +7 -7
  79. package/dist/{chunk-3xyvc3g1.js → chunk-kp2rkczm.js} +5 -5
  80. package/dist/chunk-m45r8w14.js +2 -0
  81. package/dist/{chunk-x5dc06p5.js → chunk-md36aysy.js} +6 -6
  82. package/dist/{chunk-h16qbyjd.js → chunk-n8mb6510.js} +2 -2
  83. package/dist/{chunk-q7fh1xka.js → chunk-njdppe81.js} +6 -6
  84. package/dist/{chunk-arcczsd3.js → chunk-nt3hva3f.js} +4 -4
  85. package/dist/{chunk-f2c3t1ky.js → chunk-nybty1zx.js} +2 -2
  86. package/dist/{chunk-rbmt5w9v.js → chunk-nzwcbt98.js} +2 -2
  87. package/dist/{chunk-3nmkx2yg.js → chunk-p766mk6b.js} +4 -4
  88. package/dist/{chunk-qg29g74v.js → chunk-pwt6467e.js} +1 -1
  89. package/dist/chunk-pzm8bc99.js +2 -0
  90. package/dist/{chunk-05qf3e2p.js → chunk-q1db41k8.js} +3 -3
  91. package/dist/chunk-qjm2q9we.js +2 -0
  92. package/dist/{chunk-j28r2d0q.js → chunk-r2cfezt5.js} +2 -2
  93. package/dist/{chunk-gyjqjq4a.js → chunk-rner9txv.js} +2 -2
  94. package/dist/chunk-rpe1tskt.js +2 -0
  95. package/dist/{chunk-4ree52mq.js → chunk-rsfs0x3d.js} +1 -1
  96. package/dist/{chunk-4me1smce.js → chunk-rthn3eq6.js} +60 -60
  97. package/dist/{chunk-syq3a4s2.js → chunk-sc1wkke5.js} +12 -12
  98. package/dist/{chunk-ypy39vy3.js → chunk-sj7hm8dm.js} +2 -2
  99. package/dist/{chunk-dxfkt19x.js → chunk-smq3x9a2.js} +3 -3
  100. package/dist/{chunk-zkx2m308.js → chunk-sv4d9jgf.js} +10 -10
  101. package/dist/{chunk-54vc7zr6.js → chunk-t8ap5qet.js} +6 -6
  102. package/dist/chunk-tbgz73ta.js +2 -0
  103. package/dist/chunk-tpwxvpnt.js +2 -0
  104. package/dist/{chunk-hnqpqtk2.js → chunk-ttsrhr95.js} +6 -6
  105. package/dist/{chunk-dmnncw90.js → chunk-vtmd3ssd.js} +3 -3
  106. package/dist/chunk-vvbszwjs.js +2 -0
  107. package/dist/{chunk-mwxbdpb1.js → chunk-vyv76w55.js} +2 -2
  108. package/dist/chunk-w07kke19.js +2 -0
  109. package/dist/{chunk-serrx31a.js → chunk-w1sdxmx3.js} +2 -2
  110. package/dist/{chunk-39nkd53v.js → chunk-w34w1hrg.js} +2 -2
  111. package/dist/chunk-w6dyqh92.js +2 -0
  112. package/dist/{chunk-2mqzpzy7.js → chunk-w9are744.js} +4 -4
  113. package/dist/chunk-wbcqtpkm.js +2 -0
  114. package/dist/chunk-wy8er1ps.js +2 -0
  115. package/dist/chunk-wzkjzh7w.js +2 -0
  116. package/dist/{chunk-d9hw6n2d.js → chunk-x0c8xq0s.js} +3 -3
  117. package/dist/{chunk-rgbc1qe2.js → chunk-x0vws901.js} +1 -1
  118. package/dist/{chunk-jvkdv346.js → chunk-xa8bzf00.js} +3 -3
  119. package/dist/chunk-xrspzeqx.js +2 -0
  120. package/dist/chunk-xt786nk0.js +2 -0
  121. package/dist/{chunk-v402swbm.js → chunk-xzv8t0nd.js} +1 -1
  122. package/dist/{chunk-49km7zfs.js → chunk-yvwesavg.js} +9 -9
  123. package/dist/{chunk-vpr2m2xj.js → chunk-yxtqk5p8.js} +2 -2
  124. package/dist/{chunk-9chqvq23.js → chunk-yygtmm7t.js} +3 -3
  125. package/dist/{chunk-4xxe3qe5.js → chunk-yz4jpwp3.js} +19 -19
  126. package/dist/{chunk-fs1vnqwp.js → chunk-z82a0dpd.js} +3 -3
  127. package/dist/chunk-zgnqyta0.js +2 -0
  128. package/dist/chunk-zvfr6022.js +2 -0
  129. package/dist/{chunk-wk50m71x.js → chunk-zzeas8x5.js} +1 -1
  130. package/dist/cli.js +19 -19
  131. package/dist/craft-entry.js +2 -2
  132. package/dist/craft.js +2 -2
  133. package/dist/pwa.js +3 -3
  134. package/dist/ssg.js +27 -27
  135. package/package.json +5 -5
  136. package/dist/chunk-0g9a1kks.js +0 -2
  137. package/dist/chunk-31rg3qz7.js +0 -2
  138. package/dist/chunk-336t7zzz.js +0 -2
  139. package/dist/chunk-33qd6h6n.js +0 -2
  140. package/dist/chunk-362sjw8c.js +0 -2
  141. package/dist/chunk-3j8x8mhx.js +0 -2
  142. package/dist/chunk-42r0h45w.js +0 -2
  143. package/dist/chunk-5tdz3z5q.js +0 -2
  144. package/dist/chunk-5wpgbwap.js +0 -2
  145. package/dist/chunk-6h1qa3hw.js +0 -2
  146. package/dist/chunk-6jn0p1a9.js +0 -2
  147. package/dist/chunk-8w1ep4w3.js +0 -2
  148. package/dist/chunk-918xy0ra.js +0 -2
  149. package/dist/chunk-a0xegxej.js +0 -2
  150. package/dist/chunk-a49at1ah.js +0 -2
  151. package/dist/chunk-ak04tgvw.js +0 -2
  152. package/dist/chunk-azatpcm0.js +0 -2
  153. package/dist/chunk-c1481efw.js +0 -2
  154. package/dist/chunk-c8yrvpr7.js +0 -2
  155. package/dist/chunk-d5mmgzqs.js +0 -2
  156. package/dist/chunk-e79f1nqx.js +0 -2
  157. package/dist/chunk-fn37y9w0.js +0 -2
  158. package/dist/chunk-fq4v88bm.js +0 -2
  159. package/dist/chunk-gcqc1a23.js +0 -2
  160. package/dist/chunk-hx9sejvz.js +0 -2
  161. package/dist/chunk-j23gevpf.js +0 -2
  162. package/dist/chunk-j50ave27.js +0 -2
  163. package/dist/chunk-jresy8fn.js +0 -2
  164. package/dist/chunk-jtdnstfj.js +0 -2
  165. package/dist/chunk-kf8dmjb7.js +0 -2
  166. package/dist/chunk-m6d2bq3y.js +0 -2
  167. package/dist/chunk-ndvpk5ze.js +0 -2
  168. package/dist/chunk-nvtp22qp.js +0 -2
  169. package/dist/chunk-ph0xas8r.js +0 -2
  170. package/dist/chunk-q0z39h2m.js +0 -2
  171. package/dist/chunk-r16mwj49.js +0 -2
  172. package/dist/chunk-rgv7rjrs.js +0 -2
  173. package/dist/chunk-sw385js5.js +0 -2
  174. package/dist/chunk-tdvmf3ge.js +0 -2
  175. package/dist/chunk-tx8htbte.js +0 -2
  176. package/dist/chunk-tyvpm2x1.js +0 -2
  177. package/dist/chunk-vphm6c38.js +0 -2
  178. package/dist/chunk-vvh18y7t.js +0 -2
  179. package/dist/chunk-wdvfqmgv.js +0 -2
  180. package/dist/chunk-wv171crf.js +0 -2
  181. package/dist/chunk-wva9vscy.js +0 -2
  182. package/dist/chunk-xafm270g.js +0 -2
  183. package/dist/chunk-yyr9ps8k.js +0 -2
  184. package/dist/chunk-znshn986.js +0 -3
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Jc,Yc}from"./chunk-ez35607j.js";import{H,Ss,ks,_s,Wo,qo,mr,Oe,pe,X,Es,ie,J,I,tt,yr,Jo,wr,Be,r,p,V,yn}from"./chunk-4me1smce.js";import{f,R,nt,d}from"./chunk-zkx2m308.js";import{n}from"./chunk-znshn986.js";import{se}from"./chunk-r3j4m04w.js";import{s}from"./chunk-05qf3e2p.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Ct}from"crypto";import ee from"fs";import Q from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import De from"fs";function Ce(e,t,i){let o=Buffer.alloc(i),a=De.readSync(e,o,0,i,t);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let t=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let i=t(12,16);if(i==="VP8X")return(e[20]&16)!==0;if(i==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=De.openSync(e,"r");let i=Ce(t,0,33);if(i.length>=3&&i[0]===255&&i[1]===216&&i[2]===255)return"none";if(i.length>=26&&i[0]===137&&i.toString("latin1",1,4)==="PNG"){let o=i[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(t,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(i.length>=25&&i.toString("latin1",0,4)==="RIFF"&&i.toString("latin1",8,12)==="WEBP"){if(je(i))return"possible";let o=i.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)De.closeSync(t)}}import Jt from"fs";import Re from"os";import{join as dt}from"path";import{fileURLToPath as gt}from"url";import{Worker as mt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function en(){Ae--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let i=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(i.protocol==="file:"&&Jt.existsSync(gt(i)))return gt(i)}catch{}try{let i=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return i&&rn(i)?i:void 0}catch{return}}function rn(e,t=process.env){let i=e.replace(/\\/g,"/");if(i.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![t.BUN_INSTALL_CACHE_DIR,dt(t.BUN_INSTALL||dt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>i.startsWith(a))}var pt=!1;function me(e){if(!pt)pt=!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 Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return me("node:worker_threads has no Worker in this runtime");let i=nn();if(!i)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((o,a)=>{let c;try{c=new mt(i)}catch(y){o(me(`could not start ${i}: ${Le(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:t});return}if(y.type==="result"){u(()=>o(y.value));return}let w=Error(y.error?.message??"image worker failed");if(y.error?.name)w.name=y.error.name;if(y.error?.stack)w.stack=y.error.stack;u(()=>a(w))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Le(y)||"image worker crashed")):o(me(`the worker failed before it was ready: ${Le(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(me(`the worker exited with code ${y} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],he="/_stx/images",ln=`stx:${he}:alpha-1`,un=`stx:${he}:opaque-1`,fn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function dn(e,t){let i=Q.dirname(Bun.resolveSync(e,t));while(i!==Q.dirname(i)){let o=Q.join(i,"package.json");if(ee.existsSync(o)){let a=JSON.parse(ee.readFileSync(o,"utf8"));if(a.name===e)return a.version}i=Q.dirname(i)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=Q.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=fn.map((t)=>{let i;try{i=e?dn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${i??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function ye(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function gn(e){return`/${e.split(Q.sep).map(encodeURIComponent).join("/")}`}function mn(e){let t=Q.extname(e),i=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Ct("sha256").update(e).digest("hex").slice(0,8);return`${i||"image"}-${o}`}function wt(e,t=`stx:${he}`){let i=(o)=>`${he}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(o){let a=Q.join(e,o);try{let c=await ee.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:i(o)}:null}catch{return null}},async write(o,a){let c=Q.join(e,o);await ee.promises.mkdir(Q.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await ee.promises.writeFile(l,a),await ee.promises.rename(l,c),{bytes:a.byteLength,path:c,url:i(o)}},url:i}}async function Rt(e,t=e){let i=await ee.promises.readdir(t,{withFileTypes:!0});i.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of i){let c=Q.join(t,a.name);if(a.isDirectory()){o.push(...await Rt(e,c));continue}if(!a.isFile()||!an.has(Q.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Q.relative(e,c)})}return o}function $t(e,t){return e.map((i)=>({key:gn(i.relativePath),input:i.absolutePath,name:mn(i.relativePath),...pn(i.absolutePath)?{options:{storage:t}}:{}}))}function pn(e){return Me(e)==="possible"}function hn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),i=new Set,o=8;for(let a=0;a<t.length;a+=8)await Promise.all(t.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 sn(new Uint8Array(await ee.promises.readFile(m?.path??l.fallback.path)));if(hn(u.data))i.add(c)}catch{i.add(c)}}));return i}function bn(e,t){let i=[];for(let o of t){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=ee.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)ee.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,i.push(o),!vt.has(o))vt.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 i}async function vn(e){let t=[],i=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 on(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));t.push(...c.filter((l)=>l!==null))}return t}function Ue(e){return Q.join(e,"undecodable.json")}function wn(e){try{let t=ee.readFileSync(Ue(e),"utf-8"),i=JSON.parse(t);return i&&typeof i==="object"?i:{}}catch{return{}}}function $n(e,t){try{ee.mkdirSync(Q.dirname(Ue(e)),{recursive:!0}),ee.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=ee.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function At(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function ko(e){let t=At(e);return t?ye().catalog.get(t):void 0}function _o(e){let t=At(e);return t?ye().transparent.has(t):!1}function Co(e){let t=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),i=t(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:t(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<i).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function nh(e){let t=ko(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:Co(t).map(({format:i,srcset:o})=>({type:`image/${i}`,srcset:o})),width:t.source.width,height:t.source.height,placeholder:_o(e)?void 0:t.placeholder?.dataUrl}}function ts(){let e=ye();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=ye();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function rh(e,t,i={}){if(!e||!ee.existsSync(e))return ts(),{count:0,fingerprint:""};if(i.offThread){let h=await ze("delivery",{publicDir:e,outputDir:t});if(h!==ke)return Sn(h.state),h.result}let o=await Rt(e);if(o.length===0)return ts(),{count:0,fingerprint:""};let a=wn(t),c=o.filter((h)=>{let v=a[h.relativePath];if(!v)return!0;let S=St(h.absolutePath);return!S||S.mtimeMs!==v.mtimeMs||S.size!==v.size});if(c.length===0)return ts(),{count:0,fingerprint:""};let l=wt(Q.join(t,"_stx","images"),`${ln}:${xt()}`),m={outDir:Q.join(t,"_stx","images"),storage:wt(Q.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:he,widths:cn,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 yt({...m,entries:$t(c,l)})}catch(h){if(u=await vn(c),u.length===c.length)throw h;let v=new Set(u.map((A)=>A.relativePath)),S=!1;for(let A of c){if(v.has(A.relativePath))continue;let P=St(A.absolutePath);if(!P)continue;a[A.relativePath]=P,S=!0}if(S)$n(t,a);if(u.length===0)return ts(),{count:0,fingerprint:""};y=await yt({...m,entries:$t(u,l)})}let w=await xn(y.entries),x=bn(y.entries,w),C=ye();C.catalog=new Map(Object.entries(y.entries)),C.transparent=w;let b=w.size===0&&x.length===0?y.fingerprint:Ct("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...w].sort(),droppedWebp:x.sort()})).digest("hex");return{count:u.length,fingerprint:b}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,i,o){let a=Wo(e,o);if(a!==void 0)return a;for(let c of qo(e,t,i,o))if(await r(c))return c;return null}}var le=new kt;var re="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=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 Fe(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function oe(e,t){let i=[];for(let[o,a]of Object.entries(e.static)){if(t.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)i.push(p(c));continue}if(a===re){i.push(p(c));continue}i.push(`${p(c)}="${yn(c,We(String(a)))}"`)}return i}function ae(e,t){let i=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(t.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){i.push(p(c));continue}if(typeof a==="object")continue;i.push(`${p(c)}="${yn(c,We(String(a)))}"`)}return i}function Rn(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 He={name:"StxLink",aliases:["stx-link"],render(e,t,i){let o=Rn(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(mr(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 w=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...oe(e,w)),u.push(...ae(e,w)),`<a ${u.join(" ")}>${t}</a>`}};var An=new Map;function qe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Xe=[320,640,768,1024,1280,1536,1920];function K(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}function _e(e,t,i=!1){let o=e.serverDynamic[t];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[t];if(a!==void 0)return a!=="false"&&a!==!1;return i}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),i=[];for(let o of t)if(o.includes(":")){let[a,c]=o.split(":"),l=kn[a];if(l)i.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))i.push(`(max-width: ${m}px) ${c}`)}}else i.push(o);return i.join(", ")}function Ve(e,t,i,o){return t.map((a)=>`${xe(e,a,void 0,i,o)} ${a}w`).join(", ")}function Pn(e,t,i,o,a){return t.map((c)=>{let l=i?i*c:void 0;return`${xe(e,l,void 0,o,a)} ${c}x`}).join(", ")}function xe(e,t,i,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(t)c.push(`w_${t}`);if(i)c.push(`h_${i}`);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(t)c.set("w",String(t));if(i)c.set("h",String(i));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(t)c.set("width",String(t));if(i)c.set("height",String(i));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,i="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${i}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,i){let o=K(e,"src")||"",a=ko(o),c=K(e,"alt")||"",l=K(e,"width")||(a?String(a.source.width):void 0),m=K(e,"height")||(a?String(a.source.height):void 0),u=K(e,"sizes"),y=K(e,"srcset"),w=K(e,"densities"),x=K(e,"format"),C=_o(o)||qe(o)?.transparent===!0,b=K(e,"placeholder")||(a&&!C?"thumbhash":void 0),h=K(e,"placeholderColor")||"#e5e7eb",v=K(e,"provider"),S=K(e,"class")||K(e,"className")||"",A=K(e,"style")||"",P=K(e,"objectFit")||K(e,"fit"),k=K(e,"objectPosition")||K(e,"position"),N=K(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),q=K(e,"loading"),O=K(e,"decoding")||"async",E=!!a||_e(e,"picture",!1)||!!x,B=l?Number.parseInt(l):void 0,T=m?Number.parseInt(m):void 0,z=y||"",G="";if(a)z=a.sources[a.fallback.format]||"",G=u?Ze(u):"100vw";else if(!z&&u&&v&&v!=="local"&&v!=="static")z=Ve(o,Xe,v,x),G=Ze(u);else if(!z&&w){let _=w.split(/\s+/).map((F)=>Number.parseFloat(F.replace("x","")));z=Pn(o,_,B,v,x)}else if(u)G=Ze(u);let j=[];if(A)j.push(A);if(P)j.push(`object-fit:${P}`);if(k)j.push(`object-position:${k}`);if(B&&T)j.push(`aspect-ratio:${B}/${T}`);let W=[],ce=b==="blur"||b==="color"||b==="thumbhash";if(ce&&!C){let _=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:h}:qe(o);if(_&&b==="color")j.push(`background-color:${_.color}`),W.push("backgroundColor");else if(_)j.push(`background-color:${_.color}`),j.push(`background-image:url(${_.dataUrl})`),j.push("background-size:cover"),j.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let F=In(B||16,T||9,h);j.push(`background-image:url(${F})`),j.push("background-size:cover"),j.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ce&&b&&b!=="empty"&&b!=="none")j.push(`background-image:url(${n(b)})`),j.push("background-size:cover"),j.push("background-repeat:no-repeat"),W.push("backgroundImage");let we=a?.fallback.url||xe(o,B,T,v,x),Y=[];if(Y.push(`src="${n(mr(we,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let ne=q||(L||M?"eager":U?"lazy":"");if(ne)Y.push(`loading="${n(ne)}"`);if(L)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(O)}"`),S)Y.push(`class="${n(S)}"`);if(j.length>0)Y.push(`style="${n(j.join(";"))}"`);if(z)Y.push(`srcset="${n(mr(z,"fetched"))}"`);if(G)Y.push(`sizes="${n(G)}"`);let $e=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(W.length>0){let _=typeof e.static.onload==="string"?e.static.onload:"",F=_n(W)+(_?`;${_}`:"");Y.push(`onload="${n(F)}"`),$e.add("onload")}Y.push(...oe(e,$e)),Y.push(...ae(e,$e));let D=`<img ${Y.join(" ")} />`,Z="";if(M){let F=x==="webp"?"image/webp":x==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${n(we)}"${F?` type="${F}"`:""}${z?` imagesrcset="${n(z)}"`:""}${G?` imagesizes="${n(G)}"`:""} />
3
- `}if(E){let _=[];if(a)for(let F of Co(a))_.push(`<source type="image/${F.format}" srcset="${n(F.srcset)}"${G?` sizes="${n(G)}"`:""} />`);if(!a&&(x==="avif"||x==="auto")){let F=xe(o,B,T,v,"avif"),te=z?Ve(o,Xe,v,"avif"):`${F}`;_.push(`<source type="image/avif" srcset="${n(te)}"${G?` sizes="${n(G)}"`:""} />`)}if(!a&&(x==="webp"||x==="auto")){let F=xe(o,B,T,v,"webp"),te=z?Ve(o,Xe,v,"webp"):`${F}`;_.push(`<source type="image/webp" srcset="${n(te)}"${G?` sizes="${n(G)}"`:""} />`)}return`${Z}<picture>
2
+ import{Yc,Zc}from"./chunk-27agaezn.js";import{H,ks,_s,Cs,qo,Ko,mr,Oe,pe,X,Ts,ie,J,I,tt,yr,Yo,wr,Be,r,p,V,yn}from"./chunk-rthn3eq6.js";import{f,R,nt,d}from"./chunk-sv4d9jgf.js";import{n}from"./chunk-at0k9j3q.js";import{se}from"./chunk-eks1mjr3.js";import{s}from"./chunk-q1db41k8.js";import{g}from"./chunk-0dve54ne.js";import{createHash as Ct}from"crypto";import ee from"fs";import Q from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as yt}from"ts-images/delivery";import De from"fs";function Ce(e,t,i){let o=Buffer.alloc(i),a=De.readSync(e,o,0,i,t);return o.subarray(0,a)}function je(e){if(e.length<25)return!1;let t=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let i=t(12,16);if(i==="VP8X")return(e[20]&16)!==0;if(i==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Me(e){let t;try{t=De.openSync(e,"r");let i=Ce(t,0,33);if(i.length>=3&&i[0]===255&&i[1]===216&&i[2]===255)return"none";if(i.length>=26&&i[0]===137&&i.toString("latin1",1,4)==="PNG"){let o=i[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ce(t,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(i.length>=25&&i.toString("latin1",0,4)==="RIFF"&&i.toString("latin1",8,12)==="WEBP"){if(je(i))return"possible";let o=i.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)De.closeSync(t)}}import Jt from"fs";import Re from"os";import{join as dt}from"path";import{fileURLToPath as gt}from"url";import{Worker as mt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Re.availableParallelism==="function"?Re.availableParallelism():Re.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,ht=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>ht.push(e)),Ae++}function en(){Ae--,ht.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let i=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(i.protocol==="file:"&&Jt.existsSync(gt(i)))return gt(i)}catch{}try{let i=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return i&&rn(i)?i:void 0}catch{return}}function rn(e,t=process.env){let i=e.replace(/\\/g,"/");if(i.split("/").some((a)=>/@\d[^/]*@@@\d+$/.test(a)))return!1;return![t.BUN_INSTALL_CACHE_DIR,dt(t.BUN_INSTALL||dt(Re.homedir(),".bun"),"install","cache")].filter((a)=>!!a).map((a)=>`${a.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((a)=>i.startsWith(a))}var pt=!1;function me(e){if(!pt)pt=!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 Le(e){return e instanceof Error?e.message:String(e)}async function ze(e,t){if(typeof mt!=="function")return me("node:worker_threads has no Worker in this runtime");let i=nn();if(!i)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((o,a)=>{let c;try{c=new mt(i)}catch(y){o(me(`could not start ${i}: ${Le(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:t});return}if(y.type==="result"){u(()=>o(y.value));return}let w=Error(y.error?.message??"image worker failed");if(y.error?.name)w.name=y.error.name;if(y.error?.stack)w.stack=y.error.stack;u(()=>a(w))}),c.on("error",(y)=>{u(()=>l?a(y instanceof Error?y:Error(Le(y)||"image worker crashed")):o(me(`the worker failed before it was ready: ${Le(y)}`)))}),c.on("exit",(y)=>{u(()=>l?a(Error("image worker exited before it finished")):o(me(`the worker exited with code ${y} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],he="/_stx/images",ln=`stx:${he}:alpha-1`,un=`stx:${he}:opaque-1`,fn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function dn(e,t){let i=Q.dirname(Bun.resolveSync(e,t));while(i!==Q.dirname(i)){let o=Q.join(i,"package.json");if(ee.existsSync(o)){let a=JSON.parse(ee.readFileSync(o,"utf8"));if(a.name===e)return a.version}i=Q.dirname(i)}return}function xt(){if(Pe!==void 0)return Pe;let e;try{e=Q.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=fn.map((t)=>{let i;try{i=e?dn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${i??"unknown"}`}).join("+"),Pe}var bt=Symbol.for("stx.image-delivery");function ye(){let e=globalThis;return e[bt]??={catalog:new Map,transparent:new Set},e[bt]}var vt=new Set;function gn(e){return`/${e.split(Q.sep).map(encodeURIComponent).join("/")}`}function mn(e){let t=Q.extname(e),i=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=Ct("sha256").update(e).digest("hex").slice(0,8);return`${i||"image"}-${o}`}function wt(e,t=`stx:${he}`){let i=(o)=>`${he}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(o){let a=Q.join(e,o);try{let c=await ee.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:i(o)}:null}catch{return null}},async write(o,a){let c=Q.join(e,o);await ee.promises.mkdir(Q.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await ee.promises.writeFile(l,a),await ee.promises.rename(l,c),{bytes:a.byteLength,path:c,url:i(o)}},url:i}}async function Rt(e,t=e){let i=await ee.promises.readdir(t,{withFileTypes:!0});i.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of i){let c=Q.join(t,a.name);if(a.isDirectory()){o.push(...await Rt(e,c));continue}if(!a.isFile()||!an.has(Q.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:Q.relative(e,c)})}return o}function $t(e,t){return e.map((i)=>({key:gn(i.relativePath),input:i.absolutePath,name:mn(i.relativePath),...pn(i.absolutePath)?{options:{storage:t}}:{}}))}function pn(e){return Me(e)==="possible"}function hn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,a])=>a.fallback.format==="png"),i=new Set,o=8;for(let a=0;a<t.length;a+=8)await Promise.all(t.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 sn(new Uint8Array(await ee.promises.readFile(m?.path??l.fallback.path)));if(hn(u.data))i.add(c)}catch{i.add(c)}}));return i}function bn(e,t){let i=[];for(let o of t){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=ee.openSync(m.path,"r"),!je(Ce(u,0,32))}catch{return!0}finally{if(u!==void 0)ee.closeSync(u)}}))continue;if(a.variants=a.variants.filter((m)=>m.format!=="webp"),delete a.sources.webp,i.push(o),!vt.has(o))vt.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 i}async function vn(e){let t=[],i=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 on(l.absolutePath),l}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${l.relativePath}`),null}}));t.push(...c.filter((l)=>l!==null))}return t}function Ue(e){return Q.join(e,"undecodable.json")}function wn(e){try{let t=ee.readFileSync(Ue(e),"utf-8"),i=JSON.parse(t);return i&&typeof i==="object"?i:{}}catch{return{}}}function $n(e,t){try{ee.mkdirSync(Q.dirname(Ue(e)),{recursive:!0}),ee.writeFileSync(Ue(e),JSON.stringify(t))}catch{}}function St(e){try{let t=ee.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function At(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function _o(e){let t=At(e);return t?ye().catalog.get(t):void 0}function Co(e){let t=At(e);return t?ye().transparent.has(t):!1}function Eo(e){let t=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),i=t(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:t(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<i).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function nh(e){let t=_o(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:Eo(t).map(({format:i,srcset:o})=>({type:`image/${i}`,srcset:o})),width:t.source.width,height:t.source.height,placeholder:Co(e)?void 0:t.placeholder?.dataUrl}}function ts(){let e=ye();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=ye();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function rh(e,t,i={}){if(!e||!ee.existsSync(e))return ts(),{count:0,fingerprint:""};if(i.offThread){let h=await ze("delivery",{publicDir:e,outputDir:t});if(h!==ke)return Sn(h.state),h.result}let o=await Rt(e);if(o.length===0)return ts(),{count:0,fingerprint:""};let a=wn(t),c=o.filter((h)=>{let v=a[h.relativePath];if(!v)return!0;let S=St(h.absolutePath);return!S||S.mtimeMs!==v.mtimeMs||S.size!==v.size});if(c.length===0)return ts(),{count:0,fingerprint:""};let l=wt(Q.join(t,"_stx","images"),`${ln}:${xt()}`),m={outDir:Q.join(t,"_stx","images"),storage:wt(Q.join(t,"_stx","images"),`${un}:${xt()}`),baseUrl:he,widths:cn,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 yt({...m,entries:$t(c,l)})}catch(h){if(u=await vn(c),u.length===c.length)throw h;let v=new Set(u.map((A)=>A.relativePath)),S=!1;for(let A of c){if(v.has(A.relativePath))continue;let P=St(A.absolutePath);if(!P)continue;a[A.relativePath]=P,S=!0}if(S)$n(t,a);if(u.length===0)return ts(),{count:0,fingerprint:""};y=await yt({...m,entries:$t(u,l)})}let w=await xn(y.entries),x=bn(y.entries,w),C=ye();C.catalog=new Map(Object.entries(y.entries)),C.transparent=w;let b=w.size===0&&x.length===0?y.fingerprint:Ct("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...w].sort(),droppedWebp:x.sort()})).digest("hex");return{count:u.length,fingerprint:b}}class kt{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,i,o){let a=qo(e,o);if(a!==void 0)return a;for(let c of Ko(e,t,i,o))if(await r(c))return c;return null}}var le=new kt;var re="\x00stx-boolean-attribute";function We(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=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 Fe(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function oe(e,t){let i=[];for(let[o,a]of Object.entries(e.static)){if(t.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)i.push(p(c));continue}if(a===re){i.push(p(c));continue}i.push(`${p(c)}="${yn(c,We(String(a)))}"`)}return i}function ae(e,t){let i=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(t.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){i.push(p(c));continue}if(typeof a==="object")continue;i.push(`${p(c)}="${yn(c,We(String(a)))}"`)}return i}function Rn(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 He={name:"StxLink",aliases:["stx-link"],render(e,t,i){let o=Rn(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(mr(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 w=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return u.push(...oe(e,w)),u.push(...ae(e,w)),`<a ${u.join(" ")}>${t}</a>`}};var An=new Map;function qe(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Xe=[320,640,768,1024,1280,1536,1920];function K(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let i=e.static[t];if(typeof i==="string")return i;return}function _e(e,t,i=!1){let o=e.serverDynamic[t];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[t];if(a!==void 0)return a!=="false"&&a!==!1;return i}function Ze(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),i=[];for(let o of t)if(o.includes(":")){let[a,c]=o.split(":"),l=kn[a];if(l)i.push(`(max-width: ${l}px) ${c}`);else{let m=Number.parseInt(a);if(!Number.isNaN(m))i.push(`(max-width: ${m}px) ${c}`)}}else i.push(o);return i.join(", ")}function Ve(e,t,i,o){return t.map((a)=>`${xe(e,a,void 0,i,o)} ${a}w`).join(", ")}function Pn(e,t,i,o,a){return t.map((c)=>{let l=i?i*c:void 0;return`${xe(e,l,void 0,o,a)} ${c}x`}).join(", ")}function xe(e,t,i,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(t)c.push(`w_${t}`);if(i)c.push(`h_${i}`);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(t)c.set("w",String(t));if(i)c.set("h",String(i));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(t)c.set("width",String(t));if(i)c.set("height",String(i));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,i="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${i}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,i){let o=K(e,"src")||"",a=_o(o),c=K(e,"alt")||"",l=K(e,"width")||(a?String(a.source.width):void 0),m=K(e,"height")||(a?String(a.source.height):void 0),u=K(e,"sizes"),y=K(e,"srcset"),w=K(e,"densities"),x=K(e,"format"),C=Co(o)||qe(o)?.transparent===!0,b=K(e,"placeholder")||(a&&!C?"thumbhash":void 0),h=K(e,"placeholderColor")||"#e5e7eb",v=K(e,"provider"),S=K(e,"class")||K(e,"className")||"",A=K(e,"style")||"",P=K(e,"objectFit")||K(e,"fit"),k=K(e,"objectPosition")||K(e,"position"),N=K(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),q=K(e,"loading"),O=K(e,"decoding")||"async",E=!!a||_e(e,"picture",!1)||!!x,B=l?Number.parseInt(l):void 0,T=m?Number.parseInt(m):void 0,z=y||"",G="";if(a)z=a.sources[a.fallback.format]||"",G=u?Ze(u):"100vw";else if(!z&&u&&v&&v!=="local"&&v!=="static")z=Ve(o,Xe,v,x),G=Ze(u);else if(!z&&w){let _=w.split(/\s+/).map((F)=>Number.parseFloat(F.replace("x","")));z=Pn(o,_,B,v,x)}else if(u)G=Ze(u);let j=[];if(A)j.push(A);if(P)j.push(`object-fit:${P}`);if(k)j.push(`object-position:${k}`);if(B&&T)j.push(`aspect-ratio:${B}/${T}`);let W=[],ce=b==="blur"||b==="color"||b==="thumbhash";if(ce&&!C){let _=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:h}:qe(o);if(_&&b==="color")j.push(`background-color:${_.color}`),W.push("backgroundColor");else if(_)j.push(`background-color:${_.color}`),j.push(`background-image:url(${_.dataUrl})`),j.push("background-size:cover"),j.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let F=In(B||16,T||9,h);j.push(`background-image:url(${F})`),j.push("background-size:cover"),j.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ce&&b&&b!=="empty"&&b!=="none")j.push(`background-image:url(${n(b)})`),j.push("background-size:cover"),j.push("background-repeat:no-repeat"),W.push("backgroundImage");let we=a?.fallback.url||xe(o,B,T,v,x),Y=[];if(Y.push(`src="${n(mr(we,"fetched"))}"`),Y.push(`alt="${n(c)}"`),l)Y.push(`width="${n(l)}"`);if(m)Y.push(`height="${n(m)}"`);let ne=q||(L||M?"eager":U?"lazy":"");if(ne)Y.push(`loading="${n(ne)}"`);if(L)Y.push('fetchpriority="high"');if(Y.push(`decoding="${n(O)}"`),S)Y.push(`class="${n(S)}"`);if(j.length>0)Y.push(`style="${n(j.join(";"))}"`);if(z)Y.push(`srcset="${n(mr(z,"fetched"))}"`);if(G)Y.push(`sizes="${n(G)}"`);let $e=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(W.length>0){let _=typeof e.static.onload==="string"?e.static.onload:"",F=_n(W)+(_?`;${_}`:"");Y.push(`onload="${n(F)}"`),$e.add("onload")}Y.push(...oe(e,$e)),Y.push(...ae(e,$e));let D=`<img ${Y.join(" ")} />`,Z="";if(M){let F=x==="webp"?"image/webp":x==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${n(we)}"${F?` type="${F}"`:""}${z?` imagesrcset="${n(z)}"`:""}${G?` imagesizes="${n(G)}"`:""} />
3
+ `}if(E){let _=[];if(a)for(let F of Eo(a))_.push(`<source type="image/${F.format}" srcset="${n(F.srcset)}"${G?` sizes="${n(G)}"`:""} />`);if(!a&&(x==="avif"||x==="auto")){let F=xe(o,B,T,v,"avif"),te=z?Ve(o,Xe,v,"avif"):`${F}`;_.push(`<source type="image/avif" srcset="${n(te)}"${G?` sizes="${n(G)}"`:""} />`)}if(!a&&(x==="webp"||x==="auto")){let F=xe(o,B,T,v,"webp"),te=z?Ve(o,Xe,v,"webp"):`${F}`;_.push(`<source type="image/webp" srcset="${n(te)}"${G?` sizes="${n(G)}"`:""} />`)}return`${Z}<picture>
4
4
  ${_.join(`
5
5
  `)}
6
6
  ${D}
@@ -38,5 +38,5 @@ ${D}
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
40
  </style>`}};import{existsSync as On,readFileSync as Bn}from"fs";var Ne=new Map,Ot=new Set;function Tn(e){if(Ot.has(e))return;Ot.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 Dn(e){let t=process.cwd();for(let i of[`${t}/node_modules/@iconify-json/${e}/icons.json`,`${t}/pantry/@iconify-json/${e}/icons.json`,`${t}/node_modules/@iconify/json/json/${e}.json`,`${t}/pantry/@iconify/json/json/${e}.json`])if(On(i))return i;for(let i of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return g.resolve(i)}catch{}return null}function jn(e){if(Ne.has(e))return Ne.get(e);let t=Dn(e);if(!t)return Tn(e),null;try{let i=JSON.parse(Bn(t,"utf8"));return Ne.set(e,i.icons),i.icons}catch{return null}}function de(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);if(e.static[t]!==void 0)return String(e.static[t]);if(e.clientReactive[t]!==void 0)return e.clientReactive[t];return}var st={name:"Icon",aliases:["icon","stx-icon"],render(e,t,i){let o=de(e,"name")??de(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let P=o.split(":");a=P[0],c=P[1]}let l=n(de(e,"size")||"24"),m=n(de(e,"color")||"currentColor"),u=n(de(e,"class")||""),y=n(de(e,"style")||""),w=Ne.get(a)??jn(a);if(!w)return`<!-- Icon: collection "${a}" not loaded -->`;let x=w[c];if(!x)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=x.width||24,b=x.height||24,h=`0 0 ${C} ${b}`,v=x.body;if(m!=="currentColor")v=v.replace(/currentColor/g,m);let S=u?` class="${u}"`:"",A=y?` style="${y}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${h}" fill="none"${S}${A}>${v}</svg>`}};function Bt(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}function Tt(e,t){let i=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(i);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var it={name:"Suspense",aliases:["suspense"],render(e,t,i){let o=Tt(t,"fallback"),a=o.rest,c=Tt(a,"error"),l=c.rest,m=o.region??Bt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',u=c.region??Bt(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 Te(e,...t){for(let i of t){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let o=e.static[i];if(typeof o==="string")return o}return}var ot={name:"TransitionGroup",aliases:["transition-group"],render(e,t,i){let o=(Te(e,"name")||"v").replace(/["'<>]/g,""),a=(Te(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=Te(e,"class"),l=Te(e,"id"),m=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${m}>${t}</${a}>`}};function Dt(e=le){e.registerBuiltin(He),e.registerBuiltin(Ge),e.registerBuiltin(Ke),e.registerBuiltin(Ye),e.registerBuiltin(Qe),e.registerBuiltin(et),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot)}var jt=new Map;function Mn(e){let t=jt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),jt.set(e.source,t);return t}var Mt=new WeakMap;function Lt(e){let t=Mt.get(e);if(!t)t=new Set([...e].map((o)=>o.toLowerCase())),Mt.set(e,t);let i=t;return(o)=>!/[a-z]/.test(o)&&i.has(o.toLowerCase())}function Ln(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function zt(e,t,i){let o=[],a=0,c=typeof i==="function"?i:i?(l)=>i.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let m=Mn(t);m.lastIndex=l+1;let u=m.exec(e);if(!u){a=l+1;continue}let y=u[1];if(c&&c(y)){let S=l+1+y.length;while(S<e.length&&e[S]!==">")S++;a=S+1;continue}let w=l+1+y.length,x=null,C=w,b=-1,h=!1;while(w<e.length){let S=e[w];if(x){if(S==="\\"&&w+1<e.length){w+=2;continue}if(S===x)x=null;w++;continue}if(S==='"'||S==="'"){x=S,w++;continue}if(S==="/"&&w+1<e.length&&e[w+1]===">"){b=w+2,h=!0;break}if(S===">"){b=w+1;break}w++}if(b===-1){a=l+1;continue}let v=e.slice(C,h?b-2:b-1).trim();if(h)o.push({fullMatch:e.slice(l,b),tagName:y,attributes:v,content:"",startIndex:l,endIndex:b,isSelfClosing:!0}),a=b;else{let S=`<${y}`,A=`</${y}>`,P=1,k=b,N=-1;while(P>0&&k<e.length){let L=e.indexOf(S,k),q=e.indexOf(A,k);if(q===-1)break;if(L!==-1&&L<q){let O=e[L+S.length];if(O===" "||O===">"||O==="/"||O===`
41
- `||O==="\t"){let E=Ln(e,L+S.length);if(e[E-1]!=="/")P++;k=E+1}else k=L+S.length}else{if(P--,P===0){N=q;break}k=q+A.length}}if(N===-1){a=b;continue}let U=e.slice(b,N),M=N+A.length;o.push({fullMatch:e.slice(l,M),tagName:y,attributes:v,content:U,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function at(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ut(e,t){try{let i=Buffer.from(e,"base64").toString("utf8");return JSON.parse(i)}catch{}try{let i=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(i)}catch(i){if(t?.debug)console.error("Error decoding __stx_ prop:",i);return e}}function ct(e,t){let i=0,o="",a=t;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==="{")i++;else if(c==="}"){if(i--,i===0)return e.slice(t,a+1)}a++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(ct(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return lt(e).map((t)=>[t.start,t.end])}function lt(e){let t=[],i=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,o;while((o=i.exec(e))!==null){let a=o[2]||"",c=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(a);if(!c)continue;let l=J(c[1]??c[2]??c[3]??""),m=o.index,u=m+o[0].length,y=o[1].toLowerCase();if(o[0].endsWith("/>")||Un.has(y)){t.push({start:m,end:u,names:l});continue}let w=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=new RegExp(`<\\/?${w}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");x.lastIndex=u;let C=1,b=u,h;while((h=x.exec(e))!==null)if(h[0].startsWith("</")){if(C--,C===0){b=h.index+h[0].length;break}}else if(!h[0].endsWith("/>"))C++;t.push({start:m,end:b,names:l})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function Wa(e,t){if(!/:[\w-]+=/.test(e))return e;let i=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(...Wn(e));let l=new Set([...tt(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function m(C){return a.some(([b,h])=>C>=b&&C<h)}let u=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,y=[],w=new Map,x=256;while((c=u.exec(i))!==null){if(m(c.index))continue;let C=c[0],b=c[2];if(!b||!b.includes(":"))continue;let h=/(?:^|\s)data-native(?:\s|=|$)/i.test(b.replace(/"[^"]*"|'[^']*'/g,"")),v=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,S,A=b,P=!1;while((S=v.exec(b))!==null){if(Es(b,S.index,!0)?.kind==="attribute")continue;let k=S[1],N=S[2];if(Jc(k))continue;if(I(N,l))continue;if(N.includes("()")&&!N.includes(".get(")||N.includes("$store")||N.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=N.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let q=JSON.stringify([U,N]),O=w.get(q);if(!O){if(O=Function(...U,`return (${N})`),w.size>=x)w.clear();w.set(q,O)}let E=O(...M);if(k==="class"){let B=V(Ft(E));if(B){let T=A.match(/\sclass="([^"]*)"/);if(T)A=A.replace(T[0],()=>` class="${T[1]} ${B}"`);else A=A.replace(S[0],()=>` class="${B}"`)}else A=A.replace(S[0],"");P=!0;continue}if(zn.has(k)){if(E)A=A.replace(S[0],` ${k}`);else A=A.replace(S[0],"");P=!0;continue}if(E===null||E===void 0||E===!1)A=A.replace(S[0],"");else{let B=h&&typeof E==="object"?JSON.stringify(E):String(E),T=yn(k,B);A=A.replace(S[0],()=>` ${k}="${T}"`)}P=!0}catch(U){if(U instanceof ie)throw U;continue}}if(P){let k=c[3]?" /":"",U=`<${c[1]}${A}${k}>`;y.push({start:c.index,end:c.index+C.length,replacement:U})}}if(y.length>0){let C=Array(y.length*2+1),b=0;for(let h=0;h<y.length;h++){let{start:v,end:S,replacement:A}=y[h];C[h*2]=i.slice(b,v),C[h*2+1]=A,b=S}C[y.length*2]=i.slice(b),i=C.join("")}return i}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,i,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),m=(x)=>{if(l.size===0)return!1;let C=s(x),b=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(b&&l.has(b))return!0;for(let h of l){let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${v}\\s*\\(`).test(C))return!0}return!1},u=new Set(Yc),y=(x)=>{if(!x.includes("-")||x.startsWith("@")||x.startsWith(":")||x.startsWith("x-")||x.startsWith("__"))return x;if(x.startsWith("aria-")||x.startsWith("data-"))return x;return x.replace(/-([a-z0-9])/g,(C,b)=>b.toUpperCase())},w=(x,C)=>{let b=y(x);if(c.static[b]=C,b!==x)c.staticNames[b]=x};for(let[x,C]of Object.entries(e)){let b=x.startsWith("x-")&&!u.has(x)&&!x.startsWith("x-bind:")&&!x.startsWith("x-on:")?`:${x.slice(2)}`:x;if(b.startsWith("@")){c.events[b]=C;continue}if(b.startsWith("__stx_")){let h=y(b.slice(6));c.serverDynamic[h]=Ut(C,i);continue}if(b.startsWith(":")){let h=y(b.slice(1)),v=C===re?h:C;if(h==="if"||h==="for"||h==="show"){c.clientReactive[h]=v;continue}if(o){c.clientReactive[h]=v;continue}if(I(v,a)){c.clientReactive[h]=v;continue}if(m(v)){c.clientReactive[h]=v;continue}try{if(!f(v)){if(i.debug)console.error(`Unsafe expression in :${h} binding: ${v}`);c.clientReactive[h]=v;continue}let S=Object.keys(t),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(nt(v).some((M)=>!A.has(M)&&!S.includes(M)&&(!(M in globalThis)||P.has(M)))){c.clientReactive[h]=v;continue}let U=d(v,S)(...Object.values(t));if(c.serverDynamic[h]=U,h!==b.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[h]=b.slice(1)}catch{c.clientReactive[h]=v}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let h=Hn(C,a);if(h!==null){c.clientReactive[y(b)]=h;continue}let v=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(v)try{let S=v[1];if(f(S)){let P=d(S,Object.keys(t))(...Object.values(t));w(b,P!=null?String(P):"")}else{if(i.debug)console.error(`Unsafe expression in ${b}: ${S}`);w(b,C)}}catch(S){if(i.debug)console.error(`Error evaluating expression for ${b}:`,S);w(b,C)}else{let S=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=A.exec(C))!==null)try{let k=P[1];if(!f(k)){if(i.debug)console.error(`Unsafe expression in ${b}: ${k}`);continue}let U=d(k,Object.keys(t))(...Object.values(t));S=S.replace(P[0],String(U??""))}catch(k){if(i.debug)console.error(`Error evaluating expression in ${b}:`,k)}w(b,S)}continue}w(b,C===re?"true":at(C))}return c}function Hn(e,t){if(t.size===0)return null;let i=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(i)];if(!o.some((m)=>I(m[1],t)))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 qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,i){if(!e.includes("@"))return e;if(!qn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,t,i)}catch{return e}}function ge(e){let t={},i=0,o=e.length;while(i<o){while(i<o&&/\s/.test(e[i]))i++;if(i>=o)break;let a="";while(i<o&&!/[\s=]/.test(e[i]))a+=e[i],i++;if(!a)break;while(i<o&&/\s/.test(e[i]))i++;if(i<o&&e[i]==="="){i++;while(i<o&&/\s/.test(e[i]))i++;let c="";if(i<o&&(e[i]==='"'||e[i]==="'")){let l=e[i];i++;while(i<o){let m=e[i];if(m==="\\"&&i+1<o){i++,c+=e[i],i++;continue}if(m===l){i++;break}c+=m,i++}}else if(e[i]==="{"){c=ct(e,i),i+=c.length;let l=Wt(c);if(l!==null){t[`:${a}`]=l;continue}}else while(i<o&&!/\s/.test(e[i]))c+=e[i],i++;t[a]=c}else t[a]=re}return t}function Zt(e){return Object.entries(e).map(([t,i])=>i===re?t:`${t}="${Zn(i)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vn(e){let t=new Set,i=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=i.exec(e))!==null){let a=o[1];if(le.isBuiltin(a))t.add(a)}return[...t].sort()}async function hf(e,t,i,o,a){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,l=qt.dirname(i),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let x of e.matchAll(u)){let[C,b,h]=x,v=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=h,A,P=[];while((A=v.exec(h))!==null){let[k,N,U,M]=A,L=null,q=null;if(M.startsWith(".")||M.startsWith("/")){let B=qt.resolve(l,M);if(B.endsWith(".stx"))q=B;else{let T=`${B}.stx`;try{if(Ht.statSync(T).isFile())q=T}catch{try{if(Ht.statSync(B).isDirectory())L=B}catch{}}}}else L=ks(M,l);if(!L&&!q)continue;let O=!1,E=(B,T)=>{c.set(B,T),c.set(B.toLowerCase(),T);let z=B.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(z,T),a.add(T)};if(U&&q)E(U,q),O=!0;else if(N){let B=N.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let G=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(G)return{source:G[1],local:G[2]};return{source:z,local:z}}),T=L?Ss(L):null;for(let{source:z,local:G}of B){let j=null;if(q)j=q;else if(T)j=T.get(z)??T.get(z.toLowerCase())??T.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(j)E(G,j),O=!0}}if(O)P.push({start:A.index,end:A.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)S=S.slice(0,P[k].start)+S.slice(P[k].end);m.push({start:x.index,end:x.index+C.length,value:`<script${b}>${S}</script>`})}if(m.length===0)return e;let y=[],w=0;for(let x of m)y.push(e.slice(w,x.start),x.value),w=x.end;return y.push(e.slice(w)),y.join("")}async function Gn(e,t,i,o,a){let c=e;if(!t.__importedComponents)t.__importedComponents=new Map;let l=t.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,w]=u,x=w.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of x){let b=C.split("/"),v=b[b.length-1].replace(/\.stx$/,""),S=v.includes("-")?v.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):v.charAt(0).toUpperCase()+v.slice(1),A=null,P=_s(C,i,o);for(let k of P)try{if(await Bun.file(k).exists()){A=k;break}}catch{}if(A){l.set(S,A),l.set(v,A),l.set(v.toLowerCase(),A);let k=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(k,A),a.add(A),o.debug)console.log(`Imported component: ${S} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function Kn(e,t,i,o,a){let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let w=y.index,x=w+y[0].length-1,C=1,b=x+1;while(b<c.length&&C>0){if(c[b]==="(")C++;else if(c[b]===")"){if(C--,C===0)break}b++}if(C!==0)break;let h=c.substring(x+1,b),v=b+1,S=h.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=0;continue}let A=S[1],P,k=h.slice(S[0].length),N=k.match(/^\s*,\s*/);if(N)P=k.slice(N[0].length).trim();let U={};if(P)try{U=R(P,t)}catch(B){let T=B instanceof Error?B.message:String(B);c=c.replace(c.substring(w,v),`[Error parsing component props: ${T}]`);continue}let M="",L=v,O=c.substring(v).match(/^([\s\S]*?)@endcomponent/);if(O)M=O[1].trim(),L=v+O[0].length;let E=await Be(A,U,M,l,t,i,o,m,a);c=c.substring(0,w)+E+c.substring(L),u.lastIndex=0}return c}async function Jn(e,t,i,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=er(c);if(u.size>0){let v=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...v,...u])]}let y=X(c);c=y.output;let w=tt(t);return c=await h(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await h(c,/[A-Z][a-zA-Z0-9]*/,!0,Lt(yr)),c=await h(c,/[a-z][a-z0-9]*/,!1,yr),c=y.restore(c),c;async function h(v,S,A,P){if(!v)return v;let k=v,N=zt(k,S,P),U=lt(k),M=new Map;for(let O=N.length-1;O>=0;O--){let E=N[O],B=A?H(E.tagName):E.tagName,T=ge(Xn(E.attributes,t,i)),z=U.filter(({start:Z,end:_})=>E.startIndex>=Z&&E.startIndex<_),G=z.length>0,j=new Set(w);for(let Z of z)for(let _ of Z.names)j.add(_);let W=Fn(T,t,o,G,j);if(typeof W.clientReactive.for==="string")for(let Z of J(W.clientReactive.for))j.add(Z);let ce=le.getBuiltin(E.tagName),we=ce?await wr(E.tagName,l,t,i,o):!1;if(ce&&!we){let Z={context:t,filePath:i,options:o,dependencies:a},_=ce.render(W,E.content,Z);if(Object.keys(W.events).length>0){let F=Zt(W.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${F}`)}if(Object.keys(W.clientReactive).length>0)_=Vt(_,W.clientReactive);M.set(O,_);continue}if(!A&&E.tagName.includes("-")&&!await wr(B,l,t,i,o))continue;let Y={};for(let[Z,_]of Object.entries(W.static))Y[Z]=_;for(let[Z,_]of Object.entries(W.serverDynamic))Y[Z]=_;let ne={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},D=await Be(B,Y,y.restore(E.content),l,t,i,o,m,a,[...j],ne,E.tagName);if(D=Yn(D,W,ne.declaredProps,ne.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let Z=ne.reactiveProps.filter((te)=>!ne.consumedProps.has(te)&&!["if","for","show","key","ref"].includes(te)).map(H),_=ut(D,!0);if(Z.length&&_){if(!Object.hasOwn(ge(D.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))D=D.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+D.slice(_.insertPos);let te=ve(D);D=D.slice(0,te.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+D.slice(te.insertPos)}let F=ut(D,!0);if(F){let te=ge(D.slice(F.insertPos,F.tagEnd)),Se=ve(D),Kt=ge(D.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(te,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))D=D.slice(0,Se.insertPos)+" data-stx-native-host-owner"+D.slice(Se.insertPos)}}if(Object.keys(W.events).length>0){let Z=ve(D);if(Z){let _=Zt(W.events),F=Object.keys(W.events).map((te)=>te.replace(/^@/,"").split(".")[0]).join(" ");D=D.substring(0,Z.insertPos)+` data-stx-parent-events="${F}" ${_}`+D.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)D=Vt(D,W.clientReactive);M.set(O,D)}if(M.size===0)return k;let L="",q=0;for(let O=0;O<N.length;O++){let E=M.get(O);if(E===void 0)continue;L+=k.slice(q,N[O].startIndex),L+=E,q=N[O].endIndex}return L+=k.slice(q),L}}function Vt(e,t){let i=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(t).filter(([w])=>!i.has(w)),c=a.filter(([w])=>!o.has(w)).map(([w])=>H(w)).join(" "),l=e,m=a.length>0?ve(l):null;if(m){let w=a.map(([C,b])=>`:${H(C)}="${b.replace(/"/g,"&quot;")}"`).join(" "),x=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${x} ${w}`+l.substring(m.insertPos)}let u=t.if;if(u)l=`<template :if="${u.replace(/"/g,"&quot;")}">${l}</template>`;let y=t.for;if(y){let w=t.key,x=w?` :key="${w.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${y.replace(/"/g,"&quot;")}"${x}>${l}</template>`}return l}function Yn(e,t,i=new Set,o=new Set,a=!1){let c=ut(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=t.serverDynamic.class??t.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let h=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,v=h.test(l)?l.replace(h,(S,A,P,k,N)=>`${A}class="${n(`${at(P??k??N)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+v+e.slice(c.tagEnd),c.tagEnd+=v.length-l.length,l=v}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:i,w=new Set(Object.keys(ge(l))),x=new Set(["class","className"]);for(let h of Object.keys(t.static)){let v=t.staticNames[h]??h;if(w.has(v)||y.has(h)||!u&&!Fe(v))x.add(h)}for(let h of Object.keys(t.serverDynamic)){let v=t.serverDynamicNames?.[h]??h;if(w.has(v)||y.has(h)||!u&&!Fe(v))x.add(h)}let C=[];if(u){for(let[h,v]of Object.entries(t.static)){if(x.has(h)||v!==!0&&v!==re)continue;x.add(h),C.push(`${n(t.staticNames?.[h]??h)}="true"`)}for(let[h,v]of Object.entries(t.serverDynamic)){if(x.has(h)||v!==!0)continue;x.add(h),C.push(`${n(t.serverDynamicNames?.[h]??h)}="true"`)}}let b=[...oe(t,x),...ae(t,x),...C];if(u){for(let[h,v]of Object.entries(t.serverDynamic)){if(x.has(h)||v!==!1)continue;let S=t.serverDynamicNames?.[h]??h;b.push(`${n(S)}="false"`)}for(let[h,v]of Object.entries(t.serverDynamic)){if(x.has(h)||v===null||typeof v!=="object")continue;let S=JSON.stringify(v);if(S!==void 0){let A=t.serverDynamicNames?.[h]??h;b.push(`${n(A)}="${n(S)}"`)}}}if(b.length===0)return e;return`${e.slice(0,c.insertPos)} ${b.join(" ")}${e.slice(c.insertPos)}`}function ve(e){let t=Gt(e,0);if(t)return t;let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(i)return{insertPos:i.index+1+i[1].length,tagEnd:ft(e,i.index+1+i[1].length)};return null}function ut(e,t=!1){let i=ve(e);if(!i)return null;let o=e.slice(i.insertPos,i.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Gt(e,i.tagEnd+1):i;return a&&t?Qn(e,a)??a:a}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",t.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let w=e.indexOf("-->",o+4);if(w<0)return null;o=e.indexOf("<",w+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=ft(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 w=new RegExp(`</${m}\\s*>`,"gi");if(w.lastIndex=y+1,!w.exec(e))return null;o=e.indexOf("<",w.lastIndex);continue}else{let w=ge(e.slice(u,y)),x=a>0&&(Object.hasOwn(w,"data-stx-component-wrapper")||Object.hasOwn(w,"data-stx-native-host-owner"));if(c===void 0&&!x&&Object.hasOwn(w,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!i.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&x)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Gt(e,t){let i=t;while(i<e.length){let o=e.slice(i),a=o.match(/^\s+/);if(a){i+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",i+4);if(m===-1)return null;i=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,i+c[0].length);if(u===-1)return null;i=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:i+1+l[1].length,tagEnd:ft(e,i+1+l[1].length)}}return null}function ft(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function er(e){let t=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=i[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Jo(i[2]))t.add(a);for(let a of i[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])t.add(a[1]);if(a[3])t.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))t.add(l)}}}return t}async function ns(e,t,i,o,a){if(!Xt)Dt(le),Xt=!0;let c=await hf(e,t,i,o,a);c=await Gn(c,t,i,o,a),c=await Kn(c,t,i,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Oe,(x,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let w=c;if(c=await Jn(y.output,t,i,o,a),c===w)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Vn(c);if(m.length>0)console.warn(`[stx] ${i}: 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{ko,_o,Co,nh,ts,rh,Wa,hf,ns};
41
+ `||O==="\t"){let E=Ln(e,L+S.length);if(e[E-1]!=="/")P++;k=E+1}else k=L+S.length}else{if(P--,P===0){N=q;break}k=q+A.length}}if(N===-1){a=b;continue}let U=e.slice(b,N),M=N+A.length;o.push({fullMatch:e.slice(l,M),tagName:y,attributes:v,content:U,startIndex:l,endIndex:M,isSelfClosing:!1}),a=M}}return o}function at(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function Ut(e,t){try{let i=Buffer.from(e,"base64").toString("utf8");return JSON.parse(i)}catch{}try{let i=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(i)}catch(i){if(t?.debug)console.error("Error decoding __stx_ prop:",i);return e}}function ct(e,t){let i=0,o="",a=t;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==="{")i++;else if(c==="}"){if(i--,i===0)return e.slice(t,a+1)}a++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(ct(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return lt(e).map((t)=>[t.start,t.end])}function lt(e){let t=[],i=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,o;while((o=i.exec(e))!==null){let a=o[2]||"",c=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(a);if(!c)continue;let l=J(c[1]??c[2]??c[3]??""),m=o.index,u=m+o[0].length,y=o[1].toLowerCase();if(o[0].endsWith("/>")||Un.has(y)){t.push({start:m,end:u,names:l});continue}let w=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=new RegExp(`<\\/?${w}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");x.lastIndex=u;let C=1,b=u,h;while((h=x.exec(e))!==null)if(h[0].startsWith("</")){if(C--,C===0){b=h.index+h[0].length;break}}else if(!h[0].endsWith("/>"))C++;t.push({start:m,end:b,names:l})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function qa(e,t){if(!/:[\w-]+=/.test(e))return e;let i=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(...Wn(e));let l=new Set([...tt(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function m(C){return a.some(([b,h])=>C>=b&&C<h)}let u=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,y=[],w=new Map,x=256;while((c=u.exec(i))!==null){if(m(c.index))continue;let C=c[0],b=c[2];if(!b||!b.includes(":"))continue;let h=/(?:^|\s)data-native(?:\s|=|$)/i.test(b.replace(/"[^"]*"|'[^']*'/g,"")),v=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,S,A=b,P=!1;while((S=v.exec(b))!==null){if(Ts(b,S.index,!0)?.kind==="attribute")continue;let k=S[1],N=S[2];if(Yc(k))continue;if(I(N,l))continue;if(N.includes("()")&&!N.includes(".get(")||N.includes("$store")||N.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=N.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let q=JSON.stringify([U,N]),O=w.get(q);if(!O){if(O=Function(...U,`return (${N})`),w.size>=x)w.clear();w.set(q,O)}let E=O(...M);if(k==="class"){let B=V(Ft(E));if(B){let T=A.match(/\sclass="([^"]*)"/);if(T)A=A.replace(T[0],()=>` class="${T[1]} ${B}"`);else A=A.replace(S[0],()=>` class="${B}"`)}else A=A.replace(S[0],"");P=!0;continue}if(zn.has(k)){if(E)A=A.replace(S[0],` ${k}`);else A=A.replace(S[0],"");P=!0;continue}if(E===null||E===void 0||E===!1)A=A.replace(S[0],"");else{let B=h&&typeof E==="object"?JSON.stringify(E):String(E),T=yn(k,B);A=A.replace(S[0],()=>` ${k}="${T}"`)}P=!0}catch(U){if(U instanceof ie)throw U;continue}}if(P){let k=c[3]?" /":"",U=`<${c[1]}${A}${k}>`;y.push({start:c.index,end:c.index+C.length,replacement:U})}}if(y.length>0){let C=Array(y.length*2+1),b=0;for(let h=0;h<y.length;h++){let{start:v,end:S,replacement:A}=y[h];C[h*2]=i.slice(b,v),C[h*2+1]=A,b=S}C[y.length*2]=i.slice(b),i=C.join("")}return i}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,i,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),m=(x)=>{if(l.size===0)return!1;let C=s(x),b=C.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(b&&l.has(b))return!0;for(let h of l){let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${v}\\s*\\(`).test(C))return!0}return!1},u=new Set(Zc),y=(x)=>{if(!x.includes("-")||x.startsWith("@")||x.startsWith(":")||x.startsWith("x-")||x.startsWith("__"))return x;if(x.startsWith("aria-")||x.startsWith("data-"))return x;return x.replace(/-([a-z0-9])/g,(C,b)=>b.toUpperCase())},w=(x,C)=>{let b=y(x);if(c.static[b]=C,b!==x)c.staticNames[b]=x};for(let[x,C]of Object.entries(e)){let b=x.startsWith("x-")&&!u.has(x)&&!x.startsWith("x-bind:")&&!x.startsWith("x-on:")?`:${x.slice(2)}`:x;if(b.startsWith("@")){c.events[b]=C;continue}if(b.startsWith("__stx_")){let h=y(b.slice(6));c.serverDynamic[h]=Ut(C,i);continue}if(b.startsWith(":")){let h=y(b.slice(1)),v=C===re?h:C;if(h==="if"||h==="for"||h==="show"){c.clientReactive[h]=v;continue}if(o){c.clientReactive[h]=v;continue}if(I(v,a)){c.clientReactive[h]=v;continue}if(m(v)){c.clientReactive[h]=v;continue}try{if(!f(v)){if(i.debug)console.error(`Unsafe expression in :${h} binding: ${v}`);c.clientReactive[h]=v;continue}let S=Object.keys(t),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(nt(v).some((M)=>!A.has(M)&&!S.includes(M)&&(!(M in globalThis)||P.has(M)))){c.clientReactive[h]=v;continue}let U=d(v,S)(...Object.values(t));if(c.serverDynamic[h]=U,h!==b.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[h]=b.slice(1)}catch{c.clientReactive[h]=v}continue}if(typeof C==="string"&&C.includes("{{")&&C.includes("}}")){let h=Hn(C,a);if(h!==null){c.clientReactive[y(b)]=h;continue}let v=C.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(v)try{let S=v[1];if(f(S)){let P=d(S,Object.keys(t))(...Object.values(t));w(b,P!=null?String(P):"")}else{if(i.debug)console.error(`Unsafe expression in ${b}: ${S}`);w(b,C)}}catch(S){if(i.debug)console.error(`Error evaluating expression for ${b}:`,S);w(b,C)}else{let S=C,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=A.exec(C))!==null)try{let k=P[1];if(!f(k)){if(i.debug)console.error(`Unsafe expression in ${b}: ${k}`);continue}let U=d(k,Object.keys(t))(...Object.values(t));S=S.replace(P[0],String(U??""))}catch(k){if(i.debug)console.error(`Error evaluating expression in ${b}:`,k)}w(b,S)}continue}w(b,C===re?"true":at(C))}return c}function Hn(e,t){if(t.size===0)return null;let i=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(i)];if(!o.some((m)=>I(m[1],t)))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 qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,i){if(!e.includes("@"))return e;if(!qn.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return se(e,t,i)}catch{return e}}function ge(e){let t={},i=0,o=e.length;while(i<o){while(i<o&&/\s/.test(e[i]))i++;if(i>=o)break;let a="";while(i<o&&!/[\s=]/.test(e[i]))a+=e[i],i++;if(!a)break;while(i<o&&/\s/.test(e[i]))i++;if(i<o&&e[i]==="="){i++;while(i<o&&/\s/.test(e[i]))i++;let c="";if(i<o&&(e[i]==='"'||e[i]==="'")){let l=e[i];i++;while(i<o){let m=e[i];if(m==="\\"&&i+1<o){i++,c+=e[i],i++;continue}if(m===l){i++;break}c+=m,i++}}else if(e[i]==="{"){c=ct(e,i),i+=c.length;let l=Wt(c);if(l!==null){t[`:${a}`]=l;continue}}else while(i<o&&!/\s/.test(e[i]))c+=e[i],i++;t[a]=c}else t[a]=re}return t}function Zt(e){return Object.entries(e).map(([t,i])=>i===re?t:`${t}="${Zn(i)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vn(e){let t=new Set,i=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=i.exec(e))!==null){let a=o[1];if(le.isBuiltin(a))t.add(a)}return[...t].sort()}async function yf(e,t,i,o,a){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,l=qt.dirname(i),m=[],u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let x of e.matchAll(u)){let[C,b,h]=x,v=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,S=h,A,P=[];while((A=v.exec(h))!==null){let[k,N,U,M]=A,L=null,q=null;if(M.startsWith(".")||M.startsWith("/")){let B=qt.resolve(l,M);if(B.endsWith(".stx"))q=B;else{let T=`${B}.stx`;try{if(Ht.statSync(T).isFile())q=T}catch{try{if(Ht.statSync(B).isDirectory())L=B}catch{}}}}else L=_s(M,l);if(!L&&!q)continue;let O=!1,E=(B,T)=>{c.set(B,T),c.set(B.toLowerCase(),T);let z=B.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(z,T),a.add(T)};if(U&&q)E(U,q),O=!0;else if(N){let B=N.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let G=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(G)return{source:G[1],local:G[2]};return{source:z,local:z}}),T=L?ks(L):null;for(let{source:z,local:G}of B){let j=null;if(q)j=q;else if(T)j=T.get(z)??T.get(z.toLowerCase())??T.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(j)E(G,j),O=!0}}if(O)P.push({start:A.index,end:A.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)S=S.slice(0,P[k].start)+S.slice(P[k].end);m.push({start:x.index,end:x.index+C.length,value:`<script${b}>${S}</script>`})}if(m.length===0)return e;let y=[],w=0;for(let x of m)y.push(e.slice(w,x.start),x.value),w=x.end;return y.push(e.slice(w)),y.join("")}async function Gn(e,t,i,o,a){let c=e;if(!t.__importedComponents)t.__importedComponents=new Map;let l=t.__importedComponents,m=/@import\s*\(\s*([^)]+)\s*\)/g,u;while((u=m.exec(c))!==null){let[y,w]=u,x=w.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of x){let b=C.split("/"),v=b[b.length-1].replace(/\.stx$/,""),S=v.includes("-")?v.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):v.charAt(0).toUpperCase()+v.slice(1),A=null,P=Cs(C,i,o);for(let k of P)try{if(await Bun.file(k).exists()){A=k;break}}catch{}if(A){l.set(S,A),l.set(v,A),l.set(v.toLowerCase(),A);let k=S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(k,A),a.add(A),o.debug)console.log(`Imported component: ${S} -> ${A}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(y,""),m.lastIndex=0}return c}async function Kn(e,t,i,o,a){let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=/@component\s*\(/g,y;while((y=u.exec(c))!==null){let w=y.index,x=w+y[0].length-1,C=1,b=x+1;while(b<c.length&&C>0){if(c[b]==="(")C++;else if(c[b]===")"){if(C--,C===0)break}b++}if(C!==0)break;let h=c.substring(x+1,b),v=b+1,S=h.match(/^\s*['"]([^'"]+)['"]/);if(!S){u.lastIndex=0;continue}let A=S[1],P,k=h.slice(S[0].length),N=k.match(/^\s*,\s*/);if(N)P=k.slice(N[0].length).trim();let U={};if(P)try{U=R(P,t)}catch(B){let T=B instanceof Error?B.message:String(B);c=c.replace(c.substring(w,v),`[Error parsing component props: ${T}]`);continue}let M="",L=v,O=c.substring(v).match(/^([\s\S]*?)@endcomponent/);if(O)M=O[1].trim(),L=v+O[0].length;let E=await Be(A,U,M,l,t,i,o,m,a);c=c.substring(0,w)+E+c.substring(L),u.lastIndex=0}return c}async function Jn(e,t,i,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let m=t.__processedComponents,u=er(c);if(u.size>0){let v=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...v,...u])]}let y=X(c);c=y.output;let w=tt(t);return c=await h(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await h(c,/[A-Z][a-zA-Z0-9]*/,!0,Lt(yr)),c=await h(c,/[a-z][a-z0-9]*/,!1,yr),c=y.restore(c),c;async function h(v,S,A,P){if(!v)return v;let k=v,N=zt(k,S,P),U=lt(k),M=new Map;for(let O=N.length-1;O>=0;O--){let E=N[O],B=A?H(E.tagName):E.tagName,T=ge(Xn(E.attributes,t,i)),z=U.filter(({start:Z,end:_})=>E.startIndex>=Z&&E.startIndex<_),G=z.length>0,j=new Set(w);for(let Z of z)for(let _ of Z.names)j.add(_);let W=Fn(T,t,o,G,j);if(typeof W.clientReactive.for==="string")for(let Z of J(W.clientReactive.for))j.add(Z);let ce=le.getBuiltin(E.tagName),we=ce?await wr(E.tagName,l,t,i,o):!1;if(ce&&!we){let Z={context:t,filePath:i,options:o,dependencies:a},_=ce.render(W,E.content,Z);if(Object.keys(W.events).length>0){let F=Zt(W.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${F}`)}if(Object.keys(W.clientReactive).length>0)_=Vt(_,W.clientReactive);M.set(O,_);continue}if(!A&&E.tagName.includes("-")&&!await wr(B,l,t,i,o))continue;let Y={};for(let[Z,_]of Object.entries(W.static))Y[Z]=_;for(let[Z,_]of Object.entries(W.serverDynamic))Y[Z]=_;let ne={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},D=await Be(B,Y,y.restore(E.content),l,t,i,o,m,a,[...j],ne,E.tagName);if(D=Yn(D,W,ne.declaredProps,ne.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let Z=ne.reactiveProps.filter((te)=>!ne.consumedProps.has(te)&&!["if","for","show","key","ref"].includes(te)).map(H),_=ut(D,!0);if(Z.length&&_){if(!Object.hasOwn(ge(D.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))D=D.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+D.slice(_.insertPos);let te=ve(D);D=D.slice(0,te.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+D.slice(te.insertPos)}let F=ut(D,!0);if(F){let te=ge(D.slice(F.insertPos,F.tagEnd)),Se=ve(D),Kt=ge(D.slice(Se.insertPos,Se.tagEnd));if(Object.hasOwn(te,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))D=D.slice(0,Se.insertPos)+" data-stx-native-host-owner"+D.slice(Se.insertPos)}}if(Object.keys(W.events).length>0){let Z=ve(D);if(Z){let _=Zt(W.events),F=Object.keys(W.events).map((te)=>te.replace(/^@/,"").split(".")[0]).join(" ");D=D.substring(0,Z.insertPos)+` data-stx-parent-events="${F}" ${_}`+D.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)D=Vt(D,W.clientReactive);M.set(O,D)}if(M.size===0)return k;let L="",q=0;for(let O=0;O<N.length;O++){let E=M.get(O);if(E===void 0)continue;L+=k.slice(q,N[O].startIndex),L+=E,q=N[O].endIndex}return L+=k.slice(q),L}}function Vt(e,t){let i=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(t).filter(([w])=>!i.has(w)),c=a.filter(([w])=>!o.has(w)).map(([w])=>H(w)).join(" "),l=e,m=a.length>0?ve(l):null;if(m){let w=a.map(([C,b])=>`:${H(C)}="${b.replace(/"/g,"&quot;")}"`).join(" "),x=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,m.insertPos)+`${x} ${w}`+l.substring(m.insertPos)}let u=t.if;if(u)l=`<template :if="${u.replace(/"/g,"&quot;")}">${l}</template>`;let y=t.for;if(y){let w=t.key,x=w?` :key="${w.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${y.replace(/"/g,"&quot;")}"${x}>${l}</template>`}return l}function Yn(e,t,i=new Set,o=new Set,a=!1){let c=ut(e,a);if(!c)return e;let l=e.slice(c.insertPos,c.tagEnd),m=t.serverDynamic.class??t.static.class;if(a&&typeof m==="string"&&m&&!o.has("class")){let h=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,v=h.test(l)?l.replace(h,(S,A,P,k,N)=>`${A}class="${n(`${at(P??k??N)} ${m}`)}"`):` class="${n(m)}"${l}`;e=e.slice(0,c.insertPos)+v+e.slice(c.tagEnd),c.tagEnd+=v.length-l.length,l=v}let u=a||/\bdata-native(?:\s|=)/i.test(l),y=u?o:i,w=new Set(Object.keys(ge(l))),x=new Set(["class","className"]);for(let h of Object.keys(t.static)){let v=t.staticNames[h]??h;if(w.has(v)||y.has(h)||!u&&!Fe(v))x.add(h)}for(let h of Object.keys(t.serverDynamic)){let v=t.serverDynamicNames?.[h]??h;if(w.has(v)||y.has(h)||!u&&!Fe(v))x.add(h)}let C=[];if(u){for(let[h,v]of Object.entries(t.static)){if(x.has(h)||v!==!0&&v!==re)continue;x.add(h),C.push(`${n(t.staticNames?.[h]??h)}="true"`)}for(let[h,v]of Object.entries(t.serverDynamic)){if(x.has(h)||v!==!0)continue;x.add(h),C.push(`${n(t.serverDynamicNames?.[h]??h)}="true"`)}}let b=[...oe(t,x),...ae(t,x),...C];if(u){for(let[h,v]of Object.entries(t.serverDynamic)){if(x.has(h)||v!==!1)continue;let S=t.serverDynamicNames?.[h]??h;b.push(`${n(S)}="false"`)}for(let[h,v]of Object.entries(t.serverDynamic)){if(x.has(h)||v===null||typeof v!=="object")continue;let S=JSON.stringify(v);if(S!==void 0){let A=t.serverDynamicNames?.[h]??h;b.push(`${n(A)}="${n(S)}"`)}}}if(b.length===0)return e;return`${e.slice(0,c.insertPos)} ${b.join(" ")}${e.slice(c.insertPos)}`}function ve(e){let t=Gt(e,0);if(t)return t;let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(i)return{insertPos:i.index+1+i[1].length,tagEnd:ft(e,i.index+1+i[1].length)};return null}function ut(e,t=!1){let i=ve(e);if(!i)return null;let o=e.slice(i.insertPos,i.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?Gt(e,i.tagEnd+1):i;return a&&t?Qn(e,a)??a:a}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=e.lastIndexOf("<",t.insertPos),a=0,c;while(o>=0&&o<e.length){if(e.startsWith("<!--",o)){let w=e.indexOf("-->",o+4);if(w<0)return null;o=e.indexOf("<",w+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=ft(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 w=new RegExp(`</${m}\\s*>`,"gi");if(w.lastIndex=y+1,!w.exec(e))return null;o=e.indexOf("<",w.lastIndex);continue}else{let w=ge(e.slice(u,y)),x=a>0&&(Object.hasOwn(w,"data-stx-component-wrapper")||Object.hasOwn(w,"data-stx-native-host-owner"));if(c===void 0&&!x&&Object.hasOwn(w,"data-stx-native-host-root"))return{insertPos:u,tagEnd:y};if(!i.has(m)&&e[y-1]!=="/"){if(a++,c===void 0&&x)c=a}else if(a===0)return null}o=e.indexOf("<",y+1)}return null}function Gt(e,t){let i=t;while(i<e.length){let o=e.slice(i),a=o.match(/^\s+/);if(a){i+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",i+4);if(m===-1)return null;i=m+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let m=`</${c[1].toLowerCase()}>`,u=e.toLowerCase().indexOf(m,i+c[0].length);if(u===-1)return null;i=u+m.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:i+1+l[1].length,tagEnd:ft(e,i+1+l[1].length)}}return null}function ft(e,t){let i="";for(let o=t;o<e.length;o++){let a=e[o];if(i){if(a==="\\")o++;else if(a===i)i=""}else if(a==='"'||a==="'")i=a;else if(a===">")return o}return e.length}function er(e){let t=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=i[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Yo(i[2]))t.add(a);for(let a of i[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])t.add(a[1]);if(a[3])t.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))t.add(l)}}}return t}async function ns(e,t,i,o,a){if(!Xt)Dt(le),Xt=!0;let c=await yf(e,t,i,o,a);c=await Gn(c,t,i,o,a),c=await Kn(c,t,i,o,a);let l=[];for(let m=0;m<3;m++){let u=l.length,y=pe(c,Oe,(x,C)=>`\x00STX_COMPONENT_COMMENT_${u+C}\x00`,`STX_COMPONENT_COMMENT:${u}`);l.push(...y.tokens);let w=c;if(c=await Jn(y.output,t,i,o,a),c===w)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(m,u)=>l[Number(u)]??"");if(o.debug){let m=Vn(c);if(m.length>0)console.warn(`[stx] ${i}: 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{_o,Co,Eo,nh,ts,rh,qa,yf,ns};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var{WebView:p}=globalThis.Bun;import{existsSync as y,mkdirSync as b,readdirSync as v,statSync as S}from"fs";import l from"path";var h=16384;function M(e){if(/^https?:\/\//.test(e)||e.startsWith("file://"))return e;return`file://${l.resolve(e)}`}function g(e,n,t,o){return new Promise((s)=>{let i=!1,r,m,c=()=>{if(!i){if(i=!0,clearTimeout(m),r)clearTimeout(r);e.onNavigated=void 0,s()}};m=setTimeout(c,o),e.onNavigated=()=>{if(!i)r=setTimeout(c,t)};try{let u=e.navigate(n);if(u&&typeof u.catch==="function")u.catch(c)}catch{c()}})}async function w(e,n,t){let o=`!!document.querySelector(${JSON.stringify(n)})`,s=Date.now()+t;while(Date.now()<s){try{if(await e.evaluate(o))return}catch{}await new Promise((i)=>setTimeout(i,100))}}async function T(e){try{let n=await e.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(n,h):0}catch{return 0}}async function xl(e,n,t={}){let o=Math.min(t.width??1440,h),s=Math.min(t.height??2200,h),i=t.waitMs??800,r=t.timeoutMs??15000,m=t.format??"png",c=M(e),u=(f)=>new p({width:o,height:f,headless:!0,...t.backend?{backend:t.backend}:{}}),a=u(s);try{if(await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r);if(t.fullPage){let d=await T(a);if(d>s){if(a.close(),a=u(d),await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r)}}let f=await a.screenshot({encoding:"buffer",format:m});b(l.dirname(l.resolve(n)),{recursive:!0}),await Bun.write(n,f)}finally{a.close()}if(!y(n))throw Error(`Screenshot was not produced for ${e}`);return{input:e,output:n,bytes:S(n).size}}async function $g(e,n,t={}){b(n,{recursive:!0});let o;if(!/^https?:\/\//.test(e)&&y(e)&&S(e).isDirectory())o=v(e).filter((r)=>r.endsWith(".html")).map((r)=>l.join(e,r));else o=[e];let s=t.format??"png",i=[];for(let r of o){let m=/^https?:\/\//.test(r)?new URL(r).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":l.basename(r).replace(/\.html?$/,"");i.push(await xl(r,l.join(n,`${m}.${s}`),t))}return i}
3
- export{xl,$g};
2
+ var{WebView:p}=globalThis.Bun;import{existsSync as y,mkdirSync as b,readdirSync as v,statSync as S}from"fs";import l from"path";var h=16384;function M(e){if(/^https?:\/\//.test(e)||e.startsWith("file://"))return e;return`file://${l.resolve(e)}`}function g(e,n,t,o){return new Promise((s)=>{let i=!1,r,m,c=()=>{if(!i){if(i=!0,clearTimeout(m),r)clearTimeout(r);e.onNavigated=void 0,s()}};m=setTimeout(c,o),e.onNavigated=()=>{if(!i)r=setTimeout(c,t)};try{let u=e.navigate(n);if(u&&typeof u.catch==="function")u.catch(c)}catch{c()}})}async function w(e,n,t){let o=`!!document.querySelector(${JSON.stringify(n)})`,s=Date.now()+t;while(Date.now()<s){try{if(await e.evaluate(o))return}catch{}await new Promise((i)=>setTimeout(i,100))}}async function T(e){try{let n=await e.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(n,h):0}catch{return 0}}async function Sl(e,n,t={}){let o=Math.min(t.width??1440,h),s=Math.min(t.height??2200,h),i=t.waitMs??800,r=t.timeoutMs??15000,m=t.format??"png",c=M(e),u=(f)=>new p({width:o,height:f,headless:!0,...t.backend?{backend:t.backend}:{}}),a=u(s);try{if(await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r);if(t.fullPage){let d=await T(a);if(d>s){if(a.close(),a=u(d),await g(a,c,i,r),t.waitSelector)await w(a,t.waitSelector,r)}}let f=await a.screenshot({encoding:"buffer",format:m});b(l.dirname(l.resolve(n)),{recursive:!0}),await Bun.write(n,f)}finally{a.close()}if(!y(n))throw Error(`Screenshot was not produced for ${e}`);return{input:e,output:n,bytes:S(n).size}}async function $g(e,n,t={}){b(n,{recursive:!0});let o;if(!/^https?:\/\//.test(e)&&y(e)&&S(e).isDirectory())o=v(e).filter((r)=>r.endsWith(".html")).map((r)=>l.join(e,r));else o=[e];let s=t.format??"png",i=[];for(let r of o){let m=/^https?:\/\//.test(r)?new URL(r).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":l.basename(r).replace(/\.html?$/,"");i.push(await Sl(r,l.join(n,`${m}.${s}`),t))}return i}
3
+ export{Sl,$g};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{AsyncLocalStorage as R}from"async_hooks";var b=Symbol.for("stx.runtime-config.scope"),y=globalThis,m=y[b]??=new R;function Fe(n,f){return m.run(n,f)}function vn(){return m.getStore()}function Ns(){let n=m.getStore();if(!n)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:n.public},"private",{value:n.private}))}function ci(){return Ns().public}function O(n={},f=process.env){let s=new Set;function o(e,i){if(i===null)return e===null;if(Array.isArray(i))return Array.isArray(e)&&(!i.length||e.every((r)=>i.some((u)=>o(r,u))));if(typeof i==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.entries(i).every(([r,u])=>Object.hasOwn(e,r)&&o(e[r],u));return typeof e===typeof i}function g(e,i){if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`);let t=Object.create(null);for(let[c,l]of Object.entries(e)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)||["constructor","prototype","__proto__"].includes(c))throw TypeError(`Invalid runtime config key: ${c}`);t[c]=g(l,[...i,c])}return Object.freeze(t)}let r=`STX_RUNTIME_${i.map((t)=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(s.has(r))throw TypeError(`Ambiguous runtime config environment key: ${r}`);s.add(r);let u=f[r],a=e;if(u!==void 0){try{a=typeof e==="string"?u:JSON.parse(u)}catch{throw TypeError(`Invalid runtime config override: ${r}`)}if(!o(a,e))throw TypeError(`Wrong runtime config override type: ${r}`)}function p(t){if(t===null||typeof t==="string"||typeof t==="boolean")return t;if(typeof t==="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(p));if(t&&typeof t==="object"&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null))return Object.freeze(Object.fromEntries(Object.entries(t).map(([c,l])=>[c,p(l)])));throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`)}return p(a)}return Object.freeze({public:g(n.public??{},["public"]),private:g(n.private??{},["private"])})}function C(n){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(n.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Dt(n,f){let s=n.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),o=/<head\b[^>]*>/i.exec(s),g=o?o.index+o[0].length:0;return s.slice(0,g)+C(f)+s.slice(g)}
3
- export{Fe,vn,Ns,ci,O,Dt};
2
+ import{AsyncLocalStorage as R}from"async_hooks";var b=Symbol.for("stx.runtime-config.scope"),y=globalThis,m=y[b]??=new R;function Fe(n,f){return m.run(n,f)}function vn(){return m.getStore()}function Ds(){let n=m.getStore();if(!n)throw Error("useServerRuntimeConfig requires a server request or template render");return Object.freeze(Object.defineProperty({public:n.public},"private",{value:n.private}))}function li(){return Ds().public}function O(n={},f=process.env){let s=new Set;function o(e,i){if(i===null)return e===null;if(Array.isArray(i))return Array.isArray(e)&&(!i.length||e.every((r)=>i.some((u)=>o(r,u))));if(typeof i==="object")return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.entries(i).every(([r,u])=>Object.hasOwn(e,r)&&o(e[r],u));return typeof e===typeof i}function g(e,i){if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`);let t=Object.create(null);for(let[c,l]of Object.entries(e)){if(!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)||["constructor","prototype","__proto__"].includes(c))throw TypeError(`Invalid runtime config key: ${c}`);t[c]=g(l,[...i,c])}return Object.freeze(t)}let r=`STX_RUNTIME_${i.map((t)=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()).join("__")}`;if(s.has(r))throw TypeError(`Ambiguous runtime config environment key: ${r}`);s.add(r);let u=f[r],a=e;if(u!==void 0){try{a=typeof e==="string"?u:JSON.parse(u)}catch{throw TypeError(`Invalid runtime config override: ${r}`)}if(!o(a,e))throw TypeError(`Wrong runtime config override type: ${r}`)}function p(t){if(t===null||typeof t==="string"||typeof t==="boolean")return t;if(typeof t==="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(p));if(t&&typeof t==="object"&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null))return Object.freeze(Object.fromEntries(Object.entries(t).map(([c,l])=>[c,p(l)])));throw TypeError(`Runtime config ${i.join(".")} must contain JSON values`)}return p(a)}return Object.freeze({public:g(n.public??{},["public"]),private:g(n.private??{},["private"])})}function C(n){return`<script data-stx-scoped data-stx-runtime-config type="application/json">${JSON.stringify(n.public).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function Dt(n,f){let s=n.replace(/<script\b[^>]*\bdata-stx-runtime-config\b[^>]*>[\s\S]*?<\/script>/gi,""),o=/<head\b[^>]*>/i.exec(s),g=o?o.index+o[0].length:0;return s.slice(0,g)+C(f)+s.slice(g)}
3
+ export{Fe,vn,Ds,li,O,Dt};