@stacksjs/stx 0.2.139 → 0.2.140
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.
- package/dist/cli.js +162 -145
- package/dist/client-script-bundler.d.ts +1 -1
- package/dist/client-script-bundler.js +2 -0
- package/dist/craft.js +30 -13
- package/dist/js-ts.js +4 -1
- package/dist/pwa.js +30 -13
- package/dist/signals.js +25 -8
- package/dist/ssg.js +30 -13
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -50,7 +50,7 @@ else {
|
|
|
50
50
|
});
|
|
51
51
|
})();
|
|
52
52
|
</script>
|
|
53
|
-
`}function rR($){return[/@animate\b/,/@transition\b/,/@scroll(?:Animate)?\b/,/@staggered\b/,/@sequence\b/,/@motion\b/,/@animationGroup\b/,/\bstx-transition\b/,/\bstx-(?:fade|scale|flip|rotate|slide|from-|observe)\b/,/data-animate=['"](?:auto|true|false)['"]/].some((Y)=>Y.test($))}function
|
|
53
|
+
`}function rR($){return[/@animate\b/,/@transition\b/,/@scroll(?:Animate)?\b/,/@staggered\b/,/@sequence\b/,/@motion\b/,/@animationGroup\b/,/\bstx-transition\b/,/\bstx-(?:fade|scale|flip|rotate|slide|from-|observe)\b/,/data-animate=['"](?:auto|true|false)['"]/].some((Y)=>Y.test($))}function aR($=0.1,Z="0px"){return`
|
|
54
54
|
<script data-stx-scoped>
|
|
55
55
|
// Intersection Observer for scroll animations
|
|
56
56
|
(function() {
|
|
@@ -93,7 +93,7 @@ else {
|
|
|
93
93
|
}
|
|
94
94
|
})();
|
|
95
95
|
</script>
|
|
96
|
-
`}function
|
|
96
|
+
`}function sR(){return`
|
|
97
97
|
<style id="stx-animation-base">
|
|
98
98
|
:root {
|
|
99
99
|
--stx-transition-duration: 300ms;
|
|
@@ -245,8 +245,8 @@ else {
|
|
|
245
245
|
}
|
|
246
246
|
})();
|
|
247
247
|
</script>
|
|
248
|
-
`}function IX($,Z,Y,J){let X=$;if(J.animation?.enabled===!1)return X;let Q=Y.includes("test")&&Y.includes("animation");if(!rR(X)&&!Q)return X;if(!X.includes('<style id="stx-animation-base">')){let K=
|
|
249
|
-
</head>`)}if(X.includes("stx-observe")){if(!X.includes("Intersection Observer for scroll animations")){let W=
|
|
248
|
+
`}function IX($,Z,Y,J){let X=$;if(J.animation?.enabled===!1)return X;let Q=Y.includes("test")&&Y.includes("animation");if(!rR(X)&&!Q)return X;if(!X.includes('<style id="stx-animation-base">')){let K=sR();X=X.replace("</head>",`${K}
|
|
249
|
+
</head>`)}if(X.includes("stx-observe")){if(!X.includes("Intersection Observer for scroll animations")){let W=aR(),U=X.lastIndexOf("</body>");if(U!==-1)X=X.slice(0,U)+W+`
|
|
250
250
|
`+X.slice(U)}}return X}function tR($,Z){let Y=Z.map((J)=>{let X=J.offset!==void 0?`${J.offset*100}%`:"from",Q=Object.entries(J.properties).map(([G,K])=>`${G}: ${K}`).join("; ");return`${X} { ${Q} }`}).join(`
|
|
251
251
|
`);return`@keyframes ${$} {
|
|
252
252
|
${Y}
|
|
@@ -383,8 +383,8 @@ else {
|
|
|
383
383
|
);
|
|
384
384
|
}
|
|
385
385
|
};
|
|
386
|
-
</script>`}function QM($){let Z=$.customDirectives||[];return Z.push(
|
|
387
|
-
style="--stx-transition-duration: ${Q}ms; --stx-transition-ease: ${G}; --stx-transition-delay: ${K}ms;">${$}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},
|
|
386
|
+
</script>`}function QM($){let Z=$.customDirectives||[];return Z.push(a3),Z.push(o3),Z.push(t3),Z.push(s3),Z.push(Wz),Z.push(Uz),Z.push(zz),{...$,customDirectives:Z}}var Qz,Gz,Kz,Q4,a3,s3,o3,t3,EX,Wz,Uz,zz;var e3=D(()=>{((G)=>{G.Fade="fade";G.Slide="slide";G.Scale="scale";G.Flip="flip";G.Rotate="rotate";G.Custom="custom"})(Qz||={});((J)=>{J.In="in";J.Out="out";J.Both="both"})(Gz||={});((G)=>{G.Linear="linear";G.Ease="ease";G.EaseIn="ease-in";G.EaseOut="ease-out";G.EaseInOut="ease-in-out";G.Spring="spring"})(Kz||={});Q4={duration:300,delay:0,ease:"ease",direction:"both"};a3={name:"transition",handler:($,Z,Y,J)=>{if(Z.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${$}`;let X=Z[0],Q=Z.length>1?Number.parseInt(Z[1],10)||Q4.duration:Q4.duration,G=Z.length>2?Z[2]||Q4.ease:Q4.ease,K=Z.length>3?Number.parseInt(Z[3],10)||Q4.delay:Q4.delay,W=Z.length>4?Z[4]||Q4.direction:Q4.direction,U=`stx-transition-${Math.random().toString(36).substr(2,9)}`,z=iR(X,{duration:Q,delay:K,ease:G,direction:W}),_="stx-transition",B="";if(X==="fade")B="stx-fade";else if(X==="slide")B="stx-slide";else if(X==="scale")B="stx-scale";else if(X==="flip")B="stx-flip";else if(X==="rotate")B="stx-rotate";return`<div id="${U}" class="${_} ${B} ${W==="out"?"stx-out":""}"
|
|
387
|
+
style="--stx-transition-duration: ${Q}ms; --stx-transition-ease: ${G}; --stx-transition-delay: ${K}ms;">${$}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},s3={name:"scrollAnimate",handler:($,Z,Y,J)=>{if(Z.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${$}`;let X=Z[0],Q=Z.length>1?Number.parseInt(Z[1],10)||300:300,G=Z.length>2?Z[2]||"ease":"ease",K=Z.length>3?Number.parseFloat(Z[3])||0.2:0.2,W=Z.length>4?Number.parseInt(Z[4],10)||0:0,U=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,z=`--stx-transition-duration: ${Q}ms; --stx-transition-ease: ${G}; --stx-transition-delay: ${W}ms; will-change: opacity, transform;`,_="stx-transition stx-observe stx-out";if(X==="fade")_+=" stx-fade";else if(X==="slide-up"||X==="slide")_+=" stx-from-bottom";else if(X==="slide-down")_+=" stx-from-top";else if(X==="slide-left")_+=" stx-from-right";else if(X==="slide-right")_+=" stx-from-left";else if(X==="scale")_+=" stx-scale";else if(X.includes("-"))_+=` stx-${X}`;else _+=` stx-${X}`;return`<div id="${U}" class="${_}" style="${z}" data-threshold="${K}">${$}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},o3={name:"animationGroup",handler:($,Z,Y,J)=>{if(Z.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${$}`;let X=Z[0],Q=Z.slice(1).map((U)=>U.startsWith("#")||U.startsWith(".")?U:`#${U}`),G=Y.staggerDelay||50,K=Y.sequence||!0,W=oR(X,Q,{staggerDelay:G,sequence:K});return`${$}
|
|
388
388
|
${W}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},t3={name:"motion",handler:($,Z,Y,J)=>{let X=Z.length>0?Z[0].toLowerCase()==="true":!0,Q=nR();return`<div data-animate="${X?"auto":"true"}">${$}</div>${Q}`},hasEndTag:!0,description:"Controls motion and animation preferences"};EX={default:{stiffness:100,damping:10,mass:1},gentle:{stiffness:120,damping:14,mass:1},wobbly:{stiffness:180,damping:12,mass:1},stiff:{stiffness:210,damping:20,mass:1},slow:{stiffness:280,damping:60,mass:1},molasses:{stiffness:280,damping:120,mass:1}};Wz={name:"keyframe",hasEndTag:!0,handler:($,Z,Y,J)=>{if(Z.length<1)return`<div class="stx-error">@keyframe requires an animation name</div>${$}`;let X=Z[0].replace(/['"`]/g,""),Q=Z[1]?Number.parseInt(Z[1],10):1000,G=Z[2]?.replace(/['"`]/g,"")||"ease",K=Z[3]||"1",W=Z[4]?.replace(/['"`]/g,"")||"normal",U=Z[5]?.replace(/['"`]/g,"")||"forwards",z=`stx-keyframe-${Math.random().toString(36).slice(2,9)}`,_=`
|
|
389
389
|
animation-name: ${X};
|
|
390
390
|
animation-duration: ${Q}ms;
|
|
@@ -810,7 +810,7 @@ ${H}
|
|
|
810
810
|
`),J)X=X.replace(/\n/g,`<br />
|
|
811
811
|
`);for(let z=0;z<Q.length;z++)X=X.replace(`\x00CODEBLOCK${z}\x00`,Q[z]);return X=X.replace(/<p>\s*<\/p>/g,""),X.trim()}function c1($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(J,X)=>{return`const { ${X.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
|
|
812
812
|
`});let Y=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return $=$.replace(Y,(J,X)=>{return`const { ${X.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
813
|
-
`}),$}import Lz from"process";function F1($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(Lz.env)){if(!J.startsWith($)||X===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(X),Y[J]=X}return Z["import.meta.env"]=JSON.stringify(Y),Z}function Vz($="STX_PUBLIC_"){let Z={};for(let[Y,J]of Object.entries(Lz.env))if(Y.startsWith($)&&J!==void 0)Z[Y]=J;return Z}var p4=()=>{};import Q7 from"path";function PX($){Az=$?.trim()||null}function F$(){return process.env[Fz]?.trim()||Az||P6}function c0($=process.cwd(),...Z){let Y=F$();return Q7.isAbsolute(Y)?Q7.join(Y,...Z):Q7.join($,Y,...Z)}function A$($){if(!$||Q7.isAbsolute($))return $;let Z=$.replace(/\\/g,"/");if(Z!==P6&&!Z.startsWith(`${P6}/`))return $;let Y=Z.slice(P6.length+1);return Y?Q7.join(F$(),Y):F$()}var P6=".stx",Fz="STX_DIR",Az=null;var G4=()=>{};var G7={};$0(G7,{queueClientBundleBuild:()=>Mz,hasUserImports:()=>zM,bundleClientScript:()=>BM});import p0 from"path";import A1 from"fs";function zM($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(!wz.some((G)=>G.test(X)))return console.log("[stx:bundler] detected user import:",X),!0}let J=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=J.exec($))!==null){let X=Y[1];if(/\.css(?:\?.*)?$/.test(X))continue;if(!wz.some((G)=>G.test(X)))return console.log("[stx:bundler] detected side-effect import:",X),!0}return!1}function _M($,Z,Y,J){let X=(Q,G)=>{let K=Q===Y?Z:p0.dirname(Q),W=p0.resolve(K,G),U=[W,`${W}.ts`,`${W}.tsx`,`${W}.js`,`${W}.mjs`,`${W}.jsx`,p0.join(W,"index.ts"),p0.join(W,"index.tsx"),p0.join(W,"index.js"),p0.join(W,"index.mjs")];for(let z of U)try{if(A1.existsSync(z)&&A1.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}catch{}return W};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^\//},(G)=>{if(A1.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(G)=>{let K=X(G.importer,G.path);return J.add(K),{path:K}}),Q.onResolve({filter:/^[@~]\//},(G)=>{let K=p0.resolve($,G.path.slice(2)),W=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,p0.join(K,"index.ts"),p0.join(K,"index.tsx"),p0.join(K,"index.js"),p0.join(K,"index.mjs")];for(let U of W)if(A1.existsSync(U)&&A1.statSync(U,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",U),J.add(U),{path:U};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=p0.extname(G.path).toLowerCase(),W=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)J.add(G.path);return{contents:A1.readFileSync(G.path,"utf8"),loader:W}})}}}function Mz($){let Z=globalThis,J=(Z[Nz]??Promise.resolve()).then($,$);return Z[Nz]=J.then(()=>{return},()=>{return}),J}async function BM($,Z,Y={}){let J=Y.projectRoot||process.cwd(),X=Y.minify??!1,Q=Y.cacheDir||c0(J,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${UM}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),W=p0.join(Q,`${K}.js`),U=p0.join(Q,`${K}.deps.json`),z=Bun.file(W);if(await z.exists()){let q=Bun.file(U),j=!0;if(await q.exists())try{let H=JSON.parse(await q.text());if(H.metadataVersion!==Rz||!Array.isArray(H.files))j=!1;for(let O of Array.isArray(H.files)?H.files:[])try{if(A1.statSync(O.path).mtimeMs!==O.mtimeMs){j=!1;break}}catch{j=!1;break}}catch{j=!1}if(j)return console.log("[stx:bundler] cache hit:",K),await z.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let _=yX.get(K);if(_)return await _;let B=Mz(()=>qM($,Z,{projectRoot:J,minify:X,cacheDir:Q,hash:K,cachePath:W,depsPath:U}));yX.set(K,B);try{return await B}finally{yX.delete(K)}}async function qM($,Z,Y){let{projectRoot:J,minify:X,cacheDir:Q,hash:G,cachePath:K,depsPath:W}=Y,U=c0(J,"bundle-tmp"),z=p0.join(U,`${G}.ts`),_=p0.join(U,"out",G);A1.mkdirSync(U,{recursive:!0}),A1.mkdirSync(_,{recursive:!0});let B=p0.dirname(Z),q=[],j=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,O;while((O=j.exec($))!==null){if(O[1])continue;if(O[2])O[2].split(",").forEach((F)=>{let A=F.split(":")[0].trim();if(A)q.push(A)});else if(O[3])q.push(O[3])}while((O=H.exec($))!==null){if(O[1])continue;q.push(O[2])}let V=q.length>0?`
|
|
813
|
+
`}),$}import Lz from"process";function F1($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(Lz.env)){if(!J.startsWith($)||X===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(X),Y[J]=X}return Z["import.meta.env"]=JSON.stringify(Y),Z}function Vz($="STX_PUBLIC_"){let Z={};for(let[Y,J]of Object.entries(Lz.env))if(Y.startsWith($)&&J!==void 0)Z[Y]=J;return Z}var p4=()=>{};import Q7 from"path";function PX($){Az=$?.trim()||null}function F$(){return process.env[Fz]?.trim()||Az||P6}function c0($=process.cwd(),...Z){let Y=F$();return Q7.isAbsolute(Y)?Q7.join(Y,...Z):Q7.join($,Y,...Z)}function A$($){if(!$||Q7.isAbsolute($))return $;let Z=$.replace(/\\/g,"/");if(Z!==P6&&!Z.startsWith(`${P6}/`))return $;let Y=Z.slice(P6.length+1);return Y?Q7.join(F$(),Y):F$()}var P6=".stx",Fz="STX_DIR",Az=null;var G4=()=>{};var G7={};$0(G7,{queueClientBundleBuild:()=>Mz,hasUserImports:()=>zM,bundleClientScript:()=>BM});import p0 from"path";import A1 from"fs";function zM($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(!wz.some((G)=>G.test(X)))return console.log("[stx:bundler] detected user import:",X),!0}let J=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=J.exec($))!==null){let X=Y[1];if(/\.css(?:\?.*)?$/.test(X))continue;if(X==="@stacksjs/browser")continue;if(!wz.some((G)=>G.test(X)))return console.log("[stx:bundler] detected side-effect import:",X),!0}return!1}function _M($,Z,Y,J){let X=(Q,G)=>{let K=Q===Y?Z:p0.dirname(Q),W=p0.resolve(K,G),U=[W,`${W}.ts`,`${W}.tsx`,`${W}.js`,`${W}.mjs`,`${W}.jsx`,p0.join(W,"index.ts"),p0.join(W,"index.tsx"),p0.join(W,"index.js"),p0.join(W,"index.mjs")];for(let z of U)try{if(A1.existsSync(z)&&A1.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}catch{}return W};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^\//},(G)=>{if(A1.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(G)=>{let K=X(G.importer,G.path);return J.add(K),{path:K}}),Q.onResolve({filter:/^[@~]\//},(G)=>{let K=p0.resolve($,G.path.slice(2)),W=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,p0.join(K,"index.ts"),p0.join(K,"index.tsx"),p0.join(K,"index.js"),p0.join(K,"index.mjs")];for(let U of W)if(A1.existsSync(U)&&A1.statSync(U,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",U),J.add(U),{path:U};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=p0.extname(G.path).toLowerCase(),W=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)J.add(G.path);return{contents:A1.readFileSync(G.path,"utf8"),loader:W}})}}}function Mz($){let Z=globalThis,J=(Z[Nz]??Promise.resolve()).then($,$);return Z[Nz]=J.then(()=>{return},()=>{return}),J}async function BM($,Z,Y={}){let J=Y.projectRoot||process.cwd(),X=Y.minify??!1,Q=Y.cacheDir||c0(J,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${UM}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),W=p0.join(Q,`${K}.js`),U=p0.join(Q,`${K}.deps.json`),z=Bun.file(W);if(await z.exists()){let q=Bun.file(U),j=!0;if(await q.exists())try{let H=JSON.parse(await q.text());if(H.metadataVersion!==Rz||!Array.isArray(H.files))j=!1;for(let O of Array.isArray(H.files)?H.files:[])try{if(A1.statSync(O.path).mtimeMs!==O.mtimeMs){j=!1;break}}catch{j=!1;break}}catch{j=!1}if(j)return console.log("[stx:bundler] cache hit:",K),await z.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let _=yX.get(K);if(_)return await _;let B=Mz(()=>qM($,Z,{projectRoot:J,minify:X,cacheDir:Q,hash:K,cachePath:W,depsPath:U}));yX.set(K,B);try{return await B}finally{yX.delete(K)}}async function qM($,Z,Y){let{projectRoot:J,minify:X,cacheDir:Q,hash:G,cachePath:K,depsPath:W}=Y,U=c0(J,"bundle-tmp"),z=p0.join(U,`${G}.ts`),_=p0.join(U,"out",G);A1.mkdirSync(U,{recursive:!0}),A1.mkdirSync(_,{recursive:!0});let B=p0.dirname(Z),q=[],j=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,O;while((O=j.exec($))!==null){if(O[1])continue;if(O[2])O[2].split(",").forEach((F)=>{let A=F.split(":")[0].trim();if(A)q.push(A)});else if(O[3])q.push(O[3])}while((O=H.exec($))!==null){if(O[1])continue;q.push(O[2])}let V=q.length>0?`
|
|
814
814
|
export { ${q.join(", ")} }`:"";await Bun.write(z,$+V),console.log("[stx:bundler] bundling:",G,"from:",p0.basename(Z));let L=new Set;try{let F=await Bun.build({entrypoints:[z],outdir:_,target:"browser",format:"esm",minify:X,plugins:[_M(J,B,z,L)],define:{"process.env.NODE_ENV":X?'"production"':'"development"',...F1()},root:J});if(!F.success){let k=F.logs.filter((x)=>x.level==="error").map((x)=>x.message).join(", ");return console.warn("[stx:bundler] build failed:",k),$}let A="";for(let k of F.outputs){A=await k.text();break}let w=[];for(let k of A.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let x of k[1].split(",")){let y=x.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(y){w.push([y[2],y[1]]);continue}let b=x.trim();if(/^[A-Za-z_$][\w$]*$/.test(b))w.push([b,b])}let N=A.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];A=A.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let R=`__stxBundle_${G}`,E=w.map(([k,x])=>`${JSON.stringify(k)}: ${x}`).join(", "),M=w.map(([k])=>`var ${k} = undefined;`).join(`
|
|
815
815
|
`),I=w.map(([k])=>`${k} = ${R}[${JSON.stringify(k)}];`).join(`
|
|
816
816
|
`);if(A=`${N.join(`
|
|
@@ -891,7 +891,7 @@ else {
|
|
|
891
891
|
// STX: auto-generated event bindings
|
|
892
892
|
${$.map((Y,J)=>IM(Y,J)).join(`
|
|
893
893
|
`)}`}function Ez($){let Z=[],Y=new Set,J=$.replace(/^\s*import\s+.*$/gm,""),X=0,Q=J.length,G=0;while(G<Q){let K=J[G];if(K==="'"||K==='"'||K==="`"){let W=K;if(G++,W==="`"){let U=0;while(G<Q){if(J[G]==="\\"){G+=2;continue}if(J[G]==="`"&&U===0){G++;break}if(J[G]==="$"&&J[G+1]==="{"){U++,G+=2;continue}if(J[G]==="}"&&U>0){U--,G++;continue}G++}}else while(G<Q){if(J[G]==="\\"){G+=2;continue}if(J[G]===W){G++;break}G++}continue}if(K==="/"&&J[G+1]==="/"){while(G<Q&&J[G]!==`
|
|
894
|
-
`)G++;continue}if(K==="/"&&J[G+1]==="*"){G+=2;while(G<Q-1&&!(J[G]==="*"&&J[G+1]==="/"))G++;G+=2;continue}if(K==="{"){X++,G++;continue}if(K==="}"){X--,G++;continue}if(X===0){let W=J.slice(G),U=W.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(U){let B=U[1];if(!B.startsWith("_")&&!Y.has(B))Z.push(B),Y.add(B);G+=U[0].length;continue}let z=W.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(z){z[1].split(",").forEach((B)=>{let q=B.trim(),j=q.indexOf(":"),H=j>=0?q.slice(j+1).trim().split(/[\s=]/)[0]:q.split(/[\s=]/)[0];if(H&&!H.startsWith("_")&&!Y.has(H))Z.push(H),Y.add(H)}),G+=z[0].length;continue}let _=W.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(_){let B=_[1];if(!B.startsWith("_")&&!Y.has(B))Z.push(B),Y.add(B);G+=_[0].length;continue}}G++}return Z}function SM($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function J(B){let q;while((q=Y.exec(B))!==null){let j=q[0];if(!kM.has(j))Z.add(j)}}let X=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=X.exec($))!==null)J(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)J(Q[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=K.exec($))!==null)J(Q[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=W.exec($))!==null)J(Q[1]);let U=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=U.exec($))!==null)J(Q[1]);let z=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=z.exec($))!==null)J(Q[1]);let _=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=_.exec($))!==null)J(Q[1]);return Z}async function n4($,Z={}){let Y=$,J="",X=!1,Q=[],G=U7(Y,{filePath:Z.filePath,projectRoot:Z.projectRoot});Y=G.code;let K=z7(G.styles),W=x6(Y);Y=W.code,Q=W.imports;let{hasUserImports:U,bundleClientScript:z}=await Promise.resolve().then(() => (K7(),G7));if(U(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await z(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),X=!0;if(Z.autoImports!==!1){let L=Dz(Y);Y=L.code,J=ZZ(L.stxImports,L.browserImports.filter((F)=>!Q.includes(F)))}if(J=`${_7(Y,Z.serverData)}${J}`,Y=c1(Y),!X&&r4(Z.attrs||""))Y=
|
|
894
|
+
`)G++;continue}if(K==="/"&&J[G+1]==="*"){G+=2;while(G<Q-1&&!(J[G]==="*"&&J[G+1]==="/"))G++;G+=2;continue}if(K==="{"){X++,G++;continue}if(K==="}"){X--,G++;continue}if(X===0){let W=J.slice(G),U=W.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(U){let B=U[1];if(!B.startsWith("_")&&!Y.has(B))Z.push(B),Y.add(B);G+=U[0].length;continue}let z=W.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(z){z[1].split(",").forEach((B)=>{let q=B.trim(),j=q.indexOf(":"),H=j>=0?q.slice(j+1).trim().split(/[\s=]/)[0]:q.split(/[\s=]/)[0];if(H&&!H.startsWith("_")&&!Y.has(H))Z.push(H),Y.add(H)}),G+=z[0].length;continue}let _=W.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(_){let B=_[1];if(!B.startsWith("_")&&!Y.has(B))Z.push(B),Y.add(B);G+=_[0].length;continue}}G++}return Z}function SM($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function J(B){let q;while((q=Y.exec(B))!==null){let j=q[0];if(!kM.has(j))Z.add(j)}}let X=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=X.exec($))!==null)J(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)J(Q[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=K.exec($))!==null)J(Q[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=W.exec($))!==null)J(Q[1]);let U=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=U.exec($))!==null)J(Q[1]);let z=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=z.exec($))!==null)J(Q[1]);let _=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=_.exec($))!==null)J(Q[1]);return Z}async function n4($,Z={}){let Y=$,J="",X=!1,Q=[],G=U7(Y,{filePath:Z.filePath,projectRoot:Z.projectRoot});Y=G.code;let K=z7(G.styles),W=x6(Y);Y=W.code,Q=W.imports;let{hasUserImports:U,bundleClientScript:z}=await Promise.resolve().then(() => (K7(),G7));if(U(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await z(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),X=!0;if(Z.autoImports!==!1){let L=Dz(Y);Y=L.code,J=ZZ(L.stxImports,L.browserImports.filter((F)=>!Q.includes(F)))}if(J=`${_7(Y,Z.serverData)}${J}`,Y=c1(Y),!X&&r4(Z.attrs||""))Y=a4(Y);let _=DM(Z.eventBindings||[]),B=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(B)){let L=B.replace(/\btype\s*=\s*["']module["']/i,"").trim(),F=`type="module" data-stx-scoped${L?` ${L}`:""}`;return`${K}<script ${F}>
|
|
895
895
|
${J}${Y}
|
|
896
896
|
${_}
|
|
897
897
|
</script>`}let j=/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useLocalStorage|useSessionStorage|useRef|useEventListener|useFetch|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|onMounted|onBeforeUnmount|onUnmounted|batch|untrack|peek)\s*(?:<[^>]*>)?\s*\(/.test($),H=/function __stx_setup_/.test(Y),O=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test($);function V(L){let F=L.length>0?`
|
|
@@ -924,7 +924,7 @@ catch (e) {
|
|
|
924
924
|
}
|
|
925
925
|
throw e;
|
|
926
926
|
}
|
|
927
|
-
`),K=G([]);if(Q.length===Z.length)return xz(K,Q,G);return xz((...U)=>{let z=Array(X.length);for(let _=0;_<X.length;_++)z[_]=U[X[_]];return K(...z)},Q,G,(U)=>{K=G(U)})}function xz($,Z,Y,J){let Q=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...U)=>{for(let z=0;z<=8;z++)try{return G(...U)}catch(_){let B=_ instanceof Error?_.message:"",q=Q.exec(B);if(!(_ instanceof ReferenceError)||!q)return;let j=q[1];if(W.has(j)||hz.has(j))return;W.add(j),K.push(j),G=Y(K),J?.(K)}return}}function XZ($){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 J of Y)if(J.test(Z))return!1;return!0}var bM,vz,fz,PM,gz,yM,hz;var n0=D(()=>{bM={maxSanitizeDepth:10,allowBracketNotation:!1},vz={...bM},fz=[/\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/],PM=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"]),gz=new Set(["__proto__","constructor","prototype"]),yM=/[\w)\]]\s*\[\s*['"]/;hz=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"])});function fX(){dz=0,QZ.clear()}function B7($,Z){let Y=dz++,J=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return QZ.set(J,{type:$,expression:Z}),J}function gX(){let $={};for(let[Z,Y]of QZ)$[Z]={type:Y.type,expression:Y.expression};return $}function hM($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,J;while((J=Y.exec($))!==null){let X=J[0],Q=J[1].toLowerCase(),G=QZ.get(X);Z[X]={type:Q,expression:G?.expression||""}}return Z}function GZ($,Z){let Y=$;for(let[J,X]of Z)Y=Y.split(J).join(X);return Y}function w$($){return $.includes("<!--__STX_")}var dz=0,QZ;var q7=D(()=>{QZ=new Map});function pz($,Z,Y,J){Y.lastIndex=Z;let X=Y.exec($);if(!X||X.index!==Z)return-1;J.lastIndex=Y.lastIndex;let Q=J.exec($);if(!Q)return-1;return Q.index+Q[0].length}function a4($,Z){return pz($,Z,uz,mz)}function N$($,Z){return pz($,Z,lz,cz)}function j7($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function dM($,Z){if($.startsWith("<!--",Z)){let Y=j7($,Z);return Y===-1?$.length:Y}for(let[Y,J]of[[uz,mz],[lz,cz]]){Y.lastIndex=Z;let X=Y.exec($);if(!X||X.index!==Z)continue;J.lastIndex=Y.lastIndex;let Q=J.exec($);return Q?Q.index+Q[0].length:$.length}return-1}function hX($,Z){let Y=[],J=0,X=$.length,Q=!1,G=null;while(J<X){let K=$[J];if(Q){if(G){if(K===G)G=null}else if(K==='"'||K==="'")G=K;else if(K===">")Q=!1;J++;continue}if(K!=="<"){J++;continue}let W=Z($,J);if(W>J){Y.push({start:J,end:W,token:$.slice(J,W)}),J=W;continue}let U=dM($,J);if(U>J){J=U;continue}if(/^<\/?[a-zA-Z]/.test($.slice(J,J+2)))Q=!0;J++}return Y}function K4($,Z,Y){let J=hX($,Z);if(J.length===0)return{output:$,tokens:[]};let X=J.map((K)=>K.token),Q="",G=0;for(let K=0;K<J.length;K++){let W=J[K];Q+=$.slice(G,W.start),Q+=Y(W.token,K),G=W.end}return Q+=$.slice(G),{output:Q,tokens:X}}function o4($){let{output:Z,tokens:Y}=K4($,a4,(J,X)=>`\x00STX_SCRIPT_${X}\x00`);return{output:Z,scripts:Y}}function H7($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,J)=>Z[+J]??"")}var uz,mz,lz,cz;var f6=D(()=>{uz=/<script\b[^>]*>/iy,mz=/<\/script\s*>/ig,lz=/<style\b[^>]*>/iy,cz=/<\/style\s*>/ig});var V7={};$0(V7,{usesSignalsInScript:()=>g6,unescapeHtml:()=>KZ,registerFilters:()=>rz,registerFilter:()=>dX,processExpressions:()=>d1,interpolateScriptsInTemplate:()=>az,interpolateScriptExpressions:()=>L7,getAllFilters:()=>uX,evaluateExpression:()=>G1,escapeHtml:()=>v0,defaultFilters:()=>R$,clearCustomFilters:()=>sz,applyFilters:()=>mX});function uM($){let Z=iz.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),iz.set($,Z)}return Z.lastIndex=0,Z}function dX($,Z){if($ in R$)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);O7[$]=Z}function rz($){for(let[Z,Y]of Object.entries($))dX(Z,Y)}function uX(){return{...R$,...O7}}function sz(){for(let $ of Object.keys(O7))delete O7[$]}function v0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function g6($){let{scripts:Z}=o4($);for(let Y of Z){let J=Y.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);if(!J||/\bserver\b|\bsrc\s*=/.test(J[1]))continue;let X=J[2];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function nz($,Z){let Y=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],J=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),X="",Q=!1,G=0;for(let U=0;U<J.length;U++){let z=J[U];if(!Q&&z==="`"){Q=!0,G=0;continue}if(Q){if(z==="`"&&G===0){Q=!1;continue}if(z==="$"&&J[U+1]==="{"){G++,U++,X+=" ";continue}if(z==="}"&&G>0){G--;continue}if(G>0){X+=z;continue}continue}X+=z}J=X;let K=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,W;while((W=K.exec(J))!==null){let U=W[1];if(!J.substring(0,W.index).trimEnd().endsWith(".")){if(!Y.includes(U)&&!(U in Z))return!1}}return!0}function L7($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(J,X)=>{try{let Q=G1(X,Z);if(Q===void 0)return J;return Q===null?"":String(Q)}catch{return J}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(J,X)=>{let Q=X.trim();if(/^__[A-Z_]+__$/.test(Q))return J;try{let G=G1(X,Z);if(G===void 0)return J;return JSON.stringify(G)}catch{return J}}),Y}function az($,Z,Y={}){let{output:J,scripts:X}=o4($),Q=X.map((G)=>{let K=G.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),W=G.match(/^<script\b[^>]*>/i),U=G.search(/<\/script\s*>$/i);if(!K||!W||U===-1)return G;let z=K[1],_=K[2];if(/\bsrc\s*=/.test(z))return G;if(/\bdata-raw\b/.test(z))return G;if(/\btype\s*=\s*["']application\/json["']/.test(z))return G;if(Y.skipServer&&/\bserver\b/.test(z))return G;let B=L7(_,Z);return W[0]+B+G.slice(U)});return H7(J,Q)}function d1($,Z,Y,J){let X=$,Q=(B,q)=>{let j=N$(B,q);if(j===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(B.slice(q,j))?-1:j},G=(B,q,j,H)=>{let O=j.length,{output:V,tokens:L}=K4(B,q,(F,A)=>H(O+A));return j.push(...L),V},K=[];X=G(X,Q,K,(B)=>`<!--__STX_STYLE_${B}__-->`);let W=[];X=G(X,a4,W,(B)=>`<!--__STX_SCRIPT_EXPR_${B}__-->`);let U=J?.forceSignals===!0||Z?.__stx_force_signals===!0||Array.isArray(Z?.__stx_client_signal_names)||g6($),z=new Set(Array.isArray(Z?.__stx_client_signal_names)?Z.__stx_client_signal_names:[]),_=new Set(Array.isArray(Z?.__stx_preserved_client_expressions)?Z.__stx_preserved_client_expressions:[]);X=X.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(B,q,j)=>{try{let H=G1(q,Z);return H!==void 0&&H!==null?String(H):""}catch(H){let O=H instanceof Error?H.message:String(H);return T0("Expression",`Error evaluating: {{{ ${q.trim()}}}}: ${O}`,Y,$,j,B)}}),X=X.replace(/\{!!([\s\S]*?)!!\}/g,(B,q,j)=>{try{let H=G1(q,Z);if(H===void 0&&Z.__stx_buildMode==="compile")return B7("raw",q.trim());return H!==void 0&&H!==null?String(H):""}catch(H){if(Z.__stx_buildMode==="compile")return B7("raw",q.trim());let O=H instanceof Error?H.message:String(H);return T0("Expression",`Error evaluating: {!! ${q.trim()} !!}: ${O}`,Y,$,j,B)}}),X=G(X,a4,W,(B)=>`<!--__STX_SCRIPT_EXPR_${B}__-->`),X=G(X,Q,K,(B)=>`<!--__STX_STYLE_${B}__-->`),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(B,q,j)=>{let H=q.trim();if(_.has(H))return B;let O=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=H.match(V)?.[1],A=F&&((F in Z)||O.includes(F)),w=Boolean(F&&z.has(F)),N=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,R=H.match(N),E=R&&!O.includes(R[1])&&!(R[1]in Z);if(/^__[A-Z_]+__$/.test(H))return"";try{let M=G1(q,Z);if(w)return B;if(U&&!nz(H,Z))return B;if(M===void 0&&Z.__stx_buildMode==="compile"&&!U)return B7("expr",H);return M!==void 0&&M!==null?v0(String(M)):""}catch(M){if(w)return B;if(U&&!nz(H,Z))return B;if(E)return B;let I=M instanceof Error?M.message:String(M);return T0("Expression",`Error evaluating: {{ ${H} }}: ${I}`,Y,$,j,B)}});for(let B=0;B<W.length;B++)X=X.replace(`<!--__STX_SCRIPT_EXPR_${B}__-->`,()=>W[B]);for(let B=0;B<K.length;B++)X=X.replace(`<!--__STX_STYLE_${B}__-->`,()=>K[B]);return X}function mX($,Z,Y){if(!Z.trim())return $;let J=$,X=Z.trim();while(X.length>0){let Q=X.match(/^(\w+)/);if(!Q)break;let G=Q[1];X=X.substring(G.length).trim();let K=O7[G]||R$[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(uX()).join(", ")}`);let W=[];if(X.startsWith(":")){let U=X.match(/^:([^|\s]+)/);if(U){let z=U[1].trim();try{let _=Number(z);W=[Number.isNaN(_)?z:_]}catch{W=[z]}X=X.substring(U[0].length).trim()}}else if(X.startsWith("(")){let U=1,z=1;while(U>0&&z<X.length){if(X[z]==="(")U++;if(X[z]===")")U--;z++}if(U===0){let _=X.substring(1,z-1).trim();if(_)try{if(_.startsWith("{")&&_.endsWith("}"))W=[G1(`(${_})`,Y,!0)];else{let B=[],q="",j=null,H=0,O=0,V=0,L=!1;for(let F=0;F<_.length;F++){let A=_[F];if(L){q+=A,L=!1;continue}if(A==="\\"){q+=A,L=!0;continue}if(j){if(q+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,q+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")O++;else if(A==="]")O--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&H===0&&O===0&&V===0){B.push(q),q="";continue}q+=A}if(q)B.push(q);W=B.map((F)=>{let A=F.trim();return G1(A,Y,!0)})}}catch{W=[_]}X=X.substring(z).trim()}}try{J=K(J,Y,...W)}catch(U){let z=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${z}`)}if(X.startsWith("|"))X=X.substring(1).trim();else break}return J}function mM($){let Z=!1,Y="",J=0,X=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let z=1;K+=2;while(K<$.length&&z>0){if($[K]==="{")z++;else if($[K]==="}")z--;if(z>0)K++}continue}if(Z)continue;if(W==="(")J++;else if(W===")")J--;else if(W==="[")X++;else if(W==="]")X--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&J===0&&X===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function G1($,Z,Y=!1){try{let J=$.trim(),X=mM(J);if(X>0){let Q=J.substring(0,X).trim(),G=J.substring(X+1).trim(),K=G1(Q,Z,!0);return mX(K,G,Z)}if(!R0(J)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${J}`);return V0(J,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return M0(J,Q)(...G)}catch{return V0(J,Z)}}catch(J){if(J instanceof ReferenceError){let X=/(\b\w+)\s+is not defined/.exec(J.message);if(X){let Q=X[1],G=lM(Q,Object.keys(Z));if(G&&G!==Q)J.message=`${J.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,J);throw J}}function lM($,Z){let Y=null;for(let X of Z){if(X===$)continue;let Q=cM($,X);if(Y===null||Q<Y.dist)Y={key:X,dist:Q}}if(!Y)return null;let J=Math.max($.length,Y.key.length);if(Y.dist<=2||Y.dist/J<=0.35)return Y.key;return null}function cM($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[Y,J]=$.length<Z.length?[$,Z]:[Z,$],X=Array(Y.length+1),Q=Array(Y.length+1);for(let G=0;G<=Y.length;G++)X[G]=G;for(let G=1;G<=J.length;G++){Q[0]=G;for(let K=1;K<=Y.length;K++){let W=Y[K-1]===J[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,X[K]+1,X[K-1]+W)}for(let K=0;K<=Y.length;K++)X[K]=Q[K]}return X[Y.length]}function KZ($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var O7,iz,R$;var $1=D(()=>{n0();N0();q7();f6();O7={},iz=new Map;R$={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let J=Number($);return Number.isNaN(J)?"":J.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return J.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return v0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let J=Z.__translations,X=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=J;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return X?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(uM(W),String(U))}),K},t:($,Z,Y={})=>{return R$.translate($,Z,Y)},truncate:($,Z,Y=50,J="...")=>{if($===void 0||$===null)return"";let X=String($);if(X.length<=Y)return X;if(Y<=J.length)return J.substring(0,Y);return X.substring(0,Y-J.length)+J},date:($,Z,Y="short",J="en-US")=>{if($===void 0||$===null)return"";try{let X=$ instanceof Date?$:new Date($);if(Number.isNaN(X.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(Y==="iso")return X.toISOString();return new Intl.DateTimeFormat(J,Q[Y]||Q.short).format(X)}catch{return String($)}},currency:($,Z,Y="USD",J="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return new Intl.NumberFormat(J,{style:"currency",currency:Y}).format(X)}catch{return String($)}},pluralize:($,Z,Y,J)=>{let X=Number($);if(Number.isNaN(X))return Y;let Q=J||`${Y}s`;return X===1?Y:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let Y=String($);return Y.charAt(Y.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,Y=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return Y?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,Y="")=>{return $===void 0||$===null||$===""?Y:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,Y=0,J)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(Y,J);return $},replace:($,Z,Y,J="")=>{if($===void 0||$===null)return"";let X=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(X,"g"),()=>J)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let Y=Number($);return Number.isNaN(Y)?0:Math.abs(Y)},round:($,Z,Y=0)=>{let J=Number($);if(Number.isNaN(J))return 0;let X=10**Y;return Math.round(J*X)/X}}});function M$($="const",Z=[],Y){let J=Z.length?WZ.filter((X)=>!Z.includes(X)):WZ;if(Y!==void 0)J=J.filter((X)=>{let Q=X.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${Q}(?![\\w$])`).test(Y)});return`${$} { ${J.join(", ")} } = window.stx;`}var WZ,oz;var F7=D(()=>{WZ=["batch","computed","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","goBack","goForward","navigate","nextTick","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","provide","reactive","ref","registerStoresClient","state","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","withDefaults"],oz=["onMount","onDestroy"]});class h6{cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let Y=this.cache.keys().next().value;if(Y!==void 0)this.cache.delete(Y)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function E$($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!T$.has(Y)){if(T$.size>=pM){let J=T$.keys().next().value;if(J)T$.delete(J)}T$.set(Y,new RegExp($,Z))}return T$.get(Y)}class tz{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),J=this.pool.find((K)=>K.context.join(",")===Y);if(J)return J.func;let X=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,z=X.get(U);if(!z){if(X.size>=Q){let _=X.keys().next().value;if(_)X.delete(_)}z=Function(...Z,`
|
|
927
|
+
`),K=G([]);if(Q.length===Z.length)return xz(K,Q,G);return xz((...U)=>{let z=Array(X.length);for(let _=0;_<X.length;_++)z[_]=U[X[_]];return K(...z)},Q,G,(U)=>{K=G(U)})}function xz($,Z,Y,J){let Q=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...U)=>{for(let z=0;z<=8;z++)try{return G(...U)}catch(_){let B=_ instanceof Error?_.message:"",q=Q.exec(B);if(!(_ instanceof ReferenceError)||!q)return;let j=q[1];if(W.has(j)||hz.has(j))return;W.add(j),K.push(j),G=Y(K),J?.(K)}return}}function XZ($){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 J of Y)if(J.test(Z))return!1;return!0}var bM,vz,fz,PM,gz,yM,hz;var n0=D(()=>{bM={maxSanitizeDepth:10,allowBracketNotation:!1},vz={...bM},fz=[/\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/],PM=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"]),gz=new Set(["__proto__","constructor","prototype"]),yM=/[\w)\]]\s*\[\s*['"]/;hz=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"])});function fX(){dz=0,QZ.clear()}function B7($,Z){let Y=dz++,J=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return QZ.set(J,{type:$,expression:Z}),J}function gX(){let $={};for(let[Z,Y]of QZ)$[Z]={type:Y.type,expression:Y.expression};return $}function hM($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,J;while((J=Y.exec($))!==null){let X=J[0],Q=J[1].toLowerCase(),G=QZ.get(X);Z[X]={type:Q,expression:G?.expression||""}}return Z}function GZ($,Z){let Y=$;for(let[J,X]of Z)Y=Y.split(J).join(X);return Y}function w$($){return $.includes("<!--__STX_")}var dz=0,QZ;var q7=D(()=>{QZ=new Map});function pz($,Z,Y,J){Y.lastIndex=Z;let X=Y.exec($);if(!X||X.index!==Z)return-1;J.lastIndex=Y.lastIndex;let Q=J.exec($);if(!Q)return-1;return Q.index+Q[0].length}function s4($,Z){return pz($,Z,uz,mz)}function N$($,Z){return pz($,Z,lz,cz)}function j7($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function dM($,Z){if($.startsWith("<!--",Z)){let Y=j7($,Z);return Y===-1?$.length:Y}for(let[Y,J]of[[uz,mz],[lz,cz]]){Y.lastIndex=Z;let X=Y.exec($);if(!X||X.index!==Z)continue;J.lastIndex=Y.lastIndex;let Q=J.exec($);return Q?Q.index+Q[0].length:$.length}return-1}function hX($,Z){let Y=[],J=0,X=$.length,Q=!1,G=null;while(J<X){let K=$[J];if(Q){if(G){if(K===G)G=null}else if(K==='"'||K==="'")G=K;else if(K===">")Q=!1;J++;continue}if(K!=="<"){J++;continue}let W=Z($,J);if(W>J){Y.push({start:J,end:W,token:$.slice(J,W)}),J=W;continue}let U=dM($,J);if(U>J){J=U;continue}if(/^<\/?[a-zA-Z]/.test($.slice(J,J+2)))Q=!0;J++}return Y}function K4($,Z,Y){let J=hX($,Z);if(J.length===0)return{output:$,tokens:[]};let X=J.map((K)=>K.token),Q="",G=0;for(let K=0;K<J.length;K++){let W=J[K];Q+=$.slice(G,W.start),Q+=Y(W.token,K),G=W.end}return Q+=$.slice(G),{output:Q,tokens:X}}function o4($){let{output:Z,tokens:Y}=K4($,s4,(J,X)=>`\x00STX_SCRIPT_${X}\x00`);return{output:Z,scripts:Y}}function H7($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,J)=>Z[+J]??"")}var uz,mz,lz,cz;var f6=D(()=>{uz=/<script\b[^>]*>/iy,mz=/<\/script\s*>/ig,lz=/<style\b[^>]*>/iy,cz=/<\/style\s*>/ig});var V7={};$0(V7,{usesSignalsInScript:()=>g6,unescapeHtml:()=>KZ,registerFilters:()=>rz,registerFilter:()=>dX,processExpressions:()=>d1,interpolateScriptsInTemplate:()=>sz,interpolateScriptExpressions:()=>L7,getAllFilters:()=>uX,evaluateExpression:()=>G1,escapeHtml:()=>v0,defaultFilters:()=>R$,clearCustomFilters:()=>az,applyFilters:()=>mX});function uM($){let Z=iz.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),iz.set($,Z)}return Z.lastIndex=0,Z}function dX($,Z){if($ in R$)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);O7[$]=Z}function rz($){for(let[Z,Y]of Object.entries($))dX(Z,Y)}function uX(){return{...R$,...O7}}function az(){for(let $ of Object.keys(O7))delete O7[$]}function v0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function g6($){let{scripts:Z}=o4($);for(let Y of Z){let J=Y.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);if(!J||/\bserver\b|\bsrc\s*=/.test(J[1]))continue;let X=J[2];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function nz($,Z){let Y=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],J=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),X="",Q=!1,G=0;for(let U=0;U<J.length;U++){let z=J[U];if(!Q&&z==="`"){Q=!0,G=0;continue}if(Q){if(z==="`"&&G===0){Q=!1;continue}if(z==="$"&&J[U+1]==="{"){G++,U++,X+=" ";continue}if(z==="}"&&G>0){G--;continue}if(G>0){X+=z;continue}continue}X+=z}J=X;let K=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,W;while((W=K.exec(J))!==null){let U=W[1];if(!J.substring(0,W.index).trimEnd().endsWith(".")){if(!Y.includes(U)&&!(U in Z))return!1}}return!0}function L7($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(J,X)=>{try{let Q=G1(X,Z);if(Q===void 0)return J;return Q===null?"":String(Q)}catch{return J}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(J,X)=>{let Q=X.trim();if(/^__[A-Z_]+__$/.test(Q))return J;try{let G=G1(X,Z);if(G===void 0)return J;return JSON.stringify(G)}catch{return J}}),Y}function sz($,Z,Y={}){let{output:J,scripts:X}=o4($),Q=X.map((G)=>{let K=G.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),W=G.match(/^<script\b[^>]*>/i),U=G.search(/<\/script\s*>$/i);if(!K||!W||U===-1)return G;let z=K[1],_=K[2];if(/\bsrc\s*=/.test(z))return G;if(/\bdata-raw\b/.test(z))return G;if(/\btype\s*=\s*["']application\/json["']/.test(z))return G;if(Y.skipServer&&/\bserver\b/.test(z))return G;let B=L7(_,Z);return W[0]+B+G.slice(U)});return H7(J,Q)}function d1($,Z,Y,J){let X=$,Q=(B,q)=>{let j=N$(B,q);if(j===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(B.slice(q,j))?-1:j},G=(B,q,j,H)=>{let O=j.length,{output:V,tokens:L}=K4(B,q,(F,A)=>H(O+A));return j.push(...L),V},K=[];X=G(X,Q,K,(B)=>`<!--__STX_STYLE_${B}__-->`);let W=[];X=G(X,s4,W,(B)=>`<!--__STX_SCRIPT_EXPR_${B}__-->`);let U=J?.forceSignals===!0||Z?.__stx_force_signals===!0||Array.isArray(Z?.__stx_client_signal_names)||g6($),z=new Set(Array.isArray(Z?.__stx_client_signal_names)?Z.__stx_client_signal_names:[]),_=new Set(Array.isArray(Z?.__stx_preserved_client_expressions)?Z.__stx_preserved_client_expressions:[]);X=X.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(B,q,j)=>{try{let H=G1(q,Z);return H!==void 0&&H!==null?String(H):""}catch(H){let O=H instanceof Error?H.message:String(H);return T0("Expression",`Error evaluating: {{{ ${q.trim()}}}}: ${O}`,Y,$,j,B)}}),X=X.replace(/\{!!([\s\S]*?)!!\}/g,(B,q,j)=>{try{let H=G1(q,Z);if(H===void 0&&Z.__stx_buildMode==="compile")return B7("raw",q.trim());return H!==void 0&&H!==null?String(H):""}catch(H){if(Z.__stx_buildMode==="compile")return B7("raw",q.trim());let O=H instanceof Error?H.message:String(H);return T0("Expression",`Error evaluating: {!! ${q.trim()} !!}: ${O}`,Y,$,j,B)}}),X=G(X,s4,W,(B)=>`<!--__STX_SCRIPT_EXPR_${B}__-->`),X=G(X,Q,K,(B)=>`<!--__STX_STYLE_${B}__-->`),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(B,q,j)=>{let H=q.trim();if(_.has(H))return B;let O=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=H.match(V)?.[1],A=F&&((F in Z)||O.includes(F)),w=Boolean(F&&z.has(F)),N=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,R=H.match(N),E=R&&!O.includes(R[1])&&!(R[1]in Z);if(/^__[A-Z_]+__$/.test(H))return"";try{let M=G1(q,Z);if(w)return B;if(U&&!nz(H,Z))return B;if(M===void 0&&Z.__stx_buildMode==="compile"&&!U)return B7("expr",H);return M!==void 0&&M!==null?v0(String(M)):""}catch(M){if(w)return B;if(U&&!nz(H,Z))return B;if(E)return B;let I=M instanceof Error?M.message:String(M);return T0("Expression",`Error evaluating: {{ ${H} }}: ${I}`,Y,$,j,B)}});for(let B=0;B<W.length;B++)X=X.replace(`<!--__STX_SCRIPT_EXPR_${B}__-->`,()=>W[B]);for(let B=0;B<K.length;B++)X=X.replace(`<!--__STX_STYLE_${B}__-->`,()=>K[B]);return X}function mX($,Z,Y){if(!Z.trim())return $;let J=$,X=Z.trim();while(X.length>0){let Q=X.match(/^(\w+)/);if(!Q)break;let G=Q[1];X=X.substring(G.length).trim();let K=O7[G]||R$[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(uX()).join(", ")}`);let W=[];if(X.startsWith(":")){let U=X.match(/^:([^|\s]+)/);if(U){let z=U[1].trim();try{let _=Number(z);W=[Number.isNaN(_)?z:_]}catch{W=[z]}X=X.substring(U[0].length).trim()}}else if(X.startsWith("(")){let U=1,z=1;while(U>0&&z<X.length){if(X[z]==="(")U++;if(X[z]===")")U--;z++}if(U===0){let _=X.substring(1,z-1).trim();if(_)try{if(_.startsWith("{")&&_.endsWith("}"))W=[G1(`(${_})`,Y,!0)];else{let B=[],q="",j=null,H=0,O=0,V=0,L=!1;for(let F=0;F<_.length;F++){let A=_[F];if(L){q+=A,L=!1;continue}if(A==="\\"){q+=A,L=!0;continue}if(j){if(q+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,q+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")O++;else if(A==="]")O--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&H===0&&O===0&&V===0){B.push(q),q="";continue}q+=A}if(q)B.push(q);W=B.map((F)=>{let A=F.trim();return G1(A,Y,!0)})}}catch{W=[_]}X=X.substring(z).trim()}}try{J=K(J,Y,...W)}catch(U){let z=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${z}`)}if(X.startsWith("|"))X=X.substring(1).trim();else break}return J}function mM($){let Z=!1,Y="",J=0,X=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let z=1;K+=2;while(K<$.length&&z>0){if($[K]==="{")z++;else if($[K]==="}")z--;if(z>0)K++}continue}if(Z)continue;if(W==="(")J++;else if(W===")")J--;else if(W==="[")X++;else if(W==="]")X--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&J===0&&X===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function G1($,Z,Y=!1){try{let J=$.trim(),X=mM(J);if(X>0){let Q=J.substring(0,X).trim(),G=J.substring(X+1).trim(),K=G1(Q,Z,!0);return mX(K,G,Z)}if(!R0(J)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${J}`);return V0(J,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return M0(J,Q)(...G)}catch{return V0(J,Z)}}catch(J){if(J instanceof ReferenceError){let X=/(\b\w+)\s+is not defined/.exec(J.message);if(X){let Q=X[1],G=lM(Q,Object.keys(Z));if(G&&G!==Q)J.message=`${J.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,J);throw J}}function lM($,Z){let Y=null;for(let X of Z){if(X===$)continue;let Q=cM($,X);if(Y===null||Q<Y.dist)Y={key:X,dist:Q}}if(!Y)return null;let J=Math.max($.length,Y.key.length);if(Y.dist<=2||Y.dist/J<=0.35)return Y.key;return null}function cM($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[Y,J]=$.length<Z.length?[$,Z]:[Z,$],X=Array(Y.length+1),Q=Array(Y.length+1);for(let G=0;G<=Y.length;G++)X[G]=G;for(let G=1;G<=J.length;G++){Q[0]=G;for(let K=1;K<=Y.length;K++){let W=Y[K-1]===J[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,X[K]+1,X[K-1]+W)}for(let K=0;K<=Y.length;K++)X[K]=Q[K]}return X[Y.length]}function KZ($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var O7,iz,R$;var $1=D(()=>{n0();N0();q7();f6();O7={},iz=new Map;R$={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let J=Number($);return Number.isNaN(J)?"":J.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return J.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return v0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let J=Z.__translations,X=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=J;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return X?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(uM(W),String(U))}),K},t:($,Z,Y={})=>{return R$.translate($,Z,Y)},truncate:($,Z,Y=50,J="...")=>{if($===void 0||$===null)return"";let X=String($);if(X.length<=Y)return X;if(Y<=J.length)return J.substring(0,Y);return X.substring(0,Y-J.length)+J},date:($,Z,Y="short",J="en-US")=>{if($===void 0||$===null)return"";try{let X=$ instanceof Date?$:new Date($);if(Number.isNaN(X.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(Y==="iso")return X.toISOString();return new Intl.DateTimeFormat(J,Q[Y]||Q.short).format(X)}catch{return String($)}},currency:($,Z,Y="USD",J="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return new Intl.NumberFormat(J,{style:"currency",currency:Y}).format(X)}catch{return String($)}},pluralize:($,Z,Y,J)=>{let X=Number($);if(Number.isNaN(X))return Y;let Q=J||`${Y}s`;return X===1?Y:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let Y=String($);return Y.charAt(Y.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,Y=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return Y?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,Y="")=>{return $===void 0||$===null||$===""?Y:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,Y=0,J)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(Y,J);return $},replace:($,Z,Y,J="")=>{if($===void 0||$===null)return"";let X=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(X,"g"),()=>J)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let Y=Number($);return Number.isNaN(Y)?0:Math.abs(Y)},round:($,Z,Y=0)=>{let J=Number($);if(Number.isNaN(J))return 0;let X=10**Y;return Math.round(J*X)/X}}});function M$($="const",Z=[],Y){let J=Z.length?WZ.filter((X)=>!Z.includes(X)):WZ;if(Y!==void 0)J=J.filter((X)=>{let Q=X.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${Q}(?![\\w$])`).test(Y)});return`${$} { ${J.join(", ")} } = window.stx;`}var WZ,oz;var F7=D(()=>{WZ=["batch","computed","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","goBack","goForward","navigate","nextTick","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","provide","reactive","ref","registerStoresClient","state","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","withDefaults"],oz=["onMount","onDestroy"]});class h6{cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let Y=this.cache.keys().next().value;if(Y!==void 0)this.cache.delete(Y)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function E$($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!T$.has(Y)){if(T$.size>=pM){let J=T$.keys().next().value;if(J)T$.delete(J)}T$.set(Y,new RegExp($,Z))}return T$.get(Y)}class tz{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),J=this.pool.find((K)=>K.context.join(",")===Y);if(J)return J.func;let X=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,z=X.get(U);if(!z){if(X.size>=Q){let _=X.keys().next().value;if(_)X.delete(_)}z=Function(...Z,`
|
|
928
928
|
'use strict';
|
|
929
929
|
try {
|
|
930
930
|
return ${W};
|
|
@@ -935,10 +935,10 @@ catch (e) {
|
|
|
935
935
|
}
|
|
936
936
|
throw e;
|
|
937
937
|
}
|
|
938
|
-
`),X.set(U,z)}return z(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class ez{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,X=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!X&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:X};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=X?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${J.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let J=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}let Z={};for(let[Y,J]of this.metrics.entries()){let X=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:X?.maxTime,budgetUtilization:X?J.totalTime/J.count/X.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function iM(){if(!lX)lX=new ez;return lX}var T$,pM=500,qu,lX=null,p1;var t4=D(()=>{T$=new Map;qu=new tz;p1=new Proxy({},{get($,Z){return iM()[Z]}})});var T;var A7=D(()=>{T={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var qZ={};$0(qZ,{resetCssCache:()=>eM,resetCrosswindCache:()=>$T,rebuildCrosswindCSS:()=>N7,loadCrosswindConfig:()=>rX,loadCrosswind:()=>nX,injectCrosswindCSS:()=>P0,getCrosswindServeAsset:()=>iX,getCachedCSS:()=>ZT,generateCrosswindCSS:()=>BZ,extractClassNames:()=>_Z,buildCrosswindCSS:()=>D$});import A0 from"path";import{hasLocalConfig as nM}from"bunfig/discovery";function zZ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function cX($,Z){if(M4.has($))M4.delete($);else if(M4.size>=Z_)M4.delete(M4.keys().next().value);M4.set($,Z)}function rM($){let Z=zZ($);if(i1.has(Z))i1.delete(Z);else if(i1.size>=Z_)i1.delete(i1.keys().next().value);return i1.set(Z,$),Z}function iX($){let Z=i1.get($);if(Z===void 0)return;return i1.delete($),i1.set($,Z),Z}async function sM($){if(!e4)return null;try{let Z=Bun.file(A0.join(e4,`cw-${zZ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function aM($,Z){if(!e4)return;try{if(!fs.existsSync(e4))fs.mkdirSync(e4,{recursive:!0});await Bun.write(A0.join(e4,`cw-${zZ($)}.css`),Z)}catch{}}async function $_($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig,extractClasses:Z.extractClasses}}catch{}return null}function oM(){let $=[],Z=process.cwd();while(Z!==A0.dirname(Z))$.push(A0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(A0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(A0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(A0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(A0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(A0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=A0.dirname(Z);return $}function tM(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[A0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),A0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),A0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),A0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),A0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),A0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(A0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(A0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function nX(){if(pX)return W4;pX=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await $_(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded from ${A0.dirname(A0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let X=A0.resolve(process.env.CROSSWIND_SRC),Q=await $([X]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${X}`);return W4=Q,W4}let Z=await $(oM());if(Z)return W4=Z,W4;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of Y){let Q=await $_(X);if(Q){if(W4=Q,!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded`);return W4}}let J=await $(tM());if(J)return W4=J,W4;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${T.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${T.reset}`),console.warn(`${T.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${T.reset}`),null}}function eM(){M4.clear(),i1.clear()}function $T(){W4=null,pX=!1,n1=null,w7="",M4.clear(),i1.clear(),UZ=null}async function rX($){try{if(!nM({name:"crosswind",cwd:$}))return null;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 J=A0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${T.yellow}[Crosswind]${T.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function D$($){if(I$)return w7;I$=!0;try{let Z=await nX();if(!Z||!Z.build)return I$=!1,"";if(!n1)n1=await rX($);if(!n1)return I$=!1,"";let Y=Z.defaultConfig?.theme||{},J=n1.theme||{},X={...Z.defaultConfig,...n1,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},Q=performance.now(),G=await Z.build(X),K=performance.now()-Q;if(w7=G.css,console.log(`${T.cyan}[Crosswind]${T.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),X.output){let W=A0.isAbsolute(X.output)?X.output:A0.join($,X.output),U=A0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return I$=!1,G.css}catch(Z){return console.error(`${T.red}[Crosswind]${T.reset} Build error:`,Z),I$=!1,w7}}async function N7($){n1=null,await D$($)}function ZT(){return w7}function _Z($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,J=Y.exec($);while(J!==null){for(let G of J[1].split(/\s+/))if(G.trim())Z.add(G.trim());J=Y.exec($)}let X=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=X.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=X.exec($)}return Z}async function BZ($,Z){try{let Y=await nX();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):_Z($);if(J.size===0)return"";let X=Z?A0.resolve(Z):process.cwd();if(!e4)e4=c0(X,"cache");let Q=[...J].sort().join(" "),G=`${UZ||"default"}::${Q}`,K=M4.get(G);if(K!==void 0)return cX(G,K),K;let W=await sM(G);if(W!==null)return cX(G,W),W;if(!n1){let w=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (r0(),jZ)),R=await N(X);if(R.css)if(typeof R.css==="string"){let E=A0.isAbsolute(R.css)?R.css:A0.resolve(X,R.css);if(await Bun.file(E).exists()){let M=await import(E);w=M.default||M,console.log(`${T.green}[Crosswind]${T.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(w={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let E=A0.isAbsolute(R.css.config)?R.css.config:A0.resolve(X,R.css.config);if(await Bun.file(E).exists()){let M=await import(E);w={...M.default||M,...w}}}console.log(`${T.green}[Crosswind]${T.reset} Using inline CSS config from stx.config.ts`)}}catch{}n1=w||await rX(X);try{UZ=zZ(JSON.stringify(n1??{}))}catch{UZ="unhashable"}}let U=Y.defaultConfig||Y.config,z=n1||{},_=U.theme||{},q=(z.theme||{}).extend||{},j={..._};if(Object.keys(q).length>0)j.extend=q;let H=[...U.safelist||[],...z.safelist||[]],O={...U,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},V=new Y.CSSGenerator(O);for(let w of H)V.generate(w);for(let w of J)V.generate(w);let L=V.toCSS(!0,!1),F=O.shortcuts||z.shortcuts||{};for(let[w,N]of Object.entries(F)){if(!J.has(w)&&!H.includes(w))continue;let R=N.split(/\s+/).filter(Boolean);for(let E of R)V.generate(E)}L=V.toCSS(!0,!1);let A=L.split(`
|
|
938
|
+
`),X.set(U,z)}return z(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class ez{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,X=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!X&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:X};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=X?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${J.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let J=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}let Z={};for(let[Y,J]of this.metrics.entries()){let X=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:X?.maxTime,budgetUtilization:X?J.totalTime/J.count/X.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function iM(){if(!lX)lX=new ez;return lX}var T$,pM=500,qu,lX=null,p1;var t4=D(()=>{T$=new Map;qu=new tz;p1=new Proxy({},{get($,Z){return iM()[Z]}})});var T;var A7=D(()=>{T={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var qZ={};$0(qZ,{resetCssCache:()=>eM,resetCrosswindCache:()=>$T,rebuildCrosswindCSS:()=>N7,loadCrosswindConfig:()=>rX,loadCrosswind:()=>nX,injectCrosswindCSS:()=>P0,getCrosswindServeAsset:()=>iX,getCachedCSS:()=>ZT,generateCrosswindCSS:()=>BZ,extractClassNames:()=>_Z,buildCrosswindCSS:()=>D$});import A0 from"path";import{hasLocalConfig as nM}from"bunfig/discovery";function zZ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function cX($,Z){if(M4.has($))M4.delete($);else if(M4.size>=Z_)M4.delete(M4.keys().next().value);M4.set($,Z)}function rM($){let Z=zZ($);if(i1.has(Z))i1.delete(Z);else if(i1.size>=Z_)i1.delete(i1.keys().next().value);return i1.set(Z,$),Z}function iX($){let Z=i1.get($);if(Z===void 0)return;return i1.delete($),i1.set($,Z),Z}async function aM($){if(!e4)return null;try{let Z=Bun.file(A0.join(e4,`cw-${zZ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function sM($,Z){if(!e4)return;try{if(!fs.existsSync(e4))fs.mkdirSync(e4,{recursive:!0});await Bun.write(A0.join(e4,`cw-${zZ($)}.css`),Z)}catch{}}async function $_($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig,extractClasses:Z.extractClasses}}catch{}return null}function oM(){let $=[],Z=process.cwd();while(Z!==A0.dirname(Z))$.push(A0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(A0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(A0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(A0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(A0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(A0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=A0.dirname(Z);return $}function tM(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[A0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),A0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),A0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),A0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),A0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),A0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(A0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(A0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function nX(){if(pX)return W4;pX=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await $_(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded from ${A0.dirname(A0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let X=A0.resolve(process.env.CROSSWIND_SRC),Q=await $([X]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${X}`);return W4=Q,W4}let Z=await $(oM());if(Z)return W4=Z,W4;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of Y){let Q=await $_(X);if(Q){if(W4=Q,!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded`);return W4}}let J=await $(tM());if(J)return W4=J,W4;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${T.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${T.reset}`),console.warn(`${T.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${T.reset}`),null}}function eM(){M4.clear(),i1.clear()}function $T(){W4=null,pX=!1,n1=null,w7="",M4.clear(),i1.clear(),UZ=null}async function rX($){try{if(!nM({name:"crosswind",cwd:$}))return null;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 J=A0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${T.yellow}[Crosswind]${T.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function D$($){if(I$)return w7;I$=!0;try{let Z=await nX();if(!Z||!Z.build)return I$=!1,"";if(!n1)n1=await rX($);if(!n1)return I$=!1,"";let Y=Z.defaultConfig?.theme||{},J=n1.theme||{},X={...Z.defaultConfig,...n1,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},Q=performance.now(),G=await Z.build(X),K=performance.now()-Q;if(w7=G.css,console.log(`${T.cyan}[Crosswind]${T.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),X.output){let W=A0.isAbsolute(X.output)?X.output:A0.join($,X.output),U=A0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return I$=!1,G.css}catch(Z){return console.error(`${T.red}[Crosswind]${T.reset} Build error:`,Z),I$=!1,w7}}async function N7($){n1=null,await D$($)}function ZT(){return w7}function _Z($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,J=Y.exec($);while(J!==null){for(let G of J[1].split(/\s+/))if(G.trim())Z.add(G.trim());J=Y.exec($)}let X=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=X.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=X.exec($)}return Z}async function BZ($,Z){try{let Y=await nX();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):_Z($);if(J.size===0)return"";let X=Z?A0.resolve(Z):process.cwd();if(!e4)e4=c0(X,"cache");let Q=[...J].sort().join(" "),G=`${UZ||"default"}::${Q}`,K=M4.get(G);if(K!==void 0)return cX(G,K),K;let W=await aM(G);if(W!==null)return cX(G,W),W;if(!n1){let w=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (r0(),jZ)),R=await N(X);if(R.css)if(typeof R.css==="string"){let E=A0.isAbsolute(R.css)?R.css:A0.resolve(X,R.css);if(await Bun.file(E).exists()){let M=await import(E);w=M.default||M,console.log(`${T.green}[Crosswind]${T.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(w={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let E=A0.isAbsolute(R.css.config)?R.css.config:A0.resolve(X,R.css.config);if(await Bun.file(E).exists()){let M=await import(E);w={...M.default||M,...w}}}console.log(`${T.green}[Crosswind]${T.reset} Using inline CSS config from stx.config.ts`)}}catch{}n1=w||await rX(X);try{UZ=zZ(JSON.stringify(n1??{}))}catch{UZ="unhashable"}}let U=Y.defaultConfig||Y.config,z=n1||{},_=U.theme||{},q=(z.theme||{}).extend||{},j={..._};if(Object.keys(q).length>0)j.extend=q;let H=[...U.safelist||[],...z.safelist||[]],O={...U,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},V=new Y.CSSGenerator(O);for(let w of H)V.generate(w);for(let w of J)V.generate(w);let L=V.toCSS(!0,!1),F=O.shortcuts||z.shortcuts||{};for(let[w,N]of Object.entries(F)){if(!J.has(w)&&!H.includes(w))continue;let R=N.split(/\s+/).filter(Boolean);for(let E of R)V.generate(E)}L=V.toCSS(!0,!1);let A=L.split(`
|
|
939
939
|
`);for(let[w,N]of Object.entries(F)){if(!J.has(w)&&!H.includes(w))continue;let R=N.split(/\s+/).filter(Boolean),E=[],M=[];for(let I of R){let S=I.startsWith("dark:"),y=`.${(S?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<A.length;b++){let h=A[b].trim();if(h===`${y} {`||h.startsWith(`${y} {`)){let r=b,m="";while(r<A.length){if(m+=A[r],A[r].includes("}"))break;r++}let P=m.match(/\{([^}]+)\}/);if(P)if(S)M.push(P[1].trim());else E.push(P[1].trim());break}}}if(E.length)L+=`
|
|
940
940
|
.${w} { ${E.join(" ")} }`;if(M.length)L+=`
|
|
941
|
-
@media (prefers-color-scheme: dark) { .dark .${w} { ${M.join(" ")} } }`}return cX(G,L),
|
|
941
|
+
@media (prefers-color-scheme: dark) { .dark .${w} { ${M.join(" ")} } }`}return cX(G,L),sM(G,L),L}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function P0($,Z,Y=!1){let J=await BZ($,Z);if(!J)return $;let X=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${rM(J)}.css">`:`<style data-crosswind="generated">
|
|
942
942
|
${J}
|
|
943
943
|
</style>`,Q=/(?:<style\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>)/g;if(Q.test($)){let G=!1;return $.replace(Q,()=>{if(G)return"";return G=!0,X})}if($.includes("</head>"))return $.replace("</head>",`${X}
|
|
944
944
|
</head>`);if($.includes("<body"))return $.replace(/<body([^>]*)>/,`<body$1>
|
|
@@ -1287,7 +1287,7 @@ else {
|
|
|
1287
1287
|
|
|
1288
1288
|
console.log('[stx] Lifecycle runtime initialized');
|
|
1289
1289
|
})();
|
|
1290
|
-
`}function
|
|
1290
|
+
`}function aX($){return Symbol($)}var Au,wu,Nu;var J_=D(()=>{Au=aX("theme"),wu=aX("router"),Nu=aX("i18n")});import*as Q_ from"crypto";function X_($){let Z=/\$(\w+)\./g,Y=[],J;while((J=Z.exec($))!==null)if(!Y.includes(J[1]))Y.push(J[1]);return Y}function YT(){return`stx-${Q_.randomBytes(4).toString("hex")}`}function JT($){return/\$\w+\./.test($)}function G_($){let Z=[],Y=new Set,J=/<(\w+)([^>]*?)(\s*\/?>)/g,X=$;return X=X.replace(J,(Q,G,K,W)=>{if(["script","style","template"].includes(G.toLowerCase()))return Q;let U=[],z=!1,_=K,B=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,q=[...K.matchAll(B)];for(let O of q){let V=O[0],L=O[1],F=O[2];if(JT(F)){z=!0;let A=F.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(A){let w=A[1];if(U.push({attr:L,expr:w,fullMatch:V,originalAttr:L}),X_(w).forEach((R)=>Y.add(R)),L==="text")_=_.replace(V,"");else if(L==="class")_=_.replace(V,'class=""');else if(L==="disabled"||L==="hidden")_=_.replace(V,"");else _=_.replace(V,`${L}=""`)}}}if(!z)return Q;let j=_.match(/\bid\s*=\s*"([^"]+)"/),H;if(j)H=j[1];else H=YT(),_=` id="${H}"${_}`;for(let O of U)Z.push({elementId:H,attribute:O.attr,expression:O.expr,stores:X_(O.expr)});return`<${G}${_}${W}`}),{html:X,bindings:Z,stores:Y}}function K_($,Z){if($.length===0)return"";let Y=Array.from(Z),J=`
|
|
1291
1291
|
<script>
|
|
1292
1292
|
(function() {
|
|
1293
1293
|
'use strict';
|
|
@@ -1445,7 +1445,7 @@ else {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
})();
|
|
1447
1447
|
</script>
|
|
1448
|
-
`,J}function
|
|
1448
|
+
`,J}function sX($){let{html:Z,bindings:Y,stores:J}=G_($);if(Y.length===0)return $;let X=K_(Y,J),Q=Z.lastIndexOf("</body>");if(Q!==-1)return Z.slice(0,Q)+X+Z.slice(Q);return Z+X}var oX=()=>{};function tX($){let Z=$.analytics;if(!Z?.enabled)return"";switch(Z.driver){case"fathom":return XT(Z);case"google-analytics":return QT(Z);case"plausible":return GT(Z);case"self-hosted":return KT(Z);case"custom":return WT(Z);default:return""}}function XT($){let Z=$.fathom;if(!Z?.siteId)return"";let Y=Z.scriptUrl||"https://cdn.usefathom.com/script.js",J=Z.defer!==!1?" defer":"",X=[`data-site="${S1(Z.siteId)}"`];if(Z.honorDnt)X.push('data-honor-dnt="true"');if(Z.spa)X.push('data-spa="auto"');if(Z.canonical)X.push(`data-canonical="${S1(Z.canonical)}"`);if(Z.auto===!1)X.push('data-auto="false"');return`
|
|
1449
1449
|
<!-- Fathom Analytics -->
|
|
1450
1450
|
<script src="${S1(Y)}" ${X.join(" ")}${J}></script>
|
|
1451
1451
|
`}function QT($){let Z=$.googleAnalytics;if(!Z?.measurementId)return"";let Y=S1(Z.measurementId),J=Z.debug?`gtag('config', '${Y}', { 'debug_mode': true });`:"";return`
|
|
@@ -1862,8 +1862,8 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
1862
1862
|
@end${K}`;J.push(`Added ${z} missing @end${K}`)}}if(J.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),J.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:J}},createFallbackContent($,Z){if($6())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};K1=new NZ,b$={isDevelopment(){return $6()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
|
|
1863
1863
|
`)}}});import K9 from"path";function bT($){let Z={"&":"&","<":"<",">":">",'"':""","'":"'"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function I7($,Z={}){let{allowHtml:Y=!1,maxLength:J=1e4,allowSpecialChars:X=!0,customSanitizer:Q}=Z,G=[],K=$,W=!1;if(Q){let z=Q(K);if(z!==K)K=z,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>J)K=K.substring(0,J),W=!0,G.push(`Parameter truncated to ${J} characters`);if(!Y&&/<[^>]+>/.test(K))K=bT(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:z,replacement:_,name:B}of U)if(z.test(K))K=K.replace(z,_),W=!0,G.push(`Removed ${B} from parameter`);if(!X){let z=K;if(K=K.split("").filter((_)=>{let B=_.charCodeAt(0);return B>=32&&B!==127}).join(""),K!==z)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function x_($,Z){let Y=$.replace(/\0/g,"");Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Y.includes("../")||Y.includes("./"))Y=Y.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!RZ.isValidFilePath(Y,Z))return null;return Y}function v_($){let Z=[],Y=$.trim(),J=Y!==$,X=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of X)if(Q.test(Y))Z.push(`Potentially dangerous pattern detected: ${G}`);if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),J=!0,Z.push("Null bytes removed from expression");return{value:Y,modified:J,warnings:Z}}function f_($,Z={}){return $.map((Y)=>I7(Y,Z))}function W9($){let Z={};for(let[Y,J]of Object.entries($)){if(!RZ.isValidVariableName(Y))continue;if(typeof J==="string"){let X=I7(J);Z[Y]=X.value}else if(Array.isArray(J))Z[Y]=J.map((X)=>typeof X==="string"?I7(X).value:X);else if(typeof J==="object"&&J!==null)Z[Y]=W9(J);else Z[Y]=J}return Z}var RZ;var g_=D(()=>{RZ={isValidFilePath($,Z){let Y=$.replace(/\\/g,"/");if(Y.includes("\x00"))return!1;if(Y.includes("../")||Y.includes("..\\")||Y===".."||Y.startsWith("../")||Y.endsWith("/..")||Y.includes("/..\\")||Y.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Y))return!1;if(Y.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Y===Q.slice(0,-1)||Y.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Y)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Y.includes(Q)))return!1}if(Z){let X=K9.resolve(Z,$),Q=K9.resolve(Z);if(!X.startsWith(Q+K9.sep)&&X!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Y)=>Y.test($))}}});var h_=D(()=>{VZ();P_();y_();g_();FZ()});var C1=D(()=>{h_()});class D7{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,J=this.source[this.pos];if(/\s/.test(J))return this.readWhitespace($,Z,Y);if(J==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(J==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(J==='"'||J==="'")return this.readString(J,$,Z,Y);if(J==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(J)||J==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(J))return this.readIdentifier($,Z,Y);if(J==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(J==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(J==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(J==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let X=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of X)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(J))return this.advance(),{type:"OPERATOR",value:J,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(J))return this.advance(),{type:"PUNCTUATION",value:J,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:J,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
1864
1864
|
`)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readString($,Z,Y,J){this.advance();while(this.pos<this.source.length){let X=this.source[this.pos];if(X==="\\"){this.advance(2);continue}if(X===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:J}}readTemplateString($,Z,Y){this.advance();let J=0,X=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(J>=X){this.pos=this.source.length;break}this.advance(2),J++;continue}if(Q==="{"&&J>0){J++,this.advance();continue}if(Q==="}"&&J>0){J--,this.advance();continue}if(Q==="`"&&J===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let J=this.peek(1)?.toLowerCase();if(J==="x"||J==="o"||J==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readIdentifier($,Z,Y){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readDirective($,Z,Y){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
|
|
1865
|
-
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function s0($,Z,Y,J=0){let X=0,Q=J,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)X++;else if(U===Y){if(X--,X===0)return Q}Q++}return-1}function U9($,Z){let Y=Z,J={paren:0,bracket:0,brace:0},X=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&X){Y++;continue}if((G==='"'||G==="'")&&!X){X=G,Y++;continue}if(G===X&&X!=="`"){X=null,Y++;continue}if(G==="`"&&!X){X="`",Y++;continue}if(G==="`"&&X==="`"&&Q===0){X=null,Y++;continue}if(X==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(X){Y++;continue}if(J.paren===0&&J.bracket===0&&J.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")J.paren++;else if(G===")"){if(J.paren--,J.paren<0)break}else if(G==="[")J.bracket++;else if(G==="]"){if(J.bracket--,J.bracket<0)break}else if(G==="{")J.brace++;else if(G==="}"){if(J.brace--,J.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function MZ($){let Z=[],Y="",J={paren:0,bracket:0,brace:0},X=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&X){Y+=K;continue}if((K==='"'||K==="'")&&!X){X=K,Y+=K;continue}if(K===X&&X!=="`"){X=null,Y+=K;continue}if(K==="`"&&!X){X="`",Y+=K;continue}if(K==="`"&&X==="`"&&Q===0){X=null,Y+=K;continue}if(X==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(X){Y+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&J.paren===0&&J.bracket===0&&J.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!X){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function E4($,Z){let Y=PT($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function PT($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let J=s0($,"(",")",Y);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,J),endPos:J+1}}function yT($,Z){let Y=$.lastIndexOf("<",Z);if(Y===-1)return!1;return Y>$.lastIndexOf(">",Z)}function Y6($,Z,Y,J){let X=1,Q=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&X>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),z=W?W.index:1/0,_=U?U.index:1/0;if(z<_)X++,Q=z+W[0].length;else if(_<1/0){if(X--,X===0)return _;Q=_+U[0].length}else break}return-1}function z9($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,X=E4($,J);if(!X)return null;let Q=X.endPos,G=Y6($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z="if",_=X.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(yT(K,j)){U++;continue}if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:z,condition:_,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=E4(K,V);if(!L){U++;continue}z="elseif",_=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:z,condition:_,content:K.substring(B,U),start:Q+B,end:Q+U}),z="else",_=void 0,U+=5,B=U;continue}}U++}return W.push({type:z,condition:_,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function P$($){let Z=[],Y=/@if\s*\(/g,J=Y.exec($);while(J!==null){if(Z.some((G)=>J.index>G.start&&J.index<G.end)){J=Y.exec($);continue}let Q=z9($,J.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;J=Y.exec($)}return Z}function k7($,Z,Y){let J=[],X=new RegExp(`@${Z}\\s*\\(`,"g"),Q=X.exec($);while(Q!==null){if(J.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=X.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=s0($,"(",")",W);if(U===-1){Q=X.exec($);continue}let z=$.slice(W+1,U),_=U+1,B=Y6($,Z,Y,_);if(B===-1){Q=X.exec($);continue}let q=$.slice(_,B),j=B+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:q,start:K,end:j}),X.lastIndex=j,Q=X.exec($)}return J}function TZ($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,X=E4($,J);if(!X)return null;let Q=X.endPos,G=Y6($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z=null,_=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(_++,z)z.content+=q[0];U+=q[0].length;continue}if(j){if(_--,z)z.content+=j[0];U+=j[0].length;continue}if(_>0){if(z)z.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(z)W.push(z);let L=U+H[0].length,F=E4(K,L);if(!F){U++;continue}z={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(z)W.push(z);z={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(z)z.content+=K[U];U++}}if(z)W.push(z);return{fullMatch:$.slice(Z,G+10),expression:X.expression,cases:W,start:Z,end:G+10}}var d_=()=>{};function l_($){let Z=[],Y=0;while(Y<$.length){let J=$.indexOf("{{",Y),X=$.indexOf("{!!",Y),Q=!1,G;if(J===-1&&X===-1)break;else if(J===-1)G=X,Q=!0;else if(X===-1)G=J,Q=!1;else if(X<J)G=X,Q=!0;else G=J,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,z=xT($,U,W);if(z===-1){Y=G+1;continue}let _=$.slice(U,z).trim(),B=z+W.length;Z.push({fullMatch:$.slice(G,B),expression:_,start:G,end:B,isRaw:Q}),Y=B}return Z}function xT($,Z,Y){let J=Z,X=null,Q={paren:0,bracket:0,brace:0},G=0;while(J<$.length){let K=$[J];if((J>0?$[J-1]:"")==="\\"&&X){J++;continue}if((K==='"'||K==="'")&&!X){X=K,J++;continue}if(K===X&&X!=="`"){X=null,J++;continue}if(K==="`"&&!X){X="`",J++;continue}if(K==="`"&&X==="`"&&G===0){X=null,J++;continue}if(X==="`"&&K==="$"&&$[J+1]==="{"){G++,J+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;J++;continue}if(X){J++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(J,J+Y.length)===Y)return J}J++}return-1}function c_($){let Z=MZ($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],J=[];for(let X=1;X<Z.length;X++){let Q=vT(Z[X]);if(Q)J.push(Q)}return{baseExpression:Y,filters:J}}function vT($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let J=Z.slice(0,Y).trim(),X=Y+1,Q=s0(Z,"(",")",Y);if(Q===-1)return{name:J,args:[]};let G=Z.slice(X,Q),K=_9(G);return{name:J,args:K}}function _9($){let Z=[],Y="",J={paren:0,bracket:0,brace:0},X=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&X){Y+=K;continue}if((K==='"'||K==="'")&&!X){X=K,Y+=K;continue}if(K===X&&X!=="`"){X=null,Y+=K;continue}if(K==="`"&&!X){X="`",Y+=K;continue}if(K==="`"&&X==="`"&&Q===0){X=null,Y+=K;continue}if(X==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(X){Y+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K===","&&J.paren===0&&J.bracket===0&&J.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function p_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let J=s0($,"(",")",Y);if(J===-1)return null;return{params:$.slice(Y+1,J),endPos:J+1}}function i_($){let Z=[],J=new D7($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),X=0;while(X<J.length){let Q=J[X],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,X++,X>=J.length)break}let K=J[X];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(X++,X>=J.length)break;let U=J[X];if(U.type==="IDENTIFIER"){let z=U.value;if(X++,X<J.length&&J[X].type==="OPERATOR"&&J[X].value==="="){X++;let _=X<J.length?J[X].start:$.length,B=u_(J,X,$);X=B.nextIndex,Z.push({type:"variable",name:z,value:$.slice(_,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let z=U.start,_=U.value==="{"?"}":"]",B=s0($,U.value,_,z);if(B!==-1){let q=$.slice(z,B+1);if(X=m_(J,B+1),X<J.length&&J[X].type==="OPERATOR"&&J[X].value==="="){X++;let j=X<J.length?J[X].start:$.length,H=u_(J,X,$);X=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?J[X-1].start:K.start;if(X++,X>=J.length)break;let U=J[X];if(U.type==="IDENTIFIER"){let z=U.value;X++;let _=-1;while(X<J.length){if(J[X].type==="PUNCTUATION"&&J[X].value==="{"){_=J[X].start;break}X++}if(_!==-1){let B=s0($,"{","}",_);if(B!==-1)Z.push({type:"function",name:z,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),X=m_(J,B+1)}}}else X++}return Z}function u_($,Z,Y){let J=Z,X={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(J<$.length){let G=$[J];if(G.type==="PUNCTUATION"){if(G.value==="(")X.paren++;else if(G.value===")")X.paren--;else if(G.value==="[")X.bracket++;else if(G.value==="]")X.bracket--;else if(G.value==="{")X.brace++;else if(G.value==="}")X.brace--;if(G.value===";"&&X.paren===0&&X.bracket===0&&X.brace===0){Q=G.start,J++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(X.paren===0&&X.bracket===0&&X.brace===0){Q=$[J-1]?.end??G.start;break}}Q=G.end,J++}return{nextIndex:J,endPos:Q}}function m_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var n_=()=>{};var S7=D(()=>{d_();n_()});function fT($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=TZ(J,G);if(!K)break;try{let W;if(R0(K.expression))W=M0(K.expression,Object.keys(Z))(...Object.values(Z));else W=V0(K.expression,Z);let U="",z=!1;for(let _ of K.cases)if(_.type==="default"){if(!z)U=_.content.trim()}else try{let B;if(_.value&&R0(_.value))B=M0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)B=V0(_.value,Z);if(W===B){U=_.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+U+J.substring(K.end),X=!0}catch(W){let U=W instanceof Error?W.message:String(W),z=H0("Switch",`Error evaluating @switch expression: ${U}`,G0.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function d6($,Z,Y){let J=$;J=fT(J,Z,Y);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=E4(J,K+7);if(!W)break;let U=W.endPos,z=Y6(J,"unless","endunless",U);if(z===-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 _=J.slice(U,z),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(_))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(_))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(_))!==null)F.push({pos:A.index,type:"else"});F.sort((w,N)=>w.pos-N.pos);for(let w of F)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){q=w.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${_}@endif`;J=J.substring(0,K)+j+J.substring(z+10),Q=!0}}J=q9(J,Z,Y),J=j9(J,Z,Y),J=B9(J,Z);let X=()=>{let Q=P$(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let z of K.branches){if(U)break;if(z.type==="else")W=z.content,U=!0;else try{let _;if(z.condition&&R0(z.condition))_=M0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)_=V0(z.condition,Z);if(_)W=z.content,U=!0}catch(_){W=H0(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${_ instanceof Error?_.message:String(_)}`,G0.EVALUATION_ERROR),U=!0}}J=J.substring(0,K.start)+W+J.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),z=H0("If",`Error processing @if block: ${U}`,G0.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!X())break;if(J===Q)break}return J}function r_($){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 J=[];while(Z<$.length){let X=$[Z];if(X==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(X===Y){Z++;break}J.push(X),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function B9($,Z){let Y=$;function J(K,W,U,z){let _=1,B=z,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&_>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)_++,B=V+H[0].length;else if(L<1/0){if(_--,_===0)return L;B=L+O[0].length}else break}return-1}function X(K,W,U){let z=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.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=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")z++;else if(O.type==="close")z--;else if(O.type==="else"&&z===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,_,B=Y.slice(U+5),q=r_(B);if(q)z=q.value,_=U+5+q.consumed;else _=U+5;let j=J(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=X(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=z?T4(`auth?.check && auth?.user?.[${z}]`,Z):T4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,_,B=Y.slice(U+6),q=r_(B);if(q)z=q.value,_=U+6+q.consumed;else _=U+6;let j=J(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=X(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=z?T4(`!auth?.check || !auth?.user?.[${z}]`,Z):T4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(W)z.push(W);if(U){let _=T4(U,Z);z.push(_)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let B=_.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=J(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${W}(?![a-z])`,"g"),N=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,E=[],M;while((M=A.exec(V))!==null)E.push({pos:M.index,type:"open"});while((M=w.exec(V))!==null)E.push({pos:M.index,type:"close"});while((M=N.exec(V))!==null)E.push({pos:M.index,type:"elseDirective"});while((M=R.exec(V))!==null)E.push({pos:M.index,type:"else"});E.sort((b,h)=>b.pos-h.pos);for(let b of E){if(b.type==="open"){F++;continue}if(b.type==="close"){F--;continue}if(F===0)L.push(b)}let I=[],S=0;for(let b=0;b<L.length;b++){let h=L[b];if(I.push({content:V.slice(S,h.pos),ability:void 0}),h.type==="elseDirective"){let r=V.slice(h.pos+`@${U}`.length),m=G(r);if(m){I[I.length-1]={content:V.slice(S,h.pos)},S=h.pos+`@${U}`.length+m.paramsEnd,I.push({content:"",ability:m.ability,type:m.type,id:m.id}),I.pop();let P=L[b+1],d=P?P.pos:V.length;I.push({content:V.slice(S,d),ability:m.ability,type:m.type,id:m.id}),S=d}}else S=h.pos+5}if(S<V.length){let b=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(S),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(S)})}let k=Q(j.ability,j.type,j.id),x=K==="can"?k:!k,y="";if(x)y=I[0]?.content||"";else{let b=!1;for(let h=1;h<I.length;h++){let r=I[h];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let m=Q(r.ability,r.type,r.id);if(K==="can"?m:!m){y=r.content,b=!0;break}}}if(!b&&I.length>0){let h=I[I.length-1];if(h.isFinalElse)y=h.content}}Y=Y.substring(0,B)+y+Y.substring(O+`@${W}`.length),z=!0}}return Y}function q9($,Z,Y){let J=$;function X(Q,G,K,W,U){let z=!0;while(z){z=!1;let _=new RegExp(`@${G}\\s*\\(`),B=Q.match(_);if(!B||B.index===void 0)break;let q=B.index,j=E4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=Y6(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,w=0;while(w<V.length){let N=V.indexOf("@",w);if(N===-1)break;let R=V.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,w=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,w=N+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=N;break}w=N+1}try{let N=W(L.trim()),R;if(F!==-1){let E=V.slice(0,F),M=V.slice(F+5);R=N?E:M}else R=N?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),z=!0}catch(N){let R=N instanceof Error?N.message:String(N),E=H0(U,`Error processing @${G} directive: ${R}`,G0.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(O+`@${K}`.length);break}}return Q}return J=X(J,"isset","endisset",(Q)=>{let G=T4(Q,Z);return G!==void 0&&G!==null},"Isset"),J=X(J,"empty","endempty",(Q)=>{let G=T4(Q,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"),J}function j9($,Z,Y){let J=$,X="development";function Q(G,K,W,U){let z=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let O=z.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=X===k[2]}let F=1,A=L,w=-1;while(F>0&&A<j.length){z.lastIndex=A,_.lastIndex=A;let k=z.exec(j),x=_.exec(j),y=k?k.index:1/0,b=x?x.index:1/0;if(y<b)F++,A=y+k[0].length;else if(b<1/0){if(F--,F===0){w=b;break}A=b+x[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let N=j.substring(L,w),R=-1,E=0,M=0;while(M<N.length){let k=N.indexOf("@",M);if(k===-1)break;let x=N.substring(k);if(B.test(x)){E++,M=k+1;continue}if(q.test(x)){E--,M=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(x)){R=k;break}M=k+1}let I;if(R!==-1){let k=N.slice(0,R),x=N.slice(R+5);I=U?k:x}else I=U?N:"";let S=`@${W}`.length;j=j.substring(0,V)+I+j.substring(w+S),H=!0}return j}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",X==="production"),J=Q(J,"development","enddevelopment",X==="development"),J=Q(J,"staging","endstaging",X==="staging"),J=Q(J,"testing","endtesting",X==="testing"),J}var EZ=D(()=>{J9();C1();S7();n0()});function O9($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function J6($,Z){if(!$)return Z?.nonceGenerator?.()??O9();let Y=H9.get($);if(!Y)Y=Z?.nonceGenerator?.()??O9(),H9.set($,Y);return Y}function gT($){H9.delete($)}function L9($,Z){let Y=[];for(let[J,X]of Object.entries($)){if(X===void 0||X===null)continue;if(typeof X==="boolean"){if(X)Y.push(J);continue}if(Array.isArray(X)){let Q=[...X];if(Z&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${J} ${Q.join(" ")}`)}}return Y.join("; ")}function DZ($,Z){return`<meta http-equiv="Content-Security-Policy" content="${L9($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function hT($){return{enabled:!0,directives:{strict:s_,moderate:IZ,relaxed:a_,api:o_}[$]||IZ,useNonce:$==="strict",addMetaTag:!0}}function dT($,Z){let Y={...$};for(let[J,X]of Object.entries(Z)){let Q=J,G=Y[Q];if(X===void 0||X===null)continue;if(typeof X==="boolean")Y[Q]=G||X;else if(Array.isArray(X)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...X])];Y[Q]=W}}return Y}function V9($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=Z.useNonce?J6(Y,Z):void 0,X=DZ(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1866
|
-
${X}`)}function F9($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(J,X)=>{if(X.includes("nonce="))return J;return`<script nonce="${Z}"${X}>`}),Y=Y.replace(/<style([^>]*)>/gi,(J,X)=>{if(X.includes("nonce="))return J;return`<style nonce="${Z}"${X}>`}),Y}function A9($,Z,Y,J){let X=$,Q=J.csp;if(X=X.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?J6(Z,Q):void 0;return DZ(Q.directives,G)}),X=X.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return J6(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=J6(Z,Q);return X}function uT(){return[t_,e_]}function mT($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,J]of Object.entries($))if(Array.isArray(J)&&J.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function $B($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function lT($,Z){if(!$.enabled)return{};let Y=$.useNonce?J6(Z,$):void 0,J=L9($.directives,Y);return{[$B($.reportOnly)]:J}}var H9,s_,IZ,a_,o_,t_,e_,cT;var w9=D(()=>{H9=new WeakMap;s_={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},IZ={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},a_={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},o_={"default-src":["'none'"],"frame-ancestors":["'none'"]};t_={name:"csp",handler:($,Z,Y,J)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?J6(Y,Q):void 0;return DZ(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},e_={name:"cspNonce",handler:($,Z,Y,J)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return J6(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};cT={enabled:!1,reportOnly:!1,directives:IZ,useNonce:!1,addMetaTag:!0}});import pT from"crypto";function nT($=iT){let Z=pT.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return N9=Z,Z}function rT(){if(!N9)nT();return N9}function sT($=ZB){let Z=rT();return`<input type="hidden" name="${$}" value="${Z}">`}function YB($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,J)=>{return sT(J||ZB)})}var iT=40,ZB="_token",N9=null;var JB=()=>{};async function R9($,Z,Y,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let X=$;for(let Q of J.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)X=await aT(X,Q,Z,Y,J);else X=await oT(X,Q,Z,Y,J)}return X}async function aT($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,z=E$(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],B=z.exec(U);while(B!==null){let[q,j="",H=""]=B,O=B.index||0;try{let V=j?XB(j):[],L=H.trim(),F=await G(L,V,Y,J);_.push({original:q,processed:F,startIndex:O})}catch(V){let L=V instanceof Error?V.message:String(V);if(X.debug)console.error(`Error processing custom directive @${Q}:`,V);_.push({original:q,processed:H0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,G0.EVALUATION_ERROR),startIndex:O})}B=z.exec(U)}for(let q=_.length-1;q>=0;q--){let{original:j,processed:H}=_[q];U=U.replace(j,H)}return U}async function oT($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=$,W=E$(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],z=W.exec(K);while(z!==null){let[q,j=""]=z,H=z.index||0;try{let O=XB(j),V=await G("",O,Y,J);U.push({original:q,processed:V,startIndex:H})}catch(O){let V=O instanceof Error?O.message:String(O);if(X.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:H0("CustomDirective",`Error in @${Q}(${j}): ${V}`,G0.EVALUATION_ERROR),startIndex:H})}z=W.exec(K)}let _=E$(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),B=_.exec(K);while(B!==null){let[q]=B,j=B.index||0;try{let H=await G("",[],Y,J);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(X.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:H0("CustomDirective",`Error in @${Q}: ${O}`,G0.EVALUATION_ERROR),startIndex:j})}B=_.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function XB($){if(!$.trim())return[];let Z=[],Y="",J=!1,X="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!J)J=!0,X=G;else if(G===X)J=!1;else Y+=G;else if(G===","&&!J)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var M9=D(()=>{C1();t4()});function u6($,Z){if(typeof $!=="string"||$.length===0)throw Error(`@appearanceBootstrap ${Z} must be a non-empty string`)}function eT($){if(!$||typeof $!=="object"||Array.isArray($))throw Error("@appearanceBootstrap expects an options object");let Z=$,Y=Z.appearance,J=Z.colorMode;if(u6(Z.storageKey,"storageKey"),!Y||typeof Y!=="object"||Array.isArray(Y))throw Error("@appearanceBootstrap appearance must be an object");if(!J||typeof J!=="object"||Array.isArray(J))throw Error("@appearanceBootstrap colorMode must be an object");if(u6(Y.key,"appearance.key"),u6(Y.attribute,"appearance.attribute"),u6(Y.default,"appearance.default"),u6(J.key,"colorMode.key"),u6(J.attribute,"colorMode.attribute"),u6(J.default,"colorMode.default"),!GB.test(Y.key)||!GB.test(J.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!QB.test(Y.attribute)||!QB.test(J.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(Y.allowed)||Y.allowed.length===0||Y.allowed.some((X)=>typeof X!=="string"||X.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!Y.allowed.includes(Y.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");if(!tT.has(J.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");return{storageKey:Z.storageKey,appearance:{key:Y.key,attribute:Y.attribute,allowed:[...new Set(Y.allowed)],default:Y.default},colorMode:{key:J.key,attribute:J.attribute,default:J.default}}}function $E($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ZE($){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${$E($)};const root=document.documentElement;let stored={};try{const raw=localStorage.getItem(config.storageKey);const parsed=raw?JSON.parse(raw):{};if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed))stored=parsed}catch{}const selectedAppearance=config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default;const selectedMode=["light","dark","system"].includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default;root.setAttribute("data-"+config.appearance.attribute,selectedAppearance);root.setAttribute("data-"+config.colorMode.attribute,selectedMode);let dark=selectedMode==="dark";if(selectedMode==="system"){try{dark=matchMedia("(prefers-color-scheme: dark)").matches}catch{dark=false}}root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light"}());</script>`}function YE($,Z){let Y=1,J=null,X=!1;for(let Q=Z+1;Q<$.length;Q++){let G=$[Q];if(X){X=!1;continue}if(J){if(G==="\\")X=!0;else if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="(")Y++;else if(G===")"&&--Y===0)return Q}return-1}function T9($,Z){let Y=$,J=/@appearanceBootstrap\s*\(/g,X;while((X=J.exec(Y))!==null){let Q=X.index+X[0].length-1,G=YE(Y,Q);if(G===-1)throw Error("@appearanceBootstrap has an unclosed options object");let K=Y.slice(Q+1,G).trim(),W=V0(`(${K})`,Z),U=ZE(eT(W));Y=Y.slice(0,X.index)+U+Y.slice(G+1),J.lastIndex=X.index+U.length}return Y}var QB,GB,tT;var E9=D(()=>{n0();QB=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,GB=/^[A-Za-z_$][\w$]*$/,tT=new Set(["light","dark","system"])});var D9={};$0(D9,{useTitle:()=>UB,useSeoMeta:()=>I9,usePageTitle:()=>UB,useHead:()=>bZ,seoMetaToHeadConfig:()=>C7,resetHead:()=>KB,renderHtmlAttrs:()=>_B,renderHead:()=>zB,renderBodyAttrs:()=>BB,processTitleDirective:()=>HB,processMetaDirective:()=>OB,processHeadDirective:()=>jB,mergeHeadConfigs:()=>l6,getPageMeta:()=>CZ,getHead:()=>SZ,definePageMeta:()=>WB,applyHead:()=>qB});function SZ(){return X6}function CZ(){return kZ}function KB(){X6={},JE.length=0,kZ={}}function bZ($){X6=l6(X6,$)}function l6($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function I9($){bZ(C7($))}function C7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,J=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(J)Z.push({property:"og:description",content:J});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let X=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(X)Z.push({name:"twitter:title",content:X});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});return{title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K}}function WB($){if(kZ={...kZ,...$},$.title||$.description)I9({title:$.title,description:$.description})}function UB($){let Z=typeof $==="function"?$():$;bZ({title:Z})}function zB($=X6){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${m6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([J,X])=>`${J}="${m6(X)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>{return`${X==="httpEquiv"?"http-equiv":X}="${m6(String(Q))}"`}).join(" ");Z.push(`<meta ${J}>`)}for(let Y of $.link||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>`${X}="${m6(String(Q))}"`).join(" ");Z.push(`<link ${J}>`)}for(let Y of $.script||[]){let{content:J,...X}=Y,Q=Object.entries(X).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${m6(String(K))}"`}).filter(Boolean).join(" ");if(J)Z.push(`<script ${Q}>${J}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let J=Y.type?` type="${Y.type}"`:"";Z.push(`<style${J}>${Y.content}</style>`)}return Z.join(`
|
|
1865
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function a0($,Z,Y,J=0){let X=0,Q=J,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)X++;else if(U===Y){if(X--,X===0)return Q}Q++}return-1}function U9($,Z){let Y=Z,J={paren:0,bracket:0,brace:0},X=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&X){Y++;continue}if((G==='"'||G==="'")&&!X){X=G,Y++;continue}if(G===X&&X!=="`"){X=null,Y++;continue}if(G==="`"&&!X){X="`",Y++;continue}if(G==="`"&&X==="`"&&Q===0){X=null,Y++;continue}if(X==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(X){Y++;continue}if(J.paren===0&&J.bracket===0&&J.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")J.paren++;else if(G===")"){if(J.paren--,J.paren<0)break}else if(G==="[")J.bracket++;else if(G==="]"){if(J.bracket--,J.bracket<0)break}else if(G==="{")J.brace++;else if(G==="}"){if(J.brace--,J.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function MZ($){let Z=[],Y="",J={paren:0,bracket:0,brace:0},X=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&X){Y+=K;continue}if((K==='"'||K==="'")&&!X){X=K,Y+=K;continue}if(K===X&&X!=="`"){X=null,Y+=K;continue}if(K==="`"&&!X){X="`",Y+=K;continue}if(K==="`"&&X==="`"&&Q===0){X=null,Y+=K;continue}if(X==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(X){Y+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&J.paren===0&&J.bracket===0&&J.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!X){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function E4($,Z){let Y=PT($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function PT($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let J=a0($,"(",")",Y);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,J),endPos:J+1}}function yT($,Z){let Y=$.lastIndexOf("<",Z);if(Y===-1)return!1;return Y>$.lastIndexOf(">",Z)}function Y6($,Z,Y,J){let X=1,Q=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&X>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),z=W?W.index:1/0,_=U?U.index:1/0;if(z<_)X++,Q=z+W[0].length;else if(_<1/0){if(X--,X===0)return _;Q=_+U[0].length}else break}return-1}function z9($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,X=E4($,J);if(!X)return null;let Q=X.endPos,G=Y6($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z="if",_=X.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(yT(K,j)){U++;continue}if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:z,condition:_,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=E4(K,V);if(!L){U++;continue}z="elseif",_=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:z,condition:_,content:K.substring(B,U),start:Q+B,end:Q+U}),z="else",_=void 0,U+=5,B=U;continue}}U++}return W.push({type:z,condition:_,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function P$($){let Z=[],Y=/@if\s*\(/g,J=Y.exec($);while(J!==null){if(Z.some((G)=>J.index>G.start&&J.index<G.end)){J=Y.exec($);continue}let Q=z9($,J.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;J=Y.exec($)}return Z}function k7($,Z,Y){let J=[],X=new RegExp(`@${Z}\\s*\\(`,"g"),Q=X.exec($);while(Q!==null){if(J.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=X.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=a0($,"(",")",W);if(U===-1){Q=X.exec($);continue}let z=$.slice(W+1,U),_=U+1,B=Y6($,Z,Y,_);if(B===-1){Q=X.exec($);continue}let q=$.slice(_,B),j=B+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:q,start:K,end:j}),X.lastIndex=j,Q=X.exec($)}return J}function TZ($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,X=E4($,J);if(!X)return null;let Q=X.endPos,G=Y6($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z=null,_=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(_++,z)z.content+=q[0];U+=q[0].length;continue}if(j){if(_--,z)z.content+=j[0];U+=j[0].length;continue}if(_>0){if(z)z.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(z)W.push(z);let L=U+H[0].length,F=E4(K,L);if(!F){U++;continue}z={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(z)W.push(z);z={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(z)z.content+=K[U];U++}}if(z)W.push(z);return{fullMatch:$.slice(Z,G+10),expression:X.expression,cases:W,start:Z,end:G+10}}var d_=()=>{};function l_($){let Z=[],Y=0;while(Y<$.length){let J=$.indexOf("{{",Y),X=$.indexOf("{!!",Y),Q=!1,G;if(J===-1&&X===-1)break;else if(J===-1)G=X,Q=!0;else if(X===-1)G=J,Q=!1;else if(X<J)G=X,Q=!0;else G=J,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,z=xT($,U,W);if(z===-1){Y=G+1;continue}let _=$.slice(U,z).trim(),B=z+W.length;Z.push({fullMatch:$.slice(G,B),expression:_,start:G,end:B,isRaw:Q}),Y=B}return Z}function xT($,Z,Y){let J=Z,X=null,Q={paren:0,bracket:0,brace:0},G=0;while(J<$.length){let K=$[J];if((J>0?$[J-1]:"")==="\\"&&X){J++;continue}if((K==='"'||K==="'")&&!X){X=K,J++;continue}if(K===X&&X!=="`"){X=null,J++;continue}if(K==="`"&&!X){X="`",J++;continue}if(K==="`"&&X==="`"&&G===0){X=null,J++;continue}if(X==="`"&&K==="$"&&$[J+1]==="{"){G++,J+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;J++;continue}if(X){J++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(J,J+Y.length)===Y)return J}J++}return-1}function c_($){let Z=MZ($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],J=[];for(let X=1;X<Z.length;X++){let Q=vT(Z[X]);if(Q)J.push(Q)}return{baseExpression:Y,filters:J}}function vT($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let J=Z.slice(0,Y).trim(),X=Y+1,Q=a0(Z,"(",")",Y);if(Q===-1)return{name:J,args:[]};let G=Z.slice(X,Q),K=_9(G);return{name:J,args:K}}function _9($){let Z=[],Y="",J={paren:0,bracket:0,brace:0},X=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&X){Y+=K;continue}if((K==='"'||K==="'")&&!X){X=K,Y+=K;continue}if(K===X&&X!=="`"){X=null,Y+=K;continue}if(K==="`"&&!X){X="`",Y+=K;continue}if(K==="`"&&X==="`"&&Q===0){X=null,Y+=K;continue}if(X==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(X){Y+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K===","&&J.paren===0&&J.bracket===0&&J.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function p_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let J=a0($,"(",")",Y);if(J===-1)return null;return{params:$.slice(Y+1,J),endPos:J+1}}function i_($){let Z=[],J=new D7($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),X=0;while(X<J.length){let Q=J[X],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,X++,X>=J.length)break}let K=J[X];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(X++,X>=J.length)break;let U=J[X];if(U.type==="IDENTIFIER"){let z=U.value;if(X++,X<J.length&&J[X].type==="OPERATOR"&&J[X].value==="="){X++;let _=X<J.length?J[X].start:$.length,B=u_(J,X,$);X=B.nextIndex,Z.push({type:"variable",name:z,value:$.slice(_,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let z=U.start,_=U.value==="{"?"}":"]",B=a0($,U.value,_,z);if(B!==-1){let q=$.slice(z,B+1);if(X=m_(J,B+1),X<J.length&&J[X].type==="OPERATOR"&&J[X].value==="="){X++;let j=X<J.length?J[X].start:$.length,H=u_(J,X,$);X=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?J[X-1].start:K.start;if(X++,X>=J.length)break;let U=J[X];if(U.type==="IDENTIFIER"){let z=U.value;X++;let _=-1;while(X<J.length){if(J[X].type==="PUNCTUATION"&&J[X].value==="{"){_=J[X].start;break}X++}if(_!==-1){let B=a0($,"{","}",_);if(B!==-1)Z.push({type:"function",name:z,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),X=m_(J,B+1)}}}else X++}return Z}function u_($,Z,Y){let J=Z,X={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(J<$.length){let G=$[J];if(G.type==="PUNCTUATION"){if(G.value==="(")X.paren++;else if(G.value===")")X.paren--;else if(G.value==="[")X.bracket++;else if(G.value==="]")X.bracket--;else if(G.value==="{")X.brace++;else if(G.value==="}")X.brace--;if(G.value===";"&&X.paren===0&&X.bracket===0&&X.brace===0){Q=G.start,J++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(X.paren===0&&X.bracket===0&&X.brace===0){Q=$[J-1]?.end??G.start;break}}Q=G.end,J++}return{nextIndex:J,endPos:Q}}function m_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var n_=()=>{};var S7=D(()=>{d_();n_()});function fT($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=TZ(J,G);if(!K)break;try{let W;if(R0(K.expression))W=M0(K.expression,Object.keys(Z))(...Object.values(Z));else W=V0(K.expression,Z);let U="",z=!1;for(let _ of K.cases)if(_.type==="default"){if(!z)U=_.content.trim()}else try{let B;if(_.value&&R0(_.value))B=M0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)B=V0(_.value,Z);if(W===B){U=_.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+U+J.substring(K.end),X=!0}catch(W){let U=W instanceof Error?W.message:String(W),z=H0("Switch",`Error evaluating @switch expression: ${U}`,G0.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function d6($,Z,Y){let J=$;J=fT(J,Z,Y);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=E4(J,K+7);if(!W)break;let U=W.endPos,z=Y6(J,"unless","endunless",U);if(z===-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 _=J.slice(U,z),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(_))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(_))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(_))!==null)F.push({pos:A.index,type:"else"});F.sort((w,N)=>w.pos-N.pos);for(let w of F)if(w.type==="open")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){q=w.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${_}@endif`;J=J.substring(0,K)+j+J.substring(z+10),Q=!0}}J=q9(J,Z,Y),J=j9(J,Z,Y),J=B9(J,Z);let X=()=>{let Q=P$(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let z of K.branches){if(U)break;if(z.type==="else")W=z.content,U=!0;else try{let _;if(z.condition&&R0(z.condition))_=M0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)_=V0(z.condition,Z);if(_)W=z.content,U=!0}catch(_){W=H0(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${_ instanceof Error?_.message:String(_)}`,G0.EVALUATION_ERROR),U=!0}}J=J.substring(0,K.start)+W+J.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),z=H0("If",`Error processing @if block: ${U}`,G0.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!X())break;if(J===Q)break}return J}function r_($){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 J=[];while(Z<$.length){let X=$[Z];if(X==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(X===Y){Z++;break}J.push(X),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function B9($,Z){let Y=$;function J(K,W,U,z){let _=1,B=z,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&_>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)_++,B=V+H[0].length;else if(L<1/0){if(_--,_===0)return L;B=L+O[0].length}else break}return-1}function X(K,W,U){let z=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.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=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")z++;else if(O.type==="close")z--;else if(O.type==="else"&&z===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,_,B=Y.slice(U+5),q=r_(B);if(q)z=q.value,_=U+5+q.consumed;else _=U+5;let j=J(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=X(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=z?T4(`auth?.check && auth?.user?.[${z}]`,Z):T4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,_,B=Y.slice(U+6),q=r_(B);if(q)z=q.value,_=U+6+q.consumed;else _=U+6;let j=J(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=X(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=z?T4(`!auth?.check || !auth?.user?.[${z}]`,Z):T4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(W)z.push(W);if(U){let _=T4(U,Z);z.push(_)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let B=_.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=J(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${W}(?![a-z])`,"g"),N=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,E=[],M;while((M=A.exec(V))!==null)E.push({pos:M.index,type:"open"});while((M=w.exec(V))!==null)E.push({pos:M.index,type:"close"});while((M=N.exec(V))!==null)E.push({pos:M.index,type:"elseDirective"});while((M=R.exec(V))!==null)E.push({pos:M.index,type:"else"});E.sort((b,h)=>b.pos-h.pos);for(let b of E){if(b.type==="open"){F++;continue}if(b.type==="close"){F--;continue}if(F===0)L.push(b)}let I=[],S=0;for(let b=0;b<L.length;b++){let h=L[b];if(I.push({content:V.slice(S,h.pos),ability:void 0}),h.type==="elseDirective"){let r=V.slice(h.pos+`@${U}`.length),m=G(r);if(m){I[I.length-1]={content:V.slice(S,h.pos)},S=h.pos+`@${U}`.length+m.paramsEnd,I.push({content:"",ability:m.ability,type:m.type,id:m.id}),I.pop();let P=L[b+1],d=P?P.pos:V.length;I.push({content:V.slice(S,d),ability:m.ability,type:m.type,id:m.id}),S=d}}else S=h.pos+5}if(S<V.length){let b=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(S),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(S)})}let k=Q(j.ability,j.type,j.id),x=K==="can"?k:!k,y="";if(x)y=I[0]?.content||"";else{let b=!1;for(let h=1;h<I.length;h++){let r=I[h];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let m=Q(r.ability,r.type,r.id);if(K==="can"?m:!m){y=r.content,b=!0;break}}}if(!b&&I.length>0){let h=I[I.length-1];if(h.isFinalElse)y=h.content}}Y=Y.substring(0,B)+y+Y.substring(O+`@${W}`.length),z=!0}}return Y}function q9($,Z,Y){let J=$;function X(Q,G,K,W,U){let z=!0;while(z){z=!1;let _=new RegExp(`@${G}\\s*\\(`),B=Q.match(_);if(!B||B.index===void 0)break;let q=B.index,j=E4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=Y6(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,w=0;while(w<V.length){let N=V.indexOf("@",w);if(N===-1)break;let R=V.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,w=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,w=N+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=N;break}w=N+1}try{let N=W(L.trim()),R;if(F!==-1){let E=V.slice(0,F),M=V.slice(F+5);R=N?E:M}else R=N?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),z=!0}catch(N){let R=N instanceof Error?N.message:String(N),E=H0(U,`Error processing @${G} directive: ${R}`,G0.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(O+`@${K}`.length);break}}return Q}return J=X(J,"isset","endisset",(Q)=>{let G=T4(Q,Z);return G!==void 0&&G!==null},"Isset"),J=X(J,"empty","endempty",(Q)=>{let G=T4(Q,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"),J}function j9($,Z,Y){let J=$,X="development";function Q(G,K,W,U){let z=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let O=z.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=X===k[2]}let F=1,A=L,w=-1;while(F>0&&A<j.length){z.lastIndex=A,_.lastIndex=A;let k=z.exec(j),x=_.exec(j),y=k?k.index:1/0,b=x?x.index:1/0;if(y<b)F++,A=y+k[0].length;else if(b<1/0){if(F--,F===0){w=b;break}A=b+x[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let N=j.substring(L,w),R=-1,E=0,M=0;while(M<N.length){let k=N.indexOf("@",M);if(k===-1)break;let x=N.substring(k);if(B.test(x)){E++,M=k+1;continue}if(q.test(x)){E--,M=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(x)){R=k;break}M=k+1}let I;if(R!==-1){let k=N.slice(0,R),x=N.slice(R+5);I=U?k:x}else I=U?N:"";let S=`@${W}`.length;j=j.substring(0,V)+I+j.substring(w+S),H=!0}return j}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",X==="production"),J=Q(J,"development","enddevelopment",X==="development"),J=Q(J,"staging","endstaging",X==="staging"),J=Q(J,"testing","endtesting",X==="testing"),J}var EZ=D(()=>{J9();C1();S7();n0()});function O9($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function J6($,Z){if(!$)return Z?.nonceGenerator?.()??O9();let Y=H9.get($);if(!Y)Y=Z?.nonceGenerator?.()??O9(),H9.set($,Y);return Y}function gT($){H9.delete($)}function L9($,Z){let Y=[];for(let[J,X]of Object.entries($)){if(X===void 0||X===null)continue;if(typeof X==="boolean"){if(X)Y.push(J);continue}if(Array.isArray(X)){let Q=[...X];if(Z&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${J} ${Q.join(" ")}`)}}return Y.join("; ")}function DZ($,Z){return`<meta http-equiv="Content-Security-Policy" content="${L9($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function hT($){return{enabled:!0,directives:{strict:a_,moderate:IZ,relaxed:s_,api:o_}[$]||IZ,useNonce:$==="strict",addMetaTag:!0}}function dT($,Z){let Y={...$};for(let[J,X]of Object.entries(Z)){let Q=J,G=Y[Q];if(X===void 0||X===null)continue;if(typeof X==="boolean")Y[Q]=G||X;else if(Array.isArray(X)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...X])];Y[Q]=W}}return Y}function V9($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=Z.useNonce?J6(Y,Z):void 0,X=DZ(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1866
|
+
${X}`)}function F9($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(J,X)=>{if(X.includes("nonce="))return J;return`<script nonce="${Z}"${X}>`}),Y=Y.replace(/<style([^>]*)>/gi,(J,X)=>{if(X.includes("nonce="))return J;return`<style nonce="${Z}"${X}>`}),Y}function A9($,Z,Y,J){let X=$,Q=J.csp;if(X=X.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?J6(Z,Q):void 0;return DZ(Q.directives,G)}),X=X.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return J6(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=J6(Z,Q);return X}function uT(){return[t_,e_]}function mT($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,J]of Object.entries($))if(Array.isArray(J)&&J.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function $B($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function lT($,Z){if(!$.enabled)return{};let Y=$.useNonce?J6(Z,$):void 0,J=L9($.directives,Y);return{[$B($.reportOnly)]:J}}var H9,a_,IZ,s_,o_,t_,e_,cT;var w9=D(()=>{H9=new WeakMap;a_={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},IZ={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},s_={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},o_={"default-src":["'none'"],"frame-ancestors":["'none'"]};t_={name:"csp",handler:($,Z,Y,J)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?J6(Y,Q):void 0;return DZ(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},e_={name:"cspNonce",handler:($,Z,Y,J)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return J6(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};cT={enabled:!1,reportOnly:!1,directives:IZ,useNonce:!1,addMetaTag:!0}});import pT from"crypto";function nT($=iT){let Z=pT.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return N9=Z,Z}function rT(){if(!N9)nT();return N9}function aT($=ZB){let Z=rT();return`<input type="hidden" name="${$}" value="${Z}">`}function YB($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,J)=>{return aT(J||ZB)})}var iT=40,ZB="_token",N9=null;var JB=()=>{};async function R9($,Z,Y,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let X=$;for(let Q of J.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)X=await sT(X,Q,Z,Y,J);else X=await oT(X,Q,Z,Y,J)}return X}async function sT($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,z=E$(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],B=z.exec(U);while(B!==null){let[q,j="",H=""]=B,O=B.index||0;try{let V=j?XB(j):[],L=H.trim(),F=await G(L,V,Y,J);_.push({original:q,processed:F,startIndex:O})}catch(V){let L=V instanceof Error?V.message:String(V);if(X.debug)console.error(`Error processing custom directive @${Q}:`,V);_.push({original:q,processed:H0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,G0.EVALUATION_ERROR),startIndex:O})}B=z.exec(U)}for(let q=_.length-1;q>=0;q--){let{original:j,processed:H}=_[q];U=U.replace(j,H)}return U}async function oT($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=$,W=E$(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],z=W.exec(K);while(z!==null){let[q,j=""]=z,H=z.index||0;try{let O=XB(j),V=await G("",O,Y,J);U.push({original:q,processed:V,startIndex:H})}catch(O){let V=O instanceof Error?O.message:String(O);if(X.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:H0("CustomDirective",`Error in @${Q}(${j}): ${V}`,G0.EVALUATION_ERROR),startIndex:H})}z=W.exec(K)}let _=E$(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),B=_.exec(K);while(B!==null){let[q]=B,j=B.index||0;try{let H=await G("",[],Y,J);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(X.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:H0("CustomDirective",`Error in @${Q}: ${O}`,G0.EVALUATION_ERROR),startIndex:j})}B=_.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function XB($){if(!$.trim())return[];let Z=[],Y="",J=!1,X="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!J)J=!0,X=G;else if(G===X)J=!1;else Y+=G;else if(G===","&&!J)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var M9=D(()=>{C1();t4()});function u6($,Z){if(typeof $!=="string"||$.length===0)throw Error(`@appearanceBootstrap ${Z} must be a non-empty string`)}function eT($){if(!$||typeof $!=="object"||Array.isArray($))throw Error("@appearanceBootstrap expects an options object");let Z=$,Y=Z.appearance,J=Z.colorMode;if(u6(Z.storageKey,"storageKey"),!Y||typeof Y!=="object"||Array.isArray(Y))throw Error("@appearanceBootstrap appearance must be an object");if(!J||typeof J!=="object"||Array.isArray(J))throw Error("@appearanceBootstrap colorMode must be an object");if(u6(Y.key,"appearance.key"),u6(Y.attribute,"appearance.attribute"),u6(Y.default,"appearance.default"),u6(J.key,"colorMode.key"),u6(J.attribute,"colorMode.attribute"),u6(J.default,"colorMode.default"),!GB.test(Y.key)||!GB.test(J.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!QB.test(Y.attribute)||!QB.test(J.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(Y.allowed)||Y.allowed.length===0||Y.allowed.some((X)=>typeof X!=="string"||X.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!Y.allowed.includes(Y.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");if(!tT.has(J.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");return{storageKey:Z.storageKey,appearance:{key:Y.key,attribute:Y.attribute,allowed:[...new Set(Y.allowed)],default:Y.default},colorMode:{key:J.key,attribute:J.attribute,default:J.default}}}function $E($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ZE($){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${$E($)};const root=document.documentElement;let stored={};try{const raw=localStorage.getItem(config.storageKey);const parsed=raw?JSON.parse(raw):{};if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed))stored=parsed}catch{}const selectedAppearance=config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default;const selectedMode=["light","dark","system"].includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default;root.setAttribute("data-"+config.appearance.attribute,selectedAppearance);root.setAttribute("data-"+config.colorMode.attribute,selectedMode);let dark=selectedMode==="dark";if(selectedMode==="system"){try{dark=matchMedia("(prefers-color-scheme: dark)").matches}catch{dark=false}}root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light"}());</script>`}function YE($,Z){let Y=1,J=null,X=!1;for(let Q=Z+1;Q<$.length;Q++){let G=$[Q];if(X){X=!1;continue}if(J){if(G==="\\")X=!0;else if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="(")Y++;else if(G===")"&&--Y===0)return Q}return-1}function T9($,Z){let Y=$,J=/@appearanceBootstrap\s*\(/g,X;while((X=J.exec(Y))!==null){let Q=X.index+X[0].length-1,G=YE(Y,Q);if(G===-1)throw Error("@appearanceBootstrap has an unclosed options object");let K=Y.slice(Q+1,G).trim(),W=V0(`(${K})`,Z),U=ZE(eT(W));Y=Y.slice(0,X.index)+U+Y.slice(G+1),J.lastIndex=X.index+U.length}return Y}var QB,GB,tT;var E9=D(()=>{n0();QB=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,GB=/^[A-Za-z_$][\w$]*$/,tT=new Set(["light","dark","system"])});var D9={};$0(D9,{useTitle:()=>UB,useSeoMeta:()=>I9,usePageTitle:()=>UB,useHead:()=>bZ,seoMetaToHeadConfig:()=>C7,resetHead:()=>KB,renderHtmlAttrs:()=>_B,renderHead:()=>zB,renderBodyAttrs:()=>BB,processTitleDirective:()=>HB,processMetaDirective:()=>OB,processHeadDirective:()=>jB,mergeHeadConfigs:()=>l6,getPageMeta:()=>CZ,getHead:()=>SZ,definePageMeta:()=>WB,applyHead:()=>qB});function SZ(){return X6}function CZ(){return kZ}function KB(){X6={},JE.length=0,kZ={}}function bZ($){X6=l6(X6,$)}function l6($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function I9($){bZ(C7($))}function C7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,J=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(J)Z.push({property:"og:description",content:J});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let X=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(X)Z.push({name:"twitter:title",content:X});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});return{title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K}}function WB($){if(kZ={...kZ,...$},$.title||$.description)I9({title:$.title,description:$.description})}function UB($){let Z=typeof $==="function"?$():$;bZ({title:Z})}function zB($=X6){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${m6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([J,X])=>`${J}="${m6(X)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>{return`${X==="httpEquiv"?"http-equiv":X}="${m6(String(Q))}"`}).join(" ");Z.push(`<meta ${J}>`)}for(let Y of $.link||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>`${X}="${m6(String(Q))}"`).join(" ");Z.push(`<link ${J}>`)}for(let Y of $.script||[]){let{content:J,...X}=Y,Q=Object.entries(X).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${m6(String(K))}"`}).filter(Boolean).join(" ");if(J)Z.push(`<script ${Q}>${J}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let J=Y.type?` type="${Y.type}"`:"";Z.push(`<style${J}>${Y.content}</style>`)}return Z.join(`
|
|
1867
1867
|
`)}function _B($=X6){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${m6(Y)}"`).join(" ")}function BB($=X6){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${m6(Y)}"`).join(" ")}function m6($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qB($=X6){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let J=document.querySelector(Y);if(!J){if(J=document.createElement("meta"),Z.name)J.setAttribute("name",Z.name);if(Z.property)J.setAttribute("property",Z.property);document.head.appendChild(J)}J.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,J=document.querySelector(Y);if(!J)J=document.createElement("link"),document.head.appendChild(J);for(let[X,Q]of Object.entries(Z))if(Q!==void 0)J.setAttribute(X,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function jB($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(J,X)=>{return Z+=X.trim()+`
|
|
1868
1868
|
`,""}),headContent:Z.trim()}}function HB($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,J,X,Q)=>{let G=J?X:Z[(Q||"").trim()]??Q,K=Z.__stx_runtime_head??{};return Z.__stx_runtime_head=l6(K,{title:G}),""})}function OB($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,J,X,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,_=X.includes(":")?{property:X,content:U}:{name:X,content:U},B=Z.__stx_runtime_head??{};return Z.__stx_runtime_head=l6(B,{meta:[_]}),""})}var X6,JE,kZ;var c6=D(()=>{X6={},JE=[],kZ={}});import XE from"crypto";function Z1($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function QE($){return{...yZ,...$.forms?.classes}}function PZ($,Z,Y,J){let X=$||Z;return Y?`${X} ${J}`:X}function GE(){return XE.randomUUID()}function KE($,Z,Y,J){let X=QE(J),Q=$;return Q=AB(Q,Z),Q=y$(Q,Z),Q=xZ(Q,Z,X),Q=vZ(Q,Z,X),Q}function y$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let J=GE();Z.csrf={token:J}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${Z1(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(J,X)=>{let Q=X.toUpperCase();if(X&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${Z1(Q)}">`;return J}),Y}function xZ($,Z,Y=yZ){let J=$;return J=J.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(X,Q,G,K,W,U="")=>{let z=Q||G||"POST",_=K||W||"",B=Q6(U),q=z.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${Z1(j)}" action="${Z1(_)}"${B?` ${B}`:""}>`;if(H+=`
|
|
1869
1869
|
${y$("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
|
|
@@ -1919,8 +1919,8 @@ catch { return 'Please enter a valid URL'; } },
|
|
|
1919
1919
|
}
|
|
1920
1920
|
});
|
|
1921
1921
|
})();
|
|
1922
|
-
</script>`.trim()}var yZ,VB,S9;var C9=D(()=>{n0();yZ={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};VB={required:($,Z,Y)=>{if($===void 0||$===null||$===""||Array.isArray($)&&$.length===0)return`The ${Y} field is required.`;return null},email:($,Z,Y)=>{if(!$)return null;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($)))return`The ${Y} field must be a valid email address.`;return null},min:($,Z,Y)=>{if(!$)return null;let J=Number(Z[0]);if(typeof $==="string"&&$.length<J)return`The ${Y} field must be at least ${J} characters.`;if(typeof $==="number"&&$<J)return`The ${Y} field must be at least ${J}.`;if(Array.isArray($)&&$.length<J)return`The ${Y} field must have at least ${J} items.`;return null},max:($,Z,Y)=>{if(!$)return null;let J=Number(Z[0]);if(typeof $==="string"&&$.length>J)return`The ${Y} field must not exceed ${J} characters.`;if(typeof $==="number"&&$>J)return`The ${Y} field must not exceed ${J}.`;if(Array.isArray($)&&$.length>J)return`The ${Y} field must not have more than ${J} items.`;return null},confirmed:($,Z,Y)=>{if(Z[0]!==void 0&&$!==Z[0])return`The ${Y} confirmation does not match.`;return null},numeric:($,Z,Y)=>{if(!$)return null;if(Number.isNaN(Number($)))return`The ${Y} field must be a number.`;return null},integer:($,Z,Y)=>{if(!$)return null;if(!Number.isInteger(Number($)))return`The ${Y} field must be an integer.`;return null},alpha:($,Z,Y)=>{if(!$)return null;if(!/^[a-z]+$/i.test(String($)))return`The ${Y} field must only contain letters.`;return null},alphanumeric:($,Z,Y)=>{if(!$)return null;if(!/^[a-z0-9]+$/i.test(String($)))return`The ${Y} field must only contain letters and numbers.`;return null},url:($,Z,Y)=>{if(!$)return null;try{return new URL(String($))?null:null}catch{return`The ${Y} field must be a valid URL.`}},regex:($,Z,Y)=>{if(!$)return null;try{if(!new RegExp(Z[0]).test(String($)))return`The ${Y} field format is invalid.`;return null}catch{return`The ${Y} field has an invalid validation pattern.`}},in:($,Z,Y)=>{if(!$)return null;if(!Z.includes(String($)))return`The ${Y} field must be one of: ${Z.join(", ")}.`;return null},notIn:($,Z,Y)=>{if(!$)return null;if(Z.includes(String($)))return`The ${Y} field must not be: ${Z.join(", ")}.`;return null},date:($,Z,Y)=>{if(!$)return null;let J=new Date($);if(Number.isNaN(J.getTime()))return`The ${Y} field must be a valid date.`;return null},before:($,Z,Y)=>{if(!$)return null;let J=new Date($),X=new Date(Z[0]);if(J>=X)return`The ${Y} field must be before ${Z[0]}.`;return null},after:($,Z,Y)=>{if(!$)return null;let J=new Date($),X=new Date(Z[0]);if(J<=X)return`The ${Y} field must be after ${Z[0]}.`;return null}};S9={required:{name:"required",validate:($)=>{if($===null||$===void 0||$==="")return"This field is required";if(Array.isArray($)&&$.length===0)return"This field is required";return!0},toHtml5:()=>["required"],message:"This field is required"},email:{name:"email",validate:($)=>{if(!$)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($))||"Please enter a valid email address"},toHtml5:()=>['type="email"'],message:"Please enter a valid email address"},url:{name:"url",validate:($)=>{if(!$)return!0;try{return new URL(String($)).protocol.startsWith("http")||"Please enter a valid URL"}catch{return"Please enter a valid URL"}},toHtml5:()=>['type="url"'],message:"Please enter a valid URL"},numeric:{name:"numeric",validate:($)=>{if(!$)return!0;return!Number.isNaN(Number($))||"Please enter a number"},toHtml5:()=>['type="number"'],message:"Please enter a number"},integer:{name:"integer",validate:($)=>{if(!$)return!0;let Z=Number($);return Number.isInteger(Z)||"Please enter a whole number"},toHtml5:()=>['type="number"','step="1"'],message:"Please enter a whole number"},alpha:{name:"alpha",validate:($)=>{if(!$)return!0;return/^[a-z]+$/i.test(String($))||"Please enter only letters"},toHtml5:()=>['pattern="[a-zA-Z]+"'],message:"Please enter only letters"},alphanumeric:{name:"alphanumeric",validate:($)=>{if(!$)return!0;return/^[a-z0-9]+$/i.test(String($))||"Please enter only letters and numbers"},toHtml5:()=>['pattern="[a-zA-Z0-9]+"'],message:"Please enter only letters and numbers"},min:{name:"min",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length>=Y||`Must be at least ${Y} characters`;if(typeof $==="number")return $>=Y||`Must be at least ${Y}`;if(Array.isArray($))return $.length>=Y||`Must have at least ${Y} items`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`min="${$[0]}"`],message:"Must be at least {{param}} characters"},max:{name:"max",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length<=Y||`Must be no more than ${Y} characters`;if(typeof $==="number")return $<=Y||`Must be no more than ${Y}`;if(Array.isArray($))return $.length<=Y||`Must have no more than ${Y} items`;return!0},toHtml5:($)=>[`maxlength="${$[0]}"`,`max="${$[0]}"`],message:"Must be no more than {{param}} characters"},between:{name:"between",validate:($,Z)=>{if(!$)return!0;let[Y,J]=Z.map(Number);if(typeof $==="string")return $.length>=Y&&$.length<=J||`Must be between ${Y} and ${J} characters`;if(typeof $==="number")return $>=Y&&$<=J||`Must be between ${Y} and ${J}`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`maxlength="${$[1]}"`],message:"Must be between {{min}} and {{max}}"},confirmed:{name:"confirmed",validate:($,Z,Y)=>{let J=Object.keys(Y);for(let X of J)if(X.endsWith("_confirmation")&&Y[X]===$)return!0;return"Confirmation does not match"},message:"Confirmation does not match"},in:{name:"in",validate:($,Z)=>{if(!$)return!0;return Z.includes(String($))||`Must be one of: ${Z.join(", ")}`},message:"Must be one of: {{values}}"},notIn:{name:"notIn",validate:($,Z)=>{if(!$)return!0;return!Z.includes(String($))||`Must not be: ${Z.join(", ")}`},message:"Must not be: {{values}}"},regex:{name:"regex",validate:($,Z)=>{if(!$)return!0;try{return new RegExp(Z[0]).test(String($))||"Invalid format"}catch{return"Invalid format"}},toHtml5:($)=>[`pattern="${$[0]}"`],message:"Invalid format"},date:{name:"date",validate:($)=>{if(!$)return!0;let Z=new Date(String($));return!Number.isNaN(Z.getTime())||"Please enter a valid date"},toHtml5:()=>['type="date"'],message:"Please enter a valid date"},before:{name:"before",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),J=new Date(Z[0]);return Y<J||`Must be before ${Z[0]}`},toHtml5:($)=>[`max="${$[0]}"`],message:"Must be before {{date}}"},after:{name:"after",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),J=new Date(Z[0]);return Y>J||`Must be after ${Z[0]}`},toHtml5:($)=>[`min="${$[0]}"`],message:"Must be after {{date}}"},size:{name:"size",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length===Y||`Must be exactly ${Y} characters`;if(Array.isArray($))return $.length===Y||`Must have exactly ${Y} items`;return!0},message:"Must be exactly {{size}}"},phone:{name:"phone",validate:($)=>{if(!$)return!0;return/^\+?\(?\d{1,4}\)?[-\s./\d]*$/.test(String($))||"Please enter a valid phone number"},toHtml5:()=>['type="tel"','pattern="\\+?\\(?\\d{1,4}\\)?[-\\s./\\d]*"'],message:"Please enter a valid phone number"}}});import P9 from"path";async function qE(){if(y7!==void 0)return y7;try{y7=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{y7=null}return y7}function jE($){if($)delete w1[$];else for(let Z of Object.keys(w1))delete w1[Z]}function HE(){let $=Object.entries(w1).map(([Z,Y])=>({locale:Z,loadedAt:new Date(Y.loadedAt),keyCount:RB(Y.translations)}));return{size:Object.keys(w1).length,locales:Object.keys(w1),entries:$}}function RB($,Z=0){for(let Y of Object.values($))if(Z++,Y&&typeof Y==="object"&&!Array.isArray(Y))Z=RB(Y,Z);return Z}function OE($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}function LE($){if(w1[$])return"loaded";return I4[$]||"idle"}function VE($){return I4[$]==="loading"}function FE($){return!!w1[$]}async function MB($,Z){let{locales:Y,parallel:J=!0,priority:X={},onLocaleLoaded:Q,onComplete:G,onError:K}=$,W=J?Y:[...Y].sort((U,z)=>(X[z]||0)-(X[U]||0));if(J){let U=W.map(async(z)=>{try{await x7(z,Z),Q?.(z)}catch(_){K?.(z,_ instanceof Error?_:Error(String(_)))}});await Promise.all(U)}else for(let U of W)try{await x7(U,Z),Q?.(U)}catch(z){K?.(U,z instanceof Error?z:Error(String(z)))}G?.()}function AE($,Z){queueMicrotask(()=>{MB($,Z).catch((Y)=>{if(Z.debug)console.error("Background preload error:",Y)})})}async function x7($,Z){if({...gZ,...Z.i18n}.cache&&w1[$]){let X=w1[$],Q=Z.i18n?.cacheMaxAge??0;if(!OE(X,Q))return X.translations}if(s1[$]?.state==="loading")return s1[$].promise;I4[$]="loading";let J=y9($,Z).then((X)=>{return I4[$]="loaded",delete s1[$],X}).catch((X)=>{throw I4[$]="error",s1[$]={promise:J,state:"error",error:X instanceof Error?X:Error(String(X))},X});return s1[$]={promise:J,state:"loading"},J}function TB($){return w1[$]?.translations}async function wE($,Z){let Y=TB($);if(Y)return Y;return x7($,Z)}async function NE($,Z){if(w1[$])return w1[$].translations;if(s1[$]){if(Z)return Promise.race([s1[$].promise,new Promise((Y,J)=>setTimeout(()=>J(Error(`Timeout waiting for locale: ${$}`)),Z))]);return s1[$].promise}throw Error(`Locale "${$}" is not loading. Call loadTranslationLazy first.`)}function RE(){return Object.entries(I4).filter(([$,Z])=>Z==="loading").map(([$])=>$)}function ME($){if($)delete s1[$],delete I4[$];else{for(let Z of Object.keys(s1))delete s1[Z];for(let Z of Object.keys(I4))delete I4[Z]}}async function y9($,Z){let Y={...gZ,...Z.i18n},J=P9.isAbsolute(Y.translationsDir)?Y.translationsDir:P9.resolve(Z.root||process.cwd(),Y.translationsDir);try{let X=await qE(),Q=X?await X($,{translationsDir:J,defaultLocale:Y.defaultLocale,sources:kE(Y.format)}):await TE($,Y,J);if(Q===void 0){if($!==Y.defaultLocale)return y9(Y.defaultLocale,Z);return{}}let G=Q;if(Y.cache)w1[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(X){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,X);if($!==Y.defaultLocale)return y9(Y.defaultLocale,Z);return{}}}async function TE($,Z,Y){let J=P9.join(Y,`${$}${EE(Z.format)}`);try{let X=await import(J);return X.default||X}catch(X){try{let Q=await Bun.file(J).text();if(Z.format==="yaml"||Z.format==="yml")return IE(Q);if(Z.format==="json")return JSON.parse(Q);throw X}catch{return}}}function EE($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function IE($){let Z={},Y=$.split(`
|
|
1923
|
-
`),J=[{obj:Z,indent:-1}];for(let X of Y){let Q=X.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(J.length>1&&J[J.length-1].indent>=G)J.pop();let K=J[J.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,z]=W,_=U.trim(),B=z.trim();if(B==="")K[_]={},J.push({obj:K[_],indent:G});else K[_]=DE(B)}}return Z}function DE($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let Y=Number($);if(!Number.isNaN(Y)&&$!=="")return Y;return $}function kE($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function EB($,Z){return x7($,Z)}function SE($,Z){for(let Y of $){let J=Y.trim(),X=J.match(/^\{(\d+)\}\s*(.*)$/);if(X){let G=Number.parseInt(X[1],10);if(Z===G)return X[2];continue}let Q=J.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),K=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=K)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function IB($,Z={}){return DB($,Z)}function DB($,Z){let Y="",J=0;while(J<$.length)if($[J]==="{"){let X=CE($,J);if(X===-1){Y+=$[J],J++;continue}let Q=$.slice(J+1,X);Y+=bE(Q,Z),J=X+1}else if($[J]==="'"&&J+1<$.length)if($[J+1]==="'")Y+="'",J+=2;else if($[J+1]==="{"||$[J+1]==="}")Y+=$[J+1],J+=2;else Y+=$[J],J++;else Y+=$[J],J++;return Y}function CE($,Z){let Y=0;for(let J=Z;J<$.length;J++)if($[J]==="{")Y++;else if($[J]==="}"){if(Y--,Y===0)return J}return-1}function bE($,Z){let Y=PE($);if(Y.length===0)return`{${$}}`;let J=Y[0].trim(),X=Z[J];if(Y.length===1)return X!==void 0?String(X):`{${J}}`;switch(Y[1].trim().toLowerCase()){case"plural":return yE(X,Y.slice(2).join(","),Z);case"select":return vE(X,Y.slice(2).join(","));case"selectordinal":return fE(X,Y.slice(2).join(","));case"number":return hE(X,Y[2]?.trim());case"date":return dE(X,Y[2]?.trim());case"time":return uE(X,Y[2]?.trim());default:return X!==void 0?String(X):`{${$}}`}}function PE($){let Z=[],Y="",J=0;for(let X=0;X<$.length;X++){let Q=$[X];if(Q==="{")J++,Y+=Q;else if(Q==="}")J--,Y+=Q;else if(Q===","&&J===0)Z.push(Y),Y="";else Y+=Q}if(Y)Z.push(Y);return Z}function yE($,Z,Y){let J=Number($)||0,X=x9(Z),Q=`=${J}`;if(X[Q])return b9(X[Q],J,Y);let G=xE(J);if(X[G])return b9(X[G],J,Y);if(X.other)return b9(X.other,J,Y);return String(J)}function b9($,Z,Y){let J=$.replace(/#/g,String(Z));return DB(J,Y)}function xE($){let Z=Math.abs($),Y=Math.floor(Z),J=String($).includes(".")?String($).split(".")[1].length:0;if(Y===1&&J===0)return"one";return"other"}function vE($,Z){let Y=String($||""),J=x9(Z);if(J[Y])return J[Y];return J.other||String($)}function fE($,Z){let Y=Number($)||0,J=x9(Z),X=gE(Y);if(J[X])return J[X].replace(/#/g,String(Y));if(J.other)return J.other.replace(/#/g,String(Y));return String(Y)}function gE($){let Z=Math.abs($),Y=Z%10,J=Z%100;if(Y===1&&J!==11)return"one";if(Y===2&&J!==12)return"two";if(Y===3&&J!==13)return"few";return"other"}function x9($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,J=Y.exec($);while(J!==null)Z[J[1]]=J[2],J=Y.exec($);return Z}function hE($,Z){let Y=Number($);if(Number.isNaN(Y))return String($);switch(Z){case"integer":return Math.floor(Y).toLocaleString();case"percent":return`${(Y*100).toFixed(0)}%`;case"currency":return Y.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return Y.toLocaleString()}}function dE($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let J={};switch(Z){case"short":J.dateStyle="short";break;case"medium":J.dateStyle="medium";break;case"long":J.dateStyle="long";break;case"full":J.dateStyle="full";break;default:J.dateStyle="medium"}return Y.toLocaleDateString(void 0,J)}function uE($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let J={};switch(Z){case"short":J.timeStyle="short";break;case"medium":J.timeStyle="medium";break;case"long":J.timeStyle="long";break;case"full":J.timeStyle="full";break;default:J.timeStyle="short"}return Y.toLocaleTimeString(void 0,J)}function kB($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function fZ($,Z,Y=!0,J={}){let X=$.split("."),Q=Z;for(let K of X){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(kB(G))return IB(G,J);if(G.includes("|")&&"count"in J){let K=Number(J.count),W=G.split("|");G=SE(W,K)}for(let[K,W]of Object.entries(J)){let U=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${U}`,"g"),String(W))}return G}async function v9($,Z,Y,J){let X=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...gZ,...J.i18n},K=await EB(G.locale,J);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,X=await NB(X,Q,async(z,_,B,q,j)=>{try{let H={};if(B)try{let V=[()=>JSON.parse(B),()=>{let L=`{"data":${B}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return i0(B,Z)}];for(let L of V)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(V){if(J.debug)console.error("Error parsing parameters for @translate directive:",V)}return fZ(_,K,G.fallbackToKey,H)||q.trim()}catch(H){if(J.debug)console.error("Error processing @translate directive:",H);return H0("Translate",`Error in @translate('${_}'): ${H instanceof Error?H.message:String(H)}`,G0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(J.debug){console.warn(`Processing translations in template. Sections: ${X.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let z=[...X.matchAll(W)];console.warn(`Found ${z.length} @translate matches`),z.forEach((_,B)=>console.warn(`Match ${B}: ${_[0]}, Key: ${_[1]}, Params: ${_[2]||"none"}`))}return X=await NB(X,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(z,_,B,q)=>{try{let j={};if(B)try{let H=[()=>JSON.parse(B),()=>{let O=`{"data":${B}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return i0(B,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(J.debug)console.error("Error parsing parameters for @translate directive:",H)}return fZ(_,K,G.fallbackToKey,j)}catch(j){if(J.debug)console.error("Error processing @translate directive:",j);return H0("Translate",`Error in @translate('${_}'): ${j instanceof Error?j.message:String(j)}`,G0.EVALUATION_ERROR)}}),X}async function NB($,Z,Y){let J=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((W)=>({match:Q,replacement:W}));return J.push(K),Q}),(await Promise.all(J)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function mE($,Z=!0){return(Y,J={})=>{return fZ(Y,$,Z,J)}}var y7,gZ,w1,s1,I4;var f9=D(()=>{C1();n0();gZ={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},w1={},s1={},I4={}});function cE($){let Z=$.replace(/^<template\b/i,"").replace(/>$/,"");return lE.test(Z)}function _4($){v7.lastIndex=0;let Z;while((Z=v7.exec($))!==null){if(Z[0].startsWith("</")||cE(Z[0]))continue;let Y=Z.index,J=v7.lastIndex,X=1,Q;while((Q=v7.exec($))!==null)if(Q[0].startsWith("</")){if(X--,X===0){let G=Q.index;return{start:Y,openEnd:J,closeStart:G,end:v7.lastIndex,content:$.slice(J,G)}}}else X++;return null}return null}var v7,lE;var x$=D(()=>{v7=/<\/?template\b[^>]*>/gi,lE=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i});var i6={};$0(i6,{streamingSuspenseDirective:()=>d9,streamToResponse:()=>hB,streamTemplateSimple:()=>xB,streamTemplate:()=>CB,renderStreamingPage:()=>bB,registerStreamingDirectives:()=>fB,processStreamDirectives:()=>PB,processSectionDirectives:()=>gB,islandDirective:()=>u9,generateHydrationRuntime:()=>dB,extractStreamBoundaries:()=>yB,createStreamRenderer:()=>vB,buildSuspenseResolveScript:()=>dZ,SUSPENSE_RESOLVER_RUNTIME:()=>h9});import hZ from"path";function pE($){let Z=[],Y=0,J;SB.lastIndex=0;while((J=SB.exec($))!==null){if(J.index>Y){let G=$.slice(Y,J.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let X=J[1],Q=J[2];Z.push({type:"suspense",name:X,content:Q}),Y=J.index+J[0].length}if(Y<$.length){let X=$.slice(Y);if(X.trim())Z.push({type:Z.length===0?"shell":"content",content:X})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function CB($,Z={},Y={}){let J={...N1,...Y,streaming:{...g9,...Y.streaming}},X=J.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={...Z,__filename:$,__dirname:hZ.dirname($)};if(W.trim())await D0(W,z,$);let _=pE(U),B=new Set;if(!_.some((j)=>j.type==="suspense")){let j=J.streaming?.strategy||"auto",H=new RegExp(p6.source,"g");if(!(j!=="manual"&&H.test(U))){let V=await q0(U,z,$,J,B);for(let L=0;L<V.length;L+=X)Q.enqueue(V.slice(L,L+X)),await new Promise((F)=>setTimeout(F,0))}else{let V=[],L=new RegExp(p6.source,"g"),F;while((F=L.exec(U))!==null)V.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let A=0;for(let w of V){if(w.start>A){let R=U.slice(A,w.start);if(R.trim()){let E=await q0(R,z,$,J,B);Q.enqueue(E),await new Promise((M)=>setTimeout(M,0))}}let N=await q0(w.content,z,$,J,B);Q.enqueue(N),await new Promise((R)=>setTimeout(R,0)),A=w.end}if(A<U.length){let w=U.slice(A);if(w.trim()){let N=await q0(w,z,$,J,B);Q.enqueue(N)}}}}else{let j=new Map;for(let O of _)if(O.type==="shell"||O.type==="content"){let V=await q0(O.content,z,$,J,B);Q.enqueue(V)}else if(O.type==="suspense"&&O.name){let V=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${V}" data-suspense="${O.name}" style="display:contents;">
|
|
1922
|
+
</script>`.trim()}var yZ,VB,S9;var C9=D(()=>{n0();yZ={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};VB={required:($,Z,Y)=>{if($===void 0||$===null||$===""||Array.isArray($)&&$.length===0)return`The ${Y} field is required.`;return null},email:($,Z,Y)=>{if(!$)return null;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($)))return`The ${Y} field must be a valid email address.`;return null},min:($,Z,Y)=>{if(!$)return null;let J=Number(Z[0]);if(typeof $==="string"&&$.length<J)return`The ${Y} field must be at least ${J} characters.`;if(typeof $==="number"&&$<J)return`The ${Y} field must be at least ${J}.`;if(Array.isArray($)&&$.length<J)return`The ${Y} field must have at least ${J} items.`;return null},max:($,Z,Y)=>{if(!$)return null;let J=Number(Z[0]);if(typeof $==="string"&&$.length>J)return`The ${Y} field must not exceed ${J} characters.`;if(typeof $==="number"&&$>J)return`The ${Y} field must not exceed ${J}.`;if(Array.isArray($)&&$.length>J)return`The ${Y} field must not have more than ${J} items.`;return null},confirmed:($,Z,Y)=>{if(Z[0]!==void 0&&$!==Z[0])return`The ${Y} confirmation does not match.`;return null},numeric:($,Z,Y)=>{if(!$)return null;if(Number.isNaN(Number($)))return`The ${Y} field must be a number.`;return null},integer:($,Z,Y)=>{if(!$)return null;if(!Number.isInteger(Number($)))return`The ${Y} field must be an integer.`;return null},alpha:($,Z,Y)=>{if(!$)return null;if(!/^[a-z]+$/i.test(String($)))return`The ${Y} field must only contain letters.`;return null},alphanumeric:($,Z,Y)=>{if(!$)return null;if(!/^[a-z0-9]+$/i.test(String($)))return`The ${Y} field must only contain letters and numbers.`;return null},url:($,Z,Y)=>{if(!$)return null;try{return new URL(String($))?null:null}catch{return`The ${Y} field must be a valid URL.`}},regex:($,Z,Y)=>{if(!$)return null;try{if(!new RegExp(Z[0]).test(String($)))return`The ${Y} field format is invalid.`;return null}catch{return`The ${Y} field has an invalid validation pattern.`}},in:($,Z,Y)=>{if(!$)return null;if(!Z.includes(String($)))return`The ${Y} field must be one of: ${Z.join(", ")}.`;return null},notIn:($,Z,Y)=>{if(!$)return null;if(Z.includes(String($)))return`The ${Y} field must not be: ${Z.join(", ")}.`;return null},date:($,Z,Y)=>{if(!$)return null;let J=new Date($);if(Number.isNaN(J.getTime()))return`The ${Y} field must be a valid date.`;return null},before:($,Z,Y)=>{if(!$)return null;let J=new Date($),X=new Date(Z[0]);if(J>=X)return`The ${Y} field must be before ${Z[0]}.`;return null},after:($,Z,Y)=>{if(!$)return null;let J=new Date($),X=new Date(Z[0]);if(J<=X)return`The ${Y} field must be after ${Z[0]}.`;return null}};S9={required:{name:"required",validate:($)=>{if($===null||$===void 0||$==="")return"This field is required";if(Array.isArray($)&&$.length===0)return"This field is required";return!0},toHtml5:()=>["required"],message:"This field is required"},email:{name:"email",validate:($)=>{if(!$)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($))||"Please enter a valid email address"},toHtml5:()=>['type="email"'],message:"Please enter a valid email address"},url:{name:"url",validate:($)=>{if(!$)return!0;try{return new URL(String($)).protocol.startsWith("http")||"Please enter a valid URL"}catch{return"Please enter a valid URL"}},toHtml5:()=>['type="url"'],message:"Please enter a valid URL"},numeric:{name:"numeric",validate:($)=>{if(!$)return!0;return!Number.isNaN(Number($))||"Please enter a number"},toHtml5:()=>['type="number"'],message:"Please enter a number"},integer:{name:"integer",validate:($)=>{if(!$)return!0;let Z=Number($);return Number.isInteger(Z)||"Please enter a whole number"},toHtml5:()=>['type="number"','step="1"'],message:"Please enter a whole number"},alpha:{name:"alpha",validate:($)=>{if(!$)return!0;return/^[a-z]+$/i.test(String($))||"Please enter only letters"},toHtml5:()=>['pattern="[a-zA-Z]+"'],message:"Please enter only letters"},alphanumeric:{name:"alphanumeric",validate:($)=>{if(!$)return!0;return/^[a-z0-9]+$/i.test(String($))||"Please enter only letters and numbers"},toHtml5:()=>['pattern="[a-zA-Z0-9]+"'],message:"Please enter only letters and numbers"},min:{name:"min",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length>=Y||`Must be at least ${Y} characters`;if(typeof $==="number")return $>=Y||`Must be at least ${Y}`;if(Array.isArray($))return $.length>=Y||`Must have at least ${Y} items`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`min="${$[0]}"`],message:"Must be at least {{param}} characters"},max:{name:"max",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length<=Y||`Must be no more than ${Y} characters`;if(typeof $==="number")return $<=Y||`Must be no more than ${Y}`;if(Array.isArray($))return $.length<=Y||`Must have no more than ${Y} items`;return!0},toHtml5:($)=>[`maxlength="${$[0]}"`,`max="${$[0]}"`],message:"Must be no more than {{param}} characters"},between:{name:"between",validate:($,Z)=>{if(!$)return!0;let[Y,J]=Z.map(Number);if(typeof $==="string")return $.length>=Y&&$.length<=J||`Must be between ${Y} and ${J} characters`;if(typeof $==="number")return $>=Y&&$<=J||`Must be between ${Y} and ${J}`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`maxlength="${$[1]}"`],message:"Must be between {{min}} and {{max}}"},confirmed:{name:"confirmed",validate:($,Z,Y)=>{let J=Object.keys(Y);for(let X of J)if(X.endsWith("_confirmation")&&Y[X]===$)return!0;return"Confirmation does not match"},message:"Confirmation does not match"},in:{name:"in",validate:($,Z)=>{if(!$)return!0;return Z.includes(String($))||`Must be one of: ${Z.join(", ")}`},message:"Must be one of: {{values}}"},notIn:{name:"notIn",validate:($,Z)=>{if(!$)return!0;return!Z.includes(String($))||`Must not be: ${Z.join(", ")}`},message:"Must not be: {{values}}"},regex:{name:"regex",validate:($,Z)=>{if(!$)return!0;try{return new RegExp(Z[0]).test(String($))||"Invalid format"}catch{return"Invalid format"}},toHtml5:($)=>[`pattern="${$[0]}"`],message:"Invalid format"},date:{name:"date",validate:($)=>{if(!$)return!0;let Z=new Date(String($));return!Number.isNaN(Z.getTime())||"Please enter a valid date"},toHtml5:()=>['type="date"'],message:"Please enter a valid date"},before:{name:"before",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),J=new Date(Z[0]);return Y<J||`Must be before ${Z[0]}`},toHtml5:($)=>[`max="${$[0]}"`],message:"Must be before {{date}}"},after:{name:"after",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),J=new Date(Z[0]);return Y>J||`Must be after ${Z[0]}`},toHtml5:($)=>[`min="${$[0]}"`],message:"Must be after {{date}}"},size:{name:"size",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length===Y||`Must be exactly ${Y} characters`;if(Array.isArray($))return $.length===Y||`Must have exactly ${Y} items`;return!0},message:"Must be exactly {{size}}"},phone:{name:"phone",validate:($)=>{if(!$)return!0;return/^\+?\(?\d{1,4}\)?[-\s./\d]*$/.test(String($))||"Please enter a valid phone number"},toHtml5:()=>['type="tel"','pattern="\\+?\\(?\\d{1,4}\\)?[-\\s./\\d]*"'],message:"Please enter a valid phone number"}}});import P9 from"path";async function qE(){if(y7!==void 0)return y7;try{y7=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{y7=null}return y7}function jE($){if($)delete w1[$];else for(let Z of Object.keys(w1))delete w1[Z]}function HE(){let $=Object.entries(w1).map(([Z,Y])=>({locale:Z,loadedAt:new Date(Y.loadedAt),keyCount:RB(Y.translations)}));return{size:Object.keys(w1).length,locales:Object.keys(w1),entries:$}}function RB($,Z=0){for(let Y of Object.values($))if(Z++,Y&&typeof Y==="object"&&!Array.isArray(Y))Z=RB(Y,Z);return Z}function OE($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}function LE($){if(w1[$])return"loaded";return I4[$]||"idle"}function VE($){return I4[$]==="loading"}function FE($){return!!w1[$]}async function MB($,Z){let{locales:Y,parallel:J=!0,priority:X={},onLocaleLoaded:Q,onComplete:G,onError:K}=$,W=J?Y:[...Y].sort((U,z)=>(X[z]||0)-(X[U]||0));if(J){let U=W.map(async(z)=>{try{await x7(z,Z),Q?.(z)}catch(_){K?.(z,_ instanceof Error?_:Error(String(_)))}});await Promise.all(U)}else for(let U of W)try{await x7(U,Z),Q?.(U)}catch(z){K?.(U,z instanceof Error?z:Error(String(z)))}G?.()}function AE($,Z){queueMicrotask(()=>{MB($,Z).catch((Y)=>{if(Z.debug)console.error("Background preload error:",Y)})})}async function x7($,Z){if({...gZ,...Z.i18n}.cache&&w1[$]){let X=w1[$],Q=Z.i18n?.cacheMaxAge??0;if(!OE(X,Q))return X.translations}if(a1[$]?.state==="loading")return a1[$].promise;I4[$]="loading";let J=y9($,Z).then((X)=>{return I4[$]="loaded",delete a1[$],X}).catch((X)=>{throw I4[$]="error",a1[$]={promise:J,state:"error",error:X instanceof Error?X:Error(String(X))},X});return a1[$]={promise:J,state:"loading"},J}function TB($){return w1[$]?.translations}async function wE($,Z){let Y=TB($);if(Y)return Y;return x7($,Z)}async function NE($,Z){if(w1[$])return w1[$].translations;if(a1[$]){if(Z)return Promise.race([a1[$].promise,new Promise((Y,J)=>setTimeout(()=>J(Error(`Timeout waiting for locale: ${$}`)),Z))]);return a1[$].promise}throw Error(`Locale "${$}" is not loading. Call loadTranslationLazy first.`)}function RE(){return Object.entries(I4).filter(([$,Z])=>Z==="loading").map(([$])=>$)}function ME($){if($)delete a1[$],delete I4[$];else{for(let Z of Object.keys(a1))delete a1[Z];for(let Z of Object.keys(I4))delete I4[Z]}}async function y9($,Z){let Y={...gZ,...Z.i18n},J=P9.isAbsolute(Y.translationsDir)?Y.translationsDir:P9.resolve(Z.root||process.cwd(),Y.translationsDir);try{let X=await qE(),Q=X?await X($,{translationsDir:J,defaultLocale:Y.defaultLocale,sources:kE(Y.format)}):await TE($,Y,J);if(Q===void 0){if($!==Y.defaultLocale)return y9(Y.defaultLocale,Z);return{}}let G=Q;if(Y.cache)w1[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(X){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,X);if($!==Y.defaultLocale)return y9(Y.defaultLocale,Z);return{}}}async function TE($,Z,Y){let J=P9.join(Y,`${$}${EE(Z.format)}`);try{let X=await import(J);return X.default||X}catch(X){try{let Q=await Bun.file(J).text();if(Z.format==="yaml"||Z.format==="yml")return IE(Q);if(Z.format==="json")return JSON.parse(Q);throw X}catch{return}}}function EE($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function IE($){let Z={},Y=$.split(`
|
|
1923
|
+
`),J=[{obj:Z,indent:-1}];for(let X of Y){let Q=X.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(J.length>1&&J[J.length-1].indent>=G)J.pop();let K=J[J.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,z]=W,_=U.trim(),B=z.trim();if(B==="")K[_]={},J.push({obj:K[_],indent:G});else K[_]=DE(B)}}return Z}function DE($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let Y=Number($);if(!Number.isNaN(Y)&&$!=="")return Y;return $}function kE($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function EB($,Z){return x7($,Z)}function SE($,Z){for(let Y of $){let J=Y.trim(),X=J.match(/^\{(\d+)\}\s*(.*)$/);if(X){let G=Number.parseInt(X[1],10);if(Z===G)return X[2];continue}let Q=J.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),K=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=K)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function IB($,Z={}){return DB($,Z)}function DB($,Z){let Y="",J=0;while(J<$.length)if($[J]==="{"){let X=CE($,J);if(X===-1){Y+=$[J],J++;continue}let Q=$.slice(J+1,X);Y+=bE(Q,Z),J=X+1}else if($[J]==="'"&&J+1<$.length)if($[J+1]==="'")Y+="'",J+=2;else if($[J+1]==="{"||$[J+1]==="}")Y+=$[J+1],J+=2;else Y+=$[J],J++;else Y+=$[J],J++;return Y}function CE($,Z){let Y=0;for(let J=Z;J<$.length;J++)if($[J]==="{")Y++;else if($[J]==="}"){if(Y--,Y===0)return J}return-1}function bE($,Z){let Y=PE($);if(Y.length===0)return`{${$}}`;let J=Y[0].trim(),X=Z[J];if(Y.length===1)return X!==void 0?String(X):`{${J}}`;switch(Y[1].trim().toLowerCase()){case"plural":return yE(X,Y.slice(2).join(","),Z);case"select":return vE(X,Y.slice(2).join(","));case"selectordinal":return fE(X,Y.slice(2).join(","));case"number":return hE(X,Y[2]?.trim());case"date":return dE(X,Y[2]?.trim());case"time":return uE(X,Y[2]?.trim());default:return X!==void 0?String(X):`{${$}}`}}function PE($){let Z=[],Y="",J=0;for(let X=0;X<$.length;X++){let Q=$[X];if(Q==="{")J++,Y+=Q;else if(Q==="}")J--,Y+=Q;else if(Q===","&&J===0)Z.push(Y),Y="";else Y+=Q}if(Y)Z.push(Y);return Z}function yE($,Z,Y){let J=Number($)||0,X=x9(Z),Q=`=${J}`;if(X[Q])return b9(X[Q],J,Y);let G=xE(J);if(X[G])return b9(X[G],J,Y);if(X.other)return b9(X.other,J,Y);return String(J)}function b9($,Z,Y){let J=$.replace(/#/g,String(Z));return DB(J,Y)}function xE($){let Z=Math.abs($),Y=Math.floor(Z),J=String($).includes(".")?String($).split(".")[1].length:0;if(Y===1&&J===0)return"one";return"other"}function vE($,Z){let Y=String($||""),J=x9(Z);if(J[Y])return J[Y];return J.other||String($)}function fE($,Z){let Y=Number($)||0,J=x9(Z),X=gE(Y);if(J[X])return J[X].replace(/#/g,String(Y));if(J.other)return J.other.replace(/#/g,String(Y));return String(Y)}function gE($){let Z=Math.abs($),Y=Z%10,J=Z%100;if(Y===1&&J!==11)return"one";if(Y===2&&J!==12)return"two";if(Y===3&&J!==13)return"few";return"other"}function x9($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,J=Y.exec($);while(J!==null)Z[J[1]]=J[2],J=Y.exec($);return Z}function hE($,Z){let Y=Number($);if(Number.isNaN(Y))return String($);switch(Z){case"integer":return Math.floor(Y).toLocaleString();case"percent":return`${(Y*100).toFixed(0)}%`;case"currency":return Y.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return Y.toLocaleString()}}function dE($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let J={};switch(Z){case"short":J.dateStyle="short";break;case"medium":J.dateStyle="medium";break;case"long":J.dateStyle="long";break;case"full":J.dateStyle="full";break;default:J.dateStyle="medium"}return Y.toLocaleDateString(void 0,J)}function uE($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let J={};switch(Z){case"short":J.timeStyle="short";break;case"medium":J.timeStyle="medium";break;case"long":J.timeStyle="long";break;case"full":J.timeStyle="full";break;default:J.timeStyle="short"}return Y.toLocaleTimeString(void 0,J)}function kB($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function fZ($,Z,Y=!0,J={}){let X=$.split("."),Q=Z;for(let K of X){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(kB(G))return IB(G,J);if(G.includes("|")&&"count"in J){let K=Number(J.count),W=G.split("|");G=SE(W,K)}for(let[K,W]of Object.entries(J)){let U=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${U}`,"g"),String(W))}return G}async function v9($,Z,Y,J){let X=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...gZ,...J.i18n},K=await EB(G.locale,J);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,X=await NB(X,Q,async(z,_,B,q,j)=>{try{let H={};if(B)try{let V=[()=>JSON.parse(B),()=>{let L=`{"data":${B}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return i0(B,Z)}];for(let L of V)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(V){if(J.debug)console.error("Error parsing parameters for @translate directive:",V)}return fZ(_,K,G.fallbackToKey,H)||q.trim()}catch(H){if(J.debug)console.error("Error processing @translate directive:",H);return H0("Translate",`Error in @translate('${_}'): ${H instanceof Error?H.message:String(H)}`,G0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(J.debug){console.warn(`Processing translations in template. Sections: ${X.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let z=[...X.matchAll(W)];console.warn(`Found ${z.length} @translate matches`),z.forEach((_,B)=>console.warn(`Match ${B}: ${_[0]}, Key: ${_[1]}, Params: ${_[2]||"none"}`))}return X=await NB(X,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(z,_,B,q)=>{try{let j={};if(B)try{let H=[()=>JSON.parse(B),()=>{let O=`{"data":${B}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return i0(B,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(J.debug)console.error("Error parsing parameters for @translate directive:",H)}return fZ(_,K,G.fallbackToKey,j)}catch(j){if(J.debug)console.error("Error processing @translate directive:",j);return H0("Translate",`Error in @translate('${_}'): ${j instanceof Error?j.message:String(j)}`,G0.EVALUATION_ERROR)}}),X}async function NB($,Z,Y){let J=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((W)=>({match:Q,replacement:W}));return J.push(K),Q}),(await Promise.all(J)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function mE($,Z=!0){return(Y,J={})=>{return fZ(Y,$,Z,J)}}var y7,gZ,w1,a1,I4;var f9=D(()=>{C1();n0();gZ={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},w1={},a1={},I4={}});function cE($){let Z=$.replace(/^<template\b/i,"").replace(/>$/,"");return lE.test(Z)}function _4($){v7.lastIndex=0;let Z;while((Z=v7.exec($))!==null){if(Z[0].startsWith("</")||cE(Z[0]))continue;let Y=Z.index,J=v7.lastIndex,X=1,Q;while((Q=v7.exec($))!==null)if(Q[0].startsWith("</")){if(X--,X===0){let G=Q.index;return{start:Y,openEnd:J,closeStart:G,end:v7.lastIndex,content:$.slice(J,G)}}}else X++;return null}return null}var v7,lE;var x$=D(()=>{v7=/<\/?template\b[^>]*>/gi,lE=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i});var i6={};$0(i6,{streamingSuspenseDirective:()=>d9,streamToResponse:()=>hB,streamTemplateSimple:()=>xB,streamTemplate:()=>CB,renderStreamingPage:()=>bB,registerStreamingDirectives:()=>fB,processStreamDirectives:()=>PB,processSectionDirectives:()=>gB,islandDirective:()=>u9,generateHydrationRuntime:()=>dB,extractStreamBoundaries:()=>yB,createStreamRenderer:()=>vB,buildSuspenseResolveScript:()=>dZ,SUSPENSE_RESOLVER_RUNTIME:()=>h9});import hZ from"path";function pE($){let Z=[],Y=0,J;SB.lastIndex=0;while((J=SB.exec($))!==null){if(J.index>Y){let G=$.slice(Y,J.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let X=J[1],Q=J[2];Z.push({type:"suspense",name:X,content:Q}),Y=J.index+J[0].length}if(Y<$.length){let X=$.slice(Y);if(X.trim())Z.push({type:Z.length===0?"shell":"content",content:X})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function CB($,Z={},Y={}){let J={...N1,...Y,streaming:{...g9,...Y.streaming}},X=J.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={...Z,__filename:$,__dirname:hZ.dirname($)};if(W.trim())await D0(W,z,$);let _=pE(U),B=new Set;if(!_.some((j)=>j.type==="suspense")){let j=J.streaming?.strategy||"auto",H=new RegExp(p6.source,"g");if(!(j!=="manual"&&H.test(U))){let V=await q0(U,z,$,J,B);for(let L=0;L<V.length;L+=X)Q.enqueue(V.slice(L,L+X)),await new Promise((F)=>setTimeout(F,0))}else{let V=[],L=new RegExp(p6.source,"g"),F;while((F=L.exec(U))!==null)V.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let A=0;for(let w of V){if(w.start>A){let R=U.slice(A,w.start);if(R.trim()){let E=await q0(R,z,$,J,B);Q.enqueue(E),await new Promise((M)=>setTimeout(M,0))}}let N=await q0(w.content,z,$,J,B);Q.enqueue(N),await new Promise((R)=>setTimeout(R,0)),A=w.end}if(A<U.length){let w=U.slice(A);if(w.trim()){let N=await q0(w,z,$,J,B);Q.enqueue(N)}}}}else{let j=new Map;for(let O of _)if(O.type==="shell"||O.type==="content"){let V=await q0(O.content,z,$,J,B);Q.enqueue(V)}else if(O.type==="suspense"&&O.name){let V=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${V}" data-suspense="${O.name}" style="display:contents;">
|
|
1924
1924
|
<template data-suspense-fallback>Loading...</template>
|
|
1925
1925
|
</div>`),j.set(O.name,q0(O.content,z,$,J,B))}Q.enqueue(`
|
|
1926
1926
|
<script>
|
|
@@ -2112,8 +2112,8 @@ else {
|
|
|
2112
2112
|
${W?`{${W}}`:"{}"}
|
|
2113
2113
|
</script>
|
|
2114
2114
|
</div>`}}});var lB={};$0(lB,{warnUnbalancedTags:()=>m9,findUnbalancedTags:()=>mB});function v$($){return $.replace(/[^\n]/g," ")}function mB($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,v$).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,v$).replace(/<!--[\s\S]*?-->/g,v$).replace(/\{\{\{[\s\S]*?\}\}\}/g,v$).replace(/\{\{[\s\S]*?\}\}/g,v$).replace(/\{!![\s\S]*?!!\}/g,v$),Y=new Map,J=new Map,X=/<(\/?)([A-Za-z][\w-]*)\b(?:[^>"']|"[^"]*"|'[^']*')*?(\/?)>/g,Q;while((Q=X.exec(Z))!==null){let K=Q[1]==="/",W=Q[2],U=Q[3]==="/";if(rE.has(W.toLowerCase()))continue;if(U)continue;if(K)J.set(W,(J.get(W)??0)+1);else{let z=Y.get(W);if(z)z.count++;else{let _=Z.slice(0,Q.index).split(`
|
|
2115
|
-
`).length;Y.set(W,{count:1,firstLine:_})}}}let G=[];for(let K of new Set([...Y.keys(),...J.keys()])){if(
|
|
2116
|
-
`}if(F){let y=[];if(z==="avif"||z==="auto"){let b=g7(J,A,w,q,"avif"),h=N?
|
|
2115
|
+
`).length;Y.set(W,{count:1,firstLine:_})}}}let G=[];for(let K of new Set([...Y.keys(),...J.keys()])){if(aE.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=J.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function m9($,Z){let Y;try{Y=mB($)}catch{return}if(Y.length===0)return;let J=`${Z}:${$.length}`;if(uB.has(J))return;uB.add(J);let X=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${X}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${X}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var rE,aE,uB;var l9=D(()=>{rE=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),aE=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);uB=new Set});import u1 from"path";import c9 from"fs";function cB($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function pB($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class iB{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,J){let X=$.endsWith(".stx")?$.slice(0,-4):$,Q=J?.__importedComponents;if(Q){let q=[X,X.toLowerCase(),cB(X),pB(X)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${X}.stx`,`${cB(X)}.stx`,`${pB(X)}.stx`])];if(X.startsWith("./")||X.startsWith("../")){let q=u1.resolve(u1.dirname(Z),`${X}.stx`);if(await Q0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=J?.__originalFilePath;if(U)K.push(u1.join(u1.dirname(U),"components"));if(W)K.push(W);let z=u1.join(u1.dirname(Z),"components");if(!K.includes(z))K.push(z);let _=process.cwd(),B=[u1.resolve(_,"src/components"),u1.resolve(_,"components"),u1.resolve(import.meta.dir,"components")];for(let q of B)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=u1.join(q,j);if(await Q0(H))return H}try{if(!c9.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=c9.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let V=u1.join(q,O.name);for(let L of G){let F=u1.join(V,L);if(await Q0(F))return F}}}catch{}}return null}}var R1;var p9=D(()=>{N0();R1=new iB});function B1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function f$($,Z){let Y=[];for(let[J,X]of Object.entries($.static)){if(Z.has(J))continue;let Q=$.staticNames?.[J]??J;if(typeof X==="boolean"){if(X)Y.push(B1(Q));continue}Y.push(`${B1(Q)}="${B1(X)}"`)}return Y}var uZ=()=>{};function f7($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function sE($){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 i9;var n9=D(()=>{uZ();i9={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let J=sE($),X=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=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,W=[];if(J.reactive)W.push(`:href="${f7(J.value)}"`);else W.push(`href="${f7(J.value)}"`);if(X)W.push(`class="${f7(X)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${f7(Q)}"`),W.push(`data-stx-exact-active-class="${f7(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);return W.push(...f$($,U)),`<a ${W.join(" ")}>${Z}</a>`}}});function W1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function q1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function a9($,Z,Y=!1){let J=$.serverDynamic[Z];if(J!==void 0)return J!==!1&&J!=="false";let X=$.static[Z];if(X!==void 0)return X!=="false"&&X!==!1;return Y}function nB($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let J of Z)if(J.includes(":")){let[X,Q]=J.split(":"),G=oE[X];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(X);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(J);return Y.join(", ")}function s9($,Z,Y,J){return Z.map((X)=>`${g7($,X,void 0,Y,J)} ${X}w`).join(", ")}function tE($,Z,Y,J,X){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${g7($,G,void 0,J,X)} ${Q}x`}).join(", ")}function g7($,Z,Y,J,X){if(!J||J==="local"||J==="static")return $;if(J==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(X)Q.push(`f_${X}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(J==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(X)Q.set("fm",X);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(J==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(X)Q.set("format",X);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function eE($,Z,Y="#e5e7eb"){let J=`<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(J)}`}var oE,r9,o9;var t9=D(()=>{uZ();oE={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},r9=[320,640,768,1024,1280,1536,1920];o9={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let J=q1($,"src")||"",X=q1($,"alt")||"",Q=q1($,"width"),G=q1($,"height"),K=q1($,"sizes"),W=q1($,"srcset"),U=q1($,"densities"),z=q1($,"format"),_=q1($,"placeholder"),B=q1($,"placeholderColor")||"#e5e7eb",q=q1($,"provider"),j=q1($,"class")||q1($,"className")||"",H=q1($,"style")||"",O=q1($,"quality"),V=a9($,"lazy",!0),L=a9($,"preload",!1),F=a9($,"picture",!1)||!!z,A=Q?Number.parseInt(Q):void 0,w=G?Number.parseInt(G):void 0,N=W||"",R="";if(!N&&K)N=s9(J,r9,q,z),R=nB(K);else if(!N&&U){let y=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));N=tE(J,y,A,q,z)}else if(K)R=nB(K);let E=[];if(H)E.push(H);if(A&&w)E.push(`aspect-ratio:${A}/${w}`);if(_==="blur"||_==="color"||_==="thumbhash"){let y=eE(A||16,w||9,B);E.push(`background-image:url(${y})`),E.push("background-size:cover"),E.push("background-repeat:no-repeat")}else if(_&&_!=="empty"&&_!=="none")E.push(`background-image:url(${W1(_)})`),E.push("background-size:cover"),E.push("background-repeat:no-repeat");let M=g7(J,A,w,q,z),I=[];if(I.push(`src="${W1(M)}"`),I.push(`alt="${W1(X)}"`),Q)I.push(`width="${W1(Q)}"`);if(G)I.push(`height="${W1(G)}"`);if(V)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${W1(j)}"`);if(E.length>0)I.push(`style="${W1(E.join(";"))}"`);if(N)I.push(`srcset="${W1(N)}"`);if(R)I.push(`sizes="${W1(R)}"`);let S=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);I.push(...f$($,S));let k=`<img ${I.join(" ")} />`,x="";if(L){let b=z==="webp"?"image/webp":z==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${W1(M)}"${b?` type="${b}"`:""}${N?` imagesrcset="${W1(N)}"`:""}${R?` imagesizes="${W1(R)}"`:""} />
|
|
2116
|
+
`}if(F){let y=[];if(z==="avif"||z==="auto"){let b=g7(J,A,w,q,"avif"),h=N?s9(J,r9,q,"avif"):`${b}`;y.push(`<source type="image/avif" srcset="${W1(h)}"${R?` sizes="${W1(R)}"`:""} />`)}if(z==="webp"||z==="auto"){let b=g7(J,A,w,q,"webp"),h=N?s9(J,r9,q,"webp"):`${b}`;y.push(`<source type="image/webp" srcset="${W1(h)}"${R?` sizes="${W1(R)}"`:""} />`)}return`${x}<picture>
|
|
2117
2117
|
${y.join(`
|
|
2118
2118
|
`)}
|
|
2119
2119
|
${k}
|
|
@@ -2124,7 +2124,7 @@ ${k}
|
|
|
2124
2124
|
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
2125
2125
|
<script>
|
|
2126
2126
|
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${K})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
2127
|
-
</script>`}}});function
|
|
2127
|
+
</script>`}}});function sB($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function ZI($,Z,Y){let J=sB($,Z);if(J!==void 0){let X=Number.parseInt(J,10);if(!Number.isNaN(X))return X}return Y}var aB,X2;var Q2=D(()=>{aB={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},X2={name:"StxToast",aliases:["stx-toast"],render($,Z,Y){let J=B1(sB($,"position")||"top-right"),X=ZI($,"max",5),Q=aB[J]||aB["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${J}" data-stx-toast-max="${X}" style="position:fixed;${Q};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
|
|
2128
2128
|
<style>
|
|
2129
2129
|
@keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
|
|
2130
2130
|
@keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
|
|
@@ -2151,25 +2151,25 @@ ${k}
|
|
|
2151
2151
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
2152
2152
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
2153
2153
|
</style>`}}});import{existsSync as YI,readFileSync as JI}from"fs";function $q($){if(eB.has($))return;eB.add($),console.warn(`[stx] icon collection "${$}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${$}\`.`)}function Zq($){let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify-json/${$}/icons.json`,`${Z}/pantry/@iconify-json/${$}/icons.json`,`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(YI(Y))return Y;for(let Y of[`@iconify-json/${$}/icons.json`,`@iconify/json/json/${$}.json`])try{return Z0.resolve(Y)}catch{}return null}function XI($){if(n6.has($))return n6.get($);let Z=Zq($);if(!Z)return $q($),null;try{let Y=JSON.parse(JI(Z,"utf8"));return n6.set($,Y.icons),Y.icons}catch{return null}}async function QI($){if(n6.has($))return n6.get($);let Z=Zq($);if(!Z)return $q($),null;try{let Y=await Bun.file(Z).json();return n6.set($,Y.icons),Y.icons}catch{return null}}function d$($,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}async function _2($="lucide"){await QI($)}var n6,eB,z2;var B2=D(()=>{n6=new Map,eB=new Set;z2={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let J=d$($,"name")??d$($,"icon");if(!J)return"<!-- Icon: missing name/icon prop -->";let X="lucide",Q=J;if(J.includes(":")){let L=J.split(":");X=L[0],Q=L[1]}let G=B1(d$($,"size")||"24"),K=B1(d$($,"color")||"currentColor"),W=B1(d$($,"class")||""),U=B1(d$($,"style")||""),z=n6.get(X)??XI(X);if(!z)return`<!-- Icon: collection "${X}" not loaded -->`;let _=z[Q];if(!_)return`<!-- Icon: "${Q}" not found in ${X} -->`;let B=_.width||24,q=_.height||24,j=`0 0 ${B} ${q}`,H=_.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",V=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${V}>${H}</svg>`}}});function Yq($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let J=$.static[Y];if(typeof J==="string")return J}return}function Jq($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),J=$.match(Y);if(!J)return{region:null,rest:$};return{region:J[2],rest:$.replace(J[0],"")}}var q2;var j2=D(()=>{q2={name:"Suspense",aliases:["suspense"],render($,Z,Y){let J=Jq(Z,"fallback"),X=J.rest,Q=Jq(X,"error"),G=Q.rest,K=J.region??Yq($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=Q.region??Yq($,"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>${W}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function cZ($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let J=$.static[Y];if(typeof J==="string")return J}return}var H2;var O2=D(()=>{H2={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let J=(cZ($,"name")||"v").replace(/["'<>]/g,""),X=(cZ($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=cZ($,"class"),G=cZ($,"id"),K=[`data-stx-transition-group="${J}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${X} ${K}>${Z}</${X}>`}}});function Xq(){R1.registerBuiltin(i9),R1.registerBuiltin(o9),R1.registerBuiltin(e9),R1.registerBuiltin(Y2),R1.registerBuiltin(X2),R1.registerBuiltin(G2),R1.registerBuiltin(W2),R1.registerBuiltin(z2),R1.registerBuiltin(q2),R1.registerBuiltin(H2)}var L2=D(()=>{n9();t9();$2();J2();Q2();K2();U2();B2();j2();O2();p9();n9();t9();$2();J2();Q2();K2();U2();B2();j2();O2()});function pZ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function Qq($,Z,Y){let J=[],X=0;while(X<$.length){let Q=$.indexOf("<",X);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){X=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;X=H+1;continue}let U=Q+1+W.length,z=null,_=U,B=-1,q=!1;while(U<$.length){let H=$[U];if(z){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===z)z=null;U++;continue}if(H==='"'||H==="'"){z=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){B=U+2,q=!0;break}if(H===">"){B=U+1;break}U++}if(B===-1){X=Q+1;continue}let j=$.slice(_,q?B-2:B-1).trim();if(q)J.push({fullMatch:$.slice(Q,B),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:B,isSelfClosing:!0}),X=B;else{let H=`<${W}`,O=`</${W}>`,V=1,L=B,F=-1;while(V>0&&L<$.length){let N=$.indexOf(H,L),R=$.indexOf(O,L);if(R===-1)break;if(N!==-1&&N<R){let E=$[N+H.length];if(E===" "||E===">"||E==="/"||E===`
|
|
2154
|
-
`||E==="\t")V++;L=N+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){X=B;continue}let A=$.slice(B,F),w=F+O.length;J.push({fullMatch:$.slice(Q,w),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:w,isSelfClosing:!1}),X=w}}return J}function Gq($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var Kq=D(()=>{n0();N0();f6()});var jq={};$0(jq,{processESImports:()=>Bq,processComponents:()=>nZ});import iZ from"fs";import b1 from"path";function KI($,Z,Y){let J={static:{},staticNames:{},serverDynamic:{},clientReactive:{},events:{}},X=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"]),Q=(K)=>{if(!K.includes("-")||K.startsWith("@")||K.startsWith(":")||K.startsWith("x-")||K.startsWith("__"))return K;if(K.startsWith("aria-")||K.startsWith("data-"))return K;return K.replace(/-([a-z0-9])/g,(W,U)=>U.toUpperCase())},G=(K,W)=>{let U=Q(K);if(J.static[U]=W,U!==K)J.staticNames[U]=K};for(let[K,W]of Object.entries($)){let U=K.startsWith("x-")&&!X.has(K)&&!K.startsWith("x-bind:")&&!K.startsWith("x-on:")?`:${K.slice(2)}`:K;if(U.startsWith("@")){J.events[U]=W;continue}if(U.startsWith("__stx_")){let z=Q(U.slice(6));J.serverDynamic[z]=Gq(W,Y);continue}if(U.startsWith(":")){let z=Q(U.slice(1)),_=W===V2?z:W;if(z==="if"||z==="for"||z==="show"){J.clientReactive[z]=_;continue}try{if(!R0(_)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${_}`);J.clientReactive[z]=_;continue}let B=Object.keys(Z),j=M0(_,B)(...Object.values(Z));if(j===void 0){let H=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(H.some((L)=>!O.has(L)&&!B.includes(L))){J.clientReactive[z]=_;continue}}J.serverDynamic[z]=j}catch{J.clientReactive[z]=_}continue}if(typeof W==="string"&&W.includes("{{")&&W.includes("}}")){let z=W.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let _=z[1];if(R0(_)){let q=M0(_,Object.keys(Z))(...Object.values(Z));G(U,q!=null?String(q):"")}else{if(Y.debug)console.error(`Unsafe expression in ${U}: ${_}`);G(U,W)}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${U}:`,_);G(U,W)}else{let _=W,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,q;while((q=B.exec(W))!==null)try{let j=q[1];if(!R0(j)){if(Y.debug)console.error(`Unsafe expression in ${U}: ${j}`);continue}let O=M0(j,Object.keys(Z))(...Object.values(Z));_=_.replace(q[0],String(O??""))}catch(j){if(Y.debug)console.error(`Error evaluating expression in ${U}:`,j)}G(U,_)}continue}G(U,W===V2?"true":W)}return J}function WI($){let Z={},Y=0,J=$.length;while(Y<J){while(Y<J&&/\s/.test($[Y]))Y++;if(Y>=J)break;let X="";while(Y<J&&!/[\s=]/.test($[Y]))X+=$[Y],Y++;if(!X)break;while(Y<J&&/\s/.test($[Y]))Y++;if(Y<J&&$[Y]==="="){Y++;while(Y<J&&/\s/.test($[Y]))Y++;let Q="";if(Y<J&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<J){let K=$[Y];if(K==="\\"&&Y+1<J){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<J&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[X]=Q}else Z[X]=V2}return Z}function Uq($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function UI($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Y.exec($))!==null){let X=J[1];if(R1.isBuiltin(X))Z.add(X)}return[...Z].sort()}function zI($){let Z=zq.get($);if(Z)return Z;let Y=new Map,J=[b1.join($,"src"),b1.join($,"dist"),$];function X(Q,G){if(G>6)return;let K;try{K=iZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=b1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;X(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let z=W.name.slice(0,-4);if(!Y.has(z))Y.set(z,U);let _=z.toLowerCase();if(!Y.has(_))Y.set(_,U);let B=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of J)if(X(Q,0),Y.size>0)break;return zq.set($,Y),Y}function _I($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let J=b1.join(Y,"node_modules",$);try{if(iZ.statSync(J).isDirectory())return J}catch{}let X=b1.dirname(Y);if(X===Y)return null;Y=X}}async function Bq($,Z,Y,J,X){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=b1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,z,_)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=_,j,H=[];while((j=B.exec(_))!==null){let[O,V,L,F]=j,A=null,w=null;if(F.startsWith(".")||F.startsWith("/")){let E=b1.resolve(G,F);if(E.endsWith(".stx"))w=E;else{let M=`${E}.stx`;try{if(iZ.statSync(M).isFile())w=M}catch{try{if(iZ.statSync(E).isDirectory())A=E}catch{}}}}else A=_I(F,G);if(!A&&!w)continue;let N=!1,R=(E,M)=>{Q.set(E,M),Q.set(E.toLowerCase(),M);let I=E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,M),X.add(M)};if(L&&w)R(L,w),N=!0;else if(V){let E=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let S=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(S)return{source:S[1],local:S[2]};return{source:I,local:I}}),M=A?zI(A):null;for(let{source:I,local:S}of E){let k=null;if(w)k=w;else if(M)k=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(k)R(S,k),N=!0}}if(N)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${z}>${q}</script>`}),K}async function BI($,Z,Y,J,X){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,z]=W,_=z.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of _){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[b1.resolve(b1.dirname(Y),`${B}.stx`),b1.resolve(b1.dirname(Y),B),b1.resolve(J.componentsDir||"components",`${B}.stx`),b1.resolve(J.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),X.add(V),J.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function qI($,Z,Y,J,X){let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let z=U.index,_=z+U[0].length-1,B=1,q=_+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(_+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let w={};if(L)try{w=i0(L,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(z,H),`[Error parsing component props: ${k}]`);continue}let N="",R=H,M=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)N=M[1].trim(),R=H+M[0].length;let I=await B4(V,w,N,G,Z,Y,J,K,X);Q=Q.substring(0,z)+I+Q.substring(R),W.lastIndex=0}return Q}async function jI($,Z,Y,J,X){if(!$)return $;let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=o4(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,GI),Q=H7(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=Qq(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],w=H?pZ(A.tagName):A.tagName,N=WI(A.attributes),R=KI(N,Z,J),E=R1.getBuiltin(A.tagName),M=E?await u7(w,G,Z,Y,J):!1;if(E&&!M){let x={context:Z,filePath:Y,options:J,dependencies:X},y=E.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)y=_q(y,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([h,r])=>`${h}="${Uq(r)}"`).join(" ");y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,A.startIndex)+y+V.substring(A.endIndex);continue}if(!H&&A.tagName.includes("-")&&!await u7(w,G,Z,Y,J))continue;let I={};for(let[x,y]of Object.entries(R.static))I[x]=y;for(let[x,y]of Object.entries(R.serverDynamic))I[x]=y;let k=await B4(w,I,A.content,G,Z,Y,J,K,X);if(Object.keys(R.clientReactive).length>0)k=_q(k,R.clientReactive);if(Object.keys(R.events).length>0){let x=qq(k);if(x){let y=Object.entries(R.events).map(([h,r])=>`${h}="${Uq(r)}"`).join(" "),b=Object.keys(R.events).map((h)=>h.replace(/^@/,"").split(".")[0]).join(" ");k=k.substring(0,x.insertPos)+` data-stx-parent-events="${b}" ${y}`+k.substring(x.insertPos)}}V=V.substring(0,A.startIndex)+k+V.substring(A.endIndex)}return V}}function _q($,Z){let Y=new Set(["if","for"]),J=new Set(["show"]),X=Object.entries(Z).filter(([z])=>!Y.has(z)),Q=X.filter(([z])=>!J.has(z)).map(([z])=>pZ(z)).join(" "),G=$,K=X.length>0?qq(G):null;if(K){let z=X.map(([B,q])=>`:${pZ(B)}="${q.replace(/"/g,""")}"`).join(" "),_=Q?` data-stx-parent-bindings="${Q}"`:"";G=G.substring(0,K.insertPos)+`${_} ${z}`+G.substring(K.insertPos)}let W=Z.if;if(W)G=`<template :if="${W.replace(/"/g,""")}">${G}</template>`;let U=Z.for;if(U)G=`<template :for="${U.replace(/"/g,""")}">${G}</template>`;return G}function qq($){let Z=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(Z)return{insertPos:Z.index+1+Z[1].length};let Y=0;while(Y<$.length){let J=$.slice(Y),X=J.match(/^\s+/);if(X){Y+=X[0].length;continue}if(J.startsWith("<!--")){let K=$.indexOf("-->",Y+4);if(K===-1)return null;Y=K+3;continue}let Q=J.match(/^<(script|style)\b[^>]*>/i);if(Q){let K=`</${Q[1].toLowerCase()}>`,W=$.toLowerCase().indexOf(K,Y+Q[0].length);if(W===-1)return null;Y=W+K.length;continue}let G=J.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:Y+1+G[1].length}}return null}async function nZ($,Z,Y,J,X){if(!Wq)Xq(),Wq=!0;let Q=await Bq($,Z,Y,J,X);Q=await BI(Q,Z,Y,J,X),Q=await qI(Q,Z,Y,J,X);let G=[];for(let K=0;K<3;K++){let W=K4(Q,j7,(z,_)=>`\x00STX_COMPONENT_COMMENT_${G.length+_}\x00`);G.push(...W.tokens);let U=Q;if(Q=await jI(W.output,Z,Y,J,X),Q===U)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(K,W)=>G[Number(W)]??"");if(J.debug){let K=UI(Q);if(K.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${K.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var Wq=!1,V2="\x00stx-boolean-attribute",GI,zq;var F2=D(()=>{p9();L2();Kq();f6();N0();n0();GI=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"]);zq=new Map});var sZ={};$0(sZ,{stripTypeScript:()=>Fq,splitDeclaration:()=>Rq,isCompleteImport:()=>Aq,hasVariables:()=>N2,extractVariables:()=>D0,extractScriptFromTemplate:()=>w2,convertToCommonJS:()=>rZ});import u$ from"path";import m7 from"process";function HI($){let Z=[],Y=0,J=$.split(`
|
|
2154
|
+
`||E==="\t")V++;L=N+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){X=B;continue}let A=$.slice(B,F),w=F+O.length;J.push({fullMatch:$.slice(Q,w),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:w,isSelfClosing:!1}),X=w}}return J}function Gq($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var Kq=D(()=>{n0();N0();f6()});var jq={};$0(jq,{processESImports:()=>Bq,processComponents:()=>nZ});import iZ from"fs";import b1 from"path";function KI($,Z,Y){let J={static:{},staticNames:{},serverDynamic:{},clientReactive:{},events:{}},X=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"]),Q=(K)=>{if(!K.includes("-")||K.startsWith("@")||K.startsWith(":")||K.startsWith("x-")||K.startsWith("__"))return K;if(K.startsWith("aria-")||K.startsWith("data-"))return K;return K.replace(/-([a-z0-9])/g,(W,U)=>U.toUpperCase())},G=(K,W)=>{let U=Q(K);if(J.static[U]=W,U!==K)J.staticNames[U]=K};for(let[K,W]of Object.entries($)){let U=K.startsWith("x-")&&!X.has(K)&&!K.startsWith("x-bind:")&&!K.startsWith("x-on:")?`:${K.slice(2)}`:K;if(U.startsWith("@")){J.events[U]=W;continue}if(U.startsWith("__stx_")){let z=Q(U.slice(6));J.serverDynamic[z]=Gq(W,Y);continue}if(U.startsWith(":")){let z=Q(U.slice(1)),_=W===V2?z:W;if(z==="if"||z==="for"||z==="show"){J.clientReactive[z]=_;continue}try{if(!R0(_)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${_}`);J.clientReactive[z]=_;continue}let B=Object.keys(Z),j=M0(_,B)(...Object.values(Z));if(j===void 0){let H=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(H.some((L)=>!O.has(L)&&!B.includes(L))){J.clientReactive[z]=_;continue}}J.serverDynamic[z]=j}catch{J.clientReactive[z]=_}continue}if(typeof W==="string"&&W.includes("{{")&&W.includes("}}")){let z=W.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let _=z[1];if(R0(_)){let q=M0(_,Object.keys(Z))(...Object.values(Z));G(U,q!=null?String(q):"")}else{if(Y.debug)console.error(`Unsafe expression in ${U}: ${_}`);G(U,W)}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${U}:`,_);G(U,W)}else{let _=W,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,q;while((q=B.exec(W))!==null)try{let j=q[1];if(!R0(j)){if(Y.debug)console.error(`Unsafe expression in ${U}: ${j}`);continue}let O=M0(j,Object.keys(Z))(...Object.values(Z));_=_.replace(q[0],String(O??""))}catch(j){if(Y.debug)console.error(`Error evaluating expression in ${U}:`,j)}G(U,_)}continue}G(U,W===V2?"true":W)}return J}function WI($){let Z={},Y=0,J=$.length;while(Y<J){while(Y<J&&/\s/.test($[Y]))Y++;if(Y>=J)break;let X="";while(Y<J&&!/[\s=]/.test($[Y]))X+=$[Y],Y++;if(!X)break;while(Y<J&&/\s/.test($[Y]))Y++;if(Y<J&&$[Y]==="="){Y++;while(Y<J&&/\s/.test($[Y]))Y++;let Q="";if(Y<J&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<J){let K=$[Y];if(K==="\\"&&Y+1<J){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<J&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[X]=Q}else Z[X]=V2}return Z}function Uq($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function UI($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Y.exec($))!==null){let X=J[1];if(R1.isBuiltin(X))Z.add(X)}return[...Z].sort()}function zI($){let Z=zq.get($);if(Z)return Z;let Y=new Map,J=[b1.join($,"src"),b1.join($,"dist"),$];function X(Q,G){if(G>6)return;let K;try{K=iZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=b1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;X(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let z=W.name.slice(0,-4);if(!Y.has(z))Y.set(z,U);let _=z.toLowerCase();if(!Y.has(_))Y.set(_,U);let B=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of J)if(X(Q,0),Y.size>0)break;return zq.set($,Y),Y}function _I($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let J=b1.join(Y,"node_modules",$);try{if(iZ.statSync(J).isDirectory())return J}catch{}let X=b1.dirname(Y);if(X===Y)return null;Y=X}}async function Bq($,Z,Y,J,X){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=b1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,z,_)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=_,j,H=[];while((j=B.exec(_))!==null){let[O,V,L,F]=j,A=null,w=null;if(F.startsWith(".")||F.startsWith("/")){let E=b1.resolve(G,F);if(E.endsWith(".stx"))w=E;else{let M=`${E}.stx`;try{if(iZ.statSync(M).isFile())w=M}catch{try{if(iZ.statSync(E).isDirectory())A=E}catch{}}}}else A=_I(F,G);if(!A&&!w)continue;let N=!1,R=(E,M)=>{Q.set(E,M),Q.set(E.toLowerCase(),M);let I=E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,M),X.add(M)};if(L&&w)R(L,w),N=!0;else if(V){let E=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let S=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(S)return{source:S[1],local:S[2]};return{source:I,local:I}}),M=A?zI(A):null;for(let{source:I,local:S}of E){let k=null;if(w)k=w;else if(M)k=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(k)R(S,k),N=!0}}if(N)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${z}>${q}</script>`}),K}async function BI($,Z,Y,J,X){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,z]=W,_=z.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of _){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[b1.resolve(b1.dirname(Y),`${B}.stx`),b1.resolve(b1.dirname(Y),B),b1.resolve(J.componentsDir||"components",`${B}.stx`),b1.resolve(J.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),X.add(V),J.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function qI($,Z,Y,J,X){let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let z=U.index,_=z+U[0].length-1,B=1,q=_+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(_+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let w={};if(L)try{w=i0(L,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(z,H),`[Error parsing component props: ${k}]`);continue}let N="",R=H,M=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)N=M[1].trim(),R=H+M[0].length;let I=await B4(V,w,N,G,Z,Y,J,K,X);Q=Q.substring(0,z)+I+Q.substring(R),W.lastIndex=0}return Q}async function jI($,Z,Y,J,X){if(!$)return $;let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=o4(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,GI),Q=H7(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=Qq(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],w=H?pZ(A.tagName):A.tagName,N=WI(A.attributes),R=KI(N,Z,J),E=R1.getBuiltin(A.tagName),M=E?await u7(w,G,Z,Y,J):!1;if(E&&!M){let x={context:Z,filePath:Y,options:J,dependencies:X},y=E.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)y=_q(y,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([h,r])=>`${h}="${Uq(r)}"`).join(" ");y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,A.startIndex)+y+V.substring(A.endIndex);continue}if(!H&&A.tagName.includes("-")&&!await u7(w,G,Z,Y,J))continue;let I={};for(let[x,y]of Object.entries(R.static))I[x]=y;for(let[x,y]of Object.entries(R.serverDynamic))I[x]=y;let k=await B4(w,I,A.content,G,Z,Y,J,K,X);if(Object.keys(R.clientReactive).length>0)k=_q(k,R.clientReactive);if(Object.keys(R.events).length>0){let x=qq(k);if(x){let y=Object.entries(R.events).map(([h,r])=>`${h}="${Uq(r)}"`).join(" "),b=Object.keys(R.events).map((h)=>h.replace(/^@/,"").split(".")[0]).join(" ");k=k.substring(0,x.insertPos)+` data-stx-parent-events="${b}" ${y}`+k.substring(x.insertPos)}}V=V.substring(0,A.startIndex)+k+V.substring(A.endIndex)}return V}}function _q($,Z){let Y=new Set(["if","for"]),J=new Set(["show"]),X=Object.entries(Z).filter(([z])=>!Y.has(z)),Q=X.filter(([z])=>!J.has(z)).map(([z])=>pZ(z)).join(" "),G=$,K=X.length>0?qq(G):null;if(K){let z=X.map(([B,q])=>`:${pZ(B)}="${q.replace(/"/g,""")}"`).join(" "),_=Q?` data-stx-parent-bindings="${Q}"`:"";G=G.substring(0,K.insertPos)+`${_} ${z}`+G.substring(K.insertPos)}let W=Z.if;if(W)G=`<template :if="${W.replace(/"/g,""")}">${G}</template>`;let U=Z.for;if(U)G=`<template :for="${U.replace(/"/g,""")}">${G}</template>`;return G}function qq($){let Z=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(Z)return{insertPos:Z.index+1+Z[1].length};let Y=0;while(Y<$.length){let J=$.slice(Y),X=J.match(/^\s+/);if(X){Y+=X[0].length;continue}if(J.startsWith("<!--")){let K=$.indexOf("-->",Y+4);if(K===-1)return null;Y=K+3;continue}let Q=J.match(/^<(script|style)\b[^>]*>/i);if(Q){let K=`</${Q[1].toLowerCase()}>`,W=$.toLowerCase().indexOf(K,Y+Q[0].length);if(W===-1)return null;Y=W+K.length;continue}let G=J.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:Y+1+G[1].length}}return null}async function nZ($,Z,Y,J,X){if(!Wq)Xq(),Wq=!0;let Q=await Bq($,Z,Y,J,X);Q=await BI(Q,Z,Y,J,X),Q=await qI(Q,Z,Y,J,X);let G=[];for(let K=0;K<3;K++){let W=K4(Q,j7,(z,_)=>`\x00STX_COMPONENT_COMMENT_${G.length+_}\x00`);G.push(...W.tokens);let U=Q;if(Q=await jI(W.output,Z,Y,J,X),Q===U)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(K,W)=>G[Number(W)]??"");if(J.debug){let K=UI(Q);if(K.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${K.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var Wq=!1,V2="\x00stx-boolean-attribute",GI,zq;var F2=D(()=>{p9();L2();Kq();f6();N0();n0();GI=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"]);zq=new Map});var aZ={};$0(aZ,{stripTypeScript:()=>Fq,splitDeclaration:()=>Rq,isCompleteImport:()=>Aq,hasVariables:()=>N2,extractVariables:()=>D0,extractScriptFromTemplate:()=>w2,convertToCommonJS:()=>rZ});import u$ from"path";import m7 from"process";function HI($){let Z=[],Y=0,J=$.split(`
|
|
2155
2155
|
`);for(let X of J){let Q=Y,G=null,K=!1;for(let W=0;W<X.length;W++){let U=X[W];if(K){K=!1;continue}if(U==="\\"){K=!0;continue}if(G){if(U===G)G=null;continue}if(U==="'"||U==='"'||U==="`"){G=U;continue}if(U==="/"&&W+1<X.length&&X[W+1]==="/")break;if(U==="{")Y++;else if(U==="}")Y--}if(Q===0){let W=X.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)Z.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(X)){let U=X.match(/(?:const|let|var)\s+(\w+)/);if(U)Z.push(U[1])}else{let U=X.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(U){let _=U[1].slice(1,-1).split(",").map((B)=>{let q=B.split(":");return(q.length>1?q[1]:q[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(..._)}}}}return[...new Set(Z)]}function Fq($){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(J){if(!J.includes(":"))return J;let X=[],Q="",G=0,K=0,W=null;for(let U=0;U<J.length;U++){let z=J[U];if(W){if(Q+=z,z===W)W=null;continue}if(z==='"'||z==="'"||z==="`"){W=z,Q+=z;continue}if(z==="<")G++;else if(z===">"&&G>0)G--;else if(z==="(")K++;else if(z===")")K--;if(z===","&&G===0&&K===0){X.push(Q),Q="";continue}Q+=z}if(Q)X.push(Q);return X.map((U)=>{let z=U.trim(),_=z.startsWith("..."),B=_?z.slice(3):z,q=-1,j=0;for(let w=0;w<B.length;w++)if(B[w]==="<")j++;else if(B[w]===">")j--;else if(B[w]===":"&&j===0){q=w;break}if(q===-1)return U;let O=B.substring(0,q).trim().replace(/\?$/,""),V=B.substring(q+1),L=-1,F=0;for(let w=0;w<V.length;w++)if(V[w]==="<")F++;else if(V[w]===">")F--;else if(V[w]==="="&&F===0){L=w;break}let A=_?"...":"";if(L!==-1)return`${A}${O} = ${V.substring(L+1).trim()}`;return`${A}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(J,X,Q)=>{if(!Q.includes(":"))return J;return`${X}(${Y(Q)})`});{let J=/\b(function\s+\w*\s*)\(/g,X,Q=[];while((X=J.exec(Z))!==null){let G=X.index+X[0].length-1,K=1,W=G+1,U=0,z=null;while(W<Z.length&&K>0){let q=Z[W];if(z){if(q===z)z=null;W++;continue}if(q==='"'||q==="'"||q==="`"){z=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let _=Z.substring(G+1,W);if(!_.includes(":"))continue;let B=Y(_);Q.push({start:G+1,end:W,replacement:B})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(J,X)=>{if(!X.includes(":"))return J;if(X.includes("{")||X.includes("}"))return J;return`(${X.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).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,`
|
|
2156
2156
|
|
|
2157
|
-
`),Z}async function D0($,Z,Y,J={}){if(!$.trim())return;let X;try{let v=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()}),C=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");C=C.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=v.transformSync(C)}catch{X=Fq($)}let Q={exports:{}},G=Q.exports,K=m7.cwd(),W={},U=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((v)=>v[1]).filter((v)=>!v.startsWith("node:")&&!v.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(v));for(let v of U)try{let C=u$.resolve(K,"node_modules",v),u=u$.join(C,"package.json"),e=JSON.parse(Z0("fs").readFileSync(u,"utf8")),n=e.main||"index.js";if(e.exports){let j0=typeof e.exports==="string"?e.exports:e.exports["."];if(typeof j0==="string")n=j0;else if(j0?.bun)n=j0.bun;else if(j0?.import)n=j0.import;else if(j0?.default)n=j0.default}W[v]=await import(u$.resolve(C,n))}catch{}let z=(v)=>{if(W[v])return W[v];return Z0(v)},_=Z.props||{},B=(v)=>{if(!v)return _;let C={};for(let[u,e]of Object.entries(v)){let n=_[u];if(n!==void 0)C[u]=n;else if(typeof e==="function")C[u]=e();else C[u]=e}return C};for(let[v,C]of Object.entries(_))Object.defineProperty(B,v,{value:C,enumerable:!0,configurable:!0,writable:!0});for(let v of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(_,v))continue;try{Object.defineProperty(B,v,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let q=(v)=>{if(!v)return _;let C={..._};for(let[u,e]of Object.entries(v)){let n=e&&typeof e==="object"&&!Array.isArray(e)?e:{type:e};if(C[u]===void 0&&n.default!==void 0)C[u]=typeof n.default==="function"?n.default():n.default}return C},j=()=>Z.slots||{},H=(v,C)=>{let u={...v};for(let[e,n]of Object.entries(C))if(u[e]===void 0)if(typeof n==="function")u[e]=n();else u[e]=n;return u},O=(v)=>{let C=()=>v;return C.set=(u)=>{},C.update=(u)=>{},C},V=(v)=>{let C,u=!1;return()=>{if(!u)try{C=v(),u=!0}catch{C=void 0}return C}},L=(v)=>{},F=(v)=>v(),A=(v)=>{},w=(v)=>{},N=(v)=>{},R=()=>{let v=Z.__stxServeContext,C=Z.__stxServeSearch??v?.search??"",u=v?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(C)),path:u,name:"",fullPath:u+C,hash:"",matched:[]}},E=()=>({push:(v)=>{},replace:(v)=>{},back:()=>{},forward:()=>{},go:(v)=>{}}),M=(v)=>{let C=Z.__stx_runtime_head||{};Z.__stx_runtime_head=l6(C,v||{})},I=(v)=>{M(C7(v||{}))},S=(v)=>({value:v}),k=(v)=>v,x=(v)=>({value:typeof v==="function"?v():v}),y=(v,C)=>{},b=(v)=>{},h=(v)=>{},r=(v)=>v?v():Promise.resolve(),m=(v)=>(C,...u)=>{},P=(v)=>{},d=(v,C)=>{},l=(v,C)=>C,c=()=>({value:"light"}),
|
|
2157
|
+
`),Z}async function D0($,Z,Y,J={}){if(!$.trim())return;let X;try{let v=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()}),C=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");C=C.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=v.transformSync(C)}catch{X=Fq($)}let Q={exports:{}},G=Q.exports,K=m7.cwd(),W={},U=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((v)=>v[1]).filter((v)=>!v.startsWith("node:")&&!v.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(v));for(let v of U)try{let C=u$.resolve(K,"node_modules",v),u=u$.join(C,"package.json"),e=JSON.parse(Z0("fs").readFileSync(u,"utf8")),n=e.main||"index.js";if(e.exports){let j0=typeof e.exports==="string"?e.exports:e.exports["."];if(typeof j0==="string")n=j0;else if(j0?.bun)n=j0.bun;else if(j0?.import)n=j0.import;else if(j0?.default)n=j0.default}W[v]=await import(u$.resolve(C,n))}catch{}let z=(v)=>{if(W[v])return W[v];return Z0(v)},_=Z.props||{},B=(v)=>{if(!v)return _;let C={};for(let[u,e]of Object.entries(v)){let n=_[u];if(n!==void 0)C[u]=n;else if(typeof e==="function")C[u]=e();else C[u]=e}return C};for(let[v,C]of Object.entries(_))Object.defineProperty(B,v,{value:C,enumerable:!0,configurable:!0,writable:!0});for(let v of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(_,v))continue;try{Object.defineProperty(B,v,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let q=(v)=>{if(!v)return _;let C={..._};for(let[u,e]of Object.entries(v)){let n=e&&typeof e==="object"&&!Array.isArray(e)?e:{type:e};if(C[u]===void 0&&n.default!==void 0)C[u]=typeof n.default==="function"?n.default():n.default}return C},j=()=>Z.slots||{},H=(v,C)=>{let u={...v};for(let[e,n]of Object.entries(C))if(u[e]===void 0)if(typeof n==="function")u[e]=n();else u[e]=n;return u},O=(v)=>{let C=()=>v;return C.set=(u)=>{},C.update=(u)=>{},C},V=(v)=>{let C,u=!1;return()=>{if(!u)try{C=v(),u=!0}catch{C=void 0}return C}},L=(v)=>{},F=(v)=>v(),A=(v)=>{},w=(v)=>{},N=(v)=>{},R=()=>{let v=Z.__stxServeContext,C=Z.__stxServeSearch??v?.search??"",u=v?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(C)),path:u,name:"",fullPath:u+C,hash:"",matched:[]}},E=()=>({push:(v)=>{},replace:(v)=>{},back:()=>{},forward:()=>{},go:(v)=>{}}),M=(v)=>{let C=Z.__stx_runtime_head||{};Z.__stx_runtime_head=l6(C,v||{})},I=(v)=>{M(C7(v||{}))},S=(v)=>({value:v}),k=(v)=>v,x=(v)=>({value:typeof v==="function"?v():v}),y=(v,C)=>{},b=(v)=>{},h=(v)=>{},r=(v)=>v?v():Promise.resolve(),m=(v)=>(C,...u)=>{},P=(v)=>{},d=(v,C)=>{},l=(v,C)=>C,c=()=>({value:"light"}),a=()=>O(!1),X0=(v)=>O(!1),K0=()=>O(!1),C0=()=>X0("(prefers-color-scheme: dark)"),z1=()=>X0("(prefers-color-scheme: light)"),b0=()=>X0("(prefers-reduced-motion: reduce)"),l1=()=>X0("(prefers-contrast: more)"),W0={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:{}},p=new Proxy(W0,{get(v,C){if(C in v)return v[C];return},set(v,C,u){return v[C]=u,!0}}),t={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},_0=console;try{let v=rZ(X,Y),C=new Set(Object.keys(_)),u=(J0)=>/^[a-z_$][\w$]*$/i.test(J0),e=Object.keys(Z).filter((J0)=>!C.has(J0)&&J0!=="props"&&u(J0)),n=e.map((J0)=>Z[J0]),j0=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"]),I0=[],g0=[];for(let[J0,x0]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(J0))continue;if(j0.has(J0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${J0}\\b`).test(v))continue;I0.push(J0),g0.push(x0)}let S0=HI(v).map((J0)=>`module.exports.${J0} = typeof ${J0} !== 'undefined' ? ${J0} : module.exports.${J0};`).join(`
|
|
2158
2158
|
`),k1=Z.params??{},L1=[],V1=[];for(let J0=0;J0<e.length;J0++){if(e[J0]==="params")continue;L1.push(e[J0]),V1.push(n[J0])}let B0=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","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params",...I0,...L1,`return (async () => {
|
|
2159
2159
|
${v}
|
|
2160
2160
|
${S0}
|
|
2161
2161
|
return module.exports
|
|
2162
|
-
})()`)(Q,G,z,_,B,q,H,O,V,L,F,A,w,N,R,E,M,I,S,k,x,y,b,h,r,m,P,j,d,l,c,
|
|
2162
|
+
})()`)(Q,G,z,_,B,q,H,O,V,L,F,A,w,N,R,E,M,I,S,k,x,y,b,h,r,m,P,j,d,l,c,a,X0,K0,C0,z1,b0,l1,p,t,_0,W0.confirm,W0.alert,W0.fetch,k1,...g0,...V1);if(J.preserveExisting){for(let[J0,x0]of Object.entries(B0))if(!(J0 in Z)||Z[J0]===void 0)Z[J0]=x0}else Object.assign(Z,B0);for(let[J0,x0]of Object.entries(_))if(!(J0 in Z))Z[J0]=x0}catch(v){if(m7.env.STX_DEBUG){let C=v instanceof Error?v.message:String(v);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${C}`)}try{await AI(X,Z,Y)}catch(C){if(m7.env.STX_DEBUG){let u=C instanceof Error?C.message:String(C);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${u}`)}}}}function Aq($){let Z=0,Y=null,J=!1,X=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(Y){if(G===Y){if(Y=null,J||Z===0)X=!0}continue}if(G==="'"||G==='"'||G==="`"){Y=G;continue}if(G==="{")Z++;else if(G==="}")Z--;else if($.startsWith("from",Q)&&Z===0)J=!0}return Y===null&&Z===0&&X}function rZ($,Z){let Y=Z?u$.dirname(Z):m7.cwd(),J=$.split(`
|
|
2163
2163
|
`),X=[],Q=0;while(Q<J.length){let G=J[Q].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(;Q<J.length;Q++){for(let W of J[Q])if(W==="{")K++;else if(W==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,W=!1;for(let U=Q;U<J.length&&!W;U++){let z=null,_=!1,B=J[U];for(let q=0;q<B.length;q++){let j=B[q];if(_){_=!1;continue}if(j==="\\"){_=!0;continue}if(z){if(j===z)z=null;continue}if(j==='"'||j==="'"||j==="`"){z=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=U+1,W=!0;break}}}}if(!W)Q=J.length;continue}if(G.startsWith("import ")||G==="import"||G.startsWith("import{")){let K=G,W=0;while(!Aq(K)&&Q+W+1<J.length)W++,K=`${K} ${J[Q+W].trim()}`;Q+=W;let U=K.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),z=K.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),_=K.match(/^import\s+['"](.+?)['"]/),B=K,q=(j)=>{if(j.startsWith("."))return u$.resolve(Y,j);return j};if(U){let[,j,H]=U,O=q(H);X.push(`const ${j} = await import('${O}')`),X.push(`module.exports.${j} = ${j};`)}else if(z){let[,j,H]=z,O=j.trim(),V=q(H);X.push(`const { ${O} } = await import('${V}')`);for(let L of O.split(",")){let F=L.trim().split(/\s+as\s+/).pop()?.trim();if(F)X.push(`module.exports.${F} = ${F};`)}}else if(_){let j=q(_[1]);X.push(`await import('${j}')`)}else X.push(B);Q++;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("="))X.push(J[Q]),Q++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=Hq(J,Q),{type:W,name:U,value:z}=K;X.push(`${W} ${U} = ${z};`),X.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=A2(J,Q);X.push(K.functionCode),X.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=Hq(J,Q),{type:W,name:U,value:z}=K;X.push(`${W} ${U} = ${z};`),X.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=A2(J,Q);X.push(K.functionCode),X.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=J[Q].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...J];W[Q]=K;let U=A2(W,Q);if(X.push(U.functionCode),U.name)X.push(`module.exports.default = ${U.name};`);Q=U.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");X.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let W=K[1],U=J[Q].replace(/^export\s+/,""),z=0,_=Q;for(;_<J.length;_++){let B=J[_];for(let q of B)if(q==="{")z++;else if(q==="}")z--;if(_>Q)U+=`
|
|
2164
2164
|
`+B;if(z<=0&&_>=Q)break}X.push(U),X.push(`module.exports.${W} = ${W};`),Q=_+1}else X.push(G),Q++}else if(G.includes("module.exports"))X.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))X.push(G),Q++;else Q++}return OI(X.join(`
|
|
2165
2165
|
`),Y)}function OI($,Z){let Y=$.length,J="",X=0,Q=null,G=!1,K=!1,W=0;while(X<Y){let U=$[X],z=$[X+1];if(G){if(J+=U,U===`
|
|
2166
|
-
`)G=!1;X++;continue}if(K){if(J+=U,U==="*"&&z==="/"){J+=z,X+=2,K=!1;continue}X++;continue}if(!Q&&U==="/"&&z==="/"){G=!0,J+=U,X++;continue}if(!Q&&U==="/"&&z==="*"){K=!0,J+=U,X++;continue}if(Q){if(J+=U,U==="\\"){J+=z,X+=2;continue}if(U===Q&&Q!=="`"){Q=null,X++;continue}if(Q==="`"){if(U==="$"&&z==="{"){W++,J+=z,X+=2;continue}if(U==="`"){Q=null,X++;continue}}X++;continue}if(W>0){if(U==="{")W++;else if(U==="}")W--}if(U==='"'||U==="'"||U==="`"){Q=U,J+=U,X++;continue}if(U==="a"&&$.startsWith("await",X)){let _=LI($,X);if(_){let{quote:B,path:q,end:j}=_;if(q.startsWith(".")){let H=u$.resolve(Z,q);J+=`await import(${B}${H}${B})`,X=j;continue}}}J+=U,X++}return J}function LI($,Z){let Y=Z+5;if(Y>=$.length)return null;if(!/\s/.test($[Y]))return null;while(Y<$.length&&/\s/.test($[Y]))Y++;if(!$.startsWith("import",Y))return null;Y+=6;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;let J=$[Y];if(J!=="'"&&J!=='"')return null;Y++;let X=Y;while(Y<$.length&&$[Y]!==J)if($[Y]==="\\")Y+=2;else Y++;if(Y>=$.length)return null;let Q=$.slice(X,Y);Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!==")")return null;return{quote:J,path:Q,end:Y+1}}function wq($,Z){let Y=$[Z];if(Y!=="{"&&Y!=="[")return null;let X=
|
|
2166
|
+
`)G=!1;X++;continue}if(K){if(J+=U,U==="*"&&z==="/"){J+=z,X+=2,K=!1;continue}X++;continue}if(!Q&&U==="/"&&z==="/"){G=!0,J+=U,X++;continue}if(!Q&&U==="/"&&z==="*"){K=!0,J+=U,X++;continue}if(Q){if(J+=U,U==="\\"){J+=z,X+=2;continue}if(U===Q&&Q!=="`"){Q=null,X++;continue}if(Q==="`"){if(U==="$"&&z==="{"){W++,J+=z,X+=2;continue}if(U==="`"){Q=null,X++;continue}}X++;continue}if(W>0){if(U==="{")W++;else if(U==="}")W--}if(U==='"'||U==="'"||U==="`"){Q=U,J+=U,X++;continue}if(U==="a"&&$.startsWith("await",X)){let _=LI($,X);if(_){let{quote:B,path:q,end:j}=_;if(q.startsWith(".")){let H=u$.resolve(Z,q);J+=`await import(${B}${H}${B})`,X=j;continue}}}J+=U,X++}return J}function LI($,Z){let Y=Z+5;if(Y>=$.length)return null;if(!/\s/.test($[Y]))return null;while(Y<$.length&&/\s/.test($[Y]))Y++;if(!$.startsWith("import",Y))return null;Y+=6;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;let J=$[Y];if(J!=="'"&&J!=='"')return null;Y++;let X=Y;while(Y<$.length&&$[Y]!==J)if($[Y]==="\\")Y+=2;else Y++;if(Y>=$.length)return null;let Q=$.slice(X,Y);Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!==")")return null;return{quote:J,path:Q,end:Y+1}}function wq($,Z){let Y=$[Z];if(Y!=="{"&&Y!=="[")return null;let X=a0($,Y,Y==="{"?"}":"]",Z);if(X===-1)return null;return{pattern:$.slice(Z,X+1),endPos:X+1}}function Nq($){let Z=[],Y=$.slice(1,-1).trim();if(!Y)return Z;let J=0,X=0,Q="";while(J<Y.length){let G=Y[J];if(G==="{"||G==="["){if(X++,X===1){let K=wq(Y,J);if(K){let W=Nq(K.pattern);Z.push(...W),J=K.endPos,Q="";continue}}}else if(G==="}"||G==="]")X--;if(X>0){J++;continue}if(G===","){if(Q.trim())Z.push(Q.trim());Q="",J++;continue}if(G===":"){Q="",J++;continue}if(G==="="){if(Q.trim())Z.push(Q.trim());Q="",J++;while(J<Y.length&&Y[J]!==","&&X===0){if(Y[J]==="{"||Y[J]==="[")X++;else if(Y[J]==="}"||Y[J]==="]")X--;J++}continue}if(/[\w$]/.test(G))Q+=G;J++}if(Q.trim())Z.push(Q.trim());return Z}function Rq($){let Z=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec($);if(!Z)return null;let Y=Z[0].length,J=(X)=>X===" "||X==="\t";while(Y<$.length&&J($[Y]))Y++;if($[Y]===":"){let X=0,Q=null;Y++;for(;Y<$.length;Y++){let G=$[Y];if(Q){if(G==="\\"){Y++;continue}if(G===Q)Q=null;continue}if(G==="'"||G==='"'||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{"||G==="<"){X++;continue}if(G===")"||G==="]"||G==="}"||G===">"){X--;continue}if(G==="="&&X<=0){let K=$[Y+1],W=$[Y-1];if(K!=="="&&K!==">"&&W!=="="&&W!=="!"&&W!=="<"&&W!==">")break}}if($[Y]!=="=")return null}while(Y<$.length&&J($[Y]))Y++;if($[Y]!=="=")return null;return{type:Z[1],name:Z[2],value:$.slice(Y+1).trim()}}function Hq($,Z){let Y=$[Z].trim(),J=Rq(Y),X=J?[Y,J.type,J.name,J.value]:null;if(!X){let z=Y.match(/^(?:export\s+)?(const|let|var)\s+/);if(z){let _=Y.slice(z[0].length),B=Z;if((_.startsWith("{")||_.startsWith("["))&&!_.includes(_.startsWith("{")?"}":"]")){let j=_.startsWith("{")?"}":"]",H=_;for(let O=Z+1;O<$.length;O++)if(H+=" "+$[O].trim(),B=O,$[O].includes(j))break;_=H}let q=wq(_,0);if(q){let j=z[1],H=q.pattern,O=_.slice(q.endPos).trim();if(O.startsWith("=")){let V=O.slice(1).trim(),L=V,F=Math.max(B,Z);if(Oq(V)){let R=Lq($,F,V);L=R.value,F=R.nextIndex}else F=F+1;L=L.trim().replace(/;$/,"");let A=Nq(H),w=`__stx_src_${Z}`,N=A.map((R)=>`module.exports.${R} = ${R};`).join(`
|
|
2167
2167
|
`);return{type:j,name:w,value:`${L}; ${j} ${H} = ${w};
|
|
2168
2168
|
${N}`,nextIndex:F}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}let[,Q,G,K]=X,W=K,U=Z;if(Oq(K)){let z=Lq($,Z,K);W=z.value,U=z.nextIndex}else U=Z+1;while(U<$.length){let z=$[U].trim();if(z.startsWith(".")||z.startsWith("?."))W+=`
|
|
2169
|
-
${$[U]}`,U++;else break}return W=W.trim().replace(/;$/,""),{type:Q,name:G,value:W,nextIndex:U}}function A2($,Z){let Y=$[Z].trim(),J=Y.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!J)throw Error(`Failed to parse function declaration: ${Y}`);let[,X]=J,Q=Y.replace(/^export\s+/,""),G=Z;if(VI(Y)){let K=FI($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:X,functionCode:Q,nextIndex:G}}function Oq($){let Z=$.trim();if(Z.startsWith("{"))return
|
|
2169
|
+
${$[U]}`,U++;else break}return W=W.trim().replace(/;$/,""),{type:Q,name:G,value:W,nextIndex:U}}function A2($,Z){let Y=$[Z].trim(),J=Y.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!J)throw Error(`Failed to parse function declaration: ${Y}`);let[,X]=J,Q=Y.replace(/^export\s+/,""),G=Z;if(VI(Y)){let K=FI($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:X,functionCode:Q,nextIndex:G}}function Oq($){let Z=$.trim();if(Z.startsWith("{"))return a0(Z,"{","}",0)===-1;if(Z.startsWith("["))return a0(Z,"[","]",0)===-1;return!Mq(Z)}function Mq($){let Z={paren:0,bracket:0,brace:0},Y=null,J=0;for(let X=0;X<$.length;X++){let Q=$[X];if((X>0?$[X-1]:"")==="\\"&&Y)continue;if((Q==='"'||Q==="'")&&!Y){Y=Q;continue}if(Q===Y&&Y!=="`"){Y=null;continue}if(Q==="`"&&!Y){Y="`";continue}if(Q==="`"&&Y==="`"&&J===0){Y=null;continue}if(Y==="`"&&Q==="$"&&$[X+1]==="{"){J++,X++;continue}if(J>0&&Q==="{"){J++;continue}if(J>0&&Q==="}"){J--;continue}if(Y)continue;if(Q==="(")Z.paren++;else if(Q===")")Z.paren--;else if(Q==="[")Z.bracket++;else if(Q==="]")Z.bracket--;else if(Q==="{")Z.brace++;else if(Q==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function VI($){let Z=$.indexOf("{");if(Z===-1)return!0;return a0($,"{","}",Z)===-1}function Lq($,Z,Y){let J=Y,X=Z+1;while(X<$.length&&!Mq(J)){let Q=$[X];J+=`
|
|
2170
2170
|
${Q}`,X++}while(X<$.length){let Q=$[X].trim();if(Q.startsWith(".")||Q.startsWith("?."))J+=`
|
|
2171
|
-
${$[X]}`,X++;else break}return{value:J,nextIndex:X}}function FI($,Z,Y){let J=Y,X=Z+1;while(X<$.length){let Q=J.indexOf("{");if(Q!==-1){if(
|
|
2172
|
-
${G}`,X++}return{functionCode:J,nextIndex:X}}function Vq($,Z){let Y=V0($,Z)??V0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let J={...Z,process:Object.freeze({env:{...m7.env}})};try{return Function(...Object.keys(J),`'use strict'; return (${$});`)(...Object.values(J))}catch{try{return Function(...Object.keys(J),`'use strict'; return ${$};`)(...Object.values(J))}catch{return}}}async function AI($,Z,Y){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of J){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=Vq(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let X=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of X){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=Vq(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function w2($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",J=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:J}}function N2($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var K6=D(()=>{c6();p4();n0()});var Cq={};$0(Cq,{processLoops:()=>eZ});function RI($,Z){let Y=/@component\s*\(/g,J=$,X,Q=[];while((X=Y.exec(J))!==null){let G=X.index,K=G+X[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let z=J.substring(K+1,U),_=U+1,B=z.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let q=B[1],j=z.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let V=i0(O,Z),L=JSON.stringify(V),F=`@component('${q}', ${L})`;Q.push({start:G,end:_,replacement:F})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];J=J.substring(0,K)+U+J.substring(W)}return J}function
|
|
2171
|
+
${$[X]}`,X++;else break}return{value:J,nextIndex:X}}function FI($,Z,Y){let J=Y,X=Z+1;while(X<$.length){let Q=J.indexOf("{");if(Q!==-1){if(a0(J,"{","}",Q)!==-1)break}let G=$[X];J+=`
|
|
2172
|
+
${G}`,X++}return{functionCode:J,nextIndex:X}}function Vq($,Z){let Y=V0($,Z)??V0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let J={...Z,process:Object.freeze({env:{...m7.env}})};try{return Function(...Object.keys(J),`'use strict'; return (${$});`)(...Object.values(J))}catch{try{return Function(...Object.keys(J),`'use strict'; return ${$};`)(...Object.values(J))}catch{return}}}async function AI($,Z,Y){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of J){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=Vq(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let X=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of X){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=Vq(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function w2($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",J=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:J}}function N2($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var K6=D(()=>{c6();p4();n0()});var Cq={};$0(Cq,{processLoops:()=>eZ});function RI($,Z){let Y=/@component\s*\(/g,J=$,X,Q=[];while((X=Y.exec(J))!==null){let G=X.index,K=G+X[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let z=J.substring(K+1,U),_=U+1,B=z.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let q=B[1],j=z.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let V=i0(O,Z),L=JSON.stringify(V),F=`@component('${q}', ${L})`;Q.push({start:G,end:_,replacement:F})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];J=J.substring(0,K)+U+J.substring(W)}return J}function sZ($,Z,Y){let J=$,X=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=X.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,z=null,_=!1;while(U<J.length&&W>0){let j=J[U];if(_){_=!1,U++;continue}if(j==="\\"&&z){_=!0,U++;continue}if(z){if(j===z)z=null;U++;continue}if(j==='"'||j==="'"||j==="`"){z=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let B=J.substring(K+1,U),q=Y(B);J=J.substring(0,G)+q+J.substring(U+1)}return J}function MI($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,X)=>{if(X in Z)return`:${X}="${X}"`;return J}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,X,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);JZ(Q);let U=M0(Q,G)(...K),z=JSON.stringify(U),_=Buffer.from(z,"utf8").toString("base64");return`__stx_${X}="${_}"`}catch(G){return J}}),Y}function TI($,Z){let Y=$;return Y=sZ(Y,"@break",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(R0(Q)){let K=M0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(V0(Q,Z));return G?oZ:""}catch{return""}}),Y=sZ(Y,"@continue",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(R0(Q)){let K=M0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(V0(Q,Z));return G?tZ:""}catch{return""}}),Y}function EI($){let Z=$;return Z=Z.replace(/@break(?!\()/g,oZ),Z=Z.replace(/@continue(?!\()/g,tZ),Z}function Tq($){let Z=$.includes(oZ),Y=Z?$.substring(0,$.indexOf(oZ)):$;return{hasBreak:Z,content:Y}}function Eq($){let Z=$.includes(tZ),Y=Z?$.substring(0,$.indexOf(tZ)):$;return{hasContinue:Z,content:Y}}function Dq($){let Z=$;return Z=sZ(Z,"@break",(Y)=>{let J=Y.trim();if(!XZ(J))return"";return`\`; if (${J}) { break; } result += \``}),Z=sZ(Z,"@continue",(Y)=>{let J=Y.trim();if(!XZ(J))return"";return`\`; if (${J}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function II($){let Z=/@forelse\s*\(/g,Y,J=[],X=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=X.exec($))!==null)J.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,_)=>z.pos-_.pos);let K=[],W=0;for(let z of J)W+=z.delta,K.push({pos:z.pos,depth:W});function U(z){let _=0,B=K.length-1,q=0;while(_<=B){let j=_+B>>1;if(K[j].pos<=z)q=K[j].depth,_=j+1;else B=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let z=Y.index,_=Y.index+Y[0].length-1,B=1,q=_+1,j=-1;while(q<$.length&&B>0){if($[q]==="(")B++;else if($[q]===")"){if(B--,B===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(_+1,j),O=H.indexOf(" as ");if(O===-1)continue;let V=H.substring(0,O).trim(),L=H.substring(O+4).trim(),F=j+1,A=1,w=F,N=/@forelse\s*\(/g,R=/@endforelse/g,E=-1;while(A>0&&w<$.length){N.lastIndex=w,R.lastIndex=w;let y=N.exec($),b=R.exec($);if(!b)break;if(y&&y.index<b.index)A++,w=y.index+y[0].length;else{if(A--,A===0){E=b.index;break}w=b.index+11}}if(E===-1)continue;let M=$.substring(F,E),I=E+11,S=-1,k=0,x=0;while(x<M.length){let y=M.indexOf("@",x);if(y===-1)break;let b=M.substring(y);if(/^@forelse\s*\(/.test(b))k++,x=y+1;else if(b.startsWith("@endforelse"))k--,x=y+11;else if(k===0&&b.startsWith("@empty")){if(M.length<=y+6||!/[a-z]/i.test(M[y+6])){S=y;break}x=y+1}else x=y+1}if(S===-1)continue;return{start:z,end:I,arrayExpr:V,itemVar:L,foreachContent:M.substring(0,S),emptyContent:M.substring(S+6)}}return null}function Iq($,Z){let Y=$;while(!0){let J=II(Y);if(!J)break;let{start:X,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=J;try{let z;if(R0(G))z=M0(G,Object.keys(Z))(...Object.values(Z));else z=V0(G,Z);let _;if(!Array.isArray(z)||z.length===0)_=U;else _=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,X)+_+Y.substring(Q)}catch(z){let _=z instanceof Error?z.message:String(z),B=H0("Forelse",`Error in @forelse(${G} as ${K}): ${_}`,G0.EVALUATION_ERROR);Y=Y.substring(0,X)+B+Y.substring(Q)}}return Y}function eZ($,Z,Y,J){let X=$;X=Iq(X,Z);function Q(W){let U=/@foreach\s*\(/g,z;while((z=U.exec(W))!==null){let _=z.index,B=z.index+z[0].length-1,q=1,j=B+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(B+1,H),V=O.indexOf(" as ");if(V===-1)continue;let L=_,F=O.substring(0,V),A=O.substring(V+4),w=H+1,N=1,R=w,E=/@foreach\s*\(/g,M=/@endforeach/g;while(N>0&&R<W.length){E.lastIndex=R,M.lastIndex=R;let I=E.exec(W),S=M.exec(W);if(!S)break;if(I&&I.index<S.index)N++,R=I.index+I[0].length;else{if(N--,N===0){let k=W.substring(w,S.index),x=S.index+11;return{start:L,end:x,arrayExpr:F,itemVar:A,content:k}}R=S.index+11}}}return null}function G(W,U){let z=W;while(!0){let _=Q(z);if(!_)break;let{start:B,end:q,arrayExpr:j,itemVar:H,content:O}=_;try{let V=j.trim(),L;if(R0(V))L=M0(V,Object.keys(U))(...Object.values(U));else L=V0(V,U);let F=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),F=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),F=!0;else{let S=H0("Foreach",`Error in @foreach: ${V} is not iterable`,G0.TYPE_ERROR);z=z.substring(0,B)+S+z.substring(q);continue}let A=J?.loops?.useAltLoopVariable??NI,w=H.trim(),N=null,R,E=!1;if(w.includes("=>")){let S=w.split("=>").map((k)=>k.trim());if(S.length===2&&S[0]&&S[1])N=S[0],R=S[1];else R=w}else if(!w.startsWith("[")&&!w.startsWith("{")&&w.includes(",")){let S=w.split(",").map((k)=>k.trim());if(S.length===2&&S[0]&&S[1])R=S[0],N=S[1],E=!0;else R=w}else R=w;let M="",I=L;for(let S=0;S<I.length;S++){let k=I[S],x={index:S,iteration:S+1,first:S===0,last:S===I.length-1,count:I.length},y={...U,loop:x,$loop:x};if(R.startsWith("[")&&R.endsWith("]")){let m=R.slice(1,-1).split(",").map((P)=>P.trim());if(Array.isArray(k))m.forEach((P,d)=>{if(P)y[P]=k[d]});else y[R]=k}else y[R]=k;if(N)if(!E&&F&&Array.isArray(k)&&k.length===2)y[N]=k[0],y[R]=k[1];else y[N]=S;let b=TI(O,y),h=Eq(b);if(h.hasContinue){M+=h.content;continue}let r=Tq(b);if(r.hasBreak){M+=r.content;break}if(b=Iq(b,y),b=G(b,y),b=d6(b,y,Y),b=EI(b),r=Tq(b),r.hasBreak){M+=r.content;break}if(h=Eq(b),h.hasContinue){M+=h.content;continue}b=d1(b,y,Y),b=MI(b,y),b=RI(b,y),M+=b}z=z.substring(0,B)+M+z.substring(q)}catch(V){let L=H0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${V instanceof Error?V.message:String(V)}`,G0.EVALUATION_ERROR);z=z.substring(0,B)+L+z.substring(q)}}return z}X=G(X,Z),X=Sq(X,Z,Y,J);let K=J?.loops?.maxWhileIterations??wI;return X=SI(X,Z,K),X}function kq($){return XZ($)}function Sq($,Z,Y,J){let X=$,Q=!0;while(Q){Q=!1;let G=X.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=a0(X,"(",")",W);if(U===-1)break;let z=X.slice(W+1,U),_=U+1,B=k7(X.slice(K),"for","endfor");if(B.length===0)break;let q=B[0].content,j=K+B[0].end;if(!kq(z)){let H=H0("For",`Unsafe expression in @for: ${z}`,G0.UNSAFE_EXPRESSION);X=X.substring(0,K)+H+X.substring(j),Q=!0;continue}try{let H=DI(z),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let N=kI({forExpr:z,content:q,iterVarNames:H,context:Z,filePath:Y,options:J});X=X.substring(0,K)+N+X.substring(j),Q=!0;continue}let V=Object.keys(Z),L=Object.values(Z),F=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(N,R)=>{return`\${${R}}`});F=Dq(F);let w=Function(...V,`
|
|
2173
2173
|
let result = '';
|
|
2174
2174
|
for (${z}) {
|
|
2175
2175
|
result += \`${F}\`;
|
|
@@ -2179,7 +2179,7 @@ ${G}`,X++}return{functionCode:J,nextIndex:X}}function Vq($,Z){let Y=V0($,Z)??V0(
|
|
|
2179
2179
|
for (${Z}) {
|
|
2180
2180
|
__pushIter([${J.join(", ")}])
|
|
2181
2181
|
}
|
|
2182
|
-
`),z=[];U(...W,(q)=>{z.push(q)});let _=Q??"inline.stx",B="";for(let q of z){let j={...X};J.forEach((O,V)=>{j[O]=q[V]});let H=Sq(Y,j,Q,G);H=d6(H,j,_),H=d1(H,j,_),B+=H}return B}function SI($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@while\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=G+Q[0].length-1,W=
|
|
2182
|
+
`),z=[];U(...W,(q)=>{z.push(q)});let _=Q??"inline.stx",B="";for(let q of z){let j={...X};J.forEach((O,V)=>{j[O]=q[V]});let H=Sq(Y,j,Q,G);H=d6(H,j,_),H=d1(H,j,_),B+=H}return B}function SI($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@while\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=G+Q[0].length-1,W=a0(J,"(",")",K);if(W===-1)break;let U=J.slice(K+1,W),z=k7(J.slice(G),"while","endwhile");if(z.length===0)break;let _=z[0].content,B=G+z[0].end;if(!kq(U)){let q=H0("While",`Unsafe expression in @while: ${U}`,G0.UNSAFE_EXPRESSION);J=J.substring(0,G)+q+J.substring(B),X=!0;continue}try{let q=Object.keys(Z),j=Object.values(Z),H=_.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(L,F)=>{return`\${${F}}`});H=Dq(H);let V=Function(...q,`
|
|
2183
2183
|
let result = '';
|
|
2184
2184
|
let maxIterations = ${Y}; // Configurable safety limit
|
|
2185
2185
|
let counter = 0;
|
|
@@ -2226,15 +2226,15 @@ ${Pq($).split(",").map((Q)=>Q.trim()).filter(Boolean).map((Q)=>` try { __scopeR
|
|
|
2226
2226
|
} finally {
|
|
2227
2227
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
2228
2228
|
}
|
|
2229
|
-
})();`}function yI($,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 X=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(X)return{html:$,mergedIntoExisting:X[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function xI(){M2.clear()}function vI($){if($.__onceStore instanceof Set)return $.__onceStore;return M2}async function ZY($,Z,Y,J,X,Q=new Set){let G=J.partialsDir||y0.join(y0.dirname(Y),"partials");if(G&&!y0.isAbsolute(G))G=y0.resolve(process.cwd(),G);let K=CI($,"@partial","@include"),W=vI(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let V=H.trim(),L=`${Y}:${V}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let A=K.substring(V+1,F-1),w=A.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=F;continue}let N=w[1],R=U(N,G,Y),E="";if(R&&await Bun.file(R).exists())X.add(R),E=`@include(${A})`;K=K.substring(0,O)+E+K.substring(F),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(K))!==null){let L=V.index,F=L+V[0].length-1,A=1,w=F+1;while(w<K.length&&A>0){if(K[w]==="(")A++;else if(K[w]===")")A--;w++}if(A!==0)break;let N=K.substring(F+1,w-1),R=R2(N,0);if(R===-1){O.lastIndex=w;continue}let E=N.substring(0,R).trim(),M=N.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=w;continue}let S=I[1],k=M.substring(I[0].length),x,y=R2(k,0);if(y!==-1)x=k.substring(y+1).trim();try{let b=`Boolean(${E})`,h;if(R0(b)){let P=M0(b,Object.keys(Z));h=Boolean(P(...Object.values(Z)))}else h=Boolean(V0(b,Z));let r=H?!h:h,m="";if(r){let P=U(S,G,Y);if(P&&await Bun.file(P).exists())X.add(P);m=`@include('${S}'${x?`, ${x}`:""})`}K=K.substring(0,L)+m+K.substring(w),O.lastIndex=0}catch(b){let h=b instanceof Error?b.message:String(b),r=T0("Include",`Error evaluating ${j} condition: ${h}`,Y,$,L);K=K.substring(0,L)+r+K.substring(w),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),w=K.substring(O,F+1),N=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(w,"");continue}let[,R,E,M,I]=N;try{let S,k=E.trim();if(R0(k))S=M0(k,Object.keys(Z))(...Object.values(Z));else S=V0(k,Z);let x="";if(Array.isArray(S)&&S.length>0)for(let y of S){let b={...Z,[M]:y},h=await _(R,b,$,O);x+=h}else if(I)x=await _(I,{},$,O);K=K.substring(0,O)+x+K.substring(F+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,O)+T0("Each",`Error in @each: ${k}`,Y,$,O)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),w=K.substring(O,F+1),N=A.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(w,"");continue}let R=N[1],E=A.slice(N[0].length),M,I=E.match(/^\s*,\s*\{/);if(I){E=E.slice(I[0].length-1);let x=1,y=1;while(y<E.length&&x>0){if(E[y]==="{")x++;else if(E[y]==="}"){if(x--,x===0)break}y++}M=E.substring(0,y+1),E=E.slice(y+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let x=JSON.parse(R.replace(/'/g,'"')),y={};if(M)try{y=i0(M,Z)}catch(h){let r=h instanceof Error?h.message:String(h);if(J.debug){let m=T0("Include",`Error parsing includeFirst variables: ${r}`,Y,$,O,w);K=K.replace(w,()=>m)}else K=K.replace(w,()=>S||"");continue}let b=!1;for(let h of x){let r=U(h,G,Y);if(!r)continue;if(await Q0(r)){let m=await _(h,y,$,O);K=K.replace(w,()=>m),b=!0;break}}if(!b)if(S!==void 0)K=K.replace(w,()=>S);else if(J.debug){let h=T0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,w);K=K.replace(w,()=>h)}else K=K.replace(w,"")}catch(x){let y=x instanceof Error?x.message:String(x),b=T0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,w);K=K.replace(w,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let L=y0.resolve(H),F=y0.resolve(y0.dirname(O)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=y0.resolve(H,V);else A=y0.resolve(F,V);let w=y0.normalize(A),N=w.startsWith(L+y0.sep)||w===L,R=w.startsWith(F+y0.sep)||w===F,E=!1,M=y0.dirname(F);if(w.startsWith(M+y0.sep)){if(!y0.relative(M,w).split(y0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))E=!0}if(!N&&!R&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${w}`),console.error(` Allowed dirs: ${L}, ${F}`),null;return w}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let z=y0.resolve(Y);Q.add(z);async function _(j,H={},O,V){let L=U(j,G,Y);if(!L)return T0("Include",`Could not resolve path for include: ${j}`,Y,O,V);let F=y0.resolve(L);if(Q.has(F)){let A=[...Q,F].map((w)=>y0.basename(w)).join(" -> ");return T0("Include",`Circular include detected: ${A}`,Y,O,V)}try{X.add(L);let A;if(!A)try{A=await Bun.file(L).text()}catch(m){let P=m instanceof Error?m.message:String(m);return T0("Include",`Error loading include file ${j}: ${P}`,Y,O,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:m}=await Promise.resolve().then(() => (G6(),i6));A=m(A,Z)}if(A&&(J.debug||!k$()&&!R7()))try{let{warnUnbalancedTags:m}=await Promise.resolve().then(() => (l9(),lB));m(A,L)}catch{}let w=A;try{let{processESImports:m}=await Promise.resolve().then(() => (F2(),jq));await m(A,Z,L,J,X)}catch(m){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,m instanceof Error?m.message:m)}let N=_4(w);if(N)w=N.content.trim();let E=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(E)M=`<style${E[1]}>${E[2]}</style>`;w=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),w=w.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[m,P]of Object.entries(H))I[m]=P;let S=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...A.matchAll(S)],x="",y=null;for(let m of k){let P=m[1]||"",d=m[2]||"",l=P.includes("server"),c=r4(P),
|
|
2230
|
-
`;continue}if(l)try{let{extractVariables:K0}=await Promise.resolve().then(() => (K6(),
|
|
2229
|
+
})();`}function yI($,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 X=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(X)return{html:$,mergedIntoExisting:X[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function xI(){M2.clear()}function vI($){if($.__onceStore instanceof Set)return $.__onceStore;return M2}async function ZY($,Z,Y,J,X,Q=new Set){let G=J.partialsDir||y0.join(y0.dirname(Y),"partials");if(G&&!y0.isAbsolute(G))G=y0.resolve(process.cwd(),G);let K=CI($,"@partial","@include"),W=vI(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let V=H.trim(),L=`${Y}:${V}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let A=K.substring(V+1,F-1),w=A.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=F;continue}let N=w[1],R=U(N,G,Y),E="";if(R&&await Bun.file(R).exists())X.add(R),E=`@include(${A})`;K=K.substring(0,O)+E+K.substring(F),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(K))!==null){let L=V.index,F=L+V[0].length-1,A=1,w=F+1;while(w<K.length&&A>0){if(K[w]==="(")A++;else if(K[w]===")")A--;w++}if(A!==0)break;let N=K.substring(F+1,w-1),R=R2(N,0);if(R===-1){O.lastIndex=w;continue}let E=N.substring(0,R).trim(),M=N.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=w;continue}let S=I[1],k=M.substring(I[0].length),x,y=R2(k,0);if(y!==-1)x=k.substring(y+1).trim();try{let b=`Boolean(${E})`,h;if(R0(b)){let P=M0(b,Object.keys(Z));h=Boolean(P(...Object.values(Z)))}else h=Boolean(V0(b,Z));let r=H?!h:h,m="";if(r){let P=U(S,G,Y);if(P&&await Bun.file(P).exists())X.add(P);m=`@include('${S}'${x?`, ${x}`:""})`}K=K.substring(0,L)+m+K.substring(w),O.lastIndex=0}catch(b){let h=b instanceof Error?b.message:String(b),r=T0("Include",`Error evaluating ${j} condition: ${h}`,Y,$,L);K=K.substring(0,L)+r+K.substring(w),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),w=K.substring(O,F+1),N=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(w,"");continue}let[,R,E,M,I]=N;try{let S,k=E.trim();if(R0(k))S=M0(k,Object.keys(Z))(...Object.values(Z));else S=V0(k,Z);let x="";if(Array.isArray(S)&&S.length>0)for(let y of S){let b={...Z,[M]:y},h=await _(R,b,$,O);x+=h}else if(I)x=await _(I,{},$,O);K=K.substring(0,O)+x+K.substring(F+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,O)+T0("Each",`Error in @each: ${k}`,Y,$,O)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),w=K.substring(O,F+1),N=A.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(w,"");continue}let R=N[1],E=A.slice(N[0].length),M,I=E.match(/^\s*,\s*\{/);if(I){E=E.slice(I[0].length-1);let x=1,y=1;while(y<E.length&&x>0){if(E[y]==="{")x++;else if(E[y]==="}"){if(x--,x===0)break}y++}M=E.substring(0,y+1),E=E.slice(y+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let x=JSON.parse(R.replace(/'/g,'"')),y={};if(M)try{y=i0(M,Z)}catch(h){let r=h instanceof Error?h.message:String(h);if(J.debug){let m=T0("Include",`Error parsing includeFirst variables: ${r}`,Y,$,O,w);K=K.replace(w,()=>m)}else K=K.replace(w,()=>S||"");continue}let b=!1;for(let h of x){let r=U(h,G,Y);if(!r)continue;if(await Q0(r)){let m=await _(h,y,$,O);K=K.replace(w,()=>m),b=!0;break}}if(!b)if(S!==void 0)K=K.replace(w,()=>S);else if(J.debug){let h=T0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,w);K=K.replace(w,()=>h)}else K=K.replace(w,"")}catch(x){let y=x instanceof Error?x.message:String(x),b=T0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,w);K=K.replace(w,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let L=y0.resolve(H),F=y0.resolve(y0.dirname(O)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=y0.resolve(H,V);else A=y0.resolve(F,V);let w=y0.normalize(A),N=w.startsWith(L+y0.sep)||w===L,R=w.startsWith(F+y0.sep)||w===F,E=!1,M=y0.dirname(F);if(w.startsWith(M+y0.sep)){if(!y0.relative(M,w).split(y0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))E=!0}if(!N&&!R&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${w}`),console.error(` Allowed dirs: ${L}, ${F}`),null;return w}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let z=y0.resolve(Y);Q.add(z);async function _(j,H={},O,V){let L=U(j,G,Y);if(!L)return T0("Include",`Could not resolve path for include: ${j}`,Y,O,V);let F=y0.resolve(L);if(Q.has(F)){let A=[...Q,F].map((w)=>y0.basename(w)).join(" -> ");return T0("Include",`Circular include detected: ${A}`,Y,O,V)}try{X.add(L);let A;if(!A)try{A=await Bun.file(L).text()}catch(m){let P=m instanceof Error?m.message:String(m);return T0("Include",`Error loading include file ${j}: ${P}`,Y,O,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:m}=await Promise.resolve().then(() => (G6(),i6));A=m(A,Z)}if(A&&(J.debug||!k$()&&!R7()))try{let{warnUnbalancedTags:m}=await Promise.resolve().then(() => (l9(),lB));m(A,L)}catch{}let w=A;try{let{processESImports:m}=await Promise.resolve().then(() => (F2(),jq));await m(A,Z,L,J,X)}catch(m){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,m instanceof Error?m.message:m)}let N=_4(w);if(N)w=N.content.trim();let E=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(E)M=`<style${E[1]}>${E[2]}</style>`;w=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),w=w.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[m,P]of Object.entries(H))I[m]=P;let S=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...A.matchAll(S)],x="",y=null;for(let m of k){let P=m[1]||"",d=m[2]||"",l=P.includes("server"),c=r4(P),a="";try{let{extractAndStripCssImports:K0,renderVendorStyleTags:C0}=await Promise.resolve().then(() => (v6(),Sz)),z1=K0(d,{filePath:L,projectRoot:process.cwd()});d=z1.code,a=C0(z1.styles)}catch(K0){if(J.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,K0 instanceof Error?K0.message:K0)}if(c&&d.trim())d=a4(d);if(!l)try{let{hasUserImports:K0,bundleClientScript:C0}=await Promise.resolve().then(() => (K7(),G7));if(K0(d))d=await C0(d,L,{projectRoot:process.cwd()})}catch(K0){if(J.debug)console.warn(`[stx] bundler skipped for ${L}:`,K0 instanceof Error?K0.message:K0)}let X0=bI(d);if(X0&&!l){y=`stx_scope_${y0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++bq}`;let K0=c1(d),C0=PI(K0,y);x+=`${a}<script data-stx-scoped>${C0}</script>
|
|
2230
|
+
`;continue}if(l)try{let{extractVariables:K0}=await Promise.resolve().then(() => (K6(),aZ));await K0(d,I,L)}catch(K0){if(J.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,K0)}if(!l&&!X0){let K0=P.replace(/\bclient\b/i,"").trim();y=`stx_scope_${y0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++bq}`;let C0=c1(d),z1=xq(C0,y),b0=yq(C0,z1);x+=`${a}<script data-stx-scoped${K0?` ${K0}`:""}>${b0}</script>
|
|
2231
2231
|
`}}if(y){let m=yI(w,y);if(w=m.html,m.mergedIntoExisting)x=x.replace(`window.stx._scopes['${y}']`,`window.stx._scopes['${m.mergedIntoExisting}']`),y=m.mergedIntoExisting}if(w.includes("@include")||w.includes("@partial"))w=await ZY(w,I,L,J,X,Q);let{processLoops:b}=await Promise.resolve().then(() => ($Y(),Cq)),h=b(w,I,L);h=d6(h,I,L);let r=g6(A);if(h=d1(h,I,L,{forceSignals:r}),M)h+=`
|
|
2232
2232
|
`+M;if(x)h+=`
|
|
2233
2233
|
`+x;return h}catch(A){let w=A instanceof Error?A.message:String(A);return T0("Include",`Error processing include ${j}: ${w}`,Y,O,V)}}let B=/@include\s*\(/g,q;while((q=B.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,V=H+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let L=K.substring(j,V),F=K.substring(H+1,V-1),A=F.match(/^\s*['"]([^'"]+)['"]/);if(!A){B.lastIndex=V;continue}let w=A[1],N,R=F.substring(A[0].length),E=R2(R,0);if(E!==-1)N=R.substring(E+1).trim();let M={};if(N)try{M=i0(N,Z)}catch(S){let k=S instanceof Error?S.message:String(S);K=K.replace(L,T0("Include",`Error parsing include variables for ${w}: ${k}`,Y,$,j)),B.lastIndex=0;continue}let I=await _(w,M,$,j);K=K.substring(0,j)+I+K.substring(V),B.lastIndex=0}return K}function YY($,Z){let Y=$;function J(X,Q,G,K){let W=X,U=!0;while(U){U=!1;let z=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),_=W.match(z);if(!_||_.index===void 0)break;let B=_.index,q=_[1],j=B+_[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),V=1,L=j,F=-1;while(V>0&&L<W.length){let w=W.slice(L),N=w.match(H),R=w.match(O),E=N?L+N.index:1/0,M=R?L+R.index:1/0;if(E<M)V++,L=E+(N[0].length||1);else if(M<1/0){if(V--,V===0){F=M;break}L=M+G.length+1}else break}if(F===-1)break;let A=W.slice(j,F);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(A);else Z[q].push(A);W=W.substring(0,B)+W.substring(F+`@${G}`.length),U=!0}return W}return Y=J(Y,"push","endpush",!1),Y=J(Y,"prepend","endprepend",!0),Y}function JY($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,J)=>{if(!Z[J]||Z[J].length===0)return"";return Z[J].join(`
|
|
2234
|
-
`)})}var bq=0,W6,M2;var m$=D(()=>{x$();EZ();$1();F7();t4();n0();N0();W6=new h6(500),M2=new Set});import*as T2 from"path";async function vq($,Z,Y=""){if(T2.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 gq($,Z,Y,"@js","@endjs")}async function fq($,Z,Y=""){if(T2.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return gq($,Z,Y,"@ts","@endts")}async function gq($,Z,Y,J,X){let Q=$,G=E$(`${J}([\\s\\S]*?)${X}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:z,index:_}of K)try{let B=Object.keys(
|
|
2235
|
-
${
|
|
2236
|
-
${
|
|
2237
|
-
`,
|
|
2234
|
+
`)})}var bq=0,W6,M2;var m$=D(()=>{x$();EZ();$1();F7();t4();n0();N0();W6=new h6(500),M2=new Set});import*as T2 from"path";async function vq($,Z,Y=""){if(T2.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 gq($,Z,Y,"@js","@endjs")}async function fq($,Z,Y=""){if(T2.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return gq($,Z,Y,"@ts","@endts")}async function gq($,Z,Y,J,X){let Q=$,G=E$(`${J}([\\s\\S]*?)${X}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:z,index:_}of K)try{let B={...Z,global:Z},q=Object.keys(B),j=Object.values(B),H=z.trim();if(J==="@ts")H=H.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 V=(H.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),L=V.length>0?`return { ${V.join(", ")} };`:"return {};",F=`
|
|
2235
|
+
${H}
|
|
2236
|
+
${L}
|
|
2237
|
+
`,w=Function(...q,F)(...j);if(w&&typeof w==="object")Object.assign(Z,w);Q=Q.replace(U,"")}catch(B){console.error(`Error executing ${J} code block in ${Y}:`,B);let q=B instanceof Error?B.message:String(B),j=T0(`${J} Directive`,`Error executing code: ${q}`,Y,$,_,U);console.error(j),Q=Q.replace(U,"")}return Q}var hq=D(()=>{t4();N0()});function fI($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function dq($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,J,X,Q)=>{return fI(J,Q||"_method")})}async function E2($,Z,Y,J,X){if(!J.middleware||J.middleware.length===0)return $;let Q=$,G=J.middleware.filter((K)=>K.timing===X);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(J.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,J);if(typeof W==="string")Q=W;else if(J.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(J.debug)console.error(`Error in middleware ${K.name}:`,W);if(J.debug){let U=T0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
|
|
2238
2238
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${v0(U)}</div>
|
|
2239
2239
|
`)}}}return Q}async function I2($,Z,Y,J){return E2($,Z,Y,J,"before")}async function D2($,Z,Y,J){return E2($,Z,Y,J,"after")}var k2=D(()=>{$1();N0()});import{defineRoute as Tc,defineRoutes as Ec,resetRoutes as Ic,route as Dc,setAppUrl as kc}from"stx-router";import{route as gI}from"stx-router";function uq($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,J,X,Q)=>{try{let G=X?i0(X,{}):{};return gI(J,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var mq=D(()=>{n0()});function S2($,Z,Y,J){let X=$;X=X.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,U)=>{if(!U&&W.includes(":")){let z=W.split(":"),_=W,B=z.length>1?z[1]:"";if(B&&Z[B])U=Z[B];else if(_.startsWith("og:")&&Z.openGraph&&Z.openGraph[z[1]])U=Z.openGraph[z[1]];else U="";return U?`<meta property="${z0(_)}" content="${z0(U)}">`:""}return U?`<meta name="${z0(W)}" content="${z0(U)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(X))!==null){let K=G.index,W=K+G[0].length-1,U=1,z=W+1;while(z<X.length&&U>0){if(X[z]==="(")U++;else if(X[z]===")"){if(U--,U===0)break}z++}if(U!==0)break;let _=X.substring(W+1,z).trim(),B=z+1,q=(()=>{try{let j=i0(_,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${z0(String(j.name))}"`;if(j.property)H+=` property="${z0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${z0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${z0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return H0("MetaTag",H,G0.EVALUATION_ERROR)}})();X=X.substring(0,K)+q+X.substring(B),Q.lastIndex=0}return X}function C2($,Z,Y){let J=$,X=/@structuredData\s*\(/g,Q;while((Q=X.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=J.substring(K+1,U).trim(),_=U+1,B=(()=>{try{let q=i0(z,Z);if(!q)return"";if(!q["@context"])q["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(q).replace(/<\//g,"<\\/")}</script>`}catch(q){let j=q instanceof Error?q.message:String(q);return H0("StructuredData",j,G0.EVALUATION_ERROR)}})();J=J.substring(0,G)+B+J.substring(_),X.lastIndex=0}return J}function b2($,Z,Y,J){let X=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(X))!==null){let K=X.indexOf("{",G.index+4),W=1,U=K+1,z=null,_=!1;while(U<X.length&&W>0){let V=X[U];if(_){_=!1,U++;continue}if(V==="\\"&&z){_=!0,U++;continue}if(z){if(V===z)z=null;U++;continue}if(V==='"'||V==="'"||V==="`"){z=V,U++;continue}if(V==="{")W++;else if(V==="}")W--;U++}if(W!==0)break;let B=X.substring(U).match(/^\s*\)/);if(!B)break;let q=U+B[0].length,j=X.substring(K,U),H=X.substring(G.index,q),O=((V)=>{try{let L=i0(V,Z);if(!L)return"";let F="";if(L.title)F+=`<title>${z0(L.title)}</title>
|
|
2240
2240
|
`,F+=`<meta name="title" content="${z0(L.title)}">
|
|
@@ -2284,19 +2284,19 @@ ${$.map((Q)=>{let G=Q.startsWith("http")?Q:`${Y}${Q.startsWith("/")?"":"/"}${Q}`
|
|
|
2284
2284
|
</sitemapindex>`}async function uI($,Z){let{extensions:Y=[".stx",".html",".htm"],ignore:J=["_*",".*","node_modules","components","partials","layouts"]}=Z,X=[],Q=Y.length===1?`*${Y[0]}`:`*{${Y.join(",")}}`,G=new Bun.Glob(`**/${Q}`);for await(let K of G.scan($)){if(J.some((B)=>{if(B.startsWith("*"))return K.includes(B.slice(1));return K.startsWith(B)||K.includes(`/${B}`)}))continue;let U=K.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!U.startsWith("/"))U=`/${U}`;if(U!=="/"&&U.endsWith("/"))U=U.slice(0,-1);let z=`${$}/${K}`,_;try{let B=await Bun.file(z).stat();if(B)_=new Date(B.mtime).toISOString().split("T")[0]}catch{}X.push({loc:U||"/",lastmod:_,priority:U==="/"?1:0.5})}return X.sort((K,W)=>K.loc.localeCompare(W.loc)),X}function lq($){let Z=[];for(let Y of $.rules){if(Z.push(`User-agent: ${Y.userAgent}`),Y.allow)for(let J of Y.allow)Z.push(`Allow: ${J}`);if(Y.disallow)for(let J of Y.disallow)Z.push(`Disallow: ${J}`);if(Y.crawlDelay!==void 0)Z.push(`Crawl-delay: ${Y.crawlDelay}`);Z.push("")}if($.sitemap){let Y=Array.isArray($.sitemap)?$.sitemap:[$.sitemap];for(let J of Y)Z.push(`Sitemap: ${J}`)}if($.host)Z.push(`Host: ${$.host}`);return Z.join(`
|
|
2285
2285
|
`).trim()}function mI($){return lq({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function lI($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var XY,QY;var GY=D(()=>{C1();n0();XY={name:"meta",handler:($,Z,Y,J)=>{if(Z.length<1)return H0("Meta","meta directive requires at least the meta name",G0.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${z0(X)}" content="${z0(Q)}">`},hasEndTag:!1},QY={name:"structuredData",handler:($,Z,Y,J)=>{if($.trim()==="")return H0("StructuredData","structuredData directive requires JSON-LD content",G0.INVALID_DIRECTIVE_SYNTAX);try{let X=JSON.parse($);if(!X["@context"])X["@context"]="https://schema.org";if(!X["@type"])return H0("StructuredData","structuredData requires @type property",G0.INVALID_DIRECTIVE_SYNTAX);return`<script type="application/ld+json">${JSON.stringify(X)}</script>`}catch(X){let Q=X instanceof Error?X.message:String(X);return H0("StructuredData",Q,G0.EVALUATION_ERROR)}},hasEndTag:!0}});async function cq($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(l7.exact[$])for(let J of l7.exact[$])await Promise.resolve(J(Z,$));if(l7.exact[Y])for(let J of l7.exact[Y])await Promise.resolve(J(Z,$));for(let{pattern:J,callback:X}of l7.patterns)if(J.test($)||J.test(Y))await Promise.resolve(X(Z,$))}var l7;var pq=D(()=>{l7={patterns:[],exact:{}}});function iq($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>iq(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function KY($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,J=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,X=[],Q;while((Q=J.exec($))!==null)X.push([Q.index,Q.index+Q[0].length]);function G(U){return X.some(([z,_])=>U>=z&&U<_)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,W=[];while((Q=K.exec(Y))!==null){if(G(Q.index))continue;let U=Q[0],z=Q[2];if(!z||!z.includes(":"))continue;let _=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,B,q=z,j=!1;while((B=_.exec(z))!==null){let H=B[1],O=B[2];if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let V=Object.keys(Z),L=Object.values(Z),F=O.match(/^([a-zA-Z_$][\w$]*)/);if(F&&!V.includes(F[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(F[1]))continue;let w=Function(...V,`return (${O})`)(...L);if(H==="class"){let N=iq(w);if(N){let R=q.match(/\sclass="([^"]*)"/);if(R)q=q.replace(R[0],` class="${R[1]} ${N}"`);else q=q.replace(B[0],` class="${N}"`)}else q=q.replace(B[0],"");j=!0;continue}if(cI.has(H)){if(w)q=q.replace(B[0],` ${H}`);else q=q.replace(B[0],"");j=!0;continue}if(w===null||w===void 0||w===!1)q=q.replace(B[0],"");else{let N=String(w).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");q=q.replace(B[0],` ${H}="${N}"`)}j=!0}catch{continue}}if(j){let H=U.endsWith("/>")?" /":"",V=`<${Q[1]}${q}${H}>`;W.push({start:Q.index,end:Q.index+U.length,replacement:V})}}for(let U=W.length-1;U>=0;U--){let{start:z,end:_,replacement:B}=W[U];Y=Y.slice(0,z)+B+Y.slice(_)}return Y}var cI;var y2=D(()=>{cI=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function r6($,Z){let Y=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;Y.lastIndex=Z;let J=Y.exec($);if(!J)return null;let X=/\/\s*>$/.test(J[0])||pI.has(J[1].toLowerCase()),Q=X?J[2].replace(/\/\s*$/,""):J[2];return{full:J[0],tag:J[1],attrs:Q,selfClosing:X,start:J.index,end:J.index+J[0].length}}function nI($,Z,Y){let J=1,X=Y,Q=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(J>0&&X<$.length){Q.lastIndex=X,G.lastIndex=X;let K=Q.exec($),W=G.exec($);if(!W)return-1;if(K&&K.index<W.index)J++,X=K.index+K[0].length;else{if(J--,J===0)return W.index+W[0].length;X=W.index+W[0].length}}return-1}function q4($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=nI($,Z.tag,Z.end);if(Y===-1)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};return{outerStart:Z.start,outerEnd:Y,innerHTML:$.slice(Z.end,Y-`</${Z.tag}>`.length)}}function nq($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function l$($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return J?J[1]:null}function U6($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return $.replace(new RegExp(`\\s*${Y}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${Y}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${Y}(?=\\s|$|>|/)`,"g"),"")}function z6($,Z,Y){let J=Z.selfClosing?" /":"",X=`<${Z.tag}${Y}${J}>`;return $.slice(0,Z.start)+X+$.slice(Z.end)}function rq($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function rI($){let Z=$,Y=0;while(Y<Z.length){let J=r6(Z,Y);if(!J)break;let X=l$(J.attrs,"v-for");if(X===null){Y=J.end;continue}let Q=X.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!Q){Y=J.end;continue}let G=Q[1].trim(),K=Q[2].trim(),W;if(G.includes(",")){let O=G.split(",").map((F)=>F.trim()),V=O[0],L=O[1];W=`${K} as ${L} => ${V}`}else W=`${K} as ${G}`;let U=U6(J.attrs,"v-for"),z=U6(U,":key").replace(/\s*v-bind:key="[^"]*"/g,""),_=q4(Z,J),B=Z.slice(_.outerStart,_.outerEnd),q=z6(B,{...J,start:0,end:J.end-J.start},z),j=`@foreach(${W})
|
|
2286
2286
|
`,H=`${j}${q}
|
|
2287
|
-
@endforeach`;Z=Z.slice(0,_.outerStart)+H+Z.slice(_.outerEnd),Y=_.outerStart+j.length}return Z}function
|
|
2287
|
+
@endforeach`;Z=Z.slice(0,_.outerStart)+H+Z.slice(_.outerEnd),Y=_.outerStart+j.length}return Z}function aI($){let Z=$,Y=0;while(Y<Z.length){let J=r6(Z,Y);if(!J)break;let X=l$(J.attrs,"v-if");if(X===null){Y=J.end;continue}let Q=[],G=q4(Z,J),K=U6(J.attrs,"v-if"),W=z6(Z.slice(G.outerStart,G.outerEnd),{...J,start:0,end:J.end-J.start},K);Q.push({type:"if",expr:X,outerStart:G.outerStart,outerEnd:G.outerEnd,element:W,parsedTag:J});let U=G.outerEnd,z=!0;while(z){let H=Z.slice(U).match(/^\s*/),O=H?H[0].length:0,V=r6(Z,U+O);if(!V){z=!1;break}let L=l$(V.attrs,"v-else-if"),F=nq(V.attrs,"v-else");if(L!==null){let A=q4(Z,V),w=U6(V.attrs,"v-else-if"),N=z6(Z.slice(A.outerStart,A.outerEnd),{...V,start:0,end:V.end-V.start},w);Q.push({type:"else-if",expr:L,outerStart:U,outerEnd:A.outerEnd,element:N,parsedTag:V}),U=A.outerEnd}else if(F){let A=q4(Z,V),w=U6(V.attrs,"v-else"),N=z6(Z.slice(A.outerStart,A.outerEnd),{...V,start:0,end:V.end-V.start},w);Q.push({type:"else",outerStart:U,outerEnd:A.outerEnd,element:N,parsedTag:V}),z=!1}else z=!1}let _=[];for(let H of Q)if(H.type==="if")_.push(`@if(${H.expr})
|
|
2288
2288
|
${H.element}`);else if(H.type==="else-if")_.push(`@elseif(${H.expr})
|
|
2289
2289
|
${H.element}`);else _.push(`@else
|
|
2290
2290
|
${H.element}`);_.push("@endif");let B=_.join(`
|
|
2291
|
-
`),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+B+Z.slice(j),Y=q+B.length}return Z}function
|
|
2291
|
+
`),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+B+Z.slice(j),Y=q+B.length}return Z}function sI($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function oI($){let Z=$,Y=0;while(Y<Z.length){let J=r6(Z,Y);if(!J)break;let X=J.attrs,Q=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,K=X.match(G);while(K){Q=!0;let z=K[1],_=K[2],B=K[3];X=X.replace(K[0],""),X+=` :${z}="${B}" @update:${z}="${B} = $event"`,K=X.match(G)}if(Q){let z=q4(Z,J),_=Z.slice(z.outerStart,z.outerEnd),B=z6(_,{...J,start:0,end:J.end-J.start},X);Z=Z.slice(0,z.outerStart)+B+Z.slice(z.outerEnd),Y=z.outerStart+B.length;continue}let W=l$(J.attrs,"v-model");if(W===null){Y=J.end;continue}if(iI.has(J.tag.toLowerCase())){let z=J.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,_=q4(Z,J),B=Z.slice(_.outerStart,_.outerEnd),q=z6(B,{...J,start:0,end:J.end-J.start},z);Z=Z.slice(0,_.outerStart)+q+Z.slice(_.outerEnd),Y=_.outerStart+q.length}else{let z=J.attrs.replace(/\s*v-model="[^"]*"/g,"");z+=` :modelValue="${W}" @update:modelValue="${W} = $event"`;let _=q4(Z,J),B=Z.slice(_.outerStart,_.outerEnd),q=z6(B,{...J,start:0,end:J.end-J.start},z);Z=Z.slice(0,_.outerStart)+q+Z.slice(_.outerEnd),Y=_.outerStart+q.length}}return Z}function tI($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function eI($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function $D($){let Z=$,Y=0;while(Y<Z.length){let J=r6(Z,Y);if(!J)break;let X=l$(J.attrs,"v-html");if(X===null){Y=J.end;continue}if(J.selfClosing){Y=J.end;continue}let Q=q4(Z,J),G=U6(J.attrs,"v-html"),K=J.selfClosing?" /":"",W=`<${J.tag}${G}${K}>{!! ${X} !!}</${J.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function ZD($){let Z=$,Y=0;while(Y<Z.length){let J=r6(Z,Y);if(!J)break;let X=l$(J.attrs,"v-text");if(X===null){Y=J.end;continue}if(J.selfClosing){Y=J.end;continue}let Q=q4(Z,J),G=U6(J.attrs,"v-text"),K=J.selfClosing?" /":"",W=`<${J.tag}${G}${K}>{{ ${X} }}</${J.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function YD($){return $.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function JD($){let Z=$,Y=0;while(Y<Z.length){let J=r6(Z,Y);if(!J)break;if(!nq(J.attrs,"v-once")){Y=J.end;continue}let X=U6(J.attrs,"v-once"),Q=q4(Z,J),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
|
|
2292
2292
|
${z6(G,{...J,start:0,end:J.end-J.start},X)}
|
|
2293
|
-
@endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function XD($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function QD($){return $.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function x2($){if(!rq($))return $;let Z=$;return Z=rI(Z),Z=
|
|
2293
|
+
@endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function XD($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function QD($){return $.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function x2($){if(!rq($))return $;let Z=$;return Z=rI(Z),Z=aI(Z),Z=JD(Z),Z=tI(Z),Z=eI(Z),Z=oI(Z),Z=sI(Z),Z=QD(Z),Z=$D(Z),Z=ZD(Z),Z=YD(Z),Z=XD(Z),Z}var pI,iI;var v2=D(()=>{pI=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),iI=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","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"])});function WY($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function f2($,Z,Y,J,X){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],slotContent:W[3],index:W.index});for(let U=K.length-1;U>=0;U--){let z=K[U];try{let _=V0(z.expr,Z);if(!_||typeof _!=="string"){let L=`<!-- dynamic component: could not resolve "${WY(z.expr)}" -->`;Q=Q.slice(0,z.index)+L+Q.slice(z.index+z.full.length);continue}let B=z.attrs.trim(),q={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(B))!==null){let L=H[1]||H[2],F=H[3];if(H[1])try{q[L]=V0(F,Z)}catch{q[L]=F}else q[L]=F}let O=J.componentsDir||"components",V=await B4(_,q,z.slotContent,O,Z,Y,J,new Set,X??new Set);Q=Q.slice(0,z.index)+V+Q.slice(z.index+z.full.length)}catch(_){let B=_ instanceof Error?_.message:String(_),q=`<!-- dynamic component error: ${WY(B)} -->`;Q=Q.slice(0,z.index)+q+Q.slice(z.index+z.full.length)}}return Q=await GD(Q,Z,Y,J,X),Q}async function GD($,Z,Y,J,X){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],index:W.index});for(let U=K.length-1;U>=0;U--){let z=K[U];try{let _=V0(z.expr,Z);if(!_||typeof _!=="string"){let j=`<!-- dynamic component: could not resolve "${WY(z.expr)}" -->`;Q=Q.slice(0,z.index)+j+Q.slice(z.index+z.full.length);continue}let B=J.componentsDir||"components",q=await B4(_,{},"",B,Z,Y,J,new Set,X??new Set);Q=Q.slice(0,z.index)+q+Q.slice(z.index+z.full.length)}catch(_){let B=_ instanceof Error?_.message:String(_),q=`<!-- dynamic component error: ${WY(B)} -->`;Q=Q.slice(0,z.index)+q+Q.slice(z.index+z.full.length)}}return Q}var g2=D(()=>{N0();n0()});function aq($,Z=""){let Y=`${$}${Z}`,J=0;for(let X=0;X<Y.length;X++){let Q=Y.charCodeAt(X);J=(J<<5)-J+Q,J=J&J}return`stx-${Math.abs(J).toString(36)}`}function sq($,Z,Y={}){let{prefix:J="",preserveHost:X=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=h2($),W=[],U=new Map;if(Q)for(let z of K){let _=z.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(_){let B=_[1],q=`${Z}_${B}`;U.set(B,q)}}for(let z of K){let _=oq(z,Z,J,X,U,G);W.push(_)}return W.join(`
|
|
2294
2294
|
|
|
2295
2295
|
`)}function h2($){let Z=[],Y=$.replace(/\/\*[\s\S]*?\*\//g,""),J=0,X="",Q=!1,G="";for(let K=0;K<Y.length;K++){let W=Y[K];if(W==="@"&&J===0)Q=!0;if(W==="{")J++;else if(W==="}"){if(J--,J===0){if(Q){G+=W;let U=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(U){let[,z,_,B]=U;if(z==="keyframes")Z.push({selector:`@keyframes ${_.trim()}`,declarations:B.trim()});else if(z==="media"||z==="supports"||z==="container"){let q=h2(B);Z.push({selector:`@${z} ${_.trim()}`,declarations:q.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
|
|
2296
2296
|
`)})}else Z.push({selector:`@${z} ${_.trim()}`,declarations:B.trim()})}G="",Q=!1}else if(X.trim()){X+=W;let U=X.match(/([^{]+)\{([^}]*)\}/);if(U)Z.push({selector:U[1].trim(),declarations:U[2].trim()});X=""}continue}}if(Q)G+=W;else X+=W}return Z}function oq($,Z,Y,J,X,Q){let{selector:G,declarations:K}=$;if(G.startsWith("@")){if(G.startsWith("@keyframes")){let z=G.replace("@keyframes ","").trim();return`@keyframes ${X.get(z)||z} { ${K} }`}if(G.startsWith("@media")||G.startsWith("@supports")||G.startsWith("@container")){let _=h2(`x { ${K} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((B)=>oq(B,Z,Y,J,X,Q)).join(`
|
|
2297
2297
|
`);return`${G} {
|
|
2298
2298
|
${_}
|
|
2299
|
-
}`}return`${G} { ${K} }`}let W=KD(G,Z,Y,J),U=K;for(let[z,_]of X)U=U.replace(new RegExp(`\\b${z}\\b`,"g"),_);if(Q)U=U.replace(/--([a-z-]+)/gi,`--${Z}-$1`);return`${W} { ${U} }`}function KD($,Z,Y,J){let X=$.split(",").map((G)=>G.trim()),Q=[];for(let G of X){if(G.startsWith(":host")){if(J)Q.push(G);else{let U=G.replace(/:host(\([^)]*\))?/,`.${Z}$1`);Q.push(U)}continue}if(G.includes("::slotted")){Q.push(G);continue}if(G===":root"){Q.push(`:root .${Z}`);continue}let K=Y?`${Y} .${Z}`:`.${Z}`;Q.push(`${K} ${G}`);let W=WD(G,Z);if(W)Q.push(Y?`${Y} ${W}`:W)}return Q.join(", ")}function WD($,Z){let Y=0,J=$.length;for(let W=0;W<$.length;W++){let U=$[W];if(U==="["||U==="(")Y++;else if(U==="]"||U===")")Y--;else if(Y===0&&(U===" "||U===">"||U==="+"||U==="~")){J=W;break}}let X=$.slice(0,J),Q=$.slice(J);if(!X)return"";let G=X.length,K=0;for(let W=0;W<X.length;W++){let U=X[W];if(U==="["||U==="(")K++;else if(U==="]"||U===")")K--;else if(Y===0&&K===0&&U===":"){G=W;break}}return`${X.slice(0,G)}.${Z}${X.slice(G)}${Q}`}function u2($){let Z=new Set;return $.replace(/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi,(Y)=>{let J=Y.trim();if(Z.has(J))return"";return Z.add(J),Y})}function c7($,Z){if(!UD.test($))return{html:$,hasScoped:!1};let Y=
|
|
2299
|
+
}`}return`${G} { ${K} }`}let W=KD(G,Z,Y,J),U=K;for(let[z,_]of X)U=U.replace(new RegExp(`\\b${z}\\b`,"g"),_);if(Q)U=U.replace(/--([a-z-]+)/gi,`--${Z}-$1`);return`${W} { ${U} }`}function KD($,Z,Y,J){let X=$.split(",").map((G)=>G.trim()),Q=[];for(let G of X){if(G.startsWith(":host")){if(J)Q.push(G);else{let U=G.replace(/:host(\([^)]*\))?/,`.${Z}$1`);Q.push(U)}continue}if(G.includes("::slotted")){Q.push(G);continue}if(G===":root"){Q.push(`:root .${Z}`);continue}let K=Y?`${Y} .${Z}`:`.${Z}`;Q.push(`${K} ${G}`);let W=WD(G,Z);if(W)Q.push(Y?`${Y} ${W}`:W)}return Q.join(", ")}function WD($,Z){let Y=0,J=$.length;for(let W=0;W<$.length;W++){let U=$[W];if(U==="["||U==="(")Y++;else if(U==="]"||U===")")Y--;else if(Y===0&&(U===" "||U===">"||U==="+"||U==="~")){J=W;break}}let X=$.slice(0,J),Q=$.slice(J);if(!X)return"";let G=X.length,K=0;for(let W=0;W<X.length;W++){let U=X[W];if(U==="["||U==="(")K++;else if(U==="]"||U===")")K--;else if(Y===0&&K===0&&U===":"){G=W;break}}return`${X.slice(0,G)}.${Z}${X.slice(G)}${Q}`}function u2($){let Z=new Set;return $.replace(/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi,(Y)=>{let J=Y.trim();if(Z.has(J))return"";return Z.add(J),Y})}function c7($,Z){if(!UD.test($))return{html:$,hasScoped:!1};let Y=aq(Z),J=`data-v-${Y}`,X=$,Q=new RegExp(`<style\\s+([^>]*${d2}[^>]*)>([\\s\\S]*?)</style>`,"gi"),G=!1;if(X=X.replace(Q,(K,W,U)=>{G=!0;let z=zD(U,J),_=W.replace(new RegExp(d2,"gi"),"").trim(),B=_?` ${_}`:"";return`<style data-stx-scoped="${Y}"${B}>${z}</style>`}),!G)return{html:$,hasScoped:!1};return X=BD(X,J),{html:X,hasScoped:!0}}function zD($,Z){return sq($,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${Z}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${Z}]`)}function BD($,Z){let Y=K4($,(X,Q)=>{let G=s4(X,Q);return G>Q?G:N$(X,Q)},(X,Q)=>_D(Q)),J=qD(Y.output,Z);return tq.lastIndex=0,J.replace(tq,(X,Q)=>Y.tokens[Number(Q)])}function qD($,Z){let Y=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return $.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(J,X,Q)=>{if(Y.has(X.toLowerCase()))return J;if(J.includes(Z))return J;if(X.toLowerCase()==="style"||X.toLowerCase()==="script")return J;if(Q)return J.replace(`<${X}${Q}`,`<${X} ${Z}${Q}`);if(J.endsWith("/>"))return`<${X} ${Z} />`;return`<${X} ${Z}>`})}var d2,UD,_D=($)=>`\x00stx-scope-mask-${$}\x00`,tq;var UY=D(()=>{f6();d2=String.raw`(?<![\w-])scoped(?![\w-])`,UD=new RegExp(`<style\\s+[^>]*${d2}`,"i");tq=/\u0000stx-scope-mask-(\d+)\u0000/g});function m2($){if($.includes("data-stx-cloak"))return $;let Z=$.lastIndexOf("</head>");if(Z===-1)return $;return`${$.slice(0,Z)}<style data-stx-cloak>[x-cloak]{display:none !important}</style>
|
|
2300
2300
|
${$.slice(Z)}`}function eq($){let Z=[],Y=0;while(Y<$.length){let Q=$.slice(Y),G=Q.match(/^\s+/);if(G){Y+=G[0].length;continue}if(Q.startsWith("<!--")){let _=$.indexOf("-->",Y);if(_===-1)break;Y=_+3;continue}let K=Q.match(/^<script\b[^>]*>/i);if(K){let _=$.toLowerCase().indexOf("</script>",Y+K[0].length);if(_===-1)break;Y=_+9;continue}let W=Q.match(/^<link\b[^>]*>/i);if(W){Z.push(W[0]),Y+=W[0].length;continue}let U=Q.match(/^<meta\b[^>]*>/i);if(U){Z.push(U[0]),Y+=U[0].length;continue}let z=Q.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(z){Z.push(z[0]),Y+=z[0].length;continue}break}if(Z.length===0)return{body:$,hoisted:Z};let J="",X=0;while(X<$.length&&X<Y){let Q=$.slice(X),G=Q.match(/^<link\b[^>]*>/i);if(G&&Z.includes(G[0])){X+=G[0].length;continue}let K=Q.match(/^<meta\b[^>]*>/i);if(K&&Z.includes(K[0])){X+=K[0].length;continue}let W=Q.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(W&&Z.includes(W[0])){X+=W[0].length;continue}J+=$[X],X++}return J+=$.slice(Y),{body:J,hoisted:Z}}function $j($,Z={},Y={}){let{title:J="stx App",lang:X="en",meta:Q=[],link:G=[],script:K=[],headRaw:W="",bodyClass:U="",bodyAttrs:z={}}=Z,_=Y.title||J,j=[...[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],...Q].map((R)=>{return` <meta ${Object.entries(R).map(([M,I])=>`${M}="${I}"`).join(" ")}>`}).join(`
|
|
2301
2301
|
`),H=G.map((R)=>{return` <link ${Object.entries(R).map(([M,I])=>`${M}="${I}"`).join(" ")}>`}).join(`
|
|
2302
2302
|
`),O=K.map((R)=>{if(R.src)return` <script ${Object.entries(R).filter(([M])=>M!=="content").map(([M,I])=>`${M}="${I}"`).join(" ")}></script>`;if(R.content)return` <script>${R.content}</script>`;return""}).filter(Boolean).join(`
|
|
@@ -2312,7 +2312,7 @@ ${N.join(`
|
|
|
2312
2312
|
</body>
|
|
2313
2313
|
</html>`}function zY($){return/<!DOCTYPE\b/i.test($)||/<html[\s>]/i.test($)}function l2($,Z={}){let Y=$.lastIndexOf("</head>");if(Y===-1)return $;let{meta:J=[],link:X=[],script:Q=[],headRaw:G=""}=Z,K=$.slice(0,Y),W=[];for(let U of J){let z=U.name?`name="${U.name}"`:U.property?`property="${U.property}"`:U.charset!=null?"charset=":U["http-equiv"]?`http-equiv="${U["http-equiv"]}"`:"";if(z&&K.includes(z))continue;W.push(` <meta ${Object.entries(U).map(([_,B])=>`${_}="${B}"`).join(" ")}>`)}for(let U of X){if(U.href&&K.includes(`href="${U.href}"`))continue;W.push(` <link ${Object.entries(U).map(([z,_])=>`${z}="${_}"`).join(" ")}>`)}for(let U of Q)if(U.src){if(K.includes(`src="${U.src}"`))continue;W.push(` <script ${Object.entries(U).filter(([z])=>z!=="content").map(([z,_])=>`${z}="${_}"`).join(" ")}></script>`)}else if(U.content){if(K.includes(U.content))continue;W.push(` <script>${U.content}</script>`)}if(G&&!K.includes(G))W.push(` ${G}`);if(W.length===0)return $;return`${$.slice(0,Y)}${W.join(`
|
|
2314
2314
|
`)}
|
|
2315
|
-
${$.slice(Y)}`}function p7($,Z={},Y={}){if(zY($))return $;return $j($,Z,Y)}var jD="<style data-stx-cloak>[x-cloak]{display:none !important}</style>";function n7($){let Z=$,Y=new Set,J=new Set,X=()=>{if(P1)J.add(P1);return Z};return X.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),i7)J.forEach((K)=>BY.add(K));else J.forEach((K)=>K())}},X.update=(Q)=>{X.set(Q(Z))},X.subscribe=(Q)=>{return Y.add(Q),()=>Y.delete(Q)},Object.defineProperty(X,"_isSignal",{value:!0,writable:!1}),Object.defineProperty(X,"value",{get:()=>X(),set:(Q)=>X.set(Q),configurable:!0}),X}function r7($){let Z,Y=!0,J=new Set,X=()=>{if(!Y)if(Y=!0,i7)J.forEach((G)=>BY.add(G));else J.forEach((G)=>G())},Q=()=>{if(P1)J.add(P1);if(Y){let G=P1;P1=X,_Y.push(X);try{Z=$()}finally{_Y.pop(),P1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Object.defineProperty(Q,"value",{get:()=>Q(),configurable:!0}),Q}function
|
|
2315
|
+
${$.slice(Y)}`}function p7($,Z={},Y={}){if(zY($))return $;return $j($,Z,Y)}var jD="<style data-stx-cloak>[x-cloak]{display:none !important}</style>";function n7($){let Z=$,Y=new Set,J=new Set,X=()=>{if(P1)J.add(P1);return Z};return X.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),i7)J.forEach((K)=>BY.add(K));else J.forEach((K)=>K())}},X.update=(Q)=>{X.set(Q(Z))},X.subscribe=(Q)=>{return Y.add(Q),()=>Y.delete(Q)},Object.defineProperty(X,"_isSignal",{value:!0,writable:!1}),Object.defineProperty(X,"value",{get:()=>X(),set:(Q)=>X.set(Q),configurable:!0}),X}function r7($){let Z,Y=!0,J=new Set,X=()=>{if(!Y)if(Y=!0,i7)J.forEach((G)=>BY.add(G));else J.forEach((G)=>G())},Q=()=>{if(P1)J.add(P1);if(Y){let G=P1;P1=X,_Y.push(X);try{Z=$()}finally{_Y.pop(),P1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Object.defineProperty(Q,"value",{get:()=>Q(),configurable:!0}),Q}function a7($,Z={}){let Y,J=!1,X=()=>{if(J)return;if(Y)Y(),Y=void 0;let Q=P1;P1=X,_Y.push(X);try{Y=$()}finally{_Y.pop(),P1=Q}};if(Z.immediate!==!1)X();return()=>{if(J=!0,Y)Y()}}function qY($){if(i7){$();return}i7=!0;try{$()}finally{i7=!1,BY.forEach((Z)=>Z()),BY.clear()}}function jY($){HD.push($)}function HY($){OD.push($)}function s7($){return typeof $==="function"&&$._isSignal===!0}function o7($){return typeof $==="function"&&$._isDerived===!0}function OY($){if(s7($)||o7($))return $();return $}function t7($){let Z=P1;P1=null;try{return $()}finally{P1=Z}}function Zj($,Z){let Y=typeof $==="function"?$:()=>$,J=n7([]),X=r7(()=>J().reduce((K,W)=>Z(K,W.action),Y())),Q=!1;return a7(()=>{if(Y(),!Q){Q=!0;return}if(t7(()=>J().length))J.set([])}),[X,(K,W)=>{let U={action:K};J.set([...J(),U]);let z=()=>{let _=J().filter((B)=>B!==U);if(_.length!==J().length)J.set(_)};if(W&&typeof W.then==="function")Promise.resolve(W).then(z,z);return z}]}var P1=null,_Y,i7=!1,BY,HD,OD;var c2=D(()=>{_Y=[],BY=new Set,HD=[],OD=[]});var LY={};$0(LY,{useOptimistic:()=>Zj,untrack:()=>OY,state:()=>n7,peek:()=>t7,onMount:()=>jY,onDestroy:()=>HY,isSignal:()=>s7,isDerived:()=>o7,generateSignalsRuntimeDev:()=>a6,generateSignalsRuntime:()=>e7,effect:()=>a7,derived:()=>r7,default:()=>VD,batch:()=>qY});function e7(){try{let $=LD(a6()),Y=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($);return Y=Y.replace(/\}(var |let |const |function )/g,"};$1"),Y}catch{return a6()}}function LD($){let Z=[],Y=0,J="console.log(";while(Y<$.length){let X=$.indexOf(J,Y);if(X===-1){Z.push($.slice(Y));break}Z.push($.slice(Y,X));let Q=1,G=X+J.length;while(G<$.length&&Q>0){let K=$[G];if(K==='"'||K==="'"||K==="`"){let W=K;G++;while(G<$.length&&$[G]!==W){if($[G]==="\\")G++;G++}G++;continue}if(K==="(")Q++;else if(K===")")Q--;G++}Z.push("0"),Y=G}return Z.join("")}function a6(){return`
|
|
2316
2316
|
// STX Signals Runtime (Development Build)
|
|
2317
2317
|
console.log('[stx] signals runtime loading');
|
|
2318
2318
|
// Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
|
|
@@ -2327,9 +2327,13 @@ console.log('[stx] entering IIFE');
|
|
|
2327
2327
|
|
|
2328
2328
|
// Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
2329
2329
|
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
2330
|
-
var cloakStyle = document.
|
|
2331
|
-
cloakStyle
|
|
2332
|
-
|
|
2330
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
2331
|
+
if (!cloakStyle) {
|
|
2332
|
+
cloakStyle = document.createElement('style');
|
|
2333
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
2334
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
2335
|
+
document.head.appendChild(cloakStyle);
|
|
2336
|
+
}
|
|
2333
2337
|
|
|
2334
2338
|
// ==========================================================================
|
|
2335
2339
|
// Reactive Core
|
|
@@ -8267,8 +8271,13 @@ else {
|
|
|
8267
8271
|
// Auto-initialization
|
|
8268
8272
|
// ==========================================================================
|
|
8269
8273
|
|
|
8270
|
-
|
|
8271
|
-
|
|
8274
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
8275
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
8276
|
+
// componentScope and reactive subscriptions.
|
|
8277
|
+
if (window.__stxDomReadyHandler) {
|
|
8278
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
8279
|
+
}
|
|
8280
|
+
const stxDomReadyHandler = () => {
|
|
8272
8281
|
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
8273
8282
|
// Track which scoped elements have been processed
|
|
8274
8283
|
const processedScopes = new Set();
|
|
@@ -8489,7 +8498,10 @@ catch (e) {
|
|
|
8489
8498
|
}
|
|
8490
8499
|
}
|
|
8491
8500
|
});
|
|
8492
|
-
}
|
|
8501
|
+
};
|
|
8502
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
8503
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
8504
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
8493
8505
|
|
|
8494
8506
|
// ==========================================================================
|
|
8495
8507
|
// Scope Disposal
|
|
@@ -8654,10 +8666,15 @@ catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
|
8654
8666
|
// Re-initialize components after SPA content swap.
|
|
8655
8667
|
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
8656
8668
|
var _stxLoadTimer = null;
|
|
8657
|
-
window.
|
|
8669
|
+
if (window.__stxLoadHandler) {
|
|
8670
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
8671
|
+
}
|
|
8672
|
+
function stxLoadHandler() {
|
|
8658
8673
|
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
8659
8674
|
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
8660
|
-
}
|
|
8675
|
+
}
|
|
8676
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
8677
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
8661
8678
|
function _handleStxLoad() {
|
|
8662
8679
|
_stxLoadTimer = null;
|
|
8663
8680
|
console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);
|
|
@@ -8854,7 +8871,7 @@ catch (e) { console.warn('[stx] mount callback error:', e); }
|
|
|
8854
8871
|
}
|
|
8855
8872
|
}
|
|
8856
8873
|
})();
|
|
8857
|
-
`}var VD;var c$=D(()=>{c2();c2();VD={state:n7,derived:r7,effect:
|
|
8874
|
+
`}var VD;var c$=D(()=>{c2();c2();VD={state:n7,derived:r7,effect:a7,batch:qY,onMount:jY,onDestroy:HY,isSignal:s7,isDerived:o7,untrack:OY,peek:t7,generateSignalsRuntime:e7,generateSignalsRuntimeDev:a6}});var n$={};$0(n$,{templateCache:()=>p2,readFileCached:()=>Yj,invalidateFileCacheByDir:()=>Xj,invalidateFileCache:()=>Jj,hashFilePath:()=>i$,getCachedSignalsRuntime:()=>Kj,getCachedRouterScript:()=>Wj,clearDevCaches:()=>Uj,checkCache:()=>AY,cacheTemplate:()=>wY,__setSignalsGeneratorsForTest:()=>Gj});import _6 from"fs";import p$ from"path";async function Yj($){let Y;for(let J=0;J<3;J++)try{let Q=(await _6.promises.stat($)).mtime.getTime(),G=s6.get($);if(G&&G.mtime===Q)return G.content;let K=await Bun.file($).text(),U=(await _6.promises.stat($)).mtime.getTime();if(U!==Q)continue;return s6.set($,{content:K,mtime:U}),K}catch(X){Y=X;break}throw s6.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function Jj($){s6.delete($)}function Xj($){for(let Z of s6.keys())if(Z.startsWith($))s6.delete(Z)}function Gj($){Qj=$}async function Kj($=!1){let Z=Qj??await Promise.resolve().then(() => (c$(),LY));if($)return Z.generateSignalsRuntimeDev();if(VY===null)VY=Z.generateSignalsRuntime();return VY}async function Wj(){if(FY===null){let{getRouterScript:$}=await import("stx-router");FY=$()}return FY}function Uj(){s6.clear(),j4(),VY=null,FD=null,FY=null}function zj($){let Z={debug:$.debug===!0,middleware:($.middleware??[]).map((Y)=>({name:Y.name,timing:Y.timing,handler:String(Y.handler)})),customDirectives:($.customDirectives??[]).map((Y)=>({name:Y.name,hasEndTag:Y.hasEndTag===!0,handler:String(Y.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(Z)).digest("hex")}async function AY($,Z){try{if(!Z.cachePath)return null;let Y=p$.resolve(Z.cachePath),J=p$.join(Y,`${i$($)}.html`),X=p$.join(Y,`${i$($)}.meta.json`);if(!await Q0(J)||!await Q0(X))return null;let Q=await Bun.file(X).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if(G.optionsSignature!==zj(Z))return null;if((await _6.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await Q0(W)){if((await _6.promises.stat(W)).mtime.getTime()>G.mtime)return null}else return null;return await Bun.file(J).text()}catch(Y){return console.warn(`Cache error for ${$}:`,Y),null}}async function wY($,Z,Y,J){try{if(!J.cachePath)return;let X=p$.resolve(J.cachePath);await _6.promises.mkdir(X,{recursive:!0});let Q=p$.join(X,`${i$($)}.html`),G=p$.join(X,`${i$($)}.meta.json`),K=await _6.promises.stat($);await Bun.write(Q,Z);let W={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:J.cacheVersion,optionsSignature:zj(J),generatedAt:Date.now()};await Bun.write(G,JSON.stringify(W,null,2)),p2.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(X){console.warn(`Failed to cache template ${$}:`,X)}}function i$($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,AD)}var p2,s6,VY=null,FD=null,Qj=null,FY=null,AD=16;var o6=D(()=>{N0();p2=new Map,s6=new Map});function _j($){if($.includes("window.StacksBrowser")||$.includes("StacksBrowser ="))return $;let Z=/<script\b(?![^>]*\bserver\b)[^>]*>([\s\S]*?)<\/script>/gi,Y="",J;while((J=Z.exec($))!==null)Y+=J[1]+`
|
|
8858
8875
|
`;let X=/\{\{([\s\S]*?)\}\}/g;while((J=X.exec($))!==null)Y+=J[1]+`
|
|
8859
8876
|
`;if(!Y.trim())return $;let G=["browserQuery","BrowserQueryBuilder","configureBrowser","createBrowserModel","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useDocumentVisibility","useIntervalFn"].some((B)=>{return new RegExp(`\\b${B}\\b`).test(Y)}),K=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process"]),W=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,U,z=!1;while((U=W.exec(Y))!==null)if(!K.has(U[1])){z=!0;break}if(!G&&!z)return $;let _=`<script type="module">
|
|
8860
8877
|
// STX: Auto-load @stacksjs/browser (auto-initializes API and loads models)
|
|
@@ -8875,10 +8892,10 @@ ${_}`);return _+`
|
|
|
8875
8892
|
`+X+$.slice(K+1)}return X+`
|
|
8876
8893
|
`+$}async function D4($,Z){if(!$.includes("</body>"))return $;if($.includes("data-stx-router")||$.includes("__stxRouter)return")||$.includes("__stxRouter=true"))return $;let Y=Z?.router,J="";if(Y){let K={};if(Y.container)K.container=Y.container;if(Y.interceptAllLinks!==void 0)K.interceptAllLinks=Y.interceptAllLinks;if(Y.progress!==void 0)K.progress=Y.progress;if(Y.viewTransitions!==void 0)K.viewTransitions=Y.viewTransitions;if(Y.viewTransitionDuration!==void 0)K.viewTransitionDuration=Y.viewTransitionDuration;if(Y.viewTransitionEasing!==void 0)K.viewTransitionEasing=Y.viewTransitionEasing;if(Y.scrollToTop!==void 0)K.scrollToTop=Y.scrollToTop;if(Y.prefetch!==void 0)K.prefetch=Y.prefetch;if(Y.cache!==void 0)K.cache=Y.cache;if(Y.progressColor!==void 0)K.progressColor=Y.progressColor;if(Y.progressHeight!==void 0)K.progressHeight=Y.progressHeight;if(Object.keys(K).length>0)J=`<script>window.__stxRouterConfig=${JSON.stringify(K)};</script>
|
|
8877
8894
|
`}let{getCachedRouterScript:X}=await Promise.resolve().then(() => (o6(),n$)),Q=Z?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':Z?.buildMode==="serve"?'<script data-stx-router src="/_stx/router.js"></script>':`<script data-stx-router>${await X()}</script>`,G=$.lastIndexOf("</body>");return $.slice(0,G)+J+Q+`
|
|
8878
|
-
</body>`+$.slice(G+7)}var TY={};$0(TY,{scanScriptTags:()=>Fj,rewriteStxImportSpecifiers:()=>Rj,processSignals:()=>
|
|
8879
|
-
`)}else{if(!Oj(q,Y,Z))continue;A=NY(J(F),"@if",q)}W.push({start:U,end:O,replacement:A}),G.lastIndex=O}for(let U=W.length-1;U>=0;U--){let{start:z,end:_,replacement:B}=W[U];Q=Q.substring(0,z)+B+Q.substring(_)}return Q}return J($)}function ED($){let Z=$.trim();if(Z==="")return;if(Z==="true")return!0;if(Z==="false")return!1;if(Z==="null")return!1;if(Z==="undefined")return!1;if(Z==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(Z)){let X=Number(Z);return X!==0&&!Number.isNaN(X)}let Y=Z.match(/^'((?:\\.|[^'\\])*)'$/);if(Y)return Y[1].length>0;let J=Z.match(/^"((?:\\.|[^"\\])*)"$/);if(J)return J[1].length>0;return}function ID($,Z,Y,J){if(i2.has(Y.toLowerCase()))return J;let X=Y.toLowerCase(),Q=$.toLowerCase(),G=$.length,K=1,W=J;while(W<G){let U=$.indexOf("<",W);if(U===-1)return-1;if(W=U,$.startsWith("<!--",W)){let q=$.indexOf("-->",W+4);if(q===-1)return-1;W=q+3;continue}let z=/^<(script|style)\b/i.exec($.slice(W,W+8));if(z){let q=$.indexOf(">",W);if(q===-1)return-1;if($[q-1]==="/"){W=q+1;continue}let j=Q.indexOf(`</${z[1].toLowerCase()}`,W);if(j===-1)return-1;let H=$.indexOf(">",j);if(H===-1)return-1;W=H+1;continue}if($[W+1]==="/"){let q=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(W,W+64));if(!q){W++;continue}if(q[1].toLowerCase()===X){if(K--,W+=q[0].length,K===0)return W;continue}W+=q[0].length;continue}let _=/^<([a-z][\w-]*)\b/i.exec($.slice(W,W+64));if(!_){W++;continue}let B=$.indexOf(">",W);if(B===-1)return-1;if(_[1].toLowerCase()===X){let q=$.slice(W,B+1);if(!(/\/\s*>$/.test(q)||i2.has(X)))K++}W=B+1}return-1}function kD($,Z){let Y=Z,J=$.length;for(;;){while(Y<J&&$[Y]!=="<")Y++;if(Y>=J)return!1;if($.startsWith("<!--",Y)){let G=$.indexOf("-->",Y+4);if(G===-1)return!1;Y=G+3;continue}break}if($[Y+1]==="/")return!1;let X=$.indexOf(">",Y);if(X===-1)return!1;let Q=$.slice(Y,X+1);return DD.test(Q)}function r2($){if(!$.includes(":if")&&!$.includes(":show")&&!$.includes("x-if")&&!$.includes("x-show")&&!$.includes("@if=")&&!$.includes("@show="))return $;let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);let X=(_)=>Z.some(([B,q])=>_>=B&&_<q),Q=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,G=[],K;while((K=Q.exec($))!==null){if(X(K.index))continue;let[_,B,q,j,H,O,V]=K,L=ED(H);if(L===void 0)continue;let F=K.index,A=F+_.length,R=!!V||/\/\s*>$/.test(_)||i2.has(B.toLowerCase())?A:ID($,F,B,A);if(R===-1)continue;if((j===":if"||j==="x-if"||j==="@if")&&kD($,R)){Q.lastIndex=A;continue}if(L===!0){let M=`<${B}${q}${O}${V}>`;G.push({start:F,end:A,replacement:M});continue}G.push({start:F,end:R,replacement:""}),Q.lastIndex=R}if(G.length===0)return $;G.sort((_,B)=>_.start-B.start);let W=[],U=-1;for(let _ of G){if(_.start<U)continue;W.push(_),U=_.end}let z=$;for(let _=W.length-1;_>=0;_--){let{start:B,end:q,replacement:j}=W[_];z=z.substring(0,B)+j+z.substring(q)}return z}function
|
|
8895
|
+
</body>`+$.slice(G+7)}var TY={};$0(TY,{scanScriptTags:()=>Fj,rewriteStxImportSpecifiers:()=>Rj,processSignals:()=>s2,processScriptSetup:()=>wj,preEvalLiteralReactiveIfs:()=>r2,parseLoopExpression:()=>Aj,hasSignalsSyntax:()=>MY,findMarkupIndexOutsideScripts:()=>RY,extractExports:()=>Nj,convertSignalLoopsToAttributes:()=>a2,convertSignalDirectivesToAttributes:()=>n2});function Fj($,Z={}){let Y=[];for(let J of hX($,s4)){let X=J.token.match(/^<script\b([^>]*)>/i),Q=J.token.match(/<\/script\s*>$/i);if(!X||!Q)continue;let G=X[1];if(Z.skipAttrs){if(Z.skipAttrs.lastIndex=0,Z.skipAttrs.test(G))continue}let K=X[0].length,W=J.token.length-Q[0].length;Y.push({fullMatch:J.token,attrs:G,body:J.token.slice(K,W),start:J.start,end:J.end})}return Y}function Aj($){let Z=$.trim(),Y=Z.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(Y){let X=Y[1].trim(),Q=Y[2].trim(),{itemVar:G,indexVar:K}=jj(Q);if(G)return{style:"as",iterable:X,itemVar:G,indexVar:K}}let J=Z.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(J){let X=J[1].trim(),Q=J[2].trim(),{itemVar:G,indexVar:K}=jj(X);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function jj($){let Z=$.trim(),Y=Z.match(/^(\w+)\s*=>\s*(\w+)$/);if(Y)return{itemVar:Y[2],indexVar:Y[1]};let J=Z.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(J)return{itemVar:J[1],indexVar:J[2]||null};let X=Z.match(/^(\w+)\s*,\s*(\w+)$/);if(X)return{itemVar:X[1],indexVar:X[2]};let Q=Z.match(/^(\w+)$/);if(Q)return{itemVar:Q[1],indexVar:null};return{itemVar:null,indexVar:null}}function MY($){return[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/\buseId\s*\(/,/\buseReactiveProp\s*(?:<[^>]*>)?\s*\(/,/\s:(?:if|else-if|else|for|show|text|html|model)\s*=/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/].some((Y)=>Y.test($))}function ND($){let Z=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,Y=0,J;while((J=Z.exec($))!==null){let X=J[1];if(X.startsWith("if"))Y++;else if(X==="endif")Y--;else if(Y===0)return!0}return!1}function RD($){let Z=new Set,Y=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,J=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,X;while((X=Y.exec($))!==null){let Q=X[1],G;while((G=J.exec(Q))!==null)Z.add(G[1])}return Z}function MD($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function Oj($,Z,Y){if(!$)return!1;let J=MD($),X=!1,Q=!1,G=!1,K=/([a-zA-Z_$][\w$]*)/g,W;while((W=K.exec(J))!==null){let B=W[1];if(J.slice(0,W.index).trimEnd().endsWith("."))continue;if(Hj.has(B))continue;if(Z.has(B))X=!0;else if(Y&&B in Y)Q=!0}let U=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,z;while((z=U.exec(J))!==null){let B=z[1];if(J.slice(0,z.index).trimEnd().endsWith("."))continue;if(Hj.has(B)||Y&&B in Y)continue;G=!0}return(X||G)&&!Q}function NY($,Z,Y){let J=Y===void 0?` ${Z}`:` ${Z}="${Y.replace(/"/g,""")}"`,X=$.trim(),Q=X.match(Vj);if(Q&&TD(Q[3],Q[1])){let[,G,K,W]=Q;return`<${G}${K}${J}>${W}</${G}>`}return`<template${J}>${X}</template>`}function TD($,Z){let Y=new RegExp(`<(/)?${Z}(?=[\\s/>])`,"gi"),J=0,X;while((X=Y.exec($))!==null)if(X[1]){if(J--,J<0)return!1}else J++;return!0}function n2($,Z){let Y=RD($);function J(X){let Q=X,G=/@if\s*\(/g,K,W=[];while((K=G.exec(Q))!==null){let U=K.index,z=U+K[0].length,_=1,B=z;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")")_--;B++}if(_!==0)continue;let q=Q.substring(z,B-1).trim(),j=B,H=1,O=j,V=/@(if\s*\(|endif)/g;V.lastIndex=j;let L;while((L=V.exec(Q))!==null)if(L[1].startsWith("if"))H++;else if(L[1]==="endif"){if(H--,H===0){O=L.index+L[0].length;break}}if(H!==0)continue;let F=Q.substring(j,O-6).trim(),A;if(ND(F)){let w=P$(Q.substring(U,O));if(w.length===0)continue;let N=w[0].branches.filter((M)=>M.type!=="else");if(!(N.length>0&&N.every((M)=>Oj(M.condition,Y,Z))))continue;A=w[0].branches.map((M)=>{let I=J(M.content);if(M.type==="elseif")return NY(I,"@else-if",M.condition??"");if(M.type==="else")return NY(I,"@else");return NY(I,"@if",M.condition??"")}).join(`
|
|
8896
|
+
`)}else{if(!Oj(q,Y,Z))continue;A=NY(J(F),"@if",q)}W.push({start:U,end:O,replacement:A}),G.lastIndex=O}for(let U=W.length-1;U>=0;U--){let{start:z,end:_,replacement:B}=W[U];Q=Q.substring(0,z)+B+Q.substring(_)}return Q}return J($)}function ED($){let Z=$.trim();if(Z==="")return;if(Z==="true")return!0;if(Z==="false")return!1;if(Z==="null")return!1;if(Z==="undefined")return!1;if(Z==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(Z)){let X=Number(Z);return X!==0&&!Number.isNaN(X)}let Y=Z.match(/^'((?:\\.|[^'\\])*)'$/);if(Y)return Y[1].length>0;let J=Z.match(/^"((?:\\.|[^"\\])*)"$/);if(J)return J[1].length>0;return}function ID($,Z,Y,J){if(i2.has(Y.toLowerCase()))return J;let X=Y.toLowerCase(),Q=$.toLowerCase(),G=$.length,K=1,W=J;while(W<G){let U=$.indexOf("<",W);if(U===-1)return-1;if(W=U,$.startsWith("<!--",W)){let q=$.indexOf("-->",W+4);if(q===-1)return-1;W=q+3;continue}let z=/^<(script|style)\b/i.exec($.slice(W,W+8));if(z){let q=$.indexOf(">",W);if(q===-1)return-1;if($[q-1]==="/"){W=q+1;continue}let j=Q.indexOf(`</${z[1].toLowerCase()}`,W);if(j===-1)return-1;let H=$.indexOf(">",j);if(H===-1)return-1;W=H+1;continue}if($[W+1]==="/"){let q=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(W,W+64));if(!q){W++;continue}if(q[1].toLowerCase()===X){if(K--,W+=q[0].length,K===0)return W;continue}W+=q[0].length;continue}let _=/^<([a-z][\w-]*)\b/i.exec($.slice(W,W+64));if(!_){W++;continue}let B=$.indexOf(">",W);if(B===-1)return-1;if(_[1].toLowerCase()===X){let q=$.slice(W,B+1);if(!(/\/\s*>$/.test(q)||i2.has(X)))K++}W=B+1}return-1}function kD($,Z){let Y=Z,J=$.length;for(;;){while(Y<J&&$[Y]!=="<")Y++;if(Y>=J)return!1;if($.startsWith("<!--",Y)){let G=$.indexOf("-->",Y+4);if(G===-1)return!1;Y=G+3;continue}break}if($[Y+1]==="/")return!1;let X=$.indexOf(">",Y);if(X===-1)return!1;let Q=$.slice(Y,X+1);return DD.test(Q)}function r2($){if(!$.includes(":if")&&!$.includes(":show")&&!$.includes("x-if")&&!$.includes("x-show")&&!$.includes("@if=")&&!$.includes("@show="))return $;let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);let X=(_)=>Z.some(([B,q])=>_>=B&&_<q),Q=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,G=[],K;while((K=Q.exec($))!==null){if(X(K.index))continue;let[_,B,q,j,H,O,V]=K,L=ED(H);if(L===void 0)continue;let F=K.index,A=F+_.length,R=!!V||/\/\s*>$/.test(_)||i2.has(B.toLowerCase())?A:ID($,F,B,A);if(R===-1)continue;if((j===":if"||j==="x-if"||j==="@if")&&kD($,R)){Q.lastIndex=A;continue}if(L===!0){let M=`<${B}${q}${O}${V}>`;G.push({start:F,end:A,replacement:M});continue}G.push({start:F,end:R,replacement:""}),Q.lastIndex=R}if(G.length===0)return $;G.sort((_,B)=>_.start-B.start);let W=[],U=-1;for(let _ of G){if(_.start<U)continue;W.push(_),U=_.end}let z=$;for(let _=W.length-1;_>=0;_--){let{start:B,end:q,replacement:j}=W[_];z=z.substring(0,B)+j+z.substring(q)}return z}function a2($,Z){let Y=$,J=/@(for|foreach)\s*\(/g,X,Q=[];while((X=J.exec(Y))!==null){let G=X[1],K=X.index,W=K+X[0].length,U=1,z=W;while(z<Y.length&&U>0){if(Y[z]==="(")U++;else if(Y[z]===")")U--;z++}if(U!==0)continue;let _=Y.substring(W,z-1).trim(),B=z,q=Aj(_);if(q.iterable){let N=q.iterable.trim();if(N.startsWith("[")||N.startsWith("{")||N.startsWith("'")||N.startsWith('"')||N.startsWith("`")||/^-?\d/.test(N))continue;if(Z){let R=N.split(/[.[(]/)[0].trim();if(R&&R in Z)continue}}if(q.style==="as")_=q.indexVar?`(${q.itemVar}, ${q.indexVar}) in ${q.iterable}`:`${q.itemVar} in ${q.iterable}`;let j=G==="for"?"@endfor":"@endforeach",H=1,O=B,V=G==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${G}\\s*\\(|end${G})`,"g");V.lastIndex=B;let L;while((L=V.exec(Y))!==null)if(L[1].startsWith(G))H++;else if(H--,H===0){O=L.index+L[0].length;break}if(H!==0)continue;let F=Y.substring(B,O-j.length).trim(),A=F.match(Vj),w;if(A){let[,N,R,E]=A;w=`<${N}${R} @for="${_}">${E}</${N}>`}else w=`<template @for="${_}">${F}</template>`;Q.push({start:K,end:O,replacement:w})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Y=Y.substring(0,K)+U+Y.substring(W)}return Y}function SD($){let Z=new Set,Y=[],J=0,X=0,Q=$.length,G=(z)=>{let _=J+1;while(_<Q){let B=$[_];if(B==="\\"){_+=2;continue}if(B===z)return _+1;_++}return Q},K=()=>{let z=J+2;while(z<Q&&$[z]!==`
|
|
8880
8897
|
`)z++;return z},W=()=>{let z=J+2;while(z<Q-1){if($[z]==="*"&&$[z+1]==="/")return z+2;z++}return Q},U=(z)=>{let _=z,B=0;while(_<Q){let q=$[_];if(q==="/"&&$[_+1]==="/"){let j=_+2;while(j<Q&&$[j]!==`
|
|
8881
|
-
`)j++;_=j;continue}if(q==="/"&&$[_+1]==="*"){let j=_+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;_=j+2;continue}if(q==='"'||q==="'"||q==="`"){let j=_+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===q){j++;break}j++}_=j;continue}if(q==="("||q==="["||q==="{"){B++,_++;continue}if(q===")"||q==="]"||q==="}"){B--,_++;continue}if(q===";"&&B===0)return _+1;_++}return Q};while(J<Q){let z=$[J];if(z==="/"&&$[J+1]==="/"){let _=K();Y.push($.slice(J,_)),J=_;continue}if(z==="/"&&$[J+1]==="*"){let _=W();Y.push($.slice(J,_)),J=_;continue}if(z==='"'||z==="'"||z==="`"){let _=G(z);Y.push($.slice(J,_)),J=_;continue}if(z==="{"){X++,Y.push(z),J++;continue}if(z==="}"){X--,Y.push(z),J++;continue}if(X===0){let _=J>0?$[J-1]:"";if(_===""||/\s/.test(_)||_===";"||_==="}"||_==="{"){let q=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(q){let j=q[2],H=U(J+q[0].length);if(Z.has(j)){Y.push(`/* stx: deduped const ${j} */`),J=H;continue}Z.add(j),Y.push($.slice(J,H)),J=H;continue}}}Y.push(z),J++}return Y.join("")}async function wj($,Z,Y){let J=Fj($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),X=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useId|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,Q=[];for(let O of J){let V=O.body;if(r4(O.attrs))V=
|
|
8898
|
+
`)j++;_=j;continue}if(q==="/"&&$[_+1]==="*"){let j=_+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;_=j+2;continue}if(q==='"'||q==="'"||q==="`"){let j=_+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===q){j++;break}j++}_=j;continue}if(q==="("||q==="["||q==="{"){B++,_++;continue}if(q===")"||q==="]"||q==="}"){B--,_++;continue}if(q===";"&&B===0)return _+1;_++}return Q};while(J<Q){let z=$[J];if(z==="/"&&$[J+1]==="/"){let _=K();Y.push($.slice(J,_)),J=_;continue}if(z==="/"&&$[J+1]==="*"){let _=W();Y.push($.slice(J,_)),J=_;continue}if(z==='"'||z==="'"||z==="`"){let _=G(z);Y.push($.slice(J,_)),J=_;continue}if(z==="{"){X++,Y.push(z),J++;continue}if(z==="}"){X--,Y.push(z),J++;continue}if(X===0){let _=J>0?$[J-1]:"";if(_===""||/\s/.test(_)||_===";"||_==="}"||_==="{"){let q=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(q){let j=q[2],H=U(J+q[0].length);if(Z.has(j)){Y.push(`/* stx: deduped const ${j} */`),J=H;continue}Z.add(j),Y.push($.slice(J,H)),J=H;continue}}}Y.push(z),J++}return Y.join("")}async function wj($,Z,Y){let J=Fj($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),X=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useId|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,Q=[];for(let O of J){let V=O.body;if(r4(O.attrs))V=a4(V);if(X.test(V))Q.push({fullMatch:O.fullMatch,attrs:O.attrs,content:V})}if(Q.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${wD++}`,{hasUserImports:K,bundleClientScript:W}=await Promise.resolve().then(() => (K7(),G7)),U=[];for(let O=0;O<Q.length;O++){let V=Q[O].content;if(V=x6(V).code,K(V))console.log("[stx:bundler] bundling signal script imports"),V=await W(V,Z||"",{projectRoot:process.cwd()});V=V.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(F,A)=>Rj(A));let L=c1(V);U.push(`// \u2500\u2500 merged signal script #${O+1} \u2500\u2500
|
|
8882
8899
|
${L}`)}let z=U.join(`
|
|
8883
8900
|
|
|
8884
8901
|
`);z=SD(z);let _=Nj(z),B=_.split(",").map((O)=>O.trim()).filter(Boolean),q=_7(z,Y),j=`
|
|
@@ -8892,7 +8909,7 @@ window.__stx_latestSetup=${G};
|
|
|
8892
8909
|
if(window.stx)window.stx._latestSetup=${G};
|
|
8893
8910
|
</script>`,H=$;for(let O of Q)H=H.split(O.fullMatch).join("");if(H.includes("<body"))H=H.replace(new RegExp(`<body(${qj})>`),`<body$1 data-stx="${G}">`);else{let O=["script","style","html","head","meta","link","title","!doctype"],V=!1;H=H.replace(new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${qj})>`,"gi"),(L,F,A)=>{if(V||O.includes(F.toLowerCase()))return L;return V=!0,`<${F}${A} data-stx="${G}">`})}return{output:H,setupCode:j}}function Nj($){let Z=$,Y=[],J=new Set,X=0,Q=0,G=Z.length,K="",W=()=>{Q++;let j=!1;while(Q<G){let H=Z[Q];if(H==="\\"){Q+=2;continue}if(H==="["&&!j){j=!0,Q++;continue}if(H==="]"&&j){j=!1,Q++;continue}if(H==="/"&&!j){Q++;while(Q<G&&/[gimsuyd]/.test(Z[Q]))Q++;return}if(H===`
|
|
8894
8911
|
`)return;Q++}},U=()=>{if(!K)return!0;if(/[\w)\]]/.test(K))return!1;return!0},z=(j)=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]===j){Q++;return}Q++}},_=()=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]==="`"){Q++;return}if(Z[Q]==="$"&&Z[Q+1]==="{"){Q+=2;let j=1;while(Q<G&&j>0)if(Z[Q]==="{")j++,Q++;else if(Z[Q]==="}")j--,Q++;else if(Z[Q]==="'"||Z[Q]==='"')z(Z[Q]);else if(Z[Q]==="`")_();else Q++;continue}Q++}},B=()=>{if(Z[Q]==="/"&&Z[Q+1]==="/"){while(Q<G&&Z[Q]!==`
|
|
8895
|
-
`)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},q=()=>{if(X!==0)return;let j=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let F=j[2];if(!J.has(F))Y.push(F),J.add(F);return}let H=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(H){H[1].split(",").forEach((F)=>{let A=F.trim();if(!A)return;let w=A.indexOf(":"),R=(w>=0?A.slice(w+1).trim():A).split(/[\s=]/)[0];if(R&&!J.has(R))Y.push(R),J.add(R)});return}let O=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(O){O[1].split(",").forEach((F)=>{let A=F.trim().replace(/^\.\.\./,"");if(!A)return;let w=A.split(/[\s=]/)[0];if(w&&!J.has(w))Y.push(w),J.add(w)});return}let V=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let F=V[1];if(!J.has(F))Y.push(F),J.add(F);return}let L=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let F=L[1];if(!J.has(F))Y.push(F),J.add(F)}};while(Q<G){if(B())continue;if(Z[Q]==="'"||Z[Q]==='"'){z(Z[Q]),K=Z[Q-1];continue}if(Z[Q]==="`"){_(),K="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&U()){W(),K="/";continue}if(Z[Q]==="{"){X++,K="{",Q++;continue}if(Z[Q]==="}"){X--,K="}",Q++;continue}if(X===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))q();if(!/\s/.test(Z[Q]))K=Z[Q];Q++}return Y.join(", ")}async function
|
|
8912
|
+
`)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},q=()=>{if(X!==0)return;let j=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let F=j[2];if(!J.has(F))Y.push(F),J.add(F);return}let H=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(H){H[1].split(",").forEach((F)=>{let A=F.trim();if(!A)return;let w=A.indexOf(":"),R=(w>=0?A.slice(w+1).trim():A).split(/[\s=]/)[0];if(R&&!J.has(R))Y.push(R),J.add(R)});return}let O=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(O){O[1].split(",").forEach((F)=>{let A=F.trim().replace(/^\.\.\./,"");if(!A)return;let w=A.split(/[\s=]/)[0];if(w&&!J.has(w))Y.push(w),J.add(w)});return}let V=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let F=V[1];if(!J.has(F))Y.push(F),J.add(F);return}let L=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let F=L[1];if(!J.has(F))Y.push(F),J.add(F)}};while(Q<G){if(B())continue;if(Z[Q]==="'"||Z[Q]==='"'){z(Z[Q]),K=Z[Q-1];continue}if(Z[Q]==="`"){_(),K="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&U()){W(),K="/";continue}if(Z[Q]==="{"){X++,K="{",Q++;continue}if(Z[Q]==="}"){X--,K="}",Q++;continue}if(X===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))q();if(!/\s/.test(Z[Q]))K=Z[Q];Q++}return Y.join(", ")}async function s2($,Z,Y,J){if(!MY($))return $;let X=$;if(Z.skipSignalsRuntime)return X;let{output:Q,setupCode:G}=await wj(X,Y,J);if(X=Q,X=await Bj(X,Z),X=_j(X),G){let z=RY(X,/<\/head>/i),_=z===-1?RY(X,/<body[^>]*>/i):-1;if(z!==-1)X=`${X.slice(0,z)}${G}
|
|
8896
8913
|
${X.slice(z)}`;else if(_!==-1){let B=/<body[^>]*>/i.exec(X.slice(_))[0],q=_+B.length;X=`${X.slice(0,q)}
|
|
8897
8914
|
${G}${X.slice(q)}`}else X=`${X}
|
|
8898
8915
|
${G}`}let W=X.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),U=W&&/data-stx/.test(W[1]);if(!G&&!U&&W&&!/data-stx-auto/.test(W[1])){let z=/<body[^>]*>/i,_=RY(X,z);if(_!==-1){let B=X.slice(0,_),q=X.slice(_).replace(z,(j)=>j.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));X=B+q}}return X}function RY($,Z){let Y=/<(script|style)\b[\s\S]*?<\/\1>/gi,J=[],X;while((X=Y.exec($))!==null)J.push([X.index,X.index+X[0].length]);let Q=new RegExp(Z.source,Z.flags.replace(/[gy]/g,"")),G=0;while(G<$.length){let K=Q.exec($.slice(G));if(!K)return-1;let W=G+K.index;if(!J.some(([z,_])=>W>=z&&W<_))return W;G=W+Math.max(K[0].length,1)}return-1}function Rj($){let Z=[];for(let Y of $.split(",")){let J=Y.trim();if(!J||J.startsWith("type "))continue;let X=J.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(X&&X[1]!==X[2])Z.push(`${X[2]} = ${X[1]}`)}if(Z.length===0)return Lj;return`var ${Z.join(", ")}; ${Lj}`}var wD=0,qj=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Vj,Hj,i2,DD,Lj="/* [stx import stripped, resolved via window.stx in __stx_setup] */";var $8=D(()=>{v6();S7();F7();N0();f6();Vj=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;Hj=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);i2=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);DD=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/});import r$ from"path";function Mj($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}async function Tj($,Z,Y){try{let J;if($.startsWith("/")){let X=Z;for(let Q=0;Q<5;Q++){let G=r$.join(X,$);if(await Bun.file(G).exists())return G;X=r$.dirname(X)}J=r$.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))J=r$.resolve(Z,$);else J=r$.resolve(Z,$);if(await Bun.file(J).exists())return J;return null}catch{return null}}async function Ej($,Z,Y){let J=$,X=r$.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(J))!==null){let[U,z,_,B]=G;if(Mj(_))continue;let q=await Tj(_,X,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),_.endsWith(".ts")||_.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:F1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
|
|
@@ -8906,13 +8923,13 @@ ${O}
|
|
|
8906
8923
|
\u2192 ${W}`)}}if(Q.length>0&&J.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
|
|
8907
8924
|
${Q.join(`
|
|
8908
8925
|
`)}
|
|
8909
|
-
Tip: prefer useRef(), navigate(), and composables for component code`;if(J.failOnViolation)throw Error(K);else console.warn(K)}}var bD;var e2=D(()=>{bD=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/window\.localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}]});var Cj={};$0(Cj,{getStoreScript:()=>PD,clearStoreCache:()=>yD});import EY from"path";async function PD($){let Z;if($)Z=EY.resolve($);else{let z=await d0();Z=EY.resolve(z.root||process.cwd(),z.storesDir||"stores")}let Y=
|
|
8910
|
-
${_.trim()}`)}catch(_){console.warn(`[stx] Failed to load store ${z}:`,_)}if(K.length===0)return
|
|
8926
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(J.failOnViolation)throw Error(K);else console.warn(K)}}var bD;var e2=D(()=>{bD=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/window\.localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}]});var Cj={};$0(Cj,{getStoreScript:()=>PD,clearStoreCache:()=>yD});import EY from"path";async function PD($){let Z;if($)Z=EY.resolve($);else{let z=await d0();Z=EY.resolve(z.root||process.cwd(),z.storesDir||"stores")}let Y=a$.get(Z);if(Y!==void 0)return Y||null;let J=new Bun.Glob("*.ts"),X=[];try{for await(let z of J.scan({cwd:Z,absolute:!0})){let _=EY.basename(z,".ts");if(["index","types"].includes(_))continue;if(z.includes(".d.ts"))continue;X.push(z)}}catch{return a$.set(Z,""),null}if(X.length===0)return a$.set(Z,""),null;let Q=[];for(let z of X){let _=await Bun.file(z).text();Q.push({file:z,hasUseStore:/useStore\s*\(/.test(_)})}Q.sort((z,_)=>{if(z.hasUseStore===_.hasUseStore)return 0;return z.hasUseStore?1:-1});let G=Q.map((z)=>z.file),K=[],W=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()});for(let z of G)try{let _=await Bun.file(z).text(),B=EY.basename(z,".ts");_=_.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),_=_.replace(/^export\s+(default\s+)?/gm,""),_=W.transformSync(_),K.push(`// Store: ${B}
|
|
8927
|
+
${_.trim()}`)}catch(_){console.warn(`[stx] Failed to load store ${z}:`,_)}if(K.length===0)return a$.set(Z,""),null;let U=`;(function(){
|
|
8911
8928
|
${K.join(`
|
|
8912
8929
|
|
|
8913
8930
|
`)}
|
|
8914
|
-
})();`;return
|
|
8915
|
-
${j.trim()}`)}catch(j){console.warn(`[stx] Failed to load composable ${q}:`,j)}if(Q.length===0||G.size===0)return
|
|
8931
|
+
})();`;return a$.set(Z,U),U}function yD(){a$.clear()}var a$;var bj=D(()=>{r0();p4();a$=new Map});var yj={};$0(yj,{getComposableScript:()=>gD,clearComposableCache:()=>hD});import X8 from"path";function Pj($){let Z=X8.basename($,".ts");return Z==="index"||Z==="types"||$.endsWith(".d.ts")}async function vD($){if($)return X8.resolve($);let Z=`<default>:${process.cwd()}`,Y=$Q.get(Z);if(Y!==void 0)return Y;let J=await fD();return $Q.set(Z,J),J}async function fD(){let $=await d0(),Z=$.root||process.cwd(),Y=$.composablesDir;if(Y)return X8.resolve(Z,Y);for(let J of xD){let X=X8.resolve(Z,J);try{let Q=new Bun.Glob("**/*.ts");for await(let G of Q.scan({cwd:X,absolute:!0}))if(!Pj(G))return X}catch{}}return null}async function gD($){let Z=await vD($);if(!Z)return null;let Y=s$.get(Z);if(Y!==void 0)return Y||null;let J=[];try{let q=new Bun.Glob("**/*.ts");for await(let j of q.scan({cwd:Z,absolute:!0})){if(Pj(j))continue;J.push(j)}}catch{return s$.set(Z,""),null}if(J.length===0)return s$.set(Z,""),null;J.sort();let X=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()}),Q=[],G=new Set,K=new Set;for(let q of J)try{let j=await Bun.file(q).text(),H=X8.basename(q,".ts");for(let O of j.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(O[1])K.add(O[1]);try{for(let O of X.scan(j).exports)if(O!=="default")G.add(O)}catch{}j=c1(j),j=j.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^export\s+(default\s+)?/gm,""),j=X.transformSync(j),Q.push(`// Composable: ${H}
|
|
8932
|
+
${j.trim()}`)}catch(j){console.warn(`[stx] Failed to load composable ${q}:`,j)}if(Q.length===0||G.size===0)return s$.set(Z,""),null;let W=[...G].map((q)=>` try { __c[${JSON.stringify(q)}] = ${q}; } catch (e) {}`).join(`
|
|
8916
8933
|
`),U=JSON.stringify([...G]),z=Q.join(`
|
|
8917
8934
|
|
|
8918
8935
|
`),B=`;(function(){
|
|
@@ -8936,7 +8953,7 @@ ${W}
|
|
|
8936
8953
|
}
|
|
8937
8954
|
window[__n] = __c[__n];
|
|
8938
8955
|
}
|
|
8939
|
-
})();`;return
|
|
8956
|
+
})();`;return s$.set(Z,B),B}function hD(){s$.clear(),$Q.clear()}var s$,$Q,xD;var xj=D(()=>{r0();p4();F7();s$=new Map,$Q=new Map,xD=["composables","functions"]});var gj={};$0(gj,{processDeferDirectives:()=>fj});function dD(){return`stx-defer-${++vj}`}function uD($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function mD($,Z,Y){let{trigger:J,value:X}=uD(Z),Q=Y,G,K,W,U=Y.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(U)G=U[1].trim(),Q=Q.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let z=Y.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(z)K=z[1].trim(),Q=Q.replace(/@loading[\s\S]*?(?=@error|$)/,"");let _=Y.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(_)W=_[2].trim(),Q=Q.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return Q=Q.trim(),{trigger:J,triggerValue:X,content:Q,placeholder:G,loading:K,error:W}}function lD($,Z){let{trigger:Y,triggerValue:J}=Z,X;switch(Y){case"visible":X=`
|
|
8940
8957
|
const observer = new IntersectionObserver((entries) => {
|
|
8941
8958
|
if (entries[0].isIntersecting) {
|
|
8942
8959
|
observer.disconnect();
|
|
@@ -9085,7 +9102,7 @@ else {
|
|
|
9085
9102
|
});
|
|
9086
9103
|
})();
|
|
9087
9104
|
</script>
|
|
9088
|
-
`}var hj=0;var tj={};$0(tj,{processTransitionDirectives:()=>rj,processTransitionAttributes:()=>oj,performLeave:()=>nj,performEnter:()=>ij,generateTransitionRuntime:()=>
|
|
9105
|
+
`}var hj=0;var tj={};$0(tj,{processTransitionDirectives:()=>rj,processTransitionAttributes:()=>oj,performLeave:()=>nj,performEnter:()=>ij,generateTransitionRuntime:()=>sj,generateTransitionCSS:()=>aj});function lj($,Z={}){return{enterFrom:Z.enterClass||`${$}-enter-from`,enterActive:Z.enterActiveClass||`${$}-enter-active`,enterTo:Z.enterToClass||`${$}-enter-to`,leaveFrom:Z.leaveClass||`${$}-leave-from`,leaveActive:Z.leaveActiveClass||`${$}-leave-active`,leaveTo:Z.leaveToClass||`${$}-leave-to`}}function nD($){let Z=getComputedStyle($),Y=Z.transitionDuration||"0s",J=Z.animationDuration||"0s",X=(Q)=>{let G=Q.match(/^([\d.]+)(s|ms)?$/);if(!G)return 0;let K=parseFloat(G[1]);return(G[2]||"s")==="ms"?K:K*1000};return Math.max(X(Y),X(J))}function cj($,Z){return new Promise((Y)=>{let J=Z??nD($);if(J===0){Y();return}let X=!1,Q=()=>{if(X)return;X=!0,$.removeEventListener("transitionend",G),$.removeEventListener("animationend",G),Y()},G=(K)=>{if(K.target===$)Q()};$.addEventListener("transitionend",G),$.addEventListener("animationend",G),setTimeout(Q,J+50)})}function pj($){$.offsetHeight}async function ij($,Z={}){let Y=Z.name||"stx",J=lj(Y,Z),X=typeof Z.duration==="object"?Z.duration.enter:Z.duration;if(Z.onBeforeEnter?.($),$.classList.add(J.enterFrom),$.classList.add(J.enterActive),pj($),$.classList.remove(J.enterFrom),$.classList.add(J.enterTo),Z.onEnter)await new Promise((Q)=>{Z.onEnter($,Q)});else await cj($,X);$.classList.remove(J.enterActive),$.classList.remove(J.enterTo),Z.onAfterEnter?.($)}async function nj($,Z={}){let Y=Z.name||"stx",J=lj(Y,Z),X=typeof Z.duration==="object"?Z.duration.leave:Z.duration;if(Z.onBeforeLeave?.($),$.classList.add(J.leaveFrom),$.classList.add(J.leaveActive),pj($),$.classList.remove(J.leaveFrom),$.classList.add(J.leaveTo),Z.onLeave)await new Promise((Q)=>{Z.onLeave($,Q)});else await cj($,X);$.classList.remove(J.leaveActive),$.classList.remove(J.leaveTo),Z.onAfterLeave?.($)}function rj($,Z={},Y){let J=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return $.replace(J,(X,Q,G)=>{let K=rD(Q),W=K.name||"stx",U=K.duration||300,z=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
|
|
9089
9106
|
<div
|
|
9090
9107
|
class="stx-transition-wrapper"
|
|
9091
9108
|
data-transition="${W}"
|
|
@@ -9127,7 +9144,7 @@ else {
|
|
|
9127
9144
|
});
|
|
9128
9145
|
})();
|
|
9129
9146
|
</script>
|
|
9130
|
-
`})}function rD($){let Z={},Y=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,J;while((J=Y.exec($))!==null){let X=J[1],Q=J[2]||J[3]||J[4]||J[5];switch(X){case"name":Z.name=Q;break;case"duration":Z.duration=parseInt(Q,10);break;case"mode":Z.mode=Q;break;case"easing":Z.easing=Q;break}}return Z}function
|
|
9147
|
+
`})}function rD($){let Z={},Y=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,J;while((J=Y.exec($))!==null){let X=J[1],Q=J[2]||J[3]||J[4]||J[5];switch(X){case"name":Z.name=Q;break;case"duration":Z.duration=parseInt(Q,10);break;case"mode":Z.mode=Q;break;case"easing":Z.easing=Q;break}}return Z}function aj(){return`
|
|
9131
9148
|
/* STX Transition Presets */
|
|
9132
9149
|
|
|
9133
9150
|
/* Fade */
|
|
@@ -9314,7 +9331,7 @@ else {
|
|
|
9314
9331
|
opacity: 1;
|
|
9315
9332
|
max-height: 1000px;
|
|
9316
9333
|
}
|
|
9317
|
-
`}function
|
|
9334
|
+
`}function sj(){return`
|
|
9318
9335
|
// STX Transition Runtime
|
|
9319
9336
|
(function() {
|
|
9320
9337
|
if (typeof window === 'undefined') return;
|
|
@@ -9403,7 +9420,7 @@ else {
|
|
|
9403
9420
|
|
|
9404
9421
|
console.log('[stx] Transition runtime initialized');
|
|
9405
9422
|
})();
|
|
9406
|
-
`}function oj($){let Z=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return $.replace(Z,(Y,J,X,Q)=>{let G=X||"300",K=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${J}" data-stx-transition-duration="${G}" data-stx-transition-condition="${Q}" data-stx-transition-id="${K}"`})}var $H={};$0($H,{withErrorBoundary:()=>ej,processErrorBoundaryDirectives:()=>oD,generateErrorBoundaryRuntime:()=>Yk,generateErrorBoundaryCSS:()=>Zk,createErrorBoundary:()=>$k});function
|
|
9423
|
+
`}function oj($){let Z=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return $.replace(Z,(Y,J,X,Q)=>{let G=X||"300",K=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${J}" data-stx-transition-duration="${G}" data-stx-transition-condition="${Q}" data-stx-transition-id="${K}"`})}var $H={};$0($H,{withErrorBoundary:()=>ej,processErrorBoundaryDirectives:()=>oD,generateErrorBoundaryRuntime:()=>Yk,generateErrorBoundaryCSS:()=>Zk,createErrorBoundary:()=>$k});function sD(){return`eb-${++aD}-${Date.now().toString(36)}`}function oD($,Z={},Y){let J=/@errorBoundary(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@enderrorBoundary/gi;return $.replace(J,(X,Q,G,K)=>{let W=sD(),U=tD(Q||"");return eD(W,G.trim(),K.trim(),U)})}function tD($){let Z={},Y=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\w+))/g,J;while((J=Y.exec($))!==null){let X=J[1],Q=J[2]||J[3]||J[4];switch(X){case"id":Z.id=Q;break;case"logErrors":Z.logErrors=Q==="true";break}}return Z}function eD($,Z,Y,J){let X=J.logErrors!==!1;return`
|
|
9407
9424
|
<div class="stx-error-boundary" data-boundary-id="${$}" data-has-error="false">
|
|
9408
9425
|
<div class="stx-error-boundary-content" data-boundary-content="${$}">
|
|
9409
9426
|
${Z}
|
|
@@ -9632,7 +9649,7 @@ else {
|
|
|
9632
9649
|
|
|
9633
9650
|
console.log('[stx] Error boundary runtime initialized');
|
|
9634
9651
|
})();
|
|
9635
|
-
`}var
|
|
9652
|
+
`}var aD=0;var GH={};$0(GH,{renderSSRSuspense:()=>JH,processSuspenseDirectives:()=>ZH,generateSuspenseRuntime:()=>QH,generateSuspenseCSS:()=>XH,createSSRSuspense:()=>YH});function Xk(){return`suspense-${++Jk}-${Date.now().toString(36)}`}function ZH($,Z={},Y){let J=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return $.replace(J,(X,Q,G,K)=>{let W=Xk(),U=Qk(Q||"");return Gk(W,G.trim(),K.trim(),U)})}function Qk($){let Z={},Y=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,J;while((J=Y.exec($))!==null){let X=J[1],Q=J[2]||J[3],G=J[4];switch(X){case"id":Z.id=Q;break;case"timeout":Z.timeout=G?parseInt(G,10):void 0;break}}return Z}function Gk($,Z,Y,J){let X=J.timeout||30000,Q=J.id||$;return`
|
|
9636
9653
|
<div class="stx-suspense" data-suspense-id="${$}" data-custom-id="${Q}" data-status="pending">
|
|
9637
9654
|
<div class="stx-suspense-fallback" data-suspense-fallback="${$}">
|
|
9638
9655
|
${Y}
|
|
@@ -11580,7 +11597,7 @@ else {
|
|
|
11580
11597
|
})();
|
|
11581
11598
|
</script>`}function pH($){return/\bx-data(?:\s|=)/.test($)}function Tk($){let Z=/<script\b(?=[^>]*\bdata-stx-x-element-runtime\b)[^>]*>[\s\S]*?<\/script>\s*/gi,Y=$.match(Z)||[],J=Y.length>0?$.replace(Z,""):$;if(!pH(J))return J;let X=Y[0]?.trim()||cH(),Q=J.lastIndexOf("</body>");if(Q!==-1)return J.slice(0,Q)+X+`
|
|
11582
11599
|
`+J.slice(Q);return J+`
|
|
11583
|
-
`+X}var nH={};$0(nH,{rewriteImagesWithSiblings:()=>SY});import k4 from"path";async function SY($,Z){let Y=Z.formats??Ik;if(!Z.publicDir)return $;let J=Sk($),X=[],Q=/<img\b[^>]*?>/gi,G=[],K;while((K=Q.exec($))!==null){let _=K[0],B=_.match(/\bsrc=["']([^"']+)["']/i);if(!B)continue;if(Ck(K.index,J))continue;G.push({idx:K.index,length:_.length,src:B[1],raw:_})}if(G.length===0)return $;let W=await Promise.all(G.map(async(_)=>{let B=await Dk(_.src,Z.publicDir,Y);return{match:_,sources:B}}));for(let{match:_,sources:B}of W){if(B.length===0)continue;let j=`<picture>${B.map((H)=>`<source type="${H.mime}" srcset="${bk(H.url)}">`).join("")}${_.raw}</picture>`;X.push({start:_.idx,end:_.idx+_.length,replacement:j})}if(X.length===0)return $;let U="",z=0;for(let _ of X)U+=$.slice(z,_.start),U+=_.replacement,z=_.end;return U+=$.slice(z),U}async function Dk($,Z,Y){if(!kk($))return[];let J=k4.extname($).toLowerCase();if(!Ek.has(J))return[];if(!$.startsWith("/"))return[];let X=k4.join(Z,$.slice(1)),Q=k4.dirname(X),G=k4.basename(X,J),K=k4.resolve(Q),W=k4.resolve(Z);if(!K.startsWith(W))return[];let U=k4.posix.dirname($),z=Y.map(async(B)=>{let q=k4.join(Q,`${G}${B.ext}`);if(!await Bun.file(q).exists())return null;return{url:k4.posix.join(U,`${G}${B.ext}`),mime:B.mime}});return(await Promise.all(z)).filter((B)=>B!==null)}function kk($){if(!$)return!1;if($.startsWith("http://")||$.startsWith("https://"))return!1;if($.startsWith("//"))return!1;if($.startsWith("data:"))return!1;return!0}function Sk($){let Z=[],Y=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);return Z}function Ck($,Z){for(let[Y,J]of Z)if($>=Y&&$<J)return!0;return!1}function bk($){return $.replace(/&/g,"&").replace(/"/g,""")}var Ek,Ik;var AQ=D(()=>{Ek=new Set([".jpg",".jpeg",".png",".gif"]),Ik=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}]});var rH=()=>{};function wQ($){return $.pwa?.serviceWorker?.fileName||"sw.js"}var
|
|
11600
|
+
`+X}var nH={};$0(nH,{rewriteImagesWithSiblings:()=>SY});import k4 from"path";async function SY($,Z){let Y=Z.formats??Ik;if(!Z.publicDir)return $;let J=Sk($),X=[],Q=/<img\b[^>]*?>/gi,G=[],K;while((K=Q.exec($))!==null){let _=K[0],B=_.match(/\bsrc=["']([^"']+)["']/i);if(!B)continue;if(Ck(K.index,J))continue;G.push({idx:K.index,length:_.length,src:B[1],raw:_})}if(G.length===0)return $;let W=await Promise.all(G.map(async(_)=>{let B=await Dk(_.src,Z.publicDir,Y);return{match:_,sources:B}}));for(let{match:_,sources:B}of W){if(B.length===0)continue;let j=`<picture>${B.map((H)=>`<source type="${H.mime}" srcset="${bk(H.url)}">`).join("")}${_.raw}</picture>`;X.push({start:_.idx,end:_.idx+_.length,replacement:j})}if(X.length===0)return $;let U="",z=0;for(let _ of X)U+=$.slice(z,_.start),U+=_.replacement,z=_.end;return U+=$.slice(z),U}async function Dk($,Z,Y){if(!kk($))return[];let J=k4.extname($).toLowerCase();if(!Ek.has(J))return[];if(!$.startsWith("/"))return[];let X=k4.join(Z,$.slice(1)),Q=k4.dirname(X),G=k4.basename(X,J),K=k4.resolve(Q),W=k4.resolve(Z);if(!K.startsWith(W))return[];let U=k4.posix.dirname($),z=Y.map(async(B)=>{let q=k4.join(Q,`${G}${B.ext}`);if(!await Bun.file(q).exists())return null;return{url:k4.posix.join(U,`${G}${B.ext}`),mime:B.mime}});return(await Promise.all(z)).filter((B)=>B!==null)}function kk($){if(!$)return!1;if($.startsWith("http://")||$.startsWith("https://"))return!1;if($.startsWith("//"))return!1;if($.startsWith("data:"))return!1;return!0}function Sk($){let Z=[],Y=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);return Z}function Ck($,Z){for(let[Y,J]of Z)if($>=Y&&$<J)return!0;return!1}function bk($){return $.replace(/&/g,"&").replace(/"/g,""")}var Ek,Ik;var AQ=D(()=>{Ek=new Set([".jpg",".jpeg",".png",".gif"]),Ik=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}]});var rH=()=>{};function wQ($){return $.pwa?.serviceWorker?.fileName||"sw.js"}var aH=D(()=>{rH()});var sH={};$0(sH,{injectPwaTags:()=>Pk,generateThemeColorMeta:()=>vk,generateSwRegistrationScript:()=>yk,generatePwaTags:()=>CY,generateManifestLink:()=>xk});function CY($){let Z=$.pwa;if(!Z?.enabled)return"";let Y=Z.manifest,J=Z.icons?.outputDir?`/${Z.icons.outputDir}`:"/pwa-icons",X=wQ($),Q=`
|
|
11584
11601
|
<!-- stx PWA Meta Tags -->
|
|
11585
11602
|
<link rel="manifest" href="/manifest.json">
|
|
11586
11603
|
<meta name="theme-color" content="${NQ(Y?.themeColor||"#000000")}">
|
|
@@ -11638,7 +11655,7 @@ if ('serviceWorker' in navigator) {
|
|
|
11638
11655
|
});
|
|
11639
11656
|
});
|
|
11640
11657
|
}
|
|
11641
|
-
</script>`}function xk(){return'<link rel="manifest" href="/manifest.json">'}function vk($){return`<meta name="theme-color" content="${NQ($)}">`}function NQ($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var oH=D(()=>{
|
|
11658
|
+
</script>`}function xk(){return'<link rel="manifest" href="/manifest.json">'}function vk($){return`<meta name="theme-color" content="${NQ($)}">`}function NQ($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var oH=D(()=>{aH()});var PY={};$0(PY,{validateClientScript:()=>J8,processOnceDirective:()=>Y8,processJsonDirective:()=>Z8,processDirectives:()=>q0,injectRouterScript:()=>D4});import M1 from"path";import{deriveLayoutGroup as fk}from"stx-router/layout-metadata";function tH($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function gk($,Z){let Y=$.length,J=Z,X=!0,Q=[],G=(K)=>K+9<=Y&&$[K]==="<"&&$[K+1]==="/"&&($[K+2]==="s"||$[K+2]==="S")&&($[K+3]==="c"||$[K+3]==="C")&&($[K+4]==="r"||$[K+4]==="R")&&($[K+5]==="i"||$[K+5]==="I")&&($[K+6]==="p"||$[K+6]==="P")&&($[K+7]==="t"||$[K+7]==="T")&&($[K+8]===">"||/\s/.test($[K+8]));while(J<Y){let K=$[J];if(G(J))return J;if(K==="/"&&$[J+1]==="/"){if(J=$.indexOf(`
|
|
11642
11659
|
`,J+2),J===-1)return-1;J+=1,X=!0;continue}if(K==="/"&&$[J+1]==="*"){let W=$.indexOf("*/",J+2);if(W===-1)return-1;J=W+2,X=!0;continue}if(K==="/"&&X){let W=J+1,U=!1;while(W<Y){let z=$[W];if(z==="\\"){W+=2;continue}if(z==="[")U=!0;else if(z==="]")U=!1;else if(z==="/"&&!U){W++;break}else if(z===`
|
|
11643
11660
|
`){W=-1;break}W++}if(W===-1){J++,X=!1;continue}while(W<Y&&/[a-z]/.test($[W]))W++;J=W,X=!1;continue}if(K==="'"||K==='"'){let W=K;J++;while(J<Y){if($[J]==="\\"){J+=2;continue}if($[J]===W){J++;break}if($[J]===`
|
|
11644
11661
|
`)break;J++}X=!1;continue}if(K==="`"){J++;while(J<Y){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;break}if($[J]==="$"&&$[J+1]==="{"){Q.push(!0),J+=2,X=!0;break}J++}if(Q.length===0)X=!1;continue}if(K==="}"&&Q.length>0){Q.pop(),J++;while(J<Y){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++,X=!1;break}if($[J]==="$"&&$[J+1]==="{"){Q.push(!0),J+=2,X=!0;break}J++}continue}if(/\s/.test(K));else if(/[)\].\w$]/.test(K))X=!1;else X=!0;J++}return-1}function bY($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=new RegExp(`<script\\b(?=[^>]*\\b${Y}(?:\\s|=|/?>))[^>]*>`,"i").exec($);if(!J)return null;let X=J.index+J[0].length,Q=$.indexOf("</script>",X);if(Q===-1)return null;let G=$.indexOf(">",Q);if(G===-1)return null;return{start:J.index,end:G+1}}function eH($){let Z=0;while(Z<$.length){let Y=$.indexOf("<",Z);if(Y===-1)return-1;if($.startsWith("<!--",Y)){let Q=$.indexOf("-->",Y+4);Z=Q===-1?$.length:Q+3;continue}let J=$.slice(Y),X=/^<style\b[^>]*>/i.exec(J);if(X){let Q=$.toLowerCase().indexOf("</style>",Y+X[0].length);Z=Q===-1?$.length:Q+8;continue}if(/^<script\b[^>]*>/i.test(J))return Y;Z=Y+1}return-1}function hk($){let Z=bY($,"data-stx-runtime");if(!Z)return $;let Y=eH($);if(Y===-1||Y===Z.start)return $;let J=$.slice(Z.start,Z.end),X=$.slice(0,Z.start)+$.slice(Z.end),Q=eH(X);if(Q===-1)return J+`
|
|
@@ -11653,27 +11670,27 @@ ${W.trim()}
|
|
|
11653
11670
|
@endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,F,A)=>{return j[F]=A,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,F,A)=>{if(/^(['"]).*\1$/.test(A.trim()))return L;try{let w=V0(A.trim(),Z);if(w===void 0)return L;return j[F]=String(w??""),""}catch{return L}}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,F,A)=>{if(A.includes("@parent"))j[F]=A.replace("@parent",e6);else j[F]=A.trim();return""}),Z.__sections=j,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,F,A)=>{return j[F]||A||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(W=JY(W,q),H){let L=[],F=o4(W),A=K4(F.output,N$,(w,N)=>`\x00STX_ORPHAN_STYLE_${N}\x00`);if(W=A.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(w,N,R)=>{let E=N==="SCRIPT"?F.scripts[Number(R)]:A.tokens[Number(R)];if(E)L.push(E);return""}),L.length>0){let w=L.join(`
|
|
11654
11671
|
`);j.content=j.content?`${j.content}
|
|
11655
11672
|
${w}`:w,Z.__sections=j}}if(H)try{let L;if(M1.isAbsolute(H))L=H,X.add(H);else L=await z4(()=>K8(H,Y,G,X),null,()=>{throw new r1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!L){let E=`Layout not found: ${H} (referenced from ${Y})`;if(K1.log(Error(E),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new r1(E,Y);return W}let F=await z4(()=>Bun.file(L).text(),"",()=>{throw new r1(`Failed to read layout file: ${L}`,Y,void 0,void 0,"Layout content could not be loaded")}),A=F.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${L}`);let E={},M=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(k,x,y)=>{return E[x]=y.trim(),""});for(let[k,x]of Object.entries(E))if(j[k]&&j[k].includes(e6)){let y=j[k].indexOf(e6);j[k]=j[k].slice(0,y)+x+j[k].slice(y+e6.length)}else if(!j[k])j[k]=x;let I={...Z,__sections:j},S=`@layout('${A[1]}')${M}`;return await q0(S,I,L,G,X)}let w=F.replace(/\{\{--[\s\S]*?--\}\}/g,""),N=YY(w,q),R={};return N=N.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(E,M,I)=>{return R[M]=I.trim(),`@slot('${M}')`}),N=N.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(E,M,I)=>{if(j[M]){let S=j[M];if(S.includes(e6)){let k=R[M]||"",x=S.indexOf(e6);S=S.slice(0,x)+k+S.slice(x+e6.length)}return S}return I||""}),N=uk(N,j),N=N.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),N=JY(N,q),Z.__originalFilePath=Y,W=await $O(N,Z,L,G,X),W=`<!-- stx-layout: ${H} -->
|
|
11656
|
-
${W}`,_(W)}catch(L){return K1.log(L instanceof Error?L:Error(String(L)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${L instanceof Error?L.message:String(L)}]`}return _(await $O(W,Z,Y,G,X))}function uk($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,J,X)=>{let Q=Z[J];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return X||""})}function mk($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",J={};for(let[X,Q]of Object.entries(process.env))if(X.startsWith(Y)&&Q!==void 0)J[X]=Q;$.$env=J}async function lk($,Z){await z4(()=>cq($,Z),void 0,(Y)=>{K1.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function ck($,Z,Y){let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X;while((X=J.exec($))!==null){let Q=X[1],G=X[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (K6(),
|
|
11673
|
+
${W}`,_(W)}catch(L){return K1.log(L instanceof Error?L:Error(String(L)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${L instanceof Error?L.message:String(L)}]`}return _(await $O(W,Z,Y,G,X))}function uk($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,J,X)=>{let Q=Z[J];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return X||""})}function mk($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",J={};for(let[X,Q]of Object.entries(process.env))if(X.startsWith(Y)&&Q!==void 0)J[X]=Q;$.$env=J}async function lk($,Z){await z4(()=>cq($,Z),void 0,(Y)=>{K1.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function ck($,Z,Y){let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X;while((X=J.exec($))!==null){let Q=X[1],G=X[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (K6(),aZ));await W(G,Z,Y,{preserveExisting:!0})}catch(W){let U=W instanceof Error?W:Error(String(W));K1.log(U,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${U.message}`)}}}async function pk($,Z,Y){try{let{interpolateScriptsInTemplate:J}=await Promise.resolve().then(() => ($1(),V7));return J($,Z,{skipServer:!0})}catch(J){let X=J instanceof Error?J:Error(String(J));return K1.log(X,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${X.message}`),$}}async function $O($,Z,Y,J,X){let Q=$,G=J;if(await ck(Q,Z,Y),Q=await pk(Q,Z,Y),Q=await vq(Q,Z,Y),Q=await fq(Q,Z,Y),Q=await R9(Q,Z,Y,G),g6(Q))Q=n2(Q,Z),Q=a2(Q,Z);Q=r2(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (G6(),i6));Q=K(Q,Z),Q=eZ(Q,Z,Y,G),Q=await nZ(Q,Z,Y,G,X),Q=await f2(Q,Z,Y,G,X),Q=IX(Q,Z,Y,G);let{processDeferDirectives:W}=await Promise.resolve().then(() => gj);Q=W(Q,Z,Y);let{processTeleportDirectives:U}=await Promise.resolve().then(() => mj);Q=U(Q,Z,Y);let{processTransitionDirectives:z,processTransitionAttributes:_}=await Promise.resolve().then(() => tj);Q=z(Q,Z,Y),Q=_(Q);let{processErrorBoundaryDirectives:B}=await Promise.resolve().then(() => $H);Q=B(Q,Z,Y);let{processSuspenseDirectives:q}=await Promise.resolve().then(() => GH);Q=q(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => HH);Q=j(Q,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => MH);Q=H(Q,Z,Y);let{processVirtualListDirectives:O,processVirtualGridDirectives:V,processInfiniteListDirectives:L}=await Promise.resolve().then(() => (QQ(),TH));Q=O(Q,Z,Y),Q=V(Q,Z,Y),Q=L(Q,Z,Y);let{processPartialHydrationDirectives:F,processStaticDirectives:A}=await Promise.resolve().then(() => (FQ(),EH));Q=F(Q,Z,Y),Q=A(Q);let{processComputedDirectives:w,processWatchDirectives:N}=await Promise.resolve().then(() => (gH(),fH));Q=w(Q,Z,Y),Q=N(Q,Z,Y);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (lH(),mH));Q=R(Q,Z,Y);let{processHeadDirective:E,processTitleDirective:M,processMetaDirective:I,resetHead:S}=await Promise.resolve().then(() => (c6(),D9));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)S();let k=E(Q);if(Q=k.content,k.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${k.headContent}
|
|
11657
11674
|
`;if(Q=M(Q,Z),Q=I(Q,Z),Q=uq(Q),Q=B9(Q,Z),Q=YB(Q),Q=dq(Q),Q=await ZY(Q,Z,Y,G,X),Q=await nZ(Q,Z,Y,G,X),Z.__stxProcessingDepth===1)Q=yz(Q,Z);if(Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=o2(Q),Q=d6(Q,Z,Y),Q=q9(Q,Z),Q=j9(Q,Z),Q=y$(Q,Z),Q=xZ(Q,Z),Q=vZ(Q,Z),Q=await MQ(Q,Z,Y,G),Q=await RQ(Q,Z,Y),Q=await v9(Q,Z,Y,G),Q=MX(Q,Z,Y,G),Q=S2(Q,Z,Y,G),Q=C2(Q,Z,Y),Q=b2(Q,Z,Y,G),Q=A9(Q,Z,Y,G),Q=Z8(Q,Z),Q=Y8(Q),Q=Dj(Q),!G.skipEventDirectives)Q=Z9(Q,Z,Y);if(Q=L_(Q,Z,Y),G.debug){let W0=/\bx-data\s*=/.test(Q),p=MY($);if(W0&&p)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
11658
11675
|
Both work on the same page, but they manage separate scopes.
|
|
11659
|
-
Prefer signals (state/derived/effect) for new components.`)}Q=KY(Q,Z),Q=await d1(Q,Z,Y),Q=kj(Q),Q=Sj(Q),Q=
|
|
11676
|
+
Prefer signals (state/derived/effect) for new components.`)}Q=KY(Q,Z),Q=await d1(Q,Z,Y),Q=kj(Q),Q=Sj(Q),Q=sX(Q);let{processXElementDirectives:x}=await Promise.resolve().then(() => iH);Q=x(Q);let y=Z.__originalFilePath||Y,b=i4(Z);if(Q=await s2(Q,G,y,b),Q=T9(Q,Z),Q=await D2(Q,Z,Y,G),G.media?.image?.autoSiblings){let W0=G.publicDir||"public",{rewriteImagesWithSiblings:p}=await Promise.resolve().then(() => (AQ(),nH));Q=await p(Q,{publicDir:W0})}if(G.seo?.enabled)Q=P2(Q,Z,G);let h=(W0,p,t=!0)=>{if(!p)return W0;let _0=p.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),v=W0.match(/<title\b[^>]*>[\s\S]*?<\/title>/i);if(_0&&v){if(t)W0=W0.replace(v[0],_0[0]);if(p=p.replace(_0[0],"").trim(),!p)return W0}if(/<\/head>/i.test(W0))return W0.replace(/<\/head>/i,`${p}
|
|
11660
11677
|
</head>`);if(/<head\b[^>]*>/i.test(W0))return W0.replace(/(<head\b[^>]*>)/i,`$1
|
|
11661
11678
|
${p}`);if(/<html\b[^>]*>/i.test(W0))return W0.replace(/(<html\b[^>]*>)/i,`$1
|
|
11662
11679
|
<head>
|
|
11663
11680
|
${p}
|
|
11664
|
-
</head>`);return W0},{renderHead:r,getHead:m}=await Promise.resolve().then(() => (c6(),D9)),d=Z.__stx_runtime_head??m();if(d.title||d.meta?.length||d.link?.length){let W0=r(d);if(W0)Q=h(Q,W0)}if(k.headContent)Q=h(Q,k.headContent,!d.title);if(G.csp?.enabled&&G.csp.addMetaTag)Q=V9(Q,G.csp,Z);if(G.analytics?.enabled)Q=eX(Q,G);if(G.heatmap?.enabled)Q=SX(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:W0}=await Promise.resolve().then(() => (oH(),
|
|
11681
|
+
</head>`);return W0},{renderHead:r,getHead:m}=await Promise.resolve().then(() => (c6(),D9)),d=Z.__stx_runtime_head??m();if(d.title||d.meta?.length||d.link?.length){let W0=r(d);if(W0)Q=h(Q,W0)}if(k.headContent)Q=h(Q,k.headContent,!d.title);if(G.csp?.enabled&&G.csp.addMetaTag)Q=V9(Q,G.csp,Z);if(G.analytics?.enabled)Q=eX(Q,G);if(G.heatmap?.enabled)Q=SX(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:W0}=await Promise.resolve().then(() => (oH(),sH));Q=W0(Q,G)}let l=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),c=/\bSTX\.\w+/.test(Q),a=/window\.STX\s*=/.test(Q);if(l&&c&&!a){let p=`<script data-stx-scoped>
|
|
11665
11682
|
${Y_()}
|
|
11666
11683
|
</script>`;if(Q.includes("</head>")){let t=Q.indexOf("</head>"),v=Q.slice(0,t).indexOf("<script");if(v!==-1){let C=Q.slice(0,v),u=Q.slice(v);Q=C+p+`
|
|
11667
11684
|
`+u}else Q=Q.replace("</head>",`${p}
|
|
11668
11685
|
</head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
|
|
11669
11686
|
${p}`);else Q=p+`
|
|
11670
|
-
`+Q}{let{scanScriptTags:W0}=await Promise.resolve().then(() => ($8(),TY)),p=[];for(let t of W0(Q)){if(!/\bserver\b/i.test(t.attrs))continue;let _0=t.start+t.fullMatch.indexOf(">")+1,v=gk(Q,_0);if(v===-1)continue;let C=v+9;while(C<Q.length&&/\s/.test(Q[C]))C++;p.push({start:t.start,end:C})}for(let t=p.length-1;t>=0;t--){let{start:_0,end:v}=p[t];Q=Q.substring(0,_0)+Q.substring(v)}}let X0=c7(Q,Y);if(X0.hasScoped)Q=X0.html;let K0=Z.__stx_event_bindings||[],C0=!1,z1=[],b0=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:l1}=await Promise.resolve().then(() => ($8(),TY));for(let W0 of l1(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))z1.push({match:W0.fullMatch,attrs:W0.attrs,content:W0.body});for(let{match:W0,attrs:p,content:t}of z1){C0=!0;let _0=t;J8(t,Y,J.strict);let v=await n4(t,{eventBindings:K0,attrs:p,hasColonDirectives:b0,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:b});Q=Q.replace(W0,()=>v)}if(C0)Z.__stx_event_bindings=[];if(G.csp?.enabled&&G.csp.useNonce&&typeof Z.cspNonce==="string")Q=F9(Q,Z.cspNonce);return Q}var e6="<!--PARENT_CONTENT_PLACEHOLDER-->";var _1=D(()=>{U4();f6();V$();J_();oX();$9();$Z();e3();Y9();v6();V_();$5();EZ();w9();JB();M9();E9();C1();c6();$1();C9();f9();m$();hq();$Y();yY();k2();t4();mq();GY();N0();pq();y2();v2();g2();UY();$8();F2();Ij();t2();e2();n0();l9();xX();t2();e2()});function ZO($){let Z=[],Y=[];return
|
|
11671
|
-
`);return{line:Y.length,column:Y[Y.length-1].length+1}}function JO($,Z,Y){let J=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)J.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))J.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Y.length===0)J.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)J.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)J.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)J.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return J}function XO($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function QO($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let J of Z){let X=J[1].toLowerCase();if(!X.startsWith("end"))Y.add(X)}return Array.from(Y)}var ik,nk,rk;var GO=D(()=>{ik=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],nk=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],rk=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var DQ={};$0(DQ,{renderSlot:()=>EQ,processSlots:()=>IQ,parseSlots:()=>TQ,parseSlotElement:()=>KO,extractSlotContent:()=>UO,applySlots:()=>zO});function ek($,Z){let Y=1,J=Z,X="<template",Q="</template";while(J<$.length&&Y>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(X,J)&&(J+X.length>=$.length||/[\s>\/]/.test($[J+X.length]))){Y++,J+=X.length;continue}if($.startsWith(Q,J)){let K=$.indexOf(">",J+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;J=K+1;continue}}J++}return Y===0?J:-1}function ZS($,Z){let Y=null;for(let J=Z;J<$.length;J++){let X=$[J];if(Y){if(X==="\\"){J++;continue}if(X===Y)Y=null;continue}if(X==='"'||X==="'"){Y=X;continue}if(X===">")return J+1}return-1}function YS($){let Z=[],Y=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,X=0;while(X<$.length){let Q=$.indexOf("<",X);if(Q===-1)break;if($.startsWith("<!--",Q)){let B=$.indexOf("-->",Q+4);X=B===-1?$.length:B+3;continue}let G=ZS($,Q+1);if(G===-1)break;let K=$.slice(Q,G),W=K.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!W){X=G;continue}let U=W[1]==="/",z=W[2].toLowerCase();if(U){let B=Y.lastIndexOf(z);if(B!==-1)Y.splice(B);X=G;continue}if(z==="template"&&Y.length===0){let B=K.match(J);if(B){let q=ek($,G);if(q!==-1){let j=B[1]||B[2]||B[3];Z.push({start:Q,end:q,slotName:j,content:$.slice(G,q-11).trim(),propsBinding:B[4]||void 0}),X=q;continue}}}if(!/\/\s*>$/.test(K)&&!$S.has(z)){if(Y.push(z),z==="script"||z==="style"){let B=$.toLowerCase().indexOf(`</${z}>`,G);if(B!==-1){X=B;continue}}}X=G}return Z}function TQ($){let Z={default:"",named:new Map},Y=$,J=YS($);for(let W of J)Z.named.set(W.slotName,{name:W.slotName,content:W.content,propsBinding:W.propsBinding});J.sort((W,U)=>U.start-W.start);for(let W of J)Y=Y.slice(0,W.start)+Y.slice(W.end);let X=[],Q=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,G;while((G=Q.exec(Y))!==null){let[W,U,z,_,B,q]=G,j=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(j+H).trim(),V=`<${U}${O?" "+O:""}>${q}</${U}>`;X.push({start:G.index,end:G.index+W.length,slotName:_,element:V})}let K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((G=K.exec(Y))!==null){let[W,U,z,_,B]=G,q=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),j=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=(q+j).trim(),O=`<${U}${H?" "+H:""} />`;X.push({start:G.index,end:G.index+W.length,slotName:_,element:O})}X.sort((W,U)=>U.start-W.start);for(let W of X){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 KO($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",J={},X=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=X.exec($))!==null)J[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:J,defaultContent:K}}async function EQ($,Z,Y,J){if(!$)return Y;let X=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...J};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,z]=W.split(":").map((B)=>B.trim()),_=z||U;if(Z[U]!==void 0)G[_]=Z[U]}}else G[Q]=Z;X=JS(X,G)}return X}function JS($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,J)=>{try{let X=J.trim(),Q=WO(X,Z);return v0(String(Q??""))}catch{return`{{ ${J} }}`}})}function WO($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),X=Z;for(let Q of J)if(X&&typeof X==="object"&&Q in X)X=X[Q];else return;return X}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,J,X,Q]=Y,G=Z[J],K=parseInt(Q,10);if(typeof G==="number")switch(X){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!R0($))return;return M0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function IQ($,Z,Y){let J=$;J=await XS(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let z=Z.named.get(K),_=U?.trim()||"",B=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let O=H[1],V=H[2];q[O]=WO(V,Y)}return await EQ(z,q,_,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),J}async function XS($,Z,Y){let J=[],X=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return X.push({match:K,index:U}),J.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(J),G=$;for(let K=X.length-1;K>=0;K--){let{match:W,index:U}=X[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function UO($){let Z=TQ($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function zO($,Z,Y,J){return await IQ($,{default:Z,named:Y},J)}var $S;var xY=D(()=>{$1();n0();$S=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});import QS from"fs";import a from"path";function KS($){let Z=new WeakSet;try{let Y=(J)=>{if(J===void 0)return{__stxType:"undefined"};if(typeof J==="bigint")return{__stxType:"bigint",value:J.toString()};if(typeof J==="function"||typeof J==="symbol")throw TypeError("Non-serializable component input");if(J===null||typeof J!=="object")return J;if(Z.has(J))throw TypeError("Circular component input");if(Z.add(J),J instanceof Date)return{__stxType:"date",value:J.toISOString()};if(Array.isArray(J))return J.map(Y);let X={};for(let Q of Object.keys(J).sort())X[Q]=Y(J[Q]);return X};return JSON.stringify(Y($))}catch{return null}}function _O($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function BO($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function r4($){return!BO($)}function s4($){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,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let X=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)X=X.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),X=X.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return X}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function WS($){let Z=[],Y=new Set,J=0,X=0,Q=$.length,G=(z)=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]===z){X++;return}X++}},K=()=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++;return}if($[X]==="$"&&$[X+1]==="{"){X+=2;let z=1;while(X<Q&&z>0)if($[X]==="{")z++,X++;else if($[X]==="}")z--,X++;else if($[X]==="'"||$[X]==='"')G($[X]);else if($[X]==="`")K();else X++;continue}X++}},W=()=>{if($[X]==="/"&&$[X+1]==="/"){while(X<Q&&$[X]!==`
|
|
11672
|
-
`)X++;return!0}if($[X]==="/"&&$[X+1]==="*"){X+=2;while(X<Q-1&&!($[X]==="*"&&$[X+1]==="/"))X++;return X+=2,!0}return!1},U=()=>{if(J!==0)return;let z=$.slice(X).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.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 _=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let j=_[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(X).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 q=$.slice(X).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(X<Q){if(W())continue;if($[X]==="'"||$[X]==='"'){G($[X]);continue}if($[X]==="`"){K();continue}if($[X]==="{"){J++,X++;continue}if($[X]==="}"){J--,X++;continue}if(J===0&&/[a-z]/i.test($[X])&&(X===0||/\s|[;{}()]/.test($[X-1])))U();X++}return Z}function US($){let Z=[],Y=0,J=0,X=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(X){if(G==="\\"){Q++;continue}if(G===X)X=null;continue}if(G==='"'||G==="'"||G==="`"){X=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(J,Q)),J=Q+1}if(J<$.length)Z.push($.slice(J));return Z}function zS($){let Z=0,Y=null;for(let J=0;J<$.length;J++){let X=$[J];if(Y){if(X==="\\"){J++;continue}if(X===Y)Y=null;continue}if(X==='"'||X==="'"||X==="`"){Y=X;continue}if(X==="("||X==="["||X==="{")Z++;else if(X===")"||X==="]"||X==="}")Z--;else if(X==="="&&Z===0){let Q=$[J-1],G=$[J+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function _S($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let J=Y.index-1;while(J>=0&&/\s/.test($[J]))J--;if($[J]!=="}")return;let X=J,Q=0,G=-1;for(;J>=0;J--){let W=$[J];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,X);for(let W of US(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let z=zS(U);if(z===-1)continue;let _=U.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(_))continue;if(Z[_]!==void 0)continue;let B=U.slice(z+1).trim();if(!B)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${B});`);Z[_]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function u7($,Z,Y,J,X){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],z=typeof X.root==="string"?
|
|
11687
|
+
`+Q}{let{scanScriptTags:W0}=await Promise.resolve().then(() => ($8(),TY)),p=[];for(let t of W0(Q)){if(!/\bserver\b/i.test(t.attrs))continue;let _0=t.start+t.fullMatch.indexOf(">")+1,v=gk(Q,_0);if(v===-1)continue;let C=v+9;while(C<Q.length&&/\s/.test(Q[C]))C++;p.push({start:t.start,end:C})}for(let t=p.length-1;t>=0;t--){let{start:_0,end:v}=p[t];Q=Q.substring(0,_0)+Q.substring(v)}}let X0=c7(Q,Y);if(X0.hasScoped)Q=X0.html;let K0=Z.__stx_event_bindings||[],C0=!1,z1=[],b0=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:l1}=await Promise.resolve().then(() => ($8(),TY));for(let W0 of l1(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))z1.push({match:W0.fullMatch,attrs:W0.attrs,content:W0.body});for(let{match:W0,attrs:p,content:t}of z1){C0=!0;let _0=t;J8(t,Y,J.strict);let v=await n4(t,{eventBindings:K0,attrs:p,hasColonDirectives:b0,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:b});Q=Q.replace(W0,()=>v)}if(C0)Z.__stx_event_bindings=[];if(G.csp?.enabled&&G.csp.useNonce&&typeof Z.cspNonce==="string")Q=F9(Q,Z.cspNonce);return Q}var e6="<!--PARENT_CONTENT_PLACEHOLDER-->";var _1=D(()=>{U4();f6();V$();J_();oX();$9();$Z();e3();Y9();v6();V_();$5();EZ();w9();JB();M9();E9();C1();c6();$1();C9();f9();m$();hq();$Y();yY();k2();t4();mq();GY();N0();pq();y2();v2();g2();UY();$8();F2();Ij();t2();e2();n0();l9();xX();t2();e2()});function ZO($){let Z=[],Y=[];return ak($,Z),sk($,Z,Y),ok($,Y),tk($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function ak($,Z){let Y=($.match(/\{\{/g)||[]).length,J=($.match(/\}\}/g)||[]).length;if(Y!==J)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${J} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function sk($,Z,Y){for(let J of ik){let X=new RegExp(`${J.open}(?:\\s|\\()`,"g"),Q=new RegExp(J.close,"g"),G=($.match(X)||[]).length,K=($.match(Q)||[]).length;if(J.altClose){let W=new RegExp(J.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${J.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${J.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${J.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${J.close} tags`})}}function ok($,Z){for(let Y of nk)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function tk($,Z){for(let Y of rk)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function YO($,Z){let Y=$.slice(0,Z).split(`
|
|
11688
|
+
`);return{line:Y.length,column:Y[Y.length-1].length+1}}function JO($,Z,Y){let J=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)J.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))J.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Y.length===0)J.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)J.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)J.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)J.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return J}function XO($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function QO($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let J of Z){let X=J[1].toLowerCase();if(!X.startsWith("end"))Y.add(X)}return Array.from(Y)}var ik,nk,rk;var GO=D(()=>{ik=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],nk=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],rk=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var DQ={};$0(DQ,{renderSlot:()=>EQ,processSlots:()=>IQ,parseSlots:()=>TQ,parseSlotElement:()=>KO,extractSlotContent:()=>UO,applySlots:()=>zO});function ek($,Z){let Y=1,J=Z,X="<template",Q="</template";while(J<$.length&&Y>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(X,J)&&(J+X.length>=$.length||/[\s>\/]/.test($[J+X.length]))){Y++,J+=X.length;continue}if($.startsWith(Q,J)){let K=$.indexOf(">",J+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;J=K+1;continue}}J++}return Y===0?J:-1}function ZS($,Z){let Y=null;for(let J=Z;J<$.length;J++){let X=$[J];if(Y){if(X==="\\"){J++;continue}if(X===Y)Y=null;continue}if(X==='"'||X==="'"){Y=X;continue}if(X===">")return J+1}return-1}function YS($){let Z=[],Y=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,X=0;while(X<$.length){let Q=$.indexOf("<",X);if(Q===-1)break;if($.startsWith("<!--",Q)){let B=$.indexOf("-->",Q+4);X=B===-1?$.length:B+3;continue}let G=ZS($,Q+1);if(G===-1)break;let K=$.slice(Q,G),W=K.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!W){X=G;continue}let U=W[1]==="/",z=W[2].toLowerCase();if(U){let B=Y.lastIndexOf(z);if(B!==-1)Y.splice(B);X=G;continue}if(z==="template"&&Y.length===0){let B=K.match(J);if(B){let q=ek($,G);if(q!==-1){let j=B[1]||B[2]||B[3];Z.push({start:Q,end:q,slotName:j,content:$.slice(G,q-11).trim(),propsBinding:B[4]||void 0}),X=q;continue}}}if(!/\/\s*>$/.test(K)&&!$S.has(z)){if(Y.push(z),z==="script"||z==="style"){let B=$.toLowerCase().indexOf(`</${z}>`,G);if(B!==-1){X=B;continue}}}X=G}return Z}function TQ($){let Z={default:"",named:new Map},Y=$,J=YS($);for(let W of J)Z.named.set(W.slotName,{name:W.slotName,content:W.content,propsBinding:W.propsBinding});J.sort((W,U)=>U.start-W.start);for(let W of J)Y=Y.slice(0,W.start)+Y.slice(W.end);let X=[],Q=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,G;while((G=Q.exec(Y))!==null){let[W,U,z,_,B,q]=G,j=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(j+H).trim(),V=`<${U}${O?" "+O:""}>${q}</${U}>`;X.push({start:G.index,end:G.index+W.length,slotName:_,element:V})}let K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((G=K.exec(Y))!==null){let[W,U,z,_,B]=G,q=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),j=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=(q+j).trim(),O=`<${U}${H?" "+H:""} />`;X.push({start:G.index,end:G.index+W.length,slotName:_,element:O})}X.sort((W,U)=>U.start-W.start);for(let W of X){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 KO($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",J={},X=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=X.exec($))!==null)J[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:J,defaultContent:K}}async function EQ($,Z,Y,J){if(!$)return Y;let X=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...J};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,z]=W.split(":").map((B)=>B.trim()),_=z||U;if(Z[U]!==void 0)G[_]=Z[U]}}else G[Q]=Z;X=JS(X,G)}return X}function JS($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,J)=>{try{let X=J.trim(),Q=WO(X,Z);return v0(String(Q??""))}catch{return`{{ ${J} }}`}})}function WO($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),X=Z;for(let Q of J)if(X&&typeof X==="object"&&Q in X)X=X[Q];else return;return X}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,J,X,Q]=Y,G=Z[J],K=parseInt(Q,10);if(typeof G==="number")switch(X){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!R0($))return;return M0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function IQ($,Z,Y){let J=$;J=await XS(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let z=Z.named.get(K),_=U?.trim()||"",B=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let O=H[1],V=H[2];q[O]=WO(V,Y)}return await EQ(z,q,_,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),J}async function XS($,Z,Y){let J=[],X=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return X.push({match:K,index:U}),J.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(J),G=$;for(let K=X.length-1;K>=0;K--){let{match:W,index:U}=X[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function UO($){let Z=TQ($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function zO($,Z,Y,J){return await IQ($,{default:Z,named:Y},J)}var $S;var xY=D(()=>{$1();n0();$S=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});import QS from"fs";import s from"path";function KS($){let Z=new WeakSet;try{let Y=(J)=>{if(J===void 0)return{__stxType:"undefined"};if(typeof J==="bigint")return{__stxType:"bigint",value:J.toString()};if(typeof J==="function"||typeof J==="symbol")throw TypeError("Non-serializable component input");if(J===null||typeof J!=="object")return J;if(Z.has(J))throw TypeError("Circular component input");if(Z.add(J),J instanceof Date)return{__stxType:"date",value:J.toISOString()};if(Array.isArray(J))return J.map(Y);let X={};for(let Q of Object.keys(J).sort())X[Q]=Y(J[Q]);return X};return JSON.stringify(Y($))}catch{return null}}function _O($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function BO($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function r4($){return!BO($)}function a4($){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,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let X=new Bun.Transpiler({loader:"ts",target:"browser",define:F1()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)X=X.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),X=X.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return X}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function WS($){let Z=[],Y=new Set,J=0,X=0,Q=$.length,G=(z)=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]===z){X++;return}X++}},K=()=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++;return}if($[X]==="$"&&$[X+1]==="{"){X+=2;let z=1;while(X<Q&&z>0)if($[X]==="{")z++,X++;else if($[X]==="}")z--,X++;else if($[X]==="'"||$[X]==='"')G($[X]);else if($[X]==="`")K();else X++;continue}X++}},W=()=>{if($[X]==="/"&&$[X+1]==="/"){while(X<Q&&$[X]!==`
|
|
11689
|
+
`)X++;return!0}if($[X]==="/"&&$[X+1]==="*"){X+=2;while(X<Q-1&&!($[X]==="*"&&$[X+1]==="/"))X++;return X+=2,!0}return!1},U=()=>{if(J!==0)return;let z=$.slice(X).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.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 _=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let j=_[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(X).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 q=$.slice(X).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(X<Q){if(W())continue;if($[X]==="'"||$[X]==='"'){G($[X]);continue}if($[X]==="`"){K();continue}if($[X]==="{"){J++,X++;continue}if($[X]==="}"){J--,X++;continue}if(J===0&&/[a-z]/i.test($[X])&&(X===0||/\s|[;{}()]/.test($[X-1])))U();X++}return Z}function US($){let Z=[],Y=0,J=0,X=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(X){if(G==="\\"){Q++;continue}if(G===X)X=null;continue}if(G==='"'||G==="'"||G==="`"){X=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(J,Q)),J=Q+1}if(J<$.length)Z.push($.slice(J));return Z}function zS($){let Z=0,Y=null;for(let J=0;J<$.length;J++){let X=$[J];if(Y){if(X==="\\"){J++;continue}if(X===Y)Y=null;continue}if(X==='"'||X==="'"||X==="`"){Y=X;continue}if(X==="("||X==="["||X==="{")Z++;else if(X===")"||X==="]"||X==="}")Z--;else if(X==="="&&Z===0){let Q=$[J-1],G=$[J+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function _S($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let J=Y.index-1;while(J>=0&&/\s/.test($[J]))J--;if($[J]!=="}")return;let X=J,Q=0,G=-1;for(;J>=0;J--){let W=$[J];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,X);for(let W of US(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let z=zS(U);if(z===-1)continue;let _=U.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(_))continue;if(Z[_]!==void 0)continue;let B=U.slice(z+1).trim();if(!B)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${B});`);Z[_]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function u7($,Z,Y,J,X){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],z=typeof X.root==="string"?s.resolve(X.root):void 0,_=z??s.dirname(J),B=[],q=(O)=>{if(O&&!B.includes(O))B.push(O)},j=Y.__originalFilePath;if(j)q(s.join(s.dirname(j),"components"));q(Z),q(X._rootComponentsDir),q(s.join(s.dirname(J),"components")),q(X.componentsDir);let H=X._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(z)q(s.resolve(z,"resources/views/components")),q(s.resolve(z,"resources/components")),q(s.resolve(z,"src/components")),q(s.resolve(z,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return Q0(s.resolve(s.dirname(J),`${Q}.stx`));for(let O of B){let V=s.isAbsolute(O)?O:s.resolve(_,O);for(let L of U)if(await Q0(s.join(V,L)))return!0}return!1}function qO($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}function jO($){if(!$)return!1;let Z=$.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(Z)}function HO($){let Z=new Set,Y=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useReactiveProp|useLocalStorage|useSessionStorage|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let J of $){let X;while((X=Y.exec(J))!==null)Z.add(X[1]);Y.lastIndex=0}return[...Z]}async function B4($,Z,Y,J,X,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (K6(),aZ)),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let _=new Set(z);_.add($);let B=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let q=B&&B!=="load"&&qO(B)?B:"";try{let j=(C)=>C.split("-").map((u)=>u.charAt(0).toUpperCase()+u.slice(1)).join(""),H=(C)=>C.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,V=null,L=X.__importedComponents;if(L){let C=[O,O.toLowerCase(),j(O),H(O)];for(let u of C)if(L.has(u)){V=L.get(u);break}}let F=[];if(!V){let C=[`${O}.stx`,`${j(O)}.stx`,`${H(O)}.stx`],u=[...new Set(C)],e=X.__originalFilePath,n=[];if(e){let B0=s.join(s.dirname(e),"components");n.push(B0)}if(J)n.push(J);let j0=G._rootComponentsDir;if(typeof j0==="string"&&!n.includes(j0))n.push(j0);let I0=s.join(s.dirname(Q),"components");if(!n.includes(I0))n.push(I0);if(G.componentsDir&&G.componentsDir!==J&&!n.includes(G.componentsDir))n.push(G.componentsDir);let g0=G._pluginComponentDirs;if(Array.isArray(g0)){for(let B0 of g0)if(typeof B0==="string"&&!n.includes(B0))n.push(B0)}let Q1=typeof G.root==="string"?s.resolve(G.root):void 0,S0=Q1??s.dirname(Q),k1=[];if(Q1)k1.push(s.resolve(Q1,"resources/views/components")),k1.push(s.resolve(Q1,"resources/components")),k1.push(s.resolve(Q1,"src/components")),k1.push(s.resolve(Q1,"components"));k1.push(s.resolve(import.meta.dir,"components"));for(let B0 of k1)if(!n.includes(B0))n.push(B0);let L1=[...new Set(n.map((B0)=>{if(!B0)return B0;return s.isAbsolute(B0)?B0:s.resolve(S0,B0)}))];n.length=0,n.push(...L1);let V1=`${O}\x00${Q}\x00${L1.join("\x00")}`,L0=vY.get(V1);if(L0)if(await Q0(L0))V=L0;else vY.delete(V1);if(!V&&(O.startsWith("./")||O.startsWith("../")))V=s.resolve(s.dirname(Q),`${O}.stx`),F.push(V);else if(!V)for(let B0 of n){if(!B0)continue;for(let J0 of u){let x0=s.join(B0,J0);if(F.push(x0),await Q0(x0)){V=x0;break}}if(V)break;if(!V)try{let J0=await import("fs");if(!J0.statSync(B0,{throwIfNoEntry:!1})?.isDirectory())continue;let h0=8,N4=[{path:B0,depth:0}];while(N4.length>0&&!V){let R4=N4.pop();if(R4.depth>=h0)continue;let l3;try{l3=J0.readdirSync(R4.path,{withFileTypes:!0})}catch{continue}for(let c3 of l3){if(!c3.isDirectory())continue;if(c3.name==="node_modules"||c3.name.startsWith("."))continue;let $z=s.join(R4.path,c3.name);for(let vR of u){let RX=s.join($z,vR);if(F.push(RX),await Q0(RX)){V=RX;break}}if(V)break;N4.push({path:$z,depth:R4.depth+1})}}}catch{}if(V)break}if(V)vY.set(V1,V)}if(!V||!await Q0(V)){let C=F.length>0?`
|
|
11673
11690
|
Searched paths:
|
|
11674
11691
|
${F.map((u)=>` - ${u}`).join(`
|
|
11675
|
-
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}W.add(V);let A;if(W8.has(V))A=W8.get(V);else try{A=await Bun.file(V).text(),W8.set(V,A)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let w=new Set(["__originalFilePath","__importedComponents",YZ]),N={};for(let[C,u]of Object.entries(X))if(!C.startsWith("__")||w.has(C))N[C]=u;let{extractSlotContent:R}=await Promise.resolve().then(() => (xY(),DQ)),E=R(Y),M={};if(E.defaultSlot?.trim())M.default=E.defaultSlot;for(let[C,u]of E.namedSlots)M[C]=u.content;let I={...N,...Z,props:Z,slot:Y,$slots:M,__processedComponents:_,__sections:{},...jO(Y)&&{__stx_force_signals:!0}};_S(A,I);let S=A,k=_4(S);if(k)S=k.content.trim();let x=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,y=[...A.matchAll(x)],b=[],h=y.some((C)=>/\bserver\b/.test(C[1]||"")&&/\bcache\b/.test(C[1]||""))&&y.every((C)=>/\bserver\b/.test(C[1]||"")),r=null,m=null;if(h){let C=KS({props:Z,slot:Y,buildMode:G.buildMode??"",skipEventDirectives:G.skipEventDirectives===!0});if(C!==null){r=`${V}\x00${C}`;let u=kQ.get(r);if(u){for(let e of u.dependencies)W.add(e);return u.output}m=new Set(W)}}for(let C of y){let u=C[1]||"",e=C[2]||"",n=u.includes("server");if(r4(u)&&e.trim())e=
|
|
11676
|
-
`)}`}if(Y&&X0.includes("{{ text || slot }}"))X0=X0.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{applySlots:K0}=await Promise.resolve().then(() => (xY(),DQ)),{defaultSlot:C0,namedSlots:z1}=E;X0=await K0(X0,C0,z1,I);for(let[C,u]of Object.entries(I))if(typeof u==="string"){if(u.includes("<")&&u.includes(">")||u.includes("<")||u.includes(""")){let e=KZ(u);I[C]=e}}let b0=b.some((C)=>/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),l1=HO(b);if(l1.length>0)I.__stx_client_signal_names=l1;let W0={...G,_rootComponentsDir:G._rootComponentsDir||G.componentsDir,componentsDir:
|
|
11692
|
+
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}W.add(V);let A;if(W8.has(V))A=W8.get(V);else try{A=await Bun.file(V).text(),W8.set(V,A)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let w=new Set(["__originalFilePath","__importedComponents",YZ]),N={};for(let[C,u]of Object.entries(X))if(!C.startsWith("__")||w.has(C))N[C]=u;let{extractSlotContent:R}=await Promise.resolve().then(() => (xY(),DQ)),E=R(Y),M={};if(E.defaultSlot?.trim())M.default=E.defaultSlot;for(let[C,u]of E.namedSlots)M[C]=u.content;let I={...N,...Z,props:Z,slot:Y,$slots:M,__processedComponents:_,__sections:{},...jO(Y)&&{__stx_force_signals:!0}};_S(A,I);let S=A,k=_4(S);if(k)S=k.content.trim();let x=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,y=[...A.matchAll(x)],b=[],h=y.some((C)=>/\bserver\b/.test(C[1]||"")&&/\bcache\b/.test(C[1]||""))&&y.every((C)=>/\bserver\b/.test(C[1]||"")),r=null,m=null;if(h){let C=KS({props:Z,slot:Y,buildMode:G.buildMode??"",skipEventDirectives:G.skipEventDirectives===!0});if(C!==null){r=`${V}\x00${C}`;let u=kQ.get(r);if(u){for(let e of u.dependencies)W.add(e);return u.output}m=new Set(W)}}for(let C of y){let u=C[1]||"",e=C[2]||"",n=u.includes("server");if(r4(u)&&e.trim())e=a4(e);if(n&&e)try{await U(e,I,V)}catch(I0){}if(!n){let I0=e.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),g0=I0.includes("{{")&&I0.includes("}}"),Q1=I0.includes("{!!")&&I0.includes("!!}");if(g0||Q1)I0=L7(I0,I);let S0=u.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");b.push(`<script${S0}>${I0}</script>`)}}let P=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),d=P?P[1]:"",l=P?P[2]:"",c="",a=d&&/\bscoped\b/i.test(d);if(P)c=`<style${d}>${l}</style>`;let X0=S;if(X0=X0.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),P)X0=X0.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let C=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,u=[];if(X0=X0.replace(C,(e,n)=>{let j0=n.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(j0)u.push(`<style${j0[1]}>${j0[2]}</style>`);return""}),X0=X0.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),u.length>0)c=`${c}${u.join(`
|
|
11693
|
+
`)}`}if(Y&&X0.includes("{{ text || slot }}"))X0=X0.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{applySlots:K0}=await Promise.resolve().then(() => (xY(),DQ)),{defaultSlot:C0,namedSlots:z1}=E;X0=await K0(X0,C0,z1,I);for(let[C,u]of Object.entries(I))if(typeof u==="string"){if(u.includes("<")&&u.includes(">")||u.includes("<")||u.includes(""")){let e=KZ(u);I[C]=e}}let b0=b.some((C)=>/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),l1=HO(b);if(l1.length>0)I.__stx_client_signal_names=l1;let W0={...G,_rootComponentsDir:G._rootComponentsDir||G.componentsDir,componentsDir:s.dirname(V),skipSignalsRuntime:!0,skipEventDirectives:b0||b.length===0,defaultLayout:void 0};I.__stxProcessingDepth=(X.__stxProcessingDepth||0)+1;let p=await q0(X0,I,V,W0,W),t=new Set(Array.isArray(X.__stx_preserved_client_expressions)?X.__stx_preserved_client_expressions:[]);for(let C of p.matchAll(/\{\{([\s\S]*?)\}\}/g))t.add(C[1].trim());if(t.size>0)X.__stx_preserved_client_expressions=[...t];let _0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++GS}_${Math.random().toString(36).slice(2,8)}`,v=p;if(b0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${_O(JSON.stringify(Z))}"`}catch{}let u=q?` stx-hydrate="${_O(q)}"`:"";v=`<div data-stx-scope="${_0}"${C}${u}>${p}</div>`;let e=await Promise.all(b.map(async(n)=>{let j0=n.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!j0)return n;let[,I0,g0]=j0,Q1=U7(g0,{filePath:V,projectRoot:process.cwd()}),S0=Q1.code,k1=z7(Q1.styles);S0=x6(S0).code;let{hasUserImports:L1,bundleClientScript:V1}=await Promise.resolve().then(() => (K7(),G7));if(L1(S0))S0=await V1(S0,V,{projectRoot:process.cwd(),minify:G.buildMode==="compile"});let{rewriteStxImportSpecifiers:L0}=await Promise.resolve().then(() => ($8(),TY));S0=S0.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(R4,l3)=>L0(l3));let B0=c1(S0),J0=WS(B0),x0=`function(__scopeId) {
|
|
11677
11694
|
${M$("const",[...oz,...J0],B0)}
|
|
11678
11695
|
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
11679
11696
|
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
@@ -11707,7 +11724,7 @@ finally {
|
|
|
11707
11724
|
`+c}else{if(c)v+=`
|
|
11708
11725
|
`+c;if(b.length>0){let C=I.__stx_event_bindings||[],u=i4(I),e=await Promise.all(b.map(async(n)=>{let j0=n.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!j0)return n;return await n4(j0[1],{eventBindings:C,templateContent:v,filePath:V,projectRoot:process.cwd(),serverData:u})}));v+=`
|
|
11709
11726
|
`+e.join(`
|
|
11710
|
-
`),I.__stx_event_bindings=[]}}if(
|
|
11727
|
+
`),I.__stx_event_bindings=[]}}if(a){let C=c7(v,V);if(C.hasScoped)v=C.html}if(r&&m)kQ.set(r,{output:v,dependencies:[...W].filter((C)=>!m.has(C))});return v}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{z.delete($)}}async function Q0($){return Bun.file($).exists()}function SQ($,Z){let Y=s.resolve(Z),J=s.resolve($),X=Y.endsWith(s.sep)?Y:Y+s.sep;if(J===Y||J.startsWith(X))return J;return null}async function K8($,Z,Y,J){let X=await BS($,Z,Y,J);if(X===null)return null;let Q=SQ(X,process.cwd());if(Q)return Q;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 W=s.isAbsolute(K)?K:s.resolve(process.cwd(),K);if(SQ(X,W))return s.resolve(X)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${X} (template: ${$}, from: ${Z})`),null}async function BS($,Z,Y,J){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let X=s.dirname(Z),Q=process.cwd();if($.startsWith("/")){let B=s.join(Q,$),q=SQ(B,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await Q0(q)&&J)J.add(q);return q}let G=s.join(X,$);if(await Q0(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(J)J.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let B of[".stx",".tsx",".jsx"]){let q=`${G}${B}`;if(await Q0(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(J)J.add(q);return q}}let K="",W=s.resolve(X),U=process.cwd();for(let B=0;B<10;B++){let q=s.join(W,"layouts"),j=!1;try{j=QS.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=s.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let B=$.startsWith("layouts/")?$.slice(8):$,q=s.join(K,B);if(await Q0(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(J)J.add(q);return q}if(!B.endsWith(".stx")){let j=`${q}.stx`;if(await Q0(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(J)J.add(j);return j}}}if(Y.layoutsDir){let B=s.isAbsolute(Y.layoutsDir)?Y.layoutsDir:s.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=s.join(B,q);if(await Q0(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(J)J.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await Q0(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(J)J.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let B=$.split("layouts/"),q=s.join(Y.partialsDir||X,"layouts",B[1]);if(await Q0(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(J)J.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await Q0(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(J)J.add(j);return j}}}if(Y.partialsDir){if(K=s.join(Y.partialsDir,"layouts"),await Q0(K)){let B=s.join(K,$);if(await Q0(B)){if(Y.debug)console.log(`Found in partials layouts dir: ${B}`);if(J)J.add(B);return B}if(!$.endsWith(".stx")){let q=`${B}.stx`;if(await Q0(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(J)J.add(q);return q}}}}let z=Y.partialsDir||s.join(process.cwd(),"views"),_=s.join(z,$);if(await Q0(_)){if(Y.debug)console.log(`Found in views path: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await Q0(B)){if(Y.debug)console.log(`Found in views path with extension: ${B}`);if(J)J.add(B);return B}}if(X.includes("temp")){let B=s.join(s.dirname(X),"layouts",$);if(await Q0(B)){if(Y.debug)console.log(`Found in temp layouts dir: ${B}`);if(J)J.add(B);return B}if(!$.endsWith(".stx")){let q=`${B}.stx`;if(await Q0(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(J)J.add(q);return q}}}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 CQ($,Z,Y){let J=0,X="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
|
|
11711
11728
|
`),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=Z){J=W+1,X=G[W].trim();let U=Math.max(0,W-2),z=Math.min(G.length,W+3);Q=G.slice(U,z).map((_,B)=>{let q=U+B+1;return`${q===J?"> ":" "}${q}: ${_}`}).join(`
|
|
11712
11729
|
`);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return CQ($,G)}}catch{}return{lineNumber:J,lineContent:X,context:Q}}function T0($,Z,Y,J,X,Q){let{lineNumber:G,context:K}=CQ(J,X,Q),W=Y.split("/").pop(),U=0;if(typeof X==="number"&&X>=0&&J){let _=J.lastIndexOf(`
|
|
11713
11730
|
`,Math.max(0,X-1));U=X-(_+1)+1}let z="";if(G>0)z+=`
|
|
@@ -11867,10 +11884,10 @@ ${O0.dim}${K}${O0.reset}
|
|
|
11867
11884
|
|
|
11868
11885
|
console.log('[stx] Directive runtime initialized');
|
|
11869
11886
|
})();
|
|
11870
|
-
`}function wS($){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return $.replace(Z,(Y,J,X,Q,G)=>{let W=(Q?Q.split("."):[]).reduce((U,z)=>{return U[z]=!0,U},{});return`data-stx-directive="${J}:${G}" data-stx-directive-arg="${X||""}" data-stx-directive-modifiers='${JSON.stringify(W)}'`})}var fY,PQ;var U8=D(()=>{fY=new Map,PQ=new Map});function q6($,Z=O4,Y={},J){return Z.sort((X,Q)=>X-Q).map((X)=>{return`${
|
|
11887
|
+
`}function wS($){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return $.replace(Z,(Y,J,X,Q,G)=>{let W=(Q?Q.split("."):[]).reduce((U,z)=>{return U[z]=!0,U},{});return`data-stx-directive="${J}:${G}" data-stx-directive-arg="${X||""}" data-stx-directive-modifiers='${JSON.stringify(W)}'`})}var fY,PQ;var U8=D(()=>{fY=new Map,PQ=new Map});function q6($,Z=O4,Y={},J){return Z.sort((X,Q)=>X-Q).map((X)=>{return`${s1($,{...Y,w:X,fm:J})} ${X}w`}).join(", ")}function yQ($,Z=320,Y=2560,J=0.08,X={},Q){let G=gY(Z,Y,J);return q6($,G,X,Q)}function gY($,Z,Y=0.08){let J=[],X=$;while(X<Z)J.push(Math.round(X)),X*=1+Y*2;if(J[J.length-1]!==Z)J.push(Z);return J}function Z5($,Z,Y=z8,J={},X){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${s1($,{...J,w:G,dpr:Q,fm:X})} ${Q}x`}).join(", ")}function xQ($,Z,Y=z8,J=80,X={},Q){let G={1:J,1.5:Math.round(J*0.9),2:Math.round(J*0.8),3:Math.round(J*0.7),4:Math.round(J*0.6),5:Math.round(J*0.5)};return Y.sort((K,W)=>K-W).map((K)=>{let W=Math.round(Z*K),U=G[K]||Math.round(J*Math.max(0.5,1-K*0.1));return`${s1($,{...X,w:W,q:U,dpr:K,fm:Q})} ${K}x`}).join(", ")}function Y5($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let J=Object.entries($).map(([X,Q])=>{let G=/^\d+$/.test(X)?`${X}px`:X;return{bp:G,size:Q,numericBp:Number.parseInt(G)||0}}).sort((X,Q)=>X.numericBp-Q.numericBp).map(({bp:X,size:Q})=>`(max-width: ${X}) ${Q}`);return J.push(Z),J.join(", ")}function vQ($,Z="100vw"){if(!$||$.length===0)return Z;let J=[...$].sort((X,Q)=>(X.maxWidth||0)-(Q.maxWidth||0)).filter((X)=>X.maxWidth).map((X)=>`(max-width: ${X.maxWidth}px) ${X.imageWidth}`);return J.push(Z),J.join(", ")}function s1($,Z={}){let Y=Object.entries(Z).filter(([,Q])=>Q!==void 0&&Q!==null).map(([Q,G])=>{if(Array.isArray(G))return[Q,G.join(",")];return[Q,String(G)]});if(Y.length===0)return $;let J=Y.map(([Q,G])=>`${Q}=${encodeURIComponent(G)}`).join("&"),X=$.includes("?")?"&":"?";return`${$}${X}${J}`}function gQ($){let[Z,Y]=$.split("?"),J={};if(Y)new URLSearchParams(Y).forEach((Q,G)=>{if(/^\d+$/.test(Q))J[G]=Number.parseInt(Q,10);else if(/^\d+\.\d+$/.test(Q))J[G]=Number.parseFloat(Q);else if(Q==="true")J[G]=!0;else if(Q==="false")J[G]=!1;else J[G]=Q});return{src:Z,params:J}}function hQ($){let{src:Z,widths:Y,dprValues:J,fixedWidth:X,formats:Q=S4,baseUrl:G="",params:K={}}=$,W=[];for(let U of Q){let z,_;if(X!==void 0&&J)z=Z5(Z,X,J,K,U),_=J.map((B)=>({path:"",url:s1(Z,{...K,w:Math.round(X*B),fm:U}),width:Math.round(X*B),height:0,format:U,size:0,dpr:B}));else{let B=Y||O4;z=q6(Z,B,K,U),_=B.map((q)=>({path:"",url:s1(Z,{...K,w:q,fm:U}),width:q,height:0,format:U,size:0}))}W.push({srcset:z,format:U,mimeType:_8[U],variants:_})}return W}function dQ($,Z="100vw"){return $.map(({srcset:Y,mimeType:J})=>`<source type="${J}" srcset="${Y}" sizes="${Z}" />`).join(`
|
|
11871
11888
|
`)}function uQ($,Z){if($.length===0)return;let Y=[...$].sort((X,Q)=>X.width-Q.width),J=Y.find((X)=>X.width>=Z);if(J)return J;return Y[Y.length-1]}function B8($){return _8[$]||"application/octet-stream"}function mQ($){return LO[$]||$}function lQ($){switch($.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"webp":return"webp";case"avif":return"avif";case"gif":return"gif";default:return}}var O4,z8,S4,_8,LO,fQ;var hY=D(()=>{O4=[320,480,640,768,1024,1280,1536,1920,2560],z8=[1,1.5,2,3],S4=["avif","webp","jpeg"],_8={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},LO={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};fQ={fullWidth:"100vw",halfDesktop:"(max-width: 768px) 100vw, 50vw",thirdDesktop:"(max-width: 768px) 100vw, 33.33vw",quarterDesktop:"(max-width: 480px) 100vw, (max-width: 768px) 50vw, 25vw",contentWidth:"(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 960px"}});async function cQ(){try{return await import("ts-images")}catch{return null}}async function q8($,Z={}){let Y={...dY,...Z},J=await cQ();if(J)try{return await NS($,Y,J)}catch(X){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${X}`)}return VO($,Y)}async function NS($,Z,Y){let{generatePlaceholder:J,generateThumbHash:X}=Y,G={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await X($)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let K=await J($,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:G,base64Encode:!0});return{dataURL:K.dataURL,width:K.width,height:K.height,aspectRatio:K.aspectRatio,originalWidth:K.originalWidth,originalHeight:K.originalHeight,strategy:Z.strategy,dominantColor:K.dominantColor,css:K.css}}function VO($,Z){let Y=Z.width||20,J=Z.height||Y,X="#e5e7eb",Q=`<svg xmlns="http://www.w3.org/2000/svg" width="${Y}" height="${J}" viewBox="0 0 ${Y} ${J}"><rect fill="#e5e7eb" width="${Y}" height="${J}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Q)}`,width:Y,height:J,aspectRatio:Y/J,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}async function pQ($){let Z=await cQ();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await VO($,{strategy:"thumbhash",width:32,height:32})).dataURL}function iQ($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,J=(Z>>6&63)/31.5-1,X=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,z=K>>15!==0,_=Math.max(3,z?G?5:7:G?5:7),B=Math.max(3,z?G?5:7:G?5:7),q=32,j=32,H=Math.max(0,Math.min(255,Math.round((Y+J)*255))),O=Math.max(0,Math.min(255,Math.round(Y*255))),V=Math.max(0,Math.min(255,Math.round((Y-J)*255))),L=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
|
|
11872
11889
|
<rect fill="rgb(${H},${O},${V})" width="32" height="32"/>
|
|
11873
|
-
</svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(L)}`}async function nQ($,Z=20,Y=50){return q8($,{strategy:"blur",width:Z,quality:Y,blurLevel:40})}async function rQ($){let Z=await cQ();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function
|
|
11890
|
+
</svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(L)}`}async function nQ($,Z=20,Y=50){return q8($,{strategy:"blur",width:Z,quality:Y,blurLevel:40})}async function rQ($){let Z=await cQ();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function aQ($,Z=1,Y=1){let J=`<svg xmlns="http://www.w3.org/2000/svg" width="${Z}" height="${Y}"><rect fill="${$}" width="${Z}" height="${Y}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(J)}`}function j8($,Z,Y={}){let J=Y.transitionDuration||300,X=Y.easing||"ease-out";return`
|
|
11874
11891
|
#${$} {
|
|
11875
11892
|
--stx-img-transition-duration: ${J}ms;
|
|
11876
11893
|
--stx-img-transition-easing: ${X};
|
|
@@ -11887,7 +11904,7 @@ ${O0.dim}${K}${O0.reset}
|
|
|
11887
11904
|
#${$}.stx-img-loaded img {
|
|
11888
11905
|
opacity: 1;
|
|
11889
11906
|
}
|
|
11890
|
-
`.trim()}function
|
|
11907
|
+
`.trim()}function sQ($){return`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`}async function H8($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(J5.has(Y))return J5.get(Y);let J=await q8($,Z);return J5.set(Y,J),J}function oQ(){J5.clear()}function tQ(){return{size:J5.size,keys:Array.from(J5.keys())}}var dY,X5,J5;var eQ=D(()=>{dY={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},X5=`
|
|
11891
11908
|
.stx-img-placeholder {
|
|
11892
11909
|
position: relative;
|
|
11893
11910
|
overflow: hidden;
|
|
@@ -11916,8 +11933,8 @@ ${O0.dim}${K}${O0.reset}
|
|
|
11916
11933
|
filter: blur(0);
|
|
11917
11934
|
transform: scale(1);
|
|
11918
11935
|
}
|
|
11919
|
-
`.trim();J5=new Map});import{createHash as $G}from"crypto";import{readFile as RS,stat as FO}from"fs/promises";async function Y1($){try{let Z=await RS($);return $G("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function AO($){return $G("sha256").update($).digest("hex").slice(0,16)}function uY($){return $G("sha256").update($).digest("hex").slice(0,16)}function Q5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${uY($)}-${uY(Y)}`}async function O8($){try{return(await FO($)).mtimeMs}catch{return 0}}async function J1($){try{return await FO($),!0}catch{return!1}}var j6=()=>{};import{mkdir as MS,readFile as NO,writeFile as TS,readdir as RO,rm as ZG,stat as ES}from"fs/promises";import{join as G5,dirname as IS}from"path";async function DS($){try{await MS($,{recursive:!0})}catch{}}function MO($,Z,Y){return G5($,Y,`${Z}.json`)}async function wO($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await O8(Z)!==$.srcMtime)return!1;return!0}async function K5($,Z,Y,J=L8){if(!J.enabled)return null;let X=Q5($,Z),Q=H6.get(X);if(Q){if(await wO(Q,$,J.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;H6.delete(X)}let G=MO(J.directory,X,Y);if(await J1(G))try{let K=await NO(G,"utf-8"),W=JSON.parse(K);if(await wO(W,$,J.maxAge))return W.lastAccessedAt=Date.now(),H6.set(X,W),W.data}catch{}return null}async function W5($,Z,Y,J,X=L8){if(!X.enabled)return;let Q=Q5($,Z),G=await Y1($),K=await O8($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:Q5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};H6.set(Q,W);let U=MO(X.directory,Q,J);try{await DS(IS(U)),await TS(U,JSON.stringify(W,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function U5($,Z=L8){if($==="all")H6.clear();else H6.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let X=G5(Z.directory,J);try{await ZG(X,{recursive:!0,force:!0})}catch{}}}async function TO($=L8){let Z={memoryEntries:H6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let J=G5($.directory,Y);try{let X=await RO(J);Z.diskEntries[Y]=X.length;for(let Q of X){let G=G5(J,Q),K=await ES(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function EO($=L8){let Z=0,Y=$.maxAge*24*60*60*1000;for(let J of["image","video"]){let X=G5($.directory,J);try{let Q=await RO(X);for(let G of Q){let K=G5(X,G);try{let W=await NO(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await ZG(K),H6.delete(U.key),Z++}catch{await ZG(K).catch(()=>{}),Z++}}}catch{}}return Z}var H6,L8;var mY=D(()=>{j6();H6=new Map,L8={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class z5{config;constructor($={}){this.config={...kS,...$}}async get($,Z){return K5($,Z,"image",this.config)}async set($,Z,Y){return W5($,Z,Y,"image",this.config)}async clear(){return U5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function YG($){if(!lY)lY=new z5($);else if($)lY.updateConfig($);return lY}async function _5($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return YG(J).get($,Z)}async function B5($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return YG(X).set($,Z,Y)}async function JG(){return YG().clear()}var kS,lY=null;var XG=D(()=>{mY();kS={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as SS,basename as CS,extname as bS,join as PS}from"path";import{mkdir as yS}from"fs/promises";async function QG(){try{return await import("ts-images")}catch{return null}}function IO($){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 xS($,Z){let Y=Z?IO(Z):IO("web"),J=$.formatQuality||{};return{jpeg:{...Y.jpeg,...J.jpeg},png:{...Y.png,...J.png},webp:{...Y.webp,...J.webp},avif:{...Y.avif,...J.avif}}}async function GG($,Z,Y){let J=await QG();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let X=await _5($,Z,Y);if(X)return X;try{let Q=SS($);if(!await J1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=xS(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await yS(K,{recursive:!0});let U=await Y1(Q),z=CS($,bS($)),_=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await V8(Q,Z.transformations,J);for(let j of _){let H=G[j]||{},O=`${z}-${U}.${j}`,V=PS(K,O);try{let L=await J.optimizeImage({input:q||Q,output:V,format:j,quality:H.quality,progressive:H.progressive});if(L){if(B.variants.push({path:V,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!B.originalWidth&&L.width)B.originalWidth=L.width,B.originalHeight=L.height}}catch(L){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await J.generateThumbHash(Q);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 J.generatePlaceholder(Q,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await B5($,Z,B,Y),B}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function KG($,Z,Y,J){let X=await QG();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function V8($,Z,Y){let J=Y||await QG();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await J.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)X=await J.resize(X,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)X=await J.blur(X,G.sigma);break;case"sharpen":if(G.amount!==void 0)X=await J.sharpen(X,G.amount);break;case"grayscale":X=await J.grayscale(X);break;case"rotate":if(G.angle!==void 0)X=await J.rotate(X,G.angle);break;case"flip":X=await J.flip(X);break;case"flop":X=await J.flop(X);break;case"brightness":if(G.value!==void 0)X=await J.brightness(X,G.value);break;case"contrast":if(G.value!==void 0)X=await J.contrast(X,G.value);break;case"saturation":if(G.value!==void 0)X=await J.saturation(X,G.value);break}}return await J.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}var DO=D(()=>{j6();XG()});import{resolve as vS,basename as fS,extname as gS,join as hS}from"path";import{mkdir as dS}from"fs/promises";async function uS(){try{return await import("ts-images")}catch{return null}}async function cY($,Z,Y){let J=await uS();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=vS($);if(!await J1(X))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||mS,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await dS(K,{recursive:!0});let U=await Y1(X),z=fS($,gS($)),_=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 O of Q){let V=`${z}-${O}w-${U}.${j}`,L=hS(K,V),F=`${W}/${V}`;try{let A=_[j]?.quality||80;if(await J1(L)){B.byFormat[j].push({path:L,url:F,width:O,height:0,format:j,size:0}),H.push(`${F} ${O}w`);continue}let w=await J.processImage({input:X,output:L,format:j,quality:A,resize:{width:O}});if(w)B.byFormat[j].push({path:L,url:F,width:O,height:w.height||Math.round(O*(w.height||1)/(w.width||1)),format:j,size:w.outputSize||0}),H.push(`${F} ${O}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${A}`)}}B.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await J.generateThumbHash(X);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await J.generatePlaceholder(X,{strategy:q,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||lS(Q),B}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function lS($){let Z=[...$].sort((J,X)=>J-X),Y=[];for(let J=0;J<Z.length-1;J++){let X=Z[J];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function pY($,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 mS;var kO=D(()=>{j6();mS=[320,480,640,768,1024,1280,1536,1920]});var SO={};$0(SO,{setCachedImageResult:()=>B5,processImage:()=>GG,optimizeImage:()=>KG,getCachedImageResult:()=>_5,generateSrcset:()=>pY,generateResponsiveVariants:()=>cY,clearImageCache:()=>JG,applyTransformations:()=>V8,ImageProcessorCache:()=>z5});var WG=D(()=>{DO();kO();XG()});async function cS(){try{return await Promise.resolve().then(() => (WG(),SO))}catch($){if(!CO)console.warn("[stx-media] Image processor not available, some features disabled:",$),CO=!0;return null}}async function O6($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return rS(J,Y)}if(Y.processedResult?.processed)return qG($,Y.processedResult,Z);if(Y.responsiveVariants)return xO($,Y.responsiveVariants,Z);let{src:X,alt:Q,width:G,height:K,sizes:W,widths:U=O4,dpr:z,formats:_=S4,quality:B=UG,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:V=!1,loading:L=V?"eager":nY,decoding:F=iY,fetchpriority:A,objectFit:w,objectPosition:N,crossorigin:R,referrerpolicy:E}=$,M=$.class,I=$.style,S=$.id,k=$.data||{},{isDev:x=!1,baseUrl:y=""}=Z;if(x&&!Z.optimize)return nS($);let b,h,r=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{b=await H8(X,{strategy:j,...H}),h=j8(r,b,H)}catch{}let m=z!==void 0&&G!==void 0,P;if(m)P=iS($,r,b,Z);else P=await pS($,r,b,Z);let d;if(V){let s=_.includes("webp")?"webp":_[0],X0=q6(X,U,{...q,q:B},s),K0=typeof W==="object"?Y5(W):W||"100vw";d=`<link rel="preload" as="image" imagesrcset="${X0}" imagesizes="${K0}" />`}let l=[];if(!bO&&j!=="none")l.push(X5),bO=!0;if(h)l.push(h);let c=O?yO(r):void 0;return{html:P,preloadLink:d,css:l.length>0?l.join(`
|
|
11920
|
-
`):void 0,script:c}}async function pS($,Z,Y,J){let{src:X,alt:Q,width:G,height:K,sizes:W,widths:U=O4,formats:z=S4,quality:_=UG,params:B={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":nY,decoding:O=iY,fetchpriority:V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:w}=$,N=$.class,R=$.style,E=$.data||{},M=typeof W==="object"?Y5(W):W||"100vw",I=[];for(let x of z){let y=q6(X,U,{...B,q:_},x),b=B8(x);if(q&&!j)I.push(` <source type="${b}" data-srcset="${y}" data-sizes="${M}" />`);else I.push(` <source type="${b}" srcset="${y}" sizes="${M}" />`)}let S=zG({src:
|
|
11936
|
+
`.trim();J5=new Map});import{createHash as $G}from"crypto";import{readFile as RS,stat as FO}from"fs/promises";async function Y1($){try{let Z=await RS($);return $G("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function AO($){return $G("sha256").update($).digest("hex").slice(0,16)}function uY($){return $G("sha256").update($).digest("hex").slice(0,16)}function Q5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${uY($)}-${uY(Y)}`}async function O8($){try{return(await FO($)).mtimeMs}catch{return 0}}async function J1($){try{return await FO($),!0}catch{return!1}}var j6=()=>{};import{mkdir as MS,readFile as NO,writeFile as TS,readdir as RO,rm as ZG,stat as ES}from"fs/promises";import{join as G5,dirname as IS}from"path";async function DS($){try{await MS($,{recursive:!0})}catch{}}function MO($,Z,Y){return G5($,Y,`${Z}.json`)}async function wO($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await O8(Z)!==$.srcMtime)return!1;return!0}async function K5($,Z,Y,J=L8){if(!J.enabled)return null;let X=Q5($,Z),Q=H6.get(X);if(Q){if(await wO(Q,$,J.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;H6.delete(X)}let G=MO(J.directory,X,Y);if(await J1(G))try{let K=await NO(G,"utf-8"),W=JSON.parse(K);if(await wO(W,$,J.maxAge))return W.lastAccessedAt=Date.now(),H6.set(X,W),W.data}catch{}return null}async function W5($,Z,Y,J,X=L8){if(!X.enabled)return;let Q=Q5($,Z),G=await Y1($),K=await O8($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:Q5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};H6.set(Q,W);let U=MO(X.directory,Q,J);try{await DS(IS(U)),await TS(U,JSON.stringify(W,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function U5($,Z=L8){if($==="all")H6.clear();else H6.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let X=G5(Z.directory,J);try{await ZG(X,{recursive:!0,force:!0})}catch{}}}async function TO($=L8){let Z={memoryEntries:H6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let J=G5($.directory,Y);try{let X=await RO(J);Z.diskEntries[Y]=X.length;for(let Q of X){let G=G5(J,Q),K=await ES(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function EO($=L8){let Z=0,Y=$.maxAge*24*60*60*1000;for(let J of["image","video"]){let X=G5($.directory,J);try{let Q=await RO(X);for(let G of Q){let K=G5(X,G);try{let W=await NO(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await ZG(K),H6.delete(U.key),Z++}catch{await ZG(K).catch(()=>{}),Z++}}}catch{}}return Z}var H6,L8;var mY=D(()=>{j6();H6=new Map,L8={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class z5{config;constructor($={}){this.config={...kS,...$}}async get($,Z){return K5($,Z,"image",this.config)}async set($,Z,Y){return W5($,Z,Y,"image",this.config)}async clear(){return U5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function YG($){if(!lY)lY=new z5($);else if($)lY.updateConfig($);return lY}async function _5($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return YG(J).get($,Z)}async function B5($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return YG(X).set($,Z,Y)}async function JG(){return YG().clear()}var kS,lY=null;var XG=D(()=>{mY();kS={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as SS,basename as CS,extname as bS,join as PS}from"path";import{mkdir as yS}from"fs/promises";async function QG(){try{return await import("ts-images")}catch{return null}}function IO($){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 xS($,Z){let Y=Z?IO(Z):IO("web"),J=$.formatQuality||{};return{jpeg:{...Y.jpeg,...J.jpeg},png:{...Y.png,...J.png},webp:{...Y.webp,...J.webp},avif:{...Y.avif,...J.avif}}}async function GG($,Z,Y){let J=await QG();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let X=await _5($,Z,Y);if(X)return X;try{let Q=SS($);if(!await J1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=xS(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await yS(K,{recursive:!0});let U=await Y1(Q),z=CS($,bS($)),_=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await V8(Q,Z.transformations,J);for(let j of _){let H=G[j]||{},O=`${z}-${U}.${j}`,V=PS(K,O);try{let L=await J.optimizeImage({input:q||Q,output:V,format:j,quality:H.quality,progressive:H.progressive});if(L){if(B.variants.push({path:V,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!B.originalWidth&&L.width)B.originalWidth=L.width,B.originalHeight=L.height}}catch(L){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await J.generateThumbHash(Q);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 J.generatePlaceholder(Q,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await B5($,Z,B,Y),B}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function KG($,Z,Y,J){let X=await QG();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function V8($,Z,Y){let J=Y||await QG();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await J.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)X=await J.resize(X,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)X=await J.blur(X,G.sigma);break;case"sharpen":if(G.amount!==void 0)X=await J.sharpen(X,G.amount);break;case"grayscale":X=await J.grayscale(X);break;case"rotate":if(G.angle!==void 0)X=await J.rotate(X,G.angle);break;case"flip":X=await J.flip(X);break;case"flop":X=await J.flop(X);break;case"brightness":if(G.value!==void 0)X=await J.brightness(X,G.value);break;case"contrast":if(G.value!==void 0)X=await J.contrast(X,G.value);break;case"saturation":if(G.value!==void 0)X=await J.saturation(X,G.value);break}}return await J.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}var DO=D(()=>{j6();XG()});import{resolve as vS,basename as fS,extname as gS,join as hS}from"path";import{mkdir as dS}from"fs/promises";async function uS(){try{return await import("ts-images")}catch{return null}}async function cY($,Z,Y){let J=await uS();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=vS($);if(!await J1(X))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||mS,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await dS(K,{recursive:!0});let U=await Y1(X),z=fS($,gS($)),_=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 O of Q){let V=`${z}-${O}w-${U}.${j}`,L=hS(K,V),F=`${W}/${V}`;try{let A=_[j]?.quality||80;if(await J1(L)){B.byFormat[j].push({path:L,url:F,width:O,height:0,format:j,size:0}),H.push(`${F} ${O}w`);continue}let w=await J.processImage({input:X,output:L,format:j,quality:A,resize:{width:O}});if(w)B.byFormat[j].push({path:L,url:F,width:O,height:w.height||Math.round(O*(w.height||1)/(w.width||1)),format:j,size:w.outputSize||0}),H.push(`${F} ${O}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${A}`)}}B.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await J.generateThumbHash(X);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await J.generatePlaceholder(X,{strategy:q,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||lS(Q),B}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function lS($){let Z=[...$].sort((J,X)=>J-X),Y=[];for(let J=0;J<Z.length-1;J++){let X=Z[J];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function pY($,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 mS;var kO=D(()=>{j6();mS=[320,480,640,768,1024,1280,1536,1920]});var SO={};$0(SO,{setCachedImageResult:()=>B5,processImage:()=>GG,optimizeImage:()=>KG,getCachedImageResult:()=>_5,generateSrcset:()=>pY,generateResponsiveVariants:()=>cY,clearImageCache:()=>JG,applyTransformations:()=>V8,ImageProcessorCache:()=>z5});var WG=D(()=>{DO();kO();XG()});async function cS(){try{return await Promise.resolve().then(() => (WG(),SO))}catch($){if(!CO)console.warn("[stx-media] Image processor not available, some features disabled:",$),CO=!0;return null}}async function O6($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return rS(J,Y)}if(Y.processedResult?.processed)return qG($,Y.processedResult,Z);if(Y.responsiveVariants)return xO($,Y.responsiveVariants,Z);let{src:X,alt:Q,width:G,height:K,sizes:W,widths:U=O4,dpr:z,formats:_=S4,quality:B=UG,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:V=!1,loading:L=V?"eager":nY,decoding:F=iY,fetchpriority:A,objectFit:w,objectPosition:N,crossorigin:R,referrerpolicy:E}=$,M=$.class,I=$.style,S=$.id,k=$.data||{},{isDev:x=!1,baseUrl:y=""}=Z;if(x&&!Z.optimize)return nS($);let b,h,r=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{b=await H8(X,{strategy:j,...H}),h=j8(r,b,H)}catch{}let m=z!==void 0&&G!==void 0,P;if(m)P=iS($,r,b,Z);else P=await pS($,r,b,Z);let d;if(V){let a=_.includes("webp")?"webp":_[0],X0=q6(X,U,{...q,q:B},a),K0=typeof W==="object"?Y5(W):W||"100vw";d=`<link rel="preload" as="image" imagesrcset="${X0}" imagesizes="${K0}" />`}let l=[];if(!bO&&j!=="none")l.push(X5),bO=!0;if(h)l.push(h);let c=O?yO(r):void 0;return{html:P,preloadLink:d,css:l.length>0?l.join(`
|
|
11937
|
+
`):void 0,script:c}}async function pS($,Z,Y,J){let{src:X,alt:Q,width:G,height:K,sizes:W,widths:U=O4,formats:z=S4,quality:_=UG,params:B={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":nY,decoding:O=iY,fetchpriority:V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:w}=$,N=$.class,R=$.style,E=$.data||{},M=typeof W==="object"?Y5(W):W||"100vw",I=[];for(let x of z){let y=q6(X,U,{...B,q:_},x),b=B8(x);if(q&&!j)I.push(` <source type="${b}" data-srcset="${y}" data-sizes="${M}" />`);else I.push(` <source type="${b}" srcset="${y}" sizes="${M}" />`)}let S=zG({src:s1(X,{...B,q:_}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:w,className:PO(N,Y),style:_G(R,L,F,Y),lazy:q&&!j,data:E}),k;if(Y){let x=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${x}">
|
|
11921
11938
|
<picture>
|
|
11922
11939
|
${I.join(`
|
|
11923
11940
|
`)}
|
|
@@ -11927,7 +11944,7 @@ ${I.join(`
|
|
|
11927
11944
|
${I.join(`
|
|
11928
11945
|
`)}
|
|
11929
11946
|
<img ${S} />
|
|
11930
|
-
</picture>`;return k}function iS($,Z,Y,J){let{src:X,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=UG,params:z={},lazy:_=!0,priority:B=!1,loading:q=B?"eager":nY,decoding:j=iY,fetchpriority:H,objectFit:O,objectPosition:V,crossorigin:L,referrerpolicy:F}=$,A=$.class,w=$.style,N=$.data||{},R=typeof G==="number"?G:Number.parseInt(String(G),10),E=Z5(X,R,W,{...z,q:U}),M=zG({src:
|
|
11947
|
+
</picture>`;return k}function iS($,Z,Y,J){let{src:X,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=UG,params:z={},lazy:_=!0,priority:B=!1,loading:q=B?"eager":nY,decoding:j=iY,fetchpriority:H,objectFit:O,objectPosition:V,crossorigin:L,referrerpolicy:F}=$,A=$.class,w=$.style,N=$.data||{},R=typeof G==="number"?G:Number.parseInt(String(G),10),E=Z5(X,R,W,{...z,q:U}),M=zG({src:s1(X,{...z,w:R,q:U}),alt:Q,width:G,height:K,loading:B?void 0:q,decoding:j,fetchpriority:B?"high":H,objectFit:O,objectPosition:V,crossorigin:L,referrerpolicy:F,className:PO(A,Y),style:_G(w,O,V,Y),lazy:_&&!B,data:N}),I=_&&!B?`data-srcset="${E}"`:`srcset="${E}"`;if(Y){let S=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${S}">
|
|
11931
11948
|
<img ${M} ${I} />
|
|
11932
11949
|
</div>`}return`<img ${Z?`id="${Z}" `:""}${M} ${I} />`}function nS($){let{src:Z,alt:Y,width:J,height:X,loading:Q=nY,decoding:G=iY,fetchpriority:K,objectFit:W,objectPosition:U,crossorigin:z,referrerpolicy:_,priority:B=!1}=$,q=$.class,j=$.style,H=$.id,O=$.data||{};return{html:`<img ${zG({src:Z,alt:Y,width:J,height:X,loading:B?"eager":Q,decoding:G,fetchpriority:B?"high":K,objectFit:W,objectPosition:U,crossorigin:z,referrerpolicy:_,className:q,style:_G(j,W,U),id:H,data:O})} />`}}function zG($){let Z=[];if($.lazy)Z.push(`data-src="${o1($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${o1($.src)}"`);if(Z.push(`alt="${o1($.alt)}"`),$.width)Z.push(`width="${$.width}"`);if($.height)Z.push(`height="${$.height}"`);if($.loading)Z.push(`loading="${$.loading}"`);if($.decoding)Z.push(`decoding="${$.decoding}"`);if($.fetchpriority)Z.push(`fetchpriority="${$.fetchpriority}"`);if($.crossorigin)Z.push(`crossorigin="${$.crossorigin}"`);if($.referrerpolicy)Z.push(`referrerpolicy="${$.referrerpolicy}"`);if($.className)Z.push(`class="${o1($.className)}"`);if($.style)Z.push(`style="${o1($.style)}"`);if($.id)Z.push(`id="${o1($.id)}"`);if($.data)for(let[Y,J]of Object.entries($.data))Z.push(`data-${Y}="${o1(J)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function PO($,Z){let Y=[];if($)Y.push($);if(Z)Y.push("stx-img-blur");return Y.join(" ")||""}function _G($,Z,Y,J){let X=[];if(Z)X.push(`object-fit: ${Z}`);if(Y)X.push(`object-position: ${Y}`);if(J)X.push("opacity: 0; transition: opacity 300ms ease-out");if($)X.push($);return X.join("; ")}function o1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function yO($){return`
|
|
11933
11950
|
(function() {
|
|
@@ -11977,10 +11994,10 @@ ${w.join(`
|
|
|
11977
11994
|
`)}
|
|
11978
11995
|
<img ${R.join(" ")} />
|
|
11979
11996
|
</picture>`;let x=[];if(Z.placeholder)x.push(X5);let y=G?yO(j):void 0,b;if(K&&F)b=`<link rel="preload" as="image" imagesrcset="${F}" />`;return{html:k,preloadLink:b,css:x.length>0?x.join(`
|
|
11980
|
-
`):void 0,script:y}}async function xO($,Z,Y){let J={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[X,Q]of Object.entries(Z.byFormat))if(Q)J.variants.push(...Q);return qG($,J,Y)}var CO=!1,UG=80,iY="async",nY="lazy",bO=!1;var jG=D(()=>{hY();eQ()});function
|
|
11997
|
+
`):void 0,script:y}}async function xO($,Z,Y){let J={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[X,Q]of Object.entries(Z.byFormat))if(Q)J.variants.push(...Q);return qG($,J,Y)}var CO=!1,UG=80,iY="async",nY="lazy",bO=!1;var jG=D(()=>{hY();eQ()});function aY(){return u0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,J)=>{let{src:X,alt:Q,options:G}=aS($,Z,Y);if(!X)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:X,alt:Q||"",widths:G.widths||O4,formats:G.formats||S4,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},W=Y.__isDev||!1,U=await O6(K,{isDev:W}),z=U.html;if(U.preloadLink)z=U.preloadLink+`
|
|
11981
11998
|
`+z;if(U.css)z+=`
|
|
11982
11999
|
<style>${U.css}</style>`;if(U.script)z+=`
|
|
11983
|
-
<script>${U.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function
|
|
12000
|
+
<script>${U.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function aS($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@img(")||J.startsWith("("))J=J.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=sS(J),Q=HG(X[0],Y)||"",G=HG(X[1],Y)||"",K={};if(X[2]){let W=HG(X[2],Y);if(typeof W==="object"&&W!==null)K=W;else if(typeof X[2]==="string")try{K=JSON.parse(X[2])}catch{}}return{src:Q,alt:G,options:K}}function sS($){let Z=[],Y="",J=!1,X="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!J)J=!0,X=W;else if(W===X)J=!1,X="";else Y+=W;continue}if(!J){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function HG($,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 J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var F8;var OG=D(()=>{U8();jG();hY();F8=aY()});class q5{config;constructor($={}){this.config={...oS,...$}}async get($,Z){return K5($,Z,"video",this.config)}async set($,Z,Y){return W5($,Z,Y,"video",this.config)}async clear(){return U5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function LG($){if(!sY)sY=new q5($);else if($)sY.updateConfig($);return sY}async function j5($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return LG(J).get($,Z)}async function H5($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return LG(X).set($,Z,Y)}async function oY(){return LG().clear()}var oS,sY=null;var VG=D(()=>{mY();oS={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as FG,basename as AG,extname as wG,join as tY}from"path";import{mkdir as NG}from"fs/promises";async function RG(){try{return await import("ts-videos")}catch{return null}}async function O5($,Z,Y,J){let X=await RG();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=FG($);if(!await J1(Q))return null;await NG(Y,{recursive:!0});let G=await Y1(Q),K=AG($,wG($)),W=Z.format||"webp",U=Z.timestamp||0,z=`${K}-poster-${G}.${W}`,_=tY(Y,z),B=await X.extractThumbnails(Q,{timestamps:[U],width:Z.width||1280,height:Z.height,format:W,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${W}`,"")});if(B&&B.length>0){let q=B[0];return{path:_,url:`${J}/${z}`,width:q.width||Z.width||1280,height:q.height||720,timestamp:U,size:q.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function L5($,Z,Y,J){let X=await RG();if(!X)return[];try{let Q=FG($);if(!await J1(Q))return[];await NG(Y,{recursive:!0});let G=await Y1(Q),K=AG($,wG($)),W=Z.format||"webp",_=(await new X.Input(Q).getInfo()).duration||60,B=Z.count||10,q=Z.interval||_/B,j=[];for(let O=0;O<B&&O*q<_;O++)j.push(O*q);let H=await X.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:W,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((O,V)=>({path:O.path||tY(Y,`${K}-thumb-${G}-${V}.${W}`),url:`${J}/${K}-thumb-${G}-${V}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[V],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function eY($,Z,Y,J){let X=await RG();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=FG($);if(!await J1(Q))return null;await NG(Y,{recursive:!0});let G=await Y1(Q),K=AG($,wG($)),z=(await new X.Input(Q).getInfo()).duration||60,_=Z.columns||10,B=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",O=Math.ceil(z/B),V=Math.ceil(O/_),L=`${K}-sprite-${G}.${H}`,F=tY(Y,L),A=[];for(let N=0;N<O;N++)A.push(N*B);let w=await X.extractThumbnails(Q,{timestamps:A,width:q,height:j,format:H,quality:Z.quality||70,outputDir:tY(Y,".temp")});if(!w||w.length===0)return null;try{let N=await import("ts-images"),R=_*q,E=V*j,M=await N.createSprite({images:w.map((I)=>I.path),columns:_,padding:0,outputPath:F,format:H,quality:Z.quality||70});return{url:`${J}/${L}`,path:F,columns:_,rows:V,thumbnailWidth:q,thumbnailHeight:j,interval:B,totalFrames:O}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var MG=D(()=>{j6()});import{resolve as fO,basename as gO,extname as hO,join as $$}from"path";import{mkdir as $J,writeFile as dO}from"fs/promises";async function uO(){try{return await import("ts-videos")}catch{return null}}async function V5($,Z,Y,J,X){let Q=await uO();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=fO($);if(!await J1(G))return null;let K=await Y1(G),W=gO($,hO($)),U=$$(Y,`${W}-${K}-hls`);await $J(U,{recursive:!0});let z=Z.length>0?Z:mO,_=X?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],O=0;for(let F of z){let A=$$(U,F.label);await $J(A,{recursive:!0});let w=`${F.label}.m3u8`,N=$$(A,w);try{let R=await Q.generateHLS(G,{outputDir:A,segmentDuration:_,width:F.width,height:F.height,videoBitrate:F.bitrate,audioBitrate:F.audioBitrate,playlistName:F.label});if(R)H.push({quality:F,url:`${J}/${W}-${K}-hls/${F.label}/${w}`,path:N}),O+=R.segmentCount||Math.ceil(j/_)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${F.label}: ${R}`)}}if(H.length===0)return null;let V=$$(U,"master.m3u8"),L=tS(H,J,W,K);return await dO(V,L),{manifestUrl:`${J}/${W}-${K}-hls/master.m3u8`,manifestPath:V,playlists:H,segmentCount:O,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function tS($,Z,Y,J){let X=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),W=`${G.width}x${G.height||Math.round(G.width*9/16)}`;X.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${W},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return X.join(`
|
|
11984
12001
|
`)}async function F5($,Z,Y,J,X){let Q=await uO();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=fO($);if(!await J1(G))return null;let K=await Y1(G),W=gO($,hO($)),U=$$(Y,`${W}-${K}-dash`);await $J(U,{recursive:!0});let z=Z.length>0?Z:mO,_=X?.segmentDuration||4,B=X?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,O=[],V=[];for(let w of z){let N=$$(U,w.label);await $J(N,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:N,segmentDuration:_,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate})){if(O.push({bandwidth:w.bitrate,width:w.width,height:w.height||Math.round(w.width*9/16),url:`${J}/${W}-${K}-dash/${w.label}/video`}),w.audioBitrate)V.push({bandwidth:w.audioBitrate,url:`${J}/${W}-${K}-dash/${w.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${w.label}: ${R}`)}}if(O.length===0)return null;let L=$$(U,"manifest.mpd"),F=eS(O,V,H,_,B);await dO(L,F);let A=[{type:"video",representations:O}];if(V.length>0)A.push({type:"audio",representations:V});return{manifestUrl:`${J}/${W}-${K}-dash/manifest.mpd`,manifestPath:L,adaptationSets:A,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function eS($,Z,Y,J,X){let Q=vO(Y),G=vO(X),K=`<?xml version="1.0" encoding="UTF-8"?>
|
|
11985
12002
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
11986
12003
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
@@ -12007,7 +12024,7 @@ ${w.join(`
|
|
|
12007
12024
|
</Representation>
|
|
12008
12025
|
`}K+=` </AdaptationSet>
|
|
12009
12026
|
`}return K+=` </Period>
|
|
12010
|
-
</MPD>`,K}function vO($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),X="PT";if(Z>0)X+=`${Z}H`;if(Y>0)X+=`${Y}M`;return X+=`${J}S`,X}var mO;var TG=D(()=>{j6();mO=[{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 lO,basename as $C,extname as ZC,join as YC}from"path";import{mkdir as JC}from"fs/promises";async function cO(){try{return await import("ts-videos")}catch{return null}}function XC($){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 QC($){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 A8($){let Z=await cO();if(!Z)return null;try{let Y=lO($),X=await new Z.Input(Y).getInfo();return{duration:X.duration||0,width:X.width||0,height:X.height||0,frameRate:X.frameRate||0,bitrate:X.bitrate||0,codec:X.videoCodec||"",audioCodec:X.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function ZJ($,Z,Y,J){let X=await cO();if(!X)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await j5($,Z,Y);if(Q)return Q;try{let G=lO($);if(!await J1(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await JC(K,{recursive:!0});let U=await Y1(G),z=$C($,ZC($)),_={src:$,processed:!0,hash:U};J?.({percentage:5,stage:"analyzing"}),_.metadata=await A8(G)||void 0;let B={};if(Z.quality)B.bitrate=XC(Z.quality);if(Z.platform)Object.assign(B,QC(Z.platform));if(Z.transcode)Object.assign(B,Z.transcode);if(Object.keys(B).length>0||Z.process){J?.({percentage:10,stage:"transcoding"});let q=`${z}-${U}.mp4`,j=YC(K,q);try{let H=await GC(G,j,B,X,(O)=>J?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)_.transcoded={path:j,url:`${W}/${q}`,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){_.errors=_.errors||[],_.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){J?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await O5(G,q,K,W);if(j)_.poster=j}if(Y.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let q=await L5(G,Y.thumbnails,K,W);if(q.length>0)_.thumbnails=q}if(Z.streaming){J?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await V5(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,hls:j}}if(q.format==="dash"){let j=await F5(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,dash:j}}}if(Z.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await H5($,Z,_,Y),_}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function GC($,Z,Y,J,X){try{let G=await new J.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)=>{X?.(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(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var pO=D(()=>{j6();VG();MG();TG()});var iO={};$0(iO,{setCachedVideoResult:()=>H5,processVideo:()=>ZJ,getCachedVideoResult:()=>j5,generateThumbnails:()=>L5,generateSpriteSheet:()=>eY,generatePoster:()=>O5,generateHLSManifest:()=>V5,generateDASHManifest:()=>F5,clearVideoCache:()=>oY,analyzeVideo:()=>A8,VideoProcessorCache:()=>q5});var EG=D(()=>{pO();MG();TG();VG()});async function rO(){try{return await Promise.resolve().then(() => (EG(),iO))}catch($){if(!nO)console.warn("[stx-media] Video processor not available, some features disabled:",$),nO=!0;return null}}async function A5($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return BC(J,Y)}if(Y.processedResult?.processed)return eO($,Y.processedResult,Z);let X;if(J.generatePoster&&J.src&&!$.poster)X=await qC(J,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=
|
|
12027
|
+
</MPD>`,K}function vO($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),X="PT";if(Z>0)X+=`${Z}H`;if(Y>0)X+=`${Y}M`;return X+=`${J}S`,X}var mO;var TG=D(()=>{j6();mO=[{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 lO,basename as $C,extname as ZC,join as YC}from"path";import{mkdir as JC}from"fs/promises";async function cO(){try{return await import("ts-videos")}catch{return null}}function XC($){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 QC($){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 A8($){let Z=await cO();if(!Z)return null;try{let Y=lO($),X=await new Z.Input(Y).getInfo();return{duration:X.duration||0,width:X.width||0,height:X.height||0,frameRate:X.frameRate||0,bitrate:X.bitrate||0,codec:X.videoCodec||"",audioCodec:X.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function ZJ($,Z,Y,J){let X=await cO();if(!X)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await j5($,Z,Y);if(Q)return Q;try{let G=lO($);if(!await J1(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await JC(K,{recursive:!0});let U=await Y1(G),z=$C($,ZC($)),_={src:$,processed:!0,hash:U};J?.({percentage:5,stage:"analyzing"}),_.metadata=await A8(G)||void 0;let B={};if(Z.quality)B.bitrate=XC(Z.quality);if(Z.platform)Object.assign(B,QC(Z.platform));if(Z.transcode)Object.assign(B,Z.transcode);if(Object.keys(B).length>0||Z.process){J?.({percentage:10,stage:"transcoding"});let q=`${z}-${U}.mp4`,j=YC(K,q);try{let H=await GC(G,j,B,X,(O)=>J?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)_.transcoded={path:j,url:`${W}/${q}`,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){_.errors=_.errors||[],_.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){J?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await O5(G,q,K,W);if(j)_.poster=j}if(Y.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let q=await L5(G,Y.thumbnails,K,W);if(q.length>0)_.thumbnails=q}if(Z.streaming){J?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await V5(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,hls:j}}if(q.format==="dash"){let j=await F5(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,dash:j}}}if(Z.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await H5($,Z,_,Y),_}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function GC($,Z,Y,J,X){try{let G=await new J.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)=>{X?.(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(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var pO=D(()=>{j6();VG();MG();TG()});var iO={};$0(iO,{setCachedVideoResult:()=>H5,processVideo:()=>ZJ,getCachedVideoResult:()=>j5,generateThumbnails:()=>L5,generateSpriteSheet:()=>eY,generatePoster:()=>O5,generateHLSManifest:()=>V5,generateDASHManifest:()=>F5,clearVideoCache:()=>oY,analyzeVideo:()=>A8,VideoProcessorCache:()=>q5});var EG=D(()=>{pO();MG();TG();VG()});async function rO(){try{return await Promise.resolve().then(() => (EG(),iO))}catch($){if(!nO)console.warn("[stx-media] Video processor not available, some features disabled:",$),nO=!0;return null}}async function A5($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return BC(J,Y)}if(Y.processedResult?.processed)return eO($,Y.processedResult,Z);let X;if(J.generatePoster&&J.src&&!$.poster)X=await qC(J,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=aO,autoplay:z=!1,muted:_=!1,loop:B=!1,preload:q=sO,playsinline:j=!0,lazy:H=!0,player:O="native",type:V,width:L,height:F,crossorigin:A,disablePictureInPicture:w=!1,disableRemotePlayback:N=!1}=$,R=X||K,E=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return UC($,Z);if(V&&V!=="video")return WC(Q||"",V,$);let S=G.length>0?G:Q?[{src:Q,type:oO(Q)}]:[],k=[`id="${I}"`];if(U)k.push("controls");if(z)k.push("autoplay");if(_)k.push("muted");if(B)k.push("loop");if(j)k.push("playsinline");if(w)k.push("disablepictureinpicture");if(N)k.push("disableremoteplayback");if(A)k.push(`crossorigin="${A}"`);if(H){if(k.push(`data-preload="${q}"`),k.push('preload="none"'),R)k.push(`data-poster="${o0(R)}"`);k.push("data-stx-lazy")}else if(k.push(`preload="${q}"`),R)k.push(`poster="${o0(R)}"`);if(L)k.push(`width="${L}"`);if(F)k.push(`height="${F}"`);if(E)k.push(`class="${o0(E)}"`);if(M)k.push(`style="${o0(M)}"`);let x=S.map((h)=>{return` <source ${H?`data-src="${o0(h.src)}"`:`src="${o0(h.src)}"`} type="${h.type}"${h.media?` media="${h.media}"`:""} />`}).join(`
|
|
12011
12028
|
`),y=`<video ${k.join(" ")}>
|
|
12012
12029
|
${x}
|
|
12013
12030
|
Your browser does not support the video tag.
|
|
@@ -12215,7 +12232,7 @@ else {
|
|
|
12215
12232
|
.ts-video-player__play-button svg {
|
|
12216
12233
|
margin-left: 4px;
|
|
12217
12234
|
}
|
|
12218
|
-
`.trim();return{html:F,script:A,css:w}}function oO($){switch($.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function zC($){let Z=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let Y of Z){let J=$.match(Y);if(J)return J[1]}return null}function _C($){let Z=$.match(/vimeo\.com\/(\d+)/);return Z?Z[1]:null}function o0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function tO($,Z,Y){if(Z.src)return{src:String(Z.src),...Z};let J=$.trim();if(J.startsWith("@video(")||J.startsWith("("))J=J.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=J.indexOf(",");if(X===-1)return{src:J.replace(/^['"]|['"]$/g,"")};let Q=J.slice(0,X).trim().replace(/^['"]|['"]$/g,""),G=J.slice(X+1).trim();try{let K=JSON.parse(G);return{src:Q,...K}}catch{return{src:Q}}}async function BC($,Z){let Y=await rO();if(!Y)return A5({...$,process:!1},Z);let J=Z.tsVideosConfig,X=await Y.processVideo($.src,$,J,$.onProcessProgress);if(X.processed)return eO($,X,Z);return A5({...$,process:!1},Z)}async function qC($,Z){let Y=await rO();if(!Y||!$.src)return;let J=typeof $.generatePoster==="object"?$.generatePoster:{timestamp:0},X=Z.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await Y.generatePoster($.src,J,X.outputDir,X.baseUrl||"/videos"))?.url}function eO($,Z,Y){let{controls:J=
|
|
12235
|
+
`.trim();return{html:F,script:A,css:w}}function oO($){switch($.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function zC($){let Z=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let Y of Z){let J=$.match(Y);if(J)return J[1]}return null}function _C($){let Z=$.match(/vimeo\.com\/(\d+)/);return Z?Z[1]:null}function o0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function tO($,Z,Y){if(Z.src)return{src:String(Z.src),...Z};let J=$.trim();if(J.startsWith("@video(")||J.startsWith("("))J=J.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=J.indexOf(",");if(X===-1)return{src:J.replace(/^['"]|['"]$/g,"")};let Q=J.slice(0,X).trim().replace(/^['"]|['"]$/g,""),G=J.slice(X+1).trim();try{let K=JSON.parse(G);return{src:Q,...K}}catch{return{src:Q}}}async function BC($,Z){let Y=await rO();if(!Y)return A5({...$,process:!1},Z);let J=Z.tsVideosConfig,X=await Y.processVideo($.src,$,J,$.onProcessProgress);if(X.processed)return eO($,X,Z);return A5({...$,process:!1},Z)}async function qC($,Z){let Y=await rO();if(!Y||!$.src)return;let J=typeof $.generatePoster==="object"?$.generatePoster:{timestamp:0},X=Z.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await Y.generatePoster($.src,J,X.outputDir,X.baseUrl||"/videos"))?.url}function eO($,Z,Y){let{controls:J=aO,autoplay:X=!1,muted:Q=!1,loop:G=!1,preload:K=sO,playsinline:W=!0,lazy:U=!0,width:z,height:_,crossorigin:B,disablePictureInPicture:q=!1,disableRemotePlayback:j=!1}=$,H=$.class,O=$.style,V=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,L=$.src,F=oO(L);if(Z.transcoded)L=Z.transcoded.url,F="video/mp4";let A=Z.streaming?.hls||Z.streaming?.dash;if(A){if(Z.streaming?.hls)L=Z.streaming.hls.manifestUrl,F="application/x-mpegURL";else if(Z.streaming?.dash)L=Z.streaming.dash.manifestUrl,F="application/dash+xml"}let w=Z.poster?.url||$.poster,N=[`id="${V}"`];if(J)N.push("controls");if(X)N.push("autoplay");if(Q)N.push("muted");if(G)N.push("loop");if(W)N.push("playsinline");if(q)N.push("disablepictureinpicture");if(j)N.push("disableremoteplayback");if(B)N.push(`crossorigin="${B}"`);if(U){if(N.push(`data-preload="${K}"`),N.push('preload="none"'),w)N.push(`data-poster="${o0(w)}"`);N.push("data-stx-lazy")}else if(N.push(`preload="${K}"`),w)N.push(`poster="${o0(w)}"`);let R=z||Z.metadata?.width,E=_||Z.metadata?.height;if(R)N.push(`width="${R}"`);if(E)N.push(`height="${E}"`);if(H)N.push(`class="${o0(H)}"`);if(O)N.push(`style="${o0(O)}"`);let I=` <source ${U?`data-src="${o0(L)}"`:`src="${o0(L)}"`} type="${F}" />`,S=`<video ${N.join(" ")}>
|
|
12219
12236
|
${I}
|
|
12220
12237
|
Your browser does not support the video tag.
|
|
12221
12238
|
</video>`;if(Z.spriteSheet)S=`<div class="stx-video-wrapper" data-sprite-sheet="${o0(Z.spriteSheet.url)}" data-sprite-cols="${Z.spriteSheet.columns}" data-sprite-interval="${Z.spriteSheet.interval}">
|
|
@@ -12264,7 +12281,7 @@ ${S}
|
|
|
12264
12281
|
width: 100%;
|
|
12265
12282
|
height: auto;
|
|
12266
12283
|
}
|
|
12267
|
-
`.trim();return{html:S,script:k,css:x}}var nO=!1,
|
|
12284
|
+
`.trim();return{html:S,script:k,css:x}}var nO=!1,aO=!0,sO="metadata",KC="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var IG=D(()=>{DG()});function YJ(){return u0({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,J)=>{let{src:X,options:Q}=jC($,Z,Y);if(!X)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:X,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},W={isDev:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},U=await A5(G,W),z=U.html;if(U.css)z+=`
|
|
12268
12285
|
<style>${U.css}</style>`;if(U.script)z+=`
|
|
12269
12286
|
<script>${U.script}</script>`;return z},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function jC($,Z,Y){if(Z.src)return{src:String(Z.src),options:Z.options||{}};let J=$.trim();if(J.startsWith("@video(")||J.startsWith("("))J=J.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=HC(J),Q=$L(X[0],Y)||"",G={};if(X[1]){let K=$L(X[1],Y);if(typeof K==="object"&&K!==null)G=K;else if(typeof X[1]==="string")try{G=JSON.parse(X[1])}catch{}}return{src:Q,options:G}}function HC($){let Z=[],Y="",J=!1,X="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!J)J=!0,X=W;else if(W===X)J=!1,X="";else Y+=W;continue}if(!J){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function $L($,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 J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var w8;var DG=D(()=>{U8();IG();w8=YJ()});function OC($,Z){let Y=Z.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
|
|
12270
12287
|
${$}
|
|
@@ -13660,7 +13677,7 @@ ${z}
|
|
|
13660
13677
|
customElements.define('${Z}', ${G});
|
|
13661
13678
|
`}async function CG($,Z,Y,J){if(Z.length<1)return H0("WebComponent","@webcomponent directive requires at least the tag name parameter",G0.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[L6.join(L6.dirname(J),G,`${X}.stx`),L6.join(process.cwd(),G,`${X}.stx`),L6.join(L6.dirname(J),`${X}.stx`)],W=null;for(let _ of K)if(await Q0(_)){W=await Bun.file(_).text();break}if(!W)return H0("WebComponent",`Component file not found: ${X}.stx`,G0.FILE_NOT_FOUND);let U=QL(W,X);return`<script type="module">
|
|
13662
13679
|
${GL(U)}
|
|
13663
|
-
</script>`}var SG;var bG=D(()=>{C1();N0();SG={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var KL={};$0(KL,{timingPlugin:()=>dC,pluginManager:()=>yG,definePlugin:()=>N5,debugPlugin:()=>hC,createVariablesPlugin:()=>uC,createFilterPlugin:()=>gC,createDirectivePlugin:()=>fC,PluginManager:()=>PG});function N5($){return $}class PG{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,J]of this.plugins)if(J.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 J of this.sortedPlugins){let X=J[$];if(X)try{let Q=await X(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let G=await Q(Z,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${X.name}" ${$} hook:`,G)}}return J}}function fC($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function gC($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function uC($){return N5({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var yG,hC,dC;var xG=D(()=>{yG=new PG;hC=N5({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)}}),dC=N5({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 jZ={};$0(jZ,{validateConfig:()=>zL,loadStxConfig:()=>d0,defineStxConfig:()=>UL,defaultConfig:()=>N1,config:()=>T1});import vG from"fs";import j1 from"path";import{loadConfigWithResult as mC}from"bunfig";function lC($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=j1.join(process.cwd(),"resources","views"),X=j1.join(process.cwd(),"resources","layouts");if(vG.existsSync(J)&&vG.existsSync(X))return{root:"resources",pagesDir:"views"};let Q=j1.join(process.cwd(),"resources","views","pages");if(vG.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}function cC($){if(PX($.stateDir),$.stateDir=F$(),$.cachePath=A$($.cachePath),$.build)$.build.cacheDir=A$($.build.cacheDir);if($.media?.cache)$.media.cache.directory=A$($.media.cache.directory);if($.story)$.story.outDir=A$($.story.outDir)}async function d0($){if(!$){if(R5)return R5;if(XJ)return XJ}let Z=$?j1.resolve($):process.cwd(),Y=WL.get(Z);if(Y)return Y;let J=(async()=>{let Q=(await mC({name:"stx",alias:"ui",cwd:Z,defaultConfig:N1,verbose:!1})).config;cC(Q);let G=lC(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!j1.isAbsolute(Q.partialsDir))Q.partialsDir=j1.join(K,Q.partialsDir);if(Q.componentsDir&&!j1.isAbsolute(Q.componentsDir))Q.componentsDir=j1.join(K,Q.componentsDir);if(Q.layoutsDir&&!j1.isAbsolute(Q.layoutsDir))Q.layoutsDir=j1.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (xG(),KL)),W=[],U=[];for(let z of Q.plugins){let _=typeof z==="string"?z:z[0],B=typeof z==="string"?{}:z[1]||{};try{let q,j;try{q=await import(_),j=j1.dirname(Z0.resolve(_))}catch{let O=j1.resolve(process.cwd(),_);q=await import(O),j=j1.dirname(O)}let H=q.default||q;if(K.register(H,Q),H.components){let O=j1.resolve(j,H.components);W.push(O)}if(H.pages){let O=j1.resolve(j,H.pages),V=B.path||"/";U.push({dir:O,prefix:V})}if(H.setup){let O={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=L},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await H.setup(B,O)}console.log(`[stx] Plugin loaded: ${H.name||_}`)}catch(q){console.warn(`[stx] Failed to load plugin ${_}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(WL.set(Z,J),!$)XJ=J,J.then((X)=>{R5=X}).catch(()=>{});return J}function UL($){return $}function zL($){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 J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${J.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 J=["AA","AAA"];if(!J.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${X}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${X}].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((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${X}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${X}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${X}].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 J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((X,Q)=>{if(!X.pattern||typeof X.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(X.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(X.maxAgeSeconds!==void 0&&(typeof X.maxAgeSeconds!=="number"||X.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(X.maxEntries!==void 0&&(typeof X.maxEntries!=="number"||X.maxEntries<1))Z.push({path:`pwa.routes[${Q}].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((X)=>typeof X!=="number"||X<16||X>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 J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.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 N1,R5=null,WL,XJ=null,T1;var r0=D(()=>{V$();e3();DX();$Z();yY();OG();DG();YL();GY();G4();bG();N1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:P6,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:bQ,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:CG,hasEndTag:!1,description:"Include a web component in the template"},n3,r3,XY,QY,s3,o3,t3,a3,qz,CX,F8,w8,...ZL],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}};WL=new Map;T1=new Proxy(N1,{get($,Z){if(R5&&Z in R5)return R5[Z];if(!XJ)d0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import pC from"fs";import fG from"path";import{createHighlighter as iC}from"ts-syntax-highlighter";async function C4($,Z={}){try{if(!await Q0($))throw Error(`Markdown file not found: ${$}`);let J=(await pC.promises.stat($)).mtime.getTime();if(Z.cache&&GJ.has($)){let _=GJ.get($);if(_.updatedAt>=J)return{content:_.content,data:_.data}}let X=await Bun.file($).text(),{data:Q,content:G}=Oz(X),K=Z.markdown||T1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=X7(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await nC(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:U,data:Q||{}};if(Z.cache)GJ.set($,{...z,updatedAt:J});return z}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let J=Y instanceof Error?Y.message:String(Y);return{content:T0("Markdown File",`Error reading/parsing markdown file: ${J}`,$,"",0,""),data:{}}}}async function nC($,Z,Y){let J=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!QJ)try{QJ=await iC({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let X=async(K,W,U,z)=>{let _=z.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),B=U||(Y?"text":"");if(!B)return K;try{if(!QJ.getSupportedLanguages().includes(B))return K;return(await QJ.highlight(_,B,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(J);for(let K of G){let[W,U,z,_]=K,B=await X(W,U,z,_);Q=Q.replace(W,B)}return Q}async function MQ($,Z,Y="",J={}){return await rC($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let z=K;if(!fG.isAbsolute(K))z=fG.resolve(fG.dirname(Y),K);let _={};if(W)try{try{_=JSON.parse(W)}catch{if(J.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of L){let A=F.indexOf(":");if(A>0){let w=F.substring(0,A).trim(),N=F.substring(A+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),E=N.startsWith("'")&&N.endsWith("'");if(R||E)N=N.substring(1,N.length-1);_[w]=N}}}}catch(V){if(J.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:B,data:q}=await C4(z,J),j={...Z,...q,..._},H=B,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(V,L)=>{let F=L.trim();return j[F]!==void 0?String(j[F]):V}),H}catch(z){let _=z instanceof Error?z.message:String(z);return T0("Markdown File",`Error including markdown file: ${_}`,Y,$,U,G)}})}async function rC($,Z,Y){let J=[],X;while((X=Z.exec($))!==null){let K=X[0],W=X.index,U=X;J.push(Y(...U).then((z)=>({match:K,replacement:z,index:W})))}let Q=await Promise.all(J);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var GJ,QJ=null;var $5=D(()=>{r0();N0();GJ=new Map});function KJ(){return`
|
|
13680
|
+
</script>`}var SG;var bG=D(()=>{C1();N0();SG={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var KL={};$0(KL,{timingPlugin:()=>dC,pluginManager:()=>yG,definePlugin:()=>N5,debugPlugin:()=>hC,createVariablesPlugin:()=>uC,createFilterPlugin:()=>gC,createDirectivePlugin:()=>fC,PluginManager:()=>PG});function N5($){return $}class PG{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,J]of this.plugins)if(J.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 J of this.sortedPlugins){let X=J[$];if(X)try{let Q=await X(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let G=await Q(Z,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${X.name}" ${$} hook:`,G)}}return J}}function fC($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function gC($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function uC($){return N5({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var yG,hC,dC;var xG=D(()=>{yG=new PG;hC=N5({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)}}),dC=N5({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 jZ={};$0(jZ,{validateConfig:()=>zL,loadStxConfig:()=>d0,defineStxConfig:()=>UL,defaultConfig:()=>N1,config:()=>T1});import vG from"fs";import j1 from"path";import{loadConfigWithResult as mC}from"bunfig";function lC($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=j1.join(process.cwd(),"resources","views"),X=j1.join(process.cwd(),"resources","layouts");if(vG.existsSync(J)&&vG.existsSync(X))return{root:"resources",pagesDir:"views"};let Q=j1.join(process.cwd(),"resources","views","pages");if(vG.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}function cC($){if(PX($.stateDir),$.stateDir=F$(),$.cachePath=A$($.cachePath),$.build)$.build.cacheDir=A$($.build.cacheDir);if($.media?.cache)$.media.cache.directory=A$($.media.cache.directory);if($.story)$.story.outDir=A$($.story.outDir)}async function d0($){if(!$){if(R5)return R5;if(XJ)return XJ}let Z=$?j1.resolve($):process.cwd(),Y=WL.get(Z);if(Y)return Y;let J=(async()=>{let Q=(await mC({name:"stx",alias:"ui",cwd:Z,defaultConfig:N1,verbose:!1})).config;cC(Q);let G=lC(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!j1.isAbsolute(Q.partialsDir))Q.partialsDir=j1.join(K,Q.partialsDir);if(Q.componentsDir&&!j1.isAbsolute(Q.componentsDir))Q.componentsDir=j1.join(K,Q.componentsDir);if(Q.layoutsDir&&!j1.isAbsolute(Q.layoutsDir))Q.layoutsDir=j1.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (xG(),KL)),W=[],U=[];for(let z of Q.plugins){let _=typeof z==="string"?z:z[0],B=typeof z==="string"?{}:z[1]||{};try{let q,j;try{q=await import(_),j=j1.dirname(Z0.resolve(_))}catch{let O=j1.resolve(process.cwd(),_);q=await import(O),j=j1.dirname(O)}let H=q.default||q;if(K.register(H,Q),H.components){let O=j1.resolve(j,H.components);W.push(O)}if(H.pages){let O=j1.resolve(j,H.pages),V=B.path||"/";U.push({dir:O,prefix:V})}if(H.setup){let O={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=L},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await H.setup(B,O)}console.log(`[stx] Plugin loaded: ${H.name||_}`)}catch(q){console.warn(`[stx] Failed to load plugin ${_}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(WL.set(Z,J),!$)XJ=J,J.then((X)=>{R5=X}).catch(()=>{});return J}function UL($){return $}function zL($){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 J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${J.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 J=["AA","AAA"];if(!J.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${X}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${X}].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((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${X}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${X}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${X}].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 J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((X,Q)=>{if(!X.pattern||typeof X.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(X.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(X.maxAgeSeconds!==void 0&&(typeof X.maxAgeSeconds!=="number"||X.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(X.maxEntries!==void 0&&(typeof X.maxEntries!=="number"||X.maxEntries<1))Z.push({path:`pwa.routes[${Q}].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((X)=>typeof X!=="number"||X<16||X>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 J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.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 N1,R5=null,WL,XJ=null,T1;var r0=D(()=>{V$();e3();DX();$Z();yY();OG();DG();YL();GY();G4();bG();N1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:P6,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:bQ,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:CG,hasEndTag:!1,description:"Include a web component in the template"},n3,r3,XY,QY,a3,o3,t3,s3,qz,CX,F8,w8,...ZL],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}};WL=new Map;T1=new Proxy(N1,{get($,Z){if(R5&&Z in R5)return R5[Z];if(!XJ)d0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import pC from"fs";import fG from"path";import{createHighlighter as iC}from"ts-syntax-highlighter";async function C4($,Z={}){try{if(!await Q0($))throw Error(`Markdown file not found: ${$}`);let J=(await pC.promises.stat($)).mtime.getTime();if(Z.cache&&GJ.has($)){let _=GJ.get($);if(_.updatedAt>=J)return{content:_.content,data:_.data}}let X=await Bun.file($).text(),{data:Q,content:G}=Oz(X),K=Z.markdown||T1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=X7(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await nC(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:U,data:Q||{}};if(Z.cache)GJ.set($,{...z,updatedAt:J});return z}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let J=Y instanceof Error?Y.message:String(Y);return{content:T0("Markdown File",`Error reading/parsing markdown file: ${J}`,$,"",0,""),data:{}}}}async function nC($,Z,Y){let J=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!QJ)try{QJ=await iC({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let X=async(K,W,U,z)=>{let _=z.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),B=U||(Y?"text":"");if(!B)return K;try{if(!QJ.getSupportedLanguages().includes(B))return K;return(await QJ.highlight(_,B,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(J);for(let K of G){let[W,U,z,_]=K,B=await X(W,U,z,_);Q=Q.replace(W,B)}return Q}async function MQ($,Z,Y="",J={}){return await rC($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let z=K;if(!fG.isAbsolute(K))z=fG.resolve(fG.dirname(Y),K);let _={};if(W)try{try{_=JSON.parse(W)}catch{if(J.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of L){let A=F.indexOf(":");if(A>0){let w=F.substring(0,A).trim(),N=F.substring(A+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),E=N.startsWith("'")&&N.endsWith("'");if(R||E)N=N.substring(1,N.length-1);_[w]=N}}}}catch(V){if(J.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:B,data:q}=await C4(z,J),j={...Z,...q,..._},H=B,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(V,L)=>{let F=L.trim();return j[F]!==void 0?String(j[F]):V}),H}catch(z){let _=z instanceof Error?z.message:String(z);return T0("Markdown File",`Error including markdown file: ${_}`,Y,$,U,G)}})}async function rC($,Z,Y){let J=[],X;while((X=Z.exec($))!==null){let K=X[0],W=X.index,U=X;J.push(Y(...U).then((z)=>({match:K,replacement:z,index:W})))}let Q=await Promise.all(J);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var GJ,QJ=null;var $5=D(()=>{r0();N0();GJ=new Map});function KJ(){return`
|
|
13664
13681
|
/* Theme selector for code blocks */
|
|
13665
13682
|
.theme-selector {
|
|
13666
13683
|
margin: 1rem 0;
|
|
@@ -13740,7 +13757,7 @@ else {
|
|
|
13740
13757
|
<span class="frontmatter-label">${Z}:</span>
|
|
13741
13758
|
<span>${Array.isArray(Y)?Y.join(", "):String(Y)}</span>
|
|
13742
13759
|
</div>`).join("")}
|
|
13743
|
-
</div>`}var _L=()=>{};import BL from"net";async function
|
|
13760
|
+
</div>`}var _L=()=>{};import BL from"net";async function aC($){return new Promise((Z)=>{let Y=BL.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function sC($){return new Promise((Z)=>{let Y=BL.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function oC($){if(!await aC($))return!1;return await sC($)}async function V6($,Z=20){$=Number($);for(let Y=0;Y<Z;Y++){let J=$+Y;if(await oC(J))return J}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var qL=()=>{};async function eC(){try{let $=await import("@stacksjs/desktop");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function M5($,Z={}){let Y={...tC,...Z},J=await eC();if(!J)return console.log(`${T.yellow}\u26A0${T.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let X=await J.openDevWindow($,{title:Y.title,width:Y.width,height:Y.height,darkMode:Y.darkMode,hotReload:Y.hotReload,titlebarHidden:Y.titlebarHidden,nativeSidebar:Y.nativeSidebar,sidebarWidth:Y.sidebarWidth,sidebarConfig:Y.sidebarConfig});if(X&&Y.nativeSidebar)console.log(`${T.green}\u2713${T.reset} Native sidebar enabled (macOS Tahoe style)`);return X}catch(X){return console.log(`${T.red}\u2717${T.reset} Could not open native window:`,X),!1}}function _J($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let X=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(X){let Q=X[1];try{let G=`
|
|
13744
13761
|
${Q}
|
|
13745
13762
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
13746
13763
|
`,W=Function(G)();if(W)return W}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Y=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Y)try{return JSON.parse(Y[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let J=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(J)try{let X=J[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(X)return Function(`return ${X[1]}`)()}catch(X){console.warn("Invalid native-sidebar script configuration:",X)}return}var tC;var jL=D(()=>{A7();tC={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0}});function gG(){console.log(`
|
|
@@ -14133,7 +14150,7 @@ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FO
|
|
|
14133
14150
|
`),X&&!X.endsWith(`
|
|
14134
14151
|
`))X+=`
|
|
14135
14152
|
`}X+=`NETLIFY_SITE_ID=${$.siteId}
|
|
14136
|
-
`,await Bun.write(J,X)}return{configPath:Y,siteId:$.siteId}}function Xb($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var y4;var HJ=D(()=>{mG();mG();y4=class y4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});var TL={};$0(TL,{resizeAndConvert:()=>ML,processImage:()=>e1,isSharpAvailable:()=>b5,isImageFile:()=>P5,isImageBackendAvailable:()=>t1,groupVariantsByFormat:()=>X$,getTotalSize:()=>b8,getMimeType:()=>f1,getImageMetadata:()=>Z$,getFallbackVariant:()=>J$,generateSrcSet:()=>w6,generateSizes:()=>Y$,formatSize:()=>P8,ImageProcessingError:()=>Q$,DEFAULT_WIDTHS:()=>y1,DEFAULT_QUALITY:()=>v1,DEFAULT_FORMATS:()=>x1});import iG from"fs";import C5 from"path";import NL from"os";import nG from"crypto";import{generatePlaceholder as Qb,processImage as Gb}from"ts-images";async function OJ(){if(wL)return pG;wL=!0;try{let $=await import("sharp");return pG=$.default||$,pG}catch{return null}}async function b5(){return await OJ()!==null}async function t1(){return!0}async function e1($,Z={}){let{widths:Y=y1,formats:J=x1,quality:X=v1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,z;if(typeof $==="string"){if(z=$,!await Bun.file($).exists())throw new Q$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((A)=>Buffer.from(A))}else z="buffer-input",U=$;let _=nG.createHash("sha256").update(U).digest("hex").slice(0,12),B=await Z$(U),{width:q,height:j}=B,H=q/j;await iG.promises.mkdir(K,{recursive:!0});let O=[],V=C5.basename(z,C5.extname(z)),L=Y.filter((A)=>A<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((A,w)=>A-w);for(let A of L){let w=Math.round(A/H);for(let N of J){let R=`${V}-${A}w-${_}.${N}`,E=C5.join(K,R),M=`${W}/${R}`,I=await ML(U,{width:A,height:w,format:N,quality:X,fit:Q});await Bun.write(E,I),O.push({path:E,url:M,width:A,height:w,format:N,size:I.length})}}let F;if(G!=="none")F=await Ub(U,G);return{src:z,variants:O,placeholder:F,width:q,height:j,aspectRatio:H,hash:_}}async function Z$($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await OJ();if(Y){let X=await Y(Z).metadata();return{width:X.width||0,height:X.height||0,format:X.format||"unknown",hasAlpha:X.hasAlpha}}return Wb(Z)}function Wb($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let X=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:X,format:"jpeg",hasAlpha:!1}}let J=$.readUInt16BE(Z+2);Z+=2+J}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,J=$.readUInt16LE(28)&16383;return{width:Y,height:J,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),J=(Y&16383)+1,X=(Y>>14&16383)+1;return{width:J,height:X,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new Q$("Unable to parse image dimensions","PARSE_ERROR")}async function ML($,Z){let Y=await OJ();if(Y){let X=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":X=X.webp({quality:Z.quality});break;case"avif":X=X.avif({quality:Z.quality});break;case"jpeg":X=X.jpeg({quality:Z.quality});break;case"png":X=X.png({quality:Z.quality});break}return X.toBuffer()}let J=C5.join(NL.tmpdir(),`stx-img-${nG.randomBytes(8).toString("hex")}.${Z.format}`);try{return await Gb({input:$,output:J,format:Z.format,quality:Z.quality,resize:{width:Z.width,height:Z.height,fit:Z.fit}}),Buffer.from(await Bun.file(J).arrayBuffer())}finally{await iG.promises.unlink(J).catch(()=>{})}}async function Ub($,Z){let Y=await OJ();if(Z==="blur"&&Y){let G=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),K=await Z$($);return`data:${RL[K.format]||"image/jpeg"};base64,${G}`}if(Z==="dominant-color"&&Y){let{dominant:Q}=await Y($).resize(1,1).toBuffer().then(async(G)=>{let K=await Y(G).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${Q.r}, ${Q.g}, ${Q.b})`}let J=await Z$($),X=C5.join(NL.tmpdir(),`stx-ph-${nG.randomBytes(8).toString("hex")}.${J.format==="unknown"?"bin":J.format}`);try{await Bun.write(X,$);let Q=Z==="blur"?"blur":Z==="thumbhash"?"thumbhash":"dominant-color",K=await Qb(X,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(Z==="dominant-color"&&K.dominantColor)return K.dominantColor;if(K.dataURL)return K.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await iG.promises.unlink(X).catch(()=>{})}}function w6($,Z){return(Z?$.filter((J)=>J.format===Z):$).sort((J,X)=>J.width-X.width).map((J)=>`${J.url} ${J.width}w`).join(", ")}function Y$($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,J)=>{let X=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(J[0].replace(/\D/g,""))||0)-X}).map(([Y,J])=>`(max-width: ${Y}) ${J}`).join(", ")+", 100vw"}function J$($){let Z=$.filter((J)=>J.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((J,X)=>J.width-X.width);return Y[Math.floor(Y.length/2)]}function X$($){let Z=new Map;for(let Y of $){let J=Z.get(Y.format)||[];J.push(Y),Z.set(Y.format,J)}return Z}function P5($){let Z=C5.extname($).toLowerCase();return Kb.includes(Z)}function f1($){return RL[$]||"application/octet-stream"}function b8($){return $.reduce((Z,Y)=>Z+Y.size,0)}function P8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var y1,x1,v1=80,Kb,RL,pG=null,wL=!1,Q$;var G$=D(()=>{y1=[320,640,768,1024,1280,1536,1920],x1=["webp","jpeg"],Kb=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],RL={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};Q$=class Q$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});var SL={};$0(SL,{handleImageRequest:()=>x8,createImageHandler:()=>LJ});import EL from"fs";import y8 from"path";import zb from"crypto";async function x8($,Z){let Y=Z.routePath??"/_stx/img",J=new URL($.url);if(J.pathname!==Y)return null;let X=jb(J,Z);if(!X.ok)return new Response(X.error,{status:X.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:z,fit:_}=X,B;try{B=EL.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!B.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let q=Z.cacheDir??".stx/cache/img";await EL.promises.mkdir(q,{recursive:!0});let j=`${Q}:${B.mtimeMs}:${B.size}`,H=`${K}x${W}:${U}:${z}:${_}`,O=zb.createHash("sha256").update(`${j}|${H}`).digest("hex").slice(0,16),V=y8.join(q,`${O}.${U}`),F={"Content-Type":f1(U),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${O}"`,"X-Stx-Image-Cache":"HIT"};if($.headers.get("if-none-match")===`"${O}"`)return new Response(null,{status:304,headers:F});let A=Bun.file(V);if(await A.exists())return new Response(A,{headers:F});try{let w=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:N}=await Hb(),R=await N(w,{width:K,height:W,format:U,quality:z,fit:_});return await Bun.write(V,R),F["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(R),{headers:F})}catch(w){let N=w.message;return new Response(`Image processing failed: ${N}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function LJ($){return async(Z)=>{return await x8(Z,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function jb($,Z){let Y=$.searchParams.get("src");if(!Y)return{ok:!1,error:"Missing required param: src",status:400};if(!Y.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Y.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let J=y8.extname(Y).toLowerCase();if(!_b.has(J))return{ok:!1,error:`Unsupported source extension: ${J}`,status:400};let X=y8.resolve(Z.publicDir),Q=y8.resolve(X,Y.slice(1));if(!Q.startsWith(`${X}${y8.sep}`)&&Q!==X)return{ok:!1,error:"src is outside publicDir",status:400};let G=Z.maxWidth??kL,K=Z.maxHeight??kL,W=$.searchParams.get("w"),U=$.searchParams.get("h"),z=W?Number.parseInt(W,10):0,_=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(_)||_<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!W&&!U)return{ok:!1,error:"At least one of w or h is required",status:400};let B=Math.min(z||G,G),q=Math.min(_||K,K),j=$.searchParams.get("f")||"webp";if(!IL.has(j))return{ok:!1,error:`Invalid f (must be one of: ${[...IL].join(", ")})`,status:400};let H=j,O=$.searchParams.get("q"),V=O?Number.parseInt(O,10):Z.defaultQuality??Bb;if(!Number.isFinite(V)||V<1||V>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let L=$.searchParams.get("fit")||Z.defaultFit||qb;if(!DL.has(L))return{ok:!1,error:`Invalid fit (must be one of: ${[...DL].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Y,width:B,height:q,format:H,quality:V,fit:L}}async function Hb(){return await Promise.resolve().then(() => (G$(),TL))}var IL,DL,_b,kL=4096,Bb=80,qb="cover";var rG=D(()=>{G$();IL=new Set(["webp","avif","jpeg","png"]),DL=new Set(["cover","contain","fill","inside","outside"]),_b=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function sG($,Z={}){let{src:Y,alt:J,width:X,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=v1,placeholder:z="none",formats:_=x1,widths:B=y1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,V=$.class,L=$.style,{processedImage:F,variants:A,optimize:w=!0,isDev:N=!1}=Z;if(A&&A.length>0)return Ob($,A,F);if(N||!w)return Lb($);return Vb($)}function Ob($,Z,Y){let{src:J,alt:X,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:z="async",fetchpriority:_,objectFit:B,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,V=X$(Z),L=J$(Z),F=typeof K==="object"?Y$(K):K,A=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,w=[];if(A)w.push(`aspect-ratio: ${A}`);if(B)w.push(`object-fit: ${B}`);if(q)w.push(`object-position: ${q}`);if(O)w.push(O);let N=w.length>0?` style="${w.join("; ")}"`:"",R=H?` class="${H}"`:"",E=U?"":` loading="${W}"`,M=` decoding="${z}"`,I=_?` fetchpriority="${_}"`:U?' fetchpriority="high"':"",S=["avif","webp","jpeg","png"],k=[];for(let d of S){let l=V.get(d);if(l&&l.length>0){let c=w6(l),s=f1(d);k.push(` <source type="${s}" srcset="${c}" sizes="${F}" />`)}}let x="",y="",b;if(j!=="none"&&Y?.placeholder){let d=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${d}">`,y="</div>",j==="blur")b=`
|
|
14153
|
+
`,await Bun.write(J,X)}return{configPath:Y,siteId:$.siteId}}function Xb($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var y4;var HJ=D(()=>{mG();mG();y4=class y4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});var TL={};$0(TL,{resizeAndConvert:()=>ML,processImage:()=>e1,isSharpAvailable:()=>b5,isImageFile:()=>P5,isImageBackendAvailable:()=>t1,groupVariantsByFormat:()=>X$,getTotalSize:()=>b8,getMimeType:()=>f1,getImageMetadata:()=>Z$,getFallbackVariant:()=>J$,generateSrcSet:()=>w6,generateSizes:()=>Y$,formatSize:()=>P8,ImageProcessingError:()=>Q$,DEFAULT_WIDTHS:()=>y1,DEFAULT_QUALITY:()=>v1,DEFAULT_FORMATS:()=>x1});import iG from"fs";import C5 from"path";import NL from"os";import nG from"crypto";import{generatePlaceholder as Qb,processImage as Gb}from"ts-images";async function OJ(){if(wL)return pG;wL=!0;try{let $=await import("sharp");return pG=$.default||$,pG}catch{return null}}async function b5(){return await OJ()!==null}async function t1(){return!0}async function e1($,Z={}){let{widths:Y=y1,formats:J=x1,quality:X=v1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,z;if(typeof $==="string"){if(z=$,!await Bun.file($).exists())throw new Q$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((A)=>Buffer.from(A))}else z="buffer-input",U=$;let _=nG.createHash("sha256").update(U).digest("hex").slice(0,12),B=await Z$(U),{width:q,height:j}=B,H=q/j;await iG.promises.mkdir(K,{recursive:!0});let O=[],V=C5.basename(z,C5.extname(z)),L=Y.filter((A)=>A<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((A,w)=>A-w);for(let A of L){let w=Math.round(A/H);for(let N of J){let R=`${V}-${A}w-${_}.${N}`,E=C5.join(K,R),M=`${W}/${R}`,I=await ML(U,{width:A,height:w,format:N,quality:X,fit:Q});await Bun.write(E,I),O.push({path:E,url:M,width:A,height:w,format:N,size:I.length})}}let F;if(G!=="none")F=await Ub(U,G);return{src:z,variants:O,placeholder:F,width:q,height:j,aspectRatio:H,hash:_}}async function Z$($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await OJ();if(Y){let X=await Y(Z).metadata();return{width:X.width||0,height:X.height||0,format:X.format||"unknown",hasAlpha:X.hasAlpha}}return Wb(Z)}function Wb($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let X=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:X,format:"jpeg",hasAlpha:!1}}let J=$.readUInt16BE(Z+2);Z+=2+J}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,J=$.readUInt16LE(28)&16383;return{width:Y,height:J,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),J=(Y&16383)+1,X=(Y>>14&16383)+1;return{width:J,height:X,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new Q$("Unable to parse image dimensions","PARSE_ERROR")}async function ML($,Z){let Y=await OJ();if(Y){let X=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":X=X.webp({quality:Z.quality});break;case"avif":X=X.avif({quality:Z.quality});break;case"jpeg":X=X.jpeg({quality:Z.quality});break;case"png":X=X.png({quality:Z.quality});break}return X.toBuffer()}let J=C5.join(NL.tmpdir(),`stx-img-${nG.randomBytes(8).toString("hex")}.${Z.format}`);try{return await Gb({input:$,output:J,format:Z.format,quality:Z.quality,resize:{width:Z.width,height:Z.height,fit:Z.fit}}),Buffer.from(await Bun.file(J).arrayBuffer())}finally{await iG.promises.unlink(J).catch(()=>{})}}async function Ub($,Z){let Y=await OJ();if(Z==="blur"&&Y){let G=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),K=await Z$($);return`data:${RL[K.format]||"image/jpeg"};base64,${G}`}if(Z==="dominant-color"&&Y){let{dominant:Q}=await Y($).resize(1,1).toBuffer().then(async(G)=>{let K=await Y(G).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${Q.r}, ${Q.g}, ${Q.b})`}let J=await Z$($),X=C5.join(NL.tmpdir(),`stx-ph-${nG.randomBytes(8).toString("hex")}.${J.format==="unknown"?"bin":J.format}`);try{await Bun.write(X,$);let Q=Z==="blur"?"blur":Z==="thumbhash"?"thumbhash":"dominant-color",K=await Qb(X,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(Z==="dominant-color"&&K.dominantColor)return K.dominantColor;if(K.dataURL)return K.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await iG.promises.unlink(X).catch(()=>{})}}function w6($,Z){return(Z?$.filter((J)=>J.format===Z):$).sort((J,X)=>J.width-X.width).map((J)=>`${J.url} ${J.width}w`).join(", ")}function Y$($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,J)=>{let X=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(J[0].replace(/\D/g,""))||0)-X}).map(([Y,J])=>`(max-width: ${Y}) ${J}`).join(", ")+", 100vw"}function J$($){let Z=$.filter((J)=>J.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((J,X)=>J.width-X.width);return Y[Math.floor(Y.length/2)]}function X$($){let Z=new Map;for(let Y of $){let J=Z.get(Y.format)||[];J.push(Y),Z.set(Y.format,J)}return Z}function P5($){let Z=C5.extname($).toLowerCase();return Kb.includes(Z)}function f1($){return RL[$]||"application/octet-stream"}function b8($){return $.reduce((Z,Y)=>Z+Y.size,0)}function P8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var y1,x1,v1=80,Kb,RL,pG=null,wL=!1,Q$;var G$=D(()=>{y1=[320,640,768,1024,1280,1536,1920],x1=["webp","jpeg"],Kb=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],RL={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};Q$=class Q$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});var SL={};$0(SL,{handleImageRequest:()=>x8,createImageHandler:()=>LJ});import EL from"fs";import y8 from"path";import zb from"crypto";async function x8($,Z){let Y=Z.routePath??"/_stx/img",J=new URL($.url);if(J.pathname!==Y)return null;let X=jb(J,Z);if(!X.ok)return new Response(X.error,{status:X.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:z,fit:_}=X,B;try{B=EL.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!B.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let q=Z.cacheDir??".stx/cache/img";await EL.promises.mkdir(q,{recursive:!0});let j=`${Q}:${B.mtimeMs}:${B.size}`,H=`${K}x${W}:${U}:${z}:${_}`,O=zb.createHash("sha256").update(`${j}|${H}`).digest("hex").slice(0,16),V=y8.join(q,`${O}.${U}`),F={"Content-Type":f1(U),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${O}"`,"X-Stx-Image-Cache":"HIT"};if($.headers.get("if-none-match")===`"${O}"`)return new Response(null,{status:304,headers:F});let A=Bun.file(V);if(await A.exists())return new Response(A,{headers:F});try{let w=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:N}=await Hb(),R=await N(w,{width:K,height:W,format:U,quality:z,fit:_});return await Bun.write(V,R),F["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(R),{headers:F})}catch(w){let N=w.message;return new Response(`Image processing failed: ${N}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function LJ($){return async(Z)=>{return await x8(Z,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function jb($,Z){let Y=$.searchParams.get("src");if(!Y)return{ok:!1,error:"Missing required param: src",status:400};if(!Y.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Y.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let J=y8.extname(Y).toLowerCase();if(!_b.has(J))return{ok:!1,error:`Unsupported source extension: ${J}`,status:400};let X=y8.resolve(Z.publicDir),Q=y8.resolve(X,Y.slice(1));if(!Q.startsWith(`${X}${y8.sep}`)&&Q!==X)return{ok:!1,error:"src is outside publicDir",status:400};let G=Z.maxWidth??kL,K=Z.maxHeight??kL,W=$.searchParams.get("w"),U=$.searchParams.get("h"),z=W?Number.parseInt(W,10):0,_=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(_)||_<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!W&&!U)return{ok:!1,error:"At least one of w or h is required",status:400};let B=Math.min(z||G,G),q=Math.min(_||K,K),j=$.searchParams.get("f")||"webp";if(!IL.has(j))return{ok:!1,error:`Invalid f (must be one of: ${[...IL].join(", ")})`,status:400};let H=j,O=$.searchParams.get("q"),V=O?Number.parseInt(O,10):Z.defaultQuality??Bb;if(!Number.isFinite(V)||V<1||V>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let L=$.searchParams.get("fit")||Z.defaultFit||qb;if(!DL.has(L))return{ok:!1,error:`Invalid fit (must be one of: ${[...DL].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Y,width:B,height:q,format:H,quality:V,fit:L}}async function Hb(){return await Promise.resolve().then(() => (G$(),TL))}var IL,DL,_b,kL=4096,Bb=80,qb="cover";var rG=D(()=>{G$();IL=new Set(["webp","avif","jpeg","png"]),DL=new Set(["cover","contain","fill","inside","outside"]),_b=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function aG($,Z={}){let{src:Y,alt:J,width:X,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=v1,placeholder:z="none",formats:_=x1,widths:B=y1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,V=$.class,L=$.style,{processedImage:F,variants:A,optimize:w=!0,isDev:N=!1}=Z;if(A&&A.length>0)return Ob($,A,F);if(N||!w)return Lb($);return Vb($)}function Ob($,Z,Y){let{src:J,alt:X,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:z="async",fetchpriority:_,objectFit:B,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,V=X$(Z),L=J$(Z),F=typeof K==="object"?Y$(K):K,A=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,w=[];if(A)w.push(`aspect-ratio: ${A}`);if(B)w.push(`object-fit: ${B}`);if(q)w.push(`object-position: ${q}`);if(O)w.push(O);let N=w.length>0?` style="${w.join("; ")}"`:"",R=H?` class="${H}"`:"",E=U?"":` loading="${W}"`,M=` decoding="${z}"`,I=_?` fetchpriority="${_}"`:U?' fetchpriority="high"':"",S=["avif","webp","jpeg","png"],k=[];for(let d of S){let l=V.get(d);if(l&&l.length>0){let c=w6(l),a=f1(d);k.push(` <source type="${a}" srcset="${c}" sizes="${F}" />`)}}let x="",y="",b;if(j!=="none"&&Y?.placeholder){let d=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${d}">`,y="</div>",j==="blur")b=`
|
|
14137
14154
|
#${d} {
|
|
14138
14155
|
position: relative;
|
|
14139
14156
|
background-image: url('${Y.placeholder}');
|
|
@@ -14164,7 +14181,7 @@ ${k.join(`
|
|
|
14164
14181
|
data-quality="${W}"
|
|
14165
14182
|
data-formats="${U.join(",")}"
|
|
14166
14183
|
data-widths="${z.join(",")}"
|
|
14167
|
-
`.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${oG(Y)}"${A}${w}${F}${L}${N}${R}${E} ${I} />`}}function VJ($){let Z=$.match(/<Image\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],J={},X=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,Q;while((Q=X.exec(Y))!==null){let[,G,K,W,U]=Q,z=K??W??U??!0;switch(G){case"src":J.src=String(z);break;case"alt":J.alt=String(z);break;case"width":J.width=Number(z)||z;break;case"height":J.height=Number(z)||z;break;case"sizes":J.sizes=String(z);break;case"loading":J.loading=z;break;case"priority":J.priority=z===!0||z==="true";break;case"quality":J.quality=Number(z);break;case"placeholder":J.placeholder=z;break;case"class":J.class=String(z);break;case"style":J.style=String(z);break;case"decoding":J.decoding=z;break;case"fetchpriority":J.fetchpriority=z;break;case"objectFit":J.objectFit=z;break;case"objectPosition":J.objectPosition=String(z);break}}if(!J.src||!J.alt)return null;return J}async function
|
|
14184
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${oG(Y)}"${A}${w}${F}${L}${N}${R}${E} ${I} />`}}function VJ($){let Z=$.match(/<Image\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],J={},X=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,Q;while((Q=X.exec(Y))!==null){let[,G,K,W,U]=Q,z=K??W??U??!0;switch(G){case"src":J.src=String(z);break;case"alt":J.alt=String(z);break;case"width":J.width=Number(z)||z;break;case"height":J.height=Number(z)||z;break;case"sizes":J.sizes=String(z);break;case"loading":J.loading=z;break;case"priority":J.priority=z===!0||z==="true";break;case"quality":J.quality=Number(z);break;case"placeholder":J.placeholder=z;break;case"class":J.class=String(z);break;case"style":J.style=String(z);break;case"decoding":J.decoding=z;break;case"fetchpriority":J.fetchpriority=z;break;case"objectFit":J.objectFit=z;break;case"objectPosition":J.objectPosition=String(z);break}}if(!J.src||!J.alt)return null;return J}async function sG($,Z){let Y=/<Image\s+[^>]*?\/?>/g,J=[],X=[],Q=$,G,K=[];while((G=Y.exec($))!==null)K.push({match:G[0],index:G.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],z=VJ(U);if(z){let _=await Z(z);if(Q=Q.replace(U,_.html),_.preloadLink)J.push(_.preloadLink);if(_.placeholderCss)X.push(_.placeholderCss)}}return{html:Q,preloadLinks:J,styles:X}}function oG($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var CL=D(()=>{G$()});function AJ(){FJ.clear()}async function Fb($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(FJ.has(Y))return FJ.get(Y);try{let J=await e1($,Z);return FJ.set(Y,J),J}catch{return null}}function wJ(){return u0({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async($,Z,Y)=>{let{src:J,alt:X,options:Q}=Ab($,Z,Y);if(!J)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:y1),formats:Q.formats||x1,quality:Q.quality||v1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await t1())return bL(J,X||"",Q);let W=await Fb(J,G);if(!W)return bL(J,X||"",Q);return Nb(W,X||"",Q)}})}function Ab($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@image(")||X.startsWith("("))X=X.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=wb(X),G=Q[0]||"",K=Q[1]||"",W={};if(G&&!G.startsWith("/")&&!G.startsWith(".")&&!G.startsWith("http")){let U=Y[G];if(typeof U==="string")G=U}if(Q[2])try{if(typeof Q[2]==="string")W=JSON.parse(Q[2]);else W=Q[2]}catch{}return{src:G,alt:K,options:W}}function wb($){let Z=[],Y="",J=!1,X="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'")&&U!=="\\"){if(!J)J=!0,X=W;else if(W===X)J=!1,X="";else Y+=W;continue}if(!J){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function bL($,Z,Y){let J=[`src="${x4($)}"`];if(Z)J.push(`alt="${x4(Z)}"`);if(Y.width)J.push(`width="${Y.width}"`);if(Y.height)J.push(`height="${Y.height}"`);if(Y.class)J.push(`class="${x4(Y.class)}"`);if(Y.style)J.push(`style="${x4(Y.style)}"`);if(Y.lazy!==!1)J.push('loading="lazy"');return J.push('decoding="async"'),`<img ${J.join(" ")} />`}function Nb($,Z,Y){let{variants:J,placeholder:X,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let O of J){let V=W.get(O.format)||[];V.push(O),W.set(O.format,V)}let U=["avif","webp","jpeg","png"],z=[];for(let O of U){let V=W.get(O);if(V&&V.length>0){let L=w6(V),F=f1(O),A=Y.sizes||"100vw";z.push(` <source type="${F}" srcset="${x4(L)}" sizes="${x4(A)}" />`)}}let _=W.get("jpeg")||[],B=_.length>0?_[Math.floor(_.length/2)]:J[Math.floor(J.length/2)],q=[`src="${B?.url||$.src}"`,`alt="${x4(Z)}"`];if(Y.width||Q)q.push(`width="${Y.width||Q}"`);if(Y.height||G)q.push(`height="${Y.height||G}"`);if(Y.class)q.push(`class="${x4(Y.class)}"`);let j=[];if(K)j.push(`aspect-ratio: ${K.toFixed(4)}`);if(Y.style)j.push(Y.style);if(j.length>0)q.push(`style="${j.join("; ")}"`);if(Y.lazy!==!1&&!Y.priority)q.push('loading="lazy"');if(q.push('decoding="async"'),Y.priority)q.push('fetchpriority="high"');let H=`<picture>
|
|
14168
14185
|
`;if(H+=z.join(`
|
|
14169
14186
|
`)+`
|
|
14170
14187
|
`,H+=` <img ${q.join(" ")} />
|
|
@@ -14173,7 +14190,7 @@ ${H}
|
|
|
14173
14190
|
</div>`}else if(Y.placeholder==="color"){let V=X.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");H=`<div id="${O}" class="stx-image-placeholder" style="background-color: ${V};">
|
|
14174
14191
|
${H}
|
|
14175
14192
|
</div>`}}if(Y.priority&&B){let O=f1(B.format);H=`<link rel="preload" as="image" href="${x4(B.url)}" type="${O}" />
|
|
14176
|
-
`+H}return H}function x4($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var FJ,tG;var PL=D(()=>{U8();G$();FJ=new Map;tG=wJ()});import y5 from"fs";import NJ from"path";function eG($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:J="/images",formats:X=x1,widths:Q=y1,quality:G=v1,placeholder:K="none",concurrency:W=4,cache:U=!0,cacheDir:z=".stx/image-cache",referencedOnly:_=!1,verbose:B=!1}=$,q={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(j){if(!await t1()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(U)await y5.promises.mkdir(z,{recursive:!0});if(B){let O=await b5();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${O?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${Z.join(", ")}`),console.log(` Output dir: ${Y}`),console.log(` Formats: ${X.join(", ")}`),console.log(` Widths: ${Q.join(", ")}`)}},async buildStart(){q.imageReferences.clear(),q.processedImages.clear(),q.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(j,H){if(H.endsWith(".html")||H.endsWith(".stx")){let O=Rb(j);for(let V of O)q.imageReferences.add(V)}if(j.includes("<Image")||j.includes("@image"))return await Tb(j,{formats:X,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:J,processedImages:q.processedImages});return j},async buildEnd(j){if(!await t1())return;await y5.promises.mkdir(Y,{recursive:!0});let O=[];for(let F of Z){if(!y5.existsSync(F))continue;let A=await yL(F);O.push(...A)}let V=_?O.filter((F)=>Mb(F,q.imageReferences)):O;if(q.stats.totalImages=V.length,B)console.log(`[stx-images] Processing ${V.length} images...`);let L=xL(V,W);for(let F of L)await Promise.all(F.map(async(A)=>{try{let w=await e1(A,{formats:X,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:J});q.processedImages.set(A,w),q.stats.optimizedImages++,q.stats.variants+=w.variants.length;let N=y5.statSync(A).size,R=b8(w.variants);if(q.stats.savedBytes+=Math.max(0,N-R/w.variants.length),B)console.log(` \u2713 ${NJ.basename(A)} \u2192 ${w.variants.length} variants`)}catch(w){console.error(`[stx-images] Error processing ${A}:`,w)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${q.stats.optimizedImages}/${q.stats.totalImages}`),console.log(` Variants: ${q.stats.variants}`),q.stats.savedBytes>0)console.log(` Saved: ~${P8(q.stats.savedBytes)}`)}}}function Rb($){let Z=[],Y=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);let X=/<Image[^>]+src=["']([^"']+)["']/gi;while((J=X.exec($))!==null)Z.push(J[1]);let Q=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((J=Q.exec($))!==null)Z.push(J[1]);let G=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((J=G.exec($))!==null)Z.push(J[1]);return Z}function Mb($,Z){let Y=NJ.basename($);for(let J of Z)if(J.endsWith(Y)||J.includes(Y))return!0;return!1}async function Tb($,Z){return $}async function yL($){let Z=[];async function Y(J){let X=await y5.promises.readdir(J,{withFileTypes:!0});for(let Q of X){let G=NJ.join(J,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&P5(G))Z.push(G)}}return await Y($),Z}function xL($,Z){let Y=[];for(let J=0;J<$.length;J+=Z)Y.push($.slice(J,J+Z));return Y}async function RJ($,Z,Y={}){if(!await t1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return e1($,{...Y,outputDir:Z})}async function $K($,Z,Y={}){let{formats:J=x1,widths:X=y1,quality:Q=v1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await t1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await y5.promises.mkdir(Z,{recursive:!0});let z=await yL($),_=[],B={totalImages:z.length,optimizedImages:0,savedBytes:0,variants:0},q=xL(z,K);for(let j of q){let H=await Promise.all(j.map(async(O)=>{try{let V=await e1(O,{formats:J,widths:X,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(B.optimizedImages++,B.variants+=V.variants.length,W)console.log(` \u2713 ${NJ.basename(O)}`);return V}catch(V){return console.error(`Error processing ${O}:`,V),null}}));_.push(...H.filter((O)=>O!==null))}return{processed:_,stats:B}}function MJ($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function ZK($,Z){let Y=MJ($);await Bun.write(Z,JSON.stringify(Y,null,2))}var vL=D(()=>{G$()});var gL={};$0(gL,{writeImageManifest:()=>ZK,rewriteImagesWithSiblings:()=>SY,renderImageComponent:()=>sG,processImageComponents:()=>aG,processImage:()=>e1,parseImageComponent:()=>VJ,optimizeImage:()=>RJ,optimizeDirectory:()=>$K,isSharpAvailable:()=>b5,isImageFile:()=>P5,isImageBackendAvailable:()=>t1,imageDirective:()=>tG,handleImageRequest:()=>x8,groupVariantsByFormat:()=>X$,getTotalSize:()=>b8,getMimeType:()=>f1,getImageMetadata:()=>Z$,getFallbackVariant:()=>J$,generateSrcSet:()=>w6,generateSizes:()=>Y$,generateImageManifest:()=>MJ,formatSize:()=>P8,defaultImageConfig:()=>fL,createImagePlugin:()=>eG,createImageHandler:()=>LJ,createImageDirective:()=>wJ,clearImageCache:()=>AJ,ImageProcessingError:()=>Q$,DEFAULT_WIDTHS:()=>y1,DEFAULT_QUALITY:()=>v1,DEFAULT_FORMATS:()=>x1});var fL;var TJ=D(()=>{G$();AQ();rG();CL();PL();vL();fL={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"}});function EJ($,Z,Y=new WeakSet){if(Object.is($,Z))return!0;if(typeof $!=="object"||typeof Z!=="object"||$===null||Z===null)return!1;if(Y.has($))return!0;if(Y.add($),$ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if($ instanceof RegExp&&Z instanceof RegExp)return $.source===Z.source&&$.flags===Z.flags;if(Array.isArray($)){if(!Array.isArray(Z)||$.length!==Z.length)return!1;for(let Q=0;Q<$.length;Q++)if(!EJ($[Q],Z[Q],Y))return!1;return!0}if(Array.isArray(Z))return!1;if($ instanceof Map){if(!(Z instanceof Map)||$.size!==Z.size)return!1;for(let[Q,G]of $)if(!Z.has(Q)||!EJ(G,Z.get(Q),Y))return!1;return!0}if(Z instanceof Map)return!1;if($ instanceof Set){if(!(Z instanceof Set)||$.size!==Z.size)return!1;for(let Q of $)if(!Z.has(Q))return!1;return!0}if(Z instanceof Set)return!1;let J=Object.keys($),X=Object.keys(Z);if(J.length!==X.length)return!1;for(let Q of J){if(!Object.prototype.hasOwnProperty.call(Z,Q))return!1;if(!EJ($[Q],Z[Q],Y))return!1}return!0}function Eb($){m0=$}function Ib(){return m0}function Db(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:dL()}}function dL(){return{refs:new Map,effects:new Set,cleanups:[]}}function kb($){let Z=new Set,Y=new Set,J=$,X=Symbol("ref"),Q={get value(){if(e0)Y.add(e0);return J},set value(G){if(!Object.is(G,J)){let K=J;J=G;for(let W of Z)W(G,K);for(let W of Y)W()}},subscribe(G){return Z.add(G),()=>{Z.delete(G)}}};if(m0)m0.scope.refs.set(X,Q);return Q}function uL($){let Z=hL.get($);if(Z)return Z;let Y=new Map,J=(G)=>{let K=Y.get(G);if(K)for(let W of[...K])W()},X=(G,K)=>{if(!Y.has(G))Y.set(G,new Set);return Y.get(G).add(K),()=>{Y.get(G)?.delete(K)}},Q=new Proxy($,{get(G,K,W){let U=Reflect.get(G,K,W);if(e0)X(K,e0);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let z=Object.getPrototypeOf(U);if(z===Object.prototype||z===null)return uL(U)}return U},set(G,K,W,U){let z=Reflect.get(G,K,U),_=Reflect.set(G,K,W,U);if(!Object.is(W,z))J(K);return _},deleteProperty(G,K){let W=Reflect.deleteProperty(G,K);return J(K),W}});return hL.set($,Q),Q}function Sb($){let Z,Y=!0,J=new Set,X=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=e0;if(e0=Q,Z=$(),e0=U,Y=!1,!Object.is(Z,W)){for(let z of J)z(Z,W);for(let z of X)z()}}},K=e0;return e0=Q,Z=$(),Y=!1,e0=K,{get value(){if(e0)X.add(e0);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return J.add(W),()=>{J.delete(W)}}}}function Cb($,Z,Y={}){let{immediate:J=!1,deep:X=!1,flush:Q="post"}=Y,G,K,W=!1,U=()=>{if(W)return;let j=q();if((X?!EJ(j,G):!Object.is(j,G))||J)if(Z(j,G),X&&j!==null&&typeof j==="object")try{G=structuredClone(j)}catch{G=j}else G=j},z=(j)=>{if(Q==="sync")j();else if(Q==="pre")Promise.resolve().then(j);else requestAnimationFrame(()=>{requestAnimationFrame(j)})},_=!1,B=()=>{if(W||_)return;_=!0,z(()=>{_=!1,U()})},q=()=>{if(typeof $==="function"){let j=e0;e0=B;try{return $()}finally{e0=j}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{z(U)});K=()=>{W=!0,j()}}else K=()=>{W=!0};if(G=q(),J)z(U);if(m0)m0.scope.cleanups.push(()=>K?.());return()=>K?.()}function bb($,Z,Y={}){let J=[],X=$.map((Q)=>Q.value);for(let Q of $){let G=Q.subscribe(()=>{let K=$.map((W)=>W.value);Z(K,X),X=[...K]});J.push(G)}if(Y.immediate){let Q=$.map((G)=>G.value);Z(Q,X)}return()=>{for(let Q of J)Q()}}function Pb($){let Z,Y=!1,J=()=>{if(Y)return;if(Z)Z();let X=e0;e0=J,Z=$(),e0=X};if(J(),m0)m0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function yb($){if(m0)m0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function xb($){if(m0)m0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function vb($){if(m0)m0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function fb($){if(m0)m0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function gb($){if(m0)m0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function hb($){if(m0)m0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function K$($,Z){let Y=$.hooks[Z];for(let J of Y)await J()}async function db($){await K$($,"beforeMount"),$.isMounted=!0,await K$($,"mounted")}async function ub($){if(!$.isMounted||$.isUnmounted)return;await K$($,"beforeUpdate"),await K$($,"updated")}async function mb($){if($.isUnmounted)return;await K$($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await K$($,"unmounted")}function lb(){return`
|
|
14193
|
+
`+H}return H}function x4($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var FJ,tG;var PL=D(()=>{U8();G$();FJ=new Map;tG=wJ()});import y5 from"fs";import NJ from"path";function eG($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:J="/images",formats:X=x1,widths:Q=y1,quality:G=v1,placeholder:K="none",concurrency:W=4,cache:U=!0,cacheDir:z=".stx/image-cache",referencedOnly:_=!1,verbose:B=!1}=$,q={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(j){if(!await t1()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(U)await y5.promises.mkdir(z,{recursive:!0});if(B){let O=await b5();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${O?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${Z.join(", ")}`),console.log(` Output dir: ${Y}`),console.log(` Formats: ${X.join(", ")}`),console.log(` Widths: ${Q.join(", ")}`)}},async buildStart(){q.imageReferences.clear(),q.processedImages.clear(),q.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(j,H){if(H.endsWith(".html")||H.endsWith(".stx")){let O=Rb(j);for(let V of O)q.imageReferences.add(V)}if(j.includes("<Image")||j.includes("@image"))return await Tb(j,{formats:X,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:J,processedImages:q.processedImages});return j},async buildEnd(j){if(!await t1())return;await y5.promises.mkdir(Y,{recursive:!0});let O=[];for(let F of Z){if(!y5.existsSync(F))continue;let A=await yL(F);O.push(...A)}let V=_?O.filter((F)=>Mb(F,q.imageReferences)):O;if(q.stats.totalImages=V.length,B)console.log(`[stx-images] Processing ${V.length} images...`);let L=xL(V,W);for(let F of L)await Promise.all(F.map(async(A)=>{try{let w=await e1(A,{formats:X,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:J});q.processedImages.set(A,w),q.stats.optimizedImages++,q.stats.variants+=w.variants.length;let N=y5.statSync(A).size,R=b8(w.variants);if(q.stats.savedBytes+=Math.max(0,N-R/w.variants.length),B)console.log(` \u2713 ${NJ.basename(A)} \u2192 ${w.variants.length} variants`)}catch(w){console.error(`[stx-images] Error processing ${A}:`,w)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${q.stats.optimizedImages}/${q.stats.totalImages}`),console.log(` Variants: ${q.stats.variants}`),q.stats.savedBytes>0)console.log(` Saved: ~${P8(q.stats.savedBytes)}`)}}}function Rb($){let Z=[],Y=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);let X=/<Image[^>]+src=["']([^"']+)["']/gi;while((J=X.exec($))!==null)Z.push(J[1]);let Q=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((J=Q.exec($))!==null)Z.push(J[1]);let G=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((J=G.exec($))!==null)Z.push(J[1]);return Z}function Mb($,Z){let Y=NJ.basename($);for(let J of Z)if(J.endsWith(Y)||J.includes(Y))return!0;return!1}async function Tb($,Z){return $}async function yL($){let Z=[];async function Y(J){let X=await y5.promises.readdir(J,{withFileTypes:!0});for(let Q of X){let G=NJ.join(J,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&P5(G))Z.push(G)}}return await Y($),Z}function xL($,Z){let Y=[];for(let J=0;J<$.length;J+=Z)Y.push($.slice(J,J+Z));return Y}async function RJ($,Z,Y={}){if(!await t1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return e1($,{...Y,outputDir:Z})}async function $K($,Z,Y={}){let{formats:J=x1,widths:X=y1,quality:Q=v1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await t1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await y5.promises.mkdir(Z,{recursive:!0});let z=await yL($),_=[],B={totalImages:z.length,optimizedImages:0,savedBytes:0,variants:0},q=xL(z,K);for(let j of q){let H=await Promise.all(j.map(async(O)=>{try{let V=await e1(O,{formats:J,widths:X,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(B.optimizedImages++,B.variants+=V.variants.length,W)console.log(` \u2713 ${NJ.basename(O)}`);return V}catch(V){return console.error(`Error processing ${O}:`,V),null}}));_.push(...H.filter((O)=>O!==null))}return{processed:_,stats:B}}function MJ($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function ZK($,Z){let Y=MJ($);await Bun.write(Z,JSON.stringify(Y,null,2))}var vL=D(()=>{G$()});var gL={};$0(gL,{writeImageManifest:()=>ZK,rewriteImagesWithSiblings:()=>SY,renderImageComponent:()=>aG,processImageComponents:()=>sG,processImage:()=>e1,parseImageComponent:()=>VJ,optimizeImage:()=>RJ,optimizeDirectory:()=>$K,isSharpAvailable:()=>b5,isImageFile:()=>P5,isImageBackendAvailable:()=>t1,imageDirective:()=>tG,handleImageRequest:()=>x8,groupVariantsByFormat:()=>X$,getTotalSize:()=>b8,getMimeType:()=>f1,getImageMetadata:()=>Z$,getFallbackVariant:()=>J$,generateSrcSet:()=>w6,generateSizes:()=>Y$,generateImageManifest:()=>MJ,formatSize:()=>P8,defaultImageConfig:()=>fL,createImagePlugin:()=>eG,createImageHandler:()=>LJ,createImageDirective:()=>wJ,clearImageCache:()=>AJ,ImageProcessingError:()=>Q$,DEFAULT_WIDTHS:()=>y1,DEFAULT_QUALITY:()=>v1,DEFAULT_FORMATS:()=>x1});var fL;var TJ=D(()=>{G$();AQ();rG();CL();PL();vL();fL={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"}});function EJ($,Z,Y=new WeakSet){if(Object.is($,Z))return!0;if(typeof $!=="object"||typeof Z!=="object"||$===null||Z===null)return!1;if(Y.has($))return!0;if(Y.add($),$ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if($ instanceof RegExp&&Z instanceof RegExp)return $.source===Z.source&&$.flags===Z.flags;if(Array.isArray($)){if(!Array.isArray(Z)||$.length!==Z.length)return!1;for(let Q=0;Q<$.length;Q++)if(!EJ($[Q],Z[Q],Y))return!1;return!0}if(Array.isArray(Z))return!1;if($ instanceof Map){if(!(Z instanceof Map)||$.size!==Z.size)return!1;for(let[Q,G]of $)if(!Z.has(Q)||!EJ(G,Z.get(Q),Y))return!1;return!0}if(Z instanceof Map)return!1;if($ instanceof Set){if(!(Z instanceof Set)||$.size!==Z.size)return!1;for(let Q of $)if(!Z.has(Q))return!1;return!0}if(Z instanceof Set)return!1;let J=Object.keys($),X=Object.keys(Z);if(J.length!==X.length)return!1;for(let Q of J){if(!Object.prototype.hasOwnProperty.call(Z,Q))return!1;if(!EJ($[Q],Z[Q],Y))return!1}return!0}function Eb($){m0=$}function Ib(){return m0}function Db(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:dL()}}function dL(){return{refs:new Map,effects:new Set,cleanups:[]}}function kb($){let Z=new Set,Y=new Set,J=$,X=Symbol("ref"),Q={get value(){if(e0)Y.add(e0);return J},set value(G){if(!Object.is(G,J)){let K=J;J=G;for(let W of Z)W(G,K);for(let W of Y)W()}},subscribe(G){return Z.add(G),()=>{Z.delete(G)}}};if(m0)m0.scope.refs.set(X,Q);return Q}function uL($){let Z=hL.get($);if(Z)return Z;let Y=new Map,J=(G)=>{let K=Y.get(G);if(K)for(let W of[...K])W()},X=(G,K)=>{if(!Y.has(G))Y.set(G,new Set);return Y.get(G).add(K),()=>{Y.get(G)?.delete(K)}},Q=new Proxy($,{get(G,K,W){let U=Reflect.get(G,K,W);if(e0)X(K,e0);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let z=Object.getPrototypeOf(U);if(z===Object.prototype||z===null)return uL(U)}return U},set(G,K,W,U){let z=Reflect.get(G,K,U),_=Reflect.set(G,K,W,U);if(!Object.is(W,z))J(K);return _},deleteProperty(G,K){let W=Reflect.deleteProperty(G,K);return J(K),W}});return hL.set($,Q),Q}function Sb($){let Z,Y=!0,J=new Set,X=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=e0;if(e0=Q,Z=$(),e0=U,Y=!1,!Object.is(Z,W)){for(let z of J)z(Z,W);for(let z of X)z()}}},K=e0;return e0=Q,Z=$(),Y=!1,e0=K,{get value(){if(e0)X.add(e0);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return J.add(W),()=>{J.delete(W)}}}}function Cb($,Z,Y={}){let{immediate:J=!1,deep:X=!1,flush:Q="post"}=Y,G,K,W=!1,U=()=>{if(W)return;let j=q();if((X?!EJ(j,G):!Object.is(j,G))||J)if(Z(j,G),X&&j!==null&&typeof j==="object")try{G=structuredClone(j)}catch{G=j}else G=j},z=(j)=>{if(Q==="sync")j();else if(Q==="pre")Promise.resolve().then(j);else requestAnimationFrame(()=>{requestAnimationFrame(j)})},_=!1,B=()=>{if(W||_)return;_=!0,z(()=>{_=!1,U()})},q=()=>{if(typeof $==="function"){let j=e0;e0=B;try{return $()}finally{e0=j}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{z(U)});K=()=>{W=!0,j()}}else K=()=>{W=!0};if(G=q(),J)z(U);if(m0)m0.scope.cleanups.push(()=>K?.());return()=>K?.()}function bb($,Z,Y={}){let J=[],X=$.map((Q)=>Q.value);for(let Q of $){let G=Q.subscribe(()=>{let K=$.map((W)=>W.value);Z(K,X),X=[...K]});J.push(G)}if(Y.immediate){let Q=$.map((G)=>G.value);Z(Q,X)}return()=>{for(let Q of J)Q()}}function Pb($){let Z,Y=!1,J=()=>{if(Y)return;if(Z)Z();let X=e0;e0=J,Z=$(),e0=X};if(J(),m0)m0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function yb($){if(m0)m0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function xb($){if(m0)m0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function vb($){if(m0)m0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function fb($){if(m0)m0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function gb($){if(m0)m0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function hb($){if(m0)m0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function K$($,Z){let Y=$.hooks[Z];for(let J of Y)await J()}async function db($){await K$($,"beforeMount"),$.isMounted=!0,await K$($,"mounted")}async function ub($){if(!$.isMounted||$.isUnmounted)return;await K$($,"beforeUpdate"),await K$($,"updated")}async function mb($){if($.isUnmounted)return;await K$($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await K$($,"unmounted")}function lb(){return`
|
|
14177
14194
|
<script data-stx-client-runtime>
|
|
14178
14195
|
(function() {
|
|
14179
14196
|
'use strict';
|
|
@@ -14350,10 +14367,10 @@ ${H}
|
|
|
14350
14367
|
};
|
|
14351
14368
|
window.provide = provide;
|
|
14352
14369
|
})();
|
|
14353
|
-
</script>`}var m0=null,e0=null,hL;var mL=D(()=>{hL=new WeakMap});function IJ($){for(let Z of $.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let Y=Z[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!Y)continue;let J=Number(Y[1]);if(Number.isInteger(J)&&J>=100&&J<=599)return J}return}import{abortNavigation as cb,clearMiddleware as v8,createClientCookieManager as pb,createMiddlewareContext as f8,createRouteLocation as g8,createServerCookieManager as ib,createStorageManager as nb,defineMiddleware as rb,getMiddleware as
|
|
14370
|
+
</script>`}var m0=null,e0=null,hL;var mL=D(()=>{hL=new WeakMap});function IJ($){for(let Z of $.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let Y=Z[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!Y)continue;let J=Number(Y[1]);if(Number.isInteger(J)&&J>=100&&J<=599)return J}return}import{abortNavigation as cb,clearMiddleware as v8,createClientCookieManager as pb,createMiddlewareContext as f8,createRouteLocation as g8,createServerCookieManager as ib,createStorageManager as nb,defineMiddleware as rb,getMiddleware as ab,getMiddlewareNames as h8,hasMiddleware as sb,loadMiddlewareFromDirectory as d8,navigateTo as ob,registerMiddleware as tb,runMiddleware as u8}from"stx-router";var DJ=()=>{};function x5($,Z){if(typeof window>"u")return Z;return window[$]??Z}function kJ($,Z){if(typeof window>"u")return;window[$]=Z}function lL($){let Y=x5("__STX_STORES__",{})[$];if(!Y)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Y}function eb($){return lL($)}function $P($,Z=5000){return new Promise((Y,J)=>{let X=Date.now(),Q=()=>{let G=lL($);if(G)Y(G);else if(Date.now()-X>Z)J(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(Q)};Q()})}function cL(){return x5("__STX_ROUTE_PARAMS__",{})}function pL($){return cL()[$]}function ZP($){let Z=pL($);if(Z===void 0)throw Error(`Route parameter "${$}" not found`);return Z}function iL(){return x5("__STX_MIDDLEWARE_STATE__",{})}function YP($){return iL()[$]}function JP(){if(typeof window>"u")return;if(!x5("__STX_STORES__",null))kJ("__STX_STORES__",{})}function XP($,Z){let Y=x5("__STX_STORES__",{});Y[$]=Z,kJ("__STX_STORES__",Y)}function QP(){return x5("__STX_STORE_STATE__",null)}function GP($){kJ("__STX_ROUTE_PARAMS__",$)}function KP($){kJ("__STX_MIDDLEWARE_STATE__",$)}function nL(){return typeof window>"u"}function rL(){return typeof window<"u"}function WP($){if(rL())$()}function UP($){if(nL())$()}async function sL($){try{let Z=await Bun.file($).text(),Y=zP(Z),J=_P(Z,$),X=BP(Z,Y),Q=qP(Z,Y);return{file:$,metrics:Y,issues:J,suggestions:X,performance:Q}}catch(Z){throw Error(`Failed to analyze template ${$}: ${Z instanceof Error?Z.message:String(Z)}`)}}function zP($){let Z=$.split(`
|
|
14354
14371
|
`),Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),X=(Y?Y[1]:"").split(`
|
|
14355
|
-
`).length,Q={conditionals:($.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:($.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:($.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};Q.total=Q.conditionals+Q.loops+Q.includes+Q.custom;let G=($.match(/\{\{[\s\S]*?\}\}/g)||[]).length,K=($.match(/\{!![\s\S]*?!!\}/g)||[]).length,W=($.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,U=G+K+W,z=($.match(/<[A-Z][^>]*>/g)||[]).length,_=($.match(/@(?:layout|extends)\(/g)||[]).length,B=0,q=0;for(let O of Z)if(/@(?:if|unless|foreach|for|while|section)\b/.test(O)&&!/@end/.test(O)&&!/@else/.test(O))q++,B=Math.max(B,q);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))q--;let j=B>=4?3:0,H=Math.min(10,Math.ceil(Q.total*0.5+U*0.1+z*0.3+(X>10?X*0.05:0)+j));return{lines:Z.length,characters:$.length,directives:Q,expressions:U,components:z,layouts:_,scriptLines:X,complexity:H}}function _P($,Z){let Y=[],J=
|
|
14356
|
-
`).filter((z)=>z.length>120);if(W.length>0)Y.push({type:"info",category:"maintainability",message:`Found ${W.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let U=($.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(U>3)Y.push({type:"info",category:"maintainability",message:`Found ${U} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Y}function BP($,Z){let Y=[];if(Z.complexity>7)Y.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(Z.complexity>5&&Z.directives.total>8)Y.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(Z.lines>100&&Z.components===0)Y.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(Z.expressions>20)Y.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let J=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(J&&J.length>0)Y.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(Z.directives.total===0&&Z.expressions<5)Y.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(Z.scriptLines>50)Y.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Y}function qP($,Z){let Y=1;if(Y+=Z.directives.conditionals*0.1,Y+=Z.directives.loops*0.5,Y+=Z.directives.includes*2,Y+=Z.expressions*0.05,Y+=Z.components*1,Z.scriptLines>10)Y+=Z.scriptLines*0.1;let J;if(Z.expressions===0&&Z.directives.total===0)J="high";else if(Z.expressions<5&&Z.directives.total<3)J="medium";else J="low";let X=[];if(Y>10)X.push("Consider optimizing template complexity");if(J==="low"&&Z.directives.total>5)X.push("Reduce dynamic content for better caching");if(Z.components===0&&Z.lines>40)X.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(Y*100)/100,complexityScore:Z.complexity,cacheability:J,recommendations:X}}function
|
|
14372
|
+
`).length,Q={conditionals:($.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:($.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:($.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};Q.total=Q.conditionals+Q.loops+Q.includes+Q.custom;let G=($.match(/\{\{[\s\S]*?\}\}/g)||[]).length,K=($.match(/\{!![\s\S]*?!!\}/g)||[]).length,W=($.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,U=G+K+W,z=($.match(/<[A-Z][^>]*>/g)||[]).length,_=($.match(/@(?:layout|extends)\(/g)||[]).length,B=0,q=0;for(let O of Z)if(/@(?:if|unless|foreach|for|while|section)\b/.test(O)&&!/@end/.test(O)&&!/@else/.test(O))q++,B=Math.max(B,q);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))q--;let j=B>=4?3:0,H=Math.min(10,Math.ceil(Q.total*0.5+U*0.1+z*0.3+(X>10?X*0.05:0)+j));return{lines:Z.length,characters:$.length,directives:Q,expressions:U,components:z,layouts:_,scriptLines:X,complexity:H}}function _P($,Z){let Y=[],J=aL($,"if","endif");if(J>0)Y.push({type:"error",category:"syntax",message:`Found ${J} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let X=aL($,"foreach","endforeach");if(X>0)Y.push({type:"error",category:"syntax",message:`Found ${X} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let Q=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(Q&&Q.length>0)Y.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let G=($.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(G>0)Y.push({type:"warning",category:"security",message:`Found ${G} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let K=$.match(/<img[^>]*>/g);if(K){let z=K.filter((_)=>!_.includes("alt="));if(z.length>0)Y.push({type:"warning",category:"accessibility",message:`Found ${z.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let W=$.split(`
|
|
14373
|
+
`).filter((z)=>z.length>120);if(W.length>0)Y.push({type:"info",category:"maintainability",message:`Found ${W.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let U=($.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(U>3)Y.push({type:"info",category:"maintainability",message:`Found ${U} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Y}function BP($,Z){let Y=[];if(Z.complexity>7)Y.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(Z.complexity>5&&Z.directives.total>8)Y.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(Z.lines>100&&Z.components===0)Y.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(Z.expressions>20)Y.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let J=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(J&&J.length>0)Y.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(Z.directives.total===0&&Z.expressions<5)Y.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(Z.scriptLines>50)Y.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Y}function qP($,Z){let Y=1;if(Y+=Z.directives.conditionals*0.1,Y+=Z.directives.loops*0.5,Y+=Z.directives.includes*2,Y+=Z.expressions*0.05,Y+=Z.components*1,Z.scriptLines>10)Y+=Z.scriptLines*0.1;let J;if(Z.expressions===0&&Z.directives.total===0)J="high";else if(Z.expressions<5&&Z.directives.total<3)J="medium";else J="low";let X=[];if(Y>10)X.push("Consider optimizing template complexity");if(J==="low"&&Z.directives.total>5)X.push("Reduce dynamic content for better caching");if(Z.components===0&&Z.lines>40)X.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(Y*100)/100,complexityScore:Z.complexity,cacheability:J,recommendations:X}}function aL($,Z,Y){let J=$.replace(/<!--[\s\S]*?-->/g,""),X=(J.match(new RegExp(`@${Z}\\b`,"g"))||[]).length,Q=(J.match(new RegExp(`@${Y}\\b`,"g"))||[]).length;return Math.abs(X-Q)}async function YK($=["**/*.stx"],Z){let Y=[],J=[];for(let Q of $){let G=await Array.fromAsync(new Bun.Glob(Q).scan({cwd:Z||process.cwd(),onlyFiles:!0,absolute:!0}));J.push(...G.filter((K)=>K.endsWith(".stx")))}for(let Q of J)try{let G=await sL(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let X=jP(Y);return{results:Y,summary:X}}function jP($){let Z=$.length,Y=$.reduce((U,z)=>U+z.metrics.lines,0),J=Z>0?$.reduce((U,z)=>U+z.metrics.complexity,0)/Z:0,X=$.reduce((U,z)=>U+z.issues.length,0),Q={};$.forEach((U)=>{U.issues.forEach((z)=>{Q[z.category]=(Q[z.category]||0)+1})});let G=Z>0?$.reduce((U,z)=>U+z.performance.estimatedRenderTime,0)/Z:0,K=Math.max(1,Math.min(10,Math.round(10-G/2-J/2))),W=[];if(J>6)W.push("Project has high average complexity. Consider refactoring complex templates.");if(X>Z*2)W.push("High number of issues detected. Run detailed analysis on individual files.");if(Q.security>0)W.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:Z,totalLines:Y,avgComplexity:Math.round(J*100)/100,totalIssues:X,issuesByCategory:Q,performanceScore:K,recommendations:W}}function oL($,Z,Y){let J={fullTag:Y,content:Z,attrs:$};if(/\bserver\b/.test($))return{...J,type:"server"};if(/\bdata-stx-scoped\b/.test($))return{...J,type:"client"};if(HP.test(Z))return{...J,type:"signals"};if(/\bclient\b/.test($)||/\btype\s*=\s*["']module["']/.test($)||/\bsrc\s*=/.test($))return{...J,type:"client"};return{...J,type:"server"}}function JK($){let Z=[],Y=[],J=[],X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=X.exec($))!==null){let G=oL(Q[1],Q[2],Q[0]);switch(G.type){case"signals":Z.push(G);break;case"client":Y.push(G);break;case"server":J.push(G);break}}return{signals:Z,client:Y,server:J}}var HP;var XK=D(()=>{HP=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import QK from"path";import{extractLayoutMetadata as p8}from"stx-router/layout-metadata";function VP(){if(m8!==null)return m8;try{let{getRouterScript:$}=Z0("stx-router");m8=`<script>${$()}</script>`}catch{m8=""}return m8}async function GK($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let J=QK.resolve($,Z);if(await Bun.file(J).exists())return J;return null}let Y=QK.join($,"app.stx");if(await Bun.file(Y).exists())return Y;return null}async function SJ($,Z){try{let Y=await Bun.file($).text(),J=Y,X=Y.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(X)J=X[1].trim();let Q=JK(Y),G=[...Q.client.map((A)=>A.fullTag),...Q.signals.map((A)=>A.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let z=J;for(let A of Q.server)z=z.replace(A.fullTag,"");for(let A of Q.client)z=z.replace(A.fullTag,"");z=z.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let _="<!--__STX_PAGE_SLOT__-->";if(z=z.replace(/<slot\s*\/>/gi,_).replace(/<slot\s*>\s*<\/slot>/gi,_),!z.includes(_))return console.warn(`[stx] Shell ${$} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:B,extractVariables:q,defaultConfig:j,loadStxConfig:H}=await Promise.resolve().then(() => (N6(),W$)),O=await H(),V={__filename:$,__dirname:QK.dirname($)};for(let A of G){let w=A.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(w&&!A.includes("client")&&!A.includes('type="module"'))await q(w[1],V,$)}let L=await B(z,V,$,{...j,...O,...Z},new Set),F=L.indexOf(_);if(F===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:L.substring(0,F),afterSlot:L.substring(F+_.length),filePath:$,shellScripts:G,shellStyles:K}}catch(Y){return console.error(`[stx] Error processing shell ${$}:`,Y),null}}function l8($,Z,Y){let J,X="",Q=Z.match(LP);if(Q){Z=Z.replace(Q[0],"");try{let z=Buffer.from(Q[1],"base64").toString("utf8"),_=z.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(_)J=_[1].trim();X=z.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let G=Y||J||"stx App",K=VP(),W="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
14357
14374
|
<html lang="en">
|
|
14358
14375
|
<head>
|
|
14359
14376
|
<meta charset="UTF-8">
|
|
@@ -14380,7 +14397,7 @@ ${K}
|
|
|
14380
14397
|
`));if(X.length>0)L.push(X.join(`
|
|
14381
14398
|
`));if(H.length>0)L.push(H.join(`
|
|
14382
14399
|
`));return L.push(j),L.join(`
|
|
14383
|
-
`)}var OP="stx-page-head:",LP,m8=null;var v5=D(()=>{XK();LP=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/});import{matchRoute as FP,Router as AP}from"stx-router";import{findErrorPage as WK,formatRoutes as UK,generateRouteManifest as NP,generateRouteTypes as RP,matchRoute as CJ}from"stx-router";function f4($,Z={}){return new AP($,Z).routes}function wP($,Z){let Y=FP($,Z);return Y?Y.params:null}var i8=()=>{};import{createHash as MP}from"crypto";function TP($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function IP($){return Bun.hash($).toString(16)}function tL($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,J=$.replace(EP,(Q,G,K,W)=>{let U=W.trim();if(!U)return Q;if(/\bdata-stx-src=/.test(K))return Q;if(Z.minify)U=TP(U);let z=IP(U);if(!Y.has(z))Y.set(z,U);let _=Z.integrity?` data-stx-integrity="sha384-${MP("sha384").update(U).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${z}.js"${_}${K}></script>`}),X=Array.from(Y,([Q,G])=>({hash:Q,code:G}));return{html:J,chunks:X}}function eL($){if(!$.includes("data-stx-src="))return $;let Z=new Map,Y=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,J;while((J=Y.exec($))!==null)Z.set(J[1],J[2]);let X=new Set,Q=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=Q.exec($))!==null)if(DP.has(Z.get(G[1])||""))X.add(G[2]);let K=$.lastIndexOf("</head>");if(X.size===0||K===-1)return $;let W=Array.from(X).filter((U)=>!$.includes(`rel="prefetch" href="${U}"`)).map((U)=>`<link rel="prefetch" href="${U}" as="script">`).join("");if(!W)return $;return $.slice(0,K)+W+$.slice(K)}var EP,DP;var $V=D(()=>{EP=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;DP=new Set(["visible","idle"])});var UV={};$0(UV,{generateStaticSite:()=>XV,defineStaticPaths:()=>KV,default:()=>dP,createMarkdownLoader:()=>WV,createISRHandler:()=>GV});import
|
|
14400
|
+
`)}var OP="stx-page-head:",LP,m8=null;var v5=D(()=>{XK();LP=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/});import{matchRoute as FP,Router as AP}from"stx-router";import{findErrorPage as WK,formatRoutes as UK,generateRouteManifest as NP,generateRouteTypes as RP,matchRoute as CJ}from"stx-router";function f4($,Z={}){return new AP($,Z).routes}function wP($,Z){let Y=FP($,Z);return Y?Y.params:null}var i8=()=>{};import{createHash as MP}from"crypto";function TP($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function IP($){return Bun.hash($).toString(16)}function tL($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,J=$.replace(EP,(Q,G,K,W)=>{let U=W.trim();if(!U)return Q;if(/\bdata-stx-src=/.test(K))return Q;if(Z.minify)U=TP(U);let z=IP(U);if(!Y.has(z))Y.set(z,U);let _=Z.integrity?` data-stx-integrity="sha384-${MP("sha384").update(U).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${z}.js"${_}${K}></script>`}),X=Array.from(Y,([Q,G])=>({hash:Q,code:G}));return{html:J,chunks:X}}function eL($){if(!$.includes("data-stx-src="))return $;let Z=new Map,Y=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,J;while((J=Y.exec($))!==null)Z.set(J[1],J[2]);let X=new Set,Q=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=Q.exec($))!==null)if(DP.has(Z.get(G[1])||""))X.add(G[2]);let K=$.lastIndexOf("</head>");if(X.size===0||K===-1)return $;let W=Array.from(X).filter((U)=>!$.includes(`rel="prefetch" href="${U}"`)).map((U)=>`<link rel="prefetch" href="${U}" as="script">`).join("");if(!W)return $;return $.slice(0,K)+W+$.slice(K)}var EP,DP;var $V=D(()=>{EP=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;DP=new Set(["visible","idle"])});var UV={};$0(UV,{generateStaticSite:()=>XV,defineStaticPaths:()=>KV,default:()=>dP,createMarkdownLoader:()=>WV,createISRHandler:()=>GV});import s0 from"fs";import w0 from"path";class ZV{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=w0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,J]of Object.entries(Z))this.cache.set(Y,J)}catch{}this.loaded=!0}async save(){await s0.promises.mkdir(this.cacheDir,{recursive:!0});let $=w0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,J]of this.cache)Z[Y]=J;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=s0.statSync($),J=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(s0.existsSync(Q)){let G=s0.statSync(Q);J+=`:${Q}:${G.mtimeMs}`}let X=0;for(let Q=0;Q<J.length;Q++){let G=J.charCodeAt(Q);X=(X<<5)-X+G,X=X&X}return Math.abs(X).toString(36)}get($,Z){let Y=this.cache.get($);if(!Y)return null;let J=this.getHash(Z,Y.dependencies??[]);if(Y.hash!==J)return this.cache.delete($),null;return Y.html}set($,Z,Y,J){let X=this.getHash(Z,Y);this.cache.set($,{hash:X,html:J,generatedAt:Date.now(),dependencies:Y})}}class YV{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return w0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await s0.promises.mkdir(w0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await s0.promises.unlink(Z)}async invalidatePattern($){let Z=w0.join(this.cacheDir,"isr");if(!s0.existsSync(Z))return;let Y=await s0.promises.readdir(Z);for(let J of Y){let X=J.replace(/_/g,"/").replace(".json","");if($.test(X))await s0.promises.unlink(w0.join(Z,J))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function kP($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let J=Y[1];if(!J.includes("getStaticPaths"))return null;let X=J.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!X)return null;return await Function(`
|
|
14384
14401
|
return (async function getStaticPaths() {
|
|
14385
14402
|
${X[1]}
|
|
14386
14403
|
})()
|
|
@@ -14420,10 +14437,10 @@ ${$.map((J)=>{let X=new URL(J.loc,Z).href,Q=` <url>
|
|
|
14420
14437
|
${Y.join(`
|
|
14421
14438
|
`)}
|
|
14422
14439
|
</channel>
|
|
14423
|
-
</rss>`}async function XV($={}){let Z=Date.now(),Y=await d0(),J={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||c0(process.cwd(),"ssg-cache"),contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},X={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},W={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&
|
|
14440
|
+
</rss>`}async function XV($={}){let Z=Date.now(),Y=await d0(),J={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||c0(process.cwd(),"ssg-cache"),contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},X={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},W={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&s0.existsSync(J.outputDir))await s0.promises.rm(J.outputDir,{recursive:!0});await s0.promises.mkdir(J.outputDir,{recursive:!0});let z=new ZV(J.cacheDir);if(J.cache)await z.load();try{let{generateCrosswindCSS:F}=await Promise.resolve().then(() => (U4(),qZ));await F('<div class="bg-black"></div>')}catch{}v8();let _=Y?.routeMiddleware?.dir||"middleware";await d8(process.cwd(),_);let B=h8();if(B.length>0)console.log(`Loaded ${B.length} middleware: ${B.join(", ")}`);let q=Y?.routeMiddleware?.global||[],j=f4(".",{pagesDir:J.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let F of j){let A=await SP(F);for(let w of A)H.push({route:F,url:w.url,params:w.params,props:w.props,revalidate:w.revalidate??J.revalidate})}X.totalPages=H.length,console.log(`Generating ${X.totalPages} pages...`);let O=[],V=[];for(let F=0;F<H.length;F+=J.concurrency)V.push(H.slice(F,F+J.concurrency));for(let F of V)await Promise.all(F.map(async(A)=>{let{route:w,url:N,params:R,props:E,revalidate:M}=A;try{await J.hooks.onPageStart?.(N);let I=await Bun.file(w.filePath).text(),S=fP(I),k=S?.middleware?Array.isArray(S.middleware)?S.middleware:[S.middleware]:[],x=[...q,...k];if(x.length>0){let P=g8(N,R,S||{}),d=f8(P,null),l=await u8(x,d);if(l.redirect){let c=typeof l.redirect==="string"?l.redirect:l.redirect.path||l.redirect,a=gP(String(c),N),X0=hP(N,J);await s0.promises.mkdir(w0.dirname(X0),{recursive:!0}),await Bun.write(X0,a),X.successCount++,X.pages.push({route:N,outputPath:X0,size:Buffer.byteLength(a),cached:!1}),O.push({loc:N,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${N} \u2192 redirect to ${c}`);return}if(l.abort){let c=typeof l.abort==="string"?l.abort:l.abort?.error?.message||"aborted";console.warn(` \u21B3 ${N} \u2014 middleware aborted: ${c}`);return}}let y=I.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(y)try{if(!await Function("route",`
|
|
14424
14441
|
const validate = ${y[1]};
|
|
14425
14442
|
return validate(route);
|
|
14426
|
-
`)({params:R})){console.warn(`Validation failed for ${N}, skipping...`);return}}catch{}let b=null,h=!1;if(J.cache){if(b=z.get(N,w.filePath),b)h=!0,X.cachedCount++}if(!b){let P=await JV(w,R,E,J,Y);if(b=P.html,J.cache)z.set(N,w.filePath,P.dependencies,b)}let r;if(J.trailingSlash)r=w0.join(J.outputDir,N,"index.html");else r=N==="/"?w0.join(J.outputDir,"index.html"):w0.join(J.outputDir,`${N}.html`);if(J.chunkIslands){let{html:P,chunks:d}=tL(b,{integrity:J.integrityIslands,minify:J.minify});if(d.length>0){let l=w0.join(J.outputDir,"_stx","islands");await
|
|
14443
|
+
`)({params:R})){console.warn(`Validation failed for ${N}, skipping...`);return}}catch{}let b=null,h=!1;if(J.cache){if(b=z.get(N,w.filePath),b)h=!0,X.cachedCount++}if(!b){let P=await JV(w,R,E,J,Y);if(b=P.html,J.cache)z.set(N,w.filePath,P.dependencies,b)}let r;if(J.trailingSlash)r=w0.join(J.outputDir,N,"index.html");else r=N==="/"?w0.join(J.outputDir,"index.html"):w0.join(J.outputDir,`${N}.html`);if(J.chunkIslands){let{html:P,chunks:d}=tL(b,{integrity:J.integrityIslands,minify:J.minify});if(d.length>0){let l=w0.join(J.outputDir,"_stx","islands");await s0.promises.mkdir(l,{recursive:!0});for(let c of d){let a=w0.join(l,`${c.hash}.js`);if(!await Bun.file(a).exists())await Bun.write(a,c.code);if(!Q.has(c.hash)){Q.add(c.hash);let X0=Buffer.byteLength(c.code,"utf8");G+=X0,K[c.hash]={bytes:X0,file:`/_stx/islands/${c.hash}.js`}}}if(W[N]=d.map((c)=>c.hash),b=P,J.prefetchIslands)b=eL(b)}}await s0.promises.mkdir(w0.dirname(r),{recursive:!0}),await Bun.write(r,b),O.push({loc:N,lastmod:new Date().toISOString().split("T")[0],priority:N==="/"?1:0.8});let m={route:N,outputPath:r,size:Buffer.byteLength(b,"utf8"),cached:h};if(M!==!1)m.revalidateAt=Date.now()+M*1000;X.pages.push(m),X.successCount++,await J.hooks.onPageEnd?.(N,b)}catch(I){X.failedCount++,X.errors.push({route:N,error:I}),await J.hooks.onError?.(I,N),console.error(`Error generating ${N}:`,I)}}));if(J.cache)await z.save();if(J.generate404){let F=w0.join(J.pagesDir,"404.stx");if(await Bun.file(F).exists()){let A=new Set,w={...Y,debug:!1,cache:!1},N=await q0(await Bun.file(F).text(),{},F,w,A);await Bun.write(w0.join(J.outputDir,"404.html"),N)}else await Bun.write(w0.join(J.outputDir,"404.html"),`<!DOCTYPE html>
|
|
14427
14444
|
<html lang="en">
|
|
14428
14445
|
<head>
|
|
14429
14446
|
<meta charset="UTF-8">
|
|
@@ -14444,7 +14461,7 @@ ${Y.join(`
|
|
|
14444
14461
|
<a href="/">Go home</a>
|
|
14445
14462
|
</div>
|
|
14446
14463
|
</body>
|
|
14447
|
-
</html>`)}for(let F of[500]){let A=w0.join(J.pagesDir,`${F}.stx`);if(await Bun.file(A).exists()){let w=new Set,N={...Y,debug:!1,cache:!1},R=await q0(await Bun.file(A).text(),{},A,N,w);await Bun.write(w0.join(J.outputDir,`${F}.html`),R)}}let L=w0.join(J.pagesDir,"error.stx");if(await Bun.file(L).exists()){let F=new Set,A={...Y,debug:!1,cache:!1},w=await q0(await Bun.file(L).text(),{},L,A,F);await Bun.write(w0.join(J.outputDir,"error.html"),w)}if(J.sitemap&&O.length>0){let F=xP(O,J.domain),A=w0.join(J.outputDir,"sitemap.xml");await Bun.write(A,F),X.sitemapPath=A,console.log(`Generated sitemap.xml with ${O.length} URLs`)}if(J.rss){let F=typeof J.rss==="object"?J.rss:{title:"Site Feed",description:"Latest updates",link:J.domain},A=[];if(F.getItems)A=await F.getItems();let w=vP(F,A),N=w0.join(J.outputDir,"rss.xml");await Bun.write(N,w),X.rssPath=N,console.log(`Generated rss.xml with ${A.length} items`)}if(J.publicDir&&
|
|
14464
|
+
</html>`)}for(let F of[500]){let A=w0.join(J.pagesDir,`${F}.stx`);if(await Bun.file(A).exists()){let w=new Set,N={...Y,debug:!1,cache:!1},R=await q0(await Bun.file(A).text(),{},A,N,w);await Bun.write(w0.join(J.outputDir,`${F}.html`),R)}}let L=w0.join(J.pagesDir,"error.stx");if(await Bun.file(L).exists()){let F=new Set,A={...Y,debug:!1,cache:!1},w=await q0(await Bun.file(L).text(),{},L,A,F);await Bun.write(w0.join(J.outputDir,"error.html"),w)}if(J.sitemap&&O.length>0){let F=xP(O,J.domain),A=w0.join(J.outputDir,"sitemap.xml");await Bun.write(A,F),X.sitemapPath=A,console.log(`Generated sitemap.xml with ${O.length} URLs`)}if(J.rss){let F=typeof J.rss==="object"?J.rss:{title:"Site Feed",description:"Latest updates",link:J.domain},A=[];if(F.getItems)A=await F.getItems();let w=vP(F,A),N=w0.join(J.outputDir,"rss.xml");await Bun.write(N,w),X.rssPath=N,console.log(`Generated rss.xml with ${A.length} items`)}if(J.publicDir&&s0.existsSync(J.publicDir))await QV(J.publicDir,J.outputDir),console.log(`Copied public assets from ${J.publicDir}`)}catch(z){throw await J.hooks.onError?.(z),z}if(X.buildTime=Date.now()-Z,Q.size>0){X.islandChunks={count:Q.size,totalBytes:G};let z={generatedChunks:Q.size,totalBytes:G,chunks:K,pages:W};await Bun.write(w0.join(J.outputDir,"_stx","islands-manifest.json"),JSON.stringify(z,null,2))}await J.hooks.onBuildEnd?.(X);let U=X.islandChunks?`
|
|
14448
14465
|
Island chunks: ${X.islandChunks.count} (${(X.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
14449
14466
|
Build complete!
|
|
14450
14467
|
Total: ${X.totalPages} pages
|
|
@@ -14452,7 +14469,7 @@ Build complete!
|
|
|
14452
14469
|
Cached: ${X.cachedCount}
|
|
14453
14470
|
Failed: ${X.failedCount}
|
|
14454
14471
|
Time: ${X.buildTime}ms${U}
|
|
14455
|
-
`),X}async function QV($,Z){let Y=await
|
|
14472
|
+
`),X}async function QV($,Z){let Y=await s0.promises.readdir($,{withFileTypes:!0});for(let J of Y){let X=w0.join($,J.name),Q=w0.join(Z,J.name);if(J.isDirectory())await s0.promises.mkdir(Q,{recursive:!0}),await QV(X,Q);else await s0.promises.copyFile(X,Q)}}function GV($={}){let Z=$.cacheDir||c0(process.cwd(),"ssg-cache"),Y=new YV(Z),J=$.revalidate||3600;return{async get(X){let Q=await Y.get(X);if(!Q)return null;if(Date.now()>Q.revalidateAfter)this.revalidate(X).catch(console.error);return{html:Q.html,headers:{"Cache-Control":`public, max-age=${J}, stale-while-revalidate=${J*2}`,ETag:Q.etag,"X-ISR-Generated":new Date(Q.generatedAt).toISOString(),...Q.headers}}},async revalidate(X){let G=f4(".",{pagesDir:$.pagesDir||"pages"}).find((_)=>{return X.match(_.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${X}`);return}let K=X.match(G.regex),W={};if(K)G.params.forEach((_,B)=>{W[_]=K[B+1]});let U=await d0(),{html:z}=await JV(G,W,{},$,U);await Y.set(X,{html:z,generatedAt:Date.now(),revalidateAfter:Date.now()+J*1000,etag:yP(z)}),console.log(`Revalidated: ${X}`)},async invalidate(X){if(typeof X==="string")await Y.invalidate(X);else await Y.invalidatePattern(X)}}}function KV($){return async()=>{return{paths:await $(),fallback:!1}}}function WV(){return{name:"markdown",extensions:[".md",".mdx"],async load($){let Z=await Bun.file($).text(),Y=Z.match(/^---\n([\s\S]*?)\n---/),J={},X=Z;if(Y){let U=Y[1];X=Z.slice(Y[0].length).trim();for(let z of U.split(`
|
|
14456
14473
|
`)){let _=z.indexOf(":");if(_>0){let B=z.slice(0,_).trim(),q=z.slice(_+1).trim();if(q==="true")q=!0;else if(q==="false")q=!1;else if(/^\d+$/.test(q))q=parseInt(q,10);else if(/^\d+\.\d+$/.test(q))q=parseFloat(q);else if(q.startsWith("[")&&q.endsWith("]"))q=q.slice(1,-1).split(",").map((j)=>j.trim().replace(/^['"]|['"]$/g,""));J[B]=q}}}let Q=X.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),G=[],K=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,W;while((W=K.exec(Q))!==null){let U=parseInt(W[1],10),z=W[2],_=z.toLowerCase().replace(/[^a-z0-9]+/g,"-");G.push({id:_,text:z,level:U})}return{content:Q,data:J,toc:G}}}}function fP($){let Z=$.match(/definePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!Z)return null;try{return Function(`return ${Z[1]}`)()}catch{return null}}function gP($,Z){return`<!DOCTYPE html>
|
|
14457
14474
|
<html>
|
|
14458
14475
|
<head>
|
|
@@ -14465,8 +14482,8 @@ Build complete!
|
|
|
14465
14482
|
<p>Redirecting to <a href="${$}">${$}</a>...</p>
|
|
14466
14483
|
<script>window.location.replace('${$}')</script>
|
|
14467
14484
|
</body>
|
|
14468
|
-
</html>`}function hP($,Z){if($==="/"||$==="")return w0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return w0.join(Z.outputDir,Y,"index.html");return w0.join(Z.outputDir,`${Y}.html`)}var dP;var zV=D(()=>{i8();_1();$V();r0();G4();U4();DJ();dP={generateStaticSite:XV,createISRHandler:GV,defineStaticPaths:KV,createMarkdownLoader:WV}});import{createHash as uP}from"crypto";import{getRouterScript as mP}from"stx-router";function zK($){return uP("sha256").update($).digest("hex").slice(0,8)}function _K($=!1){let Z=$?
|
|
14469
|
-
[stx build] Done in ${N}ms \u2014 ${V.length} pages compiled`),{pageCount:V.length,assets:A,outputDir:J,duration:N}}var iP;var AK=D(()=>{i8();qK();HK();bJ();v5();U4();r0();iP=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var OV={};$0(OV,{buildApp:()=>HV});import rP from"path";async function HV($={}){let Z=performance.now(),Y=$.root||process.cwd(),J=await d0(),X=J.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${X.toUpperCase()}${J.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(X==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (zV(),UV));Q=await W({pagesDir:rP.join(J.root||".",J.pagesDir||J.build?.pagesDir||"pages"),publicDir:J.publicDir||J.build?.publicDir||"public",outputDir:J.build?.outputDir||"dist",generate404:J.build?.generate404??!0,minify:J.build?.minify??!0,cleanOutput:J.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => (AK(),jV));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:X,ssg:Q,ssr:G,duration:K}}var wK=D(()=>{r0()});import PJ from"path";async function
|
|
14485
|
+
</html>`}function hP($,Z){if($==="/"||$==="")return w0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return w0.join(Z.outputDir,Y,"index.html");return w0.join(Z.outputDir,`${Y}.html`)}var dP;var zV=D(()=>{i8();_1();$V();r0();G4();U4();DJ();dP={generateStaticSite:XV,createISRHandler:GV,defineStaticPaths:KV,createMarkdownLoader:WV}});import{createHash as uP}from"crypto";import{getRouterScript as mP}from"stx-router";function zK($){return uP("sha256").update($).digest("hex").slice(0,8)}function _K($=!1){let Z=$?a6():e7(),Y=zK(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function BK(){let $=mP(),Z=zK($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function lP($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var qK=D(()=>{c$()});import _V from"path";import{createHash as cP}from"crypto";function pP($={}){let Z=new Set;return{context:new Proxy($,{get(J,X){if(X in J)return J[X];if(typeof X==="string"&&!X.startsWith("__"))Z.add(X);return},has(J,X){if(X in J)return!0;if(typeof X==="string"&&!X.startsWith("__"))Z.add(X);return!1}}),accessedKeys:Z}}async function jK($,Z,Y={}){let J=_V.resolve($),X=await Bun.file(J).text(),Q=cP("sha256").update(X).digest("hex").slice(0,16);fX();let G={};try{G=await d0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(X))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:z}=pP({__filename:J,__dirname:_V.dirname(J)}),_=new Set,B={...N1,...G,...Y,buildMode:"compile",strict:!1},q=await q0(X,z,J,B,_),j=v4(q),H=gX();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(_),contentHash:Q,streamTemplates:z.__streamTemplates}}var HK=D(()=>{_1();r0();q7();v5()});import OK from"fs";import BV from"path";function LK($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function VK($,Z){let Y=BV.join(Z,"manifest.json");OK.writeFileSync(Y,JSON.stringify($,null,2))}function FK($){let Z=BV.join($,"manifest.json");if(!OK.existsSync(Z))return null;try{let Y=OK.readFileSync(Z,"utf-8"),J=JSON.parse(Y);if(J.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${J.version}`),null;return J}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var bJ=()=>{};var jV={};$0(jV,{buildForProduction:()=>qV});import F4 from"fs";import U1 from"path";function nP($,Z){let Y=0,J=0;if(!F4.existsSync($))return{copied:Y,bytes:J};function X(Q,G){let K=F4.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(iP.has(W.name))continue;let U=U1.join(Q,W.name),z=U1.join(G,W.name);if(W.isDirectory())F4.mkdirSync(z,{recursive:!0}),X(U,z);else if(W.isFile()){if(F4.existsSync(z))continue;F4.copyFileSync(U,z),Y++,J+=F4.statSync(z).size}}}return X($,Z),{copied:Y,bytes:J}}async function qV($={}){let Z=Date.now(),Y=U1.resolve($.root||process.cwd()),J=U1.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await d0()}catch{}let Q=$.componentsDir??X.componentsDir??"components",G=$.partialsDir??X.partialsDir??"partials",K=$.layoutsDir??X.layoutsDir??"layouts",W=$.publicDir??X.publicDir??"public",U=X.app?.head||{},z=X.router?.container||"main";if(F4.existsSync(J))F4.rmSync(J,{recursive:!0});let _=[U1.join(J,"public","__stx"),U1.join(J,"public","assets"),U1.join(J,"server","pages"),U1.join(J,"server","fragments")];for(let R of _)F4.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let B=f4(Y),q=["components","layouts","partials"],j=B.filter((R)=>{return!q.some((E)=>R.pattern.startsWith(`/${E}/`)||R.pattern===`/${E}`)});console.log(`[stx build] Found ${j.length} page routes (${B.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=_K($.debug),O=BK();await Bun.write(U1.join(J,"public","__stx",H.filename),H.content),await Bun.write(U1.join(J,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let V=[],L=[];for(let R of j)try{let E=await jK(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(V.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),E.html=p7(E.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let x=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(x&&x[1]){let y=x[1];E.html=E.html.replace(" "+y,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${y}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await P0(E.html),E.fragment=c8(E.html,z);let I=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),S=U1.join("server","pages",`${I}.compiled.json`),k=U1.join("server","fragments",`${I}.html`);await Bun.write(U1.join(J,S),JSON.stringify(E,null,2)),await Bun.write(U1.join(J,k),E.fragment),L.push({pattern:R.pattern,compiledPath:S,fragmentPath:k,isDynamic:E.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${R.pattern}:`,E instanceof Error?E.message:E)}let F=U1.resolve(Y,W);if(F4.existsSync(F)){let{copied:R,bytes:E}=nP(F,U1.join(J,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let A={runtime:H.filename,router:O.filename},w=LK(L,A,J);VK(w,J);let N=Date.now()-Z;return console.log(`
|
|
14486
|
+
[stx build] Done in ${N}ms \u2014 ${V.length} pages compiled`),{pageCount:V.length,assets:A,outputDir:J,duration:N}}var iP;var AK=D(()=>{i8();qK();HK();bJ();v5();U4();r0();iP=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var OV={};$0(OV,{buildApp:()=>HV});import rP from"path";async function HV($={}){let Z=performance.now(),Y=$.root||process.cwd(),J=await d0(),X=J.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${X.toUpperCase()}${J.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(X==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (zV(),UV));Q=await W({pagesDir:rP.join(J.root||".",J.pagesDir||J.build?.pagesDir||"pages"),publicDir:J.publicDir||J.build?.publicDir||"public",outputDir:J.build?.outputDir||"dist",generate404:J.build?.generate404??!0,minify:J.build?.minify??!0,cleanOutput:J.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => (AK(),jV));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:X,ssg:Q,ssr:G,duration:K}}var wK=D(()=>{r0()});import PJ from"path";async function sP($){let Z=performance.now(),Y=await d0($),J=$||Y.root||process.cwd(),X=[Y.build?.pagesDir||Y.pagesDir||"pages",Y.componentsDir||"components",Y.layoutsDir||"layouts",Y.partialsDir||"partials"].map((K)=>PJ.resolve(J,K)),Q=[],G=0;for(let K of X){let W=await VV(K);for(let U of W){G++;let z=await Bun.file(U).text();if(LV.test(z))Q.push(PJ.relative(J,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function oP($){let Z=await d0($),Y=$||Z.root||process.cwd(),J=PJ.resolve(Y,Z.componentsDir||"components"),X=[],Q=await VV(J);for(let G of Q){let K=await Bun.file(G).text(),W=LV.test(K),U=aP.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let z=PJ.relative(Y,G);X.push({file:z,message:`Component "${z}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return X}async function VV($){let Z=[];try{let Y=new Bun.Glob("**/*.stx");for await(let J of Y.scan({cwd:$,absolute:!0}))Z.push(J)}catch{}return Z}var LV,aP;var FV=D(()=>{r0();LV=/<script\b[^>]*\bserver\b/i,aP=/<script\b[^>]*\bclient\b/i});function NK($){let Z=new Map,Y=/@(\w+)/g,J,X=1,Q=0;while((J=Y.exec($))!==null){let G=J[1],K=$.slice(Q,J.index);X+=(K.match(/\n/g)||[]).length,Q=J.index;let W=J.index-$.lastIndexOf(`
|
|
14470
14487
|
`,J.index-1);if(wV.includes(G)){let U=Z.get(G);if(U)U.count++,U.locations.push({line:X,column:W});else Z.set(G,{name:G,count:1,locations:[{line:X,column:W}]})}}return Array.from(Z.values())}function NV($,Z=[]){let Y=NK($),J=new Set(Y.map((X)=>X.name));for(let X of Z)J.add(X);for(let X of Array.from(J))if(!X.startsWith("end"))J.add(`end${X}`);return wV.filter((X)=>!J.has(X))}function RV($){let Z=[],Y={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},J=new Set;for(let Q of $)for(let[G,K]of Object.entries(Y))if(K.includes(Q)){J.add(G);break}for(let Q of J)Z.push(`import { process${eP(Q)} } from './${Q}'`);let X=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
|
|
14471
14488
|
`);return`// Tree-shaken directive bundle
|
|
14472
14489
|
// Only includes: ${$.join(", ")}
|
|
@@ -14480,7 +14497,7 @@ ${X}
|
|
|
14480
14497
|
export function isDirectiveActive(name: string): boolean {
|
|
14481
14498
|
return name in activeDirectives
|
|
14482
14499
|
}
|
|
14483
|
-
`}function MV($,Z={}){let Y=[],J=/@if\(([^)]+)\)[\s\S]*?@endif/g,X=$.matchAll(J);for(let U of X){let z=U[1].trim();if(yJ(z,Z)===!1)Y.push({start:U.index,end:U.index+U[0].length,reason:`@if condition always false: ${z}`})}let Q=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(Q);for(let U of G){let z=U[1].trim();if(yJ(z,Z)===!0)Y.push({start:U.index,end:U.index+U[0].length,reason:`@unless condition always true: ${z}`})}let K=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(Z.__ENV__==="production"){let U=$.matchAll(K);for(let z of U)Y.push({start:z.index,end:z.index+z[0].length,reason:"Development-only code in production build"})}let W=/@debug[\s\S]*?@enddebug/g;if(Z.__ENV__==="production"){let U=$.matchAll(W);for(let z of U)Y.push({start:z.index,end:z.index+z[0].length,reason:"Debug code in production build"})}return Y}function TV($,Z={}){let Y=MV($,Z),J=[];Y.sort((Q,G)=>G.start-Q.start);let X=$;for(let Q of Y)X=X.slice(0,Q.start)+X.slice(Q.end),J.push(Q.reason);return{content:X,removed:J}}function yJ($,Z){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in Z)return Z[$];let Y=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Y){let[,J,X,Q]=Y,G=J in Z?Z[J]:void 0,K=yJ(Q,Z);if(G!==void 0&&K!==void 0)switch(X){case"==":case"===":return G===K;case"!=":case"!==":return G!==K;case">":return G>K;case"<":return G<K;case">=":return G>=K;case"<=":return G<=K}}return}function EV($,Z){let Y=[],J=$;return J=J.replace(/\{\{\s*(\w+)\s*\}\}/g,(X,Q)=>{if(Q in Z)return Y.push(`{{ ${Q} }} -> ${Z[Q]}`),String(Z[Q]);return X}),J=J.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(X,Q,G,K)=>{let W=Number.parseInt(Q,10),U=Number.parseInt(K,10),z;switch(G){case"+":z=W+U;break;case"-":z=W-U;break;case"*":z=W*U;break;default:return X}return Y.push(`{{ ${Q} ${G} ${K} }} -> ${z}`),String(z)}),{content:J,folded:Y}}function IV($){let Z=$,Y=[],J=0;Z=Z.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(X)=>{let Q=`__PRESERVE_${J++}__`;return Y.push({marker:Q,content:X}),Q}),Z=Z.replace(/\{\{([\s\S]*?)\}\}/g,(X)=>{let Q=`__PRESERVE_${J++}__`;return Y.push({marker:Q,content:X}),Q}),Z=Z.replace(/\{\{--([\s\S]*?)--\}\}/g,""),Z=Z.replace(/<!--[\s\S]*?-->/g,""),Z=Z.replace(/>\s+</g,"><"),Z=Z.replace(/^\s+/gm,""),Z=Z.replace(/\s+$/gm,""),Z=Z.replace(/\s{2,}/g," ");for(let{marker:X,content:Q}of Y){let G=Z.indexOf(X);if(G!==-1)Z=Z.slice(0,G)+Q+Z.slice(G+X.length)}return Z.trim()}function DV($){let Z=new Map,Y=new Map,J=/(['"])([^'"]{10,})\1/g,X;while((X=J.exec($))!==null){let K=X[2];Y.set(K,(Y.get(K)||0)+1)}let Q=0,G=$;for(let[K,W]of Y)if(W>1){let U=`__STR_${Q++}__`;Z.set(U,K);let z=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),_=new RegExp(`(['"])${z}\\1`,"g");G=G.replace(_,U)}return{content:G,pool:Z,count:Z.size}}function kV($,Z={}){let Y={...AV,...Z},J=new Blob([$]).size,X=$,Q=[],G=[],K=[],W=[],U=0;if(Y.target==="production")Y.constants={...Y.constants,__ENV__:"production"};if(Y.deadCodeElimination){let B=TV(X,Y.constants);if(X=B.content,B.removed.length>0)Q.push("Dead code elimination"),G.push(...B.removed.map((q)=>`Removed: ${q}`))}if(Y.constantFolding&&Object.keys(Y.constants).length>0){let B=EV(X,Y.constants);if(X=B.content,W=B.folded,W.length>0)Q.push("Constant folding")}if(Y.treeShake){if(K=NV(X,Y.preserveDirectives),K.length>0)Q.push("Tree shaking")}if(Y.stringPooling){let B=DV(X);if(X=B.content,U=B.count,U>0)Q.push("String pooling")}if(Y.minifyHtml){let B=IV(X);if(B.length<X.length)X=B,Q.push("HTML minification")}let z=new Blob([X]).size,_=J>0?Math.round((1-z/J)*100):0;return{content:X,originalSize:J,optimizedSize:z,reduction:_,appliedOptimizations:Q,removedDirectives:K,foldedConstants:W,pooledStrings:U,warnings:G}}async function tP($,Z={}){let Y={...AV,...Z},J=new Map,X=[],Q=0,G=0,K=new Set;for(let[_,B]of $){let q=kV(B,Y);J.set(_,q),Q+=q.originalSize,G+=q.optimizedSize,X.push(...q.warnings.map((H)=>`${_}: ${H}`));let j=NK(B);for(let H of j)K.add(H.name)}let W;if(Y.treeShake)W=RV(Array.from(K));let U;if(Y.stringPooling)U=new Map;let z=Q>0?Math.round((1-G/Q)*100):0;return{templates:J,directiveBundle:W,stringPool:U,totalOriginalSize:Q,totalOptimizedSize:G,overallReduction:z,warnings:X}}function eP($){return $.charAt(0).toUpperCase()+$.slice(1)}var AV,wV;var SV=D(()=>{AV={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},wV=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"]});var TK={};$0(TK,{toUsers:()=>fV,toUser:()=>vV,stopBroadcasting:()=>yV,startBroadcasting:()=>PV,loadChannels:()=>xV,getBroadcastServer:()=>bV,channel:()=>dV,broadcastPrivate:()=>gV,broadcastPresence:()=>hV,broadcast:()=>MK,BroadcastServer:()=>mV,Broadcast:()=>uV});import{Broadcast as f5,BroadcastServer as $y}from"ts-broadcasting";import{channel as dV}from"ts-broadcasting";import{Broadcast as uV,BroadcastServer as mV}from"ts-broadcasting";function bV(){return g1}async function PV($){if(g1)return g1;let Z=$.driver??"bun",Y=$.host??"0.0.0.0",J=$.port??6001,X=$.scheme??"ws",Q={verbose:$.verbose??!1,driver:Z,default:Z,connections:{[Z]:{driver:Z,host:Y,port:J,scheme:X}}};return g1=new $y(Q),f5.setServer(g1),await g1.start(),g1}async function yV(){for(let $ of RK)clearInterval($);if(RK.length=0,!g1)return;await g1.stop(),g1=null}async function xV($){let Z=await import($),Y=Z.default??Z;if(typeof Y!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof Y}`);let J=0;return Y({channel(Q,G){if(J++,G.authorize&&g1)g1.channels.channel(Q,G.authorize);if(G.interval&&G.data){let K=G.event??`${Q}.updated`,W=G.data,U=setInterval(async()=>{try{let z=await W();MK(Q,K,z)}catch{}},G.interval);RK.push(U)}}}),J}function n8(){if(g1)return!0;if(!CV)CV=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function MK($,Z,Y){if(!n8())return;f5.send($,Z,Y)}function vV($,Z,Y){if(!n8())return;f5.toUser($,Z,Y)}function fV($,Z,Y){if(!n8())return;f5.toUsers($,Z,Y)}function gV($,Z,Y){if(!n8())return;f5.send(`private-${$}`,Z,Y)}function hV($,Z,Y){if(!n8())return;f5.presence($,Z,Y)}var g1=null,RK,CV=!1;var xJ=D(()=>{RK=[]});function lV($,Z){let Y={},J=$.trim();if(J.startsWith("{"))J=J.slice(1);if(J.endsWith("}"))J=J.slice(0,-1);if(J=J.trim(),!J)return Y;let X=0;while(X<J.length){while(X<J.length&&/\s/.test(J[X]))X++;if(X>=J.length)break;let Q="";if(J[X]==='"'||J[X]==="'"){let W=J[X];X++;while(X<J.length&&J[X]!==W)if(J[X]==="\\"&&X+1<J.length)Q+=J[X+1],X+=2;else Q+=J[X],X++;X++}else while(X<J.length&&/[\w$]/.test(J[X]))Q+=J[X],X++;while(X<J.length&&/\s/.test(J[X]))X++;if(J[X]===":")X++;while(X<J.length&&/\s/.test(J[X]))X++;let G,K=X;if(J[X]==='"'||J[X]==="'"){let W=J[X];X++;let U="";while(X<J.length&&J[X]!==W)if(J[X]==="\\"&&X+1<J.length)U+=J[X+1],X+=2;else U+=J[X],X++;X++,G=U}else if(J[X]==="{"){let W=1;X++;while(X<J.length&&W>0){if(J[X]==="{")W++;else if(J[X]==="}")W--;else if(J[X]==='"'||J[X]==="'"){let z=J[X];X++;while(X<J.length&&J[X]!==z){if(J[X]==="\\")X++;X++}}X++}let U=J.slice(K,X);G=lV(U,Z)}else if(J[X]==="["){let W=1;X++;while(X<J.length&&W>0){if(J[X]==="[")W++;else if(J[X]==="]")W--;else if(J[X]==='"'||J[X]==="'"){let z=J[X];X++;while(X<J.length&&J[X]!==z){if(J[X]==="\\")X++;X++}}X++}let U=J.slice(K,X);try{G=JSON.parse(U.replace(/'/g,'"'))}catch{G=U}}else{let W="";while(X<J.length&&J[X]!==","&&!/\s/.test(J[X]))W+=J[X],X++;if(W=W.trim(),W==="true")G=!0;else if(W==="false")G=!1;else if(W==="null")G=null;else if(W==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(W))G=Number(W);else if(W in Z)G=Z[W];else G=W}if(Q)Y[Q]=G;while(X<J.length&&/\s/.test(J[X]))X++;if(J[X]===",")X++}return Y}function Zy($,Z,Y){let J=[];for(let[X,Q]of Object.entries(Z)){let G=$[X];if(Q.required&&(G===void 0||G===null)){J.push(`Component "${Y}": Missing required prop "${X}"`);continue}if(G===void 0||G===null)continue;let K=Array.isArray(Q.type)?Q.type:[Q.type];if(!K.includes("any")){let W=Jy(G);if(!K.includes(W))J.push(`Component "${Y}": Prop "${X}" expected ${K.join(" | ")}, got ${W}`)}if(Q.validator&&!Q.validator(G))J.push(`Component "${Y}": Prop "${X}" failed custom validation`)}return J}function Yy($,Z){let Y={...$};for(let[J,X]of Object.entries(Z))if(Y[J]===void 0&&X.default!==void 0)Y[J]=typeof X.default==="function"?X.default():X.default;return Y}function Jy($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}function Xy(){return[cV]}var cV;var pV=D(()=>{C1();n0();N0();cV={name:"component",handler:async($,Z,Y,J)=>{if(Z.length<1)return H0("Component","component directive requires at least the component name",G0.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),Q={};if(Z.length>1)try{let z=Z.slice(1).join(",").trim();if(z.startsWith("{")){if(Q=i0(z,Y),Object.keys(Q).length===0)Q=lV(z,Y)}else{let _=z.trim(),B=Y[_];if(B&&typeof B==="object"&&!Array.isArray(B))Q=B}}catch(z){let _=z instanceof Error?z.message:String(z);return console.error("Component props parsing error:",_),H0("Component",`Error parsing component props: ${_}`,G0.EVALUATION_ERROR)}let G=Y.__stx_options||{},K=G.componentsDir||"components",W=new Set;if(!Y.__processedComponents)Y.__processedComponents=new Set;let U=Y.__processedComponents;try{return await B4(X,Q,"",K,Y,J,G,U,W)}catch(z){console.error("Component rendering error:",z);let _=z instanceof Error?z.message:String(z);return H0("Component",`Error rendering component: ${_}`,G0.COMPONENT_RENDER_ERROR)}},hasEndTag:!1}});import{mkdir as Qy,readFile as Gy,readdir as Ky,stat as iV,writeFile as Wy}from"fs/promises";import Z4 from"path";function Uy($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function EK($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function zy($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function _y($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function By($){let Z=[];async function Y(J){let X=await Ky(J,{withFileTypes:!0});X.sort((Q,G)=>Q.name.localeCompare(G.name));for(let Q of X){let G=Z4.join(J,Q.name);if(Q.isDirectory()){if(!Q.name.startsWith(".")&&Q.name!=="node_modules")await Y(G)}else if(Q.isFile()&&Q.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(Q.name))Z.push(G)}}return await Y($),Z}function qy($,Z){let Y=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return{};let J=Y[1].trim();if(!J)return{};try{return JSON.parse(J)}catch(X){throw Error(`${Z}: <script component> must contain JSON metadata (${X.message})`)}}function jy($,Z){let Y={},J=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let X of J){if(!/\bclient\b/i.test(X[1])||/\bcomponent\b|\bstx:component\b/i.test(X[1]))continue;let Q;try{Q=new Bun.Transpiler({loader:"ts"}).transformSync(X[2])}catch(W){throw Error(`${Z}: failed to transpile <script client> (${W.message})`)}let G=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,K;while(K=G.exec(Q)){let W=K[1];if(aV.has(W))throw Error(`${Z}: client method "${W}" is reserved`);let U=G.lastIndex,z=1,_="",B=!1,q=U;for(;q<Q.length&&z>0;q++){let H=Q[q];if(B){B=!1;continue}if(_){if(H==="\\")B=!0;else if(H===_)_="";continue}if(H==='"'||H==="'"||H==="`")_=H;else if(H==="{")z++;else if(H==="}")z--}if(z!==0)throw Error(`${Z}: unterminated client function "${W}"`);let j=K[0].includes("async")?"async ":"";Y[W]=`${j}${W}(${K[2]}) {${Q.slice(U,q-1)}}`,G.lastIndex=q}}return Y}function Hy($){let Z=$.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(Z?Z[1]:$).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function nV($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((Z)=>Z[1].trim()).filter(Boolean).join(`
|
|
14500
|
+
`}function MV($,Z={}){let Y=[],J=/@if\(([^)]+)\)[\s\S]*?@endif/g,X=$.matchAll(J);for(let U of X){let z=U[1].trim();if(yJ(z,Z)===!1)Y.push({start:U.index,end:U.index+U[0].length,reason:`@if condition always false: ${z}`})}let Q=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(Q);for(let U of G){let z=U[1].trim();if(yJ(z,Z)===!0)Y.push({start:U.index,end:U.index+U[0].length,reason:`@unless condition always true: ${z}`})}let K=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(Z.__ENV__==="production"){let U=$.matchAll(K);for(let z of U)Y.push({start:z.index,end:z.index+z[0].length,reason:"Development-only code in production build"})}let W=/@debug[\s\S]*?@enddebug/g;if(Z.__ENV__==="production"){let U=$.matchAll(W);for(let z of U)Y.push({start:z.index,end:z.index+z[0].length,reason:"Debug code in production build"})}return Y}function TV($,Z={}){let Y=MV($,Z),J=[];Y.sort((Q,G)=>G.start-Q.start);let X=$;for(let Q of Y)X=X.slice(0,Q.start)+X.slice(Q.end),J.push(Q.reason);return{content:X,removed:J}}function yJ($,Z){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in Z)return Z[$];let Y=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Y){let[,J,X,Q]=Y,G=J in Z?Z[J]:void 0,K=yJ(Q,Z);if(G!==void 0&&K!==void 0)switch(X){case"==":case"===":return G===K;case"!=":case"!==":return G!==K;case">":return G>K;case"<":return G<K;case">=":return G>=K;case"<=":return G<=K}}return}function EV($,Z){let Y=[],J=$;return J=J.replace(/\{\{\s*(\w+)\s*\}\}/g,(X,Q)=>{if(Q in Z)return Y.push(`{{ ${Q} }} -> ${Z[Q]}`),String(Z[Q]);return X}),J=J.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(X,Q,G,K)=>{let W=Number.parseInt(Q,10),U=Number.parseInt(K,10),z;switch(G){case"+":z=W+U;break;case"-":z=W-U;break;case"*":z=W*U;break;default:return X}return Y.push(`{{ ${Q} ${G} ${K} }} -> ${z}`),String(z)}),{content:J,folded:Y}}function IV($){let Z=$,Y=[],J=0;Z=Z.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(X)=>{let Q=`__PRESERVE_${J++}__`;return Y.push({marker:Q,content:X}),Q}),Z=Z.replace(/\{\{([\s\S]*?)\}\}/g,(X)=>{let Q=`__PRESERVE_${J++}__`;return Y.push({marker:Q,content:X}),Q}),Z=Z.replace(/\{\{--([\s\S]*?)--\}\}/g,""),Z=Z.replace(/<!--[\s\S]*?-->/g,""),Z=Z.replace(/>\s+</g,"><"),Z=Z.replace(/^\s+/gm,""),Z=Z.replace(/\s+$/gm,""),Z=Z.replace(/\s{2,}/g," ");for(let{marker:X,content:Q}of Y){let G=Z.indexOf(X);if(G!==-1)Z=Z.slice(0,G)+Q+Z.slice(G+X.length)}return Z.trim()}function DV($){let Z=new Map,Y=new Map,J=/(['"])([^'"]{10,})\1/g,X;while((X=J.exec($))!==null){let K=X[2];Y.set(K,(Y.get(K)||0)+1)}let Q=0,G=$;for(let[K,W]of Y)if(W>1){let U=`__STR_${Q++}__`;Z.set(U,K);let z=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),_=new RegExp(`(['"])${z}\\1`,"g");G=G.replace(_,U)}return{content:G,pool:Z,count:Z.size}}function kV($,Z={}){let Y={...AV,...Z},J=new Blob([$]).size,X=$,Q=[],G=[],K=[],W=[],U=0;if(Y.target==="production")Y.constants={...Y.constants,__ENV__:"production"};if(Y.deadCodeElimination){let B=TV(X,Y.constants);if(X=B.content,B.removed.length>0)Q.push("Dead code elimination"),G.push(...B.removed.map((q)=>`Removed: ${q}`))}if(Y.constantFolding&&Object.keys(Y.constants).length>0){let B=EV(X,Y.constants);if(X=B.content,W=B.folded,W.length>0)Q.push("Constant folding")}if(Y.treeShake){if(K=NV(X,Y.preserveDirectives),K.length>0)Q.push("Tree shaking")}if(Y.stringPooling){let B=DV(X);if(X=B.content,U=B.count,U>0)Q.push("String pooling")}if(Y.minifyHtml){let B=IV(X);if(B.length<X.length)X=B,Q.push("HTML minification")}let z=new Blob([X]).size,_=J>0?Math.round((1-z/J)*100):0;return{content:X,originalSize:J,optimizedSize:z,reduction:_,appliedOptimizations:Q,removedDirectives:K,foldedConstants:W,pooledStrings:U,warnings:G}}async function tP($,Z={}){let Y={...AV,...Z},J=new Map,X=[],Q=0,G=0,K=new Set;for(let[_,B]of $){let q=kV(B,Y);J.set(_,q),Q+=q.originalSize,G+=q.optimizedSize,X.push(...q.warnings.map((H)=>`${_}: ${H}`));let j=NK(B);for(let H of j)K.add(H.name)}let W;if(Y.treeShake)W=RV(Array.from(K));let U;if(Y.stringPooling)U=new Map;let z=Q>0?Math.round((1-G/Q)*100):0;return{templates:J,directiveBundle:W,stringPool:U,totalOriginalSize:Q,totalOptimizedSize:G,overallReduction:z,warnings:X}}function eP($){return $.charAt(0).toUpperCase()+$.slice(1)}var AV,wV;var SV=D(()=>{AV={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},wV=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"]});var TK={};$0(TK,{toUsers:()=>fV,toUser:()=>vV,stopBroadcasting:()=>yV,startBroadcasting:()=>PV,loadChannels:()=>xV,getBroadcastServer:()=>bV,channel:()=>dV,broadcastPrivate:()=>gV,broadcastPresence:()=>hV,broadcast:()=>MK,BroadcastServer:()=>mV,Broadcast:()=>uV});import{Broadcast as f5,BroadcastServer as $y}from"ts-broadcasting";import{channel as dV}from"ts-broadcasting";import{Broadcast as uV,BroadcastServer as mV}from"ts-broadcasting";function bV(){return g1}async function PV($){if(g1)return g1;let Z=$.driver??"bun",Y=$.host??"0.0.0.0",J=$.port??6001,X=$.scheme??"ws",Q={verbose:$.verbose??!1,driver:Z,default:Z,connections:{[Z]:{driver:Z,host:Y,port:J,scheme:X}}};return g1=new $y(Q),f5.setServer(g1),await g1.start(),g1}async function yV(){for(let $ of RK)clearInterval($);if(RK.length=0,!g1)return;await g1.stop(),g1=null}async function xV($){let Z=await import($),Y=Z.default??Z;if(typeof Y!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof Y}`);let J=0;return Y({channel(Q,G){if(J++,G.authorize&&g1)g1.channels.channel(Q,G.authorize);if(G.interval&&G.data){let K=G.event??`${Q}.updated`,W=G.data,U=setInterval(async()=>{try{let z=await W();MK(Q,K,z)}catch{}},G.interval);RK.push(U)}}}),J}function n8(){if(g1)return!0;if(!CV)CV=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function MK($,Z,Y){if(!n8())return;f5.send($,Z,Y)}function vV($,Z,Y){if(!n8())return;f5.toUser($,Z,Y)}function fV($,Z,Y){if(!n8())return;f5.toUsers($,Z,Y)}function gV($,Z,Y){if(!n8())return;f5.send(`private-${$}`,Z,Y)}function hV($,Z,Y){if(!n8())return;f5.presence($,Z,Y)}var g1=null,RK,CV=!1;var xJ=D(()=>{RK=[]});function lV($,Z){let Y={},J=$.trim();if(J.startsWith("{"))J=J.slice(1);if(J.endsWith("}"))J=J.slice(0,-1);if(J=J.trim(),!J)return Y;let X=0;while(X<J.length){while(X<J.length&&/\s/.test(J[X]))X++;if(X>=J.length)break;let Q="";if(J[X]==='"'||J[X]==="'"){let W=J[X];X++;while(X<J.length&&J[X]!==W)if(J[X]==="\\"&&X+1<J.length)Q+=J[X+1],X+=2;else Q+=J[X],X++;X++}else while(X<J.length&&/[\w$]/.test(J[X]))Q+=J[X],X++;while(X<J.length&&/\s/.test(J[X]))X++;if(J[X]===":")X++;while(X<J.length&&/\s/.test(J[X]))X++;let G,K=X;if(J[X]==='"'||J[X]==="'"){let W=J[X];X++;let U="";while(X<J.length&&J[X]!==W)if(J[X]==="\\"&&X+1<J.length)U+=J[X+1],X+=2;else U+=J[X],X++;X++,G=U}else if(J[X]==="{"){let W=1;X++;while(X<J.length&&W>0){if(J[X]==="{")W++;else if(J[X]==="}")W--;else if(J[X]==='"'||J[X]==="'"){let z=J[X];X++;while(X<J.length&&J[X]!==z){if(J[X]==="\\")X++;X++}}X++}let U=J.slice(K,X);G=lV(U,Z)}else if(J[X]==="["){let W=1;X++;while(X<J.length&&W>0){if(J[X]==="[")W++;else if(J[X]==="]")W--;else if(J[X]==='"'||J[X]==="'"){let z=J[X];X++;while(X<J.length&&J[X]!==z){if(J[X]==="\\")X++;X++}}X++}let U=J.slice(K,X);try{G=JSON.parse(U.replace(/'/g,'"'))}catch{G=U}}else{let W="";while(X<J.length&&J[X]!==","&&!/\s/.test(J[X]))W+=J[X],X++;if(W=W.trim(),W==="true")G=!0;else if(W==="false")G=!1;else if(W==="null")G=null;else if(W==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(W))G=Number(W);else if(W in Z)G=Z[W];else G=W}if(Q)Y[Q]=G;while(X<J.length&&/\s/.test(J[X]))X++;if(J[X]===",")X++}return Y}function Zy($,Z,Y){let J=[];for(let[X,Q]of Object.entries(Z)){let G=$[X];if(Q.required&&(G===void 0||G===null)){J.push(`Component "${Y}": Missing required prop "${X}"`);continue}if(G===void 0||G===null)continue;let K=Array.isArray(Q.type)?Q.type:[Q.type];if(!K.includes("any")){let W=Jy(G);if(!K.includes(W))J.push(`Component "${Y}": Prop "${X}" expected ${K.join(" | ")}, got ${W}`)}if(Q.validator&&!Q.validator(G))J.push(`Component "${Y}": Prop "${X}" failed custom validation`)}return J}function Yy($,Z){let Y={...$};for(let[J,X]of Object.entries(Z))if(Y[J]===void 0&&X.default!==void 0)Y[J]=typeof X.default==="function"?X.default():X.default;return Y}function Jy($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}function Xy(){return[cV]}var cV;var pV=D(()=>{C1();n0();N0();cV={name:"component",handler:async($,Z,Y,J)=>{if(Z.length<1)return H0("Component","component directive requires at least the component name",G0.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),Q={};if(Z.length>1)try{let z=Z.slice(1).join(",").trim();if(z.startsWith("{")){if(Q=i0(z,Y),Object.keys(Q).length===0)Q=lV(z,Y)}else{let _=z.trim(),B=Y[_];if(B&&typeof B==="object"&&!Array.isArray(B))Q=B}}catch(z){let _=z instanceof Error?z.message:String(z);return console.error("Component props parsing error:",_),H0("Component",`Error parsing component props: ${_}`,G0.EVALUATION_ERROR)}let G=Y.__stx_options||{},K=G.componentsDir||"components",W=new Set;if(!Y.__processedComponents)Y.__processedComponents=new Set;let U=Y.__processedComponents;try{return await B4(X,Q,"",K,Y,J,G,U,W)}catch(z){console.error("Component rendering error:",z);let _=z instanceof Error?z.message:String(z);return H0("Component",`Error rendering component: ${_}`,G0.COMPONENT_RENDER_ERROR)}},hasEndTag:!1}});import{mkdir as Qy,readFile as Gy,readdir as Ky,stat as iV,writeFile as Wy}from"fs/promises";import Z4 from"path";function Uy($){return $.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function EK($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function zy($){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test($)&&!$.startsWith("xml")&&!/[A-Z]/.test($)}function _y($){if($===!0)return"open";if($==="open"||$==="closed")return $;return!1}async function By($){let Z=[];async function Y(J){let X=await Ky(J,{withFileTypes:!0});X.sort((Q,G)=>Q.name.localeCompare(G.name));for(let Q of X){let G=Z4.join(J,Q.name);if(Q.isDirectory()){if(!Q.name.startsWith(".")&&Q.name!=="node_modules")await Y(G)}else if(Q.isFile()&&Q.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(Q.name))Z.push(G)}}return await Y($),Z}function qy($,Z){let Y=$.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return{};let J=Y[1].trim();if(!J)return{};try{return JSON.parse(J)}catch(X){throw Error(`${Z}: <script component> must contain JSON metadata (${X.message})`)}}function jy($,Z){let Y={},J=[...$.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let X of J){if(!/\bclient\b/i.test(X[1])||/\bcomponent\b|\bstx:component\b/i.test(X[1]))continue;let Q;try{Q=new Bun.Transpiler({loader:"ts"}).transformSync(X[2])}catch(W){throw Error(`${Z}: failed to transpile <script client> (${W.message})`)}let G=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,K;while(K=G.exec(Q)){let W=K[1];if(sV.has(W))throw Error(`${Z}: client method "${W}" is reserved`);let U=G.lastIndex,z=1,_="",B=!1,q=U;for(;q<Q.length&&z>0;q++){let H=Q[q];if(B){B=!1;continue}if(_){if(H==="\\")B=!0;else if(H===_)_="";continue}if(H==='"'||H==="'"||H==="`")_=H;else if(H==="{")z++;else if(H==="}")z--}if(z!==0)throw Error(`${Z}: unterminated client function "${W}"`);let j=K[0].includes("async")?"async ":"";Y[W]=`${j}${W}(${K[2]}) {${Q.slice(U,q-1)}}`,G.lastIndex=q}}return Y}function Hy($){let Z=$.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(Z?Z[1]:$).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function nV($){return[...$.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((Z)=>Z[1].trim()).filter(Boolean).join(`
|
|
14484
14501
|
|
|
14485
14502
|
`)}function Oy($){let Z=new Set;return{template:$.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([A-Za-z_$][\w$]*)\3/gi,(J,X,Q,G,K)=>{let W=X.toLowerCase();Z.add(W);let U=(Q||"").split(".").filter(Boolean).join(" ");return` data-stx-on-${W}="${K}"${U?` data-stx-mod-${W}="${U}"`:""}`}),eventTypes:[...Z].sort()}}function Ly($){let Z=[];return{template:$.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(J,X,Q,G)=>{let K=Z.length;return Z.push({id:K,name:X,expression:G}),` data-stx-bind-${K}=""`}),bindings:Z}}function Vy($){let Z=new Set;for(let Y of $.matchAll(/<slot\b([^>]*)>/gi))Z.add(Y[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...Z].map((Y)=>({name:Y}))}function Fy($){return[...new Set([...$.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((Z)=>Z[1]))].sort().map((Z)=>({name:Z}))}function Ay($,Z){if(!Z||!new Set(["string","number","boolean","object","array"]).has(Z.type))throw Error(`Property "${$}" must declare one of: string, number, boolean, object, array`);return{...Z,reflect:Z.reflect??Z.attribute!==!1}}async function wy($,Z,Y){let J=Z4.isAbsolute(Z.file)?Z.file:Z4.resolve($,Z.file),X=await Gy(J,"utf8"),Q=qy(X,J),G=Z4.basename(J,".stx"),K=Z.name||Q.name||Uy(G),W=`${EK(Y.prefix||"stx")}-${EK(G)}`,U=Z.tag||Q.tag||W;if(!K||!/^[A-Za-z_$][\w$]*$/.test(K))throw Error(`${J}: invalid component class name "${K}"`);if(!zy(U))throw Error(`${J}: invalid custom-element tag "${U}"; tags must be lowercase and contain a hyphen`);let z=Z.properties||Q.properties||Q.props||{},_=Object.fromEntries(Object.entries(z).map(([V,L])=>[V,Ay(V,L)])),B=Oy(Hy(X)),q=Ly(B.template),j=Q.methods||{},H=Z.methods||{},O=jy(X,J);return{file:Z4.relative($,J),sourcePath:J,name:K,tag:U,description:Z.description||Q.description||"",template:q.template,styles:nV(X),shadowMode:_y(Z.shadowDOM??Q.shadowDOM??Y.shadowDOM),progressive:Z.progressive??Q.progressive??Y.progressive??!0,properties:_,events:Z.events||Q.events||{},methods:{...j,...H,...O},eventTypes:B.eventTypes,bindings:q.bindings,slots:Vy(q.template),cssProperties:Fy(nV(X))}}function Ny(){let $=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),Z=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`const HTMLElementBase = globalThis.HTMLElement || class {};
|
|
14486
14503
|
|
|
@@ -14732,7 +14749,7 @@ export function defineComponent(Component, definition) {
|
|
|
14732
14749
|
}
|
|
14733
14750
|
return Component;
|
|
14734
14751
|
}
|
|
14735
|
-
`}function Ry($){let Z=JSON.stringify({tag:$.tag,template:$.template,styles:$.styles,shadowMode:$.shadowMode,progressive:$.progressive,properties:$.properties,eventTypes:$.eventTypes,bindings:$.bindings},null,2),Y=Object.entries($.methods).map(([J,X])=>{if(
|
|
14752
|
+
`}function Ry($){let Z=JSON.stringify({tag:$.tag,template:$.template,styles:$.styles,shadowMode:$.shadowMode,progressive:$.progressive,properties:$.properties,eventTypes:$.eventTypes,bindings:$.bindings},null,2),Y=Object.entries($.methods).map(([J,X])=>{if(sV.has(J))throw Error(`${$.sourcePath}: method "${J}" is reserved`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(X.trim()))return` ${X.trim()}`;return` ${J}($event) {
|
|
14736
14753
|
${X}
|
|
14737
14754
|
}`}).join(`
|
|
14738
14755
|
|
|
@@ -14793,7 +14810,7 @@ ${X}
|
|
|
14793
14810
|
export {}
|
|
14794
14811
|
`}function Ey($){return{schemaVersion:"1.0.0",modules:$.map((Z)=>({kind:"javascript-module",path:`./${Z.tag}.js`,declarations:[{kind:"class",name:Z.name,description:Z.description||void 0,customElement:!0,tagName:Z.tag,members:Object.entries(Z.properties).map(([Y,J])=>({kind:"field",name:Y,description:J.description,type:{text:vJ(J)},default:J.default===void 0?void 0:JSON.stringify(J.default),attribute:J.attribute===!1?void 0:J.attribute||EK(Y),reflects:J.reflect})),events:Object.entries(Z.events).map(([Y,J])=>({name:Y,description:J.description,type:{text:`CustomEvent<${J.detailType||"unknown"}>`}})),slots:Z.slots,cssProperties:Z.cssProperties}],exports:[{kind:"js",name:Z.name,declaration:{name:Z.name,module:`./${Z.tag}.js`}}]}))}}function rV($){if(!$.styles)return"";let Z=$.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(Z))return Z;return`@scope (${$.tag}) {
|
|
14795
14812
|
${Z}
|
|
14796
|
-
}`}function
|
|
14813
|
+
}`}function aV($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Iy($){let Z=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),Y=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),J=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),X=Object.fromEntries($.map((G)=>[G.tag,{template:G.template,styles:G.styles,shadowMode:G.shadowMode,properties:G.properties}])),Q=$.map((G)=>`export const render${G.name} = (props = {}, slots = {}) => renderComponent('${G.tag}', props, slots);`).join(`
|
|
14797
14814
|
`);return`const definitions = ${JSON.stringify(X,null,2)};
|
|
14798
14815
|
const escapeHTML = (value) => String(value ?? '')
|
|
14799
14816
|
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
@@ -14829,7 +14846,7 @@ export function renderComponent(tag, props = {}, slots = {}) {
|
|
|
14829
14846
|
${Q}
|
|
14830
14847
|
`}async function IK($){let Z=Z4.resolve($.inputDir),Y=Z4.resolve($.outputDir);if(!(await iV(Z).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${Z}`);let X=$.components?.length?$.components:(await By(Z)).map((H)=>({file:H}));if(!X.length)throw Error(`No .stx components found in ${Z}`);let Q=await Promise.all(X.map((H)=>wy(Z,H,$)));Q.sort((H,O)=>H.tag.localeCompare(O.tag));let G=Q.filter((H,O)=>Q.findIndex((V)=>V.tag===H.tag)!==O);if(G.length)throw Error(`Duplicate custom-element tag: ${G[0].tag}`);let K=Q.filter((H,O)=>Q.findIndex((V)=>V.name===H.name)!==O);if(K.length)throw Error(`Duplicate component class name: ${K[0].name}`);await Qy(Y,{recursive:!0});let W=[],U=async(H,O)=>{let V=Z4.join(Y,H);return await Wy(V,O.endsWith(`
|
|
14831
14848
|
`)?O:`${O}
|
|
14832
|
-
`,"utf8"),W.push(V),V};await U("runtime.js",Ny());for(let H of Q){if(await U(`${H.tag}.js`,Ry(H)),$.declarations!==!1)await U(`${H.tag}.d.ts`,My(H));if($.css!==!1&&H.styles){let O=H.shadowMode?H.styles:rV(H);await U(`${H.tag}.css`,$.minify?
|
|
14849
|
+
`,"utf8"),W.push(V),V};await U("runtime.js",Ny());for(let H of Q){if(await U(`${H.tag}.js`,Ry(H)),$.declarations!==!1)await U(`${H.tag}.d.ts`,My(H));if($.css!==!1&&H.styles){let O=H.shadowMode?H.styles:rV(H);await U(`${H.tag}.css`,$.minify?aV(O):O)}}let z=Q.map((H)=>`export { ${H.name}, default as ${H.name}Element } from './${H.tag}.js';`).join(`
|
|
14833
14850
|
`);if(await U("index.js",z),await U("ssr.js",Iy(Q)),$.declarations!==!1)await U("index.d.ts",Q.map((H)=>`export * from './${H.tag}.js'`).join(`
|
|
14834
14851
|
`)),await U("custom-elements.d.ts",Ty(Q)),await U("ssr.d.ts",`${Q.map((H)=>`export declare const render${H.name}: (props?: ${H.name}Props, slots?: Record<string, string>) => string`).join(`
|
|
14835
14852
|
`)}
|
|
@@ -14837,11 +14854,11 @@ export declare function renderComponent(tag: string, props?: Record<string, unkn
|
|
|
14837
14854
|
${Q.map((H)=>`import type { ${H.name}Props } from './${H.tag}.js'`).join(`
|
|
14838
14855
|
`)}`);let _;if($.manifest!==!1)_=await U("custom-elements.json",JSON.stringify(Ey(Q),null,2));let B;if($.css!==!1){let H=Q.filter((O)=>!O.shadowMode&&O.styles).map(rV).join(`
|
|
14839
14856
|
|
|
14840
|
-
`);if(H)B=await U("bundle.css",$.minify?
|
|
14857
|
+
`);if(H)B=await U("bundle.css",$.minify?aV(H):H)}let q;if($.bundle!==!1){q=Z4.join(Y,"bundle.js");let H;try{H=await Bun.build({entrypoints:[Z4.join(Y,"index.js")],outdir:Y,naming:"bundle.js",target:"browser",format:"esm",minify:$.minify??!0,sourcemap:$.sourcemap||"none"})}catch(O){let V=O instanceof AggregateError?O.errors:[O],L=V.map((F)=>String(F).trim()).filter(Boolean).join(`
|
|
14841
14858
|
`);throw AggregateError(V,`Failed to bundle component library${L?`
|
|
14842
14859
|
${L}`:""}`)}if(!H.success){let O=H.logs.map((V)=>String(V).trim()).filter(Boolean).join(`
|
|
14843
14860
|
`);throw AggregateError(H.logs,`Failed to bundle component library${O?`
|
|
14844
|
-
${O}`:""}`)}if(W.push(q),$.sourcemap==="external")W.push(`${q}.map`)}let j=await Promise.all(W.map(async(H)=>(await iV(H)).size));return{components:Q.map((H)=>({name:H.name,tag:H.tag,source:H.sourcePath,module:Z4.join(Y,`${H.tag}.js`)})),files:W,manifest:_,bundle:q,cssBundle:B,totalBytes:j.reduce((H,O)=>H+O,0)}}var
|
|
14861
|
+
${O}`:""}`)}if(W.push(q),$.sourcemap==="external")W.push(`${q}.map`)}let j=await Promise.all(W.map(async(H)=>(await iV(H)).size));return{components:Q.map((H)=>({name:H.name,tag:H.tag,source:H.sourcePath,module:Z4.join(Y,`${H.tag}.js`)})),files:W,manifest:_,bundle:q,cssBundle:B,totalBytes:j.reduce((H,O)=>H+O,0)}}var sV;var DK=D(()=>{sV=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"])});import kK from"fs";import r8 from"path";async function oV($){try{let Y=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return[];let J=Y[1],X=[],Q=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=Q.exec(J))!==null){let K=G[1],W=G[2]||G[3]||G[4];if(!W)continue;let U={name:W},z=K.match(/@type\s+\{([^}]+)\}/i);if(z)U.type=z[1].trim();if(K.match(/@required/i))U.required=!0;let B=K.match(/@default\s+(.+?)(?:\s+|$)/i);if(B)U.default=B[1].trim();let q=K.split(`
|
|
14845
14862
|
`).map((j)=>j.trim().replace(/^\*\s*/,"")).filter((j)=>!j.startsWith("@")&&j.length>0);U.description=q.join(" ").trim(),X.push(U)}if(X.length===0){let K=J.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(K){let U=K[1].split(",").map((z)=>z.trim()).filter(Boolean);for(let z of U){let[_]=z.split(":").map((B)=>B.trim());if(_)X.push({name:_})}}}return X}catch(Z){return console.error(`Error extracting props from ${$}:`,Z),[]}}async function tV($){try{let Z=await Bun.file($).text(),Y=Z.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||Z.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Y)return Y[1].split(`
|
|
14846
14863
|
`).map((J)=>J.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function eV($,Z=!1,Y){let J=r8.basename($,".stx"),X=await oV($),Q=await tV($),G="";if(Z&&Y)G=`<${Y}></${Y}>`;else{let K=X.map((W)=>{if(W.type==="boolean")return`:${W.name}="true"`;return`${W.name}="value"`}).join(`
|
|
14847
14864
|
`);G=`<${J}
|
|
@@ -14980,7 +14997,7 @@ ${O}`:""}`)}if(W.push(q),$.sourcemap==="external")W.push(`${q}.map`)}let j=await
|
|
|
14980
14997
|
<td>@${Q.name}</td>
|
|
14981
14998
|
<td>${Q.description||"-"}</td>
|
|
14982
14999
|
<td>${Q.hasEndTag?"Yes":"No"}</td>
|
|
14983
|
-
</tr>`;X+="</tbody></table>";for(let Q of Y)if(Q.example)X+=`<h3>@${Q.name}</h3>`,X+=`<p>${Q.description||""}</p>`,X+="<h4>Example</h4>",X+=`<pre><code>${Q.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return X+="</body></html>",X}function QF($=[],Z=[],Y=[],J){return JSON.stringify({components:$,templates:Z,directives:Y,extraContent:J||""},null,2)}async function GF($){try{let{componentsDir:Z,templatesDir:Y,webComponentsConfig:J,customDirectives:X,config:Q}=$;if(!Q.enabled)return!1;let G=Q.outputDir||"docs";if(await kK.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),Z)console.log(`Components directory: ${Z}`);if(Y)console.log(`Templates directory: ${Y}`);console.log(`Output directory: ${G}`);let K=[];if(Q.components!==!1&&Z)console.log("Generating component documentation..."),K=await $F(Z,J),console.log(`Found ${K.length} components`);let W=[];if(Q.templates!==!1&&Y)console.log("Generating template documentation..."),W=await ZF(Y),console.log(`Found ${W.length} templates`);let U=[];if(Q.directives!==!1)console.log("Generating directive documentation..."),U=await YF(X),console.log(`Found ${U.length} directives`);let z=Q.format||"markdown",_=Q.extraContent,B="",q="";switch(z){case"markdown":B=JF(K,W,U,_),q="md";break;case"html":B=XF(K,W,U,_),q="html";break;case"json":B=QF(K,W,U,_),q="json";break;default:throw Error(`Unsupported documentation format: ${z}`)}let j=r8.join(G,`stx-docs.${q}`);return await Bun.write(j,B),console.log(`Documentation generated: ${j}`),!0}catch(Z){return console.error("Error generating documentation:",Z),!1}}async function CK($){let Z={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Y=$.componentsDir||T1.componentsDir,J=$.templatesDir||".";return GF({componentsDir:Y,templatesDir:J,webComponentsConfig:T1.webComponents,customDirectives:T1.customDirectives,config:Z})}var bK=D(()=>{r0();N0()});import g5 from"process";function h5(){if(typeof globalThis<"u"&&"caches"in globalThis&&"CF"in globalThis)return{platform:"cloudflare",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","r2","d1","durable-objects","queues"]};if(typeof globalThis<"u"&&"Deno"in globalThis)return{platform:"deno",version:globalThis.Deno.version?.deno,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","deploy","ffi"]};if(typeof globalThis<"u"&&"Bun"in globalThis)return{platform:"bun",version:globalThis.Bun.version,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["sqlite","ffi","native-modules"]};if(typeof globalThis<"u"&&"EdgeRuntime"in globalThis)return{platform:"vercel",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["edge-config","blob"]};if(typeof globalThis<"u"&&"Netlify"in globalThis)return{platform:"netlify",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!1,capabilities:["blobs","edge-functions"]};if(typeof globalThis<"u"&&"fastly"in globalThis)return{platform:"fastly",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["dictionary","backend","geolocation"]};if(g5.versions?.node)return{platform:"node",version:g5.versions.node,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["fs","child-process","native-modules"]};return{platform:"unknown",supportsStreaming:!1,supportsCrypto:!1,supportsKV:!1,supportsCache:!1,capabilities:[]}}function Dy(){let $=h5();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function ky(){return h5().platform!=="unknown"}function WF($){return{get(Z){if($&&Z in $){let Y=$[Z];return typeof Y==="string"?Y:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(Z);if(g5.env)return g5.env[Z];return},getOrThrow(Z){let Y=this.get(Z);if(Y===void 0)throw Error(`Environment variable "${Z}" is not set`);return Y},has(Z){return this.get(Z)!==void 0},all(){let Z={};if($){for(let[Y,J]of Object.entries($))if(typeof J==="string")Z[Y]=J}if(typeof globalThis<"u"&&"Deno"in globalThis){let Y=globalThis.Deno.env.toObject();Object.assign(Z,Y)}if(g5.env){for(let[Y,J]of Object.entries(g5.env))if(J!==void 0)Z[Y]=J}return Z}}}function UF($){let Z=h5();if(Z.platform==="cloudflare"&&$)return $;if(Z.platform==="deno"&&"Deno"in globalThis)return Sy();if(Z.platform==="node"||Z.platform==="bun")return Cy();return}function Sy(){let $=null,Z=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Y){return(await(await Z()).get(["stx",Y])).value},async getWithMetadata(Y){let J=await Z(),X=await J.get(["stx",Y]),Q=await J.get(["stx-meta",Y]);return{value:X.value,metadata:Q.value}},async put(Y,J,X){let Q=await Z(),G=X?.expirationTtl?X.expirationTtl*1000:void 0;if(await Q.set(["stx",Y],J,G?{expireIn:G}:void 0),X?.metadata)await Q.set(["stx-meta",Y],X.metadata,G?{expireIn:G}:void 0)},async delete(Y){let J=await Z();await J.delete(["stx",Y]),await J.delete(["stx-meta",Y])},async list(Y){let J=await Z(),X=Y?.prefix?["stx",Y.prefix]:["stx"],Q=J.list({prefix:X,limit:Y?.limit||100}),G=[];for await(let K of Q){let U=K.key.slice(1).join("/");if(!U.startsWith("stx-meta/"))G.push({name:U})}return{keys:G,list_complete:!0}}}}function Cy(){let $=new Map,Z=()=>{let Y=Date.now();for(let[J,X]of $.entries())if(X.expiration&&X.expiration<Y)$.delete(J)};return{async get(Y){Z();let J=$.get(Y);if(!J)return null;if(J.expiration&&J.expiration<Date.now())return $.delete(Y),null;return J.value},async getWithMetadata(Y){Z();let J=$.get(Y);if(!J)return{value:null,metadata:null};if(J.expiration&&J.expiration<Date.now())return $.delete(Y),{value:null,metadata:null};return{value:J.value,metadata:J.metadata||null}},async put(Y,J,X){let Q=X?.expiration?X.expiration*1000:X?.expirationTtl?Date.now()+X.expirationTtl*1000:void 0;$.set(Y,{value:J,metadata:X?.metadata,expiration:Q})},async delete(Y){$.delete(Y)},async list(Y){Z();let J=[];for(let[X,Q]of $.entries()){if(Y?.prefix&&!X.startsWith(Y.prefix))continue;if(J.push({name:X,expiration:Q.expiration,metadata:Q.metadata}),Y?.limit&&J.length>=Y.limit)break}return{keys:J,list_complete:!0}}}}function zF(){let $=h5();if($.platform==="cloudflare"&&"caches"in globalThis)return by();if($.supportsStreaming)return Py();return}function by(){return{async match($){return(await caches.default).match($)},async put($,Z){await(await caches.default).put($,Z.clone())},async delete($){return(await caches.default).delete($)}}}function Py(){let $=new Map,Z=60000;return{async match(Y){let J=Y.url,X=$.get(J);if(!X)return;if(Date.now()>X.expiration){$.delete(J);return}return X.response.clone()},async put(Y,J){let X=Y.url,Q=J.headers.get("Cache-Control"),G=60000;if(Q){let K=Q.match(/max-age=(\d+)/);if(K)G=Number.parseInt(K[1],10)*1000}$.set(X,{response:J.clone(),expiration:Date.now()+G})},async delete(Y){return $.delete(Y.url)}}}function yy(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function xy($,Z){if(Z.platform==="cloudflare"){let Y=$.cf;if(Y)return{city:Y.city,country:Y.country,countryCode:Y.country,region:Y.region,latitude:Y.latitude?Number.parseFloat(Y.latitude):void 0,longitude:Y.longitude?Number.parseFloat(Y.longitude):void 0,timezone:Y.timezone}}if(Z.platform==="vercel"){let Y={},J=$.headers.get("x-vercel-ip-city"),X=$.headers.get("x-vercel-ip-country"),Q=$.headers.get("x-vercel-ip-country-region"),G=$.headers.get("x-vercel-ip-latitude"),K=$.headers.get("x-vercel-ip-longitude");if(J)Y.city=decodeURIComponent(J);if(X)Y.countryCode=X;if(Q)Y.region=Q;if(G)Y.latitude=Number.parseFloat(G);if(K)Y.longitude=Number.parseFloat(K);return Object.keys(Y).length>0?Y:void 0}if(Z.platform==="netlify"){let Y={},J=$.headers.get("x-nf-geo-city"),X=$.headers.get("x-nf-geo-country");if(J)Y.city=J;if(X)Y.countryCode=X;return Object.keys(Y).length>0?Y:void 0}return}function PK($,Z,Y){let J=new Headers($.headers);if(Z.origins==="*")J.set("Access-Control-Allow-Origin","*");else if(Z.origins&&Y&&Z.origins.includes(Y))J.set("Access-Control-Allow-Origin",Y),J.set("Vary","Origin");if(Z.methods)J.set("Access-Control-Allow-Methods",Z.methods.join(", "));if(Z.headers)J.set("Access-Control-Allow-Headers",Z.headers.join(", "));if(Z.exposeHeaders)J.set("Access-Control-Expose-Headers",Z.exposeHeaders.join(", "));if(Z.credentials)J.set("Access-Control-Allow-Credentials","true");if(Z.maxAge)J.set("Access-Control-Max-Age",String(Z.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:J})}function s8($){let Z=h5();return async(Y,J)=>{let X=performance.now(),Q=yy(),G={runtime:Z,platform:J||{},requestId:Q,geo:xy(Y,Z),timing:{start:X,getElapsed:()=>performance.now()-X},kv:UF(J?.KV),cache:zF(),env:WF(J?.env)};try{if(Y.method==="OPTIONS"&&$.cors){let W=new Response(null,{status:204});return W=PK(W,$.cors,Y.headers.get("Origin")||void 0),W}if($.cache?.enabled&&Y.method==="GET"&&G.cache){if(KF(Y,$.cache)){let U=await G.cache.match(Y);if(U){let z=new Response(U.body,U);return z.headers.set("X-Cache","HIT"),z.headers.set("X-Request-Id",Q),$.cors?PK(z,$.cors,Y.headers.get("Origin")||void 0):z}}}let K;if($.middleware&&$.middleware.length>0)K=await vy(Y,G,$.middleware,async()=>{let W=await $.render(Y,G);return typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W});else{let W=await $.render(Y,G);K=typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W}if(K.headers.set("X-Request-Id",Q),K.headers.set("X-Response-Time",`${G.timing.getElapsed().toFixed(2)}ms`),$.cache?.enabled&&Y.method==="GET"&&G.cache){if(KF(Y,$.cache)&&K.status===200){let U=$.cache.ttl||60,z=K.clone();z.headers.set("Cache-Control",`public, max-age=${U}`),await G.cache.put(Y,z),K.headers.set("X-Cache","MISS")}}if($.cors)K=PK(K,$.cors,Y.headers.get("Origin")||void 0);return K}catch(K){let W=K instanceof Error?K:Error(String(K));if($.onError)return $.onError(W,Y);return new Response(`Internal Server Error: ${W.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":Q}})}}}function KF($,Z){let J=new URL($.url).pathname;if(Z.excludePaths){for(let X of Z.excludePaths)if(X.test(J))return!1}if(Z.includePaths){for(let X of Z.includePaths)if(X.test(J))return!0;return!1}return!0}async function vy($,Z,Y,J){let X=0,Q=async()=>{if(X>=Y.length)return J();let G=Y[X];return X++,G($,Z,Q)};return Q()}function fy($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","text/html; charset=utf-8"),Y.set("Transfer-Encoding","chunked"),new Response($,{...Z,headers:Y})}function gy(){let $=new TextEncoder;return new TransformStream({transform(Z,Y){Y.enqueue($.encode(Z))}})}function hy($){let Z=new TextEncoder;return new ReadableStream({async start(Y){for await(let J of $)Y.enqueue(Z.encode(J));Y.close()}})}function dy($){let Z=s8($);return{async fetch(Y,J,X){return Z(Y,{env:J,ctx:X,KV:J.KV})}}}function uy($){let Z=s8($);return(Y)=>Z(Y,{})}function my($){let Z=s8($);return(Y)=>Z(Y,{})}function ly($){let Z=s8($);return(Y,J)=>{return Z(Y,{netlifyContext:J})}}function cy($){let Z=$.headers.get("Cookie");if(!Z)return{};let Y={};for(let J of Z.split(";")){let[X,Q]=J.split("=").map((G)=>G.trim());if(X&&Q)Y[X]=decodeURIComponent(Q)}return Y}function py($,Z,Y){let J=`${encodeURIComponent($)}=${encodeURIComponent(Z)}`;if(Y?.maxAge!==void 0)J+=`; Max-Age=${Y.maxAge}`;if(Y?.expires)J+=`; Expires=${Y.expires.toUTCString()}`;if(Y?.path)J+=`; Path=${Y.path}`;if(Y?.domain)J+=`; Domain=${Y.domain}`;if(Y?.secure)J+="; Secure";if(Y?.httpOnly)J+="; HttpOnly";if(Y?.sameSite)J+=`; SameSite=${Y.sameSite}`;return J}function iy($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...Z,headers:Y})}function ny($,Z=302){return new Response(null,{status:Z,headers:{Location:$}})}function ry($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var _F=()=>{};var VF={};$0(VF,{captureScreenshots:()=>LF,captureScreenshot:()=>xK});var{WebView:sy}=globalThis.Bun;import{existsSync as jF,mkdirSync as HF,readdirSync as ay,statSync as OF}from"fs";import d5 from"path";function oy($){if(/^https?:\/\//.test($)||$.startsWith("file://"))return $;return`file://${d5.resolve($)}`}function BF($,Z,Y,J){return new Promise((X)=>{let Q=!1,G,K,W=()=>{if(!Q){if(Q=!0,clearTimeout(K),G)clearTimeout(G);$.onNavigated=void 0,X()}};K=setTimeout(W,J),$.onNavigated=()=>{if(!Q)G=setTimeout(W,Y)};try{let U=$.navigate(Z);if(U&&typeof U.catch==="function")U.catch(W)}catch{W()}})}async function qF($,Z,Y){let J=`!!document.querySelector(${JSON.stringify(Z)})`,X=Date.now()+Y;while(Date.now()<X){try{if(await $.evaluate(J))return}catch{}await new Promise((Q)=>setTimeout(Q,100))}}async function ty($){try{let Z=await $.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof Z==="number"&&Number.isFinite(Z)&&Z>0?Math.min(Z,yK):0}catch{return 0}}async function xK($,Z,Y={}){let J=Math.min(Y.width??1440,yK),X=Math.min(Y.height??2200,yK),Q=Y.waitMs??800,G=Y.timeoutMs??15000,K=Y.format??"png",W=oy($),U=(_)=>new sy({width:J,height:_,headless:!0,...Y.backend?{backend:Y.backend}:{}}),z=U(X);try{if(await BF(z,W,Q,G),Y.waitSelector)await qF(z,Y.waitSelector,G);if(Y.fullPage){let B=await ty(z);if(B>X){if(z.close(),z=U(B),await BF(z,W,Q,G),Y.waitSelector)await qF(z,Y.waitSelector,G)}}let _=await z.screenshot({encoding:"buffer",format:K});HF(d5.dirname(d5.resolve(Z)),{recursive:!0}),await Bun.write(Z,_)}finally{z.close()}if(!jF(Z))throw Error(`Screenshot was not produced for ${$}`);return{input:$,output:Z,bytes:OF(Z).size}}async function LF($,Z,Y={}){HF(Z,{recursive:!0});let J;if(!/^https?:\/\//.test($)&&jF($)&&OF($).isDirectory())J=ay($).filter((G)=>G.endsWith(".html")).map((G)=>d5.join($,G));else J=[$];let X=Y.format??"png",Q=[];for(let G of J){let K=/^https?:\/\//.test(G)?new URL(G).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":d5.basename(G).replace(/\.html?$/,"");Q.push(await xK(G,d5.join(Z,`${K}.${X}`),Y))}return Q}var yK=16384;var vK=()=>{};function fJ($,Z={}){let Y={...AF,...Z};if($.trim()==="")return`
|
|
15000
|
+
</tr>`;X+="</tbody></table>";for(let Q of Y)if(Q.example)X+=`<h3>@${Q.name}</h3>`,X+=`<p>${Q.description||""}</p>`,X+="<h4>Example</h4>",X+=`<pre><code>${Q.example.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</code></pre>`}return X+="</body></html>",X}function QF($=[],Z=[],Y=[],J){return JSON.stringify({components:$,templates:Z,directives:Y,extraContent:J||""},null,2)}async function GF($){try{let{componentsDir:Z,templatesDir:Y,webComponentsConfig:J,customDirectives:X,config:Q}=$;if(!Q.enabled)return!1;let G=Q.outputDir||"docs";if(await kK.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),Z)console.log(`Components directory: ${Z}`);if(Y)console.log(`Templates directory: ${Y}`);console.log(`Output directory: ${G}`);let K=[];if(Q.components!==!1&&Z)console.log("Generating component documentation..."),K=await $F(Z,J),console.log(`Found ${K.length} components`);let W=[];if(Q.templates!==!1&&Y)console.log("Generating template documentation..."),W=await ZF(Y),console.log(`Found ${W.length} templates`);let U=[];if(Q.directives!==!1)console.log("Generating directive documentation..."),U=await YF(X),console.log(`Found ${U.length} directives`);let z=Q.format||"markdown",_=Q.extraContent,B="",q="";switch(z){case"markdown":B=JF(K,W,U,_),q="md";break;case"html":B=XF(K,W,U,_),q="html";break;case"json":B=QF(K,W,U,_),q="json";break;default:throw Error(`Unsupported documentation format: ${z}`)}let j=r8.join(G,`stx-docs.${q}`);return await Bun.write(j,B),console.log(`Documentation generated: ${j}`),!0}catch(Z){return console.error("Error generating documentation:",Z),!1}}async function CK($){let Z={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Y=$.componentsDir||T1.componentsDir,J=$.templatesDir||".";return GF({componentsDir:Y,templatesDir:J,webComponentsConfig:T1.webComponents,customDirectives:T1.customDirectives,config:Z})}var bK=D(()=>{r0();N0()});import g5 from"process";function h5(){if(typeof globalThis<"u"&&"caches"in globalThis&&"CF"in globalThis)return{platform:"cloudflare",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","r2","d1","durable-objects","queues"]};if(typeof globalThis<"u"&&"Deno"in globalThis)return{platform:"deno",version:globalThis.Deno.version?.deno,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","deploy","ffi"]};if(typeof globalThis<"u"&&"Bun"in globalThis)return{platform:"bun",version:globalThis.Bun.version,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["sqlite","ffi","native-modules"]};if(typeof globalThis<"u"&&"EdgeRuntime"in globalThis)return{platform:"vercel",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["edge-config","blob"]};if(typeof globalThis<"u"&&"Netlify"in globalThis)return{platform:"netlify",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!1,capabilities:["blobs","edge-functions"]};if(typeof globalThis<"u"&&"fastly"in globalThis)return{platform:"fastly",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["dictionary","backend","geolocation"]};if(g5.versions?.node)return{platform:"node",version:g5.versions.node,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["fs","child-process","native-modules"]};return{platform:"unknown",supportsStreaming:!1,supportsCrypto:!1,supportsKV:!1,supportsCache:!1,capabilities:[]}}function Dy(){let $=h5();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function ky(){return h5().platform!=="unknown"}function WF($){return{get(Z){if($&&Z in $){let Y=$[Z];return typeof Y==="string"?Y:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(Z);if(g5.env)return g5.env[Z];return},getOrThrow(Z){let Y=this.get(Z);if(Y===void 0)throw Error(`Environment variable "${Z}" is not set`);return Y},has(Z){return this.get(Z)!==void 0},all(){let Z={};if($){for(let[Y,J]of Object.entries($))if(typeof J==="string")Z[Y]=J}if(typeof globalThis<"u"&&"Deno"in globalThis){let Y=globalThis.Deno.env.toObject();Object.assign(Z,Y)}if(g5.env){for(let[Y,J]of Object.entries(g5.env))if(J!==void 0)Z[Y]=J}return Z}}}function UF($){let Z=h5();if(Z.platform==="cloudflare"&&$)return $;if(Z.platform==="deno"&&"Deno"in globalThis)return Sy();if(Z.platform==="node"||Z.platform==="bun")return Cy();return}function Sy(){let $=null,Z=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Y){return(await(await Z()).get(["stx",Y])).value},async getWithMetadata(Y){let J=await Z(),X=await J.get(["stx",Y]),Q=await J.get(["stx-meta",Y]);return{value:X.value,metadata:Q.value}},async put(Y,J,X){let Q=await Z(),G=X?.expirationTtl?X.expirationTtl*1000:void 0;if(await Q.set(["stx",Y],J,G?{expireIn:G}:void 0),X?.metadata)await Q.set(["stx-meta",Y],X.metadata,G?{expireIn:G}:void 0)},async delete(Y){let J=await Z();await J.delete(["stx",Y]),await J.delete(["stx-meta",Y])},async list(Y){let J=await Z(),X=Y?.prefix?["stx",Y.prefix]:["stx"],Q=J.list({prefix:X,limit:Y?.limit||100}),G=[];for await(let K of Q){let U=K.key.slice(1).join("/");if(!U.startsWith("stx-meta/"))G.push({name:U})}return{keys:G,list_complete:!0}}}}function Cy(){let $=new Map,Z=()=>{let Y=Date.now();for(let[J,X]of $.entries())if(X.expiration&&X.expiration<Y)$.delete(J)};return{async get(Y){Z();let J=$.get(Y);if(!J)return null;if(J.expiration&&J.expiration<Date.now())return $.delete(Y),null;return J.value},async getWithMetadata(Y){Z();let J=$.get(Y);if(!J)return{value:null,metadata:null};if(J.expiration&&J.expiration<Date.now())return $.delete(Y),{value:null,metadata:null};return{value:J.value,metadata:J.metadata||null}},async put(Y,J,X){let Q=X?.expiration?X.expiration*1000:X?.expirationTtl?Date.now()+X.expirationTtl*1000:void 0;$.set(Y,{value:J,metadata:X?.metadata,expiration:Q})},async delete(Y){$.delete(Y)},async list(Y){Z();let J=[];for(let[X,Q]of $.entries()){if(Y?.prefix&&!X.startsWith(Y.prefix))continue;if(J.push({name:X,expiration:Q.expiration,metadata:Q.metadata}),Y?.limit&&J.length>=Y.limit)break}return{keys:J,list_complete:!0}}}}function zF(){let $=h5();if($.platform==="cloudflare"&&"caches"in globalThis)return by();if($.supportsStreaming)return Py();return}function by(){return{async match($){return(await caches.default).match($)},async put($,Z){await(await caches.default).put($,Z.clone())},async delete($){return(await caches.default).delete($)}}}function Py(){let $=new Map,Z=60000;return{async match(Y){let J=Y.url,X=$.get(J);if(!X)return;if(Date.now()>X.expiration){$.delete(J);return}return X.response.clone()},async put(Y,J){let X=Y.url,Q=J.headers.get("Cache-Control"),G=60000;if(Q){let K=Q.match(/max-age=(\d+)/);if(K)G=Number.parseInt(K[1],10)*1000}$.set(X,{response:J.clone(),expiration:Date.now()+G})},async delete(Y){return $.delete(Y.url)}}}function yy(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function xy($,Z){if(Z.platform==="cloudflare"){let Y=$.cf;if(Y)return{city:Y.city,country:Y.country,countryCode:Y.country,region:Y.region,latitude:Y.latitude?Number.parseFloat(Y.latitude):void 0,longitude:Y.longitude?Number.parseFloat(Y.longitude):void 0,timezone:Y.timezone}}if(Z.platform==="vercel"){let Y={},J=$.headers.get("x-vercel-ip-city"),X=$.headers.get("x-vercel-ip-country"),Q=$.headers.get("x-vercel-ip-country-region"),G=$.headers.get("x-vercel-ip-latitude"),K=$.headers.get("x-vercel-ip-longitude");if(J)Y.city=decodeURIComponent(J);if(X)Y.countryCode=X;if(Q)Y.region=Q;if(G)Y.latitude=Number.parseFloat(G);if(K)Y.longitude=Number.parseFloat(K);return Object.keys(Y).length>0?Y:void 0}if(Z.platform==="netlify"){let Y={},J=$.headers.get("x-nf-geo-city"),X=$.headers.get("x-nf-geo-country");if(J)Y.city=J;if(X)Y.countryCode=X;return Object.keys(Y).length>0?Y:void 0}return}function PK($,Z,Y){let J=new Headers($.headers);if(Z.origins==="*")J.set("Access-Control-Allow-Origin","*");else if(Z.origins&&Y&&Z.origins.includes(Y))J.set("Access-Control-Allow-Origin",Y),J.set("Vary","Origin");if(Z.methods)J.set("Access-Control-Allow-Methods",Z.methods.join(", "));if(Z.headers)J.set("Access-Control-Allow-Headers",Z.headers.join(", "));if(Z.exposeHeaders)J.set("Access-Control-Expose-Headers",Z.exposeHeaders.join(", "));if(Z.credentials)J.set("Access-Control-Allow-Credentials","true");if(Z.maxAge)J.set("Access-Control-Max-Age",String(Z.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:J})}function a8($){let Z=h5();return async(Y,J)=>{let X=performance.now(),Q=yy(),G={runtime:Z,platform:J||{},requestId:Q,geo:xy(Y,Z),timing:{start:X,getElapsed:()=>performance.now()-X},kv:UF(J?.KV),cache:zF(),env:WF(J?.env)};try{if(Y.method==="OPTIONS"&&$.cors){let W=new Response(null,{status:204});return W=PK(W,$.cors,Y.headers.get("Origin")||void 0),W}if($.cache?.enabled&&Y.method==="GET"&&G.cache){if(KF(Y,$.cache)){let U=await G.cache.match(Y);if(U){let z=new Response(U.body,U);return z.headers.set("X-Cache","HIT"),z.headers.set("X-Request-Id",Q),$.cors?PK(z,$.cors,Y.headers.get("Origin")||void 0):z}}}let K;if($.middleware&&$.middleware.length>0)K=await vy(Y,G,$.middleware,async()=>{let W=await $.render(Y,G);return typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W});else{let W=await $.render(Y,G);K=typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W}if(K.headers.set("X-Request-Id",Q),K.headers.set("X-Response-Time",`${G.timing.getElapsed().toFixed(2)}ms`),$.cache?.enabled&&Y.method==="GET"&&G.cache){if(KF(Y,$.cache)&&K.status===200){let U=$.cache.ttl||60,z=K.clone();z.headers.set("Cache-Control",`public, max-age=${U}`),await G.cache.put(Y,z),K.headers.set("X-Cache","MISS")}}if($.cors)K=PK(K,$.cors,Y.headers.get("Origin")||void 0);return K}catch(K){let W=K instanceof Error?K:Error(String(K));if($.onError)return $.onError(W,Y);return new Response(`Internal Server Error: ${W.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":Q}})}}}function KF($,Z){let J=new URL($.url).pathname;if(Z.excludePaths){for(let X of Z.excludePaths)if(X.test(J))return!1}if(Z.includePaths){for(let X of Z.includePaths)if(X.test(J))return!0;return!1}return!0}async function vy($,Z,Y,J){let X=0,Q=async()=>{if(X>=Y.length)return J();let G=Y[X];return X++,G($,Z,Q)};return Q()}function fy($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","text/html; charset=utf-8"),Y.set("Transfer-Encoding","chunked"),new Response($,{...Z,headers:Y})}function gy(){let $=new TextEncoder;return new TransformStream({transform(Z,Y){Y.enqueue($.encode(Z))}})}function hy($){let Z=new TextEncoder;return new ReadableStream({async start(Y){for await(let J of $)Y.enqueue(Z.encode(J));Y.close()}})}function dy($){let Z=a8($);return{async fetch(Y,J,X){return Z(Y,{env:J,ctx:X,KV:J.KV})}}}function uy($){let Z=a8($);return(Y)=>Z(Y,{})}function my($){let Z=a8($);return(Y)=>Z(Y,{})}function ly($){let Z=a8($);return(Y,J)=>{return Z(Y,{netlifyContext:J})}}function cy($){let Z=$.headers.get("Cookie");if(!Z)return{};let Y={};for(let J of Z.split(";")){let[X,Q]=J.split("=").map((G)=>G.trim());if(X&&Q)Y[X]=decodeURIComponent(Q)}return Y}function py($,Z,Y){let J=`${encodeURIComponent($)}=${encodeURIComponent(Z)}`;if(Y?.maxAge!==void 0)J+=`; Max-Age=${Y.maxAge}`;if(Y?.expires)J+=`; Expires=${Y.expires.toUTCString()}`;if(Y?.path)J+=`; Path=${Y.path}`;if(Y?.domain)J+=`; Domain=${Y.domain}`;if(Y?.secure)J+="; Secure";if(Y?.httpOnly)J+="; HttpOnly";if(Y?.sameSite)J+=`; SameSite=${Y.sameSite}`;return J}function iy($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...Z,headers:Y})}function ny($,Z=302){return new Response(null,{status:Z,headers:{Location:$}})}function ry($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var _F=()=>{};var VF={};$0(VF,{captureScreenshots:()=>LF,captureScreenshot:()=>xK});var{WebView:ay}=globalThis.Bun;import{existsSync as jF,mkdirSync as HF,readdirSync as sy,statSync as OF}from"fs";import d5 from"path";function oy($){if(/^https?:\/\//.test($)||$.startsWith("file://"))return $;return`file://${d5.resolve($)}`}function BF($,Z,Y,J){return new Promise((X)=>{let Q=!1,G,K,W=()=>{if(!Q){if(Q=!0,clearTimeout(K),G)clearTimeout(G);$.onNavigated=void 0,X()}};K=setTimeout(W,J),$.onNavigated=()=>{if(!Q)G=setTimeout(W,Y)};try{let U=$.navigate(Z);if(U&&typeof U.catch==="function")U.catch(W)}catch{W()}})}async function qF($,Z,Y){let J=`!!document.querySelector(${JSON.stringify(Z)})`,X=Date.now()+Y;while(Date.now()<X){try{if(await $.evaluate(J))return}catch{}await new Promise((Q)=>setTimeout(Q,100))}}async function ty($){try{let Z=await $.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof Z==="number"&&Number.isFinite(Z)&&Z>0?Math.min(Z,yK):0}catch{return 0}}async function xK($,Z,Y={}){let J=Math.min(Y.width??1440,yK),X=Math.min(Y.height??2200,yK),Q=Y.waitMs??800,G=Y.timeoutMs??15000,K=Y.format??"png",W=oy($),U=(_)=>new ay({width:J,height:_,headless:!0,...Y.backend?{backend:Y.backend}:{}}),z=U(X);try{if(await BF(z,W,Q,G),Y.waitSelector)await qF(z,Y.waitSelector,G);if(Y.fullPage){let B=await ty(z);if(B>X){if(z.close(),z=U(B),await BF(z,W,Q,G),Y.waitSelector)await qF(z,Y.waitSelector,G)}}let _=await z.screenshot({encoding:"buffer",format:K});HF(d5.dirname(d5.resolve(Z)),{recursive:!0}),await Bun.write(Z,_)}finally{z.close()}if(!jF(Z))throw Error(`Screenshot was not produced for ${$}`);return{input:$,output:Z,bytes:OF(Z).size}}async function LF($,Z,Y={}){HF(Z,{recursive:!0});let J;if(!/^https?:\/\//.test($)&&jF($)&&OF($).isDirectory())J=sy($).filter((G)=>G.endsWith(".html")).map((G)=>d5.join($,G));else J=[$];let X=Y.format??"png",Q=[];for(let G of J){let K=/^https?:\/\//.test(G)?new URL(G).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":d5.basename(G).replace(/\.html?$/,"");Q.push(await xK(G,d5.join(Z,`${K}.${X}`),Y))}return Q}var yK=16384;var vK=()=>{};function fJ($,Z={}){let Y={...AF,...Z};if($.trim()==="")return`
|
|
14984
15001
|
`;let J=$;if(Y.trimTrailingWhitespace)J=J.replace(/[ \t]+$/gm,"");if(J=$x(J,Y),J=Xx(J,Y),J=Zx(J,Y),Y.trimTrailingWhitespace)J=J.replace(/[ \t]+$/gm,""),J=J.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(J=J.replace(/\r\n/g,`
|
|
14985
15002
|
`).replace(/\r/g,`
|
|
14986
15003
|
`),!J.endsWith(`
|
|
@@ -15439,7 +15456,7 @@ const features = [
|
|
|
15439
15456
|
})();
|
|
15440
15457
|
</script>
|
|
15441
15458
|
</body>
|
|
15442
|
-
</html>`}var Qx;var uK=D(()=>{Qx={basic:{description:"Simple page with script, style, and template sections"},component:{description:"Reusable component with props and slots"},layout:{description:"Layout template with sections and yields"},blog:{description:"Blog post with frontmatter-style variables"},api:{description:"API endpoint template with JSON response"},app:{description:"Full app with stores and components"}}});var EF={};$0(EF,{startInteractive:()=>TF});import
|
|
15459
|
+
</html>`}var Qx;var uK=D(()=>{Qx={basic:{description:"Simple page with script, style, and template sections"},component:{description:"Reusable component with props and slots"},layout:{description:"Layout template with sections and yields"},blog:{description:"Blog post with frontmatter-style variables"},api:{description:"API endpoint template with JSON response"},app:{description:"Full app with stores and components"}}});var EF={};$0(EF,{startInteractive:()=>TF});import s8 from"fs";import R6 from"path";import*as MF from"readline";function _x($,Z){let Y=$.split(" "),J=Y[0];if(Y.length===1)return Object.keys(U$).filter((X)=>X.startsWith(J));if(["render","cat","load","cd"].includes(J)){let X=Y.slice(1).join(" "),Q=R6.dirname(X)||".",G=R6.basename(X),K=R6.resolve(Z.cwd,Q);if(s8.existsSync(K)&&s8.statSync(K).isDirectory())try{return s8.readdirSync(K).filter((U)=>U.startsWith(G)).map((U)=>`${J} ${Q==="."?"":`${Q}/`}${U}`)}catch{return[]}}if(["unset","eval","set"].includes(J)){let X=Y[1]||"";return Object.keys(Z.context).filter((Q)=>Q.startsWith(X)).map((Q)=>`${J} ${Q}`)}return[]}async function TF($={}){let Z={context:$.context||{},cwd:$.cwd||process.cwd(),history:[],running:!0,lastResult:null},Y=MF.createInterface({input:process.stdin,output:process.stdout,completer:(X)=>{return[_x(X,Z),X]},historySize:$.maxHistory||100});console.log(`
|
|
15443
15460
|
${g.bold}${g.blue}stx Interactive Mode${g.reset}
|
|
15444
15461
|
${g.dim}Type 'help' for available commands, 'exit' to quit${g.reset}
|
|
15445
15462
|
`);let J=()=>{let X=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${g.cyan}stx${g.reset} ${g.dim}${X}${g.reset} ${g.green}>${g.reset} `,async(Q)=>{let G=Q.trim();if(!G){if(Z.running)J();return}Z.history.push(G);let K=G.match(/(?:[^\s"]|"[^"]*")+/g)||[],W=K[0]?.toLowerCase(),U=K.slice(1).map((z)=>z.replace(/^"|"$/g,""));if(W&&U$[W])try{await U$[W].handler(U,Z)}catch(z){console.log(`${g.red}Error:${g.reset}`,z)}else if(W)if(G.includes("{{")||G.includes("}}"))try{let z=await d1(G,Z.context,"eval");console.log(`${g.green}\u2192${g.reset} ${z}`)}catch{console.log(`${g.red}Unknown command: ${W}${g.reset}`),console.log(`${g.dim}Type 'help' for available commands${g.reset}`)}else console.log(`${g.red}Unknown command: ${W}${g.reset}`),console.log(`${g.dim}Type 'help' for available commands${g.reset}`);if(Z.running)J();else Y.close()})};Y.on("SIGINT",()=>{console.log(`
|
|
@@ -15454,7 +15471,7 @@ ${g.dim}Rendering ${Y}...${g.reset}
|
|
|
15454
15471
|
`);let Q=await q0(J,Z.context,Y,{},new Set);if(Z.lastResult=Q,X)console.log(Q);else Q.split(`
|
|
15455
15472
|
`).forEach((K,W)=>{let U=String(W+1).padStart(3," ");console.log(`${g.dim}${U}${g.reset} ${K}`)});console.log()}catch(J){console.log(`${g.red}Error rendering template:${g.reset}`,J)}}},eval:{description:"Evaluate an expression",usage:"eval <expression>",handler:async($,Z)=>{if(!$.length){console.log(`${g.red}Error: Please provide an expression to evaluate${g.reset}`);return}let Y=$.join(" ");try{let J=`{{ ${Y} }}`,Q=(await d1(J,Z.context,"eval")).trim();Z.lastResult=Q,console.log(`${g.green}\u2192${g.reset} ${Q}`)}catch(J){console.log(`${g.red}Error:${g.reset}`,J)}}},set:{description:"Set a context variable",usage:"set <key> <value>",handler:async($,Z)=>{if($.length<2){console.log(`${g.red}Error: Usage: set <key> <value>${g.reset}`);return}let Y=$[0],J=$.slice(1).join(" "),X;try{X=JSON.parse(J)}catch{X=J}Z.context[Y]=X,console.log(`${g.green}\u2713${g.reset} ${Y} = ${JSON.stringify(X)}`)}},unset:{description:"Remove a context variable",usage:"unset <key>",handler:async($,Z)=>{if(!$[0]){console.log(`${g.red}Error: Please specify a variable to remove${g.reset}`);return}if($[0]in Z.context)delete Z.context[$[0]],console.log(`${g.green}\u2713${g.reset} Removed ${$[0]}`);else console.log(`${g.yellow}Variable not found: ${$[0]}${g.reset}`)}},context:{description:"Show current context variables",usage:"context",handler:async($,Z)=>{let Y=Object.keys(Z.context);if(Y.length===0){console.log(`${g.dim}Context is empty${g.reset}`);return}console.log(`
|
|
15456
15473
|
${g.bold}Context Variables:${g.reset}
|
|
15457
|
-
`);for(let J of Y){let X=Z.context[J],Q=Array.isArray(X)?"array":typeof X,G=JSON.stringify(X).slice(0,50);console.log(` ${g.cyan}${J}${g.reset} ${g.dim}(${Q})${g.reset}: ${G}${G.length>=50?"...":""}`)}console.log()}},clear:{description:"Clear context or screen",usage:"clear [context|screen]",handler:async($,Z)=>{if($[0]==="context"||!$[0])Z.context={},console.log(`${g.green}\u2713${g.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${g.cyan}${Z.cwd}${g.reset}`);return}let Y=R6.resolve(Z.cwd,$[0]);if(!
|
|
15474
|
+
`);for(let J of Y){let X=Z.context[J],Q=Array.isArray(X)?"array":typeof X,G=JSON.stringify(X).slice(0,50);console.log(` ${g.cyan}${J}${g.reset} ${g.dim}(${Q})${g.reset}: ${G}${G.length>=50?"...":""}`)}console.log()}},clear:{description:"Clear context or screen",usage:"clear [context|screen]",handler:async($,Z)=>{if($[0]==="context"||!$[0])Z.context={},console.log(`${g.green}\u2713${g.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${g.cyan}${Z.cwd}${g.reset}`);return}let Y=R6.resolve(Z.cwd,$[0]);if(!s8.existsSync(Y)){console.log(`${g.red}Error: Directory not found: ${Y}${g.reset}`);return}if(!s8.statSync(Y).isDirectory()){console.log(`${g.red}Error: Not a directory: ${Y}${g.reset}`);return}Z.cwd=Y,console.log(`${g.green}\u2713${g.reset} ${Y}`)}},ls:{description:"List files in current directory",usage:"ls [pattern]",handler:async($,Z)=>{let Y=$[0]||"*",J=new Bun.Glob(Y),X=[];for await(let W of J.scan({cwd:Z.cwd,onlyFiles:!1}))X.push(W);if(X.length===0){console.log(`${g.dim}No files found${g.reset}`);return}X.sort();let Q=X.filter((W)=>W.endsWith(".stx")),G=X.filter((W)=>W.endsWith(".md")),K=X.filter((W)=>!W.endsWith(".stx")&&!W.endsWith(".md"));if(Q.length>0)console.log(`
|
|
15458
15475
|
${g.bold}Templates:${g.reset}`),Q.forEach((W)=>console.log(` ${g.green}${W}${g.reset}`));if(G.length>0)console.log(`
|
|
15459
15476
|
${g.bold}Markdown:${g.reset}`),G.forEach((W)=>console.log(` ${g.blue}${W}${g.reset}`));if(K.length>0)console.log(`
|
|
15460
15477
|
${g.bold}Other:${g.reset}`),K.forEach((W)=>console.log(` ${g.dim}${W}${g.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${g.red}Error: Please specify a file${g.reset}`);return}let Y=R6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${g.red}Error: File not found: ${Y}${g.reset}`);return}let X=(await Bun.file(Y).text()).split(`
|
|
@@ -15517,7 +15534,7 @@ Installing dependencies with ${K}...`),yF(`${K} install`,{cwd:X,stdio:"inherit"}
|
|
|
15517
15534
|
Next steps:
|
|
15518
15535
|
cd ${$}
|
|
15519
15536
|
${Z.packageManager||"bun"} run dev
|
|
15520
|
-
`)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function Dx($){let Z=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...Z,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...Z,"src/posts","src/utils"];case"dashboard":return[...Z,"src/stores","src/api","src/utils"];case"landing":return[...Z,"src/sections"];default:return[...Z,"src/stores"]}}function kx($,Z,Y){let J={};if(J["package.json"]=gx(Z,$,Y),J["stx.config.ts"]=hx($,Y),J["README.md"]=ux(Z,$),Y.typescript!==!1)J["tsconfig.json"]=dx();switch($){case"minimal":J["src/index.stx"]=lx();break;case"blog":J["pages/index.stx"]=nx(),J["pages/[slug].stx"]=rx(),J["layouts/app.stx"]=
|
|
15537
|
+
`)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function Dx($){let Z=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...Z,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...Z,"src/posts","src/utils"];case"dashboard":return[...Z,"src/stores","src/api","src/utils"];case"landing":return[...Z,"src/sections"];default:return[...Z,"src/stores"]}}function kx($,Z,Y){let J={};if(J["package.json"]=gx(Z,$,Y),J["stx.config.ts"]=hx($,Y),J["README.md"]=ux(Z,$),Y.typescript!==!1)J["tsconfig.json"]=dx();switch($){case"minimal":J["src/index.stx"]=lx();break;case"blog":J["pages/index.stx"]=nx(),J["pages/[slug].stx"]=rx(),J["layouts/app.stx"]=ax(),J["components/PostCard.stx"]=sx();break;case"dashboard":J["pages/index.stx"]=ox(),J["pages/settings.stx"]=tx(),J["layouts/app.stx"]=ex(),J["components/Sidebar.stx"]=$v(),J["components/StatsCard.stx"]=Zv(),J["src/stores/dashboard.ts"]=Yv();break;case"landing":J["pages/index.stx"]=Jv(),J["layouts/app.stx"]=Xv(),J["src/sections/Hero.stx"]=Qv(),J["src/sections/Features.stx"]=Gv(),J["src/sections/Pricing.stx"]=Kv(),J["components/Button.stx"]=Wv();break;case"full":J["pages/index.stx"]=xF(),J["pages/about.stx"]=cx(),J["layouts/app.stx"]=vF(),J["components/Header.stx"]=fF(),J["components/Footer.stx"]=gF(),J["src/stores/app.ts"]=hF(),J["src/i18n/en.json"]=px("en"),J["test/example.test.ts"]=ix();break;default:J["pages/index.stx"]=xF(),J["layouts/app.stx"]=vF(),J["components/Header.stx"]=fF(),J["components/Footer.stx"]=gF(),J["src/stores/app.ts"]=hF()}return J}async function Sx($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"components",X=aK($),Q=T6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Component ${X} already exists. Use --force to overwrite.`,Y;try{Z3(J);let G=yx(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created component: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create component: ${G}`}return Y}async function Cx($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"pages",X=$.toLowerCase().replace(/\s+/g,"-"),Q=T6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Page ${X} already exists. Use --force to overwrite.`,Y;try{Z3(J);let G=xx(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created page: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create page: ${G}`}return Y}async function bx($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"src/stores",X=zv($),Q=T6(J,`${X}.ts`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Store ${X} already exists. Use --force to overwrite.`,Y;try{Z3(J);let G=vx(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created store: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create store: ${G}`}return Y}async function Px($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"layouts",X=$.toLowerCase().replace(/\s+/g,"-"),Q=T6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Layout ${X} already exists. Use --force to overwrite.`,Y;try{Z3(J);let G=fx(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created layout: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create layout: ${G}`}return Y}function yx($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
|
|
15521
15538
|
// Props
|
|
15522
15539
|
const title = props.title || '${$}'
|
|
15523
15540
|
const variant = props.variant || 'default'
|
|
@@ -15547,7 +15564,7 @@ const variant = props.variant || 'default'
|
|
|
15547
15564
|
margin-top: 0.5rem;
|
|
15548
15565
|
}
|
|
15549
15566
|
</style>`);return Y.join(`
|
|
15550
|
-
`)}function xx($,Z){let Y=
|
|
15567
|
+
`)}function xx($,Z){let Y=aK($.replace(/-/g," ")),J=[];if(J.push(`<script>
|
|
15551
15568
|
const title = '${Y}'
|
|
15552
15569
|
const description = 'Page description'
|
|
15553
15570
|
</script>
|
|
@@ -15560,7 +15577,7 @@ const description = 'Page description'
|
|
|
15560
15577
|
<p>{{ description }}</p>
|
|
15561
15578
|
</div>
|
|
15562
15579
|
@endsection`),J.join(`
|
|
15563
|
-
`)}function vx($,Z){let Y=`${$}Store`,J=`${
|
|
15580
|
+
`)}function vx($,Z){let Y=`${$}Store`,J=`${aK($)}State`,X=`import { defineStore } from 'stx'
|
|
15564
15581
|
|
|
15565
15582
|
interface ${J} {
|
|
15566
15583
|
// Add your state properties here
|
|
@@ -15873,7 +15890,7 @@ describe('Example', () => {
|
|
|
15873
15890
|
expect(1 + 1).toBe(2)
|
|
15874
15891
|
})
|
|
15875
15892
|
})
|
|
15876
|
-
`}function nx(){return"<!-- Blog index -->"}function rx(){return"<!-- Blog post -->"}function
|
|
15893
|
+
`}function nx(){return"<!-- Blog index -->"}function rx(){return"<!-- Blog post -->"}function ax(){return`<!DOCTYPE html>
|
|
15877
15894
|
<html lang="en">
|
|
15878
15895
|
<head>
|
|
15879
15896
|
<meta charset="UTF-8">
|
|
@@ -15913,7 +15930,7 @@ describe('Example', () => {
|
|
|
15913
15930
|
</footer>
|
|
15914
15931
|
@yield('scripts')
|
|
15915
15932
|
</body>
|
|
15916
|
-
</html>`}function
|
|
15933
|
+
</html>`}function sx(){return"<!-- Post card -->"}function ox(){return"<!-- Dashboard index -->"}function tx(){return"<!-- Settings -->"}function ex(){return`<!DOCTYPE html>
|
|
15917
15934
|
<html lang="en">
|
|
15918
15935
|
<head>
|
|
15919
15936
|
<meta charset="UTF-8">
|
|
@@ -15984,16 +16001,16 @@ describe('Example', () => {
|
|
|
15984
16001
|
</footer>
|
|
15985
16002
|
@yield('scripts')
|
|
15986
16003
|
</body>
|
|
15987
|
-
</html>`}function Qv(){return"<!-- Hero section -->"}function Gv(){return"<!-- Features -->"}function Kv(){return"<!-- Pricing -->"}function Wv(){return"<!-- Button -->"}function Z3($){if(!$3($))rK($,{recursive:!0})}function Uv(){if($3("bun.lockb"))return"bun";if($3("pnpm-lock.yaml"))return"pnpm";if($3("yarn.lock"))return"yarn";return"bun"}function
|
|
16004
|
+
</html>`}function Qv(){return"<!-- Hero section -->"}function Gv(){return"<!-- Features -->"}function Kv(){return"<!-- Pricing -->"}function Wv(){return"<!-- Button -->"}function Z3($){if(!$3($))rK($,{recursive:!0})}function Uv(){if($3("bun.lockb"))return"bun";if($3("pnpm-lock.yaml"))return"pnpm";if($3("yarn.lock"))return"yarn";return"bun"}function aK($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function zv($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function z$($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var Ex;var dF=D(()=>{Ex={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:_v}=globalThis.Bun;import Y3 from"fs";import E6 from"path";function Bv($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function uF($={}){let{port:Z=3000,root:Y=".",stxOptions:J={},watch:X=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,z=E6.resolve(Y),_=new Map;async function B(L){let F=Y3.statSync(L),A=`${L}:${F.mtimeMs}`,w=_.get(A);if(w)return w.content;for(let P of _.keys())if(P.startsWith(`${L}:`)&&P!==A)_.delete(P);let N=await Bun.file(L).text(),R=N,E=_4(N);if(E)R=E.content.trim();let M=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],S=[],k;while((k=M.exec(N))!==null){let P=k[1],d=k[2],l=k[0];if(P.includes("server"))S.push(d);else I.push(l)}let x=N.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:E6.dirname(L)};for(let P of S)await D0(P,b,L);let m=await q0(y,b,L,J,new Set);if(x.length>0){let P=x.join(`
|
|
15988
16005
|
`);if(m.match(/(<\/head>)/i))m=m.replace(/(<\/head>)/i,`${P}
|
|
15989
16006
|
$1`)}if(I.length>0){let{interpolateScriptsInTemplate:P}=await Promise.resolve().then(() => ($1(),V7)),d=P(I.join(`
|
|
15990
16007
|
`),b);if(m.match(/(<\/body>)/i))m=m.replace(/(<\/body>)/i,`${d}
|
|
15991
16008
|
$1`);else m+=`
|
|
15992
16009
|
${d}`}return _.set(A,{content:m,mtime:F.mtimeMs}),m}async function q(L){let F=Y3.statSync(L),A=`${L}:${F.mtimeMs}`,w=_.get(A);if(w)return w.content;let{content:N}=await C4(L,J);return _.set(A,{content:N,mtime:F.mtimeMs}),N}function j(L){let F=L.startsWith("/")?L.slice(1):L,A=[F,`${F}.stx`,`${F}.md`,`${F}.html`,E6.join(F,"index.stx"),E6.join(F,"index.md"),E6.join(F,"index.html")];for(let w of A){let N=E6.join(z,w);if(Y3.existsSync(N)&&Y3.statSync(N).isFile())return N}return null}async function H(L){let F=new URL(L.url),A=async()=>{if(G[F.pathname])return await G[F.pathname](L);if(Q){let N=await Q(L);if(N)return N}let w=j(F.pathname);if(!w){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let N,R="text/html";if(w.endsWith(".stx"))N=await B(w);else if(w.endsWith(".md"))N=await q(w);else if(w.endsWith(".html"))N=await Bun.file(w).text();else if(w.endsWith(".css"))N=await Bun.file(w).text(),R="text/css";else if(w.endsWith(".js"))N=await Bun.file(w).text(),R="text/javascript";else if(w.endsWith(".json"))N=await Bun.file(w).text(),R="application/json";else return new Response(Bun.file(w));return new Response(N,{headers:{"Content-Type":R}})}catch(N){if(U)return await U(N,L);let R=N instanceof Error?N.message:String(N),M=J?.debug===!0?`<h1>Error</h1><pre>${R}
|
|
15993
16010
|
${N instanceof Error?N.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(M,{status:500,headers:{"Content-Type":"text/html"}})}};for(let w=K.length-1;w>=0;w--){let N=K[w],R=A;A=async()=>await N(L,R)}return await A()}let O=_v({port:Z,fetch:H}),V=null;if(X)V=Y3.watch(z,{recursive:!0},(L,F)=>{if(F&&(F.endsWith(".stx")||F.endsWith(".md")||F.endsWith(".html")))_.clear()});return{server:O,url:O.url.toString(),stop(){if(V)V.close();O.stop()}}}async function qv($,Z={}){let Y=E6.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let J=Y.endsWith(".md"),X=Y.endsWith(".stx");if(!J&&!X)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await uF({...Z,root:E6.dirname(Y),routes:{"/":async()=>{let Q;if(J){let{content:G}=await C4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let z=K.join(`
|
|
15994
|
-
`),_=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),B={};if(z.trim())await D0(z,B,Y);let q=new Set;Q=await q0(_,B,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function jv($){return $}function Hv($){return $}var mF=D(()=>{x$();$5();_1();N0()});import{existsSync as Ov,readFileSync as Lv}from"fs";class
|
|
16011
|
+
`),_=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),B={};if(z.trim())await D0(z,B,Y);let q=new Set;Q=await q0(_,B,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function jv($){return $}function Hv($){return $}var mF=D(()=>{x$();$5();_1();N0()});import{existsSync as Ov,readFileSync as Lv}from"fs";class sK{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...Vv,...$},this.options.includeBuiltins)Object.entries(lF).forEach(([Z,Y])=>{this.variables.set(Z,Y)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([Z,Y])=>{this.variables.set(Z,Y)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!Ov($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let Z=Lv($,"utf-8");return this.checkTemplate(Z,$)}checkTemplate($,Z="<inline>"){this.currentFile=Z,this.errors=[],this.warnings=[];let Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)this.analyzeScript(Y[1],$.indexOf(Y[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,Z){let Y=$.split(`
|
|
15995
16012
|
`),J=this.getLineNumber(Z);for(let X=0;X<Y.length;X++){let Q=Y[X],G=J+X;this.extractTypedVariables(Q,G),this.extractInterfaces(Q,Y,X,G),this.extractTypeAliases(Q,G)}}extractTypedVariables($,Z){let Y=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*:\s*([^=]+?)\s*=/);if(Y){let[,Q,G]=Y,K=this.parseTypeAnnotation(G.trim());this.variables.set(Q,K);return}let J=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(.+)/);if(J){let[,Q,G]=J,K=this.inferType(G.trim());this.variables.set(Q,K);return}let X=$.match(/(?:export\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*(\w+))?/);if(X){let[,Q,G,K]=X,W=this.parseParams(G),U=K?this.parseTypeAnnotation(K):{kind:"primitive",value:"any"};this.variables.set(Q,{kind:"function",params:W,returnType:U})}}extractInterfaces($,Z,Y,J){let X=$.match(/(?:export\s+)?interface\s+(\w+)\s*\{/);if(X){let[,Q]=X,G={},K=1,W=Y+1;while(W<Z.length&&K>0){let U=Z[W].trim();if(U.includes("{"))K++;if(U.includes("}"))K--;let z=U.match(/(\w+)\??\s*:\s*([^;]+)/);if(z&&K>0){let[,_,B]=z;G[_]=this.parseTypeAnnotation(B.trim())}W++}this.variables.set(Q,{kind:"object",name:Q,properties:G})}}extractTypeAliases($,Z){let Y=$.match(/(?:export\s+)?type\s+(\w+)\s*=\s*(.+)/);if(Y){let[,J,X]=Y,Q=this.parseTypeAnnotation(X.trim());Q.name=J,this.variables.set(J,Q)}}parseTypeAnnotation($){let Z=$.trim();if(Z.includes("|"))return{kind:"union",types:Z.split("|").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.includes("&"))return{kind:"intersection",types:Z.split("&").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.endsWith("[]"))return{kind:"array",elementType:this.parseTypeAnnotation(Z.slice(0,-2))};let Y=Z.match(/^Array<(.+)>$/);if(Y)return{kind:"array",elementType:this.parseTypeAnnotation(Y[1])};if(Z.startsWith("{")&&Z.endsWith("}")){let X={},Q=Z.slice(1,-1).trim();if(Q){let G=this.splitByComma(Q);for(let K of G){let W=K.match(/(\w+)\??\s*:\s*(.+)/);if(W){let[,U,z]=W;X[U]=this.parseTypeAnnotation(z.trim())}}}return{kind:"object",properties:X}}if(Z.startsWith('"')||Z.startsWith("'"))return{kind:"literal",value:Z.slice(1,-1)};if(/^\d+$/.test(Z))return{kind:"literal",value:Z};if(Z==="true"||Z==="false")return{kind:"literal",value:Z};if(["string","number","boolean","null","undefined","any","unknown","void","never"].includes(Z))return{kind:"primitive",value:Z};if(this.variables.has(Z))return this.variables.get(Z);return{kind:"primitive",value:"any"}}inferType($){let Z=$.trim().replace(/;$/,"");if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return{kind:"primitive",value:"string"};if(/^-?\d+(\.\d+)?$/.test(Z))return{kind:"primitive",value:"number"};if(Z==="true"||Z==="false")return{kind:"primitive",value:"boolean"};if(Z==="null")return{kind:"primitive",value:"null"};if(Z==="undefined")return{kind:"primitive",value:"undefined"};if(Z.startsWith("[")){let Y=Z.slice(1,-1).trim();if(Y){let J=this.splitByComma(Y)[0];if(J)return{kind:"array",elementType:this.inferType(J.trim())}}return{kind:"array",elementType:{kind:"primitive",value:"any"}}}if(Z.startsWith("{")){let Y={},J=this.extractObjectLiteral(Z);for(let[X,Q]of Object.entries(J))Y[X]=this.inferType(Q);return{kind:"object",properties:Y}}if(Z.includes("=>")){let Y=Z.match(/^\(([^)]*)\)\s*(?::\s*(\w+))?\s*=>/);if(Y){let J=this.parseParams(Y[1]),X=Y[2]?this.parseTypeAnnotation(Y[2]):{kind:"primitive",value:"any"};return{kind:"function",params:J,returnType:X}}}if(/^\w+$/.test(Z)&&this.variables.has(Z))return this.variables.get(Z);if(Z.includes("."))return this.resolvePropertyAccess(Z);if(Z.includes("(")){let Y=Z.split("(")[0],J=this.variables.get(Y);if(J?.kind==="function"&&J.returnType)return J.returnType}return{kind:"primitive",value:"any"}}parseParams($){if(!$.trim())return[];let Z=[],Y=this.splitByComma($);for(let J of Y){let X=J.trim(),Q=X.includes("?"),G=X.match(/(\w+)\??\s*(?::\s*([^=]+))?(?:\s*=)?/);if(G){let[,K,W]=G,U=W?this.parseTypeAnnotation(W.trim()):{kind:"primitive",value:"any"};Z.push({name:K,type:U,optional:Q})}}return Z}checkExpressions($){let Z=/\{\{([\s\S]*?)\}\}/g,Y;while((Y=Z.exec($))!==null){let X=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!X)continue;if(X.startsWith("!")||X.endsWith("!"))continue;this.checkExpression(X,G,K)}let J=/\{!!([\s\S]*?)!!\}/g;while((Y=J.exec($))!==null){let X=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!X)continue;this.checkExpression(X,G,K)}}checkExpression($,Z,Y){if($.includes("?")&&$.includes(":")){let Q=$.split("?");this.checkExpression(Q[0].trim(),Z,Y);let G=Q.slice(1).join("?").split(":");if(G.length>=2)this.checkExpression(G[0].trim(),Z,Y),this.checkExpression(G.slice(1).join(":").trim(),Z,Y);return}for(let Q of["&&","||","??"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}for(let Q of["===","!==","==","!=",">=","<=",">","<"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}if($.startsWith("!")){this.checkExpression($.slice(1).trim(),Z,Y);return}if(this.isLiteral($))return;let J=$.match(/^(\w+(?:\.\w+)*)\s*\(/);if(J){let Q=J[1],G=this.resolvePropertyAccess(Q);if(G.kind!=="function"&&G.value!=="any")this.addWarning(`'${Q}' is not a function`,Z,Y,$);return}if($.includes(".")){if(this.resolvePropertyAccess($).value==="undefined"&&this.options.checkPropertyAccess)this.addWarning(`Property access '${$}' may be undefined`,Z,Y,$);return}let X=$.match(/^\w+/)?.[0];if(X&&!this.variables.has(X))this.addError(`Variable '${X}' is not defined`,Z,Y,$)}checkDirectives($){let Z=/@if\s*\(([^)]+)\)/g,Y;while((Y=Z.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let J=/@foreach\s*\((\w+)\s+(?:as|in)\s+(\w+)(?:\s*,\s*(\w+))?\)/g;while((Y=J.exec($))!==null){let[,G,K,W]=Y,U=Y.index,z=this.getLineNumber(U,$),_=this.getColumn(U,$);if(!this.variables.has(G))this.addError(`Collection '${G}' is not defined`,z,_,Y[0]);else{let B=this.variables.get(G);if(B.kind==="array"&&B.elementType)this.variables.set(K,B.elementType);else this.variables.set(K,{kind:"primitive",value:"any"});if(W)this.variables.set(W,{kind:"primitive",value:"number"})}}let X=/@unless\s*\(([^)]+)\)/g;while((Y=X.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let Q=/@switch\s*\(([^)]+)\)/g;while((Y=Q.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}}resolvePropertyAccess($){let Z=$.split("."),Y=this.variables.get(Z[0])||{kind:"primitive",value:"any"};for(let J=1;J<Z.length;J++){let X=Z[J].replace(/\(\)$/,"");if(Y.kind==="object"&&Y.properties)if(Y.properties[X])Y=Y.properties[X];else if(!this.options.allowAny)return{kind:"primitive",value:"undefined"};else Y={kind:"primitive",value:"any"};else if(Y.kind==="array"&&Y.elementType)if(["length"].includes(X))Y={kind:"primitive",value:"number"};else if(["map","filter","find","forEach","some","every","reduce"].includes(X))Y={kind:"function",returnType:{kind:"primitive",value:"any"}};else if(["join"].includes(X))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else Y={kind:"primitive",value:"any"};else if(Y.kind==="primitive"&&Y.value==="string")if(["length"].includes(X))Y={kind:"primitive",value:"number"};else if(["toUpperCase","toLowerCase","trim","slice","substring"].includes(X))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else if(["split"].includes(X))Y={kind:"function",returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}};else Y={kind:"primitive",value:"any"};else Y={kind:"primitive",value:"any"}}return Y}isLiteral($){let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return!0;if(/^-?\d+(\.\d+)?$/.test(Z))return!0;if(Z==="true"||Z==="false")return!0;if(Z==="null"||Z==="undefined")return!0;return!1}extractObjectLiteral($){let Z={},Y=$.slice(1,-1).trim();if(!Y)return Z;let J=this.splitByComma(Y);for(let X of J){let Q=X.indexOf(":");if(Q>0){let G=X.slice(0,Q).trim(),K=X.slice(Q+1).trim();Z[G]=K}}return Z}splitByComma($){let Z=[],Y="",J=0,X=null;for(let Q=0;Q<$.length;Q++){let G=$[Q],K=Q>0?$[Q-1]:"";if((G==='"'||G==="'"||G==="`")&&K!=="\\"){if(X===G)X=null;else if(!X)X=G}if(!X){if(G==="{"||G==="["||G==="(")J++;if(G==="}"||G==="]"||G===")")J--;if(G===","&&J===0){Z.push(Y.trim()),Y="";continue}}Y+=G}if(Y.trim())Z.push(Y.trim());return Z}getLineNumber($,Z){return((Z||"").slice(0,$).match(/\n/g)||[]).length+1}getColumn($,Z){let J=Z.slice(0,$).lastIndexOf(`
|
|
15996
|
-
`);return $-J}addError($,Z,Y,J,X,Q){this.errors.push({message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"error"})}addWarning($,Z,Y,J,X,Q){let G={message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,Z){this.variables.set($,Z)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(lF).forEach(([$,Z])=>{this.variables.set($,Z)})}}function oK($){return new
|
|
16013
|
+
`);return $-J}addError($,Z,Y,J,X,Q){this.errors.push({message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"error"})}addWarning($,Z,Y,J,X,Q){let G={message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,Z){this.variables.set($,Z)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(lF).forEach(([$,Z])=>{this.variables.set($,Z)})}}function oK($){return new sK($)}function Fv($,Z){return oK(Z).checkFile($)}function Av($,Z){return oK(Z).checkTemplate($)}function wv($){let Z=[];for(let Y of $.errors){if(Z.push(`\x1B[31merror\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");if(Y.expected&&Y.received)Z.push(` expected: ${Y.expected}`),Z.push(` received: ${Y.received}`);Z.push("")}for(let Y of $.warnings){if(Z.push(`\x1B[33mwarning\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");Z.push("")}if($.valid)Z.push("\x1B[32m\u2713 No type errors found\x1B[0m");else Z.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return Z.join(`
|
|
15997
16014
|
`)}var Vv,lF;var cF=D(()=>{Vv={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},lF={console:{kind:"object",properties:{log:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},error:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},warn:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}}}},Math:{kind:"object",properties:{abs:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},floor:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},ceil:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},round:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},max:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},min:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},random:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},PI:{kind:"primitive",value:"number"},E:{kind:"primitive",value:"number"}}},JSON:{kind:"object",properties:{stringify:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},parse:{kind:"function",params:[{name:"text",type:{kind:"primitive",value:"string"}}],returnType:{kind:"primitive",value:"any"}}}},Date:{kind:"function",returnType:{kind:"object",properties:{getTime:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},toISOString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}},toLocaleDateString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}}}}},Array:{kind:"object",properties:{isArray:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},from:{kind:"function",params:[{name:"arrayLike",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},Object:{kind:"object",properties:{keys:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}},values:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}},entries:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},String:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},Number:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"number"}},Boolean:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},props:{kind:"object",properties:{}},slot:{kind:"primitive",value:"string"},loop:{kind:"object",properties:{index:{kind:"primitive",value:"number"},iteration:{kind:"primitive",value:"number"},first:{kind:"primitive",value:"boolean"},last:{kind:"primitive",value:"boolean"},even:{kind:"primitive",value:"boolean"},odd:{kind:"primitive",value:"boolean"},count:{kind:"primitive",value:"number"},remaining:{kind:"primitive",value:"number"},depth:{kind:"primitive",value:"number"},parent:{kind:"object",properties:{}}}}}});async function tK($,Z,Y){if(!eK)return;try{let J=$.getAttribute("data-island-id"),X=document.querySelector(`script[data-island-props="${J}"]`),Q=X?JSON.parse(X.textContent||"{}"):{},G=await Y(),K=G.default||G.hydrate;if(typeof K!=="function"){console.error(`Island handler for "${Z}" does not export a valid hydration function`);return}await K($,Q),$.setAttribute("data-hydrated","true")}catch(J){console.error(`Failed to hydrate island "${Z}":`,J)}}function Nv($){if(!eK)return;let Z=document.querySelectorAll("[data-island]"),Y=[];if(Z.forEach((J)=>{let X=J.getAttribute("data-island"),Q=J.getAttribute("data-priority")||"lazy";if(!X||!$[X]||J.getAttribute("data-hydrated")==="true")return;if(Q==="eager")tK(J,X,$[X]);else Y.push([J,X])}),Y.length>0&&"IntersectionObserver"in window){let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target,K=G.getAttribute("data-island");if(K&&$[K]&&G.getAttribute("data-hydrated")!=="true")tK(G,K,$[K]),J.unobserve(G)}})},{rootMargin:"200px",threshold:0});Y.forEach(([X])=>{J.observe(X)})}else setTimeout(()=>{Y.forEach(([J,X])=>{if(J.getAttribute("data-hydrated")!=="true")tK(J,X,$[X])})},1000)}function Rv($){if(!eK)return;Object.entries($).forEach(([Z,Y])=>{try{let X=Y.toString().match(/import\(['"](.+)['"]\)/);if(X&&X[1]){let Q=document.createElement("link");Q.rel="modulepreload",Q.href=X[1],Q.setAttribute("data-island-module",Z),document.head.appendChild(Q)}}catch(J){console.warn(`Failed to preload island handler for "${Z}":`,J)}})}var eK;var pF=D(()=>{eK=typeof window<"u"&&typeof document<"u"});function iF($){if(!m5)return null;let Z=document.getElementById("stx-loading-indicator");if(Z)Z.remove();let Y=document.createElement("div");Y.id="stx-loading-indicator";let J=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Y.style.cssText=`
|
|
15998
16015
|
position: fixed;
|
|
15999
16016
|
top: 0;
|
|
@@ -16430,7 +16447,7 @@ else {
|
|
|
16430
16447
|
|
|
16431
16448
|
})()
|
|
16432
16449
|
</script>
|
|
16433
|
-
`;class
|
|
16450
|
+
`;class aF{instances=new Map;componentsByFile=new Map;stateSnapshots=new Map;config;constructor($={}){this.config={preserveState:$.preserveState??!0,maxStateAge:$.maxStateAge??30000,errorRecovery:$.errorRecovery??!0,verbose:$.verbose??!1,serializeState:$.serializeState??this.defaultSerializeState.bind(this),deserializeState:$.deserializeState??this.defaultDeserializeState.bind(this)}}register($){if(this.instances.set($.id,$),!this.componentsByFile.has($.name))this.componentsByFile.set($.name,new Set);if(this.componentsByFile.get($.name).add($.id),this.config.verbose)console.log(`[HMR] Registered component: ${$.name} (${$.id})`)}unregister($){let Z=this.instances.get($);if(!Z)return;if(this.componentsByFile.get(Z.name)?.delete($),this.componentsByFile.get(Z.name)?.size===0)this.componentsByFile.delete(Z.name);if(this.stateSnapshots.delete($),Z.cleanup?.(),this.instances.delete($),this.config.verbose)console.log(`[HMR] Unregistered component: ${Z.name} (${$})`)}getInstancesByFile($){let Z=this.componentsByFile.get($)||new Set;return Array.from(Z).map((Y)=>this.instances.get(Y)).filter(Boolean)}getInstance($){return this.instances.get($)}captureState($){let Z=this.instances.get($);if(!Z||!this.config.preserveState)return;let Y=this.config.serializeState(Z);if(this.stateSnapshots.set($,Y),this.config.verbose)console.log(`[HMR] Captured state for: ${Z.name}`)}restoreState($){let Z=this.instances.get($),Y=this.stateSnapshots.get($);if(!Z||!Y||!this.config.preserveState)return!1;if(Date.now()-Y.timestamp>this.config.maxStateAge){if(this.stateSnapshots.delete($),this.config.verbose)console.log(`[HMR] State expired for: ${Z.name}`);return!1}try{if(this.config.deserializeState(Y,Z),this.config.verbose)console.log(`[HMR] Restored state for: ${Z.name}`);return!0}catch(J){return console.error(`[HMR] Failed to restore state for ${Z.name}:`,J),!1}}defaultSerializeState($){let Z={},Y={};if($.element)$.element.querySelectorAll("[data-stx-ref]").forEach((X)=>{let Q=X.getAttribute("data-stx-ref"),G=X.getAttribute("data-stx-value");if(Q&&G)try{Z[Q]=JSON.parse(G)}catch{Z[Q]=G}});return{refs:Z,reactiveObjects:Y,custom:$.state?.custom||{},timestamp:Date.now()}}defaultDeserializeState($,Z){if(Z.element)Object.entries($.refs).forEach(([Y,J])=>{let X=Z.element.querySelector(`[data-stx-ref="${Y}"]`);if(X)X.setAttribute("data-stx-value",JSON.stringify(J)),X.dispatchEvent(new CustomEvent("stx:state-restored",{detail:{name:Y,value:J},bubbles:!0}))});Z.state={...$,timestamp:Date.now()}}getAllInstances(){return Array.from(this.instances.values())}clear(){for(let $ of this.instances.values())$.cleanup?.();this.instances.clear(),this.componentsByFile.clear(),this.stateSnapshots.clear()}}class JW{registry;config;pendingUpdates=new Map;updateQueue=Promise.resolve();constructor($={}){this.config={preserveState:$.preserveState??!0,maxStateAge:$.maxStateAge??30000,errorRecovery:$.errorRecovery??!0,verbose:$.verbose??!1,serializeState:$.serializeState??(()=>({refs:{},reactiveObjects:{},custom:{},timestamp:Date.now()})),deserializeState:$.deserializeState??(()=>{})},this.registry=new aF(this.config)}register($){this.registry.register($)}unregister($){this.registry.unregister($)}async handleUpdate($){return this.updateQueue=this.updateQueue.then(()=>this.processUpdate($)),this.updateQueue}async processUpdate($){let Z=this.registry.getInstancesByFile($.file);if(Z.length===0){if(this.config.verbose)console.log(`[HMR] No instances found for: ${$.file}`);return}if(this.config.verbose)console.log(`[HMR] Updating ${Z.length} instance(s) of: ${$.file}`);for(let Y of Z)await this.updateInstance(Y,$);if(typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hmr-update",{detail:{file:$.file,count:Z.length}}))}async updateInstance($,Z){this.registry.captureState($.id);let Y=!1,J=$.element?.innerHTML||"";try{if($.element?.dispatchEvent(new CustomEvent("stx:before-hmr-update",{bubbles:!0})),$.cleanup?.(),Z.type==="style")await this.updateStyles($,Z);else await this.updateComponent($,Z);let X=this.registry.restoreState($.id);if(!X&&$.setup)await $.setup();$.element?.dispatchEvent(new CustomEvent("stx:after-hmr-update",{detail:{stateRestored:X},bubbles:!0}))}catch(X){if(Y=!0,console.error(`[HMR] Error updating component ${$.name}:`,X),this.config.errorRecovery){if($.element&&J)$.element.innerHTML=J,console.log(`[HMR] Recovered previous state for: ${$.name}`);$.element?.dispatchEvent(new CustomEvent("stx:hmr-error",{detail:{error:X},bubbles:!0}))}}if(!Y&&this.config.verbose)console.log(`[HMR] Successfully updated: ${$.name}`)}async updateComponent($,Z){if(!$.element)return;let{html:Y,script:J}=this.parseComponentCode(Z.code);if(Y)$.element.innerHTML=Y;if(J)await this.executeScript(J,$);if($.render)$.element.innerHTML=$.render();this.reinitializeInteractivity($)}async updateStyles($,Z){if(!$.element)return;let Y=Z.code.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(!Y)return;let J=Y[1],X=$.id,Q=document.querySelector(`style[data-stx-component="${X}"]`);if(!Q)Q=document.createElement("style"),Q.setAttribute("data-stx-component",X),document.head.appendChild(Q);if(Q.textContent=J,this.config.verbose)console.log(`[HMR] Updated styles for: ${$.name}`)}parseComponentCode($){let Z=$,Y="",J="",X=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(X)Y=X[1],Z=Z.replace(X[0],"");let Q=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i);if(Q)J=Q[1],Z=Z.replace(Q[0],"");return{html:Z.trim(),script:Y.trim(),style:J.trim()}}async executeScript($,Z){try{let Y={element:Z.element,props:Z.props,...typeof window<"u"?window.stx:{}},J=`
|
|
16434
16451
|
return (async function() {
|
|
16435
16452
|
${$}
|
|
16436
16453
|
})()
|
|
@@ -16701,7 +16718,7 @@ else {
|
|
|
16701
16718
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
16702
16719
|
})();
|
|
16703
16720
|
</script>
|
|
16704
|
-
`}function bv($){if(!l5)l5=new JW($);return l5}function Pv(){if(l5)l5.getRegistry().clear(),l5=null}var l5=null;var
|
|
16721
|
+
`}function bv($){if(!l5)l5=new JW($);return l5}function Pv(){if(l5)l5.getRegistry().clear(),l5=null}var l5=null;var sF=()=>{};function oF($){let Z={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return Z.checksum=tF(Z),JSON.stringify(Z).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function tF($){let Z=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Y=0;for(let J=0;J<Z.length;J++){let X=Z.charCodeAt(J);Y=(Y<<5)-Y+X,Y=Y&Y}return Math.abs(Y).toString(36)}function eF($){return`<script id="__STX_STATE__" type="application/json">${oF($)}</script>`}function yv($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function $A(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let Z=JSON.parse($.textContent||"{}");if(Z.checksum){if(tF(Z)!==Z.checksum)console.warn("[Hydration] State checksum mismatch - state may be corrupted")}return Z}catch(Z){return console.error("[Hydration] Failed to parse state:",Z),null}}class QW{state=null;options;root=null;isHydrated=!1;pendingComponents=new Map;hydratedComponents=new Set;constructor($={}){this.options={root:$.root||"#app",strict:$.strict??!1,onHydrating:$.onHydrating||(()=>{}),onHydrated:$.onHydrated||(()=>{}),onError:$.onError||console.error,performance:$.performance??!1,timeout:$.timeout??1e4}}async hydrate(){if(typeof window>"u")return;if(this.isHydrated)return;let $=this.options.performance?performance.now():0;try{this.root=typeof this.options.root==="string"?document.querySelector(this.options.root)||document.body:this.options.root,this.state=$A(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let Z=new Promise((Y,J)=>{setTimeout(()=>J(Error("Hydration timeout")),this.options.timeout)});if(await Promise.race([this.runHydration(),Z]),this.isHydrated=!0,this.root.classList.remove("stx-hydrating"),this.root.classList.add("stx-hydrated"),this.options.performance){let Y=performance.now()-$;console.log(`[Hydration] Completed in ${Y.toFixed(2)}ms`)}this.options.onHydrated(),window.dispatchEvent(new CustomEvent("stx:hydrated"))}catch(Z){this.root?.classList.remove("stx-hydrating"),this.root?.classList.add("stx-hydration-error"),this.options.onError(Z),window.dispatchEvent(new CustomEvent("stx:hydration-error",{detail:{error:Z}}))}}async runHydration(){if(!this.root)return;this.restoreGlobalState(),await this.hydrateComponents(),this.bindEventHandlers(),this.initializeReactiveBindings(),this.setupRouterIntegration()}restoreGlobalState(){if(!this.state)return;let $=window.stx;if(!$)return;if(this.state.routeParams&&$.setRouteParams)$.setRouteParams(this.state.routeParams);if(this.state.stores&&$.registerStore)Object.entries(this.state.stores).forEach(([Z,Y])=>{$.registerStore(Z,Y)});window.dispatchEvent(new CustomEvent("stx:state-restored",{detail:this.state}))}async hydrateComponents(){if(!this.root)return;let $=this.root.querySelectorAll("[data-stx-component]");for(let Z of Array.from($)){let Y=Z.getAttribute("data-stx-component"),J=Z.getAttribute("data-stx-name")||Y,X=Z.getAttribute("data-stx-hydrate")||"eager",Q=Z.getAttribute("data-stx-props");if(!Y)continue;let G={id:Y,name:J||Y,strategy:X,props:Q?JSON.parse(Q):{},events:[]};switch(this.pendingComponents.set(Y,G),G.strategy){case"eager":await this.hydrateComponent(Z,G);break;case"lazy":case"visible":this.setupVisibleHydration(Z,G);break;case"idle":this.setupIdleHydration(Z,G);break;case"interaction":this.setupInteractionHydration(Z,G);break}}}async hydrateComponent($,Z){if(this.hydratedComponents.has(Z.id))return;try{let Y=this.state?.refs[Z.id]||this.state?.reactive[Z.id]||{};this.restoreComponentState($,Y),this.bindComponentEvents($),this.initializeComponentReactivity($,Z),this.hydratedComponents.add(Z.id),$.classList.add("stx-hydrated"),$.setAttribute("data-hydrated","true"),$.dispatchEvent(new CustomEvent("stx:component-hydrated",{detail:{id:Z.id,name:Z.name},bubbles:!0}))}catch(Y){if(console.error(`[Hydration] Failed to hydrate component ${Z.id}:`,Y),$.classList.add("stx-hydration-error"),this.options.strict)throw Y}}restoreComponentState($,Z){if(!Z||typeof Z!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((J)=>{let X=J.getAttribute("data-stx-bind");if(!X||!Z[X])return;let Q=Z[X];if(J instanceof HTMLInputElement)if(J.type==="checkbox"||J.type==="radio")J.checked=Boolean(Q);else J.value=String(Q);else if(J instanceof HTMLSelectElement)J.value=String(Q);else if(J instanceof HTMLTextAreaElement)J.value=String(Q);else J.textContent=String(Q)})}setupVisibleHydration($,Z){if(!("IntersectionObserver"in window)){this.hydrateComponent($,Z);return}let Y=new IntersectionObserver((J)=>{J.forEach((X)=>{if(X.isIntersecting)Y.disconnect(),this.hydrateComponent($,Z)})},{rootMargin:"100px",threshold:0});Y.observe($)}setupIdleHydration($,Z){let Y=()=>this.hydrateComponent($,Z);if("requestIdleCallback"in window)window.requestIdleCallback(Y,{timeout:2000});else setTimeout(Y,200)}setupInteractionHydration($,Z){let Y=["mouseenter","touchstart","focusin"],J=()=>{Y.forEach((X)=>$.removeEventListener(X,J)),this.hydrateComponent($,Z)};Y.forEach((X)=>{$.addEventListener(X,J,{once:!0,passive:!0})})}bindEventHandlers(){if(!this.root)return;this.root.querySelectorAll("[data-stx-events]").forEach((Z)=>this.bindElementEvents(Z)),this.bindDirectiveEvents()}bindElementEvents($){let Z=$.getAttribute("data-stx-events");if(!Z)return;try{JSON.parse(Z).forEach((J)=>{this.bindSingleEvent($,J)})}catch(Y){console.error("[Hydration] Failed to parse events:",Y)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((Z)=>{let Y=`data-stx-on-${Z}`;this.root.querySelectorAll(`[${Y}]`).forEach((X)=>{let Q=X.getAttribute(Y);if(!Q)return;this.bindSingleEvent(X,{type:Z,handler:Q,modifiers:this.parseModifiers(X,Z)})})})}parseModifiers($,Z){let Y=[],J=$.getAttribute(`data-stx-${Z}-modifiers`);if(J)Y.push(...J.split(",").map((X)=>X.trim()));return Y}bindSingleEvent($,Z){let Y=this.resolveHandler(Z.handler);if(!Y){console.warn(`[Hydration] Handler not found: ${Z.handler}`);return}let J=(Q)=>{if(Z.modifiers?.includes("prevent")||Z.preventDefault)Q.preventDefault();if(Z.modifiers?.includes("stop")||Z.stopPropagation)Q.stopPropagation();try{Y.call($,Q)}catch(G){console.error("[Hydration] Event handler error:",G)}},X={};if(Z.modifiers?.includes("once"))X.once=!0;if(Z.modifiers?.includes("passive"))X.passive=!0;if(Z.modifiers?.includes("capture"))X.capture=!0;$.addEventListener(Z.type,J,X)}resolveHandler($){let Z=window.stx;if(Z&&Z[$])return Z[$];if(window[$])return window[$];try{if($.match(/^\w+\+\+$/)||$.match(/^\w+--$/)){let X=$.replace(/[+-]+$/,"");return()=>{if(Z&&Z[X]){if(typeof Z[X].value<"u")if($.includes("++"))Z[X].value++;else Z[X].value--}}}let Y=$.match(/^(\w+)\s*=\s*(.+)$/);if(Y){let[,X,Q]=Y;return()=>{if(Z&&Z[X]){let G=Function(`return ${Q}`)();if(typeof Z[X].value<"u")Z[X].value=G}}}let J=$.match(/^(\w+)\((.*)\)$/);if(J){let[,X,Q]=J;return(G)=>{let K=Z?.[X]||window[X];if(K){let W=Q?Function("$event",`return [${Q}]`)(G):[];K(...W)}}}return(X)=>{Function("$event","stx",$)(X,Z)}}catch{return null}}bindComponentEvents($){$.querySelectorAll("[data-stx-events]").forEach((Y)=>{this.bindElementEvents(Y)})}initializeComponentReactivity($,Z){if(!window.stx)return;$.querySelectorAll("[data-stx-reactive]").forEach((X)=>{let Q=X.getAttribute("data-stx-reactive");if(!Q)return;this.setupReactiveBinding(X,Q)})}initializeReactiveBindings(){if(!this.root)return;this.getTextNodesWithExpressions(this.root).forEach(({node:Y,expressions:J})=>{J.forEach((X)=>{this.setupTextNodeBinding(Y,X)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Y)=>{let J=Y.getAttribute("data-stx-bind-attrs");if(!J)return;try{let X=JSON.parse(J);Object.entries(X).forEach(([Q,G])=>{this.setupAttributeBinding(Y,Q,G)})}catch{}})}getTextNodesWithExpressions($){let Z=[],Y=document.createTreeWalker($,NodeFilter.SHOW_TEXT),J;while(J=Y.nextNode()){let Q=(J.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(Q)Z.push({node:J,expressions:Q.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return Z}setupTextNodeBinding($,Z){let Y=window.stx;if(!Y)return;let J=$.textContent||"",X=()=>{try{let G=Function("stx",`with(stx) { return ${Z} }`)(Y);$.textContent=J.replace(new RegExp(`\\{\\{\\s*${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};X();let Q=Z.match(/^(\w+)(\.value)?$/);if(Q&&Y[Q[1]]?.subscribe)Y[Q[1]].subscribe(X)}setupAttributeBinding($,Z,Y){let J=window.stx;if(!J)return;let X=()=>{try{let G=Function("stx",`with(stx) { return ${Y} }`)(J);if(typeof G==="boolean")if(G)$.setAttribute(Z,"");else $.removeAttribute(Z);else $.setAttribute(Z,String(G))}catch{}};X();let Q=Y.match(/^(\w+)(\.value)?$/);if(Q&&J[Q[1]]?.subscribe)J[Q[1]].subscribe(X)}setupReactiveBinding($,Z){let Y=window.stx;if(!Y)return;let J=()=>{try{let Q=Function("stx",`with(stx) { return ${Z} }`)(Y);$.textContent=String(Q)}catch{}};J();let X=Z.match(/^(\w+)(\.value)?$/);if(X&&Y[X[1]]?.subscribe)Y[X[1]].subscribe(J)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:Z}=$.detail||{};if(Z){if(window.stx?.setRouteParams){let J=new URL(Z,window.location.origin)}}}),window.addEventListener("stx:load",()=>{this.hydrateComponents(),this.bindEventHandlers()})}get hydrated(){return this.isHydrated}getState(){return this.state}async hydrateById($){let Z=this.pendingComponents.get($),Y=document.querySelector(`[data-stx-component="${$}"]`);if(Z&&Y)await this.hydrateComponent(Y,Z)}}function xv($){return`
|
|
16705
16722
|
${$?eF($):""}
|
|
16706
16723
|
<script data-stx-hydration-runtime>
|
|
16707
16724
|
(function() {
|
|
@@ -17465,7 +17482,7 @@ else {
|
|
|
17465
17482
|
border: none;
|
|
17466
17483
|
color: white;
|
|
17467
17484
|
}
|
|
17468
|
-
`.trim();return{html:Q,script:G,css:K}}function AA($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function nJ(){return"loading"in HTMLImageElement.prototype}function rJ(){return"IntersectionObserver"in window}function cW($={}){let Z={...TA,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&nJ())return Y.forEach((X)=>{if(X.tagName==="IMG"||X.tagName==="IFRAME")d4(X,Z)}),()=>{};if(!rJ())return Y.forEach((X)=>d4(X,Z)),()=>{};let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;d4(G,Z),J.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((X)=>J.observe(X)),()=>{J.disconnect()}}function d4($,Z={}){let{onLoad:Y,onLoaded:J,onError:X}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)RA($,J,X);else if(G)MA($,J,X);else if(K)nv($,J,X);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)RA(W,()=>{if(J)J($)},(_)=>{if(X)X($,_)});else if(U)MA(U,()=>{if(J)J($)},(_)=>{if(X)X($,_)});$.querySelectorAll("source[data-srcset]").forEach((_)=>{let B=_;if(B.dataset.srcset)B.srcset=B.dataset.srcset,delete B.dataset.srcset;if(B.dataset.sizes)B.sizes=B.dataset.sizes,delete B.dataset.sizes})}}function RA($,Z,Y){let J=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let Q=$.closest(".stx-img-placeholder");if(Q)Q.classList.add("stx-img-loaded");if(Z)Z($)},X=()=>{if($.classList.add("stx-img-error"),Y)Y($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function MA($,Z,Y){let J=()=>{if($.classList.add("stx-video-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-video-error"),Y)Y($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let K=G;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function nv($,Z,Y){let J=()=>{if($.classList.add("stx-iframe-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-iframe-error"),Y)Y($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function pW($){d4($,{})}function iW($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>d4(Y,{}))}function nW($={}){let Z={...TA,...$};return new IntersectionObserver((Y,J)=>{Y.forEach((X)=>{if(X.isIntersecting)d4(X.target,Z),J.unobserve(X.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function rW($,Z){$.observe(Z)}function
|
|
17485
|
+
`.trim();return{html:Q,script:G,css:K}}function AA($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function nJ(){return"loading"in HTMLImageElement.prototype}function rJ(){return"IntersectionObserver"in window}function cW($={}){let Z={...TA,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&nJ())return Y.forEach((X)=>{if(X.tagName==="IMG"||X.tagName==="IFRAME")d4(X,Z)}),()=>{};if(!rJ())return Y.forEach((X)=>d4(X,Z)),()=>{};let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;d4(G,Z),J.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((X)=>J.observe(X)),()=>{J.disconnect()}}function d4($,Z={}){let{onLoad:Y,onLoaded:J,onError:X}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)RA($,J,X);else if(G)MA($,J,X);else if(K)nv($,J,X);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)RA(W,()=>{if(J)J($)},(_)=>{if(X)X($,_)});else if(U)MA(U,()=>{if(J)J($)},(_)=>{if(X)X($,_)});$.querySelectorAll("source[data-srcset]").forEach((_)=>{let B=_;if(B.dataset.srcset)B.srcset=B.dataset.srcset,delete B.dataset.srcset;if(B.dataset.sizes)B.sizes=B.dataset.sizes,delete B.dataset.sizes})}}function RA($,Z,Y){let J=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let Q=$.closest(".stx-img-placeholder");if(Q)Q.classList.add("stx-img-loaded");if(Z)Z($)},X=()=>{if($.classList.add("stx-img-error"),Y)Y($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function MA($,Z,Y){let J=()=>{if($.classList.add("stx-video-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-video-error"),Y)Y($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let K=G;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function nv($,Z,Y){let J=()=>{if($.classList.add("stx-iframe-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-iframe-error"),Y)Y($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function pW($){d4($,{})}function iW($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>d4(Y,{}))}function nW($={}){let Z={...TA,...$};return new IntersectionObserver((Y,J)=>{Y.forEach((X)=>{if(X.isIntersecting)d4(X.target,Z),J.unobserve(X.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function rW($,Z){$.observe(Z)}function aW($){$.disconnect()}function W3(){return`
|
|
17469
17486
|
(function() {
|
|
17470
17487
|
'use strict';
|
|
17471
17488
|
|
|
@@ -17555,7 +17572,7 @@ else {
|
|
|
17555
17572
|
window.STX.lazyLoad = loadElement;
|
|
17556
17573
|
window.STX.initLazyLoading = init;
|
|
17557
17574
|
})();
|
|
17558
|
-
`.trim()}var TA;var
|
|
17575
|
+
`.trim()}var TA;var sW=D(()=>{TA={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"}});function aJ($,Z={}){let Y={...rv,...Z},J=$.closest(".stx-img-placeholder");if(!J){av($,Y);return}if(J.style.setProperty("--stx-img-transition-duration",`${Y.duration}ms`),J.style.setProperty("--stx-img-transition-easing",Y.easing),Y.loadingClass)J.classList.add(Y.loadingClass);if($.complete&&$.naturalWidth>0)EA($,J,Y);else $.addEventListener("load",()=>EA($,J,Y),{once:!0}),$.addEventListener("error",()=>sv($,J,Y),{once:!0})}function av($,Z){let Y=()=>{$.style.transition=`opacity ${Z.duration}ms ${Z.easing}`,$.style.opacity="1",$.classList.remove(Z.loadingClass),$.classList.add(Z.loadedClass)};if($.complete&&$.naturalWidth>0)Y();else $.style.opacity="0",$.classList.add(Z.loadingClass),$.addEventListener("load",Y,{once:!0})}function EA($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);if(Y.loadedClass)Z.classList.add(Y.loadedClass);if($.style.opacity="1",Y.removePlaceholder)setTimeout(()=>{Z.style.backgroundImage="none"},Y.duration)}function sv($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);Z.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function oW($,Z){let Y=U3($),J=Z.getContext("2d");if(!J)return;Z.width=Y.w,Z.height=Y.h;let X=J.createImageData(Y.w,Y.h);X.data.set(Y.rgba),J.putImageData(X,0,0)}function U3($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,J=(Z>>6&63)/31.5-1,X=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,z=K>>15!==0,_=Math.max(3,z?G?5:7:G?5:5),B=Math.max(3,z?G?5:5:G?5:7),q=32,j=32,H=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let V=0;V<32;V++){let L=(O*32+V)*4,F=V/31,A=O/31,w=Y+(F-0.5)*Q*0.5+(A-0.5)*Q*0.5,N=J*(1-F*0.3),R=X*(1-A*0.3),E=w-0.6666666666666666*N,M=(3*w-E+R)/2,I=M-R;H[L]=Math.max(0,Math.min(255,Math.round(M*255))),H[L+1]=Math.max(0,Math.min(255,Math.round(I*255))),H[L+2]=Math.max(0,Math.min(255,Math.round(E*255))),H[L+3]=255}return{w:32,h:32,rgba:H}}function tW($){let Z=U3($),Y=document.createElement("canvas");Y.width=Z.w,Y.height=Z.h;let J=Y.getContext("2d");if(!J)return"";let X=J.createImageData(Z.w,Z.h);return X.data.set(Z.rgba),J.putImageData(X,0,0),Y.toDataURL("image/png")}function eW($){let Z=atob($),Y=new Uint8Array(Z.length);for(let J=0;J<Z.length;J++)Y[J]=Z.charCodeAt(J);return Y}function $U($,Z,Y=300){return new Promise((J)=>{$.style.transition=`opacity ${Y}ms ease-out`,Z.style.transition=`opacity ${Y}ms ease-out`,Z.style.opacity="0",Z.offsetWidth,$.style.opacity="0",Z.style.opacity="1",setTimeout(J,Y)})}function ZU($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Y)=>{aJ(Y,$)})}function z3(){return`
|
|
17559
17576
|
(function() {
|
|
17560
17577
|
'use strict';
|
|
17561
17578
|
|
|
@@ -17654,7 +17671,7 @@ else {
|
|
|
17654
17671
|
.stx-img-error {
|
|
17655
17672
|
opacity: 0.5;
|
|
17656
17673
|
}
|
|
17657
|
-
`.trim()}var rv;var YU=D(()=>{rv={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"}});function
|
|
17674
|
+
`.trim()}var rv;var YU=D(()=>{rv={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"}});function sJ($,Z={}){if(Z.maxSize&&$.size>Z.maxSize)return{valid:!1,error:`File size (${IA($.size)}) exceeds maximum (${IA(Z.maxSize)})`,code:"FILE_TOO_LARGE"};if(Z.accept&&Z.accept.length>0){if(!Z.accept.some((J)=>{if(J.endsWith("/*")){let X=J.slice(0,-1);return $.type.startsWith(X)}return $.type===J}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function IA($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function oJ($,Z,Y){let J={...ov,...Z},X=sJ($,J);if(!X.valid)return{success:!1,error:X.error,name:$.name,size:$.size,type:$.type};if(J.chunkSize&&$.size>J.chunkSize)return ev($,J,Y);return tv($,J,Y)}async function tv($,Z,Y){return new Promise((J)=>{let X=new XMLHttpRequest,Q=Date.now(),G=0,K=Q;X.upload.addEventListener("progress",(U)=>{if(U.lengthComputable&&Y){let z=Date.now(),_=(z-K)/1000,B=U.loaded-G,q=_>0?B/_:0,j=U.total-U.loaded,H=q>0?j/q*1000:void 0;G=U.loaded,K=z,Y({file:$,loaded:U.loaded,total:U.total,percent:Math.round(U.loaded/U.total*100),speed:q,timeRemaining:H})}}),X.addEventListener("load",()=>{if(X.status>=200&&X.status<300)try{let U=JSON.parse(X.responseText);J({success:!0,url:U.url,id:U.id,name:$.name,size:$.size,type:$.type,data:U})}catch{J({success:!0,name:$.name,size:$.size,type:$.type})}else J({success:!1,error:`Upload failed with status ${X.status}`,name:$.name,size:$.size,type:$.type})}),X.addEventListener("error",()=>{J({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),X.addEventListener("timeout",()=>{J({success:!1,error:"Upload timed out",name:$.name,size:$.size,type:$.type})});let W=new FormData;if(W.append(Z.fieldName||"file",$),Z.formData)for(let[U,z]of Object.entries(Z.formData))W.append(U,z);if(X.open(Z.method||"POST",Z.endpoint),X.timeout=Z.timeout||60000,X.withCredentials=Z.withCredentials||!1,Z.headers)for(let[U,z]of Object.entries(Z.headers))X.setRequestHeader(U,z);X.send(W)})}async function ev($,Z,Y){let J=Z.chunkSize,X=Math.ceil($.size/J),Q=0,G;for(let K=0;K<X;K++){let W=K*J,U=Math.min(W+J,$.size),z=$.slice(W,U),_=new FormData;if(_.append(Z.fieldName||"file",z,$.name),_.append("chunk",String(K)),_.append("totalChunks",String(X)),_.append("fileName",$.name),_.append("fileSize",String($.size)),_.append("fileType",$.type),G)_.append("uploadId",G);if(Z.formData)for(let[B,q]of Object.entries(Z.formData))_.append(B,q);try{let B=await fetch(Z.endpoint,{method:Z.method||"POST",headers:Z.headers,credentials:Z.withCredentials?"include":"same-origin",body:_});if(!B.ok)return{success:!1,error:`Chunk ${K+1}/${X} failed with status ${B.status}`,name:$.name,size:$.size,type:$.type};let q=await B.json();if(!G&&q.uploadId)G=q.uploadId;if(Q=U,Y)Y({file:$,loaded:Q,total:$.size,percent:Math.round(Q/$.size*100),chunk:K+1,totalChunks:X});if(K===X-1)return{success:!0,url:q.url,id:q.id||G,name:$.name,size:$.size,type:$.type,data:q}}catch(B){return{success:!1,error:`Chunk upload failed: ${B}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function JU($,Z,Y,J){let X=[];for(let Q of $){let G=await oJ(Q,Z,(K)=>{if(Y)Y(Q,K)});if(X.push(G),J)J(Q,G)}return X}function XU($,Z=200){return new Promise((Y,J)=>{if(!$.type.startsWith("image/")){J(Error("File is not an image"));return}let X=new FileReader;X.onload=(Q)=>{let G=new Image;G.onload=()=>{let K=document.createElement("canvas"),W=G.width,U=G.height;if(W>Z||U>Z)if(W>U)U=Math.round(U*Z/W),W=Z;else W=Math.round(W*Z/U),U=Z;K.width=W,K.height=U;let z=K.getContext("2d");if(z)z.drawImage(G,0,0,W,U),Y(K.toDataURL("image/jpeg",0.7));else J(Error("Could not get canvas context"))},G.onerror=()=>J(Error("Could not load image")),G.src=Q.target?.result},X.onerror=()=>J(Error("Could not read file")),X.readAsDataURL($)})}function QU($){return new Promise((Z,Y)=>{if(!$.type.startsWith("video/")){Y(Error("File is not a video"));return}let J=document.createElement("video"),X=document.createElement("canvas");J.preload="metadata",J.muted=!0,J.playsInline=!0,J.onloadeddata=()=>{J.currentTime=0.1},J.onseeked=()=>{X.width=J.videoWidth,X.height=J.videoHeight;let Q=X.getContext("2d");if(Q)Q.drawImage(J,0,0),Z(X.toDataURL("image/jpeg",0.7));else Y(Error("Could not get canvas context"));URL.revokeObjectURL(J.src)},J.onerror=()=>{URL.revokeObjectURL(J.src),Y(Error("Could not load video"))},J.src=URL.createObjectURL($)})}function B3(){return`
|
|
17658
17675
|
(function() {
|
|
17659
17676
|
'use strict';
|
|
17660
17677
|
|
|
@@ -17724,7 +17741,7 @@ else {
|
|
|
17724
17741
|
})();
|
|
17725
17742
|
`.trim()}var ov;var GU=D(()=>{ov={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function KU(){return{script:[W3(),z3(),B3()].join(`
|
|
17726
17743
|
|
|
17727
|
-
`),css:_3()}}function DA(){let{script:$,css:Z}=KU(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),J=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:J}}var kA=D(()=>{
|
|
17744
|
+
`),css:_3()}}function DA(){let{script:$,css:Z}=KU(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),J=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:J}}var kA=D(()=>{sW();YU();GU();sW();YU();GU()});var SA=D(()=>{j6();mY()});var $f;var CA=D(()=>{jA();WG();IG();EG();OA();FA();kA();SA();$f={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]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},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}}});import tJ from"fs";import B$ from"path";async function WU($,Z={},Y={}){let J=await Bun.file($).text(),X=J.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=X?X[1]:"",G=X?J.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):J;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:B$.dirname($),props:Z,...Z};if(Q)await D0(Q,K,$);let W={...N1,...Y};return await q0(G,K,$,W,new Set)}async function bA($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:J,outputDir:X,componentsDir:Q=B$.join(J,"components"),layoutsDir:G=B$.join(J,"layouts"),partialsDir:K=B$.join(J,"partials"),globalProps:W={},placeholders:U={},views:z,debug:_=!1,generateManifest:B=!0}=$;if(_)console.log("Building STX views..."),console.log(` Source: ${J}`),console.log(` Output: ${X}`);tJ.mkdirSync(X,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:_},j;if(z&&z.length>0)j=z;else j=tJ.readdirSync(J).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=B$.join(J,H.input),V=H.output||H.input.replace(/\.stx$/,".html"),L=B$.join(X,V);if(_)console.log(` Building ${H.input}...`);try{let F={...W,...H.props,...U},A=await WU(O,F,q);await Bun.write(L,A),Y.views.push(V)}catch(F){let A=F instanceof Error?F.message:String(F);if(Y.errors.push({file:H.input,error:A}),Y.success=!1,_)console.error(` Error: ${A}`)}}if(B){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(B$.join(X,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,_)if(Y.success)console.log(`
|
|
17728
17745
|
\u2705 Built ${Y.views.length} views in ${Y.duration.toFixed(0)}ms`);else console.log(`
|
|
17729
17746
|
\u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function Zf($,Z){let Y=tJ.watch($.viewsDir,{recursive:!0},async(J,X)=>{if(!X)return;if(X.endsWith(".stx")||X.endsWith(".ts")||X.endsWith(".js")){if($.debug)console.log(`
|
|
17730
17747
|
File changed: ${X}, rebuilding...`);let Q=await bA($);Z?.(Q)}});return{close:()=>Y.close()}}async function Yf($,Z={},Y={}){let J={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},X=await WU($,Z,J);X=await Jf(X),X=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),X=X.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),X=X.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),X=X.replace(/\n\s*\n\s*\n/g,`
|
|
@@ -17818,7 +17835,7 @@ File changed: ${X}, rebuilding...`);let Q=await bA($);Z?.(Q)}});return{close:()=
|
|
|
17818
17835
|
return refs;
|
|
17819
17836
|
};
|
|
17820
17837
|
})();
|
|
17821
|
-
`}var Y4=null,eJ;var UU=D(()=>{eJ=new Map});function zf($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function zU($){return $.replace(/&/g,"&").replace(/"/g,""")}function
|
|
17838
|
+
`}var Y4=null,eJ;var UU=D(()=>{eJ=new Map});function zf($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function zU($){return $.replace(/&/g,"&").replace(/"/g,""")}function aA($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[iA($)];return $.flat(1/0).map(iA).filter((Z)=>Z!=="")}function iA($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function H$($,Z,Y){let{children:J,ref:X,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:aA(J),key:Y??Q??void 0,ref:X??void 0}}function tA($){return Object.entries($).filter(([,Z])=>Z!=null&&Z!==!1).map(([Z,Y])=>{let J=Z.replace(/[A-Z]/g,(Q)=>`-${Q.toLowerCase()}`),X=typeof Y==="number"&&!J.startsWith("--")&&J!=="opacity"&&J!=="z-index"&&J!=="flex-grow"&&J!=="flex-shrink"&&J!=="order"&&J!=="font-weight"&&J!=="line-height"?`${Y}px`:String(Y);return`${J}: ${X}`}).join("; ")}function _U($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(_U).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function _f($){if(!$)return"";let Z=[];for(let[Y,J]of Object.entries($)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;if(Y.startsWith("on")&&typeof J==="function")continue;let X=rA[Y]||Y;if(X==="class"||X==="className"){let Q=_U(J);if(Q)Z.push(` class="${zU(Q)}"`);continue}if(X==="style"){let Q=typeof J==="string"?J:tA(J);if(Q)Z.push(` style="${zU(Q)}"`);continue}if(nA.has(X)){if(J)Z.push(` ${X}`);continue}if(J!=null&&J!==!1)Z.push(` ${X}="${zU(String(J))}"`)}return Z.join("")}function q$($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return zf($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(q$).join("");if($.type===j$)return $.children.map(q$).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return q$(Q)}let Z=$.type,Y=_f($.props),J=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(J!=null)return`<${Z}${Y}>${J}</${Z}>`;if(Uf.has(Z))return`<${Z}${Y}>`;let X=$.children.map(q$).join("");return`<${Z}${Y}>${X}</${Z}>`}function eA($){return new ReadableStream({start(Z){Z.enqueue(q$($)),Z.close()}})}function Bf($,Z){if(!Z)return;for(let[Y,J]of Object.entries(Z)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;let X=rA[Y]||Y;if(Y.startsWith("on")&&typeof J==="function"){let Q=Y.slice(2).toLowerCase();$.addEventListener(Q,J);continue}if(X==="class"||X==="className"){let Q=_U(J);if(Q)$.setAttribute("class",Q);continue}if(X==="style"){let Q=typeof J==="string"?J:tA(J);if(Q)$.setAttribute("style",Q);continue}if(nA.has(X)){if(J)$.setAttribute(X,"");continue}if(J!=null&&J!==!1)$.setAttribute(X,String(J))}}function i5($,Z){if($==null||typeof $==="boolean")return;if(typeof $==="string"){Z.appendChild(document.createTextNode($));return}if(typeof $==="number"){Z.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let X of $)i5(X,Z);return}if($.type===j$){for(let X of $.children)i5(X,Z);return}if(typeof $.type==="function"){let X=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});i5(X,Z);return}let Y=document.createElement($.type);Bf(Y,$.props);let J=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(J!=null)Y.innerHTML=J;else for(let X of $.children)i5(X,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function $w($){if($.when)return H$(j$,{children:$.children});return $.fallback??null}function Zw($){let Z=$.each;if(!Z||Z.length===0)return $.fallback??null;let Y=Array.isArray($.children)?$.children[0]:$.children,J=Z.map((X,Q)=>Y(X,Q));return H$(j$,{children:J})}function Yw($){return H$(j$,{children:$.children})}function Jw($,Z,...Y){let{key:J,ref:X,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:aA(Y.length===1?Y[0]:Y),key:J??void 0,ref:X??void 0}}var j$,Uf,nA,rA,sA,oA;var Xw=D(()=>{j$=Symbol.for("stx.Fragment"),Uf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),nA=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),rA={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};sA=H$,oA=H$});function BU($,Z){let Y=new Set,J=new Map,X=new Map,Q={globalProperties:{},performance:!1,compilerOptions:{}},G={config:Q,_components:J,_directives:X,_installedPlugins:Y,use(K,...W){if(Y.has(K))return G;if(Y.add(K),typeof K==="function")K(G,...W);else if(typeof K.install==="function")K.install(G,...W);return G},provide(K,W){return $X(K,W),G},component(K,W){if(!W)return J.get(K);return J.set(K,W),G},directive(K,W){if(!W)return X.get(K);return X.set(K,W),G},mount(K){if(typeof document<"u"){let W=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(W,Q.globalProperties),document.querySelectorAll("[v-cloak]").forEach((U)=>{U.removeAttribute("v-cloak")})}return G},unmount(){J.clear(),X.clear(),Y.clear()}};return G}function Qw($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let Z=this._component.render();if(typeof Z==="string")this._shadow.innerHTML=Z}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}var Gw=D(()=>{UU()});import{dirname as qf,resolve as Kw}from"path";function jf($){let Z=$,Y=_4($);if(Y)Z=Y.content.trim();let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X=[],Q=[],G=[],K=(z)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(z),W;while((W=J.exec($))!==null){let z=W[1],_=W[2],B=W[0],q=z.includes("server");if(K(_))G.push(B);else if(q)Q.push(_);else X.push(B)}let U=Z;{let z=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,_,B=[];while((_=z.exec(U))!==null){let q=_.index+_[0].length,j=1,H=q;while(H<U.length&&j>0){let O=U.indexOf("<script",H),V=U.indexOf("</script>",H);if(V===-1)break;if(O!==-1&&O<V)j++,H=O+7;else{if(j--,j===0){B.push({start:_.index,end:V+9});break}H=V+9}}}for(let q=B.length-1;q>=0;q--)U=U.substring(0,B[q].start)+U.substring(B[q].end)}for(let z of X)U=U.replace(z,"");return{templateContent:U,serverScripts:Q,clientScripts:X,signalsScripts:G}}function Hf($,Z){return`<!DOCTYPE html>
|
|
17822
17839
|
<html lang="en">
|
|
17823
17840
|
<head>
|
|
17824
17841
|
<meta charset="UTF-8">
|
|
@@ -17857,14 +17874,14 @@ ${Q}`}var r5=null;function L3($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme
|
|
|
17857
17874
|
${K}`)}if(!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${Nf(X,Q,G)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
|
|
17858
17875
|
</body>`)}return $}var wf=($,Z,Y,J)=>`(function(){window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};function read(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(J)}:${JSON.stringify(Y)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,Nf=($,Z,Y)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Y)}:${JSON.stringify(Z)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;import{existsSync as Rf,readFileSync as Mf}from"fs";import{join as Tf,resolve as Ef}from"path";import If from"process";function V3($,Z=If.cwd()){let Y=$.i18n;if(!Y||!Array.isArray(Y.locales)||Y.locales.length===0)return null;let J=Y.defaultLocale??Y.locales[0],X=Df(Y,Z);return{locales:Y.locales,defaultLocale:J,labels:Y.labels??Object.fromEntries(Y.locales.map((Q)=>[Q,Q.toUpperCase()])),translations:X,pickerSelector:Y.pickerSelector??"#lang-picker"}}function Df($,Z){let Y=$.translations??{},J={},X=$.translationsDir,Q=X===!1?null:Ef(Z,typeof X==="string"&&X?X:"translations"),G=$.format??"json";for(let K of $.locales){let W=Q?kf(Q,K,G):{};J[K]={...W,...Y[K]??{}}}return J}function kf($,Z,Y){let J=Y==="json"?[`${Z}.json`]:[`${Z}.${Y}`,`${Z}.${Y==="yaml"?"yml":"yaml"}`];for(let X of J){let Q=Tf($,X);if(!Rf(Q))continue;try{let G=Mf(Q,"utf8"),K=Y==="json"?JSON.parse(G):Sf(G);return Uw(K)}catch{continue}}return{}}function Uw($,Z="",Y={}){if(!$||typeof $!=="object")return Y;for(let[J,X]of Object.entries($)){let Q=Z?`${Z}.${J}`:J;if(X&&typeof X==="object"&&!Array.isArray(X))Uw(X,Q,Y);else if(typeof X==="string")Y[Q]=X;else if(typeof X==="number"||typeof X==="boolean")Y[Q]=String(X)}return Y}function Sf($){let Z={},Y=[{obj:Z,indent:-1}];for(let J of $.split(`
|
|
17859
17876
|
`)){let X=J.replace(/#.*$/,"").trimEnd();if(!X.trim())continue;let Q=X.search(/\S/);if(Q===-1)continue;while(Y.length>1&&Y[Y.length-1].indent>=Q)Y.pop();let G=Y[Y.length-1].obj,K=X.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!K)continue;let[,,W,U]=K,z=W.trim(),_=U.trim();if(_==="")G[z]={},Y.push({obj:G[z],indent:Q});else G[z]=Cf(_)}return Z}function Cf($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function XX($,Z,Y){let J=$.translations[Z]?.[Y];if(typeof J==="string")return J;let X=$.translations[$.defaultLocale]?.[Y];if(typeof X==="string")return X;return Y}function F3($,Z,Y){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(J,X,Q)=>{let G=XX(Z,Y,Q);return X==="!"?G:bf(G)})}function u4($,Z,Y){if(Z===Y)return $;if($==="/")return`/${Z}/`;if($==="/404.html")return`/${Z}/404.html`;return`/${Z}${$}`}function FU($,Z){for(let Y of Z){if($===`/${Y}`||$===`/${Y}/`)return{locale:Y,path:"/"};if($.startsWith(`/${Y}/`))return{locale:Y,path:$.slice(Y.length+1)}}return{locale:null,path:$}}function A3($,Z,Y){let J=$.replace(/\/$/,""),X=[];for(let G of Y.locales){let K=`${J}${u4(Z,G,Y.defaultLocale)}`;X.push(`<link rel="alternate" hreflang="${VU(G)}" href="${VU(K)}">`)}let Q=`${J}${u4(Z,Y.defaultLocale,Y.defaultLocale)}`;return X.push(`<link rel="alternate" hreflang="x-default" href="${VU(Q)}">`),X.join(`
|
|
17860
|
-
`)}function w3($,Z){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:Z,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function VU($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function bf($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var AU=()=>{};var{Glob:Pf}=globalThis.Bun;import{cpSync as yf,existsSync as KX,mkdirSync as zw,readFileSync as _w,readdirSync as xf,rmSync as vf,statSync as ff,unlinkSync as gf,writeFileSync as QX}from"fs";import{dirname as hf,join as m4,relative as df}from"path";import Bw from"process";import uf from"bun-plugin-stx";async function NU($){let Z=Date.now(),Y=$.pagesDir??"pages",J=$.outDir??"dist",X=$.publicDir??"public";if(!$.noClean)vf(J,{recursive:!0,force:!0});zw(J,{recursive:!0});let Q=new Pf(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:J,plugins:[uf()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");cf(J);let W=RU(J).filter((j)=>j.endsWith(".html")),U=V3($,Bw.cwd()),z=new Set(W.map(GX));for(let j of W){let H=m4(J,j),O=_w(H,"utf8"),V=GX(j),L=U?U.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let F of L){let A=O;if(A=pf(A),U)A=F3(A,U,F);if(A=await P0(A,Bw.cwd()),A=j3(A,$,$.pages?.[V],V),U)A=nf(A,$,U,F,V),A=rf(A,F,U.defaultLocale,z);if(A=L3(A,$),A=
|
|
17861
|
-
</body>`);if($.spa!==!1)A=await LU(A,$.router);let w=U?lf(V,F,U.defaultLocale):j,N=m4(J,w);if(zw(mf(N),{recursive:!0}),QX(N,A),U&&F!==U.defaultLocale&&w!==j);}}if(KX(X))yf(X,J,{recursive:!0});let _=m4(J,"404.html");if(!KX(_)&&KX(m4(J,"index.html"))){let j=_w(m4(J,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${
|
|
17862
|
-
${W}`);return $}function wU($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function rf($,Z,Y,J){if(Z===Y)return $;return $.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi,(X,Q,G,K)=>{if(G.startsWith("//"))return X;if(G===`/${Z}`||G===`/${Z}/`||G.startsWith(`/${Z}/`))return X;let W=G.match(/^(\/[^?#]*)(.*)$/);if(!W)return X;let[,U,z]=W,_=U==="/"?"/":U.replace(/\/$/,"");if(!J.has(_))return X;let B=_==="/"?`/${Z}/`:`/${Z}${_}`;return`<a${Q}href="${B}${z}"${K}>`})}function
|
|
17877
|
+
`)}function w3($,Z){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:Z,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function VU($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function bf($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var AU=()=>{};var{Glob:Pf}=globalThis.Bun;import{cpSync as yf,existsSync as KX,mkdirSync as zw,readFileSync as _w,readdirSync as xf,rmSync as vf,statSync as ff,unlinkSync as gf,writeFileSync as QX}from"fs";import{dirname as hf,join as m4,relative as df}from"path";import Bw from"process";import uf from"bun-plugin-stx";async function NU($){let Z=Date.now(),Y=$.pagesDir??"pages",J=$.outDir??"dist",X=$.publicDir??"public";if(!$.noClean)vf(J,{recursive:!0,force:!0});zw(J,{recursive:!0});let Q=new Pf(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:J,plugins:[uf()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");cf(J);let W=RU(J).filter((j)=>j.endsWith(".html")),U=V3($,Bw.cwd()),z=new Set(W.map(GX));for(let j of W){let H=m4(J,j),O=_w(H,"utf8"),V=GX(j),L=U?U.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let F of L){let A=O;if(A=pf(A),U)A=F3(A,U,F);if(A=await P0(A,Bw.cwd()),A=j3(A,$,$.pages?.[V],V),U)A=nf(A,$,U,F,V),A=rf(A,F,U.defaultLocale,z);if(A=L3(A,$),A=af(A),U)A=A.replace(/<\/body>/i,`${w3(U,F)}
|
|
17878
|
+
</body>`);if($.spa!==!1)A=await LU(A,$.router);let w=U?lf(V,F,U.defaultLocale):j,N=m4(J,w);if(zw(mf(N),{recursive:!0}),QX(N,A),U&&F!==U.defaultLocale&&w!==j);}}if(KX(X))yf(X,J,{recursive:!0});let _=m4(J,"404.html");if(!KX(_)&&KX(m4(J,"index.html"))){let j=_w(m4(J,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${sf($.name)}</title>`);QX(_,j)}if($.sitemap!==!1){let j=[],H=W.filter((V)=>V!=="404.html").map(GX),O=U?U.locales:[null];for(let V of H){let L=$.pages?.[V];for(let F of O){let A=F&&U?u4(V,F,U.defaultLocale):V;j.push({path:A,page:L})}}QX(m4(J,"sitemap.xml"),H3($,j))}let B=O3($);if(B!==null)QX(m4(J,"robots.txt"),B);let q=W.map(GX);return{outDir:J,pages:q,durationMs:Date.now()-Z}}function mf($){return hf($)}function lf($,Z,Y){let J=u4($,Z,Y);if(J==="/")return"index.html";let X=J.replace(/^\//,"").replace(/\/$/,"");if(!X.includes("/")){if(Z!==Y&&X===Z)return`${Z}/index.html`;return`${X}.html`}return`${X}.html`.replace(/\.html\.html$/,".html")}function GX($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function RU($,Z=$){let Y=[];if(!KX($))return Y;for(let J of xf($,{withFileTypes:!0})){let X=m4($,J.name);if(J.isDirectory())Y.push(...RU(X,Z));else Y.push(df(Z,X))}return Y}function cf($){for(let Z of RU($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(Z))continue;let Y=m4($,Z);try{if(ff(Y).size===0)gf(Y)}catch{}}}function pf($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function nf($,Z,Y,J,X){if(!Y)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${J}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${J}">`);let Q=`${Z.url.replace(/\/$/,"")}${u4(X,J,Y.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${wU(Q)}">`);let G=J.includes("_")||J.includes("-")?J:J.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${wU(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${wU(Q)}">`);let K=A3(Z.url,X,Y);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(W)=>`${K}
|
|
17879
|
+
${W}`);return $}function wU($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function rf($,Z,Y,J){if(Z===Y)return $;return $.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi,(X,Q,G,K)=>{if(G.startsWith("//"))return X;if(G===`/${Z}`||G===`/${Z}/`||G.startsWith(`/${Z}/`))return X;let W=G.match(/^(\/[^?#]*)(.*)$/);if(!W)return X;let[,U,z]=W,_=U==="/"?"/":U.replace(/\/$/,"");if(!J.has(_))return X;let B=_==="/"?`/${Z}/`:`/${Z}${_}`;return`<a${Q}href="${B}${z}"${K}>`})}function af($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let Z=$.match(/<body\b[^>]*>/i),Y=$.search(/<\/body\s*>/i);if(!Z||Y<0)return $;let J=Z.index+Z[0].length,X=$.slice(J,Y),Q=0,G=[...X.matchAll(/<\/nav>/gi)];if(G.length>0){let B=G[G.length-1];Q=B.index+B[0].length}let K=X.length,W=X.search(/<footer\b/i);if(W!==-1)K=Math.min(K,W);let U=X.search(/<script\b[^>]*data-stx-(?:theme-toggle|reparent-progress)\b/i);if(U!==-1)K=Math.min(K,U);if(K<=Q)return $;let z=X.slice(Q,K);if(!z.trim())return $;let _=`${X.slice(0,Q)}
|
|
17863
17880
|
<main>${z}</main>
|
|
17864
|
-
${X.slice(K)}`;return`${$.slice(0,J)}${_}${$.slice(Y)}`}function
|
|
17881
|
+
${X.slice(K)}`;return`${$.slice(0,J)}${_}${$.slice(Y)}`}function sf($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function MU($){return $}var qw=D(()=>{U4();AU()});var jw=D(()=>{qw();AU()});function ef($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $g($){let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);return Z}function Zg($,Z){for(let[Y,J]of $)if(Z>=Y&&Z<J)return!0;return!1}function R3($,Z){let Y=1,J=0;for(let X=0;X<Z&&X<$.length;X++)if($[X]===`
|
|
17865
17882
|
`)Y++,J=X+1;return{line:Y,column:Z-J+1}}function Yg($,Z,Y){let J=Z.toLowerCase(),X=$.length,Q=1,G=Y;while(G<X){let K=$.indexOf("<",G);if(K===-1)return-1;if(G=K,$.startsWith("<!--",G)){let z=$.indexOf("-->",G+4);if(z===-1)return-1;G=z+3;continue}if($[G+1]==="/"){let z=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!z){G++;continue}if(z[1].toLowerCase()===J){if(Q--,G+=z[0].length,Q===0)return G;continue}G+=z[0].length;continue}let W=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!W){G++;continue}let U=$.indexOf(">",G);if(U===-1)return-1;if(W[1].toLowerCase()===J&&$[U-1]!=="/")Q++;G=U+1}return-1}function Jg($,Z,Y){let J=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,X;while((X=J.exec($))!==null){if(Zg(Z,X.index))continue;let Q=X[1].toLowerCase().split(":")[0];if(of.has(Q))continue;let G=X[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(G)){let K=$.indexOf(X[3],X.index),{line:W,column:U}=R3($,K<0?X.index:K);Y.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${X[1]}="${G}" is a bare reference and will not fire. Call it: @${X[1]}="${G}()".`,line:W,column:U,severity:"error"})}}}function Xg($,Z,Y){if(Z!=="view")return;let J=/<script\b([^>]*)>/gi,X;while((X=J.exec($))!==null)if(/(?:^|\s)client(?=[\s/=]|$)/i.test(X[1])){let{line:Q,column:G}=R3($,X.index);Y.push({ruleId:"stx/no-view-level-script-client",message:"<script client> at the top level of a view is silently dropped \u2014 only components get client scopes. Move it into a component, or use <script> (server).",line:Q,column:G,severity:"error"})}}function Hw($){let Z=$.split("/"),Y=[];for(let J of Z){if(J===""||J===".")continue;if(J==="..")Y.pop();else Y.push(J)}return Y.join("/")}function Qg($,Z,Y){let J=Z.replace(/\\/g,"/"),X=J.indexOf("resources/stores/");if(X===-1)return;let Q=J.slice(0,X+16),G=J.slice(0,J.lastIndexOf("/")),K=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,W;while((W=K.exec($))!==null){if(W[2])continue;let U=W[1],z=W[4],_;if(z.startsWith("."))_=!Hw(`${G}/${z}`).startsWith(Hw(Q));else _=!0;if(_){let{line:B,column:q}=R3($,W.index),j=U==="export"?"Value re-export":"Value import";Y.push({ruleId:"stx/store-value-imports-must-be-local",message:`${j} from "${z}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${U} type\`, or move the value into the stores dir.`,line:B,column:q,severity:"error"})}}}function Gg($){let Z=$.trim(),Y=(G)=>{let K=G.match(/[A-Za-z_$][\w$]*/g);return K?K:[]},J=/\bas\s+(.+)$/.exec(Z);if(J){let G=J[1].trim(),K=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(K)return[K[1],K[2]];let W=/^\(([^)]*)\)/.exec(G);if(W)return Y(W[1]);let U=/^([A-Za-z_$][\w$]*)/.exec(G);return U?[U[1]]:[]}let X=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(Z);if(X)return Y(X[1]);let Q=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(Z);return Q?[Q[1]]:[]}function Kg($,Z){let Y=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,J;while((J=Y.exec($))!==null){let X=Gg(J[1]);if(X.length===0)continue;let Q=$.lastIndexOf("<",J.index);if(Q===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(Q,Q+64));if(!G)continue;let K=$.indexOf(">",J.index);if(K===-1)continue;let U=$[K-1]==="/"||tf.has(G[1].toLowerCase())?K+1:Yg($,G[1],K+1),z=U===-1?K+1:U,_=$.indexOf(J[1],J.index),B=$.slice(Q,z);if(_>=0&&_+J[1].length<=z){let q=_-Q;B=B.slice(0,q)+" ".repeat(J[1].length)+B.slice(q+J[1].length)}for(let q of X){let j=new RegExp(`(?<![.\\w$])${ef(q)}\\s*\\(`,"g"),H;while((H=j.exec(B))!==null){let O=Q+H.index,{line:V,column:L}=R3($,O);Z.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${q}" is a :for iteration variable, not a signal \u2014 calling it as "${q}()" leaves it as a function and silently breaks comparisons. Use "${q}" directly.`,line:V,column:L,severity:"error"})}}}}function Wg($,Z){let Y=/<!--([\s\S]*?)-->/g,J;while((J=Y.exec($))!==null){let Q=J[1].indexOf("`");if(Q!==-1){let G=J.index+4+Q,{line:K,column:W}=R3($,G);Z.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:K,column:W,severity:"error"})}}}function N3($,Z){return $?.[Z]!==!1}function Ow($,Z={}){let Y=[],J=$g($),X=(Z.filePath??"").replace(/\\/g,"/"),Q=Z.fileKind??(/\/components?\//i.test(X)?"component":/\/layouts?\//i.test(X)?"layout":"view");if(N3(Z.rules,"stx/no-bare-function-ref-in-event"))Jg($,J,Y);if(N3(Z.rules,"stx/no-view-level-script-client"))Xg($,Q,Y);if(X&&N3(Z.rules,"stx/store-value-imports-must-be-local"))Qg($,X,Y);if(N3(Z.rules,"stx/no-signal-call-in-for-iteration-var"))Kg($,Y);if(N3(Z.rules,"stx/no-backticks-in-html-comments"))Wg($,Y);Y.sort((K,W)=>K.line-W.line||K.column-W.column);let G=new Set;return Y.filter((K)=>{let W=`${K.ruleId}:${K.line}:${K.column}`;if(G.has(W))return!1;return G.add(W),!0})}var of,tf;var Lw=D(()=>{of=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),tf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});function Vw($,Z){return $.kind===Z}var Fw=()=>{};var Aw=D(()=>{Fw()});function ww($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function Ug($,Z){if($===null||$===void 0)return!0;if(Z===String)return typeof $==="string";if(Z===Number)return typeof $==="number"&&!Number.isNaN($);if(Z===Boolean)return typeof $==="boolean";if(Z===Array)return Array.isArray($);if(Z===Object)return typeof $==="object"&&!Array.isArray($);if(Z===Function)return typeof $==="function";if(Z===Date)return $ instanceof Date;if(Z===Symbol)return typeof $==="symbol";if(typeof Z==="function")return $ instanceof Z;return!0}function Nw($,Z,Y,J){let X=J?`[${J}]`:"";if(Y.required&&(Z===void 0||Z===null))return{prop:$,message:`${X} Missing required prop: "${$}"`,value:Z,expected:Y.type?ww(Y.type):void 0};if(Z===void 0||Z===null)return null;if(Y.type){let Q=Array.isArray(Y.type)?Y.type:[Y.type];if(!Q.some((K)=>Ug(Z,K))){let K=Q.map((W)=>ww(W)).join(" | ");return{prop:$,message:`${X} Invalid prop type for "${$}": expected ${K}, got ${typeof Z}`,value:Z,expected:K}}}if(Y.validator){if(!Y.validator(Z))return{prop:$,message:`${X} Custom validation failed for prop "${$}"`,value:Z}}return null}function Rw($){let Z=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return Z;let Y={...Z};for(let[J,X]of Object.entries($)){let Q=typeof X==="function"||Array.isArray(X)?{type:X}:X||{};if(Y[J]===void 0&&Q.default!==void 0)Y[J]=typeof Q.default==="function"?Q.default():Q.default}return Y}function Mw($,Z={}){let{componentName:Y,throwOnError:J=!1,logWarnings:X=!0}=Z,Q=globalThis.__STX_CURRENT_PROPS__||{},G={...Q},K={valid:!0,errors:[],warnings:[]};for(let[W,U]of Object.entries($)){let z=typeof U==="function"||Array.isArray(U)?{type:U}:U||{};if(G[W]===void 0&&z.default!==void 0)G[W]=typeof z.default==="function"?z.default():z.default;let _=Nw(W,G[W],z,Y);if(_){if(K.valid=!1,K.errors.push(_),X)console.warn(_.message)}}for(let W of Object.keys(Q))if(!(W in $)){let U=`${Y?`[${Y}]`:""} Unknown prop: "${W}"`;if(K.warnings.push(U),X)console.warn(U)}if(J&&!K.valid){let W=K.errors.map((U)=>U.message).join(`
|
|
17866
17883
|
`);throw Error(`Prop validation failed:
|
|
17867
|
-
${W}`)}return{props:G,validation:K}}function Tw($,Z){let Y={...$};for(let[J,X]of Object.entries(Z))if(Y[J]===void 0)Y[J]=typeof X==="function"?X():X;return Y}function Ew($){return $}function Iw($){return{type:$,required:!0}}function Dw($,Z){return{type:Z,default:$}}function kw($,Z={}){return{...Z,validator:$}}function Sw($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function Cw($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function bw($,Z={}){return{...Z,type:Object}}function Pw($,Z,Y){if(!Z)return $;let J={};for(let[X,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[X];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=Nw(X,K,G,Y);if(W)console.warn(W.message)}J[X]=K}for(let[X,Q]of Object.entries($))if(!(X in J))J[X]=Q;return J}var W$={};$0(W$,{writeNetlifyConfig:()=>S8,writeManifest:()=>VK,writeImageManifest:()=>ZK,wrapComponentForHMR:()=>Cv,withDefaults:()=>Tw,webComponentDirectiveHandler:()=>CG,watermark:()=>DW,watchViews:()=>Zf,watchMultiple:()=>bb,watchEffect:()=>Pb,watch:()=>Cb,waitForStore:()=>$P,waitForLocale:()=>NE,videoDirective:()=>w8,validators:()=>RZ,validated:()=>kw,validateValueEnhanced:()=>wB,validateTemplate:()=>ZO,validateParams:()=>bW,validateFormEnhanced:()=>_E,validateFile:()=>aJ,validateFields:()=>UE,validateField:()=>FB,validateDirective:()=>JO,validateCspDirectives:()=>mT,validateConfig:()=>zL,validateComponentScripts:()=>oP,validateComponentProps:()=>Zy,validateClientScript:()=>J8,usesSignalsInScript:()=>g6,userComponentFileExists:()=>u7,useVirtualList:()=>YQ,useTitle:()=>UB,useStoreOrThrow:()=>eb,useStore:()=>UA,useSlots:()=>uA,useSeoMeta:()=>I9,useRouteParams:()=>cL,useRouteParamOrThrow:()=>ZP,useRouteParam:()=>pL,usePageTitle:()=>UB,useOptimistic:()=>Zj,useMiddlewareValue:()=>YP,useMiddlewareState:()=>iL,useLoadingIndicator:()=>nF,useHead:()=>bZ,useAttrs:()=>lA,uploadFiles:()=>JU,uploadFile:()=>oJ,updateInstance:()=>ub,untrack:()=>OY,unregisterDirective:()=>OS,unmountInstance:()=>mb,unescapeHtml:()=>KZ,transpileTypeScript:()=>s4,translate:()=>XX,transitionDirective:()=>s3,toUsers:()=>fV,toUser:()=>vV,thumbnail:()=>_W,thumbHashToRGBA:()=>U3,thumbHashToDataURL:()=>tW,templateCache:()=>p2,stxClientHelpers:()=>YW,structuredDataDirective:()=>QY,stripLocalePrefix:()=>FU,stripDocumentWrapper:()=>v4,stringToStream:()=>hy,strictCspPreset:()=>s_,streamingSuspenseDirective:()=>d9,streamToResponse:()=>hB,streamTemplateSimple:()=>xB,streamTemplate:()=>CB,stopHmrServer:()=>I5,stopBroadcasting:()=>yV,stateDirName:()=>F$,stateDir:()=>c0,state:()=>n7,startProductionServer:()=>bF,startInteractive:()=>TF,startBroadcasting:()=>PV,staggerDirective:()=>Uz,srcsetUrls:()=>SW,springDirective:()=>zz,splitByPipe:()=>MZ,smartBatchSign:()=>xW,slotContentHasExpressions:()=>jO,signUrl:()=>mJ,shouldTranspileTypeScript:()=>r4,shouldReloadOnChange:()=>M8,shouldRefreshSignature:()=>iJ,shouldIgnoreFile:()=>T8,shouldCacheComponent:()=>FH,sharpen:()=>HW,shape:()=>bw,setStateDir:()=>PX,setRouteParams:()=>GP,setMiddlewareState:()=>KP,setGlobalProvide:()=>$X,setErrorLocale:()=>A_,setCurrentInstance:()=>Eb,setCachedVideoResult:()=>H5,setCachedImageResult:()=>B5,setCached:()=>W5,serveStxFile:()=>M3,serveMultipleStxFiles:()=>T3,serveMarkdownFile:()=>BJ,serveFile:()=>qv,serveApp:()=>E3,serve:()=>uF,serializeState:()=>oF,sepia:()=>LW,seoMetaToHeadConfig:()=>C7,scrollAnimateDirective:()=>a3,screenReaderDirective:()=>r3,scopeHTML:()=>XL,scopeCSS:()=>JL,scanForSitemapEntries:()=>uI,scanA11yIssues:()=>TX,saturation:()=>wW,sanitizeParams:()=>PW,sanitizeFilePath:()=>x_,sanitizeExpression:()=>v_,sanitizeDirectiveParams:()=>f_,sanitizeDirectiveParam:()=>I7,sanitizeComponentProps:()=>W9,safeExecuteAsync:()=>z4,safeExecute:()=>b_,runPreProcessingMiddleware:()=>I2,runPostProcessingMiddleware:()=>D2,runMiddleware:()=>u8,runHooks:()=>K$,runDoctor:()=>YX,rotate:()=>NW,rewriteImagesWithSiblings:()=>SY,resolveTemplatePath:()=>K8,resolveI18n:()=>V3,resize:()=>UW,resetPlaceholders:()=>fX,resetHead:()=>KB,resetHMRHandler:()=>Pv,resetErrorConfig:()=>I_,required:()=>Iw,replacePlaceholders:()=>GZ,renderView:()=>WU,renderVideoComponent:()=>A5,renderVendorStyleTags:()=>z7,renderToString:()=>q$,renderToStream:()=>eA,renderToDOM:()=>i5,renderThumbhashToCanvas:()=>oW,renderTemplateString:()=>q3,renderTemplate:()=>qU,renderString:()=>Of,renderStreamingPage:()=>bB,renderSlot:()=>EQ,renderSSRSuspense:()=>JH,renderProtectedVideo:()=>uW,renderProtectedImg:()=>dW,renderMediaUpload:()=>yW,renderImgComponent:()=>O6,renderImageComponent:()=>sG,renderHtmlAttrs:()=>_B,renderHead:()=>zB,renderEmail:()=>Yf,renderComponentWithSlot:()=>B4,renderBodyAttrs:()=>BB,render:()=>gv,relaxedCspPreset:()=>a_,registerValidationRule:()=>WE,registerStreamingDirectives:()=>fB,registerStoresClient:()=>_A,registerStore:()=>XP,registerSeoDirectives:()=>hI,registerMiddleware:()=>tb,registerFilters:()=>rz,registerFilter:()=>dX,registerErrorMessages:()=>N_,registerEnhancedValidationRule:()=>zE,registerDirective:()=>OO,registerCspDirectives:()=>uT,registerComponentDirectives:()=>Xy,registerAnimationDirectives:()=>QM,registerA11yDirectives:()=>pR,ref:()=>kb,redirect:()=>ny,rebaseOntoStateDir:()=>A$,readMarkdownFile:()=>C4,readFileCached:()=>Yj,reactive:()=>uL,quality:()=>EW,pruneSignatureCache:()=>gW,pruneCache:()=>EO,provide:()=>yA,prop:()=>Ew,processVueTemplate:()=>x2,processVirtualListDirectives:()=>DY,processVirtualGridDirectives:()=>XQ,processVideo:()=>ZJ,processValidateDirective:()=>AB,processTranslateDirective:()=>v9,processTransitionDirectives:()=>rj,processTransitionAttributes:()=>oj,processTitleDirective:()=>HB,processTemplateBindings:()=>aX,processTeleportDirectives:()=>dj,processSuspenseDirectives:()=>ZH,processStructuredData:()=>C2,processStreamDirectives:()=>PB,processStaticDirectives:()=>LQ,processStackReplacements:()=>JY,processStackPushDirectives:()=>YY,processSlots:()=>IQ,processShell:()=>SJ,processServerBindings:()=>KY,processSeoDirective:()=>b2,processSectionDirectives:()=>gB,processScopedStyles:()=>c7,processReactiveBindings:()=>G_,processProtectedMedia:()=>mW,processPartialHydrationDirectives:()=>zQ,processOnceDirective:()=>Y8,processMiddleware:()=>E2,processMetaDirectives:()=>S2,processMetaDirective:()=>OB,processMarkdownFileDirectives:()=>MQ,processMarkdownDirectives:()=>RQ,processLoops:()=>eZ,processKeepAliveDirectives:()=>LH,processJsonDirective:()=>Z8,processInfiniteListDirectives:()=>JQ,processIncludes:()=>ZY,processImgComponents:()=>BG,processImageComponents:()=>aG,processImage:()=>e1,processHeadDirective:()=>jB,processForms:()=>KE,processFormInputDirectives:()=>xZ,processExpressions:()=>d1,processEventDirectives:()=>Z9,processErrorDirective:()=>vZ,processDynamicComponents:()=>f2,processDirectives:()=>q0,processDirectiveAttributes:()=>wS,processDeferDirectives:()=>fj,processCustomDirectives:()=>R9,processCspDirectives:()=>A9,processComponentProps:()=>Pw,processClientScript:()=>n4,processBasicFormDirectives:()=>y$,processAsyncDirectives:()=>zH,processAppearanceBootstrapDirective:()=>T9,processAnimationDirectives:()=>IX,processA11yDirectives:()=>MX,preloadTranslationsBackground:()=>AE,preloadTranslations:()=>MB,preloadIslandHandlers:()=>Rv,preloadIconCollection:()=>_2,poolStrings:()=>DV,pluginManager:()=>yG,performLeave:()=>nj,performEnter:()=>ij,peek:()=>t7,partialsCache:()=>W6,parseVideoDirectiveOptions:()=>tO,parseUrl:()=>WW,parseThumbhashString:()=>eW,parseSwitchBlock:()=>TZ,parseSlots:()=>TQ,parseSlotElement:()=>KO,parseScriptDeclarations:()=>i_,parseSFCComponent:()=>QL,parseProtectedArgs:()=>lW,parseImgComponent:()=>rY,parseImageUrl:()=>gQ,parseImageComponent:()=>VJ,parseExpressionWithFilters:()=>c_,parseCookies:()=>cy,parseConditionalBlock:()=>z9,parseArguments:()=>_9,parseAnimationShorthand:()=>JM,optional:()=>Dw,optimizeTemplate:()=>kV,optimizeImage:()=>RJ,optimizeDirectory:()=>$K,oneOf:()=>Sw,onceStore:()=>M2,onUpdated:()=>fb,onUnmounted:()=>hb,onServer:()=>UP,onMounted:()=>xb,onMount:()=>jY,onHydrated:()=>OQ,onErrorCaptured:()=>hA,onDestroy:()=>HY,onDeactivated:()=>RH,onClient:()=>WP,onBeforeUpdate:()=>vb,onBeforeUnmount:()=>gb,onBeforeMount:()=>yb,onActivated:()=>NH,observeElement:()=>rW,notFound:()=>ry,nextTick:()=>gA,navigateTo:()=>ob,mountInstance:()=>db,motionDirective:()=>t3,moderateCspPreset:()=>IZ,minifyHtml:()=>IV,metaDirective:()=>XY,mergeParams:()=>dJ,mergeHeadConfigs:()=>l6,mergeCspDirectives:()=>dT,matchRoute:()=>CJ,markdownDirectiveHandler:()=>bQ,markdownCache:()=>GJ,localizePath:()=>u4,loadTranslationLazy:()=>x7,loadTranslation:()=>EB,loadStxConfig:()=>d0,loadMiddlewareFromDirectory:()=>d8,loadManifest:()=>FK,loadElement:()=>d4,loadChannels:()=>xV,lintStxStrict:()=>Ow,lazyLoadAll:()=>iW,lazyLoad:()=>pW,keyframeDirective:()=>Wz,jsxs:()=>aA,jsxDEV:()=>oA,jsx:()=>H$,jsonResponse:()=>iy,islandDirective:()=>u9,isTest:()=>R7,isSpaNavigation:()=>KK,isSignatureValid:()=>cJ,isSignal:()=>a7,isSharpAvailable:()=>b5,isServerEnvironment:()=>ky,isServer:()=>nL,isProduction:()=>k$,isNativeLazySupported:()=>nJ,isLoading:()=>VE,isLoaded:()=>FE,isJavaScriptScript:()=>BO,isIntersectionObserverSupported:()=>rJ,isImageFile:()=>P5,isImageBackendAvailable:()=>t1,isICUFormat:()=>kB,isHydrated:()=>HQ,isHydrateTrigger:()=>qO,isEdgeEnvironment:()=>Dy,isDirectiveKind:()=>Vw,isDevelopment:()=>$6,isDerived:()=>o7,isCssOnlyChange:()=>R8,isClient:()=>rL,isAsyncComponent:()=>BH,invert:()=>VW,invalidateFileCacheByDir:()=>Xj,invalidateFileCache:()=>Jj,interpolateScriptsInTemplate:()=>az,interpolateScriptExpressions:()=>L7,inlineError:()=>H0,injectThemeBootstrap:()=>L3,injectSeoTags:()=>P2,injectSeo:()=>j3,injectRouterScript:()=>D4,injectHotReload:()=>L4,injectHeatmap:()=>SX,injectCspMetaTag:()=>V9,injectCrosswindCSS:()=>P0,injectConfigHeadTags:()=>l2,injectCloakStyle:()=>m2,injectBrowserCoreAutoImports:()=>x6,injectAnalytics:()=>eX,inject:()=>xA,initStoreRegistry:()=>JP,initNetlify:()=>FL,initLoadingIndicator:()=>Iv,initLazyLoading:()=>cW,initFile:()=>dK,initBlurUp:()=>sJ,initAllBlurUp:()=>ZU,imgDirective:()=>F8,imageDirective:()=>tG,hydrateTemplateStream:()=>cK,hydrateTemplate:()=>wx,hydrateIslands:()=>Nv,hydrateIsland:()=>BQ,hydrateFragment:()=>Nx,hydrateByStrategy:()=>qQ,hydrateAll:()=>jQ,hydrate:()=>vv,htmlResponse:()=>Bv,hoistLeadingHeadTags:()=>eq,heatmapDirective:()=>CX,hashString:()=>uY,hashFilePath:()=>i$,hashFile:()=>Y1,hashBuffer:()=>AO,hasVueTemplateSyntax:()=>rq,hasVariables:()=>N2,hasStore:()=>KA,hasPlaceholders:()=>w$,hasNetlifyConfig:()=>C8,hasMiddleware:()=>ab,hasEventDirectives:()=>HT,hasDocumentShell:()=>zY,hasDirectives:()=>XO,hasDOMSupport:()=>Zz,handleImageRequest:()=>x8,handleError:()=>dA,h:()=>Jw,groupVariantsByFormat:()=>X$,grayscale:()=>OW,gitHash:()=>nK,getUnusedDirectives:()=>NV,getTranslationSync:()=>TB,getTranslationCacheStats:()=>HE,getTranslationAsync:()=>wE,getTranslation:()=>fZ,getTotalSize:()=>b4,getTimeUntilExpiry:()=>pJ,getStoreNames:()=>WA,getStore:()=>GW,getSourceLineInfo:()=>CQ,getScreenReaderOnlyStyle:()=>uR,getScopeAttribute:()=>CC,getRouteParams:()=>wP,getPublicEnvDefine:()=>F1,getPublicEnv:()=>Vz,getPositionInfo:()=>YO,getPlaceholderRegistry:()=>gX,getPlaceholderCacheStats:()=>tQ,getPageMeta:()=>CZ,getNonce:()=>J6,getMimeType:()=>f1,getMiddlewareNames:()=>h8,getMiddleware:()=>sb,getLoadingState:()=>LE,getLoadingLocales:()=>RE,getImageMetadata:()=>Z$,getHydrationRuntime:()=>ZA,getHydratedStoreState:()=>QP,getHmrServer:()=>E8,getHead:()=>SZ,getHMRHandler:()=>bv,getFormatExtension:()=>mQ,getFileMtime:()=>O8,getFallbackVariant:()=>J$,getErrorMessage:()=>X9,getErrorLocale:()=>w_,getErrorConfig:()=>M7,getErrorCodeName:()=>LZ,getDirectives:()=>HS,getDirective:()=>jS,getCurrentInstance:()=>Ib,getCspPreset:()=>hT,getCspHeaderName:()=>$B,getCrosswindServeAsset:()=>iX,getComponentCacheStats:()=>qS,getCachedVideoResult:()=>j5,getCachedSignature:()=>vW,getCachedSignalsRuntime:()=>Kj,getCachedRouterScript:()=>Wj,getCachedPlaceholder:()=>H8,getCachedImageResult:()=>_5,getCached:()=>K5,getCacheStats:()=>TO,getBroadcastServer:()=>bV,getBestVariant:()=>uQ,getAllFilters:()=>uX,generateWidthSrcset:()=>q6,generateVirtualListCSS:()=>ZQ,generateVideoPreview:()=>QU,generateValidationScript:()=>BE,generateUploadRuntime:()=>B3,generateTreeShakenBundle:()=>RV,generateTransitionRuntime:()=>aj,generateTransitionCSS:()=>sj,generateThumbnails:()=>L5,generateThumbhashPlaceholder:()=>pQ,generateTemplatesDocs:()=>ZF,generateSuspenseRuntime:()=>QH,generateSuspenseCSS:()=>XH,generateStateScript:()=>eF,generateSrcsetData:()=>hQ,generateSrcset:()=>pY,generateSrcSet:()=>w6,generateSpriteSheet:()=>eY,generateSpaShell:()=>Wf,generateSourceTags:()=>dQ,generateSizesFromBreakpoints:()=>vQ,generateSizesAttribute:()=>Y5,generateSizes:()=>Y$,generateSitemapIndex:()=>dI,generateSitemap:()=>H3,generateSimpleMediaPicker:()=>NA,generateSignatureRuntime:()=>K3,generateSignalsRuntimeDev:()=>s6,generateSignalsRuntime:()=>e7,generateServerDataBridge:()=>_7,generateScopeId:()=>JJ,generateSFCWebComponent:()=>GL,generateRouteTypes:()=>RP,generateRouteManifest:()=>NP,generateRobotsTxt:()=>lq,generateRobots:()=>O3,generateResponsiveVariants:()=>cY,generateReactiveWebComponentTS:()=>yC,generateReactiveWebComponent:()=>PC,generateReactiveRuntime:()=>vC,generateReactiveMixin:()=>xC,generatePoster:()=>O5,generatePlaceholderStyle:()=>aQ,generatePlaceholderCSS:()=>j8,generatePlaceholder:()=>q8,generatePartialHydrationCSS:()=>_Q,generateNonce:()=>O9,generateNetlifyToml:()=>jJ,generateMinifiedMediaRuntime:()=>DA,generateMediaRuntime:()=>KU,generateMediaManagerEmbed:()=>wA,generateManifest:()=>LK,generateLoadingIndicatorHtml:()=>kv,generateLazyLoadRuntime:()=>W3,generateLQIP:()=>nQ,generateKeepAliveRuntime:()=>wH,generateKeepAliveCSS:()=>AH,generateIslandManifest:()=>VQ,generateImagePreview:()=>XU,generateImageManifest:()=>MJ,generateHydrationScript:()=>xv,generateHydrationRuntime:()=>dB,generateHydrationCSS:()=>fv,generateHydrationBootstrap:()=>GQ,generateHotReloadScript:()=>LL,generateHeatmapScript:()=>kX,generateHMRClientScript:()=>Sv,generateHLSManifest:()=>V5,generateEventBindings:()=>yv,generateDprSrcsetWithVariableQuality:()=>xQ,generateDprSrcset:()=>Z5,generateDocumentShell:()=>$j,generateDocs:()=>GF,generateDirectivesDocs:()=>YF,generateDirectiveRuntime:()=>AS,generateDefaultRobotsTxt:()=>mI,generateDASHManifest:()=>F5,generateCspMetaTag:()=>DZ,generateCspHeader:()=>L9,generateCrosswindCSS:()=>BZ,generateCompositionRuntime:()=>pA,generateComponentsDocs:()=>$F,generateComponentManifest:()=>Bk,generateComponentDoc:()=>eV,generateColorPlaceholder:()=>sQ,generateClientRuntime:()=>lb,generateCacheKey:()=>Q5,generateBrowserAutoImportDestructuring:()=>kz,generateBlurUpRuntime:()=>z3,generateBlurUpCSS:()=>_3,generateBindingsRuntime:()=>K_,generateAutoWidthSrcset:()=>yQ,generateAutoImportDestructuring:()=>ZZ,generateAsyncComponentRuntime:()=>jH,generateAsyncComponentCSS:()=>qH,generateAnimationRuntime:()=>XM,generateAnimationCSS:()=>YM,generateAnalyticsScript:()=>tX,formatTypeErrors:()=>wv,formatStxContent:()=>fJ,formatSize:()=>A6,formatRoutes:()=>UK,formatMarkdownContent:()=>fK,formatLocalizedError:()=>M_,formatICU:()=>IB,formatFilePath:()=>T7,formatError:()=>AZ,formatDoctorReport:()=>JX,formatDocsAsMarkdown:()=>JF,formatDocsAsJson:()=>QF,formatDocsAsHtml:()=>XF,format:()=>TW,foldConstants:()=>EV,flipVertical:()=>MW,flipHorizontal:()=>RW,fingerprint:()=>zK,findPantryPackage:()=>HU,findMatchingEndTag:()=>Y6,findMatchingDelimiter:()=>s0,findIfBlocks:()=>P$,findExpressions:()=>l_,findErrorPage:()=>WK,findDirectiveBlocks:()=>k7,findDeadCode:()=>MV,findDeadBranches:()=>MV,findComponentFiles:()=>SK,findCommonDir:()=>TU,filterRequiredFiles:()=>k8,fileExists:()=>Q0,extractVariables:()=>D0,extractStreamBoundaries:()=>yB,extractState:()=>$A,extractSlotContent:()=>UO,extractScriptFromTemplate:()=>w2,extractPlaceholders:()=>hM,extractParenthesizedExpression:()=>E4,extractPageResponseStatus:()=>IJ,extractLayoutMetadata:()=>p8,extractDominantColor:()=>rQ,extractDirectiveParams:()=>p_,extractDirectiveNames:()=>QO,extractContainerContent:()=>c8,extractComponentProps:()=>oV,extractComponentName:()=>KQ,extractComponentDescription:()=>tV,extractClassNames:()=>_Z,extractBridgeData:()=>i4,extractBoundProps:()=>WQ,extractBalancedExpression:()=>U9,extractAndStripCssImports:()=>U7,extractAndScopeStyles:()=>bC,extractAndProcessEvents:()=>q_,evaluateExpression:()=>G1,evaluateConstant:()=>yJ,evaluateAuthExpression:()=>T4,escapeHtml:()=>v0,errorRecovery:()=>wZ,errorLogger:()=>K1,ensureTeleportTargets:()=>uj,ensureDocumentShell:()=>p7,enhancedValidationRules:()=>S9,eliminateDeadCode:()=>TV,effect:()=>s7,dprUrls:()=>CW,docsCommand:()=>CK,disconnectObserver:()=>sW,devHelpers:()=>b$,detectShell:()=>GK,detectRuntime:()=>h5,detectProjectConfig:()=>k5,detectFormat:()=>lQ,detectBuildMode:()=>aP,derived:()=>r7,deploy:()=>VL,defineStxConfig:()=>UL,defineStore:()=>zA,defineSlots:()=>mA,defineSiteConfig:()=>MU,definePropsWithValidation:()=>Mw,defineProps:()=>Rw,definePlugin:()=>N5,definePageMeta:()=>WB,defineMiddleware:()=>rb,defineExpose:()=>fA,defineEmits:()=>vA,defineDirective:()=>u0,defineCustomElement:()=>Qw,defineConfig:()=>Ax,defineClientDirective:()=>LS,defineAsyncComponent:()=>_H,defaultMediaConfig:()=>$f,defaultImageConfig:()=>fL,defaultI18nConfig:()=>gZ,defaultHeatmapConfig:()=>jz,defaultFormClasses:()=>yZ,defaultFilters:()=>R$,defaultCspConfig:()=>cT,defaultConfig:()=>N1,default:()=>zg,dedupeScopedStyles:()=>u2,decodeThumbhash:()=>iQ,cspNonceDirective:()=>e_,cspDirective:()=>t_,crossfadeTransition:()=>$U,crop:()=>zW,createVirtualList:()=>IY,createVideoDirective:()=>YJ,createVercelHandler:()=>my,createTypeChecker:()=>oK,createTranslateFilter:()=>mE,createTextEncoderStream:()=>gy,createStxApp:()=>BU,createStreamingResponse:()=>fy,createStreamRenderer:()=>vB,createStore:()=>KW,createStorageManager:()=>nb,createServerCookieManager:()=>ib,createScope:()=>dL,createSSRSuspense:()=>YH,createRouter:()=>f4,createRouteLocation:()=>g8,createRoute:()=>Hv,createRef:()=>kb,createReactive:()=>uL,createProvideContext:()=>cA,createProject:()=>Ix,createProductionBuild:()=>Fx,createPlaceholder:()=>B7,createOptimizedBuild:()=>tP,createNetlifyHandler:()=>ly,createNetlifyClient:()=>I8,createMiddlewareContext:()=>f8,createMiddleware:()=>jv,createLazyObserver:()=>nW,createKeepAliveCache:()=>VH,createKVNamespace:()=>UF,createIslandRegistry:()=>UQ,createImgDirective:()=>sY,createImagePlugin:()=>eG,createImageHandler:()=>LJ,createImageDirective:()=>wJ,createHeatmapAggregator:()=>WM,createFileManifest:()=>D8,createEnvAccessor:()=>WF,createEnhancedError:()=>C_,createEdgeHandler:()=>s8,createEdgeCache:()=>zF,createDetailedErrorMessage:()=>T0,createDenoHandler:()=>uy,createDefaultNetlifyConfig:()=>S5,createCspHeaders:()=>lT,createCookie:()=>py,createComputed:()=>Sb,createComponentInstance:()=>Db,createCloudflareHandler:()=>dy,createClientCookieManager:()=>pb,createBuiltinDirectives:()=>FS,createApp:()=>BU,createAnimationTimeline:()=>ZM,cover:()=>qW,convertToCommonJS:()=>rZ,contrast:()=>AW,contain:()=>BW,consoleError:()=>S_,configureErrorHandling:()=>E_,config:()=>T1,computed:()=>Sb,composeShellWithPage:()=>l8,componentDirective:()=>cV,componentClientSignalNames:()=>HO,compileTemplate:()=>jK,collectDeployFiles:()=>D5,clearVideoCache:()=>oY,clearTranslationCache:()=>jE,clearSignatureCache:()=>fW,clearPlaceholderCache:()=>oQ,clearOnceStore:()=>xI,clearNonce:()=>gT,clearMiddleware:()=>v8,clearImageCache:()=>AJ,clearErrorMessages:()=>R_,clearDevCaches:()=>Uj,clearCustomFilters:()=>sz,clearComponentCache:()=>j4,clearCache:()=>U5,cleanupLoadingIndicator:()=>Dv,classifyScript:()=>oL,classifyAllScripts:()=>JK,checkTemplateFile:()=>Fv,checkTemplate:()=>Av,checkCache:()=>AY,checkAuthAccess:()=>p5,checkA11y:()=>i3,channel:()=>dV,captureScreenshots:()=>LF,captureScreenshot:()=>xK,cancelPendingLoads:()=>ME,calculateSha1:()=>qJ,calculateOptimalWidths:()=>gY,cacheTemplate:()=>wY,buildWebComponents:()=>kG,buildViews:()=>bA,buildUrl:()=>k0,buildSuspenseResolveScript:()=>dZ,buildStaticSite:()=>NU,buildRuntimeAsset:()=>_K,buildRouterAsset:()=>BK,buildLangPickerScript:()=>w3,buildImageUrl:()=>a1,buildForProduction:()=>qV,buildComponentLibrary:()=>IK,buildAuthParams:()=>G3,buildApp:()=>HV,buildAlternateLinks:()=>A3,build:()=>Vx,broadcastPrivate:()=>gV,broadcastPresence:()=>hV,broadcast:()=>MK,brightness:()=>FW,blur:()=>jW,batchSignUrls:()=>lJ,batch:()=>qY,autoFixA11yFile:()=>Xz,autoFixA11yDirectory:()=>cR,autoFixA11y:()=>Jz,auto:()=>IW,assetTags:()=>lP,arrayOf:()=>Cw,applyTranslations:()=>F3,applyTransformations:()=>V8,applySlots:()=>zO,applyPropDefaults:()=>Yy,applyPreset:()=>kW,applyHead:()=>qB,applyFilters:()=>mX,apiCspPreset:()=>o_,animationGroupDirective:()=>o3,analyzeVideo:()=>A8,analyzeUsage:()=>NK,analyzeTemplate:()=>aL,analyzeProject:()=>YK,analyzeDirectiveUsage:()=>NK,analyticsDirective:()=>UT,addStore:()=>bx,addPage:()=>Cx,addNonceToInlineContent:()=>F9,addLayout:()=>Px,addComponent:()=>Sx,abortNavigation:()=>cb,a11yDirective:()=>n3,__setSignalsGeneratorsForTest:()=>Gj,VideoProcessorCache:()=>q5,TransitionType:()=>Qz,TransitionEase:()=>Kz,TransitionDirection:()=>Gz,Tokenizer:()=>D7,TemplateTypeChecker:()=>aK,TEMPLATE_PRESETS:()=>Qx,StxValidationError:()=>E7,StxSyntaxError:()=>Q9,StxSecurityError:()=>G9,StxRuntimeError:()=>r1,StxFileError:()=>C$,StxError:()=>Z6,Show:()=>$w,SUSPENSE_RESOLVER_RUNTIME:()=>h9,STATE_DIR_ENV_VAR:()=>Fz,SPRING_PRESETS:()=>EX,ProductionBuild:()=>gJ,Portal:()=>Yw,PROJECT_TEMPLATES:()=>Ex,PRESETS:()=>uJ,MemorySessionStore:()=>XA,MIME_TYPES:()=>_8,MEDIA_DEFAULT_WIDTHS:()=>O4,MEDIA_DEFAULT_FORMATS:()=>S4,ImageProcessorCache:()=>z5,ImageProcessingError:()=>Q$,HydrationRuntime:()=>QW,HotReloadServer:()=>uG,HeatmapAggregator:()=>bX,Fragment:()=>j$,For:()=>Zw,ErrorLogger:()=>NZ,ErrorCodes:()=>G0,DeployError:()=>y4,DEFAULT_WIDTHS:()=>y1,DEFAULT_TRANSITION_OPTIONS:()=>Q4,DEFAULT_STATE_DIR:()=>P6,DEFAULT_QUALITY:()=>v1,DEFAULT_PLACEHOLDER_OPTIONS:()=>dY,DEFAULT_FORMATS:()=>x1,DEFAULT_DPR_VALUES:()=>z8,ComponentHMRHandler:()=>JW,COMMON_SIZES:()=>fQ,CLOAK_STYLE:()=>jD,BroadcastServer:()=>mV,Broadcast:()=>uV,BLUR_UP_CSS:()=>X5});var zg;var N6=D(()=>{HJ();TJ();N0();L2();p4();BA();y2();UU();Xw();Gw();xG();U4();OU();jw();Lw();mL();c6();DJ();C9();V$();$9();e3();E9();$5();v5();J9();wK();qK();FV();SV();xJ();o6();pV();DK();r0();w9();M9();HJ();EU();U8();bK();_F();vK();C1();Y9();$1();gK();$Z();f9();m$();uK();mK();$Y();yY();k2();S7();bJ();q7();_1();kF();AK();iK();i8();dF();XK();GY();mF();G4();UY();HK();pK();G6();cF();bG();QQ();FQ();pF();rF();oX();v6();aF();YA();QA();TJ();CA();PA();c$();v2();g2();jU();N0();xY();Aw();zg={}});import I3 from"path";var s5;var WX=D(()=>{N6();C1();$1();t4();_1();x$();s5={name:"bun-plugin-stx",async setup($){let Y={...await d0(),...$.config?.stx},J=new Set,X=Y.webComponents?.enabled?`./${I3.relative(I3.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await kG(Y,J);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await AY(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await z4(()=>Bun.file(G).text(),"",(H)=>{throw new C$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new C$(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:z,allScripts:_}=p1.time("script-extraction",()=>{let H=W,O=_4(W);if(O)H=O.content.trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let w of V){let N=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=w.match(/<script\b([^>]*)>/i),E=R?R[1]:"";if(/\bserver\b/i.test(E))L=N;else F.push(w)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),B={__filename:G,__dirname:I3.dirname(G),__stx:{webComponentsPath:X,builtComponents:Q}};await z4(()=>D0(U,B,G),void 0,(H)=>{let O=new r1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(K1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await p1.timeAsync("directive-processing",async()=>{return await q0(z,B,G,Y,K)});if(_.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => ($1(),V7)),O=H(_.join(`
|
|
17884
|
+
${W}`)}return{props:G,validation:K}}function Tw($,Z){let Y={...$};for(let[J,X]of Object.entries(Z))if(Y[J]===void 0)Y[J]=typeof X==="function"?X():X;return Y}function Ew($){return $}function Iw($){return{type:$,required:!0}}function Dw($,Z){return{type:Z,default:$}}function kw($,Z={}){return{...Z,validator:$}}function Sw($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function Cw($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function bw($,Z={}){return{...Z,type:Object}}function Pw($,Z,Y){if(!Z)return $;let J={};for(let[X,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[X];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=Nw(X,K,G,Y);if(W)console.warn(W.message)}J[X]=K}for(let[X,Q]of Object.entries($))if(!(X in J))J[X]=Q;return J}var W$={};$0(W$,{writeNetlifyConfig:()=>S8,writeManifest:()=>VK,writeImageManifest:()=>ZK,wrapComponentForHMR:()=>Cv,withDefaults:()=>Tw,webComponentDirectiveHandler:()=>CG,watermark:()=>DW,watchViews:()=>Zf,watchMultiple:()=>bb,watchEffect:()=>Pb,watch:()=>Cb,waitForStore:()=>$P,waitForLocale:()=>NE,videoDirective:()=>w8,validators:()=>RZ,validated:()=>kw,validateValueEnhanced:()=>wB,validateTemplate:()=>ZO,validateParams:()=>bW,validateFormEnhanced:()=>_E,validateFile:()=>sJ,validateFields:()=>UE,validateField:()=>FB,validateDirective:()=>JO,validateCspDirectives:()=>mT,validateConfig:()=>zL,validateComponentScripts:()=>oP,validateComponentProps:()=>Zy,validateClientScript:()=>J8,usesSignalsInScript:()=>g6,userComponentFileExists:()=>u7,useVirtualList:()=>YQ,useTitle:()=>UB,useStoreOrThrow:()=>eb,useStore:()=>UA,useSlots:()=>uA,useSeoMeta:()=>I9,useRouteParams:()=>cL,useRouteParamOrThrow:()=>ZP,useRouteParam:()=>pL,usePageTitle:()=>UB,useOptimistic:()=>Zj,useMiddlewareValue:()=>YP,useMiddlewareState:()=>iL,useLoadingIndicator:()=>nF,useHead:()=>bZ,useAttrs:()=>lA,uploadFiles:()=>JU,uploadFile:()=>oJ,updateInstance:()=>ub,untrack:()=>OY,unregisterDirective:()=>OS,unmountInstance:()=>mb,unescapeHtml:()=>KZ,transpileTypeScript:()=>a4,translate:()=>XX,transitionDirective:()=>a3,toUsers:()=>fV,toUser:()=>vV,thumbnail:()=>_W,thumbHashToRGBA:()=>U3,thumbHashToDataURL:()=>tW,templateCache:()=>p2,stxClientHelpers:()=>YW,structuredDataDirective:()=>QY,stripLocalePrefix:()=>FU,stripDocumentWrapper:()=>v4,stringToStream:()=>hy,strictCspPreset:()=>a_,streamingSuspenseDirective:()=>d9,streamToResponse:()=>hB,streamTemplateSimple:()=>xB,streamTemplate:()=>CB,stopHmrServer:()=>I5,stopBroadcasting:()=>yV,stateDirName:()=>F$,stateDir:()=>c0,state:()=>n7,startProductionServer:()=>bF,startInteractive:()=>TF,startBroadcasting:()=>PV,staggerDirective:()=>Uz,srcsetUrls:()=>SW,springDirective:()=>zz,splitByPipe:()=>MZ,smartBatchSign:()=>xW,slotContentHasExpressions:()=>jO,signUrl:()=>mJ,shouldTranspileTypeScript:()=>r4,shouldReloadOnChange:()=>M8,shouldRefreshSignature:()=>iJ,shouldIgnoreFile:()=>T8,shouldCacheComponent:()=>FH,sharpen:()=>HW,shape:()=>bw,setStateDir:()=>PX,setRouteParams:()=>GP,setMiddlewareState:()=>KP,setGlobalProvide:()=>$X,setErrorLocale:()=>A_,setCurrentInstance:()=>Eb,setCachedVideoResult:()=>H5,setCachedImageResult:()=>B5,setCached:()=>W5,serveStxFile:()=>M3,serveMultipleStxFiles:()=>T3,serveMarkdownFile:()=>BJ,serveFile:()=>qv,serveApp:()=>E3,serve:()=>uF,serializeState:()=>oF,sepia:()=>LW,seoMetaToHeadConfig:()=>C7,scrollAnimateDirective:()=>s3,screenReaderDirective:()=>r3,scopeHTML:()=>XL,scopeCSS:()=>JL,scanForSitemapEntries:()=>uI,scanA11yIssues:()=>TX,saturation:()=>wW,sanitizeParams:()=>PW,sanitizeFilePath:()=>x_,sanitizeExpression:()=>v_,sanitizeDirectiveParams:()=>f_,sanitizeDirectiveParam:()=>I7,sanitizeComponentProps:()=>W9,safeExecuteAsync:()=>z4,safeExecute:()=>b_,runPreProcessingMiddleware:()=>I2,runPostProcessingMiddleware:()=>D2,runMiddleware:()=>u8,runHooks:()=>K$,runDoctor:()=>YX,rotate:()=>NW,rewriteImagesWithSiblings:()=>SY,resolveTemplatePath:()=>K8,resolveI18n:()=>V3,resize:()=>UW,resetPlaceholders:()=>fX,resetHead:()=>KB,resetHMRHandler:()=>Pv,resetErrorConfig:()=>I_,required:()=>Iw,replacePlaceholders:()=>GZ,renderView:()=>WU,renderVideoComponent:()=>A5,renderVendorStyleTags:()=>z7,renderToString:()=>q$,renderToStream:()=>eA,renderToDOM:()=>i5,renderThumbhashToCanvas:()=>oW,renderTemplateString:()=>q3,renderTemplate:()=>qU,renderString:()=>Of,renderStreamingPage:()=>bB,renderSlot:()=>EQ,renderSSRSuspense:()=>JH,renderProtectedVideo:()=>uW,renderProtectedImg:()=>dW,renderMediaUpload:()=>yW,renderImgComponent:()=>O6,renderImageComponent:()=>aG,renderHtmlAttrs:()=>_B,renderHead:()=>zB,renderEmail:()=>Yf,renderComponentWithSlot:()=>B4,renderBodyAttrs:()=>BB,render:()=>gv,relaxedCspPreset:()=>s_,registerValidationRule:()=>WE,registerStreamingDirectives:()=>fB,registerStoresClient:()=>_A,registerStore:()=>XP,registerSeoDirectives:()=>hI,registerMiddleware:()=>tb,registerFilters:()=>rz,registerFilter:()=>dX,registerErrorMessages:()=>N_,registerEnhancedValidationRule:()=>zE,registerDirective:()=>OO,registerCspDirectives:()=>uT,registerComponentDirectives:()=>Xy,registerAnimationDirectives:()=>QM,registerA11yDirectives:()=>pR,ref:()=>kb,redirect:()=>ny,rebaseOntoStateDir:()=>A$,readMarkdownFile:()=>C4,readFileCached:()=>Yj,reactive:()=>uL,quality:()=>EW,pruneSignatureCache:()=>gW,pruneCache:()=>EO,provide:()=>yA,prop:()=>Ew,processVueTemplate:()=>x2,processVirtualListDirectives:()=>DY,processVirtualGridDirectives:()=>XQ,processVideo:()=>ZJ,processValidateDirective:()=>AB,processTranslateDirective:()=>v9,processTransitionDirectives:()=>rj,processTransitionAttributes:()=>oj,processTitleDirective:()=>HB,processTemplateBindings:()=>sX,processTeleportDirectives:()=>dj,processSuspenseDirectives:()=>ZH,processStructuredData:()=>C2,processStreamDirectives:()=>PB,processStaticDirectives:()=>LQ,processStackReplacements:()=>JY,processStackPushDirectives:()=>YY,processSlots:()=>IQ,processShell:()=>SJ,processServerBindings:()=>KY,processSeoDirective:()=>b2,processSectionDirectives:()=>gB,processScopedStyles:()=>c7,processReactiveBindings:()=>G_,processProtectedMedia:()=>mW,processPartialHydrationDirectives:()=>zQ,processOnceDirective:()=>Y8,processMiddleware:()=>E2,processMetaDirectives:()=>S2,processMetaDirective:()=>OB,processMarkdownFileDirectives:()=>MQ,processMarkdownDirectives:()=>RQ,processLoops:()=>eZ,processKeepAliveDirectives:()=>LH,processJsonDirective:()=>Z8,processInfiniteListDirectives:()=>JQ,processIncludes:()=>ZY,processImgComponents:()=>BG,processImageComponents:()=>sG,processImage:()=>e1,processHeadDirective:()=>jB,processForms:()=>KE,processFormInputDirectives:()=>xZ,processExpressions:()=>d1,processEventDirectives:()=>Z9,processErrorDirective:()=>vZ,processDynamicComponents:()=>f2,processDirectives:()=>q0,processDirectiveAttributes:()=>wS,processDeferDirectives:()=>fj,processCustomDirectives:()=>R9,processCspDirectives:()=>A9,processComponentProps:()=>Pw,processClientScript:()=>n4,processBasicFormDirectives:()=>y$,processAsyncDirectives:()=>zH,processAppearanceBootstrapDirective:()=>T9,processAnimationDirectives:()=>IX,processA11yDirectives:()=>MX,preloadTranslationsBackground:()=>AE,preloadTranslations:()=>MB,preloadIslandHandlers:()=>Rv,preloadIconCollection:()=>_2,poolStrings:()=>DV,pluginManager:()=>yG,performLeave:()=>nj,performEnter:()=>ij,peek:()=>t7,partialsCache:()=>W6,parseVideoDirectiveOptions:()=>tO,parseUrl:()=>WW,parseThumbhashString:()=>eW,parseSwitchBlock:()=>TZ,parseSlots:()=>TQ,parseSlotElement:()=>KO,parseScriptDeclarations:()=>i_,parseSFCComponent:()=>QL,parseProtectedArgs:()=>lW,parseImgComponent:()=>rY,parseImageUrl:()=>gQ,parseImageComponent:()=>VJ,parseExpressionWithFilters:()=>c_,parseCookies:()=>cy,parseConditionalBlock:()=>z9,parseArguments:()=>_9,parseAnimationShorthand:()=>JM,optional:()=>Dw,optimizeTemplate:()=>kV,optimizeImage:()=>RJ,optimizeDirectory:()=>$K,oneOf:()=>Sw,onceStore:()=>M2,onUpdated:()=>fb,onUnmounted:()=>hb,onServer:()=>UP,onMounted:()=>xb,onMount:()=>jY,onHydrated:()=>OQ,onErrorCaptured:()=>hA,onDestroy:()=>HY,onDeactivated:()=>RH,onClient:()=>WP,onBeforeUpdate:()=>vb,onBeforeUnmount:()=>gb,onBeforeMount:()=>yb,onActivated:()=>NH,observeElement:()=>rW,notFound:()=>ry,nextTick:()=>gA,navigateTo:()=>ob,mountInstance:()=>db,motionDirective:()=>t3,moderateCspPreset:()=>IZ,minifyHtml:()=>IV,metaDirective:()=>XY,mergeParams:()=>dJ,mergeHeadConfigs:()=>l6,mergeCspDirectives:()=>dT,matchRoute:()=>CJ,markdownDirectiveHandler:()=>bQ,markdownCache:()=>GJ,localizePath:()=>u4,loadTranslationLazy:()=>x7,loadTranslation:()=>EB,loadStxConfig:()=>d0,loadMiddlewareFromDirectory:()=>d8,loadManifest:()=>FK,loadElement:()=>d4,loadChannels:()=>xV,lintStxStrict:()=>Ow,lazyLoadAll:()=>iW,lazyLoad:()=>pW,keyframeDirective:()=>Wz,jsxs:()=>sA,jsxDEV:()=>oA,jsx:()=>H$,jsonResponse:()=>iy,islandDirective:()=>u9,isTest:()=>R7,isSpaNavigation:()=>KK,isSignatureValid:()=>cJ,isSignal:()=>s7,isSharpAvailable:()=>b5,isServerEnvironment:()=>ky,isServer:()=>nL,isProduction:()=>k$,isNativeLazySupported:()=>nJ,isLoading:()=>VE,isLoaded:()=>FE,isJavaScriptScript:()=>BO,isIntersectionObserverSupported:()=>rJ,isImageFile:()=>P5,isImageBackendAvailable:()=>t1,isICUFormat:()=>kB,isHydrated:()=>HQ,isHydrateTrigger:()=>qO,isEdgeEnvironment:()=>Dy,isDirectiveKind:()=>Vw,isDevelopment:()=>$6,isDerived:()=>o7,isCssOnlyChange:()=>R8,isClient:()=>rL,isAsyncComponent:()=>BH,invert:()=>VW,invalidateFileCacheByDir:()=>Xj,invalidateFileCache:()=>Jj,interpolateScriptsInTemplate:()=>sz,interpolateScriptExpressions:()=>L7,inlineError:()=>H0,injectThemeBootstrap:()=>L3,injectSeoTags:()=>P2,injectSeo:()=>j3,injectRouterScript:()=>D4,injectHotReload:()=>L4,injectHeatmap:()=>SX,injectCspMetaTag:()=>V9,injectCrosswindCSS:()=>P0,injectConfigHeadTags:()=>l2,injectCloakStyle:()=>m2,injectBrowserCoreAutoImports:()=>x6,injectAnalytics:()=>eX,inject:()=>xA,initStoreRegistry:()=>JP,initNetlify:()=>FL,initLoadingIndicator:()=>Iv,initLazyLoading:()=>cW,initFile:()=>dK,initBlurUp:()=>aJ,initAllBlurUp:()=>ZU,imgDirective:()=>F8,imageDirective:()=>tG,hydrateTemplateStream:()=>cK,hydrateTemplate:()=>wx,hydrateIslands:()=>Nv,hydrateIsland:()=>BQ,hydrateFragment:()=>Nx,hydrateByStrategy:()=>qQ,hydrateAll:()=>jQ,hydrate:()=>vv,htmlResponse:()=>Bv,hoistLeadingHeadTags:()=>eq,heatmapDirective:()=>CX,hashString:()=>uY,hashFilePath:()=>i$,hashFile:()=>Y1,hashBuffer:()=>AO,hasVueTemplateSyntax:()=>rq,hasVariables:()=>N2,hasStore:()=>KA,hasPlaceholders:()=>w$,hasNetlifyConfig:()=>C8,hasMiddleware:()=>sb,hasEventDirectives:()=>HT,hasDocumentShell:()=>zY,hasDirectives:()=>XO,hasDOMSupport:()=>Zz,handleImageRequest:()=>x8,handleError:()=>dA,h:()=>Jw,groupVariantsByFormat:()=>X$,grayscale:()=>OW,gitHash:()=>nK,getUnusedDirectives:()=>NV,getTranslationSync:()=>TB,getTranslationCacheStats:()=>HE,getTranslationAsync:()=>wE,getTranslation:()=>fZ,getTotalSize:()=>b4,getTimeUntilExpiry:()=>pJ,getStoreNames:()=>WA,getStore:()=>GW,getSourceLineInfo:()=>CQ,getScreenReaderOnlyStyle:()=>uR,getScopeAttribute:()=>CC,getRouteParams:()=>wP,getPublicEnvDefine:()=>F1,getPublicEnv:()=>Vz,getPositionInfo:()=>YO,getPlaceholderRegistry:()=>gX,getPlaceholderCacheStats:()=>tQ,getPageMeta:()=>CZ,getNonce:()=>J6,getMimeType:()=>f1,getMiddlewareNames:()=>h8,getMiddleware:()=>ab,getLoadingState:()=>LE,getLoadingLocales:()=>RE,getImageMetadata:()=>Z$,getHydrationRuntime:()=>ZA,getHydratedStoreState:()=>QP,getHmrServer:()=>E8,getHead:()=>SZ,getHMRHandler:()=>bv,getFormatExtension:()=>mQ,getFileMtime:()=>O8,getFallbackVariant:()=>J$,getErrorMessage:()=>X9,getErrorLocale:()=>w_,getErrorConfig:()=>M7,getErrorCodeName:()=>LZ,getDirectives:()=>HS,getDirective:()=>jS,getCurrentInstance:()=>Ib,getCspPreset:()=>hT,getCspHeaderName:()=>$B,getCrosswindServeAsset:()=>iX,getComponentCacheStats:()=>qS,getCachedVideoResult:()=>j5,getCachedSignature:()=>vW,getCachedSignalsRuntime:()=>Kj,getCachedRouterScript:()=>Wj,getCachedPlaceholder:()=>H8,getCachedImageResult:()=>_5,getCached:()=>K5,getCacheStats:()=>TO,getBroadcastServer:()=>bV,getBestVariant:()=>uQ,getAllFilters:()=>uX,generateWidthSrcset:()=>q6,generateVirtualListCSS:()=>ZQ,generateVideoPreview:()=>QU,generateValidationScript:()=>BE,generateUploadRuntime:()=>B3,generateTreeShakenBundle:()=>RV,generateTransitionRuntime:()=>sj,generateTransitionCSS:()=>aj,generateThumbnails:()=>L5,generateThumbhashPlaceholder:()=>pQ,generateTemplatesDocs:()=>ZF,generateSuspenseRuntime:()=>QH,generateSuspenseCSS:()=>XH,generateStateScript:()=>eF,generateSrcsetData:()=>hQ,generateSrcset:()=>pY,generateSrcSet:()=>w6,generateSpriteSheet:()=>eY,generateSpaShell:()=>Wf,generateSourceTags:()=>dQ,generateSizesFromBreakpoints:()=>vQ,generateSizesAttribute:()=>Y5,generateSizes:()=>Y$,generateSitemapIndex:()=>dI,generateSitemap:()=>H3,generateSimpleMediaPicker:()=>NA,generateSignatureRuntime:()=>K3,generateSignalsRuntimeDev:()=>a6,generateSignalsRuntime:()=>e7,generateServerDataBridge:()=>_7,generateScopeId:()=>JJ,generateSFCWebComponent:()=>GL,generateRouteTypes:()=>RP,generateRouteManifest:()=>NP,generateRobotsTxt:()=>lq,generateRobots:()=>O3,generateResponsiveVariants:()=>cY,generateReactiveWebComponentTS:()=>yC,generateReactiveWebComponent:()=>PC,generateReactiveRuntime:()=>vC,generateReactiveMixin:()=>xC,generatePoster:()=>O5,generatePlaceholderStyle:()=>sQ,generatePlaceholderCSS:()=>j8,generatePlaceholder:()=>q8,generatePartialHydrationCSS:()=>_Q,generateNonce:()=>O9,generateNetlifyToml:()=>jJ,generateMinifiedMediaRuntime:()=>DA,generateMediaRuntime:()=>KU,generateMediaManagerEmbed:()=>wA,generateManifest:()=>LK,generateLoadingIndicatorHtml:()=>kv,generateLazyLoadRuntime:()=>W3,generateLQIP:()=>nQ,generateKeepAliveRuntime:()=>wH,generateKeepAliveCSS:()=>AH,generateIslandManifest:()=>VQ,generateImagePreview:()=>XU,generateImageManifest:()=>MJ,generateHydrationScript:()=>xv,generateHydrationRuntime:()=>dB,generateHydrationCSS:()=>fv,generateHydrationBootstrap:()=>GQ,generateHotReloadScript:()=>LL,generateHeatmapScript:()=>kX,generateHMRClientScript:()=>Sv,generateHLSManifest:()=>V5,generateEventBindings:()=>yv,generateDprSrcsetWithVariableQuality:()=>xQ,generateDprSrcset:()=>Z5,generateDocumentShell:()=>$j,generateDocs:()=>GF,generateDirectivesDocs:()=>YF,generateDirectiveRuntime:()=>AS,generateDefaultRobotsTxt:()=>mI,generateDASHManifest:()=>F5,generateCspMetaTag:()=>DZ,generateCspHeader:()=>L9,generateCrosswindCSS:()=>BZ,generateCompositionRuntime:()=>pA,generateComponentsDocs:()=>$F,generateComponentManifest:()=>Bk,generateComponentDoc:()=>eV,generateColorPlaceholder:()=>aQ,generateClientRuntime:()=>lb,generateCacheKey:()=>Q5,generateBrowserAutoImportDestructuring:()=>kz,generateBlurUpRuntime:()=>z3,generateBlurUpCSS:()=>_3,generateBindingsRuntime:()=>K_,generateAutoWidthSrcset:()=>yQ,generateAutoImportDestructuring:()=>ZZ,generateAsyncComponentRuntime:()=>jH,generateAsyncComponentCSS:()=>qH,generateAnimationRuntime:()=>XM,generateAnimationCSS:()=>YM,generateAnalyticsScript:()=>tX,formatTypeErrors:()=>wv,formatStxContent:()=>fJ,formatSize:()=>A6,formatRoutes:()=>UK,formatMarkdownContent:()=>fK,formatLocalizedError:()=>M_,formatICU:()=>IB,formatFilePath:()=>T7,formatError:()=>AZ,formatDoctorReport:()=>JX,formatDocsAsMarkdown:()=>JF,formatDocsAsJson:()=>QF,formatDocsAsHtml:()=>XF,format:()=>TW,foldConstants:()=>EV,flipVertical:()=>MW,flipHorizontal:()=>RW,fingerprint:()=>zK,findPantryPackage:()=>HU,findMatchingEndTag:()=>Y6,findMatchingDelimiter:()=>a0,findIfBlocks:()=>P$,findExpressions:()=>l_,findErrorPage:()=>WK,findDirectiveBlocks:()=>k7,findDeadCode:()=>MV,findDeadBranches:()=>MV,findComponentFiles:()=>SK,findCommonDir:()=>TU,filterRequiredFiles:()=>k8,fileExists:()=>Q0,extractVariables:()=>D0,extractStreamBoundaries:()=>yB,extractState:()=>$A,extractSlotContent:()=>UO,extractScriptFromTemplate:()=>w2,extractPlaceholders:()=>hM,extractParenthesizedExpression:()=>E4,extractPageResponseStatus:()=>IJ,extractLayoutMetadata:()=>p8,extractDominantColor:()=>rQ,extractDirectiveParams:()=>p_,extractDirectiveNames:()=>QO,extractContainerContent:()=>c8,extractComponentProps:()=>oV,extractComponentName:()=>KQ,extractComponentDescription:()=>tV,extractClassNames:()=>_Z,extractBridgeData:()=>i4,extractBoundProps:()=>WQ,extractBalancedExpression:()=>U9,extractAndStripCssImports:()=>U7,extractAndScopeStyles:()=>bC,extractAndProcessEvents:()=>q_,evaluateExpression:()=>G1,evaluateConstant:()=>yJ,evaluateAuthExpression:()=>T4,escapeHtml:()=>v0,errorRecovery:()=>wZ,errorLogger:()=>K1,ensureTeleportTargets:()=>uj,ensureDocumentShell:()=>p7,enhancedValidationRules:()=>S9,eliminateDeadCode:()=>TV,effect:()=>a7,dprUrls:()=>CW,docsCommand:()=>CK,disconnectObserver:()=>aW,devHelpers:()=>b$,detectShell:()=>GK,detectRuntime:()=>h5,detectProjectConfig:()=>k5,detectFormat:()=>lQ,detectBuildMode:()=>sP,derived:()=>r7,deploy:()=>VL,defineStxConfig:()=>UL,defineStore:()=>zA,defineSlots:()=>mA,defineSiteConfig:()=>MU,definePropsWithValidation:()=>Mw,defineProps:()=>Rw,definePlugin:()=>N5,definePageMeta:()=>WB,defineMiddleware:()=>rb,defineExpose:()=>fA,defineEmits:()=>vA,defineDirective:()=>u0,defineCustomElement:()=>Qw,defineConfig:()=>Ax,defineClientDirective:()=>LS,defineAsyncComponent:()=>_H,defaultMediaConfig:()=>$f,defaultImageConfig:()=>fL,defaultI18nConfig:()=>gZ,defaultHeatmapConfig:()=>jz,defaultFormClasses:()=>yZ,defaultFilters:()=>R$,defaultCspConfig:()=>cT,defaultConfig:()=>N1,default:()=>zg,dedupeScopedStyles:()=>u2,decodeThumbhash:()=>iQ,cspNonceDirective:()=>e_,cspDirective:()=>t_,crossfadeTransition:()=>$U,crop:()=>zW,createVirtualList:()=>IY,createVideoDirective:()=>YJ,createVercelHandler:()=>my,createTypeChecker:()=>oK,createTranslateFilter:()=>mE,createTextEncoderStream:()=>gy,createStxApp:()=>BU,createStreamingResponse:()=>fy,createStreamRenderer:()=>vB,createStore:()=>KW,createStorageManager:()=>nb,createServerCookieManager:()=>ib,createScope:()=>dL,createSSRSuspense:()=>YH,createRouter:()=>f4,createRouteLocation:()=>g8,createRoute:()=>Hv,createRef:()=>kb,createReactive:()=>uL,createProvideContext:()=>cA,createProject:()=>Ix,createProductionBuild:()=>Fx,createPlaceholder:()=>B7,createOptimizedBuild:()=>tP,createNetlifyHandler:()=>ly,createNetlifyClient:()=>I8,createMiddlewareContext:()=>f8,createMiddleware:()=>jv,createLazyObserver:()=>nW,createKeepAliveCache:()=>VH,createKVNamespace:()=>UF,createIslandRegistry:()=>UQ,createImgDirective:()=>aY,createImagePlugin:()=>eG,createImageHandler:()=>LJ,createImageDirective:()=>wJ,createHeatmapAggregator:()=>WM,createFileManifest:()=>D8,createEnvAccessor:()=>WF,createEnhancedError:()=>C_,createEdgeHandler:()=>a8,createEdgeCache:()=>zF,createDetailedErrorMessage:()=>T0,createDenoHandler:()=>uy,createDefaultNetlifyConfig:()=>S5,createCspHeaders:()=>lT,createCookie:()=>py,createComputed:()=>Sb,createComponentInstance:()=>Db,createCloudflareHandler:()=>dy,createClientCookieManager:()=>pb,createBuiltinDirectives:()=>FS,createApp:()=>BU,createAnimationTimeline:()=>ZM,cover:()=>qW,convertToCommonJS:()=>rZ,contrast:()=>AW,contain:()=>BW,consoleError:()=>S_,configureErrorHandling:()=>E_,config:()=>T1,computed:()=>Sb,composeShellWithPage:()=>l8,componentDirective:()=>cV,componentClientSignalNames:()=>HO,compileTemplate:()=>jK,collectDeployFiles:()=>D5,clearVideoCache:()=>oY,clearTranslationCache:()=>jE,clearSignatureCache:()=>fW,clearPlaceholderCache:()=>oQ,clearOnceStore:()=>xI,clearNonce:()=>gT,clearMiddleware:()=>v8,clearImageCache:()=>AJ,clearErrorMessages:()=>R_,clearDevCaches:()=>Uj,clearCustomFilters:()=>az,clearComponentCache:()=>j4,clearCache:()=>U5,cleanupLoadingIndicator:()=>Dv,classifyScript:()=>oL,classifyAllScripts:()=>JK,checkTemplateFile:()=>Fv,checkTemplate:()=>Av,checkCache:()=>AY,checkAuthAccess:()=>p5,checkA11y:()=>i3,channel:()=>dV,captureScreenshots:()=>LF,captureScreenshot:()=>xK,cancelPendingLoads:()=>ME,calculateSha1:()=>qJ,calculateOptimalWidths:()=>gY,cacheTemplate:()=>wY,buildWebComponents:()=>kG,buildViews:()=>bA,buildUrl:()=>k0,buildSuspenseResolveScript:()=>dZ,buildStaticSite:()=>NU,buildRuntimeAsset:()=>_K,buildRouterAsset:()=>BK,buildLangPickerScript:()=>w3,buildImageUrl:()=>s1,buildForProduction:()=>qV,buildComponentLibrary:()=>IK,buildAuthParams:()=>G3,buildApp:()=>HV,buildAlternateLinks:()=>A3,build:()=>Vx,broadcastPrivate:()=>gV,broadcastPresence:()=>hV,broadcast:()=>MK,brightness:()=>FW,blur:()=>jW,batchSignUrls:()=>lJ,batch:()=>qY,autoFixA11yFile:()=>Xz,autoFixA11yDirectory:()=>cR,autoFixA11y:()=>Jz,auto:()=>IW,assetTags:()=>lP,arrayOf:()=>Cw,applyTranslations:()=>F3,applyTransformations:()=>V8,applySlots:()=>zO,applyPropDefaults:()=>Yy,applyPreset:()=>kW,applyHead:()=>qB,applyFilters:()=>mX,apiCspPreset:()=>o_,animationGroupDirective:()=>o3,analyzeVideo:()=>A8,analyzeUsage:()=>NK,analyzeTemplate:()=>sL,analyzeProject:()=>YK,analyzeDirectiveUsage:()=>NK,analyticsDirective:()=>UT,addStore:()=>bx,addPage:()=>Cx,addNonceToInlineContent:()=>F9,addLayout:()=>Px,addComponent:()=>Sx,abortNavigation:()=>cb,a11yDirective:()=>n3,__setSignalsGeneratorsForTest:()=>Gj,VideoProcessorCache:()=>q5,TransitionType:()=>Qz,TransitionEase:()=>Kz,TransitionDirection:()=>Gz,Tokenizer:()=>D7,TemplateTypeChecker:()=>sK,TEMPLATE_PRESETS:()=>Qx,StxValidationError:()=>E7,StxSyntaxError:()=>Q9,StxSecurityError:()=>G9,StxRuntimeError:()=>r1,StxFileError:()=>C$,StxError:()=>Z6,Show:()=>$w,SUSPENSE_RESOLVER_RUNTIME:()=>h9,STATE_DIR_ENV_VAR:()=>Fz,SPRING_PRESETS:()=>EX,ProductionBuild:()=>gJ,Portal:()=>Yw,PROJECT_TEMPLATES:()=>Ex,PRESETS:()=>uJ,MemorySessionStore:()=>XA,MIME_TYPES:()=>_8,MEDIA_DEFAULT_WIDTHS:()=>O4,MEDIA_DEFAULT_FORMATS:()=>S4,ImageProcessorCache:()=>z5,ImageProcessingError:()=>Q$,HydrationRuntime:()=>QW,HotReloadServer:()=>uG,HeatmapAggregator:()=>bX,Fragment:()=>j$,For:()=>Zw,ErrorLogger:()=>NZ,ErrorCodes:()=>G0,DeployError:()=>y4,DEFAULT_WIDTHS:()=>y1,DEFAULT_TRANSITION_OPTIONS:()=>Q4,DEFAULT_STATE_DIR:()=>P6,DEFAULT_QUALITY:()=>v1,DEFAULT_PLACEHOLDER_OPTIONS:()=>dY,DEFAULT_FORMATS:()=>x1,DEFAULT_DPR_VALUES:()=>z8,ComponentHMRHandler:()=>JW,COMMON_SIZES:()=>fQ,CLOAK_STYLE:()=>jD,BroadcastServer:()=>mV,Broadcast:()=>uV,BLUR_UP_CSS:()=>X5});var zg;var N6=D(()=>{HJ();TJ();N0();L2();p4();BA();y2();UU();Xw();Gw();xG();U4();OU();jw();Lw();mL();c6();DJ();C9();V$();$9();e3();E9();$5();v5();J9();wK();qK();FV();SV();xJ();o6();pV();DK();r0();w9();M9();HJ();EU();U8();bK();_F();vK();C1();Y9();$1();gK();$Z();f9();m$();uK();mK();$Y();yY();k2();S7();bJ();q7();_1();kF();AK();iK();i8();dF();XK();GY();mF();G4();UY();HK();pK();G6();cF();bG();QQ();FQ();pF();rF();oX();v6();sF();YA();QA();TJ();CA();PA();c$();v2();g2();jU();N0();xY();Aw();zg={}});import I3 from"path";var a5;var WX=D(()=>{N6();C1();$1();t4();_1();x$();a5={name:"bun-plugin-stx",async setup($){let Y={...await d0(),...$.config?.stx},J=new Set,X=Y.webComponents?.enabled?`./${I3.relative(I3.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await kG(Y,J);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await AY(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await z4(()=>Bun.file(G).text(),"",(H)=>{throw new C$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new C$(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:z,allScripts:_}=p1.time("script-extraction",()=>{let H=W,O=_4(W);if(O)H=O.content.trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let w of V){let N=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=w.match(/<script\b([^>]*)>/i),E=R?R[1]:"";if(/\bserver\b/i.test(E))L=N;else F.push(w)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),B={__filename:G,__dirname:I3.dirname(G),__stx:{webComponentsPath:X,builtComponents:Q}};await z4(()=>D0(U,B,G),void 0,(H)=>{let O=new r1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(K1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await p1.timeAsync("directive-processing",async()=>{return await q0(z,B,G,Y,K)});if(_.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => ($1(),V7)),O=H(_.join(`
|
|
17868
17885
|
`),B),V=j.search(/<\/body>/i);if(V!==-1)j=j.slice(0,V)+O+`
|
|
17869
17886
|
`+j.slice(V);else j+=`
|
|
17870
17887
|
${O}`}if(j=await D4(j),K.forEach((H)=>J.add(H)),Y.cache&&Y.cachePath){if(await wY(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new r1(`Plugin processing failed: ${String(K)}`,G);if(K1.log(W,{filePath:G,buildConfig:$.config}),b$.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),Y.debug)console.error("stx Plugin Error:",W);let U=W,z=U.line||null,_=U.context||null;return{contents:Y.debug||$6()?`<!DOCTYPE html>
|
|
@@ -17927,7 +17944,7 @@ ${O}`}if(j=await D4(j),K.forEach((H)=>J.add(H)),Y.cache&&Y.cachePath){if(await w
|
|
|
17927
17944
|
<h1>Something went wrong</h1>
|
|
17928
17945
|
<p>An internal error occurred. Please try again later.</p>
|
|
17929
17946
|
</body>
|
|
17930
|
-
</html>`,loader:"html"}}})}}});var{serve:_g}=globalThis.Bun;import J4 from"fs";import I1 from"path";async function M3($,Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=I1.resolve($);if(!J4.existsSync(K))return console.error(`${T.red}Error: File not found: ${T.bright}${K}${T.reset}`),!1;if(K.endsWith(".md"))return BJ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${T.red}Error: Unsupported file type: ${T.bright}${K}${T.reset}. Only .stx and .md files are supported.`),!1;let W=c0(process.cwd(),"output");J4.mkdirSync(W,{recursive:!0}),console.log(`${T.blue}Building ${T.bright}${$}${T.reset}...`);let U=null,z=async()=>{try{let L={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},F=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,
|
|
17947
|
+
</html>`,loader:"html"}}})}}});var{serve:_g}=globalThis.Bun;import J4 from"fs";import I1 from"path";async function M3($,Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=I1.resolve($);if(!J4.existsSync(K))return console.error(`${T.red}Error: File not found: ${T.bright}${K}${T.reset}`),!1;if(K.endsWith(".md"))return BJ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${T.red}Error: Unsupported file type: ${T.bright}${K}${T.reset}. Only .stx and .md files are supported.`),!1;let W=c0(process.cwd(),"output");J4.mkdirSync(W,{recursive:!0}),console.log(`${T.blue}Building ${T.bright}${$}${T.reset}...`);let U=null,z=async()=>{try{let L={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},F=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,a5],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!F.success)return console.error(`${T.red}Build failed:${T.reset}`,F.logs),!1;let A=F.outputs.find((N)=>N.path.endsWith(".html"));if(!A)return console.error(`${T.red}No HTML output found${T.reset}`),!1;return U=await Bun.file(A.path).text(),!0}catch(L){return console.error(`${T.red}Error building stx file:${T.reset}`,L),!1}};if(!await z())return!1;let B=I1.dirname(K);await D$(B);let q=Y;try{if(q=await V6(Y),q!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${q} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let L=Z.hmrPort||q+1;Q=E8({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (N6(),W$)),F=await L();if(F?.apiRouter)H=F?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(F?.apiRoutes){j=F.apiRoutes;let A=Object.keys(j).length;if(A>0)console.log(`${T.blue}Loaded ${T.bright}${A} API route${A>1?"s":""}${T.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:A,loadChannels:w}=await Promise.resolve().then(() => (xJ(),TK)),N=F.broadcasting;await A(N);let R=N.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${R}/ws${T.reset}`);let E=I1.join(process.cwd(),"channels.ts");if(J4.existsSync(E))try{let M=await w(E);console.log(`${T.blue}Loaded ${T.bright}${M} broadcast channel${M!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(M){console.warn(`${T.yellow}Failed to load channels.ts: ${M.message}${T.reset}`)}}catch(A){console.warn(`${T.yellow}Broadcasting failed to start: ${A.message}${T.reset}`)}}catch{}if(console.log(`${T.blue}Starting server on ${T.cyan}http://localhost:${q}/${T.reset}...`),X)console.log(`${T.magenta}Hot reload enabled on ws://localhost:${G}${T.reset}`);let O=_g({port:q,async fetch(L){let F=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[F.pathname])try{return await j[F.pathname](L)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(F.pathname==="/")return(async()=>{let M=await P0(U||"");if(X)M=L4(M,G);if(Z.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(M.includes("<html"))M=M.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;if(Z.titlebarHidden)if(M.includes("<head>"))M=M.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(M.includes("<html"))M=M.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else M=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${M}`;return M})().then((M)=>new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let A=I1.join(W,F.pathname);if(J4.existsSync(A)&&J4.statSync(A).isFile()){let E=Bun.file(A),M=I1.extname(A).toLowerCase(),I="text/plain";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let w=I1.dirname(K),N=I1.join(w,F.pathname);if(J4.existsSync(N)&&J4.statSync(N).isFile()){let E=Bun.file(N),M=I1.extname(N).toLowerCase(),I="text/plain";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let R=I1.join(process.cwd(),"public",F.pathname);if(J4.existsSync(R)&&J4.statSync(R).isFile()){let E=Bun.file(R),M=I1.extname(R).toLowerCase(),I="application/octet-stream";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
|
|
17931
17948
|
${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
17932
17949
|
${T.blue}stx${T.reset} ${T.green}${process.env.stx_VERSION||"v0.0.10"}${T.reset} ${T.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${T.reset}`),console.log(`
|
|
17933
17950
|
${T.bright}\u2192 ${T.cyan}http://localhost:${q}/${T.reset}`),console.log(`
|
|
@@ -18095,24 +18112,24 @@ Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),F6(O.u
|
|
|
18095
18112
|
</script>
|
|
18096
18113
|
</body>
|
|
18097
18114
|
</html>
|
|
18098
|
-
`,S=`/${O1.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:M,fileType:"md"}}catch(V){console.error(`${T.red}Error processing Markdown file ${T.bright}${j}${T.reset}:`,V);continue}else{let V={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:X,plugins:[V,
|
|
18115
|
+
`,S=`/${O1.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:M,fileType:"md"}}catch(V){console.error(`${T.red}Error processing Markdown file ${T.bright}${j}${T.reset}:`,V);continue}else{let V={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:X,plugins:[V,a5],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${T.red}Build failed for ${T.bright}${j}${T.reset}:`,L.logs);continue}let F=L.outputs.find((R)=>R.path.endsWith(".html"));if(!F){console.error(`${T.red}No HTML output found for ${T.bright}${j}${T.reset}`);continue}let A=await Bun.file(F.path).text(),N=`/${O1.relative(Q,H).replace(/\.stx$/,"")}`;if(N.endsWith("/index"))N=N.slice(0,-6)||"/";if(N.includes("[")){let R=[...N.matchAll(/\[([^\]]+)\]/g)].map((M)=>M[1]),E=N.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:R,filePath:H,routeTemplate:N,fileType:"stx"}),G[N]={filePath:H,content:A,fileType:"stx"}}else G[N||"/"]={filePath:H,content:A,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${T.red}No files were successfully processed${T.reset}`),!1;return!0}catch(j){return console.error(`${T.red}Error processing files:${T.reset}`,j),!1}};if(!await W())return!1;let z=Y;try{if(z=await V6(Y),z!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${z} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}console.log(`${T.blue}Starting server on ${T.cyan}http://localhost:${z}/${T.reset}...`);let _=Bg({port:z,async fetch(j){let H=new URL(j.url),O=O1.join(process.cwd(),"public",H.pathname);if(D6.existsSync(O)&&D6.statSync(O).isFile()){let F=Bun.file(O),A=O1.extname(O).toLowerCase(),w="application/octet-stream";if(A===".ts"||A===".tsx"){let N=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),E=N.transformSync(R);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":w="text/html";break;case".css":w="text/css";break;case".js":w="text/javascript";break;case".json":w="application/json";break;case".png":w="image/png";break;case".jpg":case".jpeg":w="image/jpeg";break;case".gif":w="image/gif";break;case".svg":w="image/svg+xml";break;case".ico":w="image/x-icon";break;case".woff":w="font/woff";break;case".woff2":w="font/woff2";break;case".ttf":w="font/ttf";break;case".otf":w="font/otf";break;case".eot":w="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":w}})}let V=G[H.pathname];if(!V&&!H.pathname.endsWith("/"))V=G[`${H.pathname}/`];if(!V)for(let F of K){let A=H.pathname.match(F.pattern);if(A){let w=G[F.routeTemplate];if(w){let N={};for(let M=0;M<F.paramNames.length;M++)N[F.paramNames[M]]=decodeURIComponent(A[M+1]);let R=w.content,E=`<script>window.__routeParams = ${JSON.stringify(N)};</script>`;if(R.includes("</head>"))R=R.replace("</head>",`${E}
|
|
18099
18116
|
</head>`);else R=E+R;V={...w,content:R}}break}}if(V)return P0(V.content).then((F)=>{if(F.includes("</head>"))F=F.replace("</head>",`${YW}
|
|
18100
18117
|
</head>`);return new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=O1.join(X,H.pathname);if(D6.existsSync(L)&&D6.statSync(L).isFile()){let F=Bun.file(L),A=O1.extname(L).toLowerCase(),w="text/plain";if(A===".ts"||A===".tsx"){let N=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),E=N.transformSync(R);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":w="text/html";break;case".css":w="text/css";break;case".js":w="text/javascript";break;case".json":w="application/json";break;case".png":w="image/png";break;case".jpg":case".jpeg":w="image/jpeg";break;case".gif":w="image/gif";break;case".svg":w="image/svg+xml";break;case".ico":w="image/x-icon";break;case".woff":w="font/woff";break;case".woff2":w="font/woff2";break;case".ttf":w="font/ttf";break;case".otf":w="font/otf";break;case".eot":w="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":w}})}if(H.pathname!=="/"&&G["/"]){let F=j.headers.get("X-STX-Router")==="true";return P0(G["/"].content).then((A)=>{if(F){let w=A.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(w){let N=A.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${N?N[1]:""}</title></head><body><main>${w[1]}</main></body></html>`;return new Response(E,{headers:{"Content-Type":"text/html","X-STX-Partial":"true","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(j){return new Response(`<pre>${j}
|
|
18101
18118
|
${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
18102
18119
|
${T.blue}stx${T.reset} ${T.green}${process.env.stx_VERSION||"v0.0.10"}${T.reset} ${T.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${T.reset}`),console.log(`
|
|
18103
18120
|
${T.bright}\u2192 ${T.cyan}http://localhost:${z}/${T.reset}`),console.log(`
|
|
18104
18121
|
${T.yellow}Routes:${T.reset}`);let B=new Set(K.map((j)=>j.routeTemplate)),q=Object.entries(G).filter(([j])=>!B.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:O1.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");q.push({route:H,filePath:O1.relative(process.cwd(),j.filePath),fileType:"stx"})}if(q.sort((j,H)=>j.route.localeCompare(H.route)),q.forEach((j,H)=>{let V=H===q.length-1?"\u2514\u2500 ":"\u251C\u2500 ",L=j.fileType==="md"?`${T.magenta}(markdown)${T.reset}`:"";console.log(` ${T.green}${V}${j.route}${T.reset} \u2192 ${T.bright}${j.filePath}${T.reset} ${L}`)}),console.log(`
|
|
18105
|
-
Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),F6(_.url.toString(),()=>{if(J)D6.watch(Q,{recursive:!0}).close();_.stop()}),J){console.log(`${T.blue}Watching for changes...${T.reset}`);let j=D6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${T.yellow}File ${T.bright}${O}${T.yellow} changed, rebuilding...${T.reset}`),W6.clear(),j4(),await W()});process.on("SIGINT",()=>{j.close(),_.stop(),process.exit(0)})}return!0}var xw=D(()=>{$5();r0();m$();G4();WX();N0();N8()});var{serve:qg}=globalThis.Bun;import D1 from"fs";import E0 from"path";async function vw($){try{return IJ(await Bun.file($).text())}catch{return}}function IU($){let Z=Bun.file($),Y=E0.extname($).toLowerCase(),J={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":J[Y]||"application/octet-stream",...Q}})}async function E3($=".",Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=E0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (N6(),W$)),U=await W(K),z=U.root&&U.root!=="."?E0.join(K,U.root):K,_=U.pagesDir||"pages",B=E0.join(z,_);if(!D1.existsSync(B))return console.error(`${T.red}Error: No '${_}' directory found in ${T.bright}${z}${T.reset}`),console.log(`${T.dim}Create a ${_}/ directory with .stx files to define your routes.${T.reset}`),console.log(`${T.dim}Example: ${_}/index.stx for the homepage.${T.reset}`),!1;let q=f4(z);if(q.length===0)return console.error(`${T.red}Error: No page files found in ${T.bright}${B}${T.reset}`),!1;console.log(`${T.blue}Found ${T.bright}${q.length}${T.blue} routes${T.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:P,prefix:d}of j)if(D1.existsSync(P)){let l=f4(E0.dirname(P),{pagesDir:E0.basename(P)});for(let c of l){let s=d==="/"?c.pattern:`${d}${c.pattern==="/"?"":c.pattern}`;H.push({route:{...c,pattern:s},prefix:d})}if(l.length>0)console.log(`${T.blue}Plugin pages: ${T.bright}${l.length}${T.blue} routes at ${T.cyan}${d}${T.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await GK(K,Z.stxOptions?.shell),L){if(V=await SJ(L,Z.stxOptions||{}),V)console.log(`${T.blue}Using app shell: ${T.bright}${E0.relative(K,L)}${T.reset} ${T.dim}(deprecated: use layouts/default.stx instead)${T.reset}`)}}v8(),await d8(K);let F=h8();if(F.length>0)console.log(`${T.blue}Loaded ${T.bright}${F.length}${T.blue} middleware: ${T.dim}${F.join(", ")}${T.reset}`);let A={},w=null;try{let{loadStxConfig:P}=await Promise.resolve().then(() => (N6(),W$)),d=await P(K);if(d?.apiRouter)w=d?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(d?.apiRoutes){A=d.apiRoutes;let l=Object.keys(A).length;if(l>0)console.log(`${T.blue}Loaded ${T.bright}${l} API route${l>1?"s":""}${T.reset}`)}if(d?.broadcasting?.enabled)try{let{startBroadcasting:l,loadChannels:c}=await Promise.resolve().then(() => (xJ(),TK)),s=d.broadcasting;await l(s);let X0=s.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${X0}/ws${T.reset}`);let K0=E0.join(process.cwd(),"channels.ts");if(D1.existsSync(K0))try{let C0=await c(K0);console.log(`${T.blue}Loaded ${T.bright}${C0} broadcast channel${C0!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(C0){console.warn(`${T.yellow}Failed to load channels.ts: ${C0.message}${T.reset}`)}}catch(l){console.warn(`${T.yellow}Broadcasting failed to start: ${l.message}${T.reset}`)}}catch{}let N=c0(K,"output");D1.mkdirSync(N,{recursive:!0});let R=new Map,E=new Set,M=async(P)=>{let d=WK(B,P);if(!d)return null;try{let l=await Bun.build({entrypoints:[d],outdir:N,plugins:[s5],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!l.success)return null;let c=l.outputs.find((s)=>s.path.endsWith(".html"));if(!c)return null;return await Bun.file(c.path).text()}catch{return null}},I=async(P,d)=>{try{let{processDirectives:l,extractVariables:c,defaultConfig:s,loadStxConfig:X0,injectRouterScript:K0}=await Promise.resolve().then(() => (N6(),W$)),{checkCache:C0,cacheTemplate:z1,readFileCached:b0,templateCache:l1}=await Promise.resolve().then(() => (o6(),n$)),W0=await X0(K),p=(L0)=>{if(!L0)return L0;if(E0.isAbsolute(L0))return L0;return E0.resolve(K,L0)},t={...s,...W0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)t.debug=!0;t.partialsDir=p(t.partialsDir),t.componentsDir=p(t.componentsDir),t.layoutsDir=p(t.layoutsDir),t.storesDir=p(t.storesDir||"stores"),t.cachePath=p(t.cachePath)??c0(K,"cache");let _0=!d&&!Z.profile,v=t.cache!==!1;if(v&&_0){let L0=l1.get(P.filePath);if(L0)try{if((await D1.promises.stat(P.filePath)).mtime.getTime()<=L0.mtime){let x0=!0;for(let h0 of L0.dependencies){if(!D1.existsSync(h0)){x0=!1;break}if((await D1.promises.stat(h0)).mtime.getTime()>L0.mtime){x0=!1;break}}if(x0){let h0=L0.output;if(V)h0=v4(h0,{preserveHead:!0});return{route:P,content:h0,status:await vw(P.filePath)}}}}catch{}let B0=await C0(P.filePath,t);if(B0){let J0=B0;if(V)J0=v4(J0,{preserveHead:!0});return{route:P,content:J0,status:await vw(P.filePath)}}}let C=v?await b0(P.filePath):await Bun.file(P.filePath).text(),u=IJ(C),{classifyAllScripts:e}=await Promise.resolve().then(() => (N6(),W$)),n=e(C),j0=n.server.map((L0)=>L0.content),I0=C;for(let L0 of n.server)I0=I0.replace(L0.fullTag,"");let g0={__filename:P.filePath,__dirname:E0.dirname(P.filePath),params:d??{},__stx_runtime_head:{}};for(let L0 of j0)try{await c(L0,g0,P.filePath)}catch(B0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,B0?.message||B0)}let Q1=new Set,S0;if(Z.profile){let L0=performance.now();S0=await l(I0,g0,P.filePath,t,Q1);let B0=performance.now()-L0,J0=E0.relative(K,P.filePath)||P.filePath;console.log(`[stx:profile] ${J0} \u2192 ${B0.toFixed(2)}ms`)}else S0=await l(I0,g0,P.filePath,t,Q1);if(!V)S0=await K0(S0);{let{interpolateScriptExpressions:L0}=await Promise.resolve().then(() => ($1(),V7));S0=S0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(B0,J0,x0)=>{if(!/function\s+__stx_setup_/.test(x0))return B0;return`<script${J0}>${L0(x0,g0)}</script>`})}if(V)S0=v4(S0,{preserveHead:!0});if(v&&_0)await z1(P.filePath,S0,Q1,t);let{extractStreamBoundaries:k1}=await Promise.resolve().then(() => (G6(),i6)),L1=k1(g0),V1=g0.__streamTemplates;if(V1&&typeof V1==="object"&&Object.keys(V1).length>0){let L0=g0.streamBoundaries||{},B0={...t,autoShell:!1},J0=Object.keys(V1).map((h0)=>({id:h0,render:async()=>{let N4=typeof L0[h0]==="function"?await L0[h0]():void 0;return l(V1[h0],{...g0,$boundary:N4},P.filePath,B0,new Set)}})),x0=new Set(J0.map((h0)=>h0.id));L1=[...(L1||[]).filter((h0)=>!x0.has(h0.id)),...J0]}if(L1&&L1.length>0)E.add(P.pattern);else L1=void 0;return{route:P,content:S0,status:u,boundaries:L1}}catch(l){return console.error(`${T.red}Error building ${T.bright}${P.pattern}${T.reset}:`,l),null}},S=8,k=async()=>{R.clear(),O.clear();for(let P=0;P<q.length;P+=S){let d=q.slice(P,P+S),l=await Promise.all(d.map((c)=>I(c)));for(let c of l)if(c)R.set(c.route.pattern,c)}for(let P=0;P<H.length;P+=S){let d=H.slice(P,P+S),l=await Promise.all(d.map(({route:c})=>I(c)));for(let c of l)if(c)O.set(c.route.pattern,c)}return R.size>0};if(console.log(`${T.blue}Building pages...${T.reset}`),!await k())return console.error(`${T.red}No pages were successfully built${T.reset}`),!1;await D$(K);let y=Y;try{if(y=await V6(Y),y!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${y} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let P=Z.hmrPort||y+1;Q=E8({wsPort:P,verbose:!1}),G=Q.start(P)}let b=(P,d)=>{let c=`<script data-stx-route-params>(function(){var p=${JSON.stringify(d).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${c}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${c}`);return c+P};console.log(`${T.blue}Starting server...${T.reset}`);let h=qg({port:y,async fetch(P){let d=new URL(P.url),l=U?.publicDir||"public",c=E0.join(K,l,d.pathname),s=E0.join(K,d.pathname),X0=E0.join(N,d.pathname),[K0,C0,z1]=await Promise.all([D1.promises.stat(c).catch(()=>null),D1.promises.stat(s).catch(()=>null),D1.promises.stat(X0).catch(()=>null)]);if(K0?.isFile())return IU(c);if(C0?.isFile())return IU(s);if(z1?.isFile())return IU(X0);if(d.pathname.startsWith("/_stx/component/")){let p=decodeURIComponent(d.pathname.slice(16));if(p)try{let t=`<${p} />`,_0={...buildConfig,autoShell:!1},v=await processDirectives(t,{},E0.join(K,"components",`${p}.stx`),_0,new Set);return new Response(v,{headers:{"Content-Type":"text/html"}})}catch(t){return new Response(`<div class="stx-async-error">${t.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(d.pathname==="/_stx/img"){let{handleImageRequest:p}=await Promise.resolve().then(() => (rG(),SL)),t=await p(P,{publicDir:E0.join(K,l),cacheDir:c0(K,"cache","img")});if(t)return t}if(w)try{let p=await w.handleRequest(P);if(p.status!==404)return p}catch{}if(A[d.pathname])try{return await A[d.pathname](P)}catch(p){return new Response(JSON.stringify({error:p.message}),{status:500,headers:{"Content-Type":"application/json"}})}let b0=CJ(d.pathname,q);if(b0){let p=R.get(b0.route.pattern),t=E.has(b0.route.pattern);if(b0.route.isDynamic&&Object.keys(b0.params).length>0||t){let _0=await I(b0.route,b0.params);if(_0)p=_0}if(p){let _0=p.status??200,v=CZ();if(v.validate){if(!await v.validate({params:b0.params})){let e=await M(404);if(e){let n=e;if(n=await P0(n,K),X)n=L4(n,G);return new Response(n,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(v.middleware){let u=g8(d.pathname,b0.params,v,d.search),e=f8(u,null,P),n=await u8(v.middleware,e);if(n.redirect){let j0=n.redirect.path,I0=n.redirect.options.redirectCode||302,g0=new Headers(n.responseHeaders);return g0.set("Location",j0),new Response(null,{status:I0,headers:g0})}if(n.abort){let{statusCode:j0,message:I0}=n.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${j0}</title></head><body><h1>Error ${j0}</h1><p>${I0}</p></body></html>`,{status:j0,headers:{"Content-Type":"text/html"}})}if(Object.keys(n.state).length>0){let j0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(n.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;p.content=p.content.replace("</head>",`${j0}</head>`)}}let C=p.content;if(V&&KK(P)){let u=p8(C),e=C.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=e?e[1].trim():"";if(Object.keys(b0.params).length>0)C=b(C,b0.params);C=await P0(C,K);let j0=U?.router?.container||"main";return C=c8(C,j0),new Response(C,{status:_0,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":u.layout,"X-STX-Layout-Group":u.group,...n&&{"X-STX-Title":encodeURIComponent(n)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)C=l8(V,C);if(Object.keys(b0.params).length>0)C=b(C,b0.params);if(C=await P0(C,K),X)C=L4(C,G);if(Z.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;if(Z.titlebarHidden)if(C.includes("<head>"))C=C.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else C=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${C}`;if(p.boundaries&&p.boundaries.length>0){let{renderStreamingPage:u,streamToResponse:e}=await Promise.resolve().then(() => (G6(),i6));return e(u(C,p.boundaries,{timeoutMs:30000}),{status:_0,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(C,{status:_0,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let p=H.map((_0)=>_0.route),t=CJ(d.pathname,p);if(t){let _0=O.get(t.route.pattern);if(_0){let v=_0.content;if(V)v=l8(V,v);if(Object.keys(t.params).length>0)v=b(v,t.params);if(v=await P0(v,K),X)v=L4(v,G);return new Response(v,{status:_0.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:_0}of j)if(_0!=="/"&&d.pathname.startsWith(_0)){let v=O.get(_0)||O.get(_0+"/");if(v){let C=v.content;if(V)C=l8(V,C);if(C=await P0(C,K),X)C=L4(C,G);return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let l1=R.get("/");if(l1){let p=l1.content;if(p=await P0(p,K),X)p=L4(p,G);if(Z.native)if(p.includes("<head>"))p=p.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else p="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+p;return new Response(p,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let W0=await M(404);if(W0){let p=W0;if(p=await P0(p,K),X)p=L4(p,G);return new Response(p,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let d=await M(500);if(d)return new Response(d,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
|
|
18122
|
+
Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),F6(_.url.toString(),()=>{if(J)D6.watch(Q,{recursive:!0}).close();_.stop()}),J){console.log(`${T.blue}Watching for changes...${T.reset}`);let j=D6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${T.yellow}File ${T.bright}${O}${T.yellow} changed, rebuilding...${T.reset}`),W6.clear(),j4(),await W()});process.on("SIGINT",()=>{j.close(),_.stop(),process.exit(0)})}return!0}var xw=D(()=>{$5();r0();m$();G4();WX();N0();N8()});var{serve:qg}=globalThis.Bun;import D1 from"fs";import E0 from"path";async function vw($){try{return IJ(await Bun.file($).text())}catch{return}}function IU($){let Z=Bun.file($),Y=E0.extname($).toLowerCase(),J={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":J[Y]||"application/octet-stream",...Q}})}async function E3($=".",Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=E0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (N6(),W$)),U=await W(K),z=U.root&&U.root!=="."?E0.join(K,U.root):K,_=U.pagesDir||"pages",B=E0.join(z,_);if(!D1.existsSync(B))return console.error(`${T.red}Error: No '${_}' directory found in ${T.bright}${z}${T.reset}`),console.log(`${T.dim}Create a ${_}/ directory with .stx files to define your routes.${T.reset}`),console.log(`${T.dim}Example: ${_}/index.stx for the homepage.${T.reset}`),!1;let q=f4(z);if(q.length===0)return console.error(`${T.red}Error: No page files found in ${T.bright}${B}${T.reset}`),!1;console.log(`${T.blue}Found ${T.bright}${q.length}${T.blue} routes${T.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:P,prefix:d}of j)if(D1.existsSync(P)){let l=f4(E0.dirname(P),{pagesDir:E0.basename(P)});for(let c of l){let a=d==="/"?c.pattern:`${d}${c.pattern==="/"?"":c.pattern}`;H.push({route:{...c,pattern:a},prefix:d})}if(l.length>0)console.log(`${T.blue}Plugin pages: ${T.bright}${l.length}${T.blue} routes at ${T.cyan}${d}${T.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await GK(K,Z.stxOptions?.shell),L){if(V=await SJ(L,Z.stxOptions||{}),V)console.log(`${T.blue}Using app shell: ${T.bright}${E0.relative(K,L)}${T.reset} ${T.dim}(deprecated: use layouts/default.stx instead)${T.reset}`)}}v8(),await d8(K);let F=h8();if(F.length>0)console.log(`${T.blue}Loaded ${T.bright}${F.length}${T.blue} middleware: ${T.dim}${F.join(", ")}${T.reset}`);let A={},w=null;try{let{loadStxConfig:P}=await Promise.resolve().then(() => (N6(),W$)),d=await P(K);if(d?.apiRouter)w=d?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(d?.apiRoutes){A=d.apiRoutes;let l=Object.keys(A).length;if(l>0)console.log(`${T.blue}Loaded ${T.bright}${l} API route${l>1?"s":""}${T.reset}`)}if(d?.broadcasting?.enabled)try{let{startBroadcasting:l,loadChannels:c}=await Promise.resolve().then(() => (xJ(),TK)),a=d.broadcasting;await l(a);let X0=a.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${X0}/ws${T.reset}`);let K0=E0.join(process.cwd(),"channels.ts");if(D1.existsSync(K0))try{let C0=await c(K0);console.log(`${T.blue}Loaded ${T.bright}${C0} broadcast channel${C0!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(C0){console.warn(`${T.yellow}Failed to load channels.ts: ${C0.message}${T.reset}`)}}catch(l){console.warn(`${T.yellow}Broadcasting failed to start: ${l.message}${T.reset}`)}}catch{}let N=c0(K,"output");D1.mkdirSync(N,{recursive:!0});let R=new Map,E=new Set,M=async(P)=>{let d=WK(B,P);if(!d)return null;try{let l=await Bun.build({entrypoints:[d],outdir:N,plugins:[a5],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!l.success)return null;let c=l.outputs.find((a)=>a.path.endsWith(".html"));if(!c)return null;return await Bun.file(c.path).text()}catch{return null}},I=async(P,d)=>{try{let{processDirectives:l,extractVariables:c,defaultConfig:a,loadStxConfig:X0,injectRouterScript:K0}=await Promise.resolve().then(() => (N6(),W$)),{checkCache:C0,cacheTemplate:z1,readFileCached:b0,templateCache:l1}=await Promise.resolve().then(() => (o6(),n$)),W0=await X0(K),p=(L0)=>{if(!L0)return L0;if(E0.isAbsolute(L0))return L0;return E0.resolve(K,L0)},t={...a,...W0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)t.debug=!0;t.partialsDir=p(t.partialsDir),t.componentsDir=p(t.componentsDir),t.layoutsDir=p(t.layoutsDir),t.storesDir=p(t.storesDir||"stores"),t.cachePath=p(t.cachePath)??c0(K,"cache");let _0=!d&&!Z.profile,v=t.cache!==!1;if(v&&_0){let L0=l1.get(P.filePath);if(L0)try{if((await D1.promises.stat(P.filePath)).mtime.getTime()<=L0.mtime){let x0=!0;for(let h0 of L0.dependencies){if(!D1.existsSync(h0)){x0=!1;break}if((await D1.promises.stat(h0)).mtime.getTime()>L0.mtime){x0=!1;break}}if(x0){let h0=L0.output;if(V)h0=v4(h0,{preserveHead:!0});return{route:P,content:h0,status:await vw(P.filePath)}}}}catch{}let B0=await C0(P.filePath,t);if(B0){let J0=B0;if(V)J0=v4(J0,{preserveHead:!0});return{route:P,content:J0,status:await vw(P.filePath)}}}let C=v?await b0(P.filePath):await Bun.file(P.filePath).text(),u=IJ(C),{classifyAllScripts:e}=await Promise.resolve().then(() => (N6(),W$)),n=e(C),j0=n.server.map((L0)=>L0.content),I0=C;for(let L0 of n.server)I0=I0.replace(L0.fullTag,"");let g0={__filename:P.filePath,__dirname:E0.dirname(P.filePath),params:d??{},__stx_runtime_head:{}};for(let L0 of j0)try{await c(L0,g0,P.filePath)}catch(B0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,B0?.message||B0)}let Q1=new Set,S0;if(Z.profile){let L0=performance.now();S0=await l(I0,g0,P.filePath,t,Q1);let B0=performance.now()-L0,J0=E0.relative(K,P.filePath)||P.filePath;console.log(`[stx:profile] ${J0} \u2192 ${B0.toFixed(2)}ms`)}else S0=await l(I0,g0,P.filePath,t,Q1);if(!V)S0=await K0(S0);{let{interpolateScriptExpressions:L0}=await Promise.resolve().then(() => ($1(),V7));S0=S0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(B0,J0,x0)=>{if(!/function\s+__stx_setup_/.test(x0))return B0;return`<script${J0}>${L0(x0,g0)}</script>`})}if(V)S0=v4(S0,{preserveHead:!0});if(v&&_0)await z1(P.filePath,S0,Q1,t);let{extractStreamBoundaries:k1}=await Promise.resolve().then(() => (G6(),i6)),L1=k1(g0),V1=g0.__streamTemplates;if(V1&&typeof V1==="object"&&Object.keys(V1).length>0){let L0=g0.streamBoundaries||{},B0={...t,autoShell:!1},J0=Object.keys(V1).map((h0)=>({id:h0,render:async()=>{let N4=typeof L0[h0]==="function"?await L0[h0]():void 0;return l(V1[h0],{...g0,$boundary:N4},P.filePath,B0,new Set)}})),x0=new Set(J0.map((h0)=>h0.id));L1=[...(L1||[]).filter((h0)=>!x0.has(h0.id)),...J0]}if(L1&&L1.length>0)E.add(P.pattern);else L1=void 0;return{route:P,content:S0,status:u,boundaries:L1}}catch(l){return console.error(`${T.red}Error building ${T.bright}${P.pattern}${T.reset}:`,l),null}},S=8,k=async()=>{R.clear(),O.clear();for(let P=0;P<q.length;P+=S){let d=q.slice(P,P+S),l=await Promise.all(d.map((c)=>I(c)));for(let c of l)if(c)R.set(c.route.pattern,c)}for(let P=0;P<H.length;P+=S){let d=H.slice(P,P+S),l=await Promise.all(d.map(({route:c})=>I(c)));for(let c of l)if(c)O.set(c.route.pattern,c)}return R.size>0};if(console.log(`${T.blue}Building pages...${T.reset}`),!await k())return console.error(`${T.red}No pages were successfully built${T.reset}`),!1;await D$(K);let y=Y;try{if(y=await V6(Y),y!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${y} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let P=Z.hmrPort||y+1;Q=E8({wsPort:P,verbose:!1}),G=Q.start(P)}let b=(P,d)=>{let c=`<script data-stx-route-params>(function(){var p=${JSON.stringify(d).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${c}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${c}`);return c+P};console.log(`${T.blue}Starting server...${T.reset}`);let h=qg({port:y,async fetch(P){let d=new URL(P.url),l=U?.publicDir||"public",c=E0.join(K,l,d.pathname),a=E0.join(K,d.pathname),X0=E0.join(N,d.pathname),[K0,C0,z1]=await Promise.all([D1.promises.stat(c).catch(()=>null),D1.promises.stat(a).catch(()=>null),D1.promises.stat(X0).catch(()=>null)]);if(K0?.isFile())return IU(c);if(C0?.isFile())return IU(a);if(z1?.isFile())return IU(X0);if(d.pathname.startsWith("/_stx/component/")){let p=decodeURIComponent(d.pathname.slice(16));if(p)try{let t=`<${p} />`,_0={...buildConfig,autoShell:!1},v=await processDirectives(t,{},E0.join(K,"components",`${p}.stx`),_0,new Set);return new Response(v,{headers:{"Content-Type":"text/html"}})}catch(t){return new Response(`<div class="stx-async-error">${t.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(d.pathname==="/_stx/img"){let{handleImageRequest:p}=await Promise.resolve().then(() => (rG(),SL)),t=await p(P,{publicDir:E0.join(K,l),cacheDir:c0(K,"cache","img")});if(t)return t}if(w)try{let p=await w.handleRequest(P);if(p.status!==404)return p}catch{}if(A[d.pathname])try{return await A[d.pathname](P)}catch(p){return new Response(JSON.stringify({error:p.message}),{status:500,headers:{"Content-Type":"application/json"}})}let b0=CJ(d.pathname,q);if(b0){let p=R.get(b0.route.pattern),t=E.has(b0.route.pattern);if(b0.route.isDynamic&&Object.keys(b0.params).length>0||t){let _0=await I(b0.route,b0.params);if(_0)p=_0}if(p){let _0=p.status??200,v=CZ();if(v.validate){if(!await v.validate({params:b0.params})){let e=await M(404);if(e){let n=e;if(n=await P0(n,K),X)n=L4(n,G);return new Response(n,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(v.middleware){let u=g8(d.pathname,b0.params,v,d.search),e=f8(u,null,P),n=await u8(v.middleware,e);if(n.redirect){let j0=n.redirect.path,I0=n.redirect.options.redirectCode||302,g0=new Headers(n.responseHeaders);return g0.set("Location",j0),new Response(null,{status:I0,headers:g0})}if(n.abort){let{statusCode:j0,message:I0}=n.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${j0}</title></head><body><h1>Error ${j0}</h1><p>${I0}</p></body></html>`,{status:j0,headers:{"Content-Type":"text/html"}})}if(Object.keys(n.state).length>0){let j0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(n.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;p.content=p.content.replace("</head>",`${j0}</head>`)}}let C=p.content;if(V&&KK(P)){let u=p8(C),e=C.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=e?e[1].trim():"";if(Object.keys(b0.params).length>0)C=b(C,b0.params);C=await P0(C,K);let j0=U?.router?.container||"main";return C=c8(C,j0),new Response(C,{status:_0,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":u.layout,"X-STX-Layout-Group":u.group,...n&&{"X-STX-Title":encodeURIComponent(n)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)C=l8(V,C);if(Object.keys(b0.params).length>0)C=b(C,b0.params);if(C=await P0(C,K),X)C=L4(C,G);if(Z.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;if(Z.titlebarHidden)if(C.includes("<head>"))C=C.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else C=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${C}`;if(p.boundaries&&p.boundaries.length>0){let{renderStreamingPage:u,streamToResponse:e}=await Promise.resolve().then(() => (G6(),i6));return e(u(C,p.boundaries,{timeoutMs:30000}),{status:_0,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(C,{status:_0,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let p=H.map((_0)=>_0.route),t=CJ(d.pathname,p);if(t){let _0=O.get(t.route.pattern);if(_0){let v=_0.content;if(V)v=l8(V,v);if(Object.keys(t.params).length>0)v=b(v,t.params);if(v=await P0(v,K),X)v=L4(v,G);return new Response(v,{status:_0.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:_0}of j)if(_0!=="/"&&d.pathname.startsWith(_0)){let v=O.get(_0)||O.get(_0+"/");if(v){let C=v.content;if(V)C=l8(V,C);if(C=await P0(C,K),X)C=L4(C,G);return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let l1=R.get("/");if(l1){let p=l1.content;if(p=await P0(p,K),X)p=L4(p,G);if(Z.native)if(p.includes("<head>"))p=p.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else p="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+p;return new Response(p,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let W0=await M(404);if(W0){let p=W0;if(p=await P0(p,K),X)p=L4(p,G);return new Response(p,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let d=await M(500);if(d)return new Response(d,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
|
|
18106
18123
|
${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
18107
18124
|
${T.blue}stx${T.reset} ${T.green}${process.env.stx_VERSION||"v0.0.10"}${T.reset} ${T.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${T.reset}`),console.log(`
|
|
18108
18125
|
${T.bright}\u2192 ${T.cyan}http://localhost:${y}/${T.reset}`),X)console.log(`${T.dim} HMR: ws://localhost:${G}${T.reset}`);console.log(`
|
|
18109
18126
|
${T.yellow}Routes:${T.reset}`);let m=[...UK(q,K)];for(let{route:P}of H)m.push(`${P.pattern}`);if(m.forEach((P,d)=>{let c=d===m.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${T.green}${c}${T.reset}${P}`)}),console.log(`
|
|
18110
|
-
Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),F6(h.url.toString(),()=>{if(Q)I5();h.stop()}),Z.native){let P,d=E0.join(B,"index.stx");if(D1.existsSync(d)){let c=await Bun.file(d).text();P=_J(c)}let l=U?.app?.window??{};await M5(y,{title:U?.app?.head?.title||E0.basename(K)||"stx App",width:l.width,height:l.height,darkMode:l.darkMode,hotReload:l.hotReload,titlebarHidden:l.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(J){console.log(`${T.blue}Watching for changes...${T.reset}`);let P=(c)=>{return c.startsWith("public/")||c.startsWith("public\\")},d=(c)=>{let
|
|
18127
|
+
Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),F6(h.url.toString(),()=>{if(Q)I5();h.stop()}),Z.native){let P,d=E0.join(B,"index.stx");if(D1.existsSync(d)){let c=await Bun.file(d).text();P=_J(c)}let l=U?.app?.window??{};await M5(y,{title:U?.app?.head?.title||E0.basename(K)||"stx App",width:l.width,height:l.height,darkMode:l.darkMode,hotReload:l.hotReload,titlebarHidden:l.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(J){console.log(`${T.blue}Watching for changes...${T.reset}`);let P=(c)=>{return c.startsWith("public/")||c.startsWith("public\\")},d=(c)=>{let a=c.toLowerCase();return a.endsWith(".stx")||a.endsWith(".html")||a.endsWith(".md")},l=D1.watch(K,{recursive:!0},async(c,a)=>{if(!a||T8(a))return;if(M8(a))if(P(a)){if(console.log(`${T.cyan}${a} changed${T.reset}`),X&&Q)Q.reload(a)}else if(d(a)){console.log(`${T.yellow}${a} changed, rebuilding...${T.reset}`),W6.clear(),j4();try{let{invalidateFileCache:X0,templateCache:K0}=await Promise.resolve().then(() => (o6(),n$));X0(E0.resolve(K,a)),K0.delete(E0.resolve(K,a))}catch{}if(L&&a){if(E0.resolve(K,a)===L||E0.basename(L)===a){let K0=await SJ(L,Z.stxOptions||{});if(K0)V=K0}}if(await k(),await N7(K),X&&Q)Q.reload(a)}else{console.log(`${T.yellow}${a} changed, rebuilding...${T.reset}`),W6.clear(),j4();try{let{invalidateFileCache:X0,templateCache:K0}=await Promise.resolve().then(() => (o6(),n$));X0(E0.resolve(K,a)),K0.delete(E0.resolve(K,a))}catch{}if(await k(),X&&Q)Q.reload(a)}else if(R8(a)){if(console.log(`${T.cyan}CSS ${a} changed${T.reset}`),X&&Q)Q.updateCss(a)}});process.on("SIGINT",()=>{if(l.close(),Q)I5();h.stop(),process.exit(0)})}return!0}var fw=D(()=>{v5();m$();G4();WX();i8();DJ();c6();N0();N8()});var EU=D(()=>{dG();yw();xw();fw()});var uw={};$0(uw,{runPwaAudit:()=>jg,formatAuditResult:()=>Hg,calculateAuditResult:()=>dw,auditConfig:()=>gw,auditBuildOutput:()=>hw});import O$ from"fs";import UX from"path";function gw($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let J=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:J.includes(192),message:J.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:J.includes(512),message:J.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let X=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:X.length>0,message:X.length>0?`${X.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function hw($){let Z=[],Y=UX.join($,"manifest.json"),J=O$.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:J,message:J?"manifest.json exists":"manifest.json not found in build output"}),J)try{let z=JSON.parse(O$.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(z.icons)&&z.icons.length>0,message:z.icons?.length?`${z.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let X=UX.join($,"sw.js"),Q=O$.existsSync(X);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=UX.join($,"offline.html"),K=O$.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=UX.join($,"pwa-icons");if(O$.existsSync(W)){let z=O$.readdirSync(W).filter((_)=>_.endsWith(".png")||_.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:z.length>0,message:z.length>0?`${z.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function dw($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),J=Z.filter((W)=>W.passed).length,X=Y.filter((W)=>W.passed).length,Q=Z.length>0?J/Z.length*70:70,G=Y.length>0?X/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function jg($,Z){let Y=gw($),J=Z&&O$.existsSync(Z)?hw(Z):[];return dw([...Y,...J])}function Hg($){let Z=[];Z.push(`
|
|
18111
18128
|
=== PWA Audit Report ===
|
|
18112
18129
|
`);let Y=$.score>=90?"32":$.score>=70?"33":"31";Z.push(`Score: \x1B[${Y}m${$.score}/100\x1B[0m`),Z.push(`Passed: ${$.passed} | Failed: ${$.failed} | Warnings: ${$.warnings}
|
|
18113
18130
|
`);let J=["required","recommended","optional"];for(let X of J){let Q=$.checks.filter((G)=>G.category===X);if(Q.length===0)continue;Z.push(`
|
|
18114
18131
|
${X.toUpperCase()}:`);for(let G of Q){let K=G.passed?"\x1B[32m\u2713\x1B[0m":"\x1B[31m\u2717\x1B[0m";if(Z.push(` ${K} ${G.name}: ${G.message}`),G.details)Z.push(` ${G.details}`)}}return Z.push(""),Z.join(`
|
|
18115
|
-
`)}var mw=()=>{};import D3 from"fs";import
|
|
18132
|
+
`)}var mw=()=>{};import D3 from"fs";import s5 from"path";import{gzipSync as Og}from"zlib";import{createHash as Lg}from"crypto";async function k3($,Z={}){let{includeSourceMaps:Y=!1,parseImports:J=!0,detectDuplicates:X=!0,topModulesCount:Q=20}=Z;if(!D3.existsSync($))throw Error(`Build directory not found: ${$}`);if(!D3.statSync($).isDirectory())throw Error(`Not a directory: ${$}`);let K=await Ag($,Y),W=[],U=[];for(let O of K)try{let V=await wg(O,$,J);W.push(V)}catch(V){U.push(`Failed to process ${O}: ${V}`)}let z=Tg(W,$),_=W.reduce((O,V)=>O+V.size,0),B=W.reduce((O,V)=>O+V.gzipSize,0),q=Eg(W),j=X?Ig(W):[],H=[...W].sort((O,V)=>V.size-O.size).slice(0,Q);return{timestamp:Date.now(),buildDir:s5.resolve($),chunks:z,totalSize:_,totalGzipSize:B,moduleCount:W.length,duplicates:j,byType:q,largestModules:H,warnings:U}}async function Ag($,Z){let Y=[];async function J(X){let Q=await D3.promises.readdir(X,{withFileTypes:!0});for(let G of Q){let K=s5.join(X,G.name);if(G.isDirectory()){if(!G.name.startsWith(".")&&G.name!=="node_modules")await J(K)}else if(G.isFile()){if(!Z&&G.name.endsWith(".map"))continue;Y.push(K)}}}return await J($),Y}async function wg($,Z,Y){let J=await D3.promises.readFile($),X=s5.relative(Z,$),Q=s5.extname($).toLowerCase(),G=J.length,K=Ng(J),W=Rg(J,Q),U=Lg("md5").update(J).digest("hex").slice(0,8),z=lw[Q]||"other",_=[];if(Y&&z==="js")_.push(...Mg(J.toString("utf-8")));return{id:X,path:X,size:G,gzipSize:K,parsedSize:W,extension:Q,type:z,imports:_,importedBy:[],hash:U}}function Ng($){try{let Z=Og($,{level:9}).length;return Math.min(Z,$.length)}catch{return $.length}}function Rg($,Z){if(Z.includes(".min.")||$.length<1000)return $.length;let J=lw[Z];if(J==="js")return Math.round($.length*0.6);if(J==="css")return Math.round($.length*0.7);return $.length}function Mg($){let Z=[],Y=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,J;while((J=Y.exec($))!==null)Z.push(J[1]);let X=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((J=X.exec($))!==null)Z.push(J[1]);let Q=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((J=Q.exec($))!==null)Z.push(J[1]);return[...new Set(Z)]}function Tg($,Z){let Y=new Map;for(let X of $){let Q=X.path.split(s5.sep),G;if(Q.length===1)G=s5.basename(X.path,X.extension);else G=Q[0];let K=Y.get(G)||[];K.push(X),Y.set(G,K)}let J=[];for(let[X,Q]of Y){let G=Q.reduce((z,_)=>z+_.size,0),K=Q.reduce((z,_)=>z+_.gzipSize,0),W=Q.some((z)=>Fg.some((_)=>_.test(z.path))),U=Q.some((z)=>Vg.some((_)=>_.test(z.path)));J.push({name:X,files:Q.map((z)=>z.path),modules:Q,size:G,gzipSize:K,isEntry:W,isVendor:U})}return J.sort((X,Q)=>Q.size-X.size)}function Eg($){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Y of $)Z[Y.type].count++,Z[Y.type].size+=Y.size,Z[Y.type].gzipSize+=Y.gzipSize;return Z}function Ig($){let Z=new Map;for(let J of $){let X=Z.get(J.hash)||[];X.push(J),Z.set(J.hash,X)}let Y=[];for(let[,J]of Z)if(J.length>1){let X=J[0];Y.push({path:X.path,count:J.length,wastedBytes:X.size*(J.length-1),locations:J.map((Q)=>Q.path)})}return Y.sort((J,X)=>X.wastedBytes-J.wastedBytes)}function U0($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}function zX($){let Z=$.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Y=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Y*1024;case"MB":return Y*1024*1024;case"GB":return Y*1024*1024*1024;default:return Y}}function S3($,Z){if(Z===0)return"0%";return`${($/Z*100).toFixed(1)}%`}var lw,Vg,Fg;var C3=D(()=>{lw={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},Vg=[/node_modules/,/vendor/,/bower_components/,/\.min\./],Fg=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/]});function _X($,Z){switch(Z.format){case"json":return Dg($,Z);case"markdown":return Sg($,Z);case"text":default:return kg($,Z)}}function Dg($,Z){let Y=b3($,Z);return JSON.stringify({timestamp:$.timestamp,buildDir:$.buildDir,summary:{totalSize:$.totalSize,totalSizeFormatted:U0($.totalSize),totalGzipSize:$.totalGzipSize,totalGzipSizeFormatted:U0($.totalGzipSize),moduleCount:$.moduleCount,chunkCount:$.chunks.length,duplicateCount:$.duplicates.length},byType:Object.fromEntries(Object.entries($.byType).map(([J,X])=>[J,{...X,sizeFormatted:U0(X.size),gzipSizeFormatted:U0(X.gzipSize)}])),chunks:$.chunks.map((J)=>({name:J.name,size:J.size,sizeFormatted:U0(J.size),gzipSize:J.gzipSize,gzipSizeFormatted:U0(J.gzipSize),moduleCount:J.modules.length,isEntry:J.isEntry,isVendor:J.isVendor})),largestModules:$.largestModules.slice(0,Z.topModules||10).map((J)=>({path:J.path,size:J.size,sizeFormatted:U0(J.size),gzipSize:J.gzipSize,gzipSizeFormatted:U0(J.gzipSize),type:J.type})),duplicates:$.duplicates,analysis:Y,warnings:$.warnings},null,2)}function kg($,Z){let Y=[],J=Z.showGzip!==!1;if(Y.push(""),Y.push("Bundle Analysis Report"),Y.push("\u2550".repeat(50)),Y.push(""),Y.push("Summary"),Y.push("\u2500".repeat(50)),J)Y.push(`Total Size: ${U0($.totalSize)} (${U0($.totalGzipSize)} gzip)`);else Y.push(`Total Size: ${U0($.totalSize)}`);if(Y.push(`Modules: ${$.moduleCount}`),Y.push(`Chunks: ${$.chunks.length}`),$.duplicates.length>0)Y.push(`Duplicates: ${$.duplicates.length}`);if(Y.push(""),Z.threshold&&$.totalSize>Z.threshold)Y.push(`\u26A0\uFE0F Bundle exceeds threshold of ${U0(Z.threshold)}!`),Y.push("");Y.push("Size by Type"),Y.push("\u2500".repeat(50));let X=["js","css","html","image","font","other"];for(let G of X){let K=$.byType[G];if(K.count>0){let W=S3(K.size,$.totalSize),U=J?` (${U0(K.gzipSize)} gzip)`:"";Y.push(` ${G.padEnd(8)} ${U0(K.size).padStart(12)}${U} ${W.padStart(6)} (${K.count} files)`)}}Y.push(""),Y.push("Chunks"),Y.push("\u2500".repeat(50));for(let G of $.chunks.slice(0,10)){let K=[];if(G.isEntry)K.push("entry");if(G.isVendor)K.push("vendor");let W=K.length>0?` [${K.join(", ")}]`:"",U=J?` (${U0(G.gzipSize)} gzip)`:"";Y.push(` ${G.name.padEnd(20)} ${U0(G.size).padStart(12)}${U}${W}`)}if($.chunks.length>10)Y.push(` ... and ${$.chunks.length-10} more chunks`);Y.push("");let Q=Z.topModules||10;Y.push(`Largest Modules (Top ${Q})`),Y.push("\u2500".repeat(50));for(let G=0;G<Math.min(Q,$.largestModules.length);G++){let K=$.largestModules[G],W=J?` (${U0(K.gzipSize)} gzip)`:"";Y.push(` ${(G+1).toString().padStart(2)}. ${K.path}`),Y.push(` ${U0(K.size)}${W}`)}if(Y.push(""),$.duplicates.length>0){Y.push("Duplicate Modules"),Y.push("\u2500".repeat(50));for(let G of $.duplicates.slice(0,5))Y.push(` ${G.path}`),Y.push(` ${G.count} copies, wasting ${U0(G.wastedBytes)}`);if($.duplicates.length>5)Y.push(` ... and ${$.duplicates.length-5} more duplicates`);Y.push("")}if(Z.recommendations!==!1){let G=b3($,Z);if(G.recommendations.length>0){Y.push("Recommendations"),Y.push("\u2500".repeat(50));for(let K of G.recommendations.slice(0,5)){let W=K.impact==="high"?"\u26A1":K.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Y.push(` ${W} ${K.title}`),Y.push(` ${K.description}`)}Y.push("")}}if($.warnings.length>0){Y.push("Warnings"),Y.push("\u2500".repeat(50));for(let G of $.warnings)Y.push(` \u26A0\uFE0F ${G}`);Y.push("")}return Y.join(`
|
|
18116
18133
|
`)}function Sg($,Z){let Y=[],J=Z.showGzip!==!1;if(Y.push("# Bundle Analysis Report"),Y.push(""),Y.push(`Generated: ${new Date($.timestamp).toISOString()}`),Y.push(""),Y.push("## Summary"),Y.push(""),Y.push("| Metric | Value |"),Y.push("|--------|-------|"),Y.push(`| Total Size | ${U0($.totalSize)} |`),J)Y.push(`| Gzip Size | ${U0($.totalGzipSize)} |`);Y.push(`| Modules | ${$.moduleCount} |`),Y.push(`| Chunks | ${$.chunks.length} |`),Y.push(`| Duplicates | ${$.duplicates.length} |`),Y.push(""),Y.push("## Size by Type"),Y.push(""),Y.push("| Type | Size | Gzip | % | Files |"),Y.push("|------|------|------|---|-------|");let X=["js","css","html","image","font","other"];for(let G of X){let K=$.byType[G];if(K.count>0)Y.push(`| ${G} | ${U0(K.size)} | ${U0(K.gzipSize)} | ${S3(K.size,$.totalSize)} | ${K.count} |`)}Y.push(""),Y.push("## Chunks"),Y.push(""),Y.push("| Name | Size | Gzip | Modules | Type |"),Y.push("|------|------|------|---------|------|");for(let G of $.chunks.slice(0,15)){let K=G.isEntry?"Entry":G.isVendor?"Vendor":"-";Y.push(`| ${G.name} | ${U0(G.size)} | ${U0(G.gzipSize)} | ${G.modules.length} | ${K} |`)}Y.push("");let Q=Z.topModules||10;Y.push(`## Largest Modules (Top ${Q})`),Y.push(""),Y.push("| # | Path | Size | Gzip |"),Y.push("|---|------|------|------|");for(let G=0;G<Math.min(Q,$.largestModules.length);G++){let K=$.largestModules[G];Y.push(`| ${G+1} | \`${K.path}\` | ${U0(K.size)} | ${U0(K.gzipSize)} |`)}if(Y.push(""),$.duplicates.length>0){Y.push("## Duplicates"),Y.push(""),Y.push("| Path | Copies | Wasted |"),Y.push("|------|--------|--------|");for(let G of $.duplicates.slice(0,10))Y.push(`| \`${G.path}\` | ${G.count} | ${U0(G.wastedBytes)} |`);Y.push("")}if(Z.recommendations!==!1){let G=b3($,Z);if(G.recommendations.length>0){Y.push("## Recommendations"),Y.push("");for(let K of G.recommendations)Y.push(`### ${K.title}`),Y.push(""),Y.push(K.description),Y.push(""),Y.push(`- **Impact:** ${K.impact}`),Y.push(`- **Effort:** ${K.effort}`),Y.push("")}}return Y.join(`
|
|
18117
18134
|
`)}function b3($,Z){let Y=[],J=[];if(Z.threshold&&$.totalSize>Z.threshold)Y.push({severity:"error",message:`Bundle size (${U0($.totalSize)}) exceeds threshold (${U0(Z.threshold)})`});if($.totalSize>1048576)Y.push({severity:"warning",message:`Bundle is over 1MB (${U0($.totalSize)})`,details:"Large bundles can significantly impact load time"});if($.duplicates.length>0){let K=$.duplicates.reduce((W,U)=>W+U.wastedBytes,0);Y.push({severity:"warning",message:`${$.duplicates.length} duplicate modules found, wasting ${U0(K)}`}),J.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if($.byType.js.size/$.totalSize>0.8&&$.totalSize>512000)J.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let Q=$.largestModules.filter((K)=>K.size>102400);if(Q.length>0){Y.push({severity:"info",message:`${Q.length} modules are over 100KB`});for(let K of Q){if(K.path.includes("lodash")&&!K.path.includes("lodash-es"))J.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(K.path.includes("moment"))J.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if($.byType.image.size>512000)J.push({title:"Optimize Images",description:`Images account for ${U0($.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let G=100;if($.totalSize>1048576)G-=20;else if($.totalSize>512000)G-=10;if(G-=Math.min(20,$.duplicates.length*2),G-=Math.min(15,Q.length*3),Z.threshold&&$.totalSize>Z.threshold)G-=25;return{score:Math.max(0,G),issues:Y,recommendations:J}}function cw($){for(let[Z,Y]of Object.entries(Cg))if($.includes(Z))return{title:`Optimize ${Z}`,description:`Consider using ${Y.alternative}. Potential savings: ${Y.savings}`,impact:"high",effort:"low"};return null}var Cg;var DU=D(()=>{C3();Cg={lodash:{alternative:"lodash-es or individual imports",savings:"~70%"},moment:{alternative:"date-fns or dayjs",savings:"~90%"},"chart.js":{alternative:"chart.js with tree-shaking",savings:"~50%"},"highlight.js":{alternative:"Selective language imports",savings:"~80%"},fontawesome:{alternative:"Individual icon imports",savings:"~90%"},"material-ui":{alternative:"Named imports from @mui/*",savings:"~60%"}}});function BX($,Z={}){let{title:Y="Bundle Analysis",gzip:J=!0,colorScheme:X="default"}=Z,Q=bg[X],G=Pg($),K=JSON.stringify(G);return`<!DOCTYPE html>
|
|
18118
18135
|
<html lang="en">
|
|
@@ -19075,9 +19092,9 @@ else if (data.type === 'event' && data.method) {
|
|
|
19075
19092
|
}
|
|
19076
19093
|
})();
|
|
19077
19094
|
</script>
|
|
19078
|
-
`.replace("debug: false,",`debug: ${Z},`).replace("timeout: 30000",`timeout: ${Y}`)}function
|
|
19095
|
+
`.replace("debug: false,",`debug: ${Z},`).replace("timeout: 30000",`timeout: ${Y}`)}function aw($,Z={}){if($.includes("__craftBridgeInitialized"))return $;let Y=gg(Z);if($.includes("</head>"))return $.replace("</head>",`${Y}
|
|
19079
19096
|
</head>`);if($.includes("<body"))return $.replace(/(<body[^>]*>)/,`$1
|
|
19080
|
-
${Y}`);return Y+$}var
|
|
19097
|
+
${Y}`);return Y+$}var sw=()=>{};function tw($,Z={}){let{classPrefix:Y="craft"}=Z;if(!$.includes("craft-component-styles"))if($.includes("</head>"))$=$.replace("</head>",`${`
|
|
19081
19098
|
<style id="craft-component-styles">
|
|
19082
19099
|
/* Craft Component Base Styles */
|
|
19083
19100
|
.craft-button {
|
|
@@ -20542,11 +20559,11 @@ ${Y}`);return Y+$}var aw=()=>{};function tw($,Z={}){let{classPrefix:Y="craft"}=Z
|
|
|
20542
20559
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
20543
20560
|
})();
|
|
20544
20561
|
</script>
|
|
20545
|
-
`;return $=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(J,X,Q)=>{return jX("sidebar",X,Q.trim(),Z,Y)}),$=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(J,X)=>{return jX("sidebar",X,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(J,X,Q)=>{return jX(X,Q,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(J,X,Q,G)=>{return jX(X,Q,G.trim(),Z,Y)}),$}function jX($,Z,Y,J,X){let Q=J.components?.[$]||hg[$];if(!Q)return console.warn(`[stx] Unknown Craft component: @craft-${$}`),`<div class="${X}-unknown" data-component="${$}">${Y}</div>`;let G=HX(Z),K=[Q.fallbackClasses||`${X}-${$}`];if(G.class)K.push(G.class),delete G.class;if(Q.render)return G.__fallbackClasses=K.join(" "),Q.render(G,Y);let W=og(G,Q,K);if(["input","hr","br","img"].includes(Q.fallbackTag))return`<${Q.fallbackTag} ${W}>`;return`<${Q.fallbackTag} ${W}>${Y}</${Q.fallbackTag}>`}function HX($){let Z={},Y=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,J;while((J=Y.exec($))!==null){let[X,Q,G,K]=J,W=G??K;if(X.startsWith(":"))Z[Q]=W;else if(X.startsWith("@"))Z[`on${Q.charAt(0).toUpperCase()}${Q.slice(1)}`]=W;else if(W===void 0)Z[Q]=!0;else Z[Q]=W}return Z}function dg($,Z){let Y=o5(String($.id||`craft-sidebar-${
|
|
20562
|
+
`;return $=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(J,X,Q)=>{return jX("sidebar",X,Q.trim(),Z,Y)}),$=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(J,X)=>{return jX("sidebar",X,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(J,X,Q)=>{return jX(X,Q,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(J,X,Q,G)=>{return jX(X,Q,G.trim(),Z,Y)}),$}function jX($,Z,Y,J,X){let Q=J.components?.[$]||hg[$];if(!Q)return console.warn(`[stx] Unknown Craft component: @craft-${$}`),`<div class="${X}-unknown" data-component="${$}">${Y}</div>`;let G=HX(Z),K=[Q.fallbackClasses||`${X}-${$}`];if(G.class)K.push(G.class),delete G.class;if(Q.render)return G.__fallbackClasses=K.join(" "),Q.render(G,Y);let W=og(G,Q,K);if(["input","hr","br","img"].includes(Q.fallbackTag))return`<${Q.fallbackTag} ${W}>`;return`<${Q.fallbackTag} ${W}>${Y}</${Q.fallbackTag}>`}function HX($){let Z={},Y=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,J;while((J=Y.exec($))!==null){let[X,Q,G,K]=J,W=G??K;if(X.startsWith(":"))Z[Q]=W;else if(X.startsWith("@"))Z[`on${Q.charAt(0).toUpperCase()}${Q.slice(1)}`]=W;else if(W===void 0)Z[Q]=!0;else Z[Q]=W}return Z}function dg($,Z){let Y=o5(String($.id||`craft-sidebar-${ag(Z||JSON.stringify($))}`)),J=ig($.spaces)||pg(Z),X=J.length?[]:rg($.sections)||ew(Z),Q=String($.selectedSpace||J[0]?.id||""),G=J.find((j)=>j.id===Q)||J[0],K=String($.selectedItem||$.selected||(J.length?G?.sections[0]?.items[0]?.id:X[0]?.items[0]?.id)||""),W={id:Y,variant:String($.variant||"desktop"),material:String($.material||"sidebar"),backgroundEffect:String($.backgroundEffect||"shimmer"),allowsVibrancy:$.allowsVibrancy!==!1&&$.allowsVibrancy!=="false",materialOpacity:Number($.materialOpacity??0.68),materialDarkOpacity:$.materialDarkOpacity===void 0?void 0:Number($.materialDarkOpacity),minWidth:$.minWidth===void 0?240:Number($.minWidth),maxWidth:$.maxWidth===void 0?340:Number($.maxWidth),canCollapse:$.canCollapse!==!1&&$.canCollapse!=="false",searchPlaceholder:$.searchPlaceholder?String($.searchPlaceholder):void 0,selectedItem:K,sections:X,spaces:J,selectedSpace:Q||void 0},U=String($.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),z=Number($.width||$.sidebarWidth||286),_=$.native===!1||$.native==="false"?"false":"true",B=W.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${l4(W.searchPlaceholder)}"></div>`:"",q;if(J.length)q=ng(J,Q,K);else if(X.length)q=X.map((j)=>$N(j,K)).join("");else q=Z;return`<aside class="${h1(U)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${h1(Y)}" data-native="${_}" style="--craft-sidebar-width:${z}px">
|
|
20546
20563
|
${B}
|
|
20547
20564
|
${q}
|
|
20548
20565
|
</aside>
|
|
20549
|
-
<script type="application/json" data-craft-sidebar-config="${h1(Y)}">${
|
|
20566
|
+
<script type="application/json" data-craft-sidebar-config="${h1(Y)}">${sg(W)}</script>`}function ug($,Z){let Y=o5(String($.id||$.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${h1(Y)}">
|
|
20550
20567
|
${$.label?`<div class="craft-sidebar-space-title">${l4(String($.label))}</div>`:""}
|
|
20551
20568
|
${Z}
|
|
20552
20569
|
</section>`}function mg($,Z){let Y=String($.header||$.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${h1(String($.id||"section"))}">
|
|
@@ -20563,7 +20580,7 @@ ${Y}`);return Y+$}var aw=()=>{};function tw($,Z={}){let{classPrefix:Y="craft"}=Z
|
|
|
20563
20580
|
${$.icon?`<span class="craft-sidebar-item-icon" data-icon="${h1($.icon)}"${Y}></span>`:""}
|
|
20564
20581
|
<span class="craft-sidebar-item-label">${l4($.label)}</span>
|
|
20565
20582
|
${$.badge?`<span class="craft-sidebar-item-badge">${l4($.badge)}</span>`:""}
|
|
20566
|
-
</button>`}function o5($){return $.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function
|
|
20583
|
+
</button>`}function o5($){return $.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function ag($){let Z=5381;for(let Y=0;Y<$.length;Y++)Z=Z*33^$.charCodeAt(Y);return(Z>>>0).toString(36)}function l4($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h1($){return l4($).replace(/`/g,"`")}function sg($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function og($,Z,Y){let J=[];J.push(`class="${Y.join(" ")}"`),J.push(`data-craft="${Z.nativeType}"`);for(let[X,Q]of Object.entries($))if(Q===!0)J.push(X);else if(Q!==!1&&Q!==void 0&&Q!==null){let G=String(Q).replace(/"/g,""");J.push(`${X}="${G}"`)}return J.join(" ")}var hg,ow=`
|
|
20567
20584
|
<style id="craft-component-styles">
|
|
20568
20585
|
/* Craft Component Base Styles */
|
|
20569
20586
|
.craft-button {
|
|
@@ -20995,7 +21012,7 @@ ${Y}`);return Y+$}var aw=()=>{};function tw($,Z={}){let{classPrefix:Y="craft"}=Z
|
|
|
20995
21012
|
</details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:($,Z)=>{let Y=$.variant||"info",J=$.title||"";return`<div class="craft-alert craft-alert-${Y}" role="alert">
|
|
20996
21013
|
${J?`<div class="craft-alert-title">${J}</div>`:""}
|
|
20997
21014
|
<div class="craft-alert-content">${Z}</div>
|
|
20998
|
-
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:($,Z)=>{let Y=$.content||"",J=$.position||"top";return`<span class="craft-tooltip" data-tooltip="${Y}" data-position="${J}">${Z}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:dg},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:ug},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:mg},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:lg},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:($,Z)=>{return`<input type="color" class="craft-color-picker" value="${$.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:($,Z)=>{let Y=$.value||"",J=$.min||"",X=$.max||"";return`<input type="date" class="craft-date-picker" value="${Y}" min="${J}" max="${X}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:($,Z)=>{return`<input type="time" class="craft-time-picker" value="${$.value||""}">`}}}});var UN={};$0(UN,{getAvailableTargets:()=>KN,getAvailableFormats:()=>WN,default:()=>Hh,buildNative:()=>GN});import{existsSync as XN,mkdirSync as m1,copyFileSync as k6,chmodSync as S6}from"fs";import{join as o,basename as tg}from"path";import{spawn as OX,execSync as eg}from"child_process";import{tmpdir as QN,homedir as CU,platform as $h}from"os";async function GN($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||P3(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||P3(),J=$.format||Uh(Y),X=$.output||o(process.cwd(),"dist","native");if(!XN(X))m1(X,{recursive:!0});let Q=await qU($.input,{context:$.context,options:{isDev:!1}});if(Q=
|
|
21015
|
+
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:($,Z)=>{let Y=$.content||"",J=$.position||"top";return`<span class="craft-tooltip" data-tooltip="${Y}" data-position="${J}">${Z}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:dg},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:ug},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:mg},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:lg},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:($,Z)=>{return`<input type="color" class="craft-color-picker" value="${$.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:($,Z)=>{let Y=$.value||"",J=$.min||"",X=$.max||"";return`<input type="date" class="craft-date-picker" value="${Y}" min="${J}" max="${X}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:($,Z)=>{return`<input type="time" class="craft-time-picker" value="${$.value||""}">`}}}});var UN={};$0(UN,{getAvailableTargets:()=>KN,getAvailableFormats:()=>WN,default:()=>Hh,buildNative:()=>GN});import{existsSync as XN,mkdirSync as m1,copyFileSync as k6,chmodSync as S6}from"fs";import{join as o,basename as tg}from"path";import{spawn as OX,execSync as eg}from"child_process";import{tmpdir as QN,homedir as CU,platform as $h}from"os";async function GN($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||P3(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||P3(),J=$.format||Uh(Y),X=$.output||o(process.cwd(),"dist","native");if(!XN(X))m1(X,{recursive:!0});let Q=await qU($.input,{context:$.context,options:{isDev:!1}});if(Q=aw(Q,{debug:$.verbose}),Q=tw(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${ow}
|
|
20999
21016
|
</head>`)}let G=$.name||tg($.input,".stx"),K=$.version||"1.0.0",W=$.craftPath||await Wh();if(!W)return{success:!1,target:Y,format:J,error:"Craft binary not found. Please install Craft or specify craftPath."};if($.verbose)console.log(`\uD83D\uDCE6 Building native app for ${Y}...`),console.log(` Input: ${$.input}`),console.log(` Output: ${X}`),console.log(` Craft: ${W}`);let U;switch(Y){case"macos":U=await Zh(Q,G,K,X,J,$,W);break;case"windows":U=await Xh(Q,G,K,X,J,$,W);break;case"linux":U=await Qh(Q,G,K,X,J,$,W);break;case"ios":U=await Gh(Q,G,K,X,$,W);break;case"android":U=await Kh(Q,G,K,X,$,W);break;default:U={success:!1,target:Y,format:J,error:`Unsupported target: ${Y}`}}return U.duration=Date.now()-Z,U}catch(Y){return{success:!1,target:$.target||P3(),format:$.format||"app",error:Y.message,duration:Date.now()-Z}}}async function Zh($,Z,Y,J,X,Q,G){let K=Q.bundleId||`com.stx.${Z.toLowerCase().replace(/[^a-z0-9]/g,"")}`,W=o(J,`${Z}.app`),U=o(W,"Contents"),z=o(U,"MacOS"),_=o(U,"Resources");m1(z,{recursive:!0}),m1(_,{recursive:!0});let B=o(_,"index.html");await Bun.write(B,$);let q="";if(Q.sidebar?.enabled&&Q.sidebar?.config)q=o(_,"sidebar-config.json"),await Bun.write(q,JSON.stringify(Q.sidebar.config));let j=Q.sidebar?.enabled?`--native-sidebar --sidebar-width ${Q.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",H=Q.menubarOnly??Q.systemTray;if((Q.bundleStyle||(await Yh(G)?"executable":"launcher"))==="executable"){let F=o(z,Z);k6(G,F),S6(F,493);let A={html:"index.html",title:Q.window?.title||Z,width:Q.window?.width||1200,height:Q.window?.height||800,devTools:Boolean(Q.devTools)};if(H)A.menubarOnly=!0;else if(Q.systemTray)A.systemTray=!0;if(Q.window?.frameless)A.frameless=!0;if(Q.window?.transparent)A.transparent=!0;if(Q.window?.alwaysOnTop)A.alwaysOnTop=!0;if(Q.window?.resizable===!1)A.resizable=!1;await Bun.write(o(_,"craft.json"),`${JSON.stringify(A,null,2)}
|
|
21000
21017
|
`)}else{let F=o(z,"craft");k6(G,F),S6(F,493);let A=Q.sidebar?.enabled?`--native-sidebar --sidebar-width ${Q.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",N=`#!/bin/bash
|
|
21001
21018
|
set -euo pipefail
|
|
@@ -21058,7 +21075,7 @@ Exec=${Y.toLowerCase()}
|
|
|
21058
21075
|
Terminal=false
|
|
21059
21076
|
Categories=Utility;
|
|
21060
21077
|
Icon=${Y.toLowerCase()}
|
|
21061
|
-
`;Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.desktop`),q);let j=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.png`),j),J.icon&&XN(J.icon))k6(J.icon,o(G,`${Y.toLowerCase()}.png`));let H=OX("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if(Z0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)S6(Z,493),X({success:!0});else X({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(O)=>{Z0("fs").rmSync(Q,{recursive:!0,force:!0}),X({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){X({success:!1,error:Q.message})}})}function KN(){return[P3()]}function WN($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var jh,Hh;var zN=D(()=>{aw();YN();jU();jh={buildNative:GN,getAvailableTargets:KN,getAvailableFormats:WN,detectPlatform:P3},Hh=jh});function y3($,Z){return`${Oh[Z]}${$}\x1B[0m`}function BN($,Z){return`${Lh[Z]}${$}\x1B[0m`}function x3(){console.log(""),console.log(X1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(X1(" \u2551")+X4(" \uD83D\uDCD6 STX Story ")+X1("\u2551")),console.log(X1(" \u2551")+VX(" Component Showcase & Testing ")+X1("\u2551")),console.log(X1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function PU($,Z){if(console.log(X4(" Server running at:")),console.log(""),console.log(` ${VX("\u279C")} ${X4("Local:")} ${X1($)}`),Z)console.log(` ${VX("\u279C")} ${X4("Network:")} ${X1(Z)}`);console.log("")}function v3($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?LX:bU;console.log(` ${Y(Z)} Found ${X4(String($))} story ${$===1?"file":"files"}`)}function qN($,Z){if(console.log(""),console.log(` ${_N("\u2717")} ${X4(_N("Error:"))} ${$}`),Z)console.log(` ${VX(Z)}`);console.log("")}function t5($){console.log(` ${bU("\u26A0")} ${bU("Warning:")} ${$}`)}function jN($){console.log(` ${Vh("\u2139")} ${$}`)}function HN($,Z,Y){console.log(""),console.log(X1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(X1(" \u2551")+X4(" Build Complete ")+X1("\u2551")),console.log(X1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${LX("\u2713")} Stories: ${X4(String($))}`),console.log(` ${LX("\u2713")} Output: ${X4(Z)}`),console.log(` ${LX("\u2713")} Time: ${X4(`${Y}ms`)}`),console.log("")}function yU(){console.log(""),console.log(X4(" Keyboard Shortcuts:")),console.log(""),console.log(` ${X1("h")} Show this help`),console.log(` ${X1("o")} Open in browser`),console.log(` ${X1("r")} Restart server`),console.log(` ${X1("c")} Clear console`),console.log(` ${X1("q")} Quit`),console.log("")}var Oh,Lh,_N=($)=>y3($,"red"),LX=($)=>y3($,"green"),bU=($)=>y3($,"yellow"),Vh=($)=>y3($,"blue"),X1=($)=>y3($,"cyan"),X4=($)=>BN($,"bold"),VX=($)=>BN($,"dim");var FX=D(()=>{Oh={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},Lh={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import ON from"fs";import xU from"path";function LN($,Z){let Y=[xU.join($.root,"stx.config.ts"),xU.join($.root,"stx.config.js"),xU.join($.root,"stx.config.mjs")],J=Z.debounceMs??300,X=null,Q=[];for(let G of Y)try{if(!ON.existsSync(G))continue;let K=ON.watch(G,(W)=>{if(W==="change"){if(X)clearTimeout(X);X=setTimeout(async()=>{jN("Config file changed, restarting...");try{await Z.onChange()}catch(U){t5(`Failed to restart: ${U}`)}},J)}});Q.push(K)}catch{}return{stop(){if(X)clearTimeout(X);for(let G of Q)G.close()}}}var VN=D(()=>{FX()});function NN($){let Z={...Fh,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...wN,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??FN,backgroundPresets:Z.backgroundPresets??AN,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var FN,AN,wN,Fh;var RN=D(()=>{FN=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],AN=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],wN={file:"title",order:"asc",groups:[]},Fh={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:wN,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:FN,backgroundPresets:AN,autoApplyContrastColor:!1,port:6006}});var MN={};$0(MN,{updateContextTree:()=>Z7,updateContextStoryFiles:()=>$7,createContext:()=>e5});import Ah from"path";async function e5($){let Z=$.root??process.cwd(),Y;try{let G=await import(Ah.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let J={...Y,...$.config},X=NN(J);return{root:Z,config:X,storyFiles:[],tree:void 0,mode:$.mode}}function $7($,Z){$.storyFiles=Z}function Z7($,Z){$.tree=Z}var f3=D(()=>{RN()});import vU from"fs";import TN from"path";class fU{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=TN.join($,wh),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=vU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Nh,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=TN.dirname(this.storagePath);if(await vU.promises.mkdir($,{recursive:!0}),this.storage.events.length>EN)this.storage.events=this.storage.events.slice(-EN);await vU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Rh(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,Z){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:Z}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let Z=this.viewStartTimes.get($);if(Z){let Y=Date.now()-Z;this.track({type:"view",componentId:$,metadata:{duration:Y,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,Z,Y){this.track({type:"prop_change",componentId:$,propName:Z,metadata:{value:Y}})}trackVariantSwitch($,Z){this.track({type:"variant_switch",componentId:$,variantId:Z})}trackSearch($,Z){this.track({type:"search",query:$,metadata:{resultCount:Z}})}getComponentAnalytics($,Z){let Y=this.storage.events.filter((B)=>B.componentId===$),J=Y.filter((B)=>B.type==="view"&&!B.metadata?.endView),X=Y.filter((B)=>B.type==="prop_change"),Q=Y.filter((B)=>B.type==="variant_switch"),G={};for(let B of X)if(B.propName)G[B.propName]=(G[B.propName]||0)+1;let K={};for(let B of Q)if(B.variantId)K[B.variantId]=(K[B.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((B)=>B.componentViews.includes($)).map((B)=>B.id)),U=Y.filter((B)=>B.metadata?.duration).map((B)=>B.metadata.duration),z=U.length>0?U.reduce((B,q)=>B+q,0)/U.length:0,_=Object.entries(G).sort((B,q)=>q[1]-B[1]).slice(0,5).map(([B])=>B);return{componentId:$,componentName:Z,viewCount:J.length,uniqueViews:W.size,lastViewed:J[J.length-1]?.timestamp,propChanges:G,topChangedProps:_,variantViews:K,avgTimeSpent:z}}getMostViewedComponents($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="view"&&Y.componentId&&!Y.metadata?.endView)Z.set(Y.componentId,(Z.get(Y.componentId)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({componentId:Y,viewCount:J})).sort((Y,J)=>J.viewCount-Y.viewCount).slice(0,$)}getMostChangedProps($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="prop_change"&&Y.propName)Z.set(Y.propName,(Z.get(Y.propName)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({propName:Y,changeCount:J})).sort((Y,J)=>J.changeCount-Y.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((X)=>X.type==="search"),Z=new Map,Y=0;for(let X of $){if(X.query)Z.set(X.query,(Z.get(X.query)||0)+1);if(X.metadata?.resultCount!==void 0)Y+=X.metadata.resultCount}let J=Array.from(Z.entries()).map(([X,Q])=>({query:X,count:Q})).sort((X,Q)=>Q.count-X.count).slice(0,10);return{totalSearches:$.length,topQueries:J,avgResultCount:$.length>0?Y/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Rh(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var wh=".stx/story/analytics.json",Nh=1,EN=1e4;var IN=()=>{};import gU from"fs";import DN from"path";class hU{storage;storagePath;dirty=!1;constructor($){this.storagePath=DN.join($,Mh),this.storage=this.loadStorage()}loadStorage(){try{let $=gU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Th,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=DN.dirname(this.storagePath);await gU.promises.mkdir($,{recursive:!0}),await gU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,J={}){let X={id:Eh(),name:J.name||`${$}/${Z}`,storyId:$,variantId:Z,props:Y,created:Date.now(),notes:J.notes,color:J.color};return this.storage.bookmarks.push(X),this.dirty=!0,X}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((Z)=>Z.storyId===$)}getBookmark($){return this.storage.bookmarks.find((Z)=>Z.id===$)}isBookmarked($,Z){return this.storage.bookmarks.some((Y)=>Y.storyId===$&&Y.variantId===Z)}updateBookmark($,Z){let Y=this.getBookmark($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deleteBookmark($){let Z=this.storage.bookmarks.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.bookmarks.splice(Z,1),this.dirty=!0,!0}toggleBookmark($,Z,Y){let J=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===Z);if(J)return this.deleteBookmark(J.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,Z,Y)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,Z=!0){let Y=JSON.parse($),J=0;for(let X of Y.bookmarks){if(Z){let Q=this.storage.bookmarks.find((G)=>G.id===X.id);if(Q)Object.assign(Q,X);else this.storage.bookmarks.push(X)}else this.storage.bookmarks.push(X);J++}if(J>0)this.dirty=!0;return J}}function Eh(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Mh=".stx/story/bookmarks.json",Th=1;var kN=()=>{};import dU from"fs";import g3 from"path";async function h3($){let{root:Z,config:Y}=$,J=[],X=await Ih(Z,Y.storyMatch,Y.storyIgnored);for(let Q of X){let G=g3.resolve(Z,Q),K=uU(Q,G);J.push(K)}return J}async function Ih($,Z,Y){let J=[];async function X(Q,G){let K=await dU.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=g3.join(Q,W.name),z=g3.relative(G,U);if(SN(z,Y))continue;if(W.isDirectory())await X(U,G);else if(W.isFile()){if(CN(z,Z))J.push(z)}}}return await X($,$),J}function SN($,Z){for(let Y of Z)if(bN($,Y))return!0;return!1}function CN($,Z){for(let Y of Z)if(bN($,Y))return!0;return!1}function bN($,Z){let Y=$.replace(/\\/g,"/"),X=Z.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return X=`^${X}$`,new RegExp(X).test(Y)}function uU($,Z){let Y=g3.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:Z,relativePath:$,fileName:Y,treeFile:{title:Y,path:$}}}function PN($,Z){let{root:Y,config:J}=$,X=[],Q=dU.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!CN(W,J.storyMatch))return;if(SN(W,J.storyIgnored))return;let U=g3.resolve(Y,W);try{await dU.promises.access(U);let z=uU(W,U);Z(G==="rename"?"add":"change",z)}catch{let z=uU(W,U);Z("unlink",z)}});return X.push(Q),()=>{for(let G of X)G.close()}}var mU=()=>{};function Dh($,Z){let Y=Z.treeFile||{title:Z.fileName,path:Z.relativePath};if($.tree.file==="title")return Y.title.split("/");if($.tree.file==="path")return[...Z.relativePath.split("/").slice(0,-1),Y.title];if(typeof $.tree.file==="function")return $.tree.file(Y);return[Y.title]}function d3($,Z){for(let G of Z)G.treePath=Dh($,G);let Y=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),J={treeObject:{}};Y.push(J);for(let G=0;G<Z.length;G++){let K=Z[G],W=kh(K,Y,J);Sh(K.treePath,G,W.treeObject)}let X=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Y)if(G===J)Q.push(...lU(G.treeObject,X));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:lU(G.treeObject,X)});return Q}function kh($,Z,Y){let J=$.treeFile||{title:$.fileName,path:$.relativePath};for(let X of Z)if(X.groupConfig?.include&&X.groupConfig.include(J))return X;return Y}function Sh($,Z,Y){let J=Y;for(let X=0;X<$.length;X++){let Q=$[X];if(X===$.length-1)if(J[Q]!==void 0){let K=1;while(J[`${Q}-${K}`]!==void 0)K++;J[`${Q}-${K}`]=Z}else J[Q]=Z;else{if(J[Q]===void 0)J[Q]={};else if(typeof J[Q]==="number"){let K=J[Q];J[Q]={"":K}}J=J[Q]}}}function lU($,Z){let Y=[];for(let[J,X]of Object.entries($))if(typeof X==="number")Y.push({title:J,index:X});else Y.push({title:J,children:lU(X,Z)});return Y.sort((J,X)=>Z(J.title,X.title)),Y}function yN(){return{open($){AX.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){AX.delete($)},message($,Z){}}}function cU($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of AX)try{Y.send(Z)}catch{AX.delete(Y)}}function xN($,Z){cU({type:"story-update",data:{storyId:$,...Z}})}function vN($,Z){cU({type:"story-add",data:{storyId:$,...Z}})}function fN($){cU({type:"story-remove",data:{storyId:$}})}function gN($){return`
|
|
21078
|
+
`;Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.desktop`),q);let j=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.png`),j),J.icon&&XN(J.icon))k6(J.icon,o(G,`${Y.toLowerCase()}.png`));let H=OX("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if(Z0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)S6(Z,493),X({success:!0});else X({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(O)=>{Z0("fs").rmSync(Q,{recursive:!0,force:!0}),X({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){X({success:!1,error:Q.message})}})}function KN(){return[P3()]}function WN($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var jh,Hh;var zN=D(()=>{sw();YN();jU();jh={buildNative:GN,getAvailableTargets:KN,getAvailableFormats:WN,detectPlatform:P3},Hh=jh});function y3($,Z){return`${Oh[Z]}${$}\x1B[0m`}function BN($,Z){return`${Lh[Z]}${$}\x1B[0m`}function x3(){console.log(""),console.log(X1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(X1(" \u2551")+X4(" \uD83D\uDCD6 STX Story ")+X1("\u2551")),console.log(X1(" \u2551")+VX(" Component Showcase & Testing ")+X1("\u2551")),console.log(X1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function PU($,Z){if(console.log(X4(" Server running at:")),console.log(""),console.log(` ${VX("\u279C")} ${X4("Local:")} ${X1($)}`),Z)console.log(` ${VX("\u279C")} ${X4("Network:")} ${X1(Z)}`);console.log("")}function v3($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?LX:bU;console.log(` ${Y(Z)} Found ${X4(String($))} story ${$===1?"file":"files"}`)}function qN($,Z){if(console.log(""),console.log(` ${_N("\u2717")} ${X4(_N("Error:"))} ${$}`),Z)console.log(` ${VX(Z)}`);console.log("")}function t5($){console.log(` ${bU("\u26A0")} ${bU("Warning:")} ${$}`)}function jN($){console.log(` ${Vh("\u2139")} ${$}`)}function HN($,Z,Y){console.log(""),console.log(X1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(X1(" \u2551")+X4(" Build Complete ")+X1("\u2551")),console.log(X1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${LX("\u2713")} Stories: ${X4(String($))}`),console.log(` ${LX("\u2713")} Output: ${X4(Z)}`),console.log(` ${LX("\u2713")} Time: ${X4(`${Y}ms`)}`),console.log("")}function yU(){console.log(""),console.log(X4(" Keyboard Shortcuts:")),console.log(""),console.log(` ${X1("h")} Show this help`),console.log(` ${X1("o")} Open in browser`),console.log(` ${X1("r")} Restart server`),console.log(` ${X1("c")} Clear console`),console.log(` ${X1("q")} Quit`),console.log("")}var Oh,Lh,_N=($)=>y3($,"red"),LX=($)=>y3($,"green"),bU=($)=>y3($,"yellow"),Vh=($)=>y3($,"blue"),X1=($)=>y3($,"cyan"),X4=($)=>BN($,"bold"),VX=($)=>BN($,"dim");var FX=D(()=>{Oh={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},Lh={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import ON from"fs";import xU from"path";function LN($,Z){let Y=[xU.join($.root,"stx.config.ts"),xU.join($.root,"stx.config.js"),xU.join($.root,"stx.config.mjs")],J=Z.debounceMs??300,X=null,Q=[];for(let G of Y)try{if(!ON.existsSync(G))continue;let K=ON.watch(G,(W)=>{if(W==="change"){if(X)clearTimeout(X);X=setTimeout(async()=>{jN("Config file changed, restarting...");try{await Z.onChange()}catch(U){t5(`Failed to restart: ${U}`)}},J)}});Q.push(K)}catch{}return{stop(){if(X)clearTimeout(X);for(let G of Q)G.close()}}}var VN=D(()=>{FX()});function NN($){let Z={...Fh,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...wN,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??FN,backgroundPresets:Z.backgroundPresets??AN,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var FN,AN,wN,Fh;var RN=D(()=>{FN=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],AN=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],wN={file:"title",order:"asc",groups:[]},Fh={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:wN,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:FN,backgroundPresets:AN,autoApplyContrastColor:!1,port:6006}});var MN={};$0(MN,{updateContextTree:()=>Z7,updateContextStoryFiles:()=>$7,createContext:()=>e5});import Ah from"path";async function e5($){let Z=$.root??process.cwd(),Y;try{let G=await import(Ah.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let J={...Y,...$.config},X=NN(J);return{root:Z,config:X,storyFiles:[],tree:void 0,mode:$.mode}}function $7($,Z){$.storyFiles=Z}function Z7($,Z){$.tree=Z}var f3=D(()=>{RN()});import vU from"fs";import TN from"path";class fU{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=TN.join($,wh),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=vU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Nh,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=TN.dirname(this.storagePath);if(await vU.promises.mkdir($,{recursive:!0}),this.storage.events.length>EN)this.storage.events=this.storage.events.slice(-EN);await vU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Rh(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,Z){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:Z}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let Z=this.viewStartTimes.get($);if(Z){let Y=Date.now()-Z;this.track({type:"view",componentId:$,metadata:{duration:Y,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,Z,Y){this.track({type:"prop_change",componentId:$,propName:Z,metadata:{value:Y}})}trackVariantSwitch($,Z){this.track({type:"variant_switch",componentId:$,variantId:Z})}trackSearch($,Z){this.track({type:"search",query:$,metadata:{resultCount:Z}})}getComponentAnalytics($,Z){let Y=this.storage.events.filter((B)=>B.componentId===$),J=Y.filter((B)=>B.type==="view"&&!B.metadata?.endView),X=Y.filter((B)=>B.type==="prop_change"),Q=Y.filter((B)=>B.type==="variant_switch"),G={};for(let B of X)if(B.propName)G[B.propName]=(G[B.propName]||0)+1;let K={};for(let B of Q)if(B.variantId)K[B.variantId]=(K[B.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((B)=>B.componentViews.includes($)).map((B)=>B.id)),U=Y.filter((B)=>B.metadata?.duration).map((B)=>B.metadata.duration),z=U.length>0?U.reduce((B,q)=>B+q,0)/U.length:0,_=Object.entries(G).sort((B,q)=>q[1]-B[1]).slice(0,5).map(([B])=>B);return{componentId:$,componentName:Z,viewCount:J.length,uniqueViews:W.size,lastViewed:J[J.length-1]?.timestamp,propChanges:G,topChangedProps:_,variantViews:K,avgTimeSpent:z}}getMostViewedComponents($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="view"&&Y.componentId&&!Y.metadata?.endView)Z.set(Y.componentId,(Z.get(Y.componentId)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({componentId:Y,viewCount:J})).sort((Y,J)=>J.viewCount-Y.viewCount).slice(0,$)}getMostChangedProps($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="prop_change"&&Y.propName)Z.set(Y.propName,(Z.get(Y.propName)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({propName:Y,changeCount:J})).sort((Y,J)=>J.changeCount-Y.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((X)=>X.type==="search"),Z=new Map,Y=0;for(let X of $){if(X.query)Z.set(X.query,(Z.get(X.query)||0)+1);if(X.metadata?.resultCount!==void 0)Y+=X.metadata.resultCount}let J=Array.from(Z.entries()).map(([X,Q])=>({query:X,count:Q})).sort((X,Q)=>Q.count-X.count).slice(0,10);return{totalSearches:$.length,topQueries:J,avgResultCount:$.length>0?Y/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Rh(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var wh=".stx/story/analytics.json",Nh=1,EN=1e4;var IN=()=>{};import gU from"fs";import DN from"path";class hU{storage;storagePath;dirty=!1;constructor($){this.storagePath=DN.join($,Mh),this.storage=this.loadStorage()}loadStorage(){try{let $=gU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Th,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=DN.dirname(this.storagePath);await gU.promises.mkdir($,{recursive:!0}),await gU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,J={}){let X={id:Eh(),name:J.name||`${$}/${Z}`,storyId:$,variantId:Z,props:Y,created:Date.now(),notes:J.notes,color:J.color};return this.storage.bookmarks.push(X),this.dirty=!0,X}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((Z)=>Z.storyId===$)}getBookmark($){return this.storage.bookmarks.find((Z)=>Z.id===$)}isBookmarked($,Z){return this.storage.bookmarks.some((Y)=>Y.storyId===$&&Y.variantId===Z)}updateBookmark($,Z){let Y=this.getBookmark($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deleteBookmark($){let Z=this.storage.bookmarks.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.bookmarks.splice(Z,1),this.dirty=!0,!0}toggleBookmark($,Z,Y){let J=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===Z);if(J)return this.deleteBookmark(J.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,Z,Y)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,Z=!0){let Y=JSON.parse($),J=0;for(let X of Y.bookmarks){if(Z){let Q=this.storage.bookmarks.find((G)=>G.id===X.id);if(Q)Object.assign(Q,X);else this.storage.bookmarks.push(X)}else this.storage.bookmarks.push(X);J++}if(J>0)this.dirty=!0;return J}}function Eh(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Mh=".stx/story/bookmarks.json",Th=1;var kN=()=>{};import dU from"fs";import g3 from"path";async function h3($){let{root:Z,config:Y}=$,J=[],X=await Ih(Z,Y.storyMatch,Y.storyIgnored);for(let Q of X){let G=g3.resolve(Z,Q),K=uU(Q,G);J.push(K)}return J}async function Ih($,Z,Y){let J=[];async function X(Q,G){let K=await dU.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=g3.join(Q,W.name),z=g3.relative(G,U);if(SN(z,Y))continue;if(W.isDirectory())await X(U,G);else if(W.isFile()){if(CN(z,Z))J.push(z)}}}return await X($,$),J}function SN($,Z){for(let Y of Z)if(bN($,Y))return!0;return!1}function CN($,Z){for(let Y of Z)if(bN($,Y))return!0;return!1}function bN($,Z){let Y=$.replace(/\\/g,"/"),X=Z.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return X=`^${X}$`,new RegExp(X).test(Y)}function uU($,Z){let Y=g3.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:Z,relativePath:$,fileName:Y,treeFile:{title:Y,path:$}}}function PN($,Z){let{root:Y,config:J}=$,X=[],Q=dU.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!CN(W,J.storyMatch))return;if(SN(W,J.storyIgnored))return;let U=g3.resolve(Y,W);try{await dU.promises.access(U);let z=uU(W,U);Z(G==="rename"?"add":"change",z)}catch{let z=uU(W,U);Z("unlink",z)}});return X.push(Q),()=>{for(let G of X)G.close()}}var mU=()=>{};function Dh($,Z){let Y=Z.treeFile||{title:Z.fileName,path:Z.relativePath};if($.tree.file==="title")return Y.title.split("/");if($.tree.file==="path")return[...Z.relativePath.split("/").slice(0,-1),Y.title];if(typeof $.tree.file==="function")return $.tree.file(Y);return[Y.title]}function d3($,Z){for(let G of Z)G.treePath=Dh($,G);let Y=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),J={treeObject:{}};Y.push(J);for(let G=0;G<Z.length;G++){let K=Z[G],W=kh(K,Y,J);Sh(K.treePath,G,W.treeObject)}let X=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Y)if(G===J)Q.push(...lU(G.treeObject,X));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:lU(G.treeObject,X)});return Q}function kh($,Z,Y){let J=$.treeFile||{title:$.fileName,path:$.relativePath};for(let X of Z)if(X.groupConfig?.include&&X.groupConfig.include(J))return X;return Y}function Sh($,Z,Y){let J=Y;for(let X=0;X<$.length;X++){let Q=$[X];if(X===$.length-1)if(J[Q]!==void 0){let K=1;while(J[`${Q}-${K}`]!==void 0)K++;J[`${Q}-${K}`]=Z}else J[Q]=Z;else{if(J[Q]===void 0)J[Q]={};else if(typeof J[Q]==="number"){let K=J[Q];J[Q]={"":K}}J=J[Q]}}}function lU($,Z){let Y=[];for(let[J,X]of Object.entries($))if(typeof X==="number")Y.push({title:J,index:X});else Y.push({title:J,children:lU(X,Z)});return Y.sort((J,X)=>Z(J.title,X.title)),Y}function yN(){return{open($){AX.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){AX.delete($)},message($,Z){}}}function cU($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of AX)try{Y.send(Z)}catch{AX.delete(Y)}}function xN($,Z){cU({type:"story-update",data:{storyId:$,...Z}})}function vN($,Z){cU({type:"story-add",data:{storyId:$,...Z}})}function fN($){cU({type:"story-remove",data:{storyId:$}})}function gN($){return`
|
|
21062
21079
|
<script>
|
|
21063
21080
|
(function() {
|
|
21064
21081
|
const ws = new WebSocket('${$}');
|
|
@@ -21615,7 +21632,7 @@ window.__stxPerformance = {
|
|
|
21615
21632
|
|
|
21616
21633
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
21617
21634
|
</script>
|
|
21618
|
-
`}var o60;var
|
|
21635
|
+
`}var o60;var aN=D(()=>{o60=new iN});import pU from"fs";import sN from"path";class nU{storage;storagePath;dirty=!1;constructor($){this.storagePath=sN.join($,bh),this.storage=this.loadStorage()}loadStorage(){try{let $=pU.readFileSync(this.storagePath,"utf-8"),Z=JSON.parse($);if(Z.version!==iU)return this.migrateStorage(Z);return Z}catch{return{version:iU,presets:[],recentIds:[]}}}migrateStorage($){return{version:iU,presets:$.presets||[],recentIds:$.recentIds||[]}}async save(){if(!this.dirty)return;let $=sN.dirname(this.storagePath);await pU.promises.mkdir($,{recursive:!0}),await pU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset($,Z,Y={}){let J={id:yh(),name:$,description:Y.description,props:Z,componentId:Y.componentId,created:Date.now(),usageCount:0,tags:Y.tags};return this.storage.presets.push(J),this.dirty=!0,J}getPreset($){return this.storage.presets.find((Z)=>Z.id===$)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent($){return this.storage.presets.filter((Z)=>!Z.componentId||Z.componentId===$)}getRecentPresets(){return this.storage.recentIds.map(($)=>this.getPreset($)).filter(($)=>$!==void 0)}usePreset($){let Z=this.getPreset($);if(!Z)return;return Z.lastUsed=Date.now(),Z.usageCount++,this.storage.recentIds=[$,...this.storage.recentIds.filter((Y)=>Y!==$)].slice(0,Ph),this.dirty=!0,Z}updatePreset($,Z){let Y=this.getPreset($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deletePreset($){let Z=this.storage.presets.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.presets.splice(Z,1),this.storage.recentIds=this.storage.recentIds.filter((Y)=>Y!==$),this.dirty=!0,!0}searchPresets($){let Z=$.toLowerCase();return this.storage.presets.filter((Y)=>{if(Y.name.toLowerCase().includes(Z))return!0;if(Y.description?.toLowerCase().includes(Z))return!0;if(Y.tags?.some((J)=>J.toLowerCase().includes(Z)))return!0;return!1})}getMostUsedPresets($=5){return[...this.storage.presets].sort((Z,Y)=>Y.usageCount-Z.usageCount).slice(0,$)}exportPresets($){let Z=$?this.storage.presets.filter((Y)=>$.includes(Y.id)):this.storage.presets;return JSON.stringify({presets:Z},null,2)}importPresets($,Z=!1){let Y=JSON.parse($),J=0;for(let X of Y.presets){let Q=this.storage.presets.find((G)=>G.id===X.id);if(Q&&!Z)continue;if(Q)Object.assign(Q,X);else this.storage.presets.push(X);J++}if(J>0)this.dirty=!0;return J}}function yh(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var bh=".stx/story/presets.json",iU=1,Ph=10;var oN=()=>{};import rU from"fs";async function wX($,Z,Y={}){let J=performance.now(),X=[];try{let Q=await rU.promises.stat(Z),G=tN.get(Z),K;if(G&&G.mtime===Q.mtimeMs)K=G.content;else K=await rU.promises.readFile(Z,"utf-8"),tN.set(Z,{content:K,mtime:Q.mtimeMs,analyzed:null});let{processDirectives:W}=await Promise.resolve().then(() => (_1(),PY)),U={},z=u3(K);if(z)try{await D0(z,U,Z)}catch(H){X.push(`Warning: Could not extract script variables: ${H instanceof Error?H.message:String(H)}`)}if(Y.props)Object.assign(U,Y.props);let B=await W(K,U,Z,{},new Set),q=$R(K),j=u3(K);return B=ZR(B),B=YR(B,U),{html:B,css:q,js:j,errors:X,duration:performance.now()-J}}catch(Q){return X.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${JR(X[0])}</div>`,css:"",js:"",errors:X,duration:performance.now()-J}}}async function xh($){try{let Z=await rU.promises.readFile($,"utf-8"),Y=u3(Z);if(!Y)return null;let J={};if(await D0(Y,J,$),Array.isArray(J.variants))return J.variants;return null}catch{return null}}async function eN($,Z,Y,J){let X=Z.story?.variants;if(!X){let K=await xh(Z.path);if(K)X=K}if(!X&&Y==="default")return wX($,Z.path,{props:J||{}});if(!X)return wX($,Z.path,{props:J||{}});let Q=X.find((K)=>K.id===Y);if(!Q&&Y==="default")return wX($,Z.path,{props:J||{}});if(!Q)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Y}' not found`],duration:0};let G={...Q.state,...J};if(Q.source)return vh($,Q.source,G);return wX($,Z.path,{props:G})}async function vh($,Z,Y={}){let J=performance.now(),X=[];try{let{processDirectives:Q}=await Promise.resolve().then(() => (_1(),PY)),G={...Y},K=u3(Z);if(K)try{await D0(K,G,"inline-template.stx")}catch{}let U=await Q(Z,G,"inline-template.stx",{},new Set);return U=ZR(U),U=YR(U,G),{html:U,css:$R(Z),js:u3(Z),errors:X,duration:performance.now()-J}}catch(Q){return X.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${JR(X[0])}</div>`,css:"",js:"",errors:X,duration:performance.now()-J}}}function $R($){let Z=[],Y=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,J=Y.exec($);while(J!==null)Z.push(J[1].trim()),J=Y.exec($);return Z.join(`
|
|
21619
21636
|
`)}function ZR($){return $.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function u3($){let Z=[],Y=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,J=Y.exec($);while(J!==null)Z.push(J[1].trim()),J=Y.exec($);return Z.join(`
|
|
21620
21637
|
`)}function YR($,Z){let Y=`<script>window.__stxProps = ${JSON.stringify(Z)};</script>`;return $+Y}function JR($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var tN;var XR=D(()=>{N0();tN=new Map});async function QR($,Z){let Y=await h3($);$7($,Y);let J=d3($.config,Y);Z7($,J),console.log(` Found ${Y.length} story files`);let X=typeof Z.host==="string"?Z.host:Z.host===!0?"0.0.0.0":"localhost",Q=new nU($.root),G=new hU($.root),K=new fU($.root),W=yN(),U=Bun.serve({port:Z.port,hostname:X,fetch:async(B,q)=>{let H=new URL(B.url).pathname;if(H==="/__hmr"){if(q.upgrade(B,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(H.startsWith("/api/"))return fh($,H,B,{presetsManager:Q,bookmarksManager:G,analyticsTracker:K});return gh($,H,Z.port)},websocket:{open(B){W.open(B)},close(B){W.close(B)},message(B,q){W.message(B,q)}}}),z=`http://${X}:${Z.port}`,_=PN($,async(B,q)=>{console.log(` [${B}] ${q.relativePath}`);let j=await h3($);$7($,j);let H=d3($.config,j);if(Z7($,H),B==="add")vN(q.id,{fileName:q.fileName});else if(B==="unlink")fN(q.id);else xN(q.id,{fileName:q.fileName})});if(Z.open){let B=z;try{let{exec:q}=await import("child_process"),j=process.platform;q(`${j==="darwin"?"open":j==="win32"?"start":"xdg-open"} ${B}`)}catch{}}return{server:U,url:z,close:async()=>{_(),U.stop()}}}async function fh($,Z,Y,J){let{presetsManager:X,bookmarksManager:Q,analyticsTracker:G}=J;if(Z==="/api/stories")return Response.json({files:$.storyFiles.map((K)=>({id:K.id,fileName:K.fileName,relativePath:K.relativePath,treePath:K.treePath})),tree:$.tree});if(Z.startsWith("/api/story/")){let K=Z.slice(11),W=$.storyFiles.find((U)=>U.id===K);if(!W)return new Response("Story not found",{status:404});try{let U=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:U})}catch{return new Response("Error reading story",{status:500})}}if(Z==="/api/config")return Response.json({theme:$.config.theme,responsivePresets:$.config.responsivePresets,backgroundPresets:$.config.backgroundPresets});if(Z.startsWith("/api/render/")){let K=new URL(Y.url),W=Z.slice(12).split("/"),U=W[0],z=W[1]||"default",_,B=K.searchParams.get("props");if(B)try{_=JSON.parse(B)}catch{}let q=$.storyFiles.find((j)=>j.id===U);if(!q)return new Response("Story not found",{status:404});try{let j=await eN($,q,z,_);return Response.json({html:j.html,css:j.css,js:j.js,errors:j.errors,duration:j.duration})}catch(j){return Response.json({html:"",css:"",js:"",errors:[j instanceof Error?j.message:String(j)],duration:0},{status:500})}}if(Z==="/api/presets"&&Y.method==="GET")return Response.json({presets:X.getAllPresets()});if(Z==="/api/presets"&&Y.method==="POST")try{let K=await Y.json(),W=X.createPreset(K.name,K.props,{componentId:K.componentId,description:K.description});return await X.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/presets/")&&!Z.includes("/use")&&Y.method==="GET"){let K=Z.slice(13),W=X.getPreset(K);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(Z.endsWith("/use")&&Y.method==="POST"){let K=Z.slice(13,-4),W=X.usePreset(K);if(!W)return new Response("Preset not found",{status:404});return await X.save(),Response.json(W)}if(Z.startsWith("/api/presets/")&&Y.method==="DELETE"){let K=Z.slice(13);if(!X.deletePreset(K))return new Response("Preset not found",{status:404});return await X.save(),Response.json({success:!0})}if(Z==="/api/bookmarks"&&Y.method==="GET")return Response.json({bookmarks:Q.getAllBookmarks()});if(Z==="/api/bookmarks"&&Y.method==="POST")try{let K=await Y.json(),W=Q.addBookmark(K.storyId,K.variantId,K.props,{name:K.name,notes:K.notes,color:K.color});return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/bookmarks/toggle"&&Y.method==="POST")try{let K=await Y.json(),W=Q.toggleBookmark(K.storyId,K.variantId,K.props);return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/bookmarks/")&&Z!=="/api/bookmarks/toggle"&&Y.method==="GET"){let K=Z.slice(15),W=Q.getBookmark(K);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(Z.startsWith("/api/bookmarks/")&&Y.method==="DELETE"){let K=Z.slice(15);if(!Q.deleteBookmark(K))return new Response("Bookmark not found",{status:404});return await Q.save(),Response.json({success:!0})}if(Z==="/api/analytics/track"&&Y.method==="POST")try{let K=await Y.json();if(K.type==="view"&&K.componentId)G.trackView(K.componentId,K.variantId);else if(K.type==="prop_change"&&K.componentId&&K.propName)G.trackPropChange(K.componentId,K.propName,null);else if(K.type==="variant_switch"&&K.componentId&&K.variantId)G.trackVariantSwitch(K.componentId,K.variantId);else if(K.type==="search"&&K.query)G.trackSearch(K.query,0);return await G.save(),Response.json({success:!0})}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/analytics/summary"&&Y.method==="GET")return Response.json({mostViewed:G.getMostViewedComponents(10),mostChangedProps:G.getMostChangedProps(10),searchAnalytics:G.getSearchAnalytics()});if(Z.startsWith("/api/analytics/component/")&&Y.method==="GET"){let K=Z.slice(25),W=$.storyFiles.find((z)=>z.id===K),U=G.getComponentAnalytics(K,W?.fileName||K);return Response.json(U)}return new Response("Not found",{status:404})}function gh($,Z,Y){let J=hh($,Y);return new Response(J,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function hh($,Z){let{theme:Y}=$.config,J=Y.title||"STX Story",X=`ws://localhost:${Z}/__hmr`,Q=gN(X);return`<!DOCTYPE html>
|
|
21621
21638
|
<html lang="en" class="${Y.darkClass||"dark"}">
|
|
@@ -22335,7 +22352,7 @@ else {
|
|
|
22335
22352
|
<style>${lN()}</style>
|
|
22336
22353
|
${mN()}
|
|
22337
22354
|
</body>
|
|
22338
|
-
</html>`}var GR=D(()=>{IN();kN();mU();f3();hN();pN();
|
|
22355
|
+
</html>`}var GR=D(()=>{IN();kN();mU();f3();hN();pN();aN();oN();XR()});import dh from"fs";import uh from"path";async function KR($){let Z=$.config.setupFile;if(!Z)return;let Y=uh.resolve($.root,Z);try{await dh.promises.access(Y)}catch{return}let J={storyContext:$,registerComponent:(X,Q)=>{mh.set(X,Q)},addCSS:(X)=>{lh.push(X)},addScript:(X)=>{ch.push(X)},setState:(X,Q)=>{ph.set(X,Q)}};try{let X=await import(Y);if(typeof X.default==="function")await X.default(J);else if(typeof X.setupStory==="function")await X.setupStory(J)}catch(X){console.warn(`Warning: Failed to load setup file: ${X}`)}}var mh,lh,ch,ph;var WR=D(()=>{mh=new Map,lh=[],ch=[],ph=new Map});var zR={};$0(zR,{devCommand:()=>UR,dev:()=>ih});async function UR($={}){x3();let Z=await e5({mode:"dev"});if(!Z.config.enabled){t5("Story feature is disabled in config.");return}await KR(Z);let Y=$.port??Z.config.port,J,X=async()=>{J=await QR(Z,{port:Y,open:$.open,host:$.host}),v3(Z.storyFiles.length),PU(J.url),yU()};await X();let Q=LN(Z,{onChange:async()=>{await J.close();let K=await e5({mode:"dev"});Object.assign(Z,K),await X()}}),G=async()=>{console.log(`
|
|
22339
22356
|
`),Q.stop(),await J.close(),process.exit(0)};if(process.on("SIGINT",G),process.on("SIGTERM",G),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(K)=>{switch(K.toString()){case"h":yU();break;case"o":try{let{exec:U}=await import("child_process"),z=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";U(`${z} ${J.url}`)}catch{qN("Failed to open browser")}break;case"r":await J.close(),await X();break;case"c":console.clear(),x3(),v3(Z.storyFiles.length),PU(J.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var ih;var _R=D(()=>{VN();f3();FX();GR();WR();ih=UR});function BR($){m3=[];for(let Z of $.storyFiles)if(m3.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),m3.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)m3.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function qR(){return JSON.stringify(m3)}var m3;var jR=D(()=>{m3=[]});var OR={};$0(OR,{buildCommand:()=>HR,build:()=>rh});import C6 from"fs";import L$ from"path";async function HR($={}){let Z=Date.now();x3();let Y=await e5({mode:"build"});if(!Y.config.enabled){t5("Story feature is disabled in config.");return}let J=await h3(Y);$7(Y,J);let X=d3(Y.config,J);Z7(Y,X),v3(J.length);let Q=$.outDir??Y.config.outDir,G=L$.resolve(Y.root,Q);await C6.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=nh(Y);await C6.promises.writeFile(L$.join(G,"index.html"),K);let W={files:J.map((q)=>({id:q.id,fileName:q.fileName,relativePath:q.relativePath,treePath:q.treePath})),tree:X};await C6.promises.writeFile(L$.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await C6.promises.writeFile(L$.join(G,"config.json"),JSON.stringify(U,null,2));let z=L$.join(G,"stories");await C6.promises.mkdir(z,{recursive:!0});for(let q of J){let j=await C6.promises.readFile(q.path,"utf-8");await C6.promises.writeFile(L$.join(z,`${q.id}.stx`),j)}BR(Y);let _=qR();await C6.promises.writeFile(L$.join(G,"search-index.json"),_);let B=Date.now()-Z;HN(J.length,Q,B)}function nh($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
|
|
22340
22357
|
<html lang="en">
|
|
22341
22358
|
<head>
|
|
@@ -22450,13 +22467,13 @@ else {
|
|
|
22450
22467
|
}
|
|
22451
22468
|
</script>
|
|
22452
22469
|
</body>
|
|
22453
|
-
</html>`}var rh;var LR=D(()=>{mU();f3();FX();jR();rh=HR});var FR={};$0(FR,{updateSnapshots:()=>oh,runVisualTests:()=>VR,runA11yTests:()=>Yd,formatTestResults:()=>Zd});import NX from"fs";import
|
|
22454
|
-
`)}async function Yd($,Z={}){let Y=performance.now(),J=[],X=0,Q=0;for(let K of $.storyFiles)try{let W=await Bun.file(K.path).text(),U=await i3(W,K.path);if(U.length>0){for(let z of U)J.push({storyId:K.id,variantId:"default",component:K.component,message:`A11y: ${z.message}`,expected:"No accessibility violations",actual:`${z.type}: ${z.message} (impact: ${z.impact})`});Q++}else X++}catch(W){J.push({storyId:K.id,variantId:"default",component:K.component,message:`Failed to check a11y: ${W instanceof Error?W.message:String(W)}`,expected:"File readable for a11y check",actual:"File read error"}),Q++}let G=performance.now()-Y;return{total:$.storyFiles.length,passed:X,failed:Q,new:0,failures:J,duration:G}}var AR=D(()=>{V$();G4()});var CR={};$0(CR,{default:()=>Td,createHotReloadServer:()=>SR,compileToNative:()=>NR,NATIVE_COMPONENTS:()=>tU});async function NR($,Z={}){let Y=performance.now(),J={target:Z.target||"universal",format:Z.format||"zig",optimize:Z.optimize??!0,treeShake:Z.treeShake??!0,hotReload:Z.hotReload??!1,debug:Z.debug??!1,sourceMaps:Z.sourceMaps??!1,bundle:Z.bundle??!0,minify:Z.minify??!1,components:Z.components||tU},X=typeof $==="string"?Jd($):$,Q=Qd(X.tree,J),G=Bd(Q),K=J.treeShake?jd(Q,G):Q,W=new Map;if(J.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=
|
|
22470
|
+
</html>`}var rh;var LR=D(()=>{mU();f3();FX();jR();rh=HR});var FR={};$0(FR,{updateSnapshots:()=>oh,runVisualTests:()=>VR,runA11yTests:()=>Yd,formatTestResults:()=>Zd});import NX from"fs";import ah from"path";async function VR($,Z={}){let Y=Date.now(),J={total:0,passed:0,failed:0,new:0,failures:[],duration:0},X=Z.snapshotDir||c0($.root,"story","snapshots");await NX.promises.mkdir(X,{recursive:!0});let Q=$.storyFiles;if(Z.filter&&Z.filter.length>0)Q=Q.filter((G)=>Z.filter.some((K)=>G.fileName.toLowerCase().includes(K.toLowerCase())));for(let G of Q)await sh(G,X,Z,J);return J.duration=Date.now()-Y,J}async function sh($,Z,Y,J){let X=$.story;if(!X)return;for(let Q of X.variants){J.total++;let G=ah.join(Z,`${$.id}-${Q.id}.snap`),K=th(Q.source||""),W=await $d(G);if(Y.update||!W){let U={storyId:$.id,variantId:Q.id,component:$.fileName,timestamp:Date.now(),hash:K};if(await NX.promises.writeFile(G,JSON.stringify(U,null,2)),!W)J.new++;J.passed++}else try{let U=await NX.promises.readFile(G,"utf-8"),z=JSON.parse(U);if(z.hash===K)J.passed++;else J.failed++,J.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:"Snapshot mismatch",difference:eh(z.hash,K)})}catch(U){J.failed++,J.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:`Error reading snapshot: ${U}`})}}}async function oh($,Z={}){return(await VR($,{...Z,update:!0})).total}function th($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Z.toString(16)}function eh($,Z){if($===Z)return 0;let Y=Math.abs(Number.parseInt($,16)-Number.parseInt(Z,16));return Math.min(Y/1e6,1)}async function $d($){try{return await NX.promises.access($),!0}catch{return!1}}function Zd($){let Z=[];if(Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(" STX Story Visual Regression Tests"),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),$.failures.length>0){Z.push(" \u274C Failures:"),Z.push("");for(let Y of $.failures){if(Z.push(` \u2022 ${Y.component} / ${Y.variantId}`),Z.push(` ${Y.message}`),Y.difference!==void 0)Z.push(` Difference: ${(Y.difference*100).toFixed(2)}%`);Z.push("")}}if(Z.push(" Summary:"),Z.push(` Total: ${$.total}`),Z.push(` Passed: ${$.passed} \u2713`),Z.push(` Failed: ${$.failed} \u2717`),$.new>0)Z.push(` New: ${$.new} \u26A1`);return Z.push(` Time: ${$.duration}ms`),Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),Z.join(`
|
|
22471
|
+
`)}async function Yd($,Z={}){let Y=performance.now(),J=[],X=0,Q=0;for(let K of $.storyFiles)try{let W=await Bun.file(K.path).text(),U=await i3(W,K.path);if(U.length>0){for(let z of U)J.push({storyId:K.id,variantId:"default",component:K.component,message:`A11y: ${z.message}`,expected:"No accessibility violations",actual:`${z.type}: ${z.message} (impact: ${z.impact})`});Q++}else X++}catch(W){J.push({storyId:K.id,variantId:"default",component:K.component,message:`Failed to check a11y: ${W instanceof Error?W.message:String(W)}`,expected:"File readable for a11y check",actual:"File read error"}),Q++}let G=performance.now()-Y;return{total:$.storyFiles.length,passed:X,failed:Q,new:0,failures:J,duration:G}}var AR=D(()=>{V$();G4()});var CR={};$0(CR,{default:()=>Td,createHotReloadServer:()=>SR,compileToNative:()=>NR,NATIVE_COMPONENTS:()=>tU});async function NR($,Z={}){let Y=performance.now(),J={target:Z.target||"universal",format:Z.format||"zig",optimize:Z.optimize??!0,treeShake:Z.treeShake??!0,hotReload:Z.hotReload??!1,debug:Z.debug??!1,sourceMaps:Z.sourceMaps??!1,bundle:Z.bundle??!0,minify:Z.minify??!1,components:Z.components||tU},X=typeof $==="string"?Jd($):$,Q=Qd(X.tree,J),G=Bd(Q),K=J.treeShake?jd(Q,G):Q,W=new Map;if(J.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=aU(K,{...J,target:j});W.set(j,H)}}else{let q=aU(K,J);W.set(J.target,q)}let U=Ld(K,J,W),z=Vd(X,K,J),_={compilationTime:performance.now()-Y,totalComponents:sU(X.tree),nativeComponents:oU(K),webComponents:sU(X.tree)-oU(K),bundleSize:U.length,treeShakenSize:J.treeShake?Hd(Q,K):U.length,warnings:[],errors:[]},B;if(J.sourceMaps)B=Fd(X,K);return{code:U,platformCode:W,dependencies:G,manifest:z,sourceMaps:B,stats:_}}function Jd($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),J=Y?Y[1]:$;return RR(J,Z),{id:DR(),hash:kR($),tree:Z,scripts:Nd($),styles:Rd($),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:$.includes("{{"),hasEventHandlers:$.includes("onclick")||$.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:$.length}}}function RR($,Z){let Y=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,J;while((J=Y.exec($))!==null){let[,X,Q,G]=J,K=X.startsWith("@craft-"),W={type:K?"component":"element",tag:K?X.slice(1):X,props:Xd(Q),children:[],componentName:K?X.slice(1):void 0};if(G){let U=G.replace(/<[^>]+>/g,"").trim();if(U)W.children=W.children??[],W.children.push({type:"text",text:U});RR(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function Xd($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,J;while((J=Y.exec($))!==null){let[,X,Q]=J;Z[X]=Q??!0}return Z}function Qd($,Z){return MR($,Z)}function MR($,Z){let Y=$.componentName?Z.components?.get($.componentName):void 0,J="craft.View";if(Y)J=Y.zigType;else if($.type==="text")J="craft.Text";else if($.tag)J=Gd($.tag);let X={};if($.props)for(let[W,U]of Object.entries($.props))X[W]=Kd(U);let Q=[];if($.children)for(let W of $.children)Q.push(MR(W,Z));let G=new Map;if($.props){for(let[W,U]of Object.entries($.props))if(W.startsWith("on")&&typeof U==="string")G.set(W.slice(2).toLowerCase(),U)}let K=Ud($);return{type:Wd($,Y),zigType:J,props:X,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function Gd($){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[$.toLowerCase()]||"craft.View"}function Kd($){if(typeof $==="string"){if($.startsWith("{{")&&$.endsWith("}}"))return{type:"binding",path:$.slice(2,-2).trim()};if($.includes("(")&&$.includes(")"))return{type:"callback",handler:$};return{type:"literal",value:$}}if(typeof $==="number"||typeof $==="boolean")return{type:"literal",value:$};return{type:"literal",value:String($)}}function Wd($,Z){if(Z){let J=Z.name.toLowerCase();if(J.includes("button"))return"button";if(J.includes("input")||J.includes("text"))return"input";if(J.includes("image")||J.includes("avatar"))return"image";if(J.includes("list")||J.includes("table"))return"list";if(J.includes("scroll"))return"scroll";return"custom"}if($.type==="text")return"text";let Y=$.tag?.toLowerCase();if(Y==="button")return"button";if(Y==="input"||Y==="textarea")return"input";if(Y==="img")return"image";if(Y==="ul"||Y==="ol")return"list";return"view"}function Ud($){let Z=$.props?.style,Y={},J={};if(Z){let X=Z.split(";").filter(Boolean);for(let Q of X){let[G,K]=Q.split(":").map((W)=>W.trim());if(!G||!K)continue;switch(G){case"display":Y.display=K;break;case"flex-direction":Y.flexDirection=K;break;case"justify-content":Y.justifyContent=zd(K);break;case"align-items":Y.alignItems=_d(K);break;case"gap":Y.gap=Number.parseInt(K,10);break;case"padding":Y.padding=Number.parseInt(K,10);break;case"margin":Y.margin=Number.parseInt(K,10);break;case"width":Y.width=K==="auto"?"auto":Number.parseInt(K,10);break;case"height":Y.height=K==="auto"?"auto":Number.parseInt(K,10);break;case"background-color":case"background":J.backgroundColor=K;break;case"border-color":J.borderColor=K;break;case"border-width":J.borderWidth=Number.parseInt(K,10);break;case"border-radius":J.borderRadius=Number.parseInt(K,10);break;case"opacity":J.opacity=Number.parseFloat(K);break}}}return{layout:Y,appearance:J}}function zd($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function _d($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function Bd($){let Z=[],Y=new Set;function J(X,Q){let G=X.id||DR();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:X.zigType,dependencies:Q?[Q]:[],size:TR(X),isStatic:qd(X)};Z.push(K);for(let W of X.children)J(W,G)}return J($),Z}function TR($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function qd($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function jd($,Z){return $}function Hd($,Z){let Y=0;function J(X){Y+=TR(X);for(let Q of X.children)J(Q)}return J(Z),Y}function aU($,Z){switch(Z.format){case"zig":return wR($,Z);case"typescript":return Od($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return wR($,Z)}}function wR($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('const std = @import("std");'),Y.push('const craft = @import("craft");'),Y.push(""),Y.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),Y.push(" return try build(allocator);"),Y.push("}"),Y.push(""),ER($,Y,0),Y.join(`
|
|
22455
22472
|
`)}function ER($,Z,Y){let J=" ".repeat(Y);if(Y===0)Z.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let X=`node_${Y}`;Z.push(`${J} var ${X} = try ${$.zigType}.init(allocator);`);for(let[Q,G]of Object.entries($.props))if(G.type==="literal"){let K=typeof G.value==="string"?`"${G.value}"`:String(G.value);Z.push(`${J} ${X}.set${wd(Q)}(${K});`)}for(let Q=0;Q<$.children.length;Q++){let G=$.children[Q];if(G.type==="text"){let K=G.props.text?.type==="literal"?String(G.props.text.value):"";Z.push(`${J} try ${X}.addChild(try craft.Text.init(allocator, "${K}"));`)}else ER(G,Z,Y+1),Z.push(`${J} try ${X}.addChild(node_${Y+1});`)}if(Y===0)Z.push(` return ${X}.element();`),Z.push("}")}function Od($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('import { Craft } from "@stacksjs/craft";'),Y.push(""),Y.push("export function render(): Craft.Element {"),Y.push(" return "+IR($,1)+";"),Y.push("}"),Y.join(`
|
|
22456
22473
|
`)}function IR($,Z){let Y=" ".repeat(Z),J=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);J.push(`${K}: ${U}`)}let X=J.length>0?`{ ${J.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:IR(K,Z+1)),G=Q.length>0?`,
|
|
22457
22474
|
${Y} [${Q.join(`,
|
|
22458
22475
|
${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${X}${G})`}function Ld($,Z,Y){if(Z.target==="universal"){let J=[];J.push("// Universal entry point"),J.push("");for(let[X,Q]of Y)J.push(`// --- ${X.toUpperCase()} ---`),J.push(`#if ${X.toUpperCase()}`),J.push(Q),J.push("#endif"),J.push("");return J.join(`
|
|
22459
|
-
`)}return Y.get(Z.target)||sU($,Z)}function Vd($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:kR(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)X(G)}return X(Z),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function Fd($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function DR(){return`id_${++Ad}`}function kR($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Math.abs(Z).toString(36)}function wd($){return $.charAt(0).toUpperCase()+$.slice(1)}function Nd($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function Rd($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function aU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=aU(Y);return Z}function oU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=oU(Y);return Z}function SR($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var tU,Ad=0,Md,Td;var bR=D(()=>{tU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Md={compileToNative:NR,createHotReloadServer:SR,NATIVE_COMPONENTS:tU},Td=Md});import{spawn as xR}from"child_process";import f0 from"fs";import Ed from"os";import Y0 from"path";import f from"process";import{CLI as Id}from"@stacksjs/clapp";var b6="0.2.139";V$();EU();bK();uK();t4();gK();DK();OU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",F0=new Id("stx");function PR($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function yR($){try{if(!f0.existsSync($)){let Y=Y0.dirname($),J=Y0.basename($);if(f0.existsSync(Y)){let Q=f0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(f0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function eU($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var J7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),Dd=($)=>$.endsWith(".stx")||$.endsWith(".md");function Y7($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}function kd($){if(!$)return;let Z;try{Z=JSON.parse($)}catch(Y){console.error(`\u274C --info-plist is not valid JSON: ${Y.message}`),f.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),f.exit(1);for(let[Y,J]of Object.entries(Z))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Y}" must be a string, number or boolean`),f.exit(1);return Z}async function Sd($,Z){try{let Y=["test"],J=[];if($&&$.length>0)for(let W of $)if(J7(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(J.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...J),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(Ed.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let X={...f.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=xR(Q,Y,{stdio:"inherit",shell:!1,env:X});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),f.on("SIGINT",()=>{console.log(`
|
|
22476
|
+
`)}return Y.get(Z.target)||aU($,Z)}function Vd($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:kR(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)X(G)}return X(Z),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function Fd($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function DR(){return`id_${++Ad}`}function kR($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Math.abs(Z).toString(36)}function wd($){return $.charAt(0).toUpperCase()+$.slice(1)}function Nd($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function Rd($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function sU($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=sU(Y);return Z}function oU($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=oU(Y);return Z}function SR($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var tU,Ad=0,Md,Td;var bR=D(()=>{tU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Md={compileToNative:NR,createHotReloadServer:SR,NATIVE_COMPONENTS:tU},Td=Md});import{spawn as xR}from"child_process";import f0 from"fs";import Ed from"os";import Y0 from"path";import f from"process";import{CLI as Id}from"@stacksjs/clapp";var b6="0.2.140";V$();EU();bK();uK();t4();gK();DK();OU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",F0=new Id("stx");function PR($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function yR($){try{if(!f0.existsSync($)){let Y=Y0.dirname($),J=Y0.basename($);if(f0.existsSync(Y)){let Q=f0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(f0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function eU($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var J7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),Dd=($)=>$.endsWith(".stx")||$.endsWith(".md");function Y7($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}function kd($){if(!$)return;let Z;try{Z=JSON.parse($)}catch(Y){console.error(`\u274C --info-plist is not valid JSON: ${Y.message}`),f.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),f.exit(1);for(let[Y,J]of Object.entries(Z))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Y}" must be a string, number or boolean`),f.exit(1);return Z}async function Sd($,Z){try{let Y=["test"],J=[];if($&&$.length>0)for(let W of $)if(J7(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(J.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...J),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(Ed.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let X={...f.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=xR(Q,Y,{stdio:"inherit",shell:!1,env:X});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),f.on("SIGINT",()=>{console.log(`
|
|
22460
22477
|
Test run interrupted`),K.kill("SIGINT"),f.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var Cd=f.argv.length>=3&&(Dd(f.argv[2])&&f0.existsSync(f.argv[2])||J7(f.argv[2]));if(Cd){let $=f.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<f.argv.length;Y++){let J=f.argv[Y];if(J==="--port"&&Y+1<f.argv.length){let X=PR(f.argv[++Y]);if(!X.isValid)Y7(X);Z.port=Number.parseInt(f.argv[Y],10)}else if(J==="--no-watch")Z.watch=!1;else if(J==="--highlight-theme"&&Y+1<f.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=f.argv[++Y]}else if(J==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(J==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(J==="--no-cache")Z.cache=!1;else if(J==="--native")Z.native=!0}if(J7($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),J=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),X=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(X);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(Y0.basename(z)));for(let z of U)if(!J.includes(z))J.push(z)}catch{}if(J.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),f.exit(1);if(!await T3(J,Z))f.exit(1)}catch(Y){console.error("Failed to process files:",Y),f.exit(1)}else M3($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),f.exit(1)})}else{let $=function(J,X){let Q=[];for(let G=0;G<=X.length;G++)Q[G]=[G];for(let G=0;G<=J.length;G++)Q[0][G]=G;for(let G=1;G<=X.length;G++)for(let K=1;K<=J.length;K++)if(X.charAt(G-1)===J.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[X.length][J.length]};F0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(J)=>{try{if(await CK(J))console.log("Documentation generated successfully."),f.exit(0);else console.error("Documentation generation failed."),f.exit(1)}catch(X){console.error("Error generating documentation:",X),f.exit(1)}}),F0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(J,X)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(J==="list"){console.log(`
|
|
22461
22478
|
\uD83D\uDCDA Fetching available icon collections...
|
|
22462
22479
|
`);let K=await Q(),W=Object.entries(K).sort((U,z)=>z[1].total-U[1].total);console.log(`Available collections:
|