@stacksjs/stx 0.2.915 → 0.2.917

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 (91) hide show
  1. package/dist/{chunk-dgt9kfkp.js → chunk-0asdv3hk.js} +1 -1
  2. package/dist/{chunk-z5nx021e.js → chunk-0atz8fjx.js} +1 -1
  3. package/dist/chunk-0fm6avxt.js +3 -0
  4. package/dist/{chunk-dp6r6gtb.js → chunk-0sj79ha5.js} +2 -2
  5. package/dist/{chunk-pmn9kynz.js → chunk-0v7555tr.js} +1 -1
  6. package/dist/{chunk-49980am3.js → chunk-11rnqey0.js} +1 -1
  7. package/dist/chunk-31yx4sjh.js +2 -0
  8. package/dist/{chunk-vnk582z7.js → chunk-388xpdw5.js} +31 -5
  9. package/dist/chunk-38kerh2r.js +2 -0
  10. package/dist/{chunk-4a9bqc8f.js → chunk-3h4db9yb.js} +3 -3
  11. package/dist/{chunk-man5ap64.js → chunk-43sgpy4e.js} +4 -4
  12. package/dist/{chunk-g44932zc.js → chunk-4pve3r5a.js} +1 -1
  13. package/dist/chunk-5d5dxts6.js +2 -0
  14. package/dist/{chunk-4w9pvpfd.js → chunk-5fdsyyfe.js} +1 -1
  15. package/dist/{chunk-5pb1x7x6.js → chunk-67yr4m5h.js} +1 -1
  16. package/dist/chunk-6aqr0e6s.js +2 -0
  17. package/dist/{chunk-xtf3sab5.js → chunk-6bw02d1t.js} +1 -1
  18. package/dist/{chunk-7gwysmrs.js → chunk-789yp1tg.js} +1 -1
  19. package/dist/{chunk-r1fhahnn.js → chunk-7ar11ccn.js} +1 -1
  20. package/dist/{chunk-cv6d4zr5.js → chunk-7fc0vrs5.js} +1 -1
  21. package/dist/{chunk-x1kzqxj5.js → chunk-82fg5gp6.js} +1 -1
  22. package/dist/chunk-89r7bbsk.js +2 -0
  23. package/dist/{chunk-7anbc757.js → chunk-8b8az19t.js} +4 -4
  24. package/dist/{chunk-n1y82svg.js → chunk-8x3yaahc.js} +1 -1
  25. package/dist/{chunk-n0nf8n0h.js → chunk-91p8p2cc.js} +2 -2
  26. package/dist/{chunk-bdkst2wp.js → chunk-9kn81bmp.js} +1 -1
  27. package/dist/{chunk-wz44vmgn.js → chunk-9w9y84t5.js} +2 -2
  28. package/dist/{chunk-4r0028av.js → chunk-b5qzed8y.js} +7 -7
  29. package/dist/chunk-bh2khcet.js +2 -0
  30. package/dist/{chunk-p9fyn5k4.js → chunk-bm6y085n.js} +1 -1
  31. package/dist/{chunk-etmq1qny.js → chunk-c13dv3wm.js} +1 -1
  32. package/dist/{chunk-1rfzs48h.js → chunk-c6096ssb.js} +1 -1
  33. package/dist/{chunk-t85zac4y.js → chunk-da05660m.js} +5 -5
  34. package/dist/{chunk-9xmx8hc7.js → chunk-dwt2drzf.js} +1 -1
  35. package/dist/{chunk-xj95sk0y.js → chunk-e0tvd7jj.js} +1 -1
  36. package/dist/{chunk-1jakr6f2.js → chunk-ezqfrea9.js} +1 -1
  37. package/dist/{chunk-5xbx0r3k.js → chunk-f0sxbgbm.js} +1 -1
  38. package/dist/{chunk-vq7m7xcz.js → chunk-fn1reean.js} +19 -19
  39. package/dist/{chunk-d1ka4dvr.js → chunk-h0aw9hmc.js} +2 -2
  40. package/dist/{chunk-eqdg72re.js → chunk-js1wayhb.js} +1 -1
  41. package/dist/chunk-k2t0w8z1.js +2 -0
  42. package/dist/{chunk-am7xmh9p.js → chunk-kcpxqsdj.js} +1 -1
  43. package/dist/{chunk-pcwq66w3.js → chunk-ma5ptt4m.js} +1 -1
  44. package/dist/{chunk-4w8t0a9e.js → chunk-mf5cqv1k.js} +2 -2
  45. package/dist/{chunk-47nzpbvm.js → chunk-mt5ewkbg.js} +2 -2
  46. package/dist/{chunk-zbpvmgjn.js → chunk-n4m50dpk.js} +5 -5
  47. package/dist/{chunk-9b2wdkbq.js → chunk-ngqb22wj.js} +8 -8
  48. package/dist/{chunk-whc4jptx.js → chunk-nwef47nx.js} +1 -1
  49. package/dist/{chunk-q9gbdzw0.js → chunk-p3x84jj0.js} +1 -1
  50. package/dist/chunk-p9bghe13.js +2 -0
  51. package/dist/chunk-q2cwzgd0.js +2 -0
  52. package/dist/{chunk-g0hkknzm.js → chunk-q60afqr7.js} +1 -1
  53. package/dist/chunk-s2c0ynn9.js +2 -0
  54. package/dist/{chunk-7x3tt27s.js → chunk-t65f98qv.js} +1 -1
  55. package/dist/{chunk-47z0m17p.js → chunk-v78hjbz0.js} +1 -1
  56. package/dist/{chunk-smnt37jq.js → chunk-w6ydg43d.js} +1 -1
  57. package/dist/{chunk-mdgcjzcn.js → chunk-wc10m4tp.js} +1 -1
  58. package/dist/{chunk-q85wy43m.js → chunk-wcxa8xy2.js} +1 -1
  59. package/dist/{chunk-wsfqb5jk.js → chunk-wgrj0cvs.js} +1 -1
  60. package/dist/{chunk-7qzanp9y.js → chunk-wj9bqkc0.js} +1 -1
  61. package/dist/{chunk-6t8ce21j.js → chunk-wm24jx3t.js} +1 -1
  62. package/dist/chunk-wpkwx3wq.js +2 -0
  63. package/dist/{chunk-1gj46s0g.js → chunk-wq17dce6.js} +1 -1
  64. package/dist/{chunk-yga49yw3.js → chunk-xjt5129x.js} +1 -1
  65. package/dist/{chunk-1p6gaaf3.js → chunk-yc3frw0z.js} +1 -1
  66. package/dist/{chunk-barb4gka.js → chunk-yq2krsc9.js} +1 -1
  67. package/dist/{chunk-zk5g49p5.js → chunk-ywrpmyzj.js} +1 -1
  68. package/dist/cli.js +7 -7
  69. package/dist/craft-entry.js +1 -1
  70. package/dist/craft.js +1 -1
  71. package/dist/dev-server/ts-css.d.ts +1 -1
  72. package/dist/dev-server/ts-css.js +2 -2
  73. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  74. package/dist/native/compiler/html-to-ir.js +30 -0
  75. package/dist/process.js +1 -1
  76. package/dist/pwa.js +1 -1
  77. package/dist/ssg.js +2 -2
  78. package/dist/types/config-types.d.ts +1 -0
  79. package/package.json +5 -5
  80. package/dist/chunk-490rrkrp.js +0 -2
  81. package/dist/chunk-6n50b07t.js +0 -2
  82. package/dist/chunk-g4w3wms2.js +0 -2
  83. package/dist/chunk-j3d3q3g7.js +0 -2
  84. package/dist/chunk-jmggm1ep.js +0 -3
  85. package/dist/chunk-m8mmasgc.js +0 -2
  86. package/dist/chunk-mjny8x91.js +0 -2
  87. package/dist/chunk-r4e17p2x.js +0 -2
  88. package/dist/chunk-rnsa5zz5.js +0 -2
  89. package/dist/chunk-sw5g5mbd.js +0 -2
  90. package/dist/chunk-t63y6qd5.js +0 -2
  91. package/dist/chunk-z9wwa50p.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{R}from"./chunk-0jdz31q1.js";import{Ie,Wt,oe,F,Nn,ae,P}from"./chunk-4r0028av.js";import{Zi,ho,d,m,M,Ee,p,yo,n,u,_}from"./chunk-4vz17ytv.js";import{kr}from"./chunk-wz44vmgn.js";import{ge}from"./chunk-9tv0tw7f.js";import{js}from"./chunk-nhyv3w4r.js";var he=1000,me=!1;function xe(t,r){let i=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,s;while((s=i.exec(t))!==null){let l=s.index+s[0].length,b=s.index+s[0].indexOf("("),x=_(t,"(",")",b);if(x===-1)continue;let f=t.slice(l,x).trim();if(!f)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(f)))continue;let h;try{let a=M(f,r);if(!a||typeof a!=="object")continue;h=JSON.stringify(a)}catch{continue}e+=t.slice(o,l)+h,o=x,i.lastIndex=x}return o===0?t:e+t.slice(o)}function be(t,r){let i=/@component\s*\(/g,e=t,o,s=[];while((o=i.exec(e))!==null){let l=o.index,b=l+o[0].length-1,x=1,f=b+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")"){if(x--,x===0)break}f++}if(x!==0)continue;let c=e.substring(b+1,f),h=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),w=g.match(/^\s*,\s*/);if(!w)continue;let k=g.slice(w[0].length).trim();if(!k)continue;try{let S=M(k,r),B=JSON.stringify(S),I=`@component('${y}', ${B})`;s.push({start:l,end:h,replacement:I})}catch{continue}}for(let l=s.length-1;l>=0;l--){let{start:b,end:x,replacement:f}=s[l];e=e.substring(0,b)+f+e.substring(x)}return e}function se(t,r,i){let e=t,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),s;while((s=o.exec(e))!==null){let l=s.index,b=l+s[0].length-1,x=1,f=b+1,c=null,h=!1;while(f<e.length&&x>0){let g=e[f];if(h){h=!1,f++;continue}if(g==="\\"&&c){h=!0,f++;continue}if(c){if(g===c)c=null;f++;continue}if(g==='"'||g==="'"||g==="`"){c=g,f++;continue}if(g==="(")x++;else if(g===")"){if(x--,x===0)break}f++}if(x!==0)break;let a=e.substring(b+1,f),y=i(a);e=e.substring(0,l)+y+e.substring(f+1)}return e}function ye(t,r){let i=t;return i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,s)=>{try{if(F(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Zi(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let h=JSON.stringify(c);if(h===void 0){if(!Ee(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(h,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function le(t,r){let i=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let s=i.exec(t);s;s=i.exec(t)){if(!s[1]){let f=s[0].length===3&&s[0]==="{{{"?3:2,c=s[0]==="{!!"?t.indexOf("!!}",i.lastIndex):Ie(t,s.index,f);if(c<0)break;i.lastIndex=c+(s[0]==="{!!"?3:f);continue}let l=i.lastIndex,b=!0,x=/^\s*\(/.exec(t.slice(l));if(x){let f=l+x[0].length-1,c=_(t,"(",")",f);if(c<0)break;l=c+1;try{let h=`!!(${t.slice(f+1,c).trim()})`;b=m(h)?Boolean(p(h,Object.keys(r))(...Object.values(r))):Boolean(d(h,r))}catch{b=!1}}if(e+=t.slice(o,s.index),b)return e+(s[1]==="break"?Q:ee);o=l,i.lastIndex=l}return e+t.slice(o)}function ue(t){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),i="",e=0;return Nn(t,(o,s,l)=>(i+=ie(r(t.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ie(r(t.slice(e)))}function fe(t,r,i,e){return ae(t,r,i==null?"":String(i),!1,e)}function ie(t){let r=t;return r=se(r,"@break",(i)=>{let e=i.trim();if(!yo(e))return"";return`\`; if (${e}) { break; } result += \``}),r=se(r,"@continue",(i)=>{let e=i.trim();if(!yo(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function _e(t){let r=/@forelse\s*\(/g,i,e=[],o=/@foreach\s*\(/g,s=/@endforeach/g,l;while((l=o.exec(t))!==null)e.push({pos:l.index,delta:1});while((l=s.exec(t))!==null)e.push({pos:l.index,delta:-1});e.sort((c,h)=>c.pos-h.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let h=0,a=b.length-1,y=0;while(h<=a){let g=h+a>>1;if(b[g].pos<=c)y=b[g].depth,h=g+1;else a=g-1}return y}while((i=r.exec(t))!==null){if(f(i.index)>0)continue;let c=i.index,h=i.index+i[0].length-1,a=1,y=h+1,g=-1;while(y<t.length&&a>0){if(t[y]==="(")a++;else if(t[y]===")"){if(a--,a===0){g=y;break}}y++}if(g===-1)continue;let w=t.substring(h+1,g),k=Wt(w);if(!k)continue;let{arrayExpr:S,itemVar:B}=k,I=g+1,A=1,T=I,K=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&T<t.length){K.lastIndex=T,L.lastIndex=T;let C=K.exec(t),E=L.exec(t);if(!E)break;if(C&&C.index<E.index)A++,T=C.index+C[0].length;else{if(A--,A===0){V=E.index;break}T=E.index+11}}if(V===-1)continue;let O=t.substring(I,V),Z=V+11,z=-1,D=0,N=0;while(N<O.length){let C=O.indexOf("@",N);if(C===-1)break;let E=O.substring(C);if(/^@forelse\s*\(/.test(E))D++,N=C+1;else if(E.startsWith("@endforelse"))D--,N=C+11;else if(D===0&&E.startsWith("@empty")){if(O.length<=C+6||!/[a-z]/i.test(O[C+6])){z=C;break}N=C+1}else N=C+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:S,itemVar:B,foreachContent:O.substring(0,z),emptyContent:O.substring(z+6)}}return null}function ce(t,r){let i=t;while(!0){let e=_e(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(m(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let h;if(!Array.isArray(c)||c.length===0)h=f;else h=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+h+i.substring(s)}catch(c){let h=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${h}`,n.EVALUATION_ERROR);i=i.substring(0,o)+a+i.substring(s)}}return i}var de="<!--stx:foreach-not-iterable:",$e=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Re(t,r){return`${de}${encodeURIComponent(t)}|${encodeURIComponent(r)}-->`}function Ae(t,r){console.warn(`[stx] @foreach(${t}) in ${r}: ${t} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Is(t){if(!t.includes(de))return t;return t.replace($e,(r,i,e)=>(Ae(decodeURIComponent(i),decodeURIComponent(e)),""))}function yg(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)l=s.next();return l.value}async function ui(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)await R(),l=s.next();return l.value}function*ne(t,r,i,e,o=!1){let s=t,l=new Set(r.__stx_client_signal_names||[]);for(let c of kr(t))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=ce(s,r);function b(c){let h=/@foreach\s*\(/g,a;while((a=h.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,w=1,k=g+1,S=-1;while(k<c.length&&w>0){if(c[k]==="(")w++;else if(c[k]===")"){if(w--,w===0){S=k;break}}k++}if(S===-1)continue;let B=c.substring(g+1,S),I=Wt(B);if(!I)continue;let A=y,{arrayExpr:T,itemVar:K}=I,L=S+1,V=1,O=L,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&O<c.length){Z.lastIndex=O,z.lastIndex=O;let D=Z.exec(c),N=z.exec(c);if(!N)break;if(D&&D.index<N.index)V++,O=D.index+D[0].length;else{if(V--,V===0){let C=c.substring(L,N.index),E=N.index+11;return{start:A,end:E,arrayExpr:T,itemVar:K,content:C}}O=N.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:w,arrayExpr:k,itemVar:S,content:B}=y;try{let I=k.trim(),A;if(m(I))A=p(I,Object.keys(h))(...Object.values(h));else A=d(I,h);let T=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),T=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),T=!0;else{let E=Re(I,i)+u("Foreach",`Error in @foreach: ${I} is not iterable`,n.TYPE_ERROR);a=a.substring(0,g)+E+a.substring(w);continue}let K=e?.loops?.useAltLoopVariable??me,L=S.trim(),V=null,O,Z=!1;if(L.includes("=>")){let E=L.split("=>").map((W)=>W.trim());if(E.length===2&&E[0]&&E[1])V=E[0],O=E[1];else O=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let E=L.split(",").map((W)=>W.trim());if(E.length===2&&E[0]&&E[1])O=E[0],V=E[1],Z=!0;else O=L}else O=L;let z="",D=new Set(oe(`${k} as ${S}`)),N=A,C=h[ho]??new WeakMap;for(let E=0;E<N.length;E++){if(E%16===0)yield;let W=N[E],te={index:E,iteration:E+1,first:E===0,last:E===N.length-1,count:N.length},j={...h,loop:te,$loop:te,[ho]:C};if(Array.isArray(h.__stx_client_signal_names))j.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(O.startsWith("[")&&O.endsWith("]")){let H=O.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(W))H.forEach((U,X)=>{if(U)j[U]=W[X]});else j[O]=W}else if(O.startsWith("{")&&O.endsWith("}")){let H=O.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(W!==null&&typeof W==="object")H.forEach((U)=>{let X=U.indexOf(":"),Y=(X===-1?U:U.slice(0,X)).trim(),re=X===-1?Y:U.slice(X+1).trim();if(Y&&re)j[re]=W[Y]});else j[O]=W}else j[O]=W;if(V)if(!Z&&T&&Array.isArray(W)&&W.length===2)j[V]=W[0],j[O]=W[1];else j[V]=E;let v=ce(B,j);v=yield*ne(v,j,i,e,!0),v=ge(v,j,i),v=le(v,j);let J=v.indexOf(Q),G=v.indexOf(ee),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)v=v.slice(0,q);if(v=P(v,j,i),v=ye(v,j),v=be(v,j),v=xe(v,j),z+=v,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(w)}catch(I){let A=u("Foreach",`Error in @foreach(${k.trim()} as ${S.trim()}): ${I instanceof Error?I.message:String(I)}`,n.EVALUATION_ERROR);a=a.substring(0,g)+A+a.substring(w)}}return a}s=yield*x(s,r),s=we(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=Se(s,r,f),o?s:Is(s)}function bg(t){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(t);if(!r||/^(?:const|let|var)$/.test(r[2]))return t;return`${r[1]}let ${t.slice(r[1].length)}`}function pe(t){return yo(t)}function we(t,r,i,e){let o=t,s=!0;while(s){s=!1;let l=o.match(/@for\s*\(/);if(!l||l.index===void 0)break;let b=l.index,x=b+l[0].length-1,f=_(o,"(",")",x);if(f===-1)break;let c=bg(o.slice(x+1,f)),h=f+1,a=js(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let w=u("For",`Unsafe expression in @for: ${c}`,n.UNSAFE_EXPRESSION);o=o.substring(0,b)+w+o.substring(g),s=!0;continue}try{let w=Oe(c),k=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(w.length>0&&k){let K=ke({forExpr:c,content:y,iterVarNames:w,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let S=Object.keys(r),B=Object.values(r),I=ue(y),T=Function(...S,"__stxRenderLoopValue",`
2
+ import{R}from"./chunk-0jdz31q1.js";import{Ie,Wt,oe,F,Nn,ae,P}from"./chunk-b5qzed8y.js";import{Zi,ho,d,m,M,Ee,p,yo,n,u,_}from"./chunk-4vz17ytv.js";import{kr}from"./chunk-9w9y84t5.js";import{ge}from"./chunk-9tv0tw7f.js";import{js}from"./chunk-nhyv3w4r.js";var he=1000,me=!1;function xe(t,r){let i=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,s;while((s=i.exec(t))!==null){let l=s.index+s[0].length,b=s.index+s[0].indexOf("("),x=_(t,"(",")",b);if(x===-1)continue;let f=t.slice(l,x).trim();if(!f)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(f)))continue;let h;try{let a=M(f,r);if(!a||typeof a!=="object")continue;h=JSON.stringify(a)}catch{continue}e+=t.slice(o,l)+h,o=x,i.lastIndex=x}return o===0?t:e+t.slice(o)}function be(t,r){let i=/@component\s*\(/g,e=t,o,s=[];while((o=i.exec(e))!==null){let l=o.index,b=l+o[0].length-1,x=1,f=b+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")"){if(x--,x===0)break}f++}if(x!==0)continue;let c=e.substring(b+1,f),h=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),w=g.match(/^\s*,\s*/);if(!w)continue;let k=g.slice(w[0].length).trim();if(!k)continue;try{let S=M(k,r),B=JSON.stringify(S),I=`@component('${y}', ${B})`;s.push({start:l,end:h,replacement:I})}catch{continue}}for(let l=s.length-1;l>=0;l--){let{start:b,end:x,replacement:f}=s[l];e=e.substring(0,b)+f+e.substring(x)}return e}function se(t,r,i){let e=t,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),s;while((s=o.exec(e))!==null){let l=s.index,b=l+s[0].length-1,x=1,f=b+1,c=null,h=!1;while(f<e.length&&x>0){let g=e[f];if(h){h=!1,f++;continue}if(g==="\\"&&c){h=!0,f++;continue}if(c){if(g===c)c=null;f++;continue}if(g==='"'||g==="'"||g==="`"){c=g,f++;continue}if(g==="(")x++;else if(g===")"){if(x--,x===0)break}f++}if(x!==0)break;let a=e.substring(b+1,f),y=i(a);e=e.substring(0,l)+y+e.substring(f+1)}return e}function ye(t,r){let i=t;return i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,s)=>{try{if(F(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Zi(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let h=JSON.stringify(c);if(h===void 0){if(!Ee(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(h,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function le(t,r){let i=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let s=i.exec(t);s;s=i.exec(t)){if(!s[1]){let f=s[0].length===3&&s[0]==="{{{"?3:2,c=s[0]==="{!!"?t.indexOf("!!}",i.lastIndex):Ie(t,s.index,f);if(c<0)break;i.lastIndex=c+(s[0]==="{!!"?3:f);continue}let l=i.lastIndex,b=!0,x=/^\s*\(/.exec(t.slice(l));if(x){let f=l+x[0].length-1,c=_(t,"(",")",f);if(c<0)break;l=c+1;try{let h=`!!(${t.slice(f+1,c).trim()})`;b=m(h)?Boolean(p(h,Object.keys(r))(...Object.values(r))):Boolean(d(h,r))}catch{b=!1}}if(e+=t.slice(o,s.index),b)return e+(s[1]==="break"?Q:ee);o=l,i.lastIndex=l}return e+t.slice(o)}function ue(t){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),i="",e=0;return Nn(t,(o,s,l)=>(i+=ie(r(t.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ie(r(t.slice(e)))}function fe(t,r,i,e){return ae(t,r,i==null?"":String(i),!1,e)}function ie(t){let r=t;return r=se(r,"@break",(i)=>{let e=i.trim();if(!yo(e))return"";return`\`; if (${e}) { break; } result += \``}),r=se(r,"@continue",(i)=>{let e=i.trim();if(!yo(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function _e(t){let r=/@forelse\s*\(/g,i,e=[],o=/@foreach\s*\(/g,s=/@endforeach/g,l;while((l=o.exec(t))!==null)e.push({pos:l.index,delta:1});while((l=s.exec(t))!==null)e.push({pos:l.index,delta:-1});e.sort((c,h)=>c.pos-h.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let h=0,a=b.length-1,y=0;while(h<=a){let g=h+a>>1;if(b[g].pos<=c)y=b[g].depth,h=g+1;else a=g-1}return y}while((i=r.exec(t))!==null){if(f(i.index)>0)continue;let c=i.index,h=i.index+i[0].length-1,a=1,y=h+1,g=-1;while(y<t.length&&a>0){if(t[y]==="(")a++;else if(t[y]===")"){if(a--,a===0){g=y;break}}y++}if(g===-1)continue;let w=t.substring(h+1,g),k=Wt(w);if(!k)continue;let{arrayExpr:S,itemVar:B}=k,I=g+1,A=1,T=I,K=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&T<t.length){K.lastIndex=T,L.lastIndex=T;let C=K.exec(t),E=L.exec(t);if(!E)break;if(C&&C.index<E.index)A++,T=C.index+C[0].length;else{if(A--,A===0){V=E.index;break}T=E.index+11}}if(V===-1)continue;let O=t.substring(I,V),Z=V+11,z=-1,D=0,N=0;while(N<O.length){let C=O.indexOf("@",N);if(C===-1)break;let E=O.substring(C);if(/^@forelse\s*\(/.test(E))D++,N=C+1;else if(E.startsWith("@endforelse"))D--,N=C+11;else if(D===0&&E.startsWith("@empty")){if(O.length<=C+6||!/[a-z]/i.test(O[C+6])){z=C;break}N=C+1}else N=C+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:S,itemVar:B,foreachContent:O.substring(0,z),emptyContent:O.substring(z+6)}}return null}function ce(t,r){let i=t;while(!0){let e=_e(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(m(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let h;if(!Array.isArray(c)||c.length===0)h=f;else h=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+h+i.substring(s)}catch(c){let h=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${h}`,n.EVALUATION_ERROR);i=i.substring(0,o)+a+i.substring(s)}}return i}var de="<!--stx:foreach-not-iterable:",$e=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Re(t,r){return`${de}${encodeURIComponent(t)}|${encodeURIComponent(r)}-->`}function Ae(t,r){console.warn(`[stx] @foreach(${t}) in ${r}: ${t} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Is(t){if(!t.includes(de))return t;return t.replace($e,(r,i,e)=>(Ae(decodeURIComponent(i),decodeURIComponent(e)),""))}function yg(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)l=s.next();return l.value}async function ui(t,r,i,e,o=!1){let s=ne(t,r,i,e,o),l=s.next();while(!l.done)await R(),l=s.next();return l.value}function*ne(t,r,i,e,o=!1){let s=t,l=new Set(r.__stx_client_signal_names||[]);for(let c of kr(t))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=ce(s,r);function b(c){let h=/@foreach\s*\(/g,a;while((a=h.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,w=1,k=g+1,S=-1;while(k<c.length&&w>0){if(c[k]==="(")w++;else if(c[k]===")"){if(w--,w===0){S=k;break}}k++}if(S===-1)continue;let B=c.substring(g+1,S),I=Wt(B);if(!I)continue;let A=y,{arrayExpr:T,itemVar:K}=I,L=S+1,V=1,O=L,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&O<c.length){Z.lastIndex=O,z.lastIndex=O;let D=Z.exec(c),N=z.exec(c);if(!N)break;if(D&&D.index<N.index)V++,O=D.index+D[0].length;else{if(V--,V===0){let C=c.substring(L,N.index),E=N.index+11;return{start:A,end:E,arrayExpr:T,itemVar:K,content:C}}O=N.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:w,arrayExpr:k,itemVar:S,content:B}=y;try{let I=k.trim(),A;if(m(I))A=p(I,Object.keys(h))(...Object.values(h));else A=d(I,h);let T=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),T=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),T=!0;else{let E=Re(I,i)+u("Foreach",`Error in @foreach: ${I} is not iterable`,n.TYPE_ERROR);a=a.substring(0,g)+E+a.substring(w);continue}let K=e?.loops?.useAltLoopVariable??me,L=S.trim(),V=null,O,Z=!1;if(L.includes("=>")){let E=L.split("=>").map((W)=>W.trim());if(E.length===2&&E[0]&&E[1])V=E[0],O=E[1];else O=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let E=L.split(",").map((W)=>W.trim());if(E.length===2&&E[0]&&E[1])O=E[0],V=E[1],Z=!0;else O=L}else O=L;let z="",D=new Set(oe(`${k} as ${S}`)),N=A,C=h[ho]??new WeakMap;for(let E=0;E<N.length;E++){if(E%16===0)yield;let W=N[E],te={index:E,iteration:E+1,first:E===0,last:E===N.length-1,count:N.length},j={...h,loop:te,$loop:te,[ho]:C};if(Array.isArray(h.__stx_client_signal_names))j.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(O.startsWith("[")&&O.endsWith("]")){let H=O.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(W))H.forEach((U,X)=>{if(U)j[U]=W[X]});else j[O]=W}else if(O.startsWith("{")&&O.endsWith("}")){let H=O.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(W!==null&&typeof W==="object")H.forEach((U)=>{let X=U.indexOf(":"),Y=(X===-1?U:U.slice(0,X)).trim(),re=X===-1?Y:U.slice(X+1).trim();if(Y&&re)j[re]=W[Y]});else j[O]=W}else j[O]=W;if(V)if(!Z&&T&&Array.isArray(W)&&W.length===2)j[V]=W[0],j[O]=W[1];else j[V]=E;let v=ce(B,j);v=yield*ne(v,j,i,e,!0),v=ge(v,j,i),v=le(v,j);let J=v.indexOf(Q),G=v.indexOf(ee),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)v=v.slice(0,q);if(v=P(v,j,i),v=ye(v,j),v=be(v,j),v=xe(v,j),z+=v,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(w)}catch(I){let A=u("Foreach",`Error in @foreach(${k.trim()} as ${S.trim()}): ${I instanceof Error?I.message:String(I)}`,n.EVALUATION_ERROR);a=a.substring(0,g)+A+a.substring(w)}}return a}s=yield*x(s,r),s=we(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=Se(s,r,f),o?s:Is(s)}function bg(t){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(t);if(!r||/^(?:const|let|var)$/.test(r[2]))return t;return`${r[1]}let ${t.slice(r[1].length)}`}function pe(t){return yo(t)}function we(t,r,i,e){let o=t,s=!0;while(s){s=!1;let l=o.match(/@for\s*\(/);if(!l||l.index===void 0)break;let b=l.index,x=b+l[0].length-1,f=_(o,"(",")",x);if(f===-1)break;let c=bg(o.slice(x+1,f)),h=f+1,a=js(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let w=u("For",`Unsafe expression in @for: ${c}`,n.UNSAFE_EXPRESSION);o=o.substring(0,b)+w+o.substring(g),s=!0;continue}try{let w=Oe(c),k=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(w.length>0&&k){let K=ke({forExpr:c,content:y,iterVarNames:w,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let S=Object.keys(r),B=Object.values(r),I=ue(y),T=Function(...S,"__stxRenderLoopValue",`
3
3
  let result = '';
4
4
  for (${c}) {
5
5
  result += \`${I}\`;
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Oe,ht,qt,no,ro,_e,Di,$n,dl,pl,Li,fl,gl,oo,ji,Bi,ml,Fi}from"./chunk-4r0028av.js";import{C}from"./chunk-16sfjkc4.js";import{a}from"./chunk-4w8t0a9e.js";import{Uo}from"./chunk-mdgcjzcn.js";import{l}from"./chunk-4e18r89n.js";import{existsSync as G,readFileSync as U}from"fs";import h from"path";var we=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),oe=ht.filter((e)=>!we.has(e)).sort(),ce=[...C].sort(),ke=[...new Set([...oe,...ce])].sort(),ve=new Set(oe),$e=new Set(ce),De=new Set(ke),re=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Te(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ae(e,t){let o=[];for(let d of t){if(d.offset===void 0)continue;let i=d.kind==="server"?ve:$e;re.lastIndex=0;for(let c of d.code.matchAll(re)){let m=c.index+c[0].indexOf("{")+1;for(let f of c[1].matchAll(/[^,]+/g)){let k=f[0];if(/^\s*type\s/.test(k))continue;let S=/^\s*([A-Za-z_$][\w$]*)/.exec(k);if(!S)continue;let s=S[1];if(!De.has(s)||i.has(s))continue;let u=d.offset+m+f.index+S[0].length-s.length,g=e.slice(0,u),v=g.split(`
2
+ import{Oe,ht,qt,no,ro,_e,Di,$n,dl,pl,Li,fl,gl,oo,ji,Bi,ml,Fi}from"./chunk-b5qzed8y.js";import{C}from"./chunk-16sfjkc4.js";import{a}from"./chunk-mf5cqv1k.js";import{Uo}from"./chunk-wc10m4tp.js";import{l}from"./chunk-4e18r89n.js";import{existsSync as G,readFileSync as U}from"fs";import h from"path";var we=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),oe=ht.filter((e)=>!we.has(e)).sort(),ce=[...C].sort(),ke=[...new Set([...oe,...ce])].sort(),ve=new Set(oe),$e=new Set(ce),De=new Set(ke),re=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Te(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ae(e,t){let o=[];for(let d of t){if(d.offset===void 0)continue;let i=d.kind==="server"?ve:$e;re.lastIndex=0;for(let c of d.code.matchAll(re)){let m=c.index+c[0].indexOf("{")+1;for(let f of c[1].matchAll(/[^,]+/g)){let k=f[0];if(/^\s*type\s/.test(k))continue;let S=/^\s*([A-Za-z_$][\w$]*)/.exec(k);if(!S)continue;let s=S[1];if(!De.has(s)||i.has(s))continue;let u=d.offset+m+f.index+S[0].length-s.length,g=e.slice(0,u),v=g.split(`
3
3
  `).length;o.push({line:v,column:u-(g.lastIndexOf(`
4
4
  `)+1)+1,offset:u,length:s.length,name:s,kind:d.kind,message:Te(s,d.kind)})}}}return o}import M from"path";var Ce="@stacksjs/stx-typescript-plugin";function Ee(e,t){let o=M.resolve(e);for(;;){let d=M.join(o,"tsconfig.json");if(t(d))return d;let i=M.dirname(o);if(i===o)return;o=i}}function le(e,t,o){let d=Ee(e,o);if(!d)return;let i=new Set,c=(m)=>{if(i.has(m))return;i.add(m);let f=t(m);if(!f)return;let k=f.compilerOptions?.plugins;if(Array.isArray(k)){let s=k.find((g)=>g?.name===Ce),u=Array.isArray(s?.libs)?s.libs.filter((g)=>typeof g==="string"):[];return s?{configPath:m,libs:u.map((g)=>M.resolve(M.dirname(m),g))}:null}let S=typeof f.extends==="string"?[f.extends]:Array.isArray(f.extends)?f.extends:[];for(let s of[...S].reverse()){if(typeof s!=="string"||!s.startsWith("."))continue;let u=M.resolve(M.dirname(m),s.endsWith(".json")?s:`${s}.json`),g=c(u);if(g!==void 0)return g}return};return c(d)??void 0}function Ma(e,t="",o="",d=t,i){let c=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",m=Di(ji(e)+e.code,d),f=e.kind==="client"&&i?i.project(m.code):void 0,k=$n(f?.code??m.code),S=e.kind==="client"||e.kind==="plain"?fl(t,e.code):"",s=(c+k).split(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{zh,Ho,Hh,Uh,Vh,Wh}from"./chunk-barb4gka.js";import"./chunk-z5nx021e.js";import"./chunk-dp6r6gtb.js";import"./chunk-cwcmmgvz.js";import"./chunk-wz44vmgn.js";import"./chunk-7anbc757.js";import"./chunk-nhyv3w4r.js";import"./chunk-0adc8x2h.js";import"./chunk-4w8t0a9e.js";import"./chunk-smnt37jq.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-vnk582z7.js";import"./chunk-4r0028av.js";import"./chunk-q9gbdzw0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Wh as clearStoreCache,zh as getStoreScript,Vh as getStoreScriptFor,Uh as pageStoresAll,Ho as storesRead,Hh as storesReadInFiles};
2
+ import{zh,Ho,Hh,Uh,Vh,Wh}from"./chunk-yq2krsc9.js";import"./chunk-0atz8fjx.js";import"./chunk-0sj79ha5.js";import"./chunk-cwcmmgvz.js";import"./chunk-9w9y84t5.js";import"./chunk-8b8az19t.js";import"./chunk-nhyv3w4r.js";import"./chunk-0adc8x2h.js";import"./chunk-mf5cqv1k.js";import"./chunk-w6ydg43d.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-388xpdw5.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Wh as clearStoreCache,zh as getStoreScript,Vh as getStoreScriptFor,Uh as pageStoresAll,Ho as storesRead,Hh as storesReadInFiles};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{B,An,Kt,Xt,y,s,Ce,g}from"./chunk-4r0028av.js";import{Pt,Ue,Mc,Es,si,oi,i}from"./chunk-zbpvmgjn.js";import{we}from"./chunk-0jdz31q1.js";import{ce,Vr,De,K,jn}from"./chunk-4vz17ytv.js";import{Er,Tr}from"./chunk-7x3tt27s.js";import{Dt,Rr,Ks,Xs,Gs,Lt,jt,Bt,Ft,zt,Ht,We}from"./chunk-vnk582z7.js";import{zs,a,j}from"./chunk-4w8t0a9e.js";import{Et,cn,Be,V,Da,Bo,ps,ot,La,Tt,Fe}from"./chunk-4a9bqc8f.js";import{e,Sn,xr,S}from"./chunk-9b2wdkbq.js";import{lt}from"./chunk-man5ap64.js";import{He}from"./chunk-cwcmmgvz.js";import{Wn}from"./chunk-1p6gaaf3.js";import{re,Ae,Pe}from"./chunk-7anbc757.js";import{l}from"./chunk-4e18r89n.js";import{ne}from"./chunk-e5rag6rh.js";import{c,f}from"./chunk-8tfpv6zf.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=Dn(t,o),p=Mn(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,An,Kt,Xt,y,s,Ce,g}from"./chunk-b5qzed8y.js";import{Pt,Ue,Mc,Es,si,oi,i}from"./chunk-n4m50dpk.js";import{we}from"./chunk-0jdz31q1.js";import{ce,Vr,De,K,jn}from"./chunk-4vz17ytv.js";import{Er,Tr}from"./chunk-t65f98qv.js";import{Dt,Rr,Ks,Xs,Gs,Lt,jt,Bt,Ft,zt,Ht,We}from"./chunk-388xpdw5.js";import{zs,a,j}from"./chunk-mf5cqv1k.js";import{Et,cn,Be,V,Da,Bo,ps,ot,La,Tt,Fe}from"./chunk-3h4db9yb.js";import{e,Sn,xr,S}from"./chunk-ngqb22wj.js";import{lt}from"./chunk-43sgpy4e.js";import{He}from"./chunk-cwcmmgvz.js";import{Wn}from"./chunk-yc3frw0z.js";import{re,Ae,Pe}from"./chunk-8b8az19t.js";import{l}from"./chunk-4e18r89n.js";import{ne}from"./chunk-e5rag6rh.js";import{c,f}from"./chunk-8tfpv6zf.js";async function Pn(n){try{let t=await Bun.file(n).text(),o=En(t),d=On(t,n),r=Dn(t,o),p=Mn(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 Dn(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 Mn(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 Ca(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=_n(o);return{results:o,summary:r}}function _n(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:Vn}=globalThis.Bun;import $t from"fs";import Ze from"path";function dt(){return`
@@ -454,7 +454,7 @@ else {
454
454
  };
455
455
  })();
456
456
  </script>
457
- `}function Ne(n,t,o={}){let d=Kn(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 gt(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function ht(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function yt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var et=null;function xt(n){if(!et)et=new Wt(n);return et}function st(){if(et)et.stop(),et=null}import bt from"path";var tt={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${bt.relative(bt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await zs(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 Er(u,o);if(w){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:w,loader:"html"}}}let x=await De(()=>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 U=x.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],se="",L=[];for(let k of U){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 L.push(k)}let I=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:se,templateContent:I,allScripts:L}}),R={__filename:u,__dirname:bt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await De(()=>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-am7xmh9p.js"),A=w(C.join(`
457
+ `}function Ne(n,t,o={}){let d=Kn(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 gt(n){let t=n.toLowerCase();return t.endsWith(".css")||t.endsWith(".scss")||t.endsWith(".sass")||t.endsWith(".less")}function ht(n){let t=n.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>t.endsWith(d))}function yt(n){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(n))}var et=null;function xt(n){if(!et)et=new Wt(n);return et}function st(){if(et)et.stop(),et=null}import bt from"path";var tt={name:"bun-plugin-stx",async setup(n){let o={...await a(),...n.config?.stx},d=new Set,r=o.webComponents?.enabled?`./${bt.relative(bt.dirname(n.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",p=[];if(o.webComponents?.enabled)try{let u=await zs(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 Er(u,o);if(w){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:w,loader:"html"}}}let x=await De(()=>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 U=x.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],se="",L=[];for(let k of U){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 L.push(k)}let I=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:se,templateContent:I,allScripts:L}}),R={__filename:u,__dirname:bt.dirname(u),__stx:{webComponentsPath:r,builtComponents:p}};await De(()=>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-kcpxqsdj.js"),A=w(C.join(`
458
458
  `),R),U=v.search(/<\/body>/i);if(U!==-1)v=v.slice(0,U)+A+`
459
459
  `+v.slice(U);else v+=`
460
460
  ${A}`}if(v=await Pe(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await Tr(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}),jn.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 Pe(v),m.forEach((w)=>d.add(w)),o.cache&&o.cachePath){if(await T
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 os(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(!Le.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Rt(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");Le.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,tt],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 qe(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=xt({wsPort:P,verbose:!1}),u=p.start(P)}let v={},w=null,A;try{let{loadStxConfig:P}=await import("./chunk-t63y6qd5.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-38y11q8x.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(Le.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:U,isServerApiSource:se}=await import("./chunk-xtf3sab5.js"),L=await U(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 I=Xn({port:O,async fetch(P){return Wn(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 L(P);if(q)return q;if(D.pathname==="/")return(async()=>{let F=await S(h||"");if(r)F=Ne(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(Le.existsSync(Q)&&Le.statSync(Q).isFile()){let ie=Bun.file(Q),F=ge.extname(Q).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let je=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=je.transformSync(ze);return new Response(Je,{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(Le.existsSync(pe)&&Le.statSync(pe).isFile()){let ie=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let je=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=je.transformSync(ze);return new Response(Je,{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(Le.existsSync(ke)&&Le.statSync(ke).isFile()){let ie=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let je=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=je.transformSync(ze);return new Response(Je,{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 os(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(!Le.existsSync(m))return console.error(`${e.red}Error: File not found: ${e.bright}${m}${e.reset}`),!1;if(m.endsWith(".md"))return Rt(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");Le.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,tt],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 qe(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=xt({wsPort:P,verbose:!1}),u=p.start(P)}let v={},w=null,A;try{let{loadStxConfig:P}=await import("./chunk-k2t0w8z1.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-38y11q8x.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(Le.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:U,isServerApiSource:se}=await import("./chunk-6bw02d1t.js"),L=await U(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 I=Xn({port:O,async fetch(P){return Wn(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 L(P);if(q)return q;if(D.pathname==="/")return(async()=>{let F=await S(h||"");if(r)F=Ne(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(Le.existsSync(Q)&&Le.statSync(Q).isFile()){let ie=Bun.file(Q),F=ge.extname(Q).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let je=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=je.transformSync(ze);return new Response(Je,{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(Le.existsSync(pe)&&Le.statSync(pe).isFile()){let ie=Bun.file(pe),F=ge.extname(pe).toLowerCase(),E="text/plain";if(F===".ts"||F===".tsx"){let je=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=je.transformSync(ze);return new Response(Je,{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(Le.existsSync(ke)&&Le.statSync(ke).isFile()){let ie=Bun.file(ke),F=ge.extname(ke).toLowerCase(),E="application/octet-stream";if(F===".ts"||F===".tsx"){let je=new Bun.Transpiler({loader:F===".tsx"?"tsx":"ts"}),ze=await ie.text(),Je=je.transformSync(ze);return new Response(Je,{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 U=w===O.length-1?"\u2514\u2500 ":"\u251C\u2500 ",se=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${U}${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`),Ke(C.url.toString(),()=>{if(d)Xe.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Xe.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}`),lt.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:Jn}=globalThis.Bun;import me from"fs";import oe from"path";async function Jt(n){try{return An(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 as(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-t63y6qd5.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-xtf3sab5.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 U=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(U.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}${U.length}${e.blue} routes${e.reset}`);let se=h?._pluginPageDirs||[],L=[];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}`;L.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 I=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Da(m,t.stxOptions?.shell),P){if(k=await Bo(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-t63y6qd5.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-38y11q8x.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 _=Xs(A,T);if(!_)return null;try{let z=await Bun.build({entrypoints:[_],outdir:xe,plugins:[tt],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-t63y6qd5.js"),{checkCache:N,cacheTemplate:Y,readFileCached:W,templateCache:ue}=await import("./chunk-xj95sk0y.js"),G=await Te(m),Ve=(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=Ve(de.partialsDir),de.componentsDir=Ve(de.componentsDir),de.layoutsDir=Ve(de.layoutsDir),de.storesDir=Ve(de.storesDir||"stores"),de.cachePath=Ve(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 Ie=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Ie=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Ie=!1;break}}if(Ie){let ve=le.output;if(k)ve=ot(ve,{preserveHead:!0});let rt=F.get(T.filePath);return{route:T,content:ve,status:rt?.status??await Jt(T.filePath),headers:rt?.headers}}}}catch{}let Me=await N(T.filePath,de);if(Me){let _e=Me;if(k)_e=ot(_e,{preserveHead:!0});let Ie=F.get(T.filePath);return{route:T,content:_e,status:Ie?.status??await Jt(T.filePath),headers:Ie?.headers}}}let ee=J?await W(T.filePath):await Bun.file(T.filePath).text(),ae=An(ee),{classifyAllScripts:fe}=await import("./chunk-t63y6qd5.js"),H=fe(ee),Oe=H.server.map((le)=>le.content),Re=ee;for(let le of H.server)Re=Re.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(Me){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,Me?.message||Me)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Re,te,T.filePath,de,$e);let Me=performance.now()-le,_e=oe.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${Me.toFixed(2)}ms`)}else he=await z(Re,te,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-am7xmh9p.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Me,_e,Ie)=>{if(!/function\s+__stx_setup_/.test(Ie))return Me;return`<script${_e}>${le(Ie,te)}</script>`})}if(k)he=ot(he,{preserveHead:!0});if(J&&M)await Y(T.filePath,he,$e,de);let{extractStreamBoundaries:ct}=await import("./chunk-6n50b07t.js"),Ye=ct(te),nt=te.__streamTemplates;if(nt&&typeof nt==="object"&&Object.keys(nt).length>0){let le=te.streamBoundaries||{},Me={...de,autoShell:!1},_e=Object.keys(nt).map((ve)=>({id:ve,render:async()=>{let rt=typeof le[ve]==="function"?await le[ve]():void 0;return z(nt[ve],{...te,$boundary:rt},T.filePath,Me,new Set)}})),Ie=new Set(_e.map((ve)=>ve.id));Ye=[...(Ye||[]).filter((ve)=>!Ie.has(ve.id)),..._e]}if(Ye&&Ye.length>0)ke.add(T.pattern);else Ye=void 0;let _t=Kt(te),It=Xt(te);if(M)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},je=8,ze=async()=>{let T=new Set(pe.keys()),_=new Set(I.keys());pe.clear(),I.clear();let z=t.prebuild===!1?U.filter((X)=>T.has(X.pattern)):U,Z=t.prebuild===!1?L.filter(({route:X})=>_.has(X.pattern)):L;for(let X=0;X<z.length;X+=je){let Te=z.slice(X,X+je),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+=je){let Te=Z.slice(X,X+je),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)I.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?U.length+L.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Ge=o;try{if(Ge=await qe(o),Ge!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Ge+1;p=xt({wsPort:T,verbose:!1}),u=p.start(T)}let wt=(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 St=Jn({port:Ge,hostname:t.hostname,async fetch(T){let _=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(_.pathname===si&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});let M=[...U,...L.map(({route:J})=>J)].filter((J)=>!J.isDynamic).map((J)=>J.pattern);return new Response(T.method==="HEAD"?null:oi(z,Es(),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,W]=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(W?.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-xa98a901.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=Rr(_.pathname,U);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 Re=await ie(404);if(Re){let te=Re;if(te=await S(te,m),r)te=Ne(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),Re=zt(Oe,null,T,{isServer:!0}),te=await Ht(fe.middleware,Re);if(te.redirect){let $e=te.redirect.path,he=te.redirect.options.redirectCode||302,ct=new Headers(te.responseHeaders);return ct.set("Location",$e),new Response(null,{status:he,headers:ct})}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&&La(T)&&Tt(H,h?.router?.container||"main")){let Oe=We(H),Re=Ae(H),te=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=te?cn(te[1].trim()):"";if(Object.keys(G.params).length>0)H=wt(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Fe(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":Re?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Mc]:Es(),...V(),"Cache-Control":Et}})}if(k)H=ps(k,H);if(Object.keys(G.params).length>0)H=wt(H,G.params);if(H=await S(H,m),r)H=Ne(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:Re}=await import("./chunk-6n50b07t.js");return Re(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",...V(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(L.length>0){let M=L.map((ee)=>ee.route),J=Rr(_.pathname,M);if(J){let ee=I.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)I.set(J.route.pattern,ae)}}if(ee){let ae=ee.content;if(k)ae=ps(k,ae);if(Object.keys(J.params).length>0)ae=wt(ae,J.params);if(ae=await S(ae,m),r)ae=Ne(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=I.get(ee)||I.get(ee+"/");if(!ae){let fe=L.find(({route:H})=>H.pattern===ee||H.pattern===`${ee}/`);if(fe){let H=await E(fe.route);if(H)ae=H,I.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=ps(k,fe);if(fe=await S(fe,m),r)fe=Ne(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 Ve=pe.get("/");if(Ve){let M=Ve.content;if(M=await S(M,m),r)M=Ne(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=Ne(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`),Ke(C.url.toString(),()=>{if(d)Xe.watch(p,{recursive:!0}).close();C.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Xe.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}`),lt.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:Jn}=globalThis.Bun;import me from"fs";import oe from"path";async function Jt(n){try{return An(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 as(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-k2t0w8z1.js"),h=await x(m),{createServerApi:b,isServerApiSource:C}=await import("./chunk-6bw02d1t.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 U=re(v,{pagesDir:w,pagesDirs:h._layerPageDirs?[A,...h._layerPageDirs.slice(1)]:void 0});if(U.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}${U.length}${e.blue} routes${e.reset}`);let se=h?._pluginPageDirs||[],L=[];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}`;L.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 I=new Map,k=null,P=null;if(t.stxOptions?.shell!==!1){if(P=await Da(m,t.stxOptions?.shell),P){if(k=await Bo(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-k2t0w8z1.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-38y11q8x.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 _=Xs(A,T);if(!_)return null;try{let z=await Bun.build({entrypoints:[_],outdir:xe,plugins:[tt],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-k2t0w8z1.js"),{checkCache:N,cacheTemplate:Y,readFileCached:W,templateCache:ue}=await import("./chunk-e0tvd7jj.js"),G=await Te(m),Ve=(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=Ve(de.partialsDir),de.componentsDir=Ve(de.componentsDir),de.layoutsDir=Ve(de.layoutsDir),de.storesDir=Ve(de.storesDir||"stores"),de.cachePath=Ve(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 Ie=!0;for(let ve of le.dependencies){if(!me.existsSync(ve)){Ie=!1;break}if((await me.promises.stat(ve)).mtime.getTime()>le.mtime){Ie=!1;break}}if(Ie){let ve=le.output;if(k)ve=ot(ve,{preserveHead:!0});let rt=F.get(T.filePath);return{route:T,content:ve,status:rt?.status??await Jt(T.filePath),headers:rt?.headers}}}}catch{}let Me=await N(T.filePath,de);if(Me){let _e=Me;if(k)_e=ot(_e,{preserveHead:!0});let Ie=F.get(T.filePath);return{route:T,content:_e,status:Ie?.status??await Jt(T.filePath),headers:Ie?.headers}}}let ee=J?await W(T.filePath):await Bun.file(T.filePath).text(),ae=An(ee),{classifyAllScripts:fe}=await import("./chunk-k2t0w8z1.js"),H=fe(ee),Oe=H.server.map((le)=>le.content),Re=ee;for(let le of H.server)Re=Re.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(Me){if(t.stxOptions?.debug)console.error("[stx] variable extraction error",T.filePath,Me?.message||Me)}let $e=new Set,he;if(t.profile){let le=performance.now();he=await z(Re,te,T.filePath,de,$e);let Me=performance.now()-le,_e=oe.relative(m,T.filePath)||T.filePath;console.log(`[stx:profile] ${_e} \u2192 ${Me.toFixed(2)}ms`)}else he=await z(Re,te,T.filePath,de,$e);if(!k)he=await be(he,{router:de.router});{let{interpolateScriptExpressions:le}=await import("./chunk-kcpxqsdj.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Me,_e,Ie)=>{if(!/function\s+__stx_setup_/.test(Ie))return Me;return`<script${_e}>${le(Ie,te)}</script>`})}if(k)he=ot(he,{preserveHead:!0});if(J&&M)await Y(T.filePath,he,$e,de);let{extractStreamBoundaries:ct}=await import("./chunk-6aqr0e6s.js"),Ye=ct(te),nt=te.__streamTemplates;if(nt&&typeof nt==="object"&&Object.keys(nt).length>0){let le=te.streamBoundaries||{},Me={...de,autoShell:!1},_e=Object.keys(nt).map((ve)=>({id:ve,render:async()=>{let rt=typeof le[ve]==="function"?await le[ve]():void 0;return z(nt[ve],{...te,$boundary:rt},T.filePath,Me,new Set)}})),Ie=new Set(_e.map((ve)=>ve.id));Ye=[...(Ye||[]).filter((ve)=>!Ie.has(ve.id)),..._e]}if(Ye&&Ye.length>0)ke.add(T.pattern);else Ye=void 0;let _t=Kt(te),It=Xt(te);if(M)F.set(T.filePath,{status:_t,headers:It});return{route:T,content:he,status:_t??ae,headers:It,boundaries:Ye}}catch(z){return console.error(`${e.red}Error building ${e.bright}${T.pattern}${e.reset}:`,z),null}},je=8,ze=async()=>{let T=new Set(pe.keys()),_=new Set(I.keys());pe.clear(),I.clear();let z=t.prebuild===!1?U.filter((X)=>T.has(X.pattern)):U,Z=t.prebuild===!1?L.filter(({route:X})=>_.has(X.pattern)):L;for(let X=0;X<z.length;X+=je){let Te=z.slice(X,X+je),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+=je){let Te=Z.slice(X,X+je),be=await Promise.all(Te.map(({route:N})=>E(N)));for(let N of be)if(N)I.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?U.length+L.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Sn(m);let Ge=o;try{if(Ge=await qe(o),Ge!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(r){let T=t.hmrPort||Ge+1;p=xt({wsPort:T,verbose:!1}),u=p.start(T)}let wt=(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 St=Jn({port:Ge,hostname:t.hostname,async fetch(T){let _=new URL(T.url),z=t.stxOptions?.offline??h.offline;if(_.pathname===si&&z?.enabled){if(!["GET","HEAD"].includes(T.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});let M=[...U,...L.map(({route:J})=>J)].filter((J)=>!J.isDynamic).map((J)=>J.pattern);return new Response(T.method==="HEAD"?null:oi(z,Es(),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,W]=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(W?.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-xa98a901.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=Rr(_.pathname,U);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 Re=await ie(404);if(Re){let te=Re;if(te=await S(te,m),r)te=Ne(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),Re=zt(Oe,null,T,{isServer:!0}),te=await Ht(fe.middleware,Re);if(te.redirect){let $e=te.redirect.path,he=te.redirect.options.redirectCode||302,ct=new Headers(te.responseHeaders);return ct.set("Location",$e),new Response(null,{status:he,headers:ct})}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&&La(T)&&Tt(H,h?.router?.container||"main")){let Oe=We(H),Re=Ae(H),te=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i),$e=te?cn(te[1].trim()):"";if(Object.keys(G.params).length>0)H=wt(H,G.params);H=await S(H,m);let he=h?.router?.container||"main";return H=Fe(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":Re?"true":"false",...$e&&{"X-STX-Title":encodeURIComponent($e)},[Mc]:Es(),...V(),"Cache-Control":Et}})}if(k)H=ps(k,H);if(Object.keys(G.params).length>0)H=wt(H,G.params);if(H=await S(H,m),r)H=Ne(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:Re}=await import("./chunk-6aqr0e6s.js");return Re(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",...V(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...ae}})}}if(L.length>0){let M=L.map((ee)=>ee.route),J=Rr(_.pathname,M);if(J){let ee=I.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)I.set(J.route.pattern,ae)}}if(ee){let ae=ee.content;if(k)ae=ps(k,ae);if(Object.keys(J.params).length>0)ae=wt(ae,J.params);if(ae=await S(ae,m),r)ae=Ne(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=I.get(ee)||I.get(ee+"/");if(!ae){let fe=L.find(({route:H})=>H.pattern===ee||H.pattern===`${ee}/`);if(fe){let H=await E(fe.route);if(H)ae=H,I.set(fe.route.pattern,H)}}if(ae){let fe=ae.content;if(k)fe=ps(k,fe);if(fe=await S(fe,m),r)fe=Ne(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 Ve=pe.get("/");if(Ve){let M=Ve.content;if(M=await S(M,m),r)M=Ne(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=Ne(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:${Ge}/${e.reset}`),r)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
1009
1009
  ${e.yellow}Routes:${e.reset}`);let kt=[...Gs(U,m)];for(let{route:T}of L)kt.push(`${T.pattern}`);if(kt.forEach((T,_)=>{let Z=_===kt.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`),Ke(St.url.toString(),()=>{if(p)st();St.stop()}),t.native){let T,_=oe.join(A,"index.stx");if(me.existsSync(_)){let Z=await Bun.file(_).text();T=mt(Z)}let z=h?.app?.window??{};await Qe(Ge,{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 W of Object.values(Y.resources)){if(!me.existsSync(W))continue;let ue=me.realpathSync(W);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${oe.sep}`)))N.add(ue)}for(let[Y,W]of z)if(!N.has(Y))W.close(),z.delete(Y);for(let Y of N)if(!z.has(Y)&&me.existsSync(Y))z.set(Y,me.watch(Y,{recursive:!0},(W,ue)=>{Te(Y,W,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,Y,W)=>(X=X.catch(()=>{}).then(()=>be(N,Y,W)),X),be=async(N,Y,W)=>{if(!W||yt(W))return;if(ht(W)){if(h._layerGraph){let ue=await x(m);Object.assign(h,ue),U.splice(0,U.length,...re(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Z()}if(T(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),r&&p)p.reload(W)}else if(_(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),lt.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-xj95sk0y.js");ue(oe.resolve(N,W)),G.delete(oe.resolve(N,W))}catch{}if(P&&W){if(oe.resolve(N,W)===P||oe.basename(P)===W){let G=await Bo(P,t.stxOptions||{});if(G)k=G}}if(await ze(),await xr(m),r&&p)p.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),lt.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-xj95sk0y.js");ue(oe.resolve(N,W)),G.delete(oe.resolve(N,W))}catch{}if(await ze(),r&&p)p.reload(W)}}else if(gt(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),r&&p)p.updateCss(W)}};Z(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)st();St.stop(),process.exit(0)})}return!0}import At from"fs";import it from"path";async function Yn(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`),Ke(St.url.toString(),()=>{if(p)st();St.stop()}),t.native){let T,_=oe.join(A,"index.stx");if(me.existsSync(_)){let Z=await Bun.file(_).text();T=mt(Z)}let z=h?.app?.window??{};await Qe(Ge,{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 W of Object.values(Y.resources)){if(!me.existsSync(W))continue;let ue=me.realpathSync(W);if(![...N].some((G)=>ue===G||ue.startsWith(`${G}${oe.sep}`)))N.add(ue)}for(let[Y,W]of z)if(!N.has(Y))W.close(),z.delete(Y);for(let Y of N)if(!z.has(Y)&&me.existsSync(Y))z.set(Y,me.watch(Y,{recursive:!0},(W,ue)=>{Te(Y,W,ue).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},X=Promise.resolve(),Te=(N,Y,W)=>(X=X.catch(()=>{}).then(()=>be(N,Y,W)),X),be=async(N,Y,W)=>{if(!W||yt(W))return;if(ht(W)){if(h._layerGraph){let ue=await x(m);Object.assign(h,ue),U.splice(0,U.length,...re(v,{pagesDir:w,pagesDirs:ue._layerPageDirs?[A,...ue._layerPageDirs.slice(1)]:void 0})),Z()}if(T(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),r&&p)p.reload(W)}else if(_(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),lt.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-e0tvd7jj.js");ue(oe.resolve(N,W)),G.delete(oe.resolve(N,W))}catch{}if(P&&W){if(oe.resolve(N,W)===P||oe.basename(P)===W){let G=await Bo(P,t.stxOptions||{});if(G)k=G}}if(await ze(),await xr(m),r&&p)p.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),lt.clear(),Ce();try{let{invalidateFileCache:ue,templateCache:G}=await import("./chunk-e0tvd7jj.js");ue(oe.resolve(N,W)),G.delete(oe.resolve(N,W))}catch{}if(await ze(),r&&p)p.reload(W)}}else if(gt(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),r&&p)p.updateCss(W)}};Z(),process.on("SIGINT",()=>{for(let N of z.values())N.close();if(p)st();St.stop(),process.exit(0)})}return!0}import At from"fs";import it from"path";async function Yn(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 Qn(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 Zn(n,t=!1,o){let d=it.basename(n,".stx"),r=await Yn(n),p=await Qn(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,5 +1,5 @@
1
1
  // @bun
2
- import{y,b,g}from"./chunk-4r0028av.js";import{q}from"./chunk-4w8t0a9e.js";import{i}from"./chunk-zbpvmgjn.js";import k from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,n;O.lastIndex=0;while((n=O.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function yh(e,t={},o={}){let n={...q,...o,streaming:{...M,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await y(p,f,e);let E=z(c),l=new Set;if(!E.some((h)=>h.type==="suspense")){let h=n.streaming?.strategy||"auto",S=new RegExp(T.source,"g");if(!(h!=="manual"&&S.test(c))){let u=await i(c,f,e,n,l);for(let x=0;x<u.length;x+=s)r.enqueue(u.slice(x,x+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],x=new RegExp(T.source,"g"),m;while((m=x.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let D=await i(I,f,e,n,l);r.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let h=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
2
+ import{y,b,g}from"./chunk-b5qzed8y.js";import{q}from"./chunk-mf5cqv1k.js";import{i}from"./chunk-n4m50dpk.js";import k from"path";var M={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var O=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function z(e){let t=[],o=0,n;O.lastIndex=0;while((n=O.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function yh(e,t={},o={}){let n={...q,...o,streaming:{...M,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),f={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await y(p,f,e);let E=z(c),l=new Set;if(!E.some((h)=>h.type==="suspense")){let h=n.streaming?.strategy||"auto",S=new RegExp(T.source,"g");if(!(h!=="manual"&&S.test(c))){let u=await i(c,f,e,n,l);for(let x=0;x<u.length;x+=s)r.enqueue(u.slice(x,x+s)),await new Promise((m)=>setTimeout(m,0))}else{let u=[],x=new RegExp(T.source,"g"),m;while((m=x.exec(c))!==null)u.push({name:m[1],content:m[2],start:m.index,end:m.index+m[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let D=await i(I,f,e,n,l);r.enqueue(D),await new Promise((H)=>setTimeout(H,0))}}let C=await i(_.content,f,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,f,e,n,l);r.enqueue(C)}}}}else{let h=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,f,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),h.set(d.name,i(d.content,f,e,n,l))}r.enqueue(`
5
5
  <script>
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{xg,wy,vy,xy,Sy,Sg,kg,ky,_y,wi,Cy,Er,Tr,Bs}from"./chunk-7x3tt27s.js";import{gt}from"./chunk-zkwkhesc.js";import"./chunk-4r0028av.js";import"./chunk-q9gbdzw0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Sy as __setSignalsGeneratorsForTest,gt as cacheEngineFingerprint,Tr as cacheTemplate,Er as checkCache,Cy as clearDevCaches,kg as getCachedRouterScript,Sg as getCachedSignalsRuntime,ky as getServeClientAsset,wi as getServeModuleBundle,Bs as hashFilePath,vy as invalidateFileCache,xy as invalidateFileCacheByDir,wy as readFileCached,_y as registerServeModuleBundle,xg as templateCache};
2
+ import{xg,wy,vy,xy,Sy,Sg,kg,ky,_y,wi,Cy,Er,Tr,Bs}from"./chunk-t65f98qv.js";import{gt}from"./chunk-zkwkhesc.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Sy as __setSignalsGeneratorsForTest,gt as cacheEngineFingerprint,Tr as cacheTemplate,Er as checkCache,Cy as clearDevCaches,kg as getCachedRouterScript,Sg as getCachedSignalsRuntime,ky as getServeClientAsset,wi as getServeModuleBundle,Bs as hashFilePath,vy as invalidateFileCache,xy as invalidateFileCacheByDir,wy as readFileCached,_y as registerServeModuleBundle,xg as templateCache};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{vs,xs}from"./chunk-36cz2v8k.js";import{x}from"./chunk-4r0028av.js";import{a}from"./chunk-4w8t0a9e.js";import{it,fe}from"./chunk-0vyytd9v.js";import{_c}from"./chunk-d1ka4dvr.js";import{W}from"./chunk-1jxkc6d0.js";import{w}from"./chunk-v6gkjg5f.js";import{f}from"./chunk-8tfpv6zf.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 Xu=`
2
+ import{vs,xs}from"./chunk-36cz2v8k.js";import{x}from"./chunk-b5qzed8y.js";import{a}from"./chunk-mf5cqv1k.js";import{it,fe}from"./chunk-0vyytd9v.js";import{_c}from"./chunk-h0aw9hmc.js";import{W}from"./chunk-1jxkc6d0.js";import{w}from"./chunk-v6gkjg5f.js";import{f}from"./chunk-8tfpv6zf.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 Xu=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Q,Xe}from"./chunk-4r0028av.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function gn(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Xe(t,s);if(p>s){c=p;continue}let a=Q(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
2
+ import{Q,Xe}from"./chunk-b5qzed8y.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function gn(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Xe(t,s);if(p>s){c=p;continue}let a=Q(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
3
3
  export{gn};