@stacksjs/stx 0.2.336 → 0.2.338

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 (197) hide show
  1. package/dist/app-shell.js +9 -8
  2. package/dist/{chunk-9v0fsdsf.js → chunk-066yt1hy.js} +1 -1
  3. package/dist/{chunk-eth22r93.js → chunk-0xgc5t3y.js} +1 -1
  4. package/dist/{chunk-vd5xvsnv.js → chunk-18018jkn.js} +1 -1
  5. package/dist/{chunk-5tefa8qb.js → chunk-1vb2rj09.js} +2 -2
  6. package/dist/chunk-1wsewc5h.js +2 -0
  7. package/dist/{chunk-p1hy2bwn.js → chunk-1yj4xd6n.js} +3 -3
  8. package/dist/{chunk-fqq5k9ve.js → chunk-1z1efvtw.js} +1 -1
  9. package/dist/{chunk-cdqx2c2h.js → chunk-22hch2me.js} +1 -1
  10. package/dist/{chunk-kpeqn5tx.js → chunk-2gc4cevb.js} +1 -1
  11. package/dist/{chunk-mgmn1vxy.js → chunk-39xtzfzf.js} +1 -1
  12. package/dist/{chunk-zsnrcbw1.js → chunk-3cjvqa0s.js} +2 -2
  13. package/dist/chunk-3sgdth20.js +2 -0
  14. package/dist/chunk-41dfsdy9.js +2 -0
  15. package/dist/{chunk-ymrxpwr8.js → chunk-46tmg3k4.js} +2 -2
  16. package/dist/{chunk-e1sxe3q4.js → chunk-4904n5v0.js} +2 -2
  17. package/dist/chunk-4cw0s9f4.js +4 -0
  18. package/dist/chunk-4jj4kk18.js +2 -0
  19. package/dist/chunk-4np12rj1.js +2 -0
  20. package/dist/chunk-4pcjt99d.js +2 -0
  21. package/dist/{chunk-dvvx1wny.js → chunk-57atgbyq.js} +1 -1
  22. package/dist/chunk-58j32d7n.js +2 -0
  23. package/dist/{chunk-hyfjnn7g.js → chunk-5g6rprcy.js} +1 -1
  24. package/dist/{chunk-mm59b0gg.js → chunk-5qsg9q46.js} +1 -1
  25. package/dist/{chunk-m8kezfrt.js → chunk-5r7gfwpj.js} +5 -5
  26. package/dist/chunk-799s9mwc.js +47 -0
  27. package/dist/{chunk-yxppshfd.js → chunk-7a21q2q4.js} +1 -1
  28. package/dist/chunk-7d74am4w.js +2 -0
  29. package/dist/chunk-7ngnyy5k.js +2 -0
  30. package/dist/{chunk-r8rbf28v.js → chunk-7r79j1hs.js} +1 -1
  31. package/dist/{chunk-cr8v8k53.js → chunk-7r9vgzg4.js} +1 -1
  32. package/dist/{chunk-xwxdwqn9.js → chunk-7we3xfde.js} +1 -1
  33. package/dist/{chunk-fr66xp8q.js → chunk-823h67tv.js} +1 -1
  34. package/dist/{chunk-42en0cxm.js → chunk-86v2rps7.js} +1 -1
  35. package/dist/{chunk-xz3evxqp.js → chunk-8bxtvsgm.js} +1 -1
  36. package/dist/{chunk-09jdvqhg.js → chunk-8cg15rr7.js} +2 -2
  37. package/dist/chunk-95t7pked.js +2 -0
  38. package/dist/{chunk-xdmb578h.js → chunk-97ej3abh.js} +1 -1
  39. package/dist/{chunk-kw98dfza.js → chunk-9btdax2s.js} +1 -1
  40. package/dist/{chunk-pbexz0d4.js → chunk-9bvgzqw1.js} +2 -2
  41. package/dist/{chunk-te6qym2g.js → chunk-9jc2z17q.js} +2 -2
  42. package/dist/chunk-9m5sxaen.js +2 -0
  43. package/dist/{chunk-tjag2cmm.js → chunk-a26hcag1.js} +1 -1
  44. package/dist/chunk-a3m7mgjc.js +2 -0
  45. package/dist/{chunk-9368t9jm.js → chunk-a959m68j.js} +1 -1
  46. package/dist/{chunk-fkdnfjc2.js → chunk-aftqqqcg.js} +2 -2
  47. package/dist/chunk-aved735s.js +64 -0
  48. package/dist/{chunk-q0g5c39d.js → chunk-ay336sqb.js} +1 -1
  49. package/dist/{chunk-cvphepjb.js → chunk-b3pn6dh5.js} +1 -1
  50. package/dist/{chunk-5swem3qy.js → chunk-b4cabzk9.js} +1 -1
  51. package/dist/{chunk-ej8mv2k6.js → chunk-bgrkxzr7.js} +1 -1
  52. package/dist/{chunk-2cm03y4y.js → chunk-d3kjaae0.js} +1 -1
  53. package/dist/chunk-d7zxg9bp.js +16 -0
  54. package/dist/{chunk-1ebyt1ba.js → chunk-dekxwgc2.js} +1 -1
  55. package/dist/chunk-dvafkj8w.js +2 -0
  56. package/dist/chunk-e3rgky2r.js +3747 -0
  57. package/dist/{chunk-t41aaehf.js → chunk-e4g8wz6t.js} +1 -1
  58. package/dist/chunk-e9y48d60.js +2 -0
  59. package/dist/{chunk-pbzdjhp8.js → chunk-eq2j7w8p.js} +1 -1
  60. package/dist/chunk-f08ttkqr.js +2 -0
  61. package/dist/{chunk-4jdj52c5.js → chunk-f6sejeg3.js} +1 -1
  62. package/dist/chunk-fha0nyet.js +2 -0
  63. package/dist/{chunk-6k8h1fj1.js → chunk-fjrkyhm7.js} +1 -1
  64. package/dist/chunk-fw56y3cb.js +30 -0
  65. package/dist/chunk-fx5m9d3t.js +2 -0
  66. package/dist/{chunk-mwh3ymwc.js → chunk-g6czgcg4.js} +1 -1
  67. package/dist/chunk-gtfcw1gc.js +12 -0
  68. package/dist/chunk-gz539gk6.js +2 -0
  69. package/dist/chunk-h0y4mb2m.js +2 -0
  70. package/dist/chunk-hfzv07az.js +3 -0
  71. package/dist/{chunk-nat3actx.js → chunk-hrdd26r4.js} +1 -1
  72. package/dist/{chunk-cdsbxghb.js → chunk-jkyvk4x6.js} +1 -1
  73. package/dist/{chunk-4ty8j3xn.js → chunk-jx03a693.js} +1 -1
  74. package/dist/{chunk-vvd659y4.js → chunk-k3dtvay1.js} +1 -1
  75. package/dist/chunk-kawdj1j7.js +2 -0
  76. package/dist/{chunk-d4etph79.js → chunk-kdhrk7x5.js} +1 -1
  77. package/dist/chunk-kdwerx8e.js +2 -0
  78. package/dist/{chunk-n66k2v2q.js → chunk-kermxyfe.js} +2 -2
  79. package/dist/{chunk-x7yc7e9v.js → chunk-m11pb9cx.js} +1 -1
  80. package/dist/{chunk-k6ky5et7.js → chunk-m1p2n3nf.js} +1 -1
  81. package/dist/chunk-m46edxtt.js +3 -0
  82. package/dist/chunk-meqz313r.js +2 -0
  83. package/dist/{chunk-q05eh1n4.js → chunk-mnyehz4t.js} +2 -2
  84. package/dist/{chunk-0vv5s039.js → chunk-mys0rat0.js} +1 -1
  85. package/dist/chunk-n0a55zv2.js +2 -0
  86. package/dist/{chunk-7kw3grq5.js → chunk-nf7k53ap.js} +1 -1
  87. package/dist/{chunk-kffndzch.js → chunk-nhbc464j.js} +3 -3
  88. package/dist/{chunk-1hzgxk2m.js → chunk-nvp546bb.js} +1 -1
  89. package/dist/chunk-p1cddybx.js +2 -0
  90. package/dist/chunk-q0srntf6.js +2 -0
  91. package/dist/chunk-q3g4yf5r.js +2 -0
  92. package/dist/{chunk-c2ta859c.js → chunk-q9ckfwhh.js} +1 -1
  93. package/dist/chunk-qhdp0ycf.js +2 -0
  94. package/dist/{chunk-y4nzmkea.js → chunk-qsbjtp60.js} +1 -1
  95. package/dist/{chunk-1tva0f8f.js → chunk-qtc28zy1.js} +1 -1
  96. package/dist/{chunk-2vgkc0kg.js → chunk-r10fypcd.js} +1 -1
  97. package/dist/chunk-rkykwy3z.js +2 -0
  98. package/dist/{chunk-64djh88a.js → chunk-sqvqwd0p.js} +1 -1
  99. package/dist/{chunk-67bh5vrj.js → chunk-stbns4bg.js} +1 -1
  100. package/dist/chunk-szfk6pw6.js +2 -0
  101. package/dist/{chunk-amxtypkp.js → chunk-t00ga194.js} +1 -1
  102. package/dist/chunk-temapbqe.js +2 -0
  103. package/dist/{chunk-9kxfz708.js → chunk-tr1174hz.js} +1 -1
  104. package/dist/{chunk-q85qp5we.js → chunk-tr41gn5j.js} +1 -1
  105. package/dist/{chunk-crj19mqr.js → chunk-tr9ynxdw.js} +1 -1
  106. package/dist/{chunk-71y3bhcw.js → chunk-tsmdmf5h.js} +123 -37
  107. package/dist/{chunk-gptwwv3c.js → chunk-vaggjvsm.js} +1 -1
  108. package/dist/{chunk-ya5m5vbn.js → chunk-vgfd9582.js} +1 -1
  109. package/dist/chunk-vgfnre7b.js +2 -0
  110. package/dist/{chunk-n9c975db.js → chunk-vhzc08aa.js} +1 -1
  111. package/dist/{chunk-08w4gtyf.js → chunk-vm5jbgb1.js} +3 -3
  112. package/dist/{chunk-drqdc0mh.js → chunk-vxt5c5aq.js} +1 -1
  113. package/dist/{chunk-hzfd8cz0.js → chunk-w0hzaka3.js} +78 -67
  114. package/dist/{chunk-yk6446kr.js → chunk-w72v0ab1.js} +2 -2
  115. package/dist/{chunk-c65yrgck.js → chunk-wakb8z5q.js} +10 -10
  116. package/dist/{chunk-q569zmrr.js → chunk-wb90259a.js} +1 -1
  117. package/dist/chunk-x01sw9wy.js +2 -0
  118. package/dist/{chunk-dfejgnny.js → chunk-x48crnwa.js} +1 -1
  119. package/dist/{chunk-24b4711v.js → chunk-x4vhn880.js} +1 -1
  120. package/dist/{chunk-j2dj21ay.js → chunk-xe6zmdfq.js} +1 -1
  121. package/dist/chunk-y8vj3rtt.js +2 -0
  122. package/dist/chunk-yj1dxdfr.js +2 -0
  123. package/dist/{chunk-wx5zf66r.js → chunk-yne23w3c.js} +1 -1
  124. package/dist/{chunk-zz8qgqa1.js → chunk-ypzm47q3.js} +2 -2
  125. package/dist/chunk-z07knk3p.js +2 -0
  126. package/dist/{chunk-27xfkzks.js → chunk-zj039s33.js} +1 -1
  127. package/dist/{chunk-c79nfdyj.js → chunk-zk6ghjnj.js} +1 -1
  128. package/dist/chunk-zt4pf776.js +2 -0
  129. package/dist/{chunk-4k0ce745.js → chunk-zye9r15n.js} +2 -2
  130. package/dist/chunk-zzfpwxpp.js +2 -0
  131. package/dist/cli.js +14 -14
  132. package/dist/component-contract-checks.d.ts +18 -15
  133. package/dist/component-contract.d.ts +6 -14
  134. package/dist/craft-entry.js +1 -1
  135. package/dist/craft.js +1 -1
  136. package/dist/database.js +1 -1
  137. package/dist/expressions.d.ts +45 -0
  138. package/dist/expressions.js +60 -11
  139. package/dist/includes.js +4 -0
  140. package/dist/loops.js +10 -0
  141. package/dist/pwa.js +2 -2
  142. package/dist/server-components.js +2 -1
  143. package/dist/signals.js +121 -35
  144. package/dist/slots.js +86 -12
  145. package/dist/ssg.js +2 -2
  146. package/dist/stx-virtual-ts.d.ts +205 -95
  147. package/dist/template-syntax-escape.d.ts +36 -0
  148. package/dist/template-syntax-escape.js +8 -0
  149. package/dist/utils.js +9 -2
  150. package/dist/variable-extractor.d.ts +1 -0
  151. package/dist/variable-extractor.js +8 -0
  152. package/dist/visual-testing.js +1 -1
  153. package/package.json +8 -8
  154. package/dist/chunk-046dp691.js +0 -2
  155. package/dist/chunk-1brnvyhv.js +0 -2
  156. package/dist/chunk-3ntf8f5e.js +0 -2
  157. package/dist/chunk-4tnxnzja.js +0 -2
  158. package/dist/chunk-63yfp05p.js +0 -2
  159. package/dist/chunk-7y4eqkv4.js +0 -2
  160. package/dist/chunk-7ywnkv1f.js +0 -2
  161. package/dist/chunk-80zj5516.js +0 -2
  162. package/dist/chunk-8730k51r.js +0 -2
  163. package/dist/chunk-907qxn09.js +0 -2
  164. package/dist/chunk-9fcq5x2r.js +0 -2
  165. package/dist/chunk-a97tp43x.js +0 -2
  166. package/dist/chunk-atw841yx.js +0 -2
  167. package/dist/chunk-c1m1gng4.js +0 -2
  168. package/dist/chunk-caaenc3w.js +0 -60
  169. package/dist/chunk-dbfq77qe.js +0 -4
  170. package/dist/chunk-dnesmvvb.js +0 -2
  171. package/dist/chunk-eg8ksaft.js +0 -2
  172. package/dist/chunk-ewsx2qxm.js +0 -2
  173. package/dist/chunk-farwrdr2.js +0 -3
  174. package/dist/chunk-fcenm8n1.js +0 -2
  175. package/dist/chunk-gbz6pfs8.js +0 -2
  176. package/dist/chunk-gdbkqatx.js +0 -43
  177. package/dist/chunk-jnahcd4d.js +0 -2
  178. package/dist/chunk-ke88kpva.js +0 -30
  179. package/dist/chunk-krpkfndf.js +0 -3
  180. package/dist/chunk-kxtqbrfr.js +0 -3759
  181. package/dist/chunk-m1yrakpk.js +0 -2
  182. package/dist/chunk-q2hvne0v.js +0 -2
  183. package/dist/chunk-qpbk50xd.js +0 -2
  184. package/dist/chunk-rxdd3k6n.js +0 -2
  185. package/dist/chunk-ssd10kje.js +0 -2
  186. package/dist/chunk-szx6pxh3.js +0 -2
  187. package/dist/chunk-tpmgq2dx.js +0 -12
  188. package/dist/chunk-tte4m2s9.js +0 -2
  189. package/dist/chunk-v7gjsb3f.js +0 -2
  190. package/dist/chunk-vv289x82.js +0 -2
  191. package/dist/chunk-vx6mxybh.js +0 -2
  192. package/dist/chunk-x510wr8z.js +0 -2
  193. package/dist/chunk-x95sxapm.js +0 -2
  194. package/dist/chunk-xjrhzkx2.js +0 -2
  195. package/dist/chunk-y1x2ebhv.js +0 -2
  196. package/dist/chunk-yvec3f1c.js +0 -2
  197. package/dist/chunk-yzxm75jp.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ah as u,Bh as n,th as x,yh as B,zh as c}from"./chunk-vd5xvsnv.js";import{sw as v}from"./chunk-hyfjnn7g.js";import{resolve as JJ,basename as WJ,extname as _J,join as LJ}from"path";import{mkdir as QJ}from"fs/promises";var ZJ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class V{config;constructor(K={}){this.config={...ZJ,...K}}async get(K,J){return c(K,J,"video",this.config)}async set(K,J,X){return u(K,J,X,"video",this.config)}async clear(){return n("video",this.config)}updateConfig(K){this.config={...this.config,...K}}}var S=null;function D(K){if(!S)S=new V(K);else if(K)S.updateConfig(K);return S}async function q(K,J,X){let N=X?{directory:`${X.outputDir}/../.cache`}:{};return D(N).get(K,J)}async function b(K,J,X,N){let Z=N?{directory:`${N.outputDir}/../.cache`}:{};return D(Z).set(K,J,X)}async function $J(){return D().clear()}import{resolve as y,basename as P,extname as f,join as U}from"path";import{mkdir as g}from"fs/promises";async function m(){try{return await import("ts-videos")}catch{return null}}async function h(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",M=J.timestamp||0,E=`${z}-poster-${Y}.${G}`,W=U(X,E),Q=await Z.extractThumbnails($,{timestamps:[M],width:J.width||1280,height:J.height,format:G,quality:J.quality||85,outputDir:X,outputPattern:E.replace(`.${G}`,"")});if(Q&&Q.length>0){let _=Q[0];return{path:W,url:`${N}/${E}`,width:_.width||J.width||1280,height:_.height||720,timestamp:M,size:_.size||0}}return null}catch($){return console.warn(`[stx-media] Failed to generate poster: ${$}`),null}}async function d(K,J,X,N){let Z=await m();if(!Z)return[];try{let $=y(K);if(!await B($))return[];await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",W=(await new Z.Input($).getInfo()).duration||60,Q=J.count||10,_=J.interval||W/Q,O=[];for(let w=0;w<Q&&w*_<W;w++)O.push(w*_);let L=await Z.extractThumbnails($,{timestamps:O,width:J.width||320,format:G,quality:J.quality||80,outputDir:X,outputPattern:`${z}-thumb-${Y}`});if(L&&L.length>0)return L.map((w,j)=>({path:w.path||U(X,`${z}-thumb-${Y}-${j}.${G}`),url:`${N}/${z}-thumb-${Y}-${j}.${G}`,width:w.width||J.width||320,height:w.height||180,timestamp:O[j],size:w.size||0}));return[]}catch($){return console.warn(`[stx-media] Failed to generate thumbnails: ${$}`),[]}}async function zJ(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),E=(await new Z.Input($).getInfo()).duration||60,W=J.columns||10,Q=J.interval||5,_=J.thumbnailWidth||160,O=J.thumbnailHeight||90,L=J.format||"jpeg",w=Math.ceil(E/Q),j=Math.ceil(w/W),F=`${z}-sprite-${Y}.${L}`,k=U(X,F),T=[];for(let I=0;I<w;I++)T.push(I*Q);let A=await Z.extractThumbnails($,{timestamps:T,width:_,height:O,format:L,quality:J.quality||70,outputDir:U(X,".temp")});if(!A||A.length===0)return null;try{let I=await import("ts-images"),H=W*_,kJ=j*O,jJ=await I.createSprite({images:A.map((YJ)=>YJ.path),columns:W,padding:0,outputPath:k,format:L,quality:J.quality||70});return{url:`${N}/${F}`,path:k,columns:W,rows:j,thumbnailWidth:_,thumbnailHeight:O,interval:Q,totalFrames:w}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch($){return console.warn(`[stx-media] Failed to generate sprite sheet: ${$}`),null}}import{resolve as r,basename as e,extname as i,join as C}from"path";import{mkdir as R,writeFile as o}from"fs/promises";async function t(){try{return await import("ts-videos")}catch{return null}}var s=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function p(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-hls`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||6,O=(await new $.Input(Y).getInfo()).duration||0,L=[],w=0;for(let k of E){let T=C(M,k.label);await R(T,{recursive:!0});let A=`${k.label}.m3u8`,I=C(T,A);try{let H=await $.generateHLS(Y,{outputDir:T,segmentDuration:W,width:k.width,height:k.height,videoBitrate:k.bitrate,audioBitrate:k.audioBitrate,playlistName:k.label});if(H)L.push({quality:k,url:`${N}/${G}-${z}-hls/${k.label}/${A}`,path:I}),w+=H.segmentCount||Math.ceil(O/W)}catch(H){console.warn(`[stx-media] Failed to generate HLS for ${k.label}: ${H}`)}}if(L.length===0)return null;let j=C(M,"master.m3u8"),F=GJ(L,N,G,z);return await o(j,F),{manifestUrl:`${N}/${G}-${z}-hls/master.m3u8`,manifestPath:j,playlists:L,segmentCount:w,duration:O}}catch(Y){return console.warn(`[stx-media] Failed to generate HLS manifest: ${Y}`),null}}function GJ(K,J,X,N){let Z=["#EXTM3U","#EXT-X-VERSION:3"];for(let $ of K){let{quality:Y}=$,z=Y.bitrate+(Y.audioBitrate||128000),G=`${Y.width}x${Y.height||Math.round(Y.width*9/16)}`;Z.push(`#EXT-X-STREAM-INF:BANDWIDTH=${z},RESOLUTION=${G},NAME="${Y.label}"`,`${Y.label}/${Y.label}.m3u8`)}return Z.join(`
2
+ import{ih as x,nh as B,oh as c,ph as u,qh as n}from"./chunk-18018jkn.js";import{tw as v}from"./chunk-5g6rprcy.js";import{resolve as JJ,basename as WJ,extname as _J,join as LJ}from"path";import{mkdir as QJ}from"fs/promises";var ZJ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class V{config;constructor(K={}){this.config={...ZJ,...K}}async get(K,J){return c(K,J,"video",this.config)}async set(K,J,X){return u(K,J,X,"video",this.config)}async clear(){return n("video",this.config)}updateConfig(K){this.config={...this.config,...K}}}var S=null;function D(K){if(!S)S=new V(K);else if(K)S.updateConfig(K);return S}async function q(K,J,X){let N=X?{directory:`${X.outputDir}/../.cache`}:{};return D(N).get(K,J)}async function b(K,J,X,N){let Z=N?{directory:`${N.outputDir}/../.cache`}:{};return D(Z).set(K,J,X)}async function $J(){return D().clear()}import{resolve as y,basename as P,extname as f,join as U}from"path";import{mkdir as g}from"fs/promises";async function m(){try{return await import("ts-videos")}catch{return null}}async function h(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",M=J.timestamp||0,E=`${z}-poster-${Y}.${G}`,W=U(X,E),Q=await Z.extractThumbnails($,{timestamps:[M],width:J.width||1280,height:J.height,format:G,quality:J.quality||85,outputDir:X,outputPattern:E.replace(`.${G}`,"")});if(Q&&Q.length>0){let _=Q[0];return{path:W,url:`${N}/${E}`,width:_.width||J.width||1280,height:_.height||720,timestamp:M,size:_.size||0}}return null}catch($){return console.warn(`[stx-media] Failed to generate poster: ${$}`),null}}async function d(K,J,X,N){let Z=await m();if(!Z)return[];try{let $=y(K);if(!await B($))return[];await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",W=(await new Z.Input($).getInfo()).duration||60,Q=J.count||10,_=J.interval||W/Q,O=[];for(let w=0;w<Q&&w*_<W;w++)O.push(w*_);let L=await Z.extractThumbnails($,{timestamps:O,width:J.width||320,format:G,quality:J.quality||80,outputDir:X,outputPattern:`${z}-thumb-${Y}`});if(L&&L.length>0)return L.map((w,j)=>({path:w.path||U(X,`${z}-thumb-${Y}-${j}.${G}`),url:`${N}/${z}-thumb-${Y}-${j}.${G}`,width:w.width||J.width||320,height:w.height||180,timestamp:O[j],size:w.size||0}));return[]}catch($){return console.warn(`[stx-media] Failed to generate thumbnails: ${$}`),[]}}async function zJ(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),E=(await new Z.Input($).getInfo()).duration||60,W=J.columns||10,Q=J.interval||5,_=J.thumbnailWidth||160,O=J.thumbnailHeight||90,L=J.format||"jpeg",w=Math.ceil(E/Q),j=Math.ceil(w/W),F=`${z}-sprite-${Y}.${L}`,k=U(X,F),T=[];for(let I=0;I<w;I++)T.push(I*Q);let A=await Z.extractThumbnails($,{timestamps:T,width:_,height:O,format:L,quality:J.quality||70,outputDir:U(X,".temp")});if(!A||A.length===0)return null;try{let I=await import("ts-images"),H=W*_,kJ=j*O,jJ=await I.createSprite({images:A.map((YJ)=>YJ.path),columns:W,padding:0,outputPath:k,format:L,quality:J.quality||70});return{url:`${N}/${F}`,path:k,columns:W,rows:j,thumbnailWidth:_,thumbnailHeight:O,interval:Q,totalFrames:w}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch($){return console.warn(`[stx-media] Failed to generate sprite sheet: ${$}`),null}}import{resolve as r,basename as e,extname as i,join as C}from"path";import{mkdir as R,writeFile as o}from"fs/promises";async function t(){try{return await import("ts-videos")}catch{return null}}var s=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function p(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-hls`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||6,O=(await new $.Input(Y).getInfo()).duration||0,L=[],w=0;for(let k of E){let T=C(M,k.label);await R(T,{recursive:!0});let A=`${k.label}.m3u8`,I=C(T,A);try{let H=await $.generateHLS(Y,{outputDir:T,segmentDuration:W,width:k.width,height:k.height,videoBitrate:k.bitrate,audioBitrate:k.audioBitrate,playlistName:k.label});if(H)L.push({quality:k,url:`${N}/${G}-${z}-hls/${k.label}/${A}`,path:I}),w+=H.segmentCount||Math.ceil(O/W)}catch(H){console.warn(`[stx-media] Failed to generate HLS for ${k.label}: ${H}`)}}if(L.length===0)return null;let j=C(M,"master.m3u8"),F=GJ(L,N,G,z);return await o(j,F),{manifestUrl:`${N}/${G}-${z}-hls/master.m3u8`,manifestPath:j,playlists:L,segmentCount:w,duration:O}}catch(Y){return console.warn(`[stx-media] Failed to generate HLS manifest: ${Y}`),null}}function GJ(K,J,X,N){let Z=["#EXTM3U","#EXT-X-VERSION:3"];for(let $ of K){let{quality:Y}=$,z=Y.bitrate+(Y.audioBitrate||128000),G=`${Y.width}x${Y.height||Math.round(Y.width*9/16)}`;Z.push(`#EXT-X-STREAM-INF:BANDWIDTH=${z},RESOLUTION=${G},NAME="${Y.label}"`,`${Y.label}/${Y.label}.m3u8`)}return Z.join(`
3
3
  `)}async function l(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-dash`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||4,Q=Z?.minBufferTime||2,L=(await new $.Input(Y).getInfo()).duration||0,w=[],j=[];for(let A of E){let I=C(M,A.label);await R(I,{recursive:!0});try{if(await $.generateDASH(Y,{outputDir:I,segmentDuration:W,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(w.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${N}/${G}-${z}-dash/${A.label}/video`}),A.audioBitrate)j.push({bandwidth:A.audioBitrate,url:`${N}/${G}-${z}-dash/${A.label}/audio`})}}catch(H){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${H}`)}}if(w.length===0)return null;let F=C(M,"manifest.mpd"),k=NJ(w,j,L,W,Q);await o(F,k);let T=[{type:"video",representations:w}];if(j.length>0)T.push({type:"audio",representations:j});return{manifestUrl:`${N}/${G}-${z}-dash/manifest.mpd`,manifestPath:F,adaptationSets:T,duration:L}}catch(Y){return console.warn(`[stx-media] Failed to generate DASH manifest: ${Y}`),null}}function NJ(K,J,X,N,Z){let $=a(X),Y=a(Z),z=`<?xml version="1.0" encoding="UTF-8"?>
4
4
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
5
5
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -26,4 +26,4 @@ import{Ah as u,Bh as n,th as x,yh as B,zh as c}from"./chunk-vd5xvsnv.js";import{
26
26
  </Representation>
27
27
  `}z+=` </AdaptationSet>
28
28
  `}return z+=` </Period>
29
- </MPD>`,z}function a(K){let J=Math.floor(K/3600),X=Math.floor(K%3600/60),N=Math.floor(K%60),Z="PT";if(J>0)Z+=`${J}H`;if(X>0)Z+=`${X}M`;return Z+=`${N}S`,Z}async function KJ(){try{return await import("ts-videos")}catch{return null}}function MJ(K){switch(K){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function OJ(K){switch(K){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function XJ(K){let J=await KJ();if(!J)return null;try{let X=JJ(K),Z=await new J.Input(X).getInfo();return{duration:Z.duration||0,width:Z.width||0,height:Z.height||0,frameRate:Z.frameRate||0,bitrate:Z.bitrate||0,codec:Z.videoCodec||"",audioCodec:Z.audioCodec}}catch(X){return console.warn(`[stx-media] Failed to analyze video: ${X}`),null}}async function wJ(K,J,X,N){let Z=await KJ();if(!Z)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:K,processed:!1};let $=await q(K,J,X);if($)return $;try{let Y=JJ(K);if(!await B(Y))return{src:K,processed:!1,errors:[`Source file not found: ${K}`]};let z=X.outputDir||"dist/videos",G=X.baseUrl||"/videos";await QJ(z,{recursive:!0});let M=await x(Y),E=WJ(K,_J(K)),W={src:K,processed:!0,hash:M};N?.({percentage:5,stage:"analyzing"}),W.metadata=await XJ(Y)||void 0;let Q={};if(J.quality)Q.bitrate=MJ(J.quality);if(J.platform)Object.assign(Q,OJ(J.platform));if(J.transcode)Object.assign(Q,J.transcode);if(Object.keys(Q).length>0||J.process){N?.({percentage:10,stage:"transcoding"});let _=`${E}-${M}.mp4`,O=LJ(z,_);try{let L=await AJ(Y,O,Q,Z,(w)=>N?.({percentage:10+w*0.5,stage:"transcoding"}));if(L)W.transcoded={path:O,url:`${G}/${_}`,duration:L.duration,size:L.size,video:{codec:Q.codec||"h264",width:L.width,height:L.height,bitrate:L.bitrate,frameRate:L.frameRate},audio:L.audioCodec?{codec:Q.audioCodec||"aac",bitrate:Q.audioBitrate||128000,sampleRate:Q.sampleRate||48000,channels:Q.channels||2}:void 0}}catch(L){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${L}`)}}if(J.generatePoster){N?.({percentage:65,stage:"generating-poster"});let _=typeof J.generatePoster==="object"?J.generatePoster:{timestamp:0},O=await h(Y,_,z,G);if(O)W.poster=O}if(X.thumbnails?.enabled){N?.({percentage:70,stage:"generating-thumbnails"});let _=await d(Y,X.thumbnails,z,G);if(_.length>0)W.thumbnails=_}if(J.streaming){N?.({percentage:80,stage:"generating-manifests"});let _=typeof J.streaming==="object"?J.streaming:X.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let O=await p(Y,_.qualities||X.streaming?.defaultQualities||[],z,G);if(O)W.streaming={...W.streaming,hls:O}}if(_.format==="dash"){let O=await l(Y,_.qualities||X.streaming?.defaultQualities||[],z,G);if(O)W.streaming={...W.streaming,dash:O}}}if(J.spriteSheet)N?.({percentage:90,stage:"generating-sprite-sheet"});return N?.({percentage:100,stage:"complete"}),await b(K,J,W,X),W}catch(Y){return{src:K,processed:!1,errors:[`Processing failed: ${Y}`]}}}async function AJ(K,J,X,N,Z){try{let Y=await new N.Conversion(K,J,{videoCodec:X.codec,videoBitrate:X.bitrate,width:X.maxWidth,height:X.maxHeight,frameRate:X.frameRate,audioCodec:X.audioCodec,audioBitrate:X.audioBitrate,sampleRate:X.sampleRate,channels:X.channels}).run((z)=>{Z?.(z.percentage/100)});return{duration:Y.duration||0,size:Y.size||0,width:Y.width||X.maxWidth||0,height:Y.height||X.maxHeight||0,bitrate:Y.bitrate||X.bitrate||0,frameRate:Y.frameRate||X.frameRate||30,audioCodec:Y.audioCodec}}catch($){return console.error(`[stx-media] Transcoding failed: ${$}`),null}}export{V as ih,q as jh,b as kh,$J as lh,h as mh,d as nh,zJ as oh,p as ph,l as qh,XJ as rh,wJ as sh};
29
+ </MPD>`,z}function a(K){let J=Math.floor(K/3600),X=Math.floor(K%3600/60),N=Math.floor(K%60),Z="PT";if(J>0)Z+=`${J}H`;if(X>0)Z+=`${X}M`;return Z+=`${N}S`,Z}async function KJ(){try{return await import("ts-videos")}catch{return null}}function MJ(K){switch(K){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function OJ(K){switch(K){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function XJ(K){let J=await KJ();if(!J)return null;try{let X=JJ(K),Z=await new J.Input(X).getInfo();return{duration:Z.duration||0,width:Z.width||0,height:Z.height||0,frameRate:Z.frameRate||0,bitrate:Z.bitrate||0,codec:Z.videoCodec||"",audioCodec:Z.audioCodec}}catch(X){return console.warn(`[stx-media] Failed to analyze video: ${X}`),null}}async function wJ(K,J,X,N){let Z=await KJ();if(!Z)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:K,processed:!1};let $=await q(K,J,X);if($)return $;try{let Y=JJ(K);if(!await B(Y))return{src:K,processed:!1,errors:[`Source file not found: ${K}`]};let z=X.outputDir||"dist/videos",G=X.baseUrl||"/videos";await QJ(z,{recursive:!0});let M=await x(Y),E=WJ(K,_J(K)),W={src:K,processed:!0,hash:M};N?.({percentage:5,stage:"analyzing"}),W.metadata=await XJ(Y)||void 0;let Q={};if(J.quality)Q.bitrate=MJ(J.quality);if(J.platform)Object.assign(Q,OJ(J.platform));if(J.transcode)Object.assign(Q,J.transcode);if(Object.keys(Q).length>0||J.process){N?.({percentage:10,stage:"transcoding"});let _=`${E}-${M}.mp4`,O=LJ(z,_);try{let L=await AJ(Y,O,Q,Z,(w)=>N?.({percentage:10+w*0.5,stage:"transcoding"}));if(L)W.transcoded={path:O,url:`${G}/${_}`,duration:L.duration,size:L.size,video:{codec:Q.codec||"h264",width:L.width,height:L.height,bitrate:L.bitrate,frameRate:L.frameRate},audio:L.audioCodec?{codec:Q.audioCodec||"aac",bitrate:Q.audioBitrate||128000,sampleRate:Q.sampleRate||48000,channels:Q.channels||2}:void 0}}catch(L){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${L}`)}}if(J.generatePoster){N?.({percentage:65,stage:"generating-poster"});let _=typeof J.generatePoster==="object"?J.generatePoster:{timestamp:0},O=await h(Y,_,z,G);if(O)W.poster=O}if(X.thumbnails?.enabled){N?.({percentage:70,stage:"generating-thumbnails"});let _=await d(Y,X.thumbnails,z,G);if(_.length>0)W.thumbnails=_}if(J.streaming){N?.({percentage:80,stage:"generating-manifests"});let _=typeof J.streaming==="object"?J.streaming:X.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let O=await p(Y,_.qualities||X.streaming?.defaultQualities||[],z,G);if(O)W.streaming={...W.streaming,hls:O}}if(_.format==="dash"){let O=await l(Y,_.qualities||X.streaming?.defaultQualities||[],z,G);if(O)W.streaming={...W.streaming,dash:O}}}if(J.spriteSheet)N?.({percentage:90,stage:"generating-sprite-sheet"});return N?.({percentage:100,stage:"complete"}),await b(K,J,W,X),W}catch(Y){return{src:K,processed:!1,errors:[`Processing failed: ${Y}`]}}}async function AJ(K,J,X,N,Z){try{let Y=await new N.Conversion(K,J,{videoCodec:X.codec,videoBitrate:X.bitrate,width:X.maxWidth,height:X.maxHeight,frameRate:X.frameRate,audioCodec:X.audioCodec,audioBitrate:X.audioBitrate,sampleRate:X.sampleRate,channels:X.channels}).run((z)=>{Z?.(z.percentage/100)});return{duration:Y.duration||0,size:Y.size||0,width:Y.width||X.maxWidth||0,height:Y.height||X.maxHeight||0,bitrate:Y.bitrate||X.bitrate||0,frameRate:Y.frameRate||X.frameRate||30,audioCodec:Y.audioCodec}}catch($){return console.error(`[stx-media] Transcoding failed: ${$}`),null}}export{V as Zg,q as _g,b as $g,$J as ah,h as bh,d as ch,zJ as dh,p as eh,l as fh,XJ as gh,wJ as hh};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Xe as F$}from"./chunk-fr66xp8q.js";import{hg as d7,lg as z$,mg as h6,ng as E6,pg as B1,qg as d6,rg as J5,sg as H$,tg as O$,ug as u6,vg as m6,zg as B5}from"./chunk-ke88kpva.js";import{lj as f5}from"./chunk-71y3bhcw.js";import{Bj as l1,Cj as I1,Dj as R1,Ej as i$,Fj as a$,Gj as a5,Ij as r5}from"./chunk-t41aaehf.js";import{ck as K$,dk as _$}from"./chunk-fkdnfjc2.js";import{Gk as m5,Hk as p5}from"./chunk-e1sxe3q4.js";import{Nk as n7,Ok as o7}from"./chunk-4jdj52c5.js";import{gl as U1}from"./chunk-zz8qgqa1.js";import{Bl as A5,Cl as U8}from"./chunk-p1hy2bwn.js";import{$m as G5,Br as T$,Cp as m7,Dr as s0,Er as w0,Fm as n0,Ir as T0,Jp as g6,Kp as f6,To as M0,Xm as y6,bp as o0,cn as T1,dn as C1,eq as V0,go as W$,or as U$,sq as G6,tm as h7,tq as x1,vo as j$,xo as v6,xq as t0,yo as A6}from"./chunk-kxtqbrfr.js";import{$r as e$,Qr as r1,Tr as H6,bs as $5,es as s1,is as X5,ls as G$,ms as O6,xs as J6}from"./chunk-caaenc3w.js";import{Bt as Z5,Vt as B,au as B$,bu as L$,fu as J0}from"./chunk-kffndzch.js";import{Cu as u0}from"./chunk-gptwwv3c.js";import{$v as k6,Ev as Y5,Fv as M6,Jv as D6,Kv as w6,Zv as T6,_v as C6,aw as x6,bw as S6,cw as P6,ew as b6,iw as V6}from"./chunk-hzfd8cz0.js";import{sw as r}from"./chunk-hyfjnn7g.js";var s5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function Y3($,X,Z={}){let{storage:Q="local",serializer:Y=s5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Z,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Q==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let O=L.getItem($);if(O===null)return X;let A=Y.read(O);if(J&&typeof X==="object"&&X!==null)return{...X,...A};return A}catch{return X}},F=(L)=>{let O=_();if(!O)return;try{if(L===null||L===void 0)O.removeItem($);else O.setItem($,Y.write(L))}catch(A){console.warn(`[useStorage] Failed to write key "${$}":`,A)}},z=U(),j=(L,O)=>{for(let A of W)try{A(L,O)}catch(V){console.error("[useStorage] Subscriber error:",V)}};if(K&&G){let L=(A)=>{if(A.key===$&&A.storageArea===_()){let V=z;try{z=A.newValue?Y.read(A.newValue):X}catch(E){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,E);return}j(z,V)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let H={get value(){return z},set value(L){let O=z;z=L,F(L),j(L,O)},get:()=>z,set:(L)=>{H.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=z;z=X,j(X,O)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return H}function n5($,X,Z,Q,Y={}){let{serializer:J=s5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Q;try{let H=J.read(j);if(G&&typeof Q==="object"&&Q!==null)return{...Q,...H};return H}catch(H){return console.warn(`[${X}] Failed to read key "${Z}":`,H),Q}},z=a5((()=>{let j=_();if(!j)return Q;try{return U(j.getItem(Z))}catch(H){return console.warn(`[${X}] Cannot read "${Z}":`,H),Q}})());if(r5(()=>{let j=z(),H=_();if(!H)return;try{if(j===null||j===void 0)H.removeItem(Z);else H.setItem(Z,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Z}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Z)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",j))}return z}function J3($,X,Z){return n5("local","useLocalStorage",$,X,Z)}function G3($,X,Z){return n5("session","useSessionStorage",$,X,Z)}function W3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function K3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function _3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Z=0;for(let Q in X)if(Object.prototype.hasOwnProperty.call(X,Q))Z+=(Q.length+(X.getItem(Q)?.length||0))*2;return Z}var t=null;function c1($,X,Z=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Z.has($))return!0;if(Z.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!c1($[J],X[J],Z))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!c1(G,X.get(J),Z))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Q=Object.keys($),Y=Object.keys(X);if(Q.length!==Y.length)return!1;for(let J of Q){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!c1($[J],X[J],Z))return!1}return!0}function ZJ($){t=$}function QJ(){return t}function YJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:U3()}}function U3(){return{refs:new Map,effects:new Set,cleanups:[]}}function JJ($){let X=new Set,Z=new Set,Q=$,Y=Symbol("ref"),J={get value(){let G=l1();if(G)Z.add(G);return Q},set value(G){if(!Object.is(G,Q)){let W=Q;Q=G;for(let K of X)K(G,W);for(let K of Z)if(i$())a$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(t)t.scope.refs.set(Y,J);return J}var o5=new WeakMap;function B3($){let X=o5.get($);if(X)return X;let Z=new Map,Q=(G)=>{let W=Z.get(G);if(!W)return;for(let K of[...W])if(i$())a$(K);else K()},Y=(G,W)=>{if(!Z.has(G))Z.set(G,new Set);return Z.get(G).add(W),()=>{Z.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=l1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return B3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Q(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Q(W),K}});return o5.set($,J),J}function GJ($){let X,Z=!0,Q=new Set,Y=new Set,J=()=>{Z=!0,G()},G=()=>{if(Z){let K=X,_=I1(J);if(X=$(),R1(_),Z=!1,!Object.is(X,K)){for(let U of Q)U(X,K);for(let U of Y)U()}}},W=I1(J);return X=$(),Z=!1,R1(W),{get value(){let K=l1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Q.add(K),()=>{Q.delete(K)}}}}function L3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function WJ($,X,Z={}){let{immediate:Q=!1,deep:Y=!1,flush:J="post"}=Z,G,W,K=!1,_=()=>{if(K)return;let H=j();if((Y?!c1(H,G):!Object.is(H,G))||Q)if(X(H,G),Y&&H!==null&&typeof H==="object")try{G=structuredClone(H)}catch{G=H}else G=H},U=(H)=>{if(J==="sync")H();else if(J==="pre")Promise.resolve().then(H);else L3(H)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let H=I1(z);try{return $()}finally{R1(H)}}return $.value};if(typeof $!=="function"){let H=$.subscribe(()=>{U(_)});W=()=>{K=!0,H()}}else W=()=>{K=!0};if(G=j(),Q)U(_);if(t)t.scope.cleanups.push(()=>W?.());return()=>W?.()}function KJ($,X,Z={}){let Q=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Q.push(G)}if(Z.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Q)J()}}function _J($){let X,Z=!1,Q=()=>{if(Z)return;if(X)X();let Y=I1(Q);X=$(),R1(Y)};if(Q(),t)t.scope.cleanups.push(()=>{if(Z=!0,X)X()});return()=>{if(Z=!0,X)X()}}function UJ($){if(t)t.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function BJ($){if(t)t.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function LJ($){if(t)t.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function FJ($){if(t)t.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function zJ($){if(t)t.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function jJ($){if(t)t.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Y1($,X){let Z=$.hooks[X];for(let Q of Z)await Q()}async function HJ($){await Y1($,"beforeMount"),$.isMounted=!0,await Y1($,"mounted")}async function OJ($){if(!$.isMounted||$.isUnmounted)return;await Y1($,"beforeUpdate"),await Y1($,"updated")}async function AJ($){if($.isUnmounted)return;await Y1($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await Y1($,"unmounted")}function qJ(){return`
2
+ import{Xe as F$}from"./chunk-823h67tv.js";import{Yf as d7,ag as z$,bg as h6,cg as E6,eg as B1,fg as d6,gg as J5,hg as H$,ig as O$,jg as u6,kg as m6,og as B5}from"./chunk-fw56y3cb.js";import{aj as f5}from"./chunk-tsmdmf5h.js";import{qj as l1,rj as I1,sj as R1,tj as i$,uj as a$,vj as a5,xj as r5}from"./chunk-e4g8wz6t.js";import{Tj as K$,Uj as _$}from"./chunk-aftqqqcg.js";import{vk as m5,wk as p5}from"./chunk-4904n5v0.js";import{Ck as n7,Dk as o7}from"./chunk-f6sejeg3.js";import{Xk as U1}from"./chunk-ypzm47q3.js";import{ql as A5,rl as U8}from"./chunk-1yj4xd6n.js";import{Ho as M0,Jp as V0,Om as y6,Ro as o0,Sm as G5,Vm as T1,Wm as C1,Zn as W$,cr as U$,fp as m7,gq as G6,hq as x1,im as h7,io as j$,ko as v6,lo as A6,lq as t0,mp as g6,np as f6,pr as T$,rr as s0,sr as w0,wm as n0,wr as T0}from"./chunk-e3rgky2r.js";import{Ds as Z5,Xs as B,ct as B$,dt as L$,ht as J0}from"./chunk-nhbc464j.js";import{mt as u0}from"./chunk-vaggjvsm.js";import{$t as r1,Iu as J6,cu as H6,ku as e$,mu as $5,pu as s1,tu as X5,wu as G$,xu as O6}from"./chunk-799s9mwc.js";import{$v as k6,Ev as Y5,Fv as M6,Jv as D6,Kv as w6,Zv as T6,_v as C6,aw as x6,bw as S6,cw as P6,ew as b6,jw as V6}from"./chunk-w0hzaka3.js";import{tw as r}from"./chunk-5g6rprcy.js";var s5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function Y3($,X,Z={}){let{storage:Q="local",serializer:Y=s5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Z,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Q==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let O=L.getItem($);if(O===null)return X;let A=Y.read(O);if(J&&typeof X==="object"&&X!==null)return{...X,...A};return A}catch{return X}},F=(L)=>{let O=_();if(!O)return;try{if(L===null||L===void 0)O.removeItem($);else O.setItem($,Y.write(L))}catch(A){console.warn(`[useStorage] Failed to write key "${$}":`,A)}},z=U(),j=(L,O)=>{for(let A of W)try{A(L,O)}catch(V){console.error("[useStorage] Subscriber error:",V)}};if(K&&G){let L=(A)=>{if(A.key===$&&A.storageArea===_()){let V=z;try{z=A.newValue?Y.read(A.newValue):X}catch(E){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,E);return}j(z,V)}};window.addEventListener("storage",L);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",L))}let H={get value(){return z},set value(L){let O=z;z=L,F(L),j(L,O)},get:()=>z,set:(L)=>{H.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let O=z;z=X,j(X,O)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return H}function n5($,X,Z,Q,Y={}){let{serializer:J=s5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Q;try{let H=J.read(j);if(G&&typeof Q==="object"&&Q!==null)return{...Q,...H};return H}catch(H){return console.warn(`[${X}] Failed to read key "${Z}":`,H),Q}},z=a5((()=>{let j=_();if(!j)return Q;try{return U(j.getItem(Z))}catch(H){return console.warn(`[${X}] Cannot read "${Z}":`,H),Q}})());if(r5(()=>{let j=z(),H=_();if(!H)return;try{if(j===null||j===void 0)H.removeItem(Z);else H.setItem(Z,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Z}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Z)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",j))}return z}function J3($,X,Z){return n5("local","useLocalStorage",$,X,Z)}function G3($,X,Z){return n5("session","useSessionStorage",$,X,Z)}function W3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function K3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function _3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Z=0;for(let Q in X)if(Object.prototype.hasOwnProperty.call(X,Q))Z+=(Q.length+(X.getItem(Q)?.length||0))*2;return Z}var t=null;function c1($,X,Z=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Z.has($))return!0;if(Z.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!c1($[J],X[J],Z))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!c1(G,X.get(J),Z))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Q=Object.keys($),Y=Object.keys(X);if(Q.length!==Y.length)return!1;for(let J of Q){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!c1($[J],X[J],Z))return!1}return!0}function ZJ($){t=$}function QJ(){return t}function YJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:U3()}}function U3(){return{refs:new Map,effects:new Set,cleanups:[]}}function JJ($){let X=new Set,Z=new Set,Q=$,Y=Symbol("ref"),J={get value(){let G=l1();if(G)Z.add(G);return Q},set value(G){if(!Object.is(G,Q)){let W=Q;Q=G;for(let K of X)K(G,W);for(let K of Z)if(i$())a$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(t)t.scope.refs.set(Y,J);return J}var o5=new WeakMap;function B3($){let X=o5.get($);if(X)return X;let Z=new Map,Q=(G)=>{let W=Z.get(G);if(!W)return;for(let K of[...W])if(i$())a$(K);else K()},Y=(G,W)=>{if(!Z.has(G))Z.set(G,new Set);return Z.get(G).add(W),()=>{Z.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=l1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return B3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Q(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Q(W),K}});return o5.set($,J),J}function GJ($){let X,Z=!0,Q=new Set,Y=new Set,J=()=>{Z=!0,G()},G=()=>{if(Z){let K=X,_=I1(J);if(X=$(),R1(_),Z=!1,!Object.is(X,K)){for(let U of Q)U(X,K);for(let U of Y)U()}}},W=I1(J);return X=$(),Z=!1,R1(W),{get value(){let K=l1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Q.add(K),()=>{Q.delete(K)}}}}function L3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function WJ($,X,Z={}){let{immediate:Q=!1,deep:Y=!1,flush:J="post"}=Z,G,W,K=!1,_=()=>{if(K)return;let H=j();if((Y?!c1(H,G):!Object.is(H,G))||Q)if(X(H,G),Y&&H!==null&&typeof H==="object")try{G=structuredClone(H)}catch{G=H}else G=H},U=(H)=>{if(J==="sync")H();else if(J==="pre")Promise.resolve().then(H);else L3(H)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let H=I1(z);try{return $()}finally{R1(H)}}return $.value};if(typeof $!=="function"){let H=$.subscribe(()=>{U(_)});W=()=>{K=!0,H()}}else W=()=>{K=!0};if(G=j(),Q)U(_);if(t)t.scope.cleanups.push(()=>W?.());return()=>W?.()}function KJ($,X,Z={}){let Q=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Q.push(G)}if(Z.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Q)J()}}function _J($){let X,Z=!1,Q=()=>{if(Z)return;if(X)X();let Y=I1(Q);X=$(),R1(Y)};if(Q(),t)t.scope.cleanups.push(()=>{if(Z=!0,X)X()});return()=>{if(Z=!0,X)X()}}function UJ($){if(t)t.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function BJ($){if(t)t.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function LJ($){if(t)t.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function FJ($){if(t)t.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function zJ($){if(t)t.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function jJ($){if(t)t.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Y1($,X){let Z=$.hooks[X];for(let Q of Z)await Q()}async function HJ($){await Y1($,"beforeMount"),$.isMounted=!0,await Y1($,"mounted")}async function OJ($){if(!$.isMounted||$.isUnmounted)return;await Y1($,"beforeUpdate"),await Y1($,"updated")}async function AJ($){if($.isUnmounted)return;await Y1($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await Y1($,"unmounted")}function qJ(){return`
3
3
  <script data-stx-client-runtime>
4
4
  (function() {
5
5
  'use strict';
@@ -685,7 +685,7 @@ else {
685
685
  <span class="frontmatter-label">${X}:</span>
686
686
  <span>${Array.isArray(Z)?Z.join(", "):String(Z)}</span>
687
687
  </div>`).join("")}
688
- </div>`}import z6 from"net";async function U4($){return new Promise((X)=>{let Z=z6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"0.0.0.0")})}async function B4($){return new Promise((X)=>{let Z=z6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"::")})}async function L4($){if(!await U4($))return!1;return await B4($)}async function h0($,X=20){$=Number($);for(let Z=0;Z<X;Z++){let Q=$+Z;if(await L4(Q))return Q}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var F4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function z4(){try{let $=await import("./chunk-kpeqn5tx.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function G1($,X={}){let Z={...F4,...X},Q=await z4();if(!Q)return console.log(`${B.yellow}\u26A0${B.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let Y=await Q.openDevWindow($,{title:Z.title,width:Z.width,height:Z.height,darkMode:Z.darkMode,hotReload:Z.hotReload,titlebarHidden:Z.titlebarHidden,nativeSidebar:Z.nativeSidebar,sidebarWidth:Z.sidebarWidth,sidebarConfig:Z.sidebarConfig});if(Y&&Z.nativeSidebar)console.log(`${B.green}\u2713${B.reset} Native sidebar enabled (macOS Tahoe style)`);return Y}catch(Y){return console.log(`${B.red}\u2717${B.reset} Could not open native window:`,Y),!1}}function X$($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let Y=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(Y){let J=Y[1];try{let G=`
688
+ </div>`}import z6 from"net";async function U4($){return new Promise((X)=>{let Z=z6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"0.0.0.0")})}async function B4($){return new Promise((X)=>{let Z=z6.createServer();Z.once("error",()=>X(!1)),Z.once("listening",()=>{Z.close(()=>X(!0))}),Z.listen($,"::")})}async function L4($){if(!await U4($))return!1;return await B4($)}async function h0($,X=20){$=Number($);for(let Z=0;Z<X;Z++){let Q=$+Z;if(await L4(Q))return Q}throw Error(`Could not find an available port between ${$} and ${$+X-1}`)}var F4={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0};async function z4(){try{let $=await import("./chunk-2gc4cevb.js");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function G1($,X={}){let Z={...F4,...X},Q=await z4();if(!Q)return console.log(`${B.yellow}\u26A0${B.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let Y=await Q.openDevWindow($,{title:Z.title,width:Z.width,height:Z.height,darkMode:Z.darkMode,hotReload:Z.hotReload,titlebarHidden:Z.titlebarHidden,nativeSidebar:Z.nativeSidebar,sidebarWidth:Z.sidebarWidth,sidebarConfig:Z.sidebarConfig});if(Y&&Z.nativeSidebar)console.log(`${B.green}\u2713${B.reset} Native sidebar enabled (macOS Tahoe style)`);return Y}catch(Y){return console.log(`${B.red}\u2717${B.reset} Could not open native window:`,Y),!1}}function X$($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let Y=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(Y){let J=Y[1];try{let G=`
689
689
  ${J}
690
690
  return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
691
691
  `,K=Function(G)();if(K)return K}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Z=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Z)try{return JSON.parse(Z[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let Q=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(Q)try{let Y=Q[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(Y)return Function(`return ${Y[1]}`)()}catch(Y){console.warn("Invalid native-sidebar script configuration:",Y)}return}function n$(){console.log(`
@@ -1057,7 +1057,7 @@ else {
1057
1057
  };
1058
1058
  })();
1059
1059
  </script>
1060
- `}function P0($,X,Z={}){let Q=N4(X,Z),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Q+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Q}</html>`);return $+Q}function Z$($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function Q$($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Q)=>X.endsWith(Q))}function Y$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Z)=>Z.test($))}var K1=null;function J$($){if(!K1)K1=new j6($);return K1}function D1(){if(K1)K1.stop(),K1=null}import w1 from"path";var _1={name:"bun-plugin-stx",async setup($){let Z={...await s0(),...$.config?.stx},Q=new Set,Y=Z.webComponents?.enabled?`./${w1.relative(w1.dirname($.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Z.webComponents?.enabled)try{let G=await U$(Z,Q);if(J.push(...G),Z.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Z.cache&&Z.cachePath){let L=await K$(G,Z);if(L){if(Z.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await X5(()=>Bun.file(G).text(),"",(L)=>{throw new $5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new $5(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=Z5.time("script-extraction",()=>{let L=K,O=W$(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],V="",E=[];for(let N of A){let I=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",M=N.match(/<script\b([^>]*)>/i),w=M?M[1]:"";if(/\bserver\b/i.test(w))V=I;else E.push(N)}let q=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:V,templateContent:q,allScripts:E}}),z={__filename:G,__dirname:w1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await X5(()=>M0(_,z,G),void 0,(L)=>{let O=new e$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(G$.log(O,{filePath:G,scriptContent:_}),Z.debug)throw O});let H=await Z5.timeAsync("directive-processing",async()=>{return await V0(U,z,G,Z,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-q2hvne0v.js"),O=L(F.join(`
1060
+ `}function P0($,X,Z={}){let Q=N4(X,Z),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Q+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Q}</html>`);return $+Q}function Z$($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function Q$($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Q)=>X.endsWith(Q))}function Y$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Z)=>Z.test($))}var K1=null;function J$($){if(!K1)K1=new j6($);return K1}function D1(){if(K1)K1.stop(),K1=null}import w1 from"path";var _1={name:"bun-plugin-stx",async setup($){let Z={...await s0(),...$.config?.stx},Q=new Set,Y=Z.webComponents?.enabled?`./${w1.relative(w1.dirname($.config?.outdir||"dist"),Z.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Z.webComponents?.enabled)try{let G=await U$(Z,Q);if(J.push(...G),Z.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Z.cache&&Z.cachePath){let L=await K$(G,Z);if(L){if(Z.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await X5(()=>Bun.file(G).text(),"",(L)=>{throw new $5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new $5(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=Z5.time("script-extraction",()=>{let L=K,O=W$(K);if(O)L=O.content.trim();let A=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],V="",E=[];for(let N of A){let I=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",M=N.match(/<script\b([^>]*)>/i),w=M?M[1]:"";if(/\bserver\b/i.test(w))V=I;else E.push(N)}let q=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:V,templateContent:q,allScripts:E}}),z={__filename:G,__dirname:w1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await X5(()=>M0(_,z,G),void 0,(L)=>{let O=new e$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(G$.log(O,{filePath:G,scriptContent:_}),Z.debug)throw O});let H=await Z5.timeAsync("directive-processing",async()=>{return await V0(U,z,G,Z,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-4np12rj1.js"),O=L(F.join(`
1061
1061
  `),z),A=H.search(/<\/body>/i);if(A!==-1)H=H.slice(0,A)+O+`
1062
1062
  `+H.slice(A);else H+=`
1063
1063
  ${O}`}if(H=await A6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await _$(G,H,W,Z),Z.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:H,loader:"html"}}catch(W){let K=W instanceof Error?W:new e$(`Plugin processing failed: ${String(W)}`,G);if(G$.log(K,{filePath:G,buildConfig:$.config}),O6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Z.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,F=_.context||null;return{contents:Z.debug||H6()?`<!DOCTYPE html>
@@ -1120,7 +1120,7 @@ ${O}`}if(H=await A6(H),W.forEach((L)=>Q.add(L)),Z.cache&&Z.cachePath){if(await _
1120
1120
  <h1>Something went wrong</h1>
1121
1121
  <p>An internal error occurred. Please try again later.</p>
1122
1122
  </body>
1123
- </html>`,loader:"html"}}})}};async function V4($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=Q0.resolve($);if(!E0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return t$(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=u0(process.cwd(),"output");E0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let I={name:"public-assets",setup(T){T.onResolve({filter:/^\/(images|fonts|assets|public)\//},(f)=>{return{path:f.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[I,_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!M.success)return console.error(`${B.red}Build failed:${B.reset}`,M.logs),!1;let w=M.outputs.find((T)=>T.path.endsWith(".html"));if(!w)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(w.path).text(),!0}catch(I){return console.error(`${B.red}Error building stx file:${B.reset}`,I),!1}};if(!await U())return!1;let z=Q0.dirname(W);await B$(z);let j=Z;try{if(j=await h0(Z),j!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let I=X.hmrPort||j+1;J=J$({wsPort:I,verbose:!1}),G=J.start(I)}let H={},L=null,O;try{let{loadStxConfig:I}=await import("./chunk-eg8ksaft.js"),M=await I();if(O=X.stxOptions?.serverApi??M.serverApi,M?.apiRouter)L=M?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(M?.apiRoutes){H=M.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${B.blue}Loaded ${B.bright}${w} API route${w>1?"s":""}${B.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:D}=await import("./chunk-cdqx2c2h.js"),T=M.broadcasting;await w(T);let f=T.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${f}/ws${B.reset}`);let c=Q0.join(process.cwd(),"channels.ts");if(E0.existsSync(c))try{let v=await D(c);console.log(`${B.blue}Loaded ${B.bright}${v} broadcast channel${v!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(v){console.warn(`${B.yellow}Failed to load channels.ts: ${v.message}${B.reset}`)}}catch(w){console.warn(`${B.yellow}Broadcasting failed to start: ${w.message}${B.reset}`)}}catch{}let{createServerApi:A,isServerApiSource:V}=await import("./chunk-jnahcd4d.js"),E=await A(process.cwd(),O);if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let q=M4({port:j,async fetch(I){return F$(I,await(async()=>{let M=new URL(I.url);if([K,Q0.dirname(W),Q0.join(process.cwd(),"public")].some((v)=>V(Q0.join(v,M.pathname),process.cwd(),O)))return new Response("Not Found",{status:404});if(L)try{let v=await L.handleRequest(I);if(v.status!==404)return v}catch{}if(H[M.pathname])try{return await H[M.pathname](I)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let w=await E(I);if(w)return w;if(M.pathname==="/")return(async()=>{let S=await J0(_||"");if(Y)S=P0(S,G);if(X.native)if(S.includes("<head>"))S=S.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else S="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+S;if(X.titlebarHidden)if(S.includes("<head>"))S=S.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else S=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${S}`;return S})().then((S)=>new Response(S,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let D=Q0.join(K,M.pathname);if(E0.existsSync(D)&&E0.statSync(D).isFile()){let v=Bun.file(D),S=Q0.extname(D).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),r0=H0.transformSync(G0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let T=Q0.dirname(W),f=Q0.join(T,M.pathname);if(E0.existsSync(f)&&E0.statSync(f).isFile()){let v=Bun.file(f),S=Q0.extname(f).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),r0=H0.transformSync(G0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let c=Q0.join(process.cwd(),"public",M.pathname);if(E0.existsSync(c)&&E0.statSync(c).isFile()){let v=Bun.file(c),S=Q0.extname(c).toLowerCase(),k="application/octet-stream";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),r0=H0.transformSync(G0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1123
+ </html>`,loader:"html"}}})}};async function V4($,X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=Q0.resolve($);if(!E0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return t$(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=u0(process.cwd(),"output");E0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let I={name:"public-assets",setup(T){T.onResolve({filter:/^\/(images|fonts|assets|public)\//},(f)=>{return{path:f.path,external:!0}})}},M=await Bun.build({entrypoints:[W],outdir:K,plugins:[I,_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!M.success)return console.error(`${B.red}Build failed:${B.reset}`,M.logs),!1;let w=M.outputs.find((T)=>T.path.endsWith(".html"));if(!w)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(w.path).text(),!0}catch(I){return console.error(`${B.red}Error building stx file:${B.reset}`,I),!1}};if(!await U())return!1;let z=Q0.dirname(W);await B$(z);let j=Z;try{if(j=await h0(Z),j!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let I=X.hmrPort||j+1;J=J$({wsPort:I,verbose:!1}),G=J.start(I)}let H={},L=null,O;try{let{loadStxConfig:I}=await import("./chunk-q3g4yf5r.js"),M=await I();if(O=X.stxOptions?.serverApi??M.serverApi,M?.apiRouter)L=M?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(M?.apiRoutes){H=M.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${B.blue}Loaded ${B.bright}${w} API route${w>1?"s":""}${B.reset}`)}if(M?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:D}=await import("./chunk-22hch2me.js"),T=M.broadcasting;await w(T);let f=T.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${f}/ws${B.reset}`);let c=Q0.join(process.cwd(),"channels.ts");if(E0.existsSync(c))try{let v=await D(c);console.log(`${B.blue}Loaded ${B.bright}${v} broadcast channel${v!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(v){console.warn(`${B.yellow}Failed to load channels.ts: ${v.message}${B.reset}`)}}catch(w){console.warn(`${B.yellow}Broadcasting failed to start: ${w.message}${B.reset}`)}}catch{}let{createServerApi:A,isServerApiSource:V}=await import("./chunk-n0a55zv2.js"),E=await A(process.cwd(),O);if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let q=M4({port:j,async fetch(I){return F$(I,await(async()=>{let M=new URL(I.url);if([K,Q0.dirname(W),Q0.join(process.cwd(),"public")].some((v)=>V(Q0.join(v,M.pathname),process.cwd(),O)))return new Response("Not Found",{status:404});if(L)try{let v=await L.handleRequest(I);if(v.status!==404)return v}catch{}if(H[M.pathname])try{return await H[M.pathname](I)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let w=await E(I);if(w)return w;if(M.pathname==="/")return(async()=>{let S=await J0(_||"");if(Y)S=P0(S,G);if(X.native)if(S.includes("<head>"))S=S.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else S="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+S;if(X.titlebarHidden)if(S.includes("<head>"))S=S.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(S.includes("<html"))S=S.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else S=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${S}`;return S})().then((S)=>new Response(S,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let D=Q0.join(K,M.pathname);if(E0.existsSync(D)&&E0.statSync(D).isFile()){let v=Bun.file(D),S=Q0.extname(D).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),r0=H0.transformSync(G0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let T=Q0.dirname(W),f=Q0.join(T,M.pathname);if(E0.existsSync(f)&&E0.statSync(f).isFile()){let v=Bun.file(f),S=Q0.extname(f).toLowerCase(),k="text/plain";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),r0=H0.transformSync(G0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}let c=Q0.join(process.cwd(),"public",M.pathname);if(E0.existsSync(c)&&E0.statSync(c).isFile()){let v=Bun.file(c),S=Q0.extname(c).toLowerCase(),k="application/octet-stream";if(S===".ts"||S===".tsx"){let H0=new Bun.Transpiler({loader:S===".tsx"?"tsx":"ts"}),G0=await v.text(),r0=H0.transformSync(G0);return new Response(r0,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(S){case".html":k="text/html";break;case".css":k="text/css";break;case".js":k="text/javascript";break;case".json":k="application/json";break;case".png":k="image/png";break;case".jpg":case".jpeg":k="image/jpeg";break;case".gif":k="image/gif";break;case".svg":k="image/svg+xml";break;case".ico":k="image/x-icon";break;case".woff":k="font/woff";break;case".woff2":k="font/woff2";break;case".ttf":k="font/ttf";break;case".otf":k="font/otf";break;case".eot":k="application/vnd.ms-fontobject";break}return new Response(v,{headers:{"Content-Type":k}})}return new Response("Not Found",{status:404})})())},error(I){return new Response(`<pre>${I}
1124
1124
  ${I.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1125
1125
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1126
1126
  ${B.bright}\u2192 ${B.cyan}http://localhost:${j}/${B.reset}`),console.log(`
@@ -1607,12 +1607,12 @@ ${H.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1607
1607
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1608
1608
  ${B.bright}\u2192 ${B.cyan}http://localhost:${U}/${B.reset}`),console.log(`
1609
1609
  ${B.yellow}Routes:${B.reset}`);let z=new Set(W.map((H)=>H.routeTemplate)),j=Object.entries(G).filter(([H])=>!z.has(H)).sort(([H],[L])=>H.localeCompare(L)).map(([H,L])=>({route:H==="/"?"/":H,filePath:B0.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let H of W){let L=H.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");j.push({route:L,filePath:B0.relative(process.cwd(),H.filePath),fileType:"stx"})}if(j.sort((H,L)=>H.route.localeCompare(L.route)),j.forEach((H,L)=>{let A=L===j.length-1?"\u2514\u2500 ":"\u251C\u2500 ",V=H.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${A}${H.route}${B.reset} \u2192 ${B.bright}${H.filePath}${B.reset} ${V}`)}),console.log(`
1610
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(F.url.toString(),()=>{if(Q)m0.watch(J,{recursive:!0}).close();F.stop()}),Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let H=m0.watch(J,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),o0.clear(),t0(),await K()});process.on("SIGINT",()=>{H.close(),F.stop(),process.exit(0)})}return!0}function N6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:R4}=globalThis.Bun;import e from"fs";import m from"path";async function R6($){try{return G5(await Bun.file($).text())}catch{return}}function Q5($){let X=Bun.file($),Z=m.extname($).toLowerCase(),Q={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Q[Z]||"application/octet-stream",...J}})}async function D4($=".",X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=m.resolve($),{loadStxConfig:K}=await import("./chunk-eg8ksaft.js"),_=await K(W),{createServerApi:U,isServerApiSource:F}=await import("./chunk-jnahcd4d.js"),z=X.stxOptions?.serverApi??_.serverApi,j=await U(W,z),H=_.root&&_.root!=="."?m.join(W,_.root):W,L=X.pagesDir||_.pagesDir||"pages",O=m.join(H,L);if(!e.existsSync(O)&&!_._layerPageDirs?.some((R)=>e.existsSync(R)))return console.error(`${B.red}Error: No '${L}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${O}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${L}/index.stx for the homepage.${B.reset}`),!1;let A=j$(H,{pagesDir:L,pagesDirs:_._layerPageDirs?[O,..._._layerPageDirs.slice(1)]:void 0});if(A.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${O}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${A.length}${B.blue} routes${B.reset}`);let V=_?._pluginPageDirs||[],E=[];for(let{dir:R,prefix:x}of V)if(e.existsSync(R)){let P=j$(m.dirname(R),{pagesDir:m.basename(R)});for(let y of P){let Z0=x==="/"?y.pattern:`${x}${y.pattern==="/"?"":y.pattern}`;E.push({route:{...y,pattern:Z0},prefix:x})}if(P.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${P.length}${B.blue} routes at ${B.cyan}${x}${B.reset}`)}let q=new Map,N=null,I=null;if(X.stxOptions?.shell!==!1){if(I=await d6(W,X.stxOptions?.shell),I){if(N=await J5(I,X.stxOptions||{}),N)console.log(`${B.blue}Using app shell: ${B.bright}${m.relative(W,I)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}T6(),await k6(W);let M=C6();if(M.length>0)console.log(`${B.blue}Loaded ${B.bright}${M.length}${B.blue} middleware: ${B.dim}${M.join(", ")}${B.reset}`);let w={},D=null;try{let{loadStxConfig:R}=await import("./chunk-eg8ksaft.js"),x=await R(W);if(x?.apiRouter)D=x?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(x?.apiRoutes){w=x.apiRoutes;let P=Object.keys(w).length;if(P>0)console.log(`${B.blue}Loaded ${B.bright}${P} API route${P>1?"s":""}${B.reset}`)}if(x?.broadcasting?.enabled)try{let{startBroadcasting:P,loadChannels:y}=await import("./chunk-cdqx2c2h.js"),Z0=x.broadcasting;await P(Z0);let R0=Z0.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${R0}/ws${B.reset}`);let g0=m.join(process.cwd(),"channels.ts");if(e.existsSync(g0))try{let p=await y(g0);console.log(`${B.blue}Loaded ${B.bright}${p} broadcast channel${p!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(p){console.warn(`${B.yellow}Failed to load channels.ts: ${p.message}${B.reset}`)}}catch(P){console.warn(`${B.yellow}Broadcasting failed to start: ${P.message}${B.reset}`)}}catch{}let T=u0(W,"output");e.mkdirSync(T,{recursive:!0});let f=new Map,c=new Set,v=async(R)=>{let x=D6(O,R);if(!x)return null;try{let P=await Bun.build({entrypoints:[x],outdir:T,plugins:[_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!P.success)return null;let y=P.outputs.find((Z0)=>Z0.path.endsWith(".html"));if(!y)return null;return await Bun.file(y.path).text()}catch{return null}},S=new Map,k=async(R,x)=>{try{let{processDirectives:P,extractVariables:y,defaultConfig:Z0,loadStxConfig:R0,injectRouterScript:g0}=await import("./chunk-eg8ksaft.js"),{checkCache:p,cacheTemplate:u,readFileCached:g,templateCache:h}=await import("./chunk-yzxm75jp.js"),Y0=await R0(W),f0=(i)=>{if(!i)return i;if(m.isAbsolute(i))return i;return m.resolve(W,i)},C={...Z0,...Y0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)C.debug=!0;C.partialsDir=f0(C.partialsDir),C.componentsDir=f0(C.componentsDir),C.layoutsDir=f0(C.layoutsDir),C.storesDir=f0(C.storesDir||"stores"),C.cachePath=f0(C.cachePath)??u0(W,"cache");let X0=!x&&!X.profile,a=C.cache!==!1;if(a&&X0){let i=h.get(R.filePath);if(i)try{if((await e.promises.stat(R.filePath)).mtime.getTime()<=i.mtime){let N0=!0;for(let _0 of i.dependencies){if(!e.existsSync(_0)){N0=!1;break}if((await e.promises.stat(_0)).mtime.getTime()>i.mtime){N0=!1;break}}if(N0){let _0=i.output;if(N)_0=O$(_0,{preserveHead:!0});let E1=S.get(R.filePath);return{route:R,content:_0,status:E1?.status??await R6(R.filePath),headers:E1?.headers}}}}catch{}let A0=await p(R.filePath,C);if(A0){let q0=A0;if(N)q0=O$(q0,{preserveHead:!0});let N0=S.get(R.filePath);return{route:R,content:q0,status:N0?.status??await R6(R.filePath),headers:N0?.headers}}}let o=a?await g(R.filePath):await Bun.file(R.filePath).text(),K0=G5(o),{classifyAllScripts:d}=await import("./chunk-eg8ksaft.js"),O0=d(o),D0=O0.server.map((i)=>i.content),s=o;for(let i of O0.server)s=s.replace(i.fullTag,"");let n={__filename:R.filePath,__dirname:m.dirname(R.filePath),__stx_options:C,params:x??{},__stx_runtime_head:{}};for(let i of D0)try{await y(i,n,R.filePath)}catch(A0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",R.filePath,A0?.message||A0)}let S0=new Set,j0;if(X.profile){let i=performance.now();j0=await P(s,n,R.filePath,C,S0);let A0=performance.now()-i,q0=m.relative(W,R.filePath)||R.filePath;console.log(`[stx:profile] ${q0} \u2192 ${A0.toFixed(2)}ms`)}else j0=await P(s,n,R.filePath,C,S0);if(!N)j0=await g0(j0,{router:C.router});{let{interpolateScriptExpressions:i}=await import("./chunk-q2hvne0v.js");j0=j0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(A0,q0,N0)=>{if(!/function\s+__stx_setup_/.test(N0))return A0;return`<script${q0}>${i(N0,n)}</script>`})}if(N)j0=O$(j0,{preserveHead:!0});if(a&&X0)await u(R.filePath,j0,S0,C);let{extractStreamBoundaries:Q3}=await import("./chunk-7ywnkv1f.js"),Q1=Q3(n),V1=n.__streamTemplates;if(V1&&typeof V1==="object"&&Object.keys(V1).length>0){let i=n.streamBoundaries||{},A0={...C,autoShell:!1},q0=Object.keys(V1).map((_0)=>({id:_0,render:async()=>{let E1=typeof i[_0]==="function"?await i[_0]():void 0;return P(V1[_0],{...n,$boundary:E1},R.filePath,A0,new Set)}})),N0=new Set(q0.map((_0)=>_0.id));Q1=[...(Q1||[]).filter((_0)=>!N0.has(_0.id)),...q0]}if(Q1&&Q1.length>0)c.add(R.pattern);else Q1=void 0;let l5=T1(n),i5=C1(n);if(X0)S.set(R.filePath,{status:l5,headers:i5});return{route:R,content:j0,status:l5??K0,headers:i5,boundaries:Q1}}catch(P){return console.error(`${B.red}Error building ${B.bright}${R.pattern}${B.reset}:`,P),null}},H0=8,G0=async()=>{f.clear(),q.clear();for(let R=0;R<A.length;R+=H0){let x=A.slice(R,R+H0),P=await Promise.all(x.map((y)=>k(y)));for(let y of P)if(y)f.set(y.route.pattern,y)}for(let R=0;R<E.length;R+=H0){let x=E.slice(R,R+H0),P=await Promise.all(x.map(({route:y})=>k(y)));for(let y of P)if(y)q.set(y.route.pattern,y)}return f.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await G0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await B$(W);let v0=Z;try{if(v0=await h0(Z),v0!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${v0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let R=X.hmrPort||v0+1;J=J$({wsPort:R,verbose:!1}),G=J.start(R)}let z0=(R,x)=>{let y=`<script data-stx-route-params>(function(){var p=${JSON.stringify(x).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(R.includes("</head>"))return R.replace("</head>",`${y}</head>`);if(R.includes("<body"))return R.replace(/<body([^>]*)>/,`<body$1>${y}`);return y+R};console.log(`${B.blue}Starting server...${B.reset}`);let Z1=R4({port:v0,async fetch(R){let x=new URL(R.url),P=_?.publicDir||"public",y=m.join(W,P,x.pathname),Z0=m.join(W,x.pathname),R0=m.join(T,x.pathname);if([y,Z0,R0].some((C)=>F(C,W,z)))return new Response("Not Found",{status:404});let[g0,p,u]=await Promise.all([e.promises.stat(y).catch(()=>null),e.promises.stat(Z0).catch(()=>null),e.promises.stat(R0).catch(()=>null)]);if(g0?.isFile()&&!F(y,W,z))return Q5(y);if(p?.isFile()&&!F(Z0,W,z))return Q5(Z0);if(u?.isFile()&&!F(R0,W,z))return Q5(R0);if(x.pathname.startsWith("/_stx/component/")){let C=decodeURIComponent(x.pathname.slice(16));if(C)try{let X0=`<${C} />`,a={...buildConfig,autoShell:!1},o=await processDirectives(X0,{},m.join(W,"components",`${C}.stx`),a,new Set);return new Response(o,{headers:{"Content-Type":"text/html"}})}catch(X0){return new Response(`<div class="stx-async-error">${X0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(x.pathname==="/_stx/img"){let{handleImageRequest:C}=await import("./chunk-gbz6pfs8.js"),X0=await C(R,{publicDir:m.join(W,P),cacheDir:u0(W,"cache","img")});if(X0)return X0}if(D)try{let C=await D.handleRequest(R);if(C.status!==404)return C}catch{}if(w[x.pathname])try{return await w[x.pathname](R)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=await j(R);if(g)return g;let h=Y5(x.pathname,A);if(h){let C=f.get(h.route.pattern),X0=c.has(h.route.pattern);if(h.route.isDynamic&&Object.keys(h.params).length>0||X0){let a=await k(h.route,h.params);if(a)C=a}if(C){let a=C.status??200,o=C.headers??{},K0=(h.route.filePath?y6(await Bun.file(h.route.filePath).text().catch(()=>"")):null)??{};if(K0.validate){if(!await K0.validate({params:h.params})){let D0=await v(404);if(D0){let s=D0;if(s=await J0(s,W),Y)s=P0(s,G);return new Response(s,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(K0.middleware){let O0=x6(x.pathname,h.params,K0,x.search),D0=S6(O0,null,R,{isServer:!0}),s=await P6(K0.middleware,D0);if(s.redirect){let n=s.redirect.path,S0=s.redirect.options.redirectCode||302,j0=new Headers(s.responseHeaders);return j0.set("Location",n),new Response(null,{status:S0,headers:j0})}if(s.abort){let{statusCode:n,message:S0}=s.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${n}</title></head><body><h1>Error ${n}</h1><p>${S0}</p></body></html>`,{status:n,headers:{"Content-Type":"text/html"}})}if(Object.keys(s.state).length>0){let n=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(s.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;C.content=C.content.replace("</head>",`${n}</head>`)}}let d=C.content;if(N&&u6(R)){let O0=b6(d),D0=v6(d),s=d.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=s?h6(s[1].trim()):"";if(Object.keys(h.params).length>0)d=z0(d,h.params);d=await J0(d,W);let S0=_?.router?.container||"main";return d=m6(d,S0),new Response(d,{status:a,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":O0.layout,"X-STX-Layout-Group":O0.group,"X-STX-Runtime":D0?"true":"false",...n&&{"X-STX-Title":encodeURIComponent(n)},[g6]:f6(),...B1(),"Cache-Control":z$}})}if(N)d=H$(N,d);if(Object.keys(h.params).length>0)d=z0(d,h.params);if(d=await J0(d,W),Y)d=P0(d,G);if(X.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;if(X.titlebarHidden)if(d.includes("<head>"))d=d.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else d=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${d}`;if(C.boundaries&&C.boundaries.length>0){let{renderStreamingPage:O0,streamToResponse:D0}=await import("./chunk-7ywnkv1f.js");return D0(O0(d,C.boundaries,{timeoutMs:30000}),{status:a,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(d,{status:a,headers:{"Content-Type":"text/html",...B1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...o}})}}if(E.length>0){let C=E.map((a)=>a.route),X0=Y5(x.pathname,C);if(X0){let a=q.get(X0.route.pattern);if(a){let o=a.content;if(N)o=H$(N,o);if(Object.keys(X0.params).length>0)o=z0(o,X0.params);if(o=await J0(o,W),Y)o=P0(o,G);return new Response(o,{status:a.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of V)if(a!=="/"&&x.pathname.startsWith(a)){let o=q.get(a)||q.get(a+"/");if(o){let K0=o.content;if(N)K0=H$(N,K0);if(K0=await J0(K0,W),Y)K0=P0(K0,G);return new Response(K0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let Y0=f.get("/");if(Y0){let C=Y0.content;if(C=await J0(C,W),Y)C=P0(C,G);if(X.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let f0=await v(404);if(f0){let C=f0;if(C=await J0(C,W),Y)C=P0(C,G);return new Response(C,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(R){let x=await v(500);if(x)return new Response(x,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${R}
1610
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(F.url.toString(),()=>{if(Q)m0.watch(J,{recursive:!0}).close();F.stop()}),Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let H=m0.watch(J,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${O}${B.yellow} changed, rebuilding...${B.reset}`),o0.clear(),t0(),await K()});process.on("SIGINT",()=>{H.close(),F.stop(),process.exit(0)})}return!0}function N6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:R4}=globalThis.Bun;import e from"fs";import m from"path";async function R6($){try{return G5(await Bun.file($).text())}catch{return}}function Q5($){let X=Bun.file($),Z=m.extname($).toLowerCase(),Q={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Q[Z]||"application/octet-stream",...J}})}async function D4($=".",X={}){let Z=X.port||3000,Q=X.watch!==!1,Y=X.hotReload!==!1&&Q,J=null,G=X.hmrPort||Z+1,W=m.resolve($),{loadStxConfig:K}=await import("./chunk-q3g4yf5r.js"),_=await K(W),{createServerApi:U,isServerApiSource:F}=await import("./chunk-n0a55zv2.js"),z=X.stxOptions?.serverApi??_.serverApi,j=await U(W,z),H=_.root&&_.root!=="."?m.join(W,_.root):W,L=X.pagesDir||_.pagesDir||"pages",O=m.join(H,L);if(!e.existsSync(O)&&!_._layerPageDirs?.some((R)=>e.existsSync(R)))return console.error(`${B.red}Error: No '${L}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${O}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${L}/index.stx for the homepage.${B.reset}`),!1;let A=j$(H,{pagesDir:L,pagesDirs:_._layerPageDirs?[O,..._._layerPageDirs.slice(1)]:void 0});if(A.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${O}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${A.length}${B.blue} routes${B.reset}`);let V=_?._pluginPageDirs||[],E=[];for(let{dir:R,prefix:x}of V)if(e.existsSync(R)){let P=j$(m.dirname(R),{pagesDir:m.basename(R)});for(let y of P){let Z0=x==="/"?y.pattern:`${x}${y.pattern==="/"?"":y.pattern}`;E.push({route:{...y,pattern:Z0},prefix:x})}if(P.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${P.length}${B.blue} routes at ${B.cyan}${x}${B.reset}`)}let q=new Map,N=null,I=null;if(X.stxOptions?.shell!==!1){if(I=await d6(W,X.stxOptions?.shell),I){if(N=await J5(I,X.stxOptions||{}),N)console.log(`${B.blue}Using app shell: ${B.bright}${m.relative(W,I)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}T6(),await k6(W);let M=C6();if(M.length>0)console.log(`${B.blue}Loaded ${B.bright}${M.length}${B.blue} middleware: ${B.dim}${M.join(", ")}${B.reset}`);let w={},D=null;try{let{loadStxConfig:R}=await import("./chunk-q3g4yf5r.js"),x=await R(W);if(x?.apiRouter)D=x?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(x?.apiRoutes){w=x.apiRoutes;let P=Object.keys(w).length;if(P>0)console.log(`${B.blue}Loaded ${B.bright}${P} API route${P>1?"s":""}${B.reset}`)}if(x?.broadcasting?.enabled)try{let{startBroadcasting:P,loadChannels:y}=await import("./chunk-22hch2me.js"),Z0=x.broadcasting;await P(Z0);let R0=Z0.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${R0}/ws${B.reset}`);let g0=m.join(process.cwd(),"channels.ts");if(e.existsSync(g0))try{let p=await y(g0);console.log(`${B.blue}Loaded ${B.bright}${p} broadcast channel${p!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(p){console.warn(`${B.yellow}Failed to load channels.ts: ${p.message}${B.reset}`)}}catch(P){console.warn(`${B.yellow}Broadcasting failed to start: ${P.message}${B.reset}`)}}catch{}let T=u0(W,"output");e.mkdirSync(T,{recursive:!0});let f=new Map,c=new Set,v=async(R)=>{let x=D6(O,R);if(!x)return null;try{let P=await Bun.build({entrypoints:[x],outdir:T,plugins:[_1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!P.success)return null;let y=P.outputs.find((Z0)=>Z0.path.endsWith(".html"));if(!y)return null;return await Bun.file(y.path).text()}catch{return null}},S=new Map,k=async(R,x)=>{try{let{processDirectives:P,extractVariables:y,defaultConfig:Z0,loadStxConfig:R0,injectRouterScript:g0}=await import("./chunk-q3g4yf5r.js"),{checkCache:p,cacheTemplate:u,readFileCached:g,templateCache:h}=await import("./chunk-szfk6pw6.js"),Y0=await R0(W),f0=(i)=>{if(!i)return i;if(m.isAbsolute(i))return i;return m.resolve(W,i)},C={...Z0,...Y0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)C.debug=!0;C.partialsDir=f0(C.partialsDir),C.componentsDir=f0(C.componentsDir),C.layoutsDir=f0(C.layoutsDir),C.storesDir=f0(C.storesDir||"stores"),C.cachePath=f0(C.cachePath)??u0(W,"cache");let X0=!x&&!X.profile,a=C.cache!==!1;if(a&&X0){let i=h.get(R.filePath);if(i)try{if((await e.promises.stat(R.filePath)).mtime.getTime()<=i.mtime){let N0=!0;for(let _0 of i.dependencies){if(!e.existsSync(_0)){N0=!1;break}if((await e.promises.stat(_0)).mtime.getTime()>i.mtime){N0=!1;break}}if(N0){let _0=i.output;if(N)_0=O$(_0,{preserveHead:!0});let E1=S.get(R.filePath);return{route:R,content:_0,status:E1?.status??await R6(R.filePath),headers:E1?.headers}}}}catch{}let A0=await p(R.filePath,C);if(A0){let q0=A0;if(N)q0=O$(q0,{preserveHead:!0});let N0=S.get(R.filePath);return{route:R,content:q0,status:N0?.status??await R6(R.filePath),headers:N0?.headers}}}let o=a?await g(R.filePath):await Bun.file(R.filePath).text(),K0=G5(o),{classifyAllScripts:d}=await import("./chunk-q3g4yf5r.js"),O0=d(o),D0=O0.server.map((i)=>i.content),s=o;for(let i of O0.server)s=s.replace(i.fullTag,"");let n={__filename:R.filePath,__dirname:m.dirname(R.filePath),__stx_options:C,params:x??{},__stx_runtime_head:{}};for(let i of D0)try{await y(i,n,R.filePath)}catch(A0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",R.filePath,A0?.message||A0)}let S0=new Set,j0;if(X.profile){let i=performance.now();j0=await P(s,n,R.filePath,C,S0);let A0=performance.now()-i,q0=m.relative(W,R.filePath)||R.filePath;console.log(`[stx:profile] ${q0} \u2192 ${A0.toFixed(2)}ms`)}else j0=await P(s,n,R.filePath,C,S0);if(!N)j0=await g0(j0,{router:C.router});{let{interpolateScriptExpressions:i}=await import("./chunk-4np12rj1.js");j0=j0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(A0,q0,N0)=>{if(!/function\s+__stx_setup_/.test(N0))return A0;return`<script${q0}>${i(N0,n)}</script>`})}if(N)j0=O$(j0,{preserveHead:!0});if(a&&X0)await u(R.filePath,j0,S0,C);let{extractStreamBoundaries:Q3}=await import("./chunk-fha0nyet.js"),Q1=Q3(n),V1=n.__streamTemplates;if(V1&&typeof V1==="object"&&Object.keys(V1).length>0){let i=n.streamBoundaries||{},A0={...C,autoShell:!1},q0=Object.keys(V1).map((_0)=>({id:_0,render:async()=>{let E1=typeof i[_0]==="function"?await i[_0]():void 0;return P(V1[_0],{...n,$boundary:E1},R.filePath,A0,new Set)}})),N0=new Set(q0.map((_0)=>_0.id));Q1=[...(Q1||[]).filter((_0)=>!N0.has(_0.id)),...q0]}if(Q1&&Q1.length>0)c.add(R.pattern);else Q1=void 0;let l5=T1(n),i5=C1(n);if(X0)S.set(R.filePath,{status:l5,headers:i5});return{route:R,content:j0,status:l5??K0,headers:i5,boundaries:Q1}}catch(P){return console.error(`${B.red}Error building ${B.bright}${R.pattern}${B.reset}:`,P),null}},H0=8,G0=async()=>{f.clear(),q.clear();for(let R=0;R<A.length;R+=H0){let x=A.slice(R,R+H0),P=await Promise.all(x.map((y)=>k(y)));for(let y of P)if(y)f.set(y.route.pattern,y)}for(let R=0;R<E.length;R+=H0){let x=E.slice(R,R+H0),P=await Promise.all(x.map(({route:y})=>k(y)));for(let y of P)if(y)q.set(y.route.pattern,y)}return f.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await G0())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await B$(W);let v0=Z;try{if(v0=await h0(Z),v0!==Z)console.log(`${B.yellow}Port ${Z} is busy, using port ${v0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let R=X.hmrPort||v0+1;J=J$({wsPort:R,verbose:!1}),G=J.start(R)}let z0=(R,x)=>{let y=`<script data-stx-route-params>(function(){var p=${JSON.stringify(x).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(R.includes("</head>"))return R.replace("</head>",`${y}</head>`);if(R.includes("<body"))return R.replace(/<body([^>]*)>/,`<body$1>${y}`);return y+R};console.log(`${B.blue}Starting server...${B.reset}`);let Z1=R4({port:v0,async fetch(R){let x=new URL(R.url),P=_?.publicDir||"public",y=m.join(W,P,x.pathname),Z0=m.join(W,x.pathname),R0=m.join(T,x.pathname);if([y,Z0,R0].some((C)=>F(C,W,z)))return new Response("Not Found",{status:404});let[g0,p,u]=await Promise.all([e.promises.stat(y).catch(()=>null),e.promises.stat(Z0).catch(()=>null),e.promises.stat(R0).catch(()=>null)]);if(g0?.isFile()&&!F(y,W,z))return Q5(y);if(p?.isFile()&&!F(Z0,W,z))return Q5(Z0);if(u?.isFile()&&!F(R0,W,z))return Q5(R0);if(x.pathname.startsWith("/_stx/component/")){let C=decodeURIComponent(x.pathname.slice(16));if(C)try{let X0=`<${C} />`,a={...buildConfig,autoShell:!1},o=await processDirectives(X0,{},m.join(W,"components",`${C}.stx`),a,new Set);return new Response(o,{headers:{"Content-Type":"text/html"}})}catch(X0){return new Response(`<div class="stx-async-error">${X0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(x.pathname==="/_stx/img"){let{handleImageRequest:C}=await import("./chunk-58j32d7n.js"),X0=await C(R,{publicDir:m.join(W,P),cacheDir:u0(W,"cache","img")});if(X0)return X0}if(D)try{let C=await D.handleRequest(R);if(C.status!==404)return C}catch{}if(w[x.pathname])try{return await w[x.pathname](R)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=await j(R);if(g)return g;let h=Y5(x.pathname,A);if(h){let C=f.get(h.route.pattern),X0=c.has(h.route.pattern);if(h.route.isDynamic&&Object.keys(h.params).length>0||X0){let a=await k(h.route,h.params);if(a)C=a}if(C){let a=C.status??200,o=C.headers??{},K0=(h.route.filePath?y6(await Bun.file(h.route.filePath).text().catch(()=>"")):null)??{};if(K0.validate){if(!await K0.validate({params:h.params})){let D0=await v(404);if(D0){let s=D0;if(s=await J0(s,W),Y)s=P0(s,G);return new Response(s,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(K0.middleware){let O0=x6(x.pathname,h.params,K0,x.search),D0=S6(O0,null,R,{isServer:!0}),s=await P6(K0.middleware,D0);if(s.redirect){let n=s.redirect.path,S0=s.redirect.options.redirectCode||302,j0=new Headers(s.responseHeaders);return j0.set("Location",n),new Response(null,{status:S0,headers:j0})}if(s.abort){let{statusCode:n,message:S0}=s.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${n}</title></head><body><h1>Error ${n}</h1><p>${S0}</p></body></html>`,{status:n,headers:{"Content-Type":"text/html"}})}if(Object.keys(s.state).length>0){let n=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(s.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;C.content=C.content.replace("</head>",`${n}</head>`)}}let d=C.content;if(N&&u6(R)){let O0=b6(d),D0=v6(d),s=d.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=s?h6(s[1].trim()):"";if(Object.keys(h.params).length>0)d=z0(d,h.params);d=await J0(d,W);let S0=_?.router?.container||"main";return d=m6(d,S0),new Response(d,{status:a,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":O0.layout,"X-STX-Layout-Group":O0.group,"X-STX-Runtime":D0?"true":"false",...n&&{"X-STX-Title":encodeURIComponent(n)},[g6]:f6(),...B1(),"Cache-Control":z$}})}if(N)d=H$(N,d);if(Object.keys(h.params).length>0)d=z0(d,h.params);if(d=await J0(d,W),Y)d=P0(d,G);if(X.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;if(X.titlebarHidden)if(d.includes("<head>"))d=d.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else d=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${d}`;if(C.boundaries&&C.boundaries.length>0){let{renderStreamingPage:O0,streamToResponse:D0}=await import("./chunk-fha0nyet.js");return D0(O0(d,C.boundaries,{timeoutMs:30000}),{status:a,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(d,{status:a,headers:{"Content-Type":"text/html",...B1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...o}})}}if(E.length>0){let C=E.map((a)=>a.route),X0=Y5(x.pathname,C);if(X0){let a=q.get(X0.route.pattern);if(a){let o=a.content;if(N)o=H$(N,o);if(Object.keys(X0.params).length>0)o=z0(o,X0.params);if(o=await J0(o,W),Y)o=P0(o,G);return new Response(o,{status:a.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of V)if(a!=="/"&&x.pathname.startsWith(a)){let o=q.get(a)||q.get(a+"/");if(o){let K0=o.content;if(N)K0=H$(N,K0);if(K0=await J0(K0,W),Y)K0=P0(K0,G);return new Response(K0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let Y0=f.get("/");if(Y0){let C=Y0.content;if(C=await J0(C,W),Y)C=P0(C,G);if(X.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let f0=await v(404);if(f0){let C=f0;if(C=await J0(C,W),Y)C=P0(C,G);return new Response(C,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(R){let x=await v(500);if(x)return new Response(x,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${R}
1611
1611
  ${R.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1612
1612
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1613
1613
  ${B.bright}\u2192 ${B.cyan}http://localhost:${v0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
1614
1614
  ${B.yellow}Routes:${B.reset}`);let W0=[...w6(A,W)];for(let{route:R}of E)W0.push(`${R.pattern}`);if(W0.forEach((R,x)=>{let y=x===W0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${y}${B.reset}${R}`)}),console.log(`
1615
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(Z1.url.toString(),()=>{if(J)D1();Z1.stop()}),X.native){let R,x=m.join(O,"index.stx");if(e.existsSync(x)){let y=await Bun.file(x).text();R=X$(y)}let P=_?.app?.window??{};await G1(v0,{title:_?.app?.head?.title||m.basename(W)||"stx App",width:P.width,height:P.height,darkMode:P.darkMode,hotReload:P.hotReload,titlebarHidden:P.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!R,sidebarConfig:R})}if(Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let R=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},x=(p)=>{let u=p.toLowerCase();return u.endsWith(".stx")||u.endsWith(".html")||u.endsWith(".md")},P=new Map,y=()=>{let p=new Set([W,..._._layerGraph?.layers.map((u)=>u.root)??[],..._._layerGraph?.configDependencies.map((u)=>m.dirname(u))??[]].filter((u)=>e.existsSync(u)).map((u)=>e.realpathSync(u)));for(let u of _._layerGraph?.layers??[])for(let g of Object.values(u.resources)){if(!e.existsSync(g))continue;let h=e.realpathSync(g);if(![...p].some((Y0)=>h===Y0||h.startsWith(`${Y0}${m.sep}`)))p.add(h)}for(let[u,g]of P)if(!p.has(u))g.close(),P.delete(u);for(let u of p)if(!P.has(u)&&e.existsSync(u))P.set(u,e.watch(u,{recursive:!0},(g,h)=>{R0(u,g,h).catch((Y0)=>console.error("[stx] Layer rebuild failed:",Y0))}))},Z0=Promise.resolve(),R0=(p,u,g)=>{return Z0=Z0.catch(()=>{}).then(()=>g0(p,u,g)),Z0},g0=async(p,u,g)=>{if(!g||Y$(g))return;if(Q$(g)){if(_._layerGraph){let h=await K(W);Object.assign(_,h),A.splice(0,A.length,...j$(H,{pagesDir:L,pagesDirs:h._layerPageDirs?[O,...h._layerPageDirs.slice(1)]:void 0})),y()}if(R(g)){if(console.log(`${B.cyan}${g} changed${B.reset}`),Y&&J)J.reload(g)}else if(x(g)){console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-yzxm75jp.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(I&&g){if(m.resolve(p,g)===I||m.basename(I)===g){let Y0=await J5(I,X.stxOptions||{});if(Y0)N=Y0}}if(await G0(),await L$(W),Y&&J)J.reload(g)}else{console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-yzxm75jp.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(await G0(),Y&&J)J.reload(g)}}else if(Z$(g)){if(console.log(`${B.cyan}CSS ${g} changed${B.reset}`),Y&&J)J.updateCss(g)}};y(),process.on("SIGINT",()=>{for(let p of P.values())p.close();if(J)D1();Z1.stop(),process.exit(0)})}return!0}var b={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function w4($={}){if(typeof window>"u")return;b.enabled=!0,b.maxEvents=$.maxEvents||1000,b.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>b,getComponents:()=>Array.from(b.components.values()),getComponent:(X)=>b.components.get(X),getStores:()=>Array.from(b.stores.values()),getStore:(X)=>b.stores.get(X),getEvents:()=>b.events,getPerformance:()=>b.performance,selectComponent:(X)=>K5(X),selectStore:(X)=>C4(X),inspectElement:(X)=>k4(X),highlightComponent:(X)=>a6(X),clearHighlight:()=>r6(),logComponentTree:()=>x4(),logStoreState:(X)=>S4(X),timeTravel:(X,Z)=>P4(X,Z)},y4(),b4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function T4(){b.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function p6($){if(!b.enabled)return;let X=b.components.get($);if(X){if(X.parentId){let Z=b.components.get(X.parentId);if(Z)Z.children=Z.children.filter((Q)=>Q!==$)}b.components.delete($),W5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function l6($,X,Z={},Q=[]){if(!b.enabled)return;let Y={id:$,state:X,getters:Z,actions:Q,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};b.stores.set($,Y),W5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function i6($,X,Z,Q,Y="state"){if(!b.enabled)return;let J=b.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Z,newValue:Q,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Q};W5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Z,newValue:Q}})}}function W5($){if(!b.enabled)return;if(b.events.push($),b.events.length>b.maxEvents)b.events=b.events.slice(-b.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function K5($){b.selectedComponent=$;let X=b.components.get($);if(X)a6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function C4($){b.selectedStore=$;let X=b.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function k4($){let X=$;while(X){let Z=X.getAttribute("data-stx-component-id");if(Z)return K5(Z);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function a6($){r6();let X=b.components.get($);if(X?.element){let Z=document.createElement("div");Z.id="stx-devtools-highlight",Z.style.cssText=`
1615
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),d0(Z1.url.toString(),()=>{if(J)D1();Z1.stop()}),X.native){let R,x=m.join(O,"index.stx");if(e.existsSync(x)){let y=await Bun.file(x).text();R=X$(y)}let P=_?.app?.window??{};await G1(v0,{title:_?.app?.head?.title||m.basename(W)||"stx App",width:P.width,height:P.height,darkMode:P.darkMode,hotReload:P.hotReload,titlebarHidden:P.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!R,sidebarConfig:R})}if(Q){console.log(`${B.blue}Watching for changes...${B.reset}`);let R=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},x=(p)=>{let u=p.toLowerCase();return u.endsWith(".stx")||u.endsWith(".html")||u.endsWith(".md")},P=new Map,y=()=>{let p=new Set([W,..._._layerGraph?.layers.map((u)=>u.root)??[],..._._layerGraph?.configDependencies.map((u)=>m.dirname(u))??[]].filter((u)=>e.existsSync(u)).map((u)=>e.realpathSync(u)));for(let u of _._layerGraph?.layers??[])for(let g of Object.values(u.resources)){if(!e.existsSync(g))continue;let h=e.realpathSync(g);if(![...p].some((Y0)=>h===Y0||h.startsWith(`${Y0}${m.sep}`)))p.add(h)}for(let[u,g]of P)if(!p.has(u))g.close(),P.delete(u);for(let u of p)if(!P.has(u)&&e.existsSync(u))P.set(u,e.watch(u,{recursive:!0},(g,h)=>{R0(u,g,h).catch((Y0)=>console.error("[stx] Layer rebuild failed:",Y0))}))},Z0=Promise.resolve(),R0=(p,u,g)=>{return Z0=Z0.catch(()=>{}).then(()=>g0(p,u,g)),Z0},g0=async(p,u,g)=>{if(!g||Y$(g))return;if(Q$(g)){if(_._layerGraph){let h=await K(W);Object.assign(_,h),A.splice(0,A.length,...j$(H,{pagesDir:L,pagesDirs:h._layerPageDirs?[O,...h._layerPageDirs.slice(1)]:void 0})),y()}if(R(g)){if(console.log(`${B.cyan}${g} changed${B.reset}`),Y&&J)J.reload(g)}else if(x(g)){console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-szfk6pw6.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(I&&g){if(m.resolve(p,g)===I||m.basename(I)===g){let Y0=await J5(I,X.stxOptions||{});if(Y0)N=Y0}}if(await G0(),await L$(W),Y&&J)J.reload(g)}else{console.log(`${B.yellow}${g} changed, rebuilding...${B.reset}`),o0.clear(),t0();try{let{invalidateFileCache:h,templateCache:Y0}=await import("./chunk-szfk6pw6.js");h(m.resolve(p,g)),Y0.delete(m.resolve(p,g))}catch{}if(await G0(),Y&&J)J.reload(g)}}else if(Z$(g)){if(console.log(`${B.cyan}CSS ${g} changed${B.reset}`),Y&&J)J.updateCss(g)}};y(),process.on("SIGINT",()=>{for(let p of P.values())p.close();if(J)D1();Z1.stop(),process.exit(0)})}return!0}var b={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function w4($={}){if(typeof window>"u")return;b.enabled=!0,b.maxEvents=$.maxEvents||1000,b.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>b,getComponents:()=>Array.from(b.components.values()),getComponent:(X)=>b.components.get(X),getStores:()=>Array.from(b.stores.values()),getStore:(X)=>b.stores.get(X),getEvents:()=>b.events,getPerformance:()=>b.performance,selectComponent:(X)=>K5(X),selectStore:(X)=>C4(X),inspectElement:(X)=>k4(X),highlightComponent:(X)=>a6(X),clearHighlight:()=>r6(),logComponentTree:()=>x4(),logStoreState:(X)=>S4(X),timeTravel:(X,Z)=>P4(X,Z)},y4(),b4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function T4(){b.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function p6($){if(!b.enabled)return;let X=b.components.get($);if(X){if(X.parentId){let Z=b.components.get(X.parentId);if(Z)Z.children=Z.children.filter((Q)=>Q!==$)}b.components.delete($),W5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function l6($,X,Z={},Q=[]){if(!b.enabled)return;let Y={id:$,state:X,getters:Z,actions:Q,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};b.stores.set($,Y),W5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function i6($,X,Z,Q,Y="state"){if(!b.enabled)return;let J=b.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Z,newValue:Q,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Q};W5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Z,newValue:Q}})}}function W5($){if(!b.enabled)return;if(b.events.push($),b.events.length>b.maxEvents)b.events=b.events.slice(-b.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function K5($){b.selectedComponent=$;let X=b.components.get($);if(X)a6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function C4($){b.selectedStore=$;let X=b.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function k4($){let X=$;while(X){let Z=X.getAttribute("data-stx-component-id");if(Z)return K5(Z);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function a6($){r6();let X=b.components.get($);if(X?.element){let Z=document.createElement("div");Z.id="stx-devtools-highlight",Z.style.cssText=`
1616
1616
  position: absolute;
1617
1617
  background: rgba(59, 130, 246, 0.2);
1618
1618
  border: 2px solid #3b82f6;
@@ -2881,9 +2881,9 @@ describe('Example', () => {
2881
2881
  </footer>
2882
2882
  @yield('scripts')
2883
2883
  </body>
2884
- </html>`}function tX(){return"<!-- Hero section -->"}function eX(){return"<!-- Features -->"}function $Z(){return"<!-- Pricing -->"}function XZ(){return"<!-- Button -->"}function g1($){if(!v1($))j5($,{recursive:!0})}function ZZ(){if(v1("bun.lockb"))return"bun";if(v1("pnpm-lock.yaml"))return"pnpm";if(v1("yarn.lock"))return"yarn";return"bun"}function H5($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function QZ($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function e0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:YZ}=globalThis.Bun;import f1 from"fs";import I0 from"path";function h2($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function O5($){let{loadStxConfig:X}=await import("./chunk-ssd10kje.js");return{...await X($.configDir??process.cwd()),...$.stxOptions??{}}}async function JZ($={}){let{port:X=3000,root:Z=".",watch:Q=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=I0.resolve(Z),U=await O5($),F=I0.resolve($.configDir??process.cwd()),z=await A5(F,U.serverApi),j=new Map;async function H(q){let N=f1.statSync(q),I=`${q}:${N.mtimeMs}`,M=j.get(I);if(M)return{content:M.content,status:M.status,headers:M.headers};for(let W0 of j.keys())if(W0.startsWith(`${q}:`)&&W0!==I)j.delete(W0);let w=await Bun.file(q).text(),D=w,T=W$(w);if(T)D=T.content.trim();let f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],v=[],S;while((S=f.exec(w))!==null){let W0=S[1],R=S[2],x=S[0];if(W0.includes("server"))v.push(R);else c.push(x)}let k=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],H0=D.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),G0={__filename:q,__dirname:I0.dirname(q),__stx_options:U};for(let W0 of v)await M0(W0,G0,q);let z0=await V0(H0,G0,q,U,new Set);if(k.length>0){let W0=k.join(`
2884
+ </html>`}function tX(){return"<!-- Hero section -->"}function eX(){return"<!-- Features -->"}function $Z(){return"<!-- Pricing -->"}function XZ(){return"<!-- Button -->"}function g1($){if(!v1($))j5($,{recursive:!0})}function ZZ(){if(v1("bun.lockb"))return"bun";if(v1("pnpm-lock.yaml"))return"pnpm";if(v1("yarn.lock"))return"yarn";return"bun"}function H5($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function QZ($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function e0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:YZ}=globalThis.Bun;import f1 from"fs";import I0 from"path";function h2($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function O5($){let{loadStxConfig:X}=await import("./chunk-7d74am4w.js");return{...await X($.configDir??process.cwd()),...$.stxOptions??{}}}async function JZ($={}){let{port:X=3000,root:Z=".",watch:Q=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=I0.resolve(Z),U=await O5($),F=I0.resolve($.configDir??process.cwd()),z=await A5(F,U.serverApi),j=new Map;async function H(q){let N=f1.statSync(q),I=`${q}:${N.mtimeMs}`,M=j.get(I);if(M)return{content:M.content,status:M.status,headers:M.headers};for(let W0 of j.keys())if(W0.startsWith(`${q}:`)&&W0!==I)j.delete(W0);let w=await Bun.file(q).text(),D=w,T=W$(w);if(T)D=T.content.trim();let f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],v=[],S;while((S=f.exec(w))!==null){let W0=S[1],R=S[2],x=S[0];if(W0.includes("server"))v.push(R);else c.push(x)}let k=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],H0=D.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),G0={__filename:q,__dirname:I0.dirname(q),__stx_options:U};for(let W0 of v)await M0(W0,G0,q);let z0=await V0(H0,G0,q,U,new Set);if(k.length>0){let W0=k.join(`
2885
2885
  `);if(z0.match(/(<\/head>)/i))z0=z0.replace(/(<\/head>)/i,`${W0}
2886
- $1`)}if(c.length>0){let{interpolateScriptsInTemplate:W0}=await import("./chunk-q2hvne0v.js"),R=W0(c.join(`
2886
+ $1`)}if(c.length>0){let{interpolateScriptsInTemplate:W0}=await import("./chunk-4np12rj1.js"),R=W0(c.join(`
2887
2887
  `),G0);if(z0.match(/(<\/body>)/i))z0=z0.replace(/(<\/body>)/i,`${R}
2888
2888
  $1`);else z0+=`
2889
2889
  ${R}`}let Z1=T1(G0),l$=C1(G0);return j.set(I,{content:z0,mtime:N.mtimeMs,status:Z1,headers:l$}),{content:z0,status:Z1,headers:l$}}async function L(q){let N=f1.statSync(q),I=`${q}:${N.mtimeMs}`,M=j.get(I);if(M)return M.content;let{content:w}=await T0(q,U);return j.set(I,{content:w,mtime:N.mtimeMs}),w}function O(q){let N=q.startsWith("/")?q.slice(1):q,I=[N,`${N}.stx`,`${N}.md`,`${N}.html`,I0.join(N,"index.stx"),I0.join(N,"index.md"),I0.join(N,"index.html")];for(let M of[_,...U._layerPageDirs??[]])for(let w of I){let D=I0.resolve(M,w);if(!D.startsWith(`${I0.resolve(M)}${I0.sep}`))continue;if(f1.existsSync(D)&&f1.statSync(D).isFile())return D}return null}async function A(q){if(U._layerGraph){let M=await O5($);if(M._layerGraph!==U._layerGraph)Object.assign(U,M),j.clear()}let N=new URL(q.url),I=async()=>{if(J[N.pathname])return await J[N.pathname](q);if(Y){let D=await Y(q);if(D)return D}if(U.apiRouter){let D=await U.apiRouter.handleRequest(q);if(D.status!==404)return D}if(U.apiRoutes?.[N.pathname])return U.apiRoutes[N.pathname](q);let M=await z(q);if(M)return M;let w=O(N.pathname);if(!w||U8(w,F,U.serverApi)){if(W)return await W(q);return new Response("Not Found",{status:404})}try{let D,T="text/html",f,c;if(w.endsWith(".stx")){let v=await H(w);D=v.content,f=v.status,c=v.headers}else if(w.endsWith(".md"))D=await L(w);else if(w.endsWith(".html"))D=await Bun.file(w).text();else if(w.endsWith(".css"))D=await Bun.file(w).text(),T="text/css";else if(w.endsWith(".js"))D=await Bun.file(w).text(),T="text/javascript";else if(w.endsWith(".json"))D=await Bun.file(w).text(),T="application/json";else return new Response(Bun.file(w));return new Response(D,{status:f??200,headers:{"Content-Type":T,...c}})}catch(D){if(K)return await K(D,q);let T=D instanceof Error?D.message:String(D),c=U?.debug===!0?`<h1>Error</h1><pre>${T}
@@ -4315,7 +4315,7 @@ else {
4315
4315
  \u26A0\uFE0F Built ${Z.views.length} views with ${Z.errors.length} errors`);return Z}function e_($,X){let Z=w$.watch($.viewsDir,{recursive:!0},async(Q,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
4316
4316
  File changed: ${Y}, rebuilding...`);let J=await TQ($);X?.(J)}});return{close:()=>Z.close()}}async function $9($,X={},Z={}){let Q={...Z,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await w7($,X,Q);Y=await CQ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b([^>]*)>[\s\S]*?<\/style>/gi,(G,W)=>/\bdata-(?:css=["']generated["']|stx-)/i.test(W)?"":G),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
4317
4317
 
4318
- `).trim();let J=xQ(Y);return{html:Y,text:J}}async function CQ($){try{let{generateCss:X,extractClassNames:Z}=await import("./chunk-k6ky5et7.js");if(Z($).size===0)return $;let Y=await X($);if(!Y)return $;let J=kQ(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let A of z){let V=J.get(A);if(V)j.push(V)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let H=j.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let A=`${H}; ${O[1]}`,V=K.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`),E=U.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`);return`${W}${V}class="${_}"${E}${F}`}return`${W}${K}class="${_}" style="${H}"${U}${F}`})}catch{return $}}function kQ($){let X=new Map,Z=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Q=Z.exec($);while(Q!==null){let Y=Q[1].replace(/\\/g,""),J=Q[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Q=Z.exec($)}return X}function xQ($){return $.replace(/<head\b[\s\S]*?<\/head>/gi,"").replace(/<(style|script)\b[\s\S]*?<\/\1>/gi,"").replace(/<(div|span|p)\b[^>]*\bstyle="[^"]*display:\s*none[^"]*"[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<br\s*\/?>/gi,`
4318
+ `).trim();let J=xQ(Y);return{html:Y,text:J}}async function CQ($){try{let{generateCss:X,extractClassNames:Z}=await import("./chunk-m1p2n3nf.js");if(Z($).size===0)return $;let Y=await X($);if(!Y)return $;let J=kQ(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let A of z){let V=J.get(A);if(V)j.push(V)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let H=j.join("; "),O=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(O){let A=`${H}; ${O[1]}`,V=K.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`),E=U.replace(/style\s*=\s*"[^"]*"/,`style="${A}"`);return`${W}${V}class="${_}"${E}${F}`}return`${W}${K}class="${_}" style="${H}"${U}${F}`})}catch{return $}}function kQ($){let X=new Map,Z=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Q=Z.exec($);while(Q!==null){let Y=Q[1].replace(/\\/g,""),J=Q[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Q=Z.exec($)}return X}function xQ($){return $.replace(/<head\b[\s\S]*?<\/head>/gi,"").replace(/<(style|script)\b[\s\S]*?<\/\1>/gi,"").replace(/<(div|span|p)\b[^>]*\bstyle="[^"]*display:\s*none[^"]*"[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<br\s*\/?>/gi,`
4319
4319
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
4320
4320
  `).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&copy;/g,"(c)").replace(/&middot;/g,"-").replace(/\n\s*\n\s*\n/g,`
4321
4321
 
@@ -4385,7 +4385,7 @@ ${I}`}function L0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").repla
4385
4385
  `;let Z=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
4386
4386
  `:"";if(X==="disallow")return["User-agent: *","Disallow: /","",Z].filter(Boolean).join(`
4387
4387
  `);return["User-agent: *","Allow: /","",Z].filter(Boolean).join(`
4388
- `)}var M1=null;async function eQ(){if(M1!==null)return M1;try{let $=await import("./chunk-9fcq5x2r.js");if(typeof $.getRouterScript==="function")M1=$.getRouterScript();else M1=""}catch{M1=""}return M1}async function h5($,X){let Z=await eQ();if(!Z)return $;let Q={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Q)};</script>
4388
+ `)}var M1=null;async function eQ(){if(M1!==null)return M1;try{let $=await import("./chunk-gz539gk6.js");if(typeof $.getRouterScript==="function")M1=$.getRouterScript();else M1=""}catch{M1=""}return M1}async function h5($,X){let Z=await eQ();if(!Z)return $;let Q={interceptAllLinks:!0,container:"main",...X},J=`${`<script>window.__stxRouterConfig=${JSON.stringify(Q)};</script>
4389
4389
  `}<script>${Z}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${J}
4390
4390
  </body>`);return`${$}
4391
4391
  ${J}`}var $Y=`window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};`,XY=($,X,Z,Q)=>`(function(){${$Y}function read(){try{var k=${JSON.stringify(X)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(Q)}:${JSON.stringify(Z)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,ZY=($,X,Z)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Z)}:${JSON.stringify(X)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;function P$($,X){if(X.theme===!1)return $;let Z=$.includes(m7),Q=typeof X.theme==="object"&&X.theme!==null?X.theme:{},Y=Q.default??"dark",J=Q.storageKey??"theme",G=Q.colors?.light??"#ffffff",W=Q.colors?.dark??"#000000";if(Y==="dark"&&!Z){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("data-stx-theme-meta")&&/<head\b[^>]*>/i.test($)){let K=['<meta name="color-scheme" content="dark light" data-stx-theme-meta="1">',`<meta name="theme-color" media="(prefers-color-scheme: light)" content="${G}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${W}" data-stx-theme-meta="1">`].join(`
@@ -299,4 +299,4 @@ catch (error) {
299
299
  }
300
300
  })();
301
301
  </script>`}var N={name:"pwa.installButton",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return H(j,q)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Q={name:"pwa.updatePrompt",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return J(j,q)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},T={name:"pwa.offlineIndicator",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return L(j,q)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},V={name:"pwa.pushSubscribe",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return M(j,q)},hasEndTag:!0,description:"Renders a push notification subscription button"},X=[N,Q,T,V];function Z(j){return[...j,...X]}
302
- export{N as jw,Q as kw,T as lw,V as mw,X as nw,Z as ow};
302
+ export{N as kw,Q as lw,T as mw,V as nw,X as ow,Z as pw};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Gp as b,Hp as c,Ip as d,Jp as e,lo as a}from"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{d as validateClientScript,c as processOnceDirective,b as processJsonDirective,e as processDirectives,a as injectRouterScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$u as o,Nu as a,Ou as b,Pu as c,Qu as d,Ru as e,Su as f,Tu as g,Uu as h,Vu as i,Wu as j,Xu as k,Yu as l,Zu as m,_u as n,av as p}from"./chunk-7r80apc5.js";import"./chunk-hyfjnn7g.js";export{i as useTitle,f as useSeoMeta,i as usePageTitle,d as useHead,g as seoMetaToHeadConfig,c as resetHead,k as renderHtmlAttrs,j as renderHead,l as renderBodyAttrs,o as processTitleDirective,p as processMetaDirective,n as processHeadDirective,e as mergeHeadConfigs,b as getPageMeta,a as getHead,h as definePageMeta,m as applyHead};
2
+ import{$u as o,Nu as a,Ou as b,Pu as c,Qu as d,Ru as e,Su as f,Tu as g,Uu as h,Vu as i,Wu as j,Xu as k,Yu as l,Zu as m,_u as n,av as p}from"./chunk-7r80apc5.js";import"./chunk-5g6rprcy.js";export{i as useTitle,f as useSeoMeta,i as usePageTitle,d as useHead,g as seoMetaToHeadConfig,c as resetHead,k as renderHtmlAttrs,j as renderHead,l as renderBodyAttrs,o as processTitleDirective,p as processMetaDirective,n as processHeadDirective,e as mergeHeadConfigs,b as getPageMeta,a as getHead,h as definePageMeta,m as applyHead};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Gu as a,Hu as b,Iu as c,Ju as d,Ku as e,Lu as f,Mu as g}from"./chunk-vvd659y4.js";import"./chunk-hyfjnn7g.js";export{a as withRuntimeConfig,c as useServerRuntimeConfig,d as useRuntimeConfig,f as runtimeConfigTag,e as resolveRuntimeConfig,g as injectRuntimeConfig,b as currentRuntimeConfig};
2
+ import{Ct as a,Dt as b,Et as c,Ft as d,Gt as e,Ht as f,It as g}from"./chunk-k3dtvay1.js";import"./chunk-5g6rprcy.js";export{a as withRuntimeConfig,c as useServerRuntimeConfig,d as useRuntimeConfig,f as runtimeConfigTag,e as resolveRuntimeConfig,g as injectRuntimeConfig,b as currentRuntimeConfig};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{sw as l}from"./chunk-hyfjnn7g.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
2
+ import{tw as l}from"./chunk-5g6rprcy.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
3
3
  export{d as Af,h as Bf,b as Cf,e as Df,t as Ef,JJ as Ff,O as Gf,n as Hf,KJ as If,ZJ as Jf,$J as Kf,qJ as Lf,CJ as Mf,QJ as Nf,VJ as Of,XJ as Pf,L as Qf};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Jt as a,Kt as b,Lt as c,Mt as d,Nt as e,Ot as f,Pt as g,Qt as h,Rt as i,St as j,Tt as k,Ut as l}from"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-5g6rprcy.js";export{f as structuredDataDirective,j as scanForSitemapEntries,g as registerSeoDirectives,b as processStructuredData,c as processSeoDirective,a as processMetaDirectives,e as metaDirective,d as injectSeoTags,i as generateSitemapIndex,h as generateSitemap,k as generateRobotsTxt,l as generateDefaultRobotsTxt};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Le as c,Me as d,Ne as e,Oe as f,Pe as g,Qe as h}from"./chunk-5r7gfwpj.js";import"./chunk-zye9r15n.js";import"./chunk-7we3xfde.js";import{Kp as a,Np as b}from"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{d as virtualPathFor,g as typecheckStxFiles,e as sourcePathFor,h as formatTypecheckDiagnostics,f as findRuntimeTypeDeclarations,b as extractTemplateExpressions,a as extractScriptBlocks,c as buildVirtualSource};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ah as v,Bh as P,th as x,yh as M,zh as C}from"./chunk-vd5xvsnv.js";import{sw as y}from"./chunk-hyfjnn7g.js";import{resolve as h,basename as f,extname as u,join as m}from"path";import{mkdir as l}from"fs/promises";var I={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0};class z{config;constructor(J={}){this.config={...I,...J}}async get(J,Z){return C(J,Z,"image",this.config)}async set(J,Z,Y){return v(J,Z,Y,"image",this.config)}async clear(){return P("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}var H=null;function S(J){if(!H)H=new z(J);else if(J)H.updateConfig(J);return H}async function w(J,Z,Y){let K=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S(K).get(J,Z)}async function Q(J,Z,Y,K){let X=K?{directory:`${K.outputDir}/../.cache`}:{};return S(X).set(J,Z,Y)}async function d(){return S().clear()}async function R(){try{return await import("ts-images")}catch{return null}}function b(J){switch(J){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function p(J,Z){let Y=Z?b(Z):b("web"),K=J.formatQuality||{};return{jpeg:{...Y.jpeg,...K.jpeg},png:{...Y.png,...K.png},webp:{...Y.webp,...K.webp},avif:{...Y.avif,...K.avif}}}async function g(J,Z,Y){let K=await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let X=await w(J,Z,Y);if(X)return X;try{let N=h(J);if(!await M(N))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let L=p(Y,Z.preset),V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await l(V,{recursive:!0});let q=await x(N),U=f(J,u(J)),E=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],G={src:J,processed:!0,variants:[],hash:q},j=null;if(Z.transformations&&Z.transformations.length>0)j=await D(N,Z.transformations,K);for(let $ of E){let A=L[$]||{},W=`${U}-${q}.${$}`,_=m(V,W);try{let O=await K.optimizeImage({input:j||N,output:_,format:$,quality:A.quality,progressive:A.progressive});if(O){if(G.variants.push({path:_,url:`${F}/${W}`,width:O.width||0,height:O.height||0,format:$,size:O.outputSize||0}),!G.originalWidth&&O.width)G.originalWidth=O.width,G.originalHeight=O.height}}catch(O){G.errors=G.errors||[],G.errors.push(`Failed to optimize ${$}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let $=await K.generateThumbHash(N);G.placeholder=$.dataUrl}catch($){G.errors=G.errors||[],G.errors.push(`Failed to generate thumbhash: ${$}`)}if(Z.useDominantColor)try{let $=await K.generatePlaceholder(N,{strategy:"dominant-color"});G.dominantColor=$.dominantColor}catch($){G.errors=G.errors||[],G.errors.push(`Failed to extract dominant color: ${$}`)}return await Q(J,Z,G,Y),G}catch(N){return{src:J,processed:!1,errors:[`Processing failed: ${N}`]}}}async function n(J,Z,Y,K){let X=await R();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:J,output:K,format:Z,quality:Y}))?.outputSize}}catch(N){return{success:!1,error:String(N)}}}async function D(J,Z,Y){let K=Y||await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await K.decode(J);for(let N of Z){let L=N.options||{};switch(N.type){case"resize":if(L.width||L.height)X=await K.resize(X,{width:L.width,height:L.height,fit:L.fit});break;case"blur":if(L.sigma!==void 0)X=await K.blur(X,L.sigma);break;case"sharpen":if(L.amount!==void 0)X=await K.sharpen(X,L.amount);break;case"grayscale":X=await K.grayscale(X);break;case"rotate":if(L.angle!==void 0)X=await K.rotate(X,L.angle);break;case"flip":X=await K.flip(X);break;case"flop":X=await K.flop(X);break;case"brightness":if(L.value!==void 0)X=await K.brightness(X,L.value);break;case"contrast":if(L.value!==void 0)X=await K.contrast(X,L.value);break;case"saturation":if(L.value!==void 0)X=await K.saturation(X,L.value);break}}return await K.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}import{resolve as c,basename as i,extname as r,join as o}from"path";import{mkdir as a}from"fs/promises";async function e(){try{return await import("ts-images")}catch{return null}}var s=[320,480,640,768,1024,1280,1536,1920];async function t(J,Z,Y){let K=await e();if(!K)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=c(J);if(!await M(X))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let N=Z.responsiveWidths||Y.breakpoints||s,L=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await a(V,{recursive:!0});let q=await x(X),U=i(J,r(J)),E=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},G={src:J,byFormat:{},srcsets:{}};for(let $ of L){G.byFormat[$]=[];let A=[];for(let W of N){let _=`${U}-${W}w-${q}.${$}`,O=o(V,_),B=`${F}/${_}`;try{let T=E[$]?.quality||80;if(await M(O)){G.byFormat[$].push({path:O,url:B,width:W,height:0,format:$,size:0}),A.push(`${B} ${W}w`);continue}let k=await K.processImage({input:X,output:O,format:$,quality:T,resize:{width:W}});if(k)G.byFormat[$].push({path:O,url:B,width:W,height:k.height||Math.round(W*(k.height||1)/(k.width||1)),format:$,size:k.outputSize||0}),A.push(`${B} ${W}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${$} at ${W}w: ${T}`)}}G.srcsets[$]=A.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let $=await K.generateThumbHash(X);G.placeholder={dataURL:$.dataUrl,width:$.width||32,height:$.height||32,strategy:"thumbhash"}}else{let $=await K.generatePlaceholder(X,{strategy:j,width:20});G.placeholder={dataURL:$.dataURL,width:$.width,height:$.height,strategy:j}}}catch($){console.warn(`[stx-media] Failed to generate placeholder: ${$}`)}return G.sizes=Z.sizes||JJ(N),G}catch(N){return console.error(`[stx-media] Responsive generation failed: ${N}`),null}}function JJ(J){let Z=[...J].sort((K,X)=>K-X),Y=[];for(let K=0;K<Z.length-1;K++){let X=Z[K];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function KJ(J,Z="width"){if(!J||J.length===0)return"";if(Z==="dpr")return J.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return J.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}export{z as $g,w as ah,Q as bh,d as ch,g as dh,n as eh,D as fh,t as gh,KJ as hh};
2
+ import{ih as x,nh as M,oh as C,ph as v,qh as P}from"./chunk-18018jkn.js";import{tw as y}from"./chunk-5g6rprcy.js";import{resolve as h,basename as f,extname as u,join as m}from"path";import{mkdir as l}from"fs/promises";var I={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0};class z{config;constructor(J={}){this.config={...I,...J}}async get(J,Z){return C(J,Z,"image",this.config)}async set(J,Z,Y){return v(J,Z,Y,"image",this.config)}async clear(){return P("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}var H=null;function S(J){if(!H)H=new z(J);else if(J)H.updateConfig(J);return H}async function w(J,Z,Y){let K=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S(K).get(J,Z)}async function Q(J,Z,Y,K){let X=K?{directory:`${K.outputDir}/../.cache`}:{};return S(X).set(J,Z,Y)}async function d(){return S().clear()}async function R(){try{return await import("ts-images")}catch{return null}}function b(J){switch(J){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function p(J,Z){let Y=Z?b(Z):b("web"),K=J.formatQuality||{};return{jpeg:{...Y.jpeg,...K.jpeg},png:{...Y.png,...K.png},webp:{...Y.webp,...K.webp},avif:{...Y.avif,...K.avif}}}async function g(J,Z,Y){let K=await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let X=await w(J,Z,Y);if(X)return X;try{let N=h(J);if(!await M(N))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let L=p(Y,Z.preset),V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await l(V,{recursive:!0});let q=await x(N),U=f(J,u(J)),E=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],G={src:J,processed:!0,variants:[],hash:q},j=null;if(Z.transformations&&Z.transformations.length>0)j=await D(N,Z.transformations,K);for(let $ of E){let A=L[$]||{},W=`${U}-${q}.${$}`,_=m(V,W);try{let O=await K.optimizeImage({input:j||N,output:_,format:$,quality:A.quality,progressive:A.progressive});if(O){if(G.variants.push({path:_,url:`${F}/${W}`,width:O.width||0,height:O.height||0,format:$,size:O.outputSize||0}),!G.originalWidth&&O.width)G.originalWidth=O.width,G.originalHeight=O.height}}catch(O){G.errors=G.errors||[],G.errors.push(`Failed to optimize ${$}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let $=await K.generateThumbHash(N);G.placeholder=$.dataUrl}catch($){G.errors=G.errors||[],G.errors.push(`Failed to generate thumbhash: ${$}`)}if(Z.useDominantColor)try{let $=await K.generatePlaceholder(N,{strategy:"dominant-color"});G.dominantColor=$.dominantColor}catch($){G.errors=G.errors||[],G.errors.push(`Failed to extract dominant color: ${$}`)}return await Q(J,Z,G,Y),G}catch(N){return{src:J,processed:!1,errors:[`Processing failed: ${N}`]}}}async function n(J,Z,Y,K){let X=await R();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:J,output:K,format:Z,quality:Y}))?.outputSize}}catch(N){return{success:!1,error:String(N)}}}async function D(J,Z,Y){let K=Y||await R();if(!K)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await K.decode(J);for(let N of Z){let L=N.options||{};switch(N.type){case"resize":if(L.width||L.height)X=await K.resize(X,{width:L.width,height:L.height,fit:L.fit});break;case"blur":if(L.sigma!==void 0)X=await K.blur(X,L.sigma);break;case"sharpen":if(L.amount!==void 0)X=await K.sharpen(X,L.amount);break;case"grayscale":X=await K.grayscale(X);break;case"rotate":if(L.angle!==void 0)X=await K.rotate(X,L.angle);break;case"flip":X=await K.flip(X);break;case"flop":X=await K.flop(X);break;case"brightness":if(L.value!==void 0)X=await K.brightness(X,L.value);break;case"contrast":if(L.value!==void 0)X=await K.contrast(X,L.value);break;case"saturation":if(L.value!==void 0)X=await K.saturation(X,L.value);break}}return await K.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}import{resolve as c,basename as i,extname as r,join as o}from"path";import{mkdir as a}from"fs/promises";async function e(){try{return await import("ts-images")}catch{return null}}var s=[320,480,640,768,1024,1280,1536,1920];async function t(J,Z,Y){let K=await e();if(!K)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=c(J);if(!await M(X))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let N=Z.responsiveWidths||Y.breakpoints||s,L=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],V=Y.outputDir||"dist/images",F=Y.baseUrl||"/images";await a(V,{recursive:!0});let q=await x(X),U=i(J,r(J)),E=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},G={src:J,byFormat:{},srcsets:{}};for(let $ of L){G.byFormat[$]=[];let A=[];for(let W of N){let _=`${U}-${W}w-${q}.${$}`,O=o(V,_),B=`${F}/${_}`;try{let T=E[$]?.quality||80;if(await M(O)){G.byFormat[$].push({path:O,url:B,width:W,height:0,format:$,size:0}),A.push(`${B} ${W}w`);continue}let k=await K.processImage({input:X,output:O,format:$,quality:T,resize:{width:W}});if(k)G.byFormat[$].push({path:O,url:B,width:W,height:k.height||Math.round(W*(k.height||1)/(k.width||1)),format:$,size:k.outputSize||0}),A.push(`${B} ${W}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${$} at ${W}w: ${T}`)}}G.srcsets[$]=A.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let $=await K.generateThumbHash(X);G.placeholder={dataURL:$.dataUrl,width:$.width||32,height:$.height||32,strategy:"thumbhash"}}else{let $=await K.generatePlaceholder(X,{strategy:j,width:20});G.placeholder={dataURL:$.dataURL,width:$.width,height:$.height,strategy:j}}}catch($){console.warn(`[stx-media] Failed to generate placeholder: ${$}`)}return G.sizes=Z.sizes||JJ(N),G}catch(N){return console.error(`[stx-media] Responsive generation failed: ${N}`),null}}function JJ(J){let Z=[...J].sort((K,X)=>K-X),Y=[];for(let K=0;K<Z.length-1;K++){let X=Z[K];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function KJ(J,Z="width"){if(!J||J.length===0)return"";if(Z==="dpr")return J.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return J.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}export{z as Qg,w as Rg,Q as Sg,d as Tg,g as Ug,n as Vg,D as Wg,t as Xg,KJ as Yg};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Cl as WJ}from"./chunk-p1hy2bwn.js";import{Dr as zJ,Er as XJ,hm as GJ}from"./chunk-kxtqbrfr.js";import{ot as ZJ,pt as $J}from"./chunk-nat3actx.js";import{Ct as QJ,Gt as u}from"./chunk-kffndzch.js";import{Cu as c}from"./chunk-gptwwv3c.js";import X from"path";import O from"fs";function wJ(J){if(!J||typeof J!=="object")return!1;let K=J;return typeof K.message==="string"&&(K.name==="BuildMessage"||K.name==="ResolveMessage"||("position"in K))}function UJ(J){if(J&&typeof J==="object"&&Array.isArray(J.errors))return J.errors;return[J]}function b(J,K){let $=[];for(let W of UJ(J)){if(wJ(W)){let Y=W.position||void 0;$.push({file:K||Y?.file,line:Y?.line,column:Y?.column,message:W.message??"",lineText:Y?.lineText});continue}$.push({file:K,message:W instanceof Error?W.message:String(W)})}return $}function t(J,K){return b(J,K).map(($)=>{let W=$.file?`${$.file}${$.line?`:${$.line}${$.column?`:${$.column}`:""}`:""}`:"",Y=$.lineText?`
2
+ import{rl as WJ}from"./chunk-1yj4xd6n.js";import{Yl as GJ,rr as zJ,sr as XJ}from"./chunk-e3rgky2r.js";import{ks as ZJ,ls as $J}from"./chunk-hrdd26r4.js";import{Es as QJ,Is as u}from"./chunk-nhbc464j.js";import{mt as c}from"./chunk-vaggjvsm.js";import X from"path";import O from"fs";function wJ(J){if(!J||typeof J!=="object")return!1;let K=J;return typeof K.message==="string"&&(K.name==="BuildMessage"||K.name==="ResolveMessage"||("position"in K))}function UJ(J){if(J&&typeof J==="object"&&Array.isArray(J.errors))return J.errors;return[J]}function b(J,K){let $=[];for(let W of UJ(J)){if(wJ(W)){let Y=W.position||void 0;$.push({file:K||Y?.file,line:Y?.line,column:Y?.column,message:W.message??"",lineText:Y?.lineText});continue}$.push({file:K,message:W instanceof Error?W.message:String(W)})}return $}function t(J,K){return b(J,K).map(($)=>{let W=$.file?`${$.file}${$.line?`:${$.line}${$.column?`:${$.column}`:""}`:""}`:"",Y=$.lineText?`
3
3
  ${$.lineText.trim()}`:"";return W?`${W}: ${$.message}${Y}`:`${$.message}${Y}`}).join(`
4
4
  `)}var LJ=9;function P(J,K,$){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(X.basename(J))||WJ(J,K,$)}var YJ=1,HJ=new Map,f=600,TJ=100,g=new Map;async function AJ(J){let K=g.get(J)??0;if(K>0&&K<TJ){g.set(J,K+1);return}g.set(J,1);try{let $=(await O.promises.readdir(J)).filter((z)=>z.endsWith(".js"));if($.length<=f)return;let Y=(await Promise.all($.map(async(z)=>{try{return{name:z,at:(await O.promises.stat(X.join(J,z))).mtimeMs}}catch{return null}}))).filter((z)=>z!==null);Y.sort((z,H)=>H.at-z.at);for(let z of Y.slice(f)){let H=z.name.slice(0,-3);await O.promises.rm(X.join(J,`${H}.js`),{force:!0}),await O.promises.rm(X.join(J,`${H}.deps.json`),{force:!0})}x("pruned bundle cache to",f,"entries")}catch{}}function pJ(J){return HJ.get(J)??[]}function h(J,K){if(J)HJ.set(J,K)}function MJ(J=process.env){return J.STX_DEBUG==="true"||J.STX_DEBUG==="1"}function x(...J){if(MJ())console.log("[stx:bundler]",...J)}var n=[];function r(J,K,$){n.push({filePath:J||"<inline>",message:K,details:$})}function cJ(){return n.slice()}function nJ(){n.length=0}var p;function oJ(J){p=J}function a(){if(p)return p;try{let J=XJ.strict;return typeof J==="object"&&J!==null?J.bundlerFallback??"warn":"warn"}catch{return"warn"}}var e=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function lJ(J){let K=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,$;while(($=K.exec(J))!==null){let Y=$[1];if(!e.some((H)=>H.test(Y)))return x("detected user import:",Y),!0}let W=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while(($=W.exec(J))!==null){let Y=$[1];if(/\.css(?:\?.*)?$/.test(Y))continue;if(!e.some((H)=>H.test(Y)))return x("detected side-effect import:",Y),!0}return!1}var v="stx-module:",CJ=/\.(?:[cm]?[jt]sx?|json)$/i;function xJ(J,K){return X.relative(J,K).split(X.sep).join("/")}function IJ(J,K){if(K.size===0)return J;return J.replace(/^([ \t]*import\s+(?:[^;"']*?\s+from\s+)?)(["'])([^"']+)\2/gm,($,W,Y,z)=>{let H=K.get(z);return H&&!z.startsWith(v)?`${W}${Y}${H}${Y}`:$})}function _J(J,K){let $=0,W=(z)=>{let H=`__stxMod${$++}`,j=JSON.stringify(z);return K.push(`var ${H} = globalThis.__stxModules && globalThis.__stxModules[${j}];`,`if (${H} === undefined) throw new Error("[stx] module " + ${JSON.stringify(j)} + " is not registered on this page (#1957)");`),H},Y=(z,H)=>{for(let j of z.split(",")){let T=j.trim();if(!T)continue;let Q=T.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!Q)continue;let Z=Q[1].startsWith('"')?JSON.parse(Q[1]):Q[1],G=Q[2]??Z;K.push(`var ${G} = ${H}[${JSON.stringify(Z)}];`)}};return J=J.replace(/^[ \t]*import\s+([^;"']*?)\s+from\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(z,H,j)=>{let T=j.slice(v.length),Q=W(T),Z=H.trim(),G=Z.match(/^([\w$]+)\s*(?:,\s*|$)/);if(G&&!Z.startsWith("{")&&!Z.startsWith("*"))K.push(`var ${G[1]} = ${Q}.default;`),Z=Z.slice(G[0].length).trim();let q=Z.match(/^\*\s*as\s+([\w$]+)$/);if(q)K.push(`var ${q[1]} = ${Q};`);else if(Z.startsWith("{"))Y(Z.replace(/^\{|\}$/g,""),Q);return""}),J=J.replace(/^[ \t]*import\s+["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(z,H)=>{return W(H.slice(v.length)),""}),J}function JJ(J){let K=[J,`${J}.ts`,`${J}.tsx`,`${J}.js`,`${J}.mjs`,`${J}.jsx`,X.join(J,"index.ts"),X.join(J,"index.tsx"),X.join(J,"index.js"),X.join(J,"index.mjs")];for(let $ of K)try{if(O.existsSync($)&&O.statSync($,{throwIfNoEntry:!1})?.isFile())return $}catch{}return}function NJ(J,K,$,W,Y,z=new Map,H){let j=(Q,Z,G)=>{if(P(Z,J,H))return null;if(!Y||Q!==$||!CJ.test(Z))return null;try{if(!O.statSync(Z,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}W.add(Z);let q=`${v}${xJ(process.cwd(),Z)}`;return z.set(G,q),{path:q,external:!0}},T=(Q,Z)=>{let G=Q===$?K:X.dirname(Q),q=X.resolve(G,Z);return JJ(q)??q};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(Z)=>({path:Z.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(Z)=>({path:Z.path,external:!0})),Q.onResolve({filter:/^\//},(Z)=>{let G=JJ(Z.path);if(G){let q=j(Z.importer,G,Z.path);if(q)return q;if(G!==$)W.add(G);return{path:G}}return{path:Z.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(Z)=>{let G=T(Z.importer,Z.path),q=j(Z.importer,G,Z.path);if(q)return q;return W.add(G),{path:G}}),Q.onResolve({filter:/^[@~]\//},(Z)=>{let G=X.resolve(J,Z.path.slice(2)),q=[G,`${G}.ts`,`${G}.tsx`,`${G}.js`,`${G}.mjs`,`${G}.jsx`,X.join(G,"index.ts"),X.join(G,"index.tsx"),X.join(G,"index.js"),X.join(G,"index.mjs")];for(let w of q)if(O.existsSync(w)&&O.statSync(w,{throwIfNoEntry:!1})?.isFile()){let y=j(Z.importer,w,Z.path);if(y)return y;return x(`resolved ${Z.path[0]}/ import:`,Z.path,"\u2192",w),W.add(w),{path:w}}return console.warn(`[stx:bundler] could not resolve ${Z.path[0]}/ import:`,Z.path),{path:G}}),Q.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(Z)=>{if(!Y||Z.importer!==$)return;let G=`${v}npm:${Z.path}`;return z.set(Z.path,G),{path:G,external:!0}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(Z)=>{if(P(Z.path,J,H))throw Error(`Server-only API source cannot be imported by a client script: ${Z.path}`);let G=X.extname(Z.path).toLowerCase(),q=G===".json"?"json":G===".tsx"?"tsx":G===".jsx"?"jsx":G===".ts"||G===".mts"||G===".cts"?"ts":"js";if(Z.path!==$)W.add(Z.path);return{contents:O.readFileSync(Z.path,"utf8"),loader:q}})}}}var m=new Map,D=QJ(64),KJ=Symbol.for("stx.client-bundle-build-queue");function SJ(J){let K=globalThis,W=(K[KJ]??Promise.resolve()).then(J,J);return K[KJ]=W.then(()=>{return},()=>{return}),W}async function dJ(J,K,$={}){let W=$.projectRoot||process.cwd(),Y=(await zJ(W)).serverApi,z=$.minify??!1,H=$.externalizeUserModules??!0,j=$.cacheDir||c(W,"bundle-cache"),T=new Bun.CryptoHasher("md5");T.update(`${LJ}\x00${JSON.stringify(Y??!1)}\x00${H?"registry":"inline"}\x00${J}\x00${K}`);let Q=T.digest("hex").slice(0,12),Z=X.join(j,`${Q}.js`),G=D.get(Z);if(G){if(u(G.files)&&G.files.every((A)=>!P(A.path,W,Y))){x("memo hit:",Q);let A=G.files.map((M)=>M.path);return h(K,A),$.collectInputs?.push(...A),G.code}D.delete(Z),x("memo invalidated by dep change:",Q)}let q=X.join(j,`${Q}.deps.json`),w=Bun.file(Z);if(await w.exists()){let A=Bun.file(q),M=!1,U=null;if(await A.exists())try{let N=JSON.parse(await A.text());if(N.metadataVersion!==YJ||!Array.isArray(N.files))M=!1;else U=N.files,M=!0;if(U&&(!u(U)||U.some((B)=>P(B.path,W,Y))))M=!1}catch{M=!1}if(M){if(x("cache hit:",Q),U)h(K,U.map((B)=>B.path)),$.collectInputs?.push(...U.map((B)=>B.path));let N=await w.text();if(U)D.set(Z,{code:N,files:U});return N}x("cache invalidated by dep change:",Q)}let y=m.get(Q);if(y){let A=await y;if($.collectInputs)$.collectInputs.push(...(D.get(Z)?.files??[]).map((M)=>M.path));return A}let I=SJ(()=>RJ(J,K,{projectRoot:W,minify:z,cacheDir:j,hash:Q,cachePath:Z,depsPath:q,collectInputs:$.collectInputs,externalizeUserModules:H,serverApi:Y}));m.set(Q,I);try{return await I}finally{m.delete(Q)}}var yJ=0;function BJ(J){return`${J}-${process.pid}-${++yJ}`}async function RJ(J,K,$){let{projectRoot:W,minify:Y,cacheDir:z,hash:H,cachePath:j,depsPath:T,externalizeUserModules:Q}=$,Z=c(W,"bundle-tmp"),G=BJ(H),q=X.join(Z,`${G}.ts`),w=X.join(Z,"out",G);O.mkdirSync(Z,{recursive:!0}),O.mkdirSync(w,{recursive:!0});let y=X.dirname(K),I=new Set,A=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,M=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,U=ZJ(J),{depths:N,balanced:B}=$J(U),o=(L)=>!B||N[L]===0,C;while((C=A.exec(U))!==null){if(C[1])continue;if(!o(C.index))continue;if(C[2])C[2].split(",").forEach((L)=>{let k=FJ(L);if(k)I.add(k)});else if(C[3])I.add(C[3])}while((C=M.exec(U))!==null){if(C[1])continue;if(!o(C.index))continue;I.add(C[2])}let qJ=I.size>0?`
5
5
  export { ${[...I].join(", ")} }`:"";await Bun.write(q,J+qJ),x("bundling:",H,"from:",X.basename(K));let l=new Set,d=new Map;try{let L=await Bun.build({entrypoints:[q],outdir:w,target:"browser",format:"esm",minify:Y,plugins:[NJ(W,y,q,l,Q,d,$.serverApi)],define:{"process.env.NODE_ENV":Y?'"production"':'"development"',...GJ()},root:W});if(!L.success){let S=L.logs.filter((R)=>R.level==="error").map((R)=>R.message).join(", ")||`Unable to bundle ${X.basename(K)}`,F=b(L.logs,K||void 0);if(console.warn("[stx:bundler] build failed:",S),r(K||"",S,F),a()==="error")throw Error(S);return J}let k="";for(let V of L.outputs){k=await V.text();break}let _=[];for(let V of k.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let S of V[1].split(",")){let F=S.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(F){_.push([F[2],F[1]]);continue}let R=S.trim();if(/^[A-Za-z_$][\w$]*$/.test(R))_.push([R,R])}let i=[];k=_J(IJ(k,d),i);let VJ=k.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];k=k.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let s=`__stxBundle_${H}`,kJ=_.map(([V,S])=>`${JSON.stringify(V)}: ${S}`).join(", "),jJ=_.map(([V])=>`var ${V} = undefined;`).join(`
@@ -14,4 +14,4 @@ ${k}
14
14
  return { ${kJ} };
15
15
  })();
16
16
  ${OJ}`.trim(),x("bundled:",H,"output:",k.length,"bytes"),I.size>0&&_.length===0)return console.warn(`[stx:bundler] dropped every binding for ${X.basename(K)} (${H}); serving the unbundled source and not caching this result`),J;O.mkdirSync(z,{recursive:!0}),await Bun.write(j,k);let E=Array.from(l).map((V)=>{try{return{path:V,mtimeMs:O.statSync(V).mtimeMs}}catch{return null}}).filter((V)=>V!==null);return await Bun.write(T,JSON.stringify({metadataVersion:YJ,files:E})),h(K,E.map((V)=>V.path)),$.collectInputs?.push(...E.map((V)=>V.path)),D.set(j,{code:k,files:E}),await AJ(z),k}catch(L){let k=b(L,K||void 0),_=t(L,K||void 0);if(console.warn(`[stx:bundler] error: ${_}`),r(K||"",_,k),a()==="error")throw L;return J}finally{try{O.rmSync(q,{force:!0}),O.rmSync(w,{recursive:!0,force:!0})}catch{}}}function FJ(J){let K=J.trim();if(!K)return null;let $=K.indexOf("=");if($!==-1)K=K.slice(0,$).trim();let W=K.indexOf(":");if(W!==-1)K=K.slice(W+1).trim();if(K.startsWith("..."))K=K.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(K)?K:null}
17
- export{t as gl,pJ as hl,MJ as il,r as jl,cJ as kl,nJ as ll,oJ as ml,a as nl,lJ as ol,v as pl,xJ as ql,IJ as rl,_J as sl,SJ as tl,dJ as ul,BJ as vl};
17
+ export{t as Xk,pJ as Yk,MJ as Zk,r as _k,cJ as $k,nJ as al,oJ as bl,a as cl,lJ as dl,v as el,xJ as fl,IJ as gl,_J as hl,SJ as il,dJ as jl,BJ as kl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ek as a,Fk as b,Gk as c,Hk as d,Ik as e}from"./chunk-9btdax2s.js";import"./chunk-5g6rprcy.js";export{d as runPwaAudit,e as formatAuditResult,c as calculateAuditResult,a as auditConfig,b as auditBuildOutput};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Re as a,Se as b}from"./chunk-2ver2s2y.js";import"./chunk-hyfjnn7g.js";export{b as captureScreenshots,a as captureScreenshot};
2
+ import{Re as a,Se as b}from"./chunk-2ver2s2y.js";import"./chunk-5g6rprcy.js";export{b as captureScreenshots,a as captureScreenshot};