@stacksjs/stx 0.2.901 → 0.2.903

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 (90) hide show
  1. package/dist/chunk-0xdp4nmv.js +2 -0
  2. package/dist/{chunk-xk1pht3a.js → chunk-13awfbbk.js} +1 -1
  3. package/dist/{chunk-9gjt51ac.js → chunk-21fdsmw9.js} +1 -1
  4. package/dist/{chunk-ybpxtaft.js → chunk-23b4mc1y.js} +2 -2
  5. package/dist/{chunk-ccgcj9tg.js → chunk-2krq2rdd.js} +1 -1
  6. package/dist/chunk-2v6p4eq2.js +3 -0
  7. package/dist/{chunk-mmtyp5z4.js → chunk-31r1tk86.js} +1 -1
  8. package/dist/{chunk-g4cs4dj8.js → chunk-34gnndgr.js} +2 -2
  9. package/dist/chunk-4nk3vdfy.js +2 -0
  10. package/dist/{chunk-ek4prrmd.js → chunk-4rdypyt9.js} +5 -5
  11. package/dist/{chunk-1fxq73hk.js → chunk-4t8p7ze1.js} +1 -1
  12. package/dist/{chunk-p80nnmha.js → chunk-4w4zjtp7.js} +6 -6
  13. package/dist/{chunk-6fv02vzc.js → chunk-58edra58.js} +1 -1
  14. package/dist/{chunk-0tzyr4cc.js → chunk-58q8qp81.js} +1 -1
  15. package/dist/{chunk-xf2jf63c.js → chunk-5mgn5hcm.js} +1 -1
  16. package/dist/{chunk-krdhn8h1.js → chunk-64x8sy0h.js} +1 -1
  17. package/dist/{chunk-e42x1k6j.js → chunk-70ysyphk.js} +1 -1
  18. package/dist/{chunk-kxbk4505.js → chunk-779xh5pq.js} +1 -1
  19. package/dist/{chunk-q3we5jsk.js → chunk-77a17bbm.js} +1 -1
  20. package/dist/{chunk-7pfhr4nk.js → chunk-7nf7mp27.js} +1 -1
  21. package/dist/{chunk-gypna2zb.js → chunk-9578r5x8.js} +2 -2
  22. package/dist/{chunk-5hksy9tt.js → chunk-9dbxjbzm.js} +1 -1
  23. package/dist/{chunk-03ymcxsb.js → chunk-9j2gt1ad.js} +1 -1
  24. package/dist/chunk-9y83pdcb.js +4 -0
  25. package/dist/{chunk-qgcw5jy8.js → chunk-axhcq68w.js} +1 -1
  26. package/dist/{chunk-vtan6nan.js → chunk-b5bwaety.js} +2 -2
  27. package/dist/{chunk-c0x9wyj7.js → chunk-bgkj0rxe.js} +1 -1
  28. package/dist/{chunk-6cnahhm1.js → chunk-bk5wwfe0.js} +1 -1
  29. package/dist/{chunk-9ehryt4w.js → chunk-bkqdgry9.js} +1 -1
  30. package/dist/chunk-btf1dr5t.js +2 -0
  31. package/dist/{chunk-frjpvdxn.js → chunk-bvkmrpk9.js} +1 -1
  32. package/dist/{chunk-ysncnbyf.js → chunk-bx5qk65w.js} +1 -1
  33. package/dist/{chunk-yf715phy.js → chunk-c0raqq4e.js} +1 -1
  34. package/dist/{chunk-ecknsnr2.js → chunk-cpjfv0e6.js} +1 -1
  35. package/dist/{chunk-235fkffb.js → chunk-cr3dbyaz.js} +1 -1
  36. package/dist/{chunk-e23yc82s.js → chunk-cyj7jpxj.js} +4 -4
  37. package/dist/chunk-d0hyg0rp.js +2 -0
  38. package/dist/{chunk-kmby9q2c.js → chunk-dbxby7r4.js} +2 -2
  39. package/dist/chunk-dhs9jqk4.js +2 -0
  40. package/dist/{chunk-4s6w89m2.js → chunk-dw23nre3.js} +1 -1
  41. package/dist/{chunk-yjs11rre.js → chunk-exptddjc.js} +1 -1
  42. package/dist/{chunk-ntvgvvrh.js → chunk-f50a18t8.js} +1 -1
  43. package/dist/{chunk-hg31hs5d.js → chunk-fxxw0t9j.js} +2 -2
  44. package/dist/{chunk-h1bd9496.js → chunk-g1yby51k.js} +1 -1
  45. package/dist/{chunk-e9nyfgwk.js → chunk-haq18q78.js} +1 -1
  46. package/dist/{chunk-pms1q3c6.js → chunk-hmjmvsz2.js} +1 -1
  47. package/dist/{chunk-5qkd77vw.js → chunk-jrv3xr72.js} +1 -1
  48. package/dist/{chunk-v35zj9fq.js → chunk-k7vz4sw7.js} +1 -1
  49. package/dist/chunk-kf6j1ht4.js +2 -0
  50. package/dist/{chunk-bts9v10s.js → chunk-mazr2nt7.js} +1 -1
  51. package/dist/{chunk-ndwvgwvs.js → chunk-mwrwh6d7.js} +2 -2
  52. package/dist/{chunk-6d10g8wf.js → chunk-n969kmxp.js} +1 -1
  53. package/dist/{chunk-yar3c574.js → chunk-nddkrbz4.js} +4 -4
  54. package/dist/{chunk-95tvzssr.js → chunk-pmwe0mmq.js} +1 -1
  55. package/dist/{chunk-pgqennwt.js → chunk-pnsw10w9.js} +1 -1
  56. package/dist/{chunk-9mjr6187.js → chunk-qyk29egd.js} +1 -1
  57. package/dist/{chunk-a7x8897c.js → chunk-raqc41ev.js} +1 -1
  58. package/dist/{chunk-83hs9905.js → chunk-rdrstnn9.js} +1 -1
  59. package/dist/chunk-rv8qfykd.js +2 -0
  60. package/dist/{chunk-c05zj2m9.js → chunk-txqw2wxa.js} +1 -1
  61. package/dist/chunk-vdmgd7w0.js +2 -0
  62. package/dist/{chunk-f32mtkqf.js → chunk-w53s8z3z.js} +4 -4
  63. package/dist/{chunk-c2e4m8qq.js → chunk-w55wzrc7.js} +1 -1
  64. package/dist/{chunk-52njxk3w.js → chunk-w7y27df4.js} +1 -1
  65. package/dist/{chunk-sxkkxmkc.js → chunk-xdm772rg.js} +4 -4
  66. package/dist/{chunk-8kvqv885.js → chunk-xnnb7y22.js} +1 -1
  67. package/dist/{chunk-7tjfca0a.js → chunk-yqdsnke6.js} +1 -1
  68. package/dist/chunk-yxkvz5n3.js +2 -0
  69. package/dist/{chunk-at70apjf.js → chunk-z2dgzcdk.js} +1 -1
  70. package/dist/{chunk-kxh9rqdm.js → chunk-z8pgzhg4.js} +1 -1
  71. package/dist/{chunk-sn1qtgmc.js → chunk-zr234jv3.js} +3 -3
  72. package/dist/cli.js +8 -8
  73. package/dist/component-renderer.js +1 -1
  74. package/dist/craft-entry.js +1 -1
  75. package/dist/craft.js +1 -1
  76. package/dist/pwa.js +1 -1
  77. package/dist/ssg.js +2 -2
  78. package/dist/temp-dir.js +2 -2
  79. package/package.json +5 -5
  80. package/dist/chunk-15qrs231.js +0 -2
  81. package/dist/chunk-3043ycz6.js +0 -2
  82. package/dist/chunk-77nn1ckz.js +0 -3
  83. package/dist/chunk-8jvwapq3.js +0 -2
  84. package/dist/chunk-9ejk9mwk.js +0 -4
  85. package/dist/chunk-dvy101w4.js +0 -2
  86. package/dist/chunk-frf4qp4z.js +0 -2
  87. package/dist/chunk-kdh1s839.js +0 -2
  88. package/dist/chunk-s43ty9bg.js +0 -2
  89. package/dist/chunk-wkat7js9.js +0 -2
  90. package/dist/chunk-xr5xp6v0.js +0 -2
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{yr,i}from"./chunk-xdm772rg.js";import"./chunk-9578r5x8.js";import"./chunk-w53s8z3z.js";import"./chunk-de61k0ab.js";import"./chunk-23b4mc1y.js";import"./chunk-2v6p4eq2.js";import"./chunk-jrv3xr72.js";import"./chunk-5jrpzepc.js";import"./chunk-dbxby7r4.js";import{Ae}from"./chunk-nddkrbz4.js";import"./chunk-vbmvft7g.js";import"./chunk-2krq2rdd.js";import"./chunk-65g78sge.js";import"./chunk-fxxw0t9j.js";import"./chunk-9dbxjbzm.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import{We,ao,co}from"./chunk-4w4zjtp7.js";import"./chunk-77a17bbm.js";import"./chunk-esm0pnpz.js";import"./chunk-945zygwa.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-0jdz31q1.js";import"./chunk-hdfhaddy.js";export{yr as buildModulesTag,Ae as injectRouterScript,i as processDirectives,ao as processJsonDirective,co as processOnceDirective,We as validateClientScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{As,pg,ci,fg}from"./chunk-5qkd77vw.js";import"./chunk-5jrpzepc.js";import"./chunk-kmby9q2c.js";import"./chunk-yar3c574.js";import"./chunk-vbmvft7g.js";import"./chunk-hg31hs5d.js";import"./chunk-5hksy9tt.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import{Wt}from"./chunk-p80nnmha.js";import"./chunk-q3we5jsk.js";import"./chunk-esm0pnpz.js";import"./chunk-945zygwa.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-0jdz31q1.js";import"./chunk-hdfhaddy.js";export{fg as declareBareLoopHead,Wt as parseLoopBinding,pg as processLoops,ci as processLoopsAsync,As as reportDeferredLoopWarnings};
2
+ import{As,pg,ci,fg}from"./chunk-jrv3xr72.js";import"./chunk-5jrpzepc.js";import"./chunk-dbxby7r4.js";import"./chunk-nddkrbz4.js";import"./chunk-vbmvft7g.js";import"./chunk-fxxw0t9j.js";import"./chunk-9dbxjbzm.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import{Wt}from"./chunk-4w4zjtp7.js";import"./chunk-77a17bbm.js";import"./chunk-esm0pnpz.js";import"./chunk-945zygwa.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-0jdz31q1.js";import"./chunk-hdfhaddy.js";export{fg as declareBareLoopHead,Wt as parseLoopBinding,pg as processLoops,ci as processLoopsAsync,As as reportDeferredLoopWarnings};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y,b,g}from"./chunk-p80nnmha.js";import{q}from"./chunk-hg31hs5d.js";import{i}from"./chunk-sxkkxmkc.js";import k from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,n;O.lastIndex=0;while((n=O.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function ph(e,t={},o={}){let n={...q,...o,streaming:{...M,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await y(p,f,e);let E=z(c),l=new Set;if(!E.some((h)=>h.type==="suspense")){let h=n.streaming?.strategy||"auto",S=new RegExp(T.source,"g");if(!(h!=="manual"&&S.test(c))){let u=await i(c,f,e,n,l);for(let x=0;x<u.length;x+=s)r.enqueue(u.slice(x,x+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],x=new RegExp(T.source,"g"),m;while((m=x.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let D=await i(I,f,e,n,l);r.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let h=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
2
+ import{y,b,g}from"./chunk-4w4zjtp7.js";import{q}from"./chunk-fxxw0t9j.js";import{i}from"./chunk-xdm772rg.js";import k from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,n;O.lastIndex=0;while((n=O.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function ph(e,t={},o={}){let n={...q,...o,streaming:{...M,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await y(p,f,e);let E=z(c),l=new Set;if(!E.some((h)=>h.type==="suspense")){let h=n.streaming?.strategy||"auto",S=new RegExp(T.source,"g");if(!(h!=="manual"&&S.test(c))){let u=await i(c,f,e,n,l);for(let x=0;x<u.length;x+=s)r.enqueue(u.slice(x,x+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],x=new RegExp(T.source,"g"),m;while((m=x.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let D=await i(I,f,e,n,l);r.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let h=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),h.set(d.name,i(d.content,f,e,n,l))}r.enqueue(`
5
5
  <script>
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Vl,Ul}from"./chunk-hdfhaddy.js";import{J,Or,Ys,Zs,$i,Ai,Qs,Oe,qe,ke,se,Dr,Lr,he,oe,F,mt,jr,Ni,zr,Ye,s,g,Y,Nn}from"./chunk-p80nnmha.js";import{m,M,yt,p}from"./chunk-945zygwa.js";import{r}from"./chunk-77nn1ckz.js";import{ge}from"./chunk-5jrpzepc.js";import{xr}from"./chunk-eb5v9npc.js";import{w}from"./chunk-v6gkjg5f.js";import{t}from"./chunk-68r2zs20.js";import{createHash as At}from"crypto";import K from"fs";import V from"path";import Le from"fs";function Ae(e,i,n){let o=Buffer.alloc(n),a=Le.readSync(e,o,0,n,i);return o.subarray(0,a)}function ze(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let n=i(12,16);if(n==="VP8X")return(e[20]&16)!==0;if(n==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Le.openSync(e,"r");let n=Ae(i,0,33);if(n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255)return"none";if(n.length>=26&&n[0]===137&&n.toString("latin1",1,4)==="PNG"){let o=n[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ae(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(n.length>=25&&n.toString("latin1",0,4)==="RIFF"&&n.toString("latin1",8,12)==="WEBP"){if(ze(n))return"possible";let o=n.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Le.closeSync(i)}}import sn from"fs";import Fe from"os";import{fileURLToPath as bt}from"url";var _e=Symbol("stx.image-worker.unavailable");function on(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ie=0,vt=[];async function an(){if(Ie<on()){Ie++;return}await new Promise((e)=>vt.push(e)),Ie++}function cn(){Ie--,vt.shift()?.()}var ln="@stacksjs/stx/builtins/image-warmup-worker";function un(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let n=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(n.protocol==="file:"&&sn.existsSync(bt(n)))return bt(n)}catch{}return xr(ln,e)}var xt=!1;function ue(e){if(!xt)xt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return _e}function Pe(e){return e instanceof Error?e.message:String(e)}async function We(e,i){let n;try{n=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Pe(a)}`)}if(typeof n!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=un();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await an();try{return await new Promise((a,c)=>{let l;try{l=new n(o)}catch(y){a(ue(`could not start ${o}: ${Pe(y)}`));return}let u=!1,f=!1,v=(y)=>{if(f)return;f=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){v(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;v(()=>c(h))}),l.on("error",(y)=>{v(()=>u?c(y instanceof Error?y:Error(Pe(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Pe(y)}`)))}),l.on("exit",(y)=>{v(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{cn()}}var fn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),dn=[320,640,960,1280,1920],ve="/_stx/images",gn=`stx:${ve}:alpha-1`,pn=`stx:${ve}:opaque-1`,mn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ee;function hn(e,i){let n=V.dirname(Bun.resolveSync(e,i));while(n!==V.dirname(n)){let o=V.join(n,"package.json");if(K.existsSync(o)){let a=JSON.parse(K.readFileSync(o,"utf8"));if(a.name===e)return a.version}n=V.dirname(n)}return}function wt(){if(Ee!==void 0)return Ee;let e;try{e=V.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ee=mn.map((i)=>{let n;try{n=e?hn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${n??"unknown"}`}).join("+"),Ee}var $t=Symbol.for("stx.image-delivery");function we(){let e=globalThis;return e[$t]??={catalog:new Map,transparent:new Set},e[$t]}var St=new Set;function yn(e){return`/${e.split(V.sep).map(encodeURIComponent).join("/")}`}function bn(e){let i=V.extname(e),n=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=At("sha256").update(e).digest("hex").slice(0,8);return`${n||"image"}-${o}`}function Ct(e,i=`stx:${ve}`){let n=(o)=>`${ve}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=V.join(e,o);try{let c=await K.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:n(o)}:null}catch{return null}},async write(o,a){let c=V.join(e,o);await K.promises.mkdir(V.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await K.promises.writeFile(l,a),await K.promises.rename(l,c),{bytes:a.byteLength,path:c,url:n(o)}},url:n}}async function Pt(e,i=e){let n=await K.promises.readdir(i,{withFileTypes:!0});n.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of n){let c=V.join(i,a.name);if(a.isDirectory()){o.push(...await Pt(e,c));continue}if(!a.isFile()||!fn.has(V.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:V.relative(e,c)})}return o}function Rt(e,i){return e.map((n)=>({key:yn(n.relativePath),input:n.absolutePath,name:bn(n.relativePath),...xn(n.absolutePath)?{options:{storage:i}}:{}}))}function xn(e){return Ue(e)==="possible"}function vn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function wn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),n=new Set,o=8;if(i.length===0)return n;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let f=u.variants.filter((v)=>v.format==="png").sort((v,y)=>v.width-y.width)[0];try{let v=await a(new Uint8Array(await K.promises.readFile(f?.path??u.fallback.path)));if(vn(v.data))n.add(l)}catch{n.add(l)}}));return n}function $n(e,i){let n=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let f;try{return f=K.openSync(u.path,"r"),!ze(Ae(f,0,32))}catch{return!0}finally{if(f!==void 0)K.closeSync(f)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,n.push(o),!St.has(o))St.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return n}async function Sn(e){let i=[],n=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function He(e){return V.join(e,"undecodable.json")}function Cn(e){try{let i=K.readFileSync(He(e),"utf-8"),n=JSON.parse(i);return n&&typeof n==="object"?n:{}}catch{return{}}}function Rn(e,i){try{K.mkdirSync(V.dirname(He(e)),{recursive:!0}),K.writeFileSync(He(e),JSON.stringify(i))}catch{}}function kt(e){try{let i=K.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function It(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function oi(e){let i=It(e);return i?we().catalog.get(i):void 0}function ii(e){let i=It(e);return i?we().transparent.has(i):!1}function ai(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),n=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<n).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function ly(e){let i=oi(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:ai(i).map(({format:n,srcset:o})=>({type:`image/${n}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:ii(e)?void 0:i.placeholder?.dataUrl}}function $s(){let e=we();e.catalog=new Map,e.transparent=new Set}function An(e){let i=we();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function uy(e,i,n={}){if(!e||!K.existsSync(e))return $s(),{count:0,fingerprint:""};if(n.offThread){let d=await We("delivery",{publicDir:e,outputDir:i});if(d!==_e)return An(d.state),d.result}let o=await Pt(e);if(o.length===0)return $s(),{count:0,fingerprint:""};let a=Cn(i),c=o.filter((d)=>{let x=a[d.relativePath];if(!x)return!0;let k=kt(d.absolutePath);return!k||k.mtimeMs!==x.mtimeMs||k.size!==x.size});if(c.length===0)return $s(),{count:0,fingerprint:""};let l=Ct(V.join(i,"_stx","images"),`${gn}:${wt()}`),u={outDir:V.join(i,"_stx","images"),storage:Ct(V.join(i,"_stx","images"),`${pn}:${wt()}`),baseUrl:ve,widths:dn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:f}=await import("ts-images/delivery"),v=c,y;try{y=await f({...u,entries:Rt(c,l)})}catch(d){if(v=await Sn(c),v.length===c.length)throw d;let x=new Set(v.map((A)=>A.relativePath)),k=!1;for(let A of c){if(x.has(A.relativePath))continue;let R=kt(A.absolutePath);if(!R)continue;a[A.relativePath]=R,k=!0}if(k)Rn(i,a);if(v.length===0)return $s(),{count:0,fingerprint:""};y=await f({...u,entries:Rt(v,l)})}let h=await wn(y.entries),C=$n(y.entries,h),S=we();S.catalog=new Map(Object.entries(y.entries)),S.transparent=h;let b=h.size===0&&C.length===0?y.fingerprint:At("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...h].sort(),droppedWebp:C.sort()})).digest("hex");return{count:v.length,fingerprint:b}}class _t{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,n,o){let a=$i(e,o);if(a!==void 0)return a;for(let c of Ai(e,i,n,o))if(await s(c))return c;return null}}var fe=new _t;var ne="\x00stx-boolean-attribute";function Xe(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Pn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Ze(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||Pn.has(i)}function re(e,i){let n=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)n.push(g(c));continue}if(a===ne){n.push(g(c));continue}n.push(`${g(c)}="${Nn(c,Xe(String(a)))}"`)}return n}function ie(e,i){let n=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){n.push(g(c));continue}if(typeof a==="object")continue;n.push(`${g(c)}="${Nn(c,Xe(String(a)))}"`)}return n}function In(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Ve={name:"StxLink",aliases:["stx-link"],render(e,i,n){let o=In(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,f=[];if(o.reactive)f.push(`:href="${r(o.value)}"`);else f.push(`href="${r(Dr(o.value,"navigable"))}"`);if(a)f.push(`class="${r(a)}"`);if(f.push("data-stx-link"),f.push(`data-stx-active-class="${r(c)}"`),f.push(`data-stx-exact-active-class="${r(l)}"`),u)f.push("data-stx-prefetch");let v=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(v)f.push(`data-stx-active-match="${r(v)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return f.push(...re(e,y)),f.push(...ie(e,y)),`<a ${f.join(" ")}>${i}</a>`}};var _n=new Map;function Ge(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return _n.get(i)}var En={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ke=[320,640,768,1024,1280,1536,1920];function H(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Ne(e,i,n=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return n}function Je(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),n=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=En[a];if(l)n.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))n.push(`(max-width: ${u}px) ${c}`)}}else n.push(o);return n.join(", ")}function Qe(e,i,n,o){return i.map((a)=>`${$e(e,a,void 0,n,o)} ${a}w`).join(", ")}function On(e,i,n,o,a){return i.map((c)=>{let l=n?n*c:void 0;return`${$e(e,l,void 0,o,a)} ${c}x`}).join(", ")}function $e(e,i,n,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(n)c.push(`h_${n}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(n)c.set("h",String(n));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(n)c.set("height",String(n));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function Bn(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Tn(e,i,n="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${n}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var et={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,n){let o=H(e,"src")||"",a=oi(o),c=H(e,"alt")||"",l=H(e,"width")||(a?String(a.source.width):void 0),u=H(e,"height")||(a?String(a.source.height):void 0),f=H(e,"sizes"),v=H(e,"srcset"),y=H(e,"densities"),h=H(e,"format"),C=ii(o)||Ge(o)?.transparent===!0,S=H(e,"placeholder")||(a&&!C?"thumbhash":void 0),b=H(e,"placeholderColor")||"#e5e7eb",d=H(e,"provider"),x=H(e,"class")||H(e,"className")||"",k=H(e,"style")||"",A=H(e,"objectFit")||H(e,"fit"),R=H(e,"objectPosition")||H(e,"position"),E=H(e,"quality"),G=Ne(e,"lazy",!0),z=Ne(e,"preload",!1),B=Ne(e,"priority",!1),L=H(e,"loading"),N=H(e,"decoding")||"async",q=!!a||Ne(e,"picture",!1)||!!h,P=l?Number.parseInt(l):void 0,_=u?Number.parseInt(u):void 0,T=v||"",U="";if(a)T=a.sources[a.fallback.format]||"",U=f?Je(f):"100vw";else if(!T&&f&&d&&d!=="local"&&d!=="static")T=Qe(o,Ke,d,h),U=Je(f);else if(!T&&y){let Z=y.split(/\s+/).map((I)=>Number.parseFloat(I.replace("x","")));T=On(o,Z,P,d,h)}else if(f)U=Je(f);let D=[];if(k)D.push(k);if(A)D.push(`object-fit:${A}`);if(R)D.push(`object-position:${R}`);if(P&&_)D.push(`aspect-ratio:${P}/${_}`);let te=[],ae=S==="blur"||S==="color"||S==="thumbhash";if(ae&&!C){let Z=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:b}:Ge(o);if(Z&&S==="color")D.push(`background-color:${Z.color}`),te.push("backgroundColor");else if(Z)D.push(`background-color:${Z.color}`),D.push(`background-image:url(${Z.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundColor","backgroundImage");else{let I=Tn(P||16,_||9,b);D.push(`background-image:url(${I})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundImage")}}else if(!ae&&S&&S!=="empty"&&S!=="none")D.push(`background-image:url(${r(S)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundImage");let j=a?.fallback.url||$e(o,P,_,d,h),X=[];if(X.push(`src="${r(Dr(j,"fetched"))}"`),X.push(`alt="${r(c)}"`),l)X.push(`width="${r(l)}"`);if(u)X.push(`height="${r(u)}"`);let Ce=L||(B||z?"eager":G?"lazy":"");if(Ce)X.push(`loading="${r(Ce)}"`);if(B)X.push('fetchpriority="high"');if(X.push(`decoding="${r(N)}"`),x)X.push(`class="${r(x)}"`);if(D.length>0)X.push(`style="${r(D.join(";"))}"`);if(T)X.push(`srcset="${r(Dr(T,"fetched"))}"`);if(U)X.push(`sizes="${r(U)}"`);let xe=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(te.length>0){let Z=typeof e.static.onload==="string"?e.static.onload:"",I=Bn(te)+(Z?`;${Z}`:"");X.push(`onload="${r(I)}"`),xe.add("onload")}X.push(...re(e,xe)),X.push(...ie(e,xe));let le=`<img ${X.join(" ")} />`,Q="";if(z){let I=h==="webp"?"image/webp":h==="avif"?"image/avif":"";Q=`<link rel="preload" as="image" href="${r(j)}"${I?` type="${I}"`:""}${T?` imagesrcset="${r(T)}"`:""}${U?` imagesizes="${r(U)}"`:""} />
2
+ import{Vl,Ul}from"./chunk-hdfhaddy.js";import{J,Or,Ys,Zs,$i,Ai,Qs,Oe,qe,ke,se,Dr,Lr,he,oe,F,mt,jr,Ni,zr,Ye,s,g,Y,Nn}from"./chunk-4w4zjtp7.js";import{m,M,yt,p}from"./chunk-945zygwa.js";import{r}from"./chunk-2v6p4eq2.js";import{ge}from"./chunk-5jrpzepc.js";import{xr}from"./chunk-eb5v9npc.js";import{w}from"./chunk-v6gkjg5f.js";import{t}from"./chunk-68r2zs20.js";import{createHash as At}from"crypto";import K from"fs";import V from"path";import Le from"fs";function Ae(e,i,n){let o=Buffer.alloc(n),a=Le.readSync(e,o,0,n,i);return o.subarray(0,a)}function ze(e){if(e.length<25)return!1;let i=(o,a)=>String.fromCharCode(...e.subarray(o,a));if(i(0,4)!=="RIFF"||i(8,12)!=="WEBP")return!1;let n=i(12,16);if(n==="VP8X")return(e[20]&16)!==0;if(n==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function Ue(e){let i;try{i=Le.openSync(e,"r");let n=Ae(i,0,33);if(n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255)return"none";if(n.length>=26&&n[0]===137&&n.toString("latin1",1,4)==="PNG"){let o=n[25];if(o===4||o===6)return"possible";let a=8;for(let c=0;c<64;c++){let l=Ae(i,a,8);if(l.length<8)return"unknown";let u=l.toString("latin1",4,8);if(u==="tRNS")return"possible";if(u==="IDAT"||u==="IEND")return"none";a+=12+l.readUInt32BE(0)}return"unknown"}if(n.length>=25&&n.toString("latin1",0,4)==="RIFF"&&n.toString("latin1",8,12)==="WEBP"){if(ze(n))return"possible";let o=n.toString("latin1",12,16);return o==="VP8 "||o==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(i!==void 0)Le.closeSync(i)}}import sn from"fs";import Fe from"os";import{fileURLToPath as bt}from"url";var _e=Symbol("stx.image-worker.unavailable");function on(e=typeof Fe.availableParallelism==="function"?Fe.availableParallelism():Fe.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ie=0,vt=[];async function an(){if(Ie<on()){Ie++;return}await new Promise((e)=>vt.push(e)),Ie++}function cn(){Ie--,vt.shift()?.()}var ln="@stacksjs/stx/builtins/image-warmup-worker";function un(e=process.cwd()){let i=import.meta.url.endsWith(".ts")?"ts":"js";try{let n=new URL(`./image-warmup-worker.${i}`,import.meta.url);if(n.protocol==="file:"&&sn.existsSync(bt(n)))return bt(n)}catch{}return xr(ln,e)}var xt=!1;function ue(e){if(!xt)xt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return _e}function Pe(e){return e instanceof Error?e.message:String(e)}async function We(e,i){let n;try{n=(await import("worker_threads")).Worker}catch(a){return ue(`could not load node:worker_threads: ${Pe(a)}`)}if(typeof n!=="function")return ue("node:worker_threads has no Worker in this runtime");let o=un();if(!o)return ue("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await an();try{return await new Promise((a,c)=>{let l;try{l=new n(o)}catch(y){a(ue(`could not start ${o}: ${Pe(y)}`));return}let u=!1,f=!1,v=(y)=>{if(f)return;f=!0,y(),l.terminate()};l.on("message",(y)=>{if(y.type==="ready"){u=!0,l.postMessage({task:e,args:i});return}if(y.type==="result"){v(()=>a(y.value));return}let h=Error(y.error?.message??"image worker failed");if(y.error?.name)h.name=y.error.name;if(y.error?.stack)h.stack=y.error.stack;v(()=>c(h))}),l.on("error",(y)=>{v(()=>u?c(y instanceof Error?y:Error(Pe(y)||"image worker crashed")):a(ue(`the worker failed before it was ready: ${Pe(y)}`)))}),l.on("exit",(y)=>{v(()=>u?c(Error("image worker exited before it finished")):a(ue(`the worker exited with code ${y} before it was ready`)))})})}finally{cn()}}var fn=new Set([".avif",".jpeg",".jpg",".png",".webp"]),dn=[320,640,960,1280,1920],ve="/_stx/images",gn=`stx:${ve}:alpha-1`,pn=`stx:${ve}:opaque-1`,mn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Ee;function hn(e,i){let n=V.dirname(Bun.resolveSync(e,i));while(n!==V.dirname(n)){let o=V.join(n,"package.json");if(K.existsSync(o)){let a=JSON.parse(K.readFileSync(o,"utf8"));if(a.name===e)return a.version}n=V.dirname(n)}return}function wt(){if(Ee!==void 0)return Ee;let e;try{e=V.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Ee=mn.map((i)=>{let n;try{n=e?hn(i,e):void 0}catch{}return`${i.replace("@stacksjs/","")}@${n??"unknown"}`}).join("+"),Ee}var $t=Symbol.for("stx.image-delivery");function we(){let e=globalThis;return e[$t]??={catalog:new Map,transparent:new Set},e[$t]}var St=new Set;function yn(e){return`/${e.split(V.sep).map(encodeURIComponent).join("/")}`}function bn(e){let i=V.extname(e),n=e.slice(0,-i.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),o=At("sha256").update(e).digest("hex").slice(0,8);return`${n||"image"}-${o}`}function Ct(e,i=`stx:${ve}`){let n=(o)=>`${ve}/${o.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:i,async stat(o){let a=V.join(e,o);try{let c=await K.promises.stat(a);return c.size>0?{bytes:c.size,path:a,url:n(o)}:null}catch{return null}},async write(o,a){let c=V.join(e,o);await K.promises.mkdir(V.dirname(c),{recursive:!0});let l=`${c}.${process.pid}.tmp`;return await K.promises.writeFile(l,a),await K.promises.rename(l,c),{bytes:a.byteLength,path:c,url:n(o)}},url:n}}async function Pt(e,i=e){let n=await K.promises.readdir(i,{withFileTypes:!0});n.sort((a,c)=>a.name.localeCompare(c.name));let o=[];for(let a of n){let c=V.join(i,a.name);if(a.isDirectory()){o.push(...await Pt(e,c));continue}if(!a.isFile()||!fn.has(V.extname(a.name).toLowerCase()))continue;o.push({absolutePath:c,relativePath:V.relative(e,c)})}return o}function Rt(e,i){return e.map((n)=>({key:yn(n.relativePath),input:n.absolutePath,name:bn(n.relativePath),...xn(n.absolutePath)?{options:{storage:i}}:{}}))}function xn(e){return Ue(e)==="possible"}function vn(e){for(let i=3;i<e.length;i+=4)if(e[i]!==255)return!0;return!1}async function wn(e){let i=Object.entries(e).filter(([,c])=>c.fallback.format==="png"),n=new Set,o=8;if(i.length===0)return n;let{decode:a}=await import("ts-images");for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async([l,u])=>{let f=u.variants.filter((v)=>v.format==="png").sort((v,y)=>v.width-y.width)[0];try{let v=await a(new Uint8Array(await K.promises.readFile(f?.path??u.fallback.path)));if(vn(v.data))n.add(l)}catch{n.add(l)}}));return n}function $n(e,i){let n=[];for(let o of i){let a=e[o],c=a?.variants.filter((u)=>u.format==="webp")??[];if(!a||c.length===0)continue;if(!c.some((u)=>{let f;try{return f=K.openSync(u.path,"r"),!ze(Ae(f,0,32))}catch{return!0}finally{if(f!==void 0)K.closeSync(f)}}))continue;if(a.variants=a.variants.filter((u)=>u.format!=="webp"),delete a.sources.webp,n.push(o),!St.has(o))St.add(o),console.warn(`[stx-images] ${o} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return n}async function Sn(e){let i=[],n=8;if(e.length===0)return i;let{generateThumbHash:o}=await import("ts-images");for(let a=0;a<e.length;a+=8){let c=e.slice(a,a+8),l=await Promise.all(c.map(async(u)=>{try{return await o(u.absolutePath),u}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${u.relativePath}`),null}}));i.push(...l.filter((u)=>u!==null))}return i}function He(e){return V.join(e,"undecodable.json")}function Cn(e){try{let i=K.readFileSync(He(e),"utf-8"),n=JSON.parse(i);return n&&typeof n==="object"?n:{}}catch{return{}}}function Rn(e,i){try{K.mkdirSync(V.dirname(He(e)),{recursive:!0}),K.writeFileSync(He(e),JSON.stringify(i))}catch{}}function kt(e){try{let i=K.statSync(e);return{mtimeMs:i.mtimeMs,size:i.size}}catch{return}}function It(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let i=e.split(/[?#]/,1)[0];if(!i)return;try{return`/${i.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function oi(e){let i=It(e);return i?we().catalog.get(i):void 0}function ii(e){let i=It(e);return i?we().transparent.has(i):!1}function ai(e){let i=(o)=>e.variants.filter((a)=>a.format===o).reduce((a,c)=>a+c.bytes,0),n=i(e.fallback.format);return["avif","webp"].map((o)=>({format:o,srcset:e.sources[o]||"",bytes:i(o)})).filter((o)=>o.srcset&&o.bytes>0&&o.bytes<n).sort((o,a)=>o.bytes-a.bytes).map(({format:o,srcset:a})=>({format:o,srcset:a}))}function ly(e){let i=oi(e);if(!i)return;return{src:i.fallback.url,srcset:i.sources[i.fallback.format]||"",sources:ai(i).map(({format:n,srcset:o})=>({type:`image/${n}`,srcset:o})),width:i.source.width,height:i.source.height,placeholder:ii(e)?void 0:i.placeholder?.dataUrl}}function $s(){let e=we();e.catalog=new Map,e.transparent=new Set}function An(e){let i=we();i.catalog=new Map(e.entries),i.transparent=new Set(e.transparent)}async function uy(e,i,n={}){if(!e||!K.existsSync(e))return $s(),{count:0,fingerprint:""};if(n.offThread){let d=await We("delivery",{publicDir:e,outputDir:i});if(d!==_e)return An(d.state),d.result}let o=await Pt(e);if(o.length===0)return $s(),{count:0,fingerprint:""};let a=Cn(i),c=o.filter((d)=>{let x=a[d.relativePath];if(!x)return!0;let k=kt(d.absolutePath);return!k||k.mtimeMs!==x.mtimeMs||k.size!==x.size});if(c.length===0)return $s(),{count:0,fingerprint:""};let l=Ct(V.join(i,"_stx","images"),`${gn}:${wt()}`),u={outDir:V.join(i,"_stx","images"),storage:Ct(V.join(i,"_stx","images"),`${pn}:${wt()}`),baseUrl:ve,widths:dn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},{createImageDeliveryCatalog:f}=await import("ts-images/delivery"),v=c,y;try{y=await f({...u,entries:Rt(c,l)})}catch(d){if(v=await Sn(c),v.length===c.length)throw d;let x=new Set(v.map((A)=>A.relativePath)),k=!1;for(let A of c){if(x.has(A.relativePath))continue;let R=kt(A.absolutePath);if(!R)continue;a[A.relativePath]=R,k=!0}if(k)Rn(i,a);if(v.length===0)return $s(),{count:0,fingerprint:""};y=await f({...u,entries:Rt(v,l)})}let h=await wn(y.entries),C=$n(y.entries,h),S=we();S.catalog=new Map(Object.entries(y.entries)),S.transparent=h;let b=h.size===0&&C.length===0?y.fingerprint:At("sha256").update(y.fingerprint).update(JSON.stringify({transparent:[...h].sort(),droppedWebp:C.sort()})).digest("hex");return{count:v.length,fingerprint:b}}class _t{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let i of e.aliases)this.builtins.set(i.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,i,n,o){let a=$i(e,o);if(a!==void 0)return a;for(let c of Ai(e,i,n,o))if(await s(c))return c;return null}}var fe=new _t;var ne="\x00stx-boolean-attribute";function Xe(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Pn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Ze(e){let i=e.toLowerCase();return i.startsWith("aria-")||i.startsWith("data-")||Pn.has(i)}function re(e,i){let n=[];for(let[o,a]of Object.entries(e.static)){if(i.has(o))continue;let c=e.staticNames?.[o]??o;if(typeof a==="boolean"){if(a)n.push(g(c));continue}if(a===ne){n.push(g(c));continue}n.push(`${g(c)}="${Nn(c,Xe(String(a)))}"`)}return n}function ie(e,i){let n=[];for(let[o,a]of Object.entries(e.serverDynamic??{})){if(i.has(o))continue;if(a===null||a===void 0||a===!1)continue;let c=e.serverDynamicNames?.[o]??o;if(a===!0){n.push(g(c));continue}if(typeof a==="object")continue;n.push(`${g(c)}="${Nn(c,Xe(String(a)))}"`)}return n}function In(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Ve={name:"StxLink",aliases:["stx-link"],render(e,i,n){let o=In(e),a=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),c=typeof e.static.activeClass==="string"?e.static.activeClass:"active",l=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",u=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,f=[];if(o.reactive)f.push(`:href="${r(o.value)}"`);else f.push(`href="${r(Dr(o.value,"navigable"))}"`);if(a)f.push(`class="${r(a)}"`);if(f.push("data-stx-link"),f.push(`data-stx-active-class="${r(c)}"`),f.push(`data-stx-exact-active-class="${r(l)}"`),u)f.push("data-stx-prefetch");let v=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(v)f.push(`data-stx-active-match="${r(v)}"`);let y=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return f.push(...re(e,y)),f.push(...ie(e,y)),`<a ${f.join(" ")}>${i}</a>`}};var _n=new Map;function Ge(e){if(!e)return;let i=e.split("?")[0].split("#")[0];return _n.get(i)}var En={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ke=[320,640,768,1024,1280,1536,1920];function H(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);let n=e.static[i];if(typeof n==="string")return n;return}function Ne(e,i,n=!1){let o=e.serverDynamic[i];if(o!==void 0)return o!==!1&&o!=="false";let a=e.static[i];if(a!==void 0)return a!=="false"&&a!==!1;return n}function Je(e){if(e.includes("(")||e.includes(","))return e;let i=e.trim().split(/\s+/),n=[];for(let o of i)if(o.includes(":")){let[a,c]=o.split(":"),l=En[a];if(l)n.push(`(max-width: ${l}px) ${c}`);else{let u=Number.parseInt(a);if(!Number.isNaN(u))n.push(`(max-width: ${u}px) ${c}`)}}else n.push(o);return n.join(", ")}function Qe(e,i,n,o){return i.map((a)=>`${$e(e,a,void 0,n,o)} ${a}w`).join(", ")}function On(e,i,n,o,a){return i.map((c)=>{let l=n?n*c:void 0;return`${$e(e,l,void 0,o,a)} ${c}x`}).join(", ")}function $e(e,i,n,o,a){if(!o||o==="local"||o==="static")return e;if(o==="cloudinary"){let c=[];if(i)c.push(`w_${i}`);if(n)c.push(`h_${n}`);if(a)c.push(`f_${a}`);c.push("q_auto");let l=c.join(",");return e.replace("/upload/",`/upload/${l}/`)}if(o==="imgix"){let c=new URLSearchParams;if(i)c.set("w",String(i));if(n)c.set("h",String(n));if(a)c.set("fm",a);c.set("auto","format");let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}if(o==="bunny"){let c=new URLSearchParams;if(i)c.set("width",String(i));if(n)c.set("height",String(n));if(a)c.set("format",a);let l=e.includes("?")?"&":"?";return`${e}${l}${c.toString()}`}return e}function Bn(e){return`var s=this.style;${e.map((i)=>`s.${i}=''`).join(";")}`}function Tn(e,i,n="#e5e7eb"){let o=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}"><rect width="100%" height="100%" fill="${n}"/></svg>`;return`data:image/svg+xml;base64,${btoa(o)}`}var et={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,i,n){let o=H(e,"src")||"",a=oi(o),c=H(e,"alt")||"",l=H(e,"width")||(a?String(a.source.width):void 0),u=H(e,"height")||(a?String(a.source.height):void 0),f=H(e,"sizes"),v=H(e,"srcset"),y=H(e,"densities"),h=H(e,"format"),C=ii(o)||Ge(o)?.transparent===!0,S=H(e,"placeholder")||(a&&!C?"thumbhash":void 0),b=H(e,"placeholderColor")||"#e5e7eb",d=H(e,"provider"),x=H(e,"class")||H(e,"className")||"",k=H(e,"style")||"",A=H(e,"objectFit")||H(e,"fit"),R=H(e,"objectPosition")||H(e,"position"),E=H(e,"quality"),G=Ne(e,"lazy",!0),z=Ne(e,"preload",!1),B=Ne(e,"priority",!1),L=H(e,"loading"),N=H(e,"decoding")||"async",q=!!a||Ne(e,"picture",!1)||!!h,P=l?Number.parseInt(l):void 0,_=u?Number.parseInt(u):void 0,T=v||"",U="";if(a)T=a.sources[a.fallback.format]||"",U=f?Je(f):"100vw";else if(!T&&f&&d&&d!=="local"&&d!=="static")T=Qe(o,Ke,d,h),U=Je(f);else if(!T&&y){let Z=y.split(/\s+/).map((I)=>Number.parseFloat(I.replace("x","")));T=On(o,Z,P,d,h)}else if(f)U=Je(f);let D=[];if(k)D.push(k);if(A)D.push(`object-fit:${A}`);if(R)D.push(`object-position:${R}`);if(P&&_)D.push(`aspect-ratio:${P}/${_}`);let te=[],ae=S==="blur"||S==="color"||S==="thumbhash";if(ae&&!C){let Z=a?.placeholder?{dataUrl:a.placeholder.dataUrl,color:b}:Ge(o);if(Z&&S==="color")D.push(`background-color:${Z.color}`),te.push("backgroundColor");else if(Z)D.push(`background-color:${Z.color}`),D.push(`background-image:url(${Z.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundColor","backgroundImage");else{let I=Tn(P||16,_||9,b);D.push(`background-image:url(${I})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundImage")}}else if(!ae&&S&&S!=="empty"&&S!=="none")D.push(`background-image:url(${r(S)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),te.push("backgroundImage");let j=a?.fallback.url||$e(o,P,_,d,h),X=[];if(X.push(`src="${r(Dr(j,"fetched"))}"`),X.push(`alt="${r(c)}"`),l)X.push(`width="${r(l)}"`);if(u)X.push(`height="${r(u)}"`);let Ce=L||(B||z?"eager":G?"lazy":"");if(Ce)X.push(`loading="${r(Ce)}"`);if(B)X.push('fetchpriority="high"');if(X.push(`decoding="${r(N)}"`),x)X.push(`class="${r(x)}"`);if(D.length>0)X.push(`style="${r(D.join(";"))}"`);if(T)X.push(`srcset="${r(Dr(T,"fetched"))}"`);if(U)X.push(`sizes="${r(U)}"`);let xe=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(te.length>0){let Z=typeof e.static.onload==="string"?e.static.onload:"",I=Bn(te)+(Z?`;${Z}`:"");X.push(`onload="${r(I)}"`),xe.add("onload")}X.push(...re(e,xe)),X.push(...ie(e,xe));let le=`<img ${X.join(" ")} />`,Q="";if(z){let I=h==="webp"?"image/webp":h==="avif"?"image/avif":"";Q=`<link rel="preload" as="image" href="${r(j)}"${I?` type="${I}"`:""}${T?` imagesrcset="${r(T)}"`:""}${U?` imagesizes="${r(U)}"`:""} />
3
3
  `}if(q){let Z=[];if(a)for(let I of ai(a))Z.push(`<source type="image/${I.format}" srcset="${r(I.srcset)}"${U?` sizes="${r(U)}"`:""} />`);if(!a&&(h==="avif"||h==="auto")){let I=$e(o,P,_,d,"avif"),O=T?Qe(o,Ke,d,"avif"):`${I}`;Z.push(`<source type="image/avif" srcset="${r(O)}"${U?` sizes="${r(U)}"`:""} />`)}if(!a&&(h==="webp"||h==="auto")){let I=$e(o,P,_,d,"webp"),O=T?Qe(o,Ke,d,"webp"):`${I}`;Z.push(`<source type="image/webp" srcset="${r(O)}"${U?` sizes="${r(U)}"`:""} />`)}return`${Q}<picture>
4
4
  ${Z.join(`
5
5
  `)}
@@ -38,5 +38,5 @@ ${le}
38
38
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
39
39
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
40
40
  </style>`}};import{existsSync as Mn,readFileSync as Ln}from"fs";var De=new Map,Dt=new Set;function zn(e){if(Dt.has(e))return;Dt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Un(e){let i=process.cwd();for(let n of[`${i}/node_modules/@iconify-json/${e}/icons.json`,`${i}/pantry/@iconify-json/${e}/icons.json`,`${i}/node_modules/@iconify/json/json/${e}.json`,`${i}/pantry/@iconify/json/json/${e}.json`])if(Mn(n))return n;for(let n of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return w.resolve(n)}catch{}return null}function Fn(e){if(De.has(e))return De.get(e);let i=Un(e);if(!i)return zn(e),null;try{let n=JSON.parse(Ln(i,"utf8"));return De.set(e,n),n}catch{return null}}function Wn(e,i,n,o){let a=[];if(i.rotate)a.push(`rotate(${i.rotate*90} ${n/2} ${o/2})`);if(i.hFlip)a.push(`translate(${n} 0) scale(-1 1)`);if(i.vFlip)a.push(`translate(0 ${o}) scale(1 -1)`);return a.length?`<g transform="${a.join(" ")}">${e}</g>`:e}function Hn(e,i){let n=i,o=e.icons[n],a={hFlip:!1,vFlip:!1,rotate:0};for(let u=0;!o&&u<8;u++){let f=e.aliases?.[n];if(!f)return null;if(f.hFlip)a.hFlip=!a.hFlip;if(f.vFlip)a.vFlip=!a.vFlip;if(f.rotate)a.rotate=((a.rotate+f.rotate)%4+4)%4;n=f.parent,o=e.icons[n]}if(!o)return null;let c=o.width??e.width??24,l=o.height??e.height??24;return{body:Wn(o.body,a,c,l),width:c,height:l}}function me(e,i){if(e.serverDynamic[i]!==void 0)return String(e.serverDynamic[i]);if(e.static[i]!==void 0)return String(e.static[i]);if(e.clientReactive[i]!==void 0)return e.clientReactive[i];return}var at={name:"Icon",aliases:["icon","stx-icon"],render(e,i,n){let o=me(e,"name")??me(e,"icon");if(!o)return"<!-- Icon: missing name/icon prop -->";let a="lucide",c=o;if(o.includes(":")){let x=o.split(":");a=x[0],c=x[1]}let l=r(me(e,"size")||"24"),u=r(me(e,"color")||"currentColor"),f=r(me(e,"class")||""),v=r(me(e,"style")||""),y=De.get(a)??Fn(a);if(!y)return`<!-- Icon: collection "${a}" not loaded -->`;let h=Hn(y,c);if(!h)return`<!-- Icon: "${c}" not found in ${a} -->`;let C=`0 0 ${h.width} ${h.height}`,S=h.body;if(u!=="currentColor")S=S.replace(/currentColor/g,u);let b=f?` class="${f}"`:"",d=v?` style="${v}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${l}" viewBox="${C}" fill="none"${b}${d}>${S}</svg>`}};function jt(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}function Mt(e,i){let n=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${i}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),o=e.match(n);if(!o)return{region:null,rest:e};return{region:o[2],rest:e.replace(o[0],"")}}var ct={name:"Suspense",aliases:["suspense"],render(e,i,n){let o=Mt(i,"fallback"),a=o.rest,c=Mt(a,"error"),l=c.rest,u=o.region??jt(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',f=c.region??jt(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${u}</div><div data-stx-suspense-error hidden>${f}</div><div data-stx-suspense-content hidden>${l}</div></div>`}};function je(e,...i){for(let n of i){if(e.serverDynamic[n]!==void 0)return String(e.serverDynamic[n]);let o=e.static[n];if(typeof o==="string")return o}return}var lt={name:"TransitionGroup",aliases:["transition-group"],render(e,i,n){let o=(je(e,"name")||"v").replace(/["'<>]/g,""),a=(je(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",c=je(e,"class"),l=je(e,"id"),u=[`data-stx-transition-group="${o}"`,c?`class="${c}"`:"",l?`id="${l}"`:""].filter(Boolean).join(" ");return`<${a} ${u}>${i}</${a}>`}};function Lt(e=fe){e.registerBuiltin(Ve),e.registerBuiltin(et),e.registerBuiltin(tt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it),e.registerBuiltin(ot),e.registerBuiltin(at),e.registerBuiltin(ct),e.registerBuiltin(lt)}var zt=new Map;function qn(e){let i=zt.get(e.source);if(!i)i=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),zt.set(e.source,i);return i}var Ut=new WeakMap;function Ft(e){let i=Ut.get(e);if(!i)i=new Set([...e].map((o)=>o.toLowerCase())),Ut.set(e,i);let n=i;return(o)=>!/[a-z]/.test(o)&&n.has(o.toLowerCase())}function Xn(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function Wt(e,i,n){let o=[],a=0,c=typeof n==="function"?n:n?(l)=>n.has(l.toLowerCase()):void 0;while(a<e.length){let l=e.indexOf("<",a);if(l===-1)break;let u=qn(i);u.lastIndex=l+1;let f=u.exec(e);if(!f){a=l+1;continue}let v=f[1];if(c&&c(v)){let x=l+1+v.length;while(x<e.length&&e[x]!==">")x++;a=x+1;continue}let y=l+1+v.length,h=null,C=y,S=-1,b=!1;while(y<e.length){let x=e[y];if(h){if(x==="\\"&&y+1<e.length){y+=2;continue}if(x===h)h=null;y++;continue}if(x==='"'||x==="'"){h=x,y++;continue}if(x==="/"&&y+1<e.length&&e[y+1]===">"){S=y+2,b=!0;break}if(x===">"){S=y+1;break}y++}if(S===-1){a=l+1;continue}let d=e.slice(C,b?S-2:S-1).trim();if(b)o.push({fullMatch:e.slice(l,S),tagName:v,attributes:d,content:"",startIndex:l,endIndex:S,isSelfClosing:!0}),a=S;else{let x=`<${v}`,k=`</${v}>`,A=1,R=S,E=-1;while(A>0&&R<e.length){let B=e.indexOf(x,R),L=e.indexOf(k,R);if(L===-1)break;if(B!==-1&&B<L){let N=e[B+x.length];if(N===" "||N===">"||N==="/"||N===`
41
- `||N==="\t"){let q=Xn(e,B+x.length);if(e[q-1]!=="/")A++;R=q+1}else R=B+x.length}else{if(A--,A===0){E=L;break}R=L+k.length}}if(E===-1){a=S;continue}let G=e.slice(S,E),z=E+k.length;o.push({fullMatch:e.slice(l,z),tagName:v,attributes:d,content:G,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ut(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function kn(e,i){try{let n=Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch{}try{let n=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(n)}catch(n){if(i?.debug)console.error("Error decoding __stx_ prop:",n);return e}}function Me(e,i){let n=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")n++;else if(c==="}"){if(n--,n===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Ht(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Me(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function qt(e){let i=[],n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o&&e[n]!==l){if(e[n]==="\\"&&n+1<o)n++,c+=e[n];else c+=e[n];n++}if(n<o)n++}else if(e[n]==="{")c=Me(e,n),n+=c.length;else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Vn=new Set([":for","x-for","v-for","@for"]),Xt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Gn(e){return ft(e).map((i)=>[i.start,i.end])}function ft(e){let i=[],n=new Map;for(let o of Oe(e)){let a=o.name.toLowerCase();if(o.closing){let v=n.get(a)?.pop();if(v)v.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?qt(o.attributes).find((v)=>Vn.has(v.name)):void 0,u=typeof l?.value==="string"?l.value:null,f=u!==null?{start:o.start,end:o.end,names:oe(u),tag:a}:null;if(f)i.push(f);if(!o.selfClosing&&!Xt.has(a)){let v=n.get(a);if(!v)v=[],n.set(a,v);v.push(f)}}return i}var Kn=/(?:^|\s)((?:[\w-]+:)*-?space-[xy]-(?!reverse(?:\s|$))[\w./[\]-]+)(?=\s|$)/;function Zt(e){let i=new Map,n=[];for(let o of Oe(e)){let a=o.name.toLowerCase();if(o.closing){for(let l=n.length-1;l>=0;l--)if(n[l].name===a){n.length=l;break}continue}let c=n.at(-1);if(c){if(c.utility&&c.children>0)i.set(o.start,c.utility);if(!/(?:^|\s)hidden(?=[\s=]|$)/.test(o.attributes))c.children++}if(!o.selfClosing&&!Xt.has(a)){let l=/(?:^|\s)class\s*=\s*(["'])([\s\S]*?)\1/.exec(o.attributes)?.[2];n.push({name:a,utility:l?Kn.exec(l)?.[1]??null:null,children:0})}}return i}function Vt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Vt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function Nc(e,i){if(!/:[\w-]+=/.test(e))return e;let n=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Gn(e));let l=new Set([...mt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(h){return a.some(([C,S])=>h>=C&&h<S)}let f=[],v=new Map,y=256;for(let h of Oe(n)){if(h.closing||u(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let S=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,d,x=C,k=!1;while((d=b.exec(C))!==null){if(Lr(C,d.index,!0)?.kind==="attribute")continue;let A=d[1],R=d[2];if(Vl(A))continue;if(F(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let E=Object.keys(i),G=Object.values(i),z=R.match(/^([a-zA-Z_$][\w$]*)/);if(z&&!E.includes(z[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(z[1]))continue;let B=JSON.stringify([E,R]),L=v.get(B);if(!L){if(L=Function(...E,`return (${R})`),v.size>=y)v.clear();v.set(B,L)}let N=L(...G);if(A==="class"){let q=Y(Vt(N));if(q){let P=x.match(/\sclass="([^"]*)"/);if(P)x=x.replace(P[0],()=>` class="${P[1]} ${q}"`);else x=x.replace(d[0],()=>` class="${q}"`)}else x=x.replace(d[0],"");k=!0;continue}if(Zn.has(A)){if(N)x=x.replace(d[0],` ${A}`);else x=x.replace(d[0],"");k=!0;continue}if(N===null||N===void 0||N===!1)x=x.replace(d[0],"");else{let q=S&&typeof N==="object"?JSON.stringify(N):String(N),P=Nn(A,q);x=x.replace(d[0],()=>` ${A}="${P}"`)}k=!0}catch(E){if(E instanceof he)throw E;continue}}if(k){let A=h.selfClosing?" /":"",E=`<${h.name}${x}${A}>`;f.push({start:h.start,end:h.end,replacement:E})}}if(f.length>0){let h=Array(f.length*2+1),C=0;for(let S=0;S<f.length;S++){let{start:b,end:d,replacement:x}=f[S];h[S*2]=n.slice(C,b),h[S*2+1]=x,C=d}h[f.length*2]=n.slice(C),n=h.join("")}return n}import Gt from"fs";import Kt from"path";var Jt=!1;function Jn(e,i,n,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),u=(C)=>{if(l.size===0)return!1;let S=t(C),b=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(b&&l.has(b))return!0;for(let d of l){let x=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${x}\\s*\\(`).test(S))return!0}return!1},f=new Set(Ul),v=(C)=>{if(!C.includes("-")||C.startsWith("@")||C.startsWith(":")||C.startsWith("x-")||C.startsWith("__"))return C;if(C.startsWith("aria-")||C.startsWith("data-"))return C;return C.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())},y=(C,S)=>{let b=v(C);if(c.static[b]=S,b!==C)c.staticNames[b]=C},h={...e};for(let[C,S]of Object.entries(e)){let b=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(C);if(!b)continue;delete h[C];let d=b[1]||"modelValue";if(h[`:${d}`]=S,h[`@update:${d}`]=`${S} = $event`,b[2]){let x=b[2].slice(1).split(".").map((k)=>`${k}: true`).join(", ");h[`:${b[1]?`${d}Modifiers`:"modelModifiers"}`]=`{ ${x} }`}}for(let[C,S]of Object.entries(h)){let b=C.startsWith("x-")&&!f.has(C)&&!C.startsWith("x-bind:")&&!C.startsWith("x-on:")?`:${C.slice(2)}`:C;if(b.startsWith("@")){c.events[b]=S;continue}if(b.startsWith("__stx_")){let d=v(b.slice(6));c.serverDynamic[d]=kn(S,n);continue}if(b.startsWith(":")){let d=v(b.slice(1)),x=S===ne?d:S;if(d==="if"||d==="for"||d==="show"){c.clientReactive[d]=x;continue}if(o){c.clientReactive[d]=x;continue}if(F(x,a)){c.clientReactive[d]=x;continue}if(u(x)){c.clientReactive[d]=x;continue}try{if(!m(x)){if(n.debug)console.error(`Unsafe expression in :${d} binding: ${x}`);c.clientReactive[d]=x;continue}let k=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),R=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(yt(x).some((B)=>!A.has(B)&&!k.includes(B)&&(!(B in globalThis)||R.has(B)))){c.clientReactive[d]=x;continue}let z=p(x,k)(...Object.values(i));if(c.serverDynamic[d]=z,d!==b.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[d]=b.slice(1)}catch{c.clientReactive[d]=x}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let d=tr(S,a);if(d!==null){c.clientReactive[v(b)]=d;continue}let x=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(x)try{let k=x[1];if(m(k)){let R=p(k,Object.keys(i))(...Object.values(i));y(b,R!=null?String(R):"")}else{if(n.debug)console.error(`Unsafe expression in ${b}: ${k}`);y(b,S)}}catch(k){if(n.debug)console.error(`Error evaluating expression for ${b}:`,k);y(b,S)}else{let k=S,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,R;while((R=A.exec(S))!==null)try{let E=R[1];if(!m(E)){if(n.debug)console.error(`Unsafe expression in ${b}: ${E}`);continue}let z=p(E,Object.keys(i))(...Object.values(i));k=k.replace(R[0],String(z??""))}catch(E){if(n.debug)console.error(`Error evaluating expression in ${b}:`,E)}y(b,k)}continue}y(b,S===ne?"true":ut(S))}return c}var dt=new Set;function dy(){dt.clear()}function Yn(e){let i=/^\s*(?:<!--[\s\S]*?-->\s*)*<(?:div|span)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/.exec(e);return!!i&&/\sdata-stx-component-wrapper(?=[\s=]|$)/.test(i[1])&&!/\sstx-hydrate(?=[\s=]|$)/.test(i[1])}function Qn(e,i,n){let o=`${n}\x00${e}\x00${i}`;if(dt.has(o))return;dt.add(o);let a=/space-x-/.test(i)?"flex":"flex flex-col",c=i.replace(/space-[xy]-/,"gap-");console.warn(`[stx] <${e}> in ${n} is a later child of a "${i}" stack, so it gets no spacing: the utility puts its margin on the component's scope wrapper, which generates no box. Use "${a} ${c}" on the parent instead -- gap reaches through the wrapper.`)}var gt=new Set;function py(){gt.clear()}function er(e,i){let n=`${i}\x00${e}`;if(gt.has(n))return;gt.add(n),console.warn(`[stx] <${e}> in ${i} is inside a <template :for>, so its props and slot expressions will not see the loop variables and render empty. Put the directive on the element the loop repeats instead -- <tr :for="..."> or <span :for="..." class="contents"> -- which binds correctly.`)}function tr(e,i){if(i.size===0)return null;let n=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(n)];if(!o.some((u)=>F(u[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let u of o)c+=e.slice(l,u.index).replace(/[`\\$]/g,(f)=>`\\${f}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var nr=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function rr(e,i,n){if(!e.includes("@"))return e;if(!nr.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return ge(e,i,n)}catch{return e}}function ye(e){let i={},n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o){let u=e[n];if(u==="\\"&&n+1<o){n++,c+=e[n],n++;continue}if(u===l){n++;break}c+=u,n++}}else if(e[n]==="{"){c=Me(e,n),n+=c.length;let l=Ht(c);if(l!==null){i[`:${a}`]=l;continue}}else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i[a]=c}else i[a]=ne}return i}function Yt(e){return Object.entries(e).map(([i,n])=>n===ne?i:`${i}="${sr(n)}"`).join(" ")}function sr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ir(e){let i=new Set,n=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=n.exec(e))!==null){let a=o[1];if(fe.isBuiltin(a))i.add(a)}return[...i].sort()}async function dg(e,i,n,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Kt.dirname(n),u=[],f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(f)){let[C,S,b]=h,d=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,x=b,k,A=[];while((k=d.exec(b))!==null){let[R,E,G,z]=k,B=null,L=null;if(z.startsWith(".")||z.startsWith("/")){let P=Kt.resolve(l,z);if(P.endsWith(".stx"))L=P;else{let _=`${P}.stx`;try{if(Gt.statSync(_).isFile())L=_}catch{try{if(Gt.statSync(P).isDirectory())B=P}catch{}}}}else B=Ys(z,l);if(!B&&!L)continue;let N=!1,q=(P,_)=>{c.set(P,_),c.set(P.toLowerCase(),_);let T=P.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(T,_),a.add(_)};if(G&&L)q(G,L),N=!0;else if(E){let P=E.slice(1,-1).split(",").map((T)=>T.trim()).filter(Boolean).map((T)=>{let U=T.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(U)return{source:U[1],local:U[2]};return{source:T,local:T}}),_=B?Or(B):null;for(let{source:T,local:U}of P){let D=null;if(L)D=L;else if(_)D=_.get(T)??_.get(T.toLowerCase())??_.get(T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)q(U,D),N=!0}}if(N)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)x=x.slice(0,A[R].start)+x.slice(A[R].end);u.push({start:h.index,end:h.index+C.length,value:`<script${S}>${x}</script>`})}if(u.length===0)return e;let v=[],y=0;for(let h of u)v.push(e.slice(y,h.start),h.value),y=h.end;return v.push(e.slice(y)),v.join("")}async function or(e,i,n,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,f;while((f=u.exec(c))!==null){let[v,y]=f,h=y.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let S=C.split("/"),d=S[S.length-1].replace(/\.stx$/,""),x=d.includes("-")?d.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):d.charAt(0).toUpperCase()+d.slice(1),k=null,A=Zs(C,n,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(x,k),l.set(d,k),l.set(d.toLowerCase(),k);let R=x.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${x} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(v,""),u.lastIndex=0}return c}async function ar(e,i,n,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=/@component\s*\(/g,v;while((v=f.exec(c))!==null){let y=v.index,h=y+v[0].length-1,C=1,S=h+1;while(S<c.length&&C>0){if(c[S]==="(")C++;else if(c[S]===")"){if(C--,C===0)break}S++}if(C!==0)break;let b=c.substring(h+1,S),d=S+1,x=b.match(/^\s*['"]([^'"]+)['"]/);if(!x){f.lastIndex=d;continue}let k=x[1],A,R=b.slice(x[0].length),E=R.match(/^\s*,\s*/);if(E)A=R.slice(E[0].length).trim();let G={};if(A)try{G=M(A,i)}catch(P){let _=P instanceof Error?P.message:String(P);c=c.replace(c.substring(y,d),`[Error parsing component props: ${_}]`);continue}let z="",B=d,N=c.substring(d).match(/^([\s\S]*?)@endcomponent/);if(N)z=N[1].trim(),B=d+N[0].length;let q=await Ye(k,G,z,l,i,n,o,u,a);c=c.substring(0,y)+q+c.substring(B),f.lastIndex=0}return c}async function cr(e,i,n,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=fr(c);if(f.size>0){let d=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...d,...f])]}let v=se(c);c=v.output;let y=mt(i);return c=await b(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await b(c,/[A-Z][a-zA-Z0-9]*/,!0,Ft(jr)),c=await b(c,/[a-z][a-z0-9]*/,!1,jr),c=v.restore(c),c;async function b(d,x,k,A){if(!d)return d;let R=d,E=Wt(R,x,A),G=ft(R),z=!o._nativeHostAttrs&&/space-[xy]-/.test(R),B,L=new Map;for(let P=E.length-1;P>=0;P--){let _=E[P],T=k?J(_.tagName):_.tagName,U=ye(rr(_.attributes,i,n)),D=G.filter(({start:O,end:W})=>_.startIndex>=O&&_.startIndex<W);if(D.some((O)=>O.tag==="template"))er(_.tagName,n);let te=D.length>0,ae=new Set(y);for(let O of D)for(let W of O.names)ae.add(W);let j=Jn(U,i,o,te,ae);if(typeof j.clientReactive.for==="string")for(let O of oe(j.clientReactive.for))ae.add(O);let X=fe.getBuiltin(_.tagName),Ce=X?await zr(_.tagName,l,i,n,{...o,_nativePrimitivesFallback:void 0}):!1,xe=_.tagName==="Image"&&Qs([...Object.keys(j.static),...Object.keys(j.serverDynamic),...Object.keys(j.clientReactive)],Object.keys(j.events),{...j.static,...j.serverDynamic})&&(o._pluginComponentDirs??[]).some((O)=>Or(O).has("Image"));if(X&&!Ce&&!xe){let O={context:i,filePath:n,options:o,dependencies:a},W=X.render(j,_.content,O);if(Object.keys(j.events).length>0){let ce=Yt(j.events);W=W.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ce}`)}if(Object.keys(j.clientReactive).length>0)W=Qt(W,j.clientReactive);L.set(P,W);continue}if(!k&&_.tagName.includes("-")&&!await zr(T,l,i,n,o))continue;let le={};for(let[O,W]of Object.entries(j.static))le[O]=W;for(let[O,W]of Object.entries(j.serverDynamic))le[O]=W;let Q={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(j.clientReactive),events:Object.keys(j.events)},Z=await Ye(T,le,v.restore(_.content),l,i,n,o,u,a,[...ae],Q,_.tagName);if(z&&Yn(Z)){B??=Zt(R);let O=B.get(_.startIndex);if(O)Qn(_.tagName,O,n)}let I=Z;if(I=lr(I,j,Q.declaredProps,Q.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let O=Q.reactiveProps.filter((ee)=>!Q.consumedProps.has(ee)&&!["if","for","show","key","ref"].includes(ee)).map(J),W=pt(I,!0);if(O.length&&W){if(!Object.hasOwn(ye(I.slice(W.insertPos,W.tagEnd)),"data-stx-native-host-root"))I=I.slice(0,W.insertPos)+' data-stx-native-host-root="true"'+I.slice(W.insertPos);let ee=be(I);I=I.slice(0,ee.insertPos)+` data-stx-native-forward="${O.join(" ")}"`+I.slice(ee.insertPos)}let ce=pt(I,!0);if(ce){let ee=ye(I.slice(ce.insertPos,ce.tagEnd)),Re=be(I),rn=ye(I.slice(Re.insertPos,Re.tagEnd));if(Object.hasOwn(ee,"data-stx-native-host-root")&&!Object.hasOwn(rn,"data-stx-native-host-owner"))I=I.slice(0,Re.insertPos)+" data-stx-native-host-owner"+I.slice(Re.insertPos)}}if(Object.keys(j.events).length>0){let O=be(I);if(O){let W=Yt(j.events),ce=Object.keys(j.events).map((ee)=>ee.replace(/^@/,"").split(".")[0]).join(" ");I=I.substring(0,O.insertPos)+` data-stx-parent-events="${ce}" ${W}`+I.substring(O.insertPos)}}if(Object.keys(j.clientReactive).length>0)I=Qt(I,j.clientReactive);L.set(P,I)}if(L.size===0)return R;let N="",q=0;for(let P=0;P<E.length;P++){let _=L.get(P);if(_===void 0)continue;N+=R.slice(q,E[P].startIndex),N+=_,q=E[P].endIndex}return N+=R.slice(q),N}}function Qt(e,i){let n=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([y])=>!n.has(y)),c=a.filter(([y])=>!o.has(y)).map(([y])=>J(y)).join(" "),l=e,u=a.length>0?be(l):null;if(u){let y=a.map(([C,S])=>`:${J(C)}="${S.replace(/"/g,"&quot;")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${h} ${y}`+l.substring(u.insertPos)}let f=i.if;if(f)l=`<template :if="${f.replace(/"/g,"&quot;")}">${l}</template>`;let v=i.for;if(v){let y=i.key,h=y?` :key="${y.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${v.replace(/"/g,"&quot;")}"${h}>${l}</template>`}return l}function lr(e,i,n=new Set,o=new Set,a=!1){let c=pt(e,a);if(!c)return e;let l=a?be(e):null;if(l){let u=tn(e,l).filter((f)=>f.insertPos>c.insertPos);for(let f=u.length-1;f>=0;f--)e=en(e,u[f],i,n,o,a)}return en(e,c,i,n,o,a)}function en(e,i,n,o,a,c){let l=e.slice(i.insertPos,i.tagEnd),u=n.serverDynamic.class??n.static.class;if(c&&typeof u==="string"&&u&&!a.has("class")){let b=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,d=b.test(l)?l.replace(b,(x,k,A,R,E)=>`${k}class="${r(`${ut(A??R??E)} ${u}`)}"`):` class="${r(u)}"${l}`;e=e.slice(0,i.insertPos)+d+e.slice(i.tagEnd),i.tagEnd+=d.length-l.length,l=d}let f=c||/\bdata-native(?:\s|=)/i.test(l),v=f?a:o,y=new Set(Object.keys(ye(l))),h=new Set(["class","className"]);for(let b of Object.keys(n.static)){let d=n.staticNames[b]??b;if(y.has(d)||v.has(b)||!f&&!Ze(d))h.add(b)}for(let b of Object.keys(n.serverDynamic)){let d=n.serverDynamicNames?.[b]??b;if(y.has(d)||v.has(b)||!f&&!Ze(d))h.add(b)}let C=[];if(f){for(let[b,d]of Object.entries(n.static)){if(h.has(b)||d!==!0&&d!==ne)continue;h.add(b),C.push(`${r(n.staticNames?.[b]??b)}="true"`)}for(let[b,d]of Object.entries(n.serverDynamic)){if(h.has(b)||d!==!0)continue;h.add(b),C.push(`${r(n.serverDynamicNames?.[b]??b)}="true"`)}}let S=[...re(n,h),...ie(n,h),...C];if(f){for(let[b,d]of Object.entries(n.serverDynamic)){if(h.has(b)||d!==!1)continue;let x=n.serverDynamicNames?.[b]??b;S.push(`${r(x)}="false"`)}for(let[b,d]of Object.entries(n.serverDynamic)){if(h.has(b)||d===null||typeof d!=="object")continue;let x=JSON.stringify(d);if(x!==void 0){let k=n.serverDynamicNames?.[b]??b;S.push(`${r(k)}="${r(x)}"`)}}}if(S.length===0)return e;return`${e.slice(0,i.insertPos)} ${S.join(" ")}${e.slice(i.insertPos)}`}function be(e){let i=nn(e,0);if(i)return i;let n=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(n)return{insertPos:n.index+1+n[1].length,tagEnd:ht(e,n.index+1+n[1].length)};return null}function pt(e,i=!1){let n=be(e);if(!n)return null;let o=e.slice(n.insertPos,n.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?nn(e,n.tagEnd+1):n;return a&&i?ur(e,a)??a:a}function ur(e,i){return tn(e,i)[0]??null}function tn(e,i){let n=[];if(!e.includes("data-stx-native-host-root"))return n;let o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),a=e.lastIndexOf("<",i.insertPos),c=0,l;while(a>=0&&a<e.length){if(e.startsWith("<!--",a)){let h=e.indexOf("-->",a+4);if(h<0)return n;a=e.indexOf("<",h+3);continue}let u=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(a));if(!u){a=e.indexOf("<",a+1);continue}let f=u[2].toLowerCase(),v=a+u[0].length,y=ht(e,v);if(u[1]){if(c--,l!==void 0&&c<l)l=void 0;if(c<=0)return n}else if(f==="script"||f==="style"){let h=new RegExp(`</${f}\\s*>`,"gi");if(h.lastIndex=y+1,!h.exec(e))return n;a=e.indexOf("<",h.lastIndex);continue}else{let h=ye(e.slice(v,y)),C=c>0&&(Object.hasOwn(h,"data-stx-component-wrapper")||Object.hasOwn(h,"data-stx-native-host-owner")),S=l===void 0&&!C&&Object.hasOwn(h,"data-stx-native-host-root");if(S)n.push({insertPos:v,tagEnd:y});if(!o.has(f)&&e[y-1]!=="/"){if(c++,l===void 0&&(C||S))l=c}else if(c===0)return n}a=e.indexOf("<",y+1)}return n}function nn(e,i){let n=i;while(n<e.length){let o=e.slice(n),a=o.match(/^\s+/);if(a){n+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,f=e.toLowerCase().indexOf(u,n+c[0].length);if(f===-1)return null;n=f+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:n+1+l[1].length,tagEnd:ht(e,n+1+l[1].length)}}return null}function ht(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function fr(e){let i=new Set;for(let n of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=n[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Ni(n[2]))i.add(a);for(let a of n[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function Rs(e,i,n,o,a){if(!Jt)Lt(fe),Jt=!0;let c=await dg(e,i,n,o,a);c=await or(c,i,n,o,a),c=await ar(c,i,n,o,a);let l=[];for(let u=0;u<3;u++){let f=l.length,v=ke(c,qe,(h,C)=>`\x00STX_COMPONENT_COMMENT_${f+C}\x00`,`STX_COMPONENT_COMMENT:${f}`);l.push(...v.tokens);let y=c;if(c=await cr(v.output,i,n,o,a),c===y)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,f)=>l[Number(f)]??"");if(o.debug){let u=ir(c);if(u.length>0)console.warn(`[stx] ${n}: unresolved component tag(s) after render passes: ${u.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
41
+ `||N==="\t"){let q=Xn(e,B+x.length);if(e[q-1]!=="/")A++;R=q+1}else R=B+x.length}else{if(A--,A===0){E=L;break}R=L+k.length}}if(E===-1){a=S;continue}let G=e.slice(S,E),z=E+k.length;o.push({fullMatch:e.slice(l,z),tagName:v,attributes:d,content:G,startIndex:l,endIndex:z,isSelfClosing:!1}),a=z}}return o}function ut(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function kn(e,i){try{let n=Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch{}try{let n=e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(n)}catch(n){if(i?.debug)console.error("Error decoding __stx_ prop:",n);return e}}function Me(e,i){let n=0,o="",a=i;while(a<e.length){let c=e[a];if(o){if(c==="\\")a++;else if(c===o)o=""}else if(c==='"'||c==="'"||c==="`")o=c;else if(c==="{")n++;else if(c==="}"){if(n--,n===0)return e.slice(i,a+1)}a++}return e.slice(i)}function Ht(e){let i=e.trim();if(!i.startsWith("{")||!i.endsWith("}"))return null;if(Me(i,0).length!==i.length)return null;return i.slice(1,-1).trim()}function qt(e){let i=[],n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o&&e[n]!==l){if(e[n]==="\\"&&n+1<o)n++,c+=e[n];else c+=e[n];n++}if(n<o)n++}else if(e[n]==="{")c=Me(e,n),n+=c.length;else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i.push({name:a,value:c})}else i.push({name:a,value:!0})}return i}var Zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Vn=new Set([":for","x-for","v-for","@for"]),Xt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Gn(e){return ft(e).map((i)=>[i.start,i.end])}function ft(e){let i=[],n=new Map;for(let o of Oe(e)){let a=o.name.toLowerCase();if(o.closing){let v=n.get(a)?.pop();if(v)v.end=o.end;continue}let l=/(?::for|x-for|v-for|@for)\s*=/.test(o.attributes)?qt(o.attributes).find((v)=>Vn.has(v.name)):void 0,u=typeof l?.value==="string"?l.value:null,f=u!==null?{start:o.start,end:o.end,names:oe(u),tag:a}:null;if(f)i.push(f);if(!o.selfClosing&&!Xt.has(a)){let v=n.get(a);if(!v)v=[],n.set(a,v);v.push(f)}}return i}var Kn=/(?:^|\s)((?:[\w-]+:)*-?space-[xy]-(?!reverse(?:\s|$))[\w./[\]-]+)(?=\s|$)/;function Zt(e){let i=new Map,n=[];for(let o of Oe(e)){let a=o.name.toLowerCase();if(o.closing){for(let l=n.length-1;l>=0;l--)if(n[l].name===a){n.length=l;break}continue}let c=n.at(-1);if(c){if(c.utility&&c.children>0)i.set(o.start,c.utility);if(!/(?:^|\s)hidden(?=[\s=]|$)/.test(o.attributes))c.children++}if(!o.selfClosing&&!Xt.has(a)){let l=/(?:^|\s)class\s*=\s*(["'])([\s\S]*?)\1/.exec(o.attributes)?.[2];n.push({name:a,utility:l?Kn.exec(l)?.[1]??null:null,children:0})}}return i}function Vt(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((i)=>Vt(i)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,i])=>i).map(([i])=>i).join(" ");return e?String(e):""}function Nc(e,i){if(!/:[\w-]+=/.test(e))return e;let n=e,o=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,a=[],c;while((c=o.exec(e))!==null)a.push([c.index,c.index+c[0].length]);a.push(...Gn(e));let l=new Set([...mt(i),...Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]]);function u(h){return a.some(([C,S])=>h>=C&&h<S)}let f=[],v=new Map,y=256;for(let h of Oe(n)){if(h.closing||u(h.start))continue;let C=h.attributes.trimEnd();if(!C||!C.includes(":"))continue;let S=/(?:^|\s)data-native(?:\s|=|$)/i.test(C.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,d,x=C,k=!1;while((d=b.exec(C))!==null){if(Lr(C,d.index,!0)?.kind==="attribute")continue;let A=d[1],R=d[2];if(Vl(A))continue;if(F(R,l))continue;if(R.includes("()")&&!R.includes(".get(")||R.includes("$store")||R.includes("$ref"))continue;try{let E=Object.keys(i),G=Object.values(i),z=R.match(/^([a-zA-Z_$][\w$]*)/);if(z&&!E.includes(z[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(z[1]))continue;let B=JSON.stringify([E,R]),L=v.get(B);if(!L){if(L=Function(...E,`return (${R})`),v.size>=y)v.clear();v.set(B,L)}let N=L(...G);if(A==="class"){let q=Y(Vt(N));if(q){let P=x.match(/\sclass="([^"]*)"/);if(P)x=x.replace(P[0],()=>` class="${P[1]} ${q}"`);else x=x.replace(d[0],()=>` class="${q}"`)}else x=x.replace(d[0],"");k=!0;continue}if(Zn.has(A)){if(N)x=x.replace(d[0],` ${A}`);else x=x.replace(d[0],"");k=!0;continue}if(N===null||N===void 0||N===!1)x=x.replace(d[0],"");else{let q=S&&typeof N==="object"?JSON.stringify(N):String(N),P=Nn(A,q);x=x.replace(d[0],()=>` ${A}="${P}"`)}k=!0}catch(E){if(E instanceof he)throw E;continue}}if(k){let A=h.selfClosing?" /":"",E=`<${h.name}${x}${A}>`;f.push({start:h.start,end:h.end,replacement:E})}}if(f.length>0){let h=Array(f.length*2+1),C=0;for(let S=0;S<f.length;S++){let{start:b,end:d,replacement:x}=f[S];h[S*2]=n.slice(C,b),h[S*2+1]=x,C=d}h[f.length*2]=n.slice(C),n=h.join("")}return n}import Gt from"fs";import Kt from"path";var Jt=!1;function Jn(e,i,n,o=!1,a=new Set){let c={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},l=new Set(Array.isArray(i.__stx_client_signal_names)?i.__stx_client_signal_names:[]),u=(C)=>{if(l.size===0)return!1;let S=t(C),b=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(b&&l.has(b))return!0;for(let d of l){let x=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${x}\\s*\\(`).test(S))return!0}return!1},f=new Set(Ul),v=(C)=>{if(!C.includes("-")||C.startsWith("@")||C.startsWith(":")||C.startsWith("x-")||C.startsWith("__"))return C;if(C.startsWith("aria-")||C.startsWith("data-"))return C;return C.replace(/-([a-z0-9])/g,(S,b)=>b.toUpperCase())},y=(C,S)=>{let b=v(C);if(c.static[b]=S,b!==C)c.staticNames[b]=C},h={...e};for(let[C,S]of Object.entries(e)){let b=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(C);if(!b)continue;delete h[C];let d=b[1]||"modelValue";if(h[`:${d}`]=S,h[`@update:${d}`]=`${S} = $event`,b[2]){let x=b[2].slice(1).split(".").map((k)=>`${k}: true`).join(", ");h[`:${b[1]?`${d}Modifiers`:"modelModifiers"}`]=`{ ${x} }`}}for(let[C,S]of Object.entries(h)){let b=C.startsWith("x-")&&!f.has(C)&&!C.startsWith("x-bind:")&&!C.startsWith("x-on:")?`:${C.slice(2)}`:C;if(b.startsWith("@")){c.events[b]=S;continue}if(b.startsWith("__stx_")){let d=v(b.slice(6));c.serverDynamic[d]=kn(S,n);continue}if(b.startsWith(":")){let d=v(b.slice(1)),x=S===ne?d:S;if(d==="if"||d==="for"||d==="show"){c.clientReactive[d]=x;continue}if(o){c.clientReactive[d]=x;continue}if(F(x,a)){c.clientReactive[d]=x;continue}if(u(x)){c.clientReactive[d]=x;continue}try{if(!m(x)){if(n.debug)console.error(`Unsafe expression in :${d} binding: ${x}`);c.clientReactive[d]=x;continue}let k=Object.keys(i),A=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),R=new Set(Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[]);if(yt(x).some((B)=>!A.has(B)&&(R.has(B)||!k.includes(B)&&!(B in globalThis)))){c.clientReactive[d]=x;continue}let z=p(x,k)(...Object.values(i));if(c.serverDynamic[d]=z,d!==b.slice(1)&&c.serverDynamicNames)c.serverDynamicNames[d]=b.slice(1)}catch{c.clientReactive[d]=x}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let d=tr(S,a);if(d!==null){c.clientReactive[v(b)]=d;continue}let x=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(x)try{let k=x[1];if(m(k)){let R=p(k,Object.keys(i))(...Object.values(i));y(b,R!=null?String(R):"")}else{if(n.debug)console.error(`Unsafe expression in ${b}: ${k}`);y(b,S)}}catch(k){if(n.debug)console.error(`Error evaluating expression for ${b}:`,k);y(b,S)}else{let k=S,A=/\{\{\s*([\s\S]+?)\s*\}\}/g,R;while((R=A.exec(S))!==null)try{let E=R[1];if(!m(E)){if(n.debug)console.error(`Unsafe expression in ${b}: ${E}`);continue}let z=p(E,Object.keys(i))(...Object.values(i));k=k.replace(R[0],String(z??""))}catch(E){if(n.debug)console.error(`Error evaluating expression in ${b}:`,E)}y(b,k)}continue}y(b,S===ne?"true":ut(S))}return c}var dt=new Set;function dy(){dt.clear()}function Yn(e){let i=/^\s*(?:<!--[\s\S]*?-->\s*)*<(?:div|span)\b((?:[^>"']|"[^"]*"|'[^']*')*)>/.exec(e);return!!i&&/\sdata-stx-component-wrapper(?=[\s=]|$)/.test(i[1])&&!/\sstx-hydrate(?=[\s=]|$)/.test(i[1])}function Qn(e,i,n){let o=`${n}\x00${e}\x00${i}`;if(dt.has(o))return;dt.add(o);let a=/space-x-/.test(i)?"flex":"flex flex-col",c=i.replace(/space-[xy]-/,"gap-");console.warn(`[stx] <${e}> in ${n} is a later child of a "${i}" stack, so it gets no spacing: the utility puts its margin on the component's scope wrapper, which generates no box. Use "${a} ${c}" on the parent instead -- gap reaches through the wrapper.`)}var gt=new Set;function py(){gt.clear()}function er(e,i){let n=`${i}\x00${e}`;if(gt.has(n))return;gt.add(n),console.warn(`[stx] <${e}> in ${i} is inside a <template :for>, so its props and slot expressions will not see the loop variables and render empty. Put the directive on the element the loop repeats instead -- <tr :for="..."> or <span :for="..." class="contents"> -- which binds correctly.`)}function tr(e,i){if(i.size===0)return null;let n=/\{\{\s*([\s\S]+?)\s*\}\}/g,o=[...e.matchAll(n)];if(!o.some((u)=>F(u[1],i)))return null;let a=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(a&&o.length===1)return a[1];let c="",l=0;for(let u of o)c+=e.slice(l,u.index).replace(/[`\\$]/g,(f)=>`\\${f}`),c+=`\${${u[1]}}`,l=u.index+u[0].length;return c+=e.slice(l).replace(/[`\\$]/g,(u)=>`\\${u}`),`\`${c}\``}var nr=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function rr(e,i,n){if(!e.includes("@"))return e;if(!nr.some(([a,c])=>a.test(e)&&e.includes(c)))return e;try{return ge(e,i,n)}catch{return e}}function ye(e){let i={},n=0,o=e.length;while(n<o){while(n<o&&/\s/.test(e[n]))n++;if(n>=o)break;let a="";while(n<o&&!/[\s=]/.test(e[n]))a+=e[n],n++;if(!a)break;while(n<o&&/\s/.test(e[n]))n++;if(n<o&&e[n]==="="){n++;while(n<o&&/\s/.test(e[n]))n++;let c="";if(n<o&&(e[n]==='"'||e[n]==="'")){let l=e[n];n++;while(n<o){let u=e[n];if(u==="\\"&&n+1<o){n++,c+=e[n],n++;continue}if(u===l){n++;break}c+=u,n++}}else if(e[n]==="{"){c=Me(e,n),n+=c.length;let l=Ht(c);if(l!==null){i[`:${a}`]=l;continue}}else while(n<o&&!/\s/.test(e[n]))c+=e[n],n++;i[a]=c}else i[a]=ne}return i}function Yt(e){return Object.entries(e).map(([i,n])=>n===ne?i:`${i}="${sr(n)}"`).join(" ")}function sr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ir(e){let i=new Set,n=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,o;while((o=n.exec(e))!==null){let a=o[1];if(fe.isBuiltin(a))i.add(a)}return[...i].sort()}async function dg(e,i,n,o,a){if(!/import\s/.test(e))return e;if(!i.__importedComponents)i.__importedComponents=new Map;let c=i.__importedComponents,l=Kt.dirname(n),u=[],f=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let h of e.matchAll(f)){let[C,S,b]=h,d=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,x=b,k,A=[];while((k=d.exec(b))!==null){let[R,E,G,z]=k,B=null,L=null;if(z.startsWith(".")||z.startsWith("/")){let P=Kt.resolve(l,z);if(P.endsWith(".stx"))L=P;else{let _=`${P}.stx`;try{if(Gt.statSync(_).isFile())L=_}catch{try{if(Gt.statSync(P).isDirectory())B=P}catch{}}}}else B=Ys(z,l);if(!B&&!L)continue;let N=!1,q=(P,_)=>{c.set(P,_),c.set(P.toLowerCase(),_);let T=P.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();c.set(T,_),a.add(_)};if(G&&L)q(G,L),N=!0;else if(E){let P=E.slice(1,-1).split(",").map((T)=>T.trim()).filter(Boolean).map((T)=>{let U=T.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(U)return{source:U[1],local:U[2]};return{source:T,local:T}}),_=B?Or(B):null;for(let{source:T,local:U}of P){let D=null;if(L)D=L;else if(_)D=_.get(T)??_.get(T.toLowerCase())??_.get(T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)q(U,D),N=!0}}if(N)A.push({start:k.index,end:k.index+R.length})}if(A.length===0)continue;for(let R=A.length-1;R>=0;R--)x=x.slice(0,A[R].start)+x.slice(A[R].end);u.push({start:h.index,end:h.index+C.length,value:`<script${S}>${x}</script>`})}if(u.length===0)return e;let v=[],y=0;for(let h of u)v.push(e.slice(y,h.start),h.value),y=h.end;return v.push(e.slice(y)),v.join("")}async function or(e,i,n,o,a){let c=e;if(!i.__importedComponents)i.__importedComponents=new Map;let l=i.__importedComponents,u=/@import\s*\(\s*([^)]+)\s*\)/g,f;while((f=u.exec(c))!==null){let[v,y]=f,h=y.split(",").map((C)=>C.trim().replace(/^['"]|['"]$/g,"")).filter((C)=>C.length>0);for(let C of h){let S=C.split("/"),d=S[S.length-1].replace(/\.stx$/,""),x=d.includes("-")?d.split("-").map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(""):d.charAt(0).toUpperCase()+d.slice(1),k=null,A=Zs(C,n,o);for(let R of A)try{if(await Bun.file(R).exists()){k=R;break}}catch{}if(k){l.set(x,k),l.set(d,k),l.set(d.toLowerCase(),k);let R=x.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(l.set(R,k),a.add(k),o.debug)console.log(`Imported component: ${x} -> ${k}`)}else if(o.debug)console.warn(`Could not resolve imported component: ${C}`)}c=c.replace(v,""),u.lastIndex=0}return c}async function ar(e,i,n,o,a){let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=/@component\s*\(/g,v;while((v=f.exec(c))!==null){let y=v.index,h=y+v[0].length-1,C=1,S=h+1;while(S<c.length&&C>0){if(c[S]==="(")C++;else if(c[S]===")"){if(C--,C===0)break}S++}if(C!==0)break;let b=c.substring(h+1,S),d=S+1,x=b.match(/^\s*['"]([^'"]+)['"]/);if(!x){f.lastIndex=d;continue}let k=x[1],A,R=b.slice(x[0].length),E=R.match(/^\s*,\s*/);if(E)A=R.slice(E[0].length).trim();let G={};if(A)try{G=M(A,i)}catch(P){let _=P instanceof Error?P.message:String(P);c=c.replace(c.substring(y,d),`[Error parsing component props: ${_}]`);continue}let z="",B=d,N=c.substring(d).match(/^([\s\S]*?)@endcomponent/);if(N)z=N[1].trim(),B=d+N[0].length;let q=await Ye(k,G,z,l,i,n,o,u,a);c=c.substring(0,y)+q+c.substring(B),f.lastIndex=0}return c}async function cr(e,i,n,o,a){if(!e)return e;let c=e,l=o.componentsDir||"components";if(!i.__processedComponents)i.__processedComponents=new Set;let u=i.__processedComponents,f=fr(c);if(f.size>0){let d=Array.isArray(i.__stx_client_declared_names)?i.__stx_client_declared_names:[];i.__stx_client_declared_names=[...new Set([...d,...f])]}let v=se(c);c=v.output;let y=mt(i);return c=await b(c,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),c=await b(c,/[A-Z][a-zA-Z0-9]*/,!0,Ft(jr)),c=await b(c,/[a-z][a-z0-9]*/,!1,jr),c=v.restore(c),c;async function b(d,x,k,A){if(!d)return d;let R=d,E=Wt(R,x,A),G=ft(R),z=!o._nativeHostAttrs&&/space-[xy]-/.test(R),B,L=new Map;for(let P=E.length-1;P>=0;P--){let _=E[P],T=k?J(_.tagName):_.tagName,U=ye(rr(_.attributes,i,n)),D=G.filter(({start:O,end:W})=>_.startIndex>=O&&_.startIndex<W);if(D.some((O)=>O.tag==="template"))er(_.tagName,n);let te=D.length>0,ae=new Set(y);for(let O of D)for(let W of O.names)ae.add(W);let j=Jn(U,i,o,te,ae);if(typeof j.clientReactive.for==="string")for(let O of oe(j.clientReactive.for))ae.add(O);let X=fe.getBuiltin(_.tagName),Ce=X?await zr(_.tagName,l,i,n,{...o,_nativePrimitivesFallback:void 0}):!1,xe=_.tagName==="Image"&&Qs([...Object.keys(j.static),...Object.keys(j.serverDynamic),...Object.keys(j.clientReactive)],Object.keys(j.events),{...j.static,...j.serverDynamic})&&(o._pluginComponentDirs??[]).some((O)=>Or(O).has("Image"));if(X&&!Ce&&!xe){let O={context:i,filePath:n,options:o,dependencies:a},W=X.render(j,_.content,O);if(Object.keys(j.events).length>0){let ce=Yt(j.events);W=W.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ce}`)}if(Object.keys(j.clientReactive).length>0)W=Qt(W,j.clientReactive);L.set(P,W);continue}if(!k&&_.tagName.includes("-")&&!await zr(T,l,i,n,o))continue;let le={};for(let[O,W]of Object.entries(j.static))le[O]=W;for(let[O,W]of Object.entries(j.serverDynamic))le[O]=W;let Q={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(j.clientReactive),events:Object.keys(j.events)},Z=await Ye(T,le,v.restore(_.content),l,i,n,o,u,a,[...ae],Q,_.tagName);if(z&&Yn(Z)){B??=Zt(R);let O=B.get(_.startIndex);if(O)Qn(_.tagName,O,n)}let I=Z;if(I=lr(I,j,Q.declaredProps,Q.consumedProps,o._nativeHostAttrs),o._nativeHostAttrs){let O=Q.reactiveProps.filter((ee)=>!Q.consumedProps.has(ee)&&!["if","for","show","key","ref"].includes(ee)).map(J),W=pt(I,!0);if(O.length&&W){if(!Object.hasOwn(ye(I.slice(W.insertPos,W.tagEnd)),"data-stx-native-host-root"))I=I.slice(0,W.insertPos)+' data-stx-native-host-root="true"'+I.slice(W.insertPos);let ee=be(I);I=I.slice(0,ee.insertPos)+` data-stx-native-forward="${O.join(" ")}"`+I.slice(ee.insertPos)}let ce=pt(I,!0);if(ce){let ee=ye(I.slice(ce.insertPos,ce.tagEnd)),Re=be(I),rn=ye(I.slice(Re.insertPos,Re.tagEnd));if(Object.hasOwn(ee,"data-stx-native-host-root")&&!Object.hasOwn(rn,"data-stx-native-host-owner"))I=I.slice(0,Re.insertPos)+" data-stx-native-host-owner"+I.slice(Re.insertPos)}}if(Object.keys(j.events).length>0){let O=be(I);if(O){let W=Yt(j.events),ce=Object.keys(j.events).map((ee)=>ee.replace(/^@/,"").split(".")[0]).join(" ");I=I.substring(0,O.insertPos)+` data-stx-parent-events="${ce}" ${W}`+I.substring(O.insertPos)}}if(Object.keys(j.clientReactive).length>0)I=Qt(I,j.clientReactive);L.set(P,I)}if(L.size===0)return R;let N="",q=0;for(let P=0;P<E.length;P++){let _=L.get(P);if(_===void 0)continue;N+=R.slice(q,E[P].startIndex),N+=_,q=E[P].endIndex}return N+=R.slice(q),N}}function Qt(e,i){let n=new Set(["if","for"]),o=new Set(["show"]),a=Object.entries(i).filter(([y])=>!n.has(y)),c=a.filter(([y])=>!o.has(y)).map(([y])=>J(y)).join(" "),l=e,u=a.length>0?be(l):null;if(u){let y=a.map(([C,S])=>`:${J(C)}="${S.replace(/"/g,"&quot;")}"`).join(" "),h=c?` data-stx-parent-bindings="${c}"`:"";l=l.substring(0,u.insertPos)+`${h} ${y}`+l.substring(u.insertPos)}let f=i.if;if(f)l=`<template :if="${f.replace(/"/g,"&quot;")}">${l}</template>`;let v=i.for;if(v){let y=i.key,h=y?` :key="${y.replace(/"/g,"&quot;")}"`:"";l=`<template :for="${v.replace(/"/g,"&quot;")}"${h}>${l}</template>`}return l}function lr(e,i,n=new Set,o=new Set,a=!1){let c=pt(e,a);if(!c)return e;let l=a?be(e):null;if(l){let u=tn(e,l).filter((f)=>f.insertPos>c.insertPos);for(let f=u.length-1;f>=0;f--)e=en(e,u[f],i,n,o,a)}return en(e,c,i,n,o,a)}function en(e,i,n,o,a,c){let l=e.slice(i.insertPos,i.tagEnd),u=n.serverDynamic.class??n.static.class;if(c&&typeof u==="string"&&u&&!a.has("class")){let b=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,d=b.test(l)?l.replace(b,(x,k,A,R,E)=>`${k}class="${r(`${ut(A??R??E)} ${u}`)}"`):` class="${r(u)}"${l}`;e=e.slice(0,i.insertPos)+d+e.slice(i.tagEnd),i.tagEnd+=d.length-l.length,l=d}let f=c||/\bdata-native(?:\s|=)/i.test(l),v=f?a:o,y=new Set(Object.keys(ye(l))),h=new Set(["class","className"]);for(let b of Object.keys(n.static)){let d=n.staticNames[b]??b;if(y.has(d)||v.has(b)||!f&&!Ze(d))h.add(b)}for(let b of Object.keys(n.serverDynamic)){let d=n.serverDynamicNames?.[b]??b;if(y.has(d)||v.has(b)||!f&&!Ze(d))h.add(b)}let C=[];if(f){for(let[b,d]of Object.entries(n.static)){if(h.has(b)||d!==!0&&d!==ne)continue;h.add(b),C.push(`${r(n.staticNames?.[b]??b)}="true"`)}for(let[b,d]of Object.entries(n.serverDynamic)){if(h.has(b)||d!==!0)continue;h.add(b),C.push(`${r(n.serverDynamicNames?.[b]??b)}="true"`)}}let S=[...re(n,h),...ie(n,h),...C];if(f){for(let[b,d]of Object.entries(n.serverDynamic)){if(h.has(b)||d!==!1)continue;let x=n.serverDynamicNames?.[b]??b;S.push(`${r(x)}="false"`)}for(let[b,d]of Object.entries(n.serverDynamic)){if(h.has(b)||d===null||typeof d!=="object")continue;let x=JSON.stringify(d);if(x!==void 0){let k=n.serverDynamicNames?.[b]??b;S.push(`${r(k)}="${r(x)}"`)}}}if(S.length===0)return e;return`${e.slice(0,i.insertPos)} ${S.join(" ")}${e.slice(i.insertPos)}`}function be(e){let i=nn(e,0);if(i)return i;let n=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(n)return{insertPos:n.index+1+n[1].length,tagEnd:ht(e,n.index+1+n[1].length)};return null}function pt(e,i=!1){let n=be(e);if(!n)return null;let o=e.slice(n.insertPos,n.tagEnd),a=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(o)?nn(e,n.tagEnd+1):n;return a&&i?ur(e,a)??a:a}function ur(e,i){return tn(e,i)[0]??null}function tn(e,i){let n=[];if(!e.includes("data-stx-native-host-root"))return n;let o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),a=e.lastIndexOf("<",i.insertPos),c=0,l;while(a>=0&&a<e.length){if(e.startsWith("<!--",a)){let h=e.indexOf("-->",a+4);if(h<0)return n;a=e.indexOf("<",h+3);continue}let u=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(a));if(!u){a=e.indexOf("<",a+1);continue}let f=u[2].toLowerCase(),v=a+u[0].length,y=ht(e,v);if(u[1]){if(c--,l!==void 0&&c<l)l=void 0;if(c<=0)return n}else if(f==="script"||f==="style"){let h=new RegExp(`</${f}\\s*>`,"gi");if(h.lastIndex=y+1,!h.exec(e))return n;a=e.indexOf("<",h.lastIndex);continue}else{let h=ye(e.slice(v,y)),C=c>0&&(Object.hasOwn(h,"data-stx-component-wrapper")||Object.hasOwn(h,"data-stx-native-host-owner")),S=l===void 0&&!C&&Object.hasOwn(h,"data-stx-native-host-root");if(S)n.push({insertPos:v,tagEnd:y});if(!o.has(f)&&e[y-1]!=="/"){if(c++,l===void 0&&(C||S))l=c}else if(c===0)return n}a=e.indexOf("<",y+1)}return n}function nn(e,i){let n=i;while(n<e.length){let o=e.slice(n),a=o.match(/^\s+/);if(a){n+=a[0].length;continue}if(o.startsWith("<!--")){let u=e.indexOf("-->",n+4);if(u===-1)return null;n=u+3;continue}let c=o.match(/^<(script|style)\b[^>]*>/i);if(c){let u=`</${c[1].toLowerCase()}>`,f=e.toLowerCase().indexOf(u,n+c[0].length);if(f===-1)return null;n=f+u.length;continue}let l=o.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!l)return null;return{insertPos:n+1+l[1].length,tagEnd:ht(e,n+1+l[1].length)}}return null}function ht(e,i){let n="";for(let o=i;o<e.length;o++){let a=e[o];if(n){if(a==="\\")o++;else if(a===n)n=""}else if(a==='"'||a==="'")n=a;else if(a===">")return o}return e.length}function fr(e){let i=new Set;for(let n of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let o=n[1];if(!/\bclient\b/.test(o)||/\bserver\b/.test(o))continue;for(let a of Ni(n[2]))i.add(a);for(let a of n[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(a[1])i.add(a[1]);if(a[3])i.add(a[3]);for(let c of(a[2]??"").split(",")){let l=c.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(l))i.add(l)}}}return i}async function Rs(e,i,n,o,a){if(!Jt)Lt(fe),Jt=!0;let c=await dg(e,i,n,o,a);c=await or(c,i,n,o,a),c=await ar(c,i,n,o,a);let l=[];for(let u=0;u<3;u++){let f=l.length,v=ke(c,qe,(h,C)=>`\x00STX_COMPONENT_COMMENT_${f+C}\x00`,`STX_COMPONENT_COMMENT:${f}`);l.push(...v.tokens);let y=c;if(c=await cr(v.output,i,n,o,a),c===y)break}if(l.length>0)c=c.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(u,f)=>l[Number(f)]??"");if(o.debug){let u=ir(c);if(u.length>0)console.warn(`[stx] ${n}: unresolved component tag(s) after render passes: ${u.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return c}
42
42
  export{oi,ii,ai,ly,$s,uy,kn,Nc,dy,py,dg,Rs};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{rl,s,Ce}from"./chunk-p80nnmha.js";import{gt}from"./chunk-zkwkhesc.js";import{l}from"./chunk-pjpy86c3.js";import o from"fs";import u from"path";var hg=new Map,m=new Map;async function gy(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function my(e){m.delete(e)}function hy(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function yy(e){x=e}async function yg(e=!1){let t=x??await import("./chunk-zrs22j09.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function bg(){if(S===null){let{getRouterScript:e}=await import("./chunk-hs2a040z.js");S=e()}return S}var y={};async function by(e,t=!1){let n=e==="runtime"?await yg(t):await bg(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,c=new Map,p=0;function C(e){return l(process.cwd(),"module-bundles",`${e}.js`)}function wy(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=c.get(t),i=n!==void 0;if(i)c.delete(t),p-=n.length*2;c.set(t,e),p+=e.length*2;while(c.size>1&&(c.size>E||p>T)){let r=c.keys().next().value;p-=c.get(r).length*2,c.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(u.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function yi(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=c.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function vy(){m.clear(),Ce(),rl(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Cr(e,t){try{if(!t.cachePath)return null;let n=u.resolve(t.cachePath),i=u.join(n,`${Ls(e)}.html`),r=u.join(n,`${Ls(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==gt())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function Er(e,t,n,i){try{if(!i.cachePath)return;let r=u.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=u.join(r,`${Ls(e)}.html`),a=u.join(r,`${Ls(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:gt(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),hg.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function Ls(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
2
+ import{rl,s,Ce}from"./chunk-4w4zjtp7.js";import{gt}from"./chunk-zkwkhesc.js";import{l}from"./chunk-pjpy86c3.js";import o from"fs";import u from"path";var hg=new Map,m=new Map;async function gy(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function my(e){m.delete(e)}function hy(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function yy(e){x=e}async function yg(e=!1){let t=x??await import("./chunk-zrs22j09.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function bg(){if(S===null){let{getRouterScript:e}=await import("./chunk-hs2a040z.js");S=e()}return S}var y={};async function by(e,t=!1){let n=e==="runtime"?await yg(t):await bg(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,c=new Map,p=0;function C(e){return l(process.cwd(),"module-bundles",`${e}.js`)}function wy(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=c.get(t),i=n!==void 0;if(i)c.delete(t),p-=n.length*2;c.set(t,e),p+=e.length*2;while(c.size>1&&(c.size>E||p>T)){let r=c.keys().next().value;p-=c.get(r).length*2,c.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(u.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function yi(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=c.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function vy(){m.clear(),Ce(),rl(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Cr(e,t){try{if(!t.cachePath)return null;let n=u.resolve(t.cachePath),i=u.join(n,`${Ls(e)}.html`),r=u.join(n,`${Ls(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==gt())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function Er(e,t,n,i){try{if(!i.cachePath)return;let r=u.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=u.join(r,`${Ls(e)}.html`),a=u.join(r,`${Ls(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:gt(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),hg.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function Ls(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
3
3
  export{hg,gy,my,hy,yy,yg,bg,by,wy,yi,vy,Cr,Er,Ls};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Y}from"./chunk-4w4zjtp7.js";function r(t){return Y(t)}
3
+ export{r};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{le,ue,de,Jn,Ee,Fe,ds,vu,$t,ln,Yn,Zn,Qn,pe,er,tr,ps}from"./chunk-7pfhr4nk.js";import"./chunk-9ejk9mwk.js";export{ue as DEFAULT_FORMATS,de as DEFAULT_QUALITY,le as DEFAULT_WIDTHS,ps as ImageProcessingError,tr as formatSize,ln as generateSizes,$t as generateSrcSet,Yn as getFallbackVariant,ds as getImageMetadata,pe as getMimeType,er as getTotalSize,Zn as groupVariantsByFormat,Ee as isImageBackendAvailable,Qn as isImageFile,Jn as isSharpAvailable,Fe as processImage,vu as resizeAndConvert};
2
+ import{le,ue,de,Jn,Ee,Fe,ds,vu,$t,ln,Yn,Zn,Qn,pe,er,tr,ps}from"./chunk-7nf7mp27.js";import"./chunk-9y83pdcb.js";export{ue as DEFAULT_FORMATS,de as DEFAULT_QUALITY,le as DEFAULT_WIDTHS,ps as ImageProcessingError,tr as formatSize,ln as generateSizes,$t as generateSrcSet,Yn as getFallbackVariant,ds as getImageMetadata,pe as getMimeType,er as getTotalSize,Zn as groupVariantsByFormat,Ee as isImageBackendAvailable,Qn as isImageFile,Jn as isSharpAvailable,Fe as processImage,vu as resizeAndConvert};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{kt,_t,Ct}from"./chunk-pwpge9bj.js";import"./chunk-hdfhaddy.js";import"./chunk-7b3dqeyr.js";import"./chunk-0jdz31q1.js";import"./chunk-5g5khx0m.js";import{y}from"./chunk-p80nnmha.js";import"./chunk-945zygwa.js";import"./chunk-esm0pnpz.js";import"./chunk-q3we5jsk.js";import{nn,_o,rn,ya,St,ba,Co,sn,va,on}from"./chunk-r0az4z6d.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ba("Config file changed, restarting...");try{await e.onChange()}catch(p){St(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,f=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:f,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:dt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function dt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{kt,_t,Ct}from"./chunk-pwpge9bj.js";import"./chunk-hdfhaddy.js";import"./chunk-7b3dqeyr.js";import"./chunk-0jdz31q1.js";import"./chunk-5g5khx0m.js";import{y}from"./chunk-4w4zjtp7.js";import"./chunk-945zygwa.js";import"./chunk-esm0pnpz.js";import"./chunk-77a17bbm.js";import{nn,_o,rn,ya,St,ba,Co,sn,va,on}from"./chunk-r0az4z6d.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ba("Config file changed, restarting...");try{await e.onChange()}catch(p){St(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,f=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:f,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",ct=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:ct,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:dt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function dt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,7 +556,7 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ut(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,mt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-15qrs231.js"),p={},u=h(n);if(u)try{await y(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function gt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await y(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await gt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return ft(t,a.source,c);return b(t,e.path,{props:c})}async function ft(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-15qrs231.js"),c={...r},n=h(e);if(n)try{await y(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var lt=".stx/story/presets.json",R=1,mt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ut(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,mt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-0xdp4nmv.js"),p={},u=h(n);if(u)try{await y(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function gt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await y(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await gt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return ft(t,a.source,c);return b(t,e.path,{props:c})}async function ft(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-0xdp4nmv.js"),c={...r},n=h(e);if(n)try{await y(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
561
  `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await sn(t);_t(t,r);let s=on(t.config,r);Ct(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return yt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return ht(t,g,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,f=va(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await sn(t);_t(t,m);let g=on(t.config,m);if(Ct(t,g),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{f(),p.stop()}}}async function yt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",f,i=n.searchParams.get("props");if(i)try{f=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,f);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function ht(t,e,r){let s=vt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function vt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{zo,zh,Hh}from"./chunk-yqdsnke6.js";import"./chunk-z2dgzcdk.js";import"./chunk-f50a18t8.js";import"./chunk-qs0zk04y.js";import"./chunk-dbxby7r4.js";import"./chunk-nddkrbz4.js";import"./chunk-vbmvft7g.js";import"./chunk-65g78sge.js";import"./chunk-fxxw0t9j.js";import"./chunk-9dbxjbzm.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import"./chunk-4w4zjtp7.js";import"./chunk-77a17bbm.js";import"./chunk-esm0pnpz.js";import"./chunk-945zygwa.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-0jdz31q1.js";import"./chunk-hdfhaddy.js";export{Hh as clearComposableCache,zh as getComposableScript,zo as listComposableModules};