@stacksjs/stx 0.2.267 → 0.2.269

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 (52) hide show
  1. package/dist/{chunk-yxp7wv61.js → chunk-14fzcbj0.js} +1 -1
  2. package/dist/{chunk-4mw2kfqd.js → chunk-1s63ymfh.js} +1 -1
  3. package/dist/{chunk-qf5grrg1.js → chunk-2vvaz0ng.js} +1 -1
  4. package/dist/{chunk-mbvkvac6.js → chunk-3yvmfwa9.js} +18 -18
  5. package/dist/{chunk-ykxs16y7.js → chunk-4dbfeqz0.js} +1 -1
  6. package/dist/{chunk-9rkcrzj4.js → chunk-54bk9d5c.js} +1 -1
  7. package/dist/{chunk-fn9yw31x.js → chunk-5n0w9czz.js} +1 -1
  8. package/dist/chunk-62vs8fcr.js +11 -0
  9. package/dist/{chunk-18nxwzv3.js → chunk-64bb728t.js} +8 -8
  10. package/dist/{chunk-y9tv04zh.js → chunk-6636yb8g.js} +1 -1
  11. package/dist/{chunk-m0aetx9j.js → chunk-7dx0sym7.js} +1 -1
  12. package/dist/{chunk-d3v3p15c.js → chunk-7hy6bj9b.js} +1 -1
  13. package/dist/{chunk-q5et8k2d.js → chunk-7m56m1p8.js} +1 -1
  14. package/dist/{chunk-z86pq9pd.js → chunk-7r501aag.js} +1 -1
  15. package/dist/{chunk-jb7h4qgh.js → chunk-95fvybb4.js} +1 -1
  16. package/dist/{chunk-2qsa4h1t.js → chunk-9xfnhnkn.js} +2 -2
  17. package/dist/{chunk-b41qf397.js → chunk-aedjkz48.js} +1 -1
  18. package/dist/{chunk-mcn9mwzv.js → chunk-b4q2zzyq.js} +1 -1
  19. package/dist/{chunk-jq4104he.js → chunk-c444y3z7.js} +1 -1
  20. package/dist/{chunk-r9z71gj0.js → chunk-cx5cx512.js} +1 -1
  21. package/dist/{chunk-r8qvm7a3.js → chunk-fbtcegdp.js} +1 -1
  22. package/dist/{chunk-mb0kqnwf.js → chunk-g1v5782a.js} +1 -1
  23. package/dist/{chunk-8vewrjzp.js → chunk-geb85szp.js} +1 -1
  24. package/dist/{chunk-7cts329z.js → chunk-gevrmrcf.js} +1 -1
  25. package/dist/{chunk-dpgp6rzq.js → chunk-gp2rkeqt.js} +1 -1
  26. package/dist/{chunk-e6vdk4v0.js → chunk-jhv5xcn6.js} +1 -1
  27. package/dist/{chunk-k5c19t7e.js → chunk-jjgkbz91.js} +1 -1
  28. package/dist/{chunk-78bm61kd.js → chunk-jmvmq1af.js} +1 -1
  29. package/dist/{chunk-xv2mr8vq.js → chunk-kfhv4abr.js} +1 -1
  30. package/dist/{chunk-4wnnet1k.js → chunk-kpzjb2vy.js} +1 -1
  31. package/dist/{chunk-cd4v7xyr.js → chunk-kva81xy0.js} +1 -1
  32. package/dist/{chunk-mzpb11dp.js → chunk-kwksrzjc.js} +1 -1
  33. package/dist/{chunk-6g7m08rv.js → chunk-mghvh852.js} +1 -1
  34. package/dist/{chunk-13ftt3qc.js → chunk-nv1qkd6w.js} +1 -1
  35. package/dist/{chunk-xkb16kmv.js → chunk-p5q96xv3.js} +1 -1
  36. package/dist/{chunk-cksz4k5v.js → chunk-qq3ev7wg.js} +1 -1
  37. package/dist/{chunk-c1r9q5pk.js → chunk-ra5r02m8.js} +1 -1
  38. package/dist/{chunk-sz51py35.js → chunk-ra99ktgk.js} +1 -1
  39. package/dist/{chunk-scdxk8nn.js → chunk-v7p71v7b.js} +1 -1
  40. package/dist/{chunk-fcv00xs9.js → chunk-wrte2z94.js} +1 -1
  41. package/dist/{chunk-2ed60g20.js → chunk-x4qf45j5.js} +2 -2
  42. package/dist/{chunk-g4z7gah7.js → chunk-zb0eect9.js} +1 -1
  43. package/dist/{chunk-xpsxwbw0.js → chunk-zrxxap8e.js} +1 -1
  44. package/dist/cli.js +7 -7
  45. package/dist/component-renderer.js +4 -4
  46. package/dist/craft-entry.js +1 -1
  47. package/dist/craft.js +1 -1
  48. package/dist/pwa.js +1 -1
  49. package/dist/ssg.js +2 -2
  50. package/dist/store-loader.js +2 -0
  51. package/package.json +5 -5
  52. package/dist/chunk-8evws5cc.js +0 -11
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fq as H,Xq as x,as as g,sm as O,tp as R}from"./chunk-mbvkvac6.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
2
+ import{Fq as H,Xq as x,as as g,sm as O,tp as R}from"./chunk-3yvmfwa9.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(Z.name,H(Z.content,j,q,G,$))}K.enqueue(`
5
5
  <script>
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import{$i as w,_i as O,aj as Z}from"./chunk-9n0gvfrg.js";import{$k as R,gl as U,il as T}from"./chunk-ra5r02m8.js";import{Nq as k,Ol as E,Pl as L,Rl as M,cs as C,op as W}from"./chunk-3yvmfwa9.js";import{Nt as B}from"./chunk-sde45gh3.js";import $ from"path";var Y=new Map;function b(Q,z){for(let J of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(J[1])z.add(J[1]);for(let J of Q.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let H of(J[1]??"").split(",")){let K=((H.includes(":")?H.split(":").pop():H)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(K))z.add(K)}for(let J of Q.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let H of(J[1]??"").split(",")){let V=H.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(V))z.add(V)}}async function l(Q){let z;if(Q)z=$.resolve(Q);else{let q=await C();z=$.resolve(q.root||process.cwd(),q.storesDir||"stores")}let J=new Bun.Glob("*.ts"),H=[];try{for await(let q of J.scan({cwd:z,absolute:!0})){let y=$.basename(q,".ts");if(["index","types"].includes(y))continue;if(q.includes(".d.ts"))continue;H.push(q)}}catch{return Z(Y,z,"",""),null}let V=()=>[...new Set([...H,...H.flatMap((q)=>R(q))])],K=O(V()),P=w(Y,z,K);if(P!==void 0)return P||null;if(H.length===0)return Z(Y,z,K,""),null;let A=[];for(let q of H){let y=await Bun.file(q).text();A.push({file:q,hasUseStore:/useStore\s*\(/.test(y)})}A.sort((q,y)=>{if(q.hasUseStore===y.hasUseStore)return 0;return q.hasUseStore?1:-1});let N=A.map((q)=>q.file),G=[],X=new Set,F=k({loader:"ts",target:"browser",define:M()});for(let q of N)try{let y=await Bun.file(q).text(),I=$.basename(q,".ts");if(b(y,X),U(y))y=await T(y,q,{projectRoot:process.cwd()});y=W(y),y=E(y),y=L(y),y=y.replace(/^export\s+(default\s+)?/gm,""),y=F.transformSync(y),G.push(`// Store: ${I}
3
+ ${y.trim()}`)}catch(y){console.warn(`[stx] Failed to load store ${q}:`,y)}if(G.length===0)return Z(Y,z,K,""),null;let j=G.join(`
4
+
5
+ `),x=`;(function(){
6
+ var __stx = window.stx || {};
7
+ ${B.filter((q)=>!X.has(q)&&new RegExp(`\\b${q}\\b`).test(j)).map((q)=>`var ${q} = __stx[${JSON.stringify(q)}];`).join(`
8
+ `)}
9
+ ${j}
10
+ })();`;return K=O(V()),Z(Y,z,K,x),x}function a(){Y.clear()}
11
+ export{l as Vi,a as Wi};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lg as _$,mg as K5}from"./chunk-cksz4k5v.js";import{Ag as U$,Bg as q6,Dg as Z1,Eg as y6,Fg as Q5,Gg as B$,Hg as L$,Ig as v6,Jg as g6,wg as y7}from"./chunk-r8qvm7a3.js";import{Aj as p5,Cj as c5,vj as u1,wj as O1,xj as H1,yj as m$,zj as p$}from"./chunk-w95sp0k9.js";import{Wj as Y$,Xj as J$}from"./chunk-yxp7wv61.js";import{yk as g5,zk as f5}from"./chunk-1m4sa11y.js";import{Fk as l7,Gk as i7}from"./chunk-58f0mthg.js";import{_k as Q1}from"./chunk-c1r9q5pk.js";import{$o as X5,Bp as m0,Fq as O0,Jm as x6,Nm as Z5,Pr as G$,Qm as N1,Rm as M1,Tq as Q6,Uq as E1,Xo as Z$,Yq as p0,am as b7,an as c1,as as E$,bp as S6,cm as X6,cp as z6,cs as d0,dn as L6,dq as g7,ds as M0,hs as V0,kq as P6,ln as n$,lq as b6,nn as o$,qn as l1,sm as u0,tp as j0,un as t$,xn as Q$,yn as F6}from"./chunk-mbvkvac6.js";import{Ns as s$,Vs as B,bt as W$,ct as K$,gt as o}from"./chunk-jb7h4qgh.js";import{st as S0}from"./chunk-bby4emay.js";import{Du as R6,Eu as I6,Fu as D6,Gu as w6,Hu as T6,Iu as C6,Ku as k6,Ou as A6,iu as $5,ju as H6,nu as V6,ou as E6}from"./chunk-5wkwhjjn.js";import{Yu as p}from"./chunk-f8wjdg40.js";var l5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function e7($,X,Q={}){let{storage:Z="local",serializer:Y=l5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Q,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Z==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let H=L.getItem($);if(H===null)return X;let q=Y.read(H);if(J&&typeof X==="object"&&X!==null)return{...X,...q};return q}catch{return X}},F=(L)=>{let H=_();if(!H)return;try{if(L===null||L===void 0)H.removeItem($);else H.setItem($,Y.write(L))}catch(q){console.warn(`[useStorage] Failed to write key "${$}":`,q)}},z=U(),j=(L,H)=>{for(let q of W)try{q(L,H)}catch(A){console.error("[useStorage] Subscriber error:",A)}};if(K&&G){let L=(q)=>{if(q.key===$&&q.storageArea===_()){let A=z;try{z=q.newValue?Y.read(q.newValue):X}catch(N){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,N);return}j(z,A)}};window.addEventListener("storage",L);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",L))}let O={get value(){return z},set value(L){let H=z;z=L,F(L),j(L,H)},get:()=>z,set:(L)=>{O.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let H=z;z=X,j(X,H)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return O}function i5($,X,Q,Z,Y={}){let{serializer:J=l5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Z;try{let O=J.read(j);if(G&&typeof Z==="object"&&Z!==null)return{...Z,...O};return O}catch(O){return console.warn(`[${X}] Failed to read key "${Q}":`,O),Z}},z=p5((()=>{let j=_();if(!j)return Z;try{return U(j.getItem(Q))}catch(O){return console.warn(`[${X}] Cannot read "${Q}":`,O),Z}})());if(c5(()=>{let j=z(),O=_();if(!O)return;try{if(j===null||j===void 0)O.removeItem(Q);else O.setItem(Q,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Q}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Q)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",j))}return z}function $3($,X,Q){return i5("local","useLocalStorage",$,X,Q)}function X3($,X,Q){return i5("session","useSessionStorage",$,X,Q)}function Q3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function Z3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function Y3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Q=0;for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z))Q+=(Z.length+(X.getItem(Z)?.length||0))*2;return Q}var l=null;function d1($,X,Q=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Q.has($))return!0;if(Q.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!d1($[J],X[J],Q))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!d1(G,X.get(J),Q))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Z=Object.keys($),Y=Object.keys(X);if(Z.length!==Y.length)return!1;for(let J of Z){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!d1($[J],X[J],Q))return!1}return!0}function KJ($){l=$}function _J(){return l}function UJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:J3()}}function J3(){return{refs:new Map,effects:new Set,cleanups:[]}}function BJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=u1();if(G)Q.add(G);return Z},set value(G){if(!Object.is(G,Z)){let W=Z;Z=G;for(let K of X)K(G,W);for(let K of Q)if(m$())p$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(l)l.scope.refs.set(Y,J);return J}var a5=new WeakMap;function G3($){let X=a5.get($);if(X)return X;let Q=new Map,Z=(G)=>{let W=Q.get(G);if(!W)return;for(let K of[...W])if(m$())p$(K);else K()},Y=(G,W)=>{if(!Q.has(G))Q.set(G,new Set);return Q.get(G).add(W),()=>{Q.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=u1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return G3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Z(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Z(W),K}});return a5.set($,J),J}function LJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=O1(J);if(X=$(),H1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=O1(J);return X=$(),Q=!1,H1(W),{get value(){let K=u1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Z.add(K),()=>{Z.delete(K)}}}}function W3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function FJ($,X,Q={}){let{immediate:Z=!1,deep:Y=!1,flush:J="post"}=Q,G,W,K=!1,_=()=>{if(K)return;let O=j();if((Y?!d1(O,G):!Object.is(O,G))||Z)if(X(O,G),Y&&O!==null&&typeof O==="object")try{G=structuredClone(O)}catch{G=O}else G=O},U=(O)=>{if(J==="sync")O();else if(J==="pre")Promise.resolve().then(O);else W3(O)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let O=O1(z);try{return $()}finally{H1(O)}}return $.value};if(typeof $!=="function"){let O=$.subscribe(()=>{U(_)});W=()=>{K=!0,O()}}else W=()=>{K=!0};if(G=j(),Z)U(_);if(l)l.scope.cleanups.push(()=>W?.());return()=>W?.()}function zJ($,X,Q={}){let Z=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Z.push(G)}if(Q.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Z)J()}}function jJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=O1(Z);X=$(),H1(Y)};if(Z(),l)l.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function OJ($){if(l)l.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function HJ($){if(l)l.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function AJ($){if(l)l.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function qJ($){if(l)l.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function NJ($){if(l)l.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function MJ($){if(l)l.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function n0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function VJ($){await n0($,"beforeMount"),$.isMounted=!0,await n0($,"mounted")}async function EJ($){if(!$.isMounted||$.isUnmounted)return;await n0($,"beforeUpdate"),await n0($,"updated")}async function RJ($){if($.isUnmounted)return;await n0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await n0($,"unmounted")}function IJ(){return`
2
+ import{lg as _$,mg as K5}from"./chunk-qq3ev7wg.js";import{Ag as U$,Bg as q6,Dg as Z1,Eg as y6,Fg as Q5,Gg as B$,Hg as L$,Ig as v6,Jg as g6,wg as y7}from"./chunk-fbtcegdp.js";import{Aj as p5,Cj as c5,vj as u1,wj as O1,xj as H1,yj as m$,zj as p$}from"./chunk-w95sp0k9.js";import{Wj as Y$,Xj as J$}from"./chunk-14fzcbj0.js";import{yk as g5,zk as f5}from"./chunk-1m4sa11y.js";import{Fk as l7,Gk as i7}from"./chunk-58f0mthg.js";import{_k as Q1}from"./chunk-ra5r02m8.js";import{$o as X5,Bp as m0,Fq as O0,Jm as x6,Nm as Z5,Pr as G$,Qm as N1,Rm as M1,Tq as Q6,Uq as E1,Xo as Z$,Yq as p0,am as b7,an as c1,as as E$,bp as S6,cm as X6,cp as z6,cs as d0,dn as L6,dq as g7,ds as M0,hs as V0,kq as P6,ln as n$,lq as b6,nn as o$,qn as l1,sm as u0,tp as j0,un as t$,xn as Q$,yn as F6}from"./chunk-3yvmfwa9.js";import{Ns as s$,Vs as B,bt as W$,ct as K$,gt as o}from"./chunk-95fvybb4.js";import{st as S0}from"./chunk-bby4emay.js";import{Du as R6,Eu as I6,Fu as D6,Gu as w6,Hu as T6,Iu as C6,Ku as k6,Ou as A6,iu as $5,ju as H6,nu as V6,ou as E6}from"./chunk-5wkwhjjn.js";import{Yu as p}from"./chunk-f8wjdg40.js";var l5={read:($)=>{try{return JSON.parse($)}catch{return $}},write:($)=>{return JSON.stringify($)}};function e7($,X,Q={}){let{storage:Z="local",serializer:Y=l5,mergeDefaults:J=!1,listenToStorageChanges:G=!0}=Q,W=new Set,K=typeof window<"u",_=()=>{if(!K)return null;return Z==="session"?sessionStorage:localStorage},U=()=>{let L=_();if(!L)return X;try{let H=L.getItem($);if(H===null)return X;let q=Y.read(H);if(J&&typeof X==="object"&&X!==null)return{...X,...q};return q}catch{return X}},F=(L)=>{let H=_();if(!H)return;try{if(L===null||L===void 0)H.removeItem($);else H.setItem($,Y.write(L))}catch(q){console.warn(`[useStorage] Failed to write key "${$}":`,q)}},z=U(),j=(L,H)=>{for(let q of W)try{q(L,H)}catch(A){console.error("[useStorage] Subscriber error:",A)}};if(K&&G){let L=(q)=>{if(q.key===$&&q.storageArea===_()){let A=z;try{z=q.newValue?Y.read(q.newValue):X}catch(N){console.warn(`[useStorage] Failed to read key "${$}" from a cross-tab update:`,N);return}j(z,A)}};window.addEventListener("storage",L);let H=globalThis.onDestroy;if(typeof H==="function")H(()=>window.removeEventListener("storage",L))}let O={get value(){return z},set value(L){let H=z;z=L,F(L),j(L,H)},get:()=>z,set:(L)=>{O.value=L},remove:()=>{let L=_();if(L){L.removeItem($);let H=z;z=X,j(X,H)}},subscribe:(L)=>{return W.add(L),L(z,void 0),()=>W.delete(L)}};return O}function i5($,X,Q,Z,Y={}){let{serializer:J=l5,mergeDefaults:G=!1,listenToStorageChanges:W=!0}=Y,K=typeof window<"u",_=()=>{if(!K)return null;return $==="session"?sessionStorage:localStorage},U=(j)=>{if(j===null||j===void 0)return Z;try{let O=J.read(j);if(G&&typeof Z==="object"&&Z!==null)return{...Z,...O};return O}catch(O){return console.warn(`[${X}] Failed to read key "${Q}":`,O),Z}},z=p5((()=>{let j=_();if(!j)return Z;try{return U(j.getItem(Q))}catch(O){return console.warn(`[${X}] Cannot read "${Q}":`,O),Z}})());if(c5(()=>{let j=z(),O=_();if(!O)return;try{if(j===null||j===void 0)O.removeItem(Q);else O.setItem(Q,J.write(j))}catch(L){console.warn(`[${X}] Cannot persist "${Q}":`,L)}}),K&&W){let j=(L)=>{if(L.key!==Q)return;if(L.storageArea&&L.storageArea!==_())return;z.set(U(L.newValue))};window.addEventListener("storage",j);let O=globalThis.onDestroy;if(typeof O==="function")O(()=>window.removeEventListener("storage",j))}return z}function $3($,X,Q){return i5("local","useLocalStorage",$,X,Q)}function X3($,X,Q){return i5("session","useSessionStorage",$,X,Q)}function Q3($="local"){if(typeof window>"u")return;($==="session"?sessionStorage:localStorage).clear()}function Z3($="local"){if(typeof window>"u")return[];let X=$==="session"?sessionStorage:localStorage;return Object.keys(X)}function Y3($="local"){if(typeof window>"u")return 0;let X=$==="session"?sessionStorage:localStorage,Q=0;for(let Z in X)if(Object.prototype.hasOwnProperty.call(X,Z))Q+=(Z.length+(X.getItem(Z)?.length||0))*2;return Q}var l=null;function d1($,X,Q=new WeakSet){if(Object.is($,X))return!0;if(typeof $!=="object"||typeof X!=="object"||$===null||X===null)return!1;if(Q.has($))return!0;if(Q.add($),$ instanceof Date&&X instanceof Date)return $.getTime()===X.getTime();if($ instanceof RegExp&&X instanceof RegExp)return $.source===X.source&&$.flags===X.flags;if(Array.isArray($)){if(!Array.isArray(X)||$.length!==X.length)return!1;for(let J=0;J<$.length;J++)if(!d1($[J],X[J],Q))return!1;return!0}if(Array.isArray(X))return!1;if($ instanceof Map){if(!(X instanceof Map)||$.size!==X.size)return!1;for(let[J,G]of $)if(!X.has(J)||!d1(G,X.get(J),Q))return!1;return!0}if(X instanceof Map)return!1;if($ instanceof Set){if(!(X instanceof Set)||$.size!==X.size)return!1;for(let J of $)if(!X.has(J))return!1;return!0}if(X instanceof Set)return!1;let Z=Object.keys($),Y=Object.keys(X);if(Z.length!==Y.length)return!1;for(let J of Z){if(!Object.prototype.hasOwnProperty.call(X,J))return!1;if(!d1($[J],X[J],Q))return!1}return!0}function KJ($){l=$}function _J(){return l}function UJ(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:J3()}}function J3(){return{refs:new Map,effects:new Set,cleanups:[]}}function BJ($){let X=new Set,Q=new Set,Z=$,Y=Symbol("ref"),J={get value(){let G=u1();if(G)Q.add(G);return Z},set value(G){if(!Object.is(G,Z)){let W=Z;Z=G;for(let K of X)K(G,W);for(let K of Q)if(m$())p$(K);else K()}},subscribe(G){return X.add(G),()=>{X.delete(G)}}};if(l)l.scope.refs.set(Y,J);return J}var a5=new WeakMap;function G3($){let X=a5.get($);if(X)return X;let Q=new Map,Z=(G)=>{let W=Q.get(G);if(!W)return;for(let K of[...W])if(m$())p$(K);else K()},Y=(G,W)=>{if(!Q.has(G))Q.set(G,new Set);return Q.get(G).add(W),()=>{Q.get(G)?.delete(W)}},J=new Proxy($,{get(G,W,K){let _=Reflect.get(G,W,K),U=u1();if(U)Y(W,U);if(_!==null&&typeof _==="object"&&!Array.isArray(_)){let F=Object.getPrototypeOf(_);if(F===Object.prototype||F===null)return G3(_)}return _},set(G,W,K,_){let U=Reflect.get(G,W,_),F=Reflect.set(G,W,K,_);if(!Object.is(K,U))Z(W);return F},deleteProperty(G,W){let K=Reflect.deleteProperty(G,W);return Z(W),K}});return a5.set($,J),J}function LJ($){let X,Q=!0,Z=new Set,Y=new Set,J=()=>{Q=!0,G()},G=()=>{if(Q){let K=X,_=O1(J);if(X=$(),H1(_),Q=!1,!Object.is(X,K)){for(let U of Z)U(X,K);for(let U of Y)U()}}},W=O1(J);return X=$(),Q=!1,H1(W),{get value(){let K=u1();if(K)Y.add(K);return G(),X},set value(K){console.warn("[stx] Computed properties are readonly")},subscribe(K){return Z.add(K),()=>{Z.delete(K)}}}}function W3($){if(typeof requestAnimationFrame==="function"){requestAnimationFrame(()=>{requestAnimationFrame($)});return}setTimeout($,0)}function FJ($,X,Q={}){let{immediate:Z=!1,deep:Y=!1,flush:J="post"}=Q,G,W,K=!1,_=()=>{if(K)return;let O=j();if((Y?!d1(O,G):!Object.is(O,G))||Z)if(X(O,G),Y&&O!==null&&typeof O==="object")try{G=structuredClone(O)}catch{G=O}else G=O},U=(O)=>{if(J==="sync")O();else if(J==="pre")Promise.resolve().then(O);else W3(O)},F=!1,z=()=>{if(K||F)return;F=!0,U(()=>{F=!1,_()})},j=()=>{if(typeof $==="function"){let O=O1(z);try{return $()}finally{H1(O)}}return $.value};if(typeof $!=="function"){let O=$.subscribe(()=>{U(_)});W=()=>{K=!0,O()}}else W=()=>{K=!0};if(G=j(),Z)U(_);if(l)l.scope.cleanups.push(()=>W?.());return()=>W?.()}function zJ($,X,Q={}){let Z=[],Y=$.map((J)=>J.value);for(let J of $){let G=J.subscribe(()=>{let W=$.map((K)=>K.value);X(W,Y),Y=[...W]});Z.push(G)}if(Q.immediate){let J=$.map((G)=>G.value);X(J,Y)}return()=>{for(let J of Z)J()}}function jJ($){let X,Q=!1,Z=()=>{if(Q)return;if(X)X();let Y=O1(Z);X=$(),H1(Y)};if(Z(),l)l.scope.cleanups.push(()=>{if(Q=!0,X)X()});return()=>{if(Q=!0,X)X()}}function OJ($){if(l)l.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function HJ($){if(l)l.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function AJ($){if(l)l.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function qJ($){if(l)l.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function NJ($){if(l)l.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function MJ($){if(l)l.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function n0($,X){let Q=$.hooks[X];for(let Z of Q)await Z()}async function VJ($){await n0($,"beforeMount"),$.isMounted=!0,await n0($,"mounted")}async function EJ($){if(!$.isMounted||$.isUnmounted)return;await n0($,"beforeUpdate"),await n0($,"updated")}async function RJ($){if($.isUnmounted)return;await n0($,"beforeUnmount");for(let X of $.scope.cleanups)X();$.isUnmounted=!0,await n0($,"unmounted")}function IJ(){return`
3
3
  <script data-stx-client-runtime>
4
4
  (function() {
5
5
  'use strict';
@@ -1057,7 +1057,7 @@ else {
1057
1057
  };
1058
1058
  })();
1059
1059
  </script>
1060
- `}function D0($,X,Q={}){let Z=j4(X,Q),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Z+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Z}</html>`);return $+Z}function t1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function e1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function $$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var $1=null;function X$($){if(!$1)$1=new B6($);return $1}function A1(){if($1)$1.stop(),$1=null}import q1 from"path";var X1={name:"bun-plugin-stx",async setup($){let Q={...await d0(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${q1.relative(q1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await G$(Q,Z);if(J.push(...G),Q.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Q.cache&&Q.cachePath){let L=await Y$(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await t$(()=>Bun.file(G).text(),"",(L)=>{throw new o$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new o$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=s$.time("script-extraction",()=>{let L=K,H=Z$(K);if(H)L=H.content.trim();let q=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],A="",N=[];for(let M of q){let R=M.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",w=M.match(/<script\b([^>]*)>/i),C=w?w[1]:"";if(/\bserver\b/i.test(C))A=R;else N.push(M)}let V=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:A,templateContent:V,allScripts:N}}),z={__filename:G,__dirname:q1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await t$(()=>j0(_,z,G),void 0,(L)=>{let H=new n$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(Q$.log(H,{filePath:G,scriptContent:_}),Q.debug)throw H});let O=await s$.timeAsync("directive-processing",async()=>{return await O0(U,z,G,Q,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-cd4v7xyr.js"),H=L(F.join(`
1060
+ `}function D0($,X,Q={}){let Z=j4(X,Q),Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+Z+$.slice(Y);if($.includes("</html>"))return $.replace("</html>",`${Z}</html>`);return $+Z}function t1($){let X=$.toLowerCase();return X.endsWith(".css")||X.endsWith(".scss")||X.endsWith(".sass")||X.endsWith(".less")}function e1($){let X=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((Z)=>X.endsWith(Z))}function $$($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Q)=>Q.test($))}var $1=null;function X$($){if(!$1)$1=new B6($);return $1}function A1(){if($1)$1.stop(),$1=null}import q1 from"path";var X1={name:"bun-plugin-stx",async setup($){let Q={...await d0(),...$.config?.stx},Z=new Set,Y=Q.webComponents?.enabled?`./${q1.relative(q1.dirname($.config?.outdir||"dist"),Q.webComponents.outputDir||"dist/web-components")}`:"/web-components",J=[];if(Q.webComponents?.enabled)try{let G=await G$(Q,Z);if(J.push(...G),Q.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let W=new Set;if(Q.cache&&Q.cachePath){let L=await Y$(G,Q);if(L){if(Q.debug)console.log(`Using cached version of ${G}`);return{contents:L,loader:"html"}}}let K=await t$(()=>Bun.file(G).text(),"",(L)=>{throw new o$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${L.message}`)});if(!K)throw new o$(`stx file is empty: ${G}`,G);let{scriptContent:_,templateContent:U,allScripts:F}=s$.time("script-extraction",()=>{let L=K,H=Z$(K);if(H)L=H.content.trim();let q=K.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],A="",N=[];for(let M of q){let R=M.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",w=M.match(/<script\b([^>]*)>/i),C=w?w[1]:"";if(/\bserver\b/i.test(C))A=R;else N.push(M)}let V=L.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:A,templateContent:V,allScripts:N}}),z={__filename:G,__dirname:q1.dirname(G),__stx:{webComponentsPath:Y,builtComponents:J}};await t$(()=>j0(_,z,G),void 0,(L)=>{let H=new n$(`Script execution failed in ${G}: ${L.message}`,G,void 0,void 0,_.substring(0,100));if(Q$.log(H,{filePath:G,scriptContent:_}),Q.debug)throw H});let O=await s$.timeAsync("directive-processing",async()=>{return await O0(U,z,G,Q,W)});if(F.length>0){let{interpolateScriptsInTemplate:L}=await import("./chunk-kva81xy0.js"),H=L(F.join(`
1061
1061
  `),z),q=O.search(/<\/body>/i);if(q!==-1)O=O.slice(0,q)+H+`
1062
1062
  `+O.slice(q);else O+=`
1063
1063
  ${H}`}if(O=await z6(O),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J$(G,O,W,Q),Q.debug)console.log(`Cached template ${G} with ${W.size} dependencies`)}return{contents:O,loader:"html"}}catch(W){let K=W instanceof Error?W:new n$(`Plugin processing failed: ${String(W)}`,G);if(Q$.log(K,{filePath:G,buildConfig:$.config}),F6.logDetailedError(K,{filePath:G,plugin:"bun-plugin-stx"}),Q.debug)console.error("stx Plugin Error:",K);let _=K,U=_.line||null,F=_.context||null;return{contents:Q.debug||L6()?`<!DOCTYPE html>
@@ -1120,7 +1120,7 @@ ${H}`}if(O=await z6(O),W.forEach((L)=>Z.add(L)),Q.cache&&Q.cachePath){if(await J
1120
1120
  <h1>Something went wrong</h1>
1121
1121
  <p>An internal error occurred. Please try again later.</p>
1122
1122
  </body>
1123
- </html>`,loader:"html"}}})}};async function H4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=Y0.resolve($);if(!H0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return r$(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=S0(process.cwd(),"output");H0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let A={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},N=await Bun.build({entrypoints:[W],outdir:K,plugins:[A,X1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!N.success)return console.error(`${B.red}Build failed:${B.reset}`,N.logs),!1;let V=N.outputs.find((R)=>R.path.endsWith(".html"));if(!V)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(V.path).text(),!0}catch(A){return console.error(`${B.red}Error building stx file:${B.reset}`,A),!1}};if(!await U())return!1;let z=Y0.dirname(W);await W$(z);let j=Q;try{if(j=await k0(Q),j!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let A=X.hmrPort||j+1;J=X$({wsPort:A,verbose:!1}),G=J.start(A)}let O={},L=null;try{let{loadStxConfig:A}=await import("./chunk-13ftt3qc.js"),N=await A();if(N?.apiRouter)L=N?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(N?.apiRoutes){O=N.apiRoutes;let V=Object.keys(O).length;if(V>0)console.log(`${B.blue}Loaded ${B.bright}${V} API route${V>1?"s":""}${B.reset}`)}if(N?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:M}=await import("./chunk-khfszwjy.js"),R=N.broadcasting;await V(R);let w=R.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=Y0.join(process.cwd(),"channels.ts");if(H0.existsSync(C))try{let I=await M(C);console.log(`${B.blue}Loaded ${B.bright}${I} broadcast channel${I!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(I){console.warn(`${B.yellow}Failed to load channels.ts: ${I.message}${B.reset}`)}}catch(V){console.warn(`${B.yellow}Broadcasting failed to start: ${V.message}${B.reset}`)}}catch{}if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let H=O4({port:j,async fetch(A){return _$(A,await(async()=>{let N=new URL(A.url);if(L)try{let C=await L.handleRequest(A);if(C.status!==404)return C}catch{}if(O[N.pathname])try{return await O[N.pathname](A)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(N.pathname==="/")return(async()=>{let I=await o(_||"");if(Y)I=D0(I,G);if(X.native)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;if(X.titlebarHidden)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${I}`;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=Y0.join(K,N.pathname);if(H0.existsSync(V)&&H0.statSync(V).isFile()){let C=Bun.file(V),I=Y0.extname(V).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let h=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),u=await C.text(),t=h.transformSync(u);return new Response(t,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(C,{headers:{"Content-Type":E}})}let M=Y0.dirname(W),R=Y0.join(M,N.pathname);if(H0.existsSync(R)&&H0.statSync(R).isFile()){let C=Bun.file(R),I=Y0.extname(R).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let h=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),u=await C.text(),t=h.transformSync(u);return new Response(t,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(C,{headers:{"Content-Type":E}})}let w=Y0.join(process.cwd(),"public",N.pathname);if(H0.existsSync(w)&&H0.statSync(w).isFile()){let C=Bun.file(w),I=Y0.extname(w).toLowerCase(),E="application/octet-stream";if(I===".ts"||I===".tsx"){let h=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),u=await C.text(),t=h.transformSync(u);return new Response(t,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(C,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(A){return new Response(`<pre>${A}
1123
+ </html>`,loader:"html"}}})}};async function H4($,X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=Y0.resolve($);if(!H0.existsSync(W))return console.error(`${B.red}Error: File not found: ${B.bright}${W}${B.reset}`),!1;if(W.endsWith(".md"))return r$(W,X);else if(!W.endsWith(".stx"))return console.error(`${B.red}Error: Unsupported file type: ${B.bright}${W}${B.reset}. Only .stx and .md files are supported.`),!1;let K=S0(process.cwd(),"output");H0.mkdirSync(K,{recursive:!0}),console.log(`${B.blue}Building ${B.bright}${$}${B.reset}...`);let _=null,U=async()=>{try{let A={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(w)=>{return{path:w.path,external:!0}})}},N=await Bun.build({entrypoints:[W],outdir:K,plugins:[A,X1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!N.success)return console.error(`${B.red}Build failed:${B.reset}`,N.logs),!1;let V=N.outputs.find((R)=>R.path.endsWith(".html"));if(!V)return console.error(`${B.red}No HTML output found${B.reset}`),!1;return _=await Bun.file(V.path).text(),!0}catch(A){return console.error(`${B.red}Error building stx file:${B.reset}`,A),!1}};if(!await U())return!1;let z=Y0.dirname(W);await W$(z);let j=Q;try{if(j=await k0(Q),j!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${j} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let A=X.hmrPort||j+1;J=X$({wsPort:A,verbose:!1}),G=J.start(A)}let O={},L=null;try{let{loadStxConfig:A}=await import("./chunk-nv1qkd6w.js"),N=await A();if(N?.apiRouter)L=N?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(N?.apiRoutes){O=N.apiRoutes;let V=Object.keys(O).length;if(V>0)console.log(`${B.blue}Loaded ${B.bright}${V} API route${V>1?"s":""}${B.reset}`)}if(N?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:M}=await import("./chunk-khfszwjy.js"),R=N.broadcasting;await V(R);let w=R.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${w}/ws${B.reset}`);let C=Y0.join(process.cwd(),"channels.ts");if(H0.existsSync(C))try{let I=await M(C);console.log(`${B.blue}Loaded ${B.bright}${I} broadcast channel${I!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(I){console.warn(`${B.yellow}Failed to load channels.ts: ${I.message}${B.reset}`)}}catch(V){console.warn(`${B.yellow}Broadcasting failed to start: ${V.message}${B.reset}`)}}catch{}if(console.log(`${B.blue}Starting server on ${B.cyan}http://localhost:${j}/${B.reset}...`),Y)console.log(`${B.magenta}Hot reload enabled on ws://localhost:${G}${B.reset}`);let H=O4({port:j,async fetch(A){return _$(A,await(async()=>{let N=new URL(A.url);if(L)try{let C=await L.handleRequest(A);if(C.status!==404)return C}catch{}if(O[N.pathname])try{return await O[N.pathname](A)}catch(C){return new Response(JSON.stringify({error:C.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(N.pathname==="/")return(async()=>{let I=await o(_||"");if(Y)I=D0(I,G);if(X.native)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;if(X.titlebarHidden)if(I.includes("<head>"))I=I.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(I.includes("<html"))I=I.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 I=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${I}`;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let V=Y0.join(K,N.pathname);if(H0.existsSync(V)&&H0.statSync(V).isFile()){let C=Bun.file(V),I=Y0.extname(V).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let h=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),u=await C.text(),t=h.transformSync(u);return new Response(t,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(C,{headers:{"Content-Type":E}})}let M=Y0.dirname(W),R=Y0.join(M,N.pathname);if(H0.existsSync(R)&&H0.statSync(R).isFile()){let C=Bun.file(R),I=Y0.extname(R).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let h=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),u=await C.text(),t=h.transformSync(u);return new Response(t,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(C,{headers:{"Content-Type":E}})}let w=Y0.join(process.cwd(),"public",N.pathname);if(H0.existsSync(w)&&H0.statSync(w).isFile()){let C=Bun.file(w),I=Y0.extname(w).toLowerCase(),E="application/octet-stream";if(I===".ts"||I===".tsx"){let h=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),u=await C.text(),t=h.transformSync(u);return new Response(t,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){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(C,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(A){return new Response(`<pre>${A}
1124
1124
  ${A.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
1125
1125
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1126
1126
  ${B.bright}\u2192 ${B.cyan}http://localhost:${j}/${B.reset}`),console.log(`
@@ -1607,12 +1607,12 @@ ${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
1607
1607
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1608
1608
  ${B.bright}\u2192 ${B.cyan}http://localhost:${U}/${B.reset}`),console.log(`
1609
1609
  ${B.yellow}Routes:${B.reset}`);let z=new Set(W.map((O)=>O.routeTemplate)),j=Object.entries(G).filter(([O])=>!z.has(O)).sort(([O],[L])=>O.localeCompare(L)).map(([O,L])=>({route:O==="/"?"/":O,filePath:Q0.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let O of W){let L=O.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");j.push({route:L,filePath:Q0.relative(process.cwd(),O.filePath),fileType:"stx"})}if(j.sort((O,L)=>O.route.localeCompare(L.route)),j.forEach((O,L)=>{let q=L===j.length-1?"\u2514\u2500 ":"\u251C\u2500 ",A=O.fileType==="md"?`${B.magenta}(markdown)${B.reset}`:"";console.log(` ${B.green}${q}${O.route}${B.reset} \u2192 ${B.bright}${O.filePath}${B.reset} ${A}`)}),console.log(`
1610
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(F.url.toString(),()=>{if(Z)P0.watch(J,{recursive:!0}).close();F.stop()}),Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let O=P0.watch(J,{recursive:!0},async(L,H)=>{if(!H)return;if(H.endsWith(".stx")||H.endsWith(".js")||H.endsWith(".ts")||H.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${H}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{O.close(),F.stop(),process.exit(0)})}return!0}function O6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:N4}=globalThis.Bun;import J0 from"fs";import g from"path";async function M6($){try{return Z5(await Bun.file($).text())}catch{return}}function e$($){let X=Bun.file($),Q=g.extname($).toLowerCase(),Z={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Q)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Z[Q]||"application/octet-stream",...J}})}async function M4($=".",X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=g.resolve($),{loadStxConfig:K}=await import("./chunk-13ftt3qc.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,F=X.pagesDir||_.pagesDir||"pages",z=g.join(U,F);if(!J0.existsSync(z))return console.error(`${B.red}Error: No '${F}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${z}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${F}/index.stx for the homepage.${B.reset}`),!1;let j=X5(U,{pagesDir:F});if(j.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${z}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${j.length}${B.blue} routes${B.reset}`);let O=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of O)if(J0.existsSync(D)){let x=X5(g.dirname(D),{pagesDir:g.basename(D)});for(let S of x){let b=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:b},prefix:T})}if(x.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${x.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let H=new Map,q=null,A=null;if(X.stxOptions?.shell!==!1){if(A=await y6(W,X.stxOptions?.shell),A){if(q=await Q5(A,X.stxOptions||{}),q)console.log(`${B.blue}Using app shell: ${B.bright}${g.relative(W,A)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}R6(),await D6(W);let N=I6();if(N.length>0)console.log(`${B.blue}Loaded ${B.bright}${N.length}${B.blue} middleware: ${B.dim}${N.join(", ")}${B.reset}`);let V={},M=null;try{let{loadStxConfig:D}=await import("./chunk-13ftt3qc.js"),T=await D(W);if(T?.apiRouter)M=T?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(T?.apiRoutes){V=T.apiRoutes;let x=Object.keys(V).length;if(x>0)console.log(`${B.blue}Loaded ${B.bright}${x} API route${x>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:x,loadChannels:S}=await import("./chunk-khfszwjy.js"),b=T.broadcasting;await x(b);let _0=b.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${_0}/ws${B.reset}`);let K0=g.join(process.cwd(),"channels.ts");if(J0.existsSync(K0))try{let C0=await S(K0);console.log(`${B.blue}Loaded ${B.bright}${C0} broadcast channel${C0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(C0){console.warn(`${B.yellow}Failed to load channels.ts: ${C0.message}${B.reset}`)}}catch(x){console.warn(`${B.yellow}Broadcasting failed to start: ${x.message}${B.reset}`)}}catch{}let R=S0(W,"output");J0.mkdirSync(R,{recursive:!0});let w=new Map,C=new Set,I=async(D)=>{let T=V6(z,D);if(!T)return null;try{let x=await Bun.build({entrypoints:[T],outdir:R,plugins:[X1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!x.success)return null;let S=x.outputs.find((b)=>b.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},E=new Map,h=async(D,T)=>{try{let{processDirectives:x,extractVariables:S,defaultConfig:b,loadStxConfig:_0,injectRouterScript:K0}=await import("./chunk-13ftt3qc.js"),{checkCache:C0,cacheTemplate:u$,readFileCached:r,templateCache:f1}=await import("./chunk-scdxk8nn.js"),h1=await _0(W),k=(d)=>{if(!d)return d;if(g.isAbsolute(d))return d;return g.resolve(W,d)},y={...b,...h1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)y.debug=!0;y.partialsDir=k(y.partialsDir),y.componentsDir=k(y.componentsDir),y.layoutsDir=k(y.layoutsDir),y.storesDir=k(y.storesDir||"stores"),y.cachePath=k(y.cachePath)??S0(W,"cache");let m=!T&&!X.profile,c=y.cache!==!1;if(c&&m){let d=f1.get(D.filePath);if(d)try{if((await J0.promises.stat(D.filePath)).mtime.getTime()<=d.mtime){let z0=!0;for(let $0 of d.dependencies){if(!J0.existsSync($0)){z0=!1;break}if((await J0.promises.stat($0)).mtime.getTime()>d.mtime){z0=!1;break}}if(z0){let $0=d.output;if(q)$0=L$($0,{preserveHead:!0});let j1=E.get(D.filePath);return{route:D,content:$0,status:j1?.status??await M6(D.filePath),headers:j1?.headers}}}}catch{}let L0=await C0(D.filePath,y);if(L0){let F0=L0;if(q)F0=L$(F0,{preserveHead:!0});let z0=E.get(D.filePath);return{route:D,content:F0,status:z0?.status??await M6(D.filePath),headers:z0?.headers}}}let s=c?await r(D.filePath):await Bun.file(D.filePath).text(),v=Z5(s),{classifyAllScripts:U0}=await import("./chunk-13ftt3qc.js"),B0=U0(s),a=B0.server.map((d)=>d.content),e=s;for(let d of B0.server)e=e.replace(d.fullTag,"");let n={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let d of a)try{await S(d,n,D.filePath)}catch(L0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,L0?.message||L0)}let r0=new Set,N0;if(X.profile){let d=performance.now();N0=await x(e,n,D.filePath,y,r0);let L0=performance.now()-d,F0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${F0} \u2192 ${L0.toFixed(2)}ms`)}else N0=await x(e,n,D.filePath,y,r0);if(!q)N0=await K0(N0,{router:y.router});{let{interpolateScriptExpressions:d}=await import("./chunk-cd4v7xyr.js");N0=N0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(L0,F0,z0)=>{if(!/function\s+__stx_setup_/.test(z0))return L0;return`<script${F0}>${d(z0,n)}</script>`})}if(q)N0=L$(N0,{preserveHead:!0});if(c&&m)await u$(D.filePath,N0,r0,y);let{extractStreamBoundaries:t7}=await import("./chunk-78bm61kd.js"),s0=t7(n),z1=n.__streamTemplates;if(z1&&typeof z1==="object"&&Object.keys(z1).length>0){let d=n.streamBoundaries||{},L0={...y,autoShell:!1},F0=Object.keys(z1).map(($0)=>({id:$0,render:async()=>{let j1=typeof d[$0]==="function"?await d[$0]():void 0;return x(z1[$0],{...n,$boundary:j1},D.filePath,L0,new Set)}})),z0=new Set(F0.map(($0)=>$0.id));s0=[...(s0||[]).filter(($0)=>!z0.has($0.id)),...F0]}if(s0&&s0.length>0)C.add(D.pattern);else s0=void 0;let u5=N1(n),m5=M1(n);if(m)E.set(D.filePath,{status:u5,headers:m5});return{route:D,content:N0,status:u5??v,headers:m5,boundaries:s0}}catch(x){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,x),null}},u=8,t=async()=>{w.clear(),H.clear();for(let D=0;D<j.length;D+=u){let T=j.slice(D,D+u),x=await Promise.all(T.map((S)=>h(S)));for(let S of x)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=u){let T=L.slice(D,D+u),x=await Promise.all(T.map(({route:S})=>h(S)));for(let S of x)if(S)H.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await t())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await W$(W);let W0=Q;try{if(W0=await k0(Q),W0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${W0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||W0+1;J=X$({wsPort:D,verbose:!1}),G=J.start(D)}let v1=(D,T)=>{let S=`<script data-stx-route-params>(function(){var p=${JSON.stringify(T).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(D.includes("</head>"))return D.replace("</head>",`${S}</head>`);if(D.includes("<body"))return D.replace(/<body([^>]*)>/,`<body$1>${S}`);return S+D};console.log(`${B.blue}Starting server...${B.reset}`);let g1=N4({port:W0,async fetch(D){let T=new URL(D.url),x=_?.publicDir||"public",S=g.join(W,x,T.pathname),b=g.join(W,T.pathname),_0=g.join(R,T.pathname),[K0,C0,u$]=await Promise.all([J0.promises.stat(S).catch(()=>null),J0.promises.stat(b).catch(()=>null),J0.promises.stat(_0).catch(()=>null)]);if(K0?.isFile())return e$(S);if(C0?.isFile())return e$(b);if(u$?.isFile())return e$(_0);if(T.pathname.startsWith("/_stx/component/")){let k=decodeURIComponent(T.pathname.slice(16));if(k)try{let y=`<${k} />`,m={...buildConfig,autoShell:!1},c=await processDirectives(y,{},g.join(W,"components",`${k}.stx`),m,new Set);return new Response(c,{headers:{"Content-Type":"text/html"}})}catch(y){return new Response(`<div class="stx-async-error">${y.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:k}=await import("./chunk-j135b7xt.js"),y=await k(D,{publicDir:g.join(W,x),cacheDir:S0(W,"cache","img")});if(y)return y}if(M)try{let k=await M.handleRequest(D);if(k.status!==404)return k}catch{}if(V[T.pathname])try{return await V[T.pathname](D)}catch(k){return new Response(JSON.stringify({error:k.message}),{status:500,headers:{"Content-Type":"application/json"}})}let r=$5(T.pathname,j);if(r){let k=w.get(r.route.pattern),y=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||y){let m=await h(r.route,r.params);if(m)k=m}if(k){let m=k.status??200,c=k.headers??{},s=(r.route.filePath?x6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(s.validate){if(!await s.validate({params:r.params})){let B0=await I(404);if(B0){let a=B0;if(a=await o(a,W),Y)a=D0(a,G);return new Response(a,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(s.middleware){let U0=w6(T.pathname,r.params,s,T.search),B0=T6(U0,null,D,{isServer:!0}),a=await C6(s.middleware,B0);if(a.redirect){let e=a.redirect.path,n=a.redirect.options.redirectCode||302,r0=new Headers(a.responseHeaders);return r0.set("Location",e),new Response(null,{status:n,headers:r0})}if(a.abort){let{statusCode:e,message:n}=a.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${e}</title></head><body><h1>Error ${e}</h1><p>${n}</p></body></html>`,{status:e,headers:{"Content-Type":"text/html"}})}if(Object.keys(a.state).length>0){let e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(a.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;k.content=k.content.replace("</head>",`${e}</head>`)}}let v=k.content;if(q&&v6(D)){let U0=k6(v),B0=S6(v),a=v.match(/<title[^>]*>([\s\S]*?)<\/title>/i),e=a?a[1].trim():"";if(Object.keys(r.params).length>0)v=v1(v,r.params);v=await o(v,W);let n=_?.router?.container||"main";return v=g6(v,n),new Response(v,{status:m,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":U0.layout,"X-STX-Layout-Group":U0.group,"X-STX-Runtime":B0?"true":"false",...e&&{"X-STX-Title":encodeURIComponent(e)},[P6]:b6(),...Z1(),"Cache-Control":U$}})}if(q)v=B$(q,v);if(Object.keys(r.params).length>0)v=v1(v,r.params);if(v=await o(v,W),Y)v=D0(v,G);if(X.native)if(v.includes("<head>"))v=v.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 v="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+v;if(X.titlebarHidden)if(v.includes("<head>"))v=v.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 v=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${v}`;if(k.boundaries&&k.boundaries.length>0){let{renderStreamingPage:U0,streamToResponse:B0}=await import("./chunk-78bm61kd.js");return B0(U0(v,k.boundaries,{timeoutMs:30000}),{status:m,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(v,{status:m,headers:{"Content-Type":"text/html",...Z1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...c}})}}if(L.length>0){let k=L.map((m)=>m.route),y=$5(T.pathname,k);if(y){let m=H.get(y.route.pattern);if(m){let c=m.content;if(q)c=B$(q,c);if(Object.keys(y.params).length>0)c=v1(c,y.params);if(c=await o(c,W),Y)c=D0(c,G);return new Response(c,{status:m.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:m}of O)if(m!=="/"&&T.pathname.startsWith(m)){let c=H.get(m)||H.get(m+"/");if(c){let s=c.content;if(q)s=B$(q,s);if(s=await o(s,W),Y)s=D0(s,G);return new Response(s,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let f1=w.get("/");if(f1){let k=f1.content;if(k=await o(k,W),Y)k=D0(k,G);if(X.native)if(k.includes("<head>"))k=k.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 k="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+k;return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let h1=await I(404);if(h1){let k=h1;if(k=await o(k,W),Y)k=D0(k,G);return new Response(k,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(D){let T=await I(500);if(T)return new Response(T,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${D}
1610
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(F.url.toString(),()=>{if(Z)P0.watch(J,{recursive:!0}).close();F.stop()}),Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let O=P0.watch(J,{recursive:!0},async(L,H)=>{if(!H)return;if(H.endsWith(".stx")||H.endsWith(".js")||H.endsWith(".ts")||H.endsWith(".md"))console.log(`${B.yellow}File ${B.bright}${H}${B.yellow} changed, rebuilding...${B.reset}`),m0.clear(),p0(),await K()});process.on("SIGINT",()=>{O.close(),F.stop(),process.exit(0)})}return!0}function O6($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var{serve:N4}=globalThis.Bun;import J0 from"fs";import g from"path";async function M6($){try{return Z5(await Bun.file($).text())}catch{return}}function e$($){let X=Bun.file($),Q=g.extname($).toLowerCase(),Z={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},J=[".js",".css",".json"].includes(Q)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":Z[Q]||"application/octet-stream",...J}})}async function M4($=".",X={}){let Q=X.port||3000,Z=X.watch!==!1,Y=X.hotReload!==!1&&Z,J=null,G=X.hmrPort||Q+1,W=g.resolve($),{loadStxConfig:K}=await import("./chunk-nv1qkd6w.js"),_=await K(W),U=_.root&&_.root!=="."?g.join(W,_.root):W,F=X.pagesDir||_.pagesDir||"pages",z=g.join(U,F);if(!J0.existsSync(z))return console.error(`${B.red}Error: No '${F}' directory found${B.reset}`),console.log(`${B.dim}Looked in: ${B.bright}${z}${B.reset}`),console.log(`${B.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${B.reset}`),console.log(`${B.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${B.reset}`),console.log(`${B.dim}Starting fresh? Create ${F}/index.stx for the homepage.${B.reset}`),!1;let j=X5(U,{pagesDir:F});if(j.length===0)return console.error(`${B.red}Error: No page files found in ${B.bright}${z}${B.reset}`),!1;console.log(`${B.blue}Found ${B.bright}${j.length}${B.blue} routes${B.reset}`);let O=_?._pluginPageDirs||[],L=[];for(let{dir:D,prefix:T}of O)if(J0.existsSync(D)){let x=X5(g.dirname(D),{pagesDir:g.basename(D)});for(let S of x){let b=T==="/"?S.pattern:`${T}${S.pattern==="/"?"":S.pattern}`;L.push({route:{...S,pattern:b},prefix:T})}if(x.length>0)console.log(`${B.blue}Plugin pages: ${B.bright}${x.length}${B.blue} routes at ${B.cyan}${T}${B.reset}`)}let H=new Map,q=null,A=null;if(X.stxOptions?.shell!==!1){if(A=await y6(W,X.stxOptions?.shell),A){if(q=await Q5(A,X.stxOptions||{}),q)console.log(`${B.blue}Using app shell: ${B.bright}${g.relative(W,A)}${B.reset} ${B.dim}(deprecated: use layouts/default.stx instead)${B.reset}`)}}R6(),await D6(W);let N=I6();if(N.length>0)console.log(`${B.blue}Loaded ${B.bright}${N.length}${B.blue} middleware: ${B.dim}${N.join(", ")}${B.reset}`);let V={},M=null;try{let{loadStxConfig:D}=await import("./chunk-nv1qkd6w.js"),T=await D(W);if(T?.apiRouter)M=T?.apiRouter,console.log(`${B.blue}Using custom router for API handling${B.reset}`);if(T?.apiRoutes){V=T.apiRoutes;let x=Object.keys(V).length;if(x>0)console.log(`${B.blue}Loaded ${B.bright}${x} API route${x>1?"s":""}${B.reset}`)}if(T?.broadcasting?.enabled)try{let{startBroadcasting:x,loadChannels:S}=await import("./chunk-khfszwjy.js"),b=T.broadcasting;await x(b);let _0=b.port??6001;console.log(`${B.magenta}Broadcasting on ${B.cyan}ws://localhost:${_0}/ws${B.reset}`);let K0=g.join(process.cwd(),"channels.ts");if(J0.existsSync(K0))try{let C0=await S(K0);console.log(`${B.blue}Loaded ${B.bright}${C0} broadcast channel${C0!==1?"s":""}${B.blue} from channels.ts${B.reset}`)}catch(C0){console.warn(`${B.yellow}Failed to load channels.ts: ${C0.message}${B.reset}`)}}catch(x){console.warn(`${B.yellow}Broadcasting failed to start: ${x.message}${B.reset}`)}}catch{}let R=S0(W,"output");J0.mkdirSync(R,{recursive:!0});let w=new Map,C=new Set,I=async(D)=>{let T=V6(z,D);if(!T)return null;try{let x=await Bun.build({entrypoints:[T],outdir:R,plugins:[X1],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!x.success)return null;let S=x.outputs.find((b)=>b.path.endsWith(".html"));if(!S)return null;return await Bun.file(S.path).text()}catch{return null}},E=new Map,h=async(D,T)=>{try{let{processDirectives:x,extractVariables:S,defaultConfig:b,loadStxConfig:_0,injectRouterScript:K0}=await import("./chunk-nv1qkd6w.js"),{checkCache:C0,cacheTemplate:u$,readFileCached:r,templateCache:f1}=await import("./chunk-v7p71v7b.js"),h1=await _0(W),k=(d)=>{if(!d)return d;if(g.isAbsolute(d))return d;return g.resolve(W,d)},y={...b,...h1,...X.stxOptions,autoShell:!0};if(X.debugDirectives)y.debug=!0;y.partialsDir=k(y.partialsDir),y.componentsDir=k(y.componentsDir),y.layoutsDir=k(y.layoutsDir),y.storesDir=k(y.storesDir||"stores"),y.cachePath=k(y.cachePath)??S0(W,"cache");let m=!T&&!X.profile,c=y.cache!==!1;if(c&&m){let d=f1.get(D.filePath);if(d)try{if((await J0.promises.stat(D.filePath)).mtime.getTime()<=d.mtime){let z0=!0;for(let $0 of d.dependencies){if(!J0.existsSync($0)){z0=!1;break}if((await J0.promises.stat($0)).mtime.getTime()>d.mtime){z0=!1;break}}if(z0){let $0=d.output;if(q)$0=L$($0,{preserveHead:!0});let j1=E.get(D.filePath);return{route:D,content:$0,status:j1?.status??await M6(D.filePath),headers:j1?.headers}}}}catch{}let L0=await C0(D.filePath,y);if(L0){let F0=L0;if(q)F0=L$(F0,{preserveHead:!0});let z0=E.get(D.filePath);return{route:D,content:F0,status:z0?.status??await M6(D.filePath),headers:z0?.headers}}}let s=c?await r(D.filePath):await Bun.file(D.filePath).text(),v=Z5(s),{classifyAllScripts:U0}=await import("./chunk-nv1qkd6w.js"),B0=U0(s),a=B0.server.map((d)=>d.content),e=s;for(let d of B0.server)e=e.replace(d.fullTag,"");let n={__filename:D.filePath,__dirname:g.dirname(D.filePath),params:T??{},__stx_runtime_head:{}};for(let d of a)try{await S(d,n,D.filePath)}catch(L0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",D.filePath,L0?.message||L0)}let r0=new Set,N0;if(X.profile){let d=performance.now();N0=await x(e,n,D.filePath,y,r0);let L0=performance.now()-d,F0=g.relative(W,D.filePath)||D.filePath;console.log(`[stx:profile] ${F0} \u2192 ${L0.toFixed(2)}ms`)}else N0=await x(e,n,D.filePath,y,r0);if(!q)N0=await K0(N0,{router:y.router});{let{interpolateScriptExpressions:d}=await import("./chunk-kva81xy0.js");N0=N0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(L0,F0,z0)=>{if(!/function\s+__stx_setup_/.test(z0))return L0;return`<script${F0}>${d(z0,n)}</script>`})}if(q)N0=L$(N0,{preserveHead:!0});if(c&&m)await u$(D.filePath,N0,r0,y);let{extractStreamBoundaries:t7}=await import("./chunk-jmvmq1af.js"),s0=t7(n),z1=n.__streamTemplates;if(z1&&typeof z1==="object"&&Object.keys(z1).length>0){let d=n.streamBoundaries||{},L0={...y,autoShell:!1},F0=Object.keys(z1).map(($0)=>({id:$0,render:async()=>{let j1=typeof d[$0]==="function"?await d[$0]():void 0;return x(z1[$0],{...n,$boundary:j1},D.filePath,L0,new Set)}})),z0=new Set(F0.map(($0)=>$0.id));s0=[...(s0||[]).filter(($0)=>!z0.has($0.id)),...F0]}if(s0&&s0.length>0)C.add(D.pattern);else s0=void 0;let u5=N1(n),m5=M1(n);if(m)E.set(D.filePath,{status:u5,headers:m5});return{route:D,content:N0,status:u5??v,headers:m5,boundaries:s0}}catch(x){return console.error(`${B.red}Error building ${B.bright}${D.pattern}${B.reset}:`,x),null}},u=8,t=async()=>{w.clear(),H.clear();for(let D=0;D<j.length;D+=u){let T=j.slice(D,D+u),x=await Promise.all(T.map((S)=>h(S)));for(let S of x)if(S)w.set(S.route.pattern,S)}for(let D=0;D<L.length;D+=u){let T=L.slice(D,D+u),x=await Promise.all(T.map(({route:S})=>h(S)));for(let S of x)if(S)H.set(S.route.pattern,S)}return w.size>0};if(console.log(`${B.blue}Building pages...${B.reset}`),!await t())return console.error(`${B.red}No pages were successfully built${B.reset}`),!1;await W$(W);let W0=Q;try{if(W0=await k0(Q),W0!==Q)console.log(`${B.yellow}Port ${Q} is busy, using port ${W0} instead${B.reset}`)}catch{return console.error(`${B.red}Could not find an available port${B.reset}`),!1}if(Y){let D=X.hmrPort||W0+1;J=X$({wsPort:D,verbose:!1}),G=J.start(D)}let v1=(D,T)=>{let S=`<script data-stx-route-params>(function(){var p=${JSON.stringify(T).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(D.includes("</head>"))return D.replace("</head>",`${S}</head>`);if(D.includes("<body"))return D.replace(/<body([^>]*)>/,`<body$1>${S}`);return S+D};console.log(`${B.blue}Starting server...${B.reset}`);let g1=N4({port:W0,async fetch(D){let T=new URL(D.url),x=_?.publicDir||"public",S=g.join(W,x,T.pathname),b=g.join(W,T.pathname),_0=g.join(R,T.pathname),[K0,C0,u$]=await Promise.all([J0.promises.stat(S).catch(()=>null),J0.promises.stat(b).catch(()=>null),J0.promises.stat(_0).catch(()=>null)]);if(K0?.isFile())return e$(S);if(C0?.isFile())return e$(b);if(u$?.isFile())return e$(_0);if(T.pathname.startsWith("/_stx/component/")){let k=decodeURIComponent(T.pathname.slice(16));if(k)try{let y=`<${k} />`,m={...buildConfig,autoShell:!1},c=await processDirectives(y,{},g.join(W,"components",`${k}.stx`),m,new Set);return new Response(c,{headers:{"Content-Type":"text/html"}})}catch(y){return new Response(`<div class="stx-async-error">${y.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(T.pathname==="/_stx/img"){let{handleImageRequest:k}=await import("./chunk-j135b7xt.js"),y=await k(D,{publicDir:g.join(W,x),cacheDir:S0(W,"cache","img")});if(y)return y}if(M)try{let k=await M.handleRequest(D);if(k.status!==404)return k}catch{}if(V[T.pathname])try{return await V[T.pathname](D)}catch(k){return new Response(JSON.stringify({error:k.message}),{status:500,headers:{"Content-Type":"application/json"}})}let r=$5(T.pathname,j);if(r){let k=w.get(r.route.pattern),y=C.has(r.route.pattern);if(r.route.isDynamic&&Object.keys(r.params).length>0||y){let m=await h(r.route,r.params);if(m)k=m}if(k){let m=k.status??200,c=k.headers??{},s=(r.route.filePath?x6(await Bun.file(r.route.filePath).text().catch(()=>"")):null)??{};if(s.validate){if(!await s.validate({params:r.params})){let B0=await I(404);if(B0){let a=B0;if(a=await o(a,W),Y)a=D0(a,G);return new Response(a,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(s.middleware){let U0=w6(T.pathname,r.params,s,T.search),B0=T6(U0,null,D,{isServer:!0}),a=await C6(s.middleware,B0);if(a.redirect){let e=a.redirect.path,n=a.redirect.options.redirectCode||302,r0=new Headers(a.responseHeaders);return r0.set("Location",e),new Response(null,{status:n,headers:r0})}if(a.abort){let{statusCode:e,message:n}=a.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${e}</title></head><body><h1>Error ${e}</h1><p>${n}</p></body></html>`,{status:e,headers:{"Content-Type":"text/html"}})}if(Object.keys(a.state).length>0){let e=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(a.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;k.content=k.content.replace("</head>",`${e}</head>`)}}let v=k.content;if(q&&v6(D)){let U0=k6(v),B0=S6(v),a=v.match(/<title[^>]*>([\s\S]*?)<\/title>/i),e=a?a[1].trim():"";if(Object.keys(r.params).length>0)v=v1(v,r.params);v=await o(v,W);let n=_?.router?.container||"main";return v=g6(v,n),new Response(v,{status:m,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":U0.layout,"X-STX-Layout-Group":U0.group,"X-STX-Runtime":B0?"true":"false",...e&&{"X-STX-Title":encodeURIComponent(e)},[P6]:b6(),...Z1(),"Cache-Control":U$}})}if(q)v=B$(q,v);if(Object.keys(r.params).length>0)v=v1(v,r.params);if(v=await o(v,W),Y)v=D0(v,G);if(X.native)if(v.includes("<head>"))v=v.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 v="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+v;if(X.titlebarHidden)if(v.includes("<head>"))v=v.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 v=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${v}`;if(k.boundaries&&k.boundaries.length>0){let{renderStreamingPage:U0,streamToResponse:B0}=await import("./chunk-jmvmq1af.js");return B0(U0(v,k.boundaries,{timeoutMs:30000}),{status:m,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(v,{status:m,headers:{"Content-Type":"text/html",...Z1(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...c}})}}if(L.length>0){let k=L.map((m)=>m.route),y=$5(T.pathname,k);if(y){let m=H.get(y.route.pattern);if(m){let c=m.content;if(q)c=B$(q,c);if(Object.keys(y.params).length>0)c=v1(c,y.params);if(c=await o(c,W),Y)c=D0(c,G);return new Response(c,{status:m.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:m}of O)if(m!=="/"&&T.pathname.startsWith(m)){let c=H.get(m)||H.get(m+"/");if(c){let s=c.content;if(q)s=B$(q,s);if(s=await o(s,W),Y)s=D0(s,G);return new Response(s,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let f1=w.get("/");if(f1){let k=f1.content;if(k=await o(k,W),Y)k=D0(k,G);if(X.native)if(k.includes("<head>"))k=k.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 k="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+k;return new Response(k,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let h1=await I(404);if(h1){let k=h1;if(k=await o(k,W),Y)k=D0(k,G);return new Response(k,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(D){let T=await I(500);if(T)return new Response(T,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${D}
1611
1611
  ${D.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
1612
1612
  ${B.blue}stx${B.reset} ${B.green}${process.env.stx_VERSION||"v0.0.10"}${B.reset} ${B.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${B.reset}`),console.log(`
1613
1613
  ${B.bright}\u2192 ${B.cyan}http://localhost:${W0}/${B.reset}`),Y)console.log(`${B.dim} HMR: ws://localhost:${G}${B.reset}`);console.log(`
1614
1614
  ${B.yellow}Routes:${B.reset}`);let a0=[...E6(j,W)];for(let{route:D}of L)a0.push(`${D.pattern}`);if(a0.forEach((D,T)=>{let S=T===a0.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${B.green}${S}${B.reset}${D}`)}),console.log(`
1615
- Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(g1.url.toString(),()=>{if(J)A1();g1.stop()}),X.native){let D,T=g.join(z,"index.stx");if(J0.existsSync(T)){let S=await Bun.file(T).text();D=o1(S)}let x=_?.app?.window??{};await t0(W0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:x.width,height:x.height,darkMode:x.darkMode,hotReload:x.hotReload,titlebarHidden:x.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let D=(S)=>{return S.startsWith("public/")||S.startsWith("public\\")},T=(S)=>{let b=S.toLowerCase();return b.endsWith(".stx")||b.endsWith(".html")||b.endsWith(".md")},x=J0.watch(W,{recursive:!0},async(S,b)=>{if(!b||$$(b))return;if(e1(b))if(D(b)){if(console.log(`${B.cyan}${b} changed${B.reset}`),Y&&J)J.reload(b)}else if(T(b)){console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:_0,templateCache:K0}=await import("./chunk-scdxk8nn.js");_0(g.resolve(W,b)),K0.delete(g.resolve(W,b))}catch{}if(A&&b){if(g.resolve(W,b)===A||g.basename(A)===b){let K0=await Q5(A,X.stxOptions||{});if(K0)q=K0}}if(await t(),await K$(W),Y&&J)J.reload(b)}else{console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:_0,templateCache:K0}=await import("./chunk-scdxk8nn.js");_0(g.resolve(W,b)),K0.delete(g.resolve(W,b))}catch{}if(await t(),Y&&J)J.reload(b)}else if(t1(b)){if(console.log(`${B.cyan}CSS ${b} changed${B.reset}`),Y&&J)J.updateCss(b)}});process.on("SIGINT",()=>{if(x.close(),J)A1();g1.stop(),process.exit(0)})}return!0}var P={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function V4($={}){if(typeof window>"u")return;P.enabled=!0,P.maxEvents=$.maxEvents||1000,P.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>P,getComponents:()=>Array.from(P.components.values()),getComponent:(X)=>P.components.get(X),getStores:()=>Array.from(P.stores.values()),getStore:(X)=>P.stores.get(X),getEvents:()=>P.events,getPerformance:()=>P.performance,selectComponent:(X)=>J5(X),selectStore:(X)=>R4(X),inspectElement:(X)=>I4(X),highlightComponent:(X)=>m6(X),clearHighlight:()=>p6(),logComponentTree:()=>D4(),logStoreState:(X)=>w4(X),timeTravel:(X,Q)=>T4(X,Q)},k4(),C4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function E4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function f6($){if(!P.enabled)return;let X=P.components.get($);if(X){if(X.parentId){let Q=P.components.get(X.parentId);if(Q)Q.children=Q.children.filter((Z)=>Z!==$)}P.components.delete($),Y5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function d6($,X,Q={},Z=[]){if(!P.enabled)return;let Y={id:$,state:X,getters:Q,actions:Z,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};P.stores.set($,Y),Y5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function u6($,X,Q,Z,Y="state"){if(!P.enabled)return;let J=P.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Q,newValue:Z,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Z};Y5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function Y5($){if(!P.enabled)return;if(P.events.push($),P.events.length>P.maxEvents)P.events=P.events.slice(-P.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function J5($){P.selectedComponent=$;let X=P.components.get($);if(X)m6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function R4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function I4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return J5(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function m6($){p6();let X=P.components.get($);if(X?.element){let Q=document.createElement("div");Q.id="stx-devtools-highlight",Q.style.cssText=`
1615
+ Press ${B.cyan}h${B.reset} + ${B.cyan}Enter${B.reset} to show shortcuts`),x0(g1.url.toString(),()=>{if(J)A1();g1.stop()}),X.native){let D,T=g.join(z,"index.stx");if(J0.existsSync(T)){let S=await Bun.file(T).text();D=o1(S)}let x=_?.app?.window??{};await t0(W0,{title:_?.app?.head?.title||g.basename(W)||"stx App",width:x.width,height:x.height,darkMode:x.darkMode,hotReload:x.hotReload,titlebarHidden:x.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!D,sidebarConfig:D})}if(Z){console.log(`${B.blue}Watching for changes...${B.reset}`);let D=(S)=>{return S.startsWith("public/")||S.startsWith("public\\")},T=(S)=>{let b=S.toLowerCase();return b.endsWith(".stx")||b.endsWith(".html")||b.endsWith(".md")},x=J0.watch(W,{recursive:!0},async(S,b)=>{if(!b||$$(b))return;if(e1(b))if(D(b)){if(console.log(`${B.cyan}${b} changed${B.reset}`),Y&&J)J.reload(b)}else if(T(b)){console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:_0,templateCache:K0}=await import("./chunk-v7p71v7b.js");_0(g.resolve(W,b)),K0.delete(g.resolve(W,b))}catch{}if(A&&b){if(g.resolve(W,b)===A||g.basename(A)===b){let K0=await Q5(A,X.stxOptions||{});if(K0)q=K0}}if(await t(),await K$(W),Y&&J)J.reload(b)}else{console.log(`${B.yellow}${b} changed, rebuilding...${B.reset}`),m0.clear(),p0();try{let{invalidateFileCache:_0,templateCache:K0}=await import("./chunk-v7p71v7b.js");_0(g.resolve(W,b)),K0.delete(g.resolve(W,b))}catch{}if(await t(),Y&&J)J.reload(b)}else if(t1(b)){if(console.log(`${B.cyan}CSS ${b} changed${B.reset}`),Y&&J)J.updateCss(b)}});process.on("SIGINT",()=>{if(x.close(),J)A1();g1.stop(),process.exit(0)})}return!0}var P={enabled:!1,components:new Map,stores:new Map,events:[],performance:[],selectedComponent:null,selectedStore:null,maxEvents:1000,maxPerformance:500};function V4($={}){if(typeof window>"u")return;P.enabled=!0,P.maxEvents=$.maxEvents||1000,P.maxPerformance=$.maxPerformance||500,window.__STX_DEVTOOLS__={getState:()=>P,getComponents:()=>Array.from(P.components.values()),getComponent:(X)=>P.components.get(X),getStores:()=>Array.from(P.stores.values()),getStore:(X)=>P.stores.get(X),getEvents:()=>P.events,getPerformance:()=>P.performance,selectComponent:(X)=>J5(X),selectStore:(X)=>R4(X),inspectElement:(X)=>I4(X),highlightComponent:(X)=>m6(X),clearHighlight:()=>p6(),logComponentTree:()=>D4(),logStoreState:(X)=>w4(X),timeTravel:(X,Q)=>T4(X,Q)},k4(),C4(),console.log("%c[STX DevTools] Enabled","color: #10b981; font-weight: bold;")}function E4(){P.enabled=!1,delete window.__STX_DEVTOOLS__;let $=document.getElementById("stx-devtools-panel");if($)$.remove();console.log("%c[STX DevTools] Disabled","color: #ef4444;")}function f6($){if(!P.enabled)return;let X=P.components.get($);if(X){if(X.parentId){let Q=P.components.get(X.parentId);if(Q)Q.children=Q.children.filter((Z)=>Z!==$)}P.components.delete($),Y5({timestamp:Date.now(),type:"component:unmounted",componentId:$,payload:{name:X.name}})}}function d6($,X,Q={},Z=[]){if(!P.enabled)return;let Y={id:$,state:X,getters:Q,actions:Z,history:[{timestamp:Date.now(),type:"state",name:"__init__",newValue:X}]};P.stores.set($,Y),Y5({timestamp:Date.now(),type:"store:registered",payload:{id:$,state:X}})}function u6($,X,Q,Z,Y="state"){if(!P.enabled)return;let J=P.stores.get($);if(J){let G={timestamp:Date.now(),type:Y,name:X,oldValue:Q,newValue:Z,stack:Error().stack};if(J.history.push(G),J.history.length>100)J.history=J.history.slice(-100);if(Y==="state")J.state={...J.state,[X]:Z};Y5({timestamp:Date.now(),type:`store:${Y}`,payload:{storeId:$,name:X,oldValue:Q,newValue:Z}})}}function Y5($){if(!P.enabled)return;if(P.events.push($),P.events.length>P.maxEvents)P.events=P.events.slice(-P.maxEvents);if(typeof window<"u")window.dispatchEvent(new CustomEvent("stx:devtools:event",{detail:$}))}function J5($){P.selectedComponent=$;let X=P.components.get($);if(X)m6($),console.log("%c[STX DevTools] Selected component:","color: #3b82f6;",X);return X}function R4($){P.selectedStore=$;let X=P.stores.get($);if(X)console.log("%c[STX DevTools] Selected store:","color: #8b5cf6;",X);return X}function I4($){let X=$;while(X){let Q=X.getAttribute("data-stx-component-id");if(Q)return J5(Q);X=X.parentElement}console.log("%c[STX DevTools] No component found for element","color: #f59e0b;");return}function m6($){p6();let X=P.components.get($);if(X?.element){let Q=document.createElement("div");Q.id="stx-devtools-highlight",Q.style.cssText=`
1616
1616
  position: absolute;
1617
1617
  background: rgba(59, 130, 246, 0.2);
1618
1618
  border: 2px solid #3b82f6;
@@ -2881,9 +2881,9 @@ describe('Example', () => {
2881
2881
  </footer>
2882
2882
  @yield('scripts')
2883
2883
  </body>
2884
- </html>`}function iX(){return"<!-- Hero section -->"}function aX(){return"<!-- Features -->"}function rX(){return"<!-- Pricing -->"}function sX(){return"<!-- Button -->"}function C1($){if(!T1($))L5($,{recursive:!0})}function nX(){if(T1("bun.lockb"))return"bun";if(T1("pnpm-lock.yaml"))return"pnpm";if(T1("yarn.lock"))return"yarn";return"bun"}function F5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function oX($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function c0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:tX}=globalThis.Bun;import k1 from"fs";import y0 from"path";function p2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function J8($){let{loadStxConfig:X}=await import("./chunk-k5c19t7e.js");return{...await X($.configDir??process.cwd()).catch(()=>({})),...$.stxOptions??{}}}async function eX($={}){let{port:X=3000,root:Q=".",watch:Z=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=y0.resolve(Q),U=await J8($),F=new Map;async function z(A){let N=k1.statSync(A),V=`${A}:${N.mtimeMs}`,M=F.get(V);if(M)return{content:M.content,status:M.status,headers:M.headers};for(let T of F.keys())if(T.startsWith(`${A}:`)&&T!==V)F.delete(T);let R=await Bun.file(A).text(),w=R,C=Z$(R);if(C)w=C.content.trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],h=[],u;while((u=I.exec(R))!==null){let T=u[1],x=u[2],S=u[0];if(T.includes("server"))h.push(x);else E.push(S)}let t=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],d5=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),W0={__filename:A,__dirname:y0.dirname(A)};for(let T of h)await j0(T,W0,A);let q0=await O0(d5,W0,A,U,new Set);if(t.length>0){let T=t.join(`
2884
+ </html>`}function iX(){return"<!-- Hero section -->"}function aX(){return"<!-- Features -->"}function rX(){return"<!-- Pricing -->"}function sX(){return"<!-- Button -->"}function C1($){if(!T1($))L5($,{recursive:!0})}function nX(){if(T1("bun.lockb"))return"bun";if(T1("pnpm-lock.yaml"))return"pnpm";if(T1("yarn.lock"))return"yarn";return"bun"}function F5($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function oX($){return $.replace(/[-_\s]+(.)?/g,(X,Q)=>Q?Q.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function c0($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var{serve:tX}=globalThis.Bun;import k1 from"fs";import y0 from"path";function p2($,X=200,Q={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Q}})}async function J8($){let{loadStxConfig:X}=await import("./chunk-jjgkbz91.js");return{...await X($.configDir??process.cwd()).catch(()=>({})),...$.stxOptions??{}}}async function eX($={}){let{port:X=3000,root:Q=".",watch:Z=!0,onRequest:Y,routes:J={},middleware:G=[],on404:W,onError:K}=$,_=y0.resolve(Q),U=await J8($),F=new Map;async function z(A){let N=k1.statSync(A),V=`${A}:${N.mtimeMs}`,M=F.get(V);if(M)return{content:M.content,status:M.status,headers:M.headers};for(let T of F.keys())if(T.startsWith(`${A}:`)&&T!==V)F.delete(T);let R=await Bun.file(A).text(),w=R,C=Z$(R);if(C)w=C.content.trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],h=[],u;while((u=I.exec(R))!==null){let T=u[1],x=u[2],S=u[0];if(T.includes("server"))h.push(x);else E.push(S)}let t=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],d5=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),W0={__filename:A,__dirname:y0.dirname(A)};for(let T of h)await j0(T,W0,A);let q0=await O0(d5,W0,A,U,new Set);if(t.length>0){let T=t.join(`
2885
2885
  `);if(q0.match(/(<\/head>)/i))q0=q0.replace(/(<\/head>)/i,`${T}
2886
- $1`)}if(E.length>0){let{interpolateScriptsInTemplate:T}=await import("./chunk-cd4v7xyr.js"),x=T(E.join(`
2886
+ $1`)}if(E.length>0){let{interpolateScriptsInTemplate:T}=await import("./chunk-kva81xy0.js"),x=T(E.join(`
2887
2887
  `),W0);if(q0.match(/(<\/body>)/i))q0=q0.replace(/(<\/body>)/i,`${x}
2888
2888
  $1`);else q0+=`
2889
2889
  ${x}`}let a0=N1(W0),D=M1(W0);return F.set(V,{content:q0,mtime:N.mtimeMs,status:a0,headers:D}),{content:q0,status:a0,headers:D}}async function j(A){let N=k1.statSync(A),V=`${A}:${N.mtimeMs}`,M=F.get(V);if(M)return M.content;let{content:R}=await V0(A,U);return F.set(V,{content:R,mtime:N.mtimeMs}),R}function O(A){let N=A.startsWith("/")?A.slice(1):A,V=[N,`${N}.stx`,`${N}.md`,`${N}.html`,y0.join(N,"index.stx"),y0.join(N,"index.md"),y0.join(N,"index.html")];for(let M of V){let R=y0.join(_,M);if(k1.existsSync(R)&&k1.statSync(R).isFile())return R}return null}async function L(A){let N=new URL(A.url),V=async()=>{if(J[N.pathname])return await J[N.pathname](A);if(Y){let R=await Y(A);if(R)return R}let M=O(N.pathname);if(!M){if(W)return await W(A);return new Response("Not Found",{status:404})}try{let R,w="text/html",C,I;if(M.endsWith(".stx")){let E=await z(M);R=E.content,C=E.status,I=E.headers}else if(M.endsWith(".md"))R=await j(M);else if(M.endsWith(".html"))R=await Bun.file(M).text();else if(M.endsWith(".css"))R=await Bun.file(M).text(),w="text/css";else if(M.endsWith(".js"))R=await Bun.file(M).text(),w="text/javascript";else if(M.endsWith(".json"))R=await Bun.file(M).text(),w="application/json";else return new Response(Bun.file(M));return new Response(R,{status:C??200,headers:{"Content-Type":w,...I}})}catch(R){if(K)return await K(R,A);let w=R instanceof Error?R.message:String(R),I=U?.debug===!0?`<h1>Error</h1><pre>${w}
@@ -4315,7 +4315,7 @@ else {
4315
4315
  \u26A0\uFE0F Built ${Q.views.length} views with ${Q.errors.length} errors`);return Q}function Z9($,X){let Q=V$.watch($.viewsDir,{recursive:!0},async(Z,Y)=>{if(!Y)return;if(Y.endsWith(".stx")||Y.endsWith(".ts")||Y.endsWith(".js")){if($.debug)console.log(`
4316
4316
  File changed: ${Y}, rebuilding...`);let J=await VZ($);X?.(J)}});return{close:()=>Q.close()}}async function Y9($,X={},Q={}){let Z={...Q,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},Y=await V7($,X,Z);Y=await EZ(Y),Y=Y.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),Y=Y.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),Y=Y.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),Y=Y.replace(/\n\s*\n\s*\n/g,`
4317
4317
 
4318
- `).trim();let J=IZ(Y);return{html:Y,text:J}}async function EZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-mcn9mwzv.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=RZ(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let q of z){let A=J.get(q);if(A)j.push(A)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let O=j.join("; "),H=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(H){let q=`${O}; ${H[1]}`,A=K.replace(/style\s*=\s*"[^"]*"/,`style="${q}"`),N=U.replace(/style\s*=\s*"[^"]*"/,`style="${q}"`);return`${W}${A}class="${_}"${N}${F}`}return`${W}${K}class="${_}" style="${O}"${U}${F}`})}catch{return $}}function RZ($){let X=new Map,Q=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Z=Q.exec($);while(Z!==null){let Y=Z[1].replace(/\\/g,""),J=Z[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Z=Q.exec($)}return X}function IZ($){return $.replace(/<br\s*\/?>/gi,`
4318
+ `).trim();let J=IZ(Y);return{html:Y,text:J}}async function EZ($){try{let{generateCrosswindCSS:X,extractClassNames:Q}=await import("./chunk-b4q2zzyq.js");if(Q($).size===0)return $;let Y=await X($);if(!Y)return $;let J=RZ(Y);if(J.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,W,K,_,U,F)=>{let z=_.split(/\s+/).filter(Boolean),j=[];for(let q of z){let A=J.get(q);if(A)j.push(A)}if(j.length===0)return`${W}${K}class="${_}"${U}${F}`;let O=j.join("; "),H=`${K}${U}`.match(/style\s*=\s*"([^"]*)"/);if(H){let q=`${O}; ${H[1]}`,A=K.replace(/style\s*=\s*"[^"]*"/,`style="${q}"`),N=U.replace(/style\s*=\s*"[^"]*"/,`style="${q}"`);return`${W}${A}class="${_}"${N}${F}`}return`${W}${K}class="${_}" style="${O}"${U}${F}`})}catch{return $}}function RZ($){let X=new Map,Q=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,Z=Q.exec($);while(Z!==null){let Y=Z[1].replace(/\\/g,""),J=Z[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(J)X.set(Y,J);Z=Q.exec($)}return X}function IZ($){return $.replace(/<br\s*\/?>/gi,`
4319
4319
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
4320
4320
  `).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&copy;/g,"(c)").replace(/&middot;/g,"-").replace(/\n\s*\n\s*\n/g,`
4321
4321
 
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Pf as p}from"./chunk-z86pq9pd.js";import{Hg as a,Jg as JF,Kg as ZF,Lg as qF}from"./chunk-r8qvm7a3.js";import{sj as C,tj as D}from"./chunk-gej3rmfy.js";import{Ek as QF,Fk as XF,Gk as YF}from"./chunk-58f0mthg.js";import{$o as o,Bq as FF,Fq as c,Nm as u,as as n,cs as N,fm as l,gq as e,hm as d,uq as t}from"./chunk-mbvkvac6.js";import{gt as r}from"./chunk-jb7h4qgh.js";import{Mu as S,Ou as WF}from"./chunk-5wkwhjjn.js";import G from"fs";import Z from"path";import{createHash as $F}from"crypto";WF();function g(J){return $F("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function UF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as GF}from"crypto";function VF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function i(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=GF("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>p($))),{context:E}=VF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...n,...K,...z,buildMode:"compile",strict:!1},w=await c(X,E,Q,_,L),U=a(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,status:u(X),streamTemplates:E.__streamTemplates}}var kF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function s(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(kF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function lF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=o(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await i(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=FF(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=e(F.html,W);if(k.htmlAttrs)F.html=t(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await r(F.html),F.fragment=JF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=s(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=YF(z);if(v){let{copied:Y,bytes:F}=s(v,Z.join(Q,"public",XF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${QF}/`)}let R={runtime:H.filename,router:$.filename},zF=ZF(j,R,Q);qF(zF,Q);let x=Date.now()-q;return console.log(`
2
+ import{Pf as p}from"./chunk-7r501aag.js";import{Hg as a,Jg as JF,Kg as ZF,Lg as qF}from"./chunk-fbtcegdp.js";import{sj as C,tj as D}from"./chunk-gej3rmfy.js";import{Ek as QF,Fk as XF,Gk as YF}from"./chunk-58f0mthg.js";import{$o as o,Bq as FF,Fq as c,Nm as u,as as n,cs as N,fm as l,gq as e,hm as d,uq as t}from"./chunk-3yvmfwa9.js";import{gt as r}from"./chunk-95fvybb4.js";import{Mu as S,Ou as WF}from"./chunk-5wkwhjjn.js";import G from"fs";import Z from"path";import{createHash as $F}from"crypto";WF();function g(J){return $F("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function UF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as GF}from"crypto";function VF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function i(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=GF("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>p($))),{context:E}=VF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...n,...K,...z,buildMode:"compile",strict:!1},w=await c(X,E,Q,_,L),U=a(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,status:u(X),streamTemplates:E.__streamTemplates}}var kF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function s(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(kF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function lF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=o(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await i(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=FF(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=e(F.html,W);if(k.htmlAttrs)F.html=t(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await r(F.html),F.fragment=JF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=s(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=YF(z);if(v){let{copied:Y,bytes:F}=s(v,Z.join(Q,"public",XF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${QF}/`)}let R={runtime:H.filename,router:$.filename},zF=ZF(j,R,Q);qF(zF,Q);let x=Date.now()-q;return console.log(`
3
3
  [stx build] Done in ${x}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:R,outputDir:Q,duration:x}}
4
4
  export{g as Ff,f as Gf,m as Hf,UF as If,i as Jf,lF as Kf};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Lf as v,Mf as i,Nf as t,Qf as e,Rf as HH,Sf as KH,Tf as QH,Uf as YH,Vf as ZH}from"./chunk-z86pq9pd.js";import{Xi as s}from"./chunk-6g7m08rv.js";import{Ql as a}from"./chunk-mbvkvac6.js";import{st as h}from"./chunk-bby4emay.js";import{Nt as f}from"./chunk-sde45gh3.js";import{existsSync as $H,readFileSync as qH}from"fs";import J from"path";function GH(K,Q="",V=""){let L=K.startLine>1?`
2
+ import{Lf as v,Mf as i,Nf as t,Qf as e,Rf as HH,Sf as KH,Tf as QH,Uf as YH,Vf as ZH}from"./chunk-7r501aag.js";import{Xi as s}from"./chunk-mghvh852.js";import{Ql as a}from"./chunk-3yvmfwa9.js";import{st as h}from"./chunk-bby4emay.js";import{Nt as f}from"./chunk-sde45gh3.js";import{existsSync as $H,readFileSync as qH}from"fs";import J from"path";function GH(K,Q="",V=""){let L=K.startLine>1?`
3
3
  `.repeat(K.startLine-1):"",N=t(i(K.code)),X=K.kind==="client"||K.kind==="plain"?HH(Q,K.code):"";return QH(`${L+N}
4
4
  ${X}
5
5
  export {}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Xi as a,Yi as b,Zi as c}from"./chunk-6g7m08rv.js";import"./chunk-9n0gvfrg.js";import"./chunk-mbvkvac6.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-jb7h4qgh.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{a as listComposableModules,b as getComposableScript,c as clearComposableCache};
2
+ import{Xi as a,Yi as b,Zi as c}from"./chunk-mghvh852.js";import"./chunk-9n0gvfrg.js";import"./chunk-3yvmfwa9.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-95fvybb4.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{a as listComposableModules,b as getComposableScript,c as clearComposableCache};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{dp as a,ep as b,fp as c,gp as d,hp as e,ip as f,jp as g,kp as h,lp as i,mp as j,np as k,op as l}from"./chunk-mbvkvac6.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-jb7h4qgh.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{l as stripStxRuntimeImports,a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};
2
+ import{dp as a,ep as b,fp as c,gp as d,hp as e,ip as f,jp as g,kp as h,lp as i,mp as j,np as k,op as l}from"./chunk-3yvmfwa9.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-95fvybb4.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{l as stripStxRuntimeImports,a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ql as C}from"./chunk-mbvkvac6.js";import{Ks as Y}from"./chunk-f1jd5qjb.js";import{Nt as D}from"./chunk-sde45gh3.js";import u from"path";var S=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function h(K){let J=(Q)=>Q.replace(/[^\n]/g," ");return K.replace(/<!--[\s\S]*?-->/g,J).replace(/\{\{--[\s\S]*?--\}\}/g,J)}function m(K){let J=[],Q=h(K);S.lastIndex=0;let $;while(($=S.exec(Q))!==null){let j=($[1]||"").trim(),F=($[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,z=($[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,W=$.index+F,Z=$.index+$[0].length-z,G=K.slice(W,Z);if(/\bsrc\s*=/.test(j))continue;let q=j.match(/\btype\s*=\s*["']([^"']+)["']/i);if(q&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(q[1]))continue;let X=/\bserver\b/.test(j)?"server":/\bclient\b/.test(j)?"client":"plain",U=B(K,W);J.push({kind:X,code:G,startLine:U,attrs:j})}return J}function B(K,J){let Q=1;for(let $=0;$<J&&$<K.length;$++)if(K.charCodeAt($)===10)Q++;return Q}function N(K,J){let Q=K.lastIndexOf(`
2
+ import{Ql as C}from"./chunk-3yvmfwa9.js";import{Ks as Y}from"./chunk-f1jd5qjb.js";import{Nt as D}from"./chunk-sde45gh3.js";import u from"path";var S=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function h(K){let J=(Q)=>Q.replace(/[^\n]/g," ");return K.replace(/<!--[\s\S]*?-->/g,J).replace(/\{\{--[\s\S]*?--\}\}/g,J)}function m(K){let J=[],Q=h(K);S.lastIndex=0;let $;while(($=S.exec(Q))!==null){let j=($[1]||"").trim(),F=($[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,z=($[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,W=$.index+F,Z=$.index+$[0].length-z,G=K.slice(W,Z);if(/\bsrc\s*=/.test(j))continue;let q=j.match(/\btype\s*=\s*["']([^"']+)["']/i);if(q&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(q[1]))continue;let X=/\bserver\b/.test(j)?"server":/\bclient\b/.test(j)?"client":"plain",U=B(K,W);J.push({kind:X,code:G,startLine:U,attrs:j})}return J}function B(K,J){let Q=1;for(let $=0;$<J&&$<K.length;$++)if(K.charCodeAt($)===10)Q++;return Q}function N(K,J){let Q=K.lastIndexOf(`
3
3
  `,J-1)+1;return J-Q+1}function g(K){let J=K.split(""),Q=(j,F)=>{for(let z=j;z<F&&z<J.length;z++)if(J[z]!==`
4
4
  `)J[z]=" "},$=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let j of $){j.lastIndex=0;let F;while((F=j.exec(K))!==null)Q(F.index,F.index+F[0].length)}return J.join("")}function p(K){let J=0,Q="";for(let $=0;$<K.length;$++){let j=K[$];if(Q){if(j==="\\"){$++;continue}if(j===Q)Q="";continue}if(j==='"'||j==="'"||j==="`"){Q=j;continue}if(j==="("||j==="["||j==="{"){J++;continue}if(j===")"||j==="]"||j==="}"){J--;continue}if(j==="|"&&J===0){if(K[$+1]==="|"){$++;continue}if(K[$-1]==="|")continue;return K.slice(0,$)}}return K}var R=new Set([":for","x-for","v-for"]),w=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,O="__stx_interpolated",y="__StxElement",f="__StxTemplateValue",l=`type ${f}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function L(K){return K.replace(/\{\{[\s\S]*?\}\}/g,O).replace(/\{!![\s\S]*?!!\}/g,O)}function Vj(K){return K.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(J)=>{let Q=J.split(`
5
5
  `).length-1,$=J.length-Q;return`0${" ".repeat(Math.max(0,$-1))}${`
@@ -11,7 +11,7 @@ catch (e) {
11
11
  }
12
12
  throw e;
13
13
  }
14
- `),Z.set(X,V)}return V(...W)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:U,context:J.slice()});return U}clear(){this.pool.length=0,this.fnCache.clear()}}var pJ=new qJ;class UJ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(Q){this.enabled=Q}isEnabled(){return this.enabled}setBudget(Q,J){this.budgets.set(Q,{warnThreshold:0.8,action:"warn",...J})}setBudgets(Q){for(let[J,Y]of Object.entries(Q))this.setBudget(J,Y)}removeBudget(Q){this.budgets.delete(Q)}getBudgets(){let Q={};for(let[J,Y]of this.budgets.entries())Q[J]=Y;return Q}onViolation(Q){this.violationHandlers.push(Q)}offViolation(Q){let J=this.violationHandlers.indexOf(Q);if(J!==-1)this.violationHandlers.splice(J,1)}time(Q,J){if(!this.enabled)return J();let Y=performance.now(),$=J(),Z=performance.now()-Y;return this.recordTime(Q,Z),this.checkBudget(Q,Z),$}async timeAsync(Q,J){if(!this.enabled)return J();let Y=performance.now(),$=await J(),Z=performance.now()-Y;return this.recordTime(Q,Z),this.checkBudget(Q,Z),$}checkBudget(Q,J){let Y=this.budgets.get(Q);if(!Y)return;let $=J/Y.maxTime*100,Z=Y.warnThreshold!==void 0?J>=Y.maxTime*Y.warnThreshold&&J<Y.maxTime:!1,q=J>=Y.maxTime;if(!Z&&!q)return;let U={label:Q,actualTime:J,budgetTime:Y.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:Z};this.violations.push(U);while(this.violations.length>this.maxViolations)this.violations.shift();for(let G of this.violationHandlers)try{G(U)}catch{}let W=Z?`[Performance Warning] "${Q}" took ${J.toFixed(2)}ms (${$.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${Q}" took ${J.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(W);break;case"warn":console.warn(W);break;case"error":console.error(W);break;case"throw":if(q)throw Error(W);else console.warn(W);break}}recordTime(Q,J){let Y=this.metrics.get(Q);if(Y)Y.count++,Y.totalTime+=J,Y.maxTime=Math.max(Y.maxTime,J),Y.minTime=Math.min(Y.minTime,J);else this.metrics.set(Q,{count:1,totalTime:J,maxTime:J,minTime:J})}getStats(Q){if(Q){let Y=this.metrics.get(Q);if(!Y)return{};let $=this.budgets.get(Q);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:$?.maxTime,budgetUtilization:$?Y.totalTime/Y.count/$.maxTime*100:void 0}}let J={};for(let[Y,$]of this.metrics.entries()){let Z=this.budgets.get(Y);J[Y]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:Z?.maxTime,budgetUtilization:Z?$.totalTime/$.count/Z.maxTime*100:void 0}}return J}getViolations(Q){if(Q)return this.violations.filter((J)=>J.label===Q);return[...this.violations]}getViolationStats(){let Q={},J=0,Y=0;for(let $ of this.violations)if(Q[$.label]=(Q[$.label]||0)+1,$.isWarning)J++;else Y++;return{total:this.violations.length,byLabel:Q,warnings:J,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var h=null;function zJ(){if(!h)h=new UJ;return h}var gJ=new Proxy({},{get(Q,J){return zJ()[J]}});var WJ=[];function FJ(Q){let J=new c(Q);return WJ.push(J),J}function hJ(){for(let Q of WJ)Q.clear()}function i(Q,...J){return`${J.map((Y)=>String(Y??"")).join("\x00")}\x00${Q.length}\x00${Bun.hash(Q)}`}function cJ(Q){let J=[];for(let Y of new Set(Q))try{J.push({path:Y,mtimeMs:OJ.statSync(Y).mtimeMs})}catch{}return J}function iJ(Q){for(let J of Q)try{if(OJ.statSync(J.path).mtimeMs!==J.mtimeMs)return!1}catch{return!1}return!0}var L=null,n=!1,I=null,M="",K=!1,IJ=256,z=new Map,j=new Map,H=null,w=null;function k(Q){return Bun.hash(Q).toString(16).padStart(16,"0").slice(0,16)}function l(Q,J){if(z.has(Q))z.delete(Q);else if(z.size>=IJ)z.delete(z.keys().next().value);z.set(Q,J)}function HJ(Q){let J=k(Q);if(j.has(J))j.delete(J);else if(j.size>=IJ)j.delete(j.keys().next().value);return j.set(J,Q),J}function eJ(Q){let J=j.get(Q);if(J===void 0)return;return j.delete(Q),j.set(Q,J),J}async function TJ(Q){if(!H)return null;try{let J=Bun.file(O.join(H,`cw-${k(Q)}.css`));if(!await J.exists())return null;return await J.text()}catch{return null}}async function BJ(Q,J){if(!H)return;try{if(!fs.existsSync(H))fs.mkdirSync(H,{recursive:!0});await Bun.write(O.join(H,`cw-${k(Q)}.css`),J)}catch{}}async function GJ(Q){try{let J=await import(Q);if(J&&J.CSSGenerator)return{CSSGenerator:J.CSSGenerator,config:J.config,build:J.build,defaultConfig:J.defaultConfig,extractClasses:J.extractClasses}}catch{}return null}function KJ(){let Q=[],J=process.cwd();while(J!==O.dirname(J))Q.push(O.join(J,"node_modules","@cwcss","crosswind","dist","index.js")),Q.push(O.join(J,"node_modules","@cwcss","crosswind","src","index.ts")),Q.push(O.join(J,"pantry","@cwcss","crosswind","dist","index.js")),Q.push(O.join(J,"pantry","@cwcss","crosswind","src","index.ts")),Q.push(O.join(J,"node_modules","@stacksjs","crosswind","dist","index.js")),Q.push(O.join(J,"pantry","@stacksjs","crosswind","dist","index.js")),J=O.dirname(J);return Q}function RJ(){let Q=[],J=process.env.HOME||process.env.USERPROFILE||"";if(J){let Y=[O.join(J,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),O.join(J,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),O.join(J,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),O.join(J,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),O.join(J,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),O.join(J,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];Q.push(...Y)}return Q.push(O.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),Q.push(O.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),Q}async function XJ(){if(n)return L;n=!0;try{let Q=async(Z)=>{for(let q of Z){if(!await Bun.file(q).exists())continue;let U=await GJ(q);if(U){if(!process.env.STACKS_DEV_QUIET)console.log(`${F.green}[Crosswind]${F.reset} CSS engine loaded from ${O.dirname(O.dirname(q))}`);return U}}return null};if(process.env.CROSSWIND_SRC){let Z=O.resolve(process.env.CROSSWIND_SRC),q=await Q([Z]);if(!q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Z}`);return L=q,L}let J=await Q(KJ());if(J)return L=J,L;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Z of Y){let q=await GJ(Z);if(q){if(L=q,!process.env.STACKS_DEV_QUIET)console.log(`${F.green}[Crosswind]${F.reset} CSS engine loaded`);return L}}let $=await Q(RJ());if($)return L=$,L;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${F.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${F.reset}`),console.warn(`${F.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${F.reset}`),null}}function JQ(){x.clear(),z.clear(),j.clear()}function QQ(){x.clear(),L=null,n=!1,I=null,M="",z.clear(),j.clear(),w=null}async function VJ(Q){try{if(!AJ({name:"crosswind",cwd:Q}))return null;let{loadConfigWithResult:J}=await import("bunfig"),Y=await J({name:"crosswind",cwd:Q,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let $=O.relative(Q,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${F.green}[Crosswind]${F.reset} Loaded config from ${$||Y.path}`);return Y.config}catch(J){if(J instanceof Error&&J.name==="ConfigNotFoundError")return null;return console.warn(`${F.yellow}[Crosswind]${F.reset} Failed to load crosswind config:`,J instanceof Error?J.message:J),null}}async function PJ(Q){let J=null;try{let{loadStxConfig:Y}=await import("./chunk-k5c19t7e.js"),$=await Y(Q);if($.css)if(typeof $.css==="string"){let Z=O.isAbsolute($.css)?$.css:O.resolve(Q,$.css);if(await Bun.file(Z).exists()){let q=await import(Z);J=q.default||q,console.log(`${F.green}[Crosswind]${F.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(J={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let Z=O.isAbsolute($.css.config)?$.css.config:O.resolve(Q,$.css.config);if(await Bun.file(Z).exists()){let q=await import(Z);J={...q.default||q,...J}}}console.log(`${F.green}[Crosswind]${F.reset} Using inline CSS config from stx.config.ts`)}}catch{}return J||await VJ(Q)}function EJ(Q){try{let J=new WeakSet;return k(JSON.stringify(Q??{},(Y,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(J.has($))return"[circular]";J.add($)}return $})??"")}catch{return"unhashable"}}async function DJ(Q){if(K)return M;K=!0;try{let J=await XJ();if(!J||!J.build)return K=!1,"";if(!I)I=await VJ(Q);if(!I)return K=!1,"";let Y=J.defaultConfig?.theme||{},$=I.theme||{},Z={...J.defaultConfig,...I,theme:{...Y,...$,extend:{...Y.extend||{},...$.extend||{}}}},q=performance.now(),U=await J.build(Z),W=performance.now()-q;if(M=U.css,console.log(`${F.cyan}[Crosswind]${F.reset} Built ${U.classes.size} classes in ${W.toFixed(1)}ms`),Z.output){let G=O.isAbsolute(Z.output)?Z.output:O.join(Q,Z.output),X=O.dirname(G);if(!fs.existsSync(X))fs.mkdirSync(X,{recursive:!0});await Bun.write(G,U.css)}return K=!1,U.css}catch(J){return console.error(`${F.red}[Crosswind]${F.reset} Build error:`,J),K=!1,M}}async function YQ(Q){I=null,await DJ(Q)}function $Q(){return M}function MJ(Q){let J=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,$=Y.exec(Q);while($!==null){for(let U of $[1].split(/\s+/))if(U.trim())J.add(U.trim());$=Y.exec(Q)}let Z=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,q=Z.exec(Q);while(q!==null){let U=q[1].match(/'([^']+)'/g);if(U){for(let W of U)for(let G of W.slice(1,-1).split(/\s+/))if(G.trim())J.add(G.trim())}q=Z.exec(Q)}return J}var x=FJ(64);async function wJ(Q,J){let Y=x.get(i(Q,J,w));if(Y!==void 0)return Y;let $=await SJ(Q,J);if($)x.set(i(Q,J,w),$);return $}async function SJ(Q,J){try{let Y=await XJ();if(!Y)return"";let $=typeof Y.extractClasses==="function"?Y.extractClasses(Q):MJ(Q);if($.size===0)return"";let Z=J?O.resolve(J):process.cwd();if(!H)H=jJ(Z,"cache");let q=[...$].sort().join(" "),U=`${w||"default"}::${q}`,W=z.get(U);if(W!==void 0)return l(U,W),W;let G=await TJ(U);if(G!==null)return l(U,G),G;if(!I)I=await PJ(Z),w=EJ(I);let X=Y.defaultConfig||Y.config,V=I||{},A=ZJ(X,V),{safelist:T,includePreflight:R,minify:b,tokenCSS:LJ}=A,o=A.config,P=new Y.CSSGenerator(o);for(let N of T)P.generate(N);for(let N of $)P.generate(N);let _=P.toCSS(R,b),r=o.shortcuts||V.shortcuts||{};for(let[N,y]of Object.entries(r)){if(!$.has(N)&&!T.includes(N))continue;let f=y.split(/\s+/).filter(Boolean);for(let D of f)P.generate(D)}_=P.toCSS(R,b);let E=_.split(`
14
+ `),Z.set(X,V)}return V(...W)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:U,context:J.slice()});return U}clear(){this.pool.length=0,this.fnCache.clear()}}var pJ=new qJ;class UJ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(Q){this.enabled=Q}isEnabled(){return this.enabled}setBudget(Q,J){this.budgets.set(Q,{warnThreshold:0.8,action:"warn",...J})}setBudgets(Q){for(let[J,Y]of Object.entries(Q))this.setBudget(J,Y)}removeBudget(Q){this.budgets.delete(Q)}getBudgets(){let Q={};for(let[J,Y]of this.budgets.entries())Q[J]=Y;return Q}onViolation(Q){this.violationHandlers.push(Q)}offViolation(Q){let J=this.violationHandlers.indexOf(Q);if(J!==-1)this.violationHandlers.splice(J,1)}time(Q,J){if(!this.enabled)return J();let Y=performance.now(),$=J(),Z=performance.now()-Y;return this.recordTime(Q,Z),this.checkBudget(Q,Z),$}async timeAsync(Q,J){if(!this.enabled)return J();let Y=performance.now(),$=await J(),Z=performance.now()-Y;return this.recordTime(Q,Z),this.checkBudget(Q,Z),$}checkBudget(Q,J){let Y=this.budgets.get(Q);if(!Y)return;let $=J/Y.maxTime*100,Z=Y.warnThreshold!==void 0?J>=Y.maxTime*Y.warnThreshold&&J<Y.maxTime:!1,q=J>=Y.maxTime;if(!Z&&!q)return;let U={label:Q,actualTime:J,budgetTime:Y.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:Z};this.violations.push(U);while(this.violations.length>this.maxViolations)this.violations.shift();for(let G of this.violationHandlers)try{G(U)}catch{}let W=Z?`[Performance Warning] "${Q}" took ${J.toFixed(2)}ms (${$.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${Q}" took ${J.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(W);break;case"warn":console.warn(W);break;case"error":console.error(W);break;case"throw":if(q)throw Error(W);else console.warn(W);break}}recordTime(Q,J){let Y=this.metrics.get(Q);if(Y)Y.count++,Y.totalTime+=J,Y.maxTime=Math.max(Y.maxTime,J),Y.minTime=Math.min(Y.minTime,J);else this.metrics.set(Q,{count:1,totalTime:J,maxTime:J,minTime:J})}getStats(Q){if(Q){let Y=this.metrics.get(Q);if(!Y)return{};let $=this.budgets.get(Q);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:$?.maxTime,budgetUtilization:$?Y.totalTime/Y.count/$.maxTime*100:void 0}}let J={};for(let[Y,$]of this.metrics.entries()){let Z=this.budgets.get(Y);J[Y]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:Z?.maxTime,budgetUtilization:Z?$.totalTime/$.count/Z.maxTime*100:void 0}}return J}getViolations(Q){if(Q)return this.violations.filter((J)=>J.label===Q);return[...this.violations]}getViolationStats(){let Q={},J=0,Y=0;for(let $ of this.violations)if(Q[$.label]=(Q[$.label]||0)+1,$.isWarning)J++;else Y++;return{total:this.violations.length,byLabel:Q,warnings:J,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var h=null;function zJ(){if(!h)h=new UJ;return h}var gJ=new Proxy({},{get(Q,J){return zJ()[J]}});var WJ=[];function FJ(Q){let J=new c(Q);return WJ.push(J),J}function hJ(){for(let Q of WJ)Q.clear()}function i(Q,...J){return`${J.map((Y)=>String(Y??"")).join("\x00")}\x00${Q.length}\x00${Bun.hash(Q)}`}function cJ(Q){let J=[];for(let Y of new Set(Q))try{J.push({path:Y,mtimeMs:OJ.statSync(Y).mtimeMs})}catch{}return J}function iJ(Q){for(let J of Q)try{if(OJ.statSync(J.path).mtimeMs!==J.mtimeMs)return!1}catch{return!1}return!0}var L=null,n=!1,I=null,M="",K=!1,IJ=256,z=new Map,j=new Map,H=null,w=null;function k(Q){return Bun.hash(Q).toString(16).padStart(16,"0").slice(0,16)}function l(Q,J){if(z.has(Q))z.delete(Q);else if(z.size>=IJ)z.delete(z.keys().next().value);z.set(Q,J)}function HJ(Q){let J=k(Q);if(j.has(J))j.delete(J);else if(j.size>=IJ)j.delete(j.keys().next().value);return j.set(J,Q),J}function eJ(Q){let J=j.get(Q);if(J===void 0)return;return j.delete(Q),j.set(Q,J),J}async function TJ(Q){if(!H)return null;try{let J=Bun.file(O.join(H,`cw-${k(Q)}.css`));if(!await J.exists())return null;return await J.text()}catch{return null}}async function BJ(Q,J){if(!H)return;try{if(!fs.existsSync(H))fs.mkdirSync(H,{recursive:!0});await Bun.write(O.join(H,`cw-${k(Q)}.css`),J)}catch{}}async function GJ(Q){try{let J=await import(Q);if(J&&J.CSSGenerator)return{CSSGenerator:J.CSSGenerator,config:J.config,build:J.build,defaultConfig:J.defaultConfig,extractClasses:J.extractClasses}}catch{}return null}function KJ(){let Q=[],J=process.cwd();while(J!==O.dirname(J))Q.push(O.join(J,"node_modules","@cwcss","crosswind","dist","index.js")),Q.push(O.join(J,"node_modules","@cwcss","crosswind","src","index.ts")),Q.push(O.join(J,"pantry","@cwcss","crosswind","dist","index.js")),Q.push(O.join(J,"pantry","@cwcss","crosswind","src","index.ts")),Q.push(O.join(J,"node_modules","@stacksjs","crosswind","dist","index.js")),Q.push(O.join(J,"pantry","@stacksjs","crosswind","dist","index.js")),J=O.dirname(J);return Q}function RJ(){let Q=[],J=process.env.HOME||process.env.USERPROFILE||"";if(J){let Y=[O.join(J,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),O.join(J,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),O.join(J,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),O.join(J,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),O.join(J,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),O.join(J,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];Q.push(...Y)}return Q.push(O.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),Q.push(O.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),Q}async function XJ(){if(n)return L;n=!0;try{let Q=async(Z)=>{for(let q of Z){if(!await Bun.file(q).exists())continue;let U=await GJ(q);if(U){if(!process.env.STACKS_DEV_QUIET)console.log(`${F.green}[Crosswind]${F.reset} CSS engine loaded from ${O.dirname(O.dirname(q))}`);return U}}return null};if(process.env.CROSSWIND_SRC){let Z=O.resolve(process.env.CROSSWIND_SRC),q=await Q([Z]);if(!q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Z}`);return L=q,L}let J=await Q(KJ());if(J)return L=J,L;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Z of Y){let q=await GJ(Z);if(q){if(L=q,!process.env.STACKS_DEV_QUIET)console.log(`${F.green}[Crosswind]${F.reset} CSS engine loaded`);return L}}let $=await Q(RJ());if($)return L=$,L;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${F.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${F.reset}`),console.warn(`${F.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${F.reset}`),null}}function JQ(){x.clear(),z.clear(),j.clear()}function QQ(){x.clear(),L=null,n=!1,I=null,M="",z.clear(),j.clear(),w=null}async function VJ(Q){try{if(!AJ({name:"crosswind",cwd:Q}))return null;let{loadConfigWithResult:J}=await import("bunfig"),Y=await J({name:"crosswind",cwd:Q,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let $=O.relative(Q,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${F.green}[Crosswind]${F.reset} Loaded config from ${$||Y.path}`);return Y.config}catch(J){if(J instanceof Error&&J.name==="ConfigNotFoundError")return null;return console.warn(`${F.yellow}[Crosswind]${F.reset} Failed to load crosswind config:`,J instanceof Error?J.message:J),null}}async function PJ(Q){let J=null;try{let{loadStxConfig:Y}=await import("./chunk-jjgkbz91.js"),$=await Y(Q);if($.css)if(typeof $.css==="string"){let Z=O.isAbsolute($.css)?$.css:O.resolve(Q,$.css);if(await Bun.file(Z).exists()){let q=await import(Z);J=q.default||q,console.log(`${F.green}[Crosswind]${F.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(J={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let Z=O.isAbsolute($.css.config)?$.css.config:O.resolve(Q,$.css.config);if(await Bun.file(Z).exists()){let q=await import(Z);J={...q.default||q,...J}}}console.log(`${F.green}[Crosswind]${F.reset} Using inline CSS config from stx.config.ts`)}}catch{}return J||await VJ(Q)}function EJ(Q){try{let J=new WeakSet;return k(JSON.stringify(Q??{},(Y,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(J.has($))return"[circular]";J.add($)}return $})??"")}catch{return"unhashable"}}async function DJ(Q){if(K)return M;K=!0;try{let J=await XJ();if(!J||!J.build)return K=!1,"";if(!I)I=await VJ(Q);if(!I)return K=!1,"";let Y=J.defaultConfig?.theme||{},$=I.theme||{},Z={...J.defaultConfig,...I,theme:{...Y,...$,extend:{...Y.extend||{},...$.extend||{}}}},q=performance.now(),U=await J.build(Z),W=performance.now()-q;if(M=U.css,console.log(`${F.cyan}[Crosswind]${F.reset} Built ${U.classes.size} classes in ${W.toFixed(1)}ms`),Z.output){let G=O.isAbsolute(Z.output)?Z.output:O.join(Q,Z.output),X=O.dirname(G);if(!fs.existsSync(X))fs.mkdirSync(X,{recursive:!0});await Bun.write(G,U.css)}return K=!1,U.css}catch(J){return console.error(`${F.red}[Crosswind]${F.reset} Build error:`,J),K=!1,M}}async function YQ(Q){I=null,await DJ(Q)}function $Q(){return M}function MJ(Q){let J=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,$=Y.exec(Q);while($!==null){for(let U of $[1].split(/\s+/))if(U.trim())J.add(U.trim());$=Y.exec(Q)}let Z=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,q=Z.exec(Q);while(q!==null){let U=q[1].match(/'([^']+)'/g);if(U){for(let W of U)for(let G of W.slice(1,-1).split(/\s+/))if(G.trim())J.add(G.trim())}q=Z.exec(Q)}return J}var x=FJ(64);async function wJ(Q,J){let Y=x.get(i(Q,J,w));if(Y!==void 0)return Y;let $=await SJ(Q,J);if($)x.set(i(Q,J,w),$);return $}async function SJ(Q,J){try{let Y=await XJ();if(!Y)return"";let $=typeof Y.extractClasses==="function"?Y.extractClasses(Q):MJ(Q);if($.size===0)return"";let Z=J?O.resolve(J):process.cwd();if(!H)H=jJ(Z,"cache");let q=[...$].sort().join(" "),U=`${w||"default"}::${q}`,W=z.get(U);if(W!==void 0)return l(U,W),W;let G=await TJ(U);if(G!==null)return l(U,G),G;if(!I)I=await PJ(Z),w=EJ(I);let X=Y.defaultConfig||Y.config,V=I||{},A=ZJ(X,V),{safelist:T,includePreflight:R,minify:b,tokenCSS:LJ}=A,o=A.config,P=new Y.CSSGenerator(o);for(let N of T)P.generate(N);for(let N of $)P.generate(N);let _=P.toCSS(R,b),r=o.shortcuts||V.shortcuts||{};for(let[N,y]of Object.entries(r)){if(!$.has(N)&&!T.includes(N))continue;let f=y.split(/\s+/).filter(Boolean);for(let D of f)P.generate(D)}_=P.toCSS(R,b);let E=_.split(`
15
15
  `);for(let[N,y]of Object.entries(r)){if(!$.has(N)&&!T.includes(N))continue;let f=y.split(/\s+/).filter(Boolean),D=[],C=[];for(let p of f){let a=p.startsWith("dark:"),s=`.${(a?p.slice(5):p).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let S=0;S<E.length;S++){let t=E[S].trim();if(t===`${s} {`||t.startsWith(`${s} {`)){let v=S,e="";while(v<E.length){if(e+=E[v],E[v].includes("}"))break;v++}let g=e.match(/\{([^}]+)\}/);if(g)if(a)C.push(g[1].trim());else D.push(g[1].trim());break}}}if(D.length)_+=`
16
16
  .${N} { ${D.join(" ")} }`;if(C.length)_+=`
17
17
  @media (prefers-color-scheme: dark) { .dark .${N} { ${C.join(" ")} } }`}return _=LJ+_,l(U,_),BJ(U,_),_}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function ZQ(Q,J,Y=!1){let $=await wJ(Q,J);if(!$)return Q;let Z=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${HJ($)}.css">`:`<style data-crosswind="generated">
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fq as k,Hl as A,Il as D,Sm as T,Tm as y,Xo as x,_l as B,am as F,as as w,cp as M,tp as R}from"./chunk-mbvkvac6.js";import{Yu as P}from"./chunk-f8wjdg40.js";function b(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,X){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(X?.some((Y)=>q>=Y.start&&N<=Y.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,X)=>J.start-X.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function j(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>D(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as v,resolve as H}from"path";function f(K){let z=K,G=x(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],X=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],Y=$[2],E=$[0],Z=N.includes("server");if(X(Y))J.push(E);else if(Z)Q.push(Y);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,Y,E=[];while((Y=N.exec(q))!==null){let Z=Y.index+Y[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:Y.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
2
+ import{Fq as k,Hl as A,Il as D,Sm as T,Tm as y,Xo as x,_l as B,am as F,as as w,cp as M,tp as R}from"./chunk-3yvmfwa9.js";import{Yu as P}from"./chunk-f8wjdg40.js";function b(K){return K.endsWith(".md")||K.endsWith(".markdown")}function C(K){let z=[];_(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let G=[...z];_(/<code\b[^>]*>[\s\S]*?<\/code>/gi,G);function _(J,X){let $;while(($=J.exec(K))!==null){let q=$.index,N=q+$[0].length;if(X?.some((Y)=>q>=Y.start&&N<=Y.end))continue;z.push({start:q,end:N})}}if(z.length===0)return K;z.sort((J,X)=>J.start-X.start);let U="",Q=0;for(let J of z){if(J.start<Q)continue;U+=K.slice(Q,J.start),U+=`@raw${K.slice(J.start,J.end)}@endraw`,Q=J.end}return U+=K.slice(Q),U}async function j(K,z={}){let{data:G,content:_}=A(K),Q=await(z.renderer??((J)=>D(J)))(_);return{html:C(Q),frontmatter:G??{}}}import{dirname as v,resolve as H}from"path";function f(K){let z=K,G=x(K);if(G)z=G.content.trim();let _=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U=[],Q=[],J=[],X=(N)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(N),$;while(($=_.exec(K))!==null){let N=$[1],Y=$[2],E=$[0],Z=N.includes("server");if(X(Y))J.push(E);else if(Z)Q.push(Y);else U.push(E)}let q=z;{let N=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,Y,E=[];while((Y=N.exec(q))!==null){let Z=Y.index+Y[0].length,L=q.indexOf("</script>",Z);if(L===-1)continue;E.push({start:Y.index,end:L+9}),N.lastIndex=L+9}for(let Z=E.length-1;Z>=0;Z--)q=q.substring(0,E[Z].start)+q.substring(E[Z].end)}for(let N of U)q=q.replace(N,"");return{templateContent:q,serverScripts:Q,clientScripts:U,signalsScripts:J}}function g(K,z){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -14,5 +14,5 @@ ${Q.join(`
14
14
  `)}`}else{if(G.processClientScripts!==!1&&Q.length>0){let N=X.__stx_event_bindings||[],Y=B(X),Z=(await Promise.all(Q.map(async(V)=>{let W=V.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!W)return V;return await F(W[1],{eventBindings:N,templateContent:q,serverData:Y,filePath:z})}))).join(`
15
15
  `);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${Z}
16
16
  $1`);else q+=`
17
- ${Z}`}q=await M(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCrosswindCSS:N}=await import("./chunk-mcn9mwzv.js");q=await N(q)}catch{}return q}
17
+ ${Z}`}q=await M(q)}if(G.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=g(q,G.title)}if(G.injectCSS)try{let{injectCrosswindCSS:N}=await import("./chunk-b4q2zzyq.js");q=await N(q)}catch{}return q}
18
18
  export{b as qk,C as rk,j as sk,s as tk,i as uk,I as vk};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ig as a}from"./chunk-8vewrjzp.js";import"./chunk-mbvkvac6.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-jb7h4qgh.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{a as buildApp};
2
+ import{ig as a}from"./chunk-geb85szp.js";import"./chunk-3yvmfwa9.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-95fvybb4.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{a as buildApp};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$s as f,Ws as a,Xs as b,Ys as c,Zs as d,_s as e,at as g,bt as h,ct as i,dt as j,et as k,ft as l,gt as m}from"./chunk-jb7h4qgh.js";import"./chunk-bby4emay.js";import"./chunk-f8wjdg40.js";export{f as resolveUserCrosswindConfig,c as resetCssCache,d as resetCrosswindCache,i as rebuildCrosswindCSS,e as loadCrosswindConfig,b as loadCrosswind,m as injectCrosswindCSS,a as getCrosswindServeAsset,j as getCachedCSS,l as generateCrosswindCSS,g as fingerprintConfig,k as extractClassNames,h as buildCrosswindCSS};
2
+ import{$s as f,Ws as a,Xs as b,Ys as c,Zs as d,_s as e,at as g,bt as h,ct as i,dt as j,et as k,ft as l,gt as m}from"./chunk-95fvybb4.js";import"./chunk-bby4emay.js";import"./chunk-f8wjdg40.js";export{f as resolveUserCrosswindConfig,c as resetCssCache,d as resetCrosswindCache,i as rebuildCrosswindCSS,e as loadCrosswindConfig,b as loadCrosswind,m as injectCrosswindCSS,a as getCrosswindServeAsset,j as getCachedCSS,l as generateCrosswindCSS,g as fingerprintConfig,k as extractClassNames,h as buildCrosswindCSS};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fq as X,ym as W}from"./chunk-mbvkvac6.js";import V from"fs";import M from"path";import*as Y from"readline";var j={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},Q={help:{description:"Show available commands",usage:"help [command]",handler:async(q,z)=>{if(q[0]&&Q[q[0]]){let A=Q[q[0]];console.log(`
2
+ import{Fq as X,ym as W}from"./chunk-3yvmfwa9.js";import V from"fs";import M from"path";import*as Y from"readline";var j={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},Q={help:{description:"Show available commands",usage:"help [command]",handler:async(q,z)=>{if(q[0]&&Q[q[0]]){let A=Q[q[0]];console.log(`
3
3
  ${j.bold}${q[0]}${j.reset} - ${A.description}`),console.log(` Usage: ${j.cyan}${A.usage}${j.reset}
4
4
  `)}else{console.log(`
5
5
  ${j.bold}Available Commands:${j.reset}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{tk as m}from"./chunk-2qsa4h1t.js";import{Yu as z}from"./chunk-f8wjdg40.js";import{existsSync as s,mkdirSync as T,copyFileSync as F,chmodSync as A}from"fs";import{join as Z,basename as Yq}from"path";import{spawn as j,execSync as Zq}from"child_process";import{tmpdir as c,homedir as P,platform as Lq}from"os";var Iq=`
2
+ import{tk as m}from"./chunk-9xfnhnkn.js";import{Yu as z}from"./chunk-f8wjdg40.js";import{existsSync as s,mkdirSync as T,copyFileSync as F,chmodSync as A}from"fs";import{join as Z,basename as Yq}from"path";import{spawn as j,execSync as Zq}from"child_process";import{tmpdir as c,homedir as P,platform as Lq}from"os";var Iq=`
3
3
  <script>
4
4
  (function() {
5
5
  'use strict';
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lm as D,mm as O,yq as P}from"./chunk-mbvkvac6.js";import{Lu as c,Nu as h,Ou as i}from"./chunk-5wkwhjjn.js";import{Vu as p,Yu as d}from"./chunk-f8wjdg40.js";var R=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function C(z,Q,F){let J={fullTag:F,content:Q,attrs:z};if(/\bserver\b/.test(z))return{...J,type:"server"};if(/\bdata-stx-scoped\b/.test(z))return{...J,type:"client"};if(R.test(Q))return{...J,type:"signals"};if(/\bclient\b/.test(z)||/\btype\s*=\s*["']module["']/.test(z)||/\bsrc\s*=/.test(z))return{...J,type:"client"};return{...J,type:"server"}}var y=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function b(z){let Q=[],F=[],J=[],$=0;while($<z.length){let X=z.indexOf("<",$);if(X===-1)break;let j=O(z,X);if(j>X){$=j;continue}let Z=D(z,X);if(Z>X){let U=z.slice(X,Z),B=y.exec(U);if(B){let Y=C(B[1],B[2],U);switch(Y.type){case"signals":Q.push(Y);break;case"client":F.push(Y);break;case"server":J.push(Y);break}}$=Z;continue}$=X+(z.startsWith("<!--",X)?4:1)}return{signals:Q,client:F,server:J}}var S=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function f(z){let Q=[],F=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=F.exec(z))!==null)Q.push({start:J.index,end:J.index+J[0].length});return Q}function x(z,Q){return Q.some((F)=>z>=F.start&&z<F.end)}function u(z){let Q=(z||"").trim();if(!Q)return null;if(/[\s>+~,:]/.test(Q))return null;let F={},J=Q,$=J.match(/^[a-z][\w-]*/i);if($)F.tag=$[0].toLowerCase(),J=J.slice($[0].length);while(J.length>0){let X=J.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(X){if(F.attr=X[1],X[3]!==void 0&&X[3]!=="")F.attrValue=X[3];J=J.slice(X[0].length);continue}let j=J.match(/^#([\w-]+)/);if(j){F.id=j[1],J=J.slice(j[0].length);continue}let Z=J.match(/^\.([\w-]+)/);if(Z){F.className=Z[1],J=J.slice(Z[0].length);continue}return null}if(!F.tag&&!F.attr&&!F.id&&!F.className)return null;return F}function g(z,Q){if(Q.attr){if(!(Q.attrValue===void 0?new RegExp(`\\b${Q.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${Q.attr}\\s*=\\s*(["'])\\s*${Q.attrValue}\\s*\\1`,"i")).test(z))return!1}if(Q.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${Q.id}\\s*\\1`,"i").test(z))return!1}if(Q.className){let F=z.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!F)return!1;if(!F[2].split(/\s+/).includes(Q.className))return!1}return!0}function E(z,Q="main"){let F=u(Q);if(!F)return null;let J=/<([a-z][\w-]*)\b([^>]*)>/gi,$=f(z),X;while((X=J.exec(z))!==null){if(x(X.index,$))continue;let j=X[1].toLowerCase(),Z=X[2]||"";if(Z.trimEnd().endsWith("/")||S.has(j))continue;if(F.tag&&F.tag!==j)continue;if(!g(Z,F))continue;let U=X[0],B=X.index+U.length,Y=new RegExp(`<(/?)${j}\\b([^>]*)>`,"gi");Y.lastIndex=B;let W=1,G;while((G=Y.exec(z))!==null){if(x(G.index,$))continue;let w=G[1]==="/";if(!w&&(G[2]||"").trimEnd().endsWith("/"))continue;if(W+=w?-1:1,W===0)return{openTag:U,openIndex:X.index,start:B,end:G.index,tagName:j}}return null}return null}var t="X-STX-Router",zz="private, no-store";function M(z){return z.headers.get("X-STX-Router")==="true"}function m(z,Q){if(!z)return Q;return z.split(",").some((J)=>J.trim().toLowerCase()===Q.toLowerCase())?z:`${z}, ${Q}`}function Fz(z){return{Vary:m(z,"X-STX-Router")}}import _ from"path";c();var o="stx-page-head:",n=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v=null;function l(){if(v!==null)return v;try{let{getRouterScript:z}=(i(),p(h));v=`<script>${z()}</script>`}catch{v=""}return v}async function Bz(z,Q){if(Q===!1)return null;if(Q&&typeof Q==="string"){let J=_.resolve(z,Q);if(await Bun.file(J).exists())return J;return null}let F=_.join(z,"app.stx");if(await Bun.file(F).exists())return F;return null}async function Uz(z,Q){try{let F=await Bun.file(z).text(),J=F,$=F.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if($)J=$[1].trim();let X=b(F),j=[...X.client.map((K)=>K.fullTag),...X.signals.map((K)=>K.fullTag)],Z=[],U=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,B;while((B=U.exec(F))!==null)Z.push(B[0]);let Y=J;for(let K of X.server)Y=Y.replace(K.fullTag,"");for(let K of X.client)Y=Y.replace(K.fullTag,"");Y=Y.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let W="<!--__STX_PAGE_SLOT__-->";if(Y=Y.replace(/<slot\s*\/>/gi,W).replace(/<slot\s*>\s*<\/slot>/gi,W),!Y.includes(W))return console.warn(`[stx] Shell ${z} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:G,extractVariables:w,defaultConfig:q,loadStxConfig:H}=await import("./chunk-13ftt3qc.js"),A=await H(),V={__filename:z,__dirname:_.dirname(z)};for(let K of j){let I=K.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(I&&!K.includes("client")&&!K.includes('type="module"'))await w(I[1],V,z)}let k=await G(Y,V,z,{...q,...A,...Q},new Set),N=k.indexOf(W);if(N===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:k.substring(0,N),afterSlot:k.substring(N+W.length),filePath:z,shellScripts:j,shellStyles:Z}}catch(F){return console.error(`[stx] Error processing shell ${z}:`,F),null}}function Wz(z,Q,F){let J,$="",X=Q.match(n);if(X){Q=Q.replace(X[0],"");try{let Y=Buffer.from(X[1],"base64").toString("utf8"),W=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(W)J=W[1].trim();$=Y.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let j=F||J||"stx App",Z=l(),U="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
2
+ import{lm as D,mm as O,yq as P}from"./chunk-3yvmfwa9.js";import{Lu as c,Nu as h,Ou as i}from"./chunk-5wkwhjjn.js";import{Vu as p,Yu as d}from"./chunk-f8wjdg40.js";var R=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function C(z,Q,F){let J={fullTag:F,content:Q,attrs:z};if(/\bserver\b/.test(z))return{...J,type:"server"};if(/\bdata-stx-scoped\b/.test(z))return{...J,type:"client"};if(R.test(Q))return{...J,type:"signals"};if(/\bclient\b/.test(z)||/\btype\s*=\s*["']module["']/.test(z)||/\bsrc\s*=/.test(z))return{...J,type:"client"};return{...J,type:"server"}}var y=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function b(z){let Q=[],F=[],J=[],$=0;while($<z.length){let X=z.indexOf("<",$);if(X===-1)break;let j=O(z,X);if(j>X){$=j;continue}let Z=D(z,X);if(Z>X){let U=z.slice(X,Z),B=y.exec(U);if(B){let Y=C(B[1],B[2],U);switch(Y.type){case"signals":Q.push(Y);break;case"client":F.push(Y);break;case"server":J.push(Y);break}}$=Z;continue}$=X+(z.startsWith("<!--",X)?4:1)}return{signals:Q,client:F,server:J}}var S=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function f(z){let Q=[],F=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=F.exec(z))!==null)Q.push({start:J.index,end:J.index+J[0].length});return Q}function x(z,Q){return Q.some((F)=>z>=F.start&&z<F.end)}function u(z){let Q=(z||"").trim();if(!Q)return null;if(/[\s>+~,:]/.test(Q))return null;let F={},J=Q,$=J.match(/^[a-z][\w-]*/i);if($)F.tag=$[0].toLowerCase(),J=J.slice($[0].length);while(J.length>0){let X=J.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(X){if(F.attr=X[1],X[3]!==void 0&&X[3]!=="")F.attrValue=X[3];J=J.slice(X[0].length);continue}let j=J.match(/^#([\w-]+)/);if(j){F.id=j[1],J=J.slice(j[0].length);continue}let Z=J.match(/^\.([\w-]+)/);if(Z){F.className=Z[1],J=J.slice(Z[0].length);continue}return null}if(!F.tag&&!F.attr&&!F.id&&!F.className)return null;return F}function g(z,Q){if(Q.attr){if(!(Q.attrValue===void 0?new RegExp(`\\b${Q.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${Q.attr}\\s*=\\s*(["'])\\s*${Q.attrValue}\\s*\\1`,"i")).test(z))return!1}if(Q.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${Q.id}\\s*\\1`,"i").test(z))return!1}if(Q.className){let F=z.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!F)return!1;if(!F[2].split(/\s+/).includes(Q.className))return!1}return!0}function E(z,Q="main"){let F=u(Q);if(!F)return null;let J=/<([a-z][\w-]*)\b([^>]*)>/gi,$=f(z),X;while((X=J.exec(z))!==null){if(x(X.index,$))continue;let j=X[1].toLowerCase(),Z=X[2]||"";if(Z.trimEnd().endsWith("/")||S.has(j))continue;if(F.tag&&F.tag!==j)continue;if(!g(Z,F))continue;let U=X[0],B=X.index+U.length,Y=new RegExp(`<(/?)${j}\\b([^>]*)>`,"gi");Y.lastIndex=B;let W=1,G;while((G=Y.exec(z))!==null){if(x(G.index,$))continue;let w=G[1]==="/";if(!w&&(G[2]||"").trimEnd().endsWith("/"))continue;if(W+=w?-1:1,W===0)return{openTag:U,openIndex:X.index,start:B,end:G.index,tagName:j}}return null}return null}var t="X-STX-Router",zz="private, no-store";function M(z){return z.headers.get("X-STX-Router")==="true"}function m(z,Q){if(!z)return Q;return z.split(",").some((J)=>J.trim().toLowerCase()===Q.toLowerCase())?z:`${z}, ${Q}`}function Fz(z){return{Vary:m(z,"X-STX-Router")}}import _ from"path";c();var o="stx-page-head:",n=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v=null;function l(){if(v!==null)return v;try{let{getRouterScript:z}=(i(),p(h));v=`<script>${z()}</script>`}catch{v=""}return v}async function Bz(z,Q){if(Q===!1)return null;if(Q&&typeof Q==="string"){let J=_.resolve(z,Q);if(await Bun.file(J).exists())return J;return null}let F=_.join(z,"app.stx");if(await Bun.file(F).exists())return F;return null}async function Uz(z,Q){try{let F=await Bun.file(z).text(),J=F,$=F.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if($)J=$[1].trim();let X=b(F),j=[...X.client.map((K)=>K.fullTag),...X.signals.map((K)=>K.fullTag)],Z=[],U=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,B;while((B=U.exec(F))!==null)Z.push(B[0]);let Y=J;for(let K of X.server)Y=Y.replace(K.fullTag,"");for(let K of X.client)Y=Y.replace(K.fullTag,"");Y=Y.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let W="<!--__STX_PAGE_SLOT__-->";if(Y=Y.replace(/<slot\s*\/>/gi,W).replace(/<slot\s*>\s*<\/slot>/gi,W),!Y.includes(W))return console.warn(`[stx] Shell ${z} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:G,extractVariables:w,defaultConfig:q,loadStxConfig:H}=await import("./chunk-nv1qkd6w.js"),A=await H(),V={__filename:z,__dirname:_.dirname(z)};for(let K of j){let I=K.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(I&&!K.includes("client")&&!K.includes('type="module"'))await w(I[1],V,z)}let k=await G(Y,V,z,{...q,...A,...Q},new Set),N=k.indexOf(W);if(N===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:k.substring(0,N),afterSlot:k.substring(N+W.length),filePath:z,shellScripts:j,shellStyles:Z}}catch(F){return console.error(`[stx] Error processing shell ${z}:`,F),null}}function Wz(z,Q,F){let J,$="",X=Q.match(n);if(X){Q=Q.replace(X[0],"");try{let Y=Buffer.from(X[1],"base64").toString("utf8"),W=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(W)J=W[1].trim();$=Y.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let j=F||J||"stx App",Z=l(),U="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Zo as b,_o as c,dm as a}from"./chunk-mbvkvac6.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-jb7h4qgh.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{b as processESImports,c as processComponents,a as freeIdentifiers};
2
+ import{Zo as b,_o as c,dm as a}from"./chunk-3yvmfwa9.js";import"./chunk-0athjw48.js";import"./chunk-135mme4g.js";import"./chunk-f3m0q482.js";import"./chunk-f1jd5qjb.js";import"./chunk-95fvybb4.js";import"./chunk-jnbhyzkv.js";import"./chunk-bby4emay.js";import"./chunk-52wr95ps.js";import"./chunk-j24k071e.js";import"./chunk-sde45gh3.js";import"./chunk-5wkwhjjn.js";import"./chunk-krgth3gf.js";import"./chunk-f8wjdg40.js";export{b as processESImports,c as processComponents,a as freeIdentifiers};