@stacksjs/stx 0.2.83 → 0.2.85

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 (53) hide show
  1. package/dist/app-shell.js +56 -56
  2. package/dist/build-assets.js +6 -6
  3. package/dist/build-mode-detector.js +101 -101
  4. package/dist/build-views.js +155 -155
  5. package/dist/build.js +43 -43
  6. package/dist/caching.js +6 -6
  7. package/dist/cli.js +57 -57
  8. package/dist/component-processing.js +22 -22
  9. package/dist/component-renderer.js +38 -38
  10. package/dist/components.js +101 -101
  11. package/dist/dev-server/index.js +42 -42
  12. package/dist/dev-server/serve-app.js +56 -56
  13. package/dist/dev-server/serve-file.js +56 -56
  14. package/dist/dev-server/serve-markdown.js +42 -42
  15. package/dist/dev-server/serve-multi.js +55 -55
  16. package/dist/dev-server.js +56 -56
  17. package/dist/docs.js +102 -102
  18. package/dist/dynamic-components.js +38 -38
  19. package/dist/includes.js +38 -38
  20. package/dist/index.js +56 -56
  21. package/dist/interactive.js +102 -102
  22. package/dist/lazy-loader.js +101 -101
  23. package/dist/plugin.js +50 -50
  24. package/dist/process.js +37 -37
  25. package/dist/production-builder.js +37 -37
  26. package/dist/production-server.js +37 -37
  27. package/dist/pwa/index.js +101 -101
  28. package/dist/pwa/offline.js +101 -101
  29. package/dist/pwa.js +90 -90
  30. package/dist/render.js +159 -159
  31. package/dist/runtime-injection.js +6 -6
  32. package/dist/serve.js +112 -112
  33. package/dist/signal-processing.js +6 -6
  34. package/dist/signals.js +6 -6
  35. package/dist/site-builder/build.js +103 -103
  36. package/dist/site-builder/index.js +44 -44
  37. package/dist/ssg.js +19 -19
  38. package/dist/ssr.js +89 -89
  39. package/dist/story/cli.js +42 -42
  40. package/dist/story/commands/dev.js +42 -42
  41. package/dist/story/commands/index.js +42 -42
  42. package/dist/story/index.js +42 -42
  43. package/dist/story/renderer.js +102 -102
  44. package/dist/story/server.js +42 -42
  45. package/dist/story/visual-testing.js +102 -102
  46. package/dist/streaming.js +38 -38
  47. package/dist/template-compiler.js +30 -30
  48. package/dist/template-hydrator.js +116 -116
  49. package/dist/testing.js +101 -101
  50. package/dist/utils.js +38 -38
  51. package/dist/variable-extractor.js +11 -11
  52. package/dist/web-components.js +101 -101
  53. package/package.json +5 -5
