@stacksjs/stx 0.2.902 → 0.2.904

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 (84) hide show
  1. package/dist/{chunk-dz51m8bm.js → chunk-0hcek8nq.js} +1 -1
  2. package/dist/{chunk-fd2d2a69.js → chunk-27qkwvbe.js} +1 -1
  3. package/dist/{chunk-8fg6gwds.js → chunk-3ahvypx3.js} +1 -1
  4. package/dist/{chunk-br1kkmbz.js → chunk-4z926gay.js} +4 -4
  5. package/dist/{chunk-jj7g3c8q.js → chunk-576wtm6d.js} +1 -1
  6. package/dist/{chunk-5883qema.js → chunk-5zcjcyys.js} +1 -1
  7. package/dist/{chunk-3ykhczg6.js → chunk-65c11t6g.js} +2 -2
  8. package/dist/{chunk-af50zx8y.js → chunk-6c8s1pax.js} +2 -2
  9. package/dist/{chunk-3mr0kx0h.js → chunk-6h6aahc8.js} +1 -1
  10. package/dist/{chunk-de3tjmqc.js → chunk-71d353be.js} +1 -1
  11. package/dist/{chunk-5c2yf28r.js → chunk-8vbx58s6.js} +4 -4
  12. package/dist/{chunk-zfrrfk0s.js → chunk-96jntfwp.js} +1 -1
  13. package/dist/{chunk-q72z9ask.js → chunk-9fcanx7q.js} +1 -1
  14. package/dist/{chunk-3xpnw4s1.js → chunk-9pjzj75t.js} +1 -1
  15. package/dist/{chunk-h1a2mk6h.js → chunk-9rxxm68c.js} +1 -1
  16. package/dist/{chunk-v650d8rj.js → chunk-9ze3xvsr.js} +1 -1
  17. package/dist/{chunk-ckey09ej.js → chunk-a1k0aj2r.js} +1 -1
  18. package/dist/chunk-am2v9pqa.js +2 -0
  19. package/dist/{chunk-bhvv6ngq.js → chunk-btyb4bfz.js} +1 -1
  20. package/dist/{chunk-wf7st1kj.js → chunk-bx5y6qsg.js} +5 -5
  21. package/dist/{chunk-dysb1g8f.js → chunk-cb9h2wwq.js} +1 -1
  22. package/dist/{chunk-g56ax995.js → chunk-dpgc8wmw.js} +1 -1
  23. package/dist/{chunk-nxat557m.js → chunk-dyz7cmf4.js} +1 -1
  24. package/dist/{chunk-k80jhkqx.js → chunk-e3svj8ex.js} +1 -1
  25. package/dist/{chunk-mphbgnta.js → chunk-essmq8yb.js} +2 -2
  26. package/dist/{chunk-6c2hsv1w.js → chunk-fcqc9yws.js} +1 -1
  27. package/dist/{chunk-6mhz9stn.js → chunk-g5nts6e0.js} +1 -1
  28. package/dist/{chunk-m59tzyqp.js → chunk-gyqg3xjp.js} +2 -2
  29. package/dist/chunk-gyzebnpx.js +2 -0
  30. package/dist/{chunk-55t633yd.js → chunk-jj1f1v1r.js} +3 -3
  31. package/dist/{chunk-v29fnbq1.js → chunk-jwvv842z.js} +4 -4
  32. package/dist/{chunk-w0sj4ehs.js → chunk-m0p328a3.js} +1 -1
  33. package/dist/chunk-m2dgf6pt.js +2 -0
  34. package/dist/chunk-mmk5xqhr.js +2 -0
  35. package/dist/{chunk-be1jvk13.js → chunk-n1wn4wvm.js} +1 -1
  36. package/dist/{chunk-s9t97mza.js → chunk-n642g6n0.js} +1 -1
  37. package/dist/{chunk-thzj12av.js → chunk-n7rwbccm.js} +3 -3
  38. package/dist/{chunk-8pmm7je2.js → chunk-n9axtmxs.js} +1 -1
  39. package/dist/{chunk-nfddhtkd.js → chunk-pd8ck9p3.js} +1 -1
  40. package/dist/{chunk-mtevtq09.js → chunk-q33x40dg.js} +1 -1
  41. package/dist/{chunk-by9s2a8d.js → chunk-q3ztpbz4.js} +1 -1
  42. package/dist/chunk-qchmvwds.js +2 -0
  43. package/dist/chunk-qx4wkt90.js +2 -0
  44. package/dist/chunk-r9rwdg9k.js +3 -0
  45. package/dist/{chunk-vaxxe2db.js → chunk-rzmk73fz.js} +1 -1
  46. package/dist/{chunk-f4jmkx33.js → chunk-s0sxq6ap.js} +1 -1
  47. package/dist/{chunk-aq5ffmrs.js → chunk-s8v6dxhg.js} +1 -1
  48. package/dist/{chunk-z9nqmatt.js → chunk-scdkctdb.js} +1 -1
  49. package/dist/chunk-sxqq3tft.js +2 -0
  50. package/dist/{chunk-8e6en8x7.js → chunk-tf0feafg.js} +1 -1
  51. package/dist/{chunk-44fmhh0e.js → chunk-tqm66mh3.js} +4 -4
  52. package/dist/{chunk-r1tf52r2.js → chunk-tx27trcp.js} +2 -2
  53. package/dist/{chunk-16edtncx.js → chunk-ty5frr9t.js} +6 -6
  54. package/dist/{chunk-fys8hswh.js → chunk-tzebte8p.js} +1 -1
  55. package/dist/chunk-v5y66rwr.js +9 -0
  56. package/dist/{chunk-xjtq49hm.js → chunk-vbq6vt0e.js} +1 -1
  57. package/dist/chunk-vh9yx344.js +2 -0
  58. package/dist/{chunk-bn1xt7t6.js → chunk-w10vj4rc.js} +1 -1
  59. package/dist/{chunk-k4gmqhat.js → chunk-w96jck0a.js} +1 -1
  60. package/dist/{chunk-27bqcv20.js → chunk-wh07jf0t.js} +1 -1
  61. package/dist/{chunk-33h2z0s5.js → chunk-xzmsfrez.js} +1 -1
  62. package/dist/{chunk-9hde8azp.js → chunk-ymeemdg9.js} +2 -2
  63. package/dist/{chunk-10cnra24.js → chunk-z43xcwnk.js} +1 -1
  64. package/dist/chunk-zb6fa26w.js +2 -0
  65. package/dist/{chunk-4n102da4.js → chunk-zve1xqvs.js} +1 -1
  66. package/dist/cli.js +7 -7
  67. package/dist/component-renderer.js +1 -1
  68. package/dist/craft-entry.js +1 -1
  69. package/dist/craft.js +1 -1
  70. package/dist/module-syntax.js +13 -0
  71. package/dist/pwa.js +1 -1
  72. package/dist/ssg.js +2 -2
  73. package/package.json +5 -5
  74. package/dist/chunk-0yhkgv37.js +0 -2
  75. package/dist/chunk-65g78sge.js +0 -9
  76. package/dist/chunk-846bpzjc.js +0 -2
  77. package/dist/chunk-b6td3pfh.js +0 -2
  78. package/dist/chunk-b7dw6rhk.js +0 -3
  79. package/dist/chunk-m67qmg51.js +0 -2
  80. package/dist/chunk-nbk4tjdy.js +0 -2
  81. package/dist/chunk-ps1khncy.js +0 -2
  82. package/dist/chunk-r368e96r.js +0 -2
  83. package/dist/chunk-xhb89sf5.js +0 -2
  84. package/dist/chunk-yc6rvmbt.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{m,p}from"./chunk-945zygwa.js";import{oe,F,g}from"./chunk-16edtncx.js";function z(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function B(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let f=t.indexOf("-->",s+4);n=f===-1?t.length:f+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function Z(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let f=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=f||N.has(c)?-1:B(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!f&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function L(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",f=u[2].toLowerCase();if(c){let l=i.lastIndexOf(f);if(l!==-1)i.splice(l);e=s;continue}if(f==="template"&&i.length===0){let l=a.match(r);if(l){let h=z(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(f)){if(i.push(f),f==="script"||f==="style"){let l=t.toLowerCase().indexOf(`</${f}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function yu(t){let o={default:"",named:new Map},i=t,r=L(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=Z(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Km(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function bu(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of c){let[d,l]=f.split(":").map((S)=>S.trim()),h=l||d;if(s[h]=o[d],o[d]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=j(e,s,a,u)}return e}function j(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(F(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!F(s,r))return e;let a=_(s,o);if(a===void 0)return e;return g(String(a??""))}catch{return`{{ ${n} }}`}})}function _(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!m(t))return;return p(t,Object.keys(o))(...Object.values(o))}catch{return}}async function wu(t,o,i,r){let e=t;e=await I(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,f)=>{let d=o.named.get(u),l=f?.trim()||"",h=c||"",S={},E=[],C=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=C.exec(h))!==null){let w=b[1],x=b[2];S[w]=_(x,i),E.push([w,x])}if(r!==void 0&&d?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=d.propsBinding.trim(),x=oe(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let M=E.map(([A,P])=>{let O=S[A],R;try{R=O===void 0?void 0:JSON.stringify(O)}catch{}return`${JSON.stringify(A)}:(${R??P})`}).join(","),v=g(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${g(`${y} in [{${M}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${v}">${d.content}</template>`}return await bu(d,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let f=c?.trim()||"";return o.default||f}),e}async function I(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function Gm(t){let o=yu(t);return{defaultSlot:o.default,namedSlots:o.named}}async function Xm(t,o,i,r,e){return await wu(t,{default:o,named:i},r,e)}
2
+ import{m,p}from"./chunk-945zygwa.js";import{oe,F,g}from"./chunk-ty5frr9t.js";function z(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function B(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let f=t.indexOf("-->",s+4);n=f===-1?t.length:f+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function Z(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let f=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=f||N.has(c)?-1:B(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!f&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function L(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",f=u[2].toLowerCase();if(c){let l=i.lastIndexOf(f);if(l!==-1)i.splice(l);e=s;continue}if(f==="template"&&i.length===0){let l=a.match(r);if(l){let h=z(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(f)){if(i.push(f),f==="script"||f==="style"){let l=t.toLowerCase().indexOf(`</${f}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function yu(t){let o={default:"",named:new Map},i=t,r=L(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=Z(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Km(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function bu(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of c){let[d,l]=f.split(":").map((S)=>S.trim()),h=l||d;if(s[h]=o[d],o[d]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=j(e,s,a,u)}return e}function j(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(F(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!F(s,r))return e;let a=_(s,o);if(a===void 0)return e;return g(String(a??""))}catch{return`{{ ${n} }}`}})}function _(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!m(t))return;return p(t,Object.keys(o))(...Object.values(o))}catch{return}}async function wu(t,o,i,r){let e=t;e=await I(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,f)=>{let d=o.named.get(u),l=f?.trim()||"",h=c||"",S={},E=[],C=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=C.exec(h))!==null){let w=b[1],x=b[2];S[w]=_(x,i),E.push([w,x])}if(r!==void 0&&d?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=d.propsBinding.trim(),x=oe(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let M=E.map(([A,P])=>{let O=S[A],R;try{R=O===void 0?void 0:JSON.stringify(O)}catch{}return`${JSON.stringify(A)}:(${R??P})`}).join(","),v=g(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${g(`${y} in [{${M}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${v}">${d.content}</template>`}return await bu(d,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let f=c?.trim()||"";return o.default||f}),e}async function I(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function Gm(t){let o=yu(t);return{defaultSlot:o.default,namedSlots:o.named}}async function Xm(t,o,i,r,e){return await wu(t,{default:o,named:i},r,e)}
3
3
  export{yu,Km,bu,wu,Gm,Xm};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Pe,uo,Kg,Ay,Gg,Py,On,g,Y,ae,Nn,Ne,Xg,Wi,Jg,Iy,P,qi,Yg,Oy,N,Ny}from"./chunk-16edtncx.js";import"./chunk-vaxxe2db.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{Yg as applyFilters,Py as clearCustomFilters,Xg as clientLoopScopes,uo as defaultFilters,Nn as escapeAttributeValue,g as escapeHtml,Y as escapeHtmlValue,ae as escapeInterpolatedHtmlValue,N as evaluateExpression,Pe as findMustacheEnd,Gg as getAllFilters,Jg as interpolateScriptAttributes,Wi as interpolateScriptExpressions,Iy as interpolateScriptsInTemplate,P as processExpressions,qi as processExpressionsChunked,Kg as registerFilter,Ay as registerFilters,On as replaceInterpolations,Oy as resetRejectedExpressionWarnings,Ny as unescapeHtml,Ne as usesSignalsInScript};
2
+ import{Pe,uo,Kg,Ay,Gg,Py,On,g,Y,ae,Nn,Ne,Xg,Wi,Jg,Iy,P,qi,Yg,Oy,N,Ny}from"./chunk-ty5frr9t.js";import"./chunk-rzmk73fz.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{Yg as applyFilters,Py as clearCustomFilters,Xg as clientLoopScopes,uo as defaultFilters,Nn as escapeAttributeValue,g as escapeHtml,Y as escapeHtmlValue,ae as escapeInterpolatedHtmlValue,N as evaluateExpression,Pe as findMustacheEnd,Gg as getAllFilters,Jg as interpolateScriptAttributes,Wi as interpolateScriptExpressions,Iy as interpolateScriptsInTemplate,P as processExpressions,qi as processExpressionsChunked,Kg as registerFilter,Ay as registerFilters,On as replaceInterpolations,Oy as resetRejectedExpressionWarnings,Ny as unescapeHtml,Ne as usesSignalsInScript};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{P}from"./chunk-16edtncx.js";import{i}from"./chunk-44fmhh0e.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
2
+ import{P}from"./chunk-ty5frr9t.js";import{i}from"./chunk-tqm66mh3.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{hr,ze}from"./chunk-qs0zk04y.js";import{X,k,Nr,eo,A}from"./chunk-16edtncx.js";import{a,j}from"./chunk-3ykhczg6.js";import{ti}from"./chunk-6mhz9stn.js";import{Z}from"./chunk-65g78sge.js";import{gt}from"./chunk-zkwkhesc.js";import{l}from"./chunk-pjpy86c3.js";import{t,h}from"./chunk-68r2zs20.js";import d from"path";import E from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as St}from"crypto";var vt=12;function G(e,n,s){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(e))||ti(e,n,s)}var ct=2;function Jf(e){let n=process.env.STX_BUNDLE_CACHE_DIR?.trim();return n?d.resolve(n):l(e,"bundle-cache")}function rt(e,n){let s=e;for(let i of Bt(n))if(i!==d.sep)s=s.split(i).join("\x00root");return s}var it=new Map;function Bt(e){let n=d.resolve(e),s=it.get(n);if(!s){let i=n;try{i=E.realpathSync(n)}catch{}s=[...new Set([n,i])].sort((c,p)=>p.length-c.length),it.set(n,s)}return s}function jt(e,n){try{let s=E.statSync(e),i=d.resolve(n),c=e.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,e):e,...c?{inRoot:!0}:{},mtimeMs:s.mtimeMs,size:s.size,hash:Bun.hash(E.readFileSync(e)).toString(36)}}catch{return null}}function ut(e,n){return e.inRoot?d.join(d.resolve(n),e.path):e.path}function Et(e,n){for(let s of e){let i=ut(s,n);try{let c=E.statSync(i);if(c.size!==s.size)return!1;if(c.mtimeMs!==s.mtimeMs&&Bun.hash(E.readFileSync(i)).toString(36)!==s.hash)return!1}catch{return!1}}return!0}var dt=new Map,_t=100;function Yf(e=process.env){let n=Number(e.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(n)&&n>=1?Math.floor(n):2000}var q=new Map;async function Mt(e){let n=q.get(e)??0;if(n>0&&n<_t){q.set(e,n+1);return}q.set(e,1);try{let s=(await E.promises.readdir(e)).filter((o)=>o.endsWith(".js")),i=Yf();if(s.length<=i)return;let p=(await Promise.all(s.map(async(o)=>{try{return{name:o,at:(await E.promises.stat(d.join(e,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,w)=>w.at-o.at);for(let o of p.slice(i)){let w=o.name.slice(0,-3);await E.promises.rm(d.join(e,`${w}.js`),{force:!0}),await E.promises.rm(d.join(e,`${w}.deps.json`),{force:!0})}T("pruned bundle cache to",i,"entries")}catch{}}function Te(e){return dt.get(e)??[]}function Y(e,n){if(e)dt.set(e,n)}function Zf(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function T(...e){if(Zf())console.log("[stx:bundler]",...e)}var et=[];function Ec(e,n,s){et.push({filePath:e||"<inline>",message:n,details:s})}function mn(){return et.slice()}function hn(){et.length=0}var K;function ty(e){K=e}function Tc(){if(K)return K;try{let e=j.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var tt=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function yn(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,s;while((s=n.exec(e))!==null){let c=s[1];if(!tt.some((o)=>o.test(c)))return T("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((s=i.exec(e))!==null){let c=s[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!tt.some((o)=>o.test(c)))return T("detected side-effect import:",c),!0}return!1}var mr="stx-module:",Rt=/\.(?:[cm]?[jt]sx?|json)$/i;function Qf(e,n){return d.relative(e,n).split(d.sep).join("/")}function eg(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(s,i,c,p)=>{let o=n.get(p);return o&&!p.startsWith(mr)?`${i}${c}${o}${c}`:s})}function tg(e,n){let s=0,i=(p)=>{let o=`__stxMod${s++}`,w=JSON.stringify(p);return n.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let w of p.split(",")){let C=w.trim();if(!C)continue;let R=C.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!R)continue;let S=R[1].startsWith('"')?JSON.parse(R[1]):R[1],f=R[2]??S;n.push(`var ${f} = ${o}[${JSON.stringify(S)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,w)=>{let C=w.slice(mr.length),R=i(C),S=o.trim(),f=S.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!S.startsWith("{")&&!S.startsWith("*"))n.push(`var ${f[1]} = ${R}.default;`),S=S.slice(f[0].length).trim();let v=S.match(/^\*\s*as\s+([\w$]+)$/);if(v)n.push(`var ${v[1]} = ${R};`);else if(S.startsWith("{"))c(S.replace(/^\{|\}$/g,""),R);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(mr.length)),"")),e}function ot(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,d.join(e,"index.ts"),d.join(e,"index.tsx"),d.join(e,"index.js"),d.join(e,"index.mjs")];for(let s of n)try{if(E.existsSync(s)&&E.statSync(s,{throwIfNoEntry:!1})?.isFile())return s}catch{}return}var H=new lt;function ks(e,n){let s=new Bun.CryptoHasher("md5");for(let[i,c]of[...e].sort(([p],[o])=>p<o?-1:p>o?1:0))s.update(`${i}\x00${c}\x00`);return H.run({modules:e,key:s.digest("hex").slice(0,12)},n)}var pt=new lt;function ng(e){return pt.run(!0,e)}function rg(){return pt.getStore()===!0}function $c(e){if(!rg())return;throw Error(`The client script of ${e} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function bn(){return H.getStore()?.key??""}function ft(e,n,s,i,c,p,o=new Map,w,C,R){let S=new Map([[s,i],...R??[]]),f=(B)=>B!==void 0&&S.has(B),v=(B,r,u)=>{if(G(r,e,w))return null;if(!p||!f(B)||!Rt.test(r))return null;try{if(!E.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let _=`${mr}${Qf(process.cwd(),r)}`;return o.set(u,_),{path:_,external:!0}},b=(B,r)=>{let u=f(B)?n:d.dirname(B),_=d.resolve(u,r);return ot(_)??_};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^\//},(r)=>{if(f(r.path))return{path:r.path};let u=ot(r.path);if(u){let _=v(r.importer,u,r.path);if(_)return _;if(!f(u))c.add(u);return{path:u}}return{path:r.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(r)=>{let u=b(r.importer,r.path),_=v(r.importer,u,r.path);if(_)return _;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(r)=>{let u=d.resolve(e,r.path.slice(2)),_=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let x of _)if(E.existsSync(x)&&E.statSync(x,{throwIfNoEntry:!1})?.isFile()){let D=v(r.importer,x,r.path);if(D)return D;return T(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",x),c.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(!f(r.importer))return;let u=`${mr}npm:${r.path}`;return o.set(r.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(S.has(r.path))return{contents:S.get(r.path),loader:"ts"};if(G(r.path,e,w))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let u=d.extname(r.path).toLowerCase(),_=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(r.path))c.add(r.path);let x=C?.get(r.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:E.readFileSync(r.path,"utf8"),loader:_}})}}}var Q=new Map,V=k(64),at=Symbol.for("stx.client-bundle-build-queue");function sg(e){let n=globalThis,i=(n[at]??Promise.resolve()).then(e,e);return n[at]=i.then(()=>{return},()=>{return}),i}async function wn(e,n,s={}){let i=s.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=s.minify??!1,o=s.externalizeUserModules??!0,w=s.expose?.length?[...new Set(s.expose)].sort():void 0,C=s.cacheDir||Jf(i),R=H.getStore(),S=new Bun.CryptoHasher("md5");S.update(`${vt}\x00${gt()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${p?"minified":"readable"}\x00${R?.key??""}\x00${rt(e,i)}\x00${rt(n,i)}`);let f=S.digest("hex").slice(0,12),v=d.join(C,`${f}.js`),b=V.get(v);if(b){if(eo(b.files)&&b.files.every((x)=>!G(x.path,i,c))){T("memo hit:",f);let x=b.files.map((D)=>D.path);return Y(n,x),s.collectInputs?.push(...x),b.code}V.delete(v),T("memo invalidated by dep change:",f)}let B=d.join(C,`${f}.deps.json`),r=Bun.file(v);if(await r.exists()){let x=Bun.file(B),D=!1,N=null;if(await x.exists())try{let O=JSON.parse(await x.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Et(O.files,i))N=Nr(O.files.map((g)=>ut(g,i))),D=N.length===O.files.length&&!N.some((g)=>G(g.path,i,c))}catch{D=!1}if(D){if(T("cache hit:",f),N)Y(n,N.map((L)=>L.path)),s.collectInputs?.push(...N.map((L)=>L.path));let O=await r.text(),g=new Date;if(E.promises.utimes(v,g,g).catch(()=>{}),N)V.set(v,{code:O,files:N});return O}T("cache invalidated by dep change:",f)}let u=Q.get(f);if(u){let x=await u;if(s.collectInputs)s.collectInputs.push(...(V.get(v)?.files??[]).map((D)=>D.path));return x}$c(n);let _=sg(()=>Ft(e,n,{projectRoot:i,minify:p,cacheDir:C,hash:f,cachePath:v,depsPath:B,collectInputs:s.collectInputs,externalizeUserModules:o,serverApi:c,expose:w,throwOnFailure:s.throwOnFailure,substitutes:R?.modules}));Q.set(f,_);try{return await _}finally{Q.delete(f)}}function Rc(e){return`${e}-${process.pid}-${St()}`}async function ny(e,n){let{projectRoot:s}=n,i=Rc(new Bun.CryptoHasher("md5").update([...e.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(s,"bundle-tmp"),"out",i);E.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,w=0;for(let[f,v]of e){let b=d.join(s,`.stx-split-${i}-${w++}.ts`);p.set(b,v),o.set(d.basename(b).replace(/\.ts$/,""),f)}let[C,R]=[...p][0],S=new Set;$c(n.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[ft(s,d.dirname(n.filePath),C,R,S,!1,new Map,void 0,H.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...A()},root:s});if(!f.success)throw Error(f.logs.filter((b)=>b.level==="error").map((b)=>b.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let b of f.outputs){let B=d.basename(b.path);if(b.kind==="entry-point"){let r=o.get(B.replace(/\.js$/,""));if(r!==void 0)v.entries.set(r,await b.text())}else if(b.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await b.text())}return n.collectInputs?.push(...S),v}finally{try{E.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Ft(e,n,s){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:w,depsPath:C,externalizeUserModules:R}=s,S=l(i,"bundle-tmp"),f=Rc(o),v=d.join(i,`.stx-client-${f}.ts`),b=d.join(S,"out",f);E.mkdirSync(b,{recursive:!0});let B=d.dirname(n),r=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,_=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,x=t(e),{depths:D,balanced:N}=h(x),O=(F)=>!N||D[F]===0,g;while((g=u.exec(x))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((F)=>{let m=It(F);if(m)r.add(m)});else if(g[3])r.add(g[3])}while((g=_.exec(x))!==null){if(g[1])continue;if(!O(g.index))continue;r.add(g[2])}let L=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=L.exec(x))!==null){if(!O(g.index))continue;let F=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(F&&tt.some((m)=>m.test(F)))continue;if(g[1])r.add(g[1]);if(g[2])r.add(g[2]);for(let m of(g[3]??"").split(",")){let M=m.trim();if(!M||/^type\s/.test(M))continue;let P=/\bas\s+(\w+)\s*$/.exec(M)?.[1]??/^\w+$/.exec(M)?.[0];if(P)r.add(P)}}for(let F of x.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of F[1].split(",")){let M=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(M)r.delete(M)}let mt=r.size>0?`
2
+ import{Z}from"./chunk-v5y66rwr.js";import{hr,ze}from"./chunk-qs0zk04y.js";import{X,k,Nr,eo,A}from"./chunk-ty5frr9t.js";import{a,j}from"./chunk-65c11t6g.js";import{ti}from"./chunk-g5nts6e0.js";import{gt}from"./chunk-zkwkhesc.js";import{l}from"./chunk-pjpy86c3.js";import{t,h}from"./chunk-68r2zs20.js";import d from"path";import E from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as St}from"crypto";var vt=12;function G(e,n,s){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(e))||ti(e,n,s)}var ct=2;function Jf(e){let n=process.env.STX_BUNDLE_CACHE_DIR?.trim();return n?d.resolve(n):l(e,"bundle-cache")}function rt(e,n){let s=e;for(let i of Bt(n))if(i!==d.sep)s=s.split(i).join("\x00root");return s}var it=new Map;function Bt(e){let n=d.resolve(e),s=it.get(n);if(!s){let i=n;try{i=E.realpathSync(n)}catch{}s=[...new Set([n,i])].sort((c,p)=>p.length-c.length),it.set(n,s)}return s}function jt(e,n){try{let s=E.statSync(e),i=d.resolve(n),c=e.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,e):e,...c?{inRoot:!0}:{},mtimeMs:s.mtimeMs,size:s.size,hash:Bun.hash(E.readFileSync(e)).toString(36)}}catch{return null}}function ut(e,n){return e.inRoot?d.join(d.resolve(n),e.path):e.path}function Et(e,n){for(let s of e){let i=ut(s,n);try{let c=E.statSync(i);if(c.size!==s.size)return!1;if(c.mtimeMs!==s.mtimeMs&&Bun.hash(E.readFileSync(i)).toString(36)!==s.hash)return!1}catch{return!1}}return!0}var dt=new Map,_t=100;function Yf(e=process.env){let n=Number(e.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(n)&&n>=1?Math.floor(n):2000}var q=new Map;async function Mt(e){let n=q.get(e)??0;if(n>0&&n<_t){q.set(e,n+1);return}q.set(e,1);try{let s=(await E.promises.readdir(e)).filter((o)=>o.endsWith(".js")),i=Yf();if(s.length<=i)return;let p=(await Promise.all(s.map(async(o)=>{try{return{name:o,at:(await E.promises.stat(d.join(e,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,w)=>w.at-o.at);for(let o of p.slice(i)){let w=o.name.slice(0,-3);await E.promises.rm(d.join(e,`${w}.js`),{force:!0}),await E.promises.rm(d.join(e,`${w}.deps.json`),{force:!0})}T("pruned bundle cache to",i,"entries")}catch{}}function Te(e){return dt.get(e)??[]}function Y(e,n){if(e)dt.set(e,n)}function Zf(e=process.env){return e.STX_DEBUG==="true"||e.STX_DEBUG==="1"}function T(...e){if(Zf())console.log("[stx:bundler]",...e)}var et=[];function Ec(e,n,s){et.push({filePath:e||"<inline>",message:n,details:s})}function mn(){return et.slice()}function hn(){et.length=0}var K;function ty(e){K=e}function Tc(){if(K)return K;try{let e=j.strict;return typeof e==="object"&&e!==null?e.bundlerFallback??"warn":"warn"}catch{return"warn"}}var tt=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function yn(e){let n=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,s;while((s=n.exec(e))!==null){let c=s[1];if(!tt.some((o)=>o.test(c)))return T("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((s=i.exec(e))!==null){let c=s[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!tt.some((o)=>o.test(c)))return T("detected side-effect import:",c),!0}return!1}var mr="stx-module:",Rt=/\.(?:[cm]?[jt]sx?|json)$/i;function Qf(e,n){return d.relative(e,n).split(d.sep).join("/")}function eg(e,n){if(n.size===0)return e;return e.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(s,i,c,p)=>{let o=n.get(p);return o&&!p.startsWith(mr)?`${i}${c}${o}${c}`:s})}function tg(e,n){let s=0,i=(p)=>{let o=`__stxMod${s++}`,w=JSON.stringify(p);return n.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let w of p.split(",")){let C=w.trim();if(!C)continue;let R=C.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!R)continue;let S=R[1].startsWith('"')?JSON.parse(R[1]):R[1],f=R[2]??S;n.push(`var ${f} = ${o}[${JSON.stringify(S)}];`)}};return e=e.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,w)=>{let C=w.slice(mr.length),R=i(C),S=o.trim(),f=S.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!S.startsWith("{")&&!S.startsWith("*"))n.push(`var ${f[1]} = ${R}.default;`),S=S.slice(f[0].length).trim();let v=S.match(/^\*\s*as\s+([\w$]+)$/);if(v)n.push(`var ${v[1]} = ${R};`);else if(S.startsWith("{"))c(S.replace(/^\{|\}$/g,""),R);return""}),e=e.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(mr.length)),"")),e}function ot(e){let n=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,d.join(e,"index.ts"),d.join(e,"index.tsx"),d.join(e,"index.js"),d.join(e,"index.mjs")];for(let s of n)try{if(E.existsSync(s)&&E.statSync(s,{throwIfNoEntry:!1})?.isFile())return s}catch{}return}var H=new lt;function ks(e,n){let s=new Bun.CryptoHasher("md5");for(let[i,c]of[...e].sort(([p],[o])=>p<o?-1:p>o?1:0))s.update(`${i}\x00${c}\x00`);return H.run({modules:e,key:s.digest("hex").slice(0,12)},n)}var pt=new lt;function ng(e){return pt.run(!0,e)}function rg(){return pt.getStore()===!0}function $c(e){if(!rg())return;throw Error(`The client script of ${e} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function bn(){return H.getStore()?.key??""}function ft(e,n,s,i,c,p,o=new Map,w,C,R){let S=new Map([[s,i],...R??[]]),f=(B)=>B!==void 0&&S.has(B),v=(B,r,u)=>{if(G(r,e,w))return null;if(!p||!f(B)||!Rt.test(r))return null;try{if(!E.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let _=`${mr}${Qf(process.cwd(),r)}`;return o.set(u,_),{path:_,external:!0}},b=(B,r)=>{let u=f(B)?n:d.dirname(B),_=d.resolve(u,r);return ot(_)??_};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),B.onResolve({filter:/^\//},(r)=>{if(f(r.path))return{path:r.path};let u=ot(r.path);if(u){let _=v(r.importer,u,r.path);if(_)return _;if(!f(u))c.add(u);return{path:u}}return{path:r.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(r)=>{let u=b(r.importer,r.path),_=v(r.importer,u,r.path);if(_)return _;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(r)=>{let u=d.resolve(e,r.path.slice(2)),_=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let x of _)if(E.existsSync(x)&&E.statSync(x,{throwIfNoEntry:!1})?.isFile()){let D=v(r.importer,x,r.path);if(D)return D;return T(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",x),c.add(x),{path:x}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(!f(r.importer))return;let u=`${mr}npm:${r.path}`;return o.set(r.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(S.has(r.path))return{contents:S.get(r.path),loader:"ts"};if(G(r.path,e,w))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let u=d.extname(r.path).toLowerCase(),_=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(r.path))c.add(r.path);let x=C?.get(r.path);if(x!==void 0)return{contents:x,loader:"js"};return{contents:E.readFileSync(r.path,"utf8"),loader:_}})}}}var Q=new Map,V=k(64),at=Symbol.for("stx.client-bundle-build-queue");function sg(e){let n=globalThis,i=(n[at]??Promise.resolve()).then(e,e);return n[at]=i.then(()=>{return},()=>{return}),i}async function wn(e,n,s={}){let i=s.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=s.minify??!1,o=s.externalizeUserModules??!0,w=s.expose?.length?[...new Set(s.expose)].sort():void 0,C=s.cacheDir||Jf(i),R=H.getStore(),S=new Bun.CryptoHasher("md5");S.update(`${vt}\x00${gt()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${p?"minified":"readable"}\x00${R?.key??""}\x00${rt(e,i)}\x00${rt(n,i)}`);let f=S.digest("hex").slice(0,12),v=d.join(C,`${f}.js`),b=V.get(v);if(b){if(eo(b.files)&&b.files.every((x)=>!G(x.path,i,c))){T("memo hit:",f);let x=b.files.map((D)=>D.path);return Y(n,x),s.collectInputs?.push(...x),b.code}V.delete(v),T("memo invalidated by dep change:",f)}let B=d.join(C,`${f}.deps.json`),r=Bun.file(v);if(await r.exists()){let x=Bun.file(B),D=!1,N=null;if(await x.exists())try{let O=JSON.parse(await x.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Et(O.files,i))N=Nr(O.files.map((g)=>ut(g,i))),D=N.length===O.files.length&&!N.some((g)=>G(g.path,i,c))}catch{D=!1}if(D){if(T("cache hit:",f),N)Y(n,N.map((L)=>L.path)),s.collectInputs?.push(...N.map((L)=>L.path));let O=await r.text(),g=new Date;if(E.promises.utimes(v,g,g).catch(()=>{}),N)V.set(v,{code:O,files:N});return O}T("cache invalidated by dep change:",f)}let u=Q.get(f);if(u){let x=await u;if(s.collectInputs)s.collectInputs.push(...(V.get(v)?.files??[]).map((D)=>D.path));return x}$c(n);let _=sg(()=>Ft(e,n,{projectRoot:i,minify:p,cacheDir:C,hash:f,cachePath:v,depsPath:B,collectInputs:s.collectInputs,externalizeUserModules:o,serverApi:c,expose:w,throwOnFailure:s.throwOnFailure,substitutes:R?.modules}));Q.set(f,_);try{return await _}finally{Q.delete(f)}}function Rc(e){return`${e}-${process.pid}-${St()}`}async function ny(e,n){let{projectRoot:s}=n,i=Rc(new Bun.CryptoHasher("md5").update([...e.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(s,"bundle-tmp"),"out",i);E.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,w=0;for(let[f,v]of e){let b=d.join(s,`.stx-split-${i}-${w++}.ts`);p.set(b,v),o.set(d.basename(b).replace(/\.ts$/,""),f)}let[C,R]=[...p][0],S=new Set;$c(n.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[ft(s,d.dirname(n.filePath),C,R,S,!1,new Map,void 0,H.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...A()},root:s});if(!f.success)throw Error(f.logs.filter((b)=>b.level==="error").map((b)=>b.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let b of f.outputs){let B=d.basename(b.path);if(b.kind==="entry-point"){let r=o.get(B.replace(/\.js$/,""));if(r!==void 0)v.entries.set(r,await b.text())}else if(b.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await b.text())}return n.collectInputs?.push(...S),v}finally{try{E.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Ft(e,n,s){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:w,depsPath:C,externalizeUserModules:R}=s,S=l(i,"bundle-tmp"),f=Rc(o),v=d.join(i,`.stx-client-${f}.ts`),b=d.join(S,"out",f);E.mkdirSync(b,{recursive:!0});let B=d.dirname(n),r=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,_=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,x=t(e),{depths:D,balanced:N}=h(x),O=(F)=>!N||D[F]===0,g;while((g=u.exec(x))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((F)=>{let m=It(F);if(m)r.add(m)});else if(g[3])r.add(g[3])}while((g=_.exec(x))!==null){if(g[1])continue;if(!O(g.index))continue;r.add(g[2])}let L=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=L.exec(x))!==null){if(!O(g.index))continue;let F=/^\s*['"]([^'"]+)['"]/.exec(e.slice(g.index+g[0].length))?.[1];if(F&&tt.some((m)=>m.test(F)))continue;if(g[1])r.add(g[1]);if(g[2])r.add(g[2]);for(let m of(g[3]??"").split(",")){let M=m.trim();if(!M||/^type\s/.test(M))continue;let P=/\bas\s+(\w+)\s*$/.exec(M)?.[1]??/^\w+$/.exec(M)?.[0];if(P)r.add(P)}}for(let F of x.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of F[1].split(",")){let M=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(M)r.delete(M)}let mt=r.size>0?`
3
3
  export { ${[...r].join(", ")} }`:"";T("bundling:",o,"from:",d.basename(n));let nt=new Set,st=new Map;try{let F=await Bun.build({entrypoints:[v],outdir:b,target:"browser",format:"esm",minify:c?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[ft(i,B,v,e+mt,nt,R,st,s.serverApi,s.substitutes)],define:{"process.env.NODE_ENV":c?'"production"':'"development"',...A()},root:i});if(!F.success){let I=F.logs.filter((U)=>U.level==="error").map((U)=>U.message).join(", ")||`Unable to bundle ${d.basename(n)}`,z=hr(F.logs,n||void 0);if(console.warn("[stx:bundler] build failed:",I),Ec(n||"",I,z),s.throwOnFailure||Tc()==="error")throw Error(I);return e}let m="";for(let y of F.outputs){m=await y.text();break}let M=[];for(let y of m.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of y[1].split(",")){let z=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){M.push([z[2],z[1]]);continue}let U=I.trim();if(/^[A-Za-z_$][\w$]*$/.test(U))M.push([U,U])}if(s.expose){let y=new Set(s.expose);for(let I=M.length-1;I>=0;I--)if(!y.has(M[I][0]))M.splice(I,1)}let P=[];m=tg(eg(m,st),P);let ht=m.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(m=m.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),c&&m)try{m=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(m)}catch{}let xt=Z(m),W=`__stxBundle_${o}`,yt=new Set(X(e,!0).split(",").map((y)=>y.trim())),$t=M.map(([y,I])=>`get ${JSON.stringify(y)}() { return ${I} }${yt.has(y)?`, set ${JSON.stringify(y)}(__stxValue_${I}) { ${I} = __stxValue_${I} }`:""}`).join(", "),bt=M.map(([y])=>`var ${y} = undefined;`).join(`
4
4
  `),wt=M.map(([y])=>`${y} = ${W}[${JSON.stringify(y)}];`).join(`
5
5
  `);if(m=`${ht.join(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ay,ug,ct,Oc,cy,Cs,Es,Ts}from"./chunk-5c2yf28r.js";import"./chunk-9hde8azp.js";import"./chunk-b7dw6rhk.js";import"./chunk-5jrpzepc.js";import"./chunk-vbmvft7g.js";import"./chunk-16edtncx.js";import"./chunk-vaxxe2db.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{cy as clearOnceStore,Oc as onceStore,ct as partialsCache,Cs as processIncludes,Es as processStackPushDirectives,Ts as processStackReplacements,ay as resetUnscopedSignalWarnings,ug as topLevelElements};
2
+ import{ay,ug,ct,Oc,cy,Cs,Es,Ts}from"./chunk-8vbx58s6.js";import"./chunk-ymeemdg9.js";import"./chunk-r9rwdg9k.js";import"./chunk-5jrpzepc.js";import"./chunk-vbmvft7g.js";import"./chunk-ty5frr9t.js";import"./chunk-rzmk73fz.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{cy as clearOnceStore,Oc as onceStore,ct as partialsCache,Cs as processIncludes,Es as processStackPushDirectives,Ts as processStackReplacements,ay as resetUnscopedSignalWarnings,ug as topLevelElements};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Dh,Fo,Lh,jh,Bh,Fh}from"./chunk-n9axtmxs.js";import"./chunk-9ze3xvsr.js";import"./chunk-g5nts6e0.js";import"./chunk-qs0zk04y.js";import"./chunk-essmq8yb.js";import"./chunk-4z926gay.js";import"./chunk-vbmvft7g.js";import"./chunk-v5y66rwr.js";import"./chunk-65c11t6g.js";import"./chunk-n1wn4wvm.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import"./chunk-ty5frr9t.js";import"./chunk-rzmk73fz.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{Fh as clearStoreCache,Dh as getStoreScript,Bh as getStoreScriptFor,jh as pageStoresAll,Fo as storesRead,Lh as storesReadInFiles};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ft}from"./chunk-0b57fgpn.js";import{At,sr}from"./chunk-qt2mr3f0.js";import{ye,Rn,El,Tl}from"./chunk-16edtncx.js";import{Wr,qr,Kr,Xr,De}from"./chunk-945zygwa.js";import{z}from"./chunk-esm0pnpz.js";import{Ki}from"./chunk-vaxxe2db.js";import{S}from"./chunk-af50zx8y.js";import{i}from"./chunk-44fmhh0e.js";import{q,a}from"./chunk-3ykhczg6.js";import{Jc}from"./chunk-vw7crz0z.js";import{qn,Kn,rt,Be,Ma,Da,Gn}from"./chunk-55t633yd.js";import{vn,Qo}from"./chunk-6mhz9stn.js";import{Xn}from"./chunk-gnf1e5q7.js";import{fn,fr,gr}from"./chunk-arfpzf17.js";import{re}from"./chunk-br1kkmbz.js";import m from"fs";import c from"path";import{createHash as Y}from"crypto";function I(n){return Y("sha256").update(n).digest("hex").slice(0,8)}function W(n=!1){let l=n?sr():At(),o=I(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function J(){let n=ft(),l=I(n);return{content:n,filename:`router.${l}.js`,hash:l}}import U from"path";import{createHash as Q}from"crypto";function ee(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function V(n,l,o={}){let r=U.resolve(n),e=await Bun.file(r).text(),x=Q("sha256").update(e).digest("hex").slice(0,16);El();let _={};try{_=await a(o.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>ye(R))),{context:D}=ee({__filename:r,__dirname:U.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...q,..._,...o,buildMode:"compile",strict:!1},f=await i(e,D,r,T,A),w=qn(f)+Kn(f)+rt(f),j=Tl();return{route:l,sourceFile:n,html:f,fragment:w,placeholders:j,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(A),contentHash:x,status:Rn(e),streamTemplates:D.__streamTemplates}}var te=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function X(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(x,_){let y=m.readdirSync(x,{withFileTypes:!0});for(let d of y){if(te.has(d.name))continue;let g=c.join(x,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Nm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),x=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=De(e.app?.head,{known:Xr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=Xn(A),f=n.serverApi??e.serverApi,w=typeof f==="object"?f:{};if(f)vn(o,w);if(e.runtimeConfig)z(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=re(o,{pagesDirs:e._layerPageDirs}),Z=["components","layouts","partials"],P=R.filter((s)=>!Z.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=W(n.debug),b=J();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",b.filename),b.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${b.filename} (${(b.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let B=[],O=[];for(let s of P){let h=T(s.pattern),M=h.rendering==="prerender";if(M&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await V(s.filePath,s.pattern,{configDir:o,componentsDir:x,partialsDir:_,layoutsDir:y,debug:n.debug});if(B.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,b.filename),t.html=Kr(t.html,g,{bodyScripts:[`<script src="/__stx/${b.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Wr(t.html,u);if(g.htmlAttrs)t.html=qr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let G=p[1];t.html=t.html.replace(" "+G,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${G}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await S(t.html),M){let p=await Gn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Be(t.html,D,!0);let N=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),K=c.join("server","pages",`${N}.compiled.json`),L=c.join("server","fragments",`${N}.html`);await Bun.write(c.join(r,K),JSON.stringify(t,null,2)),await Bun.write(c.join(r,L),t.fragment),O.push({pattern:s.pattern,compiledPath:K,fragmentPath:L,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:M}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(o,d);if(m.existsSync(H)){let{copied:s,bytes:h}=X(H,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let k=gr(o);if(k){let{copied:s,bytes:h}=X(k,c.join(r,"public",fr));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${fn}/`)}let E={runtime:v.filename,router:b.filename},C=Ma(O,E,r);if(C.routeRules=A,C.routerContainer=D,f)C.apiRoutes=await Qo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Ki(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Jc(e._layerGraph),null,2));Da(C,r);let F=Date.now()-l;return console.log(`
2
+ import{ft}from"./chunk-0b57fgpn.js";import{At,sr}from"./chunk-qt2mr3f0.js";import{ye,Rn,El,Tl}from"./chunk-ty5frr9t.js";import{Wr,qr,Kr,Xr,De}from"./chunk-945zygwa.js";import{z}from"./chunk-esm0pnpz.js";import{Ki}from"./chunk-rzmk73fz.js";import{S}from"./chunk-6c8s1pax.js";import{i}from"./chunk-tqm66mh3.js";import{q,a}from"./chunk-65c11t6g.js";import{Jc}from"./chunk-vw7crz0z.js";import{qn,Kn,rt,Be,Ma,Da,Gn}from"./chunk-jj1f1v1r.js";import{vn,Qo}from"./chunk-g5nts6e0.js";import{Xn}from"./chunk-gnf1e5q7.js";import{fn,fr,gr}from"./chunk-arfpzf17.js";import{re}from"./chunk-4z926gay.js";import m from"fs";import c from"path";import{createHash as Y}from"crypto";function I(n){return Y("sha256").update(n).digest("hex").slice(0,8)}function W(n=!1){let l=n?sr():At(),o=I(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function J(){let n=ft(),l=I(n);return{content:n,filename:`router.${l}.js`,hash:l}}import U from"path";import{createHash as Q}from"crypto";function ee(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function V(n,l,o={}){let r=U.resolve(n),e=await Bun.file(r).text(),x=Q("sha256").update(e).digest("hex").slice(0,16);El();let _={};try{_=await a(o.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>ye(R))),{context:D}=ee({__filename:r,__dirname:U.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...q,..._,...o,buildMode:"compile",strict:!1},f=await i(e,D,r,T,A),w=qn(f)+Kn(f)+rt(f),j=Tl();return{route:l,sourceFile:n,html:f,fragment:w,placeholders:j,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(A),contentHash:x,status:Rn(e),streamTemplates:D.__streamTemplates}}var te=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function X(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(x,_){let y=m.readdirSync(x,{withFileTypes:!0});for(let d of y){if(te.has(d.name))continue;let g=c.join(x,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Nm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),x=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=De(e.app?.head,{known:Xr,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=Xn(A),f=n.serverApi??e.serverApi,w=typeof f==="object"?f:{};if(f)vn(o,w);if(e.runtimeConfig)z(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=re(o,{pagesDirs:e._layerPageDirs}),Z=["components","layouts","partials"],P=R.filter((s)=>!Z.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=W(n.debug),b=J();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",b.filename),b.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${b.filename} (${(b.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let B=[],O=[];for(let s of P){let h=T(s.pattern),M=h.rendering==="prerender";if(M&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await V(s.filePath,s.pattern,{configDir:o,componentsDir:x,partialsDir:_,layoutsDir:y,debug:n.debug});if(B.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,b.filename),t.html=Kr(t.html,g,{bodyScripts:[`<script src="/__stx/${b.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Wr(t.html,u);if(g.htmlAttrs)t.html=qr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let G=p[1];t.html=t.html.replace(" "+G,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${G}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await S(t.html),M){let p=await Gn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Be(t.html,D,!0);let N=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),K=c.join("server","pages",`${N}.compiled.json`),L=c.join("server","fragments",`${N}.html`);await Bun.write(c.join(r,K),JSON.stringify(t,null,2)),await Bun.write(c.join(r,L),t.fragment),O.push({pattern:s.pattern,compiledPath:K,fragmentPath:L,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:M}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(o,d);if(m.existsSync(H)){let{copied:s,bytes:h}=X(H,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let k=gr(o);if(k){let{copied:s,bytes:h}=X(k,c.join(r,"public",fr));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${fn}/`)}let E={runtime:v.filename,router:b.filename},C=Ma(O,E,r);if(C.routeRules=A,C.routerContainer=D,f)C.apiRoutes=await Qo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Ki(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Jc(e._layerGraph),null,2));Da(C,r);let F=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${F}ms \u2014 ${B.length} pages compiled`),{pageCount:B.length,assets:E,outputDir:r,duration:F}}
4
4
  export{Nm};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{B,Rn,Kt,Gt,y,s,Ce,g}from"./chunk-16edtncx.js";import{Pt,He,Ac,_s,ni,ri,i}from"./chunk-44fmhh0e.js";import{we}from"./chunk-0jdz31q1.js";import{ce,Vr,Me,K,Ln}from"./chunk-945zygwa.js";import{Dt,$r,Ws,qs,Ks,Lt,jt,Bt,Ft,zt,Ht,pt}from"./chunk-0b57fgpn.js";import{Bs,a,j}from"./chunk-3ykhczg6.js";import{Tt,cn,je,U,Oa,Lo,us,rt,Na,st,Be}from"./chunk-55t633yd.js";import{Cr,Er}from"./chunk-fd2d2a69.js";import{e,Sn,vr,S}from"./chunk-af50zx8y.js";import{ct}from"./chunk-5c2yf28r.js";import{ze}from"./chunk-qs0zk04y.js";import{Un}from"./chunk-zfrrfk0s.js";import{re,Re,Ae}from"./chunk-br1kkmbz.js";import{l}from"./chunk-pjpy86c3.js";import{ne}from"./chunk-qykbjg3z.js";import{c,f}from"./chunk-p92272k0.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=An(t,o),p=Dn(t,o);return{file:n,metrics:o,issues:d,suggestions:r,performance:p}}catch(t){throw Error(`Failed to analyze template ${n}: ${t instanceof Error?t.message:String(t)}`)}}function En(n){let t=n.split(`
2
+ import{B,Rn,Kt,Gt,y,s,Ce,g}from"./chunk-ty5frr9t.js";import{Pt,He,Ac,_s,ni,ri,i}from"./chunk-tqm66mh3.js";import{we}from"./chunk-0jdz31q1.js";import{ce,Vr,Me,K,Ln}from"./chunk-945zygwa.js";import{Dt,$r,Ws,qs,Ks,Lt,jt,Bt,Ft,zt,Ht,pt}from"./chunk-0b57fgpn.js";import{Bs,a,j}from"./chunk-65c11t6g.js";import{Tt,cn,je,U,Oa,Lo,us,rt,Na,st,Be}from"./chunk-jj1f1v1r.js";import{Cr,Er}from"./chunk-27qkwvbe.js";import{e,Sn,vr,S}from"./chunk-6c8s1pax.js";import{ct}from"./chunk-8vbx58s6.js";import{ze}from"./chunk-qs0zk04y.js";import{Un}from"./chunk-96jntfwp.js";import{re,Re,Ae}from"./chunk-4z926gay.js";import{l}from"./chunk-pjpy86c3.js";import{ne}from"./chunk-qykbjg3z.js";import{c,f}from"./chunk-p92272k0.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=An(t,o),p=Dn(t,o);return{file:n,metrics:o,issues:d,suggestions:r,performance:p}}catch(t){throw Error(`Failed to analyze template ${n}: ${t instanceof Error?t.message:String(t)}`)}}function En(n){let t=n.split(`
3
3
  `),o=n.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=(o?o[1]:"").split(`
4
4
  `).length,p={conditionals:(n.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(n.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(n.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};p.total=p.conditionals+p.loops+p.includes+p.custom;let u=(n.match(/\{\{[\s\S]*?\}\}/g)||[]).length,m=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length,x=(n.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,h=u+m+x,b=(n.match(/<[A-Z][^>]*>/g)||[]).length,C=(n.match(/@(?:layout|extends)\(/g)||[]).length,R=0,O=0;for(let A of t)if(/@(?:if|unless|foreach|for|while|section)\b/.test(A)&&!/@end/.test(A)&&!/@else/.test(A))O++,R=Math.max(R,O);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(A))O--;let v=R>=4?3:0,w=Math.min(10,Math.ceil(p.total*0.5+h*0.1+b*0.3+(r>10?r*0.05:0)+v));return{lines:t.length,characters:n.length,directives:p,expressions:h,components:b,layouts:C,scriptLines:r,complexity:w}}function On(n,t){let o=[],d=Ut(n,"if","endif");if(d>0)o.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let r=Ut(n,"foreach","endforeach");if(r>0)o.push({type:"error",category:"syntax",message:`Found ${r} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let p=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(p&&p.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(n.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)o.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let m=n.match(/<img[^>]*>/g);if(m){let b=m.filter((C)=>!C.includes("alt="));if(b.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${b.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let x=n.split(`
5
5
  `).filter((b)=>b.length>120);if(x.length>0)o.push({type:"info",category:"maintainability",message:`Found ${x.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(n.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)o.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function An(n,t){let o=[];if(t.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(t.complexity>5&&t.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(t.lines>100&&t.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(t.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=n.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(t.directives.total===0&&t.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(t.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function Dn(n,t){let o=1;if(o+=t.directives.conditionals*0.1,o+=t.directives.loops*0.5,o+=t.directives.includes*2,o+=t.expressions*0.05,o+=t.components*1,t.scriptLines>10)o+=t.scriptLines*0.1;let d;if(t.expressions===0&&t.directives.total===0)d="high";else if(t.expressions<5&&t.directives.total<3)d="medium";else d="low";let r=[];if(o>10)r.push("Consider optimizing template complexity");if(d==="low"&&t.directives.total>5)r.push("Reduce dynamic content for better caching");if(t.components===0&&t.lines>40)r.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:t.complexity,cacheability:d,recommendations:r}}function Ut(n,t,o){let d=n.replace(/<!--[\s\S]*?-->/g,""),r=(d.match(new RegExp(`@${t}\\b`,"g"))||[]).length,p=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(r-p)}async function Sa(n=["**/*.stx"],t){let o=[],d=[];for(let p of n){let u=await Array.fromAsync(new Bun.Glob(p).scan({cwd:t||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((m)=>m.endsWith(".stx")))}for(let p of d)try{let u=await Pn(p);o.push(u)}catch(u){console.warn(`Failed to analyze ${p}:`,u)}let r=Mn(o);return{results:o,summary:r}}function Mn(n){let t=n.length,o=n.reduce((h,b)=>h+b.metrics.lines,0),d=t>0?n.reduce((h,b)=>h+b.metrics.complexity,0)/t:0,r=n.reduce((h,b)=>h+b.issues.length,0),p={};n.forEach((h)=>{h.issues.forEach((b)=>{p[b.category]=(p[b.category]||0)+1})});let u=t>0?n.reduce((h,b)=>h+b.performance.estimatedRenderTime,0)/t:0,m=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),x=[];if(d>6)x.push("Project has high average complexity. Consider refactoring complex templates.");if(r>t*2)x.push("High number of issues detected. Run detailed analysis on individual files.");if(p.security>0)x.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:t,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:r,issuesByCategory:p,performanceScore:m,recommendations:x}}var{serve:Wn}=globalThis.Bun;import Rt from"fs";import Qe from"path";function dt(){return`
@@ -454,7 +454,7 @@ else {
454
454
  };
455
455
  })();
456
456
  </script>
457
- `}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var Ze=null;function bt(n){if(!Ze)Ze=new Wt(n);return Ze}function ot(){if(Ze)Ze.stop(),Ze=null}import vt from"path";var et={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${vt.relative(vt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await Bs(o,d);if(p.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}n.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(o.cache&&o.cachePath){let w=await Cr(u,o);if(w){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:w,loader:"html"}}}let x=await Me(()=>Bun.file(u).text(),"",(w)=>{throw new Vr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${w.message}`)});if(!x)throw new Vr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:b,allScripts:C}=we.time("script-extraction",()=>{let w=x,A=B(x);if(A)w=A.content.trim();let W=x.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],se="",I=[];for(let k of W){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),q=D?D[1]:"";if(/\bserver\b/i.test(q))se=P;else I.push(k)}let L=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:se,templateContent:L,allScripts:I}}),R={__filename:u,__dirname:vt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await Me(()=>y(h,R,u),void 0,(w)=>{let A=new ce(`Script execution failed in ${u}: ${w.message}`,u,void 0,void 0,h.substring(0,100));if(K.log(A,{filePath:u,scriptContent:h}),o.debug)throw A});let v=await we.timeAsync("directive-processing",async()=>await i(b,R,u,o,m));if(C.length>0){let{interpolateScriptsInTemplate:w}=await import("./chunk-3xpnw4s1.js"),A=w(C.join(`
457
+ `}function Ue(n,t,o={}){let d=qn(t,o),r=c(n);if(r!==-1)return n.slice(0,r)+d+n.slice(r);if(n.includes("</html>"))return n.replace("</html>",`${d}</html>`);return n+d}function ht(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function yt(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function xt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var Ze=null;function bt(n){if(!Ze)Ze=new Wt(n);return Ze}function ot(){if(Ze)Ze.stop(),Ze=null}import vt from"path";var et={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${vt.relative(vt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await Bs(o,d);if(p.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}n.onLoad({filter:/\.stx$/},async({path:u})=>{try{let m=new Set;if(o.cache&&o.cachePath){let w=await Cr(u,o);if(w){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:w,loader:"html"}}}let x=await Me(()=>Bun.file(u).text(),"",(w)=>{throw new Vr(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${w.message}`)});if(!x)throw new Vr(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:b,allScripts:C}=we.time("script-extraction",()=>{let w=x,A=B(x);if(A)w=A.content.trim();let W=x.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],se="",I=[];for(let k of W){let P=k.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",D=k.match(/<script\b([^>]*)>/i),q=D?D[1]:"";if(/\bserver\b/i.test(q))se=P;else I.push(k)}let L=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:se,templateContent:L,allScripts:I}}),R={__filename:u,__dirname:vt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await Me(()=>y(h,R,u),void 0,(w)=>{let A=new ce(`Script execution failed in ${u}: ${w.message}`,u,void 0,void 0,h.substring(0,100));if(K.log(A,{filePath:u,scriptContent:h}),o.debug)throw A});let v=await we.timeAsync("directive-processing",async()=>await i(b,R,u,o,m));if(C.length>0){let{interpolateScriptsInTemplate:w}=await import("./chunk-9pjzj75t.js"),A=w(C.join(`
458
458
  `),R),W=v.search(/<\/body>/i);if(W!==-1)v=v.slice(0,W)+A+`
459
459
  `+v.slice(W);else v+=`
460
460
  ${A}`}if(v=await Ae(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await Er(u,v,m,o),o.debug)console.log(`Cached template ${u} with ${m.size} dependencies`)}return{contents:v,loader:"html"}}catch(m){let x=m instanceof Error?m:new ce(`Plugin processing failed: ${String(m)}`,u);if(K.log(x,{filePath:u,buildConfig:n.config}),Ln.logDetailedError(x,{filePath:u,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",x);let h=x,b=h.line||null,C=h.context||null;return{contents:o.debug||ne()?`<!DOCTYPE html>
@@ -517,7 +517,7 @@ ${A}`}if(v=await Ae(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await E
517
517
  <h1>Something went wrong</h1>
518
518
  <p>An internal error occurred. Please try again later.</p>
519
519
  </body>
520
- </html>`,loader:"html"}}})}};async function ss(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=ge.resolve(n);if(!Ie.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Et(m,t);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let x=l(process.cwd(),"output");Ie.mkdirSync(x,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${n}${e.reset}...`);let h=null,b=async()=>{try{let P={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},D=await Bun.build({entrypoints:[m],outdir:x,plugins:[P,et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!D.success)return console.error(`${e.red}Build failed:${e.reset}`,D.logs),!1;let q=D.outputs.find((xe)=>xe.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(q.path).text(),!0}catch(P){return console.error(`${e.red}Error building stx file:${e.reset}`,P),!1}};if(!await b())return!1;let R=ge.dirname(m);await Sn(R);let O=o;try{if(O=await Ve(o),O!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${O} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let P=t.hmrPort||O+1;p=bt({wsPort:P,verbose:!1}),u=p.start(P)}let v={},w=null,A;try{let{loadStxConfig:P}=await import("./chunk-m67qmg51.js"),D=await P();if(A=t.stxOptions?.serverApi??D.serverApi,D?.apiRouter)w=D?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(D?.apiRoutes){v=D.apiRoutes;let q=Object.keys(v).length;if(q>0)console.log(`${e.blue}Loaded ${e.bright}${q} API route${q>1?"s":""}${e.reset}`)}if(D?.broadcasting?.enabled)try{let{startBroadcasting:q,loadChannels:Q}=await import("./chunk-cvxg2rc1.js"),xe=D.broadcasting;await q(xe);let pe=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let ke=ge.join(process.cwd(),"channels.ts");if(Ie.existsSync(ke))try{let ie=await Q(ke);console.log(`${e.blue}Loaded ${e.bright}${ie} broadcast channel${ie!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ie){console.warn(`${e.yellow}Failed to load channels.ts: ${ie.message}${e.reset}`)}}catch(q){console.warn(`${e.yellow}Broadcasting failed to start: ${q.message}${e.reset}`)}}catch{}let{createServerApi:W,isServerApiSource:se}=await import("./chunk-8fg6gwds.js"),I=await W(process.cwd(),A);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${O}/${e.reset}...`),r)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let L=Kn({port:O,async fetch(P){return Un(P,await(async()=>{let D=new URL(P.url);if([x,ge.dirname(m),ge.join(process.cwd(),"public")].some((ie)=>se(ge.join(ie,D.pathname),process.cwd(),A)))return new Response("Not Found",{status:404});if(w)try{let ie=await w.handleRequest(P);if(ie.status!==404)return ie}catch{}if(v[D.pathname])try{return await v[D.pathname](P)}catch(ie){return new Response(JSON.stringify({error:ie.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await I(P);if(q)return q;if(D.pathname==="/")return(async()=>{let F=await S(h||"");if(r)F=Ue(F,u);if(t.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(t.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Q=ge.join(x,D.pathname);if(Ie.existsSync(Q)&&Ie.statSync(Q).isFile()){let ie=Bun.file(Q),F=ge.extname(Q).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(ie,{headers:{"Content-Type":E}})}let xe=ge.dirname(m),pe=ge.join(xe,D.pathname);if(Ie.existsSync(pe)&&Ie.statSync(pe).isFile()){let ie=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(ie,{headers:{"Content-Type":E}})}let ke=ge.join(process.cwd(),"public",D.pathname);if(Ie.existsSync(ke)&&Ie.statSync(ke).isFile()){let ie=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(ie,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(P){return new Response(`<pre>${P}
520
+ </html>`,loader:"html"}}})}};async function ss(n,t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=ge.resolve(n);if(!Ie.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Et(m,t);else if(!m.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${m}${e.reset}. Only .stx and .md files are supported.`),!1;let x=l(process.cwd(),"output");Ie.mkdirSync(x,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${n}${e.reset}...`);let h=null,b=async()=>{try{let P={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(pe)=>({path:pe.path,external:!0}))}},D=await Bun.build({entrypoints:[m],outdir:x,plugins:[P,et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!D.success)return console.error(`${e.red}Build failed:${e.reset}`,D.logs),!1;let q=D.outputs.find((xe)=>xe.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(q.path).text(),!0}catch(P){return console.error(`${e.red}Error building stx file:${e.reset}`,P),!1}};if(!await b())return!1;let R=ge.dirname(m);await Sn(R);let O=o;try{if(O=await Ve(o),O!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${O} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let P=t.hmrPort||O+1;p=bt({wsPort:P,verbose:!1}),u=p.start(P)}let v={},w=null,A;try{let{loadStxConfig:P}=await import("./chunk-gyzebnpx.js"),D=await P();if(A=t.stxOptions?.serverApi??D.serverApi,D?.apiRouter)w=D?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(D?.apiRoutes){v=D.apiRoutes;let q=Object.keys(v).length;if(q>0)console.log(`${e.blue}Loaded ${e.bright}${q} API route${q>1?"s":""}${e.reset}`)}if(D?.broadcasting?.enabled)try{let{startBroadcasting:q,loadChannels:Q}=await import("./chunk-cvxg2rc1.js"),xe=D.broadcasting;await q(xe);let pe=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${pe}/ws${e.reset}`);let ke=ge.join(process.cwd(),"channels.ts");if(Ie.existsSync(ke))try{let ie=await Q(ke);console.log(`${e.blue}Loaded ${e.bright}${ie} broadcast channel${ie!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ie){console.warn(`${e.yellow}Failed to load channels.ts: ${ie.message}${e.reset}`)}}catch(q){console.warn(`${e.yellow}Broadcasting failed to start: ${q.message}${e.reset}`)}}catch{}let{createServerApi:W,isServerApiSource:se}=await import("./chunk-3ahvypx3.js"),I=await W(process.cwd(),A);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${O}/${e.reset}...`),r)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let L=Kn({port:O,async fetch(P){return Un(P,await(async()=>{let D=new URL(P.url);if([x,ge.dirname(m),ge.join(process.cwd(),"public")].some((ie)=>se(ge.join(ie,D.pathname),process.cwd(),A)))return new Response("Not Found",{status:404});if(w)try{let ie=await w.handleRequest(P);if(ie.status!==404)return ie}catch{}if(v[D.pathname])try{return await v[D.pathname](P)}catch(ie){return new Response(JSON.stringify({error:ie.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await I(P);if(q)return q;if(D.pathname==="/")return(async()=>{let F=await S(h||"");if(r)F=Ue(F,u);if(t.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(t.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(F.includes("<html"))F=F.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;return F})().then((F)=>new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Q=ge.join(x,D.pathname);if(Ie.existsSync(Q)&&Ie.statSync(Q).isFile()){let ie=Bun.file(Q),F=ge.extname(Q).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(ie,{headers:{"Content-Type":E}})}let xe=ge.dirname(m),pe=ge.join(xe,D.pathname);if(Ie.existsSync(pe)&&Ie.statSync(pe).isFile()){let ie=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(ie,{headers:{"Content-Type":E}})}let ke=ge.join(process.cwd(),"public",D.pathname);if(Ie.existsSync(ke)&&Ie.statSync(ke).isFile()){let ie=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let Fe=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),Ne=await ie.text(),Ge=Fe.transformSync(Ne);return new Response(Ge,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(F){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(ie,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(P){return new Response(`<pre>${P}
521
521
  ${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
522
522
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
523
523
  ${e.bright}\u2192 ${e.cyan}http://localhost:${O}/${e.reset}`),console.log(`
@@ -1002,12 +1002,12 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1002
1002
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1003
1003
  ${e.bright}\u2192 ${e.cyan}http://localhost:${b}/${e.reset}`),console.log(`
1004
1004
  ${e.yellow}Routes:${e.reset}`);let R=new Set(m.map((v)=>v.routeTemplate)),O=Object.entries(u).filter(([v])=>!R.has(v)).sort(([v],[w])=>v.localeCompare(w)).map(([v,w])=>({route:v==="/"?"/":v,filePath:Se.relative(process.cwd(),w.filePath),fileType:w.fileType}));for(let v of m){let w=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");O.push({route:w,filePath:Se.relative(process.cwd(),v.filePath),fileType:"stx"})}if(O.sort((v,w)=>v.route.localeCompare(w.route)),O.forEach((v,w)=>{let W=w===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",se=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${W}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${se}`)}),console.log(`
1005
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(p,{recursive:!0},async(w,A)=>{if(!A)return;if(A.endsWith(".stx")||A.endsWith(".js")||A.endsWith(".ts")||A.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${A}${e.yellow} changed, rebuilding...${e.reset}`),ct.clear(),Ce(),await x()});process.on("SIGINT",()=>{v.close(),C.stop(),process.exit(0)})}return!0}function qt(n){return String(n??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Gn}=globalThis.Bun;import me from"fs";import oe from"path";async function Jt(n){try{return Rn(await Bun.file(n).text())}catch{return}}function Ot(n){let t=Bun.file(n),o=oe.extname(n).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},p=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(t,{headers:{"Content-Type":d[o]||"application/octet-stream",...p}})}async function is(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=oe.resolve(n),{loadStxConfig:x}=await import("./chunk-m67qmg51.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-8fg6gwds.js"),R=t.stxOptions?.serverApi??h.serverApi,O=await b(m,R),v=h.root&&h.root!=="."?oe.join(m,h.root):m,w=t.pagesDir||h.pagesDir||"pages",A=oe.join(v,w);if(!me.existsSync(A)&&!h._layerPageDirs?.some((T)=>me.existsSync(T)))return console.error(`${e.red}Error: No '${w}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${A}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${w}/index.stx for the homepage.${e.reset}`),!1;let W=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(W.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${A}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${W.length}${e.blue} routes${e.reset}`);let se=h?._pluginPageDirs||[],I=[];for(let{dir:T,prefix:_}of se)if(me.existsSync(T)){let z=re(oe.dirname(T),{pagesDir:oe.basename(T)});for(let Z of z){let X=_==="/"?Z.pattern:`${_}${Z.pattern==="/"?"":Z.pattern}`;I.push({route:{...Z,pattern:X},prefix:_})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${_}${e.reset}`)}let L=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Oa(m,t.stxOptions?.shell),P){if(k=await Lo(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${oe.relative(m,P)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Lt(),await Bt(m);let D=jt();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let q={},Q=null;try{let{loadStxConfig:T}=await import("./chunk-m67qmg51.js"),_=await T(m);if(_?.apiRouter)Q=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){q=_.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(_?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Z}=await import("./chunk-cvxg2rc1.js"),X=_.broadcasting;await z(X);let Te=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Te}/ws${e.reset}`);let be=oe.join(process.cwd(),"channels.ts");if(me.existsSync(be))try{let N=await Z(be);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let xe=l(m,"output");me.mkdirSync(xe,{recursive:!0});let pe=new Map,ke=new Set,ie=async(T)=>{let _=qs(A,T);if(!_)return null;try{let z=await Bun.build({entrypoints:[_],outdir:xe,plugins:[et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Z=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Z)return null;return await Bun.file(Z.path).text()}catch{return null}},F=new Map,E=async(T,_)=>{try{let{processDirectives:z,extractVariables:Z,defaultConfig:X,loadStxConfig:Te,injectRouterScript:be}=await import("./chunk-m67qmg51.js"),{checkCache:N,cacheTemplate:Y,readFileCached:V,templateCache:ue}=await import("./chunk-dysb1g8f.js"),G=await Te(m),We=(le)=>{if(!le)return le;if(oe.isAbsolute(le))return le;return oe.resolve(m,le)},de={...X,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=We(de.partialsDir),de.componentsDir=We(de.componentsDir),de.layoutsDir=We(de.layoutsDir),de.storesDir=We(de.storesDir||"stores"),de.cachePath=We(de.cachePath)??l(m,"cache");let M=!_&&!t.profile,J=de.cache!==!1;if(J&&M){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Le=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Le=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Le=!1;break}}if(Le){let ve=le.output;if(k)ve=rt(ve,{preserveHead:!0});let nt=F.get(T.filePath);return{route:T,content:ve,status:nt?.status??await Jt(T.filePath),headers:nt?.headers}}}}catch{}let De=await N(T.filePath,de);if(De){let _e=De;if(k)_e=rt(_e,{preserveHead:!0});let Le=F.get(T.filePath);return{route:T,content:_e,status:Le?.status??await Jt(T.filePath),headers:Le?.headers}}}let ee=J?await V(T.filePath):await Bun.file(T.filePath).text(),ae=Rn(ee),{classifyAllScripts:fe}=await import("./chunk-m67qmg51.js"),H=fe(ee),Oe=H.server.map((le)=>le.content),Pe=ee;for(let le of H.server)Pe=Pe.replace(le.fullTag,"");let te={__filename:T.filePath,__dirname:oe.dirname(T.filePath),__stx_options:de,params:_??{},__stx_runtime_head:{}};for(let le of Oe)try{await Z(le,te,T.filePath)}catch(De){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,De?.message||De)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Pe,te,T.filePath,de,$e);let De=performance.now()-le,_e=oe.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${De.toFixed(2)}ms`)}else he=await z(Pe,te,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-3xpnw4s1.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,_e,Le)=>{if(!/function\s+__stx_setup_/.test(Le))return De;return`<script${_e}>${le(Le,te)}</script>`})}if(k)he=rt(he,{preserveHead:!0});if(J&&M)await Y(T.filePath,he,$e,de);let{extractStreamBoundaries:lt}=await import("./chunk-xhb89sf5.js"),Je=lt(te),tt=te.__streamTemplates;if(tt&&typeof tt==="object"&&Object.keys(tt).length>0){let le=te.streamBoundaries||{},De={...de,autoShell:!1},_e=Object.keys(tt).map((ve)=>({id:ve,render:async()=>{let nt=typeof le[ve]==="function"?await le[ve]():void 0;return z(tt[ve],{...te,$boundary:nt},T.filePath,De,new Set)}})),Le=new Set(_e.map((ve)=>ve.id));Je=[...(Je||[]).filter((ve)=>!Le.has(ve.id)),..._e]}if(Je&&Je.length>0)ke.add(T.pattern);else Je=void 0;let _t=Kt(te),It=Gt(te);if(M)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Je}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},Fe=8,Ne=async()=>{let T=new Set(pe.keys()),_=new Set(L.keys());pe.clear(),L.clear();let z=t.prebuild===!1?W.filter((X)=>T.has(X.pattern)):W,Z=t.prebuild===!1?I.filter(({route:X})=>_.has(X.pattern)):I;for(let X=0;X<z.length;X+=Fe){let Te=z.slice(X,X+Fe),be=await Promise.all(Te.map((N)=>E(N)));for(let N of be)if(N)pe.set(N.route.pattern,N)}for(let X=0;X<Z.length;X+=Fe){let Te=Z.slice(X,X+Fe),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)L.set(N.route.pattern,N)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?W.length+I.length>0:await Ne()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,_)=>{let Z=`<script data-stx-route-params>(function(){var p=${JSON.stringify(_).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(T.includes("</head>"))return f(T,Z,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Z}`);return Z+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Gn({port:Xe,hostname:t.hostname,async fetch(T){let _=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(_.pathname===ni&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});let M=[...W,...I.map(({route:J})=>J)].filter((J)=>!J.isDynamic).map((J)=>J.pattern);return new Response(T.method==="HEAD"?null:ri(z,_s(),M),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Z=h?.publicDir||"public",X=oe.join(m,Z,_.pathname),Te=oe.join(m,_.pathname),be=oe.join(xe,_.pathname);if([X,Te,be].some((M)=>C(M,m,R)))return new Response("Not Found",{status:404});let[N,Y,V]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Te).catch(()=>null),me.promises.stat(be).catch(()=>null)]);if(N?.isFile()&&!C(X,m,R))return Ot(X);if(Y?.isFile()&&!C(Te,m,R))return Ot(Te);if(V?.isFile()&&!C(be,m,R))return Ot(be);if(_.pathname.startsWith("/_stx/component/")){let M=decodeURIComponent(_.pathname.slice(16));if(M)try{let J=`<${M} />`,ee={...buildConfig,autoShell:!1},ae=await processDirectives(J,{},oe.join(m,"components",`${M}.stx`),ee,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(J){return new Response(`<div class="stx-async-error">${J.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(_.pathname==="/_stx/img"){let{handleImageRequest:M}=await import("./chunk-kf6j1ht4.js"),J=await M(T,{publicDir:oe.join(m,Z),cacheDir:l(m,"cache","img")});if(J)return J}if(Q)try{let M=await Q.handleRequest(T);if(M.status!==404)return M}catch{}if(q[_.pathname])try{return await q[_.pathname](T)}catch(M){return new Response(JSON.stringify({error:M.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=$r(_.pathname,W);if(G){let M=pe.get(G.route.pattern),J=ke.has(G.route.pattern);if(!M||G.route.isDynamic&&Object.keys(G.params).length>0||J){let ee=await E(G.route,G.params);if(ee){if(M=ee,!G.route.isDynamic&&!J)pe.set(G.route.pattern,ee)}}if(M){let ee=M.status??200,ae=M.headers??{},fe=(G.route.filePath?Pt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Pe=await ie(404);if(Pe){let te=Pe;if(te=await S(te,m),r)te=Ue(te,u);return new Response(te,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=Ft(_.pathname,G.params,fe,_.search),Pe=zt(Oe,null,T,{isServer:!0}),te=await Ht(fe.middleware,Pe);if(te.redirect){let $e=te.redirect.path,he=te.redirect.options.redirectCode||302,lt=new Headers(te.responseHeaders);return lt.set("Location",$e),new Response(null,{status:he,headers:lt})}if(te.abort){let{statusCode:$e,message:he}=te.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${$e}</title></head><body><h1>Error ${$e}</h1><p>${he}</p></body></html>`,{status:$e,headers:{"Content-Type":"text/html"}})}if(Object.keys(te.state).length>0){let $e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(te.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;M.content=f(M.content,$e,"")}}let H=M.content;if(k&&Na(T)&&st(H,h?.router?.container||"main")){let Oe=pt(H),Pe=Re(H),te=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=te?cn(te[1].trim()):"";if(Object.keys(G.params).length>0)H=St(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Be(H,he,!0),new Response(H,{status:ee,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Pe?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Ac]:_s(),...U(),"Cache-Control":Tt}})}if(k)H=us(k,H);if(Object.keys(G.params).length>0)H=St(H,G.params);if(H=await S(H,m),r)H=Ue(H,u);if(t.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;if(t.titlebarHidden)if(H.includes("<head>"))H=H.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else H=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${H}`;if(M.boundaries&&M.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Pe}=await import("./chunk-xhb89sf5.js");return Pe(Oe(H,M.boundaries,{timeoutMs:30000}),{status:ee,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(H,{status:ee,headers:{"Content-Type":"text/html",...U(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(I.length>0){let M=I.map((ee)=>ee.route),J=$r(_.pathname,M);if(J){let ee=L.get(J.route.pattern);if(!ee||J.route.isDynamic){let ae=await E(J.route,J.params);if(ae){if(ee=ae,!J.route.isDynamic)L.set(J.route.pattern,ae)}}if(ee){let ae=ee.content;if(k)ae=us(k,ae);if(Object.keys(J.params).length>0)ae=St(ae,J.params);if(ae=await S(ae,m),r)ae=Ue(ae,u);return new Response(ae,{status:ee.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ee}of se)if(ee!=="/"&&_.pathname.startsWith(ee)){let ae=L.get(ee)||L.get(ee+"/");if(!ae){let fe=I.find(({route:H})=>H.pattern===ee||H.pattern===`${ee}/`);if(fe){let H=await E(fe.route);if(H)ae=H,L.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=us(k,fe);if(fe=await S(fe,m),r)fe=Ue(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Dt(_.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let M=We.content;if(M=await S(M,m),r)M=Ue(M,u);if(t.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await ie(404);if(de){let M=de;if(M=await S(M,m),r)M=Ue(M,u);return new Response(M,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let _=await ie(500);if(_)return new Response(_,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
1005
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(C.url.toString(),()=>{if(d)Ke.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ke.watch(p,{recursive:!0},async(w,A)=>{if(!A)return;if(A.endsWith(".stx")||A.endsWith(".js")||A.endsWith(".ts")||A.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${A}${e.yellow} changed, rebuilding...${e.reset}`),ct.clear(),Ce(),await x()});process.on("SIGINT",()=>{v.close(),C.stop(),process.exit(0)})}return!0}function qt(n){return String(n??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:Gn}=globalThis.Bun;import me from"fs";import oe from"path";async function Jt(n){try{return Rn(await Bun.file(n).text())}catch{return}}function Ot(n){let t=Bun.file(n),o=oe.extname(n).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},p=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(t,{headers:{"Content-Type":d[o]||"application/octet-stream",...p}})}async function is(n=".",t={}){let o=t.port||3000,d=t.watch!==!1,r=t.hotReload!==!1&&d,p=null,u=t.hmrPort||o+1,m=oe.resolve(n),{loadStxConfig:x}=await import("./chunk-gyzebnpx.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-3ahvypx3.js"),R=t.stxOptions?.serverApi??h.serverApi,O=await b(m,R),v=h.root&&h.root!=="."?oe.join(m,h.root):m,w=t.pagesDir||h.pagesDir||"pages",A=oe.join(v,w);if(!me.existsSync(A)&&!h._layerPageDirs?.some((T)=>me.existsSync(T)))return console.error(`${e.red}Error: No '${w}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${A}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${w}/index.stx for the homepage.${e.reset}`),!1;let W=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(W.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${A}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${W.length}${e.blue} routes${e.reset}`);let se=h?._pluginPageDirs||[],I=[];for(let{dir:T,prefix:_}of se)if(me.existsSync(T)){let z=re(oe.dirname(T),{pagesDir:oe.basename(T)});for(let Z of z){let X=_==="/"?Z.pattern:`${_}${Z.pattern==="/"?"":Z.pattern}`;I.push({route:{...Z,pattern:X},prefix:_})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${_}${e.reset}`)}let L=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Oa(m,t.stxOptions?.shell),P){if(k=await Lo(P,t.stxOptions||{}),k)console.log(`${e.blue}Using app shell: ${e.bright}${oe.relative(m,P)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}Lt(),await Bt(m);let D=jt();if(D.length>0)console.log(`${e.blue}Loaded ${e.bright}${D.length}${e.blue} middleware: ${e.dim}${D.join(", ")}${e.reset}`);let q={},Q=null;try{let{loadStxConfig:T}=await import("./chunk-gyzebnpx.js"),_=await T(m);if(_?.apiRouter)Q=_?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(_?.apiRoutes){q=_.apiRoutes;let z=Object.keys(q).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(_?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:Z}=await import("./chunk-cvxg2rc1.js"),X=_.broadcasting;await z(X);let Te=X.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Te}/ws${e.reset}`);let be=oe.join(process.cwd(),"channels.ts");if(me.existsSync(be))try{let N=await Z(be);console.log(`${e.blue}Loaded ${e.bright}${N} broadcast channel${N!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(N){console.warn(`${e.yellow}Failed to load channels.ts: ${N.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let xe=l(m,"output");me.mkdirSync(xe,{recursive:!0});let pe=new Map,ke=new Set,ie=async(T)=>{let _=qs(A,T);if(!_)return null;try{let z=await Bun.build({entrypoints:[_],outdir:xe,plugins:[et],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...t.stxOptions});if(!z.success)return null;let Z=z.outputs.find((X)=>X.path.endsWith(".html"));if(!Z)return null;return await Bun.file(Z.path).text()}catch{return null}},F=new Map,E=async(T,_)=>{try{let{processDirectives:z,extractVariables:Z,defaultConfig:X,loadStxConfig:Te,injectRouterScript:be}=await import("./chunk-gyzebnpx.js"),{checkCache:N,cacheTemplate:Y,readFileCached:V,templateCache:ue}=await import("./chunk-cb9h2wwq.js"),G=await Te(m),We=(le)=>{if(!le)return le;if(oe.isAbsolute(le))return le;return oe.resolve(m,le)},de={...X,...G,...t.stxOptions,autoShell:!0};if(t.debugDirectives)de.debug=!0;de.partialsDir=We(de.partialsDir),de.componentsDir=We(de.componentsDir),de.layoutsDir=We(de.layoutsDir),de.storesDir=We(de.storesDir||"stores"),de.cachePath=We(de.cachePath)??l(m,"cache");let M=!_&&!t.profile,J=de.cache!==!1;if(J&&M){let le=ue.get(T.filePath);if(le)try{if((await me.promises.stat(T.filePath)).mtime.getTime()<=le.mtime){let Le=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Le=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Le=!1;break}}if(Le){let ve=le.output;if(k)ve=rt(ve,{preserveHead:!0});let nt=F.get(T.filePath);return{route:T,content:ve,status:nt?.status??await Jt(T.filePath),headers:nt?.headers}}}}catch{}let De=await N(T.filePath,de);if(De){let _e=De;if(k)_e=rt(_e,{preserveHead:!0});let Le=F.get(T.filePath);return{route:T,content:_e,status:Le?.status??await Jt(T.filePath),headers:Le?.headers}}}let ee=J?await V(T.filePath):await Bun.file(T.filePath).text(),ae=Rn(ee),{classifyAllScripts:fe}=await import("./chunk-gyzebnpx.js"),H=fe(ee),Oe=H.server.map((le)=>le.content),Pe=ee;for(let le of H.server)Pe=Pe.replace(le.fullTag,"");let te={__filename:T.filePath,__dirname:oe.dirname(T.filePath),__stx_options:de,params:_??{},__stx_runtime_head:{}};for(let le of Oe)try{await Z(le,te,T.filePath)}catch(De){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,De?.message||De)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Pe,te,T.filePath,de,$e);let De=performance.now()-le,_e=oe.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${De.toFixed(2)}ms`)}else he=await z(Pe,te,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-9pjzj75t.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(De,_e,Le)=>{if(!/function\s+__stx_setup_/.test(Le))return De;return`<script${_e}>${le(Le,te)}</script>`})}if(k)he=rt(he,{preserveHead:!0});if(J&&M)await Y(T.filePath,he,$e,de);let{extractStreamBoundaries:lt}=await import("./chunk-zb6fa26w.js"),Je=lt(te),tt=te.__streamTemplates;if(tt&&typeof tt==="object"&&Object.keys(tt).length>0){let le=te.streamBoundaries||{},De={...de,autoShell:!1},_e=Object.keys(tt).map((ve)=>({id:ve,render:async()=>{let nt=typeof le[ve]==="function"?await le[ve]():void 0;return z(tt[ve],{...te,$boundary:nt},T.filePath,De,new Set)}})),Le=new Set(_e.map((ve)=>ve.id));Je=[...(Je||[]).filter((ve)=>!Le.has(ve.id)),..._e]}if(Je&&Je.length>0)ke.add(T.pattern);else Je=void 0;let _t=Kt(te),It=Gt(te);if(M)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Je}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},Fe=8,Ne=async()=>{let T=new Set(pe.keys()),_=new Set(L.keys());pe.clear(),L.clear();let z=t.prebuild===!1?W.filter((X)=>T.has(X.pattern)):W,Z=t.prebuild===!1?I.filter(({route:X})=>_.has(X.pattern)):I;for(let X=0;X<z.length;X+=Fe){let Te=z.slice(X,X+Fe),be=await Promise.all(Te.map((N)=>E(N)));for(let N of be)if(N)pe.set(N.route.pattern,N)}for(let X=0;X<Z.length;X+=Fe){let Te=Z.slice(X,X+Fe),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)L.set(N.route.pattern,N)}return pe.size>0};if(console.log(`${e.blue}${t.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(t.prebuild===!1?W.length+I.length>0:await Ne()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Xe=o;try{if(Xe=await Ve(o),Xe!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Xe} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Xe+1;p=bt({wsPort:T,verbose:!1}),u=p.start(T)}let St=(T,_)=>{let Z=`<script data-stx-route-params>(function(){var p=${JSON.stringify(_).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(T.includes("</head>"))return f(T,Z,"");if(T.includes("<body"))return T.replace(/<body([^>]*)>/,`<body$1>${Z}`);return Z+T};console.log(`${e.blue}Starting server...${e.reset}`);let kt=Gn({port:Xe,hostname:t.hostname,async fetch(T){let _=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(_.pathname===ni&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});let M=[...W,...I.map(({route:J})=>J)].filter((J)=>!J.isDynamic).map((J)=>J.pattern);return new Response(T.method==="HEAD"?null:ri(z,_s(),M),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Z=h?.publicDir||"public",X=oe.join(m,Z,_.pathname),Te=oe.join(m,_.pathname),be=oe.join(xe,_.pathname);if([X,Te,be].some((M)=>C(M,m,R)))return new Response("Not Found",{status:404});let[N,Y,V]=await Promise.all([me.promises.stat(X).catch(()=>null),me.promises.stat(Te).catch(()=>null),me.promises.stat(be).catch(()=>null)]);if(N?.isFile()&&!C(X,m,R))return Ot(X);if(Y?.isFile()&&!C(Te,m,R))return Ot(Te);if(V?.isFile()&&!C(be,m,R))return Ot(be);if(_.pathname.startsWith("/_stx/component/")){let M=decodeURIComponent(_.pathname.slice(16));if(M)try{let J=`<${M} />`,ee={...buildConfig,autoShell:!1},ae=await processDirectives(J,{},oe.join(m,"components",`${M}.stx`),ee,new Set);return new Response(ae,{headers:{"Content-Type":"text/html"}})}catch(J){return new Response(`<div class="stx-async-error">${J.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(_.pathname==="/_stx/img"){let{handleImageRequest:M}=await import("./chunk-kf6j1ht4.js"),J=await M(T,{publicDir:oe.join(m,Z),cacheDir:l(m,"cache","img")});if(J)return J}if(Q)try{let M=await Q.handleRequest(T);if(M.status!==404)return M}catch{}if(q[_.pathname])try{return await q[_.pathname](T)}catch(M){return new Response(JSON.stringify({error:M.message}),{status:500,headers:{"Content-Type":"application/json"}})}let ue=await O(T);if(ue)return ue;let G=$r(_.pathname,W);if(G){let M=pe.get(G.route.pattern),J=ke.has(G.route.pattern);if(!M||G.route.isDynamic&&Object.keys(G.params).length>0||J){let ee=await E(G.route,G.params);if(ee){if(M=ee,!G.route.isDynamic&&!J)pe.set(G.route.pattern,ee)}}if(M){let ee=M.status??200,ae=M.headers??{},fe=(G.route.filePath?Pt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(fe.validate){if(!await fe.validate({params:G.params})){let Pe=await ie(404);if(Pe){let te=Pe;if(te=await S(te,m),r)te=Ue(te,u);return new Response(te,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(fe.middleware){let Oe=Ft(_.pathname,G.params,fe,_.search),Pe=zt(Oe,null,T,{isServer:!0}),te=await Ht(fe.middleware,Pe);if(te.redirect){let $e=te.redirect.path,he=te.redirect.options.redirectCode||302,lt=new Headers(te.responseHeaders);return lt.set("Location",$e),new Response(null,{status:he,headers:lt})}if(te.abort){let{statusCode:$e,message:he}=te.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${$e}</title></head><body><h1>Error ${$e}</h1><p>${he}</p></body></html>`,{status:$e,headers:{"Content-Type":"text/html"}})}if(Object.keys(te.state).length>0){let $e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(te.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;M.content=f(M.content,$e,"")}}let H=M.content;if(k&&Na(T)&&st(H,h?.router?.container||"main")){let Oe=pt(H),Pe=Re(H),te=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=te?cn(te[1].trim()):"";if(Object.keys(G.params).length>0)H=St(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Be(H,he,!0),new Response(H,{status:ee,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Oe.layout,"X-STX-Layout-Group":Oe.group,"X-STX-Runtime":Pe?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Ac]:_s(),...U(),"Cache-Control":Tt}})}if(k)H=us(k,H);if(Object.keys(G.params).length>0)H=St(H,G.params);if(H=await S(H,m),r)H=Ue(H,u);if(t.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;if(t.titlebarHidden)if(H.includes("<head>"))H=H.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else H=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${H}`;if(M.boundaries&&M.boundaries.length>0){let{renderStreamingPage:Oe,streamToResponse:Pe}=await import("./chunk-zb6fa26w.js");return Pe(Oe(H,M.boundaries,{timeoutMs:30000}),{status:ee,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(H,{status:ee,headers:{"Content-Type":"text/html",...U(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(I.length>0){let M=I.map((ee)=>ee.route),J=$r(_.pathname,M);if(J){let ee=L.get(J.route.pattern);if(!ee||J.route.isDynamic){let ae=await E(J.route,J.params);if(ae){if(ee=ae,!J.route.isDynamic)L.set(J.route.pattern,ae)}}if(ee){let ae=ee.content;if(k)ae=us(k,ae);if(Object.keys(J.params).length>0)ae=St(ae,J.params);if(ae=await S(ae,m),r)ae=Ue(ae,u);return new Response(ae,{status:ee.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ee}of se)if(ee!=="/"&&_.pathname.startsWith(ee)){let ae=L.get(ee)||L.get(ee+"/");if(!ae){let fe=I.find(({route:H})=>H.pattern===ee||H.pattern===`${ee}/`);if(fe){let H=await E(fe.route);if(H)ae=H,L.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=us(k,fe);if(fe=await S(fe,m),r)fe=Ue(fe,u);return new Response(fe,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Dt(_.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let We=pe.get("/");if(We){let M=We.content;if(M=await S(M,m),r)M=Ue(M,u);if(t.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;return new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let de=await ie(404);if(de){let M=de;if(M=await S(M,m),r)M=Ue(M,u);return new Response(M,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(T){let _=await ie(500);if(_)return new Response(_,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${T}
1006
1006
  ${T.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1007
1007
  ${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
1008
1008
  ${e.bright}\u2192 ${e.cyan}http://localhost:${Xe}/${e.reset}`),r)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
1009
1009
  ${e.yellow}Routes:${e.reset}`);let Ct=[...Ks(W,m)];for(let{route:T}of I)Ct.push(`${T.pattern}`);if(Ct.forEach((T,_)=>{let Z=_===Ct.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Z}${e.reset}${T}`)}),console.log(`
1010
- Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.url.toString(),()=>{if(p)ot();kt.stop()}),t.native){let T,_=oe.join(A,"index.stx");if(me.existsSync(_)){let Z=await Bun.file(_).text();T=gt(Z)}let z=h?.app?.window??{};await Ye(Xe,{title:h?.app?.head?.title||oe.basename(m)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(N)=>N.startsWith("public/")||N.startsWith("public\\"),_=(N)=>{let Y=N.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},z=new Map,Z=()=>{let N=new Set([m,...h._layerGraph?.layers.map((Y)=>Y.root)??[],...h._layerGraph?.configDependencies.map((Y)=>oe.dirname(Y))??[]].filter((Y)=>me.existsSync(Y)).map((Y)=>me.realpathSync(Y)));for(let Y of h._layerGraph?.layers??[])for(let V of Object.values(Y.resources)){if(!me.existsSync(V))continue;let ue=me.realpathSync(V);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${oe.sep}`)))N.add(ue)}for(let[Y,V]of z)if(!N.has(Y))V.close(),z.delete(Y);for(let Y of N)if(!z.has(Y)&&me.existsSync(Y))z.set(Y,me.watch(Y,{recursive:!0},(V,ue)=>{Te(Y,V,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,Y,V)=>(X=X.catch(()=>{}).then(()=>be(N,Y,V)),X),be=async(N,Y,V)=>{if(!V||xt(V))return;if(yt(V)){if(h._layerGraph){let ue=await x(m);Object.assign(h,ue),W.splice(0,W.length,...re(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Z()}if(T(V)){if(console.log(`${e.cyan}${V} changed${e.reset}`),r&&p)p.reload(V)}else if(_(V)){console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-dysb1g8f.js");ue(oe.resolve(N,V)),G.delete(oe.resolve(N,V))}catch{}if(P&&V){if(oe.resolve(N,V)===P||oe.basename(P)===V){let G=await Lo(P,t.stxOptions||{});if(G)k=G}}if(await Ne(),await vr(m),r&&p)p.reload(V)}else{console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-dysb1g8f.js");ue(oe.resolve(N,V)),G.delete(oe.resolve(N,V))}catch{}if(await Ne(),r&&p)p.reload(V)}}else if(ht(V)){if(console.log(`${e.cyan}CSS ${V} changed${e.reset}`),r&&p)p.updateCss(V)}};Z(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)ot();kt.stop(),process.exit(0)})}return!0}import At from"fs";import it from"path";async function Jn(n){try{let o=(await Bun.file(n).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],r=[],p=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=p.exec(d))!==null){let m=u[1],x=u[2]||u[3]||u[4];if(!x)continue;let h={name:x},b=m.match(/@type\s+\{([^}]+)\}/i);if(b)h.type=b[1].trim();if(m.match(/@required/i))h.required=!0;let R=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(R)h.default=R[1].trim();let O=m.split(`
1010
+ Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),qe(kt.url.toString(),()=>{if(p)ot();kt.stop()}),t.native){let T,_=oe.join(A,"index.stx");if(me.existsSync(_)){let Z=await Bun.file(_).text();T=gt(Z)}let z=h?.app?.window??{};await Ye(Xe,{title:h?.app?.head?.title||oe.basename(m)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??t.titlebarHidden===!0,nativeSidebar:!!T,sidebarConfig:T})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let T=(N)=>N.startsWith("public/")||N.startsWith("public\\"),_=(N)=>{let Y=N.toLowerCase();return Y.endsWith(".stx")||Y.endsWith(".html")||Y.endsWith(".md")},z=new Map,Z=()=>{let N=new Set([m,...h._layerGraph?.layers.map((Y)=>Y.root)??[],...h._layerGraph?.configDependencies.map((Y)=>oe.dirname(Y))??[]].filter((Y)=>me.existsSync(Y)).map((Y)=>me.realpathSync(Y)));for(let Y of h._layerGraph?.layers??[])for(let V of Object.values(Y.resources)){if(!me.existsSync(V))continue;let ue=me.realpathSync(V);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${oe.sep}`)))N.add(ue)}for(let[Y,V]of z)if(!N.has(Y))V.close(),z.delete(Y);for(let Y of N)if(!z.has(Y)&&me.existsSync(Y))z.set(Y,me.watch(Y,{recursive:!0},(V,ue)=>{Te(Y,V,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,Y,V)=>(X=X.catch(()=>{}).then(()=>be(N,Y,V)),X),be=async(N,Y,V)=>{if(!V||xt(V))return;if(yt(V)){if(h._layerGraph){let ue=await x(m);Object.assign(h,ue),W.splice(0,W.length,...re(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Z()}if(T(V)){if(console.log(`${e.cyan}${V} changed${e.reset}`),r&&p)p.reload(V)}else if(_(V)){console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-cb9h2wwq.js");ue(oe.resolve(N,V)),G.delete(oe.resolve(N,V))}catch{}if(P&&V){if(oe.resolve(N,V)===P||oe.basename(P)===V){let G=await Lo(P,t.stxOptions||{});if(G)k=G}}if(await Ne(),await vr(m),r&&p)p.reload(V)}else{console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),ct.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-cb9h2wwq.js");ue(oe.resolve(N,V)),G.delete(oe.resolve(N,V))}catch{}if(await Ne(),r&&p)p.reload(V)}}else if(ht(V)){if(console.log(`${e.cyan}CSS ${V} changed${e.reset}`),r&&p)p.updateCss(V)}};Z(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)ot();kt.stop(),process.exit(0)})}return!0}import At from"fs";import it from"path";async function Jn(n){try{let o=(await Bun.file(n).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],r=[],p=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=p.exec(d))!==null){let m=u[1],x=u[2]||u[3]||u[4];if(!x)continue;let h={name:x},b=m.match(/@type\s+\{([^}]+)\}/i);if(b)h.type=b[1].trim();if(m.match(/@required/i))h.required=!0;let R=m.match(/@default\s+(.+?)(?:\s+|$)/i);if(R)h.default=R[1].trim();let O=m.split(`
1011
1011
  `).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);h.description=O.join(" ").trim(),r.push(h)}if(r.length===0){let m=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(m){let h=m[1].split(",").map((b)=>b.trim()).filter(Boolean);for(let b of h){let[C]=b.split(":").map((R)=>R.trim());if(C)r.push({name:C})}}}return r}catch(t){return console.error(`Error extracting props from ${n}:`,t),[]}}async function Yn(n){try{let t=await Bun.file(n).text(),o=t.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||t.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(o)return o[1].split(`
1012
1012
  `).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Qn(n,t=!1,o){let d=it.basename(n,".stx"),r=await Jn(n),p=await Yn(n),u="";if(t&&o)u=`<${o}></${o}>`;else{let m=r.map((x)=>{if(x.type==="boolean")return`:${x.name}="true"`;return`${x.name}="value"`}).join(`
1013
1013
  `);u=`<${d}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{hg,gy,my,hy,yy,yg,bg,by,wy,yi,vy,Cr,Er,Ls}from"./chunk-fd2d2a69.js";import{gt}from"./chunk-zkwkhesc.js";import"./chunk-16edtncx.js";import"./chunk-vaxxe2db.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{yy as __setSignalsGeneratorsForTest,gt as cacheEngineFingerprint,Er as cacheTemplate,Cr as checkCache,vy as clearDevCaches,bg as getCachedRouterScript,yg as getCachedSignalsRuntime,by as getServeClientAsset,yi as getServeModuleBundle,Ls as hashFilePath,my as invalidateFileCache,hy as invalidateFileCacheByDir,gy as readFileCached,wy as registerServeModuleBundle,hg as templateCache};
2
+ import{hg,gy,my,hy,yy,yg,bg,by,wy,yi,vy,Cr,Er,Ls}from"./chunk-27qkwvbe.js";import{gt}from"./chunk-zkwkhesc.js";import"./chunk-ty5frr9t.js";import"./chunk-rzmk73fz.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{yy as __setSignalsGeneratorsForTest,gt as cacheEngineFingerprint,Er as cacheTemplate,Cr as checkCache,vy as clearDevCaches,bg as getCachedRouterScript,yg as getCachedSignalsRuntime,by as getServeClientAsset,yi as getServeModuleBundle,Ls as hashFilePath,my as invalidateFileCache,hy as invalidateFileCacheByDir,gy as readFileCached,wy as registerServeModuleBundle,hg as templateCache};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ia,Am,Do,Pm,fu,gu,Im,Om}from"./chunk-s9t97mza.js";import"./chunk-w0sj4ehs.js";import"./chunk-v650d8rj.js";import"./chunk-6mhz9stn.js";import"./chunk-qs0zk04y.js";import"./chunk-mphbgnta.js";import"./chunk-br1kkmbz.js";import"./chunk-vbmvft7g.js";import"./chunk-65g78sge.js";import"./chunk-3ykhczg6.js";import"./chunk-be1jvk13.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import{_e,ro}from"./chunk-16edtncx.js";import"./chunk-vaxxe2db.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{Ia as buildScriptVirtualFile,Am as buildVirtualSource,_e as extractScriptBlocks,ro as extractTemplateExpressions,fu as findRuntimeTypeDeclarations,gu as findStxModuleDeclarations,Om as formatTypecheckDiagnostics,Pm as sourcePathFor,Im as typecheckStxFiles,Do as virtualPathFor};
2
+ import{Ia,Am,Do,Pm,fu,gu,Im,Om}from"./chunk-n642g6n0.js";import"./chunk-m0p328a3.js";import"./chunk-9ze3xvsr.js";import"./chunk-g5nts6e0.js";import"./chunk-qs0zk04y.js";import"./chunk-essmq8yb.js";import"./chunk-4z926gay.js";import"./chunk-vbmvft7g.js";import"./chunk-v5y66rwr.js";import"./chunk-65c11t6g.js";import"./chunk-n1wn4wvm.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import{_e,ro}from"./chunk-ty5frr9t.js";import"./chunk-rzmk73fz.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{Ia as buildScriptVirtualFile,Am as buildVirtualSource,_e as extractScriptBlocks,ro as extractTemplateExpressions,fu as findRuntimeTypeDeclarations,gu as findStxModuleDeclarations,Om as formatTypecheckDiagnostics,Pm as sourcePathFor,Im as typecheckStxFiles,Do as virtualPathFor};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jf,Yf,Te,Zf,Ec,mn,hn,ty,Tc,yn,mr,Qf,eg,tg,ks,ng,rg,$c,bn,sg,wn,Rc,ny}from"./chunk-v650d8rj.js";import"./chunk-6mhz9stn.js";import"./chunk-qs0zk04y.js";import"./chunk-65g78sge.js";import"./chunk-3ykhczg6.js";import"./chunk-be1jvk13.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import"./chunk-16edtncx.js";import"./chunk-vaxxe2db.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{mr as MODULE_SPECIFIER_PREFIX,$c as assertBundleBuildCanSettle,Jf as bundleCacheDir,Yf as bundleCacheEntryLimit,ny as bundleClientEntriesSplit,wn as bundleClientScript,hn as clearBundleFailures,Te as clientBundleDependencies,mn as getBundleFailures,yn as hasUserImports,rg as isWithinBundlerCallback,bn as moduleSubstitutionKey,eg as normalizeRegistrySpecifiers,sg as queueClientBundleBuild,Ec as recordBundleFailure,Qf as registryIdForPath,Tc as resolveBundlerFallback,tg as rewriteRegistryImports,ty as setBundlerFallbackMode,Zf as shouldLogBundlerDiagnostics,Rc as tempBuildName,ks as withModuleSubstitutes,ng as withinBundlerCallback};
2
+ import{Jf,Yf,Te,Zf,Ec,mn,hn,ty,Tc,yn,mr,Qf,eg,tg,ks,ng,rg,$c,bn,sg,wn,Rc,ny}from"./chunk-9ze3xvsr.js";import"./chunk-g5nts6e0.js";import"./chunk-qs0zk04y.js";import"./chunk-v5y66rwr.js";import"./chunk-65c11t6g.js";import"./chunk-n1wn4wvm.js";import"./chunk-5mrt1enm.js";import"./chunk-vw7crz0z.js";import"./chunk-150cz8qq.js";import"./chunk-0b57fgpn.js";import"./chunk-ty5frr9t.js";import"./chunk-rzmk73fz.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{mr as MODULE_SPECIFIER_PREFIX,$c as assertBundleBuildCanSettle,Jf as bundleCacheDir,Yf as bundleCacheEntryLimit,ny as bundleClientEntriesSplit,wn as bundleClientScript,hn as clearBundleFailures,Te as clientBundleDependencies,mn as getBundleFailures,yn as hasUserImports,rg as isWithinBundlerCallback,bn as moduleSubstitutionKey,eg as normalizeRegistrySpecifiers,sg as queueClientBundleBuild,Ec as recordBundleFailure,Qf as registryIdForPath,Tc as resolveBundlerFallback,tg as rewriteRegistryImports,ty as setBundlerFallbackMode,Zf as shouldLogBundlerDiagnostics,Rc as tempBuildName,ks as withModuleSubstitutes,ng as withinBundlerCallback};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-0jdz31q1.js";import"./chunk-945zygwa.js";import"./chunk-hdfhaddy.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-16edtncx.js";import"./chunk-esm0pnpz.js";import"./chunk-vaxxe2db.js";import"./chunk-5mrt1enm.js";import"./chunk-be1jvk13.js";import{l}from"./chunk-pjpy86c3.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-0jdz31q1.js";import"./chunk-945zygwa.js";import"./chunk-hdfhaddy.js";import"./chunk-7b3dqeyr.js";import"./chunk-5g5khx0m.js";import"./chunk-ty5frr9t.js";import"./chunk-esm0pnpz.js";import"./chunk-rzmk73fz.js";import"./chunk-5mrt1enm.js";import"./chunk-n1wn4wvm.js";import{l}from"./chunk-pjpy86c3.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{xt,Hl}from"./chunk-hdfhaddy.js";import{D}from"./chunk-7b3dqeyr.js";import{X,Js,o,me,Q,x,sl,Xt,Pn,Xe,Je}from"./chunk-16edtncx.js";import{_r}from"./chunk-br1kkmbz.js";import{W}from"./chunk-a7bqrjm5.js";import{_n}from"./chunk-vbmvft7g.js";var G=`(?:"[^"]*"|'[^']*'|[^>"'])*`,H=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,q=65536,J=4,N=new Map;function fy(){N.clear()}function K(e){let c=[];for(let t of x(e,Q)){let n=t.token.match(/^<script\b([^>]*)>/i),s=t.token.match(/<\/script\s*>$/i);if(!n||!s)continue;let a=n[0].length,f=t.token.length-s[0].length;c.push(Object.freeze({fullMatch:t.token,attrs:n[1],body:t.token.slice(a,f),start:t.start,end:t.end}))}return c}function Ps(e,c={}){let t=e.length>=q,n=t?N.get(e):void 0;if(n===void 0){if(n=K(e),t)sl(N,J),N.set(e,n)}let s=c.skipAttrs;if(!s)return n.slice();let a=[];for(let f of n)if(s.lastIndex=0,!s.test(f.attrs))a.push(f);return a}function pi(e){let c=e.trim(),t=c.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(t){let s=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:i}=j(a);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:i}}let n=c.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(n){let s=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:i}=j(s);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:i}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function j(e){let c=e.trim(),t=c.match(/^(\w+)\s*=>\s*(\w+)$/);if(t)return{itemVar:t[2],indexVar:t[1]};let n=c.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(n)return{itemVar:n[1],indexVar:n[2]||null};let s=c.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let a=c.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Is(e,c){return Hl(e,c)}function Y(e){let c=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,t=0,n;while((n=c.exec(e))!==null){let s=n[1];if(s.startsWith("if"))t++;else if(s==="endif")t--;else if(t===0)return!0}return!1}function Sr(e){let c=new Set,t=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,n=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=t.exec(e))!==null){let a=s[1],f;while((f=n.exec(a))!==null)c.add(f[1])}return c}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let c=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${G})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=x(e,(a,f)=>{c.lastIndex=f;let i=c.exec(a);if(!i||i.index!==f||!t.test(i[2]))return-1;return c.lastIndex}),s=[];for(let a of n){c.lastIndex=0;let f=c.exec(a.token);if(!f)continue;let i=f[2].match(t),p=pi(i?.[1]??i?.[2]??""),m=[p.itemVar,p.indexVar].filter(Boolean);if(m.length===0)continue;let r=f[1],g=/\/\s*>$/.test(a.token)||M.has(r.toLowerCase())?a.end:P(e,a.start,r,a.end);if(g!==-1)s.push({start:a.start,end:g,vars:new Set(m)})}return s}var z=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function te(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function B(e,c,t,n){if(!e)return!1;let s=te(e),a=!1,f=!1,i=!1,p=/([a-zA-Z_$][\w$]*)/g,m;while((m=p.exec(s))!==null){let u=m[1];if(s.slice(0,m.index).trimEnd().endsWith("."))continue;if(z.has(u))continue;if(c.has(u)||n?.has(u))a=!0;else if(t&&u in t)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,l;while((l=r.exec(s))!==null){let u=l[1];if(s.slice(0,l.index).trimEnd().endsWith("."))continue;if(z.has(u)||t&&u in t)continue;i=!0}return(a||i)&&!f}function L(e,c,t){let n=t===void 0?` ${c}`:` ${c}="${t.replace(/"/g,"&quot;")}"`,s=e.trim(),a=s.match(H);if(a&&!ne(a[1])&&se(a[3],a[1])){let[,f,i,p]=a;return`<${f}${i}${n}>${p}</${f}>`}return`<template${n}>${s}</template>`}function ne(e){return/^[A-Z]/.test(e)}function se(e,c){let t=new RegExp(`<(/)?${c}(?=[\\s/>])`,"gi"),n=0,s;while((s=t.exec(e))!==null)if(s[1]){if(n--,n<0)return!1}else n++;return!0}function fi(e,c){let t=Sr(e);function n(s){let a=s,f=ee(s),i=(l)=>{let g=new Set;for(let u of f)if(l>u.start&&l<u.end)for(let d of u.vars)g.add(d);return g},p=/@if\s*\(/g,m,r=[];while((m=p.exec(a))!==null){let l=m.index,g=l+m[0].length,u=1,d=g;while(d<a.length&&u>0){if(a[d]==="(")u++;else if(a[d]===")")u--;d++}if(u!==0)continue;let S=a.substring(g,d-1).trim(),w=d,E=1,y=w,b=/@(if\s*\(|endif)/g;b.lastIndex=w;let h;while((h=b.exec(a))!==null)if(h[1].startsWith("if"))E++;else if(h[1]==="endif"){if(E--,E===0){y=h.index+h[0].length;break}}if(E!==0)continue;let R=a.substring(w,y-6).trim(),A;if(Y(R)){let C=_n(a.substring(l,y));if(C.length===0)continue;let T=C[0].branches.filter((_)=>_.type!=="else"),k=i(l);if(!(T.length>0&&T.every((_)=>B(_.condition,t,c,k))))continue;A=C[0].branches.map((_)=>{let V=n(_.content);if(_.type==="elseif")return L(V,"@else-if",_.condition??"");if(_.type==="else")return L(V,"@else");return L(V,"@if",_.condition??"")}).join(`
2
+ import{xt,Hl}from"./chunk-hdfhaddy.js";import{D}from"./chunk-7b3dqeyr.js";import{X,Js,o,me,Q,x,sl,Xt,Pn,Xe,Je}from"./chunk-ty5frr9t.js";import{_r}from"./chunk-4z926gay.js";import{W}from"./chunk-a7bqrjm5.js";import{_n}from"./chunk-vbmvft7g.js";var G=`(?:"[^"]*"|'[^']*'|[^>"'])*`,H=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,q=65536,J=4,N=new Map;function fy(){N.clear()}function K(e){let c=[];for(let t of x(e,Q)){let n=t.token.match(/^<script\b([^>]*)>/i),s=t.token.match(/<\/script\s*>$/i);if(!n||!s)continue;let a=n[0].length,f=t.token.length-s[0].length;c.push(Object.freeze({fullMatch:t.token,attrs:n[1],body:t.token.slice(a,f),start:t.start,end:t.end}))}return c}function Ps(e,c={}){let t=e.length>=q,n=t?N.get(e):void 0;if(n===void 0){if(n=K(e),t)sl(N,J),N.set(e,n)}let s=c.skipAttrs;if(!s)return n.slice();let a=[];for(let f of n)if(s.lastIndex=0,!s.test(f.attrs))a.push(f);return a}function pi(e){let c=e.trim(),t=c.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(t){let s=t[1].trim(),a=t[2].trim(),{itemVar:f,indexVar:i}=j(a);if(f)return{style:"as",iterable:s,itemVar:f,indexVar:i}}let n=c.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(n){let s=n[1].trim(),a=n[2].trim(),{itemVar:f,indexVar:i}=j(s);if(f)return{style:"in",iterable:a,itemVar:f,indexVar:i}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function j(e){let c=e.trim(),t=c.match(/^(\w+)\s*=>\s*(\w+)$/);if(t)return{itemVar:t[2],indexVar:t[1]};let n=c.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(n)return{itemVar:n[1],indexVar:n[2]||null};let s=c.match(/^(\w+)\s*,\s*(\w+)$/);if(s)return{itemVar:s[1],indexVar:s[2]};let a=c.match(/^(\w+)$/);if(a)return{itemVar:a[1],indexVar:null};return{itemVar:null,indexVar:null}}function Is(e,c){return Hl(e,c)}function Y(e){let c=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,t=0,n;while((n=c.exec(e))!==null){let s=n[1];if(s.startsWith("if"))t++;else if(s==="endif")t--;else if(t===0)return!0}return!1}function Sr(e){let c=new Set,t=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,n=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,s;while((s=t.exec(e))!==null){let a=s[1],f;while((f=n.exec(a))!==null)c.add(f[1])}return c}function ee(e){if(!/[:@]for\s*=/.test(e)&&!/\bx-for\s*=/.test(e))return[];let c=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${G})>`,"iy"),t=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,n=x(e,(a,f)=>{c.lastIndex=f;let i=c.exec(a);if(!i||i.index!==f||!t.test(i[2]))return-1;return c.lastIndex}),s=[];for(let a of n){c.lastIndex=0;let f=c.exec(a.token);if(!f)continue;let i=f[2].match(t),p=pi(i?.[1]??i?.[2]??""),m=[p.itemVar,p.indexVar].filter(Boolean);if(m.length===0)continue;let r=f[1],g=/\/\s*>$/.test(a.token)||M.has(r.toLowerCase())?a.end:P(e,a.start,r,a.end);if(g!==-1)s.push({start:a.start,end:g,vars:new Set(m)})}return s}var z=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function te(e){return e.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function B(e,c,t,n){if(!e)return!1;let s=te(e),a=!1,f=!1,i=!1,p=/([a-zA-Z_$][\w$]*)/g,m;while((m=p.exec(s))!==null){let u=m[1];if(s.slice(0,m.index).trimEnd().endsWith("."))continue;if(z.has(u))continue;if(c.has(u)||n?.has(u))a=!0;else if(t&&u in t)f=!0}let r=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,l;while((l=r.exec(s))!==null){let u=l[1];if(s.slice(0,l.index).trimEnd().endsWith("."))continue;if(z.has(u)||t&&u in t)continue;i=!0}return(a||i)&&!f}function L(e,c,t){let n=t===void 0?` ${c}`:` ${c}="${t.replace(/"/g,"&quot;")}"`,s=e.trim(),a=s.match(H);if(a&&!ne(a[1])&&se(a[3],a[1])){let[,f,i,p]=a;return`<${f}${i}${n}>${p}</${f}>`}return`<template${n}>${s}</template>`}function ne(e){return/^[A-Z]/.test(e)}function se(e,c){let t=new RegExp(`<(/)?${c}(?=[\\s/>])`,"gi"),n=0,s;while((s=t.exec(e))!==null)if(s[1]){if(n--,n<0)return!1}else n++;return!0}function fi(e,c){let t=Sr(e);function n(s){let a=s,f=ee(s),i=(l)=>{let g=new Set;for(let u of f)if(l>u.start&&l<u.end)for(let d of u.vars)g.add(d);return g},p=/@if\s*\(/g,m,r=[];while((m=p.exec(a))!==null){let l=m.index,g=l+m[0].length,u=1,d=g;while(d<a.length&&u>0){if(a[d]==="(")u++;else if(a[d]===")")u--;d++}if(u!==0)continue;let S=a.substring(g,d-1).trim(),w=d,E=1,y=w,b=/@(if\s*\(|endif)/g;b.lastIndex=w;let h;while((h=b.exec(a))!==null)if(h[1].startsWith("if"))E++;else if(h[1]==="endif"){if(E--,E===0){y=h.index+h[0].length;break}}if(E!==0)continue;let R=a.substring(w,y-6).trim(),A;if(Y(R)){let C=_n(a.substring(l,y));if(C.length===0)continue;let T=C[0].branches.filter((_)=>_.type!=="else"),k=i(l);if(!(T.length>0&&T.every((_)=>B(_.condition,t,c,k))))continue;A=C[0].branches.map((_)=>{let V=n(_.content);if(_.type==="elseif")return L(V,"@else-if",_.condition??"");if(_.type==="else")return L(V,"@else");return L(V,"@if",_.condition??"")}).join(`
3
3
  `)}else{if(!B(S,t,c,i(l)))continue;A=L(n(R),"@if",S)}r.push({start:l,end:y,replacement:A}),p.lastIndex=y}for(let l=r.length-1;l>=0;l--){let{start:g,end:u,replacement:d}=r[l];a=a.substring(0,g)+d+a.substring(u)}return a}return n(e)}function re(e){let c=e.trim();if(c==="")return;if(c==="true")return!0;if(c==="false")return!1;if(c==="null")return!1;if(c==="undefined")return!1;if(c==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(c)){let s=Number(c);return s!==0&&!Number.isNaN(s)}let t=c.match(/^'((?:\\.|[^'\\])*)'$/);if(t)return t[1].length>0;let n=c.match(/^"((?:\\.|[^"\\])*)"$/);if(n)return n[1].length>0;return}var M=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Z=/<(script|style)\b/iy,ie=/<\/script/gi,oe=/<\/style/gi;function P(e,c,t,n){if(M.has(t.toLowerCase()))return n;let s=t.toLowerCase(),a=e.length,f=1,i=n;while(i<a){let p=e.indexOf("<",i);if(p===-1)return-1;if(i=p,e.startsWith("<!--",i)){let g=e.indexOf("-->",i+4);if(g===-1)return-1;i=g+3;continue}Z.lastIndex=i;let m=Z.exec(e);if(m){let g=e.indexOf(">",i);if(g===-1)return-1;if(e[g-1]==="/"){i=g+1;continue}let u=m[1].toLowerCase()==="script"?ie:oe;u.lastIndex=i;let d=u.exec(e);if(d===null)return-1;let S=e.indexOf(">",d.index);if(S===-1)return-1;i=S+1;continue}if(e[i+1]==="/"){let g=/^<\/([a-z][\w-]*)\s*>/i.exec(e.slice(i,i+64));if(!g){i++;continue}if(g[1].toLowerCase()===s){if(f--,i+=g[0].length,f===0)return i;continue}i+=g[0].length;continue}let r=/^<([a-z][\w-]*)\b/i.exec(e.slice(i,i+64));if(!r){i++;continue}let l=e.indexOf(">",i);if(l===-1)return-1;if(r[1].toLowerCase()===s){let g=e.slice(i,l+1);if(!(/\/\s*>$/.test(g)||M.has(s)))f++}i=l+1}return-1}var ce=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ae(e,c){let t=c,n=e.length;for(;;){while(t<n&&e[t]!=="<")t++;if(t>=n)return!1;if(e.startsWith("<!--",t)){let f=e.indexOf("-->",t+4);if(f===-1)return!1;t=f+3;continue}break}if(e[t+1]==="/")return!1;let s=e.indexOf(">",t);if(s===-1)return!1;let a=e.slice(t,s+1);return ce.test(a)}function gi(e){if(!e.includes(":if")&&!e.includes(":show")&&!e.includes("x-if")&&!e.includes("x-show")&&!e.includes("@if=")&&!e.includes("@show="))return e;let c=[],t=/<([a-zA-Z][\w-]*)/y,n=/\s/,s=new Set([":if",":show","x-if","x-show","@if","@show"]);x(e,(r,l)=>{t.lastIndex=l;let g=t.exec(r);if(!g||/^(?:script|style)$/i.test(g[1]))return-1;let u=t.lastIndex,d;while(u<r.length){let S=u;while(u<r.length&&n.test(r[u]))u++;let w=u;if(r[w]==="/"){w++;while(w<r.length&&n.test(r[w]))w++}if(r[w]===">"){if(d)c.push({start:l,end:w+1,tag:g[1],...d});return-1}if(u===S)return-1;let E=u;while(u<r.length&&!n.test(r[u])&&r[u]!=="="&&r[u]!==">")u++;if(u===E)return-1;let y=r.slice(E,u);if(y.startsWith("@")&&y.includes("("))return-1;let b=u,h=u;while(h<r.length&&n.test(r[h]))h++;if(r[h]!=="="){u=b;continue}h++;while(h<r.length&&n.test(r[h]))h++;let R=r[h];if(R==='"'||R==="'"){let A=r.indexOf(R,h+1);if(A===-1)return-1;if(!d&&R==='"'&&s.has(y))d={attrName:y,attrStart:S,attrEnd:A+1,value:r.slice(h+1,A)};u=A+1}else{u=h;while(u<r.length&&!n.test(r[u])&&r[u]!==">")u++}}return-1});let a=[],f=-1;for(let r of c){let{start:l,end:g,tag:u,attrName:d,value:S}=r;if(l<f)continue;let w=re(S);if(w===void 0)continue;let b=/\/\s*>$/.test(e.slice(l,g))||M.has(u.toLowerCase())?g:P(e,l,u,g);if(b===-1)continue;if((d===":if"||d==="x-if"||d==="@if")&&ae(e,b))continue;if(w===!0){let R=e.slice(l,r.attrStart)+e.slice(r.attrEnd,g);a.push({start:l,end:g,replacement:R});continue}a.push({start:l,end:b,replacement:""}),f=b}if(a.length===0)return e;a.sort((r,l)=>r.start-l.start);let i=[],p=-1;for(let r of a){if(r.start<p)continue;i.push(r),p=r.end}let m=e;for(let r=i.length-1;r>=0;r--){let{start:l,end:g,replacement:u}=i[r];m=m.substring(0,l)+u+m.substring(g)}return m}var F=[":for","@for","x-for"];function gg(e){let c=/(\s)((?::|@|x-|v-)[\w.:-]+)\s*=\s*"([^"]*\{\{[^"]*)"/g;return e.replace(c,(t,n,s,a)=>{let f=a.replace(/'((?:[^'\\]|\\.)*)'/g,(i,p)=>{if(!p.includes("{{"))return i;return`\`${p.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{\s*([^}]+?)\s*\}\}/g,(r,l)=>`\${${l}}`)}\``});return`${n}${s}="${f}"`})}function Os(e,c){if(!c||Object.keys(c).length===0)return e;if(!F.some((i)=>e.includes(`${i}=`)))return e;let t=Sr(e);if(Array.isArray(c.__stx_client_signal_names)){for(let i of c.__stx_client_signal_names)if(typeof i==="string")t.add(i)}let n=e,s=[],a=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,f;while((f=a.exec(n))!==null){let[i,p,m]=f,r=f.index,l=r+i.length,g=F.map((A)=>({attr:A,m:new RegExp(`\\s${A}="([^"]*)"`).exec(m)})).find((A)=>A.m!==null);if(!g||!g.m)continue;let u=pi(g.m[1]);if(!u.iterable||!u.itemVar)continue;let d=u.iterable.trim().split(/[.[(]/)[0].trim();if(!d||t.has(d)||!(d in c))continue;let S=P(n,r,p,l);if(S===-1)continue;let w=m.replace(new RegExp(`\\s${g.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),E=n.slice(l,S-`</${p}>`.length),y={...c,[u.itemVar]:void 0};if(u.indexVar)y[u.indexVar]=void 0;let b=Os(E,y),h=u.indexVar?`${u.iterable} as ${u.indexVar} => ${u.itemVar}`:`${u.iterable} as ${u.itemVar}`,R=p.toLowerCase()==="template"?b:`<${p}${w}>${b}</${p}>`;s.push({start:r,end:S,replacement:`@foreach(${h})${R}@endforeach`}),a.lastIndex=S}for(let i=s.length-1;i>=0;i--){let{start:p,end:m,replacement:r}=s[i];n=n.slice(0,p)+r+n.slice(m)}return n}function Ns(e,c){let t=e,n=/@(for|foreach)\s*\(/g,s,a=[],f=[];while((s=n.exec(t))!==null){let i=s[1],p=s.index,m=p+s[0].length,r=1,l=m;while(l<t.length&&r>0){if(t[l]==="(")r++;else if(t[l]===")")r--;l++}if(r!==0)continue;let g=t.substring(m,l-1).trim(),u=l,d=pi(g),S=i==="for"?"@endfor":"@endforeach",w=1,E=u,y=i==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${i}\\s*\\(|end${i})`,"g");y.lastIndex=u;let b;while((b=y.exec(t))!==null)if(b[1].startsWith(i))w++;else if(w--,w===0){E=b.index+b[0].length;break}if(w!==0)continue;let h=()=>{let v=[d.itemVar,d.indexVar].filter(Boolean);if(v.length)f.push({start:p,end:E,vars:v})};if(d.iterable){let v=d.iterable.trim();if(v.startsWith("[")||v.startsWith("{")||v.startsWith("'")||v.startsWith('"')||v.startsWith("`")||/^-?\d/.test(v)){h();continue}let I=v.split(/[.[(]/)[0].trim(),_=c?I in c:!1,V=f.some((O)=>p>O.start&&p<O.end&&O.vars.includes(I));if(I&&(_||V)){h();continue}}if(d.style==="as")g=d.indexVar?`(${d.itemVar}, ${d.indexVar}) in ${d.iterable}`:`${d.itemVar} in ${d.iterable}`;let R=t.substring(u,E-S.length).trim(),A=c?{...c}:{};if(d.itemVar)delete A[d.itemVar];if(d.indexVar)delete A[d.indexVar];let C=gg(Ns(R,A)),T=C.match(H),k;if(T){let[,v,I,_]=T;k=`<${v}${I} @for="${g}">${_}</${v}>`}else k=`<template @for="${g}">${C}</template>`;a.push({start:p,end:E,replacement:k}),n.lastIndex=E}for(let i=a.length-1;i>=0;i--){let{start:p,end:m,replacement:r}=a[i];t=t.substring(0,p)+r+t.substring(m)}return t}function le(e){let c=new Set,t=[],n=0,s=0,a=e.length,f=(r)=>{let l=n+1;while(l<a){let g=e[l];if(g==="\\"){l+=2;continue}if(g===r)return l+1;l++}return a},i=()=>{let r=n+2;while(r<a&&e[r]!==`
4
4
  `)r++;return r},p=()=>{let r=n+2;while(r<a-1){if(e[r]==="*"&&e[r+1]==="/")return r+2;r++}return a},m=(r)=>{let l=r,g=0;while(l<a){let u=e[l];if(u==="/"&&e[l+1]==="/"){let d=l+2;while(d<a&&e[d]!==`
5
- `)d++;l=d;continue}if(u==="/"&&e[l+1]==="*"){let d=l+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;l=d+2;continue}if(u==='"'||u==="'"||u==="`"){let d=l+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===u){d++;break}d++}l=d;continue}if(u==="("||u==="["||u==="{"){g++,l++;continue}if(u===")"||u==="]"||u==="}"){g--,l++;continue}if(u===";"&&g===0)return l+1;l++}return a};while(n<a){let r=e[n];if(r==="/"&&e[n+1]==="/"){let l=i();t.push(e.slice(n,l)),n=l;continue}if(r==="/"&&e[n+1]==="*"){let l=p();t.push(e.slice(n,l)),n=l;continue}if(r==='"'||r==="'"||r==="`"){let l=f(r);t.push(e.slice(n,l)),n=l;continue}if(r==="{"){s++,t.push(r),n++;continue}if(r==="}"){s--,t.push(r),n++;continue}if(s===0){let l=n>0?e[n-1]:"";if(l===""||/\s/.test(l)||l===";"||l==="}"||l==="{"){let u=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(u){let d=u[2],S=m(n+u[0].length);if(c.has(d)){t.push(`/* stx: deduped const ${d} */`),n=S;continue}c.add(d),t.push(e.slice(n,S)),n=S;continue}}}t.push(r),n++}return t.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function fe(e){let c=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${G})>`,"iy"),t=null,n=null;return x(e,(s,a)=>{c.lastIndex=a;let f=c.exec(s);if(!f)return-1;let i=f[1].toLowerCase();if(i==="script"||i==="style")return-1;let p=a+f[0].length-1;if(i==="body"&&n===null)n=p;if(t===null&&!ue.has(i))t=p;return a+f[0].length}),n??t}function de(e,c,t,n){let s=[],a=` data-stx="${n}"`,f=0,i=!1,p=(m)=>{if(t!==null&&!i&&t>=f&&t<=m)s.push(e.slice(f,t),a,e.slice(t,m)),i=!0;else s.push(e.slice(f,m))};for(let m of c){if(m.start<f)continue;p(m.start),f=m.end}return p(e.length),s.join("")}async function Ms(e,c,t,n={}){let s=Ps(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:i,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-nxat557m.js"));for(let b of s){let h=b.body;if(Xe(b.attrs))h=Je(h);if(n.forceClientSetup||a.test(h)){f.push({content:h,start:b.start,end:b.end});continue}if(!i(h))continue;try{let R=await p(Xt(h).code,c||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(R))f.push({content:h,start:b.start,end:b.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let m=`${c??""}\x00${f.map((b)=>b.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(m).toString(36).slice(0,10)}`,l=[];for(let b=0;b<f.length;b++){let h=f[b].bundled??Xt(f[b].content).code;if(!f[b].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=Ot(h);let R=D(h);l.push(`// \u2500\u2500 merged signal script #${b+1} \u2500\u2500
5
+ `)d++;l=d;continue}if(u==="/"&&e[l+1]==="*"){let d=l+2;while(d<a-1&&!(e[d]==="*"&&e[d+1]==="/"))d++;l=d+2;continue}if(u==='"'||u==="'"||u==="`"){let d=l+1;while(d<a){if(e[d]==="\\"){d+=2;continue}if(e[d]===u){d++;break}d++}l=d;continue}if(u==="("||u==="["||u==="{"){g++,l++;continue}if(u===")"||u==="]"||u==="}"){g--,l++;continue}if(u===";"&&g===0)return l+1;l++}return a};while(n<a){let r=e[n];if(r==="/"&&e[n+1]==="/"){let l=i();t.push(e.slice(n,l)),n=l;continue}if(r==="/"&&e[n+1]==="*"){let l=p();t.push(e.slice(n,l)),n=l;continue}if(r==='"'||r==="'"||r==="`"){let l=f(r);t.push(e.slice(n,l)),n=l;continue}if(r==="{"){s++,t.push(r),n++;continue}if(r==="}"){s--,t.push(r),n++;continue}if(s===0){let l=n>0?e[n-1]:"";if(l===""||/\s/.test(l)||l===";"||l==="}"||l==="{"){let u=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(u){let d=u[2],S=m(n+u[0].length);if(c.has(d)){t.push(`/* stx: deduped const ${d} */`),n=S;continue}c.add(d),t.push(e.slice(n,S)),n=S;continue}}}t.push(r),n++}return t.join("")}var ue=new Set(["script","style","html","head","meta","link","title","!doctype"]);function fe(e){let c=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${G})>`,"iy"),t=null,n=null;return x(e,(s,a)=>{c.lastIndex=a;let f=c.exec(s);if(!f)return-1;let i=f[1].toLowerCase();if(i==="script"||i==="style")return-1;let p=a+f[0].length-1;if(i==="body"&&n===null)n=p;if(t===null&&!ue.has(i))t=p;return a+f[0].length}),n??t}function de(e,c,t,n){let s=[],a=` data-stx="${n}"`,f=0,i=!1,p=(m)=>{if(t!==null&&!i&&t>=f&&t<=m)s.push(e.slice(f,t),a,e.slice(t,m)),i=!0;else s.push(e.slice(f,m))};for(let m of c){if(m.start<f)continue;p(m.start),f=m.end}return p(e.length),s.join("")}async function Ms(e,c,t,n={}){let s=Ps(e,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),a=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,f=[],{hasUserImports:i,bundleClientScript:p}=await o("stx/client-script-bundler",()=>import("./chunk-dyz7cmf4.js"));for(let b of s){let h=b.body;if(Xe(b.attrs))h=Je(h);if(n.forceClientSetup||a.test(h)){f.push({content:h,start:b.start,end:b.end});continue}if(!i(h))continue;try{let R=await p(Xt(h).code,c||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(a.test(R))f.push({content:h,start:b.start,end:b.end})}catch{}}if(f.length===0)return{output:e,setupCode:null};let m=`${c??""}\x00${f.map((b)=>b.content).join("\x00")}`,r=`__stx_setup_${Bun.hash(m).toString(36).slice(0,10)}`,l=[];for(let b=0;b<f.length;b++){let h=f[b].bundled??Xt(f[b].content).code;if(!f[b].bundled&&i(h))h=await p(h,c||"",{projectRoot:process.cwd()});h=Ot(h);let R=D(h);l.push(`// \u2500\u2500 merged signal script #${b+1} \u2500\u2500
6
6
  ${R}`)}let g=l.join(`
7
7
 
8
8
  `);g=le(g);let d=X(g).split(",").map((b)=>b.trim()).filter(Boolean),S=Pn(g,t),w=`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{bs,ws}from"./chunk-7nn5s0c3.js";import{x}from"./chunk-16edtncx.js";import{a}from"./chunk-3ykhczg6.js";import{ot,fe}from"./chunk-9y83pdcb.js";import{xc}from"./chunk-r1tf52r2.js";import{W}from"./chunk-a7bqrjm5.js";import{w}from"./chunk-v6gkjg5f.js";import{f}from"./chunk-p92272k0.js";import{existsSync as z,mkdirSync as C,copyFileSync as I,chmodSync as B,rmSync as xe}from"fs";import{join as c,basename as ye,resolve as K}from"path";import{spawn as _}from"child_process";import{platform as Se}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=x(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var Vu=`
2
+ import{bs,ws}from"./chunk-7nn5s0c3.js";import{x}from"./chunk-ty5frr9t.js";import{a}from"./chunk-65c11t6g.js";import{ot,fe}from"./chunk-9y83pdcb.js";import{xc}from"./chunk-tx27trcp.js";import{W}from"./chunk-a7bqrjm5.js";import{w}from"./chunk-v6gkjg5f.js";import{f}from"./chunk-p92272k0.js";import{existsSync as z,mkdirSync as C,copyFileSync as I,chmodSync as B,rmSync as xe}from"fs";import{join as c,basename as ye,resolve as K}from"path";import{spawn as _}from"child_process";import{platform as Se}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=x(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var Vu=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';