@@ -15,12 +15,12 @@ catch (e) {
15
15
  `),K=G([]);if(J.length===Z.length)return a3(K,J,G);return a3((...q)=>{let W=Array(Q.length);for(let U=0;U<Q.length;U++)W[U]=q[Q[U]];return K(...W)},J,G,(q)=>{K=G(q)})}function a3($,Z,Y,X){let J=/^(\w+) is not defined$/,G=$,K=[],z=new Set(Z);return(...q)=>{for(let W=0;W<=8;W++)try{return G(...q)}catch(U){let B=U instanceof Error?U.message:"",_=J.exec(B);if(!(U instanceof ReferenceError)||!_)return;let j=_[1];if(z.has(j)||Z6.has(j))return;z.add(j),K.push(j),G=Y(K),X?.(K)}return}}function d5($){let Z=$.trim(),Y=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let X of Y)if(X.test(Z))return!1;return!0}var iX,t3,e3,nX,$6,oX,Z6;var H0=k(()=>{iX={maxSanitizeDepth:10,allowBracketNotation:!1},t3={...iX},e3=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],nX=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),$6=new Set(["__proto__","constructor","prototype"]),oX=/[\w)\]]\s*\[\s*['"]/;Z6=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});var u5={};n(u5,{stripTypeScript:()=>G6,hasVariables:()=>U6,extractVariables:()=>s0,extractScriptFromTemplate:()=>q6,convertToCommonJS:()=>w4});import v1 from"path";import Q5 from"process";function eX($){let Z=[],Y=0,X=$.split(`
16
16
  `);for(let Q of X){let J=Y,G=null,K=!1;for(let z=0;z<Q.length;z++){let q=Q[z];if(K){K=!1;continue}if(q==="\\"){K=!0;continue}if(G){if(q===G)G=null;continue}if(q==="'"||q==='"'||q==="`"){G=q;continue}if(q==="/"&&z+1<Q.length&&Q[z+1]==="/")break;if(q==="{")Y++;else if(q==="}")Y--}if(J===0){let z=Q.match(/(?:const|let|var)\s+(\w+)\s*=/);if(z)Z.push(z[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(Q)){let q=Q.match(/(?:const|let|var)\s+(\w+)/);if(q)Z.push(q[1])}else{let q=Q.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(q){let U=q[1].slice(1,-1).split(",").map((B)=>{let _=B.split(":");return(_.length>1?_[1]:_[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(...U)}}}}return[...new Set(Z)]}function G6($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let Q=[],J="",G=0,K=0,z=null;for(let q=0;q<X.length;q++){let W=X[q];if(z){if(J+=W,W===z)z=null;continue}if(W==='"'||W==="'"||W==="`"){z=W,J+=W;continue}if(W==="<")G++;else if(W===">"&&G>0)G--;else if(W==="(")K++;else if(W===")")K--;if(W===","&&G===0&&K===0){Q.push(J),J="";continue}J+=W}if(J)Q.push(J);return Q.map((q)=>{let W=q.trim(),U=W.startsWith("..."),B=U?W.slice(3):W,_=-1,j=0;for(let A=0;A<B.length;A++)if(B[A]==="<")j++;else if(B[A]===">")j--;else if(B[A]===":"&&j===0){_=A;break}if(_===-1)return q;let F=B.substring(0,_).trim().replace(/\?$/,""),L=B.substring(_+1),O=-1,V=0;for(let A=0;A<L.length;A++)if(L[A]==="<")V++;else if(L[A]===">")V--;else if(L[A]==="="&&V===0){O=A;break}let w=U?"...":"";if(O!==-1)return`${w}${F} = ${L.substring(O+1).trim()}`;return`${w}${F}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,Q,J)=>{if(!J.includes(":"))return X;return`${Q}(${Y(J)})`});{let X=/\b(function\s+\w*\s*)\(/g,Q,J=[];while((Q=X.exec(Z))!==null){let G=Q.index+Q[0].length-1,K=1,z=G+1,q=0,W=null;while(z<Z.length&&K>0){let _=Z[z];if(W){if(_===W)W=null;z++;continue}if(_==='"'||_==="'"||_==="`"){W=_,z++;continue}if(_==="<")q++;else if(_===">"&&q>0)q--;else if(q===0){if(_==="(")K++;else if(_===")")K--}if(K>0)z++}if(K!==0)continue;let U=Z.substring(G+1,z);if(!U.includes(":"))continue;let B=Y(U);J.push({start:G+1,end:z,replacement:B})}for(let G=J.length-1;G>=0;G--){let{start:K,end:z,replacement:q}=J[G];Z=Z.substring(0,K)+q+Z.substring(z)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,Q)=>{if(!Q.includes(":"))return X;if(Q.includes("{")||Q.includes("}"))return X;return`(${Q.split(",").map((G)=>{let[K,...z]=G.split("="),q=K.split(":")[0].trim();if(z.length>0)return`${q} = ${z.join("=").trim()}`;return q}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
17
17
 
18
- `),Z}async function s0($,Z,Y,X={}){if(!$.trim())return;let Q;try{let y=new Bun.Transpiler({loader:"ts",target:"browser",define:c0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=y.transformSync(v)}catch{Q=G6($)}let J={exports:{}},G=J.exports,K=Q5.cwd(),z={},q=[...Q.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((y)=>y[1]).filter((y)=>!y.startsWith("node:")&&!y.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(y));for(let y of q)try{let v=v1.resolve(K,"node_modules",y),x=v1.join(v,"package.json"),g=JSON.parse(G0("fs").readFileSync(x,"utf8")),m=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")m=s;else if(s?.bun)m=s.bun;else if(s?.import)m=s.import;else if(s?.default)m=s.default}z[y]=await import(v1.resolve(v,m))}catch{}let W=(y)=>{if(z[y])return z[y];return G0(y)},U=Z.props||{},B=Object.assign((y)=>{if(!y)return U;let v={};for(let[x,g]of Object.entries(y)){let m=U[x];if(m!==void 0)v[x]=m;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},U),_=(y)=>{if(!y)return U;let v={...U};for(let[x,g]of Object.entries(y)){let m=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&m.default!==void 0)v[x]=typeof m.default==="function"?m.default():m.default}return v},j=()=>Z.slots||{},H=(y,v)=>{let x={...y};for(let[g,m]of Object.entries(v))if(x[g]===void 0)if(typeof m==="function")x[g]=m();else x[g]=m;return x},F=(y)=>{let v=()=>y;return v.set=(x)=>{},v.update=(x)=>{},v},L=(y)=>{let v,x=!1;return()=>{if(!x)try{v=y(),x=!0}catch{v=void 0}return v}},O=(y)=>{},V=(y)=>y(),w=(y)=>{},A=(y)=>{},N=(y)=>{},R=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),T=()=>({push:(y)=>{},replace:(y)=>{},back:()=>{},forward:()=>{},go:(y)=>{}}),M=(y)=>{L1(y);let v=Z.__stx_runtime_head||{},x=y||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(y)=>{g5(y);let v=X5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(y)=>({value:y}),E=(y)=>y,C=(y)=>({value:typeof y==="function"?y():y}),S=(y,v)=>{},b=(y)=>{},P=(y)=>{},d=(y)=>y?y():Promise.resolve(),f=(y)=>(v,...x)=>{},u=(y)=>{},o=(y,v)=>{},A0=(y,v)=>v,o0=()=>({value:"light"}),b0=()=>({value:!1}),M0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},e=new Proxy(M0,{get(y,v){if(v in y)return y[v];return},set(y,v,x){return y[v]=x,!0}}),_0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},W0=console;try{let y=w4(Q,Y),v=new Set(Object.keys(U)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),m=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),s=[],Q0=[];for(let[t,p0]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(m.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(y))continue;s.push(t),Q0.push(p0)}let y0=eX(y).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
18
+ `),Z}async function s0($,Z,Y,X={}){if(!$.trim())return;let Q;try{let b=new Bun.Transpiler({loader:"ts",target:"browser",define:c0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=b.transformSync(v)}catch{Q=G6($)}let J={exports:{}},G=J.exports,K=Q5.cwd(),z={},q=[...Q.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((b)=>b[1]).filter((b)=>!b.startsWith("node:")&&!b.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(b));for(let b of q)try{let v=v1.resolve(K,"node_modules",b),x=v1.join(v,"package.json"),g=JSON.parse(G0("fs").readFileSync(x,"utf8")),m=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")m=s;else if(s?.bun)m=s.bun;else if(s?.import)m=s.import;else if(s?.default)m=s.default}z[b]=await import(v1.resolve(v,m))}catch{}let W=(b)=>{if(z[b])return z[b];return G0(b)},U=Z.props||{},B=Object.assign((b)=>{if(!b)return U;let v={};for(let[x,g]of Object.entries(b)){let m=U[x];if(m!==void 0)v[x]=m;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},U),_=(b)=>{if(!b)return U;let v={...U};for(let[x,g]of Object.entries(b)){let m=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&m.default!==void 0)v[x]=typeof m.default==="function"?m.default():m.default}return v},j=()=>Z.slots||{},H=(b,v)=>{let x={...b};for(let[g,m]of Object.entries(v))if(x[g]===void 0)if(typeof m==="function")x[g]=m();else x[g]=m;return x},F=(b)=>{let v=()=>b;return v.set=(x)=>{},v.update=(x)=>{},v},L=(b)=>{let v,x=!1;return()=>{if(!x)try{v=b(),x=!0}catch{v=void 0}return v}},O=(b)=>{},V=(b)=>b(),w=(b)=>{},A=(b)=>{},N=(b)=>{},R=()=>{let b=Z.__stxServeContext,v=Z.__stxServeSearch??b?.search??"",x=b?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(v)),path:x,name:"",fullPath:x+v,hash:"",matched:[]}},T=()=>({push:(b)=>{},replace:(b)=>{},back:()=>{},forward:()=>{},go:(b)=>{}}),M=(b)=>{L1(b);let v=Z.__stx_runtime_head||{},x=b||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(b)=>{g5(b);let v=X5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(b)=>({value:b}),E=(b)=>b,C=(b)=>({value:typeof b==="function"?b():b}),S=(b,v)=>{},y=(b)=>{},P=(b)=>{},d=(b)=>b?b():Promise.resolve(),f=(b)=>(v,...x)=>{},u=(b)=>{},o=(b,v)=>{},A0=(b,v)=>v,o0=()=>({value:"light"}),b0=()=>({value:!1}),I0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},e=new Proxy(I0,{get(b,v){if(v in b)return b[v];return},set(b,v,x){return b[v]=x,!0}}),_0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},W0=console;try{let b=w4(Q,Y),v=new Set(Object.keys(U)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),m=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),s=[],Q0=[];for(let[t,p0]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(m.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(b))continue;s.push(t),Q0.push(p0)}let y0=eX(b).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
19
19
  `),j1=Z.params??{},z0=[],H1=[];for(let t=0;t<x.length;t++){if(x[t]==="params")continue;z0.push(x[t]),H1.push(g[t])}let v5=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...s,...z0,`return (async () => {
20
- ${y}
20
+ ${b}
21
21
  ${y0}
22
22
  return module.exports
23
- })()`)(J,G,W,U,B,_,H,F,L,O,V,w,A,N,R,T,M,I,D,E,C,S,b,P,d,f,u,j,o,A0,o0,b0,e,_0,W0,M0.confirm,M0.alert,M0.fetch,j1,...Q0,...H1);if(X.preserveExisting){for(let[t,p0]of Object.entries(v5))if(!(t in Z)||Z[t]===void 0)Z[t]=p0}else Object.assign(Z,v5);for(let[t,p0]of Object.entries(U))if(!(t in Z))Z[t]=p0}catch(y){if(Q5.env.STX_DEBUG){let v=y instanceof Error?y.message:String(y);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await JJ(Q,Z,Y)}catch(v){if(Q5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function w4($,Z){let Y=Z?v1.dirname(Z):Q5.cwd(),X=$.split(`
23
+ })()`)(J,G,W,U,B,_,H,F,L,O,V,w,A,N,R,T,M,I,D,E,C,S,y,P,d,f,u,j,o,A0,o0,b0,e,_0,W0,I0.confirm,I0.alert,I0.fetch,j1,...Q0,...H1);if(X.preserveExisting){for(let[t,p0]of Object.entries(v5))if(!(t in Z)||Z[t]===void 0)Z[t]=p0}else Object.assign(Z,v5);for(let[t,p0]of Object.entries(U))if(!(t in Z))Z[t]=p0}catch(b){if(Q5.env.STX_DEBUG){let v=b instanceof Error?b.message:String(b);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await JJ(Q,Z,Y)}catch(v){if(Q5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function w4($,Z){let Y=Z?v1.dirname(Z):Q5.cwd(),X=$.split(`
24
24
  `),Q=[],J=0;while(J<X.length){let G=X[J].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;J<X.length;J++){for(let z of X[J])if(z==="{")K++;else if(z==="}")K--;if(K<=0)break}}J++;continue}if(G.startsWith("definePageMeta(")){let K=0,z=!1;for(let q=J;q<X.length&&!z;q++){let W=null,U=!1,B=X[q];for(let _=0;_<B.length;_++){let j=B[_];if(U){U=!1;continue}if(j==="\\"){U=!0;continue}if(W){if(j===W)W=null;continue}if(j==='"'||j==="'"||j==="`"){W=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){J=q+1,z=!0;break}}}}if(!z)J=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),z=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+['"](.+)['"]/),W=(U)=>{if(U.startsWith("."))return v1.resolve(Y,U);return U};if(K){let[,U,B]=K,_=W(B);Q.push(`const ${U} = await import('${_}')`),Q.push(`module.exports.${U} = ${U};`)}else if(z){let[,U,B]=z,_=U.trim(),j=W(B);Q.push(`const { ${_} } = await import('${j}')`);for(let H of _.split(",")){let F=H.trim().split(/\s+as\s+/).pop()?.trim();if(F)Q.push(`module.exports.${F} = ${F};`)}}else if(q){let U=W(q[1]);Q.push(`await import('${U}')`)}else Q.push(G);J++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))Q.push(X[J]),J++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=Y6(X,J),{type:z,name:q,value:W}=K;Q.push(`${z} ${q} = ${W};`),Q.push(`module.exports.${q} = ${q};`),J=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=V4(X,J);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),J=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=Y6(X,J),{type:z,name:q,value:W}=K;Q.push(`${z} ${q} = ${W};`),Q.push(`module.exports.${q} = ${q};`),J=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=V4(X,J);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),J=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[J].replace(/^(\s*)export\s+default\s+/,"$1"),z=[...X];z[J]=K;let q=V4(z,J);if(Q.push(q.functionCode),q.name)Q.push(`module.exports.default = ${q.name};`);J=q.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");Q.push(`module.exports.default = ${K};`),J++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let z=K[1],q=X[J].replace(/^export\s+/,""),W=0,U=J;for(;U<X.length;U++){let B=X[U];for(let _ of B)if(_==="{")W++;else if(_==="}")W--;if(U>J)q+=`
25
25
  `+B;if(W<=0&&U>=J)break}Q.push(q),Q.push(`module.exports.${z} = ${z};`),J=U+1}else Q.push(G),J++}else if(G.includes("module.exports"))Q.push(G),J++;else if(G.trim()&&!G.startsWith("//"))Q.push(G),J++;else J++}return $J(Q.join(`
26
26
  `),Y)}function $J($,Z){let Y=$.length,X="",Q=0,J=null,G=!1,K=!1,z=0;while(Q<Y){let q=$[Q],W=$[Q+1];if(G){if(X+=q,q===`
@@ -798,8 +798,8 @@ ${H}
798
798
  filter: blur(0);
799
799
  transform: scale(1);
800
800
  }
801
- `.trim();y4=new Map});import{createHash as c6}from"crypto";import{readFile as oJ,stat as l6}from"fs/promises";async function N0($){try{let Z=await oJ($);return c6("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function p6($){return c6("sha256").update($).digest("hex").slice(0,16)}function i5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${p6($)}-${p6(Y)}`}async function P4($){try{return(await l6($)).mtimeMs}catch{return 0}}async function w0($){try{return await l6($),!0}catch{return!1}}var A1=()=>{};import{mkdir as sJ,readFile as rJ,writeFile as aJ,readdir as xB,rm as tJ,stat as fB}from"fs/promises";import{join as n6,dirname as eJ}from"path";async function $Q($){try{await sJ($,{recursive:!0})}catch{}}function o6($,Z,Y){return n6($,Y,`${Z}.json`)}async function i6($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await P4(Z)!==$.srcMtime)return!1;return!0}async function n5($,Z,Y,X=v4){if(!X.enabled)return null;let Q=i5($,Z),J=u1.get(Q);if(J){if(await i6(J,$,X.maxAge))return J.lastAccessedAt=Date.now(),J.data;u1.delete(Q)}let G=o6(X.directory,Q,Y);if(await w0(G))try{let K=await rJ(G,"utf-8"),z=JSON.parse(K);if(await i6(z,$,X.maxAge))return z.lastAccessedAt=Date.now(),u1.set(Q,z),z.data}catch{}return null}async function o5($,Z,Y,X,Q=v4){if(!Q.enabled)return;let J=i5($,Z),G=await N0($),K=await P4($),z={key:J,src:$,srcHash:G,srcMtime:K,optionsHash:i5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};u1.set(J,z);let q=o6(Q.directory,J,X);try{await $Q(eJ(q)),await aJ(q,JSON.stringify(z,null,2))}catch(W){console.warn(`[stx-media] Failed to write cache: ${W}`)}}async function s5($,Z=v4){if($==="all")u1.clear();else u1.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let Q=n6(Z.directory,X);try{await tJ(Q,{recursive:!0,force:!0})}catch{}}}var u1,v4;var x4=k(()=>{A1();u1=new Map,v4={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class a5{config;constructor($={}){this.config={...ZQ,...$}}async get($,Z){return n5($,Z,"image",this.config)}async set($,Z,Y){return o5($,Z,Y,"image",this.config)}async clear(){return s5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function f4($){if(!r5)r5=new a5($);else if($)r5.updateConfig($);return r5}async function t5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return f4(X).get($,Z)}async function e5($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return f4(Q).set($,Z,Y)}async function s6(){return f4().clear()}var ZQ,r5=null;var g4=k(()=>{x4();ZQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as YQ,basename as XQ,extname as JQ,join as QQ}from"path";import{mkdir as GQ}from"fs/promises";async function h4(){try{return await import("ts-images")}catch{return null}}function r6($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function KQ($,Z){let Y=Z?r6(Z):r6("web"),X=$.formatQuality||{};return{jpeg:{...Y.jpeg,...X.jpeg},png:{...Y.png,...X.png},webp:{...Y.webp,...X.webp},avif:{...Y.avif,...X.avif}}}async function a6($,Z,Y){let X=await h4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await t5($,Z,Y);if(Q)return Q;try{let J=YQ($);if(!await w0(J))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=KQ(Y,Z.preset),K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await GQ(K,{recursive:!0});let q=await N0(J),W=XQ($,JQ($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:q},_=null;if(Z.transformations&&Z.transformations.length>0)_=await d4(J,Z.transformations,X);for(let j of U){let H=G[j]||{},F=`${W}-${q}.${j}`,L=QQ(K,F);try{let O=await X.optimizeImage({input:_||J,output:L,format:j,quality:H.quality,progressive:H.progressive});if(O){if(B.variants.push({path:L,url:`${z}/${F}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!B.originalWidth&&O.width)B.originalWidth=O.width,B.originalHeight=O.height}}catch(O){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(J);B.placeholder=j.dataUrl}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(J,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await e5($,Z,B,Y),B}catch(J){return{src:$,processed:!1,errors:[`Processing failed: ${J}`]}}}async function t6($,Z,Y,X){let Q=await h4();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(J){return{success:!1,error:String(J)}}}async function d4($,Z,Y){let X=Y||await h4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await X.decode($);for(let J of Z){let G=J.options||{};switch(J.type){case"resize":if(G.width||G.height)Q=await X.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await X.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await X.sharpen(Q,G.amount);break;case"grayscale":Q=await X.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await X.rotate(Q,G.angle);break;case"flip":Q=await X.flip(Q);break;case"flop":Q=await X.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await X.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await X.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await X.saturation(Q,G.value);break}}return await X.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var e6=k(()=>{A1();g4()});import{resolve as zQ,basename as WQ,extname as qQ,join as UQ}from"path";import{mkdir as BQ}from"fs/promises";async function _Q(){try{return await import("ts-images")}catch{return null}}async function $9($,Z,Y){let X=await _Q();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=zQ($);if(!await w0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let J=Z.responsiveWidths||Y.breakpoints||jQ,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await BQ(K,{recursive:!0});let q=await N0(Q),W=WQ($,qQ($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},B={src:$,byFormat:{},srcsets:{}};for(let j of G){B.byFormat[j]=[];let H=[];for(let F of J){let L=`${W}-${F}w-${q}.${j}`,O=UQ(K,L),V=`${z}/${L}`;try{let w=U[j]?.quality||80;if(await w0(O)){B.byFormat[j].push({path:O,url:V,width:F,height:0,format:j,size:0}),H.push(`${V} ${F}w`);continue}let A=await X.processImage({input:Q,output:O,format:j,quality:w,resize:{width:F}});if(A)B.byFormat[j].push({path:O,url:V,width:F,height:A.height||Math.round(F*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${F}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${F}w: ${w}`)}}B.srcsets[j]=H.join(", ")}let _=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(_!=="none")try{if(_==="thumbhash"){let j=await X.generateThumbHash(Q);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(Q,{strategy:_,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:_}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||HQ(J),B}catch(J){return console.error(`[stx-media] Responsive generation failed: ${J}`),null}}function HQ($){let Z=[...$].sort((X,Q)=>X-Q),Y=[];for(let X=0;X<Z.length-1;X++){let Q=Z[X];Y.push(`(max-width: ${Q}px) ${Q}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function Z9($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var jQ;var Y9=k(()=>{A1();jQ=[320,480,640,768,1024,1280,1536,1920]});var X9={};n(X9,{setCachedImageResult:()=>e5,processImage:()=>a6,optimizeImage:()=>t6,getCachedImageResult:()=>t5,generateSrcset:()=>Z9,generateResponsiveVariants:()=>$9,clearImageCache:()=>s6,applyTransformations:()=>d4,ImageProcessorCache:()=>a5});var J9=k(()=>{e6();Y9();g4()});async function OQ(){try{return await Promise.resolve().then(() => (J9(),X9))}catch($){if(!Q9)console.warn("[stx-media] Image processor not available, some features disabled:",$),Q9=!0;return null}}async function $$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return wQ(X,Y)}if(Y.processedResult?.processed)return c4($,Y.processedResult,Z);if(Y.responsiveVariants)return W9($,Y.responsiveVariants,Z);let{src:Q,alt:J,width:G,height:K,sizes:z,widths:q=d1,dpr:W,formats:U=B5,quality:B=u4,params:_={},placeholder:j="none",placeholderOptions:H={},lazy:F=!0,priority:L=!1,loading:O=L?"eager":Y$,decoding:V=Z$,fetchpriority:w,objectFit:A,objectPosition:N,crossorigin:R,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:C=!1,baseUrl:S=""}=Z;if(C&&!Z.optimize)return VQ($);let b,P,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!L)try{b=await u6(Q,{strategy:j,...H}),P=d6(d,b,H)}catch{}let f=W!==void 0&&G!==void 0,u;if(f)u=FQ($,d,b,Z);else u=await LQ($,d,b,Z);let o;if(L){let b0=U.includes("webp")?"webp":U[0],M0=E4(Q,q,{..._,q:B},b0),e=typeof z==="object"?k4(z):z||"100vw";o=`<link rel="preload" as="image" imagesrcset="${M0}" imagesizes="${e}" />`}let A0=[];if(!G9&&j!=="none")A0.push(C4),G9=!0;if(P)A0.push(P);let o0=F?z9(d):void 0;return{html:u,preloadLink:o,css:A0.length>0?A0.join(`
802
- `):void 0,script:o0}}async function LQ($,Z,Y,X){let{src:Q,alt:J,width:G,height:K,sizes:z,widths:q=d1,formats:W=B5,quality:U=u4,params:B={},lazy:_=!0,priority:j=!1,loading:H=j?"eager":Y$,decoding:F=Z$,fetchpriority:L,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,N=$.class,R=$.style,T=$.data||{},M=typeof z==="object"?k4(z):z||"100vw",I=[];for(let C of W){let S=E4(Q,q,{...B,q:U},C),b=S4(C);if(_&&!j)I.push(` <source type="${b}" data-srcset="${S}" data-sizes="${M}" />`);else I.push(` <source type="${b}" srcset="${S}" sizes="${M}" />`)}let D=m4({src:_5(Q,{...B,q:U}),alt:J,width:G,height:K,loading:j?void 0:H,decoding:F,fetchpriority:j?"high":L,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A,className:K9(N,Y),style:p4(R,O,V,Y),lazy:_&&!j,data:T}),E;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
801
+ `.trim();y4=new Map});import{createHash as c6}from"crypto";import{readFile as oJ,stat as l6}from"fs/promises";async function R0($){try{let Z=await oJ($);return c6("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function p6($){return c6("sha256").update($).digest("hex").slice(0,16)}function i5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${p6($)}-${p6(Y)}`}async function P4($){try{return(await l6($)).mtimeMs}catch{return 0}}async function w0($){try{return await l6($),!0}catch{return!1}}var A1=()=>{};import{mkdir as sJ,readFile as rJ,writeFile as aJ,readdir as xB,rm as tJ,stat as fB}from"fs/promises";import{join as n6,dirname as eJ}from"path";async function $Q($){try{await sJ($,{recursive:!0})}catch{}}function o6($,Z,Y){return n6($,Y,`${Z}.json`)}async function i6($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await P4(Z)!==$.srcMtime)return!1;return!0}async function n5($,Z,Y,X=v4){if(!X.enabled)return null;let Q=i5($,Z),J=u1.get(Q);if(J){if(await i6(J,$,X.maxAge))return J.lastAccessedAt=Date.now(),J.data;u1.delete(Q)}let G=o6(X.directory,Q,Y);if(await w0(G))try{let K=await rJ(G,"utf-8"),z=JSON.parse(K);if(await i6(z,$,X.maxAge))return z.lastAccessedAt=Date.now(),u1.set(Q,z),z.data}catch{}return null}async function o5($,Z,Y,X,Q=v4){if(!Q.enabled)return;let J=i5($,Z),G=await R0($),K=await P4($),z={key:J,src:$,srcHash:G,srcMtime:K,optionsHash:i5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};u1.set(J,z);let q=o6(Q.directory,J,X);try{await $Q(eJ(q)),await aJ(q,JSON.stringify(z,null,2))}catch(W){console.warn(`[stx-media] Failed to write cache: ${W}`)}}async function s5($,Z=v4){if($==="all")u1.clear();else u1.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let Q=n6(Z.directory,X);try{await tJ(Q,{recursive:!0,force:!0})}catch{}}}var u1,v4;var x4=k(()=>{A1();u1=new Map,v4={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class a5{config;constructor($={}){this.config={...ZQ,...$}}async get($,Z){return n5($,Z,"image",this.config)}async set($,Z,Y){return o5($,Z,Y,"image",this.config)}async clear(){return s5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function f4($){if(!r5)r5=new a5($);else if($)r5.updateConfig($);return r5}async function t5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return f4(X).get($,Z)}async function e5($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return f4(Q).set($,Z,Y)}async function s6(){return f4().clear()}var ZQ,r5=null;var g4=k(()=>{x4();ZQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as YQ,basename as XQ,extname as JQ,join as QQ}from"path";import{mkdir as GQ}from"fs/promises";async function h4(){try{return await import("ts-images")}catch{return null}}function r6($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function KQ($,Z){let Y=Z?r6(Z):r6("web"),X=$.formatQuality||{};return{jpeg:{...Y.jpeg,...X.jpeg},png:{...Y.png,...X.png},webp:{...Y.webp,...X.webp},avif:{...Y.avif,...X.avif}}}async function a6($,Z,Y){let X=await h4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await t5($,Z,Y);if(Q)return Q;try{let J=YQ($);if(!await w0(J))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=KQ(Y,Z.preset),K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await GQ(K,{recursive:!0});let q=await R0(J),W=XQ($,JQ($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:q},_=null;if(Z.transformations&&Z.transformations.length>0)_=await d4(J,Z.transformations,X);for(let j of U){let H=G[j]||{},F=`${W}-${q}.${j}`,L=QQ(K,F);try{let O=await X.optimizeImage({input:_||J,output:L,format:j,quality:H.quality,progressive:H.progressive});if(O){if(B.variants.push({path:L,url:`${z}/${F}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!B.originalWidth&&O.width)B.originalWidth=O.width,B.originalHeight=O.height}}catch(O){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(J);B.placeholder=j.dataUrl}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(J,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await e5($,Z,B,Y),B}catch(J){return{src:$,processed:!1,errors:[`Processing failed: ${J}`]}}}async function t6($,Z,Y,X){let Q=await h4();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(J){return{success:!1,error:String(J)}}}async function d4($,Z,Y){let X=Y||await h4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await X.decode($);for(let J of Z){let G=J.options||{};switch(J.type){case"resize":if(G.width||G.height)Q=await X.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await X.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await X.sharpen(Q,G.amount);break;case"grayscale":Q=await X.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await X.rotate(Q,G.angle);break;case"flip":Q=await X.flip(Q);break;case"flop":Q=await X.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await X.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await X.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await X.saturation(Q,G.value);break}}return await X.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var e6=k(()=>{A1();g4()});import{resolve as zQ,basename as WQ,extname as qQ,join as UQ}from"path";import{mkdir as BQ}from"fs/promises";async function _Q(){try{return await import("ts-images")}catch{return null}}async function $9($,Z,Y){let X=await _Q();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=zQ($);if(!await w0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let J=Z.responsiveWidths||Y.breakpoints||jQ,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await BQ(K,{recursive:!0});let q=await R0(Q),W=WQ($,qQ($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},B={src:$,byFormat:{},srcsets:{}};for(let j of G){B.byFormat[j]=[];let H=[];for(let F of J){let L=`${W}-${F}w-${q}.${j}`,O=UQ(K,L),V=`${z}/${L}`;try{let w=U[j]?.quality||80;if(await w0(O)){B.byFormat[j].push({path:O,url:V,width:F,height:0,format:j,size:0}),H.push(`${V} ${F}w`);continue}let A=await X.processImage({input:Q,output:O,format:j,quality:w,resize:{width:F}});if(A)B.byFormat[j].push({path:O,url:V,width:F,height:A.height||Math.round(F*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${F}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${F}w: ${w}`)}}B.srcsets[j]=H.join(", ")}let _=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(_!=="none")try{if(_==="thumbhash"){let j=await X.generateThumbHash(Q);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(Q,{strategy:_,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:_}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||HQ(J),B}catch(J){return console.error(`[stx-media] Responsive generation failed: ${J}`),null}}function HQ($){let Z=[...$].sort((X,Q)=>X-Q),Y=[];for(let X=0;X<Z.length-1;X++){let Q=Z[X];Y.push(`(max-width: ${Q}px) ${Q}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function Z9($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var jQ;var Y9=k(()=>{A1();jQ=[320,480,640,768,1024,1280,1536,1920]});var X9={};n(X9,{setCachedImageResult:()=>e5,processImage:()=>a6,optimizeImage:()=>t6,getCachedImageResult:()=>t5,generateSrcset:()=>Z9,generateResponsiveVariants:()=>$9,clearImageCache:()=>s6,applyTransformations:()=>d4,ImageProcessorCache:()=>a5});var J9=k(()=>{e6();Y9();g4()});async function OQ(){try{return await Promise.resolve().then(() => (J9(),X9))}catch($){if(!Q9)console.warn("[stx-media] Image processor not available, some features disabled:",$),Q9=!0;return null}}async function $$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return wQ(X,Y)}if(Y.processedResult?.processed)return c4($,Y.processedResult,Z);if(Y.responsiveVariants)return W9($,Y.responsiveVariants,Z);let{src:Q,alt:J,width:G,height:K,sizes:z,widths:q=d1,dpr:W,formats:U=B5,quality:B=u4,params:_={},placeholder:j="none",placeholderOptions:H={},lazy:F=!0,priority:L=!1,loading:O=L?"eager":Y$,decoding:V=Z$,fetchpriority:w,objectFit:A,objectPosition:N,crossorigin:R,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:C=!1,baseUrl:S=""}=Z;if(C&&!Z.optimize)return VQ($);let y,P,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!L)try{y=await u6(Q,{strategy:j,...H}),P=d6(d,y,H)}catch{}let f=W!==void 0&&G!==void 0,u;if(f)u=FQ($,d,y,Z);else u=await LQ($,d,y,Z);let o;if(L){let b0=U.includes("webp")?"webp":U[0],I0=E4(Q,q,{..._,q:B},b0),e=typeof z==="object"?k4(z):z||"100vw";o=`<link rel="preload" as="image" imagesrcset="${I0}" imagesizes="${e}" />`}let A0=[];if(!G9&&j!=="none")A0.push(C4),G9=!0;if(P)A0.push(P);let o0=F?z9(d):void 0;return{html:u,preloadLink:o,css:A0.length>0?A0.join(`
802
+ `):void 0,script:o0}}async function LQ($,Z,Y,X){let{src:Q,alt:J,width:G,height:K,sizes:z,widths:q=d1,formats:W=B5,quality:U=u4,params:B={},lazy:_=!0,priority:j=!1,loading:H=j?"eager":Y$,decoding:F=Z$,fetchpriority:L,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,N=$.class,R=$.style,T=$.data||{},M=typeof z==="object"?k4(z):z||"100vw",I=[];for(let C of W){let S=E4(Q,q,{...B,q:U},C),y=S4(C);if(_&&!j)I.push(` <source type="${y}" data-srcset="${S}" data-sizes="${M}" />`);else I.push(` <source type="${y}" srcset="${S}" sizes="${M}" />`)}let D=m4({src:_5(Q,{...B,q:U}),alt:J,width:G,height:K,loading:j?void 0:H,decoding:F,fetchpriority:j?"high":L,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A,className:K9(N,Y),style:p4(R,O,V,Y),lazy:_&&!j,data:T}),E;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
803
803
  <picture>
804
804
  ${I.join(`
805
805
  `)}
@@ -858,12 +858,12 @@ ${A.join(`
858
858
  ${A.join(`
859
859
  `)}
860
860
  <img ${R.join(" ")} />
861
- </picture>`;let C=[];if(Z.placeholder)C.push(C4);let S=G?z9(j):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:b,css:C.length>0?C.join(`
861
+ </picture>`;let C=[];if(Z.placeholder)C.push(C4);let S=G?z9(j):void 0,y;if(K&&V)y=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:y,css:C.length>0?C.join(`
862
862
  `):void 0,script:S}}async function W9($,Z,Y){let X={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[Q,J]of Object.entries(Z.byFormat))if(J)X.variants.push(...J);return c4($,X,Y)}var Q9=!1,u4=80,Z$="async",Y$="lazy",G9=!1;var q9=k(()=>{b4();m6()});function AQ(){return l5({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:Q,alt:J,options:G}=NQ($,Z,Y);if(!Q)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Q,alt:J||"",widths:G.widths||d1,formats:G.formats||B5,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},z=Y.__isDev||!1,q=await $$(K,{isDev:z}),W=q.html;if(q.preloadLink)W=q.preloadLink+`
863
863
  `+W;if(q.css)W+=`
864
864
  <style>${q.css}</style>`;if(q.script)W+=`
865
- <script>${q.script}</script>`;return W},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function NQ($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=RQ(X),J=l4(Q[0],Y)||"",G=l4(Q[1],Y)||"",K={};if(Q[2]){let z=l4(Q[2],Y);if(typeof z==="object"&&z!==null)K=z;else if(typeof Q[2]==="string")try{K=JSON.parse(Q[2])}catch{}}return{src:J,alt:G,options:K}}function RQ($){let Z=[],Y="",X=!1,Q="",J=0,G=0;for(let K=0;K<$.length;K++){let z=$[K],q=K>0?$[K-1]:"";if((z==='"'||z==="'"||z==="`")&&q!=="\\"){if(!X)X=!0,Q=z;else if(z===Q)X=!1,Q="";else Y+=z;continue}if(!X){if(z==="{")J++;if(z==="}")J--;if(z==="[")G++;if(z==="]")G--;if(z===","&&J===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=z}if(Y.trim())Z.push(Y.trim());return Z}function l4($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let X=Z[Y];if(X!==void 0)return X}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var U9;var B9=k(()=>{D4();q9();b4();U9=AQ()});class J${config;constructor($={}){this.config={...TQ,...$}}async get($,Z){return n5($,Z,"video",this.config)}async set($,Z,Y){return o5($,Z,Y,"video",this.config)}async clear(){return s5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function i4($){if(!X$)X$=new J$($);else if($)X$.updateConfig($);return X$}async function Q$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return i4(X).get($,Z)}async function G$($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return i4(Q).set($,Z,Y)}async function _9(){return i4().clear()}var TQ,X$=null;var n4=k(()=>{x4();TQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as o4,basename as s4,extname as r4,join as K$}from"path";import{mkdir as a4}from"fs/promises";async function t4(){try{return await import("ts-videos")}catch{return null}}async function z$($,Z,Y,X){let Q=await t4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let J=o4($);if(!await w0(J))return null;await a4(Y,{recursive:!0});let G=await N0(J),K=s4($,r4($)),z=Z.format||"webp",q=Z.timestamp||0,W=`${K}-poster-${G}.${z}`,U=K$(Y,W),B=await Q.extractThumbnails(J,{timestamps:[q],width:Z.width||1280,height:Z.height,format:z,quality:Z.quality||85,outputDir:Y,outputPattern:W.replace(`.${z}`,"")});if(B&&B.length>0){let _=B[0];return{path:U,url:`${X}/${W}`,width:_.width||Z.width||1280,height:_.height||720,timestamp:q,size:_.size||0}}return null}catch(J){return console.warn(`[stx-media] Failed to generate poster: ${J}`),null}}async function W$($,Z,Y,X){let Q=await t4();if(!Q)return[];try{let J=o4($);if(!await w0(J))return[];await a4(Y,{recursive:!0});let G=await N0(J),K=s4($,r4($)),z=Z.format||"webp",U=(await new Q.Input(J).getInfo()).duration||60,B=Z.count||10,_=Z.interval||U/B,j=[];for(let F=0;F<B&&F*_<U;F++)j.push(F*_);let H=await Q.extractThumbnails(J,{timestamps:j,width:Z.width||320,format:z,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((F,L)=>({path:F.path||K$(Y,`${K}-thumb-${G}-${L}.${z}`),url:`${X}/${K}-thumb-${G}-${L}.${z}`,width:F.width||Z.width||320,height:F.height||180,timestamp:j[L],size:F.size||0}));return[]}catch(J){return console.warn(`[stx-media] Failed to generate thumbnails: ${J}`),[]}}async function j9($,Z,Y,X){let Q=await t4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let J=o4($);if(!await w0(J))return null;await a4(Y,{recursive:!0});let G=await N0(J),K=s4($,r4($)),W=(await new Q.Input(J).getInfo()).duration||60,U=Z.columns||10,B=Z.interval||5,_=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",F=Math.ceil(W/B),L=Math.ceil(F/U),O=`${K}-sprite-${G}.${H}`,V=K$(Y,O),w=[];for(let N=0;N<F;N++)w.push(N*B);let A=await Q.extractThumbnails(J,{timestamps:w,width:_,height:j,format:H,quality:Z.quality||70,outputDir:K$(Y,".temp")});if(!A||A.length===0)return null;try{let N=await import("ts-images"),R=U*_,T=L*j,M=await N.createSprite({images:A.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:U,rows:L,thumbnailWidth:_,thumbnailHeight:j,interval:B,totalFrames:F}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(J){return console.warn(`[stx-media] Failed to generate sprite sheet: ${J}`),null}}var e4=k(()=>{A1()});import{resolve as O9,basename as L9,extname as F9,join as N1}from"path";import{mkdir as q$,writeFile as V9}from"fs/promises";async function w9(){try{return await import("ts-videos")}catch{return null}}async function U$($,Z,Y,X,Q){let J=await w9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=O9($);if(!await w0(G))return null;let K=await N0(G),z=L9($,F9($)),q=N1(Y,`${z}-${K}-hls`);await q$(q,{recursive:!0});let W=Z.length>0?Z:A9,U=Q?.segmentDuration||6,j=(await new J.Input(G).getInfo()).duration||0,H=[],F=0;for(let V of W){let w=N1(q,V.label);await q$(w,{recursive:!0});let A=`${V.label}.m3u8`,N=N1(w,A);try{let R=await J.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(R)H.push({quality:V,url:`${X}/${z}-${K}-hls/${V.label}/${A}`,path:N}),F+=R.segmentCount||Math.ceil(j/U)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${R}`)}}if(H.length===0)return null;let L=N1(q,"master.m3u8"),O=MQ(H,X,z,K);return await V9(L,O),{manifestUrl:`${X}/${z}-${K}-hls/master.m3u8`,manifestPath:L,playlists:H,segmentCount:F,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function MQ($,Z,Y,X){let Q=["#EXTM3U","#EXT-X-VERSION:3"];for(let J of $){let{quality:G}=J,K=G.bitrate+(G.audioBitrate||128000),z=`${G.width}x${G.height||Math.round(G.width*9/16)}`;Q.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${z},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return Q.join(`
866
- `)}async function B$($,Z,Y,X,Q){let J=await w9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=O9($);if(!await w0(G))return null;let K=await N0(G),z=L9($,F9($)),q=N1(Y,`${z}-${K}-dash`);await q$(q,{recursive:!0});let W=Z.length>0?Z:A9,U=Q?.segmentDuration||4,B=Q?.minBufferTime||2,H=(await new J.Input(G).getInfo()).duration||0,F=[],L=[];for(let A of W){let N=N1(q,A.label);await q$(N,{recursive:!0});try{if(await J.generateDASH(G,{outputDir:N,segmentDuration:U,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(F.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${X}/${z}-${K}-dash/${A.label}/video`}),A.audioBitrate)L.push({bandwidth:A.audioBitrate,url:`${X}/${z}-${K}-dash/${A.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${R}`)}}if(F.length===0)return null;let O=N1(q,"manifest.mpd"),V=IQ(F,L,H,U,B);await V9(O,V);let w=[{type:"video",representations:F}];if(L.length>0)w.push({type:"audio",representations:L});return{manifestUrl:`${X}/${z}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function IQ($,Z,Y,X,Q){let J=H9(Y),G=H9(Q),K=`<?xml version="1.0" encoding="UTF-8"?>
865
+ <script>${q.script}</script>`;return W},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function NQ($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=RQ(X),J=l4(Q[0],Y)||"",G=l4(Q[1],Y)||"",K={};if(Q[2]){let z=l4(Q[2],Y);if(typeof z==="object"&&z!==null)K=z;else if(typeof Q[2]==="string")try{K=JSON.parse(Q[2])}catch{}}return{src:J,alt:G,options:K}}function RQ($){let Z=[],Y="",X=!1,Q="",J=0,G=0;for(let K=0;K<$.length;K++){let z=$[K],q=K>0?$[K-1]:"";if((z==='"'||z==="'"||z==="`")&&q!=="\\"){if(!X)X=!0,Q=z;else if(z===Q)X=!1,Q="";else Y+=z;continue}if(!X){if(z==="{")J++;if(z==="}")J--;if(z==="[")G++;if(z==="]")G--;if(z===","&&J===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=z}if(Y.trim())Z.push(Y.trim());return Z}function l4($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let X=Z[Y];if(X!==void 0)return X}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var U9;var B9=k(()=>{D4();q9();b4();U9=AQ()});class J${config;constructor($={}){this.config={...TQ,...$}}async get($,Z){return n5($,Z,"video",this.config)}async set($,Z,Y){return o5($,Z,Y,"video",this.config)}async clear(){return s5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function i4($){if(!X$)X$=new J$($);else if($)X$.updateConfig($);return X$}async function Q$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return i4(X).get($,Z)}async function G$($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return i4(Q).set($,Z,Y)}async function _9(){return i4().clear()}var TQ,X$=null;var n4=k(()=>{x4();TQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as o4,basename as s4,extname as r4,join as K$}from"path";import{mkdir as a4}from"fs/promises";async function t4(){try{return await import("ts-videos")}catch{return null}}async function z$($,Z,Y,X){let Q=await t4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let J=o4($);if(!await w0(J))return null;await a4(Y,{recursive:!0});let G=await R0(J),K=s4($,r4($)),z=Z.format||"webp",q=Z.timestamp||0,W=`${K}-poster-${G}.${z}`,U=K$(Y,W),B=await Q.extractThumbnails(J,{timestamps:[q],width:Z.width||1280,height:Z.height,format:z,quality:Z.quality||85,outputDir:Y,outputPattern:W.replace(`.${z}`,"")});if(B&&B.length>0){let _=B[0];return{path:U,url:`${X}/${W}`,width:_.width||Z.width||1280,height:_.height||720,timestamp:q,size:_.size||0}}return null}catch(J){return console.warn(`[stx-media] Failed to generate poster: ${J}`),null}}async function W$($,Z,Y,X){let Q=await t4();if(!Q)return[];try{let J=o4($);if(!await w0(J))return[];await a4(Y,{recursive:!0});let G=await R0(J),K=s4($,r4($)),z=Z.format||"webp",U=(await new Q.Input(J).getInfo()).duration||60,B=Z.count||10,_=Z.interval||U/B,j=[];for(let F=0;F<B&&F*_<U;F++)j.push(F*_);let H=await Q.extractThumbnails(J,{timestamps:j,width:Z.width||320,format:z,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((F,L)=>({path:F.path||K$(Y,`${K}-thumb-${G}-${L}.${z}`),url:`${X}/${K}-thumb-${G}-${L}.${z}`,width:F.width||Z.width||320,height:F.height||180,timestamp:j[L],size:F.size||0}));return[]}catch(J){return console.warn(`[stx-media] Failed to generate thumbnails: ${J}`),[]}}async function j9($,Z,Y,X){let Q=await t4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let J=o4($);if(!await w0(J))return null;await a4(Y,{recursive:!0});let G=await R0(J),K=s4($,r4($)),W=(await new Q.Input(J).getInfo()).duration||60,U=Z.columns||10,B=Z.interval||5,_=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",F=Math.ceil(W/B),L=Math.ceil(F/U),O=`${K}-sprite-${G}.${H}`,V=K$(Y,O),w=[];for(let N=0;N<F;N++)w.push(N*B);let A=await Q.extractThumbnails(J,{timestamps:w,width:_,height:j,format:H,quality:Z.quality||70,outputDir:K$(Y,".temp")});if(!A||A.length===0)return null;try{let N=await import("ts-images"),R=U*_,T=L*j,M=await N.createSprite({images:A.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:U,rows:L,thumbnailWidth:_,thumbnailHeight:j,interval:B,totalFrames:F}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(J){return console.warn(`[stx-media] Failed to generate sprite sheet: ${J}`),null}}var e4=k(()=>{A1()});import{resolve as O9,basename as L9,extname as F9,join as N1}from"path";import{mkdir as q$,writeFile as V9}from"fs/promises";async function w9(){try{return await import("ts-videos")}catch{return null}}async function U$($,Z,Y,X,Q){let J=await w9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=O9($);if(!await w0(G))return null;let K=await R0(G),z=L9($,F9($)),q=N1(Y,`${z}-${K}-hls`);await q$(q,{recursive:!0});let W=Z.length>0?Z:A9,U=Q?.segmentDuration||6,j=(await new J.Input(G).getInfo()).duration||0,H=[],F=0;for(let V of W){let w=N1(q,V.label);await q$(w,{recursive:!0});let A=`${V.label}.m3u8`,N=N1(w,A);try{let R=await J.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(R)H.push({quality:V,url:`${X}/${z}-${K}-hls/${V.label}/${A}`,path:N}),F+=R.segmentCount||Math.ceil(j/U)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${R}`)}}if(H.length===0)return null;let L=N1(q,"master.m3u8"),O=MQ(H,X,z,K);return await V9(L,O),{manifestUrl:`${X}/${z}-${K}-hls/master.m3u8`,manifestPath:L,playlists:H,segmentCount:F,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function MQ($,Z,Y,X){let Q=["#EXTM3U","#EXT-X-VERSION:3"];for(let J of $){let{quality:G}=J,K=G.bitrate+(G.audioBitrate||128000),z=`${G.width}x${G.height||Math.round(G.width*9/16)}`;Q.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${z},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return Q.join(`
866
+ `)}async function B$($,Z,Y,X,Q){let J=await w9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=O9($);if(!await w0(G))return null;let K=await R0(G),z=L9($,F9($)),q=N1(Y,`${z}-${K}-dash`);await q$(q,{recursive:!0});let W=Z.length>0?Z:A9,U=Q?.segmentDuration||4,B=Q?.minBufferTime||2,H=(await new J.Input(G).getInfo()).duration||0,F=[],L=[];for(let A of W){let N=N1(q,A.label);await q$(N,{recursive:!0});try{if(await J.generateDASH(G,{outputDir:N,segmentDuration:U,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(F.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${X}/${z}-${K}-dash/${A.label}/video`}),A.audioBitrate)L.push({bandwidth:A.audioBitrate,url:`${X}/${z}-${K}-dash/${A.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${R}`)}}if(F.length===0)return null;let O=N1(q,"manifest.mpd"),V=IQ(F,L,H,U,B);await V9(O,V);let w=[{type:"video",representations:F}];if(L.length>0)w.push({type:"audio",representations:L});return{manifestUrl:`${X}/${z}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function IQ($,Z,Y,X,Q){let J=H9(Y),G=H9(Q),K=`<?xml version="1.0" encoding="UTF-8"?>
867
867
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
868
868
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
869
869
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -889,11 +889,11 @@ ${A.join(`
889
889
  </Representation>
890
890
  `}K+=` </AdaptationSet>
891
891
  `}return K+=` </Period>
892
- </MPD>`,K}function H9($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),Q="PT";if(Z>0)Q+=`${Z}H`;if(Y>0)Q+=`${Y}M`;return Q+=`${X}S`,Q}var A9;var $7=k(()=>{A1();A9=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as N9,basename as DQ,extname as EQ,join as kQ}from"path";import{mkdir as SQ}from"fs/promises";async function R9(){try{return await import("ts-videos")}catch{return null}}function bQ($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function yQ($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function Z7($){let Z=await R9();if(!Z)return null;try{let Y=N9($),Q=await new Z.Input(Y).getInfo();return{duration:Q.duration||0,width:Q.width||0,height:Q.height||0,frameRate:Q.frameRate||0,bitrate:Q.bitrate||0,codec:Q.videoCodec||"",audioCodec:Q.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function T9($,Z,Y,X){let Q=await R9();if(!Q)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let J=await Q$($,Z,Y);if(J)return J;try{let G=N9($);if(!await w0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",z=Y.baseUrl||"/videos";await SQ(K,{recursive:!0});let q=await N0(G),W=DQ($,EQ($)),U={src:$,processed:!0,hash:q};X?.({percentage:5,stage:"analyzing"}),U.metadata=await Z7(G)||void 0;let B={};if(Z.quality)B.bitrate=bQ(Z.quality);if(Z.platform)Object.assign(B,yQ(Z.platform));if(Z.transcode)Object.assign(B,Z.transcode);if(Object.keys(B).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let _=`${W}-${q}.mp4`,j=kQ(K,_);try{let H=await CQ(G,j,B,Q,(F)=>X?.({percentage:10+F*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${z}/${_}`,duration:H.duration,size:H.size,video:{codec:B.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:B.audioCodec||"aac",bitrate:B.audioBitrate||128000,sampleRate:B.sampleRate||48000,channels:B.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let _=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await z$(G,_,K,z);if(j)U.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let _=await W$(G,Y.thumbnails,K,z);if(_.length>0)U.thumbnails=_}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let _=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let j=await U$(G,_.qualities||Y.streaming?.defaultQualities||[],K,z);if(j)U.streaming={...U.streaming,hls:j}}if(_.format==="dash"){let j=await B$(G,_.qualities||Y.streaming?.defaultQualities||[],K,z);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await G$($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function CQ($,Z,Y,X,Q){try{let G=await new X.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{Q?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(J){return console.error(`[stx-media] Transcoding failed: ${J}`),null}}var M9=k(()=>{A1();n4();e4();$7()});var I9={};n(I9,{setCachedVideoResult:()=>G$,processVideo:()=>T9,getCachedVideoResult:()=>Q$,generateThumbnails:()=>W$,generateSpriteSheet:()=>j9,generatePoster:()=>z$,generateHLSManifest:()=>U$,generateDASHManifest:()=>B$,clearVideoCache:()=>_9,analyzeVideo:()=>Z7,VideoProcessorCache:()=>J$});var D9=k(()=>{M9();e4();$7();n4()});async function k9(){try{return await Promise.resolve().then(() => (D9(),I9))}catch($){if(!E9)console.warn("[stx-media] Video processor not available, some features disabled:",$),E9=!0;return null}}async function _$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return hQ(X,Y)}if(Y.processedResult?.processed)return C9($,Y.processedResult,Z);let Q;if(X.generatePoster&&X.src&&!$.poster)Q=await dQ(X,Y);let{src:J,sources:G=[],poster:K,posterPlaceholder:z,controls:q=S9,autoplay:W=!1,muted:U=!1,loop:B=!1,preload:_=b9,playsinline:j=!0,lazy:H=!0,player:F="native",type:L,width:O,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:N=!1}=$,R=Q||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(F==="ts-video")return xQ($,Z);if(L&&L!=="video")return vQ(J||"",L,$);let D=G.length>0?G:J?[{src:J,type:y9(J)}]:[],E=[`id="${I}"`];if(q)E.push("controls");if(W)E.push("autoplay");if(U)E.push("muted");if(B)E.push("loop");if(j)E.push("playsinline");if(A)E.push("disablepictureinpicture");if(N)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${_}"`),E.push('preload="none"'),R)E.push(`data-poster="${B0(R)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${_}"`),R)E.push(`poster="${B0(R)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${B0(T)}"`);if(M)E.push(`style="${B0(M)}"`);let C=D.map((P)=>{return` <source ${H?`data-src="${B0(P.src)}"`:`src="${B0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
892
+ </MPD>`,K}function H9($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),Q="PT";if(Z>0)Q+=`${Z}H`;if(Y>0)Q+=`${Y}M`;return Q+=`${X}S`,Q}var A9;var $7=k(()=>{A1();A9=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as N9,basename as DQ,extname as EQ,join as kQ}from"path";import{mkdir as SQ}from"fs/promises";async function R9(){try{return await import("ts-videos")}catch{return null}}function bQ($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function yQ($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function Z7($){let Z=await R9();if(!Z)return null;try{let Y=N9($),Q=await new Z.Input(Y).getInfo();return{duration:Q.duration||0,width:Q.width||0,height:Q.height||0,frameRate:Q.frameRate||0,bitrate:Q.bitrate||0,codec:Q.videoCodec||"",audioCodec:Q.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function T9($,Z,Y,X){let Q=await R9();if(!Q)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let J=await Q$($,Z,Y);if(J)return J;try{let G=N9($);if(!await w0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",z=Y.baseUrl||"/videos";await SQ(K,{recursive:!0});let q=await R0(G),W=DQ($,EQ($)),U={src:$,processed:!0,hash:q};X?.({percentage:5,stage:"analyzing"}),U.metadata=await Z7(G)||void 0;let B={};if(Z.quality)B.bitrate=bQ(Z.quality);if(Z.platform)Object.assign(B,yQ(Z.platform));if(Z.transcode)Object.assign(B,Z.transcode);if(Object.keys(B).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let _=`${W}-${q}.mp4`,j=kQ(K,_);try{let H=await CQ(G,j,B,Q,(F)=>X?.({percentage:10+F*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${z}/${_}`,duration:H.duration,size:H.size,video:{codec:B.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:B.audioCodec||"aac",bitrate:B.audioBitrate||128000,sampleRate:B.sampleRate||48000,channels:B.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let _=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await z$(G,_,K,z);if(j)U.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let _=await W$(G,Y.thumbnails,K,z);if(_.length>0)U.thumbnails=_}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let _=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let j=await U$(G,_.qualities||Y.streaming?.defaultQualities||[],K,z);if(j)U.streaming={...U.streaming,hls:j}}if(_.format==="dash"){let j=await B$(G,_.qualities||Y.streaming?.defaultQualities||[],K,z);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await G$($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function CQ($,Z,Y,X,Q){try{let G=await new X.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{Q?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(J){return console.error(`[stx-media] Transcoding failed: ${J}`),null}}var M9=k(()=>{A1();n4();e4();$7()});var I9={};n(I9,{setCachedVideoResult:()=>G$,processVideo:()=>T9,getCachedVideoResult:()=>Q$,generateThumbnails:()=>W$,generateSpriteSheet:()=>j9,generatePoster:()=>z$,generateHLSManifest:()=>U$,generateDASHManifest:()=>B$,clearVideoCache:()=>_9,analyzeVideo:()=>Z7,VideoProcessorCache:()=>J$});var D9=k(()=>{M9();e4();$7();n4()});async function k9(){try{return await Promise.resolve().then(() => (D9(),I9))}catch($){if(!E9)console.warn("[stx-media] Video processor not available, some features disabled:",$),E9=!0;return null}}async function _$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return hQ(X,Y)}if(Y.processedResult?.processed)return C9($,Y.processedResult,Z);let Q;if(X.generatePoster&&X.src&&!$.poster)Q=await dQ(X,Y);let{src:J,sources:G=[],poster:K,posterPlaceholder:z,controls:q=S9,autoplay:W=!1,muted:U=!1,loop:B=!1,preload:_=b9,playsinline:j=!0,lazy:H=!0,player:F="native",type:L,width:O,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:N=!1}=$,R=Q||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(F==="ts-video")return xQ($,Z);if(L&&L!=="video")return vQ(J||"",L,$);let D=G.length>0?G:J?[{src:J,type:y9(J)}]:[],E=[`id="${I}"`];if(q)E.push("controls");if(W)E.push("autoplay");if(U)E.push("muted");if(B)E.push("loop");if(j)E.push("playsinline");if(A)E.push("disablepictureinpicture");if(N)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${_}"`),E.push('preload="none"'),R)E.push(`data-poster="${B0(R)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${_}"`),R)E.push(`poster="${B0(R)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${B0(T)}"`);if(M)E.push(`style="${B0(M)}"`);let C=D.map((P)=>{return` <source ${H?`data-src="${B0(P.src)}"`:`src="${B0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
893
893
  `),S=`<video ${E.join(" ")}>
894
894
  ${C}
895
895
  Your browser does not support the video tag.
896
- </video>`,b;if(H)b=`
896
+ </video>`,y;if(H)y=`
897
897
  (function() {
898
898
  var video = document.getElementById('${I}');
899
899
  if (!video) return;
@@ -928,7 +928,7 @@ ${C}
928
928
 
929
929
  observer.observe(video);
930
930
  })();
931
- `.trim();return{html:S,script:b}}function vQ($,Z,Y){let{width:X=640,height:Q=360}=Y,J=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,z,q=null;switch(Z){case"youtube":q=fQ($),z=q?`https://www.youtube-nocookie.com/embed/${q}`:$;break;case"vimeo":q=gQ($),z=q?`https://player.vimeo.com/video/${q}`:$;break;case"dailymotion":q=$.split("/").pop()||"",z=`https://www.dailymotion.com/embed/video/${q}`;break;case"twitch":q=$.split("/").pop()||"",z=`https://player.twitch.tv/?video=${q}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:z=$}let W=[`id="${K}"`,`src="${B0(z)}"`,`width="${X}"`,`height="${Q}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(J)W.push(`class="${B0(J)}"`);if(G)W.push(`style="${B0(G)}"`);if(Y.lazy)W.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
931
+ `.trim();return{html:S,script:y}}function vQ($,Z,Y){let{width:X=640,height:Q=360}=Y,J=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,z,q=null;switch(Z){case"youtube":q=fQ($),z=q?`https://www.youtube-nocookie.com/embed/${q}`:$;break;case"vimeo":q=gQ($),z=q?`https://player.vimeo.com/video/${q}`:$;break;case"dailymotion":q=$.split("/").pop()||"",z=`https://www.dailymotion.com/embed/video/${q}`;break;case"twitch":q=$.split("/").pop()||"",z=`https://player.twitch.tv/?video=${q}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:z=$}let W=[`id="${K}"`,`src="${B0(z)}"`,`width="${X}"`,`height="${Q}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(J)W.push(`class="${B0(J)}"`);if(G)W.push(`style="${B0(G)}"`);if(Y.lazy)W.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
932
932
  <iframe ${W.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
933
933
  </div>`}}function xQ($,Z={}){let{src:Y,sources:X=[],poster:Q,controls:J=!0,autoplay:G=!1,muted:K=!1,loop:z=!1,preload:q="metadata",playsinline:W=!0,lazy:U=!0,width:B,height:_}=$,j=$.class,H=$.style,F=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,L={src:X.length>0?X:Y,autoplay:G,loop:z,muted:K,playsinline:W,preload:q,poster:Q,controls:J,title:$.title},O=["position: relative",B?`width: ${typeof B==="number"?B+"px":B}`:"width: 100%",_?`height: ${typeof _==="number"?_+"px":_}`:"",H||""].filter(Boolean).join("; "),V=`
934
934
  <div
@@ -1564,8 +1564,8 @@ ${W}
1564
1564
  customElements.define('${Z}', ${G});
1565
1565
  `}async function a9($,Z,Y,X){if(Z.length<1)return r("WebComponent","@webcomponent directive requires at least the tag name parameter",i.INVALID_DIRECTIVE_SYNTAX);let Q=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[O5.join(O5.dirname(X),G,`${Q}.stx`),O5.join(process.cwd(),G,`${Q}.stx`),O5.join(O5.dirname(X),`${Q}.stx`)],z=null;for(let U of K)if(await c(U)){z=await Bun.file(U).text();break}if(!z)return r("WebComponent",`Component file not found: ${Q}.stx`,i.FILE_NOT_FOUND);let q=QG(z,Q);return`<script type="module">
1566
1566
  ${GG(q)}
1567
- </script>`}var t9=k(()=>{t0();O0()});var e9={};n(e9,{timingPlugin:()=>UG,pluginManager:()=>KG,definePlugin:()=>A$,debugPlugin:()=>qG,createVariablesPlugin:()=>BG,createFilterPlugin:()=>WG,createDirectivePlugin:()=>zG,PluginManager:()=>U7});function A$($){return $}class U7{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let J=await Q(Y);if(J){if(J.template!==void 0)Y.template=J.template;if(J.context)Y.context={...Y.context,...J.context};if(J.metadata)Y.metadata={...Y.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${X.name}" ${$} hook:`,J)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return X}}function zG($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function WG($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function BG($){return A$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var KG,qG,UG;var $8=k(()=>{KG=new U7;qG=A$({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),UG=A$({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var j7={};n(j7,{validateConfig:()=>OG,loadStxConfig:()=>R$,defineStxConfig:()=>HG,defaultConfig:()=>T1,config:()=>_7});import B7 from"fs";import R0 from"path";import{loadConfigWithResult as _G}from"bunfig";function jG($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=R0.join(process.cwd(),"resources","views"),Q=R0.join(process.cwd(),"resources","layouts");if(B7.existsSync(X)&&B7.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=R0.join(process.cwd(),"resources","views","pages");if(B7.existsSync(J))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function R$($){if(!$){if(p1)return p1;if(N$)return N$}let Z=$?R0.resolve($):process.cwd(),Y=Z8.get(Z);if(Y)return Y;let X=(async()=>{let J=(await _G({name:"stx",alias:"ui",cwd:Z,defaultConfig:T1,verbose:!1})).config,G=jG(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!R0.isAbsolute(J.partialsDir))J.partialsDir=R0.join(K,J.partialsDir);if(J.componentsDir&&!R0.isAbsolute(J.componentsDir))J.componentsDir=R0.join(K,J.componentsDir);if(J.layoutsDir&&!R0.isAbsolute(J.layoutsDir))J.layoutsDir=R0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => ($8(),e9)),z=[],q=[];for(let W of J.plugins){let U=typeof W==="string"?W:W[0],B=typeof W==="string"?{}:W[1]||{};try{let _,j;try{_=await import(U),j=R0.dirname(G0.resolve(U))}catch{let F=R0.resolve(process.cwd(),U);_=await import(F),j=R0.dirname(F)}let H=_.default||_;if(K.register(H,J),H.components){let F=R0.resolve(j,H.components);z.push(F)}if(H.pages){let F=R0.resolve(j,H.pages),L=B.path||"/";q.push({dir:F,prefix:L})}if(H.setup){let F={addDirective:(L)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(L)},addRoute:(L,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[L]=O},addMiddleware:(L)=>{J.middleware=J.middleware||[],J.middleware.push(L)},pluginDir:j,config:J};await H.setup(B,F)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(_){console.warn(`[stx] Failed to load plugin ${U}:`,_.message)}}J._pluginComponentDirs=z,J._pluginPageDirs=q}return J})();if(Z8.set(Z,X),!$)N$=X,X.then((Q)=>{p1=Q}).catch(()=>{});return X}function HG($){return $}function OG($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!X.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var T1,p1=null,Z8,N$=null,_7;var c1=k(()=>{N4();R4();T4();M4();I4();B9();X7();g9();W7();t9();T1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:g6,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:a9,hasEndTag:!1,description:"Include a web component in the template"},N6,R6,s9,r9,T6,I6,D6,M6,b6,P6,U9,Y7,...f9],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};Z8=new Map;_7=new Proxy(T1,{get($,Z){if(p1&&Z in p1)return p1[Z];if(!N$)R$().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import Y8 from"fs";import X0 from"path";function L7($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function O7($,Z){if(M1.has($))M1.delete($);else if(M1.size>=LG)M1.delete(M1.keys().next().value);M1.set($,Z)}async function FG($){if(!Y1)return null;try{let Z=Bun.file(X0.join(Y1,`cw-${L7($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function VG($,Z){if(!Y1)return;try{if(!Y8.existsSync(Y1))Y8.mkdirSync(Y1,{recursive:!0});await Bun.write(X0.join(Y1,`cw-${L7($)}.css`),Z)}catch{}}async function J8($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function wG(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==X0.dirname(Y))$.push(X0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=X0.dirname(Y);if(Z){let X=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function AG(){if(X8)return L5;X8=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await J8(Y);if(X){if(L5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded`);return L5}}let Z=wG();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await J8(Y);if(X){if(L5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(Y))}`);return L5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${L0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${L0.reset}`),console.warn(`${L0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${L0.reset}`),null}}async function NG($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=X0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${L0.yellow}[Crosswind]${L0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function RG($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let z of K.slice(1,-1).split(/\s+/))if(z.trim())Z.add(z.trim())}J=Q.exec($)}return Z}async function TG($,Z){try{let Y=await AG();if(!Y)return"";let X=RG($);if(X.size===0)return"";let Q=Z?X0.resolve(Z):process.cwd();if(!Y1)Y1=X0.join(Q,".stx/cache");let J=[...X].sort().join(" "),G=`${H7||"default"}::${J}`,K=M1.get(G);if(K!==void 0)return O7(G,K),K;let z=await FG(G);if(z!==null)return O7(G,z),z;if(!T$){let A=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (c1(),j7)),R=await N(Q);if(R.css)if(typeof R.css==="string"){let T=X0.isAbsolute(R.css)?R.css:X0.resolve(Q,R.css);if(await Bun.file(T).exists()){let M=await import(T);A=M.default||M,console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=X0.isAbsolute(R.css.config)?R.css.config:X0.resolve(Q,R.css.config);if(await Bun.file(T).exists()){let M=await import(T);A={...M.default||M,...A}}}console.log(`${L0.green}[Crosswind]${L0.reset} Using inline CSS config from stx.config.ts`)}}catch{}T$=A||await NG(Q);try{H7=L7(JSON.stringify(T$??{}))}catch{H7="unhashable"}}let q=Y.defaultConfig||Y.config,W=T$||{},U=q.theme||{},_=(W.theme||{}).extend||{},j={...U};if(Object.keys(_).length>0)j.extend=_;let H=[...q.safelist||[],...W.safelist||[]],F={...q,...W,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},L=new Y.CSSGenerator(F);for(let A of H)L.generate(A);for(let A of X)L.generate(A);let O=L.toCSS(!0,!1),V=F.shortcuts||W.shortcuts||{};for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean);for(let T of R)L.generate(T)}O=L.toCSS(!0,!1);let w=O.split(`
1568
- `);for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean),T=[],M=[];for(let I of R){let D=I.startsWith("dark:"),S=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let P=w[b].trim();if(P===`${S} {`||P.startsWith(`${S} {`)){let d=b,f="";while(d<w.length){if(f+=w[d],w[d].includes("}"))break;d++}let u=f.match(/\{([^}]+)\}/);if(u)if(D)M.push(u[1].trim());else T.push(u[1].trim());break}}}if(T.length)O+=`
1567
+ </script>`}var t9=k(()=>{t0();O0()});var e9={};n(e9,{timingPlugin:()=>UG,pluginManager:()=>KG,definePlugin:()=>A$,debugPlugin:()=>qG,createVariablesPlugin:()=>BG,createFilterPlugin:()=>WG,createDirectivePlugin:()=>zG,PluginManager:()=>U7});function A$($){return $}class U7{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let J=await Q(Y);if(J){if(J.template!==void 0)Y.template=J.template;if(J.context)Y.context={...Y.context,...J.context};if(J.metadata)Y.metadata={...Y.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${X.name}" ${$} hook:`,J)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return X}}function zG($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function WG($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function BG($){return A$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var KG,qG,UG;var $8=k(()=>{KG=new U7;qG=A$({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),UG=A$({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var j7={};n(j7,{validateConfig:()=>OG,loadStxConfig:()=>R$,defineStxConfig:()=>HG,defaultConfig:()=>T1,config:()=>_7});import B7 from"fs";import T0 from"path";import{loadConfigWithResult as _G}from"bunfig";function jG($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=T0.join(process.cwd(),"resources","views"),Q=T0.join(process.cwd(),"resources","layouts");if(B7.existsSync(X)&&B7.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=T0.join(process.cwd(),"resources","views","pages");if(B7.existsSync(J))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function R$($){if(!$){if(p1)return p1;if(N$)return N$}let Z=$?T0.resolve($):process.cwd(),Y=Z8.get(Z);if(Y)return Y;let X=(async()=>{let J=(await _G({name:"stx",alias:"ui",cwd:Z,defaultConfig:T1,verbose:!1})).config,G=jG(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!T0.isAbsolute(J.partialsDir))J.partialsDir=T0.join(K,J.partialsDir);if(J.componentsDir&&!T0.isAbsolute(J.componentsDir))J.componentsDir=T0.join(K,J.componentsDir);if(J.layoutsDir&&!T0.isAbsolute(J.layoutsDir))J.layoutsDir=T0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => ($8(),e9)),z=[],q=[];for(let W of J.plugins){let U=typeof W==="string"?W:W[0],B=typeof W==="string"?{}:W[1]||{};try{let _,j;try{_=await import(U),j=T0.dirname(G0.resolve(U))}catch{let F=T0.resolve(process.cwd(),U);_=await import(F),j=T0.dirname(F)}let H=_.default||_;if(K.register(H,J),H.components){let F=T0.resolve(j,H.components);z.push(F)}if(H.pages){let F=T0.resolve(j,H.pages),L=B.path||"/";q.push({dir:F,prefix:L})}if(H.setup){let F={addDirective:(L)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(L)},addRoute:(L,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[L]=O},addMiddleware:(L)=>{J.middleware=J.middleware||[],J.middleware.push(L)},pluginDir:j,config:J};await H.setup(B,F)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(_){console.warn(`[stx] Failed to load plugin ${U}:`,_.message)}}J._pluginComponentDirs=z,J._pluginPageDirs=q}return J})();if(Z8.set(Z,X),!$)N$=X,X.then((Q)=>{p1=Q}).catch(()=>{});return X}function HG($){return $}function OG($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!X.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var T1,p1=null,Z8,N$=null,_7;var c1=k(()=>{N4();R4();T4();M4();I4();B9();X7();g9();W7();t9();T1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:g6,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:a9,hasEndTag:!1,description:"Include a web component in the template"},N6,R6,s9,r9,T6,I6,D6,M6,b6,P6,U9,Y7,...f9],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};Z8=new Map;_7=new Proxy(T1,{get($,Z){if(p1&&Z in p1)return p1[Z];if(!N$)R$().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import Y8 from"fs";import X0 from"path";function L7($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function O7($,Z){if(M1.has($))M1.delete($);else if(M1.size>=LG)M1.delete(M1.keys().next().value);M1.set($,Z)}async function FG($){if(!Y1)return null;try{let Z=Bun.file(X0.join(Y1,`cw-${L7($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function VG($,Z){if(!Y1)return;try{if(!Y8.existsSync(Y1))Y8.mkdirSync(Y1,{recursive:!0});await Bun.write(X0.join(Y1,`cw-${L7($)}.css`),Z)}catch{}}async function J8($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function wG(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==X0.dirname(Y))$.push(X0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=X0.dirname(Y);if(Z){let X=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function AG(){if(X8)return L5;X8=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await J8(Y);if(X){if(L5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded`);return L5}}let Z=wG();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await J8(Y);if(X){if(L5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(Y))}`);return L5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${L0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${L0.reset}`),console.warn(`${L0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${L0.reset}`),null}}async function NG($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=X0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${L0.yellow}[Crosswind]${L0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function RG($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let z of K.slice(1,-1).split(/\s+/))if(z.trim())Z.add(z.trim())}J=Q.exec($)}return Z}async function TG($,Z){try{let Y=await AG();if(!Y)return"";let X=RG($);if(X.size===0)return"";let Q=Z?X0.resolve(Z):process.cwd();if(!Y1)Y1=X0.join(Q,".stx/cache");let J=[...X].sort().join(" "),G=`${H7||"default"}::${J}`,K=M1.get(G);if(K!==void 0)return O7(G,K),K;let z=await FG(G);if(z!==null)return O7(G,z),z;if(!T$){let A=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (c1(),j7)),R=await N(Q);if(R.css)if(typeof R.css==="string"){let T=X0.isAbsolute(R.css)?R.css:X0.resolve(Q,R.css);if(await Bun.file(T).exists()){let M=await import(T);A=M.default||M,console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=X0.isAbsolute(R.css.config)?R.css.config:X0.resolve(Q,R.css.config);if(await Bun.file(T).exists()){let M=await import(T);A={...M.default||M,...A}}}console.log(`${L0.green}[Crosswind]${L0.reset} Using inline CSS config from stx.config.ts`)}}catch{}T$=A||await NG(Q);try{H7=L7(JSON.stringify(T$??{}))}catch{H7="unhashable"}}let q=Y.defaultConfig||Y.config,W=T$||{},U=q.theme||{},_=(W.theme||{}).extend||{},j={...U};if(Object.keys(_).length>0)j.extend=_;let H=[...q.safelist||[],...W.safelist||[]],F={...q,...W,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},L=new Y.CSSGenerator(F);for(let A of H)L.generate(A);for(let A of X)L.generate(A);let O=L.toCSS(!0,!1),V=F.shortcuts||W.shortcuts||{};for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean);for(let T of R)L.generate(T)}O=L.toCSS(!0,!1);let w=O.split(`
1568
+ `);for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean),T=[],M=[];for(let I of R){let D=I.startsWith("dark:"),S=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let y=0;y<w.length;y++){let P=w[y].trim();if(P===`${S} {`||P.startsWith(`${S} {`)){let d=y,f="";while(d<w.length){if(f+=w[d],w[d].includes("}"))break;d++}let u=f.match(/\{([^}]+)\}/);if(u)if(D)M.push(u[1].trim());else T.push(u[1].trim());break}}}if(T.length)O+=`
1569
1569
  .${A} { ${T.join(" ")} }`;if(M.length)O+=`
1570
1570
  @media (prefers-color-scheme: dark) { .dark .${A} { ${M.join(" ")} } }`}return O7(G,O),VG(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function Q8($,Z){let Y=await TG($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
1571
1571
  ${Y}
@@ -2456,7 +2456,7 @@ window.__stx_reactive = (function() {
2456
2456
  ${rG()}
2457
2457
  ${Y}
2458
2458
  </script>`}function E8($,Z,Y){if(D8=0,!eG($))return $;let X=iG($);if(X.length===0)return $;let Q=tG($,X),J=aG(X,Z),G=Q.lastIndexOf("</body>");if(G!==-1)Q=Q.slice(0,G)+J+`
2459
- `+Q.slice(G);else Q+=J;return Q}function tG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${D$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${D$(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${D$(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${D$(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function eG($){return/x-data\s*=\s*["']/.test($)}var D8=0,lG=0;var k8=k(()=>{u0()});import $K from"fs";import A7 from"path";import{createHighlighter as ZK}from"ts-syntax-highlighter";async function YK($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await $K.promises.stat($)).mtime.getTime();if(Z.cache&&N7.has($)){let U=N7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=x6(Q),K=Z.markdown||_7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},q=U5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)q=await XK(q,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let W={content:q,data:J||{}};if(Z.cache)N7.set($,{...W,updatedAt:X});return W}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function XK($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!E$)try{E$=await ZK({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,z,q,W)=>{let U=W.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),B=q||(Y?"text":"");if(!B)return K;try{if(!E$.getSupportedLanguages().includes(B))return K;return(await E$.highlight(U,B,{theme:Z})).html}catch(_){console.error(`Error highlighting code block with language ${q}:`,_)}return K},J=$,G=$.matchAll(X);for(let K of G){let[z,q,W,U]=K,B=await Q(z,q,W,U);J=J.replace(z,B)}return J}async function S8($,Z,Y="",X={}){return await JK($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,q)=>{try{let W=K;if(!A7.isAbsolute(K))W=A7.resolve(A7.dirname(Y),K);let U={};if(z)try{try{U=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(R||T)N=N.substring(1,N.length-1);U[A]=N}}}}catch(L){if(X.debug)console.error("Error parsing context in @markdown-file directive:",L)}let{content:B,data:_}=await YK(W,X),j={...Z,..._,...U},H=B,F=/\{\{([^}]+)\}\}/g;return H=H.replace(F,(L,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):L}),H}catch(W){let U=W instanceof Error?W.message:String(W);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,q,G)}})}async function JK($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],z=Q.index,q=Q;X.push(Y(...q).then((W)=>({match:K,replacement:W,index:z})))}let J=await Promise.all(X);J.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of J)G=G.replace(K,()=>z);return G}var N7,E$=null;var b8=k(()=>{c1();O0();N7=new Map});function X1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var y8=k(()=>{H0()});function J1($,Z){let Y=QK($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function QK($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function I1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let z=G.exec($),q=K.exec($),W=z?z.index:1/0,U=q?q.index:1/0;if(W<U)Q++,J=W+z[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+q[0].length}else break}return-1}function C8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=I1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W="if",U=Q.expression,B=0,_=0;while(q<K.length){let j=K.indexOf("@",q);if(j===-1)break;q=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){_++,q++;continue}if(/^@endif(?![a-z])/.test(H)){_--,q+=6;continue}if(_===0){let F=H.match(/^@elseif\s*/);if(F){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q});let L=q+F[0].length,O=J1(K,L);if(!O){q++;continue}W="elseif",U=O.expression,q=O.endPos,B=q;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q}),W="else",U=void 0,q+=5,B=q;continue}}q++}return z.push({type:W,condition:U,content:K.slice(B),start:J+B,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function V5($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let J=C8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function k$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,z=K+J[0].length-1,q=D0($,"(",")",z);if(q===-1){J=Q.exec($);continue}let W=$.slice(z+1,q),U=q+1,B=I1($,Z,Y,U);if(B===-1){J=Q.exec($);continue}let _=$.slice(U,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:_,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function R7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=I1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W=null,U=0;while(q<K.length){let B=K.slice(q),_=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(_){if(U++,W)W.content+=_[0];q+=_[0].length;continue}if(j){if(U--,W)W.content+=j[0];q+=j[0].length;continue}if(U>0){if(W)W.content+=K[q];q++;continue}let H=B.match(/^@case\s*/),F=B.match(/^@default(?![a-z])/),L=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(W)z.push(W);let O=q+H[0].length,V=J1(K,O);if(!V){q++;continue}W={type:"case",value:V.expression,content:""},q=V.endPos}else if(F&&B.startsWith("@default")){if(W)z.push(W);W={type:"default",content:""},q+=F[0].length}else if(L&&B.startsWith("@break"))q+=L[0].length;else{if(W)W.content+=K[q];q++}}if(W)z.push(W);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:z,start:Z,end:G+10}}var P8=()=>{};var v8=()=>{};var S$=k(()=>{P8();v8()});function WK($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=R7(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let q="",W=!1;for(let U of K.cases)if(U.type==="default"){if(!W)q=U.content.trim()}else try{let B;if(U.value&&Z0(U.value))B=Y0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)B=$0(U.value,Z);if(z===B){q=U.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+q+X.substring(K.end),Q=!0}catch(z){let q=z instanceof Error?z.message:String(z),W=r("Switch",`Error evaluating @switch expression: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function D1($,Z,Y){let X=$;X=WK(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=J1(X,K+7);if(!z)break;let q=z.endPos,W=I1(X,"unless","endunless",q);if(W===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=X.slice(q,W),B=z.expression,_=-1;{let H=0,F=/@(?:if|unless)\s*\(/g,L=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=F.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=L.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){_=A.pos;break}}let j;if(_!==-1){let H=U.slice(0,_),F=U.slice(_+5);j=`@if (${B})${F}@else ${H}@endif`}else j=`@if (!(${B}))${U}@endif`;X=X.substring(0,K)+j+X.substring(W+10),J=!0}}X=M7(X,Z,Y),X=I7(X,Z,Y),X=T7(X,Z);let Q=()=>{let J=V5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let z="",q=!1;for(let W of K.branches){if(q)break;if(W.type==="else")z=W.content,q=!0;else try{let U;if(W.condition&&Z0(W.condition))U=Y0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)U=$0(W.condition,Z);if(U)z=W.content,q=!0}catch(U){z=r(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),q=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let q=z instanceof Error?z.message:String(z),W=r("If",`Error processing @if block: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(!0){let J=X;if(!Q())break;if(X===J)break}return X}function x8($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function T7($,Z){let Y=$;function X(K,z,q,W){let U=1,B=W,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${q}(?![a-z])`,"g");while(B<K.length&&U>0){_.lastIndex=B,j.lastIndex=B;let H=_.exec(K),F=j.exec(K),L=H?H.index:1/0,O=F?F.index:1/0;if(L<O)U++,B=L+H[0].length;else if(O<1/0){if(U--,U===0)return O;B=O+F[0].length}else break}return-1}function Q(K,z,q){let W=0,U=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${q}(?![a-z])`,"g"),_=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((F,L)=>F.pos-L.pos);for(let F of j)if(F.type==="open")W++;else if(F.type==="close")W--;else if(F.type==="else"&&W===0)return F.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+5),_=x8(B);if(_)W=_.value,U=q+5+_.consumed;else U=q+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${q} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"auth","endauth"),L;if(!Z.auth)L=!1;else L=W?X1(`auth?.check && auth?.user?.[${W}]`,Z):X1("auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+6),_=x8(B);if(_)W=_.value,U=q+6+_.consumed;else U=q+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${q} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"guest","endguest"),L;if(!Z.auth)L=!0;else L=W?X1(`!auth?.check || !auth?.user?.[${W}]`,Z):X1("!auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+9),K=!0}}function J(K,z,q){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(z)W.push(z);if(q){let U=X1(q,Z);W.push(U)}return Z.permissions.check(...W)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,q=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let B=U.index,_=Y.slice(B+`@${K}`.length),j=G(_);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,F=X(Y,K,z,H);if(F===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${z} \u2014 the block was skipped.`);break}let L=Y.slice(H,F),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${z}(?![a-z])`,"g"),N=new RegExp(`@${q}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(L))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(L))!==null)T.push({pos:M.index,type:"close"});while((M=N.exec(L))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(L))!==null)T.push({pos:M.index,type:"else"});T.sort((b,P)=>b.pos-P.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let I=[],D=0;for(let b=0;b<O.length;b++){let P=O[b];if(I.push({content:L.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let d=L.slice(P.pos+`@${q}`.length),f=G(d);if(f){I[I.length-1]={content:L.slice(D,P.pos)},D=P.pos+`@${q}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let u=O[b+1],o=u?u.pos:L.length;I.push({content:L.slice(D,o),ability:f.ability,type:f.type,id:f.id}),D=o}}else D=P.pos+5}if(D<L.length){let b=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:L.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:L.slice(D)})}let E=J(j.ability,j.type,j.id),C=K==="can"?E:!E,S="";if(C)S=I[0]?.content||"";else{let b=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,B)+S+Y.substring(F+`@${z}`.length),W=!0}}return Y}function M7($,Z,Y){let X=$;function Q(J,G,K,z,q){let W=!0;while(W){W=!1;let U=new RegExp(`@${G}\\s*\\(`),B=J.match(U);if(!B||B.index===void 0)break;let _=B.index,j=J1(J,_+`@${G}`.length);if(!j)break;let H=j.endPos,F=I1(J,G,K,H);if(F===-1){console.warn(`[stx] @${G} directive at position ${_} has no matching @${K} \u2014 the block was skipped.`);break}let L=J.slice(H,F),O=j.expression,V=-1,w=0,A=0;while(A<L.length){let N=L.indexOf("@",A);if(N===-1)break;let R=L.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=N;break}A=N+1}try{let N=z(O.trim()),R;if(V!==-1){let T=L.slice(0,V),M=L.slice(V+5);R=N?T:M}else R=N?L:"";J=J.substring(0,_)+R+J.substring(F+`@${K}`.length),W=!0}catch(N){let R=N instanceof Error?N.message:String(N),T=r(q,`Error processing @${G} directive: ${R}`,i.EVALUATION_ERROR);J=J.substring(0,_)+T+J.substring(F+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=X1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=X1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function I7($,Z,Y){let X=$,Q="development";function J(G,K,z,q){let W=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${z}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),_=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,W.lastIndex=0;let F=W.exec(j);if(!F)break;let L=F.index,O=L+F[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,q=Q===E[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){W.lastIndex=w,U.lastIndex=w;let E=W.exec(j),C=U.exec(j),S=E?E.index:1/0,b=C?C.index:1/0;if(S<b)V++,w=S+E[0].length;else if(b<1/0){if(V--,V===0){A=b;break}w=b+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${L} has no matching @${z} \u2014 the block was skipped.`);break}let N=j.substring(O,A),R=-1,T=0,M=0;while(M<N.length){let E=N.indexOf("@",M);if(E===-1)break;let C=N.substring(E);if(B.test(C)){T++,M=E+1;continue}if(_.test(C)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){R=E;break}M=E+1}let I;if(R!==-1){let E=N.slice(0,R),C=N.slice(R+5);I=q?E:C}else I=q?N:"";let D=`@${z}`.length;j=j.substring(0,L)+I+j.substring(A+D),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var b$=k(()=>{y8();t0();S$();H0()});function g8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function y$($,Z){if(!$)return Z?.nonceGenerator?.()??g8();let Y=f8.get($);if(!Y)Y=Z?.nonceGenerator?.()??g8(),f8.set($,Y);return Y}function qK($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function h8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${qK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function d8($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?y$(Y,Z):void 0,Q=h8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
2459
+ `+Q.slice(G);else Q+=J;return Q}function tG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${D$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${D$(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${D$(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${D$(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function eG($){return/x-data\s*=\s*["']/.test($)}var D8=0,lG=0;var k8=k(()=>{u0()});import $K from"fs";import A7 from"path";import{createHighlighter as ZK}from"ts-syntax-highlighter";async function YK($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await $K.promises.stat($)).mtime.getTime();if(Z.cache&&N7.has($)){let U=N7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=x6(Q),K=Z.markdown||_7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},q=U5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)q=await XK(q,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let W={content:q,data:J||{}};if(Z.cache)N7.set($,{...W,updatedAt:X});return W}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function XK($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!E$)try{E$=await ZK({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,z,q,W)=>{let U=W.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),B=q||(Y?"text":"");if(!B)return K;try{if(!E$.getSupportedLanguages().includes(B))return K;return(await E$.highlight(U,B,{theme:Z})).html}catch(_){console.error(`Error highlighting code block with language ${q}:`,_)}return K},J=$,G=$.matchAll(X);for(let K of G){let[z,q,W,U]=K,B=await Q(z,q,W,U);J=J.replace(z,B)}return J}async function S8($,Z,Y="",X={}){return await JK($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,q)=>{try{let W=K;if(!A7.isAbsolute(K))W=A7.resolve(A7.dirname(Y),K);let U={};if(z)try{try{U=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(R||T)N=N.substring(1,N.length-1);U[A]=N}}}}catch(L){if(X.debug)console.error("Error parsing context in @markdown-file directive:",L)}let{content:B,data:_}=await YK(W,X),j={...Z,..._,...U},H=B,F=/\{\{([^}]+)\}\}/g;return H=H.replace(F,(L,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):L}),H}catch(W){let U=W instanceof Error?W.message:String(W);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,q,G)}})}async function JK($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],z=Q.index,q=Q;X.push(Y(...q).then((W)=>({match:K,replacement:W,index:z})))}let J=await Promise.all(X);J.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of J)G=G.replace(K,()=>z);return G}var N7,E$=null;var b8=k(()=>{c1();O0();N7=new Map});function X1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var y8=k(()=>{H0()});function J1($,Z){let Y=QK($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function QK($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function I1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let z=G.exec($),q=K.exec($),W=z?z.index:1/0,U=q?q.index:1/0;if(W<U)Q++,J=W+z[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+q[0].length}else break}return-1}function C8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=I1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W="if",U=Q.expression,B=0,_=0;while(q<K.length){let j=K.indexOf("@",q);if(j===-1)break;q=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){_++,q++;continue}if(/^@endif(?![a-z])/.test(H)){_--,q+=6;continue}if(_===0){let F=H.match(/^@elseif\s*/);if(F){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q});let L=q+F[0].length,O=J1(K,L);if(!O){q++;continue}W="elseif",U=O.expression,q=O.endPos,B=q;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q}),W="else",U=void 0,q+=5,B=q;continue}}q++}return z.push({type:W,condition:U,content:K.slice(B),start:J+B,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function V5($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let J=C8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function k$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,z=K+J[0].length-1,q=D0($,"(",")",z);if(q===-1){J=Q.exec($);continue}let W=$.slice(z+1,q),U=q+1,B=I1($,Z,Y,U);if(B===-1){J=Q.exec($);continue}let _=$.slice(U,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:_,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function R7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=I1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W=null,U=0;while(q<K.length){let B=K.slice(q),_=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(_){if(U++,W)W.content+=_[0];q+=_[0].length;continue}if(j){if(U--,W)W.content+=j[0];q+=j[0].length;continue}if(U>0){if(W)W.content+=K[q];q++;continue}let H=B.match(/^@case\s*/),F=B.match(/^@default(?![a-z])/),L=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(W)z.push(W);let O=q+H[0].length,V=J1(K,O);if(!V){q++;continue}W={type:"case",value:V.expression,content:""},q=V.endPos}else if(F&&B.startsWith("@default")){if(W)z.push(W);W={type:"default",content:""},q+=F[0].length}else if(L&&B.startsWith("@break"))q+=L[0].length;else{if(W)W.content+=K[q];q++}}if(W)z.push(W);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:z,start:Z,end:G+10}}var P8=()=>{};var v8=()=>{};var S$=k(()=>{P8();v8()});function WK($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=R7(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let q="",W=!1;for(let U of K.cases)if(U.type==="default"){if(!W)q=U.content.trim()}else try{let B;if(U.value&&Z0(U.value))B=Y0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)B=$0(U.value,Z);if(z===B){q=U.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+q+X.substring(K.end),Q=!0}catch(z){let q=z instanceof Error?z.message:String(z),W=r("Switch",`Error evaluating @switch expression: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function D1($,Z,Y){let X=$;X=WK(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=J1(X,K+7);if(!z)break;let q=z.endPos,W=I1(X,"unless","endunless",q);if(W===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=X.slice(q,W),B=z.expression,_=-1;{let H=0,F=/@(?:if|unless)\s*\(/g,L=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=F.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=L.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){_=A.pos;break}}let j;if(_!==-1){let H=U.slice(0,_),F=U.slice(_+5);j=`@if (${B})${F}@else ${H}@endif`}else j=`@if (!(${B}))${U}@endif`;X=X.substring(0,K)+j+X.substring(W+10),J=!0}}X=M7(X,Z,Y),X=I7(X,Z,Y),X=T7(X,Z);let Q=()=>{let J=V5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let z="",q=!1;for(let W of K.branches){if(q)break;if(W.type==="else")z=W.content,q=!0;else try{let U;if(W.condition&&Z0(W.condition))U=Y0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)U=$0(W.condition,Z);if(U)z=W.content,q=!0}catch(U){z=r(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),q=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let q=z instanceof Error?z.message:String(z),W=r("If",`Error processing @if block: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(!0){let J=X;if(!Q())break;if(X===J)break}return X}function x8($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function T7($,Z){let Y=$;function X(K,z,q,W){let U=1,B=W,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${q}(?![a-z])`,"g");while(B<K.length&&U>0){_.lastIndex=B,j.lastIndex=B;let H=_.exec(K),F=j.exec(K),L=H?H.index:1/0,O=F?F.index:1/0;if(L<O)U++,B=L+H[0].length;else if(O<1/0){if(U--,U===0)return O;B=O+F[0].length}else break}return-1}function Q(K,z,q){let W=0,U=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${q}(?![a-z])`,"g"),_=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((F,L)=>F.pos-L.pos);for(let F of j)if(F.type==="open")W++;else if(F.type==="close")W--;else if(F.type==="else"&&W===0)return F.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+5),_=x8(B);if(_)W=_.value,U=q+5+_.consumed;else U=q+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${q} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"auth","endauth"),L;if(!Z.auth)L=!1;else L=W?X1(`auth?.check && auth?.user?.[${W}]`,Z):X1("auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+6),_=x8(B);if(_)W=_.value,U=q+6+_.consumed;else U=q+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${q} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"guest","endguest"),L;if(!Z.auth)L=!0;else L=W?X1(`!auth?.check || !auth?.user?.[${W}]`,Z):X1("!auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+9),K=!0}}function J(K,z,q){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(z)W.push(z);if(q){let U=X1(q,Z);W.push(U)}return Z.permissions.check(...W)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,q=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let B=U.index,_=Y.slice(B+`@${K}`.length),j=G(_);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,F=X(Y,K,z,H);if(F===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${z} \u2014 the block was skipped.`);break}let L=Y.slice(H,F),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${z}(?![a-z])`,"g"),N=new RegExp(`@${q}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(L))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(L))!==null)T.push({pos:M.index,type:"close"});while((M=N.exec(L))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(L))!==null)T.push({pos:M.index,type:"else"});T.sort((y,P)=>y.pos-P.pos);for(let y of T){if(y.type==="open"){V++;continue}if(y.type==="close"){V--;continue}if(V===0)O.push(y)}let I=[],D=0;for(let y=0;y<O.length;y++){let P=O[y];if(I.push({content:L.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let d=L.slice(P.pos+`@${q}`.length),f=G(d);if(f){I[I.length-1]={content:L.slice(D,P.pos)},D=P.pos+`@${q}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let u=O[y+1],o=u?u.pos:L.length;I.push({content:L.slice(D,o),ability:f.ability,type:f.type,id:f.id}),D=o}}else D=P.pos+5}if(D<L.length){let y=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:L.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:L.slice(D)})}let E=J(j.ability,j.type,j.id),C=K==="can"?E:!E,S="";if(C)S=I[0]?.content||"";else{let y=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){S=d.content,y=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,y=!0;break}}}if(!y&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,B)+S+Y.substring(F+`@${z}`.length),W=!0}}return Y}function M7($,Z,Y){let X=$;function Q(J,G,K,z,q){let W=!0;while(W){W=!1;let U=new RegExp(`@${G}\\s*\\(`),B=J.match(U);if(!B||B.index===void 0)break;let _=B.index,j=J1(J,_+`@${G}`.length);if(!j)break;let H=j.endPos,F=I1(J,G,K,H);if(F===-1){console.warn(`[stx] @${G} directive at position ${_} has no matching @${K} \u2014 the block was skipped.`);break}let L=J.slice(H,F),O=j.expression,V=-1,w=0,A=0;while(A<L.length){let N=L.indexOf("@",A);if(N===-1)break;let R=L.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=N;break}A=N+1}try{let N=z(O.trim()),R;if(V!==-1){let T=L.slice(0,V),M=L.slice(V+5);R=N?T:M}else R=N?L:"";J=J.substring(0,_)+R+J.substring(F+`@${K}`.length),W=!0}catch(N){let R=N instanceof Error?N.message:String(N),T=r(q,`Error processing @${G} directive: ${R}`,i.EVALUATION_ERROR);J=J.substring(0,_)+T+J.substring(F+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=X1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=X1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function I7($,Z,Y){let X=$,Q="development";function J(G,K,z,q){let W=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${z}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),_=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,W.lastIndex=0;let F=W.exec(j);if(!F)break;let L=F.index,O=L+F[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,q=Q===E[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){W.lastIndex=w,U.lastIndex=w;let E=W.exec(j),C=U.exec(j),S=E?E.index:1/0,y=C?C.index:1/0;if(S<y)V++,w=S+E[0].length;else if(y<1/0){if(V--,V===0){A=y;break}w=y+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${L} has no matching @${z} \u2014 the block was skipped.`);break}let N=j.substring(O,A),R=-1,T=0,M=0;while(M<N.length){let E=N.indexOf("@",M);if(E===-1)break;let C=N.substring(E);if(B.test(C)){T++,M=E+1;continue}if(_.test(C)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){R=E;break}M=E+1}let I;if(R!==-1){let E=N.slice(0,R),C=N.slice(R+5);I=q?E:C}else I=q?N:"";let D=`@${z}`.length;j=j.substring(0,L)+I+j.substring(A+D),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var b$=k(()=>{y8();t0();S$();H0()});function g8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function y$($,Z){if(!$)return Z?.nonceGenerator?.()??g8();let Y=f8.get($);if(!Y)Y=Z?.nonceGenerator?.()??g8(),f8.set($,Y);return Y}function qK($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function h8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${qK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function d8($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?y$(Y,Z):void 0,Q=h8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
2460
2460
  ${Q}`)}function u8($,Z,Y,X){let Q=$,J=X.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!J?.enabled||!J.directives)return"<!-- CSP not configured -->";let G=J.useNonce?y$(Z,J):void 0;return h8(J.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!J?.enabled||!J.useNonce)return"";return y$(Z,J)}),J?.enabled&&J.useNonce)Z.cspNonce=y$(Z,J);return Q}var f8;var m8=k(()=>{f8=new WeakMap});import UK from"crypto";function _K($=BK){let Z=UK.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return D7=Z,Z}function jK(){if(!D7)_K();return D7}function HK($=p8){let Z=jK();return`<input type="hidden" name="${$}" value="${Z}">`}function c8($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return HK(X||p8)})}var BK=40,p8="_token",D7=null;var l8=()=>{};async function i8($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let Q=$;for(let J of X.customDirectives){if(!J.name||typeof J.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",J);continue}if(J.hasEndTag)Q=await OK(Q,J,Z,Y,X);else Q=await LK(Q,J,Z,Y,X)}return Q}async function OK($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=`@${J}`,z=`@end${J}`,q=$,W=g1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),U=[],B=W.exec(q);while(B!==null){let[_,j="",H=""]=B,F=B.index||0;try{let L=j?n8(j):[],O=H.trim(),V=await G(O,L,Y,X);U.push({original:_,processed:V,startIndex:F})}catch(L){let O=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${J}:`,L);U.push({original:_,processed:r("CustomDirective",`Error in @${J}${j?`(${j})`:""}: ${O}`,i.EVALUATION_ERROR),startIndex:F})}B=W.exec(q)}for(let _=U.length-1;_>=0;_--){let{original:j,processed:H}=U[_];q=q.replace(j,H)}return q}async function LK($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=$,z=g1(`@${J}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),q=[],W=z.exec(K);while(W!==null){let[_,j=""]=W,H=W.index||0;try{let F=n8(j),L=await G("",F,Y,X);q.push({original:_,processed:L,startIndex:H})}catch(F){let L=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${J}:`,F);q.push({original:_,processed:r("CustomDirective",`Error in @${J}(${j}): ${L}`,i.EVALUATION_ERROR),startIndex:H})}W=z.exec(K)}let U=g1(`@${J}(?!\\w)(?!\\s*\\()`,"g"),B=U.exec(K);while(B!==null){let[_]=B,j=B.index||0;try{let H=await G("",[],Y,X);q.push({original:_,processed:H,startIndex:j})}catch(H){let F=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${J}:`,H);q.push({original:_,processed:r("CustomDirective",`Error in @${J}: ${F}`,i.EVALUATION_ERROR),startIndex:j})}B=U.exec(K)}for(let _=q.length-1;_>=0;_--){let{original:j,processed:H}=q[_];K=K.replace(j,H)}return K}function n8($){if(!$.trim())return[];let Z=[],Y="",X=!1,Q="";for(let J=0;J<$.length;J++){let G=$[J];if((G==='"'||G==="'")&&(J===0||$[J-1]!=="\\"))if(!X)X=!0,Q=G;else if(G===Q)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((J)=>{let G=J.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var o8=k(()=>{t0();h1()});import FK from"crypto";function F0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function C$($,Z,Y,X){let Q=$||Z;return Y?`${Q} ${X}`:Q}function VK(){return FK.randomUUID()}function P$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=VK();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${F0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,Q)=>{let J=Q.toUpperCase();if(Q&&!["GET","POST"].includes(J))return`<input type="hidden" name="_method" value="${F0(J)}">`;return X}),Y}function a8($,Z,Y=r8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,J,G,K,z,q="")=>{let W=J||G||"POST",U=K||z||"",B=Q1(q),_=W.toUpperCase(),j=["GET","POST"].includes(_)?_:"POST",H=`<form method="${F0(j)}" action="${F0(U)}"${B?` ${B}`:""}>`;if(H+=`
2461
2461
  ${P$("@csrf",Z)}`,!["GET","POST"].includes(_))H+=`
2462
2462
  ${P$(`@method('${_}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(Q,J,G,K,z,q="")=>{let W=J||G||"",U=K||z||"",B=Q1(q),_=w5(W,Z),j=_!==void 0&&_!==null?_:U||"",H=B.match(/type=['"]([^'"]+)['"]/i),F=H?H[1]:"text",L=A5(W,Z),O=B.match(/class=['"]([^'"]+)['"]/i),V=C$(O?O[1]:"",Y.input,L,Y.inputError),w=B.replace(/class=['"][^'"]+['"]/i,"");return w=w.replace(/type=['"][^'"]+['"]/i,""),`<input type="${F0(F)}" name="${F0(W)}" value="${F0(j)}" class="${V}"${w?` ${w}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(Q,J,G="",K="")=>{let z=Q1(G),q=w5(J,Z)||K.trim(),W=A5(J,Z),U=z.match(/class=['"]([^'"]+)['"]/i),B=C$(U?U[1]:"",Y.input,W,Y.inputError),_=z.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${F0(J)}" class="${B}"${_?` ${_}`:""}>${F0(q)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(Q,J,G="",K)=>{let z=Q1(G),q=w5(J,Z),W=A5(J,Z),U=z.match(/class=['"]([^'"]+)['"]/i),B=C$(U?U[1]:"",Y.input,W,Y.inputError),_=z.replace(/class=['"][^'"]+['"]/i,""),j=K;if(q!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,F,L)=>{if((Array.isArray(q)?q.some((V)=>String(V)===L):String(q)===L)&&!F.includes("selected"))return F.replace(/(<option)/,"$1 selected");return H});return`<select name="${F0(J)}" class="${B}"${_?` ${_}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(Q,J,G="1",K="")=>{let z=Q1(K),q=w5(J,Z),W=q!==void 0&&(Array.isArray(q)?q.some((j)=>String(j)===G):q===!0||String(q)===G),U=z.match(/class=['"]([^'"]+)['"]/i),B=U?U[1]:Y.checkInput,_=z.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${F0(J)}" value="${F0(G)}" class="${B}"${W?" checked":""}${_?` ${_}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(Q,J,G,K="")=>{let z=Q1(K),q=w5(J,Z),W=q!==void 0&&q===G,U=z.match(/class=['"]([^'"]+)['"]/i),B=U?U[1]:Y.checkInput,_=z.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${F0(J)}" value="${F0(G)}" class="${B}"${W?" checked":""}${_?` ${_}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(Q,J,G="")=>{let K=Q1(G),z=K.match(/accept=['"]([^'"]+)['"]/i),q=z?z[1]:"",W=K.includes("multiple"),U=A5(J,Z),B=K.match(/class=['"]([^'"]+)['"]/i),_=C$(B?B[1]:"",Y.input,U,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${F0(J)}"`,`class="${_}"`];if(q)H.push(`accept="${F0(q)}"`);if(W)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(Q,J,G="",K)=>{let z=Q1(G),q=z.match(/class=['"]([^'"]+)['"]/i),W=q?q[1]:Y.label,U=z.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${F0(J)}" class="${W}"${U?` ${U}`:""}>${K}</label>`}),X}function t8($,Z,Y=r8){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,Q,J)=>{try{if(A5(Q,Z))return J.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return s8(Q,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(Q);return s8(Q,Z)}let z=K.trim();if(Z0(z)){let q=$0(z,Z);return q!==void 0?String(q):z}return z}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function A5($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function s8($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function w5($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let X=$.slice(0,-2);if(Y=Z[X],Y!==void 0)return Y}return Z[$]}function Q1($){if(!$.trim())return"";let Z=[],Y=$.trim(),X=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,Q;while((Q=X.exec(Y))!==null){let[,J,,G]=Q;Z.push(`${J}="${G.trim()}"`)}return Z.join(" ")}var r8;var e8=k(()=>{H0();r8={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"}});import S7 from"path";async function wK(){if(N5!==void 0)return N5;try{N5=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{N5=null}return N5}function AK($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}async function NK($,Z){if({...C7,...Z.i18n}.cache&&b7[$]){let Q=b7[$],J=Z.i18n?.cacheMaxAge??0;if(!AK(Q,J))return Q.translations}if(R5[$]?.state==="loading")return R5[$].promise;E7[$]="loading";let X=y7($,Z).then((Q)=>{return E7[$]="loaded",delete R5[$],Q}).catch((Q)=>{throw E7[$]="error",R5[$]={promise:X,state:"error",error:Q instanceof Error?Q:Error(String(Q))},Q});return R5[$]={promise:X,state:"loading"},X}async function y7($,Z){let Y={...C7,...Z.i18n},X=S7.isAbsolute(Y.translationsDir)?Y.translationsDir:S7.resolve(Z.root||process.cwd(),Y.translationsDir);try{let Q=await wK(),J=Q?await Q($,{translationsDir:X,defaultLocale:Y.defaultLocale,sources:DK(Y.format)}):await RK($,Y,X);if(J===void 0){if($!==Y.defaultLocale)return y7(Y.defaultLocale,Z);return{}}let G=J;if(Y.cache)b7[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(Q){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,Q);if($!==Y.defaultLocale)return y7(Y.defaultLocale,Z);return{}}}async function RK($,Z,Y){let X=S7.join(Y,`${$}${TK(Z.format)}`);try{let Q=await import(X);return Q.default||Q}catch(Q){try{let J=await Bun.file(X).text();if(Z.format==="yaml"||Z.format==="yml")return MK(J);if(Z.format==="json")return JSON.parse(J);throw Q}catch{return}}}function TK($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function MK($){let Z={},Y=$.split(`
@@ -2652,8 +2652,8 @@ else {
2652
2652
  ${z?`{${z}}`:"{}"}
2653
2653
  </script>
2654
2654
  </div>`}}});var UZ={};n(UZ,{warnUnbalancedTags:()=>f7,findUnbalancedTags:()=>qZ});function G1($){return $.replace(/[^\n]/g," ")}function qZ($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,G1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,G1).replace(/<!--[\s\S]*?-->/g,G1).replace(/\{\{\{[\s\S]*?\}\}\}/g,G1).replace(/\{\{[\s\S]*?\}\}/g,G1).replace(/\{!![\s\S]*?!!\}/g,G1).replace(/"[^"]*"/g,G1).replace(/'[^']*'/g,G1),Y=new Map,X=new Map,Q=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,J;while((J=Q.exec(Z))!==null){let K=J[1]==="/",z=J[2],q=J[3]==="/";if(Yz.has(z.toLowerCase()))continue;if(q)continue;if(K)X.set(z,(X.get(z)??0)+1);else{let W=Y.get(z);if(W)W.count++;else{let U=Z.slice(0,J.index).split(`
2655
- `).length;Y.set(z,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(Xz.has(K.toLowerCase()))continue;let z=Y.get(K)?.count??0,q=X.get(K)??0;if(z!==q)G.push({tag:K,opened:z,closed:q,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function f7($,Z){let Y;try{Y=qZ($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(WZ.has(X))return;WZ.add(X);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:J,opened:G,closed:K,firstOpenLine:z}of Y)if(G>K){let q=z?` (first opened at line ${z})`:"";console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 an unclosed <${J}>${q} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${J}>.`)}var Yz,Xz,WZ;var g7=k(()=>{Yz=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Xz=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);WZ=new Set});import g0 from"path";import h7 from"fs";function BZ($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function _Z($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class jZ{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let Q=$.endsWith(".stx")?$.slice(0,-4):$,J=X?.__importedComponents;if(J){let _=[Q,Q.toLowerCase(),BZ(Q),_Z(Q)];for(let j of _)if(J.has(j))return J.get(j)}let G=[...new Set([`${Q}.stx`,`${BZ(Q)}.stx`,`${_Z(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let _=g0.resolve(g0.dirname(Z),`${Q}.stx`);if(await c(_))return _;return null}let K=[],z=Y.componentsDir||"",q=X?.__originalFilePath;if(q)K.push(g0.join(g0.dirname(q),"components"));if(z)K.push(z);let W=g0.join(g0.dirname(Z),"components");if(!K.includes(W))K.push(W);let U=process.cwd(),B=[g0.resolve(U,"src/components"),g0.resolve(U,"components"),g0.resolve(import.meta.dir,"components")];for(let _ of B)if(!K.includes(_))K.push(_);for(let _ of K){if(!_)continue;for(let j of G){let H=g0.join(_,j);if(await c(H))return H}try{if(!h7.statSync(_,{throwIfNoEntry:!1})?.isDirectory())continue;let H=h7.readdirSync(_,{withFileTypes:!0});for(let F of H)if(F.isDirectory()){let L=g0.join(_,F.name);for(let O of G){let V=g0.join(L,O);if(await c(V))return V}}}catch{}}return null}}var k0;var d7=k(()=>{O0();k0=new jZ});function K1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jz($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var u7;var m7=k(()=>{u7={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=Jz($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),J=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,z=[];if(X.reactive)z.push(`:href="${K1(X.value)}"`);else z.push(`href="${K1(X.value)}"`);if(Q)z.push(`class="${K1(Q)}"`);if(z.push("data-stx-link"),z.push(`data-stx-active-class="${K1(J)}"`),z.push(`data-stx-exact-active-class="${K1(G)}"`),K)z.push("data-stx-prefetch");let q=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[W,U]of Object.entries($.static)){if(q.has(W))continue;if(typeof U==="boolean"){if(U)z.push(K1(W))}else z.push(`${K1(W)}="${K1(U)}"`)}return`<a ${z.join(" ")}>${Z}</a>`}}});function U0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function T0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function c7($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return Y}function HZ($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[Q,J]=X.split(":"),G=Qz[Q];if(G)Y.push(`(max-width: ${G}px) ${J}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${J}`)}}else Y.push(X);return Y.join(", ")}function l7($,Z,Y,X){return Z.map((Q)=>`${I5($,Q,void 0,Y,X)} ${Q}w`).join(", ")}function Gz($,Z,Y,X,Q){return Z.map((J)=>{let G=Y?Y*J:void 0;return`${I5($,G,void 0,X,Q)} ${J}x`}).join(", ")}function I5($,Z,Y,X,Q){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let J=[];if(Z)J.push(`w_${Z}`);if(Y)J.push(`h_${Y}`);if(Q)J.push(`f_${Q}`);J.push("q_auto");let G=J.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let J=new URLSearchParams;if(Z)J.set("w",String(Z));if(Y)J.set("h",String(Y));if(Q)J.set("fm",Q);J.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}if(X==="bunny"){let J=new URLSearchParams;if(Z)J.set("width",String(Z));if(Y)J.set("height",String(Y));if(Q)J.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}return $}function Kz($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var Qz,p7,i7;var n7=k(()=>{Qz={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},p7=[320,640,768,1024,1280,1536,1920];i7={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=T0($,"src")||"",Q=T0($,"alt")||"",J=T0($,"width"),G=T0($,"height"),K=T0($,"sizes"),z=T0($,"srcset"),q=T0($,"densities"),W=T0($,"format"),U=T0($,"placeholder"),B=T0($,"placeholderColor")||"#e5e7eb",_=T0($,"provider"),j=T0($,"class")||T0($,"className")||"",H=T0($,"style")||"",F=T0($,"quality"),L=c7($,"lazy",!0),O=c7($,"preload",!1),V=c7($,"picture",!1)||!!W,w=J?Number.parseInt(J):void 0,A=G?Number.parseInt(G):void 0,N=z||"",R="";if(!N&&K)N=l7(X,p7,_,W),R=HZ(K);else if(!N&&q){let S=q.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));N=Gz(X,S,w,_,W)}else if(K)R=HZ(K);let T=[];if(H)T.push(H);if(w&&A)T.push(`aspect-ratio:${w}/${A}`);if(U==="blur"||U==="color"||U==="thumbhash"){let S=Kz(w||16,A||9,B);T.push(`background-image:url(${S})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${U0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=I5(X,w,A,_,W),I=[];if(I.push(`src="${U0(M)}"`),I.push(`alt="${U0(Q)}"`),J)I.push(`width="${U0(J)}"`);if(G)I.push(`height="${U0(G)}"`);if(L)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${U0(j)}"`);if(T.length>0)I.push(`style="${U0(T.join(";"))}"`);if(N)I.push(`srcset="${U0(N)}"`);if(R)I.push(`sizes="${U0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,b]of Object.entries($.static)){if(D.has(S))continue;if(typeof b==="boolean"){if(b)I.push(U0(S))}else I.push(`${U0(S)}="${U0(b)}"`)}let E=`<img ${I.join(" ")} />`,C="";if(O){let b=W==="webp"?"image/webp":W==="avif"?"image/avif":"";C=`<link rel="preload" as="image" href="${U0(M)}"${b?` type="${b}"`:""}${N?` imagesrcset="${U0(N)}"`:""}${R?` imagesizes="${U0(R)}"`:""} />
2656
- `}if(V){let S=[];if(W==="avif"||W==="auto"){let b=I5(X,w,A,_,"avif"),P=N?l7(X,p7,_,"avif"):`${b}`;S.push(`<source type="image/avif" srcset="${U0(P)}"${R?` sizes="${U0(R)}"`:""} />`)}if(W==="webp"||W==="auto"){let b=I5(X,w,A,_,"webp"),P=N?l7(X,p7,_,"webp"):`${b}`;S.push(`<source type="image/webp" srcset="${U0(P)}"${R?` sizes="${U0(R)}"`:""} />`)}return`${C}<picture>
2655
+ `).length;Y.set(z,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(Xz.has(K.toLowerCase()))continue;let z=Y.get(K)?.count??0,q=X.get(K)??0;if(z!==q)G.push({tag:K,opened:z,closed:q,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function f7($,Z){let Y;try{Y=qZ($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(WZ.has(X))return;WZ.add(X);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:J,opened:G,closed:K,firstOpenLine:z}of Y)if(G>K){let q=z?` (first opened at line ${z})`:"";console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 an unclosed <${J}>${q} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${J}>.`)}var Yz,Xz,WZ;var g7=k(()=>{Yz=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Xz=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);WZ=new Set});import g0 from"path";import h7 from"fs";function BZ($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function _Z($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class jZ{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let Q=$.endsWith(".stx")?$.slice(0,-4):$,J=X?.__importedComponents;if(J){let _=[Q,Q.toLowerCase(),BZ(Q),_Z(Q)];for(let j of _)if(J.has(j))return J.get(j)}let G=[...new Set([`${Q}.stx`,`${BZ(Q)}.stx`,`${_Z(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let _=g0.resolve(g0.dirname(Z),`${Q}.stx`);if(await c(_))return _;return null}let K=[],z=Y.componentsDir||"",q=X?.__originalFilePath;if(q)K.push(g0.join(g0.dirname(q),"components"));if(z)K.push(z);let W=g0.join(g0.dirname(Z),"components");if(!K.includes(W))K.push(W);let U=process.cwd(),B=[g0.resolve(U,"src/components"),g0.resolve(U,"components"),g0.resolve(import.meta.dir,"components")];for(let _ of B)if(!K.includes(_))K.push(_);for(let _ of K){if(!_)continue;for(let j of G){let H=g0.join(_,j);if(await c(H))return H}try{if(!h7.statSync(_,{throwIfNoEntry:!1})?.isDirectory())continue;let H=h7.readdirSync(_,{withFileTypes:!0});for(let F of H)if(F.isDirectory()){let L=g0.join(_,F.name);for(let O of G){let V=g0.join(L,O);if(await c(V))return V}}}catch{}}return null}}var k0;var d7=k(()=>{O0();k0=new jZ});function K1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jz($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var u7;var m7=k(()=>{u7={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=Jz($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),J=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,z=[];if(X.reactive)z.push(`:href="${K1(X.value)}"`);else z.push(`href="${K1(X.value)}"`);if(Q)z.push(`class="${K1(Q)}"`);if(z.push("data-stx-link"),z.push(`data-stx-active-class="${K1(J)}"`),z.push(`data-stx-exact-active-class="${K1(G)}"`),K)z.push("data-stx-prefetch");let q=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[W,U]of Object.entries($.static)){if(q.has(W))continue;if(typeof U==="boolean"){if(U)z.push(K1(W))}else z.push(`${K1(W)}="${K1(U)}"`)}return`<a ${z.join(" ")}>${Z}</a>`}}});function U0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function c7($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return Y}function HZ($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[Q,J]=X.split(":"),G=Qz[Q];if(G)Y.push(`(max-width: ${G}px) ${J}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${J}`)}}else Y.push(X);return Y.join(", ")}function l7($,Z,Y,X){return Z.map((Q)=>`${I5($,Q,void 0,Y,X)} ${Q}w`).join(", ")}function Gz($,Z,Y,X,Q){return Z.map((J)=>{let G=Y?Y*J:void 0;return`${I5($,G,void 0,X,Q)} ${J}x`}).join(", ")}function I5($,Z,Y,X,Q){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let J=[];if(Z)J.push(`w_${Z}`);if(Y)J.push(`h_${Y}`);if(Q)J.push(`f_${Q}`);J.push("q_auto");let G=J.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let J=new URLSearchParams;if(Z)J.set("w",String(Z));if(Y)J.set("h",String(Y));if(Q)J.set("fm",Q);J.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}if(X==="bunny"){let J=new URLSearchParams;if(Z)J.set("width",String(Z));if(Y)J.set("height",String(Y));if(Q)J.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}return $}function Kz($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var Qz,p7,i7;var n7=k(()=>{Qz={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},p7=[320,640,768,1024,1280,1536,1920];i7={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=M0($,"src")||"",Q=M0($,"alt")||"",J=M0($,"width"),G=M0($,"height"),K=M0($,"sizes"),z=M0($,"srcset"),q=M0($,"densities"),W=M0($,"format"),U=M0($,"placeholder"),B=M0($,"placeholderColor")||"#e5e7eb",_=M0($,"provider"),j=M0($,"class")||M0($,"className")||"",H=M0($,"style")||"",F=M0($,"quality"),L=c7($,"lazy",!0),O=c7($,"preload",!1),V=c7($,"picture",!1)||!!W,w=J?Number.parseInt(J):void 0,A=G?Number.parseInt(G):void 0,N=z||"",R="";if(!N&&K)N=l7(X,p7,_,W),R=HZ(K);else if(!N&&q){let S=q.split(/\s+/).map((y)=>Number.parseFloat(y.replace("x","")));N=Gz(X,S,w,_,W)}else if(K)R=HZ(K);let T=[];if(H)T.push(H);if(w&&A)T.push(`aspect-ratio:${w}/${A}`);if(U==="blur"||U==="color"||U==="thumbhash"){let S=Kz(w||16,A||9,B);T.push(`background-image:url(${S})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${U0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=I5(X,w,A,_,W),I=[];if(I.push(`src="${U0(M)}"`),I.push(`alt="${U0(Q)}"`),J)I.push(`width="${U0(J)}"`);if(G)I.push(`height="${U0(G)}"`);if(L)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${U0(j)}"`);if(T.length>0)I.push(`style="${U0(T.join(";"))}"`);if(N)I.push(`srcset="${U0(N)}"`);if(R)I.push(`sizes="${U0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,y]of Object.entries($.static)){if(D.has(S))continue;if(typeof y==="boolean"){if(y)I.push(U0(S))}else I.push(`${U0(S)}="${U0(y)}"`)}let E=`<img ${I.join(" ")} />`,C="";if(O){let y=W==="webp"?"image/webp":W==="avif"?"image/avif":"";C=`<link rel="preload" as="image" href="${U0(M)}"${y?` type="${y}"`:""}${N?` imagesrcset="${U0(N)}"`:""}${R?` imagesizes="${U0(R)}"`:""} />
2656
+ `}if(V){let S=[];if(W==="avif"||W==="auto"){let y=I5(X,w,A,_,"avif"),P=N?l7(X,p7,_,"avif"):`${y}`;S.push(`<source type="image/avif" srcset="${U0(P)}"${R?` sizes="${U0(R)}"`:""} />`)}if(W==="webp"||W==="auto"){let y=I5(X,w,A,_,"webp"),P=N?l7(X,p7,_,"webp"):`${y}`;S.push(`<source type="image/webp" srcset="${U0(P)}"${R?` sizes="${U0(R)}"`:""} />`)}return`${C}<picture>
2657
2657
  ${S.join(`
2658
2658
  `)}
2659
2659
  ${E}
@@ -2691,7 +2691,7 @@ ${E}
2691
2691
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
2692
2692
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
2693
2693
  </style>`}}});import{existsSync as qz,readFileSync as Uz}from"fs";function Bz($){try{return G0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(qz(Y))return Y;return null}function _z($){if(h$.has($))return h$.get($);let Z=Bz($);if(!Z)return null;try{let Y=JSON.parse(Uz(Z,"utf8"));return h$.set($,Y.icons),Y.icons}catch{return null}}function n1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}var h$,Q3;var G3=k(()=>{h$=new Map;Q3={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=n1($,"name")??n1($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let Q="lucide",J=X;if(X.includes(":")){let O=X.split(":");Q=O[0],J=O[1]}let G=m0(n1($,"size")||"24"),K=m0(n1($,"color")||"currentColor"),z=m0(n1($,"class")||""),q=m0(n1($,"style")||""),W=h$.get(Q)??_z(Q);if(!W)return`<!-- Icon: collection "${Q}" not loaded -->`;let U=W[J];if(!U)return`<!-- Icon: "${J}" not found in ${Q} -->`;let B=U.width||24,_=U.height||24,j=`0 0 ${B} ${_}`,H=U.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let F=z?` class="${z}"`:"",L=q?` style="${q}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${F}${L}>${H}</svg>`}}});function wZ($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}function AZ($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),X=$.match(Y);if(!X)return{region:null,rest:$};return{region:X[2],rest:$.replace(X[0],"")}}var K3;var z3=k(()=>{K3={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=AZ(Z,"fallback"),Q=X.rest,J=AZ(Q,"error"),G=J.rest,K=X.region??wZ($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',z=J.region??wZ($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${z}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function d$($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}var W3;var q3=k(()=>{W3={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(d$($,"name")||"v").replace(/["'<>]/g,""),Q=(d$($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",J=d$($,"class"),G=d$($,"id"),K=[`data-stx-transition-group="${X}"`,J?`class="${J}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${Q} ${K}>${Z}</${Q}>`}}});function NZ(){k0.registerBuiltin(u7),k0.registerBuiltin(i7),k0.registerBuiltin(o7),k0.registerBuiltin(a7),k0.registerBuiltin(e7),k0.registerBuiltin(Z3),k0.registerBuiltin(X3),k0.registerBuiltin(Q3),k0.registerBuiltin(K3),k0.registerBuiltin(W3)}var RZ=k(()=>{m7();n7();s7();t7();$3();Y3();J3();G3();z3();q3();d7();m7();n7();s7();t7();$3();Y3();J3();G3();z3();q3()});function TZ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function MZ($,Z,Y){let X=[],Q=0;while(Q<$.length){let J=$.indexOf("<",Q);if(J===-1)break;let K=$.slice(J+1).match(new RegExp(`^(${Z.source})`));if(!K){Q=J+1;continue}let z=K[1];if(Y&&Y.has(z.toLowerCase())){let H=J+1+z.length;while(H<$.length&&$[H]!==">")H++;Q=H+1;continue}let q=J+1+z.length,W=null,U=q,B=-1,_=!1;while(q<$.length){let H=$[q];if(W){if(H==="\\"&&q+1<$.length){q+=2;continue}if(H===W)W=null;q++;continue}if(H==='"'||H==="'"){W=H,q++;continue}if(H==="/"&&q+1<$.length&&$[q+1]===">"){B=q+2,_=!0;break}if(H===">"){B=q+1;break}q++}if(B===-1){Q=J+1;continue}let j=$.slice(U,_?B-2:B-1).trim();if(_)X.push({fullMatch:$.slice(J,B),tagName:z,attributes:j,content:"",startIndex:J,endIndex:B,isSelfClosing:!0}),Q=B;else{let H=`<${z}`,F=`</${z}>`,L=1,O=B,V=-1;while(L>0&&O<$.length){let N=$.indexOf(H,O),R=$.indexOf(F,O);if(R===-1)break;if(N!==-1&&N<R){let T=$[N+H.length];if(T===" "||T===">"||T==="/"||T===`
2694
- `||T==="\t")L++;O=N+H.length}else{if(L--,L===0){V=R;break}O=R+F.length}}if(V===-1){Q=B;continue}let w=$.slice(B,V),A=V+F.length;X.push({fullMatch:$.slice(J,A),tagName:z,attributes:j,content:w,startIndex:J,endIndex:A,isSelfClosing:!1}),Q=A}}return X}function IZ($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var DZ=k(()=>{H0();O0();I$()});var CZ={};n(CZ,{processESImports:()=>yZ,processComponents:()=>m$});import u$ from"fs";import v0 from"path";function Hz($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),J=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,z)=>z.toUpperCase())};for(let[G,K]of Object.entries($)){let z=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(z.startsWith("@")){X.events[z]=K;continue}if(z.startsWith("__stx_")){let q=J(z.slice(6));X.serverDynamic[q]=IZ(K,Y);continue}if(z.startsWith(":")){let q=J(z.slice(1)),W=K==="true"?q:K;try{if(!Z0(W)){if(Y.debug)console.error(`Unsafe expression in :${q} binding: ${W}`);X.clientReactive[q]=W;continue}let U=Object.keys(Z),_=Y0(W,U)(...Object.values(Z));if(_===void 0){let j=W.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((L)=>!H.has(L)&&!U.includes(L))){X.clientReactive[q]=W;continue}}X.serverDynamic[q]=_}catch{X.clientReactive[q]=W}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let q=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(q)try{let W=q[1];if(Z0(W)){let B=Y0(W,Object.keys(Z))(...Object.values(Z));X.static[z]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${z}: ${W}`);X.static[z]=K}}catch(W){if(Y.debug)console.error(`Error evaluating expression for ${z}:`,W);X.static[z]=K}else{let W=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=U.exec(K))!==null)try{let _=B[1];if(!Z0(_)){if(Y.debug)console.error(`Unsafe expression in ${z}: ${_}`);continue}let H=Y0(_,Object.keys(Z))(...Object.values(Z));W=W.replace(B[0],String(H??""))}catch(_){if(Y.debug)console.error(`Error evaluating expression in ${z}:`,_)}X.static[z]=W}continue}X.static[z]=K}return X}function Oz($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let Q="";while(Y<X&&!/[\s=]/.test($[Y]))Q+=$[Y],Y++;if(!Q)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let J="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,J+=$[Y],Y++;continue}if(K===G){Y++;break}J+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))J+=$[Y],Y++;Z[Q]=J}else Z[Q]="true"}return Z}function kZ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Lz($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let Q=X[1];if(k0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function Fz($){let Z=SZ.get($);if(Z)return Z;let Y=new Map,X=[v0.join($,"src"),v0.join($,"dist"),$];function Q(J,G){if(G>6)return;let K;try{K=u$.readdirSync(J,{withFileTypes:!0})}catch{return}for(let z of K){let q=v0.join(J,z.name);if(z.isDirectory()){if(z.name==="node_modules"||z.name.startsWith("."))continue;Q(q,G+1)}else if(z.isFile()&&z.name.endsWith(".stx")){let W=z.name.slice(0,-4);if(!Y.has(W))Y.set(W,q);let U=W.toLowerCase();if(!Y.has(U))Y.set(U,q);let B=W.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,q)}}}for(let J of X)if(Q(J,0),Y.size>0)break;return SZ.set($,Y),Y}function Vz($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=v0.join(Y,"node_modules",$);try{if(u$.statSync(X).isDirectory())return X}catch{}let Q=v0.dirname(Y);if(Q===Y)return null;Y=Q}}async function yZ($,Z,Y,X,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let J=Z.__importedComponents,G=v0.dirname(Y),K=$,z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(z,(q,W,U)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,_=U,j,H=[];while((j=B.exec(U))!==null){let[F,L,O,V]=j,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=v0.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let M=`${T}.stx`;try{if(u$.statSync(M).isFile())A=M}catch{try{if(u$.statSync(T).isDirectory())w=T}catch{}}}}else w=Vz(V,G);if(!w&&!A)continue;let N=!1,R=(T,M)=>{J.set(T,M),J.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();J.set(I,M),Q.add(M)};if(O&&A)R(O,A),N=!0;else if(L){let T=L.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?Fz(w):null;for(let{source:I,local:D}of T){let E=null;if(A)E=A;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)R(D,E),N=!0}}if(N)H.push({start:j.index,end:j.index+F.length})}if(H.length===0)return q;for(let F=H.length-1;F>=0;F--)_=_.slice(0,H[F].start)+_.slice(H[F].end);return`<script${W}>${_}</script>`}),K}async function wz($,Z,Y,X,Q){let J=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=K.exec(J))!==null){let[q,W]=z,U=W.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of U){let _=B.split("/"),H=_[_.length-1].replace(/\.stx$/,""),F=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),L=null,O=[v0.resolve(v0.dirname(Y),`${B}.stx`),v0.resolve(v0.dirname(Y),B),v0.resolve(X.componentsDir||"components",`${B}.stx`),v0.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){L=V;break}}catch{}if(L){G.set(F,L),G.set(H,L),G.set(H.toLowerCase(),L);let V=F.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,L),Q.add(L),X.debug)console.log(`Imported component: ${F} -> ${L}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}J=J.replace(q,""),K.lastIndex=0}return J}async function Az($,Z,Y,X,Q){let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=/@component\s*\(/g,q;while((q=z.exec(J))!==null){let W=q.index,U=W+q[0].length-1,B=1,_=U+1;while(_<J.length&&B>0){if(J[_]==="(")B++;else if(J[_]===")"){if(B--,B===0)break}_++}if(B!==0)break;let j=J.substring(U+1,_),H=_+1,F=j.match(/^\s*['"]([^'"]+)['"]/);if(!F){z.lastIndex=0;continue}let L=F[1],O,V=j.slice(F[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let A={};if(O)try{A=j0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);J=J.replace(J.substring(W,H),`[Error parsing component props: ${E}]`);continue}let N="",R=H,M=J.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)N=M[1].trim(),R=H+M[0].length;let I=await k1(L,A,N,G,Z,Y,X,K,Q);J=J.substring(0,W)+I+J.substring(R),z.lastIndex=0}return J}async function Nz($,Z,Y,X,Q){if(!$)return $;let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=F7(J);return J=z.output,J=await B(J,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),J=await B(J,/[A-Z][a-zA-Z0-9]*/,!0),J=await B(J,/[a-z][a-z0-9]*/,!1,jz),J=V7(J,z.scripts),J;async function B(_,j,H,F){if(!_)return _;let L=_,O=MZ(L,j,F);for(let V=O.length-1;V>=0;V--){let w=O[V],A=H?TZ(w.tagName):w.tagName,N=Oz(w.attributes),R=Hz(N,Z,X),T=k0.getBuiltin(w.tagName),M=T?await PZ(A,G,Z,Y,X):!1;if(T&&!M){let C={context:Z,filePath:Y,options:X,dependencies:Q},S=T.render(R,w.content,C);if(Object.keys(R.clientReactive).length>0)S=bZ(S,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([P,d])=>`${P}="${kZ(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}L=L.substring(0,w.startIndex)+S+L.substring(w.endIndex);continue}let I={};for(let[C,S]of Object.entries(R.static))I[C]=S;for(let[C,S]of Object.entries(R.serverDynamic))I[C]=S;let E=await k1(A,I,w.content,G,Z,Y,X,K,Q);if(Object.keys(R.clientReactive).length>0)E=bZ(E,R.clientReactive);if(Object.keys(R.events).length>0){let C=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(C){let S=Object.entries(R.events).map(([P,d])=>`${P}="${kZ(d)}"`).join(" "),b=C[1].length+C[2].length;E=E.substring(0,b)+" "+S+E.substring(b)}}L=L.substring(0,w.startIndex)+E+L.substring(w.endIndex)}return L}}function bZ($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([J,G])=>`:${J}="${G.replace(/"/g,"&quot;")}"`).join(" "),Q=Y[1].length+Y[2].length;return $.substring(0,Q)+" "+X+$.substring(Q)}async function m$($,Z,Y,X,Q){if(!EZ)NZ(),EZ=!0;let J=await yZ($,Z,Y,X,Q);J=await wz(J,Z,Y,X,Q),J=await Az(J,Z,Y,X,Q);for(let G=0;G<3;G++){let K=J;if(J=await Nz(J,Z,Y,X,Q),J===K)break}if(X.debug){let G=Lz(J);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return J}var EZ=!1,jz,SZ;var U3=k(()=>{d7();RZ();DZ();O0();H0();jz=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);SZ=new Map});var uZ={};n(uZ,{processLoops:()=>B3});function Mz($,Z){let Y=/@component\s*\(/g,X=$,Q,J=[];while((Q=Y.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,z=1,q=K+1;while(q<X.length&&z>0){if(X[q]==="(")z++;else if(X[q]===")"){if(z--,z===0)break}q++}if(z!==0)continue;let W=X.substring(K+1,q),U=q+1,B=W.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let _=B[1],j=W.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let F=j.slice(H[0].length).trim();if(!F)continue;try{let L=j0(F,Z),O=JSON.stringify(L),V=`@component('${_}', ${O})`;J.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=J.length-1;G>=0;G--){let{start:K,end:z,replacement:q}=J[G];X=X.substring(0,K)+q+X.substring(z)}return X}function p$($,Z,Y){let X=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),J;while((J=Q.exec(X))!==null){let G=J.index,K=G+J[0].length-1,z=1,q=K+1,W=null,U=!1;while(q<X.length&&z>0){let j=X[q];if(U){U=!1,q++;continue}if(j==="\\"&&W){U=!0,q++;continue}if(W){if(j===W)W=null;q++;continue}if(j==='"'||j==="'"||j==="`"){W=j,q++;continue}if(j==="(")z++;else if(j===")"){if(z--,z===0)break}q++}if(z!==0)break;let B=X.substring(K+1,q),_=Y(B);X=X.substring(0,G)+_+X.substring(q+1)}return X}function Iz($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,Q,J)=>{try{let G=Object.keys(Z),K=Object.values(Z);h5(J);let q=Y0(J,G)(...K),W=JSON.stringify(q),U=Buffer.from(W,"utf8").toString("base64");return`__stx_${Q}="${U}"`}catch(G){return X}}),Y}function Dz($,Z){let Y=$;return Y=p$(Y,"@break",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?c$:""}catch{return""}}),Y=p$(Y,"@continue",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?l$:""}catch{return""}}),Y}function Ez($){let Z=$;return Z=Z.replace(/@break(?!\()/g,c$),Z=Z.replace(/@continue(?!\()/g,l$),Z}function vZ($){let Z=$.includes(c$),Y=Z?$.substring(0,$.indexOf(c$)):$;return{hasBreak:Z,content:Y}}function xZ($){let Z=$.includes(l$),Y=Z?$.substring(0,$.indexOf(l$)):$;return{hasContinue:Z,content:Y}}function gZ($){let Z=$;return Z=p$(Z,"@break",(Y)=>{let X=Y.trim();if(!d5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=p$(Z,"@continue",(Y)=>{let X=Y.trim();if(!d5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function kz($){let Z=/@forelse\s*\(/g,Y,X=[],Q=/@foreach\s*\(/g,J=/@endforeach/g,G;while((G=Q.exec($))!==null)X.push({pos:G.index,delta:1});while((G=J.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((W,U)=>W.pos-U.pos);let K=[],z=0;for(let W of X)z+=W.delta,K.push({pos:W.pos,depth:z});function q(W){let U=0,B=K.length-1,_=0;while(U<=B){let j=U+B>>1;if(K[j].pos<=W)_=K[j].depth,U=j+1;else B=j-1}return _}while((Y=Z.exec($))!==null){if(q(Y.index)>0)continue;let W=Y.index,U=Y.index+Y[0].length-1,B=1,_=U+1,j=-1;while(_<$.length&&B>0){if($[_]==="(")B++;else if($[_]===")"){if(B--,B===0){j=_;break}}_++}if(j===-1)continue;let H=$.substring(U+1,j),F=H.indexOf(" as ");if(F===-1)continue;let L=H.substring(0,F).trim(),O=H.substring(F+4).trim(),V=j+1,w=1,A=V,N=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(w>0&&A<$.length){N.lastIndex=A,R.lastIndex=A;let S=N.exec($),b=R.exec($);if(!b)break;if(S&&S.index<b.index)w++,A=S.index+S[0].length;else{if(w--,w===0){T=b.index;break}A=b.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,C=0;while(C<M.length){let S=M.indexOf("@",C);if(S===-1)break;let b=M.substring(S);if(/^@forelse\s*\(/.test(b))E++,C=S+1;else if(b.startsWith("@endforelse"))E--,C=S+11;else if(E===0&&b.startsWith("@empty")){if(M.length<=S+6||!/[a-z]/i.test(M[S+6])){D=S;break}C=S+1}else C=S+1}if(D===-1)continue;return{start:W,end:I,arrayExpr:L,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function fZ($,Z){let Y=$;while(!0){let X=kz(Y);if(!X)break;let{start:Q,end:J,arrayExpr:G,itemVar:K,foreachContent:z,emptyContent:q}=X;try{let W;if(Z0(G))W=Y0(G,Object.keys(Z))(...Object.values(Z));else W=$0(G,Z);let U;if(!Array.isArray(W)||W.length===0)U=q;else U=`@foreach (${G} as ${K})${z}@endforeach`;Y=Y.substring(0,Q)+U+Y.substring(J)}catch(W){let U=W instanceof Error?W.message:String(W),B=r("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,i.EVALUATION_ERROR);Y=Y.substring(0,Q)+B+Y.substring(J)}}return Y}function B3($,Z,Y,X){let Q=$;Q=fZ(Q,Z);function J(z){let q=/@foreach\s*\(/g,W;while((W=q.exec(z))!==null){let U=W.index,B=W.index+W[0].length-1,_=1,j=B+1,H=-1;while(j<z.length&&_>0){if(z[j]==="(")_++;else if(z[j]===")"){if(_--,_===0){H=j;break}}j++}if(H===-1)continue;let F=z.substring(B+1,H),L=F.indexOf(" as ");if(L===-1)continue;let O=U,V=F.substring(0,L),w=F.substring(L+4),A=H+1,N=1,R=A,T=/@foreach\s*\(/g,M=/@endforeach/g;while(N>0&&R<z.length){T.lastIndex=R,M.lastIndex=R;let I=T.exec(z),D=M.exec(z);if(!D)break;if(I&&I.index<D.index)N++,R=I.index+I[0].length;else{if(N--,N===0){let E=z.substring(A,D.index),C=D.index+11;return{start:O,end:C,arrayExpr:V,itemVar:w,content:E}}R=D.index+11}}}return null}function G(z,q){let W=z;while(!0){let U=J(W);if(!U)break;let{start:B,end:_,arrayExpr:j,itemVar:H,content:F}=U;try{let L=j.trim(),O;if(Z0(L))O=Y0(L,Object.keys(q))(...Object.values(q));else O=$0(L,q);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${L} is not iterable`,i.TYPE_ERROR);W=W.substring(0,B)+D+W.substring(_);continue}let w=X?.loops?.useAltLoopVariable??Tz,A=H.trim(),N=null,R,T=!1;if(A.includes("=>")){let D=A.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1];else R=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let D=A.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1],T=!0;else R=A}else R=A;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],C={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...q,loop:C,$loop:C};if(R.startsWith("[")&&R.endsWith("]")){let f=R.slice(1,-1).split(",").map((u)=>u.trim());if(Array.isArray(E))f.forEach((u,o)=>{if(u)S[u]=E[o]});else S[R]=E}else S[R]=E;if(N)if(!T&&V&&Array.isArray(E)&&E.length===2)S[N]=E[0],S[R]=E[1];else S[N]=D;let b=Dz(F,S),P=xZ(b);if(P.hasContinue){M+=P.content;continue}let d=vZ(b);if(d.hasBreak){M+=d.content;break}if(b=fZ(b,S),b=G(b,S),b=D1(b,S,Y),b=Ez(b),d=vZ(b),d.hasBreak){M+=d.content;break}if(P=xZ(b),P.hasContinue){M+=P.content;continue}b=l0(b,S,Y),b=Iz(b,S),b=Mz(b,S),M+=b}W=W.substring(0,B)+M+W.substring(_)}catch(L){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${L instanceof Error?L.message:String(L)}`,i.EVALUATION_ERROR);W=W.substring(0,B)+O+W.substring(_)}}return W}Q=G(Q,Z),Q=dZ(Q,Z,Y,X);let K=X?.loops?.maxWhileIterations??Rz;return Q=yz(Q,Z,K),Q}function hZ($){return d5($)}function dZ($,Z,Y,X){let Q=$,J=!0;while(J){J=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=K+G[0].length-1,q=D0(Q,"(",")",z);if(q===-1)break;let W=Q.slice(z+1,q),U=q+1,B=k$(Q.slice(K),"for","endfor");if(B.length===0)break;let _=B[0].content,j=K+B[0].end;if(!hZ(W)){let H=r("For",`Unsafe expression in @for: ${W}`,i.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(j),J=!0;continue}try{let H=Sz(W),F=/@(?:for|foreach|if|unless)\s*\(/.test(_);if(H.length>0&&F){let N=bz({forExpr:W,content:_,iterVarNames:H,context:Z,filePath:Y,options:X});Q=Q.substring(0,K)+N+Q.substring(j),J=!0;continue}let L=Object.keys(Z),O=Object.values(Z),V=_.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(N,R)=>{return`\${${R}}`});V=gZ(V);let A=Function(...L,`
2694
+ `||T==="\t")L++;O=N+H.length}else{if(L--,L===0){V=R;break}O=R+F.length}}if(V===-1){Q=B;continue}let w=$.slice(B,V),A=V+F.length;X.push({fullMatch:$.slice(J,A),tagName:z,attributes:j,content:w,startIndex:J,endIndex:A,isSelfClosing:!1}),Q=A}}return X}function IZ($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var DZ=k(()=>{H0();O0();I$()});var CZ={};n(CZ,{processESImports:()=>yZ,processComponents:()=>m$});import u$ from"fs";import v0 from"path";function Hz($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),J=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,z)=>z.toUpperCase())};for(let[G,K]of Object.entries($)){let z=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(z.startsWith("@")){X.events[z]=K;continue}if(z.startsWith("__stx_")){let q=J(z.slice(6));X.serverDynamic[q]=IZ(K,Y);continue}if(z.startsWith(":")){let q=J(z.slice(1)),W=K==="true"?q:K;try{if(!Z0(W)){if(Y.debug)console.error(`Unsafe expression in :${q} binding: ${W}`);X.clientReactive[q]=W;continue}let U=Object.keys(Z),_=Y0(W,U)(...Object.values(Z));if(_===void 0){let j=W.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((L)=>!H.has(L)&&!U.includes(L))){X.clientReactive[q]=W;continue}}X.serverDynamic[q]=_}catch{X.clientReactive[q]=W}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let q=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(q)try{let W=q[1];if(Z0(W)){let B=Y0(W,Object.keys(Z))(...Object.values(Z));X.static[z]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${z}: ${W}`);X.static[z]=K}}catch(W){if(Y.debug)console.error(`Error evaluating expression for ${z}:`,W);X.static[z]=K}else{let W=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=U.exec(K))!==null)try{let _=B[1];if(!Z0(_)){if(Y.debug)console.error(`Unsafe expression in ${z}: ${_}`);continue}let H=Y0(_,Object.keys(Z))(...Object.values(Z));W=W.replace(B[0],String(H??""))}catch(_){if(Y.debug)console.error(`Error evaluating expression in ${z}:`,_)}X.static[z]=W}continue}X.static[z]=K}return X}function Oz($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let Q="";while(Y<X&&!/[\s=]/.test($[Y]))Q+=$[Y],Y++;if(!Q)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let J="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,J+=$[Y],Y++;continue}if(K===G){Y++;break}J+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))J+=$[Y],Y++;Z[Q]=J}else Z[Q]="true"}return Z}function kZ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Lz($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let Q=X[1];if(k0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function Fz($){let Z=SZ.get($);if(Z)return Z;let Y=new Map,X=[v0.join($,"src"),v0.join($,"dist"),$];function Q(J,G){if(G>6)return;let K;try{K=u$.readdirSync(J,{withFileTypes:!0})}catch{return}for(let z of K){let q=v0.join(J,z.name);if(z.isDirectory()){if(z.name==="node_modules"||z.name.startsWith("."))continue;Q(q,G+1)}else if(z.isFile()&&z.name.endsWith(".stx")){let W=z.name.slice(0,-4);if(!Y.has(W))Y.set(W,q);let U=W.toLowerCase();if(!Y.has(U))Y.set(U,q);let B=W.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,q)}}}for(let J of X)if(Q(J,0),Y.size>0)break;return SZ.set($,Y),Y}function Vz($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=v0.join(Y,"node_modules",$);try{if(u$.statSync(X).isDirectory())return X}catch{}let Q=v0.dirname(Y);if(Q===Y)return null;Y=Q}}async function yZ($,Z,Y,X,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let J=Z.__importedComponents,G=v0.dirname(Y),K=$,z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(z,(q,W,U)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,_=U,j,H=[];while((j=B.exec(U))!==null){let[F,L,O,V]=j,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=v0.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let M=`${T}.stx`;try{if(u$.statSync(M).isFile())A=M}catch{try{if(u$.statSync(T).isDirectory())w=T}catch{}}}}else w=Vz(V,G);if(!w&&!A)continue;let N=!1,R=(T,M)=>{J.set(T,M),J.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();J.set(I,M),Q.add(M)};if(O&&A)R(O,A),N=!0;else if(L){let T=L.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?Fz(w):null;for(let{source:I,local:D}of T){let E=null;if(A)E=A;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)R(D,E),N=!0}}if(N)H.push({start:j.index,end:j.index+F.length})}if(H.length===0)return q;for(let F=H.length-1;F>=0;F--)_=_.slice(0,H[F].start)+_.slice(H[F].end);return`<script${W}>${_}</script>`}),K}async function wz($,Z,Y,X,Q){let J=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=K.exec(J))!==null){let[q,W]=z,U=W.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of U){let _=B.split("/"),H=_[_.length-1].replace(/\.stx$/,""),F=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),L=null,O=[v0.resolve(v0.dirname(Y),`${B}.stx`),v0.resolve(v0.dirname(Y),B),v0.resolve(X.componentsDir||"components",`${B}.stx`),v0.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){L=V;break}}catch{}if(L){G.set(F,L),G.set(H,L),G.set(H.toLowerCase(),L);let V=F.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,L),Q.add(L),X.debug)console.log(`Imported component: ${F} -> ${L}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}J=J.replace(q,""),K.lastIndex=0}return J}async function Az($,Z,Y,X,Q){let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=/@component\s*\(/g,q;while((q=z.exec(J))!==null){let W=q.index,U=W+q[0].length-1,B=1,_=U+1;while(_<J.length&&B>0){if(J[_]==="(")B++;else if(J[_]===")"){if(B--,B===0)break}_++}if(B!==0)break;let j=J.substring(U+1,_),H=_+1,F=j.match(/^\s*['"]([^'"]+)['"]/);if(!F){z.lastIndex=0;continue}let L=F[1],O,V=j.slice(F[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let A={};if(O)try{A=j0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);J=J.replace(J.substring(W,H),`[Error parsing component props: ${E}]`);continue}let N="",R=H,M=J.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)N=M[1].trim(),R=H+M[0].length;let I=await k1(L,A,N,G,Z,Y,X,K,Q);J=J.substring(0,W)+I+J.substring(R),z.lastIndex=0}return J}async function Nz($,Z,Y,X,Q){if(!$)return $;let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=F7(J);return J=z.output,J=await B(J,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),J=await B(J,/[A-Z][a-zA-Z0-9]*/,!0),J=await B(J,/[a-z][a-z0-9]*/,!1,jz),J=V7(J,z.scripts),J;async function B(_,j,H,F){if(!_)return _;let L=_,O=MZ(L,j,F);for(let V=O.length-1;V>=0;V--){let w=O[V],A=H?TZ(w.tagName):w.tagName,N=Oz(w.attributes),R=Hz(N,Z,X),T=k0.getBuiltin(w.tagName),M=T?await PZ(A,G,Z,Y,X):!1;if(T&&!M){let C={context:Z,filePath:Y,options:X,dependencies:Q},S=T.render(R,w.content,C);if(Object.keys(R.clientReactive).length>0)S=bZ(S,R.clientReactive);if(Object.keys(R.events).length>0){let y=Object.entries(R.events).map(([P,d])=>`${P}="${kZ(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${y}`)}L=L.substring(0,w.startIndex)+S+L.substring(w.endIndex);continue}let I={};for(let[C,S]of Object.entries(R.static))I[C]=S;for(let[C,S]of Object.entries(R.serverDynamic))I[C]=S;let E=await k1(A,I,w.content,G,Z,Y,X,K,Q);if(Object.keys(R.clientReactive).length>0)E=bZ(E,R.clientReactive);if(Object.keys(R.events).length>0){let C=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(C){let S=Object.entries(R.events).map(([P,d])=>`${P}="${kZ(d)}"`).join(" "),y=C[1].length+C[2].length;E=E.substring(0,y)+" "+S+E.substring(y)}}L=L.substring(0,w.startIndex)+E+L.substring(w.endIndex)}return L}}function bZ($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([J,G])=>`:${J}="${G.replace(/"/g,"&quot;")}"`).join(" "),Q=Y[1].length+Y[2].length;return $.substring(0,Q)+" "+X+$.substring(Q)}async function m$($,Z,Y,X,Q){if(!EZ)NZ(),EZ=!0;let J=await yZ($,Z,Y,X,Q);J=await wz(J,Z,Y,X,Q),J=await Az(J,Z,Y,X,Q);for(let G=0;G<3;G++){let K=J;if(J=await Nz(J,Z,Y,X,Q),J===K)break}if(X.debug){let G=Lz(J);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return J}var EZ=!1,jz,SZ;var U3=k(()=>{d7();RZ();DZ();O0();H0();jz=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);SZ=new Map});var uZ={};n(uZ,{processLoops:()=>B3});function Mz($,Z){let Y=/@component\s*\(/g,X=$,Q,J=[];while((Q=Y.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,z=1,q=K+1;while(q<X.length&&z>0){if(X[q]==="(")z++;else if(X[q]===")"){if(z--,z===0)break}q++}if(z!==0)continue;let W=X.substring(K+1,q),U=q+1,B=W.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let _=B[1],j=W.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let F=j.slice(H[0].length).trim();if(!F)continue;try{let L=j0(F,Z),O=JSON.stringify(L),V=`@component('${_}', ${O})`;J.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=J.length-1;G>=0;G--){let{start:K,end:z,replacement:q}=J[G];X=X.substring(0,K)+q+X.substring(z)}return X}function p$($,Z,Y){let X=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),J;while((J=Q.exec(X))!==null){let G=J.index,K=G+J[0].length-1,z=1,q=K+1,W=null,U=!1;while(q<X.length&&z>0){let j=X[q];if(U){U=!1,q++;continue}if(j==="\\"&&W){U=!0,q++;continue}if(W){if(j===W)W=null;q++;continue}if(j==='"'||j==="'"||j==="`"){W=j,q++;continue}if(j==="(")z++;else if(j===")"){if(z--,z===0)break}q++}if(z!==0)break;let B=X.substring(K+1,q),_=Y(B);X=X.substring(0,G)+_+X.substring(q+1)}return X}function Iz($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,Q,J)=>{try{let G=Object.keys(Z),K=Object.values(Z);h5(J);let q=Y0(J,G)(...K),W=JSON.stringify(q),U=Buffer.from(W,"utf8").toString("base64");return`__stx_${Q}="${U}"`}catch(G){return X}}),Y}function Dz($,Z){let Y=$;return Y=p$(Y,"@break",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?c$:""}catch{return""}}),Y=p$(Y,"@continue",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?l$:""}catch{return""}}),Y}function Ez($){let Z=$;return Z=Z.replace(/@break(?!\()/g,c$),Z=Z.replace(/@continue(?!\()/g,l$),Z}function vZ($){let Z=$.includes(c$),Y=Z?$.substring(0,$.indexOf(c$)):$;return{hasBreak:Z,content:Y}}function xZ($){let Z=$.includes(l$),Y=Z?$.substring(0,$.indexOf(l$)):$;return{hasContinue:Z,content:Y}}function gZ($){let Z=$;return Z=p$(Z,"@break",(Y)=>{let X=Y.trim();if(!d5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=p$(Z,"@continue",(Y)=>{let X=Y.trim();if(!d5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function kz($){let Z=/@forelse\s*\(/g,Y,X=[],Q=/@foreach\s*\(/g,J=/@endforeach/g,G;while((G=Q.exec($))!==null)X.push({pos:G.index,delta:1});while((G=J.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((W,U)=>W.pos-U.pos);let K=[],z=0;for(let W of X)z+=W.delta,K.push({pos:W.pos,depth:z});function q(W){let U=0,B=K.length-1,_=0;while(U<=B){let j=U+B>>1;if(K[j].pos<=W)_=K[j].depth,U=j+1;else B=j-1}return _}while((Y=Z.exec($))!==null){if(q(Y.index)>0)continue;let W=Y.index,U=Y.index+Y[0].length-1,B=1,_=U+1,j=-1;while(_<$.length&&B>0){if($[_]==="(")B++;else if($[_]===")"){if(B--,B===0){j=_;break}}_++}if(j===-1)continue;let H=$.substring(U+1,j),F=H.indexOf(" as ");if(F===-1)continue;let L=H.substring(0,F).trim(),O=H.substring(F+4).trim(),V=j+1,w=1,A=V,N=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(w>0&&A<$.length){N.lastIndex=A,R.lastIndex=A;let S=N.exec($),y=R.exec($);if(!y)break;if(S&&S.index<y.index)w++,A=S.index+S[0].length;else{if(w--,w===0){T=y.index;break}A=y.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,C=0;while(C<M.length){let S=M.indexOf("@",C);if(S===-1)break;let y=M.substring(S);if(/^@forelse\s*\(/.test(y))E++,C=S+1;else if(y.startsWith("@endforelse"))E--,C=S+11;else if(E===0&&y.startsWith("@empty")){if(M.length<=S+6||!/[a-z]/i.test(M[S+6])){D=S;break}C=S+1}else C=S+1}if(D===-1)continue;return{start:W,end:I,arrayExpr:L,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function fZ($,Z){let Y=$;while(!0){let X=kz(Y);if(!X)break;let{start:Q,end:J,arrayExpr:G,itemVar:K,foreachContent:z,emptyContent:q}=X;try{let W;if(Z0(G))W=Y0(G,Object.keys(Z))(...Object.values(Z));else W=$0(G,Z);let U;if(!Array.isArray(W)||W.length===0)U=q;else U=`@foreach (${G} as ${K})${z}@endforeach`;Y=Y.substring(0,Q)+U+Y.substring(J)}catch(W){let U=W instanceof Error?W.message:String(W),B=r("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,i.EVALUATION_ERROR);Y=Y.substring(0,Q)+B+Y.substring(J)}}return Y}function B3($,Z,Y,X){let Q=$;Q=fZ(Q,Z);function J(z){let q=/@foreach\s*\(/g,W;while((W=q.exec(z))!==null){let U=W.index,B=W.index+W[0].length-1,_=1,j=B+1,H=-1;while(j<z.length&&_>0){if(z[j]==="(")_++;else if(z[j]===")"){if(_--,_===0){H=j;break}}j++}if(H===-1)continue;let F=z.substring(B+1,H),L=F.indexOf(" as ");if(L===-1)continue;let O=U,V=F.substring(0,L),w=F.substring(L+4),A=H+1,N=1,R=A,T=/@foreach\s*\(/g,M=/@endforeach/g;while(N>0&&R<z.length){T.lastIndex=R,M.lastIndex=R;let I=T.exec(z),D=M.exec(z);if(!D)break;if(I&&I.index<D.index)N++,R=I.index+I[0].length;else{if(N--,N===0){let E=z.substring(A,D.index),C=D.index+11;return{start:O,end:C,arrayExpr:V,itemVar:w,content:E}}R=D.index+11}}}return null}function G(z,q){let W=z;while(!0){let U=J(W);if(!U)break;let{start:B,end:_,arrayExpr:j,itemVar:H,content:F}=U;try{let L=j.trim(),O;if(Z0(L))O=Y0(L,Object.keys(q))(...Object.values(q));else O=$0(L,q);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${L} is not iterable`,i.TYPE_ERROR);W=W.substring(0,B)+D+W.substring(_);continue}let w=X?.loops?.useAltLoopVariable??Tz,A=H.trim(),N=null,R,T=!1;if(A.includes("=>")){let D=A.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1];else R=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let D=A.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1],T=!0;else R=A}else R=A;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],C={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...q,loop:C,$loop:C};if(R.startsWith("[")&&R.endsWith("]")){let f=R.slice(1,-1).split(",").map((u)=>u.trim());if(Array.isArray(E))f.forEach((u,o)=>{if(u)S[u]=E[o]});else S[R]=E}else S[R]=E;if(N)if(!T&&V&&Array.isArray(E)&&E.length===2)S[N]=E[0],S[R]=E[1];else S[N]=D;let y=Dz(F,S),P=xZ(y);if(P.hasContinue){M+=P.content;continue}let d=vZ(y);if(d.hasBreak){M+=d.content;break}if(y=fZ(y,S),y=G(y,S),y=D1(y,S,Y),y=Ez(y),d=vZ(y),d.hasBreak){M+=d.content;break}if(P=xZ(y),P.hasContinue){M+=P.content;continue}y=l0(y,S,Y),y=Iz(y,S),y=Mz(y,S),M+=y}W=W.substring(0,B)+M+W.substring(_)}catch(L){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${L instanceof Error?L.message:String(L)}`,i.EVALUATION_ERROR);W=W.substring(0,B)+O+W.substring(_)}}return W}Q=G(Q,Z),Q=dZ(Q,Z,Y,X);let K=X?.loops?.maxWhileIterations??Rz;return Q=yz(Q,Z,K),Q}function hZ($){return d5($)}function dZ($,Z,Y,X){let Q=$,J=!0;while(J){J=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=K+G[0].length-1,q=D0(Q,"(",")",z);if(q===-1)break;let W=Q.slice(z+1,q),U=q+1,B=k$(Q.slice(K),"for","endfor");if(B.length===0)break;let _=B[0].content,j=K+B[0].end;if(!hZ(W)){let H=r("For",`Unsafe expression in @for: ${W}`,i.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(j),J=!0;continue}try{let H=Sz(W),F=/@(?:for|foreach|if|unless)\s*\(/.test(_);if(H.length>0&&F){let N=bz({forExpr:W,content:_,iterVarNames:H,context:Z,filePath:Y,options:X});Q=Q.substring(0,K)+N+Q.substring(j),J=!0;continue}let L=Object.keys(Z),O=Object.values(Z),V=_.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(N,R)=>{return`\${${R}}`});V=gZ(V);let A=Function(...L,`
2695
2695
  let result = '';
2696
2696
  for (${W}) {
2697
2697
  result += \`${V}\`;
@@ -2748,12 +2748,12 @@ ${vz($).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>` try { __scopeR
2748
2748
  } finally {
2749
2749
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
2750
2750
  }
2751
- })();`}function fz($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let Q=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let J=Y[1],G=Y[2],K=Y[3];return{html:`${J}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function hz($){if($.__onceStore instanceof Set)return $.__onceStore;return gz}async function H3($,Z,Y,X,Q,J=new Set){let G=X.partialsDir||K0.join(K0.dirname(Y),"partials");if(G&&!K0.isAbsolute(G))G=K0.resolve(process.cwd(),G);let K=Cz($,"@partial","@include"),z=hz(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,F)=>{let L=H.trim(),O=`${Y}:${L}`;if(z.has(O))return"";return z.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let F=H.index,L=F+H[0].length-1,O=1,V=L+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(L+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let N=A[1],R=q(N,G,Y),T="";if(R&&await Bun.file(R).exists())Q.add(R),T=`@include(${w})`;K=K.substring(0,F)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let F=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),L;while((L=F.exec(K))!==null){let O=L.index,V=O+L[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let N=K.substring(V+1,A-1),R=j3(N,0);if(R===-1){F.lastIndex=A;continue}let T=N.substring(0,R).trim(),M=N.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){F.lastIndex=A;continue}let D=I[1],E=M.substring(I[0].length),C,S=j3(E,0);if(S!==-1)C=E.substring(S+1).trim();try{let b=`Boolean(${T})`,P;if(Z0(b)){let u=Y0(b,Object.keys(Z));P=Boolean(u(...Object.values(Z)))}else P=Boolean($0(b,Z));let d=H?!P:P,f="";if(d){let u=q(D,G,Y);if(u&&await Bun.file(u).exists())Q.add(u);f=`@include('${D}'${C?`, ${C}`:""})`}K=K.substring(0,O)+f+K.substring(A),F.lastIndex=0}catch(b){let P=b instanceof Error?b.message:String(b),d=J0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+d+K.substring(A),F.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let F=H.index,L=F+H[0].length-1,O=1,V=L+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(L+1,V),A=K.substring(F,V+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let[,R,T,M,I]=N;try{let D,E=T.trim();if(Z0(E))D=Y0(E,Object.keys(Z))(...Object.values(Z));else D=$0(E,Z);let C="";if(Array.isArray(D)&&D.length>0)for(let S of D){let b={...Z,[M]:S},P=await U(R,b,$,F);C+=P}else if(I)C=await U(I,{},$,F);K=K.substring(0,F)+C+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,F)+J0("Each",`Error in @each: ${E}`,Y,$,F)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let F=H.index,L=F+H[0].length-1,O=1,V=L+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(L+1,V),A=K.substring(F,V+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let R=N[1],T=w.slice(N[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let C=1,S=1;while(S<T.length&&C>0){if(T[S]==="{")C++;else if(T[S]==="}"){if(C--,C===0)break}S++}M=T.substring(0,S+1),T=T.slice(S+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let C=JSON.parse(R.replace(/'/g,'"')),S={};if(M)try{S=j0(M,Z)}catch(P){let d=P instanceof Error?P.message:String(P);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,F,A);K=K.replace(A,()=>f)}else K=K.replace(A,()=>D||"");continue}let b=!1;for(let P of C){let d=q(P,G,Y);if(!d)continue;if(await c(d)){let f=await U(P,S,$,F);K=K.replace(A,()=>f),b=!0;break}}if(!b)if(D!==void 0)K=K.replace(A,()=>D);else if(X.debug){let P=J0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,F,A);K=K.replace(A,()=>P)}else K=K.replace(A,"")}catch(C){let S=C instanceof Error?C.message:String(C),b=J0("Include",`Error processing @includeFirst: ${S}`,Y,$,F,A);K=K.replace(A,()=>b)}j.lastIndex=0}}function q(j,H,F){try{let L=j;if(!j.endsWith(".stx"))L=`${j}.stx`;let O=K0.resolve(H),V=K0.resolve(K0.dirname(F)),w;if(!L.startsWith("./")&&!L.startsWith("../"))w=K0.resolve(H,L);else w=K0.resolve(V,L);let A=K0.normalize(w),N=A.startsWith(O+K0.sep)||A===O,R=A.startsWith(V+K0.sep)||A===V,T=!1,M=K0.dirname(V);if(A.startsWith(M+K0.sep)){if(!K0.relative(M,A).split(K0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))T=!0}if(!N&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return A}catch(L){return console.error(`Error resolving path ${j}: ${L}`),null}}let W=K0.resolve(Y);J.add(W);async function U(j,H={},F,L){let O=q(j,G,Y);if(!O)return J0("Include",`Could not resolve path for include: ${j}`,Y,F,L);let V=K0.resolve(O);if(J.has(V)){let w=[...J,V].map((A)=>K0.basename(A)).join(" -> ");return J0("Include",`Circular include detected: ${w}`,Y,F,L)}try{Q.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let u=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${u}`,Y,F,L)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (M5(),T5));w=f(w,Z)}if(w&&(X.debug||!j5()&&!H$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (g7(),UZ));f(w,O)}catch{}let A=w;try{let{processESImports:f}=await Promise.resolve().then(() => (U3(),CZ));await f(w,Z,O,X,Q)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let N=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(N)A=N[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,u]of Object.entries(H))I[f]=u;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],C="",S=null;for(let f of E){let u=f[1]||"",o=f[2]||"",A0=u.includes("server"),o0=V1(u),b0="";try{let{extractAndStripCssImports:e,renderVendorStyleTags:_0}=await Promise.resolve().then(() => (W5(),O6)),W0=e(o,{filePath:O,projectRoot:process.cwd()});o=W0.code,b0=_0(W0.styles)}catch(e){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,e instanceof Error?e.message:e)}if(o0&&o.trim())o=w1(o);if(!A0)try{let{hasUserImports:e,bundleClientScript:_0}=await Promise.resolve().then(() => (p5(),m5));if(e(o))o=await _0(o,O,{projectRoot:process.cwd()})}catch(e){if(X.debug)console.warn(`[stx] bundler skipped for ${O}:`,e instanceof Error?e.message:e)}let M0=Pz(o);if(M0&&!A0){S=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++mZ}`;let e=r0(o),_0=xz(e,S);C+=`${b0}<script data-stx-scoped>${_0}</script>
2752
- `;continue}if(A0)try{let{extractVariables:e}=await Promise.resolve().then(() => (x1(),u5));await e(o,I,O)}catch(e){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,e)}if(!A0&&!M0){let e=u.replace(/\bclient\b/i,"").trim();S=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++mZ}`;let _0=r0(o),W0=`
2751
+ })();`}function fz($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let Q=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let J=Y[1],G=Y[2],K=Y[3];return{html:`${J}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function hz($){if($.__onceStore instanceof Set)return $.__onceStore;return gz}async function H3($,Z,Y,X,Q,J=new Set){let G=X.partialsDir||K0.join(K0.dirname(Y),"partials");if(G&&!K0.isAbsolute(G))G=K0.resolve(process.cwd(),G);let K=Cz($,"@partial","@include"),z=hz(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,F)=>{let L=H.trim(),O=`${Y}:${L}`;if(z.has(O))return"";return z.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let F=H.index,L=F+H[0].length-1,O=1,V=L+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(L+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let N=A[1],R=q(N,G,Y),T="";if(R&&await Bun.file(R).exists())Q.add(R),T=`@include(${w})`;K=K.substring(0,F)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let F=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),L;while((L=F.exec(K))!==null){let O=L.index,V=O+L[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let N=K.substring(V+1,A-1),R=j3(N,0);if(R===-1){F.lastIndex=A;continue}let T=N.substring(0,R).trim(),M=N.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){F.lastIndex=A;continue}let D=I[1],E=M.substring(I[0].length),C,S=j3(E,0);if(S!==-1)C=E.substring(S+1).trim();try{let y=`Boolean(${T})`,P;if(Z0(y)){let u=Y0(y,Object.keys(Z));P=Boolean(u(...Object.values(Z)))}else P=Boolean($0(y,Z));let d=H?!P:P,f="";if(d){let u=q(D,G,Y);if(u&&await Bun.file(u).exists())Q.add(u);f=`@include('${D}'${C?`, ${C}`:""})`}K=K.substring(0,O)+f+K.substring(A),F.lastIndex=0}catch(y){let P=y instanceof Error?y.message:String(y),d=J0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+d+K.substring(A),F.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let F=H.index,L=F+H[0].length-1,O=1,V=L+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(L+1,V),A=K.substring(F,V+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let[,R,T,M,I]=N;try{let D,E=T.trim();if(Z0(E))D=Y0(E,Object.keys(Z))(...Object.values(Z));else D=$0(E,Z);let C="";if(Array.isArray(D)&&D.length>0)for(let S of D){let y={...Z,[M]:S},P=await U(R,y,$,F);C+=P}else if(I)C=await U(I,{},$,F);K=K.substring(0,F)+C+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,F)+J0("Each",`Error in @each: ${E}`,Y,$,F)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let F=H.index,L=F+H[0].length-1,O=1,V=L+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(L+1,V),A=K.substring(F,V+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let R=N[1],T=w.slice(N[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let C=1,S=1;while(S<T.length&&C>0){if(T[S]==="{")C++;else if(T[S]==="}"){if(C--,C===0)break}S++}M=T.substring(0,S+1),T=T.slice(S+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let C=JSON.parse(R.replace(/'/g,'"')),S={};if(M)try{S=j0(M,Z)}catch(P){let d=P instanceof Error?P.message:String(P);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,F,A);K=K.replace(A,()=>f)}else K=K.replace(A,()=>D||"");continue}let y=!1;for(let P of C){let d=q(P,G,Y);if(!d)continue;if(await c(d)){let f=await U(P,S,$,F);K=K.replace(A,()=>f),y=!0;break}}if(!y)if(D!==void 0)K=K.replace(A,()=>D);else if(X.debug){let P=J0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,F,A);K=K.replace(A,()=>P)}else K=K.replace(A,"")}catch(C){let S=C instanceof Error?C.message:String(C),y=J0("Include",`Error processing @includeFirst: ${S}`,Y,$,F,A);K=K.replace(A,()=>y)}j.lastIndex=0}}function q(j,H,F){try{let L=j;if(!j.endsWith(".stx"))L=`${j}.stx`;let O=K0.resolve(H),V=K0.resolve(K0.dirname(F)),w;if(!L.startsWith("./")&&!L.startsWith("../"))w=K0.resolve(H,L);else w=K0.resolve(V,L);let A=K0.normalize(w),N=A.startsWith(O+K0.sep)||A===O,R=A.startsWith(V+K0.sep)||A===V,T=!1,M=K0.dirname(V);if(A.startsWith(M+K0.sep)){if(!K0.relative(M,A).split(K0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))T=!0}if(!N&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return A}catch(L){return console.error(`Error resolving path ${j}: ${L}`),null}}let W=K0.resolve(Y);J.add(W);async function U(j,H={},F,L){let O=q(j,G,Y);if(!O)return J0("Include",`Could not resolve path for include: ${j}`,Y,F,L);let V=K0.resolve(O);if(J.has(V)){let w=[...J,V].map((A)=>K0.basename(A)).join(" -> ");return J0("Include",`Circular include detected: ${w}`,Y,F,L)}try{Q.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let u=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${u}`,Y,F,L)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (M5(),T5));w=f(w,Z)}if(w&&(X.debug||!j5()&&!H$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (g7(),UZ));f(w,O)}catch{}let A=w;try{let{processESImports:f}=await Promise.resolve().then(() => (U3(),CZ));await f(w,Z,O,X,Q)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let N=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(N)A=N[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,u]of Object.entries(H))I[f]=u;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],C="",S=null;for(let f of E){let u=f[1]||"",o=f[2]||"",A0=u.includes("server"),o0=V1(u),b0="";try{let{extractAndStripCssImports:e,renderVendorStyleTags:_0}=await Promise.resolve().then(() => (W5(),O6)),W0=e(o,{filePath:O,projectRoot:process.cwd()});o=W0.code,b0=_0(W0.styles)}catch(e){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,e instanceof Error?e.message:e)}if(o0&&o.trim())o=w1(o);if(!A0)try{let{hasUserImports:e,bundleClientScript:_0}=await Promise.resolve().then(() => (p5(),m5));if(e(o))o=await _0(o,O,{projectRoot:process.cwd()})}catch(e){if(X.debug)console.warn(`[stx] bundler skipped for ${O}:`,e instanceof Error?e.message:e)}let I0=Pz(o);if(I0&&!A0){S=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++mZ}`;let e=r0(o),_0=xz(e,S);C+=`${b0}<script data-stx-scoped>${_0}</script>
2752
+ `;continue}if(A0)try{let{extractVariables:e}=await Promise.resolve().then(() => (x1(),u5));await e(o,I,O)}catch(e){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,e)}if(!A0&&!I0){let e=u.replace(/\bclient\b/i,"").trim();S=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++mZ}`;let _0=r0(o),W0=`
2753
2753
  if (!window.stx._scopes) window.stx._scopes = {};
2754
2754
  window.stx._scopes['${S}'] = { __destroyCallbacks: __destroyHooks };
2755
- `,y=pZ(_0,W0);C+=`${b0}<script data-stx-scoped${e?` ${e}`:""}>${y}</script>
2756
- `}}if(S){let f=fz(A,S);if(A=f.html,f.mergedIntoExisting)C=C.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await H3(A,I,O,X,Q,J);let{processLoops:b}=await Promise.resolve().then(() => (_3(),uZ)),P=b(A,I,O);P=D1(P,I,O);let d=o1(w);if(P=l0(P,I,O,{forceSignals:d}),M)P+=`
2755
+ `,b=pZ(_0,W0);C+=`${b0}<script data-stx-scoped${e?` ${e}`:""}>${b}</script>
2756
+ `}}if(S){let f=fz(A,S);if(A=f.html,f.mergedIntoExisting)C=C.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await H3(A,I,O,X,Q,J);let{processLoops:y}=await Promise.resolve().then(() => (_3(),uZ)),P=y(A,I,O);P=D1(P,I,O);let d=o1(w);if(P=l0(P,I,O,{forceSignals:d}),M)P+=`
2757
2757
  `+M;if(C)P+=`
2758
2758
  `+C;return P}catch(w){let A=w instanceof Error?w.message:String(w);return J0("Include",`Error processing include ${j}: ${A}`,Y,F,L)}}let B=/@include\s*\(/g,_;while((_=B.exec(K))!==null){let j=_.index,H=j+_[0].length-1,F=1,L=H+1;while(L<K.length&&F>0){if(K[L]==="(")F++;else if(K[L]===")")F--;L++}if(F!==0)break;let O=K.substring(j,L),V=K.substring(H+1,L-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){B.lastIndex=L;continue}let A=w[1],N,R=V.substring(w[0].length),T=j3(R,0);if(T!==-1)N=R.substring(T+1).trim();let M={};if(N)try{M=j0(N,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,J0("Include",`Error parsing include variables for ${A}: ${E}`,Y,$,j)),B.lastIndex=0;continue}let I=await U(A,M,$,j);K=K.substring(0,j)+I+K.substring(L),B.lastIndex=0}return K}function O3($,Z){let Y=$;function X(Q,J,G,K){let z=Q,q=!0;while(q){q=!1;let W=new RegExp(`@${J}\\(['"]([^'"]+)['"]\\)`),U=z.match(W);if(!U||U.index===void 0)break;let B=U.index,_=U[1],j=B+U[0].length,H=new RegExp(`@${J}\\(`),F=new RegExp(`@${G}(?![a-z])`),L=1,O=j,V=-1;while(L>0&&O<z.length){let A=z.slice(O),N=A.match(H),R=A.match(F),T=N?O+N.index:1/0,M=R?O+R.index:1/0;if(T<M)L++,O=T+(N[0].length||1);else if(M<1/0){if(L--,L===0){V=M;break}O=M+G.length+1}else break}if(V===-1)break;let w=z.slice(j,V);if(!Z[_])Z[_]=[];if(K)Z[_].unshift(w);else Z[_].push(w);z=z.substring(0,B)+z.substring(V+`@${G}`.length),q=!0}return z}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function L3($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
2759
2759
  `)})}var mZ=0,HL,gz;var cZ=k(()=>{b$();u0();h1();H0();O0();HL=new q5(500),gz=new Set});import*as F3 from"path";async function lZ($,Z,Y=""){if(F3.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return nZ($,Z,Y,"@js","@endjs")}async function iZ($,Z,Y=""){if(F3.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return nZ($,Z,Y,"@ts","@endts")}async function nZ($,Z,Y,X,Q){let J=$,G=g1(`${X}([\\s\\S]*?)${Q}`,"g"),K=[],z;while((z=G.exec($))!==null)K.push({fullMatch:z[0],content:z[1]||"",index:z.index});for(let{fullMatch:q,content:W,index:U}of K)try{let B=Object.keys(Z),_=Object.values(Z),j=W.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let F=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),L=F.length>0?`return { ${F.join(", ")} };`:"return {};",O=`
@@ -7235,10 +7235,10 @@ else {
7235
7235
  var root = scriptEl ? scriptEl.nextElementSibling : null;
7236
7236
  if (!root && scriptEl) root = scriptEl.previousElementSibling || scriptEl.parentElement;
7237
7237
 
7238
- // SPA fallback: during router navigation, script is appended to <body>
7238
+ // SPA fallback: during router navigation, script is appended to body>
7239
7239
  // (not inside the content container), so nextElementSibling won't find the page content.
7240
7240
  // Only use fallback when we genuinely couldn't find a suitable root element.
7241
- // Do NOT fallback just because the script is in <body> \u2014 layout scripts in <body>
7241
+ // Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
7242
7242
  // with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
7243
7243
  var needsFallback = !root || root === document.body
7244
7244
  || (root && root.tagName === 'SCRIPT');
@@ -7557,7 +7557,7 @@ else {
7557
7557
  mountCallbacks.forEach(fn => fn());
7558
7558
  });
7559
7559
 
7560
- // Multi-root fragment fix: a no-<body> setup page tags only the FIRST
7560
+ // Multi-root fragment fix: a no-body> setup page tags only the FIRST
7561
7561
  // top-level element with data-stx (signal-processing.ts marks one element),
7562
7562
  // so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
7563
7563
  // never hydrated, which read as "{{ }} doesn't work under :if/:for". The
@@ -7654,7 +7654,7 @@ else {
7654
7654
  el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
7655
7655
  });
7656
7656
 
7657
- // Process <head> elements (title, meta) that may contain {{ }} expressions
7657
+ // Process head> elements (title, meta) that may contain {{ }} expressions
7658
7658
  // Use componentScope which now contains variables from processed components
7659
7659
  const headElements = document.querySelectorAll('head title, head meta[content]');
7660
7660
  headElements.forEach(el => {
@@ -7850,7 +7850,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
7850
7850
 
7851
7851
  // Apply new page's SFC setup function. During SPA navigation, re-executed page
7852
7852
  // scripts set window.stx._latestSetup to the new setup function. This takes priority
7853
- // over the stale data-stx attribute on <body> (which has the PREVIOUS page's function name).
7853
+ // over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).
7854
7854
  var usedLatestSetup = false;
7855
7855
  if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
7856
7856
  try {
@@ -7934,7 +7934,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
7934
7934
 
7935
7935
  // Process the container content \u2014 bind {{ }}, :attr, @event directives.
7936
7936
  // Run synchronously (not in setTimeout) so componentScope is captured correctly.
7937
- // The DOMContentLoaded path processes <body> synchronously \u2014 the SPA path must match.
7937
+ // The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.
7938
7938
  console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));
7939
7939
  if (!container.__stx_scope) {
7940
7940
  // Dispose previous effects on the container (from prior navigation)
@@ -10776,23 +10776,23 @@ ${V}`:V,Z.__sections=j}}if(H)try{let O;if(S0.isAbsolute(H))O=H,Q.add(H);else O=a
10776
10776
  ${z}`,U(z)}catch(O){return d0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return U(await YX(z,Z,Y,G,Q))}function BU($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,X,Q)=>{let J=Z[X];if(J!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(J))return J}return Q||""})}function _U($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",X={};for(let[Q,J]of Object.entries(process.env))if(Q.startsWith(Y)&&J!==void 0)X[Q]=J;$.$env=X}async function jU($,Z){await m1(()=>Y2($,Z),void 0,(Y)=>{d0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function HU($,Z,Y){let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=X.exec($))!==null){let J=Q[1],G=Q[2];if(!/\bserver\b/.test(J)||!G.trim())continue;try{let{extractVariables:z}=await Promise.resolve().then(() => (x1(),u5));await z(G,Z,Y,{preserveExisting:!0})}catch(z){let q=z instanceof Error?z:Error(String(z));d0.log(q,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${q.message}`)}}}async function OU($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (u0(),JX));return X($,Z,{skipServer:!0})}catch(X){let Q=X instanceof Error?X:Error(String(X));return d0.log(Q,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${Q.message}`),$}}async function YX($,Z,Y,X,Q){let J=$,G=X;if(await HU(J,Z,Y),J=await OU(J,Z,Y),J=await lZ(J,Z,Y),J=await iZ(J,Z,Y),J=await i8(J,Z,Y,G),o1(J))J=S3(J,Z),J=y3(J,Z);J=b3(J);let{processStreamDirectives:K}=await Promise.resolve().then(() => (M5(),T5));J=K(J,Z),J=B3(J,Z,Y,G),J=await m$(J,Z,Y,G,Q),J=await q2(J,Z,Y,G,Q),J=E6(J,Z,Y,G);let{processDeferDirectives:z}=await Promise.resolve().then(() => i2);J=z(J,Z,Y);let{processTeleportDirectives:q}=await Promise.resolve().then(() => o2);J=q(J,Z,Y);let{processTransitionDirectives:W,processTransitionAttributes:U}=await Promise.resolve().then(() => t2);J=W(J,Z,Y),J=U(J);let{processErrorBoundaryDirectives:B}=await Promise.resolve().then(() => $Y);J=B(J,Z,Y);let{processSuspenseDirectives:_}=await Promise.resolve().then(() => ZY);J=_(J,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => QY);J=j(J,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => KY);J=H(J,Z,Y);let{processVirtualListDirectives:F,processVirtualGridDirectives:L,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (_Y(),BY));J=F(J,Z,Y),J=L(J,Z,Y),J=O(J,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:w}=await Promise.resolve().then(() => (EY(),DY));J=V(J,Z,Y),J=w(J);let{processComputedDirectives:A,processWatchDirectives:N}=await Promise.resolve().then(() => (dY(),hY));J=A(J,Z,Y),J=N(J,Z,Y);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (lY(),cY));J=R(J,Z,Y);let{processHeadDirective:T,processTitleDirective:M,processMetaDirective:I,resetHead:D}=await Promise.resolve().then(() => (J5(),L4));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let E=T(J);if(J=E.content,E.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${E.headContent}
10777
10777
  `;if(J=M(J,Z),J=I(J,Z),J=$2(J),J=T7(J,Z),J=c8(J),J=sZ(J),J=await H3(J,Z,Y,G,Q),J=await m$(J,Z,Y,G,Q),J=J.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),J=v3(J),J=D1(J,Z,Y),J=M7(J,Z),J=I7(J,Z),J=P$(J,Z),J=a8(J,Z),J=t8(J,Z),J=await S8(J,Z,Y,G),J=await f6(J,Z,Y),J=await XZ(J,Z,Y,G),J=A6(J,Z,Y,G),J=l9(J,Z,Y,G),J=i9(J,Z,Y),J=n9(J,Z,Y,G),J=u8(J,Z,Y,G),J=z4(J,Z),J=W4(J),J=d2(J),!G.skipEventDirectives)J=R8(J,Z,Y);if(J=E8(J,Z,Y),G.debug){let x=/\bx-data\s*=/.test(J),g=K4($);if(x&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
10778
10778
  Both work on the same page, but they manage separate scopes.
10779
- Prefer signals (state/derived/effect) for new components.`)}J=Q2(J,Z),J=await l0(J,Z,Y),J=u2(J),J=m2(J),J=j8(J);let{processXElementDirectives:C}=await Promise.resolve().then(() => oY);J=C(J);let S=Z.__originalFilePath||Y,b=K5(Z);if(J=await C3(J,G,S,b),J=await tZ(J,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (rY(),sY));J=await g(J,{publicDir:x})}if(G.seo?.enabled)J=o9(J,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
10779
+ Prefer signals (state/derived/effect) for new components.`)}J=Q2(J,Z),J=await l0(J,Z,Y),J=u2(J),J=m2(J),J=j8(J);let{processXElementDirectives:C}=await Promise.resolve().then(() => oY);J=C(J);let S=Z.__originalFilePath||Y,y=K5(Z);if(J=await C3(J,G,S,y),J=await tZ(J,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (rY(),sY));J=await g(J,{publicDir:x})}if(G.seo?.enabled)J=o9(J,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
10780
10780
  </head>`);if(/<head\b[^>]*>/i.test(x))return x.replace(/(<head\b[^>]*>)/i,`$1
10781
10781
  ${g}`);if(/<html\b[^>]*>/i.test(x))return x.replace(/(<html\b[^>]*>)/i,`$1
10782
10782
  <head>
10783
10783
  ${g}
10784
10784
  </head>`);return x},{renderHead:d,getHead:f}=await Promise.resolve().then(() => (J5(),L4)),u=Z.__stx_runtime_head,o=u&&(u.title||u.meta?.length||u.link?.length)?u:f();if(o.title||o.meta?.length||o.link?.length){let x=d(o);if(x)J=P(J,x)}if(E.headContent)J=P(J,E.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)J=d8(J,G.csp,Z);if(G.analytics?.enabled)J=O8(J,G);if(G.heatmap?.enabled)J=C6(J,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:x}=await Promise.resolve().then(() => ($X(),eY));J=x(J,G)}let A0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(J),o0=/\bSTX\.\w+/.test(J),b0=/window\.STX\s*=/.test(J);if(A0&&o0&&!b0){let g=`<script data-stx-scoped>
10785
10785
  ${q8()}
10786
- </script>`;if(J.includes("</head>")){let m=J.indexOf("</head>"),Q0=J.slice(0,m).indexOf("<script");if(Q0!==-1){let I0=J.slice(0,Q0),y0=J.slice(Q0);J=I0+g+`
10786
+ </script>`;if(J.includes("</head>")){let m=J.indexOf("</head>"),Q0=J.slice(0,m).indexOf("<script");if(Q0!==-1){let N0=J.slice(0,Q0),y0=J.slice(Q0);J=N0+g+`
10787
10787
  `+y0}else J=J.replace("</head>",`${g}
10788
10788
  </head>`)}else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
10789
10789
  ${g}`);else J=g+`
10790
- `+J}{let x=/<script\s+server\b[^>]*>/gi,g,m=[];while((g=x.exec(J))!==null){let s=g.index+g[0].length,Q0=qU(J,s);if(Q0===-1)continue;let I0=Q0+9;while(I0<J.length&&/\s/.test(J[I0]))I0++;m.push({start:g.index,end:I0})}for(let s=m.length-1;s>=0;s--){let{start:Q0,end:I0}=m[s];J=J.substring(0,Q0)+J.substring(I0)}}let M0=n$(J,Y);if(M0.hasScoped)J=M0.html;let e=Z.__stx_event_bindings||[],_0=!1,W0=[],y=/\s:[a-z][\w.-]*\s*=/.test(J),{scanScriptTags:v}=await Promise.resolve().then(() => (P3(),v2));for(let x of v(J,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))W0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:m}of W0){_0=!0;let s=m;q4(m,Y,X.strict);let Q0=await z5(m,{eventBindings:e,attrs:g,hasColonDirectives:y,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});J=J.replace(x,()=>Q0)}if(_0)Z.__stx_event_bindings=[];return J}var C1="<!--PARENT_CONTENT_PLACEHOLDER-->";var x$=k(()=>{G8();I$();N4();U8();H8();L8();M4();R4();T8();W5();k8();b8();b$();m8();l8();o8();t0();J5();u0();e8();JZ();cZ();oZ();_3();I4();eZ();h1();Z2();W7();O0();X2();G2();W2();U2();w3();P3();U3();h2();x3();f3();H0();g7();x3();f3()});var QX=()=>{};var qX={};n(qX,{renderSlot:()=>KX,processSlots:()=>WX,parseSlots:()=>GX,parseSlotElement:()=>FU,extractSlotContent:()=>AU,applySlots:()=>NU});function LU($,Z){let Y=1,X=Z,Q="<template",J="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(Q,X)&&(X+Q.length>=$.length||/[\s>\/]/.test($[X+Q.length]))){Y++,X+=Q.length;continue}if($.startsWith(J,X)){let K=$.indexOf(">",X+J.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function GX($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,Q=[],J;while((J=X.exec($))!==null){let[W,U,B,_,j]=J,H=U||B||_,F=J.index+W.length,L=LU($,F);if(L!==-1){let O=$.slice(F,L-11).trim();Q.push({start:J.index,end:L,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}Q.sort((W,U)=>U.start-W.start);for(let W of Q)Y=Y.slice(0,W.start)+Y.slice(W.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,z;while((z=K.exec(Y))!==null){let[W,U,B,_,j,H]=z,F=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(F+L).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:z.index,end:z.index+W.length,slotName:_,element:V})}let q=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((z=q.exec(Y))!==null){let[W,U,B,_,j]=z,H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(H+F).trim(),O=`<${U}${L?" "+L:""} />`;G.push({start:z.index,end:z.index+W.length,slotName:_,element:O})}G.sort((W,U)=>U.start-W.start);for(let W of G){let U=Z.named.get(W.slotName);if(U)U.content+=W.element;else Z.named.set(W.slotName,{name:W.slotName,content:W.element});Y=Y.slice(0,W.start)+Y.slice(W.end)}return Z.default=Y.trim(),Z}function FU($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,J;while((J=Q.exec($))!==null)X[J[1]]=J[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function KX($,Z,Y,X){if(!$)return Y;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let J=$.propsBinding.trim(),G={...X};if(J.startsWith("{")&&J.endsWith("}")){let K=J.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean);for(let z of K){let[q,W]=z.split(":").map((B)=>B.trim()),U=W||q;if(Z[q]!==void 0)G[U]=Z[q]}}else G[J]=Z;Q=VU(Q,G)}return Q}function VU($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let Q=X.trim(),J=zX(Q,Z);return P0(String(J??""))}catch{return`{{ ${X} }}`}})}function zX($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),Q=Z;for(let J of X)if(Q&&typeof Q==="object"&&J in Q)Q=Q[J];else return;return Q}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,Q,J]=Y,G=Z[X],K=parseInt(J,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!Z0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function WX($,Z,Y){let X=$;X=await wU(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,z,q)=>{let W=Z.named.get(K),U=q?.trim()||"",B=z||"",_={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let F=H[1],L=H[2];_[F]=zX(L,Y)}return await KX(W,_,U,Y)});let J=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(J,(G,K)=>{if(G.includes("name="))return G;let z=K?.trim()||"";return Z.default||z}),X}async function wU($,Z,Y){let X=[],Q=[];$.replace(Z,(K,...z)=>{let q=z[z.length-2];return Q.push({match:K,index:q}),X.push(Y(K,...z.slice(0,-2))),K});let J=await Promise.all(X),G=$;for(let K=Q.length-1;K>=0;K--){let{match:z,index:q}=Q[K];G=G.slice(0,q)+J[K]+G.slice(q+z.length)}return G}function AU($){let Z=GX($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function NU($,Z,Y,X){return await WX($,{default:Z,named:Y},X)}var UX=k(()=>{u0();H0()});import RU from"fs";import h from"path";function BX($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function MU($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function V1($){return!MU($)}function w1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:c0()}).transformSync(Z);for(let J=0;J<Y.length;J++)Q=Q.replace(`"__STX_EXPR_${J}__"`,Y[J]),Q=Q.replace(`'__STX_EXPR_${J}__'`,Y[J]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function IU($){let Z=[],Y=new Set,X=0,Q=0,J=$.length,G=(W)=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]===W){Q++;return}Q++}},K=()=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let W=1;while(Q<J&&W>0)if($[Q]==="{")W++,Q++;else if($[Q]==="}")W--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},z=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<J&&$[Q]!==`
10791
- `)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<J-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},q=()=>{if(X!==0)return;let W=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(W){let j=W[2].split(",").map((H)=>{let F=H.trim().split(":");return F[F.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(Q<J){if(z())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){X++,Q++;continue}if($[Q]==="}"){X--,Q++;continue}if(X===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))q();Q++}return Z}function DU($){let Z=[],Y=0,X=0,Q=null;for(let J=0;J<$.length;J++){let G=$[J];if(Q){if(G==="\\"){J++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,J)),X=J+1}if(X<$.length)Z.push($.slice(X));return Z}function EU($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let Q=$[X];if(Y){if(Q==="\\"){X++;continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let J=$[X-1],G=$[X+1];if(J==="!"||J==="<"||J===">"||J==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function kU($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let Q=X,J=0,G=-1;for(;X>=0;X--){let z=$[X];if(z==="}")J++;else if(z==="{"){if(J--,J===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let z of DU(K)){let q=z.trim();if(!q||q.startsWith("..."))continue;let W=EU(q);if(W===-1)continue;let U=q.slice(0,W).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let B=q.slice(W+1).trim();if(!B)continue;try{let _=Object.keys(Z),j=Function(..._,`"use strict"; return (${B});`);Z[U]=j(..._.map((H)=>Z[H]))}catch{}}}catch{}}async function PZ($,Z,Y,X,Q){let J=$.endsWith(".stx")?$.slice(0,-4):$,G=(F)=>F.split("-").map((L)=>L.charAt(0).toUpperCase()+L.slice(1)).join(""),K=(F)=>F.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),z=Y.__importedComponents;if(z){for(let F of[J,J.toLowerCase(),G(J),K(J)])if(z.has(F))return!0}let q=[...new Set([`${J}.stx`,`${G(J)}.stx`,`${K(J)}.stx`])],W=typeof Q.root==="string"?h.resolve(Q.root):void 0,U=W??h.dirname(X),B=[],_=(F)=>{if(F&&!B.includes(F))B.push(F)},j=Y.__originalFilePath;if(j)_(h.join(h.dirname(j),"components"));_(Z),_(h.join(h.dirname(X),"components")),_(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let F of H)_(typeof F==="string"?F:null);if(W)_(h.resolve(W,"resources/views/components")),_(h.resolve(W,"resources/components")),_(h.resolve(W,"src/components")),_(h.resolve(W,"components"));if(J.startsWith("./")||J.startsWith("../"))return c(h.resolve(h.dirname(X),`${J}.stx`));for(let F of B){let L=h.isAbsolute(F)?F:h.resolve(U,F);for(let O of q)if(await c(h.join(L,O)))return!0}return!1}function SU($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function k1($,Z,Y,X,Q,J,G,K=new Set,z){let{extractVariables:q}=await Promise.resolve().then(() => (x1(),u5)),W=K??new Set;if(W.has($))return`[Circular component reference: ${$}]`;let U=new Set(W);U.add($);let B=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let _=B&&B!=="load"&&SU(B)?B:"";try{let j=(y)=>y.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(y)=>y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),F=$.endsWith(".stx")?$.slice(0,-4):$,L=null,O=Q.__importedComponents;if(O){let y=[F,F.toLowerCase(),j(F),H(F)];for(let v of y)if(O.has(v)){L=O.get(v);break}}let V=[];if(!L){let y=[`${F}.stx`,`${j(F)}.stx`,`${H(F)}.stx`],v=[...new Set(y)],x=Q.__originalFilePath,g=[];if(x){let z0=h.join(h.dirname(x),"components");g.push(z0)}if(X)g.push(X);let m=h.join(h.dirname(J),"components");if(!g.includes(m))g.push(m);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let z0 of s)if(typeof z0==="string"&&!g.includes(z0))g.push(z0)}let Q0=typeof G.root==="string"?h.resolve(G.root):void 0,I0=Q0??h.dirname(J),y0=[];if(Q0)y0.push(h.resolve(Q0,"resources/views/components")),y0.push(h.resolve(Q0,"resources/components")),y0.push(h.resolve(Q0,"src/components")),y0.push(h.resolve(Q0,"components"));y0.push(h.resolve(import.meta.dir,"components"));for(let z0 of y0)if(!g.includes(z0))g.push(z0);let j1=[...new Set(g.map((z0)=>{if(!z0)return z0;return h.isAbsolute(z0)?z0:h.resolve(I0,z0)}))];if(g.length=0,g.push(...j1),F.startsWith("./")||F.startsWith("../"))L=h.resolve(h.dirname(J),`${F}.stx`),V.push(L);else for(let z0 of g){if(!z0)continue;for(let H1 of v){let Y5=h.join(z0,H1);if(V.push(Y5),await c(Y5)){L=Y5;break}}if(L)break;if(!L)try{let H1=await import("fs");if(!H1.statSync(z0,{throwIfNoEntry:!1})?.isDirectory())continue;let v5=8,t=[{path:z0,depth:0}];while(t.length>0&&!L){let p0=t.pop();if(p0.depth>=v5)continue;let H4;try{H4=H1.readdirSync(p0.path,{withFileTypes:!0})}catch{continue}for(let x5 of H4){if(!x5.isDirectory())continue;if(x5.name==="node_modules"||x5.name.startsWith("."))continue;let n3=h.join(p0.path,x5.name);for(let DX of v){let O4=h.join(n3,DX);if(V.push(O4),await c(O4)){L=O4;break}}if(L)break;t.push({path:n3,depth:p0.depth+1})}}}catch{}if(L)break}}if(!L||!await c(L)){let y=V.length>0?`
10790
+ `+J}{let x=/<script\s+server\b[^>]*>/gi,g,m=[];while((g=x.exec(J))!==null){let s=g.index+g[0].length,Q0=qU(J,s);if(Q0===-1)continue;let N0=Q0+9;while(N0<J.length&&/\s/.test(J[N0]))N0++;m.push({start:g.index,end:N0}),x.lastIndex=N0}for(let s=m.length-1;s>=0;s--){let{start:Q0,end:N0}=m[s];J=J.substring(0,Q0)+J.substring(N0)}}let I0=n$(J,Y);if(I0.hasScoped)J=I0.html;let e=Z.__stx_event_bindings||[],_0=!1,W0=[],b=/\s:[a-z][\w.-]*\s*=/.test(J),{scanScriptTags:v}=await Promise.resolve().then(() => (P3(),v2));for(let x of v(J,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))W0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:m}of W0){_0=!0;let s=m;q4(m,Y,X.strict);let Q0=await z5(m,{eventBindings:e,attrs:g,hasColonDirectives:b,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:y});J=J.replace(x,()=>Q0)}if(_0)Z.__stx_event_bindings=[];return J}var C1="<!--PARENT_CONTENT_PLACEHOLDER-->";var x$=k(()=>{G8();I$();N4();U8();H8();L8();M4();R4();T8();W5();k8();b8();b$();m8();l8();o8();t0();J5();u0();e8();JZ();cZ();oZ();_3();I4();eZ();h1();Z2();W7();O0();X2();G2();W2();U2();w3();P3();U3();h2();x3();f3();H0();g7();x3();f3()});var QX=()=>{};var qX={};n(qX,{renderSlot:()=>KX,processSlots:()=>WX,parseSlots:()=>GX,parseSlotElement:()=>FU,extractSlotContent:()=>AU,applySlots:()=>NU});function LU($,Z){let Y=1,X=Z,Q="<template",J="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(Q,X)&&(X+Q.length>=$.length||/[\s>\/]/.test($[X+Q.length]))){Y++,X+=Q.length;continue}if($.startsWith(J,X)){let K=$.indexOf(">",X+J.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function GX($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,Q=[],J;while((J=X.exec($))!==null){let[W,U,B,_,j]=J,H=U||B||_,F=J.index+W.length,L=LU($,F);if(L!==-1){let O=$.slice(F,L-11).trim();Q.push({start:J.index,end:L,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}Q.sort((W,U)=>U.start-W.start);for(let W of Q)Y=Y.slice(0,W.start)+Y.slice(W.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,z;while((z=K.exec(Y))!==null){let[W,U,B,_,j,H]=z,F=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(F+L).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:z.index,end:z.index+W.length,slotName:_,element:V})}let q=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((z=q.exec(Y))!==null){let[W,U,B,_,j]=z,H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(H+F).trim(),O=`<${U}${L?" "+L:""} />`;G.push({start:z.index,end:z.index+W.length,slotName:_,element:O})}G.sort((W,U)=>U.start-W.start);for(let W of G){let U=Z.named.get(W.slotName);if(U)U.content+=W.element;else Z.named.set(W.slotName,{name:W.slotName,content:W.element});Y=Y.slice(0,W.start)+Y.slice(W.end)}return Z.default=Y.trim(),Z}function FU($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,J;while((J=Q.exec($))!==null)X[J[1]]=J[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function KX($,Z,Y,X){if(!$)return Y;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let J=$.propsBinding.trim(),G={...X};if(J.startsWith("{")&&J.endsWith("}")){let K=J.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean);for(let z of K){let[q,W]=z.split(":").map((B)=>B.trim()),U=W||q;if(Z[q]!==void 0)G[U]=Z[q]}}else G[J]=Z;Q=VU(Q,G)}return Q}function VU($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let Q=X.trim(),J=zX(Q,Z);return P0(String(J??""))}catch{return`{{ ${X} }}`}})}function zX($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),Q=Z;for(let J of X)if(Q&&typeof Q==="object"&&J in Q)Q=Q[J];else return;return Q}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,Q,J]=Y,G=Z[X],K=parseInt(J,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!Z0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function WX($,Z,Y){let X=$;X=await wU(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,z,q)=>{let W=Z.named.get(K),U=q?.trim()||"",B=z||"",_={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let F=H[1],L=H[2];_[F]=zX(L,Y)}return await KX(W,_,U,Y)});let J=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(J,(G,K)=>{if(G.includes("name="))return G;let z=K?.trim()||"";return Z.default||z}),X}async function wU($,Z,Y){let X=[],Q=[];$.replace(Z,(K,...z)=>{let q=z[z.length-2];return Q.push({match:K,index:q}),X.push(Y(K,...z.slice(0,-2))),K});let J=await Promise.all(X),G=$;for(let K=Q.length-1;K>=0;K--){let{match:z,index:q}=Q[K];G=G.slice(0,q)+J[K]+G.slice(q+z.length)}return G}function AU($){let Z=GX($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function NU($,Z,Y,X){return await WX($,{default:Z,named:Y},X)}var UX=k(()=>{u0();H0()});import RU from"fs";import h from"path";function BX($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function MU($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function V1($){return!MU($)}function w1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:c0()}).transformSync(Z);for(let J=0;J<Y.length;J++)Q=Q.replace(`"__STX_EXPR_${J}__"`,Y[J]),Q=Q.replace(`'__STX_EXPR_${J}__'`,Y[J]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function IU($){let Z=[],Y=new Set,X=0,Q=0,J=$.length,G=(W)=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]===W){Q++;return}Q++}},K=()=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let W=1;while(Q<J&&W>0)if($[Q]==="{")W++,Q++;else if($[Q]==="}")W--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},z=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<J&&$[Q]!==`
10791
+ `)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<J-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},q=()=>{if(X!==0)return;let W=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(W){let j=W[2].split(",").map((H)=>{let F=H.trim().split(":");return F[F.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(Q<J){if(z())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){X++,Q++;continue}if($[Q]==="}"){X--,Q++;continue}if(X===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))q();Q++}return Z}function DU($){let Z=[],Y=0,X=0,Q=null;for(let J=0;J<$.length;J++){let G=$[J];if(Q){if(G==="\\"){J++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,J)),X=J+1}if(X<$.length)Z.push($.slice(X));return Z}function EU($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let Q=$[X];if(Y){if(Q==="\\"){X++;continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let J=$[X-1],G=$[X+1];if(J==="!"||J==="<"||J===">"||J==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function kU($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let Q=X,J=0,G=-1;for(;X>=0;X--){let z=$[X];if(z==="}")J++;else if(z==="{"){if(J--,J===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let z of DU(K)){let q=z.trim();if(!q||q.startsWith("..."))continue;let W=EU(q);if(W===-1)continue;let U=q.slice(0,W).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let B=q.slice(W+1).trim();if(!B)continue;try{let _=Object.keys(Z),j=Function(..._,`"use strict"; return (${B});`);Z[U]=j(..._.map((H)=>Z[H]))}catch{}}}catch{}}async function PZ($,Z,Y,X,Q){let J=$.endsWith(".stx")?$.slice(0,-4):$,G=(F)=>F.split("-").map((L)=>L.charAt(0).toUpperCase()+L.slice(1)).join(""),K=(F)=>F.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),z=Y.__importedComponents;if(z){for(let F of[J,J.toLowerCase(),G(J),K(J)])if(z.has(F))return!0}let q=[...new Set([`${J}.stx`,`${G(J)}.stx`,`${K(J)}.stx`])],W=typeof Q.root==="string"?h.resolve(Q.root):void 0,U=W??h.dirname(X),B=[],_=(F)=>{if(F&&!B.includes(F))B.push(F)},j=Y.__originalFilePath;if(j)_(h.join(h.dirname(j),"components"));_(Z),_(h.join(h.dirname(X),"components")),_(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let F of H)_(typeof F==="string"?F:null);if(W)_(h.resolve(W,"resources/views/components")),_(h.resolve(W,"resources/components")),_(h.resolve(W,"src/components")),_(h.resolve(W,"components"));if(J.startsWith("./")||J.startsWith("../"))return c(h.resolve(h.dirname(X),`${J}.stx`));for(let F of B){let L=h.isAbsolute(F)?F:h.resolve(U,F);for(let O of q)if(await c(h.join(L,O)))return!0}return!1}function SU($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function k1($,Z,Y,X,Q,J,G,K=new Set,z){let{extractVariables:q}=await Promise.resolve().then(() => (x1(),u5)),W=K??new Set;if(W.has($))return`[Circular component reference: ${$}]`;let U=new Set(W);U.add($);let B=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let _=B&&B!=="load"&&SU(B)?B:"";try{let j=(b)=>b.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(b)=>b.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),F=$.endsWith(".stx")?$.slice(0,-4):$,L=null,O=Q.__importedComponents;if(O){let b=[F,F.toLowerCase(),j(F),H(F)];for(let v of b)if(O.has(v)){L=O.get(v);break}}let V=[];if(!L){let b=[`${F}.stx`,`${j(F)}.stx`,`${H(F)}.stx`],v=[...new Set(b)],x=Q.__originalFilePath,g=[];if(x){let z0=h.join(h.dirname(x),"components");g.push(z0)}if(X)g.push(X);let m=h.join(h.dirname(J),"components");if(!g.includes(m))g.push(m);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let z0 of s)if(typeof z0==="string"&&!g.includes(z0))g.push(z0)}let Q0=typeof G.root==="string"?h.resolve(G.root):void 0,N0=Q0??h.dirname(J),y0=[];if(Q0)y0.push(h.resolve(Q0,"resources/views/components")),y0.push(h.resolve(Q0,"resources/components")),y0.push(h.resolve(Q0,"src/components")),y0.push(h.resolve(Q0,"components"));y0.push(h.resolve(import.meta.dir,"components"));for(let z0 of y0)if(!g.includes(z0))g.push(z0);let j1=[...new Set(g.map((z0)=>{if(!z0)return z0;return h.isAbsolute(z0)?z0:h.resolve(N0,z0)}))];if(g.length=0,g.push(...j1),F.startsWith("./")||F.startsWith("../"))L=h.resolve(h.dirname(J),`${F}.stx`),V.push(L);else for(let z0 of g){if(!z0)continue;for(let H1 of v){let Y5=h.join(z0,H1);if(V.push(Y5),await c(Y5)){L=Y5;break}}if(L)break;if(!L)try{let H1=await import("fs");if(!H1.statSync(z0,{throwIfNoEntry:!1})?.isDirectory())continue;let v5=8,t=[{path:z0,depth:0}];while(t.length>0&&!L){let p0=t.pop();if(p0.depth>=v5)continue;let H4;try{H4=H1.readdirSync(p0.path,{withFileTypes:!0})}catch{continue}for(let x5 of H4){if(!x5.isDirectory())continue;if(x5.name==="node_modules"||x5.name.startsWith("."))continue;let n3=h.join(p0.path,x5.name);for(let DX of v){let O4=h.join(n3,DX);if(V.push(O4),await c(O4)){L=O4;break}}if(L)break;t.push({path:n3,depth:p0.depth+1})}}}catch{}if(L)break}}if(!L||!await c(L)){let b=V.length>0?`
10792
10792
  Searched paths:
10793
10793
  ${V.map((v)=>` - ${v}`).join(`
10794
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${y}`}z.add(L);let w;if(m3.has(L))w=m3.get(L);else try{w=await Bun.file(L).text(),m3.set(L,w)}catch(y){return`[Error loading component: ${y instanceof Error?y.message:String(y)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[y,v]of Object.entries(Q))if(!y.startsWith("__")||A.has(y))N[y]=v;let R={...N,...Z,props:Z,slot:Y,__processedComponents:U,__sections:{}};kU(w,R);let T=w,M=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)T=M[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let y of D){let v=y[1]||"",x=y[2]||"",g=v.includes("server");if(V1(v)&&x.trim())x=w1(x);if(g&&x)try{await q(x,R,L)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=l0(s,R,L);let Q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${Q0}>${s}</script>`)}}let C=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=C?C[1]:"",b=C?C[2]:"",P="",d=S&&/\bscoped\b/i.test(S);if(C)P=`<style${S}>${b}</style>`;let f=T;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),C)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let y=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(y,(x,g)=>{let m=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(m)v.push(`<style${m[1]}>${m[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
10795
- `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:u,applySlots:o}=await Promise.resolve().then(() => (UX(),qX)),{defaultSlot:A0,namedSlots:o0}=u(Y);f=await o(f,A0||Y,o0,R);for(let[y,v]of Object.entries(R))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=c3(v);R[y]=x}}let b0=E.some((y)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(y)),M0={...G,componentsDir:h.dirname(L),skipSignalsRuntime:!0,skipEventDirectives:b0,defaultLayout:void 0};R.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let e=await V0(f,R,L,M0,z),_0=`stx_${F.replace(/[^a-zA-Z0-9]/g,"_")}_${++TU}_${Math.random().toString(36).slice(2,8)}`,W0=e;if(b0){let y="";if(Object.keys(Z).length>0)try{y=` data-stx-props="${BX(JSON.stringify(Z))}"`}catch{}let v=_?` stx-hydrate="${BX(_)}"`:"";if(W0=`<div data-stx-scope="${_0}"${y}${v}>${e}</div>`,W0=E.map((g)=>{let m=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!m)return g;let[,s,Q0]=m,I0=r0(Q0),y0=`
10794
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${b}`}z.add(L);let w;if(m3.has(L))w=m3.get(L);else try{w=await Bun.file(L).text(),m3.set(L,w)}catch(b){return`[Error loading component: ${b instanceof Error?b.message:String(b)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[b,v]of Object.entries(Q))if(!b.startsWith("__")||A.has(b))N[b]=v;let R={...N,...Z,props:Z,slot:Y,__processedComponents:U,__sections:{}};kU(w,R);let T=w,M=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)T=M[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let b of D){let v=b[1]||"",x=b[2]||"",g=v.includes("server");if(V1(v)&&x.trim())x=w1(x);if(g&&x)try{await q(x,R,L)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=l0(s,R,L);let Q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${Q0}>${s}</script>`)}}let C=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=C?C[1]:"",y=C?C[2]:"",P="",d=S&&/\bscoped\b/i.test(S);if(C)P=`<style${S}>${y}</style>`;let f=T;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),C)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let b=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(b,(x,g)=>{let m=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(m)v.push(`<style${m[1]}>${m[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
10795
+ `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:u,applySlots:o}=await Promise.resolve().then(() => (UX(),qX)),{defaultSlot:A0,namedSlots:o0}=u(Y);f=await o(f,A0||Y,o0,R);for(let[b,v]of Object.entries(R))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=c3(v);R[b]=x}}let b0=E.some((b)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(b)),I0={...G,componentsDir:h.dirname(L),skipSignalsRuntime:!0,skipEventDirectives:b0,defaultLayout:void 0};R.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let e=await V0(f,R,L,I0,z),_0=`stx_${F.replace(/[^a-zA-Z0-9]/g,"_")}_${++TU}_${Math.random().toString(36).slice(2,8)}`,W0=e;if(b0){let b="";if(Object.keys(Z).length>0)try{b=` data-stx-props="${BX(JSON.stringify(Z))}"`}catch{}let v=_?` stx-hydrate="${BX(_)}"`:"";if(W0=`<div data-stx-scope="${_0}"${b}${v}>${e}</div>`,W0=E.map((g)=>{let m=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!m)return g;let[,s,Q0]=m,N0=r0(Q0),y0=`
10796
10796
  (function() {
10797
10797
  const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
10798
10798
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -10804,12 +10804,12 @@ ${V.map((v)=>` - ${v}`).join(`
10804
10804
  const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
10805
10805
  const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
10806
10806
 
10807
- ${I0}
10807
+ ${N0}
10808
10808
 
10809
10809
  // Register all defined signals and functions in this scope
10810
10810
  const __localVars = {};
10811
10811
  try {
10812
- ${IU(I0).map((j1)=>`if (typeof ${j1} !== 'undefined') __localVars['${j1}'] = ${j1};`).join(`
10812
+ ${IU(N0).map((j1)=>`if (typeof ${j1} !== 'undefined') __localVars['${j1}'] = ${j1};`).join(`
10813
10813
  `)}
10814
10814
  }
10815
10815
  catch (e) {}
@@ -10818,9 +10818,9 @@ catch (e) {}
10818
10818
  `)+`
10819
10819
  `+W0,P)W0+=`
10820
10820
  `+P}else{if(P)W0+=`
10821
- `+P;if(E.length>0){let y=R.__stx_event_bindings||[],v=K5(R),x=await Promise.all(E.map(async(g)=>{let m=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!m)return g;return await z5(m[1],{eventBindings:y,templateContent:W0,filePath:L,projectRoot:process.cwd(),serverData:v})}));W0+=`
10821
+ `+P;if(E.length>0){let b=R.__stx_event_bindings||[],v=K5(R),x=await Promise.all(E.map(async(g)=>{let m=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!m)return g;return await z5(m[1],{eventBindings:b,templateContent:W0,filePath:L,projectRoot:process.cwd(),serverData:v})}));W0+=`
10822
10822
  `+x.join(`
10823
- `),R.__stx_event_bindings=[]}}if(d){let y=n$(W0,L);if(y.hasScoped)W0=y.html}return W0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{W.delete($)}}async function c($){return Bun.file($).exists()}function p3($,Z){let Y=h.resolve(Z),X=h.resolve($),Q=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(Q))return X;return null}async function q7($,Z,Y,X){let Q=await bU($,Z,Y,X);if(Q===null)return null;let J=p3(Q,process.cwd());if(J)return J;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let z=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(p3(Q,z))return h.resolve(Q)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Q} (template: ${$}, from: ${Z})`),null}async function bU($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let Q=h.dirname(Z),J=process.cwd();if($.startsWith("/")){let B=h.join(J,$),_=p3(B,J);if(!_)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${_}`);if(await c(_)&&X)X.add(_);return _}let G=h.join(Q,$);if(await c(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let B of[".stx",".tsx",".jsx"]){let _=`${G}${B}`;if(await c(_)){if(Y.debug)console.log(`Found direct path with extension: ${_}`);if(X)X.add(_);return _}}let K="",z=h.resolve(Q),q=process.cwd();for(let B=0;B<10;B++){let _=h.join(z,"layouts"),j=!1;try{j=RU.statSync(_,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=_;break}let H=h.dirname(z);if(H===z||H.length<q.length)break;z=H}if(K){let B=$.startsWith("layouts/")?$.slice(8):$,_=h.join(K,B);if(await c(_)){if(Y.debug)console.log(`Found in current layouts dir: ${_}`);if(X)X.add(_);return _}if(!B.endsWith(".stx")){let j=`${_}.stx`;if(await c(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let B=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),_=$.startsWith("layouts/")?$.slice(8):$,j=h.join(B,_);if(await c(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await c(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let B=$.split("layouts/"),_=h.join(Y.partialsDir||Q,"layouts",B[1]);if(await c(_)){if(Y.debug)console.log(`Found in layouts path: ${_}`);if(X)X.add(_);return _}if(!_.endsWith(".stx")){let j=`${_}.stx`;if(await c(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=h.join(Y.partialsDir,"layouts"),await c(K)){let B=h.join(K,$);if(await c(B)){if(Y.debug)console.log(`Found in partials layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let _=`${B}.stx`;if(await c(_)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${_}`);if(X)X.add(_);return _}}}}let W=Y.partialsDir||h.join(process.cwd(),"views"),U=h.join(W,$);if(await c(U)){if(Y.debug)console.log(`Found in views path: ${U}`);if(X)X.add(U);return U}if(!$.endsWith(".stx")){let B=`${U}.stx`;if(await c(B)){if(Y.debug)console.log(`Found in views path with extension: ${B}`);if(X)X.add(B);return B}}if(Q.includes("temp")){let B=h.join(h.dirname(Q),"layouts",$);if(await c(B)){if(Y.debug)console.log(`Found in temp layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let _=`${B}.stx`;if(await c(_)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${_}`);if(X)X.add(_);return _}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function _X($,Z,Y){let X=0,Q="",J="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10823
+ `),R.__stx_event_bindings=[]}}if(d){let b=n$(W0,L);if(b.hasScoped)W0=b.html}return W0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{W.delete($)}}async function c($){return Bun.file($).exists()}function p3($,Z){let Y=h.resolve(Z),X=h.resolve($),Q=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(Q))return X;return null}async function q7($,Z,Y,X){let Q=await bU($,Z,Y,X);if(Q===null)return null;let J=p3(Q,process.cwd());if(J)return J;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let z=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(p3(Q,z))return h.resolve(Q)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Q} (template: ${$}, from: ${Z})`),null}async function bU($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let Q=h.dirname(Z),J=process.cwd();if($.startsWith("/")){let B=h.join(J,$),_=p3(B,J);if(!_)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${_}`);if(await c(_)&&X)X.add(_);return _}let G=h.join(Q,$);if(await c(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let B of[".stx",".tsx",".jsx"]){let _=`${G}${B}`;if(await c(_)){if(Y.debug)console.log(`Found direct path with extension: ${_}`);if(X)X.add(_);return _}}let K="",z=h.resolve(Q),q=process.cwd();for(let B=0;B<10;B++){let _=h.join(z,"layouts"),j=!1;try{j=RU.statSync(_,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=_;break}let H=h.dirname(z);if(H===z||H.length<q.length)break;z=H}if(K){let B=$.startsWith("layouts/")?$.slice(8):$,_=h.join(K,B);if(await c(_)){if(Y.debug)console.log(`Found in current layouts dir: ${_}`);if(X)X.add(_);return _}if(!B.endsWith(".stx")){let j=`${_}.stx`;if(await c(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let B=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),_=$.startsWith("layouts/")?$.slice(8):$,j=h.join(B,_);if(await c(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await c(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let B=$.split("layouts/"),_=h.join(Y.partialsDir||Q,"layouts",B[1]);if(await c(_)){if(Y.debug)console.log(`Found in layouts path: ${_}`);if(X)X.add(_);return _}if(!_.endsWith(".stx")){let j=`${_}.stx`;if(await c(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=h.join(Y.partialsDir,"layouts"),await c(K)){let B=h.join(K,$);if(await c(B)){if(Y.debug)console.log(`Found in partials layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let _=`${B}.stx`;if(await c(_)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${_}`);if(X)X.add(_);return _}}}}let W=Y.partialsDir||h.join(process.cwd(),"views"),U=h.join(W,$);if(await c(U)){if(Y.debug)console.log(`Found in views path: ${U}`);if(X)X.add(U);return U}if(!$.endsWith(".stx")){let B=`${U}.stx`;if(await c(B)){if(Y.debug)console.log(`Found in views path with extension: ${B}`);if(X)X.add(B);return B}}if(Q.includes("temp")){let B=h.join(h.dirname(Q),"layouts",$);if(await c(B)){if(Y.debug)console.log(`Found in temp layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let _=`${B}.stx`;if(await c(_)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${_}`);if(X)X.add(_);return _}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function _X($,Z,Y){let X=0,Q="",J="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10824
10824
  `),K=0;for(let z=0;z<G.length;z++)if(K+=G[z].length+1,K>=Z){X=z+1,Q=G[z].trim();let q=Math.max(0,z-2),W=Math.min(G.length,z+3);J=G.slice(q,W).map((U,B)=>{let _=q+B+1;return`${_===X?"> ":" "}${_}: ${U}`}).join(`
10825
10825
  `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return _X($,G)}}catch{}return{lineNumber:X,lineContent:Q,context:J}}function J0($,Z,Y,X,Q,J){let{lineNumber:G,context:K}=_X(X,Q,J),z=Y.split("/").pop(),q=0;if(typeof Q==="number"&&Q>=0&&X){let U=X.lastIndexOf(`
10826
10826
  `,Math.max(0,Q-1));q=Q-(U+1)+1}let W="";if(G>0)W+=`